Search is not available for this dataset
text
string | meta
dict |
---|---|
module IndexOnBuiltin where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
{-# BUILTIN NATURAL Nat #-}
{-# BUILTIN ZERO zero #-}
{-# BUILTIN SUC suc #-}
data Fin : Nat -> Set where
fz : {n : Nat} -> Fin (suc n)
fs : {n : Nat} -> Fin n -> Fin (suc n)
f : Fin 2 -> Fin 1
f fz = fz
f (fs i) = i
| {
"alphanum_fraction": 0.5384615385,
"avg_line_length": 16.4210526316,
"ext": "agda",
"hexsha": "d030e1dbec3b9dda2e98e0782c16d5980adc2d8f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/succeed/IndexOnBuiltin.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "test/succeed/IndexOnBuiltin.agda",
"max_line_length": 40,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/IndexOnBuiltin.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 111,
"size": 312
} |
{-# OPTIONS --allow-unsolved-metas #-}
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module AgdaIntroduction where
-- We add 3 to the fixities of the Agda standard library 0.8.1 (see
-- Data/Nat.agda).
infixl 10 _*_
infixl 9 _+_
infixr 5 _∷_ _++_
infix 4 _≡_
-- Dependent function types
id : (A : Set) → A → A
id A x = x
-- λ-notation
id₂ : (A : Set) → A → A
id₂ = λ A → λ x → x
id₃ : (A : Set) → A → A
id₃ = λ A x → x
-- Implicit arguments
id₄ : {A : Set} → A → A
id₄ x = x
id₅ : {A : Set} → A → A
id₅ = λ x → x
-- Inductively defined sets and families
data Bool : Set where
false true : Bool
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
data List (A : Set) : Set where
[] : List A
_∷_ : A → List A → List A
data Vec (A : Set) : ℕ → Set where
[] : Vec A zero
_∷_ : {n : ℕ} → A → Vec A n → Vec A (succ n)
data Fin : ℕ → Set where
fzero : {n : ℕ} → Fin (succ n)
fsucc : {n : ℕ} → Fin n → Fin (succ n)
-- Structurally recursive functions and pattern matching
_+_ : ℕ → ℕ → ℕ
zero + n = n
succ m + n = succ (m + n)
map : {A B : Set} → (A → B) → List A → List B
map f [] = []
map f (x ∷ xs) = f x ∷ map f xs
f : ℕ → ℕ
f zero = zero
{-# CATCHALL #-}
f _ = succ zero
-- The absurd pattern
magic : {A : Set} → Fin zero → A
magic ()
-- The with constructor
filter : {A : Set} → (A → Bool) → List A → List A
filter p [] = []
filter p (x ∷ xs) with p x
... | true = x ∷ filter p xs
... | false = filter p xs
filter' : {A : Set} → (A → Bool) → List A → List A
filter' p [] = []
filter' p (x ∷ xs) with p x
filter' p (x ∷ xs) | true = x ∷ filter' p xs
filter' p (x ∷ xs) | false = filter' p xs
-- Mutual definitions
even : ℕ → Bool
odd : ℕ → Bool
even zero = true
even (succ n) = odd n
odd zero = false
odd (succ n) = even n
data EvenList : Set
data OddList : Set
data EvenList where
[] : EvenList
_∷_ : ℕ → OddList → EvenList
data OddList where
_∷_ : ℕ → EvenList → OddList
-- Normalisation
data _≡_ {A : Set} : A → A → Set where
refl : {a : A} → a ≡ a
length : {A : Set} → List A → ℕ
length [] = zero
length (x ∷ xs) = succ zero + length xs
_++_ : {A : Set} → List A → List A → List A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ xs ++ ys
succCong : {m n : ℕ} → m ≡ n → succ m ≡ succ n
succCong refl = refl
length-++ : {A : Set}(xs ys : List A) →
length (xs ++ ys) ≡ length xs + length ys
length-++ [] ys = refl
length-++ (x ∷ xs) ys = succCong (length-++ xs ys)
-- Coverage and termination checkers
head : {A : Set} → List A → A
head [] = ?
head (x ∷ xs) = x
ack : ℕ → ℕ → ℕ
ack zero n = succ n
ack (succ m) zero = ack m (succ zero)
ack (succ m) (succ n) = ack m (ack (succ m) n)
-- Combinators for equational reasoning
postulate
sym : {A : Set}{a b : A} → a ≡ b → b ≡ a
trans : {A : Set}{a b c : A} → a ≡ b → b ≡ c → a ≡ c
subst : {A : Set}(P : A → Set){a b : A} → a ≡ b → P a → P b
postulate
_*_ : ℕ → ℕ → ℕ
*-comm : ∀ m n → m * n ≡ n * m
*-rightIdentity : ∀ n → n * succ zero ≡ n
*-leftIdentity : ∀ n → succ zero * n ≡ n
*-leftIdentity n =
trans {ℕ} {succ zero * n} {n * succ zero} {n} (*-comm (succ zero) n) (*-rightIdentity n)
module ER
{A : Set}
(_∼_ : A → A → Set)
(∼-refl : ∀ {x} → x ∼ x)
(∼-trans : ∀ {x y z} → x ∼ y → y ∼ z → x ∼ z)
where
infixr 5 _∼⟨_⟩_
infix 6 _∎
_∼⟨_⟩_ : ∀ x {y z} → x ∼ y → y ∼ z → x ∼ z
_ ∼⟨ x∼y ⟩ y∼z = ∼-trans x∼y y∼z
_∎ : ∀ x → x ∼ x
_∎ _ = ∼-refl
open module ≡-Reasoning = ER _≡_ (refl {ℕ}) (trans {ℕ})
renaming ( _∼⟨_⟩_ to _≡⟨_⟩_ )
*-leftIdentity' : ∀ n → succ zero * n ≡ n
*-leftIdentity' n =
succ zero * n ≡⟨ *-comm (succ zero) n ⟩
n * succ zero ≡⟨ *-rightIdentity n ⟩
n ∎
| {
"alphanum_fraction": 0.5119356513,
"avg_line_length": 21.7740112994,
"ext": "agda",
"hexsha": "89c620b0fbffddd0735d0df8e0ad2d0c1e70841e",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/thesis/report/AgdaIntroduction.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/thesis/report/AgdaIntroduction.agda",
"max_line_length": 90,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/thesis/report/AgdaIntroduction.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 1552,
"size": 3854
} |
module Data.Option.Proofs where
import Lvl
open import Data
open import Data.Option
open import Data.Option.Functions
open import Functional
open import Structure.Setoid using (Equiv)
open import Structure.Function.Domain
open import Structure.Function
import Structure.Operator.Names as Names
open import Structure.Operator.Properties
open import Structure.Relator.Properties
open import Type
private variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ : Lvl.Level
private variable T A B C : Type{ℓ}
private variable x : T
private variable o : Option(T)
module _ where
open Structure.Setoid
open import Function.Equals
module _ ⦃ _ : let _ = A ; _ = B ; _ = C in Equiv{ℓₑ}(Option(C)) ⦄ {f : B → C}{g : A → B} where
map-preserves-[∘] : (map(f ∘ g) ⊜ (map f) ∘ (map g))
_⊜_.proof map-preserves-[∘] {None} = reflexivity(_≡_)
_⊜_.proof map-preserves-[∘] {Some x} = reflexivity(_≡_)
module _ ⦃ _ : Equiv{ℓₑ}(Option(A)) ⦄ where
map-preserves-id : (map id ⊜ id)
_⊜_.proof map-preserves-id {None} = reflexivity(_≡_)
_⊜_.proof map-preserves-id {Some x} = reflexivity(_≡_)
andThenᵣ-Some : ((_andThen Some) ⊜ id)
_⊜_.proof andThenᵣ-Some {None} = reflexivity(_≡_)
_⊜_.proof andThenᵣ-Some {Some x} = reflexivity(_≡_)
module _ ⦃ _ : Equiv{ℓₑ}(Option(A)) ⦄ where
andThenᵣ-None : o andThen (const{Y = Option(A)} None) ≡ None
andThenᵣ-None {o = None} = reflexivity(_≡_)
andThenᵣ-None {o = Some x} = reflexivity(_≡_)
module _ ⦃ _ : let _ = A in Equiv{ℓₑ}(Option(B)) ⦄ {f : A → Option(B)} where
andThenₗ-None : (None andThen f ≡ None)
andThenₗ-None = reflexivity(_≡_)
andThenₗ-Some : (Some(x) andThen f ≡ f(x))
andThenₗ-Some = reflexivity(_≡_)
module _ ⦃ _ : let _ = A ; _ = B in Equiv{ℓₑ}(Option(C)) ⦄ {f : A → Option(B)} {g : B → Option(C)} where
andThen-associativity : (o andThen (p ↦ f(p) andThen g) ≡ (o andThen f) andThen g)
andThen-associativity {None} = reflexivity(_≡_)
andThen-associativity {Some x} = reflexivity(_≡_)
module _ where
open import Function.Equals
module _ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ ⦃ equiv-option-B : Equiv{ℓₑ}(Option B) ⦄ ⦃ some-func : Function(Some) ⦄ where
map-function : Function(map {T₁ = A}{T₂ = B})
Dependent._⊜_.proof (Function.congruence map-function (Dependent.intro p)) {None} = reflexivity _
Dependent._⊜_.proof (Function.congruence map-function (Dependent.intro p)) {Some x} = congruence₁(Some) p
module _ ⦃ equiv-option-B : Equiv{ℓₑ}(Option B) ⦄ where
andThen-function : Function(Functional.swap(_andThen_ {T₁ = A}{T₂ = B}))
Dependent._⊜_.proof (Function.congruence andThen-function {f} {g} _) {None} = reflexivity _
Dependent._⊜_.proof (Function.congruence andThen-function {f} {g} (Dependent.intro p)) {Some x} = p{x}
module _
⦃ equiv-T : Equiv{ℓₑ₁}(T) ⦄
⦃ equiv-opt-T : Equiv{ℓₑ₂}(Option(T)) ⦄
⦃ some-func : Function(Some) ⦄
{_▫_ : T → T → T}
where
open Structure.Setoid
instance
and-combine-associativity : ⦃ _ : Associativity(_▫_) ⦄ → Associativity(and-combine(_▫_))
and-combine-associativity = intro p where
p : Names.Associativity(and-combine(_▫_))
p {None} {None} {None} = reflexivity(_≡_)
p {None} {None} {Some _} = reflexivity(_≡_)
p {None} {Some _} {None} = reflexivity(_≡_)
p {None} {Some _} {Some _} = reflexivity(_≡_)
p {Some _} {None} {None} = reflexivity(_≡_)
p {Some _} {None} {Some _} = reflexivity(_≡_)
p {Some _} {Some _} {None} = reflexivity(_≡_)
p {Some _} {Some _} {Some _} = congruence₁(Some) (associativity(_▫_))
module _ where --instance
or-combine-associativity : ∀{f} ⦃ idemp-f : Idempotent(f) ⦄ (_ : ∀{x y} → (f(x) ▫ y ≡ f(x ▫ y))) (_ : ∀{x y} → (x ▫ f(y) ≡ f(x ▫ y))) → ⦃ _ : Associativity(_▫_) ⦄ → Associativity(or-combine(_▫_) f f) -- TODO: What are the unnamed properties here in the assumptions called? Also, the constant function of an absorber have all these properties. The identity function also have it.
or-combine-associativity {f = f} compatₗ compatᵣ = intro p where
p : Names.Associativity(or-combine(_▫_) f f)
p {None} {None} {None} = reflexivity(_≡_)
p {None} {None} {Some z} = congruence₁(Some) (symmetry(_≡_) (idempotent(f)))
p {None} {Some y} {None} = reflexivity(_≡_)
p {None} {Some y} {Some z} = congruence₁(Some) compatₗ
p {Some x} {None} {None} = congruence₁(Some) (idempotent(f))
p {Some x} {None} {Some z} = congruence₁(Some) (transitivity(_≡_) compatₗ (symmetry(_≡_) compatᵣ))
p {Some x} {Some y} {None} = congruence₁(Some) (symmetry(_≡_) compatᵣ)
p {Some x} {Some y} {Some z} = congruence₁(Some) (associativity(_▫_))
| {
"alphanum_fraction": 0.6318449874,
"avg_line_length": 46.0970873786,
"ext": "agda",
"hexsha": "b86e827ee7a2b97f52ab755102172dbbaa4d193c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/Option/Proofs.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Data/Option/Proofs.agda",
"max_line_length": 382,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/Option/Proofs.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 1744,
"size": 4748
} |
module index where
-- You probably want to start with this module:
import README
-- For a brief presentation of every single module, head over to
import Everything
-- Otherwise, here is an exhaustive, stern list of all the available modules:
| {
"alphanum_fraction": 0.7755102041,
"avg_line_length": 24.5,
"ext": "agda",
"hexsha": "4acb132ae08755470d029049b925d94d19befb56",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/travis/index.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/travis/index.agda",
"max_line_length": 77,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/travis/index.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 50,
"size": 245
} |
{-# OPTIONS --cubical --safe --no-sized-types --no-guardedness #-}
module Agda.Builtin.Cubical.Glue where
open import Agda.Primitive
open import Agda.Builtin.Sigma
open import Agda.Primitive.Cubical renaming (primINeg to ~_; primIMax to _∨_; primIMin to _∧_;
primHComp to hcomp; primTransp to transp; primComp to comp;
itIsOne to 1=1)
open import Agda.Builtin.Cubical.Path
open import Agda.Builtin.Cubical.Sub renaming (Sub to _[_↦_]; primSubOut to ouc)
module Helpers where
-- Homogeneous filling
hfill : ∀ {ℓ} {A : Set ℓ} {φ : I}
(u : ∀ i → Partial φ A)
(u0 : A [ φ ↦ u i0 ]) (i : I) → A
hfill {φ = φ} u u0 i =
hcomp (λ j → \ { (φ = i1) → u (i ∧ j) 1=1
; (i = i0) → ouc u0 })
(ouc u0)
-- Heterogeneous filling defined using comp
fill : ∀ {ℓ : I → Level} (A : ∀ i → Set (ℓ i)) {φ : I}
(u : ∀ i → Partial φ (A i))
(u0 : A i0 [ φ ↦ u i0 ]) →
∀ i → A i
fill A {φ = φ} u u0 i =
comp (λ j → A (i ∧ j)) _
(λ j → \ { (φ = i1) → u (i ∧ j) 1=1
; (i = i0) → ouc u0 })
(ouc {φ = φ} u0)
module _ {ℓ} {A : Set ℓ} where
refl : {x : A} → x ≡ x
refl {x = x} = λ _ → x
sym : {x y : A} → x ≡ y → y ≡ x
sym p = λ i → p (~ i)
cong : ∀ {ℓ'} {B : A → Set ℓ'} {x y : A}
(f : (a : A) → B a) (p : x ≡ y)
→ PathP (λ i → B (p i)) (f x) (f y)
cong f p = λ i → f (p i)
isContr : ∀ {ℓ} → Set ℓ → Set ℓ
isContr A = Σ A \ x → (∀ y → x ≡ y)
fiber : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) (y : B) → Set (ℓ ⊔ ℓ')
fiber {A = A} f y = Σ A \ x → f x ≡ y
open Helpers
-- We make this a record so that isEquiv can be proved using
-- copatterns. This is good because copatterns don't get unfolded
-- unless a projection is applied so it should be more efficient.
record isEquiv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : Set (ℓ ⊔ ℓ') where
field
equiv-proof : (y : B) → isContr (fiber f y)
open isEquiv public
infix 4 _≃_
_≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ')
A ≃ B = Σ (A → B) \ f → (isEquiv f)
equivFun : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → A ≃ B → A → B
equivFun e = fst e
-- Improved version of equivProof compared to Lemma 5 in CCHM. We put
-- the (φ = i0) face in contr' making it be definitionally c in this
-- case. This makes the computational behavior better, in particular
-- for transp in Glue.
equivProof : ∀ {la lt} (T : Set la) (A : Set lt) → (w : T ≃ A) → (a : A)
→ ∀ ψ → (Partial ψ (fiber (w .fst) a)) → fiber (w .fst) a
equivProof A B w a ψ fb = contr' {A = fiber (w .fst) a} (w .snd .equiv-proof a) ψ fb
where
contr' : ∀ {ℓ} {A : Set ℓ} → isContr A → (φ : I) → (u : Partial φ A) → A
contr' {A = A} (c , p) φ u = hcomp (λ i → λ { (φ = i1) → p (u 1=1) i
; (φ = i0) → c }) c
{-# BUILTIN EQUIV _≃_ #-}
{-# BUILTIN EQUIVFUN equivFun #-}
{-# BUILTIN EQUIVPROOF equivProof #-}
primitive
primGlue : ∀ {ℓ ℓ'} (A : Set ℓ) {φ : I}
→ (T : Partial φ (Set ℓ')) → (e : PartialP φ (λ o → T o ≃ A))
→ Set ℓ'
prim^glue : ∀ {ℓ ℓ'} {A : Set ℓ} {φ : I}
→ {T : Partial φ (Set ℓ')} → {e : PartialP φ (λ o → T o ≃ A)}
→ PartialP φ T → A → primGlue A T e
prim^unglue : ∀ {ℓ ℓ'} {A : Set ℓ} {φ : I}
→ {T : Partial φ (Set ℓ')} → {e : PartialP φ (λ o → T o ≃ A)}
→ primGlue A T e → A
-- Needed for transp in Glue.
primFaceForall : (I → I) → I
module _ {ℓ : I → Level} (P : (i : I) → Set (ℓ i)) where
private
E : (i : I) → Set (ℓ i)
E = λ i → P i
~E : (i : I) → Set (ℓ (~ i))
~E = λ i → P (~ i)
A = P i0
B = P i1
f : A → B
f x = transp E i0 x
g : B → A
g y = transp ~E i0 y
u : ∀ i → A → E i
u i x = transp (λ j → E (i ∧ j)) (~ i) x
v : ∀ i → B → E i
v i y = transp (λ j → ~E ( ~ i ∧ j)) i y
fiberPath : (y : B) → (xβ0 xβ1 : fiber f y) → xβ0 ≡ xβ1
fiberPath y (x0 , β0) (x1 , β1) k = ω , λ j → δ (~ j) where
module _ (j : I) where
private
sys : A → ∀ i → PartialP (~ j ∨ j) (λ _ → E (~ i))
sys x i (j = i0) = v (~ i) y
sys x i (j = i1) = u (~ i) x
ω0 = comp ~E _ (sys x0) ((β0 (~ j)))
ω1 = comp ~E _ (sys x1) ((β1 (~ j)))
θ0 = fill ~E (sys x0) (inc (β0 (~ j)))
θ1 = fill ~E (sys x1) (inc (β1 (~ j)))
sys = λ {j (k = i0) → ω0 j ; j (k = i1) → ω1 j}
ω = hcomp sys (g y)
θ = hfill sys (inc (g y))
δ = λ (j : I) → comp E _
(λ i → λ { (j = i0) → v i y ; (k = i0) → θ0 j (~ i)
; (j = i1) → u i ω ; (k = i1) → θ1 j (~ i) })
(θ j)
γ : (y : B) → y ≡ f (g y)
γ y j = comp E _ (λ i → λ { (j = i0) → v i y
; (j = i1) → u i (g y) }) (g y)
pathToisEquiv : isEquiv f
pathToisEquiv .equiv-proof y .fst .fst = g y
pathToisEquiv .equiv-proof y .fst .snd = sym (γ y)
pathToisEquiv .equiv-proof y .snd = fiberPath y _
pathToEquiv : A ≃ B
pathToEquiv .fst = f
pathToEquiv .snd = pathToisEquiv
{-# BUILTIN PATHTOEQUIV pathToEquiv #-}
| {
"alphanum_fraction": 0.4496783958,
"avg_line_length": 33.2452830189,
"ext": "agda",
"hexsha": "c7ed5e75ae186911881b15dc4df408ad918d67f7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "phadej/agda",
"max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Glue.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "phadej/agda",
"max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Glue.agda",
"max_line_length": 104,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "phadej/agda",
"max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Glue.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2149,
"size": 5286
} |
{-# OPTIONS --without-K #-}
-- Copied from "https://code.google.com/p/agda/issues/attachmentText?id=846&aid=8460000000&name=DivModUtils.agda&token=GDo1rQ6ldpTKOCjtbzSWPu19HL0%3A1373287197978"
module DivModUtils where
open import Data.Nat
open import Data.Bool
open import Data.Nat.DivMod
open import Relation.Nullary
open import Data.Nat.Properties
open import Data.Fin using (Fin; toℕ; zero; suc; fromℕ≤)
open import Data.Fin.Properties
open import Relation.Binary.PropositionalEquality
open import Function
open import Data.Product
open import Relation.Binary
open import Data.Empty
open import Relation.Nullary.Negation
open ≡-Reasoning
open ≤-Reasoning
renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≡⟨_⟩'_)
open DecTotalOrder decTotalOrder
using () renaming (refl to ≤-refl; antisym to ≤-antisym)
import Algebra
open Algebra.CommutativeSemiring commutativeSemiring using (+-comm; +-assoc)
------------------------------------------------------------------------------
i+[j∸m]≡i+j∸m : ∀ i j m → m ≤ j → i + (j ∸ m) ≡ i + j ∸ m
i+[j∸m]≡i+j∸m i zero zero lt = refl
i+[j∸m]≡i+j∸m i zero (suc m) ()
i+[j∸m]≡i+j∸m i (suc j) zero lt = refl
i+[j∸m]≡i+j∸m i (suc j) (suc m) (s≤s m≤j) = begin
i + (j ∸ m) ≡⟨ i+[j∸m]≡i+j∸m i j m m≤j ⟩
suc (i + j) ∸ suc m ≡⟨ cong (λ y → y ∸ suc m) $
solve 2
(λ i' j' → con 1 :+ (i' :+ j') := i' :+ (con 1 :+ j'))
refl i j ⟩
(i + suc j) ∸ suc m ∎
where open SemiringSolver
-- Following code taken from
-- https://github.com/copumpkin/derpa/blob/master/REPA/Index.agda#L210
-- the next few bits are lemmas to prove uniqueness of euclidean division
-- first : for nonzero divisors, a nonzero quotient would require a larger
-- dividend than is consistent with a zero quotient, regardless of
-- remainders.
large : ∀ {d} {r : Fin (suc d)} x (r′ : Fin (suc d)) → toℕ r ≢ suc x * suc d + toℕ r′
large {d} {r} x r′ pf = irrefl pf (
start
suc (toℕ r)
≤⟨ bounded r ⟩
suc d
≤⟨ m≤m+n (suc d) (x * suc d) ⟩
suc d + x * suc d -- same as (suc x * suc d)
≤⟨ m≤m+n (suc x * suc d) (toℕ r′) ⟩
suc x * suc d + toℕ r′ -- clearer in two steps, and we'd need assoc anyway
□)
where
open ≤-Reasoning
open Relation.Binary.StrictTotalOrder Data.Nat.Properties.strictTotalOrder
-- a raw statement of the uniqueness, in the arrangement of terms that's
-- easiest to work with computationally
addMul-lemma′ : ∀ x x′ d (r r′ : Fin (suc d)) →
x * suc d + toℕ r ≡ x′ * suc d + toℕ r′ → r ≡ r′ × x ≡ x′
addMul-lemma′ zero zero d r r′ hyp = (toℕ-injective hyp) , refl
addMul-lemma′ zero (suc x′) d r r′ hyp = ⊥-elim (large x′ r′ hyp)
addMul-lemma′ (suc x) zero d r r′ hyp = ⊥-elim (large x r (sym hyp))
addMul-lemma′ (suc x) (suc x′) d r r′ hyp
rewrite +-assoc (suc d) (x * suc d) (toℕ r)
| +-assoc (suc d) (x′ * suc d) (toℕ r′)
with addMul-lemma′ x x′ d r r′ (cancel-+-left (suc d) hyp)
... | pf₁ , pf₂ = pf₁ , cong suc pf₂
-- and now rearranged to the order that Data.Nat.DivMod uses
addMul-lemma : ∀ x x′ d (r r′ : Fin (suc d)) →
toℕ r + x * suc d ≡ toℕ r′ + x′ * suc d → r ≡ r′ × x ≡ x′
addMul-lemma x x′ d r r′ hyp rewrite +-comm (toℕ r) (x * suc d)
| +-comm (toℕ r′) (x′ * suc d)
= addMul-lemma′ x x′ d r r′ hyp
DivMod-lemma : ∀ x d (r : Fin (suc d)) → (res : DivMod (toℕ r + x * suc d) (suc d)) →
res ≡ result x r refl
DivMod-lemma x d r (result q r′ eq) with addMul-lemma x q d r r′ eq
DivMod-lemma x d r (result .x .r eq) | refl , refl =
cong (result x r) (proof-irrelevance eq refl)
divMod-lemma : ∀ x d (r : Fin (suc d)) →
(toℕ r + x * suc d) divMod suc d ≡ result x r refl
divMod-lemma x d r with (toℕ r + x * suc d) divMod suc d
divMod-lemma x d r | q rewrite DivMod-lemma x d r q = refl
mod-lemma : ∀ x d (r : Fin (suc d)) → (toℕ r + x * suc d) mod suc d ≡ r
mod-lemma x d r rewrite divMod-lemma x d r = refl
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.5718810916,
"avg_line_length": 39.4615384615,
"ext": "agda",
"hexsha": "84c21989e7d15a26af13d6567cc8cfd60b2dfa66",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "Univalence/DivModUtils.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "Univalence/Obsolete/DivModUtils.agda",
"max_line_length": 163,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "Univalence/DivModUtils.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
"num_tokens": 1507,
"size": 4104
} |
module Chain
{U : Set}(T : U -> Set)
(_==_ : {a b : U} -> T a -> T b -> Set)
(refl : {a : U}(x : T a) -> x == x)
(trans : {a b c : U}(x : T a)(y : T b)(z : T c) -> x == y -> y == z -> x == z)
where
infix 30 _∼_
infix 3 proof_
infixl 2 _≡_by_
infix 1 _qed
data _∼_ {a b : U}(x : T a)(y : T b) : Set where
prf : x == y -> x ∼ y
proof_ : {a : U}(x : T a) -> x ∼ x
proof x = prf (refl x)
_≡_by_ : {a b c : U}{x : T a}{y : T b} -> x ∼ y -> (z : T c) -> y == z -> x ∼ z
prf p ≡ z by q = prf (trans _ _ _ p q)
_qed : {a b : U}{x : T a}{y : T b} -> x ∼ y -> x == y
prf p qed = p
| {
"alphanum_fraction": 0.4108658744,
"avg_line_length": 23.56,
"ext": "agda",
"hexsha": "cb402aca562b3db4110afe310a1e4ae9d0fc4f2f",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "benchmark/cwf/Chain.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "benchmark/cwf/Chain.agda",
"max_line_length": 80,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "benchmark/cwf/Chain.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 298,
"size": 589
} |
-- Andreas, 2013-03-15 issue reported by Nisse
-- {-# OPTIONS -v tc.proj:40 -v tc.conv.elim:40 #-}
module Issue821 where
import Common.Level
data D (A : Set) : Set where
c : D A → D A
f : (A : Set) → D A → D A
f A (c x) = x
postulate
A : Set
P : D A → Set
x : D A
p : P x
Q : P (f A x) → Set
Foo : Set₁
Foo = Q p
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/TypeChecking/Conversion.hs:466
-- Reason was that f is projection-like so the test x =?= f A x
-- actually becomes x =?= x .f with unequal spine shapes (empty vs. non-empty).
-- Agda thought this was impossible.
| {
"alphanum_fraction": 0.6342592593,
"avg_line_length": 22.3448275862,
"ext": "agda",
"hexsha": "ea231db2b4fa100d3acf8ee3da2a7b9d3442a300",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue821.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Fail/Issue821.agda",
"max_line_length": 79,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Fail/Issue821.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 217,
"size": 648
} |
module Data.Num.Next where
open import Data.Num.Core
open import Data.Num.Maximum
open import Data.Num.Bounded
open import Data.Nat
open import Data.Nat.Properties
open import Data.Nat.Properties.Simple
open import Data.Nat.Properties.Extra
open import Data.Fin as Fin
using (Fin; fromℕ≤; inject≤)
renaming (zero to z; suc to s)
open import Data.Fin.Properties using (toℕ-fromℕ≤; bounded)
open import Data.Product
open import Function
open import Relation.Nullary.Decidable
open import Relation.Nullary
open import Relation.Nullary.Negation
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
open ≤-Reasoning renaming (begin_ to start_; _∎ to _□; _≡⟨_⟩_ to _≈⟨_⟩_)
open DecTotalOrder decTotalOrder using (reflexive) renaming (refl to ≤-refl)
--------------------------------------------------------------------------------
-- next-numeral: NullBase
--------------------------------------------------------------------------------
next-numeral-NullBase : ∀ {d o}
→ (xs : Numeral 0 (suc d) o)
→ ¬ (Maximum xs)
→ Numeral 0 (suc d) o
next-numeral-NullBase xs ¬max with Greatest? (lsd xs)
next-numeral-NullBase xs ¬max | yes greatest =
contradiction (Maximum-NullBase-Greatest xs greatest) ¬max
next-numeral-NullBase (x ∙) ¬max | no ¬greatest = digit+1 x ¬greatest ∙
next-numeral-NullBase (x ∷ xs) ¬max | no ¬greatest = digit+1 x ¬greatest ∷ xs
next-numeral-NullBase-lemma : ∀ {d o}
→ (xs : Numeral 0 (suc d) o)
→ (¬max : ¬ (Maximum xs))
→ ⟦ next-numeral-NullBase xs ¬max ⟧ ≡ suc ⟦ xs ⟧
next-numeral-NullBase-lemma {d} {o} xs ¬max with Greatest? (lsd xs)
next-numeral-NullBase-lemma {d} {o} xs ¬max | yes greatest =
contradiction (Maximum-NullBase-Greatest xs greatest) ¬max
next-numeral-NullBase-lemma {d} {o} (x ∙) ¬max | no ¬greatest =
begin
Digit-toℕ (digit+1 x ¬greatest) o
≡⟨ digit+1-toℕ x ¬greatest ⟩
suc (Fin.toℕ x + o)
∎
next-numeral-NullBase-lemma {d} {o} (x ∷ xs) ¬max | no ¬greatest =
begin
⟦ digit+1 x ¬greatest ∷ xs ⟧
≡⟨ refl ⟩
Digit-toℕ (digit+1 x ¬greatest) o + ⟦ xs ⟧ * zero
≡⟨ cong (λ w → w + ⟦ xs ⟧ * zero) (digit+1-toℕ x ¬greatest) ⟩
suc (Fin.toℕ x + o + ⟦ xs ⟧ * zero)
≡⟨ refl ⟩
suc ⟦ x ∷ xs ⟧
∎
next-numeral-is-greater-NullBase : ∀ {d o}
→ (xs : Numeral 0 (suc d) o)
→ (¬max : ¬ (Maximum xs))
→ ⟦ next-numeral-NullBase xs ¬max ⟧ > ⟦ xs ⟧
next-numeral-is-greater-NullBase xs ¬max =
start
suc ⟦ xs ⟧
≈⟨ sym (next-numeral-NullBase-lemma xs ¬max) ⟩
⟦ next-numeral-NullBase xs ¬max ⟧
□
next-numeral-is-immediate-NullBase : ∀ {d o}
→ (xs : Numeral 0 (suc d) o)
→ (ys : Numeral 0 (suc d) o)
→ (¬max : ¬ (Maximum xs))
→ ⟦ ys ⟧ > ⟦ xs ⟧
→ ⟦ ys ⟧ ≥ ⟦ next-numeral-NullBase xs ¬max ⟧
next-numeral-is-immediate-NullBase xs ys ¬max prop =
start
⟦ next-numeral-NullBase xs ¬max ⟧
≈⟨ next-numeral-NullBase-lemma xs ¬max ⟩
suc ⟦ xs ⟧
≤⟨ prop ⟩
⟦ ys ⟧
□
--------------------------------------------------------------------------------
-- next-numeral: Proper
--------------------------------------------------------------------------------
mutual
Gapped#0 : ∀ b d o → Set
Gapped#0 b d o = suc d < carry o * suc b
Gapped#N : ∀ b d o
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ Set
Gapped#N b d o xs proper = suc d < (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b
where
next-xs : Numeral (suc b) (suc d) o
next-xs = next-numeral-Proper xs proper
Gapped#0? : ∀ b d o → Dec (Gapped#0 b d o)
Gapped#0? b d o = suc (suc d) ≤? carry o * suc b
Gapped#N? : ∀ b d o
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ Dec (Gapped#N b d o xs proper)
Gapped#N? b d o xs proper = suc (suc d) ≤? (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b
where
next-xs : Numeral (suc b) (suc d) o
next-xs = next-numeral-Proper xs proper
-- Gap#N
Gapped : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ Set
Gapped {b} {d} {o} (x ∙) proper = Gapped#0 b d o
Gapped {b} {d} {o} (x ∷ xs) proper = Gapped#N b d o xs proper
Gapped? : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ Dec (Gapped {b} {d} {o} xs proper)
Gapped? {b} {d} {o} (x ∙) proper = Gapped#0? b d o
Gapped? {b} {d} {o} (x ∷ xs) proper = Gapped#N? b d o xs proper
data NextView : (b d o : ℕ) (xs : Numeral b d o) (proper : 2 ≤ d + o) → Set where
Interval : ∀ b d o
→ {xs : Numeral (suc b) (suc d) o}
→ {proper : 2 ≤ suc (d + o)}
→ (¬greatest : ¬ (Greatest (lsd xs)))
→ NextView (suc b) (suc d) o xs proper
GappedEndpoint : ∀ b d o
→ {xs : Numeral (suc b) (suc d) o}
→ {proper : 2 ≤ suc (d + o)}
→ (greatest : Greatest (lsd xs))
→ (gapped : Gapped xs proper)
→ NextView (suc b) (suc d) o xs proper
UngappedEndpoint : ∀ b d o
→ {xs : Numeral (suc b) (suc d) o}
→ {proper : 2 ≤ suc (d + o)}
→ (greatest : Greatest (lsd xs))
→ (¬gapped : ¬ (Gapped xs proper))
→ NextView (suc b) (suc d) o xs proper
nextView : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ NextView (suc b) (suc d) o xs proper
nextView {b} {d} {o} xs proper with Greatest? (lsd xs)
nextView {b} {d} {o} xs proper | yes greatest with Gapped? xs proper
nextView {b} {d} {o} xs proper | yes greatest | yes gapped = GappedEndpoint b d o greatest gapped
nextView {b} {d} {o} xs proper | yes greatest | no ¬gapped = UngappedEndpoint b d o greatest ¬gapped
nextView {b} {d} {o} xs proper | no ¬greatest = Interval b d o ¬greatest
next-numeral-Proper-Interval : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (¬greatest : ¬ (Greatest (lsd xs)))
→ (proper : 2 ≤ suc (d + o))
→ Numeral (suc b) (suc d) o
next-numeral-Proper-Interval (x ∙) ¬greatest proper = digit+1 x ¬greatest ∙
next-numeral-Proper-Interval (x ∷ xs) ¬greatest proper = digit+1 x ¬greatest ∷ xs
next-numeral-Proper-GappedEndpoint : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ (gapped : Gapped xs proper)
→ Numeral (suc b) (suc d) o
next-numeral-Proper-GappedEndpoint {b} {d} {o} (x ∙) proper gapped = z ∷ carry-digit d o proper ∙
next-numeral-Proper-GappedEndpoint {b} {d} {o} (x ∷ xs) proper gapped = z ∷ next-numeral-Proper xs proper
next-numeral-Proper-UngappedEndpoint : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (greatest : Greatest (lsd xs))
→ (proper : 2 ≤ suc (d + o))
→ (¬gapped : ¬ (Gapped xs proper))
→ Numeral (suc b) (suc d) o
next-numeral-Proper-UngappedEndpoint {b} {d} {o} (x ∙) greatest proper gapped
= digit+1-n x greatest (carry o * suc b) lower-bound ∷ carry-digit d o proper ∙
where
lower-bound : carry o * suc b > 0
lower-bound =
start
1
≤⟨ m≤m*1+n 1 b ⟩
1 * suc b
≤⟨ *n-mono (suc b) (m≤m⊔n 1 o) ⟩
carry o * suc b
□
next-numeral-Proper-UngappedEndpoint {b} {d} {o} (x ∷ xs) greatest proper gapped
= digit+1-n x greatest gap lower-bound ∷ next-xs
where
next-xs : Numeral (suc b) (suc d) o
next-xs = next-numeral-Proper xs proper
gap : ℕ
gap = (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b
lower-bound : gap > 0
lower-bound =
start
1
≤⟨ m≤m*1+n 1 b ⟩
1 * suc b
≤⟨ *n-mono (suc b) (m≥n+o⇒m∸o≥n ⟦ next-xs ⟧ 1 ⟦ xs ⟧ (next-numeral-is-greater-Proper xs proper)) ⟩
(⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b
□
next-numeral-Proper : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ Numeral (suc b) (suc d) o
next-numeral-Proper xs proper with nextView xs proper
next-numeral-Proper xs proper | Interval b d o ¬greatest
= next-numeral-Proper-Interval xs ¬greatest proper
next-numeral-Proper xs proper | GappedEndpoint b d o greatest gapped
= next-numeral-Proper-GappedEndpoint xs proper gapped
next-numeral-Proper xs proper | UngappedEndpoint b d o greatest ¬gapped
= next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped
next-numeral-Proper-Interval-lemma : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (¬greatest : ¬ (Greatest (lsd xs)))
→ (proper : 2 ≤ suc (d + o))
→ ⟦ next-numeral-Proper-Interval xs ¬greatest proper ⟧ ≡ suc ⟦ xs ⟧
next-numeral-Proper-Interval-lemma {b} {d} {o} (x ∙) ¬greatest proper =
-- ⟦ digit+1 x ¬greatest ∙ ⟧ ≡ suc ⟦ x ∙ ⟧
begin
Digit-toℕ (digit+1 x ¬greatest) o
≡⟨ digit+1-toℕ x ¬greatest ⟩
suc (Digit-toℕ x o)
∎
next-numeral-Proper-Interval-lemma {b} {d} {o} (x ∷ xs) ¬greatest proper =
-- ⟦ digit+1 x ¬greatest ∷ xs ⟧ ≡ suc ⟦ x ∷ xs ⟧
begin
Digit-toℕ (digit+1 x ¬greatest) o + ⟦ xs ⟧ * suc b
≡⟨ cong (λ w → w + ⟦ xs ⟧ * suc b) (digit+1-toℕ x ¬greatest) ⟩
suc (Digit-toℕ x o) + ⟦ xs ⟧ * suc b
∎
next-numeral-Proper-GappedEndpoint-lemma : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (greatest : Greatest (lsd xs))
→ (proper : 2 ≤ suc (d + o))
→ (gapped : Gapped xs proper)
→ ⟦ next-numeral-Proper-GappedEndpoint xs proper gapped ⟧ > suc ⟦ xs ⟧
next-numeral-Proper-GappedEndpoint-lemma {b} {d} {o} (x ∙) greatest proper gapped =
-- ⟦ z ∷ carry-digit d o proper ∙ ⟧ > suc ⟦ x ∙ ⟧
start
suc (suc (Fin.toℕ x + o))
≈⟨ cong (λ w → suc w + o) greatest ⟩
suc (suc d) + o
≈⟨ +-comm (suc (suc d)) o ⟩
o + suc (suc d)
≤⟨ n+-mono o gapped ⟩
o + carry o * suc b
≈⟨ cong (λ w → o + w * suc b) (sym (carry-digit-toℕ d o proper)) ⟩
o + (Digit-toℕ (carry-digit d o proper) o) * suc b
□
next-numeral-Proper-GappedEndpoint-lemma {b} {d} {o} (x ∷ xs) greatest proper gapped
= proof
where
next-xs : Numeral (suc b) (suc d) o
next-xs = next-numeral-Proper xs proper
next-xs>xs : ⟦ next-xs ⟧ > ⟦ xs ⟧
next-xs>xs = next-numeral-is-greater-Proper xs proper
next : Numeral (suc b) (suc d) o
next = z ∷ next-xs
-- ⟦ z ∷ next-numeral-Proper xs (Maximum-Proper xs proper) proper ⟧ > suc ⟦ x ∷ xs ⟧
proof : ⟦ next ⟧ > suc ⟦ x ∷ xs ⟧
proof = start
suc (suc (Digit-toℕ x o)) + ⟦ xs ⟧ * suc b
≈⟨ cong (λ w → suc (suc w) + ⟦ xs ⟧ * suc b) (greatest-digit-toℕ x greatest) ⟩
suc (suc d) + o + ⟦ xs ⟧ * suc b
≈⟨ +-assoc (suc (suc d)) o (⟦ xs ⟧ * suc b) ⟩
suc (suc d) + (o + ⟦ xs ⟧ * suc b)
≈⟨ a+[b+c]≡b+[a+c] (suc (suc d)) o (⟦ xs ⟧ * suc b) ⟩
o + (suc (suc d) + ⟦ xs ⟧ * suc b)
≤⟨ n+-mono o (+n-mono (⟦ xs ⟧ * suc b) gapped) ⟩
o + ((⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b + ⟦ xs ⟧ * suc b)
≈⟨ cong (λ w → o + w) (sym (distribʳ-*-+ (suc b) (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) ⟦ xs ⟧)) ⟩
o + (⟦ next-xs ⟧ ∸ ⟦ xs ⟧ + ⟦ xs ⟧) * suc b
≈⟨ cong (λ w → o + w * suc b) (m∸n+n≡m (<⇒≤ next-xs>xs)) ⟩
o + ⟦ next-xs ⟧ * suc b
≈⟨ refl ⟩
⟦ z ∷ next-xs ⟧
□
next-numeral-Proper-UngappedEndpoint-lemma : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (greatest : Greatest (lsd xs))
→ (proper : 2 ≤ suc (d + o))
→ (¬gapped : ¬ (Gapped xs proper))
→ ⟦ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped ⟧ ≡ suc ⟦ xs ⟧
next-numeral-Proper-UngappedEndpoint-lemma {b} {d} {o} (x ∙) greatest proper ¬gapped = proof
-- ⟦ digit+1-n x greatest (carry o * suc b) lower-bound ∷ carry-digit d o proper ∙ ⟧ ≡ suc ⟦ x ∙ ⟧
where
lower-bound : carry o * suc b > 0
lower-bound =
start
1
≤⟨ m≤m*1+n 1 b ⟩
1 * suc b
≤⟨ *n-mono (suc b) (m≤m⊔n 1 o) ⟩
carry o * suc b
□
upper-bound : carry o * suc b ≤ suc d
upper-bound = ≤-pred $ ≰⇒> ¬gapped
upper-bound' : carry o * suc b ≤ suc (Fin.toℕ x + o)
upper-bound' = start
carry o * suc b
≤⟨ upper-bound ⟩
suc d
≈⟨ sym greatest ⟩
suc (Fin.toℕ x)
≤⟨ m≤m+n (suc (Fin.toℕ x)) o ⟩
suc (Fin.toℕ x + o)
□
next : Numeral (suc b) (suc d) o
next = digit+1-n x greatest (carry o * suc b) lower-bound ∷ carry-digit d o proper ∙
proof : ⟦ next ⟧ ≡ suc (Digit-toℕ x o)
proof =
begin
Digit-toℕ (digit+1-n x greatest (carry o * suc b) lower-bound) o + Digit-toℕ (carry-digit d o proper) o * suc b
≡⟨ cong (λ w → Digit-toℕ (digit+1-n x greatest (carry o * suc b) lower-bound) o + w * suc b) (carry-digit-toℕ d o proper) ⟩
Digit-toℕ (digit+1-n x greatest (carry o * suc b) lower-bound) o + carry o * suc b
≡⟨ cong (λ w → w + carry o * suc b) (digit+1-n-toℕ x greatest (carry o * suc b) lower-bound upper-bound) ⟩
suc (Fin.toℕ x + o) ∸ carry o * suc b + carry o * suc b
≡⟨ m∸n+n≡m upper-bound' ⟩
suc (Digit-toℕ x o)
∎
next-numeral-Proper-UngappedEndpoint-lemma {b} {d} {o} (x ∷ xs) greatest proper ¬gapped = proof
-- ⟦ digit+1-n x greatest gap gap>0 ∷ next ∙ ⟧ ≡ suc ⟦ x ∷ xs ⟧
where
¬max-xs : ¬ (Maximum xs)
¬max-xs = Maximum-Proper xs proper
next-xs : Numeral (suc b) (suc d) o
next-xs = next-numeral-Proper xs proper
lower-bound : (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b > 0
lower-bound =
start
1
≤⟨ m≤m*1+n 1 b ⟩
1 * suc b
≤⟨ *n-mono (suc b) (m≥n+o⇒m∸o≥n ⟦ next-xs ⟧ 1 ⟦ xs ⟧ (next-numeral-is-greater-Proper xs proper)) ⟩
(⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b
□
upper-bound : (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b ≤ suc d
upper-bound = ≤-pred $ ≰⇒> ¬gapped
next : Numeral (suc b) (suc d) o
next = digit+1-n x greatest ((⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b) lower-bound ∷ next-xs
⟦next-xs⟧>⟦xs⟧ : ⟦ next-xs ⟧ > ⟦ xs ⟧
⟦next-xs⟧>⟦xs⟧ = next-numeral-is-greater-Proper xs proper
upper-bound' : ⟦ next-xs ⟧ * suc b ∸ ⟦ xs ⟧ * suc b ≤ suc (Digit-toℕ x o)
upper-bound' =
start
⟦ next-xs ⟧ * suc b ∸ ⟦ xs ⟧ * suc b
≈⟨ sym (*-distrib-∸ʳ (suc b) ⟦ next-xs ⟧ ⟦ xs ⟧) ⟩
(⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b
≤⟨ upper-bound ⟩
suc d
≤⟨ m≤m+n (suc d) o ⟩
suc d + o
≈⟨ cong (λ w → w + o) (sym greatest) ⟩
suc (Digit-toℕ x o)
□
proof : ⟦ next ⟧ ≡ suc ⟦ x ∷ xs ⟧
proof =
begin
⟦ next ⟧
≡⟨ cong (λ w → w + ⟦ next-xs ⟧ * suc b) (digit+1-n-toℕ x greatest ((⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b) lower-bound upper-bound) ⟩
suc (Digit-toℕ x o) ∸ (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b + ⟦ next-xs ⟧ * suc b
≡⟨ cong (λ w → suc (Digit-toℕ x o) ∸ w + ⟦ next-xs ⟧ * suc b) (*-distrib-∸ʳ (suc b) ⟦ next-xs ⟧ ⟦ xs ⟧) ⟩
suc (Digit-toℕ x o) ∸ (⟦ next-xs ⟧ * suc b ∸ ⟦ xs ⟧ * suc b) + ⟦ next-xs ⟧ * suc b
≡⟨ m∸[o∸n]+o≡m+n (suc (Digit-toℕ x o)) (⟦ xs ⟧ * suc b) (⟦ next-xs ⟧ * suc b) (*n-mono (suc b) (<⇒≤ ⟦next-xs⟧>⟦xs⟧)) upper-bound' ⟩
suc ⟦ x ∷ xs ⟧
∎
next-numeral-is-greater-Proper : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ ⟦ next-numeral-Proper xs proper ⟧ > ⟦ xs ⟧
next-numeral-is-greater-Proper xs proper with nextView xs proper
next-numeral-is-greater-Proper xs proper | Interval b d o ¬greatest =
start
suc ⟦ xs ⟧
≈⟨ sym (next-numeral-Proper-Interval-lemma xs ¬greatest proper) ⟩
⟦ next-numeral-Proper-Interval xs ¬greatest proper ⟧
□
next-numeral-is-greater-Proper xs proper | GappedEndpoint b d o greatest gapped =
start
suc ⟦ xs ⟧
≤⟨ n≤1+n (suc ⟦ xs ⟧) ⟩
suc (suc ⟦ xs ⟧)
≤⟨ next-numeral-Proper-GappedEndpoint-lemma xs greatest proper gapped ⟩
⟦ next-numeral-Proper-GappedEndpoint xs proper gapped ⟧
□
next-numeral-is-greater-Proper xs proper | UngappedEndpoint b d o greatest ¬gapped =
start
suc ⟦ xs ⟧
≈⟨ sym (next-numeral-Proper-UngappedEndpoint-lemma xs greatest proper ¬gapped) ⟩
⟦ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped ⟧
□
-- gap : ∀ {b d o}
-- → (xs : Numeral (suc b) (suc d) o)
-- → (proper : 2 ≤ suc (d + o))
-- → ℕ
-- gap {b} {d} {o} (x ∙) proper = carry o * suc b
-- gap {b} {d} {o} (x ∷ xs) proper = (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b
-- where
-- next-xs : Numeral (suc b) (suc d) o
-- next-xs = next-numeral-Proper xs proper
--
-- gap>0 : ∀ {b d o}
-- → (xs : Numeral (suc b) (suc d) o)
-- → (proper : 2 ≤ suc (d + o))
-- → gap xs proper > 0
-- gap>0 {b} {d} {o} (x ∙) proper =
-- start
-- 1
-- ≤⟨ m≤m*1+n 1 b ⟩
-- 1 * suc b
-- ≤⟨ *n-mono (suc b) (m≤m⊔n 1 o) ⟩
-- carry o * suc b
-- □
-- gap>0 {b} {d} {o} (x ∷ xs) proper =
-- start
-- 1
-- ≤⟨ m≤m*1+n 1 b ⟩
-- 1 * suc b
-- ≤⟨ *n-mono (suc b) (m≥n+o⇒m∸o≥n ⟦ next-xs ⟧ 1 ⟦ xs ⟧ (next-numeral-is-greater-Proper xs proper)) ⟩
-- (⟦ next-xs ⟧ ∸ ⟦ xs ⟧) * suc b
-- □
-- where
-- next-xs : Numeral (suc b) (suc d) o
-- next-xs = next-numeral-Proper xs proper
--------------------------------------------------------------------------------
-- Properties of next-numeral on Proper Numbers
--------------------------------------------------------------------------------
next-numeral-Proper-refine-target : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ NextView (suc b) (suc d) o xs proper
→ Set
next-numeral-Proper-refine-target xs proper (Interval b d o ¬greatest) = next-numeral-Proper xs proper ≡ next-numeral-Proper-Interval xs ¬greatest proper
next-numeral-Proper-refine-target xs proper (GappedEndpoint b d o greatest gapped) = next-numeral-Proper xs proper ≡ next-numeral-Proper-GappedEndpoint xs proper gapped
next-numeral-Proper-refine-target xs proper (UngappedEndpoint b d o greatest ¬gapped) = next-numeral-Proper xs proper ≡ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped
next-numeral-Proper-refine : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ (view : NextView (suc b) (suc d) o xs proper)
→ next-numeral-Proper-refine-target xs proper view
next-numeral-Proper-refine xs proper (Interval b d o ¬greatest) with nextView xs proper
next-numeral-Proper-refine xs proper (Interval b d o ¬greatest) | Interval _ _ _ _ = refl
next-numeral-Proper-refine xs proper (Interval b d o ¬greatest) | GappedEndpoint _ _ _ greatest _ = contradiction greatest ¬greatest
next-numeral-Proper-refine xs proper (Interval b d o ¬greatest) | UngappedEndpoint _ _ _ greatest _ = contradiction greatest ¬greatest
next-numeral-Proper-refine xs proper (GappedEndpoint b d o greatest gapped) with nextView xs proper
next-numeral-Proper-refine xs proper (GappedEndpoint b d o greatest gapped) | Interval _ _ _ ¬greatest = contradiction greatest ¬greatest
next-numeral-Proper-refine xs proper (GappedEndpoint b d o greatest gapped) | GappedEndpoint _ _ _ _ _ = refl
next-numeral-Proper-refine xs proper (GappedEndpoint b d o greatest gapped) | UngappedEndpoint _ _ _ _ ¬gapped = contradiction gapped ¬gapped
next-numeral-Proper-refine xs proper (UngappedEndpoint b d o greatest ¬gapped) with nextView xs proper
next-numeral-Proper-refine xs proper (UngappedEndpoint b d o greatest ¬gapped) | Interval _ _ _ ¬greatest = contradiction greatest ¬greatest
next-numeral-Proper-refine xs proper (UngappedEndpoint b d o greatest ¬gapped) | GappedEndpoint _ _ _ _ gapped = contradiction gapped ¬gapped
next-numeral-Proper-refine xs proper (UngappedEndpoint b d o greatest ¬gapped) | UngappedEndpoint _ _ _ _ _ = refl
--------------------------------------------------------------------------------
-- next-numeral-is-immediate-Proper
--------------------------------------------------------------------------------
next-numeral-is-immediate-Proper : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (ys : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ ⟦ ys ⟧ > ⟦ xs ⟧
→ ⟦ ys ⟧ ≥ ⟦ next-numeral-Proper xs proper ⟧
next-numeral-is-immediate-Proper xs ys proper prop with nextView xs proper
next-numeral-is-immediate-Proper xs ys proper prop | Interval b d o ¬greatest =
start
⟦ next-numeral-Proper-Interval xs ¬greatest proper ⟧
≈⟨ next-numeral-Proper-Interval-lemma xs ¬greatest proper ⟩
suc ⟦ xs ⟧
≤⟨ prop ⟩
⟦ ys ⟧
□
next-numeral-is-immediate-Proper xs (y ∙) proper prop | GappedEndpoint b d o greatest gapped
= contradiction prop $ >⇒≰ $
start
suc (Digit-toℕ y o)
≤⟨ s≤s (greatest-of-all o (lsd xs) y greatest) ⟩
suc (Digit-toℕ (lsd xs) o)
≤⟨ s≤s (lsd-toℕ xs) ⟩
suc ⟦ xs ⟧
□
next-numeral-is-immediate-Proper (x ∙) (y ∷ ys) proper prop | GappedEndpoint b d o greatest gapped =
start
o + (Digit-toℕ (carry-digit d o proper) o) * suc b
≈⟨ cong (λ w → o + w * suc b) (carry-digit-toℕ d o proper) ⟩
o + carry o * suc b
≤⟨ n+-mono o (*n-mono (suc b) ys-lower-bound) ⟩
o + ⟦ ys ⟧ * suc b
≤⟨ +n-mono (⟦ ys ⟧ * suc b) (n≤m+n (Fin.toℕ y) o) ⟩
Digit-toℕ y o + ⟦ ys ⟧ * suc b
□
where
≥carry : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ ⟦ xs ⟧ > 0
→ ⟦ xs ⟧ ≥ carry o
≥carry {_} {_} {zero} xs proper prop = prop
≥carry {_} {_} {suc o} (x ∙) proper prop = n≤m+n (Fin.toℕ x) (suc o)
≥carry {b} {_} {suc o} (x ∷ xs) proper prop =
start
suc o
≤⟨ n≤m+n (Fin.toℕ x) (suc o) ⟩
Fin.toℕ x + suc o
≤⟨ m≤m+n (Fin.toℕ x + suc o) (⟦ xs ⟧ * suc b) ⟩
Fin.toℕ x + suc o + ⟦ xs ⟧ * suc b
□
ys-lower-bound : ⟦ ys ⟧ ≥ carry o
ys-lower-bound = ≥carry ys proper (tail-mono-strict-Null x y ys greatest prop)
next-numeral-is-immediate-Proper (x ∷ xs) (y ∷ ys) proper prop | GappedEndpoint b d o greatest gapped =
start
o + ⟦ next-xs ⟧ * suc b
≤⟨ n+-mono o (*n-mono (suc b) ⟦next-xs⟧≤⟦ys⟧) ⟩
o + ⟦ ys ⟧ * suc b
≤⟨ +n-mono (⟦ ys ⟧ * suc b) (n≤m+n (Fin.toℕ y) o) ⟩
Digit-toℕ y o + ⟦ ys ⟧ * suc b
□
where
next-xs : Numeral (suc b) (suc d) o
next-xs = next-numeral-Proper xs proper
⟦xs⟧<⟦ys⟧ : ⟦ xs ⟧ < ⟦ ys ⟧
⟦xs⟧<⟦ys⟧ = tail-mono-strict x xs y ys greatest prop
⟦next-xs⟧≤⟦ys⟧ : ⟦ next-xs ⟧ ≤ ⟦ ys ⟧
⟦next-xs⟧≤⟦ys⟧ = next-numeral-is-immediate-Proper xs ys proper ⟦xs⟧<⟦ys⟧
next-numeral-is-immediate-Proper xs ys proper prop | UngappedEndpoint b d o greatest ¬gapped =
start
⟦ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped ⟧
≈⟨ next-numeral-Proper-UngappedEndpoint-lemma xs greatest proper ¬gapped ⟩
suc ⟦ xs ⟧
≤⟨ prop ⟩
⟦ ys ⟧
□
--------------------------------------------------------------------------------
-- next-numeral
--------------------------------------------------------------------------------
next-numeral : ∀ {b d o}
→ (xs : Numeral b d o)
→ ¬ (Maximum xs)
→ Numeral b d o
next-numeral {b} {d} {o} xs ¬max with numView b d o
next-numeral xs ¬max | NullBase d o = next-numeral-NullBase xs ¬max
next-numeral xs ¬max | NoDigits b o = NoDigits-explode xs
next-numeral xs ¬max | AllZeros b = contradiction (Maximum-AllZeros xs) ¬max
next-numeral xs ¬max | Proper b d o proper = next-numeral-Proper xs proper
--------------------------------------------------------------------------------
-- next-numeral-is-greater
--------------------------------------------------------------------------------
next-numeral-is-greater : ∀ {b d o}
→ (xs : Numeral b d o)
→ (¬max : ¬ (Maximum xs))
→ ⟦ next-numeral xs ¬max ⟧ > ⟦ xs ⟧
next-numeral-is-greater {b} {d} {o} xs ¬max with numView b d o
next-numeral-is-greater xs ¬max | NullBase d o = next-numeral-is-greater-NullBase xs ¬max
next-numeral-is-greater xs ¬max | NoDigits b o = NoDigits-explode xs
next-numeral-is-greater xs ¬max | AllZeros b = contradiction (Maximum-AllZeros xs) ¬max
next-numeral-is-greater xs ¬max | Proper b d o proper = next-numeral-is-greater-Proper xs proper
--------------------------------------------------------------------------------
-- next-numeral-is-immediate
--------------------------------------------------------------------------------
next-numeral-is-immediate : ∀ {b d o}
→ (xs : Numeral b d o)
→ (ys : Numeral b d o)
→ (¬max : ¬ (Maximum xs))
→ ⟦ ys ⟧ > ⟦ xs ⟧
→ ⟦ ys ⟧ ≥ ⟦ next-numeral xs ¬max ⟧
next-numeral-is-immediate {b} {d} {o} xs ys ¬max prop with numView b d o
next-numeral-is-immediate xs ys ¬max prop | NullBase d o = next-numeral-is-immediate-NullBase xs ys ¬max prop
next-numeral-is-immediate xs ys ¬max prop | NoDigits b o = NoDigits-explode xs
next-numeral-is-immediate xs ys ¬max prop | AllZeros b = contradiction (Maximum-AllZeros xs) ¬max
next-numeral-is-immediate xs ys ¬max prop | Proper b d o proper = next-numeral-is-immediate-Proper xs ys proper prop
--------------------------------------------------------------------------------
-- properties of the gaps
--------------------------------------------------------------------------------
Gapped#N⇒Gapped#0 : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ Gapped#N b d o xs proper
→ Gapped#0 b d o
Gapped#N⇒Gapped#0 xs proper gapped#N with nextView xs proper
Gapped#N⇒Gapped#0 xs proper gapped#N | Interval b d o ¬greatest =
start
suc (suc d)
≤⟨ gapped#N ⟩
(⟦ next-numeral-Proper-Interval xs ¬greatest proper ⟧ ∸ ⟦ xs ⟧) * suc b
≤⟨ *n-mono (suc b) $
start
⟦ next-numeral-Proper-Interval xs ¬greatest proper ⟧ ∸ ⟦ xs ⟧
≈⟨ cong (λ w → w ∸ ⟦ xs ⟧) (next-numeral-Proper-Interval-lemma xs ¬greatest proper) ⟩
suc ⟦ xs ⟧ ∸ ⟦ xs ⟧
≈⟨ m+n∸n≡m (suc zero) ⟦ xs ⟧ ⟩
suc zero
≤⟨ m≤m⊔n 1 o ⟩
suc zero ⊔ o
□
⟩
(suc zero ⊔ o) * suc b
□
Gapped#N⇒Gapped#0 (x ∙) proper gapped#N | GappedEndpoint b d o greatest gapped#0 = gapped#0
Gapped#N⇒Gapped#0 (x ∷ xs) proper _ | GappedEndpoint b d o greatest gapped#N = Gapped#N⇒Gapped#0 xs proper gapped#N
Gapped#N⇒Gapped#0 xs proper gapped#N | UngappedEndpoint b d o greatest ¬gapped =
start
suc (suc d)
≤⟨ gapped#N ⟩
(⟦ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped ⟧ ∸ ⟦ xs ⟧) * suc b
≤⟨ *n-mono (suc b) $
start
⟦ next-numeral-Proper-UngappedEndpoint xs greatest proper ¬gapped ⟧ ∸ ⟦ xs ⟧
≈⟨ cong (λ w → w ∸ ⟦ xs ⟧) (next-numeral-Proper-UngappedEndpoint-lemma xs greatest proper ¬gapped) ⟩
suc ⟦ xs ⟧ ∸ ⟦ xs ⟧
≈⟨ m+n∸n≡m (suc zero) ⟦ xs ⟧ ⟩
suc zero
≤⟨ m≤m⊔n 1 o ⟩
suc zero ⊔ o
□
⟩
(suc zero ⊔ o) * suc b
□
-- ¬Gapped#0⇒¬Gapped#N : ∀ {b d o}
-- → (xs : Numeral (suc b) (suc d) o)
-- → (proper : 2 ≤ suc (d + o))
-- → ¬ (Gapped#0 b d o)
-- → ¬ (Gapped#N b d o xs proper)
-- ¬Gapped#0⇒¬Gapped#N xs proper ¬Gapped#0 = contraposition (Gapped#N⇒Gapped#0 xs proper) ¬Gapped#0
¬Gapped#0⇒¬Gapped : ∀ {b d o}
→ (xs : Numeral (suc b) (suc d) o)
→ (proper : 2 ≤ suc (d + o))
→ ¬ (Gapped#0 b d o)
→ ¬ (Gapped xs proper)
¬Gapped#0⇒¬Gapped (x ∙) proper ¬Gapped#0 = ¬Gapped#0
¬Gapped#0⇒¬Gapped (x ∷ xs) proper ¬Gapped#0 = contraposition
(Gapped#N⇒Gapped#0 xs proper)
¬Gapped#0
| {
"alphanum_fraction": 0.5012573914,
"avg_line_length": 42.3395683453,
"ext": "agda",
"hexsha": "32fd09dc9dfd8024a86370640f037890dedd6fba",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/numeral",
"max_forks_repo_path": "Data/Num/Next.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/numeral",
"max_issues_repo_path": "Data/Num/Next.agda",
"max_line_length": 183,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/numeral",
"max_stars_repo_path": "Data/Num/Next.agda",
"max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z",
"num_tokens": 10273,
"size": 29426
} |
module #14 where
{-
Why do the induction principles for identity types not allow us to construct a
function f : ∏(x:A) ∏(p:x=x) (p = refl[x]) with the defining equation
f(x,refl[x]) :≡ refl[refl[x]] ?
-}
{-
To use induction here we need proof that refl x ≡ p then use refl as a relation to prove
that refl x ≡ p again. It's a circular construction.
-}
open import Relation.Binary.PropositionalEquality
{- Closest I could get this into Agda. Does not compile.
f : {A : Set} → (x : A) → (p : x ≡ x) → p ≡ refl x
f x (refl x) = refl (refl x)
-}
| {
"alphanum_fraction": 0.6346153846,
"avg_line_length": 28.6,
"ext": "agda",
"hexsha": "00e15315c3a7a5299734f91b273693dff94b45ba",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CodaFi/HoTT-Exercises",
"max_forks_repo_path": "Chapter1/#14.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "CodaFi/HoTT-Exercises",
"max_issues_repo_path": "Chapter1/#14.agda",
"max_line_length": 90,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CodaFi/HoTT-Exercises",
"max_stars_repo_path": "Chapter1/#14.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 185,
"size": 572
} |
module Generic.Test where
import Generic.Test.Data
import Generic.Test.DeriveEq
import Generic.Test.Elim
import Generic.Test.Eq
import Generic.Test.Experiment
import Generic.Test.ReadData
import Generic.Test.Reify
| {
"alphanum_fraction": 0.8465116279,
"avg_line_length": 21.5,
"ext": "agda",
"hexsha": "d1efe7c1611fab46d2433f4df4626e57a317e2b0",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z",
"max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "turion/Generic",
"max_forks_repo_path": "src/Generic/Test.agda",
"max_issues_count": 9,
"max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "turion/Generic",
"max_issues_repo_path": "src/Generic/Test.agda",
"max_line_length": 30,
"max_stars_count": 30,
"max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "turion/Generic",
"max_stars_repo_path": "src/Generic/Test.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z",
"num_tokens": 48,
"size": 215
} |
module Pi-.Category where
open import Relation.Binary.PropositionalEquality
open import Categories.Category.Monoidal
open import Categories.Category.Monoidal.Braided
open import Categories.Category.Monoidal.Symmetric
open import Categories.Category.Monoidal.Rigid
open import Categories.Category.Monoidal.CompactClosed
open import Categories.Functor.Bifunctor
open import Categories.Category
open import Categories.Category.Inverse
open import Categories.Category.Product
open import Data.Product
open import Data.Sum
open import Data.Empty
open import Relation.Nullary
open import Base
open import Pi-.Syntax
open import Pi-.Opsem
open import Pi-.Eval
open import Pi-.NoRepeat
open import Pi-.Interp
open import Pi-.Properties
open import Pi-.Invariants
open import Pi-.Examples
Pi- : Category _ _ _
Pi- = record {
Obj = 𝕌
; _⇒_ = _↔_
; _≈_ = λ c₁ c₂ → eval c₁ ∼ eval c₂
; id = id↔
; _∘_ = λ f g → g ⨾ f
; assoc = assoc
; sym-assoc = λ x → sym (assoc x)
; identityˡ = identityˡ _
; identityʳ = identityʳ _
; identity² = λ {(v ⃗) → refl ; (v ⃖) → refl}
; equiv = record { refl = λ a → refl
; sym = λ f~g a → sym (f~g a)
; trans = λ f~g g~h a → trans (f~g a) (g~h a) }
; ∘-resp-≈ = ∘-resp-≈
}
where
identityˡ : ∀ {A B} (c : A ↔ B) (v : Val A B) → eval (c ⨾ id↔) v ≡ eval c v
identityˡ c v rewrite eval≡interp (c ⨾ id↔) v | eval≡interp c v = lem c v
where
lem : ∀ {A B} (c : A ↔ B) (v : Val A B) → interp (c ⨾ id↔) v ≡ interp c v
lem c (x ⃗) with interp c (x ⃗)
... | x₁ ⃗ = refl
... | x₁ ⃖ = refl
lem c (x ⃖) with interp c (x ⃖)
... | x₁ ⃗ = refl
... | x₁ ⃖ = refl
identityʳ : ∀ {A B} (c : A ↔ B) (v : Val A B) → eval (id↔ ⨾ c) v ≡ eval c v
identityʳ c v rewrite eval≡interp (id↔ ⨾ c) v | eval≡interp c v = lem c v
where
lem : ∀ {A B} (c : A ↔ B) (v : Val A B) → interp (id↔ ⨾ c) v ≡ interp c v
lem c (x ⃗) with interp c (x ⃗)
... | x₁ ⃗ = refl
... | x₁ ⃖ = refl
lem c (x ⃖) with interp c (x ⃖)
... | x₁ ⃗ = refl
... | x₁ ⃖ = refl
Pi-Monoidal : Monoidal Pi-
Pi-Monoidal = record {
⊗ = record { F₀ = λ {(A , B) → A +ᵤ B}
; F₁ = λ {(c₁ , c₂) → c₁ ⊕ c₂ }
; identity = λ { (inj₁ v ⃗) → refl
; (inj₂ v ⃗) → refl
; (inj₁ v ⃖) → refl
; (inj₂ v ⃖) → refl}
; homomorphism = homomorphism
; F-resp-≈ = λ {(A , B)} {(C , D)} {(f , g)} {(f' , g')} (f~f' , g~g')
→ F-resp-≈ f f' g g' f~f' g~g'}
; unit = 𝟘
; unitorˡ = record { from = unite₊l
; to = uniti₊l
; iso = record { isoˡ = λ { (inj₂ v ⃗) → refl
; (inj₂ v ⃖) → refl}
; isoʳ = λ { (v ⃗) → refl
; (v ⃖) → refl}}}
; unitorʳ = record { from = unite₊r
; to = uniti₊r
; iso = record { isoˡ = λ { (inj₁ v ⃗) → refl
; (inj₁ v ⃖) → refl}
; isoʳ = λ { (v ⃗) → refl
; (v ⃖) → refl}}}
; associator = record { from = assocr₊
; to = assocl₊
; iso = record { isoˡ = λ { (inj₁ (inj₁ v) ⃗) → refl
; (inj₁ (inj₂ v) ⃗) → refl
; (inj₂ v ⃗) → refl
; (inj₁ (inj₁ v) ⃖) → refl
; (inj₁ (inj₂ v) ⃖) → refl
; (inj₂ v ⃖) → refl}
; isoʳ = λ { (inj₁ v ⃗) → refl
; (inj₂ (inj₁ v) ⃗) → refl
; (inj₂ (inj₂ v) ⃗) → refl
; (inj₁ v ⃖) → refl
; (inj₂ (inj₁ v) ⃖) → refl
; (inj₂ (inj₂ v) ⃖) → refl}}}
; unitorˡ-commute-from = unitorˡ-commute-from _
; unitorˡ-commute-to = unitorˡ-commute-to _
; unitorʳ-commute-from = unitorʳ-commute-from _
; unitorʳ-commute-to = unitorʳ-commute-to _
; assoc-commute-from = assoc-commute-from _ _ _
; assoc-commute-to = assoc-commute-to _ _ _
; triangle = λ { (inj₁ (inj₁ v) ⃗) → refl
; (inj₂ v ⃗) → refl
; (inj₁ v ⃖) → refl
; (inj₂ v ⃖) → refl}
; pentagon = λ { (inj₁ (inj₁ (inj₁ v)) ⃗) → refl
; (inj₁ (inj₁ (inj₂ v)) ⃗) → refl
; (inj₁ (inj₂ v) ⃗) → refl
; (inj₂ v ⃗) → refl
; (inj₁ v ⃖) → refl
; (inj₂ (inj₁ v) ⃖) → refl
; (inj₂ (inj₂ (inj₁ v)) ⃖) → refl
; (inj₂ (inj₂ (inj₂ v)) ⃖) → refl}
}
where
F-resp-≈ : ∀ {A B C D} (f f' : A ↔ B) (g g' : C ↔ D) → (eval f ∼ eval f') → (eval g ∼ eval g')
→ (eval (f ⊕ g) ∼ eval (f' ⊕ g'))
F-resp-≈ f f' g g' f~f' g~g' x rewrite eval≡interp (f ⊕ g) x | eval≡interp (f' ⊕ g') x =
lem f f' g g' (λ x → trans (sym (eval≡interp f x)) (trans (f~f' x) (eval≡interp f' x)))
(λ x → trans (sym (eval≡interp g x)) (trans (g~g' x) (eval≡interp g' x))) x
where
lem : ∀ {A B C D} (f f' : A ↔ B) (g g' : C ↔ D) → (interp f ∼ interp f') → (interp g ∼ interp g')
→ (interp (f ⊕ g) ∼ interp (f' ⊕ g'))
lem f f' g g' f~f' g~g' (inj₁ x ⃗) with f~f' (x ⃗) | interp f' (x ⃗) | inspect (interp f') (x ⃗)
... | eq | x' ⃗ | [ eq' ] rewrite eq | eq' = refl
... | eq | x' ⃖ | [ eq' ] rewrite eq | eq' = refl
lem f f' g g' f~f' g~g' (inj₂ y ⃗) with g~g' (y ⃗) | interp g' (y ⃗) | inspect (interp g') (y ⃗)
... | eq | y' ⃗ | [ eq' ] rewrite eq | eq' = refl
... | eq | y' ⃖ | [ eq' ] rewrite eq | eq' = refl
lem f f' g g' f~f' g~g' (inj₁ x ⃖) with f~f' (x ⃖) | interp f' (x ⃖) | inspect (interp f') (x ⃖)
... | eq | x' ⃗ | [ eq' ] rewrite eq | eq' = refl
... | eq | x' ⃖ | [ eq' ] rewrite eq | eq' = refl
lem f f' g g' f~f' g~g' (inj₂ y ⃖) with g~g' (y ⃖) | interp g' (y ⃖) | inspect (interp g') (y ⃖)
... | eq | y' ⃗ | [ eq' ] rewrite eq | eq' = refl
... | eq | y' ⃖ | [ eq' ] rewrite eq | eq' = refl
unitorˡ-commute-from : ∀ {A B} (f : A ↔ B) (x : _) → eval ((id↔ ⊕ f) ⨾ unite₊l) x ≡ eval (unite₊l ⨾ f) x
unitorˡ-commute-from f x rewrite eval≡interp ((id↔ ⊕ f) ⨾ unite₊l) x | eval≡interp (unite₊l ⨾ f) x = lem f x
where
lem : ∀ {A B} (f : A ↔ B) (x : _) → interp ((id↔ ⊕ f) ⨾ unite₊l) x ≡ interp (unite₊l ⨾ f) x
lem f (inj₂ y ⃗) with interp f (y ⃗)
... | x ⃗ = refl
... | x ⃖ = refl
lem f (x ⃖) with interp f (x ⃖)
... | x₁ ⃗ = refl
... | x₁ ⃖ = refl
unitorˡ-commute-to : ∀ {A B} (f : A ↔ B) (x : _) → eval (f ⨾ uniti₊l) x ≡ eval (uniti₊l ⨾ (id↔ ⊕ f)) x
unitorˡ-commute-to f x rewrite eval≡interp (f ⨾ uniti₊l) x | eval≡interp (uniti₊l ⨾ (id↔ ⊕ f)) x = lem f x
where
lem : ∀ {A B} (f : A ↔ B) (x : _) → interp (f ⨾ uniti₊l) x ≡ interp (uniti₊l ⨾ (id↔ ⊕ f)) x
lem f (x ⃗) with interp f (x ⃗)
... | x₁ ⃗ = refl
... | x₁ ⃖ = refl
lem f (inj₂ y ⃖) with interp f (y ⃖)
... | x ⃗ = refl
... | x ⃖ = refl
unitorʳ-commute-from : ∀ {A B} (f : A ↔ B) (x : _) → eval ((f ⊕ id↔) ⨾ swap₊ ⨾ unite₊l) x ≡ eval ((swap₊ ⨾ unite₊l) ⨾ f) x
unitorʳ-commute-from f x rewrite eval≡interp ((f ⊕ id↔) ⨾ swap₊ ⨾ unite₊l) x | eval≡interp ((swap₊ ⨾ unite₊l) ⨾ f) x = lem f x
where
lem : ∀ {A B} (f : A ↔ B) (x : _) → interp ((f ⊕ id↔) ⨾ swap₊ ⨾ unite₊l) x ≡ interp ((swap₊ ⨾ unite₊l) ⨾ f) x
lem f (inj₁ x ⃗) with interp f (x ⃗)
... | x₁ ⃗ = refl
... | x₁ ⃖ = refl
lem f (x ⃖) with interp f (x ⃖)
... | x₁ ⃗ = refl
... | x₁ ⃖ = refl
unitorʳ-commute-to : ∀ {A B} (f : A ↔ B) (x : _) → eval (f ⨾ uniti₊l ⨾ swap₊) x ≡ eval ((uniti₊l ⨾ swap₊) ⨾ (f ⊕ id↔)) x
unitorʳ-commute-to f x rewrite eval≡interp (f ⨾ uniti₊l ⨾ swap₊) x | eval≡interp ((uniti₊l ⨾ swap₊) ⨾ (f ⊕ id↔)) x = lem f x
where
lem : ∀ {A B} (f : A ↔ B) (x : _) → interp (f ⨾ uniti₊l ⨾ swap₊) x ≡ interp ((uniti₊l ⨾ swap₊) ⨾ (f ⊕ id↔)) x
lem f (x ⃗) with interp f (x ⃗)
... | x₁ ⃗ = refl
... | x₁ ⃖ = refl
lem f (inj₁ x ⃖) with interp f (x ⃖)
... | x₁ ⃗ = refl
... | x₁ ⃖ = refl
assoc-commute-from : ∀ {A B C D E F} (f : A ↔ B) (g : C ↔ D) (h : E ↔ F) (x : _) → eval (((f ⊕ g) ⊕ h) ⨾ assocr₊) x ≡ eval (assocr₊ ⨾ (f ⊕ (g ⊕ h))) x
assoc-commute-from f g h x rewrite eval≡interp (((f ⊕ g) ⊕ h) ⨾ assocr₊) x | eval≡interp (assocr₊ ⨾ (f ⊕ (g ⊕ h))) x = lem f g h x
where
lem : ∀ {A B C D E F} (f : A ↔ B) (g : C ↔ D) (h : E ↔ F) (x : _) → interp (((f ⊕ g) ⊕ h) ⨾ assocr₊) x ≡ interp (assocr₊ ⨾ (f ⊕ (g ⊕ h))) x
lem f g h (inj₁ (inj₁ x) ⃗) with interp f (x ⃗)
... | x' ⃗ = refl
... | x' ⃖ = refl
lem f g h (inj₁ (inj₂ y) ⃗) with interp g (y ⃗)
... | y' ⃗ = refl
... | y' ⃖ = refl
lem f g h (inj₂ z ⃗) with interp h (z ⃗)
... | z' ⃗ = refl
... | z' ⃖ = refl
lem f g h (inj₁ x ⃖) with interp f (x ⃖)
... | x' ⃗ = refl
... | x' ⃖ = refl
lem f g h (inj₂ (inj₁ y) ⃖) with interp g (y ⃖)
... | y' ⃗ = refl
... | y' ⃖ = refl
lem f g h (inj₂ (inj₂ z) ⃖) with interp h (z ⃖)
... | z' ⃗ = refl
... | z' ⃖ = refl
assoc-commute-to : ∀ {A B C D E F} (f : A ↔ B) (g : C ↔ D) (h : E ↔ F) (x : _) → eval ((f ⊕ (g ⊕ h)) ⨾ assocl₊) x ≡ eval (assocl₊ ⨾ ((f ⊕ g) ⊕ h)) x
assoc-commute-to f g h x rewrite eval≡interp ((f ⊕ (g ⊕ h)) ⨾ assocl₊) x | eval≡interp (assocl₊ ⨾ ((f ⊕ g) ⊕ h)) x = lem f g h x
where
lem : ∀ {A B C D E F} (f : A ↔ B) (g : C ↔ D) (h : E ↔ F) (x : _) → interp ((f ⊕ (g ⊕ h)) ⨾ assocl₊) x ≡ interp (assocl₊ ⨾ ((f ⊕ g) ⊕ h)) x
lem f g h (inj₁ x ⃗) with interp f (x ⃗)
... | x' ⃗ = refl
... | x' ⃖ = refl
lem f g h (inj₂ (inj₁ y) ⃗) with interp g (y ⃗)
... | y' ⃗ = refl
... | y' ⃖ = refl
lem f g h (inj₂ (inj₂ z) ⃗) with interp h (z ⃗)
... | z' ⃗ = refl
... | z' ⃖ = refl
lem f g h (inj₁ (inj₁ x) ⃖) with interp f (x ⃖)
... | x' ⃗ = refl
... | x' ⃖ = refl
lem f g h (inj₁ (inj₂ y) ⃖) with interp g (y ⃖)
... | y' ⃗ = refl
... | y' ⃖ = refl
lem f g h (inj₂ z ⃖) with interp h (z ⃖)
... | z' ⃗ = refl
... | z' ⃖ = refl
Pi-Braided : Braided Pi-Monoidal
Pi-Braided = record { braiding = record { F⇒G = record { η = λ _ → swap₊
; commute = λ {(f , g) x → commute f g x}
; sym-commute = λ {(f , g) x → sym (commute f g x)}}
; F⇐G = record { η = λ _ → swap₊
; commute = λ { (f , g) x → commute g f x}
; sym-commute = λ {(f , g) x → sym (commute g f x)}}
; iso = λ _ → record { isoˡ = λ { (inj₁ v ⃗) → refl
; (inj₂ v ⃗) → refl
; (inj₁ v ⃖) → refl
; (inj₂ v ⃖) → refl}
; isoʳ = λ { (inj₁ v ⃗) → refl
; (inj₂ v ⃗) → refl
; (inj₁ v ⃖) → refl
; (inj₂ v ⃖) → refl} } }
; hexagon₁ = λ { (inj₁ (inj₁ v) ⃗) → refl
; (inj₁ (inj₂ v) ⃗) → refl
; (inj₂ v ⃗) → refl
; (inj₁ v ⃖) → refl
; (inj₂ (inj₁ v) ⃖) → refl
; (inj₂ (inj₂ v) ⃖) → refl}
; hexagon₂ = λ { (inj₁ (inj₁ v) ⃖) → refl
; (inj₁ (inj₂ v) ⃖) → refl
; (inj₂ v ⃖) → refl
; (inj₁ v ⃗) → refl
; (inj₂ (inj₁ v) ⃗) → refl
; (inj₂ (inj₂ v) ⃗) → refl}}
where
commute : ∀ {A B C D} (f : A ↔ C) (g : B ↔ D) (x : _)
→ eval ((f ⊕ g) ⨾ swap₊) x ≡ eval (swap₊ ⨾ (g ⊕ f)) x
commute f g x rewrite eval≡interp ((f ⊕ g) ⨾ swap₊) x | eval≡interp (swap₊ ⨾ (g ⊕ f)) x = lem f g x
where
lem : ∀ {A B C D} (f : A ↔ C) (g : B ↔ D) (x : _)
→ interp ((f ⊕ g) ⨾ swap₊) x ≡ interp (swap₊ ⨾ (g ⊕ f)) x
lem f g (inj₁ x ⃗) with interp f (x ⃗)
... | _ ⃗ = refl
... | _ ⃖ = refl
lem f g (inj₂ y ⃗) with interp g (y ⃗)
... | _ ⃗ = refl
... | _ ⃖ = refl
lem f g (inj₁ y ⃖) with interp g (y ⃖)
... | _ ⃗ = refl
... | _ ⃖ = refl
lem f g (inj₂ x ⃖) with interp f (x ⃖)
... | _ ⃗ = refl
... | _ ⃖ = refl
Pi-Symmetric : Symmetric Pi-Monoidal
Pi-Symmetric = record { braided = Pi-Braided
; commutative = λ { (inj₁ v ⃗) → refl
; (inj₂ v ⃗) → refl
; (inj₁ v ⃖) → refl
; (inj₂ v ⃖) → refl}}
Pi-Rigid : LeftRigid Pi-Monoidal
Pi-Rigid = record { _⁻¹ = -_
; η = η₊
; ε = swap₊ ⨾ ε₊
; snake₁ = λ { (v ⃗) → refl
; (v ⃖) → refl}
; snake₂ = λ { ((- v) ⃗) → refl
; ((- v) ⃖) → refl}}
Pi-CompactClosed : CompactClosed Pi-Monoidal
Pi-CompactClosed = record { symmetric = Pi-Symmetric
; rigid = inj₁ Pi-Rigid}
¬Pi-Inverse : ¬(Inverse Pi-)
¬Pi-Inverse record { _⁻¹ = _⁻¹ } with (ε₊ {𝟙} ⊕ id↔ {𝟙}) ⁻¹
... | c , (_ , _) , uniq = contr
where
c₁ c₂ : 𝟘 +ᵤ 𝟙 ↔ (𝟙 +ᵤ - 𝟙) +ᵤ 𝟙
c₁ = η₊ ⊕ id↔
c₂ = (η₊ ⊕ id↔) ⨾ swap₊ ⨾ (id↔ ⊕ swap₊) ⨾ assocl₊
c₁pinv : (eval (((ε₊ {𝟙} ⊕ id↔) ⨾ c₁) ⨾ (ε₊ ⊕ id↔)) ∼ eval (ε₊ ⊕ id↔))
× (eval ((c₁ ⨾ (ε₊ ⊕ id↔)) ⨾ c₁) ∼ eval c₁)
c₁pinv = p₁ , p₂
where
p₁ : eval (((ε₊ {𝟙} ⊕ id↔) ⨾ c₁) ⨾ (ε₊ ⊕ id↔)) ∼ eval (ε₊ ⊕ id↔)
p₁ (inj₁ (inj₁ tt) ⃗) = refl
p₁ (inj₁ (inj₂ (- tt)) ⃗) = refl
p₁ (inj₂ tt ⃗) = refl
p₁ (inj₂ tt ⃖) = refl
p₂ : eval ((c₁ ⨾ (ε₊ ⊕ id↔)) ⨾ c₁) ∼ eval c₁
p₂ (inj₂ tt ⃗) = refl
p₂ (inj₁ (inj₁ tt) ⃖) = refl
p₂ (inj₁ (inj₂ (- tt)) ⃖) = refl
p₂ (inj₂ tt ⃖) = refl
c₂pinv : (eval (((ε₊ {𝟙} ⊕ id↔) ⨾ c₂) ⨾ (ε₊ ⊕ id↔)) ∼ eval (ε₊ ⊕ id↔))
× (eval ((c₂ ⨾ (ε₊ ⊕ id↔)) ⨾ c₂) ∼ eval c₂)
c₂pinv = p₁ , p₂
where
p₁ : eval (((ε₊ {𝟙} ⊕ id↔) ⨾ c₂) ⨾ (ε₊ ⊕ id↔)) ∼ eval (ε₊ ⊕ id↔)
p₁ (inj₁ (inj₁ tt) ⃗) = refl
p₁ (inj₁ (inj₂ (- tt)) ⃗) = refl
p₁ (inj₂ tt ⃗) = refl
p₁ (inj₂ tt ⃖) = refl
p₂ : eval ((c₂ ⨾ (ε₊ ⊕ id↔)) ⨾ c₂) ∼ eval c₂
p₂ (inj₂ tt ⃗) = refl
p₂ (inj₁ (inj₁ tt) ⃖) = refl
p₂ (inj₁ (inj₂ (- tt)) ⃖) = refl
p₂ (inj₂ tt ⃖) = refl
c∼c₁ : eval c ∼ eval c₁
c∼c₁ = uniq c₁pinv
c∼c₂ : eval c ∼ eval c₂
c∼c₂ = uniq c₂pinv
contr : ⊥
contr with trans (sym (c∼c₁ (inj₂ _ ⃗))) (c∼c₂ (inj₂ _ ⃗))
... | ()
IHom : ∀ {A B C} → C ↔ (- A +ᵤ B) → (C +ᵤ A) ↔ B
IHom f = (f ⊕ id↔) ⨾ [A+B]+C=[A+C]+B ⨾ (swap₊ ⊕ id↔) ⨾ (ε₊ ⊕ id↔) ⨾ unite₊l
IHom' : ∀ {A B C} → C +ᵤ A ↔ B → C ↔ - A +ᵤ B
IHom' f = uniti₊l ⨾ (η₊ ⊕ id↔) ⨾ (swap₊ ⊕ id↔) ⨾ (assocr₊ ⨾ id↔ ⊕ swap₊) ⨾ id↔ ⊕ f
IHom'∘IHom : ∀ {A B C} → (f : C ↔ (- A +ᵤ B)) → interp f ∼ interp (IHom' (IHom f))
IHom'∘IHom f (c ⃗) with interp f (c ⃗)
IHom'∘IHom f (c ⃗) | inj₁ (- a) ⃗ = refl
IHom'∘IHom f (c ⃗) | inj₂ b ⃗ = refl
IHom'∘IHom f (c ⃗) | (c' ⃖) = refl
IHom'∘IHom f (inj₁ (- a) ⃖) with interp f (inj₁ (- a) ⃖)
IHom'∘IHom f (inj₁ (- a) ⃖) | inj₁ (- a') ⃗ = refl
IHom'∘IHom f (inj₁ (- a) ⃖) | inj₂ b ⃗ = refl
IHom'∘IHom f (inj₁ (- a) ⃖) | c ⃖ = refl
IHom'∘IHom f (inj₂ b ⃖) with interp f (inj₂ b ⃖)
IHom'∘IHom f (inj₂ b ⃖) | inj₁ (- a) ⃗ = refl
IHom'∘IHom f (inj₂ b ⃖) | inj₂ b' ⃗ = refl
IHom'∘IHom f (inj₂ b ⃖) | c ⃖ = refl
IHom∘IHom' : ∀ {A B C} → (f : (C +ᵤ A) ↔ B) → interp f ∼ interp (IHom (IHom' f))
IHom∘IHom' f (inj₁ c ⃗) with interp f (inj₁ c ⃗)
IHom∘IHom' f (inj₁ c ⃗) | b ⃗ = refl
IHom∘IHom' f (inj₁ c ⃗) | inj₁ c' ⃖ = refl
IHom∘IHom' f (inj₁ c ⃗) | inj₂ a ⃖ = refl
IHom∘IHom' f (inj₂ a ⃗) with interp f (inj₂ a ⃗)
IHom∘IHom' f (inj₂ a ⃗) | b ⃗ = refl
IHom∘IHom' f (inj₂ a ⃗) | inj₁ c ⃖ = refl
IHom∘IHom' f (inj₂ a ⃗) | inj₂ a' ⃖ = refl
IHom∘IHom' f (b ⃖) with interp f (b ⃖)
IHom∘IHom' f (b ⃖) | b' ⃗ = refl
IHom∘IHom' f (b ⃖) | inj₁ c ⃖ = refl
IHom∘IHom' f (b ⃖) | inj₂ a ⃖ = refl
Ev : ∀ {A B} → (- A +ᵤ B) +ᵤ A ↔ B
Ev = [A+B]+C=[A+C]+B ⨾ ((swap₊ ⨾ ε₊) ⊕ id↔) ⨾ unite₊l
hof : ∀ {A B} → (𝟘 ↔ (- A +ᵤ B)) → (A ↔ B)
hof f = uniti₊l ⨾ (f ⊕ id↔) ⨾ [A+B]+C=[A+C]+B ⨾ (swap₊ ⨾ ε₊) ⊕ id↔ ⨾ unite₊l
hof' : ∀ {A B} → (A ↔ B) → (𝟘 ↔ (- A +ᵤ B))
hof' f = η₊ ⨾ (f ⊕ id↔) ⨾ swap₊
hof'∘hof : ∀ {A B} → (f : 𝟘 ↔ (- A +ᵤ B)) → interp f ∼ interp (hof' (hof f))
hof'∘hof f (inj₁ (- a) ⃖) with interp f (inj₁ (- a) ⃖)
hof'∘hof f (inj₁ (- a) ⃖) | inj₁ (- a') ⃗ = refl
hof'∘hof f (inj₁ (- a) ⃖) | inj₂ b ⃗ = refl
hof'∘hof f (inj₂ b ⃖) with interp f (inj₂ b ⃖)
hof'∘hof f (inj₂ b ⃖) | inj₁ (- a) ⃗ = refl
hof'∘hof f (inj₂ b ⃖) | inj₂ b' ⃗ = refl
hof∘hof' : ∀ {A B} → (f : A ↔ B) → interp f ∼ interp (hof (hof' f))
hof∘hof' f (a ⃗) with interp f (a ⃗)
hof∘hof' f (a ⃗) | b ⃗ = refl
hof∘hof' f (a ⃗) | a' ⃖ = refl
hof∘hof' f (b ⃖) with interp f (b ⃖)
hof∘hof' f (b ⃖) | b' ⃗ = refl
hof∘hof' f (b ⃖) | a ⃖ = refl
| {
"alphanum_fraction": 0.3881241565,
"avg_line_length": 45.0729927007,
"ext": "agda",
"hexsha": "2c41c4fbf624b192cf69583c34ed6de2b4ca1b42",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "Pi-/Category.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "Pi-/Category.agda",
"max_line_length": 152,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "Pi-/Category.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 8057,
"size": 18525
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Groups.Definition
open import Rings.Definition
open import Rings.IntegralDomains.Definition
open import Setoids.Setoids
open import Sets.EquivalenceRelations
module Fields.FieldOfFractions.Group {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} {_*_ : A → A → A} {R : Ring S _+_ _*_} (I : IntegralDomain R) where
open import Fields.FieldOfFractions.Setoid I
open import Fields.FieldOfFractions.Addition I
fieldOfFractionsGroup : Group fieldOfFractionsSetoid fieldOfFractionsPlus
Group.+WellDefined fieldOfFractionsGroup {record { num = a ; denom = b ; denomNonzero = b!=0 }} {record { num = c ; denom = d ; denomNonzero = d!=0 }} {record { num = e ; denom = f ; denomNonzero = f!=0 }} {record { num = g ; denom = h ; denomNonzero = h!=0 }} af=be ch=dg = need
where
open Setoid S
open Ring R
open Equivalence eq
have1 : (c * h) ∼ (d * g)
have1 = ch=dg
have2 : (a * f) ∼ (b * e)
have2 = af=be
need : (((a * d) + (b * c)) * (f * h)) ∼ ((b * d) * (((e * h) + (f * g))))
need = transitive (transitive (Ring.*Commutative R) (transitive (Ring.*DistributesOver+ R) (Group.+WellDefined (Ring.additiveGroup R) (transitive *Associative (transitive (*WellDefined (*Commutative) reflexive) (transitive (*WellDefined *Associative reflexive) (transitive (*WellDefined (*WellDefined have2 reflexive) reflexive) (transitive (symmetric *Associative) (transitive (*WellDefined reflexive *Commutative) (transitive *Associative (transitive (*WellDefined (transitive (transitive (symmetric *Associative) (*WellDefined reflexive *Commutative)) *Associative) reflexive) (symmetric *Associative))))))))) (transitive *Commutative (transitive (transitive (symmetric *Associative) (*WellDefined reflexive (transitive (*WellDefined reflexive *Commutative) (transitive *Associative (transitive (*WellDefined have1 reflexive) (transitive (symmetric *Associative) (*WellDefined reflexive *Commutative))))))) *Associative))))) (symmetric (Ring.*DistributesOver+ R))
Group.0G fieldOfFractionsGroup = record { num = Ring.0R R ; denom = Ring.1R R ; denomNonzero = IntegralDomain.nontrivial I }
Group.inverse fieldOfFractionsGroup record { num = a ; denom = b ; denomNonzero = p } = record { num = Group.inverse (Ring.additiveGroup R) a ; denom = b ; denomNonzero = p }
Group.+Associative fieldOfFractionsGroup {record { num = a ; denom = b ; denomNonzero = b!=0 }} {record { num = c ; denom = d ; denomNonzero = d!=0 }} {record { num = e ; denom = f ; denomNonzero = f!=0 }} = need
where
open Setoid S
open Equivalence eq
need : (((a * (d * f)) + (b * ((c * f) + (d * e)))) * ((b * d) * f)) ∼ ((b * (d * f)) * ((((a * d) + (b * c)) * f) + ((b * d) * e)))
need = transitive (Ring.*Commutative R) (Ring.*WellDefined R (symmetric (Ring.*Associative R)) (transitive (Group.+WellDefined (Ring.additiveGroup R) reflexive (Ring.*DistributesOver+ R)) (transitive (Group.+WellDefined (Ring.additiveGroup R) reflexive (Group.+WellDefined (Ring.additiveGroup R) (Ring.*Associative R) (Ring.*Associative R))) (transitive (Group.+Associative (Ring.additiveGroup R)) (Group.+WellDefined (Ring.additiveGroup R) (transitive (transitive (Group.+WellDefined (Ring.additiveGroup R) (transitive (Ring.*Associative R) (Ring.*Commutative R)) (Ring.*Commutative R)) (symmetric (Ring.*DistributesOver+ R))) (Ring.*Commutative R)) reflexive)))))
Group.identRight fieldOfFractionsGroup {record { num = a ; denom = b ; denomNonzero = b!=0 }} = need
where
open Setoid S
open Equivalence eq
need : (((a * Ring.1R R) + (b * Group.0G (Ring.additiveGroup R))) * b) ∼ ((b * Ring.1R R) * a)
need = transitive (transitive (Ring.*WellDefined R (transitive (Group.+WellDefined (Ring.additiveGroup R) (transitive (Ring.*Commutative R) (Ring.identIsIdent R)) reflexive) (transitive (Group.+WellDefined (Ring.additiveGroup R) reflexive (Ring.timesZero R)) (Group.identRight (Ring.additiveGroup R)))) reflexive) (Ring.*Commutative R)) (symmetric (Ring.*WellDefined R (transitive (Ring.*Commutative R) (Ring.identIsIdent R)) reflexive))
Group.identLeft fieldOfFractionsGroup {record { num = a ; denom = b }} = need
where
open Setoid S
open Equivalence eq
need : (((Group.0G (Ring.additiveGroup R) * b) + (Ring.1R R * a)) * b) ∼ ((Ring.1R R * b) * a)
need = transitive (transitive (Ring.*WellDefined R (transitive (Group.+WellDefined (Ring.additiveGroup R) reflexive (Ring.identIsIdent R)) (transitive (Group.+WellDefined (Ring.additiveGroup R) (transitive (Ring.*Commutative R) (Ring.timesZero R)) reflexive) (Group.identLeft (Ring.additiveGroup R)))) reflexive) (Ring.*Commutative R)) (Ring.*WellDefined R (symmetric (Ring.identIsIdent R)) reflexive)
Group.invLeft fieldOfFractionsGroup {record { num = a ; denom = b }} = need
where
open Setoid S
open Equivalence eq
need : (((Group.inverse (Ring.additiveGroup R) a * b) + (b * a)) * Ring.1R R) ∼ ((b * b) * Group.0G (Ring.additiveGroup R))
need = transitive (transitive (transitive (Ring.*Commutative R) (Ring.identIsIdent R)) (transitive (Group.+WellDefined (Ring.additiveGroup R) (Ring.*Commutative R) reflexive) (transitive (symmetric (Ring.*DistributesOver+ R)) (transitive (Ring.*WellDefined R reflexive (Group.invLeft (Ring.additiveGroup R))) (Ring.timesZero R))))) (symmetric (Ring.timesZero R))
Group.invRight fieldOfFractionsGroup {record { num = a ; denom = b }} = need
where
open Setoid S
open Equivalence eq
need : (((a * b) + (b * Group.inverse (Ring.additiveGroup R) a)) * Ring.1R R) ∼ ((b * b) * Group.0G (Ring.additiveGroup R))
need = transitive (transitive (transitive (Ring.*Commutative R) (Ring.identIsIdent R)) (transitive (Group.+WellDefined (Ring.additiveGroup R) (Ring.*Commutative R) reflexive) (transitive (symmetric (Ring.*DistributesOver+ R)) (transitive (Ring.*WellDefined R reflexive (Group.invRight (Ring.additiveGroup R))) (Ring.timesZero R))))) (symmetric (Ring.timesZero R))
| {
"alphanum_fraction": 0.6965769359,
"avg_line_length": 102,
"ext": "agda",
"hexsha": "5d755fc182d677fbcd12b8f1e02c5a65aba640fa",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Fields/FieldOfFractions/Group.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Fields/FieldOfFractions/Group.agda",
"max_line_length": 970,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Fields/FieldOfFractions/Group.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 1853,
"size": 6018
} |
open import Data.Empty using (⊥-elim)
open import Data.Fin using (Fin; _≟_)
open import Data.Nat using (suc; zero)
open import Data.Nat.Properties using (suc-injective; 0≢1+n)
open import Data.Product using (∃-syntax; _×_; _,_; proj₁; proj₂)
open import Data.Sum using (inj₁; inj₂)
open import Data.Vec using (lookup; _[_]≔_)
open import Data.Vec.Properties using (lookup∘update; lookup∘update′)
open import Relation.Binary.PropositionalEquality using (refl; sym; cong; trans; _≡_; _≢_; module ≡-Reasoning)
open import Relation.Nullary using (yes; no)
open ≡-Reasoning
open import Common
open import Global
open import Local
open import Projection
completeness :
∀{ n } { act : Action n } { c c′ g g-size }
-> { g-size-is-size-g : g-size ≡ size-g g }
-> g ↔ c
-> c - act →c c′
-> ∃[ g′ ] g - act →g g′ × g′ ↔ c′
completeness assoc (→c-comm c p≢q lp≡c[p] lq≡c[q] c→c′ (→l-send p _ _) (→l-send .p _ _))
= ⊥-elim (p≢q refl)
completeness assoc (→c-comm c p≢q lp≡c[p] lq≡c[q] c→c′ (→l-recv p _ _) (→l-send .p _ _))
= ⊥-elim (p≢q refl)
completeness assoc (→c-comm c p≢q lp≡c[p] lq≡c[q] c→c′ (→l-recv p _ _) (→l-recv .p _ _))
= ⊥-elim (p≢q refl)
completeness
{n}
{act}
{c′ = c′}
{g = g}
{g-size = g-size}
{g-size-is-size-g = g-size-is-size-g}
assoc
(→c-comm {p} {q} {l} c p≢q lp≡c[p] lq≡c[q] refl
lpReduce@(→l-send {lp = lp} {lpSub = lp′} .p refl p≢q-p)
lqReduce@(→l-recv {lp = lq} {lpSub = lq′} .q refl p≢q-q)
)
with proj-inv-send-recv {g = g}
(trans (sym (_↔_.isProj assoc p)) (sym lp≡c[p]))
(trans (sym (_↔_.isProj assoc q)) (sym lq≡c[q]))
... | inj₁ (p≢q , g′ , refl , refl , refl)
= g′ , →g-prefix , record { isProj = isProj-g′ }
where
isProj-g′ : (r : Fin n) -> lookup c′ r ≡ project g′ r
isProj-g′ r with r ≟ p | r ≟ q
... | yes refl | yes refl = ⊥-elim (p≢q refl)
... | no r≢p | yes refl
rewrite lookup∘update q (c [ p ]≔ lp′) lq′
= refl
... | yes refl | no r≢q
rewrite lookup∘update′ p≢q (c [ p ]≔ lp′) lq′
rewrite lookup∘update p c lp′
= refl
... | no r≢p | no r≢q
rewrite lookup∘update′ r≢q (c [ p ]≔ lp′) lq′
rewrite lookup∘update′ r≢p c lp′
rewrite sym (proj-prefix-other {l = l} p q r {p≢q} g′ (¬≡-flip r≢p) (¬≡-flip r≢q))
rewrite _↔_.isProj assoc r
= refl
... | inj₂ (r , s , r≢s , l′ , gSub , refl , r≢p , s≢p , r≢q , s≢q , gSub-proj-p , gSub-proj-q)
with g-size
... | zero
= ⊥-elim (0≢1+n g-size-is-size-g)
... | suc gSub-size
= g′ , gReduce , record { isProj = isProj-g′ }
where
lrSub = project gSub r
lsSub = project gSub s
remove-prefix-g : ∃[ cSub ] cSub ≡ (c [ r ]≔ lrSub) [ s ]≔ lsSub × gSub ↔ cSub
remove-prefix-g = config-gt-remove-prefix g c assoc refl
completeness-gSub : ∃[ gSub′ ] gSub - act →g gSub′ × gSub′ ↔ ((((c [ r ]≔ lrSub) [ s ]≔ lsSub) [ p ]≔ lp′) [ q ]≔ lq′)
completeness-gSub with remove-prefix-g
... | cSub , refl , gSub↔cSub
= completeness {g = gSub} {g-size = gSub-size} {gSub-size-is-size-gSub} gSub↔cSub cSub→cSub′
where
gSub-size-is-size-gSub : gSub-size ≡ size-g gSub
gSub-size-is-size-gSub = suc-injective g-size-is-size-g
cSub′ = (cSub [ p ]≔ lp′) [ q ]≔ lq′
cSub→cSub′ : cSub - act →c cSub′
cSub→cSub′
with remove-prefix-g
... | cSub , refl , gSub↔cSub = →c-comm cSub p≢q lp≡cSub[p] lq≡cSub[q] refl lpReduce lqReduce
where
lp≡cSub[p] : lp ≡ lookup cSub p
lp≡cSub[p]
rewrite lp≡c[p]
rewrite sym (lookup∘update′ (¬≡-flip r≢p) c lrSub)
rewrite sym (lookup∘update′ (¬≡-flip s≢p) (c [ r ]≔ lrSub) lsSub)
= refl
lq≡cSub[q] : lq ≡ lookup cSub q
lq≡cSub[q]
rewrite lq≡c[q]
rewrite sym (lookup∘update′ (¬≡-flip r≢q) c lrSub)
rewrite sym (lookup∘update′ (¬≡-flip s≢q) (c [ r ]≔ lrSub) lsSub)
= refl
g′ : Global n
g′ with completeness-gSub
... | gSub′ , _ , _ = msgSingle r s r≢s l′ gSub′
gReduce : g - act →g g′
gReduce with completeness-gSub
... | gSub′ , gSubReduce , gSub′↔cSub′
= →g-cont gSubReduce (¬≡-flip r≢p) (¬≡-flip r≢q) (¬≡-flip s≢p) (¬≡-flip s≢q)
isProj-g′ : (t : Fin n) -> lookup c′ t ≡ project g′ t
isProj-g′ t with remove-prefix-g | completeness-gSub
... | cSub , un-c′ , g′↔c′ | gSub′ , gSubReduce , gSub′↔cSub′
with r ≟ t | s ≟ t
... | yes refl | yes refl = ⊥-elim (r≢s refl)
... | no r≢t | yes refl
rewrite sym (_↔_.isProj gSub′↔cSub′ s)
rewrite lookup∘update′ s≢q (c [ p ]≔ lp′) lq′
rewrite lookup∘update′ s≢p c lp′
rewrite _↔_.isProj assoc s
rewrite proj-prefix-recv {l = l′} r s gSub r≢s
rewrite lookup∘update′ s≢q (((c [ r ]≔ lrSub) [ s ]≔ lsSub) [ p ]≔ lp′) lq′
rewrite lookup∘update′ s≢p ((c [ r ]≔ lrSub) [ s ]≔ lsSub) lp′
rewrite lookup∘update s (c [ r ]≔ lrSub) lsSub
= refl
... | yes refl | no s≢t
rewrite sym (_↔_.isProj gSub′↔cSub′ r)
rewrite lookup∘update′ r≢q (c [ p ]≔ lp′) lq′
rewrite lookup∘update′ r≢p c lp′
rewrite _↔_.isProj assoc r
rewrite proj-prefix-send {l = l′} r s gSub r≢s
rewrite lookup∘update′ r≢q (((c [ r ]≔ lrSub) [ s ]≔ lsSub) [ p ]≔ lp′) lq′
rewrite lookup∘update′ r≢p ((c [ r ]≔ lrSub) [ s ]≔ lsSub) lp′
rewrite lookup∘update′ r≢s (c [ r ]≔ lrSub) lsSub
rewrite lookup∘update r c lrSub
= refl
... | no r≢t | no s≢t
rewrite proj-prefix-other {l = l′} r s t {r≢s} gSub′ r≢t s≢t
with p ≟ t | q ≟ t
... | yes refl | yes refl = ⊥-elim (p≢q refl)
... | yes refl | no q≢t
rewrite lookup∘update′ p≢q (c [ p ]≔ lp′) lq′
rewrite lookup∘update p c lp′
rewrite sym (_↔_.isProj gSub′↔cSub′ p)
rewrite lookup∘update′ p≢q (((c [ r ]≔ lrSub) [ s ]≔ lsSub) [ p ]≔ lp′) lq′
rewrite lookup∘update p ((c [ r ]≔ lrSub) [ s ]≔ lsSub) lp′
= refl
... | no p≢t | yes refl
rewrite lookup∘update q (c [ p ]≔ lp′) lq′
rewrite sym (_↔_.isProj gSub′↔cSub′ q)
rewrite lookup∘update q (((c [ r ]≔ lrSub) [ s ]≔ lsSub) [ p ]≔ lp′) lq′
= refl
... | no p≢t | no q≢t
rewrite lookup∘update′ (¬≡-flip q≢t) (c [ p ]≔ lp′) lq′
rewrite lookup∘update′ (¬≡-flip p≢t) c lp′
rewrite sym (_↔_.isProj gSub′↔cSub′ t)
rewrite lookup∘update′ (¬≡-flip q≢t) (((c [ r ]≔ lrSub) [ s ]≔ lsSub) [ p ]≔ lp′) lq′
rewrite lookup∘update′ (¬≡-flip p≢t) ((c [ r ]≔ lrSub) [ s ]≔ lsSub) lp′
rewrite lookup∘update′ (¬≡-flip s≢t) (c [ r ]≔ lrSub) lsSub
rewrite lookup∘update′ (¬≡-flip r≢t) c lrSub
= refl
| {
"alphanum_fraction": 0.4837579189,
"avg_line_length": 46.9556962025,
"ext": "agda",
"hexsha": "9058d0ad1c7a2a5dc075b1a1fff3eedb90f56f2d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "fangyi-zhou/mpst-in-agda",
"max_forks_repo_path": "Completeness.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T11:30:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-08-31T10:15:38.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "fangyi-zhou/mpst-in-agda",
"max_issues_repo_path": "Completeness.agda",
"max_line_length": 128,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "fangyi-zhou/mpst-in-agda",
"max_stars_repo_path": "Completeness.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-14T17:36:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-08-14T17:36:53.000Z",
"num_tokens": 2821,
"size": 7419
} |
-- Andreas, 2019-08-20, issue #4016
-- Debug printing should not crash Agda even if there are
-- __IMPOSSIBLE__s buried inside values that get printed.
{-# OPTIONS -v scope.decl.trace:80 #-} -- KEEP!
-- The following is some random code (see issue #4010)
-- that happened to trigger an internal error with verbosity 80.
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.List
data D : Set where
c : D
module M where
private
unquoteDecl g = do
ty ← quoteTC D
_ ← declareDef (arg (arg-info visible relevant) g) ty
qc ← quoteTC c
defineFun g (clause [] [] qc ∷ [])
-- Should print lots of debug stuff and succeed.
| {
"alphanum_fraction": 0.6806358382,
"avg_line_length": 23.8620689655,
"ext": "agda",
"hexsha": "ff68586a3a254665092f189c92a9d564a1ea8083",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Succeed/Issue4016.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue4016.agda",
"max_line_length": 64,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue4016.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 192,
"size": 692
} |
-- Andreas, 2018-10-18, issue #3285, reported by ice1000
-- Testcase by Frederik NF
f : Set → Set
f x = x
syntax f a = a
-- WAS: internal error
--
-- Now: parse error: Malformed syntax declaration
| {
"alphanum_fraction": 0.675,
"avg_line_length": 16.6666666667,
"ext": "agda",
"hexsha": "9d2d8c571ca6114b51ecfc5d7fb95edbc8dd0e59",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue3285.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue3285.agda",
"max_line_length": 56,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue3285.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 65,
"size": 200
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.Freudenthal
module homotopy.IterSuspensionStable where
{- π (S k) (Ptd-Susp^ (S n) X) == π k (Ptd-Susp^ n X), where k = S k'
Susp^Stable below assumes k ≠ O instead of taking k' as the argument -}
module Susp^StableSucc {i} (k n : ℕ) (Skle : S k ≤ n *2)
(X : Ptd i) {{_ : is-connected ⟨ n ⟩ (de⊙ X)}} where
{- some numeric computations -}
private
Skle' : ⟨ S k ⟩ ≤T ⟨ n ⟩₋₁ +2+ ⟨ n ⟩₋₁
Skle' = ≤T-trans (⟨⟩-monotone-≤ Skle) (inl (lemma n))
where lemma : (n : ℕ) → ⟨ n *2 ⟩ == ⟨ n ⟩₋₁ +2+ ⟨ n ⟩₋₁
lemma O = idp
lemma (S n') = ap S (ap S (lemma n')
∙ ! (+2+-βr ⟨ S n' ⟩₋₂ ⟨ S n' ⟩₋₂))
private
module F = FreudenthalIso
⟨ n ⟩₋₂ k Skle' X
stable : πS (S k) (⊙Susp X) ≃ᴳ πS k X
stable =
πS (S k) (⊙Susp X)
≃ᴳ⟨ πS-Ω-split-iso k (⊙Susp X) ⟩
πS k (⊙Ω (⊙Susp X))
≃ᴳ⟨ Ω^S-group-Trunc-fuse-diag-iso k (⊙Ω (⊙Susp X)) ⁻¹ᴳ ⟩
Ω^S-group k (⊙Trunc ⟨ S k ⟩ (⊙Ω (⊙Susp X)))
≃ᴳ⟨ F.iso ⁻¹ᴳ ⟩
Ω^S-group k (⊙Trunc ⟨ S k ⟩ X)
≃ᴳ⟨ Ω^S-group-Trunc-fuse-diag-iso k X ⟩
πS k X ≃ᴳ∎
| {
"alphanum_fraction": 0.4961767205,
"avg_line_length": 31.8108108108,
"ext": "agda",
"hexsha": "9fc226b944cde6972907de0caba2f8f8363d4cec",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/IterSuspensionStable.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/IterSuspensionStable.agda",
"max_line_length": 74,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/IterSuspensionStable.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 565,
"size": 1177
} |
module eq where
open import level
----------------------------------------------------------------------
-- datatypes
----------------------------------------------------------------------
data _≡_ {ℓ} {A : Set ℓ} (x : A) : A → Set ℓ where
refl : x ≡ x
{-# BUILTIN EQUALITY _≡_ #-}
----------------------------------------------------------------------
-- syntax
----------------------------------------------------------------------
infix 4 _≡_
----------------------------------------------------------------------
-- operations
----------------------------------------------------------------------
sym : ∀ {ℓ}{A : Set ℓ}{x y : A} → x ≡ y → y ≡ x
sym refl = refl
trans : ∀ {ℓ}{A : Set ℓ}{x y z : A} → x ≡ y → y ≡ z → x ≡ z
trans refl refl = refl
cong : ∀ {ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'}(p : A → B) {x y : A} → x ≡ y → p x ≡ p y
cong p refl = refl
congf : ∀{l l' : Level}{A : Set l}{B : Set l'}{f f' : A → B}{b c : A} → f ≡ f' → b ≡ c → (f b) ≡ (f' c)
congf refl refl = refl
congf2 : ∀{l l' l'' : Level}{A : Set l}{B : Set l'}{C : Set l''}{f f' : A → B → C}{b c : A}{d e : B} → f ≡ f' → b ≡ c → d ≡ e → (f b d) ≡ (f' c e)
congf2 refl refl refl = refl
cong2 : ∀{i j k}{A : Set i}{B : Set j}{C : Set k}{a a' : A}{b b' : B}
→ (f : A → B → C)
→ a ≡ a'
→ b ≡ b'
→ f a b ≡ f a' b'
cong2 f refl refl = refl
cong3 : ∀{i j k l}{A : Set i}{B : Set j}{C : Set k}{D : Set l}{a a' : A}{b b' : B}{c c' : C}
→ (f : A → B → C → D)
→ a ≡ a'
→ b ≡ b'
→ c ≡ c'
→ f a b c ≡ f a' b' c'
cong3 f refl refl refl = refl
| {
"alphanum_fraction": 0.3146214099,
"avg_line_length": 28.9056603774,
"ext": "agda",
"hexsha": "03e17b1bdf2f9855874175b68dba45332dc5dc25",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "heades/AUGL",
"max_forks_repo_path": "eq.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "heades/AUGL",
"max_issues_repo_path": "eq.agda",
"max_line_length": 146,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "heades/AUGL",
"max_stars_repo_path": "eq.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 562,
"size": 1532
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Base.Types
open import LibraBFT.Concrete.System
open import LibraBFT.Concrete.System.Parameters
import LibraBFT.Impl.Consensus.ConsensusTypes.Properties.QuorumCert as QC
import LibraBFT.Impl.Consensus.ConsensusTypes.QuorumCert as QuorumCert
open import LibraBFT.Impl.Consensus.ConsensusTypes.SyncInfo as SI
open import LibraBFT.Impl.Properties.Util
open import LibraBFT.Impl.Types.BlockInfo as BI
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Consensus.Types.EpochDep
open import LibraBFT.ImplShared.Interface.Output
open import LibraBFT.ImplShared.Util.Dijkstra.All
open import Optics.All
open import Util.Prelude
open import Yasm.System ℓ-RoundManager ℓ-VSFP ConcSysParms
open Invariants
open RoundManagerTransProps
module LibraBFT.Impl.Consensus.ConsensusTypes.Properties.SyncInfo where
module verifyMSpec (self : SyncInfo) (validator : ValidatorVerifier) where
epoch = self ^∙ siHighestQuorumCert ∙ qcCertifiedBlock ∙ biEpoch
record SIVerifyProps (pre : RoundManager) : Set where
field
sivpEp≡ : epoch ≡ self ^∙ siHighestCommitCert ∙ qcCertifiedBlock ∙ biEpoch
sivpTcEp≡ : maybeS (self ^∙ siHighestTimeoutCert) Unit $ λ tc -> epoch ≡ tc ^∙ tcEpoch
sivpHqc≥Hcc : (self ^∙ siHighestQuorumCert) [ _≥_ ]L self ^∙ siHighestCommitCert at qcCertifiedBlock ∙ biRound
sivpHqc≢empty : self ^∙ siHighestCommitCert ∙ qcCommitInfo ≢ BI.empty
sivpHqcVer : QC.Contract (self ^∙ siHighestQuorumCert) validator
sivpHccVer : maybeS (self ^∙ sixxxHighestCommitCert) Unit $ λ qc → QC.Contract qc validator
-- Waiting on TimeoutCertificate Contract : sivpHtcVer : maybeS (self ^∙ siHighestTimeoutCert ) Unit $ λ tc → {!!}
module _ (pre : RoundManager) where
record Contract (r : Either ErrLog Unit) (post : RoundManager) (outs : List Output) : Set where
constructor mkContract
field
-- General properties / invariants
rmInv : Preserves RoundManagerInv pre post
noStateChange : pre ≡ post
-- Output
noMsgOuts : OutputProps.NoMsgs outs
-- Syncing
syncResCorr : r ≡ Right unit → SIVerifyProps pre
-- NOTE: Since the output contains no messages and the state does not
-- change, nothing needs to be said about the quorum certificats in the
-- output and post state
verifyCorrect : SI.verify self validator ≡ Right unit → SIVerifyProps pre
verifyCorrect verify≡
with epoch ≟ self ^∙ siHighestCommitCert ∙ qcCertifiedBlock ∙ biEpoch
...| no ep≢ = absurd (Left _ ≡ Right _) case verify≡ of λ ()
...| yes sivpEp≡
with sivpTcEp≡ verify≡
where
sivpTcEp≡ : SI.verify.step₁ self validator ≡ Right unit
→ maybeS (self ^∙ siHighestTimeoutCert) Unit (\tc -> epoch ≡ tc ^∙ tcEpoch)
× SI.verify.step₂ self validator ≡ Right unit
sivpTcEp≡ verify≡₁
with self ^∙ siHighestTimeoutCert
...| nothing = unit , verify≡₁
...| just tc
with epoch ≟ tc ^∙ tcEpoch
...| yes tce≡ = tce≡ , verify≡₁
...| no tce≢ = absurd (Left _ ≡ Right _) case verify≡₁ of λ ()
...| sivpTcEp≡ , verify≡₂
with sivpHqc≥Hcc verify≡₂
where
sivpHqc≥Hcc : (SI.verify.step₂ self validator ≡ Right unit)
→ (self ^∙ siHighestQuorumCert) [ _≥_ ]L self ^∙ siHighestCommitCert at qcCertifiedBlock ∙ biRound
× SI.verify.step₃ self validator ≡ Right unit
sivpHqc≥Hcc verify≡₂
with self ^∙ siHighestQuorumCert ∙ qcCertifiedBlock ∙ biRound
≥? self ^∙ siHighestCommitCert ∙ qcCertifiedBlock ∙ biRound
...| yes hqc≥hcc = hqc≥hcc , verify≡₂
...| no hqc<hcc = absurd Left _ ≡ Right _ case verify≡₂ of λ ()
...| sivpHqc≥Hcc , verify≡₃
with sivpHqc≢empty verify≡₃
where
sivpHqc≢empty : (SI.verify.step₃ self validator ≡ Right unit)
→ self ^∙ siHighestCommitCert ∙ qcCommitInfo ≢ BI.empty
× SI.verify.step₄ self validator ≡ Right unit
sivpHqc≢empty verify≡₃
with self ^∙ siHighestCommitCert ∙ qcCommitInfo ≟ BI.empty
...| no ≢empty = ≢empty , verify≡₃
...| yes ≡empty = absurd Left _ ≡ Right _ case verify≡₃ of λ ()
...| sivpHqc≢empty , verify≡₄
with sivpHqcVer verify≡₄
where
sivpHqcVer : (SI.verify.step₄ self validator ≡ Right unit)
→ QC.Contract (self ^∙ siHighestQuorumCert) validator
× SI.verify.step₅ self validator ≡ Right unit
sivpHqcVer verify≡₄
with QuorumCert.verify (self ^∙ siHighestQuorumCert) validator | inspect
(QuorumCert.verify (self ^∙ siHighestQuorumCert)) validator
...| Left _ | _ = absurd Left _ ≡ Right _ case verify≡₄ of λ ()
...| Right unit | [ R ]
with QC.contract (self ^∙ siHighestQuorumCert) validator (Right unit) refl R
...| qcCon = qcCon , verify≡₄
...| sivpHqcVer , verify≡₅
with sivpHccVer verify≡₅
where
sivpHccVer : (SI.verify.step₅ self validator ≡ Right unit)
→ (maybeS (self ^∙ sixxxHighestCommitCert) Unit $ λ qc → QC.Contract qc validator)
× SI.verify.step₆ self validator ≡ Right unit
sivpHccVer verify≡₅
with self ^∙ sixxxHighestCommitCert
...| nothing = unit , verify≡₅
...| just qc
with QuorumCert.verify qc validator | inspect
(QuorumCert.verify qc) validator
...| Left _ | _ = absurd Left _ ≡ Right _ case verify≡₅ of λ ()
...| Right unit | [ R ] = QC.contract qc validator (Right unit) refl R , verify≡₅
...| sivpHccVer , verify≡₆ =
-- TODO: continue case analysis for remaining fields
record
{ sivpEp≡ = sivpEp≡
; sivpTcEp≡ = sivpTcEp≡
; sivpHqc≥Hcc = sivpHqc≥Hcc
; sivpHqc≢empty = sivpHqc≢empty
; sivpHqcVer = sivpHqcVer
; sivpHccVer = sivpHccVer
-- ; sivpHtcVer =
}
contract : ∀ Q → (RWS-Post-⇒ Contract Q) → LBFT-weakestPre (SI.verifyM self validator) Q pre
contract Q pf = LBFT-⇒ (SI.verifyM self validator) pre (mkContract id refl refl verifyCorrect) pf
| {
"alphanum_fraction": 0.6524022864,
"avg_line_length": 47.2481751825,
"ext": "agda",
"hexsha": "e5754c08804d651fd18fa6e233d18139e81c41e2",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Impl/Consensus/ConsensusTypes/Properties/SyncInfo.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Impl/Consensus/ConsensusTypes/Properties/SyncInfo.agda",
"max_line_length": 124,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Impl/Consensus/ConsensusTypes/Properties/SyncInfo.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2056,
"size": 6473
} |
module Rationals.Add.Assoc where
open import Equality
open import Function
open import Nats using (zero; ℕ)
renaming (suc to s; _+_ to _:+:_; _*_ to _:*:_)
open import Rationals
open import Rationals.Properties
open import Nats.Add.Comm
open import Nats.Add.Assoc
open import Nats.Multiply.Distrib
open import Nats.Multiply.Assoc
open import Nats.Multiply.Comm
------------------------------------------------------------------------
-- internal stuffs
private
a+b+c=a+/b+c/ : ∀ a b c → a + (b + c) ≡ (a + b) + c
a+b+c=a+/b+c/ (ax ÷ ay) (bx ÷ by) (cx ÷ cy)
rewrite ax ÷ ay ↑ (by :*: cy)
| bx ÷ by ↑ (ay :*: cy)
| cx ÷ cy ↑ (ay :*: by)
| nat-multiply-assoc ay by cy
| sym $ nat-multiply-distrib (bx :*: cy) (cx :*: by) ay
| sym $ nat-multiply-distrib (ax :*: by) (bx :*: ay) cy
| sym $ nat-add-assoc (ax :*: (by :*: cy))
(bx :*: cy :*: ay) (cx :*: by :*: ay)
| nat-multiply-assoc ax by cy
| nat-multiply-comm ay by
| nat-multiply-assoc cx by ay
| nat-multiply-assoc bx cy ay
| nat-multiply-assoc bx ay cy
| nat-multiply-comm cy ay
= refl
rational-add-assoc : ∀ a b c → a + (b + c) ≡ (a + b) + c
rational-add-assoc = a+b+c=a+/b+c/
| {
"alphanum_fraction": 0.502265861,
"avg_line_length": 32.2926829268,
"ext": "agda",
"hexsha": "48c5f7c31d3e761da158048f435a2145de0ccb80",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "ice1k/Theorems",
"max_forks_repo_path": "src/Rationals/Add/Assoc.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "ice1k/Theorems",
"max_issues_repo_path": "src/Rationals/Add/Assoc.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "ice1k/Theorems",
"max_stars_repo_path": "src/Rationals/Add/Assoc.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z",
"num_tokens": 412,
"size": 1324
} |
-- Intuitionistic propositional calculus.
-- Gentzen-style formalisation of syntax.
-- Normal forms and neutrals.
module IPC.Syntax.GentzenNormalForm where
open import IPC.Syntax.Gentzen public
-- Derivations.
mutual
-- Normal forms, or introductions.
infix 3 _⊢ⁿᶠ_
data _⊢ⁿᶠ_ (Γ : Cx Ty) : Ty → Set where
neⁿᶠ : ∀ {A} → Γ ⊢ⁿᵉ A → Γ ⊢ⁿᶠ A
lamⁿᶠ : ∀ {A B} → Γ , A ⊢ⁿᶠ B → Γ ⊢ⁿᶠ A ▻ B
pairⁿᶠ : ∀ {A B} → Γ ⊢ⁿᶠ A → Γ ⊢ⁿᶠ B → Γ ⊢ⁿᶠ A ∧ B
unitⁿᶠ : Γ ⊢ⁿᶠ ⊤
inlⁿᶠ : ∀ {A B} → Γ ⊢ⁿᶠ A → Γ ⊢ⁿᶠ A ∨ B
inrⁿᶠ : ∀ {A B} → Γ ⊢ⁿᶠ B → Γ ⊢ⁿᶠ A ∨ B
-- Neutrals, or eliminations.
infix 3 _⊢ⁿᵉ_
data _⊢ⁿᵉ_ (Γ : Cx Ty) : Ty → Set where
varⁿᵉ : ∀ {A} → A ∈ Γ → Γ ⊢ⁿᵉ A
appⁿᵉ : ∀ {A B} → Γ ⊢ⁿᵉ A ▻ B → Γ ⊢ⁿᶠ A → Γ ⊢ⁿᵉ B
fstⁿᵉ : ∀ {A B} → Γ ⊢ⁿᵉ A ∧ B → Γ ⊢ⁿᵉ A
sndⁿᵉ : ∀ {A B} → Γ ⊢ⁿᵉ A ∧ B → Γ ⊢ⁿᵉ B
boomⁿᵉ : ∀ {C} → Γ ⊢ⁿᵉ ⊥ → Γ ⊢ⁿᵉ C
caseⁿᵉ : ∀ {A B C} → Γ ⊢ⁿᵉ A ∨ B → Γ , A ⊢ⁿᶠ C → Γ , B ⊢ⁿᶠ C → Γ ⊢ⁿᵉ C
infix 3 _⊢⋆ⁿᶠ_
_⊢⋆ⁿᶠ_ : Cx Ty → Cx Ty → Set
Γ ⊢⋆ⁿᶠ ∅ = 𝟙
Γ ⊢⋆ⁿᶠ Ξ , A = Γ ⊢⋆ⁿᶠ Ξ × Γ ⊢ⁿᶠ A
infix 3 _⊢⋆ⁿᵉ_
_⊢⋆ⁿᵉ_ : Cx Ty → Cx Ty → Set
Γ ⊢⋆ⁿᵉ ∅ = 𝟙
Γ ⊢⋆ⁿᵉ Ξ , A = Γ ⊢⋆ⁿᵉ Ξ × Γ ⊢ⁿᵉ A
-- Translation to simple terms.
mutual
nf→tm : ∀ {A Γ} → Γ ⊢ⁿᶠ A → Γ ⊢ A
nf→tm (neⁿᶠ t) = ne→tm t
nf→tm (lamⁿᶠ t) = lam (nf→tm t)
nf→tm (pairⁿᶠ t u) = pair (nf→tm t) (nf→tm u)
nf→tm unitⁿᶠ = unit
nf→tm (inlⁿᶠ t) = inl (nf→tm t)
nf→tm (inrⁿᶠ t) = inr (nf→tm t)
ne→tm : ∀ {A Γ} → Γ ⊢ⁿᵉ A → Γ ⊢ A
ne→tm (varⁿᵉ i) = var i
ne→tm (appⁿᵉ t u) = app (ne→tm t) (nf→tm u)
ne→tm (fstⁿᵉ t) = fst (ne→tm t)
ne→tm (sndⁿᵉ t) = snd (ne→tm t)
ne→tm (boomⁿᵉ t) = boom (ne→tm t)
ne→tm (caseⁿᵉ t u v) = case (ne→tm t) (nf→tm u) (nf→tm v)
nf→tm⋆ : ∀ {Ξ Γ} → Γ ⊢⋆ⁿᶠ Ξ → Γ ⊢⋆ Ξ
nf→tm⋆ {∅} ∙ = ∙
nf→tm⋆ {Ξ , A} (ts , t) = nf→tm⋆ ts , nf→tm t
ne→tm⋆ : ∀ {Ξ Γ} → Γ ⊢⋆ⁿᵉ Ξ → Γ ⊢⋆ Ξ
ne→tm⋆ {∅} ∙ = ∙
ne→tm⋆ {Ξ , A} (ts , t) = ne→tm⋆ ts , ne→tm t
-- Monotonicity with respect to context inclusion.
mutual
mono⊢ⁿᶠ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ⁿᶠ A → Γ′ ⊢ⁿᶠ A
mono⊢ⁿᶠ η (neⁿᶠ t) = neⁿᶠ (mono⊢ⁿᵉ η t)
mono⊢ⁿᶠ η (lamⁿᶠ t) = lamⁿᶠ (mono⊢ⁿᶠ (keep η) t)
mono⊢ⁿᶠ η (pairⁿᶠ t u) = pairⁿᶠ (mono⊢ⁿᶠ η t) (mono⊢ⁿᶠ η u)
mono⊢ⁿᶠ η unitⁿᶠ = unitⁿᶠ
mono⊢ⁿᶠ η (inlⁿᶠ t) = inlⁿᶠ (mono⊢ⁿᶠ η t)
mono⊢ⁿᶠ η (inrⁿᶠ t) = inrⁿᶠ (mono⊢ⁿᶠ η t)
mono⊢ⁿᵉ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ⁿᵉ A → Γ′ ⊢ⁿᵉ A
mono⊢ⁿᵉ η (varⁿᵉ i) = varⁿᵉ (mono∈ η i)
mono⊢ⁿᵉ η (appⁿᵉ t u) = appⁿᵉ (mono⊢ⁿᵉ η t) (mono⊢ⁿᶠ η u)
mono⊢ⁿᵉ η (fstⁿᵉ t) = fstⁿᵉ (mono⊢ⁿᵉ η t)
mono⊢ⁿᵉ η (sndⁿᵉ t) = sndⁿᵉ (mono⊢ⁿᵉ η t)
mono⊢ⁿᵉ η (boomⁿᵉ t) = boomⁿᵉ (mono⊢ⁿᵉ η t)
mono⊢ⁿᵉ η (caseⁿᵉ t u v) = caseⁿᵉ (mono⊢ⁿᵉ η t) (mono⊢ⁿᶠ (keep η) u) (mono⊢ⁿᶠ (keep η) v)
mono⊢⋆ⁿᶠ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢⋆ⁿᶠ Ξ → Γ′ ⊢⋆ⁿᶠ Ξ
mono⊢⋆ⁿᶠ {∅} η ∙ = ∙
mono⊢⋆ⁿᶠ {Ξ , A} η (ts , t) = mono⊢⋆ⁿᶠ η ts , mono⊢ⁿᶠ η t
mono⊢⋆ⁿᵉ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢⋆ⁿᵉ Ξ → Γ′ ⊢⋆ⁿᵉ Ξ
mono⊢⋆ⁿᵉ {∅} η ∙ = ∙
mono⊢⋆ⁿᵉ {Ξ , A} η (ts , t) = mono⊢⋆ⁿᵉ η ts , mono⊢ⁿᵉ η t
-- Reflexivity.
refl⊢⋆ⁿᵉ : ∀ {Γ} → Γ ⊢⋆ⁿᵉ Γ
refl⊢⋆ⁿᵉ {∅} = ∙
refl⊢⋆ⁿᵉ {Γ , A} = mono⊢⋆ⁿᵉ weak⊆ refl⊢⋆ⁿᵉ , varⁿᵉ top
| {
"alphanum_fraction": 0.4815740162,
"avg_line_length": 30.4952380952,
"ext": "agda",
"hexsha": "921ea78063e2eacb74b34781560921a3f5cb2a07",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "IPC/Syntax/GentzenNormalForm.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "IPC/Syntax/GentzenNormalForm.agda",
"max_line_length": 91,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "IPC/Syntax/GentzenNormalForm.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 2401,
"size": 3202
} |
module Issue1296.SolvedMeta where
open import Common.Prelude
open import Common.Equality
test : zero ≡ {!!}
test = refl
| {
"alphanum_fraction": 0.762295082,
"avg_line_length": 15.25,
"ext": "agda",
"hexsha": "d552e2ebff9af371055415d52c3292cd40aa6712",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue1296/SolvedMeta.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue1296/SolvedMeta.agda",
"max_line_length": 33,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue1296/SolvedMeta.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 32,
"size": 122
} |
{-# OPTIONS --safe #-}
module Cubical.Categories.Instances.Semilattice where
open import Cubical.Foundations.Prelude
open import Cubical.Algebra.Semilattice
open import Cubical.Categories.Category
open import Cubical.Categories.Instances.Poset
open Category
module _ {ℓ} (L : Semilattice ℓ) where
open JoinSemilattice L
JoinSemilatticeCategory : Category ℓ ℓ
JoinSemilatticeCategory = PosetCategory IndPoset
module _ {ℓ} (L : Semilattice ℓ) where
open MeetSemilattice L
MeetSemilatticeCategory : Category ℓ ℓ
MeetSemilatticeCategory = PosetCategory IndPoset
| {
"alphanum_fraction": 0.7982758621,
"avg_line_length": 22.3076923077,
"ext": "agda",
"hexsha": "e698f39ae2c120961de2829833a6c3d0d0de817e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Seanpm2001-web/cubical",
"max_forks_repo_path": "Cubical/Categories/Instances/Semilattice.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Seanpm2001-web/cubical",
"max_issues_repo_path": "Cubical/Categories/Instances/Semilattice.agda",
"max_line_length": 53,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FernandoLarrain/cubical",
"max_stars_repo_path": "Cubical/Categories/Instances/Semilattice.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z",
"num_tokens": 162,
"size": 580
} |
{-# OPTIONS --without-K --safe #-}
module Definition.Typed.Decidable where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Conversion
open import Definition.Conversion.Decidable
open import Definition.Conversion.Soundness
open import Definition.Conversion.Stability
open import Definition.Conversion.Consequences.Completeness
open import Tools.Nullary
-- Decidability of conversion of well-formed types
dec : ∀ {A B Γ} → Γ ⊢ A → Γ ⊢ B → Dec (Γ ⊢ A ≡ B)
dec ⊢A ⊢B = map soundnessConv↑ completeEq
(decConv↑ (completeEq (refl ⊢A))
(completeEq (refl ⊢B)))
-- Decidability of conversion of well-formed terms
decTerm : ∀ {t u A Γ} → Γ ⊢ t ∷ A → Γ ⊢ u ∷ A → Dec (Γ ⊢ t ≡ u ∷ A)
decTerm ⊢t ⊢u = map soundnessConv↑Term completeEqTerm
(decConv↑Term (completeEqTerm (refl ⊢t))
(completeEqTerm (refl ⊢u)))
| {
"alphanum_fraction": 0.6652935118,
"avg_line_length": 34.6785714286,
"ext": "agda",
"hexsha": "954034a8fc6fa0e520ee41a911d91516a841abcc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Vtec234/logrel-mltt",
"max_forks_repo_path": "Definition/Typed/Decidable.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Vtec234/logrel-mltt",
"max_issues_repo_path": "Definition/Typed/Decidable.agda",
"max_line_length": 67,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Vtec234/logrel-mltt",
"max_stars_repo_path": "Definition/Typed/Decidable.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 263,
"size": 971
} |
test : Set → Set
test record{} = record{}
-- Record pattern at non-record type Set
-- when checking that the clause test record {} = record {} has
-- type Set → Set
| {
"alphanum_fraction": 0.6646706587,
"avg_line_length": 23.8571428571,
"ext": "agda",
"hexsha": "161a4368fcb99c5353c85c86f19fdbf28968f9c8",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/RecordPattern0.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/RecordPattern0.agda",
"max_line_length": 63,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/RecordPattern0.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 42,
"size": 167
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Ideal where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Logic using ([_]; _∈_)
open import Cubical.Algebra.Ring
private
variable
ℓ : Level
module _ (R' : Ring {ℓ}) where
open Ring R' renaming (Carrier to R)
{- by default, 'ideal' means two-sided ideal -}
record isIdeal (I : R → hProp ℓ) : Type ℓ where
field
+-closed : {x y : R} → x ∈ I → y ∈ I → (x + y) ∈ I
-closed : {x : R} → x ∈ I → - x ∈ I
0r-closed : 0r ∈ I
·-closedLeft : {x : R} → (r : R) → x ∈ I → r · x ∈ I
·-closedRight : {x : R} → (r : R) → x ∈ I → x · r ∈ I
Ideal : Type _
Ideal = Σ[ I ∈ (R → hProp ℓ) ] isIdeal I
record isLeftIdeal (I : R → hProp ℓ) : Type ℓ where
field
+-closed : {x y : R} → x ∈ I → y ∈ I → (x + y) ∈ I
-closed : {x : R} → x ∈ I → - x ∈ I
0r-closed : 0r ∈ I
·-closedLeft : {x : R} → (r : R) → x ∈ I → r · x ∈ I
record isRightIdeal (I : R → hProp ℓ) : Type ℓ where
field
+-closed : {x y : R} → x ∈ I → y ∈ I → (x + y) ∈ I
-closed : {x : R} → x ∈ I → - x ∈ I
0r-closed : 0r ∈ I
·-closedRight : {x : R} → (r : R) → x ∈ I → x · r ∈ I
{- Examples of ideals -}
zeroSubset : (x : R) → hProp ℓ
zeroSubset x = (x ≡ 0r) , isSetRing R' _ _
open Theory R'
isIdealZeroIdeal : isIdeal zeroSubset
isIdealZeroIdeal = record
{ +-closed = λ x≡0 y≡0 → _ + _ ≡⟨ cong (λ u → u + _) x≡0 ⟩
0r + _ ≡⟨ +-lid _ ⟩
_ ≡⟨ y≡0 ⟩
0r ∎
; -closed = λ x≡0 → - _ ≡⟨ cong (λ u → - u) x≡0 ⟩
- 0r ≡⟨ 0-selfinverse ⟩
0r ∎
; 0r-closed = refl
; ·-closedLeft = λ r x≡0 → r · _ ≡⟨ cong (λ u → r · u) x≡0 ⟩
r · 0r ≡⟨ 0-rightNullifies r ⟩
0r ∎
; ·-closedRight = λ r x≡0 → _ · r ≡⟨ cong (λ u → u · r) x≡0 ⟩
0r · r ≡⟨ 0-leftNullifies r ⟩
0r ∎
}
zeroIdeal : Ideal
zeroIdeal = zeroSubset , isIdealZeroIdeal
| {
"alphanum_fraction": 0.4021952176,
"avg_line_length": 35.4305555556,
"ext": "agda",
"hexsha": "c78376d7f8313ea856a07cf7ec0ab9e223341862",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "knrafto/cubical",
"max_forks_repo_path": "Cubical/Algebra/Ideal.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "knrafto/cubical",
"max_issues_repo_path": "Cubical/Algebra/Ideal.agda",
"max_line_length": 84,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "knrafto/cubical",
"max_stars_repo_path": "Cubical/Algebra/Ideal.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 870,
"size": 2551
} |
module Lemmachine.Utils where
open import Lemmachine.Request
open import Lemmachine.Response
open import Data.Maybe
open import Data.Bool hiding (_≟_)
open import Data.String
open import Data.Function
open import Data.Product
open import Relation.Nullary
open import Data.List hiding (any)
open import Data.List.Any
open Membership-≡
Application = Request → Response
Middleware = Application → Application
fetch : String → List (String × String) → Maybe String
fetch x xs with any (_≟_ x ∘ proj₁) xs
... | yes p = just (proj₂ (proj₁ (find p)))
... | no _ = nothing
private
fromHeaders : RequestHeaders → List (String × String)
fromHeaders xs = Data.List.map f xs where
f : RequestHeader → String × String
f (k , v) = k , v
fetchHeader : String → RequestHeaders → Maybe String
fetchHeader x xs with any (_≟_ x ∘ headerKey) xs
... | yes p = just (headerValue (proj₁ (find p)))
... | no _ = nothing
fetchContentType : String → List String → Maybe String
fetchContentType _ [] = nothing
fetchContentType "*" (y ∷ _) = just y
fetchContentType "*/*" (y ∷ _) = just y
fetchContentType x (y ∷ ys) with x == y
... | true = just y
... | false = fetchContentType x ys
fetchAccept : RequestHeaders → List String → Maybe String
fetchAccept hs cs with fetchHeader "Accept" hs
fetchAccept hs _ | nothing = nothing
fetchAccept _ [] | just _ = nothing
fetchAccept _ xss | just y = fetchContentType y xss
postulate
isDate : String → Bool
isModified : String → String → Bool
now : String
| {
"alphanum_fraction": 0.7128514056,
"avg_line_length": 29.2941176471,
"ext": "agda",
"hexsha": "07380ae9e89942004574cbddba086aae8cbc0a1c",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "src/Lemmachine/Utils.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "src/Lemmachine/Utils.agda",
"max_line_length": 57,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "src/Lemmachine/Utils.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 398,
"size": 1494
} |
open import Agda.Builtin.Bool
data ⊥ : Set where
record ⊤ : Set where
IsTrue : Bool → Set
IsTrue false = ⊥
IsTrue true = ⊤
record Squash {ℓ} (A : Set ℓ) : Set ℓ where
field
.unsquash : A
open Squash
f : .Bool → Squash Set₁
f b .unsquash = Set
module M where
IsTrue' : Set
IsTrue' = IsTrue b
g : Squash Set₁
g .unsquash = Set
module N where
open M
h : IsTrue' true → Set₁
h p = Set
| {
"alphanum_fraction": 0.6172248804,
"avg_line_length": 14.4137931034,
"ext": "agda",
"hexsha": "8601fa1a3c87bd72ac9706ebce88a2dd3eb5692e",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue3627.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue3627.agda",
"max_line_length": 43,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue3627.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 159,
"size": 418
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import LogicalFormulae
open import Boolean.Definition
module Boolean.Lemmas where
notNot : (x : Bool) → not (not x) ≡ x
notNot BoolTrue = refl
notNot BoolFalse = refl
notXor : (x y : Bool) → not (xor x y) ≡ xor (not x) y
notXor BoolTrue BoolTrue = refl
notXor BoolTrue BoolFalse = refl
notXor BoolFalse BoolTrue = refl
notXor BoolFalse BoolFalse = refl
| {
"alphanum_fraction": 0.7266949153,
"avg_line_length": 26.2222222222,
"ext": "agda",
"hexsha": "b093ef6c63d0e19358a3683a83684004d169776b",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Boolean/Lemmas.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Boolean/Lemmas.agda",
"max_line_length": 58,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Boolean/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 150,
"size": 472
} |
module Module where
record R
: Set
where
module M where
module N where
module O where
postulate
A
: Set
x
: R
x
= record {M}
module P
= N
| {
"alphanum_fraction": 0.5857988166,
"avg_line_length": 6.5,
"ext": "agda",
"hexsha": "143d96925bac7170dcc4137ec41f1e04d10f679a",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z",
"max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "msuperdock/agda-unused",
"max_forks_repo_path": "data/declaration/Module.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "msuperdock/agda-unused",
"max_issues_repo_path": "data/declaration/Module.agda",
"max_line_length": 19,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "msuperdock/agda-unused",
"max_stars_repo_path": "data/declaration/Module.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z",
"num_tokens": 58,
"size": 169
} |
-- Andreas, 2018-08-14, issue #3176, reported by identicalsnowflake
--
-- Absurd lambdas should be equal.
-- In this case, they were only considered equal during give, but not upon reload.
open import Agda.Builtin.Nat renaming (Nat to ℕ)
open import Agda.Builtin.Equality
record Σ (A : Set) (B : A → Set) : Set where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
open Σ public
∃ : ∀ {A : Set} → (A → Set) → Set
∃ = Σ _
_×_ : ∀ _ _ → _
_×_ a b = ∃ λ (_ : a) → b
record Fin (n : ℕ) : Set where
field
m : ℕ
.p : ∃ λ k → (ℕ.suc k + m) ≡ n
module _ (n : ℕ) where
data S : Set where
V : S
K : Fin n → S
_X_ : S → S → S
[_] : ∀ {n} → S n → (Fin n → Set) → Set → Set
[ V ] k t = t
[ K i ] k _ = k i
[ s₁ X s₂ ] k t = [ s₁ ] k t × [ s₂ ] k t
postulate
ignore : ∀ {t : Set} → t
_<*>_ : ∀ {s : S 0} {t₁ t₂}
→ [ s ] (λ ()) (t₁ → t₂)
→ [ s ] (λ ()) t₁
→ [ s ] (λ ()) t₂
_<*>_ {s₁ X s₂} {t₁} {t₂} (f , _) (x , _) =
let v : [ s₁ ] (λ ()) t₂
v = _<*>_ {s = s₁} {t₁ = t₁} {t₂ = t₂} f x
in
ignore
_<*>_ f x = ignore
-- Should succeed.
| {
"alphanum_fraction": 0.4895168642,
"avg_line_length": 19.9454545455,
"ext": "agda",
"hexsha": "83985da2c1b7fe326fc217f9e9cfcf6b2ad8c6dc",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z",
"max_forks_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "hborum/agda",
"max_forks_repo_path": "test/Succeed/Issue3176.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Succeed/Issue3176.agda",
"max_line_length": 82,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Succeed/Issue3176.agda",
"max_stars_repo_stars_event_max_datetime": "2021-07-07T10:49:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-07T10:49:57.000Z",
"num_tokens": 473,
"size": 1097
} |
module Hello where
-- Oh, you made it! Well done! This line is a comment.
-- In the beginning, Agda knows nothing, but we can teach it about numbers.
data Nat : Set where
zero : Nat
suc : Nat -> Nat
-- data Nat = Zero | Suc Nat -- in Haskell
-- Now we can say how to add numbers.
_+N_ : Nat -> Nat -> Nat
m +N zero = m
m +N suc n = suc (m +N n)
-- Now we can try adding some numbers.
four : Nat
four = (suc (suc zero)) +N (suc (suc zero))
-- To make it go, select "Evaluate term to normal form" from the
-- Agda menu, then type "four", without the quotes, and press return.
-- Hopefully, you should get a response
-- suc (suc (suc (suc zero)))
-- Done?
-- Now you can start Ex1.agda
-- WARNING Ex1.agda requires you to give a definition of addition.
-- There are lots of ways to define addition, and by the end of the
-- exercise, it will matter which you choose. If you start just by
-- copying the above definition, you will reach a point where you
-- may wish to reconsider it, and hopefully learn something useful
-- about the way Agda works.
| {
"alphanum_fraction": 0.6797385621,
"avg_line_length": 26.775,
"ext": "agda",
"hexsha": "cf0e98cb1e5b6149e01bc2bb4332032e8282c71e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "clarkdm/CS410",
"max_forks_repo_path": "Hello.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "clarkdm/CS410",
"max_issues_repo_path": "Hello.agda",
"max_line_length": 75,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "523a8749f49c914bcd28402116dcbe79a78dbbf4",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "clarkdm/CS410",
"max_stars_repo_path": "Hello.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 300,
"size": 1071
} |
module Terms where
import Level
open import Data.Unit as Unit
open import Data.List as List
open import Data.Product as Product
open import Categories.Category using (Category)
data Type : Set where
Nat : Type
_ˢ : Type → Type
_⇒_ : Type → Type → Type
infixr 5 _⇒_
open import Common.Context Type
using (Ctx; Var; zero; ctx-cat; ctx-bin-coproducts)
renaming (succ to succ)
open Categories.Category.Category ctx-cat
renaming ( _⇒_ to _▹_
; _≡_ to _≈_
; _∘_ to _●_
; id to ctx-id
)
open import Categories.Object.BinaryCoproducts ctx-cat
open BinaryCoproducts ctx-bin-coproducts
data Term (Γ : Ctx) : (σ : Type) → Set where
var : ∀{σ : Type} (x : Var Γ σ) → Term Γ σ
abs : ∀{σ τ : Type} (t : Term (σ ∷ Γ) τ) → Term Γ (σ ⇒ τ)
app : ∀{σ τ : Type} (t : Term Γ (σ ⇒ τ))
(s : Term Γ σ) → Term Γ τ
-- Constants for recursion over ℕ
𝟘 : Term Γ Nat
s⁺ : Term Γ (Nat ⇒ Nat)
R : ∀{σ : Type} → Term Γ (σ ⇒ (Nat ⇒ σ ⇒ σ) ⇒ Nat ⇒ σ)
-- Constants for corecursion over streams
hd : ∀{σ : Type} → Term Γ (σ ˢ ⇒ σ)
tl : ∀{σ : Type} → Term Γ (σ ˢ ⇒ σ ˢ)
C : ∀{σ τ : Type} → Term Γ ((σ ⇒ τ) ⇒ (σ ⇒ σ) ⇒ σ ⇒ τ ˢ)
-- Improve readability
_⟨$⟩_ : ∀{Γ σ τ} (t : Term Γ (σ ⇒ τ)) (s : Term Γ σ) → Term Γ τ
t ⟨$⟩ s = app t s
infixl 0 _⟨$⟩_
hd′ : ∀{Γ σ} → Term Γ (σ ˢ) → Term Γ σ
hd′ s = hd ⟨$⟩ s
tl′ : ∀{Γ σ} → Term Γ (σ ˢ) → Term Γ (σ ˢ)
tl′ s = tl ⟨$⟩ s
C′ : ∀{Γ σ τ} → Term Γ (σ ⇒ τ) → Term Γ (σ ⇒ σ) → Term Γ (σ ⇒ τ ˢ)
C′ h t = (C ⟨$⟩ h) ⟨$⟩ t
R′ : ∀{Γ σ} → Term Γ σ → Term Γ (Nat ⇒ σ ⇒ σ) → Term Γ (Nat ⇒ σ)
R′ x f = R ⟨$⟩ x ⟨$⟩ f
ƛ : ∀{Γ σ τ} → (Var (σ ∷ Γ) σ → Term (σ ∷ Γ) τ) → Term Γ (σ ⇒ τ)
ƛ f = abs (f zero)
abs₁ : ∀{Γ τ σ} →
(Term (τ ∷ Γ) τ → Term (τ ∷ Γ) σ)
→ Term Γ (τ ⇒ σ)
abs₁ f = abs (f (var zero))
abs₂ : ∀{Γ τ₁ τ₂ σ} →
(Term (τ₂ ∷ τ₁ ∷ Γ) τ₁ →
Term (τ₂ ∷ τ₁ ∷ Γ) τ₂ →
Term (τ₂ ∷ τ₁ ∷ Γ) σ) →
Term Γ (τ₁ ⇒ τ₂ ⇒ σ)
abs₂ {Γ} {τ₁} f = abs (abs (f x₁ x₂))
where
x₁ = var (succ τ₁ zero)
x₂ = var zero
abs₃ : ∀{Γ τ₁ τ₂ τ₃ σ} →
(Term (τ₃ ∷ τ₂ ∷ τ₁ ∷ Γ) τ₁ →
Term (τ₃ ∷ τ₂ ∷ τ₁ ∷ Γ) τ₂ →
Term (τ₃ ∷ τ₂ ∷ τ₁ ∷ Γ) τ₃ →
Term (τ₃ ∷ τ₂ ∷ τ₁ ∷ Γ) σ) →
Term Γ (τ₁ ⇒ τ₂ ⇒ τ₃ ⇒ σ)
abs₃ {Γ} {τ₁} {τ₂} f = abs (abs (abs (f x₁ x₂ x₃)))
where
x₁ = var (succ τ₁ (succ τ₁ zero))
x₂ = var (succ τ₂ zero)
x₃ = var zero
--------------------------------------
---- Examples ---
π₁ : ∀{Γ σ τ} → Term Γ (σ ⇒ τ ⇒ σ)
π₁ = abs₂ (λ x₁ x₂ → x₁)
π₂ : ∀{Γ σ τ} → Term Γ (σ ⇒ τ ⇒ τ)
π₂ = abs₂ (λ x₁ x₂ → x₂)
-- | Prepend element to a stream
-- hd (cons x s) = x
-- tl (cons x s) = s
-- This needs to use continuations.
conc : ∀{Γ σ} → Term Γ (σ ⇒ σ ˢ ⇒ σ ˢ)
conc {Γ} {σ} = abs (abs (C′ f g ⟨$⟩ i))
where
-- | State space
S = (σ ⇒ σ ˢ ⇒ σ) ⇒ σ
-- | local context
Γ′ = σ ˢ ∷ σ ∷ Γ
f : Term Γ′ (S ⇒ σ)
f = abs₁ (λ v → v ⟨$⟩ π₁)
g : Term Γ′ (S ⇒ S)
g = abs₂ (λ v _h →
v ⟨$⟩ (abs₂ (λ _ s →
h ⟨$⟩ (hd′ s) ⟨$⟩ (tl′ s))
)
)
where
Γ′′ = σ ˢ ∷ σ ∷ (σ ⇒ σ ˢ ⇒ σ) ∷ S ∷ Γ′
h : Term Γ′′ (σ ⇒ σ ˢ ⇒ σ)
h = var (succ (σ ⇒ σ ˢ ⇒ σ) (succ (σ ⇒ σ ˢ ⇒ σ) zero))
i : Term Γ′ S
i = abs₁ (λ h → h ⟨$⟩ x ⟨$⟩ s)
where
s : Term ((σ ⇒ σ ˢ ⇒ σ) ∷ Γ′) (σ ˢ)
s = var (succ (σ ˢ) zero)
x : Term ((σ ⇒ σ ˢ ⇒ σ) ∷ Γ′) σ
x = var (succ σ (succ σ zero))
_∺_ : ∀{Γ σ} → Term Γ σ → Term Γ (σ ˢ) → Term Γ (σ ˢ)
x ∺ s = conc ⟨$⟩ x ⟨$⟩ s
id′ : ∀{Γ σ} → Term Γ (σ ⇒ σ)
id′ = abs₁ (λ x → x)
repeat : ∀{Γ σ} → Term Γ (σ ⇒ σ ˢ)
repeat = C′ id′ id′
-- | Extend a stream that is defined up to n by an element on the right, i.e.,
-- ext x 0 s = repeat x
-- hd (ext x (n+1) s) = hd s
-- tl (ext x (n+1) s) = ext x n (tl s)
-- Thus ext is given by a recursion, followed by a corecursion:
-- ext x = R (λ_. repeat x) f
-- f _ h s = hd s ∷ (h (tl s))
ext : ∀{Γ σ} → Term Γ (σ ⇒ Nat ⇒ σ ˢ ⇒ σ ˢ)
ext {Γ} {σ} = abs (R′ (abs (repeat ⟨$⟩ x)) f)
where
Γ′ = σ ∷ Γ
x : Term (σ ˢ ∷ Γ′) σ
x = var (succ σ zero)
f : Term Γ′ (Nat ⇒ (σ ˢ ⇒ σ ˢ) ⇒ σ ˢ ⇒ σ ˢ)
f = abs₃ (λ _ h s → (hd′ s) ∺ (h ⟨$⟩ (tl′ s)))
| {
"alphanum_fraction": 0.4474544605,
"avg_line_length": 26.9308176101,
"ext": "agda",
"hexsha": "b0744ec39fd1eae592ae113f15c1af7cb7b9a685",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hbasold/Sandbox",
"max_forks_repo_path": "TypeTheory/SystemT+Corec/Terms.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hbasold/Sandbox",
"max_issues_repo_path": "TypeTheory/SystemT+Corec/Terms.agda",
"max_line_length": 78,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hbasold/Sandbox",
"max_stars_repo_path": "TypeTheory/SystemT+Corec/Terms.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1936,
"size": 4282
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
-- this module characterizes a category of all equalizer indexed by I.
-- this notion formalizes a category with all equalizer up to certain cardinal.
module Categories.Diagram.Equalizer.Indexed {o ℓ e} (C : Category o ℓ e) where
open import Level
open Category C
record IndexedEqualizerOf {i} {I : Set i} {A B : Obj} (M : I → A ⇒ B) : Set (i ⊔ o ⊔ e ⊔ ℓ) where
field
E : Obj
arr : E ⇒ A
-- a reference morphism
ref : E ⇒ B
equality : ∀ i → M i ∘ arr ≈ ref
equalize : ∀ {X} (h : X ⇒ A) (r : X ⇒ B) → (∀ i → M i ∘ h ≈ r) → X ⇒ E
universal : ∀ {X} (h : X ⇒ A) (r : X ⇒ B) (eq : ∀ i → M i ∘ h ≈ r) → h ≈ arr ∘ equalize h r eq
unique : ∀ {X} {l : X ⇒ E} (h : X ⇒ A) (r : X ⇒ B) (eq : ∀ i → M i ∘ h ≈ r) → h ≈ arr ∘ l → l ≈ equalize h r eq
record IndexedEqualizer {i} (I : Set i) : Set (i ⊔ o ⊔ e ⊔ ℓ) where
field
A B : Obj
M : I → A ⇒ B
equalizerOf : IndexedEqualizerOf M
open IndexedEqualizerOf equalizerOf public
AllEqualizers : ∀ i → Set (o ⊔ ℓ ⊔ e ⊔ suc i)
AllEqualizers i = (I : Set i) → IndexedEqualizer I
AllEqualizersOf : ∀ i → Set (o ⊔ ℓ ⊔ e ⊔ suc i)
AllEqualizersOf i = ∀ {I : Set i} {A B : Obj} (M : I → A ⇒ B) → IndexedEqualizerOf M
| {
"alphanum_fraction": 0.5560711524,
"avg_line_length": 34.0263157895,
"ext": "agda",
"hexsha": "a2c34df002cf704cd81d193ae58d257a0a8a19cf",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Diagram/Equalizer/Indexed.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Diagram/Equalizer/Indexed.agda",
"max_line_length": 118,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Diagram/Equalizer/Indexed.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 491,
"size": 1293
} |
-- Andreas, 2016-11-19 issue #2309
-- No-eta-equality needs to be respected in pattern matching
-- also before the clause compiler.
record Unit : Set where
constructor unit
no-eta-equality
record R : Set₁ where
field Fst : Unit → Set
Snd : (x : Unit) → Fst x
open R
Test : (A : Set) (a : A) → R
Fst (Test A a) unit = A
Snd (Test A a) x = a -- should not be accepted
| {
"alphanum_fraction": 0.6408268734,
"avg_line_length": 22.7647058824,
"ext": "agda",
"hexsha": "9e8c6dd16d4e29e5b0fca3b8e07ac72adeea634c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue2309.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Fail/Issue2309.agda",
"max_line_length": 60,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Fail/Issue2309.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 130,
"size": 387
} |
{- functions related to lift types. The main function is do-lift, which
is called from hnf -}
module lift where
open import lib
open import cedille-types
open import ctxt
open import syntax-util
open import subst
liftingType-to-kind : liftingType → kind
liftingType-to-kind (LiftArrow l1 l2) = KndArrow (liftingType-to-kind l1) (liftingType-to-kind l2)
liftingType-to-kind (LiftStar _) = star
liftingType-to-kind (LiftParens _ l _) = liftingType-to-kind l
liftingType-to-kind (LiftTpArrow tp l) = KndTpArrow tp (liftingType-to-kind l)
liftingType-to-kind (LiftPi _ x tp l) = KndPi posinfo-gen posinfo-gen x (Tkt tp) (liftingType-to-kind l)
liftingType-to-type : var → liftingType → type
liftingType-to-type X (LiftArrow l1 l2) = TpArrow (liftingType-to-type X l1) NotErased (liftingType-to-type X l2)
liftingType-to-type X (LiftTpArrow tp l) = TpArrow tp NotErased (liftingType-to-type X l)
liftingType-to-type X (LiftStar _) = TpVar posinfo-gen X
liftingType-to-type X (LiftParens _ l _) = liftingType-to-type X l
liftingType-to-type X (LiftPi _ x tp l) = Abs posinfo-gen Pi posinfo-gen x (Tkt tp) (liftingType-to-type X l)
{- create a type-level redex of the form
(↑ X . (λ xs . t) : ls → l) xs
where xs and ls are packaged as the input list of tuples, l is the
input liftingType, and t is the input term. -}
lift-freeze : var → 𝕃 (var × liftingType) → liftingType → term → type
lift-freeze X tobind l t =
let xs = map fst tobind in
TpApp* (Lft posinfo-gen posinfo-gen X (Lam* xs t) (LiftArrow* (map snd tobind) l))
(map (λ p → TpVar posinfo-gen (fst p)) tobind)
do-liftargs : ctxt → type → liftingType → 𝕃 term → var → 𝕃 (var × liftingType) → type
do-liftargs Γ tp (LiftArrow l1 l2) (arg :: args) X tobind =
do-liftargs Γ (TpApp tp (lift-freeze X tobind l1 arg)) l2 args X tobind
do-liftargs Γ tp (LiftTpArrow l1 l2) (arg :: args) X tobind =
do-liftargs Γ (TpAppt tp arg) l2 args X tobind
do-liftargs Γ tp (LiftPi _ x _ l) (arg :: args) X tobind =
do-liftargs Γ (TpAppt tp arg) (subst Γ arg x l) args X tobind
do-liftargs Γ tp (LiftParens _ l _) args X tobind = do-liftargs Γ tp l args X tobind
do-liftargs Γ tp _ _ _ _ = tp
-- tobind are the variables we have seen going through the lifting type (they are also mapped by the trie)
do-lifth : ctxt → trie liftingType →
𝕃 (var × liftingType) → type → var → liftingType →
(term → term) → -- function to put terms in hnf
term →
type
do-lifth Γ m tobind origtp X (LiftParens _ l _) hnf t = do-lifth Γ m tobind origtp X l hnf t
do-lifth Γ m tobind origtp X (LiftArrow l1 l2) hnf (Lam _ _ _ x _ t) =
do-lifth Γ (trie-insert m x l1) ((x , l1) :: tobind) origtp X l2 hnf t
do-lifth Γ m tobind origtp X (LiftTpArrow tp l2) hnf (Lam _ _ _ x _ t) =
TpLambda posinfo-gen posinfo-gen x (Tkt tp) (do-lifth Γ m tobind origtp X l2 hnf t)
do-lifth Γ m tobind origtp X l hnf t with decompose-apps (hnf t)
do-lifth Γ m tobind origtp X l hnf t | (Var _ x) , args with trie-lookup m x
do-lifth Γ m tobind origtp X l hnf t | (Var _ x) , args | nothing = origtp -- the term being lifted is not headed by one of the bound vars
do-lifth Γ m tobind origtp X l hnf t | (Var _ x) , args | just l' =
rebind tobind (do-liftargs Γ (TpVar posinfo-gen x) l' (reverse args) X tobind)
where rebind : 𝕃 (var × liftingType) → type → type
rebind ((x , l'):: xs) tp = rebind xs (TpLambda posinfo-gen posinfo-gen x (Tkk (liftingType-to-kind l')) tp)
rebind [] tp = tp
do-lifth Γ m tobind origtp X l hnf t | _ , args = origtp
-- lift a term to a type at the given liftingType, if possible.
do-lift : ctxt → type → var → liftingType → (term → term) {- hnf -} → term → type
do-lift Γ origtp X l hnf t = do-lifth Γ empty-trie [] origtp X l hnf t
| {
"alphanum_fraction": 0.6825270949,
"avg_line_length": 52.5416666667,
"ext": "agda",
"hexsha": "056ccdeb8d7a550832c7d090541ecaf5c641bf22",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "xoltar/cedille",
"max_forks_repo_path": "src/lift.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "xoltar/cedille",
"max_issues_repo_path": "src/lift.agda",
"max_line_length": 138,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "xoltar/cedille",
"max_stars_repo_path": "src/lift.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1285,
"size": 3783
} |
{--
-- normalize a finite type to (1 + (1 + (1 + ... + (1 + 0) ... )))
-- a bunch of ones ending with zero with left biased + in between
toℕ : U → ℕ
toℕ ZERO = 0
toℕ ONE = 1
toℕ (PLUS t₁ t₂) = toℕ t₁ + toℕ t₂
toℕ (TIMES t₁ t₂) = toℕ t₁ * toℕ t₂
fromℕ : ℕ → U
fromℕ 0 = ZERO
fromℕ (suc n) = PLUS ONE (fromℕ n)
normalℕ : U → U
normalℕ = fromℕ ∘ toℕ
-- invert toℕ: give t and n such that toℕ t = n, return constraints on components of t
reflectPlusZero : {m n : ℕ} → (m + n ≡ 0) → m ≡ 0 × n ≡ 0
reflectPlusZero {0} {0} refl = (refl , refl)
reflectPlusZero {0} {suc n} ()
reflectPlusZero {suc m} {0} ()
reflectPlusZero {suc m} {suc n} ()
-- nbe
nbe : {t₁ t₂ : U} → (p : toℕ t₁ ≡ toℕ t₂) → (⟦ t₁ ⟧ → ⟦ t₂ ⟧) → (t₁ ⟷ t₂)
nbe {ZERO} {ZERO} refl f = id⟷
nbe {ZERO} {ONE} ()
nbe {ZERO} {PLUS t₁ t₂} p f = {!!}
nbe {ZERO} {TIMES t₂ t₃} p f = {!!}
nbe {ONE} {ZERO} ()
nbe {ONE} {ONE} p f = id⟷
nbe {ONE} {PLUS t₂ t₃} p f = {!!}
nbe {ONE} {TIMES t₂ t₃} p f = {!!}
nbe {PLUS t₁ t₂} {ZERO} p f = {!!}
nbe {PLUS t₁ t₂} {ONE} p f = {!!}
nbe {PLUS t₁ t₂} {PLUS t₃ t₄} p f = {!!}
nbe {PLUS t₁ t₂} {TIMES t₃ t₄} p f = {!!}
nbe {TIMES t₁ t₂} {ZERO} p f = {!!}
nbe {TIMES t₁ t₂} {ONE} p f = {!!}
nbe {TIMES t₁ t₂} {PLUS t₃ t₄} p f = {!!}
nbe {TIMES t₁ t₂} {TIMES t₃ t₄} p f = {!!}
-- build a combinator that does the normalization
assocrU : {m : ℕ} (n : ℕ) → (PLUS (fromℕ n) (fromℕ m)) ⟷ fromℕ (n + m)
assocrU 0 = unite₊
assocrU (suc n) = assocr₊ ◎ (id⟷ ⊕ assocrU n)
distrU : (m : ℕ) {n : ℕ} → TIMES (fromℕ m) (fromℕ n) ⟷ fromℕ (m * n)
distrU 0 = distz
distrU (suc n) {m} = dist ◎ (unite⋆ ⊕ distrU n) ◎ assocrU m
normalU : (t : U) → t ⟷ normalℕ t
normalU ZERO = id⟷
normalU ONE = uniti₊ ◎ swap₊
normalU (PLUS t₁ t₂) = (normalU t₁ ⊕ normalU t₂) ◎ assocrU (toℕ t₁)
normalU (TIMES t₁ t₂) = (normalU t₁ ⊗ normalU t₂) ◎ distrU (toℕ t₁)
-- a few lemmas
fromℕplus : {m n : ℕ} → fromℕ (m + n) ⟷ PLUS (fromℕ m) (fromℕ n)
fromℕplus {0} {n} =
fromℕ n
⟷⟨ uniti₊ ⟩
PLUS ZERO (fromℕ n) □
fromℕplus {suc m} {n} =
fromℕ (suc (m + n))
⟷⟨ id⟷ ⟩
PLUS ONE (fromℕ (m + n))
⟷⟨ id⟷ ⊕ fromℕplus {m} {n} ⟩
PLUS ONE (PLUS (fromℕ m) (fromℕ n))
⟷⟨ assocl₊ ⟩
PLUS (PLUS ONE (fromℕ m)) (fromℕ n)
⟷⟨ id⟷ ⟩
PLUS (fromℕ (suc m)) (fromℕ n) □
normalℕswap : {t₁ t₂ : U} → normalℕ (PLUS t₁ t₂) ⟷ normalℕ (PLUS t₂ t₁)
normalℕswap {t₁} {t₂} =
fromℕ (toℕ t₁ + toℕ t₂)
⟷⟨ fromℕplus {toℕ t₁} {toℕ t₂} ⟩
PLUS (normalℕ t₁) (normalℕ t₂)
⟷⟨ swap₊ ⟩
PLUS (normalℕ t₂) (normalℕ t₁)
⟷⟨ ! (fromℕplus {toℕ t₂} {toℕ t₁}) ⟩
fromℕ (toℕ t₂ + toℕ t₁) □
assocrUS : {m : ℕ} {t : U} → PLUS t (fromℕ m) ⟷ fromℕ (toℕ t + m)
assocrUS {m} {ZERO} = unite₊
assocrUS {m} {ONE} = id⟷
assocrUS {m} {t} =
PLUS t (fromℕ m)
⟷⟨ normalU t ⊕ id⟷ ⟩
PLUS (normalℕ t) (fromℕ m)
⟷⟨ ! fromℕplus ⟩
fromℕ (toℕ t + m) □
-- convert each combinator to a normal form
normal⟷ : {t₁ t₂ : U} → (c₁ : t₁ ⟷ t₂) →
Σ[ c₂ ∈ normalℕ t₁ ⟷ normalℕ t₂ ] (c₁ ⇔ (normalU t₁ ◎ c₂ ◎ (! (normalU t₂))))
normal⟷ {PLUS ZERO t} {.t} unite₊ =
(id⟷ ,
(unite₊
⇔⟨ idr◎r ⟩
unite₊ ◎ id⟷
⇔⟨ resp◎⇔ id⇔ linv◎r ⟩
unite₊ ◎ (normalU t ◎ (! (normalU t)))
⇔⟨ assoc◎l ⟩
(unite₊ ◎ normalU t) ◎ (! (normalU t))
⇔⟨ resp◎⇔ unitel₊⇔ id⇔ ⟩
((id⟷ ⊕ normalU t) ◎ unite₊) ◎ (! (normalU t))
⇔⟨ resp◎⇔ id⇔ idl◎r ⟩
((id⟷ ⊕ normalU t) ◎ unite₊) ◎ (id⟷ ◎ (! (normalU t)))
⇔⟨ id⇔ ⟩
normalU (PLUS ZERO t) ◎ (id⟷ ◎ (! (normalU t))) ▤))
normal⟷ {t} {PLUS ZERO .t} uniti₊ =
(id⟷ ,
(uniti₊
⇔⟨ idl◎r ⟩
id⟷ ◎ uniti₊
⇔⟨ resp◎⇔ linv◎r id⇔ ⟩
(normalU t ◎ (! (normalU t))) ◎ uniti₊
⇔⟨ assoc◎r ⟩
normalU t ◎ ((! (normalU t)) ◎ uniti₊)
⇔⟨ resp◎⇔ id⇔ unitir₊⇔ ⟩
normalU t ◎ (uniti₊ ◎ (id⟷ ⊕ (! (normalU t))))
⇔⟨ resp◎⇔ id⇔ idl◎r ⟩
normalU t ◎ (id⟷ ◎ (uniti₊ ◎ (id⟷ ⊕ (! (normalU t)))))
⇔⟨ id⇔ ⟩
normalU t ◎ (id⟷ ◎ (! ((id⟷ ⊕ (normalU t)) ◎ unite₊)))
⇔⟨ id⇔ ⟩
normalU t ◎ (id⟷ ◎ (! (normalU (PLUS ZERO t)))) ▤))
normal⟷ {PLUS ZERO t₂} {PLUS .t₂ ZERO} swap₊ =
(normalℕswap {ZERO} {t₂} ,
(swap₊
⇔⟨ {!!} ⟩
(unite₊ ◎ normalU t₂) ◎
(normalℕswap {ZERO} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ id⟷)))
⇔⟨ resp◎⇔ unitel₊⇔ id⇔ ⟩
((id⟷ ⊕ normalU t₂) ◎ unite₊) ◎
(normalℕswap {ZERO} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ id⟷)))
⇔⟨ id⇔ ⟩
normalU (PLUS ZERO t₂) ◎ (normalℕswap {ZERO} {t₂} ◎ (! (normalU (PLUS t₂ ZERO)))) ▤))
normal⟷ {PLUS ONE t₂} {PLUS .t₂ ONE} swap₊ =
(normalℕswap {ONE} {t₂} ,
(swap₊
⇔⟨ {!!} ⟩
((normalU ONE ⊕ normalU t₂) ◎ assocrU (toℕ ONE)) ◎
(normalℕswap {ONE} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ ! (normalU ONE))))
⇔⟨ id⇔ ⟩
normalU (PLUS ONE t₂) ◎ (normalℕswap {ONE} {t₂} ◎ (! (normalU (PLUS t₂ ONE)))) ▤))
normal⟷ {PLUS t₁ t₂} {PLUS .t₂ .t₁} swap₊ =
(normalℕswap {t₁} {t₂} ,
(swap₊
⇔⟨ {!!} ⟩
((normalU t₁ ⊕ normalU t₂) ◎ assocrU (toℕ t₁)) ◎
(normalℕswap {t₁} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ ! (normalU t₁))))
⇔⟨ id⇔ ⟩
normalU (PLUS t₁ t₂) ◎ (normalℕswap {t₁} {t₂} ◎ (! (normalU (PLUS t₂ t₁)))) ▤))
normal⟷ {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃} assocl₊ = {!!}
normal⟷ {PLUS (PLUS t₁ t₂) t₃} {PLUS .t₁ (PLUS .t₂ .t₃)} assocr₊ = {!!}
normal⟷ {TIMES ONE t} {.t} unite⋆ = {!!}
normal⟷ {t} {TIMES ONE .t} uniti⋆ = {!!}
normal⟷ {TIMES t₁ t₂} {TIMES .t₂ .t₁} swap⋆ = {!!}
normal⟷ {TIMES t₁ (TIMES t₂ t₃)} {TIMES (TIMES .t₁ .t₂) .t₃} assocl⋆ = {!!}
normal⟷ {TIMES (TIMES t₁ t₂) t₃} {TIMES .t₁ (TIMES .t₂ .t₃)} assocr⋆ = {!!}
normal⟷ {TIMES ZERO t} {ZERO} distz = {!!}
normal⟷ {ZERO} {TIMES ZERO t} factorz = {!!}
normal⟷ {TIMES (PLUS t₁ t₂) t₃} {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)} dist = {!!}
normal⟷ {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)} {TIMES (PLUS t₁ t₂) t₃} factor = {!!}
normal⟷ {t} {.t} id⟷ =
(id⟷ ,
(id⟷
⇔⟨ linv◎r ⟩
normalU t ◎ (! (normalU t))
⇔⟨ resp◎⇔ id⇔ idl◎r ⟩
normalU t ◎ (id⟷ ◎ (! (normalU t))) ▤))
normal⟷ {t₁} {t₃} (_◎_ {t₂ = t₂} c₁ c₂) = {!!}
normal⟷ {PLUS t₁ t₂} {PLUS t₃ t₄} (c₁ ⊕ c₂) = {!!}
normal⟷ {TIMES t₁ t₂} {TIMES t₃ t₄} (c₁ ⊗ c₂) = {!!}
-- if c₁ c₂ : t₁ ⟷ t₂ and c₁ ∼ c₂ then we want a canonical combinator
-- normalℕ t₁ ⟷ normalℕ t₂. If we have that then we should be able to
-- decide whether c₁ ∼ c₂ by normalizing and looking at the canonical
-- combinator.
-- Use ⇔ to normalize a path
{-# NO_TERMINATION_CHECK #-}
normalize : {t₁ t₂ : U} → (c₁ : t₁ ⟷ t₂) → Σ[ c₂ ∈ t₁ ⟷ t₂ ] (c₁ ⇔ c₂)
normalize unite₊ = (unite₊ , id⇔)
normalize uniti₊ = (uniti₊ , id⇔)
normalize swap₊ = (swap₊ , id⇔)
normalize assocl₊ = (assocl₊ , id⇔)
normalize assocr₊ = (assocr₊ , id⇔)
normalize unite⋆ = (unite⋆ , id⇔)
normalize uniti⋆ = (uniti⋆ , id⇔)
normalize swap⋆ = (swap⋆ , id⇔)
normalize assocl⋆ = (assocl⋆ , id⇔)
normalize assocr⋆ = (assocr⋆ , id⇔)
normalize distz = (distz , id⇔)
normalize factorz = (factorz , id⇔)
normalize dist = (dist , id⇔)
normalize factor = (factor , id⇔)
normalize id⟷ = (id⟷ , id⇔)
normalize (c₁ ◎ c₂) with normalize c₁ | normalize c₂
... | (c₁' , α) | (c₂' , β) = {!!}
normalize (c₁ ⊕ c₂) with normalize c₁ | normalize c₂
... | (c₁' , α) | (c₂₁ ⊕ c₂₂ , β) =
(assocl₊ ◎ ((c₁' ⊕ c₂₁) ⊕ c₂₂) ◎ assocr₊ , trans⇔ (resp⊕⇔ α β) assoc⊕l)
... | (c₁' , α) | (c₂' , β) = (c₁' ⊕ c₂' , resp⊕⇔ α β)
normalize (c₁ ⊗ c₂) with normalize c₁ | normalize c₂
... | (c₁₁ ⊕ c₁₂ , α) | (c₂' , β) =
(dist ◎ ((c₁₁ ⊗ c₂') ⊕ (c₁₂ ⊗ c₂')) ◎ factor ,
trans⇔ (resp⊗⇔ α β) dist⇔)
... | (c₁' , α) | (c₂₁ ⊗ c₂₂ , β) =
(assocl⋆ ◎ ((c₁' ⊗ c₂₁) ⊗ c₂₂) ◎ assocr⋆ , trans⇔ (resp⊗⇔ α β) assoc⊗l)
... | (c₁' , α) | (c₂' , β) = (c₁' ⊗ c₂' , resp⊗⇔ α β)
record Permutation (t t' : U) : Set where
field
t₀ : U -- no occurrences of TIMES .. (TIMES .. ..)
phase₀ : t ⟷ t₀
t₁ : U -- no occurrences of TIMES (PLUS .. ..)
phase₁ : t₀ ⟷ t₁
t₂ : U -- no occurrences of TIMES
phase₂ : t₁ ⟷ t₂
t₃ : U -- no nested left PLUS, all PLUS of form PLUS simple (PLUS ...)
phase₃ : t₂ ⟷ t₃
t₄ : U -- no occurrences PLUS ZERO
phase₄ : t₃ ⟷ t₄
t₅ : U -- do actual permutation using swapij
phase₅ : t₄ ⟷ t₅
rest : t₅ ⟷ t' -- blah blah
p◎id∼p : ∀ {t₁ t₂} {c : t₁ ⟷ t₂} → (c ◎ id⟷ ∼ c)
p◎id∼p {t₁} {t₂} {c} v =
(begin (proj₁ (perm2path (c ◎ id⟷) v))
≡⟨ {!!} ⟩
(proj₁ (perm2path id⟷ (proj₁ (perm2path c v))))
≡⟨ {!!} ⟩
(proj₁ (perm2path c v)) ∎)
-- perm2path {t} id⟷ v = (v , edge •[ t , v ] •[ t , v ])
--perm2path (_◎_ {t₁} {t₂} {t₃} c₁ c₂) v₁ with perm2path c₁ v₁
--... | (v₂ , p) with perm2path c₂ v₂
--... | (v₃ , q) = (v₃ , seq p q)
-- Equivalences between paths leading to 2path structure
-- Two paths are the same if they go through the same points
_∼_ : ∀ {t₁ t₂ v₁ v₂} →
(p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) →
(q : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) →
Set
(edge ._ ._) ∼ (edge ._ ._) = ⊤
(edge ._ ._) ∼ (seq p q) = {!!}
(edge ._ ._) ∼ (left p) = {!!}
(edge ._ ._) ∼ (right p) = {!!}
(edge ._ ._) ∼ (par p q) = {!!}
seq p p₁ ∼ edge ._ ._ = {!!}
seq p₁ p ∼ seq q q₁ = {!!}
seq p p₁ ∼ left q = {!!}
seq p p₁ ∼ right q = {!!}
seq p p₁ ∼ par q q₁ = {!!}
left p ∼ edge ._ ._ = {!!}
left p ∼ seq q q₁ = {!!}
left p ∼ left q = {!!}
right p ∼ edge ._ ._ = {!!}
right p ∼ seq q q₁ = {!!}
right p ∼ right q = {!!}
par p p₁ ∼ edge ._ ._ = {!!}
par p p₁ ∼ seq q q₁ = {!!}
par p p₁ ∼ par q q₁ = {!!}
-- Equivalences between paths leading to 2path structure
-- Following the HoTT approach two paths are considered the same if they
-- map the same points to equal points
infix 4 _∼_
_∼_ : ∀ {t₁ t₂ v₁ v₂ v₂'} →
(p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) →
(q : Path •[ t₁ , v₁ ] •[ t₂ , v₂' ]) →
Set
_∼_ {t₁} {t₂} {v₁} {v₂} {v₂'} p q = (v₂ ≡ v₂')
-- Lemma 2.4.2
p∼p : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ p
p∼p {p = path c} _ = refl
p∼q→q∼p : {t₁ t₂ : U} {p q : Path t₁ t₂} → (p ∼ q) → (q ∼ p)
p∼q→q∼p {p = path c₁} {q = path c₂} α v = sym (α v)
p∼q∼r→p∼r : {t₁ t₂ : U} {p q r : Path t₁ t₂} →
(p ∼ q) → (q ∼ r) → (p ∼ r)
p∼q∼r→p∼r {p = path c₁} {q = path c₂} {r = path c₃} α β v = trans (α v) (β v)
-- lift inverses and compositions to paths
inv : {t₁ t₂ : U} → Path t₁ t₂ → Path t₂ t₁
inv (path c) = path (! c)
infixr 10 _●_
_●_ : {t₁ t₂ t₃ : U} → Path t₁ t₂ → Path t₂ t₃ → Path t₁ t₃
path c₁ ● path c₂ = path (c₁ ◎ c₂)
-- Lemma 2.1.4
p∼p◎id : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ p ● path id⟷
p∼p◎id {t₁} {t₂} {path c} v =
(begin (perm2path c v)
≡⟨ refl ⟩
(perm2path c (perm2path id⟷ v))
≡⟨ refl ⟩
(perm2path (c ◎ id⟷) v) ∎)
p∼id◎p : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ path id⟷ ● p
p∼id◎p {t₁} {t₂} {path c} v =
(begin (perm2path c v)
≡⟨ refl ⟩
(perm2path id⟷ (perm2path c v))
≡⟨ refl ⟩
(perm2path (id⟷ ◎ c) v) ∎)
!p◎p∼id : {t₁ t₂ : U} {p : Path t₁ t₂} → (inv p) ● p ∼ path id⟷
!p◎p∼id {t₁} {t₂} {path c} v =
(begin (perm2path ((! c) ◎ c) v)
≡⟨ refl ⟩
(perm2path c (perm2path (! c) v))
≡⟨ invr {t₁} {t₂} {c} {v} ⟩
(perm2path id⟷ v) ∎)
p◎!p∼id : {t₁ t₂ : U} {p : Path t₁ t₂} → p ● (inv p) ∼ path id⟷
p◎!p∼id {t₁} {t₂} {path c} v =
(begin (perm2path (c ◎ (! c)) v)
≡⟨ refl ⟩
(perm2path (! c) (perm2path c v))
≡⟨ invl {t₁} {t₂} {c} {v} ⟩
(perm2path id⟷ v) ∎)
!!p∼p : {t₁ t₂ : U} {p : Path t₁ t₂} → inv (inv p) ∼ p
!!p∼p {t₁} {t₂} {path c} v =
begin (perm2path (! (! c)) v
≡⟨ cong (λ x → perm2path x v) (!! {c = c}) ⟩
perm2path c v ∎)
assoc◎ : {t₁ t₂ t₃ t₄ : U} {p : Path t₁ t₂} {q : Path t₂ t₃} {r : Path t₃ t₄} →
p ● (q ● r) ∼ (p ● q) ● r
assoc◎ {t₁} {t₂} {t₃} {t₄} {path c₁} {path c₂} {path c₃} v =
begin (perm2path (c₁ ◎ (c₂ ◎ c₃)) v
≡⟨ refl ⟩
perm2path (c₂ ◎ c₃) (perm2path c₁ v)
≡⟨ refl ⟩
perm2path c₃ (perm2path c₂ (perm2path c₁ v))
≡⟨ refl ⟩
perm2path c₃ (perm2path (c₁ ◎ c₂) v)
≡⟨ refl ⟩
perm2path ((c₁ ◎ c₂) ◎ c₃) v ∎)
resp◎ : {t₁ t₂ t₃ : U} {p q : Path t₁ t₂} {r s : Path t₂ t₃} →
p ∼ q → r ∼ s → (p ● r) ∼ (q ● s)
resp◎ {t₁} {t₂} {t₃} {path c₁} {path c₂} {path c₃} {path c₄} α β v =
begin (perm2path (c₁ ◎ c₃) v
≡⟨ refl ⟩
perm2path c₃ (perm2path c₁ v)
≡⟨ cong (λ x → perm2path c₃ x) (α v) ⟩
perm2path c₃ (perm2path c₂ v)
≡⟨ β (perm2path c₂ v) ⟩
perm2path c₄ (perm2path c₂ v)
≡⟨ refl ⟩
perm2path (c₂ ◎ c₄) v ∎)
-- Recall that two perminators are the same if they denote the same
-- permutation; in that case there is a 2path between them in the relevant
-- path space
data _⇔_ {t₁ t₂ : U} : Path t₁ t₂ → Path t₁ t₂ → Set where
2path : {p q : Path t₁ t₂} → (p ∼ q) → (p ⇔ q)
-- Examples
p q r : Path BOOL BOOL
p = path id⟷
q = path swap₊
r = path (swap₊ ◎ id⟷)
α : q ⇔ r
α = 2path (p∼p◎id {p = path swap₊})
-- The equivalence of paths makes U a 1groupoid: the points are types t : U;
-- the 1paths are ⟷; and the 2paths between them are ⇔
G : 1Groupoid
G = record
{ set = U
; _↝_ = Path
; _≈_ = _⇔_
; id = path id⟷
; _∘_ = λ q p → p ● q
; _⁻¹ = inv
; lneutr = λ p → 2path (p∼q→q∼p p∼p◎id)
; rneutr = λ p → 2path (p∼q→q∼p p∼id◎p)
; assoc = λ r q p → 2path assoc◎
; equiv = record {
refl = 2path p∼p
; sym = λ { (2path α) → 2path (p∼q→q∼p α) }
; trans = λ { (2path α) (2path β) → 2path (p∼q∼r→p∼r α β) }
}
; linv = λ p → 2path p◎!p∼id
; rinv = λ p → 2path !p◎p∼id
; ∘-resp-≈ = λ { (2path β) (2path α) → 2path (resp◎ α β) }
}
------------------------------------------------------------------------------
data ΩU : Set where
ΩZERO : ΩU -- empty set of paths
ΩONE : ΩU -- a trivial path
ΩPLUS : ΩU → ΩU → ΩU -- disjoint union of paths
ΩTIMES : ΩU → ΩU → ΩU -- pairs of paths
PATH : (t₁ t₂ : U) → ΩU -- level 0 paths between values
-- values
Ω⟦_⟧ : ΩU → Set
Ω⟦ ΩZERO ⟧ = ⊥
Ω⟦ ΩONE ⟧ = ⊤
Ω⟦ ΩPLUS t₁ t₂ ⟧ = Ω⟦ t₁ ⟧ ⊎ Ω⟦ t₂ ⟧
Ω⟦ ΩTIMES t₁ t₂ ⟧ = Ω⟦ t₁ ⟧ × Ω⟦ t₂ ⟧
Ω⟦ PATH t₁ t₂ ⟧ = Path t₁ t₂
-- two perminators are the same if they denote the same permutation
-- 2paths
data _⇔_ : ΩU → ΩU → Set where
unite₊ : {t : ΩU} → ΩPLUS ΩZERO t ⇔ t
uniti₊ : {t : ΩU} → t ⇔ ΩPLUS ΩZERO t
swap₊ : {t₁ t₂ : ΩU} → ΩPLUS t₁ t₂ ⇔ ΩPLUS t₂ t₁
assocl₊ : {t₁ t₂ t₃ : ΩU} → ΩPLUS t₁ (ΩPLUS t₂ t₃) ⇔ ΩPLUS (ΩPLUS t₁ t₂) t₃
assocr₊ : {t₁ t₂ t₃ : ΩU} → ΩPLUS (ΩPLUS t₁ t₂) t₃ ⇔ ΩPLUS t₁ (ΩPLUS t₂ t₃)
unite⋆ : {t : ΩU} → ΩTIMES ΩONE t ⇔ t
uniti⋆ : {t : ΩU} → t ⇔ ΩTIMES ΩONE t
swap⋆ : {t₁ t₂ : ΩU} → ΩTIMES t₁ t₂ ⇔ ΩTIMES t₂ t₁
assocl⋆ : {t₁ t₂ t₃ : ΩU} → ΩTIMES t₁ (ΩTIMES t₂ t₃) ⇔ ΩTIMES (ΩTIMES t₁ t₂) t₃
assocr⋆ : {t₁ t₂ t₃ : ΩU} → ΩTIMES (ΩTIMES t₁ t₂) t₃ ⇔ ΩTIMES t₁ (ΩTIMES t₂ t₃)
distz : {t : ΩU} → ΩTIMES ΩZERO t ⇔ ΩZERO
factorz : {t : ΩU} → ΩZERO ⇔ ΩTIMES ΩZERO t
dist : {t₁ t₂ t₃ : ΩU} →
ΩTIMES (ΩPLUS t₁ t₂) t₃ ⇔ ΩPLUS (ΩTIMES t₁ t₃) (ΩTIMES t₂ t₃)
factor : {t₁ t₂ t₃ : ΩU} →
ΩPLUS (ΩTIMES t₁ t₃) (ΩTIMES t₂ t₃) ⇔ ΩTIMES (ΩPLUS t₁ t₂) t₃
id⇔ : {t : ΩU} → t ⇔ t
_◎_ : {t₁ t₂ t₃ : ΩU} → (t₁ ⇔ t₂) → (t₂ ⇔ t₃) → (t₁ ⇔ t₃)
_⊕_ : {t₁ t₂ t₃ t₄ : ΩU} →
(t₁ ⇔ t₃) → (t₂ ⇔ t₄) → (ΩPLUS t₁ t₂ ⇔ ΩPLUS t₃ t₄)
_⊗_ : {t₁ t₂ t₃ t₄ : ΩU} →
(t₁ ⇔ t₃) → (t₂ ⇔ t₄) → (ΩTIMES t₁ t₂ ⇔ ΩTIMES t₃ t₄)
_∼⇔_ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) →
PATH t₁ t₂ ⇔ PATH t₁ t₂
-- two spaces are equivalent if there is a path between them; this path
-- automatically has an inverse which is an equivalence. It is a
-- quasi-equivalence but for finite types that's the same as an equivalence.
infix 4 _≃_
_≃_ : (t₁ t₂ : U) → Set
t₁ ≃ t₂ = (t₁ ⟷ t₂)
-- Univalence says (t₁ ≃ t₂) ≃ (t₁ ⟷ t₂) but as shown above, we actually have
-- this by definition instead of up to ≃
------------------------------------------------------------------------------
------------------------------------------------------------------------------
------------------------------------------------------------------------------
another idea is to look at c and massage it as follows: rewrite every
swap+ ; c
to
c' ; swaps ; c''
general start with
id || id || c
examine c and move anything that's not swap to left. If we get to
c' || id || id
we are done
if we get to:
c' || id || swap+;c
then we rewrite
c';c1 || swaps || c2;c
and we keep going
module Phase₁ where
-- no occurrences of (TIMES (TIMES t₁ t₂) t₃)
approach that maintains the invariants in proofs
invariant : (t : U) → Bool
invariant ZERO = true
invariant ONE = true
invariant (PLUS t₁ t₂) = invariant t₁ ∧ invariant t₂
invariant (TIMES ZERO t₂) = invariant t₂
invariant (TIMES ONE t₂) = invariant t₂
invariant (TIMES (PLUS t₁ t₂) t₃) = (invariant t₁ ∧ invariant t₂) ∧ invariant t₃
invariant (TIMES (TIMES t₁ t₂) t₃) = false
Invariant : (t : U) → Set
Invariant t = invariant t ≡ true
invariant? : Decidable Invariant
invariant? t with invariant t
... | true = yes refl
... | false = no (λ ())
conj : ∀ {b₁ b₂} → (b₁ ≡ true) → (b₂ ≡ true) → (b₁ ∧ b₂ ≡ true)
conj {true} {true} p q = refl
conj {true} {false} p ()
conj {false} {true} ()
conj {false} {false} ()
phase₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (True (invariant? t₂) × t₁ ⟷ t₂)
phase₁ ZERO = (ZERO , (fromWitness {Q = invariant? ZERO} refl , id⟷))
phase₁ ONE = (ONE , (fromWitness {Q = invariant? ONE} refl , id⟷))
phase₁ (PLUS t₁ t₂) with phase₁ t₁ | phase₁ t₂
... | (t₁' , (p₁ , c₁)) | (t₂' , (p₂ , c₂)) with toWitness p₁ | toWitness p₂
... | t₁'ok | t₂'ok =
(PLUS t₁' t₂' ,
(fromWitness {Q = invariant? (PLUS t₁' t₂')} (conj t₁'ok t₂'ok) ,
c₁ ⊕ c₂))
phase₁ (TIMES ZERO t) with phase₁ t
... | (t' , (p , c)) with toWitness p
... | t'ok =
(TIMES ZERO t' ,
(fromWitness {Q = invariant? (TIMES ZERO t')} t'ok ,
id⟷ ⊗ c))
phase₁ (TIMES ONE t) with phase₁ t
... | (t' , (p , c)) with toWitness p
... | t'ok =
(TIMES ONE t' ,
(fromWitness {Q = invariant? (TIMES ONE t')} t'ok ,
id⟷ ⊗ c))
phase₁ (TIMES (PLUS t₁ t₂) t₃) with phase₁ t₁ | phase₁ t₂ | phase₁ t₃
... | (t₁' , (p₁ , c₁)) | (t₂' , (p₂ , c₂)) | (t₃' , (p₃ , c₃))
with toWitness p₁ | toWitness p₂ | toWitness p₃
... | t₁'ok | t₂'ok | t₃'ok =
(TIMES (PLUS t₁' t₂') t₃' ,
(fromWitness {Q = invariant? (TIMES (PLUS t₁' t₂') t₃')}
(conj (conj t₁'ok t₂'ok) t₃'ok) ,
(c₁ ⊕ c₂) ⊗ c₃))
phase₁ (TIMES (TIMES t₁ t₂) t₃) = {!!}
-- invariants are informal
-- rewrite (TIMES (TIMES t₁ t₂) t₃) to TIMES t₁ (TIMES t₂ t₃)
invariant : (t : U) → Bool
invariant ZERO = true
invariant ONE = true
invariant (PLUS t₁ t₂) = invariant t₁ ∧ invariant t₂
invariant (TIMES ZERO t₂) = invariant t₂
invariant (TIMES ONE t₂) = invariant t₂
invariant (TIMES (PLUS t₁ t₂) t₃) = invariant t₁ ∧ invariant t₂ ∧ invariant t₃
invariant (TIMES (TIMES t₁ t₂) t₃) = false
step₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (t₁ ⟷ t₂)
step₁ ZERO = (ZERO , id⟷)
step₁ ONE = (ONE , id⟷)
step₁ (PLUS t₁ t₂) with step₁ t₁ | step₁ t₂
... | (t₁' , c₁) | (t₂' , c₂) = (PLUS t₁' t₂' , c₁ ⊕ c₂)
step₁ (TIMES (TIMES t₁ t₂) t₃) with step₁ t₁ | step₁ t₂ | step₁ t₃
... | (t₁' , c₁) | (t₂' , c₂) | (t₃' , c₃) =
(TIMES t₁' (TIMES t₂' t₃') , ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)
step₁ (TIMES ZERO t₂) with step₁ t₂
... | (t₂' , c₂) = (TIMES ZERO t₂' , id⟷ ⊗ c₂)
step₁ (TIMES ONE t₂) with step₁ t₂
... | (t₂' , c₂) = (TIMES ONE t₂' , id⟷ ⊗ c₂)
step₁ (TIMES (PLUS t₁ t₂) t₃) with step₁ t₁ | step₁ t₂ | step₁ t₃
... | (t₁' , c₁) | (t₂' , c₂) | (t₃' , c₃) =
(TIMES (PLUS t₁' t₂') t₃' , (c₁ ⊕ c₂) ⊗ c₃)
{-# NO_TERMINATION_CHECK #-}
phase₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (t₁ ⟷ t₂)
phase₁ t with invariant t
... | true = (t , id⟷)
... | false with step₁ t
... | (t' , c) with phase₁ t'
... | (t'' , c') = (t'' , c ◎ c')
test₁ = phase₁ (TIMES (TIMES (TIMES ONE ONE) (TIMES ONE ONE)) ONE)
TIMES ONE (TIMES ONE (TIMES ONE (TIMES ONE ONE))) ,
(((id⟷ ⊗ id⟷) ⊗ (id⟷ ⊗ id⟷)) ⊗ id⟷ ◎ assocr⋆) ◎
((id⟷ ⊗ id⟷) ⊗ ((id⟷ ⊗ id⟷) ⊗ id⟷ ◎ assocr⋆) ◎ assocr⋆) ◎ id⟷
-- Now any perminator (t₁ ⟷ t₂) can be transformed to a canonical
-- representation in which we first associate all the TIMES to the right
-- and then do the rest of the perminator
normalize₁ : {t₁ t₂ : U} → (t₁ ⟷ t₂) →
(Σ[ t₁' ∈ U ] (t₁ ⟷ t₁' × t₁' ⟷ t₂))
normalize₁ {ZERO} {t} c = ZERO , id⟷ , c
normalize₁ {ONE} c = ONE , id⟷ , c
normalize₁ {PLUS .ZERO t₂} unite₊ with phase₁ t₂
... | (t₂n , cn) = PLUS ZERO t₂n , id⟷ ⊕ cn , unite₊ ◎ ! cn
normalize₁ {PLUS t₁ t₂} uniti₊ = {!!}
normalize₁ {PLUS t₁ t₂} swap₊ = {!!}
normalize₁ {PLUS t₁ ._} assocl₊ = {!!}
normalize₁ {PLUS ._ t₂} assocr₊ = {!!}
normalize₁ {PLUS t₁ t₂} uniti⋆ = {!!}
normalize₁ {PLUS ._ ._} factor = {!!}
normalize₁ {PLUS t₁ t₂} id⟷ = {!!}
normalize₁ {PLUS t₁ t₂} (c ◎ c₁) = {!!}
normalize₁ {PLUS t₁ t₂} (c ⊕ c₁) = {!!}
normalize₁ {TIMES t₁ t₂} c = {!!}
record Permutation (t t' : U) : Set where
field
t₀ : U -- no occurrences of TIMES .. (TIMES .. ..)
phase₀ : t ⟷ t₀
t₁ : U -- no occurrences of TIMES (PLUS .. ..)
phase₁ : t₀ ⟷ t₁
t₂ : U -- no occurrences of TIMES
phase₂ : t₁ ⟷ t₂
t₃ : U -- no nested left PLUS, all PLUS of form PLUS simple (PLUS ...)
phase₃ : t₂ ⟷ t₃
t₄ : U -- no occurrences PLUS ZERO
phase₄ : t₃ ⟷ t₄
t₅ : U -- do actual permutation using swapij
phase₅ : t₄ ⟷ t₅
rest : t₅ ⟷ t' -- blah blah
canonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → Permutation t₁ t₂
canonical c = {!!}
------------------------------------------------------------------------------
-- These paths do NOT reach "inside" the finite sets. For example, there is
-- NO PATH between false and true in BOOL even though there is a path between
-- BOOL and BOOL that "twists the space around."
--
-- In more detail how do these paths between types relate to the whole
-- discussion about higher groupoid structure of type formers (Sec. 2.5 and
-- on).
-- Then revisit the early parts of Ch. 2 about higher groupoid structure for
-- U, how functions from U to U respect the paths in U, type families and
-- dependent functions, homotopies and equivalences, and then Sec. 2.5 and
-- beyond again.
should this be on the code as done now or on their interpreation
i.e. data _⟷_ : ⟦ U ⟧ → ⟦ U ⟧ → Set where
can add recursive types
rec : U
⟦_⟧ takes an additional argument X that is passed around
⟦ rec ⟧ X = X
fixpoitn
data μ (t : U) : Set where
⟨_⟩ : ⟦ t ⟧ (μ t) → μ t
-- We identify functions with the paths above. Since every function is
-- reversible, every function corresponds to a path and there is no
-- separation between functions and paths and no need to mediate between them
-- using univalence.
--
-- Note that none of the above functions are dependent functions.
------------------------------------------------------------------------------
-- Now we consider homotopies, i.e., paths between functions. Since our
-- functions are identified with the paths ⟷, the homotopies are paths
-- between elements of ⟷
-- First, a sanity check. Our notion of paths matches the notion of
-- equivalences in the conventional HoTT presentation
-- Homotopy between two functions (paths)
-- That makes id ∼ not which is bad. The def. of ∼ should be parametric...
_∼_ : {t₁ t₂ t₃ : U} → (f : t₁ ⟷ t₂) → (g : t₁ ⟷ t₃) → Set
_∼_ {t₁} {t₂} {t₃} f g = t₂ ⟷ t₃
-- Every f and g of the right type are related by ∼
homotopy : {t₁ t₂ t₃ : U} → (f : t₁ ⟷ t₂) → (g : t₁ ⟷ t₃) → (f ∼ g)
homotopy f g = (! f) ◎ g
-- Equivalences
--
-- If f : t₁ ⟷ t₂ has two inverses g₁ g₂ : t₂ ⟷ t₁ then g₁ ∼ g₂. More
-- generally, any two paths of the same type are related by ∼.
equiv : {t₁ t₂ : U} → (f g : t₁ ⟷ t₂) → (f ∼ g)
equiv f g = id⟷
-- It follows that any two types in U are equivalent if there is a path
-- between them
_≃_ : (t₁ t₂ : U) → Set
t₁ ≃ t₂ = t₁ ⟷ t₂
-- Now we want to understand the type of paths between paths
------------------------------------------------------------------------------
elems : (t : U) → List ⟦ t ⟧
elems ZERO = []
elems ONE = [ tt ]
elems (PLUS t₁ t₂) = map inj₁ (elems t₁) ++ map inj₂ (elems t₂)
elems (TIMES t₁ t₂) = concat
(map
(λ v₂ → map (λ v₁ → (v₁ , v₂)) (elems t₁))
(elems t₂))
_≟_ : {t : U} → ⟦ t ⟧ → ⟦ t ⟧ → Bool
_≟_ {ZERO} ()
_≟_ {ONE} tt tt = true
_≟_ {PLUS t₁ t₂} (inj₁ v) (inj₁ w) = v ≟ w
_≟_ {PLUS t₁ t₂} (inj₁ v) (inj₂ w) = false
_≟_ {PLUS t₁ t₂} (inj₂ v) (inj₁ w) = false
_≟_ {PLUS t₁ t₂} (inj₂ v) (inj₂ w) = v ≟ w
_≟_ {TIMES t₁ t₂} (v₁ , w₁) (v₂ , w₂) = v₁ ≟ v₂ ∧ w₁ ≟ w₂
findLoops : {t t₁ t₂ : U} → (PLUS t t₁ ⟷ PLUS t t₂) → List ⟦ t ⟧ →
List (Σ[ t ∈ U ] ⟦ t ⟧)
findLoops c [] = []
findLoops {t} c (v ∷ vs) = ? with perm2path c (inj₁ v)
... | (inj₂ _ , loops) = loops ++ findLoops c vs
... | (inj₁ v' , loops) with v ≟ v'
... | true = (t , v) ∷ loops ++ findLoops c vs
... | false = loops ++ findLoops c vs
traceLoopsEx : {t : U} → List (Σ[ t ∈ U ] ⟦ t ⟧)
traceLoopsEx {t} = findLoops traceBodyEx (elems (PLUS t (PLUS t t)))
-- traceLoopsEx {ONE} ==> (PLUS ONE (PLUS ONE ONE) , inj₂ (inj₁ tt)) ∷ []
-- Each permutation is a "path" between types. We can think of this path as
-- being indexed by "time" where "time" here is in discrete units
-- corresponding to the sequencing of combinators. A homotopy between paths p
-- and q is a map that, for each "time unit", maps the specified type along p
-- to a corresponding type along q. At each such time unit, the mapping
-- between types is itself a path. So a homotopy is essentially a collection
-- of paths. As an example, given two paths starting at t₁ and ending at t₂
-- and going through different intermediate points:
-- p = t₁ -> t -> t' -> t₂
-- q = t₁ -> u -> u' -> t₂
-- A possible homotopy between these two paths is a path from t to u and
-- another path from t' to u'. Things get slightly more complicated if the
-- number of intermediate points is not the same etc. but that's the basic idea.
-- The vertical paths must commute with the horizontal ones.
--
-- Postulate the groupoid laws and use them to prove commutativity etc.
--
-- Bool -id-- Bool -id-- Bool -id-- Bool
-- | | | |
-- | not id | the last square does not commute
-- | | | |
-- Bool -not- Bool -not- Bool -not- Bool
--
-- If the large rectangle commutes then the smaller squares commute. For a
-- proof, let p o q o r o s be the left-bottom path and p' o q' o r' o s' be
-- the top-right path. Let's focus on the square:
--
-- A-- r'--C
-- | |
-- ? s'
-- | |
-- B-- s --D
--
-- We have a path from A to B that is: !q' o !p' o p o q o r.
-- Now let's see if r' o s' is equivalent to
-- !q' o !p' o p o q o r o s
-- We know p o q o r o s ⇔ p' o q' o r' o s'
-- If we know that ⇔ is preserved by composition then:
-- !q' o !p' o p o q o r o s ⇔ !q' o !p' o p' o q' o r' o s'
-- and of course by inverses and id being unit of composition:
-- !q' o !p' o p o q o r o s ⇔ r' o s'
-- and we are done.
{-# NO_TERMINATION_CHECK #-}
Path∼ : ∀ {t₁ t₂ t₁' t₂' v₁ v₂ v₁' v₂'} →
(p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) →
(q : Path •[ t₁' , v₁' ] •[ t₂' , v₂' ]) →
Set
-- sequential composition
Path∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
(_●_ {t₂ = t₂} {v₂ = v₂} p₁ p₂) (_●_ {t₂ = t₂'} {v₂ = v₂'} q₁ q₂) =
(Path∼ p₁ q₁ × Path∼ p₂ q₂) ⊎
(Path∼ {t₁} {t₂} {t₁'} {t₁'} {v₁} {v₂} {v₁'} {v₁'} p₁ id⟷• × Path∼ p₂ (q₁ ● q₂)) ⊎
(Path∼ p₁ (q₁ ● q₂) × Path∼ {t₂} {t₃} {t₃'} {t₃'} {v₂} {v₃} {v₃'} {v₃'} p₂ id⟷•) ⊎
(Path∼ {t₁} {t₁} {t₁'} {t₂'} {v₁} {v₁} {v₁'} {v₂'} id⟷• q₁ × Path∼ (p₁ ● p₂) q₂) ⊎
(Path∼ (p₁ ● p₂) q₁ × Path∼ {t₃} {t₃} {t₂'} {t₃'} {v₃} {v₃} {v₂'} {v₃'} id⟷• q₂)
Path∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
(_●_ {t₂ = t₂} {v₂ = v₂} p q) c =
(Path∼ {t₁} {t₂} {t₁'} {t₁'} {v₁} {v₂} {v₁'} {v₁'} p id⟷• × Path∼ q c)
⊎ (Path∼ p c × Path∼ {t₂} {t₃} {t₃'} {t₃'} {v₂} {v₃} {v₃'} {v₃'} q id⟷•)
Path∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
c (_●_ {t₂ = t₂'} {v₂ = v₂'} p q) =
(Path∼ {t₁} {t₁} {t₁'} {t₂'} {v₁} {v₁} {v₁'} {v₂'} id⟷• p × Path∼ c q)
⊎ (Path∼ c p × Path∼ {t₃} {t₃} {t₂'} {t₃'} {v₃} {v₃} {v₂'} {v₃'} id⟷• q)
-- choices
Path∼ (⊕1• p) (⊕1• q) = Path∼ p q
Path∼ (⊕1• p) _ = ⊥
Path∼ _ (⊕1• p) = ⊥
Path∼ (⊕2• p) (⊕2• q) = Path∼ p q
Path∼ (⊕2• p) _ = ⊥
Path∼ _ (⊕2• p) = ⊥
-- parallel paths
Path∼ (p₁ ⊗• p₂) (q₁ ⊗• q₂) = Path∼ p₁ q₁ × Path∼ p₂ q₂
Path∼ (p₁ ⊗• p₂) _ = ⊥
Path∼ _ (q₁ ⊗• q₂) = ⊥
-- simple edges connecting two points
Path∼ {t₁} {t₂} {t₁'} {t₂'} {v₁} {v₂} {v₁'} {v₂'} c₁ c₂ =
Path •[ t₁ , v₁ ] •[ t₁' , v₁' ] × Path •[ t₂ , v₂ ] •[ t₂' , v₂' ]
-- In the setting of finite types (in particular with no loops) every pair of
-- paths with related start and end points is equivalent. In other words, we
-- really have no interesting 2-path structure.
allequiv : ∀ {t₁ t₂ t₁' t₂' v₁ v₂ v₁' v₂'} →
(p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) →
(q : Path •[ t₁' , v₁' ] •[ t₂' , v₂' ]) →
(start : Path •[ t₁ , v₁ ] •[ t₁' , v₁' ]) →
(end : Path •[ t₂ , v₂ ] •[ t₂' , v₂' ]) →
Path∼ p q
allequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
(_●_ {t₂ = t₂} {v₂ = v₂} p₁ p₂) (_●_ {t₂ = t₂'} {v₂ = v₂'} q₁ q₂)
start end = {!!}
allequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
(_●_ {t₂ = t₂} {v₂ = v₂} p q) c start end = {!!}
allequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
c (_●_ {t₂ = t₂'} {v₂ = v₂'} p q) start end = {!!}
allequiv (⊕1• p) (⊕1• q) start end = {!!}
allequiv (⊕1• p) _ start end = {!!}
allequiv _ (⊕1• p) start end = {!!}
allequiv (⊕2• p) (⊕2• q) start end = {!!}
allequiv (⊕2• p) _ start end = {!!}
allequiv _ (⊕2• p) start end = {!!}
-- parallel paths
allequiv (p₁ ⊗• p₂) (q₁ ⊗• q₂) start end = {!!}
allequiv (p₁ ⊗• p₂) _ start end = {!!}
allequiv _ (q₁ ⊗• q₂) start end = {!!}
-- simple edges connecting two points
allequiv {t₁} {t₂} {t₁'} {t₂'} {v₁} {v₂} {v₁'} {v₂'} c₁ c₂ start end = {!!}
refl∼ : ∀ {t₁ t₂ v₁ v₂} → (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → Path∼ p p
refl∼ unite•₊ = id⟷• , id⟷•
refl∼ uniti•₊ = id⟷• , id⟷•
refl∼ swap1•₊ = id⟷• , id⟷•
refl∼ swap2•₊ = id⟷• , id⟷•
refl∼ assocl1•₊ = id⟷• , id⟷•
refl∼ assocl2•₊ = id⟷• , id⟷•
refl∼ assocl3•₊ = id⟷• , id⟷•
refl∼ assocr1•₊ = id⟷• , id⟷•
refl∼ assocr2•₊ = id⟷• , id⟷•
refl∼ assocr3•₊ = id⟷• , id⟷•
refl∼ unite•⋆ = id⟷• , id⟷•
refl∼ uniti•⋆ = id⟷• , id⟷•
refl∼ swap•⋆ = id⟷• , id⟷•
refl∼ assocl•⋆ = id⟷• , id⟷•
refl∼ assocr•⋆ = id⟷• , id⟷•
refl∼ distz• = id⟷• , id⟷•
refl∼ factorz• = id⟷• , id⟷•
refl∼ dist1• = id⟷• , id⟷•
refl∼ dist2• = id⟷• , id⟷•
refl∼ factor1• = id⟷• , id⟷•
refl∼ factor2• = id⟷• , id⟷•
refl∼ id⟷• = id⟷• , id⟷•
refl∼ (p ● q) = inj₁ (refl∼ p , refl∼ q)
refl∼ (⊕1• p) = refl∼ p
refl∼ (⊕2• q) = refl∼ q
refl∼ (p ⊗• q) = refl∼ p , refl∼ q
-- Extensional view
-- First we enumerate all the values of a given finite type
size : U → ℕ
size ZERO = 0
size ONE = 1
size (PLUS t₁ t₂) = size t₁ + size t₂
size (TIMES t₁ t₂) = size t₁ * size t₂
enum : (t : U) → ⟦ t ⟧ → Fin (size t)
enum ZERO () -- absurd
enum ONE tt = zero
enum (PLUS t₁ t₂) (inj₁ v₁) = inject+ (size t₂) (enum t₁ v₁)
enum (PLUS t₁ t₂) (inj₂ v₂) = raise (size t₁) (enum t₂ v₂)
enum (TIMES t₁ t₂) (v₁ , v₂) = fromℕ≤ (pr {s₁} {s₂} {n₁} {n₂})
where n₁ = enum t₁ v₁
n₂ = enum t₂ v₂
s₁ = size t₁
s₂ = size t₂
pr : {s₁ s₂ : ℕ} → {n₁ : Fin s₁} {n₂ : Fin s₂} →
((toℕ n₁ * s₂) + toℕ n₂) < (s₁ * s₂)
pr {0} {_} {()}
pr {_} {0} {_} {()}
pr {suc s₁} {suc s₂} {zero} {zero} = {!z≤n!}
pr {suc s₁} {suc s₂} {zero} {Fsuc n₂} = {!!}
pr {suc s₁} {suc s₂} {Fsuc n₁} {zero} = {!!}
pr {suc s₁} {suc s₂} {Fsuc n₁} {Fsuc n₂} = {!!}
vals3 : Fin 3 × Fin 3 × Fin 3
vals3 = (enum THREE LL , enum THREE LR , enum THREE R)
where THREE = PLUS (PLUS ONE ONE) ONE
LL = inj₁ (inj₁ tt)
LR = inj₁ (inj₂ tt)
R = inj₂ tt
--}
xxx : {s₁ s₂ : ℕ} → (i : Fin s₁) → (j : Fin s₂) →
suc (toℕ i * s₂ + toℕ j) ≤ s₁ * s₂
xxx {0} {_} ()
xxx {suc s₁} {s₂} i j = {!!}
-- i : Fin (suc s₁)
-- j : Fin s₂
-- ?0 : suc (toℕ i * s₂ + toℕ j) ≤ suc s₁ * s₂
-- (suc (toℕ i) * s₂ + toℕ j ≤ s₂ + s₁ * s₂
-- (suc (toℕ i) * s₂ + toℕ j ≤ s₁ * s₂ + s₂
utoVecℕ : (t : U) → Vec (Fin (utoℕ t)) (utoℕ t)
utoVecℕ ZERO = []
utoVecℕ ONE = [ zero ]
utoVecℕ (PLUS t₁ t₂) =
map (inject+ (utoℕ t₂)) (utoVecℕ t₁) ++
map (raise (utoℕ t₁)) (utoVecℕ t₂)
utoVecℕ (TIMES t₁ t₂) =
concat (map (λ i → map (λ j → inject≤ (fromℕ (toℕ i * utoℕ t₂ + toℕ j))
(xxx i j))
(utoVecℕ t₂))
(utoVecℕ t₁))
-- Vector representation of types so that we can test permutations
utoVec : (t : U) → Vec ⟦ t ⟧ (utoℕ t)
utoVec ZERO = []
utoVec ONE = [ tt ]
utoVec (PLUS t₁ t₂) = map inj₁ (utoVec t₁) ++ map inj₂ (utoVec t₂)
utoVec (TIMES t₁ t₂) =
concat (map (λ v₁ → map (λ v₂ → (v₁ , v₂)) (utoVec t₂)) (utoVec t₁))
-- Examples permutations and their actions on a simple ordered vector
module PermExamples where
-- ordered vector: position i has value i
ordered : ∀ {n} → Vec (Fin n) n
ordered = tabulate id
-- empty permutation p₀ { }
p₀ : Perm 0
p₀ = []
v₀ = permute p₀ ordered
-- permutation p₁ { 0 -> 0 }
p₁ : Perm 1
p₁ = 0F ∷ p₀
where 0F = fromℕ 0
v₁ = permute p₁ ordered
-- permutations p₂ { 0 -> 0, 1 -> 1 }
-- q₂ { 0 -> 1, 1 -> 0 }
p₂ q₂ : Perm 2
p₂ = 0F ∷ p₁
where 0F = inject+ 1 (fromℕ 0)
q₂ = 1F ∷ p₁
where 1F = fromℕ 1
v₂ = permute p₂ ordered
w₂ = permute q₂ ordered
-- permutations p₃ { 0 -> 0, 1 -> 1, 2 -> 2 }
-- s₃ { 0 -> 0, 1 -> 2, 2 -> 1 }
-- q₃ { 0 -> 1, 1 -> 0, 2 -> 2 }
-- r₃ { 0 -> 1, 1 -> 2, 2 -> 0 }
-- t₃ { 0 -> 2, 1 -> 0, 2 -> 1 }
-- u₃ { 0 -> 2, 1 -> 1, 2 -> 0 }
p₃ q₃ r₃ s₃ t₃ u₃ : Perm 3
p₃ = 0F ∷ p₂
where 0F = inject+ 2 (fromℕ 0)
s₃ = 0F ∷ q₂
where 0F = inject+ 2 (fromℕ 0)
q₃ = 1F ∷ p₂
where 1F = inject+ 1 (fromℕ 1)
r₃ = 2F ∷ p₂
where 2F = fromℕ 2
t₃ = 1F ∷ q₂
where 1F = inject+ 1 (fromℕ 1)
u₃ = 2F ∷ q₂
where 2F = fromℕ 2
v₃ = permute p₃ ordered
y₃ = permute s₃ ordered
w₃ = permute q₃ ordered
x₃ = permute r₃ ordered
z₃ = permute t₃ ordered
α₃ = permute u₃ ordered
-- end module PermExamples
------------------------------------------------------------------------------
-- Testing
t₁ = PLUS ZERO BOOL
t₂ = BOOL
m₁ = matchP {t₁} {t₂} unite₊
-- (inj₂ (inj₁ tt) , inj₁ tt) ∷ (inj₂ (inj₂ tt) , inj₂ tt) ∷ []
m₂ = matchP {t₂} {t₁} uniti₊
-- (inj₁ tt , inj₂ (inj₁ tt)) ∷ (inj₂ tt , inj₂ (inj₂ tt)) ∷ []
t₃ = PLUS BOOL ONE
t₄ = PLUS ONE BOOL
m₃ = matchP {t₃} {t₄} swap₊
-- (inj₂ tt , inj₁ tt) ∷
-- (inj₁ (inj₁ tt) , inj₂ (inj₁ tt)) ∷
-- (inj₁ (inj₂ tt) , inj₂ (inj₂ tt)) ∷ []
m₄ = matchP {t₄} {t₃} swap₊
-- (inj₂ (inj₁ tt) , inj₁ (inj₁ tt)) ∷
-- (inj₂ (inj₂ tt) , inj₁ (inj₂ tt)) ∷
-- (inj₁ tt , inj₂ tt) ∷ []
t₅ = PLUS ONE (PLUS BOOL ONE)
t₆ = PLUS (PLUS ONE BOOL) ONE
m₅ = matchP {t₅} {t₆} assocl₊
-- (inj₁ tt , inj₁ (inj₁ tt)) ∷
-- (inj₂ (inj₁ (inj₁ tt)) , inj₁ (inj₂ (inj₁ tt))) ∷
-- (inj₂ (inj₁ (inj₂ tt)) , inj₁ (inj₂ (inj₂ tt))) ∷
-- (inj₂ (inj₂ tt) , inj₂ tt) ∷ []
m₆ = matchP {t₆} {t₅} assocr₊
-- (inj₁ (inj₁ tt) , inj₁ tt) ∷
-- (inj₁ (inj₂ (inj₁ tt)) , inj₂ (inj₁ (inj₁ tt))) ∷
-- (inj₁ (inj₂ (inj₂ tt)) , inj₂ (inj₁ (inj₂ tt))) ∷
-- (inj₂ tt , inj₂ (inj₂ tt)) ∷ []
t₇ = TIMES ONE BOOL
t₈ = BOOL
m₇ = matchP {t₇} {t₈} unite⋆
-- ((tt , inj₁ tt) , inj₁ tt) ∷ ((tt , inj₂ tt) , inj₂ tt) ∷ []
m₈ = matchP {t₈} {t₇} uniti⋆
-- (inj₁ tt , (tt , inj₁ tt)) ∷ (inj₂ tt , (tt , inj₂ tt)) ∷ []
t₉ = TIMES BOOL ONE
t₁₀ = TIMES ONE BOOL
m₉ = matchP {t₉} {t₁₀} swap⋆
-- ((inj₁ tt , tt) , (tt , inj₁ tt)) ∷
-- ((inj₂ tt , tt) , (tt , inj₂ tt)) ∷ []
m₁₀ = matchP {t₁₀} {t₉} swap⋆
-- ((tt , inj₁ tt) , (inj₁ tt , tt)) ∷
-- ((tt , inj₂ tt) , (inj₂ tt , tt)) ∷ []
t₁₁ = TIMES BOOL (TIMES ONE BOOL)
t₁₂ = TIMES (TIMES BOOL ONE) BOOL
m₁₁ = matchP {t₁₁} {t₁₂} assocl⋆
-- ((inj₁ tt , (tt , inj₁ tt)) , ((inj₁ tt , tt) , inj₁ tt)) ∷
-- ((inj₁ tt , (tt , inj₂ tt)) , ((inj₁ tt , tt) , inj₂ tt)) ∷
-- ((inj₂ tt , (tt , inj₁ tt)) , ((inj₂ tt , tt) , inj₁ tt)) ∷
-- ((inj₂ tt , (tt , inj₂ tt)) , ((inj₂ tt , tt) , inj₂ tt)) ∷ []
m₁₂ = matchP {t₁₂} {t₁₁} assocr⋆
-- (((inj₁ tt , tt) , inj₁ tt) , (inj₁ tt , (tt , inj₁ tt)) ∷
-- (((inj₁ tt , tt) , inj₂ tt) , (inj₁ tt , (tt , inj₂ tt)) ∷
-- (((inj₂ tt , tt) , inj₁ tt) , (inj₂ tt , (tt , inj₁ tt)) ∷
-- (((inj₂ tt , tt) , inj₂ tt) , (inj₂ tt , (tt , inj₂ tt)) ∷ []
t₁₃ = TIMES ZERO BOOL
t₁₄ = ZERO
m₁₃ = matchP {t₁₃} {t₁₄} distz
-- []
m₁₄ = matchP {t₁₄} {t₁₃} factorz
-- []
t₁₅ = TIMES (PLUS BOOL ONE) BOOL
t₁₆ = PLUS (TIMES BOOL BOOL) (TIMES ONE BOOL)
m₁₅ = matchP {t₁₅} {t₁₆} dist
-- ((inj₁ (inj₁ tt) , inj₁ tt) , inj₁ (inj₁ tt , inj₁ tt)) ∷
-- ((inj₁ (inj₁ tt) , inj₂ tt) , inj₁ (inj₁ tt , inj₂ tt)) ∷
-- ((inj₁ (inj₂ tt) , inj₁ tt) , inj₁ (inj₂ tt , inj₁ tt)) ∷
-- ((inj₁ (inj₂ tt) , inj₂ tt) , inj₁ (inj₂ tt , inj₂ tt)) ∷
-- ((inj₂ tt , inj₁ tt) , inj₂ (tt , inj₁ tt)) ∷
-- ((inj₂ tt , inj₂ tt) , inj₂ (tt , inj₂ tt)) ∷ []
m₁₆ = matchP {t₁₆} {t₁₅} factor
-- (inj₁ (inj₁ tt , inj₁ tt) , (inj₁ (inj₁ tt) , inj₁ tt)) ∷
-- (inj₁ (inj₁ tt , inj₂ tt) , (inj₁ (inj₁ tt) , inj₂ tt)) ∷
-- (inj₁ (inj₂ tt , inj₁ tt) , (inj₁ (inj₂ tt) , inj₁ tt)) ∷
-- (inj₁ (inj₂ tt , inj₂ tt) , (inj₁ (inj₂ tt) , inj₂ tt)) ∷
-- (inj₂ (tt , inj₁ tt) , (inj₂ tt , inj₁ tt)) ∷
-- (inj₂ (tt , inj₂ tt) , (inj₂ tt , inj₂ tt)) ∷ []
t₁₇ = BOOL
t₁₈ = BOOL
m₁₇ = matchP {t₁₇} {t₁₈} id⟷
-- (inj₁ tt , inj₁ tt) ∷ (inj₂ tt , inj₂ tt) ∷ []
--◎
--⊕
--⊗
------------------------------------------------------------------------------
mergeS :: SubPerm → SubPerm (suc m * n) (m * n) → SubPerm (suc m * suc n) (m * suc n)
mergeS = ?
subP : ∀ {m n} → Fin (suc m) → Perm n → SubPerm (suc m * n) (m * n)
subP {m} {0} i β = {!!}
subP {m} {suc n} i (j ∷ β) = mergeS ? (subP {m} {n} i β)
-- injectP (Perm n) (m * n)
-- ...
-- SP (suc m * n) (m * n)
-- SP (n + m * n) (m * n)
--SP (suc m * n) (m * n)
--
--
--==>
--
--(suc m * suc n) (m * suc n)
--m : ℕ
--n : ℕ
--i : Fin (suc m)
--j : Fin (suc n)
--β : Perm n
--?1 : SubPerm (suc m * suc n) (m * suc n)
tcompperm : ∀ {m n} → Perm m → Perm n → Perm (m * n)
tcompperm [] β = []
tcompperm (i ∷ α) β = merge (subP i β) (tcompperm α β)
-- shift m=3 n=4 i=ax:F3 β=[ay:F4,by:F3,cy:F2,dy:F1] γ=[r4,...,r11]:P8
-- ==> [F12,F11,F10,F9...γ]
-- m = 3
-- n = 4
-- 3 * 4
-- x = [ ax, bx, cx ] : P 3, y : [ay, by, cy, dy] : P 4
-- (shift ax 4 y) ||
-- ( (shift bx 4 y) ||
-- ( (shift cx 4 y) ||
-- [])))
--
-- ax : F3, bx : F2, cx : F1
-- ay : F4, by : F3, cy : F2, dy : F1
--
-- suc m = 3, m = 2
-- F12 F11 F10 F9 F8 F7 F6 F5 F4 F3 F2 F1
-- [ r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11 ]
-- ---------------
-- ax : F3 with y=[F4,F3,F2,F1]
-- --------------
-- bx : F2
-- ------------------
-- cx : F1
-- β should be something like i * n + entry in β
{--
0 * n = 0
(suc m) * n = n + (m * n)
comb2perm (c₁ ⊗ c₂) = tcompperm (comb2perm c₁) (comb2perm c₂)
c1 = swap+ (f->t,t->f) [1,0]
c2 = id (f->f,t->t) [0,0]
c1xc2 (f,f)->(t,f), (f,t)->(t,t), (t,f)->(f,f), (t,t)->(f,t)
[
ff ft tf tt
2 2 0 0
index in α * n + index in β
--}
pex qex pqex qpex : Perm 3
pex = inject+ 1 (fromℕ 1) ∷ fromℕ 1 ∷ zero ∷ []
qex = zero ∷ fromℕ 1 ∷ zero ∷ []
pqex = fromℕ 2 ∷ fromℕ 1 ∷ zero ∷ []
qpex = inject+ 1 (fromℕ 1) ∷ zero ∷ zero ∷ []
pqexv = (permute qex ∘ permute pex) (tabulate id)
pqexv' = permute pqex (tabulate id)
qpexv = (permute pex ∘ permute qex) (tabulate id)
qpexv' = permute qpex (tabulate id)
-- [1,1,0]
-- [z] => [z]
-- [y,z] => [z,y]
-- [x,y,z] => [z,x,y]
-- [0,1,0]
-- [w] => [w]
-- [v,w] => [w,v]
-- [u,v,w] => [u,w,v]
-- R,R,_ ◌ _,R,_
-- R in p1 takes you to middle which also goes R, so first goes RR
-- [a,b,c] ◌ [d,e,f]
-- [a+p2[a], ...]
-- [1,1,0] ◌ [0,1,0] one step [2,1,0]
-- [z] => [z]
-- [y,z] => [z,y]
-- [x,y,z] => [z,y,x]
-- [1,1,0] ◌ [0,1,0]
-- [z] => [z] => [z]
-- [y,z] =>
-- [x,y,z] =>
-- so [1,1,0] ◌ [0,1,0] ==> [2,1,0]
-- so [0,1,0] ◌ [1,1,0] ==> [1,0,0]
-- pex takes [0,1,2] to [2,0,1]
-- qex takes [0,1,2] to [0,2,1]
-- pex ◌ qex takes [0,1,2] to [2,1,0]
-- qex ◌ pex takes [0,1,2] to [1,0,2]
-- seq : ∀ {m n} → (m ≤ n) → Perm m → Perm n → Perm m
-- seq lp [] _ = []
-- seq lp (i ∷ p) q = (lookupP i q) ∷ (seq lp p q)
-- i F+ ...
-- lookupP : ∀ {n} → Fin n → Perm n → Fin n
-- i : Fin (suc m)
-- p : Perm m
-- q : Perm n
--
-- (zero ∷ p₁) ◌ (q ∷ q₁) = q ∷ (p₁ ◌ q₁)
-- (suc p ∷ p₁) ◌ (zero ∷ q₁) = {!!}
-- (suc p ∷ p₁) ◌ (suc q ∷ q₁) = {!!}
--
-- data Perm : ℕ → Set where
-- [] : Perm 0
-- _∷_ : {n : ℕ} → Fin (suc n) → Perm n → Perm (suc n)
-- Given a vector of (suc n) elements, return one of the elements and
-- the rest. Example: pick (inject+ 1 (fromℕ 1)) (10 ∷ 20 ∷ 30 ∷ 40 ∷ [])
pick : ∀ {ℓ} {n : ℕ} {A : Set ℓ} → Fin n → Vec A (suc n) → (A × Vec A n)
pick {ℓ} {0} {A} ()
pick {ℓ} {suc n} {A} zero (v ∷ vs) = (v , vs)
pick {ℓ} {suc n} {A} (suc i) (v ∷ vs) =
let (w , ws) = pick {ℓ} {n} {A} i vs
in (w , v ∷ ws)
insertV : ∀ {ℓ} {n : ℕ} {A : Set ℓ} →
A → Fin (suc n) → Vec A n → Vec A (suc n)
insertV {n = 0} v zero [] = [ v ]
insertV {n = 0} v (suc ())
insertV {n = suc n} v zero vs = v ∷ vs
insertV {n = suc n} v (suc i) (w ∷ ws) = w ∷ insertV v i ws
-- A permutation takes two vectors of the same size, matches one
-- element from each and returns another permutation
data P {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') :
(m n : ℕ) → (m ≡ n) → Vec A m → Vec B n → Set (ℓ ⊔ ℓ') where
nil : P A B 0 0 refl [] []
cons : {m n : ℕ} {i : Fin (suc m)} {j : Fin (suc n)} → (p : m ≡ n) →
(v : A) → (w : B) → (vs : Vec A m) → (ws : Vec B n) →
P A B m n p vs ws →
P A B (suc m) (suc n) (cong suc p) (insertV v i vs) (insertV w j ws)
-- A permutation is a sequence of "insertions".
infixr 5 _∷_
data Perm : ℕ → Set where
[] : Perm 0
_∷_ : {n : ℕ} → Fin (suc n) → Perm n → Perm (suc n)
lookupP : ∀ {n} → Fin n → Perm n → Fin n
lookupP () []
lookupP zero (j ∷ _) = j
lookupP {suc n} (suc i) (j ∷ q) = inject₁ (lookupP i q)
insert : ∀ {ℓ n} {A : Set ℓ} → Vec A n → Fin (suc n) → A → Vec A (suc n)
insert vs zero w = w ∷ vs
insert [] (suc ()) -- absurd
insert (v ∷ vs) (suc i) w = v ∷ insert vs i w
-- A permutation acts on a vector by inserting each element in its new
-- position.
permute : ∀ {ℓ n} {A : Set ℓ} → Perm n → Vec A n → Vec A n
permute [] [] = []
permute (p ∷ ps) (v ∷ vs) = insert (permute ps vs) p v
-- Use a permutation to match up the elements in two vectors. See more
-- convenient function matchP below.
match : ∀ {t t'} → (size t ≡ size t') → Perm (size t) →
Vec ⟦ t ⟧ (size t) → Vec ⟦ t' ⟧ (size t) →
Vec (⟦ t ⟧ × ⟦ t' ⟧) (size t)
match {t} {t'} sp α vs vs' =
let js = permute α (tabulate id)
in zip (tabulate (λ j → lookup (lookup j js) vs)) vs'
-- swap
--
-- swapperm produces the permutations that maps:
-- [ a , b || x , y , z ]
-- to
-- [ x , y , z || a , b ]
-- Ex.
-- permute (swapperm {5} (inject+ 2 (fromℕ 2))) ordered=[0,1,2,3,4]
-- produces [2,3,4,0,1]
-- Explicitly:
-- swapex : Perm 5
-- swapex = inject+ 1 (fromℕ 3) -- :: Fin 5
-- ∷ inject+ 0 (fromℕ 3) -- :: Fin 4
-- ∷ zero
-- ∷ zero
-- ∷ zero
-- ∷ []
swapperm : ∀ {n} → Fin n → Perm n
swapperm {0} () -- absurd
swapperm {suc n} zero = idperm
swapperm {suc n} (suc i) =
subst Fin (-+-id n i)
(inject+ (toℕ i) (fromℕ (n ∸ toℕ i))) ∷ swapperm {n} i
-- compositions
-- Sequential composition
scompperm : ∀ {n} → Perm n → Perm n → Perm n
scompperm α β = {!!}
-- Sub-permutations
-- useful for parallel and multiplicative compositions
-- Perm 4 has elements [Fin 4, Fin 3, Fin 2, Fin 1]
-- SubPerm 11 7 has elements [Fin 11, Fin 10, Fin 9, Fin 8]
-- So Perm 4 is a special case SubPerm 4 0
data SubPerm : ℕ → ℕ → Set where
[]s : {n : ℕ} → SubPerm n n
_∷s_ : {n m : ℕ} → Fin (suc n) → SubPerm n m → SubPerm (suc n) m
merge : ∀ {m n} → SubPerm m n → Perm n → Perm m
merge []s β = β
merge (i ∷s α) β = i ∷ merge α β
injectP : ∀ {m} → Perm m → (n : ℕ) → SubPerm (m + n) n
injectP [] n = []s
injectP (i ∷ α) n = inject+ n i ∷s injectP α n
-- Parallel + composition
pcompperm : ∀ {m n} → Perm m → Perm n → Perm (m + n)
pcompperm {m} {n} α β = merge (injectP α n) β
-- Multiplicative * composition
tcompperm : ∀ {m n} → Perm m → Perm n → Perm (m * n)
tcompperm [] β = []
tcompperm (i ∷ α) β = {!!}
------------------------------------------------------------------------------
-- A combinator t₁ ⟷ t₂ denotes a permutation.
comb2perm : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → Perm (size t₁)
comb2perm {PLUS ZERO t} {.t} unite₊ = idperm
comb2perm {t} {PLUS ZERO .t} uniti₊ = idperm
comb2perm {PLUS t₁ t₂} {PLUS .t₂ .t₁} swap₊ with size t₂
... | 0 = idperm
... | suc j = swapperm {size t₁ + suc j}
(inject≤ (fromℕ (size t₁)) (suc≤ (size t₁) j))
comb2perm {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃} assocl₊ = idperm
comb2perm {PLUS (PLUS t₁ t₂) t₃} {PLUS .t₁ (PLUS .t₂ .t₃)} assocr₊ = idperm
comb2perm {TIMES ONE t} {.t} unite⋆ = idperm
comb2perm {t} {TIMES ONE .t} uniti⋆ = idperm
comb2perm {TIMES t₁ t₂} {TIMES .t₂ .t₁} swap⋆ = idperm
comb2perm assocl⋆ = idperm
comb2perm assocr⋆ = idperm
comb2perm distz = idperm
comb2perm factorz = idperm
comb2perm dist = idperm
comb2perm factor = idperm
comb2perm id⟷ = idperm
comb2perm (c₁ ◎ c₂) = scompperm
(comb2perm c₁)
(subst Perm (sym (size≡ c₁)) (comb2perm c₂))
comb2perm (c₁ ⊕ c₂) = pcompperm (comb2perm c₁) (comb2perm c₂)
comb2perm (c₁ ⊗ c₂) = tcompperm (comb2perm c₁) (comb2perm c₂)
-- Convenient way of "seeing" what the permutation does for each combinator
matchP : ∀ {t t'} → (t ⟷ t') → Vec (⟦ t ⟧ × ⟦ t' ⟧) (size t)
matchP {t} {t'} c =
match sp (comb2perm c) (utoVec t)
(subst (λ n → Vec ⟦ t' ⟧ n) (sym sp) (utoVec t'))
where sp = size≡ c
------------------------------------------------------------------------------
-- Extensional equivalence of combinators: two combinators are
-- equivalent if they denote the same permutation. Generally we would
-- require that the two permutations map the same value x to values y
-- and z that have a path between them, but because the internals of each
-- type are discrete groupoids, this reduces to saying that y and z
-- are identical, and hence that the permutations are identical.
infix 10 _∼_
_∼_ : ∀ {t₁ t₂} → (c₁ c₂ : t₁ ⟷ t₂) → Set
c₁ ∼ c₂ = (comb2perm c₁ ≡ comb2perm c₂)
-- The relation ~ is an equivalence relation
refl∼ : ∀ {t₁ t₂} {c : t₁ ⟷ t₂} → (c ∼ c)
refl∼ = refl
sym∼ : ∀ {t₁ t₂} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₁)
sym∼ = sym
trans∼ : ∀ {t₁ t₂} {c₁ c₂ c₃ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₃) → (c₁ ∼ c₃)
trans∼ = trans
-- The relation ~ validates the groupoid laws
c◎id∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ id⟷ ∼ c
c◎id∼c = {!!}
id◎c∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ◎ c ∼ c
id◎c∼c = {!!}
assoc∼ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
c₁ ◎ (c₂ ◎ c₃) ∼ (c₁ ◎ c₂) ◎ c₃
assoc∼ = {!!}
linv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ ! c ∼ id⟷
linv∼ = {!!}
rinv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → ! c ◎ c ∼ id⟷
rinv∼ = {!!}
resp∼ : {t₁ t₂ t₃ : U} {c₁ c₂ : t₁ ⟷ t₂} {c₃ c₄ : t₂ ⟷ t₃} →
(c₁ ∼ c₂) → (c₃ ∼ c₄) → (c₁ ◎ c₃ ∼ c₂ ◎ c₄)
resp∼ = {!!}
-- The equivalence ∼ of paths makes U a 1groupoid: the points are
-- types (t : U); the 1paths are ⟷; and the 2paths between them are
-- based on extensional equivalence ∼
G : 1Groupoid
G = record
{ set = U
; _↝_ = _⟷_
; _≈_ = _∼_
; id = id⟷
; _∘_ = λ p q → q ◎ p
; _⁻¹ = !
; lneutr = λ c → c◎id∼c {c = c}
; rneutr = λ c → id◎c∼c {c = c}
; assoc = λ c₃ c₂ c₁ → assoc∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃}
; equiv = record {
refl = λ {c} → refl∼ {c = c}
; sym = λ {c₁} {c₂} → sym∼ {c₁ = c₁} {c₂ = c₂}
; trans = λ {c₁} {c₂} {c₃} → trans∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃}
}
; linv = λ c → linv∼ {c = c}
; rinv = λ c → rinv∼ {c = c}
; ∘-resp-≈ = λ α β → resp∼ β α
}
-- And there are additional laws
assoc⊕∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
c₁ ⊕ (c₂ ⊕ c₃) ∼ assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊
assoc⊕∼ = {!!}
assoc⊗∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
c₁ ⊗ (c₂ ⊗ c₃) ∼ assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆
assoc⊗∼ = {!!}
------------------------------------------------------------------------------
-- Picture so far:
--
-- path p
-- =====================
-- || || ||
-- || ||2path ||
-- || || ||
-- || || path q ||
-- t₁ =================t₂
-- || ... ||
-- =====================
--
-- The types t₁, t₂, etc are discrete groupoids. The paths between
-- them correspond to permutations. Each syntactically different
-- permutation corresponds to a path but equivalent permutations are
-- connected by 2paths. But now we want an alternative definition of
-- 2paths that is structural, i.e., that looks at the actual
-- construction of the path t₁ ⟷ t₂ in terms of combinators... The
-- theorem we want is that α ∼ β iff we can rewrite α to β using
-- various syntactic structural rules. We start with a collection of
-- simplication rules and then try to show they are complete.
-- Simplification rules
infix 30 _⇔_
data _⇔_ : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂) → Set where
assoc◎l : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
(c₁ ◎ (c₂ ◎ c₃)) ⇔ ((c₁ ◎ c₂) ◎ c₃)
assoc◎r : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
((c₁ ◎ c₂) ◎ c₃) ⇔ (c₁ ◎ (c₂ ◎ c₃))
assoc⊕l : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(c₁ ⊕ (c₂ ⊕ c₃)) ⇔ (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊)
assoc⊕r : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊) ⇔ (c₁ ⊕ (c₂ ⊕ c₃))
assoc⊗l : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(c₁ ⊗ (c₂ ⊗ c₃)) ⇔ (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)
assoc⊗r : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆) ⇔ (c₁ ⊗ (c₂ ⊗ c₃))
dist⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
((c₁ ⊕ c₂) ⊗ c₃) ⇔ (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor)
factor⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor) ⇔ ((c₁ ⊕ c₂) ⊗ c₃)
idl◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (id⟷ ◎ c) ⇔ c
idl◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ id⟷ ◎ c
idr◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ id⟷) ⇔ c
idr◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ (c ◎ id⟷)
linv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ ! c) ⇔ id⟷
linv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (c ◎ ! c)
rinv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (! c ◎ c) ⇔ id⟷
rinv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (! c ◎ c)
unitel₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(unite₊ ◎ c₂) ⇔ ((c₁ ⊕ c₂) ◎ unite₊)
uniter₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
((c₁ ⊕ c₂) ◎ unite₊) ⇔ (unite₊ ◎ c₂)
unitil₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(uniti₊ ◎ (c₁ ⊕ c₂)) ⇔ (c₂ ◎ uniti₊)
unitir₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(c₂ ◎ uniti₊) ⇔ (uniti₊ ◎ (c₁ ⊕ c₂))
unitial₊⇔ : {t₁ t₂ : U} → (uniti₊ {PLUS t₁ t₂} ◎ assocl₊) ⇔ (uniti₊ ⊕ id⟷)
unitiar₊⇔ : {t₁ t₂ : U} → (uniti₊ {t₁} ⊕ id⟷ {t₂}) ⇔ (uniti₊ ◎ assocl₊)
swapl₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
(swap₊ ◎ (c₁ ⊕ c₂)) ⇔ ((c₂ ⊕ c₁) ◎ swap₊)
swapr₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
((c₂ ⊕ c₁) ◎ swap₊) ⇔ (swap₊ ◎ (c₁ ⊕ c₂))
unitel⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(unite⋆ ◎ c₂) ⇔ ((c₁ ⊗ c₂) ◎ unite⋆)
uniter⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
((c₁ ⊗ c₂) ◎ unite⋆) ⇔ (unite⋆ ◎ c₂)
unitil⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(uniti⋆ ◎ (c₁ ⊗ c₂)) ⇔ (c₂ ◎ uniti⋆)
unitir⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(c₂ ◎ uniti⋆) ⇔ (uniti⋆ ◎ (c₁ ⊗ c₂))
unitial⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {TIMES t₁ t₂} ◎ assocl⋆) ⇔ (uniti⋆ ⊗ id⟷)
unitiar⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {t₁} ⊗ id⟷ {t₂}) ⇔ (uniti⋆ ◎ assocl⋆)
swapl⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
(swap⋆ ◎ (c₁ ⊗ c₂)) ⇔ ((c₂ ⊗ c₁) ◎ swap⋆)
swapr⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
((c₂ ⊗ c₁) ◎ swap⋆) ⇔ (swap⋆ ◎ (c₁ ⊗ c₂))
swapfl⋆⇔ : {t₁ t₂ t₃ : U} →
(swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor) ⇔
(factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷))
swapfr⋆⇔ : {t₁ t₂ t₃ : U} →
(factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷)) ⇔
(swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor)
id⇔ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ c
trans⇔ : {t₁ t₂ : U} {c₁ c₂ c₃ : t₁ ⟷ t₂} →
(c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)
resp◎⇔ : {t₁ t₂ t₃ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₁ ⟷ t₂} {c₄ : t₂ ⟷ t₃} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ◎ c₂) ⇔ (c₃ ◎ c₄)
resp⊕⇔ : {t₁ t₂ t₃ t₄ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊕ c₂) ⇔ (c₃ ⊕ c₄)
resp⊗⇔ : {t₁ t₂ t₃ t₄ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊗ c₂) ⇔ (c₃ ⊗ c₄)
-- better syntax for writing 2paths
infix 2 _▤
infixr 2 _⇔⟨_⟩_
_⇔⟨_⟩_ : {t₁ t₂ : U} (c₁ : t₁ ⟷ t₂) {c₂ : t₁ ⟷ t₂} {c₃ : t₁ ⟷ t₂} →
(c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)
_ ⇔⟨ α ⟩ β = trans⇔ α β
_▤ : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → (c ⇔ c)
_▤ c = id⇔
-- Inverses for 2paths
2! : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₂ ⇔ c₁)
2! assoc◎l = assoc◎r
2! assoc◎r = assoc◎l
2! assoc⊕l = assoc⊕r
2! assoc⊕r = assoc⊕l
2! assoc⊗l = assoc⊗r
2! assoc⊗r = assoc⊗l
2! dist⇔ = factor⇔
2! factor⇔ = dist⇔
2! idl◎l = idl◎r
2! idl◎r = idl◎l
2! idr◎l = idr◎r
2! idr◎r = idr◎l
2! linv◎l = linv◎r
2! linv◎r = linv◎l
2! rinv◎l = rinv◎r
2! rinv◎r = rinv◎l
2! unitel₊⇔ = uniter₊⇔
2! uniter₊⇔ = unitel₊⇔
2! unitil₊⇔ = unitir₊⇔
2! unitir₊⇔ = unitil₊⇔
2! swapl₊⇔ = swapr₊⇔
2! swapr₊⇔ = swapl₊⇔
2! unitial₊⇔ = unitiar₊⇔
2! unitiar₊⇔ = unitial₊⇔
2! unitel⋆⇔ = uniter⋆⇔
2! uniter⋆⇔ = unitel⋆⇔
2! unitil⋆⇔ = unitir⋆⇔
2! unitir⋆⇔ = unitil⋆⇔
2! unitial⋆⇔ = unitiar⋆⇔
2! unitiar⋆⇔ = unitial⋆⇔
2! swapl⋆⇔ = swapr⋆⇔
2! swapr⋆⇔ = swapl⋆⇔
2! swapfl⋆⇔ = swapfr⋆⇔
2! swapfr⋆⇔ = swapfl⋆⇔
2! id⇔ = id⇔
2! (trans⇔ α β) = trans⇔ (2! β) (2! α)
2! (resp◎⇔ α β) = resp◎⇔ (2! α) (2! β)
2! (resp⊕⇔ α β) = resp⊕⇔ (2! α) (2! β)
2! (resp⊗⇔ α β) = resp⊗⇔ (2! α) (2! β)
-- a nice example of 2 paths
negEx : neg₅ ⇔ neg₁
negEx = uniti⋆ ◎ (swap⋆ ◎ ((swap₊ ⊗ id⟷) ◎ (swap⋆ ◎ unite⋆)))
⇔⟨ resp◎⇔ id⇔ assoc◎l ⟩
uniti⋆ ◎ ((swap⋆ ◎ (swap₊ ⊗ id⟷)) ◎ (swap⋆ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ swapl⋆⇔ id⇔) ⟩
uniti⋆ ◎ (((id⟷ ⊗ swap₊) ◎ swap⋆) ◎ (swap⋆ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ assoc◎r ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (swap⋆ ◎ (swap⋆ ◎ unite⋆)))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ assoc◎l) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ ((swap⋆ ◎ swap⋆) ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ (resp◎⇔ linv◎l id⇔)) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (id⟷ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ idl◎l) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ unite⋆)
⇔⟨ assoc◎l ⟩
(uniti⋆ ◎ (id⟷ ⊗ swap₊)) ◎ unite⋆
⇔⟨ resp◎⇔ unitil⋆⇔ id⇔ ⟩
(swap₊ ◎ uniti⋆) ◎ unite⋆
⇔⟨ assoc◎r ⟩
swap₊ ◎ (uniti⋆ ◎ unite⋆)
⇔⟨ resp◎⇔ id⇔ linv◎l ⟩
swap₊ ◎ id⟷
⇔⟨ idr◎l ⟩
swap₊ ▤
-- The equivalence ⇔ of paths is rich enough to make U a 1groupoid:
-- the points are types (t : U); the 1paths are ⟷; and the 2paths
-- between them are based on the simplification rules ⇔
G' : 1Groupoid
G' = record
{ set = U
; _↝_ = _⟷_
; _≈_ = _⇔_
; id = id⟷
; _∘_ = λ p q → q ◎ p
; _⁻¹ = !
; lneutr = λ _ → idr◎l
; rneutr = λ _ → idl◎l
; assoc = λ _ _ _ → assoc◎l
; equiv = record {
refl = id⇔
; sym = 2!
; trans = trans⇔
}
; linv = λ {t₁} {t₂} α → linv◎l
; rinv = λ {t₁} {t₂} α → rinv◎l
; ∘-resp-≈ = λ p∼q r∼s → resp◎⇔ r∼s p∼q
}
------------------------------------------------------------------------------
-- Inverting permutations to syntactic combinators
perm2comb : {t₁ t₂ : U} → (size t₁ ≡ size t₂) → Perm (size t₁) → (t₁ ⟷ t₂)
perm2comb {ZERO} {t₂} sp [] = {!!}
perm2comb {ONE} {t₂} sp p = {!!}
perm2comb {PLUS t₁ t₂} {t₃} sp p = {!!}
perm2comb {TIMES t₁ t₂} {t₃} sp p = {!!}
------------------------------------------------------------------------------
-- Soundness and completeness
--
-- Proof of soundness and completeness: now we want to verify that ⇔
-- is sound and complete with respect to ∼. The statement to prove is
-- that for all c₁ and c₂, we have c₁ ∼ c₂ iff c₁ ⇔ c₂
soundness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₁ ∼ c₂)
soundness assoc◎l = assoc∼
soundness assoc◎r = sym∼ assoc∼
soundness assoc⊕l = assoc⊕∼
soundness assoc⊕r = sym∼ assoc⊕∼
soundness assoc⊗l = assoc⊗∼
soundness assoc⊗r = sym∼ assoc⊗∼
soundness dist⇔ = {!!}
soundness factor⇔ = {!!}
soundness idl◎l = id◎c∼c
soundness idl◎r = sym∼ id◎c∼c
soundness idr◎l = c◎id∼c
soundness idr◎r = sym∼ c◎id∼c
soundness linv◎l = linv∼
soundness linv◎r = sym∼ linv∼
soundness rinv◎l = rinv∼
soundness rinv◎r = sym∼ rinv∼
soundness unitel₊⇔ = {!!}
soundness uniter₊⇔ = {!!}
soundness unitil₊⇔ = {!!}
soundness unitir₊⇔ = {!!}
soundness unitial₊⇔ = {!!}
soundness unitiar₊⇔ = {!!}
soundness swapl₊⇔ = {!!}
soundness swapr₊⇔ = {!!}
soundness unitel⋆⇔ = {!!}
soundness uniter⋆⇔ = {!!}
soundness unitil⋆⇔ = {!!}
soundness unitir⋆⇔ = {!!}
soundness unitial⋆⇔ = {!!}
soundness unitiar⋆⇔ = {!!}
soundness swapl⋆⇔ = {!!}
soundness swapr⋆⇔ = {!!}
soundness swapfl⋆⇔ = {!!}
soundness swapfr⋆⇔ = {!!}
soundness id⇔ = refl∼
soundness (trans⇔ α β) = trans∼ (soundness α) (soundness β)
soundness (resp◎⇔ α β) = resp∼ (soundness α) (soundness β)
soundness (resp⊕⇔ α β) = {!!}
soundness (resp⊗⇔ α β) = {!!}
-- The idea is to invert evaluation and use that to extract from each
-- extensional representation of a combinator, a canonical syntactic
-- representative
canonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂)
canonical c = perm2comb (size≡ c) (comb2perm c)
-- Note that if c₁ ⇔ c₂, then by soundness c₁ ∼ c₂ and hence their
-- canonical representatives are identical.
canonicalWellDefined : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} →
(c₁ ⇔ c₂) → (canonical c₁ ≡ canonical c₂)
canonicalWellDefined {t₁} {t₂} {c₁} {c₂} α =
cong₂ perm2comb (size∼ c₁ c₂) (soundness α)
-- If we can prove that every combinator is equal to its normal form
-- then we can prove completeness.
inversion : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ canonical c
inversion = {!!}
resp≡⇔ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ≡ c₂) → (c₁ ⇔ c₂)
resp≡⇔ {t₁} {t₂} {c₁} {c₂} p rewrite p = id⇔
completeness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₁ ⇔ c₂)
completeness {t₁} {t₂} {c₁} {c₂} c₁∼c₂ =
c₁
⇔⟨ inversion ⟩
canonical c₁
⇔⟨ resp≡⇔ (cong₂ perm2comb (size∼ c₁ c₂) c₁∼c₂) ⟩
canonical c₂
⇔⟨ 2! inversion ⟩
c₂ ▤
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Nat and Fin lemmas
suc≤ : (m n : ℕ) → suc m ≤ m + suc n
suc≤ 0 n = s≤s z≤n
suc≤ (suc m) n = s≤s (suc≤ m n)
-+-id : (n : ℕ) → (i : Fin n) → suc (n ∸ toℕ i) + toℕ i ≡ suc n
-+-id 0 () -- absurd
-+-id (suc n) zero = +-right-identity (suc (suc n))
-+-id (suc n) (suc i) = begin
suc (suc n ∸ toℕ (suc i)) + toℕ (suc i)
≡⟨ refl ⟩
suc (n ∸ toℕ i) + suc (toℕ i)
≡⟨ +-suc (suc (n ∸ toℕ i)) (toℕ i) ⟩
suc (suc (n ∸ toℕ i) + toℕ i)
≡⟨ cong suc (-+-id n i) ⟩
suc (suc n) ∎
p0 p1 : Perm 4
p0 = idπ
p1 = swap (inject+ 1 (fromℕ 2)) (inject+ 3 (fromℕ 0))
(swap (fromℕ 3) zero
(swap zero (inject+ 1 (fromℕ 2))
idπ))
xx = action p1 (10 ∷ 20 ∷ 30 ∷ 40 ∷ [])
n≤sn : ∀ {x} → x ≤ suc x
n≤sn {0} = z≤n
n≤sn {suc n} = s≤s (n≤sn {n})
<implies≤ : ∀ {x y} → (x < y) → (x ≤ y)
<implies≤ (s≤s z≤n) = z≤n
<implies≤ {suc x} {suc y} (s≤s p) =
begin (suc x
≤⟨ p ⟩
y
≤⟨ n≤sn {y} ⟩
suc y ∎)
where open ≤-Reasoning
bounded≤ : ∀ {n} (i : Fin n) → toℕ i ≤ n
bounded≤ i = <implies≤ (bounded i)
n≤n : (n : ℕ) → n ≤ n
n≤n 0 = z≤n
n≤n (suc n) = s≤s (n≤n n)
-- Convenient way of "seeing" what the permutation does for each combinator
matchP : ∀ {t t'} → (t ⟷ t') → Vec (⟦ t ⟧ × ⟦ t' ⟧) (size t)
matchP {t} {t'} c =
match sp (comb2perm c) (utoVec t)
(subst (λ n → Vec ⟦ t' ⟧ n) (sym sp) (utoVec t'))
where sp = size≡ c
infix 90 _X_
data Swap (n : ℕ) : Set where
_X_ : Fin n → Fin n → Swap n
Perm : ℕ → Set
Perm n = List (Swap n)
showSwap : ∀ {n} → Swap n → String
showSwap (i X j) = show (toℕ i) ++S " X " ++S show (toℕ j)
actionπ : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → Perm n → Vec A n → Vec A n
actionπ π vs = foldl swapX vs π
where
swapX : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → Vec A n → Swap n → Vec A n
swapX vs (i X j) = (vs [ i ]≔ lookup j vs) [ j ]≔ lookup i vs
swapπ : ∀ {m n} → Perm (m + n)
swapπ {0} {n} = []
swapπ {suc m} {n} =
concatL
(replicate (suc m)
(toList
(zipWith _X_
(mapV inject₁ (allFin (m + n)))
(tail (allFin (suc m + n))))))
scompπ : ∀ {n} → Perm n → Perm n → Perm n
scompπ = _++L_
injectπ : ∀ {m} → Perm m → (n : ℕ) → Perm (m + n)
injectπ π n = mapL (λ { (i X j) → (inject+ n i) X (inject+ n j) }) π
raiseπ : ∀ {n} → Perm n → (m : ℕ) → Perm (m + n)
raiseπ π m = mapL (λ { (i X j) → (raise m i) X (raise m j) }) π
pcompπ : ∀ {m n} → Perm m → Perm n → Perm (m + n)
pcompπ {m} {n} α β = (injectπ α n) ++L (raiseπ β m)
idπ : ∀ {n} → Perm n
idπ {n} = toList (zipWith _X_ (allFin n) (allFin n))
tcompπ : ∀ {m n} → Perm m → Perm n → Perm (m * n)
tcompπ {m} {n} α β =
concatL (mapL
(λ { (i X j) →
mapL (λ { (k X l) →
(inject≤ (fromℕ (toℕ i * n + toℕ k))
(i*n+k≤m*n i k))
X
(inject≤ (fromℕ (toℕ j * n + toℕ l))
(i*n+k≤m*n j l))})
(β ++L idπ {n})})
(α ++L idπ {m}))
module Sort (A : Set) {_<_ : Rel A lzero} ( _<?_ : Decidable _<_) where
insert : (A × A → A × A) → A → List A → List A
insert shift x [] = x ∷ []
insert shift x (y ∷ ys) with x <? y
... | yes _ = x ∷ y ∷ ys
... | no _ = let (y' , x') = shift (x , y)
in y' ∷ insert shift x' ys
sort : (A × A → A × A) → List A → List A
sort shift [] = []
sort shift (x ∷ xs) = insert shift x (sort shift xs)
data _<S_ {n : ℕ} : Rel (Transposition< n) lzero where
<1 : ∀ {i j k l : Fin n} {p₁ : toℕ i < toℕ j} {p₂ : toℕ k < toℕ l} →
(toℕ i < toℕ k) → (_X_ i j {p₁}) <S (_X_ k l {p₂})
<2 : ∀ {i j k l : Fin n} {p₁ : toℕ i < toℕ j} {p₂ : toℕ k < toℕ l} →
(toℕ i ≡ toℕ k) → (toℕ j < toℕ l) →
(_X_ i j {p₁}) <S (_X_ k l {p₂})
d<S : {n : ℕ} → Decidable (_<S_ {n})
d<S (_X_ i j {p₁}) (_X_ k l {p₂}) with suc (toℕ i) ≤? toℕ k
d<S (_X_ i j {p₁}) (_X_ k l {p₂}) | yes p = yes (<1 p)
d<S (_X_ i j {p₁}) (_X_ k l {p₂}) | no p with toℕ i ≟ toℕ k
d<S (_X_ i j {p₁}) (_X_ k l {p₂}) | no p | yes p= with suc (toℕ j) ≤? toℕ l
d<S (_X_ i j {p₁}) (_X_ k l {p₂}) | no p | yes p= | yes p' = yes (<2 p= p')
d<S (_X_ i j {p₁}) (_X_ k l {p₂}) | no p | yes p= | no p' =
no (λ { (<1 i<k) → p i<k ;
(<2 i≡k j<l) → p' j<l})
d<S (_X_ i j {p₁}) (_X_ k l {p₂}) | no p | no p≠ =
no (λ { (<1 i<k) → p i<k ;
(<2 i≡k j<l) → p≠ i≡k })
module TSort (n : ℕ) = Sort (Transposition< n) {_<S_} d<S
-- If we shift a transposition past another, there is nothing to do if
-- the four indices are different. If however there is a common index,
-- we have to adjust the transpositions.
shift : {n : ℕ} → Transposition< n × Transposition< n →
Transposition< n × Transposition< n
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
with toℕ i ≟ toℕ k | toℕ i ≟ toℕ l | toℕ j ≟ toℕ k | toℕ j ≟ toℕ l
--
-- a bunch of impossible cases given that i < j and k < l
--
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| _ | _ | yes j≡k | yes j≡l
with trans (sym j≡k) (j≡l) | i<j→i≠j {toℕ k} {toℕ l} k<l
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| _ | _ | yes j≡k | yes j≡l
| k≡l | ¬k≡l with ¬k≡l k≡l
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| _ | _ | yes j≡k | yes j≡l
| k≡l | ¬k≡l | ()
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| _ | yes i≡l | _ | yes j≡l
with trans i≡l (sym j≡l) | i<j→i≠j {toℕ i} {toℕ j} i<j
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| _ | yes i≡l | _ | yes j≡l
| i≡j | ¬i≡j with ¬i≡j i≡j
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| _ | yes i≡l | _ | yes j≡l
| i≡j | ¬i≡j | ()
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| yes i≡k | _ | yes j≡k | _
with trans i≡k (sym j≡k) | i<j→i≠j {toℕ i} {toℕ j} i<j
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| yes i≡k | _ | yes j≡k | _
| i≡j | ¬i≡j with ¬i≡j i≡j
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| yes i≡k | _ | yes j≡k | _
| i≡j | ¬i≡j | ()
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| yes i≡k | yes i≡l | _ | _
with trans (sym i≡k) i≡l | i<j→i≠j {toℕ k} {toℕ l} k<l
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| yes i≡k | yes i≡l | _ | _
| k≡l | ¬k≡l with ¬k≡l k≡l
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| yes i≡k | yes i≡l | _ | _
| k≡l | ¬k≡l | ()
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| _ | yes i≡l | yes j≡k | _
with subst₂ _<_ (sym j≡k) (sym i≡l) k<l | i<j→j≮i {toℕ i} {toℕ j} i<j
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| _ | yes i≡l | yes j≡k | _
| j<i | j≮i with j≮i j<i
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| _ | yes i≡l | yes j≡k | _
| j<i | j≮i | ()
--
-- end of impossible cases
--
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| no ¬i≡k | no ¬i≡l | no ¬j≡k | no ¬j≡l =
-- no interference
(_X_ k l {k<l} , _X_ i j {i<j})
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| yes i≡k | no ¬i≡l | no ¬j≡k | yes j≡l =
-- Ex: 2 X 5 , 2 X 5
(_X_ k l {k<l} , _X_ i j {i<j})
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| no ¬i≡k | no ¬i≡l | no ¬j≡k | yes j≡l
with toℕ i <? toℕ k
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| no ¬i≡k | no ¬i≡l | no ¬j≡k | yes j≡l
| yes i<k =
(_X_ i k {i<k} , _X_ i j {i<j})
-- Ex: 2 X 5 , 3 X 5
-- becomes 2 X 3 , 2 X 5
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| no ¬i≡k | no ¬i≡l | no ¬j≡k | yes j≡l
| no i≮k =
(_X_ k i
{i≰j∧j≠i→j<i (toℕ i) (toℕ k) (i≮j∧i≠j→i≰j (toℕ i) (toℕ k) i≮k ¬i≡k)
(i≠j→j≠i (toℕ i) (toℕ k) ¬i≡k)} ,
_X_ i j {i<j})
-- Ex: 2 X 5 , 1 X 5
-- becomes 1 X 2 , 2 X 5
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| no ¬i≡k | no ¬i≡l | yes j≡k | no ¬j≡l =
-- Ex: 2 X 5 , 5 X 6
-- becomes 2 x 6 , 2 X 5
(_X_ i l {trans< (subst ((λ j → toℕ i < j)) j≡k i<j) k<l} , _X_ i j {i<j})
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| no ¬i≡k | yes i≡l | no ¬j≡k | no ¬j≡l =
-- Ex: 2 X 5 , 1 X 2
-- becomes 1 X 5 , 2 X 5
(_X_ k j {trans< (subst ((λ l → toℕ k < l)) (sym i≡l) k<l) i<j} ,
_X_ i j {i<j})
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| yes i≡k | no ¬i≡l | no ¬j≡k | no ¬j≡l
with toℕ j <? toℕ l
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| yes i≡k | no ¬i≡l | no ¬j≡k | no ¬j≡l
| yes j<l =
-- Ex: 2 X 3 , 2 X 4
-- becomes 3 X 4 , 2 X 3
(_X_ j l {j<l} , _X_ i j {i<j})
shift {n} (_X_ i j {i<j} , _X_ k l {k<l})
| yes i≡k | no ¬i≡l | no ¬j≡k | no ¬j≡l
| no j≮l =
-- Ex: 2 X 5 , 2 X 4
-- becomes 4 X 5 , 2 X 5
(_X_ l j {i≰j∧j≠i→j<i (toℕ j) (toℕ l) (i≮j∧i≠j→i≰j (toℕ j) (toℕ l) j≮l ¬j≡l)
(i≠j→j≠i (toℕ j) (toℕ l) ¬j≡l)} ,
_X_ i j {i<j})
-- Coalesce permutations i X j followed by i X k
-- Do termination proof...
{-# NO_TERMINATION_CHECK #-}
coalesce : {n : ℕ} → Perm< n → Perm< n
coalesce [] = []
coalesce (x ∷ []) = x ∷ []
coalesce (_X_ i j {i<j} ∷ _X_ k l {k<l} ∷ π) with toℕ i ≟ toℕ k
coalesce (_X_ i j {i<j} ∷ _X_ k l {k<l} ∷ π)
| no ¬i≡k = _X_ i j {i<j} ∷ coalesce (_X_ k l {k<l} ∷ π)
coalesce (_X_ i j {i<j} ∷ _X_ k l {k<l} ∷ π)
| yes i≡k with toℕ j <? toℕ l
coalesce {n} (_X_ i j {i<j} ∷ _X_ k l {k<l} ∷ π)
| yes i≡k | yes j<l =
-- Ex: 2 X 5 , 2 X 6
-- becomes 2 X 6 , 5 X 6
coalesce {n} (sort (shift {n}) (_X_ k l {k<l} ∷ _X_ j l {j<l} ∷ π))
where open TSort n
coalesce {n} (_X_ i j {i<j} ∷ _X_ k l {k<l} ∷ π)
| yes i≡k | no j≮l with toℕ j ≟ toℕ l
coalesce {n} (_X_ i j {i<j} ∷ _X_ k l {k<l} ∷ π)
| yes i≡k | no j≮l | yes j≡l =
-- Ex: 2 X 5 , 2 X 5
-- disappears
coalesce {n} π
coalesce {n} (_X_ i j {i<j} ∷ _X_ k l {k<l} ∷ π)
| yes i≡k | no j≮l | no ¬j≡l =
-- Ex: 2 X 5 , 2 X 3
-- becomes 2 X 3 , 3 X 5
-- should never happen if input is sorted but the type Perm<
-- does not capture this
coalesce {n}
(sort
(shift {n})
(_X_ k l {k<l} ∷
_X_ l j {i≰j∧j≠i→j<i (toℕ j) (toℕ l)
(i≮j∧i≠j→i≰j (toℕ j) (toℕ l) j≮l ¬j≡l)
(i≠j→j≠i (toℕ j) (toℕ l) ¬j≡l)} ∷
π))
where open TSort n
-- Normalized permutations have exactly one entry for each position
infixr 5 _∷_
data NPerm : ℕ → Set where
[] : NPerm 0
_∷_ : {n : ℕ} → Fin (suc n) → NPerm n → NPerm (suc n)
lookupP : ∀ {n} → Fin n → NPerm n → Fin n
lookupP () []
lookupP zero (j ∷ _) = j
lookupP {suc n} (suc i) (j ∷ q) = inject₁ (lookupP i q)
insert : ∀ {ℓ n} {A : Set ℓ} → Vec A n → Fin (suc n) → A → Vec A (suc n)
insert vs zero w = w ∷ vs
insert [] (suc ()) -- absurd
insert (v ∷ vs) (suc i) w = v ∷ insert vs i w
-- A normalized permutation acts on a vector by inserting each element in its
-- new position.
permute : ∀ {ℓ n} {A : Set ℓ} → NPerm n → Vec A n → Vec A n
permute [] [] = []
permute (p ∷ ps) (v ∷ vs) = insert (permute ps vs) p v
-- Convert normalized permutation to a sequence of transpositions
nperm2list : ∀ {n} → NPerm n → Perm< n
nperm2list {0} [] = []
nperm2list {suc n} (p ∷ ps) = {!!}
-- Aggregate a sequence of transpositions to one insertion in the right
-- position
aggregate : ∀ {n} → Perm< n → NPerm n
aggregate = {!!}
{--
aggregate [] = []
aggregate (_X_ i j {p₁} ∷ []) = _X_ i j {p₁} ∷ []
aggregate (_X_ i j {p₁} ∷ _X_ k l {p₂} ∷ π) with toℕ i ≟ toℕ k | toℕ j ≟ toℕ l
aggregate (_X_ i j {p₁} ∷ _X_ k l {p₂} ∷ π) | yes _ | yes _ =
aggregate (_X_ k l {p₂} ∷ π)
aggregate (_X_ i j {p₁} ∷ _X_ k l {p₂} ∷ π) | _ | _ =
(_X_ i j {p₁}) ∷ aggregate (_X_ k l {p₂} ∷ π)
--}
normalize : ∀ {n} → Perm n → NPerm n
normalize {n} = aggregate ∘ sort ∘ normalize<
where open TSort n
-- Examples
nsnn₁ nsnn₂ nsnn₃ nsnn₄ nsnn₅ : List String
nsnn₁ = mapL showTransposition< (nperm2list (normalize (c2π neg₁)))
where open TSort 2
-- 0 X 1 ∷ []
nsnn₂ = mapL showTransposition< (nperm2list (normalize (c2π neg₂)))
where open TSort 2
-- 0 X 1 ∷ []
nsnn₃ = mapL showTransposition< (nperm2list (normalize (c2π neg₃)))
where open TSort 2
-- 0 X 1 ∷ []
nsnn₄ = mapL showTransposition< (nperm2list (normalize (c2π neg₄)))
where open TSort 2
-- 0 X 1 ∷ []
nsnn₅ = mapL showTransposition< (nperm2list (normalize (c2π neg₅)))
where open TSort 2
-- 0 X 1 ∷ []
nswap₁₂ nswap₂₃ nswap₁₃ : List String
nswap₁₂ = mapL showTransposition< (nperm2list (normalize (c2π SWAP12)))
nswap₂₃ = mapL showTransposition< (nperm2list (normalize (c2π SWAP23)))
nswap₁₃ = mapL showTransposition< (nperm2list (normalize (c2π SWAP13)))
xxx : Perm 5
xxx = (_X_ (inject+ 1 (fromℕ 3)) (fromℕ 4) {s≤s (s≤s (s≤s z≤n))}) ∷
(_X_ (inject+ 3 (fromℕ 1)) (inject+ 1 (fromℕ 3)) {s≤s z≤n}) ∷
(_X_ zero (inject+ 1 (fromℕ 3)) {z≤n}) ∷
(_X_ (inject+ 3 (fromℕ 1)) (inject+ 2 (fromℕ 2)) {s≤s z≤n}) ∷ []
yyy : ∀ {ℓ m n} {A B : Set ℓ} → Vec A m → Vec B n → Vec (A ⊎ B) (m + n)
yyy vs ws = mapV inj₁ vs ++V mapV inj₂ ws
xxx : ∀ {ℓ m n} {A B : Set ℓ} → Vec A m → Vec B n → Vec (A × B) (m * n)
xxx vs ws = concatV (mapV (λ v₁ → mapV (λ v₂ → (v₁ , v₂)) ws) vs)
vs : Vec ℕ 7
vs = 0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ 6 ∷ []
ws : Vec ℕ 5
ws = 10 ∷ 11 ∷ 12 ∷ 13 ∷ 14 ∷ []
us : Vec ℕ 3
us = 100 ∷ 101 ∷ 102 ∷ []
os : Vec ℕ 1
os = 1000 ∷ []
-- xxx vs ws
-- (0 , 10) ∷ (0 , 11) ∷ (0 , 12) ∷ (0 , 13) ∷ (0 , 14) ∷
-- (1 , 10) ∷ (1 , 11) ∷ (1 , 12) ∷ (1 , 13) ∷ (1 , 14) ∷
-- (2 , 10) ∷ (2 , 11) ∷ (2 , 12) ∷ (2 , 13) ∷ (2 , 14) ∷
-- (3 , 10) ∷ (3 , 11) ∷ (3 , 12) ∷ (3 , 13) ∷ (3 , 14) ∷
-- (4 , 10) ∷ (4 , 11) ∷ (4 , 12) ∷ (4 , 13) ∷ (4 , 14) ∷
-- (5 , 10) ∷ (5 , 11) ∷ (5 , 12) ∷ (5 , 13) ∷ (5 , 14) ∷
-- (6 , 10) ∷ (6 , 11) ∷ (6 , 12) ∷ (6 , 13) ∷ (6 , 14) ∷
-- []
-- xxx ws vs
-- (10 , 0) ∷ (10 , 1) ∷ (10 , 2) ∷ (10 , 3) ∷ (10 , 4) ∷ (10 , 5) ∷ (10 , 6) ∷
-- (11 , 0) ∷ (11 , 1) ∷ (11 , 2) ∷ (11 , 3) ∷ (11 , 4) ∷ (11 , 5) ∷ (11 , 6) ∷
-- (12 , 0) ∷ (12 , 1) ∷ (12 , 2) ∷ (12 , 3) ∷ (12 , 4) ∷ (12 , 5) ∷ (12 , 6) ∷
-- (13 , 0) ∷ (13 , 1) ∷ (13 , 2) ∷ (13 , 3) ∷ (13 , 4) ∷ (13 , 5) ∷ (13 , 6) ∷
-- (14 , 0) ∷ (14 , 1) ∷ (14 , 2) ∷ (14 , 3) ∷ (14 , 4) ∷ (14 , 5) ∷ (14 , 6) ∷
-- []
xxx : Perm 5
xxx = cycle→Perm
(inject+ 3 (fromℕ 1) ∷
inject+ 1 (fromℕ 3) ∷
inject+ 2 (fromℕ 2) ∷
inject+ 0 (fromℕ 4) ∷ [])
-- cycle (1 3 2 4)
-- 1 X 4 ∷ 1 X 2 ∷ 1 X 3 ∷ []
a : Vec ℕ 5
a = 0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ []
-- actionπ xxx a
-- 0 ∷ 3 ∷ 4 ∷ 2 ∷ 1 ∷ []
bbb = transpose {3} {4} -- 3 * 2 => 2 * 3
-- (zero , zero) ∷
-- (suc zero , suc (suc (suc zero))) ∷
-- (suc (suc zero) , suc zero) ∷
-- (suc (suc (suc zero)) , suc (suc (suc (suc zero)))) ∷
-- (suc (suc (suc (suc zero))) , suc (suc zero)) ∷ []
{--
------------------------------------------------------------------------------
-- Extensional equivalence of combinators: two combinators are
-- equivalent if they denote the same permutation. Generally we would
-- require that the two permutations map the same value x to values y
-- and z that have a path between them, but because the internals of each
-- type are discrete groupoids, this reduces to saying that y and z
-- are identical, and hence that the permutations are identical.
normalize : ∀ {n} → Perm n → Perm< n
normalize = sort ∘ filter=
infix 10 _∼_
_∼_ : ∀ {t₁ t₂} → (c₁ c₂ : t₁ ⟷ t₂) → Set
c₁ ∼ c₂ = (normalize (c2π c₁) ≡ normalize (c2π c₂))
-- The relation ~ is an equivalence relation
refl∼ : ∀ {t₁ t₂} {c : t₁ ⟷ t₂} → (c ∼ c)
refl∼ = refl
sym∼ : ∀ {t₁ t₂} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₁)
sym∼ = sym
trans∼ : ∀ {t₁ t₂} {c₁ c₂ c₃ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₃) → (c₁ ∼ c₃)
trans∼ = trans
-- The relation ~ validates the groupoid laws
c◎id∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ id⟷ ∼ c
c◎id∼c = {!!}
id◎c∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ◎ c ∼ c
id◎c∼c = {!!}
assoc∼ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
c₁ ◎ (c₂ ◎ c₃) ∼ (c₁ ◎ c₂) ◎ c₃
assoc∼ = {!!}
linv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ ! c ∼ id⟷
linv∼ = {!!}
rinv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → ! c ◎ c ∼ id⟷
rinv∼ = {!!}
resp∼ : {t₁ t₂ t₃ : U} {c₁ c₂ : t₁ ⟷ t₂} {c₃ c₄ : t₂ ⟷ t₃} →
(c₁ ∼ c₂) → (c₃ ∼ c₄) → (c₁ ◎ c₃ ∼ c₂ ◎ c₄)
resp∼ = {!!}
-- The equivalence ∼ of paths makes U a 1groupoid: the points are
-- types (t : U); the 1paths are ⟷; and the 2paths between them are
-- based on extensional equivalence ∼
G : 1Groupoid
G = record
{ set = U
; _↝_ = _⟷_
; _≈_ = _∼_
; id = id⟷
; _∘_ = λ p q → q ◎ p
; _⁻¹ = !
; lneutr = λ c → c◎id∼c {c = c}
; rneutr = λ c → id◎c∼c {c = c}
; assoc = λ c₃ c₂ c₁ → assoc∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃}
; equiv = record {
refl = λ {c} → refl∼ {c = c}
; sym = λ {c₁} {c₂} → sym∼ {c₁ = c₁} {c₂ = c₂}
; trans = λ {c₁} {c₂} {c₃} → trans∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃}
}
; linv = λ c → linv∼ {c = c}
; rinv = λ c → rinv∼ {c = c}
; ∘-resp-≈ = {!!} -- λ α β → resp∼ β α
}
-- And there are additional laws
assoc⊕∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
c₁ ⊕ (c₂ ⊕ c₃) ∼ assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊
assoc⊕∼ = {!!}
assoc⊗∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
c₁ ⊗ (c₂ ⊗ c₃) ∼ assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆
assoc⊗∼ = {!!}
------------------------------------------------------------------------------
-- Picture so far:
--
-- path p
-- =====================
-- || || ||
-- || ||2path ||
-- || || ||
-- || || path q ||
-- t₁ =================t₂
-- || ... ||
-- =====================
--
-- The types t₁, t₂, etc are discrete groupoids. The paths between
-- them correspond to permutations. Each syntactically different
-- permutation corresponds to a path but equivalent permutations are
-- connected by 2paths. But now we want an alternative definition of
-- 2paths that is structural, i.e., that looks at the actual
-- construction of the path t₁ ⟷ t₂ in terms of combinators... The
-- theorem we want is that α ∼ β iff we can rewrite α to β using
-- various syntactic structural rules. We start with a collection of
-- simplication rules and then try to show they are complete.
-- Simplification rules
infix 30 _⇔_
data _⇔_ : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂) → Set where
assoc◎l : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
(c₁ ◎ (c₂ ◎ c₃)) ⇔ ((c₁ ◎ c₂) ◎ c₃)
assoc◎r : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
((c₁ ◎ c₂) ◎ c₃) ⇔ (c₁ ◎ (c₂ ◎ c₃))
assoc⊕l : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(c₁ ⊕ (c₂ ⊕ c₃)) ⇔ (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊)
assoc⊕r : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊) ⇔ (c₁ ⊕ (c₂ ⊕ c₃))
assoc⊗l : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(c₁ ⊗ (c₂ ⊗ c₃)) ⇔ (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)
assoc⊗r : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆) ⇔ (c₁ ⊗ (c₂ ⊗ c₃))
dist⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
((c₁ ⊕ c₂) ⊗ c₃) ⇔ (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor)
factor⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor) ⇔ ((c₁ ⊕ c₂) ⊗ c₃)
idl◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (id⟷ ◎ c) ⇔ c
idl◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ id⟷ ◎ c
idr◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ id⟷) ⇔ c
idr◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ (c ◎ id⟷)
linv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ ! c) ⇔ id⟷
linv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (c ◎ ! c)
rinv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (! c ◎ c) ⇔ id⟷
rinv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (! c ◎ c)
unitel₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(unite₊ ◎ c₂) ⇔ ((c₁ ⊕ c₂) ◎ unite₊)
uniter₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
((c₁ ⊕ c₂) ◎ unite₊) ⇔ (unite₊ ◎ c₂)
unitil₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(uniti₊ ◎ (c₁ ⊕ c₂)) ⇔ (c₂ ◎ uniti₊)
unitir₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(c₂ ◎ uniti₊) ⇔ (uniti₊ ◎ (c₁ ⊕ c₂))
unitial₊⇔ : {t₁ t₂ : U} → (uniti₊ {PLUS t₁ t₂} ◎ assocl₊) ⇔ (uniti₊ ⊕ id⟷)
unitiar₊⇔ : {t₁ t₂ : U} → (uniti₊ {t₁} ⊕ id⟷ {t₂}) ⇔ (uniti₊ ◎ assocl₊)
swapl₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
(swap₊ ◎ (c₁ ⊕ c₂)) ⇔ ((c₂ ⊕ c₁) ◎ swap₊)
swapr₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
((c₂ ⊕ c₁) ◎ swap₊) ⇔ (swap₊ ◎ (c₁ ⊕ c₂))
unitel⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(unite⋆ ◎ c₂) ⇔ ((c₁ ⊗ c₂) ◎ unite⋆)
uniter⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
((c₁ ⊗ c₂) ◎ unite⋆) ⇔ (unite⋆ ◎ c₂)
unitil⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(uniti⋆ ◎ (c₁ ⊗ c₂)) ⇔ (c₂ ◎ uniti⋆)
unitir⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(c₂ ◎ uniti⋆) ⇔ (uniti⋆ ◎ (c₁ ⊗ c₂))
unitial⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {TIMES t₁ t₂} ◎ assocl⋆) ⇔ (uniti⋆ ⊗ id⟷)
unitiar⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {t₁} ⊗ id⟷ {t₂}) ⇔ (uniti⋆ ◎ assocl⋆)
swapl⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
(swap⋆ ◎ (c₁ ⊗ c₂)) ⇔ ((c₂ ⊗ c₁) ◎ swap⋆)
swapr⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
((c₂ ⊗ c₁) ◎ swap⋆) ⇔ (swap⋆ ◎ (c₁ ⊗ c₂))
swapfl⋆⇔ : {t₁ t₂ t₃ : U} →
(swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor) ⇔
(factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷))
swapfr⋆⇔ : {t₁ t₂ t₃ : U} →
(factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷)) ⇔
(swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor)
id⇔ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ c
trans⇔ : {t₁ t₂ : U} {c₁ c₂ c₃ : t₁ ⟷ t₂} →
(c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)
resp◎⇔ : {t₁ t₂ t₃ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₁ ⟷ t₂} {c₄ : t₂ ⟷ t₃} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ◎ c₂) ⇔ (c₃ ◎ c₄)
resp⊕⇔ : {t₁ t₂ t₃ t₄ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊕ c₂) ⇔ (c₃ ⊕ c₄)
resp⊗⇔ : {t₁ t₂ t₃ t₄ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊗ c₂) ⇔ (c₃ ⊗ c₄)
-- better syntax for writing 2paths
infix 2 _▤
infixr 2 _⇔⟨_⟩_
_⇔⟨_⟩_ : {t₁ t₂ : U} (c₁ : t₁ ⟷ t₂) {c₂ : t₁ ⟷ t₂} {c₃ : t₁ ⟷ t₂} →
(c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)
_ ⇔⟨ α ⟩ β = trans⇔ α β
_▤ : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → (c ⇔ c)
_▤ c = id⇔
-- Inverses for 2paths
2! : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₂ ⇔ c₁)
2! assoc◎l = assoc◎r
2! assoc◎r = assoc◎l
2! assoc⊕l = assoc⊕r
2! assoc⊕r = assoc⊕l
2! assoc⊗l = assoc⊗r
2! assoc⊗r = assoc⊗l
2! dist⇔ = factor⇔
2! factor⇔ = dist⇔
2! idl◎l = idl◎r
2! idl◎r = idl◎l
2! idr◎l = idr◎r
2! idr◎r = idr◎l
2! linv◎l = linv◎r
2! linv◎r = linv◎l
2! rinv◎l = rinv◎r
2! rinv◎r = rinv◎l
2! unitel₊⇔ = uniter₊⇔
2! uniter₊⇔ = unitel₊⇔
2! unitil₊⇔ = unitir₊⇔
2! unitir₊⇔ = unitil₊⇔
2! swapl₊⇔ = swapr₊⇔
2! swapr₊⇔ = swapl₊⇔
2! unitial₊⇔ = unitiar₊⇔
2! unitiar₊⇔ = unitial₊⇔
2! unitel⋆⇔ = uniter⋆⇔
2! uniter⋆⇔ = unitel⋆⇔
2! unitil⋆⇔ = unitir⋆⇔
2! unitir⋆⇔ = unitil⋆⇔
2! unitial⋆⇔ = unitiar⋆⇔
2! unitiar⋆⇔ = unitial⋆⇔
2! swapl⋆⇔ = swapr⋆⇔
2! swapr⋆⇔ = swapl⋆⇔
2! swapfl⋆⇔ = swapfr⋆⇔
2! swapfr⋆⇔ = swapfl⋆⇔
2! id⇔ = id⇔
2! (trans⇔ α β) = trans⇔ (2! β) (2! α)
2! (resp◎⇔ α β) = resp◎⇔ (2! α) (2! β)
2! (resp⊕⇔ α β) = resp⊕⇔ (2! α) (2! β)
2! (resp⊗⇔ α β) = resp⊗⇔ (2! α) (2! β)
-- a nice example of 2 paths
negEx : neg₅ ⇔ neg₁
negEx = uniti⋆ ◎ (swap⋆ ◎ ((swap₊ ⊗ id⟷) ◎ (swap⋆ ◎ unite⋆)))
⇔⟨ resp◎⇔ id⇔ assoc◎l ⟩
uniti⋆ ◎ ((swap⋆ ◎ (swap₊ ⊗ id⟷)) ◎ (swap⋆ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ swapl⋆⇔ id⇔) ⟩
uniti⋆ ◎ (((id⟷ ⊗ swap₊) ◎ swap⋆) ◎ (swap⋆ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ assoc◎r ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (swap⋆ ◎ (swap⋆ ◎ unite⋆)))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ assoc◎l) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ ((swap⋆ ◎ swap⋆) ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ (resp◎⇔ linv◎l id⇔)) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (id⟷ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ idl◎l) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ unite⋆)
⇔⟨ assoc◎l ⟩
(uniti⋆ ◎ (id⟷ ⊗ swap₊)) ◎ unite⋆
⇔⟨ resp◎⇔ unitil⋆⇔ id⇔ ⟩
(swap₊ ◎ uniti⋆) ◎ unite⋆
⇔⟨ assoc◎r ⟩
swap₊ ◎ (uniti⋆ ◎ unite⋆)
⇔⟨ resp◎⇔ id⇔ linv◎l ⟩
swap₊ ◎ id⟷
⇔⟨ idr◎l ⟩
swap₊ ▤
-- The equivalence ⇔ of paths is rich enough to make U a 1groupoid:
-- the points are types (t : U); the 1paths are ⟷; and the 2paths
-- between them are based on the simplification rules ⇔
G' : 1Groupoid
G' = record
{ set = U
; _↝_ = _⟷_
; _≈_ = _⇔_
; id = id⟷
; _∘_ = λ p q → q ◎ p
; _⁻¹ = !
; lneutr = λ _ → idr◎l
; rneutr = λ _ → idl◎l
; assoc = λ _ _ _ → assoc◎l
; equiv = record {
refl = id⇔
; sym = 2!
; trans = trans⇔
}
; linv = λ {t₁} {t₂} α → linv◎l
; rinv = λ {t₁} {t₂} α → rinv◎l
; ∘-resp-≈ = λ p∼q r∼s → resp◎⇔ r∼s p∼q
}
------------------------------------------------------------------------------
-- Inverting permutations to syntactic combinators
π2c : {t₁ t₂ : U} → (size t₁ ≡ size t₂) → NPerm (size t₁) → (t₁ ⟷ t₂)
π2c = {!!}
------------------------------------------------------------------------------
-- Soundness and completeness
--
-- Proof of soundness and completeness: now we want to verify that ⇔
-- is sound and complete with respect to ∼. The statement to prove is
-- that for all c₁ and c₂, we have c₁ ∼ c₂ iff c₁ ⇔ c₂
soundness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₁ ∼ c₂)
soundness assoc◎l = {!!} -- assoc∼
soundness assoc◎r = {!!} -- sym∼ assoc∼
soundness assoc⊕l = {!!} -- assoc⊕∼
soundness assoc⊕r = {!!} -- sym∼ assoc⊕∼
soundness assoc⊗l = {!!} -- assoc⊗∼
soundness assoc⊗r = {!!} -- sym∼ assoc⊗∼
soundness dist⇔ = {!!}
soundness factor⇔ = {!!}
soundness idl◎l = {!!} -- id◎c∼c
soundness idl◎r = {!!} -- sym∼ id◎c∼c
soundness idr◎l = {!!} -- c◎id∼c
soundness idr◎r = {!!} -- sym∼ c◎id∼c
soundness linv◎l = {!!} -- linv∼
soundness linv◎r = {!!} -- sym∼ linv∼
soundness rinv◎l = {!!} -- rinv∼
soundness rinv◎r = {!!} -- sym∼ rinv∼
soundness unitel₊⇔ = {!!}
soundness uniter₊⇔ = {!!}
soundness unitil₊⇔ = {!!}
soundness unitir₊⇔ = {!!}
soundness unitial₊⇔ = {!!}
soundness unitiar₊⇔ = {!!}
soundness swapl₊⇔ = {!!}
soundness swapr₊⇔ = {!!}
soundness unitel⋆⇔ = {!!}
soundness uniter⋆⇔ = {!!}
soundness unitil⋆⇔ = {!!}
soundness unitir⋆⇔ = {!!}
soundness unitial⋆⇔ = {!!}
soundness unitiar⋆⇔ = {!!}
soundness swapl⋆⇔ = {!!}
soundness swapr⋆⇔ = {!!}
soundness swapfl⋆⇔ = {!!}
soundness swapfr⋆⇔ = {!!}
soundness id⇔ = {!!} -- refl∼
soundness (trans⇔ α β) = {!!} -- trans∼ (soundness α) (soundness β)
soundness (resp◎⇔ α β) = {!!} -- resp∼ (soundness α) (soundness β)
soundness (resp⊕⇔ α β) = {!!}
soundness (resp⊗⇔ α β) = {!!}
-- The idea is to invert evaluation and use that to extract from each
-- extensional representation of a combinator, a canonical syntactic
-- representative
canonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂)
canonical c = π2c (size≡ c) (normalize (c2π c))
-- Note that if c₁ ⇔ c₂, then by soundness c₁ ∼ c₂ and hence their
-- canonical representatives are identical.
canonicalWellDefined : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} →
(c₁ ⇔ c₂) → (canonical c₁ ≡ canonical c₂)
canonicalWellDefined {t₁} {t₂} {c₁} {c₂} α =
cong₂ π2c (size∼ c₁ c₂) (soundness α)
-- If we can prove that every combinator is equal to its normal form
-- then we can prove completeness.
inversion : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ canonical c
inversion = {!!}
resp≡⇔ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ≡ c₂) → (c₁ ⇔ c₂)
resp≡⇔ {t₁} {t₂} {c₁} {c₂} p rewrite p = id⇔
completeness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₁ ⇔ c₂)
completeness {t₁} {t₂} {c₁} {c₂} c₁∼c₂ =
c₁
⇔⟨ inversion ⟩
canonical c₁
⇔⟨ resp≡⇔ (cong₂ π2c (size∼ c₁ c₂) c₁∼c₂) ⟩
canonical c₂
⇔⟨ 2! inversion ⟩
c₂ ▤
------------------------------------------------------------------------------
-- normalize a finite type to (1 + (1 + (1 + ... + (1 + 0) ... )))
-- a bunch of ones ending with zero with left biased + in between
toℕ : U → ℕ
toℕ ZERO = 0
toℕ ONE = 1
toℕ (PLUS t₁ t₂) = toℕ t₁ + toℕ t₂
toℕ (TIMES t₁ t₂) = toℕ t₁ * toℕ t₂
fromℕ : ℕ → U
fromℕ 0 = ZERO
fromℕ (suc n) = PLUS ONE (fromℕ n)
normalℕ : U → U
normalℕ = fromℕ ∘ toℕ
-- invert toℕ: give t and n such that toℕ t = n, return constraints on components of t
reflectPlusZero : {m n : ℕ} → (m + n ≡ 0) → m ≡ 0 × n ≡ 0
reflectPlusZero {0} {0} refl = (refl , refl)
reflectPlusZero {0} {suc n} ()
reflectPlusZero {suc m} {0} ()
reflectPlusZero {suc m} {suc n} ()
-- nbe
nbe : {t₁ t₂ : U} → (p : toℕ t₁ ≡ toℕ t₂) → (⟦ t₁ ⟧ → ⟦ t₂ ⟧) → (t₁ ⟷ t₂)
nbe {ZERO} {ZERO} refl f = id⟷
nbe {ZERO} {ONE} ()
nbe {ZERO} {PLUS t₁ t₂} p f = {!!}
nbe {ZERO} {TIMES t₂ t₃} p f = {!!}
nbe {ONE} {ZERO} ()
nbe {ONE} {ONE} p f = id⟷
nbe {ONE} {PLUS t₂ t₃} p f = {!!}
nbe {ONE} {TIMES t₂ t₃} p f = {!!}
nbe {PLUS t₁ t₂} {ZERO} p f = {!!}
nbe {PLUS t₁ t₂} {ONE} p f = {!!}
nbe {PLUS t₁ t₂} {PLUS t₃ t₄} p f = {!!}
nbe {PLUS t₁ t₂} {TIMES t₃ t₄} p f = {!!}
nbe {TIMES t₁ t₂} {ZERO} p f = {!!}
nbe {TIMES t₁ t₂} {ONE} p f = {!!}
nbe {TIMES t₁ t₂} {PLUS t₃ t₄} p f = {!!}
nbe {TIMES t₁ t₂} {TIMES t₃ t₄} p f = {!!}
-- build a combinator that does the normalization
assocrU : {m : ℕ} (n : ℕ) → (PLUS (fromℕ n) (fromℕ m)) ⟷ fromℕ (n + m)
assocrU 0 = unite₊
assocrU (suc n) = assocr₊ ◎ (id⟷ ⊕ assocrU n)
distrU : (m : ℕ) {n : ℕ} → TIMES (fromℕ m) (fromℕ n) ⟷ fromℕ (m * n)
distrU 0 = distz
distrU (suc n) {m} = dist ◎ (unite⋆ ⊕ distrU n) ◎ assocrU m
normalU : (t : U) → t ⟷ normalℕ t
normalU ZERO = id⟷
normalU ONE = uniti₊ ◎ swap₊
normalU (PLUS t₁ t₂) = (normalU t₁ ⊕ normalU t₂) ◎ assocrU (toℕ t₁)
normalU (TIMES t₁ t₂) = (normalU t₁ ⊗ normalU t₂) ◎ distrU (toℕ t₁)
-- a few lemmas
fromℕplus : {m n : ℕ} → fromℕ (m + n) ⟷ PLUS (fromℕ m) (fromℕ n)
fromℕplus {0} {n} =
fromℕ n
⟷⟨ uniti₊ ⟩
PLUS ZERO (fromℕ n) □
fromℕplus {suc m} {n} =
fromℕ (suc (m + n))
⟷⟨ id⟷ ⟩
PLUS ONE (fromℕ (m + n))
⟷⟨ id⟷ ⊕ fromℕplus {m} {n} ⟩
PLUS ONE (PLUS (fromℕ m) (fromℕ n))
⟷⟨ assocl₊ ⟩
PLUS (PLUS ONE (fromℕ m)) (fromℕ n)
⟷⟨ id⟷ ⟩
PLUS (fromℕ (suc m)) (fromℕ n) □
normalℕswap : {t₁ t₂ : U} → normalℕ (PLUS t₁ t₂) ⟷ normalℕ (PLUS t₂ t₁)
normalℕswap {t₁} {t₂} =
fromℕ (toℕ t₁ + toℕ t₂)
⟷⟨ fromℕplus {toℕ t₁} {toℕ t₂} ⟩
PLUS (normalℕ t₁) (normalℕ t₂)
⟷⟨ swap₊ ⟩
PLUS (normalℕ t₂) (normalℕ t₁)
⟷⟨ ! (fromℕplus {toℕ t₂} {toℕ t₁}) ⟩
fromℕ (toℕ t₂ + toℕ t₁) □
assocrUS : {m : ℕ} {t : U} → PLUS t (fromℕ m) ⟷ fromℕ (toℕ t + m)
assocrUS {m} {ZERO} = unite₊
assocrUS {m} {ONE} = id⟷
assocrUS {m} {t} =
PLUS t (fromℕ m)
⟷⟨ normalU t ⊕ id⟷ ⟩
PLUS (normalℕ t) (fromℕ m)
⟷⟨ ! fromℕplus ⟩
fromℕ (toℕ t + m) □
-- convert each combinator to a normal form
normal⟷ : {t₁ t₂ : U} → (c₁ : t₁ ⟷ t₂) →
Σ[ c₂ ∈ normalℕ t₁ ⟷ normalℕ t₂ ] (c₁ ⇔ (normalU t₁ ◎ c₂ ◎ (! (normalU t₂))))
normal⟷ {PLUS ZERO t} {.t} unite₊ =
(id⟷ ,
(unite₊
⇔⟨ idr◎r ⟩
unite₊ ◎ id⟷
⇔⟨ resp◎⇔ id⇔ linv◎r ⟩
unite₊ ◎ (normalU t ◎ (! (normalU t)))
⇔⟨ assoc◎l ⟩
(unite₊ ◎ normalU t) ◎ (! (normalU t))
⇔⟨ resp◎⇔ unitel₊⇔ id⇔ ⟩
((id⟷ ⊕ normalU t) ◎ unite₊) ◎ (! (normalU t))
⇔⟨ resp◎⇔ id⇔ idl◎r ⟩
((id⟷ ⊕ normalU t) ◎ unite₊) ◎ (id⟷ ◎ (! (normalU t)))
⇔⟨ id⇔ ⟩
normalU (PLUS ZERO t) ◎ (id⟷ ◎ (! (normalU t))) ▤))
normal⟷ {t} {PLUS ZERO .t} uniti₊ =
(id⟷ ,
(uniti₊
⇔⟨ idl◎r ⟩
id⟷ ◎ uniti₊
⇔⟨ resp◎⇔ linv◎r id⇔ ⟩
(normalU t ◎ (! (normalU t))) ◎ uniti₊
⇔⟨ assoc◎r ⟩
normalU t ◎ ((! (normalU t)) ◎ uniti₊)
⇔⟨ resp◎⇔ id⇔ unitir₊⇔ ⟩
normalU t ◎ (uniti₊ ◎ (id⟷ ⊕ (! (normalU t))))
⇔⟨ resp◎⇔ id⇔ idl◎r ⟩
normalU t ◎ (id⟷ ◎ (uniti₊ ◎ (id⟷ ⊕ (! (normalU t)))))
⇔⟨ id⇔ ⟩
normalU t ◎ (id⟷ ◎ (! ((id⟷ ⊕ (normalU t)) ◎ unite₊)))
⇔⟨ id⇔ ⟩
normalU t ◎ (id⟷ ◎ (! (normalU (PLUS ZERO t)))) ▤))
normal⟷ {PLUS ZERO t₂} {PLUS .t₂ ZERO} swap₊ =
(normalℕswap {ZERO} {t₂} ,
(swap₊
⇔⟨ {!!} ⟩
(unite₊ ◎ normalU t₂) ◎
(normalℕswap {ZERO} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ id⟷)))
⇔⟨ resp◎⇔ unitel₊⇔ id⇔ ⟩
((id⟷ ⊕ normalU t₂) ◎ unite₊) ◎
(normalℕswap {ZERO} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ id⟷)))
⇔⟨ id⇔ ⟩
normalU (PLUS ZERO t₂) ◎ (normalℕswap {ZERO} {t₂} ◎ (! (normalU (PLUS t₂ ZERO)))) ▤))
normal⟷ {PLUS ONE t₂} {PLUS .t₂ ONE} swap₊ =
(normalℕswap {ONE} {t₂} ,
(swap₊
⇔⟨ {!!} ⟩
((normalU ONE ⊕ normalU t₂) ◎ assocrU (toℕ ONE)) ◎
(normalℕswap {ONE} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ ! (normalU ONE))))
⇔⟨ id⇔ ⟩
normalU (PLUS ONE t₂) ◎ (normalℕswap {ONE} {t₂} ◎ (! (normalU (PLUS t₂ ONE)))) ▤))
normal⟷ {PLUS t₁ t₂} {PLUS .t₂ .t₁} swap₊ =
(normalℕswap {t₁} {t₂} ,
(swap₊
⇔⟨ {!!} ⟩
((normalU t₁ ⊕ normalU t₂) ◎ assocrU (toℕ t₁)) ◎
(normalℕswap {t₁} {t₂} ◎ ((! (assocrU (toℕ t₂))) ◎ (! (normalU t₂) ⊕ ! (normalU t₁))))
⇔⟨ id⇔ ⟩
normalU (PLUS t₁ t₂) ◎ (normalℕswap {t₁} {t₂} ◎ (! (normalU (PLUS t₂ t₁)))) ▤))
normal⟷ {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃} assocl₊ = {!!}
normal⟷ {PLUS (PLUS t₁ t₂) t₃} {PLUS .t₁ (PLUS .t₂ .t₃)} assocr₊ = {!!}
normal⟷ {TIMES ONE t} {.t} unite⋆ = {!!}
normal⟷ {t} {TIMES ONE .t} uniti⋆ = {!!}
normal⟷ {TIMES t₁ t₂} {TIMES .t₂ .t₁} swap⋆ = {!!}
normal⟷ {TIMES t₁ (TIMES t₂ t₃)} {TIMES (TIMES .t₁ .t₂) .t₃} assocl⋆ = {!!}
normal⟷ {TIMES (TIMES t₁ t₂) t₃} {TIMES .t₁ (TIMES .t₂ .t₃)} assocr⋆ = {!!}
normal⟷ {TIMES ZERO t} {ZERO} distz = {!!}
normal⟷ {ZERO} {TIMES ZERO t} factorz = {!!}
normal⟷ {TIMES (PLUS t₁ t₂) t₃} {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)} dist = {!!}
normal⟷ {PLUS (TIMES .t₁ .t₃) (TIMES .t₂ .t₃)} {TIMES (PLUS t₁ t₂) t₃} factor = {!!}
normal⟷ {t} {.t} id⟷ =
(id⟷ ,
(id⟷
⇔⟨ linv◎r ⟩
normalU t ◎ (! (normalU t))
⇔⟨ resp◎⇔ id⇔ idl◎r ⟩
normalU t ◎ (id⟷ ◎ (! (normalU t))) ▤))
normal⟷ {t₁} {t₃} (_◎_ {t₂ = t₂} c₁ c₂) = {!!}
normal⟷ {PLUS t₁ t₂} {PLUS t₃ t₄} (c₁ ⊕ c₂) = {!!}
normal⟷ {TIMES t₁ t₂} {TIMES t₃ t₄} (c₁ ⊗ c₂) = {!!}
-- if c₁ c₂ : t₁ ⟷ t₂ and c₁ ∼ c₂ then we want a canonical combinator
-- normalℕ t₁ ⟷ normalℕ t₂. If we have that then we should be able to
-- decide whether c₁ ∼ c₂ by normalizing and looking at the canonical
-- combinator.
-- Use ⇔ to normalize a path
{-# NO_TERMINATION_CHECK #-}
normalize : {t₁ t₂ : U} → (c₁ : t₁ ⟷ t₂) → Σ[ c₂ ∈ t₁ ⟷ t₂ ] (c₁ ⇔ c₂)
normalize unite₊ = (unite₊ , id⇔)
normalize uniti₊ = (uniti₊ , id⇔)
normalize swap₊ = (swap₊ , id⇔)
normalize assocl₊ = (assocl₊ , id⇔)
normalize assocr₊ = (assocr₊ , id⇔)
normalize unite⋆ = (unite⋆ , id⇔)
normalize uniti⋆ = (uniti⋆ , id⇔)
normalize swap⋆ = (swap⋆ , id⇔)
normalize assocl⋆ = (assocl⋆ , id⇔)
normalize assocr⋆ = (assocr⋆ , id⇔)
normalize distz = (distz , id⇔)
normalize factorz = (factorz , id⇔)
normalize dist = (dist , id⇔)
normalize factor = (factor , id⇔)
normalize id⟷ = (id⟷ , id⇔)
normalize (c₁ ◎ c₂) with normalize c₁ | normalize c₂
... | (c₁' , α) | (c₂' , β) = {!!}
normalize (c₁ ⊕ c₂) with normalize c₁ | normalize c₂
... | (c₁' , α) | (c₂₁ ⊕ c₂₂ , β) =
(assocl₊ ◎ ((c₁' ⊕ c₂₁) ⊕ c₂₂) ◎ assocr₊ , trans⇔ (resp⊕⇔ α β) assoc⊕l)
... | (c₁' , α) | (c₂' , β) = (c₁' ⊕ c₂' , resp⊕⇔ α β)
normalize (c₁ ⊗ c₂) with normalize c₁ | normalize c₂
... | (c₁₁ ⊕ c₁₂ , α) | (c₂' , β) =
(dist ◎ ((c₁₁ ⊗ c₂') ⊕ (c₁₂ ⊗ c₂')) ◎ factor ,
trans⇔ (resp⊗⇔ α β) dist⇔)
... | (c₁' , α) | (c₂₁ ⊗ c₂₂ , β) =
(assocl⋆ ◎ ((c₁' ⊗ c₂₁) ⊗ c₂₂) ◎ assocr⋆ , trans⇔ (resp⊗⇔ α β) assoc⊗l)
... | (c₁' , α) | (c₂' , β) = (c₁' ⊗ c₂' , resp⊗⇔ α β)
record Permutation (t t' : U) : Set where
field
t₀ : U -- no occurrences of TIMES .. (TIMES .. ..)
phase₀ : t ⟷ t₀
t₁ : U -- no occurrences of TIMES (PLUS .. ..)
phase₁ : t₀ ⟷ t₁
t₂ : U -- no occurrences of TIMES
phase₂ : t₁ ⟷ t₂
t₃ : U -- no nested left PLUS, all PLUS of form PLUS simple (PLUS ...)
phase₃ : t₂ ⟷ t₃
t₄ : U -- no occurrences PLUS ZERO
phase₄ : t₃ ⟷ t₄
t₅ : U -- do actual permutation using swapij
phase₅ : t₄ ⟷ t₅
rest : t₅ ⟷ t' -- blah blah
p◎id∼p : ∀ {t₁ t₂} {c : t₁ ⟷ t₂} → (c ◎ id⟷ ∼ c)
p◎id∼p {t₁} {t₂} {c} v =
(begin (proj₁ (perm2path (c ◎ id⟷) v))
≡⟨ {!!} ⟩
(proj₁ (perm2path id⟷ (proj₁ (perm2path c v))))
≡⟨ {!!} ⟩
(proj₁ (perm2path c v)) ∎)
-- perm2path {t} id⟷ v = (v , edge •[ t , v ] •[ t , v ])
--perm2path (_◎_ {t₁} {t₂} {t₃} c₁ c₂) v₁ with perm2path c₁ v₁
--... | (v₂ , p) with perm2path c₂ v₂
--... | (v₃ , q) = (v₃ , seq p q)
-- Equivalences between paths leading to 2path structure
-- Two paths are the same if they go through the same points
_∼_ : ∀ {t₁ t₂ v₁ v₂} →
(p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) →
(q : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) →
Set
(edge ._ ._) ∼ (edge ._ ._) = ⊤
(edge ._ ._) ∼ (seq p q) = {!!}
(edge ._ ._) ∼ (left p) = {!!}
(edge ._ ._) ∼ (right p) = {!!}
(edge ._ ._) ∼ (par p q) = {!!}
seq p p₁ ∼ edge ._ ._ = {!!}
seq p₁ p ∼ seq q q₁ = {!!}
seq p p₁ ∼ left q = {!!}
seq p p₁ ∼ right q = {!!}
seq p p₁ ∼ par q q₁ = {!!}
left p ∼ edge ._ ._ = {!!}
left p ∼ seq q q₁ = {!!}
left p ∼ left q = {!!}
right p ∼ edge ._ ._ = {!!}
right p ∼ seq q q₁ = {!!}
right p ∼ right q = {!!}
par p p₁ ∼ edge ._ ._ = {!!}
par p p₁ ∼ seq q q₁ = {!!}
par p p₁ ∼ par q q₁ = {!!}
-- Equivalences between paths leading to 2path structure
-- Following the HoTT approach two paths are considered the same if they
-- map the same points to equal points
infix 4 _∼_
_∼_ : ∀ {t₁ t₂ v₁ v₂ v₂'} →
(p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) →
(q : Path •[ t₁ , v₁ ] •[ t₂ , v₂' ]) →
Set
_∼_ {t₁} {t₂} {v₁} {v₂} {v₂'} p q = (v₂ ≡ v₂')
-- Lemma 2.4.2
p∼p : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ p
p∼p {p = path c} _ = refl
p∼q→q∼p : {t₁ t₂ : U} {p q : Path t₁ t₂} → (p ∼ q) → (q ∼ p)
p∼q→q∼p {p = path c₁} {q = path c₂} α v = sym (α v)
p∼q∼r→p∼r : {t₁ t₂ : U} {p q r : Path t₁ t₂} →
(p ∼ q) → (q ∼ r) → (p ∼ r)
p∼q∼r→p∼r {p = path c₁} {q = path c₂} {r = path c₃} α β v = trans (α v) (β v)
-- lift inverses and compositions to paths
inv : {t₁ t₂ : U} → Path t₁ t₂ → Path t₂ t₁
inv (path c) = path (! c)
infixr 10 _●_
_●_ : {t₁ t₂ t₃ : U} → Path t₁ t₂ → Path t₂ t₃ → Path t₁ t₃
path c₁ ● path c₂ = path (c₁ ◎ c₂)
-- Lemma 2.1.4
p∼p◎id : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ p ● path id⟷
p∼p◎id {t₁} {t₂} {path c} v =
(begin (perm2path c v)
≡⟨ refl ⟩
(perm2path c (perm2path id⟷ v))
≡⟨ refl ⟩
(perm2path (c ◎ id⟷) v) ∎)
p∼id◎p : {t₁ t₂ : U} {p : Path t₁ t₂} → p ∼ path id⟷ ● p
p∼id◎p {t₁} {t₂} {path c} v =
(begin (perm2path c v)
≡⟨ refl ⟩
(perm2path id⟷ (perm2path c v))
≡⟨ refl ⟩
(perm2path (id⟷ ◎ c) v) ∎)
!p◎p∼id : {t₁ t₂ : U} {p : Path t₁ t₂} → (inv p) ● p ∼ path id⟷
!p◎p∼id {t₁} {t₂} {path c} v =
(begin (perm2path ((! c) ◎ c) v)
≡⟨ refl ⟩
(perm2path c (perm2path (! c) v))
≡⟨ invr {t₁} {t₂} {c} {v} ⟩
(perm2path id⟷ v) ∎)
p◎!p∼id : {t₁ t₂ : U} {p : Path t₁ t₂} → p ● (inv p) ∼ path id⟷
p◎!p∼id {t₁} {t₂} {path c} v =
(begin (perm2path (c ◎ (! c)) v)
≡⟨ refl ⟩
(perm2path (! c) (perm2path c v))
≡⟨ invl {t₁} {t₂} {c} {v} ⟩
(perm2path id⟷ v) ∎)
!!p∼p : {t₁ t₂ : U} {p : Path t₁ t₂} → inv (inv p) ∼ p
!!p∼p {t₁} {t₂} {path c} v =
begin (perm2path (! (! c)) v
≡⟨ cong (λ x → perm2path x v) (!! {c = c}) ⟩
perm2path c v ∎)
assoc◎ : {t₁ t₂ t₃ t₄ : U} {p : Path t₁ t₂} {q : Path t₂ t₃} {r : Path t₃ t₄} →
p ● (q ● r) ∼ (p ● q) ● r
assoc◎ {t₁} {t₂} {t₃} {t₄} {path c₁} {path c₂} {path c₃} v =
begin (perm2path (c₁ ◎ (c₂ ◎ c₃)) v
≡⟨ refl ⟩
perm2path (c₂ ◎ c₃) (perm2path c₁ v)
≡⟨ refl ⟩
perm2path c₃ (perm2path c₂ (perm2path c₁ v))
≡⟨ refl ⟩
perm2path c₃ (perm2path (c₁ ◎ c₂) v)
≡⟨ refl ⟩
perm2path ((c₁ ◎ c₂) ◎ c₃) v ∎)
resp◎ : {t₁ t₂ t₃ : U} {p q : Path t₁ t₂} {r s : Path t₂ t₃} →
p ∼ q → r ∼ s → (p ● r) ∼ (q ● s)
resp◎ {t₁} {t₂} {t₃} {path c₁} {path c₂} {path c₃} {path c₄} α β v =
begin (perm2path (c₁ ◎ c₃) v
≡⟨ refl ⟩
perm2path c₃ (perm2path c₁ v)
≡⟨ cong (λ x → perm2path c₃ x) (α v) ⟩
perm2path c₃ (perm2path c₂ v)
≡⟨ β (perm2path c₂ v) ⟩
perm2path c₄ (perm2path c₂ v)
≡⟨ refl ⟩
perm2path (c₂ ◎ c₄) v ∎)
-- Recall that two perminators are the same if they denote the same
-- permutation; in that case there is a 2path between them in the relevant
-- path space
data _⇔_ {t₁ t₂ : U} : Path t₁ t₂ → Path t₁ t₂ → Set where
2path : {p q : Path t₁ t₂} → (p ∼ q) → (p ⇔ q)
-- Examples
p q r : Path BOOL BOOL
p = path id⟷
q = path swap₊
r = path (swap₊ ◎ id⟷)
α : q ⇔ r
α = 2path (p∼p◎id {p = path swap₊})
-- The equivalence of paths makes U a 1groupoid: the points are types t : U;
-- the 1paths are ⟷; and the 2paths between them are ⇔
G : 1Groupoid
G = record
{ set = U
; _↝_ = Path
; _≈_ = _⇔_
; id = path id⟷
; _∘_ = λ q p → p ● q
; _⁻¹ = inv
; lneutr = λ p → 2path (p∼q→q∼p p∼p◎id)
; rneutr = λ p → 2path (p∼q→q∼p p∼id◎p)
; assoc = λ r q p → 2path assoc◎
; equiv = record {
refl = 2path p∼p
; sym = λ { (2path α) → 2path (p∼q→q∼p α) }
; trans = λ { (2path α) (2path β) → 2path (p∼q∼r→p∼r α β) }
}
; linv = λ p → 2path p◎!p∼id
; rinv = λ p → 2path !p◎p∼id
; ∘-resp-≈ = λ { (2path β) (2path α) → 2path (resp◎ α β) }
}
------------------------------------------------------------------------------
data ΩU : Set where
ΩZERO : ΩU -- empty set of paths
ΩONE : ΩU -- a trivial path
ΩPLUS : ΩU → ΩU → ΩU -- disjoint union of paths
ΩTIMES : ΩU → ΩU → ΩU -- pairs of paths
PATH : (t₁ t₂ : U) → ΩU -- level 0 paths between values
-- values
Ω⟦_⟧ : ΩU → Set
Ω⟦ ΩZERO ⟧ = ⊥
Ω⟦ ΩONE ⟧ = ⊤
Ω⟦ ΩPLUS t₁ t₂ ⟧ = Ω⟦ t₁ ⟧ ⊎ Ω⟦ t₂ ⟧
Ω⟦ ΩTIMES t₁ t₂ ⟧ = Ω⟦ t₁ ⟧ × Ω⟦ t₂ ⟧
Ω⟦ PATH t₁ t₂ ⟧ = Path t₁ t₂
-- two perminators are the same if they denote the same permutation
-- 2paths
data _⇔_ : ΩU → ΩU → Set where
unite₊ : {t : ΩU} → ΩPLUS ΩZERO t ⇔ t
uniti₊ : {t : ΩU} → t ⇔ ΩPLUS ΩZERO t
swap₊ : {t₁ t₂ : ΩU} → ΩPLUS t₁ t₂ ⇔ ΩPLUS t₂ t₁
assocl₊ : {t₁ t₂ t₃ : ΩU} → ΩPLUS t₁ (ΩPLUS t₂ t₃) ⇔ ΩPLUS (ΩPLUS t₁ t₂) t₃
assocr₊ : {t₁ t₂ t₃ : ΩU} → ΩPLUS (ΩPLUS t₁ t₂) t₃ ⇔ ΩPLUS t₁ (ΩPLUS t₂ t₃)
unite⋆ : {t : ΩU} → ΩTIMES ΩONE t ⇔ t
uniti⋆ : {t : ΩU} → t ⇔ ΩTIMES ΩONE t
swap⋆ : {t₁ t₂ : ΩU} → ΩTIMES t₁ t₂ ⇔ ΩTIMES t₂ t₁
assocl⋆ : {t₁ t₂ t₃ : ΩU} → ΩTIMES t₁ (ΩTIMES t₂ t₃) ⇔ ΩTIMES (ΩTIMES t₁ t₂) t₃
assocr⋆ : {t₁ t₂ t₃ : ΩU} → ΩTIMES (ΩTIMES t₁ t₂) t₃ ⇔ ΩTIMES t₁ (ΩTIMES t₂ t₃)
distz : {t : ΩU} → ΩTIMES ΩZERO t ⇔ ΩZERO
factorz : {t : ΩU} → ΩZERO ⇔ ΩTIMES ΩZERO t
dist : {t₁ t₂ t₃ : ΩU} →
ΩTIMES (ΩPLUS t₁ t₂) t₃ ⇔ ΩPLUS (ΩTIMES t₁ t₃) (ΩTIMES t₂ t₃)
factor : {t₁ t₂ t₃ : ΩU} →
ΩPLUS (ΩTIMES t₁ t₃) (ΩTIMES t₂ t₃) ⇔ ΩTIMES (ΩPLUS t₁ t₂) t₃
id⇔ : {t : ΩU} → t ⇔ t
_◎_ : {t₁ t₂ t₃ : ΩU} → (t₁ ⇔ t₂) → (t₂ ⇔ t₃) → (t₁ ⇔ t₃)
_⊕_ : {t₁ t₂ t₃ t₄ : ΩU} →
(t₁ ⇔ t₃) → (t₂ ⇔ t₄) → (ΩPLUS t₁ t₂ ⇔ ΩPLUS t₃ t₄)
_⊗_ : {t₁ t₂ t₃ t₄ : ΩU} →
(t₁ ⇔ t₃) → (t₂ ⇔ t₄) → (ΩTIMES t₁ t₂ ⇔ ΩTIMES t₃ t₄)
_∼⇔_ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) →
PATH t₁ t₂ ⇔ PATH t₁ t₂
-- two spaces are equivalent if there is a path between them; this path
-- automatically has an inverse which is an equivalence. It is a
-- quasi-equivalence but for finite types that's the same as an equivalence.
infix 4 _≃_
_≃_ : (t₁ t₂ : U) → Set
t₁ ≃ t₂ = (t₁ ⟷ t₂)
-- Univalence says (t₁ ≃ t₂) ≃ (t₁ ⟷ t₂) but as shown above, we actually have
-- this by definition instead of up to ≃
------------------------------------------------------------------------------
------------------------------------------------------------------------------
------------------------------------------------------------------------------
another idea is to look at c and massage it as follows: rewrite every
swap+ ; c
to
c' ; swaps ; c''
general start with
id || id || c
examine c and move anything that's not swap to left. If we get to
c' || id || id
we are done
if we get to:
c' || id || swap+;c
then we rewrite
c';c1 || swaps || c2;c
and we keep going
module Phase₁ where
-- no occurrences of (TIMES (TIMES t₁ t₂) t₃)
approach that maintains the invariants in proofs
invariant : (t : U) → Bool
invariant ZERO = true
invariant ONE = true
invariant (PLUS t₁ t₂) = invariant t₁ ∧ invariant t₂
invariant (TIMES ZERO t₂) = invariant t₂
invariant (TIMES ONE t₂) = invariant t₂
invariant (TIMES (PLUS t₁ t₂) t₃) = (invariant t₁ ∧ invariant t₂) ∧ invariant t₃
invariant (TIMES (TIMES t₁ t₂) t₃) = false
Invariant : (t : U) → Set
Invariant t = invariant t ≡ true
invariant? : Decidable Invariant
invariant? t with invariant t
... | true = yes refl
... | false = no (λ ())
conj : ∀ {b₁ b₂} → (b₁ ≡ true) → (b₂ ≡ true) → (b₁ ∧ b₂ ≡ true)
conj {true} {true} p q = refl
conj {true} {false} p ()
conj {false} {true} ()
conj {false} {false} ()
phase₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (True (invariant? t₂) × t₁ ⟷ t₂)
phase₁ ZERO = (ZERO , (fromWitness {Q = invariant? ZERO} refl , id⟷))
phase₁ ONE = (ONE , (fromWitness {Q = invariant? ONE} refl , id⟷))
phase₁ (PLUS t₁ t₂) with phase₁ t₁ | phase₁ t₂
... | (t₁' , (p₁ , c₁)) | (t₂' , (p₂ , c₂)) with toWitness p₁ | toWitness p₂
... | t₁'ok | t₂'ok =
(PLUS t₁' t₂' ,
(fromWitness {Q = invariant? (PLUS t₁' t₂')} (conj t₁'ok t₂'ok) ,
c₁ ⊕ c₂))
phase₁ (TIMES ZERO t) with phase₁ t
... | (t' , (p , c)) with toWitness p
... | t'ok =
(TIMES ZERO t' ,
(fromWitness {Q = invariant? (TIMES ZERO t')} t'ok ,
id⟷ ⊗ c))
phase₁ (TIMES ONE t) with phase₁ t
... | (t' , (p , c)) with toWitness p
... | t'ok =
(TIMES ONE t' ,
(fromWitness {Q = invariant? (TIMES ONE t')} t'ok ,
id⟷ ⊗ c))
phase₁ (TIMES (PLUS t₁ t₂) t₃) with phase₁ t₁ | phase₁ t₂ | phase₁ t₃
... | (t₁' , (p₁ , c₁)) | (t₂' , (p₂ , c₂)) | (t₃' , (p₃ , c₃))
with toWitness p₁ | toWitness p₂ | toWitness p₃
... | t₁'ok | t₂'ok | t₃'ok =
(TIMES (PLUS t₁' t₂') t₃' ,
(fromWitness {Q = invariant? (TIMES (PLUS t₁' t₂') t₃')}
(conj (conj t₁'ok t₂'ok) t₃'ok) ,
(c₁ ⊕ c₂) ⊗ c₃))
phase₁ (TIMES (TIMES t₁ t₂) t₃) = {!!}
-- invariants are informal
-- rewrite (TIMES (TIMES t₁ t₂) t₃) to TIMES t₁ (TIMES t₂ t₃)
invariant : (t : U) → Bool
invariant ZERO = true
invariant ONE = true
invariant (PLUS t₁ t₂) = invariant t₁ ∧ invariant t₂
invariant (TIMES ZERO t₂) = invariant t₂
invariant (TIMES ONE t₂) = invariant t₂
invariant (TIMES (PLUS t₁ t₂) t₃) = invariant t₁ ∧ invariant t₂ ∧ invariant t₃
invariant (TIMES (TIMES t₁ t₂) t₃) = false
step₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (t₁ ⟷ t₂)
step₁ ZERO = (ZERO , id⟷)
step₁ ONE = (ONE , id⟷)
step₁ (PLUS t₁ t₂) with step₁ t₁ | step₁ t₂
... | (t₁' , c₁) | (t₂' , c₂) = (PLUS t₁' t₂' , c₁ ⊕ c₂)
step₁ (TIMES (TIMES t₁ t₂) t₃) with step₁ t₁ | step₁ t₂ | step₁ t₃
... | (t₁' , c₁) | (t₂' , c₂) | (t₃' , c₃) =
(TIMES t₁' (TIMES t₂' t₃') , ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)
step₁ (TIMES ZERO t₂) with step₁ t₂
... | (t₂' , c₂) = (TIMES ZERO t₂' , id⟷ ⊗ c₂)
step₁ (TIMES ONE t₂) with step₁ t₂
... | (t₂' , c₂) = (TIMES ONE t₂' , id⟷ ⊗ c₂)
step₁ (TIMES (PLUS t₁ t₂) t₃) with step₁ t₁ | step₁ t₂ | step₁ t₃
... | (t₁' , c₁) | (t₂' , c₂) | (t₃' , c₃) =
(TIMES (PLUS t₁' t₂') t₃' , (c₁ ⊕ c₂) ⊗ c₃)
{-# NO_TERMINATION_CHECK #-}
phase₁ : (t₁ : U) → Σ[ t₂ ∈ U ] (t₁ ⟷ t₂)
phase₁ t with invariant t
... | true = (t , id⟷)
... | false with step₁ t
... | (t' , c) with phase₁ t'
... | (t'' , c') = (t'' , c ◎ c')
test₁ = phase₁ (TIMES (TIMES (TIMES ONE ONE) (TIMES ONE ONE)) ONE)
TIMES ONE (TIMES ONE (TIMES ONE (TIMES ONE ONE))) ,
(((id⟷ ⊗ id⟷) ⊗ (id⟷ ⊗ id⟷)) ⊗ id⟷ ◎ assocr⋆) ◎
((id⟷ ⊗ id⟷) ⊗ ((id⟷ ⊗ id⟷) ⊗ id⟷ ◎ assocr⋆) ◎ assocr⋆) ◎ id⟷
-- Now any perminator (t₁ ⟷ t₂) can be transformed to a canonical
-- representation in which we first associate all the TIMES to the right
-- and then do the rest of the perminator
normalize₁ : {t₁ t₂ : U} → (t₁ ⟷ t₂) →
(Σ[ t₁' ∈ U ] (t₁ ⟷ t₁' × t₁' ⟷ t₂))
normalize₁ {ZERO} {t} c = ZERO , id⟷ , c
normalize₁ {ONE} c = ONE , id⟷ , c
normalize₁ {PLUS .ZERO t₂} unite₊ with phase₁ t₂
... | (t₂n , cn) = PLUS ZERO t₂n , id⟷ ⊕ cn , unite₊ ◎ ! cn
normalize₁ {PLUS t₁ t₂} uniti₊ = {!!}
normalize₁ {PLUS t₁ t₂} swap₊ = {!!}
normalize₁ {PLUS t₁ ._} assocl₊ = {!!}
normalize₁ {PLUS ._ t₂} assocr₊ = {!!}
normalize₁ {PLUS t₁ t₂} uniti⋆ = {!!}
normalize₁ {PLUS ._ ._} factor = {!!}
normalize₁ {PLUS t₁ t₂} id⟷ = {!!}
normalize₁ {PLUS t₁ t₂} (c ◎ c₁) = {!!}
normalize₁ {PLUS t₁ t₂} (c ⊕ c₁) = {!!}
normalize₁ {TIMES t₁ t₂} c = {!!}
record Permutation (t t' : U) : Set where
field
t₀ : U -- no occurrences of TIMES .. (TIMES .. ..)
phase₀ : t ⟷ t₀
t₁ : U -- no occurrences of TIMES (PLUS .. ..)
phase₁ : t₀ ⟷ t₁
t₂ : U -- no occurrences of TIMES
phase₂ : t₁ ⟷ t₂
t₃ : U -- no nested left PLUS, all PLUS of form PLUS simple (PLUS ...)
phase₃ : t₂ ⟷ t₃
t₄ : U -- no occurrences PLUS ZERO
phase₄ : t₃ ⟷ t₄
t₅ : U -- do actual permutation using swapij
phase₅ : t₄ ⟷ t₅
rest : t₅ ⟷ t' -- blah blah
canonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → Permutation t₁ t₂
canonical c = {!!}
------------------------------------------------------------------------------
-- These paths do NOT reach "inside" the finite sets. For example, there is
-- NO PATH between false and true in BOOL even though there is a path between
-- BOOL and BOOL that "twists the space around."
--
-- In more detail how do these paths between types relate to the whole
-- discussion about higher groupoid structure of type formers (Sec. 2.5 and
-- on).
-- Then revisit the early parts of Ch. 2 about higher groupoid structure for
-- U, how functions from U to U respect the paths in U, type families and
-- dependent functions, homotopies and equivalences, and then Sec. 2.5 and
-- beyond again.
should this be on the code as done now or on their interpreation
i.e. data _⟷_ : ⟦ U ⟧ → ⟦ U ⟧ → Set where
can add recursive types
rec : U
⟦_⟧ takes an additional argument X that is passed around
⟦ rec ⟧ X = X
fixpoitn
data μ (t : U) : Set where
⟨_⟩ : ⟦ t ⟧ (μ t) → μ t
-- We identify functions with the paths above. Since every function is
-- reversible, every function corresponds to a path and there is no
-- separation between functions and paths and no need to mediate between them
-- using univalence.
--
-- Note that none of the above functions are dependent functions.
------------------------------------------------------------------------------
-- Now we consider homotopies, i.e., paths between functions. Since our
-- functions are identified with the paths ⟷, the homotopies are paths
-- between elements of ⟷
-- First, a sanity check. Our notion of paths matches the notion of
-- equivalences in the conventional HoTT presentation
-- Homotopy between two functions (paths)
-- That makes id ∼ not which is bad. The def. of ∼ should be parametric...
_∼_ : {t₁ t₂ t₃ : U} → (f : t₁ ⟷ t₂) → (g : t₁ ⟷ t₃) → Set
_∼_ {t₁} {t₂} {t₃} f g = t₂ ⟷ t₃
-- Every f and g of the right type are related by ∼
homotopy : {t₁ t₂ t₃ : U} → (f : t₁ ⟷ t₂) → (g : t₁ ⟷ t₃) → (f ∼ g)
homotopy f g = (! f) ◎ g
-- Equivalences
--
-- If f : t₁ ⟷ t₂ has two inverses g₁ g₂ : t₂ ⟷ t₁ then g₁ ∼ g₂. More
-- generally, any two paths of the same type are related by ∼.
equiv : {t₁ t₂ : U} → (f g : t₁ ⟷ t₂) → (f ∼ g)
equiv f g = id⟷
-- It follows that any two types in U are equivalent if there is a path
-- between them
_≃_ : (t₁ t₂ : U) → Set
t₁ ≃ t₂ = t₁ ⟷ t₂
-- Now we want to understand the type of paths between paths
------------------------------------------------------------------------------
elems : (t : U) → List ⟦ t ⟧
elems ZERO = []
elems ONE = [ tt ]
elems (PLUS t₁ t₂) = map inj₁ (elems t₁) ++ map inj₂ (elems t₂)
elems (TIMES t₁ t₂) = concat
(map
(λ v₂ → map (λ v₁ → (v₁ , v₂)) (elems t₁))
(elems t₂))
_≟_ : {t : U} → ⟦ t ⟧ → ⟦ t ⟧ → Bool
_≟_ {ZERO} ()
_≟_ {ONE} tt tt = true
_≟_ {PLUS t₁ t₂} (inj₁ v) (inj₁ w) = v ≟ w
_≟_ {PLUS t₁ t₂} (inj₁ v) (inj₂ w) = false
_≟_ {PLUS t₁ t₂} (inj₂ v) (inj₁ w) = false
_≟_ {PLUS t₁ t₂} (inj₂ v) (inj₂ w) = v ≟ w
_≟_ {TIMES t₁ t₂} (v₁ , w₁) (v₂ , w₂) = v₁ ≟ v₂ ∧ w₁ ≟ w₂
findLoops : {t t₁ t₂ : U} → (PLUS t t₁ ⟷ PLUS t t₂) → List ⟦ t ⟧ →
List (Σ[ t ∈ U ] ⟦ t ⟧)
findLoops c [] = []
findLoops {t} c (v ∷ vs) = ? with perm2path c (inj₁ v)
... | (inj₂ _ , loops) = loops ++ findLoops c vs
... | (inj₁ v' , loops) with v ≟ v'
... | true = (t , v) ∷ loops ++ findLoops c vs
... | false = loops ++ findLoops c vs
traceLoopsEx : {t : U} → List (Σ[ t ∈ U ] ⟦ t ⟧)
traceLoopsEx {t} = findLoops traceBodyEx (elems (PLUS t (PLUS t t)))
-- traceLoopsEx {ONE} ==> (PLUS ONE (PLUS ONE ONE) , inj₂ (inj₁ tt)) ∷ []
-- Each permutation is a "path" between types. We can think of this path as
-- being indexed by "time" where "time" here is in discrete units
-- corresponding to the sequencing of combinators. A homotopy between paths p
-- and q is a map that, for each "time unit", maps the specified type along p
-- to a corresponding type along q. At each such time unit, the mapping
-- between types is itself a path. So a homotopy is essentially a collection
-- of paths. As an example, given two paths starting at t₁ and ending at t₂
-- and going through different intermediate points:
-- p = t₁ -> t -> t' -> t₂
-- q = t₁ -> u -> u' -> t₂
-- A possible homotopy between these two paths is a path from t to u and
-- another path from t' to u'. Things get slightly more complicated if the
-- number of intermediate points is not the same etc. but that's the basic idea.
-- The vertical paths must commute with the horizontal ones.
--
-- Postulate the groupoid laws and use them to prove commutativity etc.
--
-- Bool -id-- Bool -id-- Bool -id-- Bool
-- | | | |
-- | not id | the last square does not commute
-- | | | |
-- Bool -not- Bool -not- Bool -not- Bool
--
-- If the large rectangle commutes then the smaller squares commute. For a
-- proof, let p o q o r o s be the left-bottom path and p' o q' o r' o s' be
-- the top-right path. Let's focus on the square:
--
-- A-- r'--C
-- | |
-- ? s'
-- | |
-- B-- s --D
--
-- We have a path from A to B that is: !q' o !p' o p o q o r.
-- Now let's see if r' o s' is equivalent to
-- !q' o !p' o p o q o r o s
-- We know p o q o r o s ⇔ p' o q' o r' o s'
-- If we know that ⇔ is preserved by composition then:
-- !q' o !p' o p o q o r o s ⇔ !q' o !p' o p' o q' o r' o s'
-- and of course by inverses and id being unit of composition:
-- !q' o !p' o p o q o r o s ⇔ r' o s'
-- and we are done.
{-# NO_TERMINATION_CHECK #-}
Path∼ : ∀ {t₁ t₂ t₁' t₂' v₁ v₂ v₁' v₂'} →
(p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) →
(q : Path •[ t₁' , v₁' ] •[ t₂' , v₂' ]) →
Set
-- sequential composition
Path∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
(_●_ {t₂ = t₂} {v₂ = v₂} p₁ p₂) (_●_ {t₂ = t₂'} {v₂ = v₂'} q₁ q₂) =
(Path∼ p₁ q₁ × Path∼ p₂ q₂) ⊎
(Path∼ {t₁} {t₂} {t₁'} {t₁'} {v₁} {v₂} {v₁'} {v₁'} p₁ id⟷• × Path∼ p₂ (q₁ ● q₂)) ⊎
(Path∼ p₁ (q₁ ● q₂) × Path∼ {t₂} {t₃} {t₃'} {t₃'} {v₂} {v₃} {v₃'} {v₃'} p₂ id⟷•) ⊎
(Path∼ {t₁} {t₁} {t₁'} {t₂'} {v₁} {v₁} {v₁'} {v₂'} id⟷• q₁ × Path∼ (p₁ ● p₂) q₂) ⊎
(Path∼ (p₁ ● p₂) q₁ × Path∼ {t₃} {t₃} {t₂'} {t₃'} {v₃} {v₃} {v₂'} {v₃'} id⟷• q₂)
Path∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
(_●_ {t₂ = t₂} {v₂ = v₂} p q) c =
(Path∼ {t₁} {t₂} {t₁'} {t₁'} {v₁} {v₂} {v₁'} {v₁'} p id⟷• × Path∼ q c)
⊎ (Path∼ p c × Path∼ {t₂} {t₃} {t₃'} {t₃'} {v₂} {v₃} {v₃'} {v₃'} q id⟷•)
Path∼ {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
c (_●_ {t₂ = t₂'} {v₂ = v₂'} p q) =
(Path∼ {t₁} {t₁} {t₁'} {t₂'} {v₁} {v₁} {v₁'} {v₂'} id⟷• p × Path∼ c q)
⊎ (Path∼ c p × Path∼ {t₃} {t₃} {t₂'} {t₃'} {v₃} {v₃} {v₂'} {v₃'} id⟷• q)
-- choices
Path∼ (⊕1• p) (⊕1• q) = Path∼ p q
Path∼ (⊕1• p) _ = ⊥
Path∼ _ (⊕1• p) = ⊥
Path∼ (⊕2• p) (⊕2• q) = Path∼ p q
Path∼ (⊕2• p) _ = ⊥
Path∼ _ (⊕2• p) = ⊥
-- parallel paths
Path∼ (p₁ ⊗• p₂) (q₁ ⊗• q₂) = Path∼ p₁ q₁ × Path∼ p₂ q₂
Path∼ (p₁ ⊗• p₂) _ = ⊥
Path∼ _ (q₁ ⊗• q₂) = ⊥
-- simple edges connecting two points
Path∼ {t₁} {t₂} {t₁'} {t₂'} {v₁} {v₂} {v₁'} {v₂'} c₁ c₂ =
Path •[ t₁ , v₁ ] •[ t₁' , v₁' ] × Path •[ t₂ , v₂ ] •[ t₂' , v₂' ]
-- In the setting of finite types (in particular with no loops) every pair of
-- paths with related start and end points is equivalent. In other words, we
-- really have no interesting 2-path structure.
allequiv : ∀ {t₁ t₂ t₁' t₂' v₁ v₂ v₁' v₂'} →
(p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) →
(q : Path •[ t₁' , v₁' ] •[ t₂' , v₂' ]) →
(start : Path •[ t₁ , v₁ ] •[ t₁' , v₁' ]) →
(end : Path •[ t₂ , v₂ ] •[ t₂' , v₂' ]) →
Path∼ p q
allequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
(_●_ {t₂ = t₂} {v₂ = v₂} p₁ p₂) (_●_ {t₂ = t₂'} {v₂ = v₂'} q₁ q₂)
start end = {!!}
allequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
(_●_ {t₂ = t₂} {v₂ = v₂} p q) c start end = {!!}
allequiv {t₁} {t₃} {t₁'} {t₃'} {v₁} {v₃} {v₁'} {v₃'}
c (_●_ {t₂ = t₂'} {v₂ = v₂'} p q) start end = {!!}
allequiv (⊕1• p) (⊕1• q) start end = {!!}
allequiv (⊕1• p) _ start end = {!!}
allequiv _ (⊕1• p) start end = {!!}
allequiv (⊕2• p) (⊕2• q) start end = {!!}
allequiv (⊕2• p) _ start end = {!!}
allequiv _ (⊕2• p) start end = {!!}
-- parallel paths
allequiv (p₁ ⊗• p₂) (q₁ ⊗• q₂) start end = {!!}
allequiv (p₁ ⊗• p₂) _ start end = {!!}
allequiv _ (q₁ ⊗• q₂) start end = {!!}
-- simple edges connecting two points
allequiv {t₁} {t₂} {t₁'} {t₂'} {v₁} {v₂} {v₁'} {v₂'} c₁ c₂ start end = {!!}
refl∼ : ∀ {t₁ t₂ v₁ v₂} → (p : Path •[ t₁ , v₁ ] •[ t₂ , v₂ ]) → Path∼ p p
refl∼ unite•₊ = id⟷• , id⟷•
refl∼ uniti•₊ = id⟷• , id⟷•
refl∼ swap1•₊ = id⟷• , id⟷•
refl∼ swap2•₊ = id⟷• , id⟷•
refl∼ assocl1•₊ = id⟷• , id⟷•
refl∼ assocl2•₊ = id⟷• , id⟷•
refl∼ assocl3•₊ = id⟷• , id⟷•
refl∼ assocr1•₊ = id⟷• , id⟷•
refl∼ assocr2•₊ = id⟷• , id⟷•
refl∼ assocr3•₊ = id⟷• , id⟷•
refl∼ unite•⋆ = id⟷• , id⟷•
refl∼ uniti•⋆ = id⟷• , id⟷•
refl∼ swap•⋆ = id⟷• , id⟷•
refl∼ assocl•⋆ = id⟷• , id⟷•
refl∼ assocr•⋆ = id⟷• , id⟷•
refl∼ distz• = id⟷• , id⟷•
refl∼ factorz• = id⟷• , id⟷•
refl∼ dist1• = id⟷• , id⟷•
refl∼ dist2• = id⟷• , id⟷•
refl∼ factor1• = id⟷• , id⟷•
refl∼ factor2• = id⟷• , id⟷•
refl∼ id⟷• = id⟷• , id⟷•
refl∼ (p ● q) = inj₁ (refl∼ p , refl∼ q)
refl∼ (⊕1• p) = refl∼ p
refl∼ (⊕2• q) = refl∼ q
refl∼ (p ⊗• q) = refl∼ p , refl∼ q
-- Extensional view
-- First we enumerate all the values of a given finite type
size : U → ℕ
size ZERO = 0
size ONE = 1
size (PLUS t₁ t₂) = size t₁ + size t₂
size (TIMES t₁ t₂) = size t₁ * size t₂
enum : (t : U) → ⟦ t ⟧ → Fin (size t)
enum ZERO () -- absurd
enum ONE tt = zero
enum (PLUS t₁ t₂) (inj₁ v₁) = inject+ (size t₂) (enum t₁ v₁)
enum (PLUS t₁ t₂) (inj₂ v₂) = raise (size t₁) (enum t₂ v₂)
enum (TIMES t₁ t₂) (v₁ , v₂) = fromℕ≤ (pr {s₁} {s₂} {n₁} {n₂})
where n₁ = enum t₁ v₁
n₂ = enum t₂ v₂
s₁ = size t₁
s₂ = size t₂
pr : {s₁ s₂ : ℕ} → {n₁ : Fin s₁} {n₂ : Fin s₂} →
((toℕ n₁ * s₂) + toℕ n₂) < (s₁ * s₂)
pr {0} {_} {()}
pr {_} {0} {_} {()}
pr {suc s₁} {suc s₂} {zero} {zero} = {!z≤n!}
pr {suc s₁} {suc s₂} {zero} {Fsuc n₂} = {!!}
pr {suc s₁} {suc s₂} {Fsuc n₁} {zero} = {!!}
pr {suc s₁} {suc s₂} {Fsuc n₁} {Fsuc n₂} = {!!}
vals3 : Fin 3 × Fin 3 × Fin 3
vals3 = (enum THREE LL , enum THREE LR , enum THREE R)
where THREE = PLUS (PLUS ONE ONE) ONE
LL = inj₁ (inj₁ tt)
LR = inj₁ (inj₂ tt)
R = inj₂ tt
xxx : {s₁ s₂ : ℕ} → (i : Fin s₁) → (j : Fin s₂) →
suc (toℕ i * s₂ + toℕ j) ≤ s₁ * s₂
xxx {0} {_} ()
xxx {suc s₁} {s₂} i j = {!!}
-- i : Fin (suc s₁)
-- j : Fin s₂
-- ?0 : suc (toℕ i * s₂ + toℕ j) ≤ suc s₁ * s₂
-- (suc (toℕ i) * s₂ + toℕ j ≤ s₂ + s₁ * s₂
-- (suc (toℕ i) * s₂ + toℕ j ≤ s₁ * s₂ + s₂
utoVecℕ : (t : U) → Vec (Fin (utoℕ t)) (utoℕ t)
utoVecℕ ZERO = []
utoVecℕ ONE = [ zero ]
utoVecℕ (PLUS t₁ t₂) =
map (inject+ (utoℕ t₂)) (utoVecℕ t₁) ++
map (raise (utoℕ t₁)) (utoVecℕ t₂)
utoVecℕ (TIMES t₁ t₂) =
concat (map (λ i → map (λ j → inject≤ (fromℕ (toℕ i * utoℕ t₂ + toℕ j))
(xxx i j))
(utoVecℕ t₂))
(utoVecℕ t₁))
-- Vector representation of types so that we can test permutations
utoVec : (t : U) → Vec ⟦ t ⟧ (utoℕ t)
utoVec ZERO = []
utoVec ONE = [ tt ]
utoVec (PLUS t₁ t₂) = map inj₁ (utoVec t₁) ++ map inj₂ (utoVec t₂)
utoVec (TIMES t₁ t₂) =
concat (map (λ v₁ → map (λ v₂ → (v₁ , v₂)) (utoVec t₂)) (utoVec t₁))
-- Examples permutations and their actions on a simple ordered vector
module PermExamples where
-- ordered vector: position i has value i
ordered : ∀ {n} → Vec (Fin n) n
ordered = tabulate id
-- empty permutation p₀ { }
p₀ : Perm 0
p₀ = []
v₀ = permute p₀ ordered
-- permutation p₁ { 0 -> 0 }
p₁ : Perm 1
p₁ = 0F ∷ p₀
where 0F = fromℕ 0
v₁ = permute p₁ ordered
-- permutations p₂ { 0 -> 0, 1 -> 1 }
-- q₂ { 0 -> 1, 1 -> 0 }
p₂ q₂ : Perm 2
p₂ = 0F ∷ p₁
where 0F = inject+ 1 (fromℕ 0)
q₂ = 1F ∷ p₁
where 1F = fromℕ 1
v₂ = permute p₂ ordered
w₂ = permute q₂ ordered
-- permutations p₃ { 0 -> 0, 1 -> 1, 2 -> 2 }
-- s₃ { 0 -> 0, 1 -> 2, 2 -> 1 }
-- q₃ { 0 -> 1, 1 -> 0, 2 -> 2 }
-- r₃ { 0 -> 1, 1 -> 2, 2 -> 0 }
-- t₃ { 0 -> 2, 1 -> 0, 2 -> 1 }
-- u₃ { 0 -> 2, 1 -> 1, 2 -> 0 }
p₃ q₃ r₃ s₃ t₃ u₃ : Perm 3
p₃ = 0F ∷ p₂
where 0F = inject+ 2 (fromℕ 0)
s₃ = 0F ∷ q₂
where 0F = inject+ 2 (fromℕ 0)
q₃ = 1F ∷ p₂
where 1F = inject+ 1 (fromℕ 1)
r₃ = 2F ∷ p₂
where 2F = fromℕ 2
t₃ = 1F ∷ q₂
where 1F = inject+ 1 (fromℕ 1)
u₃ = 2F ∷ q₂
where 2F = fromℕ 2
v₃ = permute p₃ ordered
y₃ = permute s₃ ordered
w₃ = permute q₃ ordered
x₃ = permute r₃ ordered
z₃ = permute t₃ ordered
α₃ = permute u₃ ordered
-- end module PermExamples
------------------------------------------------------------------------------
-- Testing
t₁ = PLUS ZERO BOOL
t₂ = BOOL
m₁ = matchP {t₁} {t₂} unite₊
-- (inj₂ (inj₁ tt) , inj₁ tt) ∷ (inj₂ (inj₂ tt) , inj₂ tt) ∷ []
m₂ = matchP {t₂} {t₁} uniti₊
-- (inj₁ tt , inj₂ (inj₁ tt)) ∷ (inj₂ tt , inj₂ (inj₂ tt)) ∷ []
t₃ = PLUS BOOL ONE
t₄ = PLUS ONE BOOL
m₃ = matchP {t₃} {t₄} swap₊
-- (inj₂ tt , inj₁ tt) ∷
-- (inj₁ (inj₁ tt) , inj₂ (inj₁ tt)) ∷
-- (inj₁ (inj₂ tt) , inj₂ (inj₂ tt)) ∷ []
m₄ = matchP {t₄} {t₃} swap₊
-- (inj₂ (inj₁ tt) , inj₁ (inj₁ tt)) ∷
-- (inj₂ (inj₂ tt) , inj₁ (inj₂ tt)) ∷
-- (inj₁ tt , inj₂ tt) ∷ []
t₅ = PLUS ONE (PLUS BOOL ONE)
t₆ = PLUS (PLUS ONE BOOL) ONE
m₅ = matchP {t₅} {t₆} assocl₊
-- (inj₁ tt , inj₁ (inj₁ tt)) ∷
-- (inj₂ (inj₁ (inj₁ tt)) , inj₁ (inj₂ (inj₁ tt))) ∷
-- (inj₂ (inj₁ (inj₂ tt)) , inj₁ (inj₂ (inj₂ tt))) ∷
-- (inj₂ (inj₂ tt) , inj₂ tt) ∷ []
m₆ = matchP {t₆} {t₅} assocr₊
-- (inj₁ (inj₁ tt) , inj₁ tt) ∷
-- (inj₁ (inj₂ (inj₁ tt)) , inj₂ (inj₁ (inj₁ tt))) ∷
-- (inj₁ (inj₂ (inj₂ tt)) , inj₂ (inj₁ (inj₂ tt))) ∷
-- (inj₂ tt , inj₂ (inj₂ tt)) ∷ []
t₇ = TIMES ONE BOOL
t₈ = BOOL
m₇ = matchP {t₇} {t₈} unite⋆
-- ((tt , inj₁ tt) , inj₁ tt) ∷ ((tt , inj₂ tt) , inj₂ tt) ∷ []
m₈ = matchP {t₈} {t₇} uniti⋆
-- (inj₁ tt , (tt , inj₁ tt)) ∷ (inj₂ tt , (tt , inj₂ tt)) ∷ []
t₉ = TIMES BOOL ONE
t₁₀ = TIMES ONE BOOL
m₉ = matchP {t₉} {t₁₀} swap⋆
-- ((inj₁ tt , tt) , (tt , inj₁ tt)) ∷
-- ((inj₂ tt , tt) , (tt , inj₂ tt)) ∷ []
m₁₀ = matchP {t₁₀} {t₉} swap⋆
-- ((tt , inj₁ tt) , (inj₁ tt , tt)) ∷
-- ((tt , inj₂ tt) , (inj₂ tt , tt)) ∷ []
t₁₁ = TIMES BOOL (TIMES ONE BOOL)
t₁₂ = TIMES (TIMES BOOL ONE) BOOL
m₁₁ = matchP {t₁₁} {t₁₂} assocl⋆
-- ((inj₁ tt , (tt , inj₁ tt)) , ((inj₁ tt , tt) , inj₁ tt)) ∷
-- ((inj₁ tt , (tt , inj₂ tt)) , ((inj₁ tt , tt) , inj₂ tt)) ∷
-- ((inj₂ tt , (tt , inj₁ tt)) , ((inj₂ tt , tt) , inj₁ tt)) ∷
-- ((inj₂ tt , (tt , inj₂ tt)) , ((inj₂ tt , tt) , inj₂ tt)) ∷ []
m₁₂ = matchP {t₁₂} {t₁₁} assocr⋆
-- (((inj₁ tt , tt) , inj₁ tt) , (inj₁ tt , (tt , inj₁ tt)) ∷
-- (((inj₁ tt , tt) , inj₂ tt) , (inj₁ tt , (tt , inj₂ tt)) ∷
-- (((inj₂ tt , tt) , inj₁ tt) , (inj₂ tt , (tt , inj₁ tt)) ∷
-- (((inj₂ tt , tt) , inj₂ tt) , (inj₂ tt , (tt , inj₂ tt)) ∷ []
t₁₃ = TIMES ZERO BOOL
t₁₄ = ZERO
m₁₃ = matchP {t₁₃} {t₁₄} distz
-- []
m₁₄ = matchP {t₁₄} {t₁₃} factorz
-- []
t₁₅ = TIMES (PLUS BOOL ONE) BOOL
t₁₆ = PLUS (TIMES BOOL BOOL) (TIMES ONE BOOL)
m₁₅ = matchP {t₁₅} {t₁₆} dist
-- ((inj₁ (inj₁ tt) , inj₁ tt) , inj₁ (inj₁ tt , inj₁ tt)) ∷
-- ((inj₁ (inj₁ tt) , inj₂ tt) , inj₁ (inj₁ tt , inj₂ tt)) ∷
-- ((inj₁ (inj₂ tt) , inj₁ tt) , inj₁ (inj₂ tt , inj₁ tt)) ∷
-- ((inj₁ (inj₂ tt) , inj₂ tt) , inj₁ (inj₂ tt , inj₂ tt)) ∷
-- ((inj₂ tt , inj₁ tt) , inj₂ (tt , inj₁ tt)) ∷
-- ((inj₂ tt , inj₂ tt) , inj₂ (tt , inj₂ tt)) ∷ []
m₁₆ = matchP {t₁₆} {t₁₅} factor
-- (inj₁ (inj₁ tt , inj₁ tt) , (inj₁ (inj₁ tt) , inj₁ tt)) ∷
-- (inj₁ (inj₁ tt , inj₂ tt) , (inj₁ (inj₁ tt) , inj₂ tt)) ∷
-- (inj₁ (inj₂ tt , inj₁ tt) , (inj₁ (inj₂ tt) , inj₁ tt)) ∷
-- (inj₁ (inj₂ tt , inj₂ tt) , (inj₁ (inj₂ tt) , inj₂ tt)) ∷
-- (inj₂ (tt , inj₁ tt) , (inj₂ tt , inj₁ tt)) ∷
-- (inj₂ (tt , inj₂ tt) , (inj₂ tt , inj₂ tt)) ∷ []
t₁₇ = BOOL
t₁₈ = BOOL
m₁₇ = matchP {t₁₇} {t₁₈} id⟷
-- (inj₁ tt , inj₁ tt) ∷ (inj₂ tt , inj₂ tt) ∷ []
--◎
--⊕
--⊗
------------------------------------------------------------------------------
mergeS :: SubPerm → SubPerm (suc m * n) (m * n) → SubPerm (suc m * suc n) (m * suc n)
mergeS = ?
subP : ∀ {m n} → Fin (suc m) → Perm n → SubPerm (suc m * n) (m * n)
subP {m} {0} i β = {!!}
subP {m} {suc n} i (j ∷ β) = mergeS ? (subP {m} {n} i β)
-- injectP (Perm n) (m * n)
-- ...
-- SP (suc m * n) (m * n)
-- SP (n + m * n) (m * n)
--SP (suc m * n) (m * n)
--
--
--==>
--
--(suc m * suc n) (m * suc n)
--m : ℕ
--n : ℕ
--i : Fin (suc m)
--j : Fin (suc n)
--β : Perm n
--?1 : SubPerm (suc m * suc n) (m * suc n)
tcompperm : ∀ {m n} → Perm m → Perm n → Perm (m * n)
tcompperm [] β = []
tcompperm (i ∷ α) β = merge (subP i β) (tcompperm α β)
-- shift m=3 n=4 i=ax:F3 β=[ay:F4,by:F3,cy:F2,dy:F1] γ=[r4,...,r11]:P8
-- ==> [F12,F11,F10,F9...γ]
-- m = 3
-- n = 4
-- 3 * 4
-- x = [ ax, bx, cx ] : P 3, y : [ay, by, cy, dy] : P 4
-- (shift ax 4 y) ||
-- ( (shift bx 4 y) ||
-- ( (shift cx 4 y) ||
-- [])))
--
-- ax : F3, bx : F2, cx : F1
-- ay : F4, by : F3, cy : F2, dy : F1
--
-- suc m = 3, m = 2
-- F12 F11 F10 F9 F8 F7 F6 F5 F4 F3 F2 F1
-- [ r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11 ]
-- ---------------
-- ax : F3 with y=[F4,F3,F2,F1]
-- --------------
-- bx : F2
-- ------------------
-- cx : F1
-- β should be something like i * n + entry in β
0 * n = 0
(suc m) * n = n + (m * n)
comb2perm (c₁ ⊗ c₂) = tcompperm (comb2perm c₁) (comb2perm c₂)
c1 = swap+ (f->t,t->f) [1,0]
c2 = id (f->f,t->t) [0,0]
c1xc2 (f,f)->(t,f), (f,t)->(t,t), (t,f)->(f,f), (t,t)->(f,t)
[
ff ft tf tt
2 2 0 0
index in α * n + index in β
pex qex pqex qpex : Perm 3
pex = inject+ 1 (fromℕ 1) ∷ fromℕ 1 ∷ zero ∷ []
qex = zero ∷ fromℕ 1 ∷ zero ∷ []
pqex = fromℕ 2 ∷ fromℕ 1 ∷ zero ∷ []
qpex = inject+ 1 (fromℕ 1) ∷ zero ∷ zero ∷ []
pqexv = (permute qex ∘ permute pex) (tabulate id)
pqexv' = permute pqex (tabulate id)
qpexv = (permute pex ∘ permute qex) (tabulate id)
qpexv' = permute qpex (tabulate id)
-- [1,1,0]
-- [z] => [z]
-- [y,z] => [z,y]
-- [x,y,z] => [z,x,y]
-- [0,1,0]
-- [w] => [w]
-- [v,w] => [w,v]
-- [u,v,w] => [u,w,v]
-- R,R,_ ◌ _,R,_
-- R in p1 takes you to middle which also goes R, so first goes RR
-- [a,b,c] ◌ [d,e,f]
-- [a+p2[a], ...]
-- [1,1,0] ◌ [0,1,0] one step [2,1,0]
-- [z] => [z]
-- [y,z] => [z,y]
-- [x,y,z] => [z,y,x]
-- [1,1,0] ◌ [0,1,0]
-- [z] => [z] => [z]
-- [y,z] =>
-- [x,y,z] =>
-- so [1,1,0] ◌ [0,1,0] ==> [2,1,0]
-- so [0,1,0] ◌ [1,1,0] ==> [1,0,0]
-- pex takes [0,1,2] to [2,0,1]
-- qex takes [0,1,2] to [0,2,1]
-- pex ◌ qex takes [0,1,2] to [2,1,0]
-- qex ◌ pex takes [0,1,2] to [1,0,2]
-- seq : ∀ {m n} → (m ≤ n) → Perm m → Perm n → Perm m
-- seq lp [] _ = []
-- seq lp (i ∷ p) q = (lookupP i q) ∷ (seq lp p q)
-- i F+ ...
-- lookupP : ∀ {n} → Fin n → Perm n → Fin n
-- i : Fin (suc m)
-- p : Perm m
-- q : Perm n
--
-- (zero ∷ p₁) ◌ (q ∷ q₁) = q ∷ (p₁ ◌ q₁)
-- (suc p ∷ p₁) ◌ (zero ∷ q₁) = {!!}
-- (suc p ∷ p₁) ◌ (suc q ∷ q₁) = {!!}
--
-- data Perm : ℕ → Set where
-- [] : Perm 0
-- _∷_ : {n : ℕ} → Fin (suc n) → Perm n → Perm (suc n)
-- Given a vector of (suc n) elements, return one of the elements and
-- the rest. Example: pick (inject+ 1 (fromℕ 1)) (10 ∷ 20 ∷ 30 ∷ 40 ∷ [])
pick : ∀ {ℓ} {n : ℕ} {A : Set ℓ} → Fin n → Vec A (suc n) → (A × Vec A n)
pick {ℓ} {0} {A} ()
pick {ℓ} {suc n} {A} zero (v ∷ vs) = (v , vs)
pick {ℓ} {suc n} {A} (suc i) (v ∷ vs) =
let (w , ws) = pick {ℓ} {n} {A} i vs
in (w , v ∷ ws)
insertV : ∀ {ℓ} {n : ℕ} {A : Set ℓ} →
A → Fin (suc n) → Vec A n → Vec A (suc n)
insertV {n = 0} v zero [] = [ v ]
insertV {n = 0} v (suc ())
insertV {n = suc n} v zero vs = v ∷ vs
insertV {n = suc n} v (suc i) (w ∷ ws) = w ∷ insertV v i ws
-- A permutation takes two vectors of the same size, matches one
-- element from each and returns another permutation
data P {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') :
(m n : ℕ) → (m ≡ n) → Vec A m → Vec B n → Set (ℓ ⊔ ℓ') where
nil : P A B 0 0 refl [] []
cons : {m n : ℕ} {i : Fin (suc m)} {j : Fin (suc n)} → (p : m ≡ n) →
(v : A) → (w : B) → (vs : Vec A m) → (ws : Vec B n) →
P A B m n p vs ws →
P A B (suc m) (suc n) (cong suc p) (insertV v i vs) (insertV w j ws)
-- A permutation is a sequence of "insertions".
infixr 5 _∷_
data Perm : ℕ → Set where
[] : Perm 0
_∷_ : {n : ℕ} → Fin (suc n) → Perm n → Perm (suc n)
lookupP : ∀ {n} → Fin n → Perm n → Fin n
lookupP () []
lookupP zero (j ∷ _) = j
lookupP {suc n} (suc i) (j ∷ q) = inject₁ (lookupP i q)
insert : ∀ {ℓ n} {A : Set ℓ} → Vec A n → Fin (suc n) → A → Vec A (suc n)
insert vs zero w = w ∷ vs
insert [] (suc ()) -- absurd
insert (v ∷ vs) (suc i) w = v ∷ insert vs i w
-- A permutation acts on a vector by inserting each element in its new
-- position.
permute : ∀ {ℓ n} {A : Set ℓ} → Perm n → Vec A n → Vec A n
permute [] [] = []
permute (p ∷ ps) (v ∷ vs) = insert (permute ps vs) p v
-- Use a permutation to match up the elements in two vectors. See more
-- convenient function matchP below.
match : ∀ {t t'} → (size t ≡ size t') → Perm (size t) →
Vec ⟦ t ⟧ (size t) → Vec ⟦ t' ⟧ (size t) →
Vec (⟦ t ⟧ × ⟦ t' ⟧) (size t)
match {t} {t'} sp α vs vs' =
let js = permute α (tabulate id)
in zip (tabulate (λ j → lookup (lookup j js) vs)) vs'
-- swap
--
-- swapperm produces the permutations that maps:
-- [ a , b || x , y , z ]
-- to
-- [ x , y , z || a , b ]
-- Ex.
-- permute (swapperm {5} (inject+ 2 (fromℕ 2))) ordered=[0,1,2,3,4]
-- produces [2,3,4,0,1]
-- Explicitly:
-- swapex : Perm 5
-- swapex = inject+ 1 (fromℕ 3) -- :: Fin 5
-- ∷ inject+ 0 (fromℕ 3) -- :: Fin 4
-- ∷ zero
-- ∷ zero
-- ∷ zero
-- ∷ []
swapperm : ∀ {n} → Fin n → Perm n
swapperm {0} () -- absurd
swapperm {suc n} zero = idperm
swapperm {suc n} (suc i) =
subst Fin (-+-id n i)
(inject+ (toℕ i) (fromℕ (n ∸ toℕ i))) ∷ swapperm {n} i
-- compositions
-- Sequential composition
scompperm : ∀ {n} → Perm n → Perm n → Perm n
scompperm α β = {!!}
-- Sub-permutations
-- useful for parallel and multiplicative compositions
-- Perm 4 has elements [Fin 4, Fin 3, Fin 2, Fin 1]
-- SubPerm 11 7 has elements [Fin 11, Fin 10, Fin 9, Fin 8]
-- So Perm 4 is a special case SubPerm 4 0
data SubPerm : ℕ → ℕ → Set where
[]s : {n : ℕ} → SubPerm n n
_∷s_ : {n m : ℕ} → Fin (suc n) → SubPerm n m → SubPerm (suc n) m
merge : ∀ {m n} → SubPerm m n → Perm n → Perm m
merge []s β = β
merge (i ∷s α) β = i ∷ merge α β
injectP : ∀ {m} → Perm m → (n : ℕ) → SubPerm (m + n) n
injectP [] n = []s
injectP (i ∷ α) n = inject+ n i ∷s injectP α n
-- Parallel + composition
pcompperm : ∀ {m n} → Perm m → Perm n → Perm (m + n)
pcompperm {m} {n} α β = merge (injectP α n) β
-- Multiplicative * composition
tcompperm : ∀ {m n} → Perm m → Perm n → Perm (m * n)
tcompperm [] β = []
tcompperm (i ∷ α) β = {!!}
------------------------------------------------------------------------------
-- A combinator t₁ ⟷ t₂ denotes a permutation.
comb2perm : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → Perm (size t₁)
comb2perm {PLUS ZERO t} {.t} unite₊ = idperm
comb2perm {t} {PLUS ZERO .t} uniti₊ = idperm
comb2perm {PLUS t₁ t₂} {PLUS .t₂ .t₁} swap₊ with size t₂
... | 0 = idperm
... | suc j = swapperm {size t₁ + suc j}
(inject≤ (fromℕ (size t₁)) (suc≤ (size t₁) j))
comb2perm {PLUS t₁ (PLUS t₂ t₃)} {PLUS (PLUS .t₁ .t₂) .t₃} assocl₊ = idperm
comb2perm {PLUS (PLUS t₁ t₂) t₃} {PLUS .t₁ (PLUS .t₂ .t₃)} assocr₊ = idperm
comb2perm {TIMES ONE t} {.t} unite⋆ = idperm
comb2perm {t} {TIMES ONE .t} uniti⋆ = idperm
comb2perm {TIMES t₁ t₂} {TIMES .t₂ .t₁} swap⋆ = idperm
comb2perm assocl⋆ = idperm
comb2perm assocr⋆ = idperm
comb2perm distz = idperm
comb2perm factorz = idperm
comb2perm dist = idperm
comb2perm factor = idperm
comb2perm id⟷ = idperm
comb2perm (c₁ ◎ c₂) = scompperm
(comb2perm c₁)
(subst Perm (sym (size≡ c₁)) (comb2perm c₂))
comb2perm (c₁ ⊕ c₂) = pcompperm (comb2perm c₁) (comb2perm c₂)
comb2perm (c₁ ⊗ c₂) = tcompperm (comb2perm c₁) (comb2perm c₂)
-- Convenient way of "seeing" what the permutation does for each combinator
matchP : ∀ {t t'} → (t ⟷ t') → Vec (⟦ t ⟧ × ⟦ t' ⟧) (size t)
matchP {t} {t'} c =
match sp (comb2perm c) (utoVec t)
(subst (λ n → Vec ⟦ t' ⟧ n) (sym sp) (utoVec t'))
where sp = size≡ c
------------------------------------------------------------------------------
-- Extensional equivalence of combinators: two combinators are
-- equivalent if they denote the same permutation. Generally we would
-- require that the two permutations map the same value x to values y
-- and z that have a path between them, but because the internals of each
-- type are discrete groupoids, this reduces to saying that y and z
-- are identical, and hence that the permutations are identical.
infix 10 _∼_
_∼_ : ∀ {t₁ t₂} → (c₁ c₂ : t₁ ⟷ t₂) → Set
c₁ ∼ c₂ = (comb2perm c₁ ≡ comb2perm c₂)
-- The relation ~ is an equivalence relation
refl∼ : ∀ {t₁ t₂} {c : t₁ ⟷ t₂} → (c ∼ c)
refl∼ = refl
sym∼ : ∀ {t₁ t₂} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₁)
sym∼ = sym
trans∼ : ∀ {t₁ t₂} {c₁ c₂ c₃ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₂ ∼ c₃) → (c₁ ∼ c₃)
trans∼ = trans
-- The relation ~ validates the groupoid laws
c◎id∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ id⟷ ∼ c
c◎id∼c = {!!}
id◎c∼c : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ◎ c ∼ c
id◎c∼c = {!!}
assoc∼ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
c₁ ◎ (c₂ ◎ c₃) ∼ (c₁ ◎ c₂) ◎ c₃
assoc∼ = {!!}
linv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ◎ ! c ∼ id⟷
linv∼ = {!!}
rinv∼ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → ! c ◎ c ∼ id⟷
rinv∼ = {!!}
resp∼ : {t₁ t₂ t₃ : U} {c₁ c₂ : t₁ ⟷ t₂} {c₃ c₄ : t₂ ⟷ t₃} →
(c₁ ∼ c₂) → (c₃ ∼ c₄) → (c₁ ◎ c₃ ∼ c₂ ◎ c₄)
resp∼ = {!!}
-- The equivalence ∼ of paths makes U a 1groupoid: the points are
-- types (t : U); the 1paths are ⟷; and the 2paths between them are
-- based on extensional equivalence ∼
G : 1Groupoid
G = record
{ set = U
; _↝_ = _⟷_
; _≈_ = _∼_
; id = id⟷
; _∘_ = λ p q → q ◎ p
; _⁻¹ = !
; lneutr = λ c → c◎id∼c {c = c}
; rneutr = λ c → id◎c∼c {c = c}
; assoc = λ c₃ c₂ c₁ → assoc∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃}
; equiv = record {
refl = λ {c} → refl∼ {c = c}
; sym = λ {c₁} {c₂} → sym∼ {c₁ = c₁} {c₂ = c₂}
; trans = λ {c₁} {c₂} {c₃} → trans∼ {c₁ = c₁} {c₂ = c₂} {c₃ = c₃}
}
; linv = λ c → linv∼ {c = c}
; rinv = λ c → rinv∼ {c = c}
; ∘-resp-≈ = λ α β → resp∼ β α
}
-- And there are additional laws
assoc⊕∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
c₁ ⊕ (c₂ ⊕ c₃) ∼ assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊
assoc⊕∼ = {!!}
assoc⊗∼ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
c₁ ⊗ (c₂ ⊗ c₃) ∼ assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆
assoc⊗∼ = {!!}
------------------------------------------------------------------------------
-- Picture so far:
--
-- path p
-- =====================
-- || || ||
-- || ||2path ||
-- || || ||
-- || || path q ||
-- t₁ =================t₂
-- || ... ||
-- =====================
--
-- The types t₁, t₂, etc are discrete groupoids. The paths between
-- them correspond to permutations. Each syntactically different
-- permutation corresponds to a path but equivalent permutations are
-- connected by 2paths. But now we want an alternative definition of
-- 2paths that is structural, i.e., that looks at the actual
-- construction of the path t₁ ⟷ t₂ in terms of combinators... The
-- theorem we want is that α ∼ β iff we can rewrite α to β using
-- various syntactic structural rules. We start with a collection of
-- simplication rules and then try to show they are complete.
-- Simplification rules
infix 30 _⇔_
data _⇔_ : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂) → Set where
assoc◎l : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
(c₁ ◎ (c₂ ◎ c₃)) ⇔ ((c₁ ◎ c₂) ◎ c₃)
assoc◎r : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₃ ⟷ t₄} →
((c₁ ◎ c₂) ◎ c₃) ⇔ (c₁ ◎ (c₂ ◎ c₃))
assoc⊕l : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(c₁ ⊕ (c₂ ⊕ c₃)) ⇔ (assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊)
assoc⊕r : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(assocl₊ ◎ ((c₁ ⊕ c₂) ⊕ c₃) ◎ assocr₊) ⇔ (c₁ ⊕ (c₂ ⊕ c₃))
assoc⊗l : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(c₁ ⊗ (c₂ ⊗ c₃)) ⇔ (assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆)
assoc⊗r : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(assocl⋆ ◎ ((c₁ ⊗ c₂) ⊗ c₃) ◎ assocr⋆) ⇔ (c₁ ⊗ (c₂ ⊗ c₃))
dist⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
((c₁ ⊕ c₂) ⊗ c₃) ⇔ (dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor)
factor⇔ : {t₁ t₂ t₃ t₄ t₅ t₆ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₅ ⟷ t₆} →
(dist ◎ ((c₁ ⊗ c₃) ⊕ (c₂ ⊗ c₃)) ◎ factor) ⇔ ((c₁ ⊕ c₂) ⊗ c₃)
idl◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (id⟷ ◎ c) ⇔ c
idl◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ id⟷ ◎ c
idr◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ id⟷) ⇔ c
idr◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ (c ◎ id⟷)
linv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (c ◎ ! c) ⇔ id⟷
linv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (c ◎ ! c)
rinv◎l : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → (! c ◎ c) ⇔ id⟷
rinv◎r : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → id⟷ ⇔ (! c ◎ c)
unitel₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(unite₊ ◎ c₂) ⇔ ((c₁ ⊕ c₂) ◎ unite₊)
uniter₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
((c₁ ⊕ c₂) ◎ unite₊) ⇔ (unite₊ ◎ c₂)
unitil₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(uniti₊ ◎ (c₁ ⊕ c₂)) ⇔ (c₂ ◎ uniti₊)
unitir₊⇔ : {t₁ t₂ : U} {c₁ : ZERO ⟷ ZERO} {c₂ : t₁ ⟷ t₂} →
(c₂ ◎ uniti₊) ⇔ (uniti₊ ◎ (c₁ ⊕ c₂))
unitial₊⇔ : {t₁ t₂ : U} → (uniti₊ {PLUS t₁ t₂} ◎ assocl₊) ⇔ (uniti₊ ⊕ id⟷)
unitiar₊⇔ : {t₁ t₂ : U} → (uniti₊ {t₁} ⊕ id⟷ {t₂}) ⇔ (uniti₊ ◎ assocl₊)
swapl₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
(swap₊ ◎ (c₁ ⊕ c₂)) ⇔ ((c₂ ⊕ c₁) ◎ swap₊)
swapr₊⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
((c₂ ⊕ c₁) ◎ swap₊) ⇔ (swap₊ ◎ (c₁ ⊕ c₂))
unitel⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(unite⋆ ◎ c₂) ⇔ ((c₁ ⊗ c₂) ◎ unite⋆)
uniter⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
((c₁ ⊗ c₂) ◎ unite⋆) ⇔ (unite⋆ ◎ c₂)
unitil⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(uniti⋆ ◎ (c₁ ⊗ c₂)) ⇔ (c₂ ◎ uniti⋆)
unitir⋆⇔ : {t₁ t₂ : U} {c₁ : ONE ⟷ ONE} {c₂ : t₁ ⟷ t₂} →
(c₂ ◎ uniti⋆) ⇔ (uniti⋆ ◎ (c₁ ⊗ c₂))
unitial⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {TIMES t₁ t₂} ◎ assocl⋆) ⇔ (uniti⋆ ⊗ id⟷)
unitiar⋆⇔ : {t₁ t₂ : U} → (uniti⋆ {t₁} ⊗ id⟷ {t₂}) ⇔ (uniti⋆ ◎ assocl⋆)
swapl⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
(swap⋆ ◎ (c₁ ⊗ c₂)) ⇔ ((c₂ ⊗ c₁) ◎ swap⋆)
swapr⋆⇔ : {t₁ t₂ t₃ t₄ : U} {c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} →
((c₂ ⊗ c₁) ◎ swap⋆) ⇔ (swap⋆ ◎ (c₁ ⊗ c₂))
swapfl⋆⇔ : {t₁ t₂ t₃ : U} →
(swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor) ⇔
(factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷))
swapfr⋆⇔ : {t₁ t₂ t₃ : U} →
(factor ◎ (swap₊ {t₂} {t₁} ⊗ id⟷)) ⇔
(swap₊ {TIMES t₂ t₃} {TIMES t₁ t₃} ◎ factor)
id⇔ : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ c
trans⇔ : {t₁ t₂ : U} {c₁ c₂ c₃ : t₁ ⟷ t₂} →
(c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)
resp◎⇔ : {t₁ t₂ t₃ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₂ ⟷ t₃} {c₃ : t₁ ⟷ t₂} {c₄ : t₂ ⟷ t₃} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ◎ c₂) ⇔ (c₃ ◎ c₄)
resp⊕⇔ : {t₁ t₂ t₃ t₄ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊕ c₂) ⇔ (c₃ ⊕ c₄)
resp⊗⇔ : {t₁ t₂ t₃ t₄ : U}
{c₁ : t₁ ⟷ t₂} {c₂ : t₃ ⟷ t₄} {c₃ : t₁ ⟷ t₂} {c₄ : t₃ ⟷ t₄} →
(c₁ ⇔ c₃) → (c₂ ⇔ c₄) → (c₁ ⊗ c₂) ⇔ (c₃ ⊗ c₄)
-- better syntax for writing 2paths
infix 2 _▤
infixr 2 _⇔⟨_⟩_
_⇔⟨_⟩_ : {t₁ t₂ : U} (c₁ : t₁ ⟷ t₂) {c₂ : t₁ ⟷ t₂} {c₃ : t₁ ⟷ t₂} →
(c₁ ⇔ c₂) → (c₂ ⇔ c₃) → (c₁ ⇔ c₃)
_ ⇔⟨ α ⟩ β = trans⇔ α β
_▤ : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → (c ⇔ c)
_▤ c = id⇔
-- Inverses for 2paths
2! : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₂ ⇔ c₁)
2! assoc◎l = assoc◎r
2! assoc◎r = assoc◎l
2! assoc⊕l = assoc⊕r
2! assoc⊕r = assoc⊕l
2! assoc⊗l = assoc⊗r
2! assoc⊗r = assoc⊗l
2! dist⇔ = factor⇔
2! factor⇔ = dist⇔
2! idl◎l = idl◎r
2! idl◎r = idl◎l
2! idr◎l = idr◎r
2! idr◎r = idr◎l
2! linv◎l = linv◎r
2! linv◎r = linv◎l
2! rinv◎l = rinv◎r
2! rinv◎r = rinv◎l
2! unitel₊⇔ = uniter₊⇔
2! uniter₊⇔ = unitel₊⇔
2! unitil₊⇔ = unitir₊⇔
2! unitir₊⇔ = unitil₊⇔
2! swapl₊⇔ = swapr₊⇔
2! swapr₊⇔ = swapl₊⇔
2! unitial₊⇔ = unitiar₊⇔
2! unitiar₊⇔ = unitial₊⇔
2! unitel⋆⇔ = uniter⋆⇔
2! uniter⋆⇔ = unitel⋆⇔
2! unitil⋆⇔ = unitir⋆⇔
2! unitir⋆⇔ = unitil⋆⇔
2! unitial⋆⇔ = unitiar⋆⇔
2! unitiar⋆⇔ = unitial⋆⇔
2! swapl⋆⇔ = swapr⋆⇔
2! swapr⋆⇔ = swapl⋆⇔
2! swapfl⋆⇔ = swapfr⋆⇔
2! swapfr⋆⇔ = swapfl⋆⇔
2! id⇔ = id⇔
2! (trans⇔ α β) = trans⇔ (2! β) (2! α)
2! (resp◎⇔ α β) = resp◎⇔ (2! α) (2! β)
2! (resp⊕⇔ α β) = resp⊕⇔ (2! α) (2! β)
2! (resp⊗⇔ α β) = resp⊗⇔ (2! α) (2! β)
-- a nice example of 2 paths
negEx : neg₅ ⇔ neg₁
negEx = uniti⋆ ◎ (swap⋆ ◎ ((swap₊ ⊗ id⟷) ◎ (swap⋆ ◎ unite⋆)))
⇔⟨ resp◎⇔ id⇔ assoc◎l ⟩
uniti⋆ ◎ ((swap⋆ ◎ (swap₊ ⊗ id⟷)) ◎ (swap⋆ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ swapl⋆⇔ id⇔) ⟩
uniti⋆ ◎ (((id⟷ ⊗ swap₊) ◎ swap⋆) ◎ (swap⋆ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ assoc◎r ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (swap⋆ ◎ (swap⋆ ◎ unite⋆)))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ assoc◎l) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ ((swap⋆ ◎ swap⋆) ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ (resp◎⇔ linv◎l id⇔)) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ (id⟷ ◎ unite⋆))
⇔⟨ resp◎⇔ id⇔ (resp◎⇔ id⇔ idl◎l) ⟩
uniti⋆ ◎ ((id⟷ ⊗ swap₊) ◎ unite⋆)
⇔⟨ assoc◎l ⟩
(uniti⋆ ◎ (id⟷ ⊗ swap₊)) ◎ unite⋆
⇔⟨ resp◎⇔ unitil⋆⇔ id⇔ ⟩
(swap₊ ◎ uniti⋆) ◎ unite⋆
⇔⟨ assoc◎r ⟩
swap₊ ◎ (uniti⋆ ◎ unite⋆)
⇔⟨ resp◎⇔ id⇔ linv◎l ⟩
swap₊ ◎ id⟷
⇔⟨ idr◎l ⟩
swap₊ ▤
-- The equivalence ⇔ of paths is rich enough to make U a 1groupoid:
-- the points are types (t : U); the 1paths are ⟷; and the 2paths
-- between them are based on the simplification rules ⇔
G' : 1Groupoid
G' = record
{ set = U
; _↝_ = _⟷_
; _≈_ = _⇔_
; id = id⟷
; _∘_ = λ p q → q ◎ p
; _⁻¹ = !
; lneutr = λ _ → idr◎l
; rneutr = λ _ → idl◎l
; assoc = λ _ _ _ → assoc◎l
; equiv = record {
refl = id⇔
; sym = 2!
; trans = trans⇔
}
; linv = λ {t₁} {t₂} α → linv◎l
; rinv = λ {t₁} {t₂} α → rinv◎l
; ∘-resp-≈ = λ p∼q r∼s → resp◎⇔ r∼s p∼q
}
------------------------------------------------------------------------------
-- Inverting permutations to syntactic combinators
perm2comb : {t₁ t₂ : U} → (size t₁ ≡ size t₂) → Perm (size t₁) → (t₁ ⟷ t₂)
perm2comb {ZERO} {t₂} sp [] = {!!}
perm2comb {ONE} {t₂} sp p = {!!}
perm2comb {PLUS t₁ t₂} {t₃} sp p = {!!}
perm2comb {TIMES t₁ t₂} {t₃} sp p = {!!}
------------------------------------------------------------------------------
-- Soundness and completeness
--
-- Proof of soundness and completeness: now we want to verify that ⇔
-- is sound and complete with respect to ∼. The statement to prove is
-- that for all c₁ and c₂, we have c₁ ∼ c₂ iff c₁ ⇔ c₂
soundness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ⇔ c₂) → (c₁ ∼ c₂)
soundness assoc◎l = assoc∼
soundness assoc◎r = sym∼ assoc∼
soundness assoc⊕l = assoc⊕∼
soundness assoc⊕r = sym∼ assoc⊕∼
soundness assoc⊗l = assoc⊗∼
soundness assoc⊗r = sym∼ assoc⊗∼
soundness dist⇔ = {!!}
soundness factor⇔ = {!!}
soundness idl◎l = id◎c∼c
soundness idl◎r = sym∼ id◎c∼c
soundness idr◎l = c◎id∼c
soundness idr◎r = sym∼ c◎id∼c
soundness linv◎l = linv∼
soundness linv◎r = sym∼ linv∼
soundness rinv◎l = rinv∼
soundness rinv◎r = sym∼ rinv∼
soundness unitel₊⇔ = {!!}
soundness uniter₊⇔ = {!!}
soundness unitil₊⇔ = {!!}
soundness unitir₊⇔ = {!!}
soundness unitial₊⇔ = {!!}
soundness unitiar₊⇔ = {!!}
soundness swapl₊⇔ = {!!}
soundness swapr₊⇔ = {!!}
soundness unitel⋆⇔ = {!!}
soundness uniter⋆⇔ = {!!}
soundness unitil⋆⇔ = {!!}
soundness unitir⋆⇔ = {!!}
soundness unitial⋆⇔ = {!!}
soundness unitiar⋆⇔ = {!!}
soundness swapl⋆⇔ = {!!}
soundness swapr⋆⇔ = {!!}
soundness swapfl⋆⇔ = {!!}
soundness swapfr⋆⇔ = {!!}
soundness id⇔ = refl∼
soundness (trans⇔ α β) = trans∼ (soundness α) (soundness β)
soundness (resp◎⇔ α β) = resp∼ (soundness α) (soundness β)
soundness (resp⊕⇔ α β) = {!!}
soundness (resp⊗⇔ α β) = {!!}
-- The idea is to invert evaluation and use that to extract from each
-- extensional representation of a combinator, a canonical syntactic
-- representative
canonical : {t₁ t₂ : U} → (t₁ ⟷ t₂) → (t₁ ⟷ t₂)
canonical c = perm2comb (size≡ c) (comb2perm c)
-- Note that if c₁ ⇔ c₂, then by soundness c₁ ∼ c₂ and hence their
-- canonical representatives are identical.
canonicalWellDefined : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} →
(c₁ ⇔ c₂) → (canonical c₁ ≡ canonical c₂)
canonicalWellDefined {t₁} {t₂} {c₁} {c₂} α =
cong₂ perm2comb (size∼ c₁ c₂) (soundness α)
-- If we can prove that every combinator is equal to its normal form
-- then we can prove completeness.
inversion : {t₁ t₂ : U} {c : t₁ ⟷ t₂} → c ⇔ canonical c
inversion = {!!}
resp≡⇔ : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ≡ c₂) → (c₁ ⇔ c₂)
resp≡⇔ {t₁} {t₂} {c₁} {c₂} p rewrite p = id⇔
completeness : {t₁ t₂ : U} {c₁ c₂ : t₁ ⟷ t₂} → (c₁ ∼ c₂) → (c₁ ⇔ c₂)
completeness {t₁} {t₂} {c₁} {c₂} c₁∼c₂ =
c₁
⇔⟨ inversion ⟩
canonical c₁
⇔⟨ resp≡⇔ (cong₂ perm2comb (size∼ c₁ c₂) c₁∼c₂) ⟩
canonical c₂
⇔⟨ 2! inversion ⟩
c₂ ▤
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Nat and Fin lemmas
suc≤ : (m n : ℕ) → suc m ≤ m + suc n
suc≤ 0 n = s≤s z≤n
suc≤ (suc m) n = s≤s (suc≤ m n)
-+-id : (n : ℕ) → (i : Fin n) → suc (n ∸ toℕ i) + toℕ i ≡ suc n
-+-id 0 () -- absurd
-+-id (suc n) zero = +-right-identity (suc (suc n))
-+-id (suc n) (suc i) = begin
suc (suc n ∸ toℕ (suc i)) + toℕ (suc i)
≡⟨ refl ⟩
suc (n ∸ toℕ i) + suc (toℕ i)
≡⟨ +-suc (suc (n ∸ toℕ i)) (toℕ i) ⟩
suc (suc (n ∸ toℕ i) + toℕ i)
≡⟨ cong suc (-+-id n i) ⟩
suc (suc n) ∎
p0 p1 : Perm 4
p0 = idπ
p1 = swap (inject+ 1 (fromℕ 2)) (inject+ 3 (fromℕ 0))
(swap (fromℕ 3) zero
(swap zero (inject+ 1 (fromℕ 2))
idπ))
xx = action p1 (10 ∷ 20 ∷ 30 ∷ 40 ∷ [])
n≤sn : ∀ {x} → x ≤ suc x
n≤sn {0} = z≤n
n≤sn {suc n} = s≤s (n≤sn {n})
<implies≤ : ∀ {x y} → (x < y) → (x ≤ y)
<implies≤ (s≤s z≤n) = z≤n
<implies≤ {suc x} {suc y} (s≤s p) =
begin (suc x
≤⟨ p ⟩
y
≤⟨ n≤sn {y} ⟩
suc y ∎)
where open ≤-Reasoning
bounded≤ : ∀ {n} (i : Fin n) → toℕ i ≤ n
bounded≤ i = <implies≤ (bounded i)
n≤n : (n : ℕ) → n ≤ n
n≤n 0 = z≤n
n≤n (suc n) = s≤s (n≤n n)
-- Convenient way of "seeing" what the permutation does for each combinator
matchP : ∀ {t t'} → (t ⟷ t') → Vec (⟦ t ⟧ × ⟦ t' ⟧) (size t)
matchP {t} {t'} c =
match sp (comb2perm c) (utoVec t)
(subst (λ n → Vec ⟦ t' ⟧ n) (sym sp) (utoVec t'))
where sp = size≡ c
infix 90 _X_
data Swap (n : ℕ) : Set where
_X_ : Fin n → Fin n → Swap n
Perm : ℕ → Set
Perm n = List (Swap n)
showSwap : ∀ {n} → Swap n → String
showSwap (i X j) = show (toℕ i) ++S " X " ++S show (toℕ j)
actionπ : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → Perm n → Vec A n → Vec A n
actionπ π vs = foldl swapX vs π
where
swapX : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → Vec A n → Swap n → Vec A n
swapX vs (i X j) = (vs [ i ]≔ lookup j vs) [ j ]≔ lookup i vs
swapπ : ∀ {m n} → Perm (m + n)
swapπ {0} {n} = []
swapπ {suc m} {n} =
concatL
(replicate (suc m)
(toList
(zipWith _X_
(mapV inject₁ (allFin (m + n)))
(tail (allFin (suc m + n))))))
scompπ : ∀ {n} → Perm n → Perm n → Perm n
scompπ = _++L_
injectπ : ∀ {m} → Perm m → (n : ℕ) → Perm (m + n)
injectπ π n = mapL (λ { (i X j) → (inject+ n i) X (inject+ n j) }) π
raiseπ : ∀ {n} → Perm n → (m : ℕ) → Perm (m + n)
raiseπ π m = mapL (λ { (i X j) → (raise m i) X (raise m j) }) π
pcompπ : ∀ {m n} → Perm m → Perm n → Perm (m + n)
pcompπ {m} {n} α β = (injectπ α n) ++L (raiseπ β m)
idπ : ∀ {n} → Perm n
idπ {n} = toList (zipWith _X_ (allFin n) (allFin n))
tcompπ : ∀ {m n} → Perm m → Perm n → Perm (m * n)
tcompπ {m} {n} α β =
concatL (mapL
(λ { (i X j) →
mapL (λ { (k X l) →
(inject≤ (fromℕ (toℕ i * n + toℕ k))
(i*n+k≤m*n i k))
X
(inject≤ (fromℕ (toℕ j * n + toℕ l))
(i*n+k≤m*n j l))})
(β ++L idπ {n})})
(α ++L idπ {m}))
--}
swap+π : (m n : ℕ) → Transposition* (m + n)
swap+π 0 n = []
swap+π (suc m) n =
concatL
(replicate (suc m)
(toList
(zipWith mkTransposition
(mapV inject₁ (allFin (m + n)))
(tail (allFin (suc m + n))))))
-- Ex:
swap11 swap21 swap32 : List String
swap11 = showTransposition* (swap+π 1 1)
-- 0 X 1 ∷ []
-- actionπ (swap+π 1 1) ("a" ∷ "b" ∷ [])
-- "b" ∷ "a" ∷ []
swap21 = showTransposition* (swap+π 2 1)
-- 0 X 1 ∷ 1 X 2 ∷ 0 X 1 ∷ 1 X 2 ∷ []
-- actionπ (swap+π 2 1) ("a" ∷ "b" ∷ "c" ∷ [])
-- "c" ∷ "a" ∷ "b" ∷ []
swap32 = showTransposition* (swap+π 3 2)
-- 0 X 1 ∷ 1 X 2 ∷ 2 X 3 ∷ 3 X 4 ∷
-- 0 X 1 ∷ 1 X 2 ∷ 2 X 3 ∷ 3 X 4 ∷
-- 0 X 1 ∷ 1 X 2 ∷ 2 X 3 ∷ 3 X 4 ∷ []
-- actionπ (swap+π 3 2) ("a" ∷ "b" ∷ "c" ∷ "d" ∷ "e" ∷ [])
-- "d" ∷ "e" ∷ "a" ∷ "b" ∷ "c" ∷ []
delete : ∀ {n} → List (Fin n) → Fin n → List (Fin n)
delete [] _ = []
delete (j ∷ js) i with toℕ i ≟ toℕ j
delete (j ∷ js) i | yes _ = js
delete (j ∷ js) i | no _ = j ∷ delete js i
extendπ : ∀ {n} → Transposition* n → Transposition* n
extendπ {n} π =
let existing = mapL (λ { (i X j) → i }) π
all = toList (allFin n)
diff = foldl delete all existing
in π ++L mapL (λ i → _X_ i i {i≤i (toℕ i)}) diff
tcompπ : ∀ {m n} → Transposition* m → Transposition* n → Transposition* (m * n)
tcompπ {m} {n} α β =
concatMap
(λ { (i X j) →
mapL (λ { (k X l) →
mkTransposition
(inject≤ (fromℕ (toℕ i * n + toℕ k)) (i*n+k≤m*n i k))
(inject≤ (fromℕ (toℕ j * n + toℕ l)) (i*n+k≤m*n j l))})
(extendπ β)})
(extendπ α)
{--
pcompπ : ∀ {m n} → Transposition* m → Transposition* n → Transposition* (m + n)
pcompπ {m} {n} α β = injectπ n α ++L raiseπ m β
where injectπ : ∀ {m} → (n : ℕ) → Transposition* m → Transposition* (m + n)
injectπ n = mapL (λ { (i X j) →
mkTransposition (inject+ n i) (inject+ n j) })
raiseπ : ∀ {n} → (m : ℕ) → Transposition* n → Transposition* (m + n)
raiseπ m = mapL (λ { (i X j) →
mkTransposition (raise m i) (raise m j)})
--}
-- Identity permutation as explicit product of transpositions
idπ : (n : ℕ) → Transposition* n
idπ n = toList (zipWith mkTransposition (allFin n) (allFin n))
-- Ex:
idπ5 = showTransposition* (idπ 5)
-- 0 X 0 ∷ 1 X 1 ∷ 2 X 2 ∷ 3 X 3 ∷ 4 X 4 ∷ []
-- actionπ (idπ 5) ("1" ∷ "2" ∷ "3" ∷ "4" ∷ "5" ∷ [])
-- "1" ∷ "2" ∷ "3" ∷ "4" ∷ "5" ∷ []
concatMap
(λ { (i X j) →
mapL (λ { (k X l) →
mkTransposition
(inject≤ (fromℕ (toℕ i * n + toℕ k)) (i*n+k≤m*n i k))
(inject≤ (fromℕ (toℕ j * n + toℕ l)) (i*n+k≤m*n j l))})
(extendπ β)})
(extendπ α)
-----
{--
-- Representation I:
-- Our first representation of a permutation is as a product of
-- "transpositions." This product is not commutative; we apply it from
-- left to right. Because we eventually want to normalize permutations
-- to some canonical representation, we insist that the first
-- component of a transposition is always ≤ than the second
infix 90 _X_
data Transposition (n : ℕ) : Set where
_X_ : (i j : Fin n) → {p : toℕ i ≤ toℕ j} → Transposition n
mkTransposition : {n : ℕ} → (i j : Fin n) → Transposition n
mkTransposition {n} i j with toℕ i ≤? toℕ j
... | yes p = _X_ i j {p}
... | no p = _X_ j i {i≰j→j≤i (toℕ i) (toℕ j) p}
Transposition* : ℕ → Set
Transposition* n = List (Transposition n)
showTransposition* : ∀ {n} → Transposition* n → List String
showTransposition* =
mapL (λ { (i X j) → show (toℕ i) ++S " X " ++S show (toℕ j) })
actionπ : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → Transposition* n → Vec A n → Vec A n
actionπ π vs = foldl swapX vs π
where
swapX : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → Vec A n → Transposition n → Vec A n
swapX vs (i X j) = (vs [ i ]≔ lookup j vs) [ j ]≔ lookup i vs
-- Representation II:
-- This is also a product of transpositions but the transpositions are such
-- that the first component is always < the second, i.e., we got rid of trivial
-- transpositions that swap an element with itself
data Transposition< (n : ℕ) : Set where
_X!_ : (i j : Fin n) → {p : toℕ i < toℕ j} → Transposition< n
Transposition<* : ℕ → Set
Transposition<* n = List (Transposition< n)
showTransposition<* : ∀ {n} → Transposition<* n → List String
showTransposition<* =
mapL (λ { (i X! j) → show (toℕ i) ++S " X! " ++S show (toℕ j) })
filter= : {n : ℕ} → Transposition* n → Transposition<* n
filter= [] = []
filter= (_X_ i j {p≤} ∷ π) with toℕ i ≟ toℕ j
... | yes p= = filter= π
... | no p≠ = _X!_ i j {i≠j∧i≤j→i<j (toℕ i) (toℕ j) p≠ p≤} ∷ filter= π
-- Representation IV
-- A product of cycles where each cycle is a non-empty sequence of indices
Cycle : ℕ → Set
Cycle n = List⁺ (Fin n)
Cycle* : ℕ → Set
Cycle* n = List (Cycle n)
-- convert a cycle to a product of transpositions
cycle→transposition* : ∀ {n} → Cycle n → Transposition* n
cycle→transposition* (i , []) = []
cycle→transposition* (i , (j ∷ ns)) =
mkTransposition i j ∷ cycle→transposition* (i , ns)
cycle*→transposition* : ∀ {n} → Cycle* n → Transposition* n
cycle*→transposition* cs = concatMap cycle→transposition* cs
-- Ex:
cycleEx1 cycleEx2 : Cycle 5
-- cycleEx1 (0 1 2 3 4) which rotates right
cycleEx1 = inject+ 4 (fromℕ 0) ,
inject+ 3 (fromℕ 1) ∷
inject+ 2 (fromℕ 2) ∷
inject+ 1 (fromℕ 3) ∷
inject+ 0 (fromℕ 4) ∷ []
-- cycleEx1 (0 4 3 2 1) which rotates left
cycleEx2 = inject+ 4 (fromℕ 0) ,
inject+ 0 (fromℕ 4) ∷
inject+ 1 (fromℕ 3) ∷
inject+ 2 (fromℕ 2) ∷
inject+ 3 (fromℕ 1) ∷ []
cycleEx1→transposition* cycleEx2→transposition* : List String
cycleEx1→transposition* = showTransposition* (cycle→transposition* cycleEx1)
-- 0 X 1 ∷ 0 X 2 ∷ 0 X 3 ∷ 0 X 4 ∷ []
-- actionπ (cycle→transposition* cycleEx1) (0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ [])
-- 4 ∷ 0 ∷ 1 ∷ 2 ∷ 3 ∷ []
cycleEx2→transposition* = showTransposition* (cycle→transposition* cycleEx2)
-- 0 X 4 ∷ 0 X 3 ∷ 0 X 2 ∷ 0 X 1 ∷ []
-- actionπ (cycle→transposition* cycleEx2) (0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ [])
-- 1 ∷ 2 ∷ 3 ∷ 4 ∷ 0 ∷ []
-- Convert from Cauchy 2 line representation to product of cycles
-- Helper that checks if there is a cycle that starts at i
-- Returns the cycle containing i and the rest of the permutation
-- without that cycle
findCycle : ∀ {n} → Fin n → Cycle* n → Maybe (Cycle n × Cycle* n)
findCycle i [] = nothing
findCycle i (c ∷ cs) with toℕ i ≟ toℕ (head c)
findCycle i (c ∷ cs) | yes _ = just (c , cs)
findCycle i (c ∷ cs) | no _ =
maybe′ (λ { (c' , cs') → just (c' , c ∷ cs') }) nothing (findCycle i cs)
-- Another helper that repeatedly tries to merge smaller cycles
{-# NO_TERMINATION_CHECK #-}
mergeCycles : ∀ {n} → Cycle* n → Cycle* n
mergeCycles [] = []
mergeCycles (c ∷ cs) with findCycle (last c) cs
mergeCycles (c ∷ cs) | nothing = c ∷ mergeCycles cs
mergeCycles (c ∷ cs) | just (c' , cs') = mergeCycles ((c ⁺++ ntail c') ∷ cs')
-- To convert a Cauchy representation to a product of cycles, just create
-- a cycle of size 2 for each entry and then merge the cycles
cauchy→cycle* : ∀ {n} → Cauchy n → Cycle* n
cauchy→cycle* {n} perm =
mergeCycles (toList (zipWith (λ i j → i ∷⁺ [ j ]) (allFin n) perm))
cauchyEx1→transposition* cauchyEx2→transposition* : List String
cauchyEx1→transposition* =
showTransposition* (cycle*→transposition* (cauchy→cycle* cauchyEx1))
-- 0 X 2 ∷ 0 X 4 ∷ 0 X 1 ∷ 0 X 0 ∷ 3 X 3 ∷ 5 X 5 ∷ []
-- actionπ (cycle*→transposition* (cauchy→cycle* cauchyEx1))
-- (0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ [])
-- 1 ∷ 4 ∷ 0 ∷ 3 ∷ 2 ∷ 5 ∷ []
cauchyEx2→transposition* =
showTransposition* (cycle*→transposition* (cauchy→cycle* cauchyEx2))
-- 0 X 3 ∷ 0 X 0 ∷ 1 X 2 ∷ 1 X 1 ∷ 4 X 5 ∷ 4 X 4 ∷ []
-- actionπ (cycle*→transposition* (cauchy→cycle* cauchyEx2))
-- (0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ [])
-- 3 ∷ 2 ∷ 1 ∷ 0 ∷ 5 ∷ 4 ∷ []
-- Cauchy to product of transpostions
cauchy→transposition* : ∀ {n} → Cauchy n → Transposition* n
cauchy→transposition* = cycle*→transposition* ∘ cauchy→cycle*
-- Ex:
swap+π : (m n : ℕ) → Transposition* (m + n)
swap+π m n = cauchy→transposition* (swap+cauchy m n)
swap11 swap21 swap32 : List String
swap11 = showTransposition* (swap+π 1 1)
-- 0 X 1 ∷ 0 X 0 ∷ []
-- actionπ (swap+π 1 1) ("a" ∷ "b" ∷ [])
-- "b" ∷ "a" ∷ []
swap21 = showTransposition* (swap+π 2 1)
-- 0 X 1 ∷ 0 X 2 ∷ 0 X 0 ∷ []
-- actionπ (swap+π 2 1) ("a" ∷ "b" ∷ "c" ∷ [])
-- "c" ∷ "a" ∷ "b" ∷ []
swap32 = showTransposition* (swap+π 3 2)
-- 0 X 2 ∷ 0 X 4 ∷ 0 X 1 ∷ 0 X 3 ∷ 0 X 0 ∷ []
-- actionπ (swap+π 3 2) ("a" ∷ "b" ∷ "c" ∷ "d" ∷ "e" ∷ [])
-- "d" ∷ "e" ∷ "a" ∷ "b" ∷ "c" ∷ []
-- Ex:
pcompπ : ∀ {m n} → Cauchy m → Cauchy n → Transposition* (m + n)
pcompπ α β = cauchy→transposition* (pcompcauchy α β)
swap11+21 swap21+11 : List String
swap11+21 = showTransposition* (pcompπ (swap+cauchy 1 1) (swap+cauchy 2 1))
-- 0 X 1 ∷ 0 X 0 ∷ 2 X 3 ∷ 2 X 4 ∷ 2 X 2 ∷ []
-- actionπ (pcompπ (swap+cauchy 1 1) (swap+cauchy 2 1))
-- ("a" ∷ "b" ∷ "1" ∷ "2" ∷ "3" ∷ [])
-- "b" ∷ "a" ∷ "3" ∷ "1" ∷ "2" ∷ []
swap21+11 = showTransposition* (pcompπ (swap+cauchy 2 1) (swap+cauchy 1 1))
-- 0 X 1 ∷ 0 X 2 ∷ 0 X 0 ∷ 3 X 4 ∷ 3 X 3 ∷ []
-- actionπ (pcompπ (swap+cauchy 2 1) (swap+cauchy 1 1))
-- ("1" ∷ "2" ∷ "3" ∷ "a" ∷ "b" ∷ [])
-- "3" ∷ "1" ∷ "2" ∷ "b" ∷ "a" ∷ []
-- Ex:
tcompπ : ∀ {m n} → Cauchy m → Cauchy n → Transposition* (m * n)
tcompπ α β = cauchy→transposition* (tcompcauchy α β)
swap21*swap11 : List String
swap21*swap11 = showTransposition* (tcompπ (swap+cauchy 2 1) (swap+cauchy 1 1))
-- 0 X 3 ∷ 0 X 4 ∷ 0 X 1 ∷ 0 X 2 ∷ 0 X 5 ∷ 0 X 0 ∷ []
-- Recall (swap+π 2 1)
-- 0 X 1 ∷ 0 X 2 ∷ 0 X 0 ∷ []
-- actionπ (swap+π 2 1) ("a" ∷ "b" ∷ "c" ∷ [])
-- "c" ∷ "a" ∷ "b" ∷ []
-- Recall (swap+π 1 1)
-- 0 X 1 ∷ 0 X 0 ∷ []
-- actionπ (swap+π 1 1) ("1" ∷ "2" ∷ [])
-- "2" ∷ "1" ∷ []
-- Tensor tensorvs
-- ("a" , "1") ∷ ("a" , "2") ∷
-- ("b" , "1") ∷ ("b" , "2") ∷
-- ("c" , "1") ∷ ("c" , "2") ∷ []
-- actionπ (tcompπ (swap+cauchy 2 1) (swap+cauchy 1 1)) tensorvs
-- ("c" , "2") ∷ ("c" , "1") ∷
-- ("a" , "2") ∷ ("a" , "1") ∷
-- ("b" , "2") ∷ ("b" , "1") ∷ []
-- Ex:
swap⋆π : (m n : ℕ) → Transposition* (m * n)
swap⋆π m n = cauchy→transposition* (swap⋆cauchy m n)
swap3x2→2x3 : List String
swap3x2→2x3 = showTransposition* (swap⋆π 3 2)
-- 0 X 0 ∷ 1 X 3 ∷ 1 X 4 ∷ 1 X 2 ∷ 1 X 1 ∷ 5 X 5 ∷ []
-- Let vs3x2 =
-- ("a" , 1) ∷ ("a" , 2) ∷
-- ("b" , 1) ∷ ("b" , 2) ∷
-- ("c" , 1) ∷ ("c" , 2) ∷ []
-- actionπ (swap⋆π 3 2) vs3x2
-- ("a" , 1) ∷ ("b" , 1) ∷ ("c" , 1) ∷
-- ("a" , 2) ∷ ("b" , 2) ∷ ("c" , 2) ∷ []
c2π : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → Transposition* (size t₁)
c2π = cauchy→transposition* ∘ c2cauchy
-- Convenient way of seeing c : t₁ ⟷ t₂ as a permutation
showπ : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → Vec (⟦ t₁ ⟧ × ⟦ t₂ ⟧) (size t₁)
showπ {t₁} {t₂} c =
let vs₁ = utoVec t₁
vs₂ = utoVec t₂
in zip (actionπ (c2π c) vs₁) (subst (Vec ⟦ t₂ ⟧) (sym (size≡ c)) vs₂)
-- Examples
NEG1π NEG2π NEG3π NEG4π NEG5π : Vec (⟦ BOOL ⟧ × ⟦ BOOL ⟧) 2
NEG1π = showπ NEG1
-- (true , false) ∷ (false , true) ∷ []
NEG2π = showπ NEG2
-- (true , false) ∷ (false , true) ∷ []
NEG3π = showπ NEG3
-- (true , false) ∷ (false , true) ∷ []
NEG4π = showπ NEG4
-- (true , false) ∷ (false , true) ∷ []
NEG5π = showπ NEG5
-- (true , false) ∷ (false , true) ∷ []
cnotπ : Vec (⟦ BOOL² ⟧ × ⟦ BOOL² ⟧) 4
cnotπ = showπ {BOOL²} {BOOL²} CNOT
-- ((false , false) , (false , false)) ∷
-- ((false , true) , (false , true)) ∷
-- ((true , true) , (true , false)) ∷
-- ((true , false) , (true , true)) ∷ []
toffoliπ : Vec (⟦ TIMES BOOL BOOL² ⟧ × ⟦ TIMES BOOL BOOL² ⟧) 8
toffoliπ = showπ {TIMES BOOL BOOL²} {TIMES BOOL BOOL²} TOFFOLI
-- ((false , false , false) , (false , false , false)) ∷
-- ((false , false , true) , (false , false , true)) ∷
-- ((false , true , false) , (false , true , false)) ∷
-- ((false , true , true) , (false , true , true)) ∷
-- ((true , false , false) , (true , false , false) ∷
-- ((true , false , true) , (true , false , true)) ∷
-- ((true , true , true) , (true , true , false)) ∷
-- ((true , true , false) , (true , true , true)) ∷ []
-- The elements of PLUS ONE (PLUS ONE ONE) in canonical order are:
-- inj₁ tt
-- inj₂ (inj₁ tt)
-- inj₂ (inj₂ tt)
id3π swap12π swap23π swap13π rotlπ rotrπ :
Vec (⟦ PLUS ONE (PLUS ONE ONE) ⟧ × ⟦ PLUS ONE (PLUS ONE ONE) ⟧) 3
id3π = showπ {PLUS ONE (PLUS ONE ONE)} {PLUS ONE (PLUS ONE ONE)} id⟷
-- (inj₁ tt , inj₁ tt) ∷
-- (inj₂ (inj₁ tt) , inj₂ (inj₁ tt)) ∷
-- (inj₂ (inj₂ tt) , inj₂ (inj₂ tt)) ∷ []
swap12π = showπ {PLUS ONE (PLUS ONE ONE)} {PLUS ONE (PLUS ONE ONE)} SWAP12
-- (inj₂ (inj₁ tt) , inj₁ tt) ∷
-- (inj₁ tt , inj₂ (inj₁ tt)) ∷
-- (inj₂ (inj₂ tt) , inj₂ (inj₂ tt)) ∷ []
swap23π = showπ {PLUS ONE (PLUS ONE ONE)} {PLUS ONE (PLUS ONE ONE)} SWAP23
-- (inj₁ tt , inj₁ tt) ∷
-- (inj₂ (inj₂ tt) , inj₂ (inj₁ tt)) ∷
-- (inj₂ (inj₁ tt) , inj₂ (inj₂ tt)) ∷ []
swap13π = showπ {PLUS ONE (PLUS ONE ONE)} {PLUS ONE (PLUS ONE ONE)} SWAP13
-- (inj₂ (inj₂ tt) , inj₁ tt) ∷
-- (inj₂ (inj₁ tt) , inj₂ (inj₁ tt)) ∷
-- (inj₁ tt , inj₂ (inj₂ tt)) ∷ []
rotrπ = showπ {PLUS ONE (PLUS ONE ONE)} {PLUS ONE (PLUS ONE ONE)} ROTR
-- (inj₂ (inj₁ tt) , inj₁ tt) ∷
-- (inj₂ (inj₂ tt) , inj₂ (inj₁ tt)) ∷
-- (inj₁ tt , inj₂ (inj₂ tt)) ∷ []
rotlπ = showπ {PLUS ONE (PLUS ONE ONE)} {PLUS ONE (PLUS ONE ONE)} ROTL
-- (inj₂ (inj₂ tt) , inj₁ tt) ∷
-- (inj₁ tt , inj₂ (inj₁ tt)) ∷
-- (inj₂ (inj₁ tt) , inj₂ (inj₂ tt)) ∷ []
peresπ : Vec (((Bool × Bool) × Bool) × ((Bool × Bool) × Bool)) 8
peresπ = showπ PERES
-- (((false , false) , false) , (false , false) , false) ∷
-- (((false , false) , true) , (false , false) , true) ∷
-- (((false , true) , false) , (false , true) , false) ∷
-- (((false , true) , true) , (false , true) , true) ∷
-- (((true , true) , true) , (true , false) , false) ∷
-- (((true , true) , false) , (true , false) , true) ∷
-- (((true , false) , false) , (true , true) , false) ∷
-- (((true , false) , true) , (true , true) , true) ∷ []
fulladderπ :
Vec ((Bool × ((Bool × Bool) × Bool)) × (Bool × (Bool × (Bool × Bool)))) 16
fulladderπ = showπ FULLADDER
-- ((false , (false , false) , false) , false , false , false , false) ∷
-- ((true , (false , false) , false) , false , false , false , true) ∷
-- ((false , (false , false) , true) , false , false , true , false) ∷
-- ((true , (false , false) , true) , false , false , true , true) ∷
-- ((false , (false , true) , false) , false , true , true , false) ∷
-- ((false , (false , true) , true) , false , true , false , true) ∷
-- ((true , (false , true) , true) , false , true , false , false) ∷
-- ((true , (false , true) , false) , false , true , true , true) ∷
-- ((true , (true , true) , false) , true , false , false , false) ∷
-- ((false , (true , true) , false) , true , false , false , true) ∷
-- ((true , (true , true) , true) , true , false , true , false) ∷
-- ((false , (true , true) , true) , true , false , true , true) ∷
-- ((true , (true , false) , true) , true , true , false , false) ∷
-- ((false , (true , false) , true) , true , true , false , true) ∷
-- ((false , (true , false) , false) , true , true , true , false) ∷
-- ((true , (true , false) , false) , true , true , true , true) ∷ []
-- which agrees with spec.
------------------------------------------------------------------------------
-- Normalization
-- We sort the list of transpositions using a variation of bubble
-- sort. Like in the conventional bubble sort we look at pairs of
-- transpositions and swap them if they are out of order but if we
-- encounter (i X j) followed by (i X j) we remove both.
-- one pass of bubble sort
-- goal is to reach a sorted sequene with no repeats in the first position
-- Ex: (0 X 2) ∷ (3 X 4) ∷ (4 X 6) ∷ (5 X 6)
-- There is probably lots of room for improvement. Here is the idea.
-- We take a list of transpositions (a_i X b_i) where a_i < b_i and keep
-- looking at adjacent pairs doing the following transformations:
--
-- A. (a X b) (a X b) => id
-- B. (a X b) (c X d) => (c X d) (a X b) if c < a
-- C. (a X b) (c X b) => (c X a) (a X b) if c < a
-- D. (a X b) (c X a) => (c X b) (a X b)
-- E. (a X b) (a X d) => (a X d) (b X d) if b < d
-- F. (a X b) (a X d) => (a X d) (d X b) if d < b
--
-- The point is that we get closer and closer to the following
-- invariant. For any two adjacent transpositions (a X b) (c X d) we have
-- that a < c. Transformations B, C, and D rewrite anything in which a > c.
-- Transformations A, E, and F rewrite anything in which a = c. Termination
-- is subtle clearly.
--
-- New strategy to implement: So could we index things so that a first set of
-- (up to) n passes 'bubble down' (0 X a) until there is only one left at the
-- root, then recurse on the tail to 'bubble down' (1 X b)'s [if any]? That
-- would certainly ensure termination.
{-# NO_TERMINATION_CHECK #-}
bubble : ∀ {n} → Transposition<* n → Transposition<* n
bubble [] = []
bubble (x ∷ []) = x ∷ []
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
--
-- check every possible equality between the indices
--
with toℕ i ≟ toℕ k | toℕ i ≟ toℕ l | toℕ j ≟ toℕ k | toℕ j ≟ toℕ l
--
-- get rid of a bunch of impossible cases given that i < j and k < l
--
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| _ | _ | yes j≡k | yes j≡l
with trans (sym j≡k) (j≡l) | i<j→i≠j {toℕ k} {toℕ l} k<l
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| _ | _ | yes j≡k | yes j≡l
| k≡l | ¬k≡l with ¬k≡l k≡l
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| _ | _ | yes j≡k | yes j≡l
| k≡l | ¬k≡l | ()
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| _ | yes i≡l | _ | yes j≡l
with trans i≡l (sym j≡l) | i<j→i≠j {toℕ i} {toℕ j} i<j
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| _ | yes i≡l | _ | yes j≡l
| i≡j | ¬i≡j with ¬i≡j i≡j
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| _ | yes i≡l | _ | yes j≡l
| i≡j | ¬i≡j | ()
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| yes i≡k | _ | yes j≡k | _
with trans i≡k (sym j≡k) | i<j→i≠j {toℕ i} {toℕ j} i<j
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| yes i≡k | _ | yes j≡k | _
| i≡j | ¬i≡j with ¬i≡j i≡j
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| yes i≡k | _ | yes j≡k | _
| i≡j | ¬i≡j | ()
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| yes i≡k | yes i≡l | _ | _
with trans (sym i≡k) i≡l | i<j→i≠j {toℕ k} {toℕ l} k<l
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| yes i≡k | yes i≡l | _ | _
| k≡l | ¬k≡l with ¬k≡l k≡l
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| yes i≡k | yes i≡l | _ | _
| k≡l | ¬k≡l | ()
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| _ | yes i≡l | yes j≡k | _
with subst₂ _<_ (sym j≡k) (sym i≡l) k<l | i<j→j≮i {toℕ i} {toℕ j} i<j
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| _ | yes i≡l | yes j≡k | _
| j<i | j≮i with j≮i j<i
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| _ | yes i≡l | yes j≡k | _
| j<i | j≮i | ()
--
-- end of impossible cases
--
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| no ¬i≡k | no ¬i≡l | no ¬j≡k | no ¬j≡l with toℕ i <? toℕ k
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| no ¬i≡k | no ¬i≡l | no ¬j≡k | no ¬j≡l | yes i<k =
-- already sorted; no repeat in first position; skip and recur
-- Ex: 2 X! 5 , 3 X! 4
_X!_ i j {i<j} ∷ bubble (_X!_ k l {k<l} ∷ π)
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| no ¬i≡k | no ¬i≡l | no ¬j≡k | no ¬j≡l | no i≮k =
-- Case B.
-- not sorted; no repeat in first position; no interference
-- just slide one transposition past the other
-- Ex: 2 X! 5 , 1 X! 4
-- becomes 1 X! 4 , 2 X! 5
_X!_ k l {k<l} ∷ bubble (_X!_ i j {i<j} ∷ π)
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| yes i≡k | no ¬i≡l | no ¬j≡k | yes j≡l =
-- Case A.
-- transposition followed by its inverse; simplify by removing both
-- Ex: 2 X! 5 , 2 X! 5
-- becomes id and is deleted
bubble π
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| no ¬i≡k | no ¬i≡l | no ¬j≡k | yes j≡l with toℕ i <? toℕ k
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| no ¬i≡k | no ¬i≡l | no ¬j≡k | yes j≡l | yes i<k =
-- already sorted; no repeat in first position; skip and recur
-- Ex: 2 X! 5 , 3 X! 5
_X!_ i j {i<j} ∷ bubble (_X!_ k l {k<l} ∷ π)
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| no ¬i≡k | no ¬i≡l | no ¬j≡k | yes j≡l | no i≮k =
_X!_ k i
{i≰j∧j≠i→j<i (toℕ i) (toℕ k) (i≮j∧i≠j→i≰j (toℕ i) (toℕ k) i≮k ¬i≡k)
(i≠j→j≠i (toℕ i) (toℕ k) ¬i≡k)} ∷
bubble (_X!_ i j {i<j} ∷ π)
-- Case C.
-- Ex: 2 X! 5 , 1 X! 5
-- becomes 1 X! 2 , 2 X! 5
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| no ¬i≡k | no ¬i≡l | yes j≡k | no ¬j≡l =
-- already sorted; no repeat in first position; skip and recur
-- Ex: 2 X! 5 , 5 X! 6
_X!_ i j {i<j} ∷ bubble (_X!_ k l {k<l} ∷ π)
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| no ¬i≡k | yes i≡l | no ¬j≡k | no ¬j≡l =
-- Case D.
-- Ex: 2 X! 5 , 1 X! 2
-- becomes 1 X! 5 , 2 X! 5
_X!_ k j {trans< (subst ((λ l → toℕ k < l)) (sym i≡l) k<l) i<j} ∷
bubble (_X!_ i j {i<j} ∷ π)
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| yes i≡k | no ¬i≡l | no ¬j≡k | no ¬j≡l with toℕ j <? toℕ l
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| yes i≡k | no ¬i≡l | no ¬j≡k | no ¬j≡l | yes j<l =
-- Case E.
-- Ex: 2 X! 5 , 2 X! 6
-- becomes 2 X! 6 , 5 X! 6
_X!_ k l {k<l} ∷ bubble (_X!_ j l {j<l} ∷ π)
bubble (_X!_ i j {i<j} ∷ _X!_ k l {k<l} ∷ π)
| yes i≡k | no ¬i≡l | no ¬j≡k | no ¬j≡l | no j≮l =
-- Case F.
-- Ex: 2 X! 5 , 2 X! 3
-- becomes 2 X! 3 , 3 X! 5
_X!_ k l {k<l} ∷
bubble (_X!_ l j {i≰j∧j≠i→j<i (toℕ j) (toℕ l)
(i≮j∧i≠j→i≰j (toℕ j) (toℕ l) j≮l ¬j≡l)
(i≠j→j≠i (toℕ j) (toℕ l) ¬j≡l)} ∷ π)
-- sorted and no repeats in first position
{-# NO_TERMINATION_CHECK #-}
canonical? : ∀ {n} → Transposition<* n → Bool
canonical? [] = true
canonical? (x ∷ []) = true
canonical? (i X! j ∷ k X! l ∷ π) with toℕ i <? toℕ k
canonical? (i X! j ∷ _X!_ k l {k<l} ∷ π) | yes i<k =
canonical? (_X!_ k l {k<l} ∷ π)
canonical? (i X! j ∷ _X!_ k l {k<l} ∷ π) | no i≮k = false
{-# NO_TERMINATION_CHECK #-}
sort : ∀ {n} → Transposition<* n → Transposition<* n
sort π with canonical? π
sort π | true = π
sort π | false = sort (bubble π)
-- Examples
snn₁ snn₂ snn₃ snn₄ snn₅ : List String
snn₁ = showTransposition<* (sort (filter= (c2π NEG1)))
-- 0 X! 1 ∷ []
snn₂ = showTransposition<* (sort (filter= (c2π NEG2)))
-- 0 X! 1 ∷ []
snn₃ = showTransposition<* (sort (filter= (c2π NEG3)))
-- 0 X! 1 ∷ []
snn₄ = showTransposition<* (sort (filter= (c2π NEG4)))
-- 0 X! 1 ∷ []
snn₅ = showTransposition<* (sort (filter= (c2π NEG5)))
-- 0 X! 1 ∷ []
sncnot sntoffoli : List String
sncnot = showTransposition<* (sort (filter= (c2π CNOT)))
-- 2 X! 3 ∷ []
sntoffoli = showTransposition<* (sort (filter= (c2π TOFFOLI)))
-- 6 X! 7 ∷ []
snswap12 snswap23 snswap13 snrotl snrotr : List String
snswap12 = showTransposition<* (sort (filter= (c2π SWAP12)))
-- 0 X! 1 ∷ []
snswap23 = showTransposition<* (sort (filter= (c2π SWAP23)))
-- 1 X! 2 ∷ []
snswap13 = showTransposition<* (sort (filter= (c2π SWAP13)))
-- 0 X! 2 ∷ []
snrotl = showTransposition<* (sort (filter= (c2π ROTL)))
-- 0 X! 2 ∷ 1 X! 2 ∷ []
snrotr = showTransposition<* (sort (filter= (c2π ROTR)))
-- 0 X! 1 ∷ 1 X! 2 ∷ []
snperes snfulladder : List String
snperes = showTransposition<* (sort (filter= (c2π PERES)))
-- 4 X! 7 ∷ 5 X! 6 ∷ 6 X! 7 ∷ []
snfulladder = showTransposition<* (sort (filter= (c2π FULLADDER)))
-- ?
-- Normalization
normalizeπ : {t₁ t₂ : U} → (c : t₁ ⟷ t₂) → Transposition<* (size t₁)
normalizeπ = sort ∘ filter= ∘ c2π
--}
-- Courtesy of Wolfram Kahl, a dependent cong₂
cong₂D : {a b c : Level} {A : Set a} {B : A → Set b} {C : Set c}
(f : (x : A) → B x → C)
→ {x₁ x₂ : A} {y₁ : B x₁} {y₂ : B x₂}
→ (x₁≡x₂ : x₁ ≡ x₂) → y₁ ≡ subst B (sym x₁≡x₂) y₂ → f x₁ y₁ ≡ f x₂ y₂
cong₂D f refl refl = refl
congD : {a b : Level} {A : Set a} {B : A → Set b}
(f : (x : A) → B x) → {x₁ x₂ : A} → (x₁≡x₂ : x₁ ≡ x₂) →
subst B (sym x₁≡x₂) (f x₂) ≡ f x₁
congD f refl = refl
{--
-- even more useful is something which captures the equalities
-- inherent in a combinator
-- note that the code below "hand inlines" most of size≡,
-- mainly for greater convenience
adjustBy : {t₁ t₂ : U} {P : ℕ → Set} → (c : t₁ ⟷ t₂) → (P (size t₁) → P (size t₂))
adjustBy {P = P} (c₀ ◎ c₁) p = subst P (size≡ c₁) (subst P (size≡ c₀) p)
adjustBy {PLUS t₁ t₂} {PLUS t₃ t₄} {P} (c₀ ⊕ c₁) p =
subst P (cong₂ _+_ (size≡ c₀) (refl)) (subst P (cong₂ _+_ {size t₁} (refl) (size≡ c₁)) p)
adjustBy (c₀ ⊗ c₁) p = {!!}
adjustBy unite₊ p = p
adjustBy uniti₊ p = p
adjustBy {PLUS t₁ t₂} {PLUS .t₂ .t₁} {P} swap₊ p =
subst P (+-comm (size t₁) (size t₂) ) p
adjustBy assocl₊ p = {!!}
adjustBy assocr₊ p = {!!}
adjustBy unite⋆ p = {!!}
adjustBy uniti⋆ p = {!!}
adjustBy swap⋆ p = {!!}
adjustBy assocl⋆ p = {!!}
adjustBy assocr⋆ p = {!!}
adjustBy distz p = {!!}
adjustBy factorz p = {!!}
adjustBy dist p = {!!}
adjustBy factor p = {!!}
adjustBy id⟷ p = p
adjustBy foldBool p = p
adjustBy unfoldBool p = p
--}
{--
OLD definition
swap+cauchy' : (m n : ℕ) → Cauchy (m + n)
swap+cauchy' m n with splitAt n (allFin (n + m))
... | (zeron , (nsum , _)) =
(subst (λ s → Vec (Fin s) m) (+-comm n m) nsum) ++V
(subst (λ s → Vec (Fin s) n) (+-comm n m) zeron)
--}
{--
-- Proofs about proofs. Should be elsewhere
sym-sym : {A : Set} {x y : A} → (p : x ≡ y) → sym (sym p) ≡ p
sym-sym refl = refl
trans-refl : {A : Set} {x y : A} → (p : x ≡ y) → trans p refl ≡ p
trans-refl refl = refl
-- Proof about natural numbers proof
sym-comm : ∀ (m n : ℕ) → sym (+-comm m n) ≡ +-comm n m
sym-comm 0 0 = refl
sym-comm 0 (suc n) =
begin (sym (sym (cong suc $ +-right-identity n))
≡⟨ sym-sym (cong suc (+-right-identity n)) ⟩
cong suc (+-right-identity n)
≡⟨ cong
(cong suc)
(trans (sym (sym-sym (+-right-identity n))) (sym-comm 0 n)) ⟩
cong suc (+-comm n 0)
≡⟨ sym (trans-refl (cong suc (+-comm n 0))) ⟩
trans (cong suc (+-comm n 0)) (sym (+-suc 0 n)) ∎)
where open ≡-Reasoning
sym-comm (suc m) 0 = {!!}
sym-comm (suc m) (suc n) = {!!}
--}
{--
these are all true, but not actually used! And they cause termination
issues in my older Agda, so I'll just comment them out for now. JC
i≰j→j≤i : (i j : ℕ) → (i ≰ j) → (j ≤ i)
i≰j→j≤i i 0 p = z≤n
i≰j→j≤i 0 (suc j) p with p z≤n
i≰j→j≤i 0 (suc j) p | ()
i≰j→j≤i (suc i) (suc j) p with i ≤? j
i≰j→j≤i (suc i) (suc j) p | yes p' with p (s≤s p')
i≰j→j≤i (suc i) (suc j) p | yes p' | ()
i≰j→j≤i (suc i) (suc j) p | no p' = s≤s (i≰j→j≤i i j p')
i≠j∧i≤j→i<j : (i j : ℕ) → (¬ i ≡ j) → (i ≤ j) → (i < j)
i≠j∧i≤j→i<j 0 0 p≠ p≤ with p≠ refl
i≠j∧i≤j→i<j 0 0 p≠ p≤ | ()
i≠j∧i≤j→i<j 0 (suc j) p≠ p≤ = s≤s z≤n
i≠j∧i≤j→i<j (suc i) 0 p≠ ()
i≠j∧i≤j→i<j (suc i) (suc j) p≠ (s≤s p≤) with i ≟ j
i≠j∧i≤j→i<j (suc i) (suc j) p≠ (s≤s p≤) | yes p' with p≠ (cong suc p')
i≠j∧i≤j→i<j (suc i) (suc j) p≠ (s≤s p≤) | yes p' | ()
i≠j∧i≤j→i<j (suc i) (suc j) p≠ (s≤s p≤) | no p' = s≤s (i≠j∧i≤j→i<j i j p' p≤)
i<j→i≠j : {i j : ℕ} → (i < j) → (¬ i ≡ j)
i<j→i≠j {0} (s≤s p) ()
i<j→i≠j {suc i} (s≤s p) refl = i<j→i≠j {i} p refl
i<j→j≮i : {i j : ℕ} → (i < j) → (j ≮ i)
i<j→j≮i {0} (s≤s p) ()
i<j→j≮i {suc i} (s≤s p) (s≤s q) = i<j→j≮i {i} p q
i≰j∧j≠i→j<i : (i j : ℕ) → (i ≰ j) → (¬ j ≡ i) → j < i
i≰j∧j≠i→j<i i j i≰j ¬j≡i = i≠j∧i≤j→i<j j i ¬j≡i (i≰j→j≤i i j i≰j)
i≠j→j≠i : (i j : ℕ) → (¬ i ≡ j) → (¬ j ≡ i)
i≠j→j≠i i j i≠j j≡i = i≠j (sym j≡i)
si≠sj→i≠j : (i j : ℕ) → (¬ Data.Nat.suc i ≡ Data.Nat.suc j) → (¬ i ≡ j)
si≠sj→i≠j i j ¬si≡sj i≡j = ¬si≡sj (cong suc i≡j)
si≮sj→i≮j : (i j : ℕ) → (¬ Data.Nat.suc i < Data.Nat.suc j) → (¬ i < j)
si≮sj→i≮j i j si≮sj i<j = si≮sj (s≤s i<j)
i≮j∧i≠j→i≰j : (i j : ℕ) → (i ≮ j) → (¬ i ≡ j) → (i ≰ j)
i≮j∧i≠j→i≰j 0 0 i≮j ¬i≡j i≤j = ¬i≡j refl
i≮j∧i≠j→i≰j 0 (suc j) i≮j ¬i≡j i≤j = i≮j (s≤s z≤n)
i≮j∧i≠j→i≰j (suc i) 0 i≮j ¬i≡j ()
i≮j∧i≠j→i≰j (suc i) (suc j) si≮sj ¬si≡sj (s≤s i≤j) =
i≮j∧i≠j→i≰j i j (si≮sj→i≮j i j si≮sj) (si≠sj→i≠j i j ¬si≡sj) i≤j
-}
-- this is a non-dependently typed version of tensor product of vectors.
tensorvec : ∀ {m n} {A B C : Set} →
(A → B → C) → Vec A m → Vec B n → Vec C (m * n)
tensorvec {0} _ [] _ = []
tensorvec {suc m} {n} {C = C} f (x ∷ α) β =
subst
(λ i → Vec C (n + m * n))
(+-*-suc m n)
(mapV (f x) β ++V tensorvec f α β)
-- this is a better template
tensorvec' : ∀ {A B C : ℕ → Set} → (∀ {m n} → A m → B n → C (m * n)) →
(∀ {m} → (n : ℕ) → C m → C (n + m)) →
∀ {m n j} → Vec (A m) j → Vec (B n) n → Vec (C (m * n)) (j * n)
tensorvec' _ _ {j = 0} [] _ = []
tensorvec' {A} {B} {C} f shift {m} {n} {suc j} (x ∷ α) β =
subst
(λ i → Vec (C (m * n)) (n + j * n))
(+-*-suc j n)
(mapV (f x) β ++V (tensorvec' {A} {B} {C} f shift α β))
-- raise d by b*n and inject in m*n
raise∘inject : ∀ {m n} → (b : Fin m) (d : Fin n) → Fin (m * n)
raise∘inject {0} {n} () d
raise∘inject {suc m} {n} b d =
inject≤ (raise (toℕ b * n) d) (i*n+n≤sucm*n {m} {n} b)
tcompcauchy' : ∀ {i m n} → Vec (Fin m) i → Cauchy n → Vec (Fin (m * n)) (i * n)
tcompcauchy' {0} {m} {n} [] β = []
tcompcauchy' {suc i} {m} {n} (b ∷ α) β =
mapV (raise∘inject {m} {n} b) β ++V tcompcauchy' {i} {m} {n} α β
tcompcauchy2 : ∀ {m n} → Cauchy m → Cauchy n → Cauchy (m * n)
tcompcauchy2 = tcompcauchy'
leq-lem-0 : (m n : ℕ) → suc n ≤ n + suc m
leq-lem-0 m n =
begin (suc n
≤⟨ m≤m+n (suc n) m ⟩
suc (n + m)
≡⟨ cong suc (+-comm n m) ⟩
suc m + n
≡⟨ +-comm (suc m) n ⟩
n + suc m ∎)
where open ≤-Reasoning
leq-lem-1 : (n : ℕ) → suc ((n + 0) + 0) ≤ n + suc (suc (n + 0))
leq-lem-1 n =
begin (suc ((n + 0) + 0)
≡⟨ cong suc (+-right-identity (n + 0)) ⟩
suc (n + 0)
≡⟨ cong suc (+-right-identity n) ⟩
suc n
≤⟨ n≤1+n (suc n) ⟩
suc (suc n)
≤⟨ n≤m+n n (suc (suc n)) ⟩
n + suc (suc n)
≡⟨ cong (λ x → n + suc (suc x)) (sym (+-right-identity n)) ⟩
n + suc (suc (n + 0)) ∎)
where open ≤-Reasoning
simplify-≤ : {m n m' n' : ℕ} →
(m ≤ n) → (m ≡ m') → (n ≡ n') → (m' ≤ n')
simplify-≤ leq refl refl = leq
raise-lem-0 : (m n : ℕ) → (leq : suc n ≤ n + suc m) →
raise n zero ≡ inject≤ (fromℕ n) leq
raise-lem-0 m 0 (s≤s leq) = refl
raise-lem-0 m (suc n) (s≤s leq) = cong suc (raise-lem-0 m n leq)
simplify-≤ : {m n m' n' : ℕ} →
(m ≤ n) → (m ≡ m') → (n ≡ n') → (m' ≤ n')
simplify-≤ leq refl refl = leq
inject≤-≡ : ∀ {m m' n : ℕ} → (i : Fin m) → (leq : m ≤ n) → (eqm : m ≡ m') →
inject≤ {m} {n} i leq ≡
inject≤ {m'} {n} (subst Fin eqm i) (subst (λ x → x ≤ n) eqm leq)
inject≤-≡ i leq refl = refl
leq-Fin : (n m : ℕ) → (j : Fin (suc n)) → toℕ j ≤ n + m
leq-Fin 0 m zero = z≤n
leq-Fin 0 m (suc ())
leq-Fin (suc n) m zero = z≤n
leq-Fin (suc n) m (suc j) = s≤s (leq-Fin n m j)
leq-lem-1 : (m n : ℕ) → (j : Fin (suc m)) → (d : Fin (suc n)) →
suc (toℕ j * suc n + toℕ d) ≤ suc m * suc n
leq-lem-1 0 0 zero zero = s≤s z≤n
leq-lem-1 0 0 zero (suc ())
leq-lem-1 0 0 (suc ()) zero
leq-lem-1 0 0 (suc () ) _
leq-lem-1 0 (suc n) zero zero = s≤s z≤n
leq-lem-1 0 (suc n) zero (suc d) = s≤s (s≤s (leq-Fin n 0 d))
leq-lem-1 0 (suc n) (suc ()) _
leq-lem-1 (suc m) 0 zero zero = s≤s z≤n
leq-lem-1 (suc m) 0 zero (suc ())
leq-lem-1 (suc m) 0 (suc j) zero = s≤s (leq-lem-1 m 0 j zero)
leq-lem-1 (suc m) 0 (suc j) (suc ())
leq-lem-1 (suc m) (suc n) zero zero = s≤s z≤n
leq-lem-1 (suc m) (suc n) zero (suc d) =
s≤s (s≤s (leq-Fin n (suc m * suc (suc n)) d))
leq-lem-1 (suc m) (suc n) (suc j) d = s≤s (s≤s pr)
where
pr = begin (suc ((n + toℕ j * suc (suc n)) + toℕ d)
≡⟨ sym (+-suc (n + toℕ j * suc (suc n)) (toℕ d)) ⟩
(n + toℕ j * suc (suc n)) + suc (toℕ d)
≤⟨ cong+l≤
(bounded d)
(n + toℕ j * suc (suc n)) ⟩
(n + toℕ j * suc (suc n)) + suc (suc n)
≤⟨ cong+r≤
(cong+l≤
(cong*r≤ (bounded' m j) (suc (suc n)))
n)
(suc (suc n)) ⟩
(n + m * suc (suc n)) + suc (suc n)
≡⟨ +-assoc n (m * suc (suc n)) (suc (suc n)) ⟩
n + (m * suc (suc n) + suc (suc n))
≡⟨ cong
(λ x → n + x)
(+-comm (m * suc (suc n)) (suc (suc n))) ⟩
n + (suc (suc n) + m * suc (suc n))
≡⟨ refl ⟩
n + suc m * suc (suc n) ∎)
where open ≤-Reasoning
leq-lem-2 : (m n : ℕ) → (j : Fin (suc m)) → (d : Fin (suc n)) →
suc (suc (toℕ j) * suc n + toℕ d) ≤ suc (suc m) * suc n
leq-lem-2 m n j d =
begin (suc (suc (toℕ j) * suc n + toℕ d)
≤⟨ s≤s (cong+l≤ (bounded' n d) (suc (toℕ j) * suc n)) ⟩
suc (suc (toℕ j) * suc n + n)
≡⟨ sym (+-suc (suc (toℕ j) * suc n) n) ⟩
suc (toℕ j) * suc n + suc n
≡⟨ +-comm (suc (toℕ j) * suc n) (suc n) ⟩
suc n + suc (toℕ j) * suc n
≡⟨ refl ⟩
suc (suc (toℕ j)) * suc n
≤⟨ cong*r≤
(s≤s (s≤s (bounded' m j)))
(suc n) ⟩
suc (suc m) * suc n ∎)
where open ≤-Reasoning
leq-lem-0 : (m n : ℕ) → suc n ≤ n + suc m
leq-lem-0 m n =
begin (suc n
≤⟨ m≤m+n (suc n) m ⟩
suc (n + m)
≡⟨ cong suc (+-comm n m) ⟩
suc m + n
≡⟨ +-comm (suc m) n ⟩
n + suc m ∎)
where open ≤-Reasoning
-- the extra 'm' is really handy
inject-id : (m : ℕ) (j : Fin (suc m)) (leq : toℕ j ≤ m) →
j ≡ inject≤ (fromℕ (toℕ j)) (s≤s leq)
inject-id 0 zero z≤n = refl
inject-id 0 (suc j) ()
inject-id (suc m) zero z≤n = refl
inject-id (suc m) (suc j) (s≤s leq) = cong suc (inject-id m j leq)
raise-lem-0 : (m n : ℕ) → (leq : suc n ≤ n + suc m) →
raise n zero ≡ inject≤ (fromℕ n) leq
raise-lem-0 m 0 (s≤s leq) = refl
raise-lem-0 m (suc n) (s≤s leq) = cong suc (raise-lem-0 m n leq)
raise-lem-0' : (m n : ℕ) (j : Fin (suc m)) →
(leq : suc (n + toℕ j) ≤ n + (suc m)) →
raise n j ≡ inject≤ (fromℕ (n + toℕ j)) leq
raise-lem-0' m 0 j (s≤s leq) = inject-id m j leq
raise-lem-0' m (suc n) j (s≤s leq) = cong suc (raise-lem-0' m n j leq)
raise-lem-1 : (n : ℕ) → (d : Fin (suc n)) →
(leq : toℕ d ≤ n) →
(leq' : suc (n + suc (toℕ d)) ≤ n + suc (suc n)) →
raise n (inject≤ (fromℕ (toℕ (suc d))) (s≤s (s≤s leq)))
≡ inject≤ (fromℕ (n + toℕ (suc d))) leq'
raise-lem-1 0 zero z≤n (s≤s (s≤s z≤n)) = refl
raise-lem-1 0 (suc d) () leq'
raise-lem-1 (suc n) zero z≤n (s≤s leq') =
begin (suc (raise n (suc zero))
≡⟨ cong suc (raise-lem-0' (suc (suc n)) n (suc zero) leq') ⟩
suc (inject≤ (fromℕ (n + 1)) leq') ∎)
where open ≡-Reasoning
raise-lem-1 (suc n) (suc d) (s≤s leq) (s≤s leq') = cong suc (
begin (raise n (suc (suc _)))
≡⟨ cong (λ x → raise n (suc (suc x))) (sym (inject-id n d leq)) ⟩
raise n (suc (suc d))
≡⟨ raise-lem-0' (suc (suc n)) n (suc (suc d)) leq' ⟩
inject≤ (fromℕ (n + suc (suc (toℕ d)))) leq' ∎)
where open ≡-Reasoning
cancel+l : (r k n : ℕ) → r + k ≤ n → k ≤ n
cancel+l 0 k n x = x
cancel+l (suc r) k 0 ()
cancel+l (suc r) k (suc n) (s≤s x) = trans≤ (cancel+l r k n x) (i≤si _)
lastV : {ℓ : Level} {A : Set ℓ} {n : ℕ} → Vec A (suc n) → A
lastV (x ∷ []) = x
lastV (_ ∷ x ∷ xs) = lastV (x ∷ xs)
last-map : {A B : Set} → (n : ℕ) → (xs : Vec A (suc n)) → (f : A → B) →
lastV (mapV f xs) ≡ f (lastV xs)
last-map 0 (x ∷ []) f = refl
last-map (suc n) (_ ∷ x ∷ xs) f = last-map n (x ∷ xs) f
{--
transposeIndex : (m n : ℕ) →
(b : Fin (suc (suc m))) → (d : Fin (suc (suc n))) →
Fin (suc (suc m) * suc (suc n))
transposeIndex m n b d with toℕ b * suc (suc n) + toℕ d
transposeIndex m n b d | i with suc i ≟ suc (suc m) * suc (suc n)
transposeIndex m n b d | i | yes _ =
fromℕ (suc (n + suc (suc (n + m * suc (suc n)))))
transposeIndex m n b d | i | no _ =
inject≤
((i * (suc (suc m))) mod (suc (n + suc (suc (n + m * suc (suc n))))))
(i≤si (suc (n + suc (suc (n + m * suc (suc n))))))
--}
transposeIndex : (m n : ℕ) →
(b : Fin (suc (suc m))) → (d : Fin (suc (suc n))) →
Fin (suc (suc m) * suc (suc n))
transposeIndex m n b d =
inject≤
(fromℕ (toℕ d * suc (suc m) + toℕ b))
(trans≤ (i*n+k≤m*n d b) (refl′ (*-comm (suc (suc n)) (suc (suc m)))))
swap⋆cauchy : (m n : ℕ) → Cauchy (m * n)
swap⋆cauchy 0 n = []
swap⋆cauchy 1 n = subst Cauchy (sym (+-right-identity n)) (idcauchy n)
swap⋆cauchy (suc (suc m)) 0 =
subst Cauchy (sym (*-right-zero (suc (suc m)))) []
swap⋆cauchy (suc (suc m)) 1 =
subst Cauchy (sym (i*1≡i (suc (suc m)))) (idcauchy (suc (suc m)))
swap⋆cauchy (suc (suc m)) (suc (suc n)) =
concatV
(mapV
(λ b → mapV (λ d → transposeIndex m n b d) (allFin (suc (suc n))))
(allFin (suc (suc m))))
transposeIndex0 : (m n : ℕ) →
(b : Fin m) → (d : Fin n) → Fin (m * n)
transposeIndex0 m n b d =
inject≤
(fromℕ (toℕ d * m + toℕ b))
(trans≤ (i*n+k≤m*n d b) (refl′ (*-comm n m)))
-- another way to check injectivity
isElement : ∀ {m n} → Fin m → Vec (Fin m) n → Maybe (Fin n)
isElement _ [] = nothing
isElement x (y ∷ ys) with toℕ x ≟ toℕ y | isElement x ys
... | yes _ | _ = just zero
... | no _ | nothing = nothing
... | no _ | just i = just (suc i)
injective : ∀ {m n} → Pred (Vec (Fin m) n) lzero
injective {m} {n} π = ∀ {i j} → lookup i π ≡ lookup j π → i ≡ j
{--
isInjective : ∀ {m n} → UnaryDecidable (injective {m} {n})
isInjective {m} {0} [] = yes f
where f : {i j : Fin 0} → (lookup i [] ≡ lookup j []) → (i ≡ j)
f {()}
isInjective {m} {suc n} (b ∷ π) with isElement b π | isInjective {m} {n} π
... | just i | _ = no {!!}
... | nothing | no ¬inj = no {!!}
... | nothing | yes inj = yes {!!}
--}
{--
transpose≡ : (m n : ℕ) (i j : Fin (suc (suc m) * suc (suc n)))
(bi bj : Fin (suc (suc m))) (di dj : Fin (suc (suc n)))
(deci : toℕ i ≡ toℕ di + toℕ bi * suc (suc n))
(decj : toℕ j ≡ toℕ dj + toℕ bj * suc (suc n))
(tpr : transposeIndex m n bi di ≡ transposeIndex m n bj dj) → (i ≡ j)
transpose≡ m n i j bi bj di dj deci decj tpr =
let (d≡ , b≡) = fin-addMul-lemma (suc (suc n)) (suc (suc m)) di dj bi bj stpr
d+bn≡ = cong₂ (λ x y → toℕ x + toℕ y * suc (suc n)) d≡ b≡
in toℕ-injective (trans deci (trans d+bn≡ (sym decj)))
where stpr = begin (toℕ di * suc (suc m) + toℕ bi
≡⟨ sym (to-from _) ⟩
toℕ (fromℕ (toℕ di * suc (suc m) + toℕ bi))
≡⟨ sym (inject≤-lemma _ _) ⟩
toℕ (inject≤
(fromℕ (toℕ di * suc (suc m) + toℕ bi))
(trans≤
(i*n+k≤m*n di bi)
(refl′ (*-comm (suc (suc n)) (suc (suc m))))))
≡⟨ cong toℕ tpr ⟩
toℕ (inject≤
(fromℕ (toℕ dj * suc (suc m) + toℕ bj))
(trans≤
(i*n+k≤m*n dj bj)
(refl′ (*-comm (suc (suc n)) (suc (suc m))))))
≡⟨ inject≤-lemma _ _ ⟩
toℕ (fromℕ (toℕ dj * suc (suc m) + toℕ bj))
≡⟨ to-from _ ⟩
toℕ dj * suc (suc m) + toℕ bj ∎)
where open ≡-Reasoning
swap⋆perm' : (m n : ℕ) (i j : Fin (m * n))
(p : lookup i (swap⋆cauchy m n) ≡ lookup j (swap⋆cauchy m n)) → (i ≡ j)
swap⋆perm' 0 n () j p
swap⋆perm' 1 n i j p = toℕ-injective pr
where pr = begin (toℕ i
≡⟨ cong toℕ (sym (lookup-allFin i)) ⟩
toℕ (lookup i (idcauchy (n + 0)))
≡⟨ cong
(λ x → toℕ (lookup i x))
(sym (subst-allFin (sym (+-right-identity n)))) ⟩
toℕ (lookup i (subst Cauchy (sym (+-right-identity n)) (idcauchy n)))
≡⟨ cong toℕ p ⟩
toℕ (lookup j (subst Cauchy (sym (+-right-identity n)) (idcauchy n)))
≡⟨ cong
(λ x → toℕ (lookup j x))
i (subst-allFin (sym (+-right-identity n))) ⟩
toℕ (lookup j (idcauchy (n + 0)))
≡⟨ cong toℕ (lookup-allFin j) ⟩
toℕ j ∎)
where open ≡-Reasoning
swap⋆perm' (suc (suc m)) 0 i j p rewrite (*-right-zero m) = ⊥-elim (Fin0-⊥ i)
swap⋆perm' (suc (suc m)) 1 i j p = toℕ-injective pr
where pr = begin (toℕ i
≡⟨ cong toℕ (sym (lookup-allFin i)) ⟩
toℕ (lookup i (idcauchy (suc (suc m) * 1)))
≡⟨ cong
(λ x → toℕ (lookup i x))
(sym (subst-allFin (sym (i*1≡i (suc (suc m)))))) ⟩
toℕ (lookup i
(subst Cauchy (sym (i*1≡i (suc (suc m))))
(idcauchy (suc (suc m)))))
≡⟨ cong toℕ p ⟩
toℕ (lookup j
(subst Cauchy (sym (i*1≡i (suc (suc m))))
(idcauchy (suc (suc m)))))
≡⟨ cong
(λ x → toℕ (lookup j x))
(subst-allFin (sym (i*1≡i (suc (suc m))))) ⟩
toℕ (lookup j (idcauchy (suc (suc m) * 1)))
≡⟨ cong toℕ (lookup-allFin j) ⟩
toℕ j ∎)
where open ≡-Reasoning
swap⋆perm' (suc (suc m)) (suc (suc n)) i j p =
let fin-result bi di deci deci' = fin-divMod (suc (suc m)) (suc (suc n)) i
fin-result bj dj decj decj' = fin-divMod (suc (suc m)) (suc (suc n)) j
in transpose≡ m n i j bi bj di dj deci decj pr
where pr = let fin-result bi di deci deci' = fin-divMod (suc (suc m)) (suc (suc n)) i
fin-result bj dj decj decj' = fin-divMod (suc (suc m)) (suc (suc n)) j
in
begin (transposeIndex m n bi di
≡⟨ cong₂ (λ x y → transposeIndex m n x y)
(sym (lookup-allFin bi)) (sym (lookup-allFin di)) ⟩
transposeIndex m n
(lookup bi (allFin (suc (suc m))))
(lookup di (allFin (suc (suc n))))
≡⟨ sym (lookup-2d (suc (suc m)) (suc (suc n)) i
(allFin (suc (suc m))) (allFin (suc (suc n)))
(λ {(b , d) → transposeIndex m n b d})) ⟩
lookup i
(concatV
(mapV
(λ b →
mapV
(λ d → transposeIndex m n b d)
(allFin (suc (suc n))))
(allFin (suc (suc m)))))
≡⟨ p ⟩
lookup j
(concatV
(mapV
(λ b →
mapV
(λ d → transposeIndex m n b d)
(allFin (suc (suc n))))
(allFin (suc (suc m)))))
≡⟨ lookup-2d (suc (suc m)) (suc (suc n)) j
(allFin (suc (suc m))) (allFin (suc (suc n)))
(λ {(b , d) → transposeIndex m n b d}) ⟩
transposeIndex m n
(lookup bj (allFin (suc (suc m))))
(lookup dj (allFin (suc (suc n))))
≡⟨ cong₂ (λ x y → transposeIndex m n x y)
(lookup-allFin bj) (lookup-allFin dj) ⟩
transposeIndex m n bj dj ∎)
where open ≡-Reasoning
swap⋆perm : (m n : ℕ) → Permutation (m * n)
swap⋆perm m n = (swap⋆cauchy m n , λ {i} {j} p → swap⋆perm' m n i j p)
--}
subst-allFin : ∀ {m n} → (eq : m ≡ n) → subst Cauchy eq (allFin m) ≡ allFin n
subst-allFin refl = refl
{--
transposeIndex' : (m n : ℕ) → (b : Fin (suc (suc m))) (d : Fin (suc (suc n))) →
(toℕ b ≡ suc m × toℕ d ≡ suc n) →
transposeIndex m n b d ≡ fromℕ (suc n + suc m * suc (suc n))
transposeIndex' m n b d (b≡ , d≡)
with suc (toℕ b * suc (suc n) + toℕ d) ≟ suc (suc m) * suc (suc n)
transposeIndex' m n b d (b≡ , d≡) | yes i= = refl
transposeIndex' m n b d (b≡ , d≡) | no i≠ = ⊥-elim (i≠ contra)
where contra = begin (suc (toℕ b * suc (suc n) + toℕ d)
≡⟨ cong₂ (λ x y → suc (x * suc (suc n) + y)) b≡ d≡ ⟩
suc (suc m * suc (suc n) + suc n)
≡⟨ sym (+-suc (suc m * suc (suc n)) (suc n)) ⟩
suc m * suc (suc n) + suc (suc n)
≡⟨ +-comm (suc m * suc (suc n)) (suc (suc n)) ⟩
suc (suc n) + suc m * suc (suc n)
≡⟨ refl ⟩
suc (suc m) * suc (suc n) ∎)
where open ≡-Reasoning
--}
{--
transposeIndex'' : (m n : ℕ) (b : Fin (suc (suc m))) (d : Fin (suc (suc n)))
(p≠ : ¬ suc (toℕ b * suc (suc n) + toℕ d) ≡ suc (suc m) * suc (suc n)) →
transposeIndex m n b d ≡
inject≤
(((toℕ b * suc (suc n) + toℕ d) * (suc (suc m))) mod (suc n + suc m * suc (suc n)))
(i≤si (suc n + suc m * suc (suc n)))
transposeIndex'' m n b d p≠ with
suc (toℕ b * suc (suc n) + toℕ d) ≟ suc (suc m) * suc (suc n)
... | yes w = ⊥-elim (p≠ w)
... | no ¬w = refl
--}
{--
subst-lookup-transpose : (m n : ℕ) (b : Fin (suc (suc m))) (d : Fin (suc (suc n))) →
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(lookup
(subst Fin (*-comm (suc (suc m)) (suc (suc n)))
(transposeIndex m n b d))
(concatV
(mapV
(λ b → mapV (λ d → transposeIndex n m b d) (allFin (suc (suc m))))
(allFin (suc (suc n))))))
≡ inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d)
subst-lookup-transpose m n b d
with suc (toℕ b * suc (suc n) + toℕ d) ≟ suc (suc m) * suc (suc n)
subst-lookup-transpose m n b d | yes p= =
let (b= , d=) = max-b-d m n b d p= in
begin (subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(lookup
(subst Fin (*-comm (suc (suc m)) (suc (suc n)))
(fromℕ (suc n + suc m * suc (suc n))))
(concatV
(mapV
(λ b → mapV (λ d → transposeIndex n m b d) (allFin (suc (suc m))))
(allFin (suc (suc n))))))
≡⟨ cong (λ x → subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(lookup x
(concatV
(mapV
(λ b →
mapV
(λ d → transposeIndex n m b d)
(allFin (suc (suc m))))
(allFin (suc (suc n)))))))
(subst-fin
(suc n + suc m * suc (suc n))
(suc m + suc n * suc (suc m))
(*-comm (suc (suc m)) (suc (suc n)))) ⟩
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(lookup
(fromℕ (suc m + suc n * suc (suc m)))
(concatV
(mapV
(λ b → mapV (λ d → transposeIndex n m b d) (allFin (suc (suc m))))
(allFin (suc (suc n))))))
≡⟨ cong
(λ x → subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(lookup (fromℕ (suc m + suc n * suc (suc m))) x))
(concat-map-map-tabulate (suc (suc n)) (suc (suc m))
(λ {(b , d) → transposeIndex n m b d})) ⟩
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(lookup
(fromℕ (suc m + suc n * suc (suc m)))
(tabulate (λ k →
let (b , d) = fin-project (suc (suc n)) (suc (suc m)) k in
transposeIndex n m b d)))
≡⟨ cong (subst Fin (*-comm (suc (suc n)) (suc (suc m))))
(lookup-fromℕ-allFin
(suc m + suc n * suc (suc m))
(λ k →
let (b , d) = fin-project (suc (suc n)) (suc (suc m)) k in
transposeIndex n m b d)) ⟩
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(let (b , d) = fin-project (suc (suc n)) (suc (suc m))
(fromℕ (suc m + suc n * suc (suc m)))
in transposeIndex n m b d)
≡⟨ cong
(λ x →
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(let (b , d) = x in transposeIndex n m b d))
(fin-project-2 n m) ⟩
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(transposeIndex n m (fromℕ (suc n)) (fromℕ (suc m)))
≡⟨ cong (subst Fin (*-comm (suc (suc n)) (suc (suc m))))
(transposeIndex' n m (fromℕ (suc n)) (fromℕ (suc m))
(to-from (suc n) , to-from (suc m))) ⟩
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(fromℕ (suc m + suc n * suc (suc m)))
≡⟨ subst-fin
(suc (m + suc (suc (m + n * suc (suc m)))))
(suc (n + suc (suc (n + m * suc (suc n)))))
(*-comm (suc (suc n)) (suc (suc m))) ⟩
fromℕ (suc (n + suc (suc (n + m * suc (suc n)))))
≡⟨ sym (fin=1 n m) ⟩
fromℕ (suc n + suc m * suc (suc n))
≡⟨ toℕ-injective
(trans (to-from (suc n + suc m * suc (suc n)))
(trans (+-comm (suc n) (suc m * suc (suc n)))
(trans (sym (to-from (suc m * suc (suc n) + suc n)))
(sym (inject≤-lemma
(fromℕ (suc m * suc (suc n) + suc n))
(refl′
(trans (sym (+-suc (suc m * suc (suc n)) (suc n)))
(+-comm (suc m * suc (suc n)) (suc (suc n)))))))))) ⟩
inject≤
(fromℕ (suc m * suc (suc n) + suc n))
(refl′ (trans
(sym (+-suc (suc m * suc (suc n)) (suc n)))
(+-comm (suc m * suc (suc n)) (suc (suc n)))))
≡⟨ cong₂D!
(λ x y → inject≤ (fromℕ x) y)
(cong₂ (λ x y → x * suc (suc n) + y) b= d=)
(≤-proof-irrelevance
(subst (λ z → suc z ≤ suc (suc n) + suc m * suc (suc n))
(cong₂ (λ x y → x * suc (suc n) + y) b= d=)
(i*n+k≤m*n b d))
(refl′
(trans
(sym (cong suc (cong suc (+-suc (n + m * suc (suc n)) (suc n)))))
(+-comm (suc m * suc (suc n)) (suc (suc n)))))) ⟩
inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d) ∎)
where open ≡-Reasoning
subst-lookup-transpose m n b d | no p≠ =
let leq : suc (toℕ b * suc (suc n) + toℕ d) ≤ suc n + suc m * suc (suc n)
leq = not-max-b-d m n b d p≠
p'≠ : ¬ suc (toℕ d * suc (suc m) + toℕ b) ≡ suc (suc n) * suc (suc m)
p'≠ = not-max-b-d' m n b d p≠ in
begin (subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(lookup
(subst Fin (*-comm (suc (suc m)) (suc (suc n)))
(inject≤
((((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))) mod
(suc n + suc m * suc (suc n)))
(i≤si (suc n + suc m * suc (suc n)))))
(concatV
(mapV
(λ b → mapV (λ d → transposeIndex n m b d) (allFin (suc (suc m))))
(allFin (suc (suc n))))))
≡⟨ cong₂
(λ x y → subst Fin (*-comm (suc (suc n)) (suc (suc m))) (lookup x y))
(subst-inject-mod
{((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))}
(*-comm (suc (suc m)) (suc (suc n))))
(concat-map-map-tabulate (suc (suc n)) (suc (suc m))
(λ {(b , d) → transposeIndex n m b d})) ⟩
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(lookup
(inject≤
((((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))) mod
(suc m + suc n * suc (suc m)))
(i≤si (suc m + suc n * suc (suc m))))
(tabulate (λ k →
let (b , d) = fin-project (suc (suc n)) (suc (suc m)) k in
transposeIndex n m b d)))
≡⟨ cong (subst Fin (*-comm (suc (suc n)) (suc (suc m))))
(lookup∘tabulate
(λ k →
let (b , d) = fin-project (suc (suc n)) (suc (suc m)) k in
transposeIndex n m b d)
(inject≤
((((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))) mod
(suc m + suc n * suc (suc m)))
(i≤si (suc m + suc n * suc (suc m))))) ⟩
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(let (d' , b') = fin-project
(suc (suc n)) (suc (suc m))
(inject≤
((((toℕ b * suc (suc n)) + toℕ d) * (suc (suc m))) mod
(suc m + suc n * suc (suc m)))
(i≤si (suc m + suc n * suc (suc m))))
in transposeIndex n m d' b')
≡⟨ cong
(λ x →
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
let (d' , b') = x in transposeIndex n m d' b')
(fin-project-3 m n b d p'≠) ⟩
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(transposeIndex n m d b)
≡⟨ cong (subst Fin (*-comm (suc (suc n)) (suc (suc m))))
(transposeIndex'' n m d b p'≠) ⟩
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(inject≤
(((toℕ d * suc (suc m) + toℕ b) * suc (suc n)) mod
(suc m + suc n * suc (suc m)))
(i≤si (suc m + suc n * suc (suc m))))
≡⟨ subst-inject-mod
{(toℕ d * suc (suc m) + toℕ b) * suc (suc n)}
(*-comm (suc (suc n)) (suc (suc m))) ⟩
inject≤
(((toℕ d * suc (suc m) + toℕ b) * suc (suc n)) mod
(suc n + suc m * suc (suc n)))
(i≤si (suc n + suc m * suc (suc n)))
≡⟨ inject-mod m n b d leq ⟩
inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d) ∎)
where open ≡-Reasoning
--}
{--
lookup-swap-2 :
(m n : ℕ) (b : Fin (suc (suc m))) (d : Fin (suc (suc n))) →
lookup
(transposeIndex m n b d)
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV
(mapV
(λ b → mapV (λ d → transposeIndex n m b d) (allFin (suc (suc m))))
(allFin (suc (suc n)))))) ≡
inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d)
lookup-swap-2 m n b d =
begin (lookup
(transposeIndex m n b d)
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV
(mapV
(λ b → mapV (λ d → transposeIndex n m b d) (allFin (suc (suc m))))
(allFin (suc (suc n))))))
≡⟨ lookup-subst-1
(transposeIndex m n b d)
(concatV
(mapV
(λ b → mapV (λ d → transposeIndex n m b d) (allFin (suc (suc m))))
(allFin (suc (suc n)))))
(*-comm (suc (suc n)) (suc (suc m)))
(*-comm (suc (suc m)) (suc (suc n)))
(proof-irrelevance
(sym (*-comm (suc (suc n)) (suc (suc m))))
(*-comm (suc (suc m)) (suc (suc n)))) ⟩
subst Fin (*-comm (suc (suc n)) (suc (suc m)))
(lookup
(subst Fin (*-comm (suc (suc m)) (suc (suc n)))
(transposeIndex m n b d))
(concatV
(mapV
(λ b → mapV (λ d → transposeIndex n m b d) (allFin (suc (suc m))))
(allFin (suc (suc n))))))
≡⟨ subst-lookup-transpose m n b d ⟩
inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d) ∎)
where open ≡-Reasoning
--}
{--
lookup-swap-1 :
(m n : ℕ) → (b : Fin (suc (suc m))) → (d : Fin (suc (suc n))) →
lookup
(lookup
(inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d))
(concatV
(mapV (λ b₁ → mapV (transposeIndex m n b₁) (allFin (suc (suc n))))
(allFin (suc (suc m))))))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV
(mapV (λ b₁ → mapV (transposeIndex n m b₁) (allFin (suc (suc m))))
(allFin (suc (suc n)))))) ≡
lookup
(inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d))
(concatV
(mapV
(λ b₁ →
mapV
(λ d₁ → inject≤ (fromℕ (toℕ b₁ * suc (suc n) + toℕ d₁)) (i*n+k≤m*n b₁ d₁))
(allFin (suc (suc n))))
(allFin (suc (suc m)))))
lookup-swap-1 m n b d =
begin (lookup
(lookup
(inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d))
(concatV
(mapV (λ b₁ → mapV (transposeIndex m n b₁) (allFin (suc (suc n))))
(allFin (suc (suc m))))))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV
(mapV (λ b₁ → mapV (transposeIndex n m b₁) (allFin (suc (suc m))))
(allFin (suc (suc n))))))
≡⟨ cong
(λ x → lookup x
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV
(mapV (λ b₁ → mapV (transposeIndex n m b₁) (allFin (suc (suc m))))
(allFin (suc (suc n)))))))
(lookup-concat' (suc (suc m)) (suc (suc n)) b d (i*n+k≤m*n b d)
(λ {(b , d) → transposeIndex m n b d})
(allFin (suc (suc m))) (allFin (suc (suc n)))) ⟩
lookup
(transposeIndex m n
(lookup b (allFin (suc (suc m))))
(lookup d (allFin (suc (suc n)))))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV
(mapV (λ b₁ → mapV (transposeIndex n m b₁) (allFin (suc (suc m))))
(allFin (suc (suc n))))))
≡⟨ cong₂
(λ x y → lookup (transposeIndex m n x y)
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV
(mapV
(λ b₁ →
mapV (transposeIndex n m b₁) (allFin (suc (suc m))))
(allFin (suc (suc n)))))))
(lookup-allFin b)
(lookup-allFin d) ⟩
lookup
(transposeIndex m n b d)
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV
(mapV (λ b₁ → mapV (transposeIndex n m b₁) (allFin (suc (suc m))))
(allFin (suc (suc n))))))
≡⟨ lookup-swap-2 m n b d ⟩
inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d)
≡⟨ sym (cong₂
(λ x y → let b' = x
d' = y in
inject≤
(fromℕ (toℕ b' * suc (suc n) + toℕ d'))
(i*n+k≤m*n b' d'))
(lookup-allFin b)
(lookup-allFin d)) ⟩
let b' = lookup b (allFin (suc (suc m)))
d' = lookup d (allFin (suc (suc n))) in
inject≤
(fromℕ (toℕ b' * suc (suc n) + toℕ d'))
(i*n+k≤m*n b' d')
≡⟨ sym (lookup-concat' (suc (suc m)) (suc (suc n)) b d (i*n+k≤m*n b d)
(λ {(b , d) →
inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d)})
(allFin (suc (suc m))) (allFin (suc (suc n)))) ⟩
lookup
(inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d))
(concatV
(mapV
(λ b₁ →
mapV
(λ d₁ →
inject≤ (fromℕ (toℕ b₁ * suc (suc n) + toℕ d₁)) (i*n+k≤m*n b₁ d₁))
(allFin (suc (suc n))))
(allFin (suc (suc m))))) ∎)
where open ≡-Reasoning
--}
{--
lookup-swap : (m n : ℕ) (i : Fin (suc (suc m) * suc (suc n))) →
let vs = allFin (suc (suc m))
ws = allFin (suc (suc n)) in
lookup
(lookup i (concatV (mapV (λ b → mapV (transposeIndex m n b) ws) vs)))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV (mapV (λ b → mapV (transposeIndex n m b) vs) ws)))
≡ lookup i
(concatV
(mapV
(λ b → mapV
(λ d → inject≤
(fromℕ (toℕ b * (suc (suc n)) + toℕ d))
(i*n+k≤m*n b d))
ws)
vs))
lookup-swap m n i =
let vs = allFin (suc (suc m))
ws = allFin (suc (suc n)) in
begin (lookup
(lookup i (concatV (mapV (λ b → mapV (transposeIndex m n b) ws) vs)))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV (mapV (λ b → mapV (transposeIndex n m b) vs) ws)))
≡⟨ cong
(λ x →
lookup
(lookup x (concatV (mapV (λ b → mapV (transposeIndex m n b) ws) vs)))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV (mapV (λ b → mapV (transposeIndex n m b) vs) ws))))
(fin-proj-lem (suc (suc m)) (suc (suc n)) i) ⟩
let (b , d) = fin-project (suc (suc m)) (suc (suc n)) i in
lookup
(lookup
(inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d))
(concatV (mapV (λ b → mapV (transposeIndex m n b) ws) vs)))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV (mapV (λ b → mapV (transposeIndex n m b) vs) ws)))
≡⟨ cong
(λ x → let (b , d) = fin-project (suc (suc m)) (suc (suc n)) i in x)
(lookup-swap-1 m n b d) ⟩
let (b , d) = fin-project (suc (suc m)) (suc (suc n)) i in
lookup
(inject≤
(fromℕ (toℕ b * suc (suc n) + toℕ d))
(i*n+k≤m*n b d))
(concatV
(mapV
(λ b → mapV
(λ d → inject≤
(fromℕ (toℕ b * (suc (suc n)) + toℕ d))
(i*n+k≤m*n b d))
ws)
vs))
≡⟨ cong
(λ x →
lookup x
(concatV
(mapV
(λ b → mapV
(λ d → inject≤
(fromℕ (toℕ b * (suc (suc n)) + toℕ d))
(i*n+k≤m*n b d))
ws)
vs)))
(sym (fin-proj-lem (suc (suc m)) (suc (suc n)) i)) ⟩
lookup i
(concatV
(mapV
(λ b → mapV
(λ d → inject≤
(fromℕ (toℕ b * (suc (suc n)) + toℕ d))
(i*n+k≤m*n b d))
ws)
vs)) ∎)
where open ≡-Reasoning
--}
{--
tabulate-lookup-concat : (m n : ℕ) →
let vec = (λ m n f →
concatV
(mapV
(λ b → mapV (f m n b) (allFin (suc (suc n))))
(allFin (suc (suc m))))) in
tabulate {suc (suc m) * suc (suc n)} (λ i →
lookup
(lookup i (vec m n transposeIndex))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m))) (vec n m transposeIndex)))
≡
vec m n (λ m n b d → inject≤
(fromℕ (toℕ b * (suc (suc n)) + toℕ d))
(i*n+k≤m*n b d))
tabulate-lookup-concat m n =
let vec = (λ m n f →
concatV
(mapV
(λ b → mapV (f m n b) (allFin (suc (suc n))))
(allFin (suc (suc m))))) in
begin (tabulate {suc (suc m) * suc (suc n)} (λ i →
lookup
(lookup i (vec m n transposeIndex))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(vec n m transposeIndex)))
≡⟨ finext _ _ (λ i → lookup-swap m n i) ⟩
tabulate {suc (suc m) * suc (suc n)} (λ i →
lookup i (vec m n (λ m n b d →
inject≤
(fromℕ (toℕ b * (suc (suc n)) + toℕ d))
(i*n+k≤m*n b d))))
≡⟨ tabulate∘lookup (vec m n (λ m n b d →
inject≤
(fromℕ (toℕ b * (suc (suc n)) + toℕ d))
(i*n+k≤m*n b d))) ⟩
vec m n (λ m n b d → inject≤
(fromℕ (toℕ b * (suc (suc n)) + toℕ d))
(i*n+k≤m*n b d)) ∎)
where open ≡-Reasoning
--}
{--
swap⋆idemp : (m n : ℕ) →
scompcauchy
(swap⋆cauchy m n)
(subst Cauchy (*-comm n m) (swap⋆cauchy n m))
≡
allFin (m * n)
swap⋆idemp 0 n = refl
swap⋆idemp 1 0 = refl
swap⋆idemp 1 1 = refl
swap⋆idemp 1 (suc (suc n)) =
begin (scompcauchy
(subst Cauchy (sym (+-right-identity (suc (suc n))))
(allFin (suc (suc n))))
(subst Cauchy (*-comm (suc (suc n)) 1)
(subst Cauchy (sym (i*1≡i (suc (suc n)))) (allFin (suc (suc n)))))
≡⟨ cong₂ (λ x y → scompcauchy x (subst Cauchy (*-comm (suc (suc n)) 1) y))
(subst-allFin (sym (+-right-identity (suc (suc n)))))
(subst-allFin (sym (i*1≡i (suc (suc n))))) ⟩
scompcauchy
(allFin (suc (suc n) + 0))
(subst Cauchy (*-comm (suc (suc n)) 1) (allFin (suc (suc n) * 1)))
≡⟨ cong (scompcauchy (allFin (suc (suc n) + 0)))
(subst-allFin (*-comm (suc (suc n)) 1)) ⟩
scompcauchy
(allFin (suc (suc n) + 0))
(allFin (1 * suc (suc n)))
≡⟨ scomplid (allFin (suc (suc n) + 0)) ⟩
allFin (1 * suc (suc n)) ∎)
where open ≡-Reasoning
swap⋆idemp (suc (suc m)) 0 =
begin (scompcauchy
(subst Cauchy (sym (*-right-zero (suc (suc m)))) (allFin 0))
(subst Cauchy (*-comm 0 (suc (suc m))) (allFin 0))
≡⟨ cong₂ scompcauchy
(subst-allFin (sym (*-right-zero (suc (suc m)))))
(subst-allFin (*-comm 0 (suc (suc m)))) ⟩
scompcauchy
(allFin (suc (suc m) * 0))
(allFin (suc (suc m) * 0))
≡⟨ scomplid (allFin (suc (suc m) * 0)) ⟩
allFin (suc (suc m) * 0) ∎)
where open ≡-Reasoning
swap⋆idemp (suc (suc m)) 1 =
begin (scompcauchy
(subst Cauchy (sym (i*1≡i (suc (suc m)))) (idcauchy (suc (suc m))))
(subst Cauchy (*-comm 1 (suc (suc m)))
(subst Cauchy (sym (+-right-identity (suc (suc m))))
(idcauchy (suc (suc m)))))
≡⟨ cong₂
(λ x y → scompcauchy x (subst Cauchy (*-comm 1 (suc (suc m))) y))
(subst-allFin (sym (i*1≡i (suc (suc m)))))
(subst-allFin (sym (+-right-identity (suc (suc m))))) ⟩
scompcauchy
(allFin (suc (suc m) * 1))
(subst Cauchy (*-comm 1 (suc (suc m))) (allFin (suc (suc m) + 0)))
≡⟨ cong (scompcauchy (allFin (suc (suc m) * 1)))
(subst-allFin (*-comm 1 (suc (suc m)))) ⟩
scompcauchy
(allFin (suc (suc m) * 1))
(allFin (suc (suc m) * 1))
≡⟨ scomplid (allFin (suc (suc m) * 1)) ⟩
allFin (suc (suc m) * 1) ∎)
where open ≡-Reasoning
swap⋆idemp (suc (suc m)) (suc (suc n)) =
begin (scompcauchy
(swap⋆cauchy (suc (suc m)) (suc (suc n)))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(swap⋆cauchy (suc (suc n)) (suc (suc m))))
≡⟨ refl ⟩
scompcauchy
(concatV
(mapV
(λ b → mapV (λ d → transposeIndex m n b d) (allFin (suc (suc n))))
(allFin (suc (suc m)))))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV
(mapV
(λ d → mapV (λ b → transposeIndex n m d b) (allFin (suc (suc m))))
(allFin (suc (suc n))))))
≡⟨ refl ⟩
tabulate {suc (suc m) * suc (suc n)} (λ i →
lookup
(lookup i
(concatV
(mapV
(λ b →
mapV
(λ d → transposeIndex m n b d)
(allFin (suc (suc n))))
(allFin (suc (suc m))))))
(subst Cauchy (*-comm (suc (suc n)) (suc (suc m)))
(concatV
(mapV
(λ d →
mapV
(λ b → transposeIndex n m d b)
(allFin (suc (suc m))))
(allFin (suc (suc n)))))))
≡⟨ tabulate-lookup-concat m n ⟩
concatV
(mapV
(λ b →
mapV
(λ d → inject≤
(fromℕ (toℕ b * (suc (suc n)) + toℕ d))
(i*n+k≤m*n b d))
(allFin (suc (suc n))))
(allFin (suc (suc m))))
≡⟨ sym (allFin* (suc (suc m)) (suc (suc n))) ⟩
allFin (suc (suc m) * suc (suc n)) ∎)
where open ≡-Reasoning
--}
{--
-- The type Cauchy is too weak to allow us to invert it to combinators
cauchy2c : {t₁ t₂ : U} → (size t₁ ≡ size t₂) → Cauchy (size t₁) → (t₁ ⟷ t₂)
cauchy2c {ZERO} {ONE} () π
cauchy2c {ZERO} {BOOL} () π
cauchy2c {ONE} {ZERO} () π
cauchy2c {ONE} {BOOL} () π
cauchy2c {BOOL} {ZERO} () π
cauchy2c {BOOL} {ONE} () π
cauchy2c {ZERO} {ZERO} refl [] = id⟷
cauchy2c {ONE} {ONE} sp π = id⟷
cauchy2c {ZERO} {PLUS t₂ t₃} sp π = {!!}
cauchy2c {ZERO} {TIMES t₂ t₃} sp π = {!!}
cauchy2c {ONE} {PLUS t₂ t₃} sp π = {!!}
cauchy2c {ONE} {TIMES t₂ t₃} sp π = {!!}
cauchy2c {PLUS t₁ t₂} {ZERO} sp π = {!!}
cauchy2c {PLUS t₁ t₂} {ONE} sp π = {!!}
cauchy2c {PLUS t₁ t₂} {PLUS t₃ t₄} sp π = {!!}
cauchy2c {PLUS t₁ t₂} {TIMES t₃ t₄} sp π = {!!}
cauchy2c {PLUS t₁ t₂} {BOOL} sp π = {!!}
cauchy2c {TIMES t₁ t₂} {ZERO} sp π = {!!}
cauchy2c {TIMES t₁ t₂} {ONE} sp π = {!!}
cauchy2c {TIMES t₁ t₂} {PLUS t₃ t₄} sp π = {!!}
cauchy2c {TIMES t₁ t₂} {TIMES t₃ t₄} sp π = {!!}
cauchy2c {TIMES t₁ t₂} {BOOL} sp π = {!!}
cauchy2c {BOOL} {PLUS t₂ t₃} sp π = {!!}
cauchy2c {BOOL} {TIMES t₂ t₃} sp π = {!!}
-- LOOK HERE
cauchy2c {BOOL} {BOOL} refl (zero ∷ zero ∷ []) = {!!} -- ILLEGAL
cauchy2c {BOOL} {BOOL} refl (zero ∷ suc zero ∷ []) = id⟷
cauchy2c {BOOL} {BOOL} refl (zero ∷ suc (suc ()) ∷ [])
cauchy2c {BOOL} {BOOL} refl (suc zero ∷ zero ∷ []) = NOT
cauchy2c {BOOL} {BOOL} refl (suc zero ∷ suc zero ∷ []) = {!!} --ILLEGAL
cauchy2c {BOOL} {BOOL} refl (suc zero ∷ suc (suc ()) ∷ [])
cauchy2c {BOOL} {BOOL} refl (suc (suc ()) ∷ b ∷ [])
--}
-- A view of (t : U) as normalized types
-- Normalized types are (1 + (1 + (1 + (1 + ... 0))))
data NormalU : Set where
NZERO : NormalU
NSUC : NormalU → NormalU
fromNormalU : NormalU → U
fromNormalU NZERO = ZERO
fromNormalU (NSUC n) = PLUS ONE (fromNormalU n)
normalU+ : NormalU → NormalU → NormalU
normalU+ NZERO n₂ = n₂
normalU+ (NSUC n₁) n₂ = NSUC (normalU+ n₁ n₂)
normalU⋆ : NormalU → NormalU → NormalU
normalU⋆ NZERO n₂ = NZERO
normalU⋆ (NSUC n₁) n₂ = normalU+ n₂ (normalU⋆ n₁ n₂)
normalU : U → NormalU
normalU ZERO = NZERO
normalU ONE = NSUC NZERO
normalU BOOL = NSUC (NSUC NZERO)
normalU (PLUS t₁ t₂) = normalU+ (normalU t₁) (normalU t₂)
normalU (TIMES t₁ t₂) = normalU⋆ (normalU t₁) (normalU t₂)
data Normalized : (t : NormalU) → Set where
nzero : Normalized NZERO
nsuc : {t : NormalU} → Normalized t → Normalized (NSUC t)
normalized+ : (n₁ n₂ : NormalU) →
Normalized n₁ → Normalized n₂ → Normalized (normalU+ n₁ n₂)
normalized+ NZERO n₂ nd₁ nd₂ = nd₂
normalized+ (NSUC n₁) n₂ (nsuc nd₁) nd₂ = nsuc (normalized+ n₁ n₂ nd₁ nd₂)
normalized⋆ : (n₁ n₂ : NormalU) →
Normalized n₁ → Normalized n₂ → Normalized (normalU⋆ n₁ n₂)
normalized⋆ NZERO n₂ nzero nd₂ = nzero
normalized⋆ (NSUC n₁) n₂ (nsuc nd₁) nd₂ =
normalized+ n₂ (normalU⋆ n₁ n₂) nd₂ (normalized⋆ n₁ n₂ nd₁ nd₂)
normalized : (t : U) → Normalized (normalU t)
normalized ZERO = nzero
normalized ONE = nsuc nzero
normalized BOOL = nsuc (nsuc nzero)
normalized (PLUS t₁ t₂) =
normalized+ (normalU t₁) (normalU t₂) (normalized t₁) (normalized t₂)
normalized (TIMES t₁ t₂) =
normalized⋆ (normalU t₁) (normalU t₂) (normalized t₁) (normalized t₂)
assocr : (n₁ n₂ : NormalU) →
PLUS (fromNormalU n₁) (fromNormalU n₂) ⟷ fromNormalU (normalU+ n₁ n₂)
assocr NZERO n₂ = unite₊
assocr (NSUC n₁) n₂ = assocr₊ ◎ (id⟷ ⊕ assocr n₁ n₂)
distr : (n₁ n₂ : NormalU) →
TIMES (fromNormalU n₁) (fromNormalU n₂) ⟷ fromNormalU (normalU⋆ n₁ n₂)
distr NZERO n₂ = distz
distr (NSUC n₁) n₂ = dist ◎ (unite⋆ ⊕ distr n₁ n₂) ◎ assocr n₂ (normalU⋆ n₁ n₂)
canonicalU : U → U
canonicalU = fromNormalU ∘ normalU
normalizeC : (t : U) → t ⟷ canonicalU t
normalizeC ZERO = id⟷
normalizeC ONE = uniti₊ ◎ swap₊
normalizeC BOOL = unfoldBool ◎
((uniti₊ ◎ swap₊) ⊕ (uniti₊ ◎ swap₊)) ◎
(assocr₊ ◎ (id⟷ ⊕ unite₊))
normalizeC (PLUS t₀ t₁) =
(normalizeC t₀ ⊕ normalizeC t₁) ◎ assocr (normalU t₀) (normalU t₁)
normalizeC (TIMES t₀ t₁) =
(normalizeC t₀ ⊗ normalizeC t₁) ◎ distr (normalU t₀) (normalU t₁)
fin+ : {m n : ℕ} → Fin m → Fin n → Fin (m + n)
fin+ {0} {n} () _
fin+ {suc m} {n} zero b = inject≤ b (n≤m+n (suc m) n)
fin+ {suc m} {n} (suc a) b = suc (fin+ {m} {n} a b)
fin* : {m n : ℕ} → Fin m → Fin n → Fin (m * n)
fin* {0} {n} () _
fin* {suc m} {0} zero ()
fin* {suc m} {suc n} zero b = zero
fin* {suc m} {n} (suc a) b = fin+ b (fin* a b)
| {
"alphanum_fraction": 0.477287874,
"avg_line_length": 35.1745835904,
"ext": "agda",
"hexsha": "f01f961b9192cf9514ec50da9a26090e579682ad",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "Univalence/Obsolete/Pifextra.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "Univalence/Obsolete/Pifextra.agda",
"max_line_length": 94,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "Univalence/Obsolete/Pifextra.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
"num_tokens": 106217,
"size": 228072
} |
{-# OPTIONS --warning=error --safe --without-K #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import LogicalFormulae
open import Numbers.Integers.Integers
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Subtraction
open import Numbers.Naturals.Naturals
open import Numbers.Naturals.Order
open import Numbers.Naturals.Exponentiation
open import Numbers.Primes.PrimeNumbers
open import Maybe
open import Semirings.Definition
import Semirings.Solver
open module NatSolver = Semirings.Solver ℕSemiring multiplicationNIsCommutative
module LectureNotes.NumbersAndSets.Lecture1 where
a-Na : (a : ℕ) → a -N' a ≡ yes 0
a-Na zero = refl
a-Na (succ a) = a-Na a
-N''lemma : (a b : ℕ) → (a<b : a ≤N b) → b -N' a ≡ yes (subtractionNResult.result (-N a<b))
-N''lemma zero (succ b) (inl x) = refl
-N''lemma (succ a) (succ b) (inl x) = -N''lemma a b (inl (canRemoveSuccFrom<N x))
-N''lemma a b (inr x) rewrite x | a-Na b = ans
where
ans : yes 0 ≡ yes (subtractionNResult.result (-N (inr (refl {x = b}))))
ans with -N (inr (refl {x = b}))
ans | record { result = result ; pr = pr } with result
ans | record { result = result ; pr = pr } | zero = refl
ans | record { result = result ; pr = pr } | succ bl = exFalso (cannotAddAndEnlarge'' pr)
-N'' : (a b : ℕ) (a<b : a ≤N b) → ℕ
-N'' a b a<b with -N''lemma a b a<b
... | bl with b -N' a
-N'' a b a<b | bl | yes x = x
n3Bigger : (n : ℕ) → (n ≡ 0) || (n ≤N n ^N 3)
n3Bigger n = exponentiationIncreases n 2
n3Bigger' : (n : ℕ) → n ≤N n ^N 3
n3Bigger' zero = inr refl
n3Bigger' (succ n) with n3Bigger (succ n)
n3Bigger' (succ n) | inr f = f
-- How to use the semiring solver
-- The process is very mechanical; I haven't yet worked out how to do reflection,
-- so there's quite a bit of transcribing expressions into the Expr form.
-- The first two arguments to from-to-by are totally mindless in construction.
proof : (n : ℕ) → ((n *N n) +N ((2 *N n) +N 1)) ≡ (n +N 1) *N (n +N 1)
proof n =
from plus (times (const n) (const n)) (plus (times (succ (succ zero)) (const n)) (succ zero))
to times (plus (const n) (succ zero)) (plus (const n) (succ zero))
by
applyEquality (λ i → succ (n *N n) +N (n +N i)) ((from (const n) to (plus (const n) zero) by refl))
| {
"alphanum_fraction": 0.6525198939,
"avg_line_length": 39,
"ext": "agda",
"hexsha": "bfd769631d9af42baaa5a8e5793be4db098ca12c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "LectureNotes/NumbersAndSets/Lecture1.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "LectureNotes/NumbersAndSets/Lecture1.agda",
"max_line_length": 103,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "LectureNotes/NumbersAndSets/Lecture1.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 789,
"size": 2262
} |
------------------------------------------------------------------------------
-- Induction principles for Tree and Forest
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Program.Mirror.Induction.InductionPrinciples where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Program.Mirror.Type
------------------------------------------------------------------------------
-- These induction principles *not cover* the mutual structure of the
-- types Tree and Rose (Bertot and Casterán, 2004, p. 401).
-- Induction principle for Tree.
Tree-ind : (A : D → Set) →
(∀ d {ts} → Forest ts → A (node d ts)) →
∀ {t} → Tree t → A t
Tree-ind A h (tree d Fts) = h d Fts
-- Induction principle for Forest.
Forest-ind : (A : D → Set) →
A [] →
(∀ {t ts} → Tree t → Forest ts → A ts → A (t ∷ ts)) →
∀ {ts} → Forest ts → A ts
Forest-ind A A[] h fnil = A[]
Forest-ind A A[] h (fcons Tt Fts) = h Tt Fts (Forest-ind A A[] h Fts)
------------------------------------------------------------------------------
-- References
--
-- Bertot, Yves and Castéran, Pierre (2004). Interactive Theorem
-- Proving and Program Development. Coq’Art: The Calculus of Inductive
-- Constructions. Springer.
| {
"alphanum_fraction": 0.4726904922,
"avg_line_length": 37.075,
"ext": "agda",
"hexsha": "4a6e719d59c1cdf7109b53da90597f880b8bcb25",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/FOT/FOTC/Program/Mirror/Induction/InductionPrinciples.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/Program/Mirror/Induction/InductionPrinciples.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/FOTC/Program/Mirror/Induction/InductionPrinciples.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 350,
"size": 1483
} |
{-# OPTIONS --without-K --safe #-}
module Polynomial.Simple.Solver where
open import Polynomial.Expr public
open import Polynomial.Simple.AlmostCommutativeRing public hiding (-raw-almostCommutative⟶)
open import Data.Vec hiding (_⊛_)
open import Algebra.Solver.Ring.AlmostCommutativeRing using (-raw-almostCommutative⟶)
open import Polynomial.Parameters
open import Function
open import Data.Maybe
open import Data.Vec.N-ary
open import Data.Bool using (Bool; true; false; T; if_then_else_)
open import Data.Empty using (⊥-elim)
module Ops {ℓ₁ ℓ₂} (ring : AlmostCommutativeRing ℓ₁ ℓ₂) where
open AlmostCommutativeRing ring
zero-homo : ∀ x → T (is-just (0≟ x)) → 0# ≈ x
zero-homo x _ with 0≟ x
zero-homo x _ | just p = p
zero-homo x () | nothing
homo : Homomorphism ℓ₁ ℓ₂ ℓ₁ ℓ₂
homo = record
{ coeffs = record
{ coeffs = AlmostCommutativeRing.rawRing ring
; Zero-C = λ x → is-just (0≟ x)
}
; ring = record
{ isAlmostCommutativeRing = record
{ isCommutativeSemiring = isCommutativeSemiring
; -‿cong = -‿cong
; -‿*-distribˡ = -‿*-distribˡ
; -‿+-comm = -‿+-comm
}
}
; morphism = -raw-almostCommutative⟶ _
; Zero-C⟶Zero-R = zero-homo
}
⟦_⟧ : ∀ {n} → Expr Carrier n → Vec Carrier n → Carrier
⟦ Κ x ⟧ ρ = x
⟦ Ι x ⟧ ρ = lookup ρ x
⟦ x ⊕ y ⟧ ρ = ⟦ x ⟧ ρ + ⟦ y ⟧ ρ
⟦ x ⊗ y ⟧ ρ = ⟦ x ⟧ ρ * ⟦ y ⟧ ρ
⟦ ⊝ x ⟧ ρ = - ⟦ x ⟧ ρ
⟦ x ⊛ i ⟧ ρ = ⟦ x ⟧ ρ ^ i
open import Polynomial.NormalForm.Definition (Homomorphism.coeffs homo)
open import Polynomial.NormalForm.Operations (Homomorphism.coeffs homo)
norm : ∀ {n} → Expr Carrier n → Poly n
norm = go
where
go : ∀ {n} → Expr Carrier n → Poly n
go (Κ x) = κ x
go (Ι x) = ι x
go (x ⊕ y) = go x ⊞ go y
go (x ⊗ y) = go x ⊠ go y
go (⊝ x) = ⊟ go x
go (x ⊛ i) = go x ⊡ i
⟦_⇓⟧ : ∀ {n} → Expr Carrier n → Vec Carrier n → Carrier
⟦ expr ⇓⟧ = ⟦ norm expr ⟧ₚ where
open import Polynomial.NormalForm.Semantics homo
renaming (⟦_⟧ to ⟦_⟧ₚ)
correct : ∀ {n} (expr : Expr Carrier n) ρ → ⟦ expr ⇓⟧ ρ ≈ ⟦ expr ⟧ ρ
correct {n = n} = go
where
open import Polynomial.Homomorphism homo
go : ∀ (expr : Expr Carrier n) ρ → ⟦ expr ⇓⟧ ρ ≈ ⟦ expr ⟧ ρ
go (Κ x) ρ = κ-hom x ρ
go (Ι x) ρ = ι-hom x ρ
go (x ⊕ y) ρ = ⊞-hom (norm x) (norm y) ρ ⟨ trans ⟩ (go x ρ ⟨ +-cong ⟩ go y ρ)
go (x ⊗ y) ρ = ⊠-hom (norm x) (norm y) ρ ⟨ trans ⟩ (go x ρ ⟨ *-cong ⟩ go y ρ)
go (⊝ x) ρ = ⊟-hom (norm x) ρ ⟨ trans ⟩ -‿cong (go x ρ)
go (x ⊛ i) ρ = ⊡-hom (norm x) i ρ ⟨ trans ⟩ pow-cong i (go x ρ)
open import Relation.Binary.Reflection setoid Ι ⟦_⟧ ⟦_⇓⟧ correct public
open import Data.Nat using (ℕ)
open import Data.Product
solve : ∀ {ℓ₁ ℓ₂}
→ (ring : AlmostCommutativeRing ℓ₁ ℓ₂)
→ (n : ℕ)
→ (f : N-ary n (Expr (AlmostCommutativeRing.Carrier ring) n) (Expr (AlmostCommutativeRing.Carrier ring) n × Expr (AlmostCommutativeRing.Carrier ring) n))
→ Eqʰ n (AlmostCommutativeRing._≈_ ring) (curryⁿ (Ops.⟦_⇓⟧ ring (proj₁ (Ops.close ring n f)))) (curryⁿ (Ops.⟦_⇓⟧ ring (proj₂ (Ops.close ring n f))))
→ Eq n (AlmostCommutativeRing._≈_ ring) (curryⁿ (Ops.⟦_⟧ ring (proj₁ (Ops.close ring n f)))) (curryⁿ (Ops.⟦_⟧ ring (proj₂ (Ops.close ring n f))))
solve ring = solve′
where
open Ops ring renaming (solve to solve′)
{-# INLINE solve #-}
_⊜_ : ∀ {ℓ₁ ℓ₂}
→ (ring : AlmostCommutativeRing ℓ₁ ℓ₂)
→ (n : ℕ)
→ Expr (AlmostCommutativeRing.Carrier ring) n
→ Expr (AlmostCommutativeRing.Carrier ring) n
→ Expr (AlmostCommutativeRing.Carrier ring) n × Expr (AlmostCommutativeRing.Carrier ring) n
_⊜_ _ _ = _,_
{-# INLINE _⊜_ #-}
| {
"alphanum_fraction": 0.5992936702,
"avg_line_length": 34.4018691589,
"ext": "agda",
"hexsha": "57d6779025865bb01c6625382e4fb15264eed648",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z",
"max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mckeankylej/agda-ring-solver",
"max_forks_repo_path": "src/Polynomial/Simple/Solver.agda",
"max_issues_count": 5,
"max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mckeankylej/agda-ring-solver",
"max_issues_repo_path": "src/Polynomial/Simple/Solver.agda",
"max_line_length": 159,
"max_stars_count": 36,
"max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mckeankylej/agda-ring-solver",
"max_stars_repo_path": "src/Polynomial/Simple/Solver.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z",
"num_tokens": 1473,
"size": 3681
} |
------------------------------------------------------------------------
-- A class of algebraic structures, based on non-recursive simple
-- types, satisfies the property that isomorphic instances of a
-- structure are equal (assuming univalence)
------------------------------------------------------------------------
-- In fact, isomorphism and equality are basically the same thing, and
-- the main theorem can be instantiated with several different
-- "universes", not only the one based on simple types.
-- This module is similar to
-- Univalence-axiom.Isomorphism-is-equality.Simple, but the
-- definitions of isomorphism used below are perhaps closer to the
-- "standard" ones. Carrier types also live in Type rather than Type₁
-- (at the cost of quite a bit of lifting).
-- This module has been developed in collaboration with Thierry
-- Coquand.
{-# OPTIONS --without-K --safe #-}
open import Equality
module Univalence-axiom.Isomorphism-is-equality.Simple.Variant
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open import Bijection eq as B using (_↔_)
open Derived-definitions-and-properties eq
renaming (lower-extensionality to lower-ext)
open import Equality.Decision-procedures eq
open import Equivalence eq as Eq using (_≃_)
open import Function-universe eq hiding (id; _∘_)
open import H-level eq
open import H-level.Closure eq
open import Logical-equivalence using (_⇔_; module _⇔_)
open import Preimage eq
open import Prelude as P hiding (id)
open import Univalence-axiom eq
------------------------------------------------------------------------
-- Universes with some extra stuff
-- A record type packing up some assumptions.
record Assumptions : Type₃ where
field
-- Univalence at three different levels.
univ : Univalence (# 0)
univ₁ : Univalence (# 1)
univ₂ : Univalence (# 2)
abstract
-- Extensionality.
ext : Extensionality (# 1) (# 1)
ext = dependent-extensionality univ₂ univ₁
ext₀ : Extensionality (# 0) (# 0)
ext₀ = dependent-extensionality univ₁ univ
-- Universes with some extra stuff.
record Universe : Type₃ where
field
-- Codes for something.
U : Type₁
-- Interpretation of codes.
El : U → Type → Type₁
-- A predicate, possibly specifying what it means for a bijection
-- to be an isomorphism between two elements.
Is-isomorphism : ∀ a {B C} → B ↔ C → El a B → El a C → Type₁
-- El a, seen as a predicate, respects equivalences (assuming
-- univalence).
resp : Assumptions → ∀ a {B C} → B ≃ C → El a B → El a C
-- The resp function respects identities (assuming univalence).
resp-id : (ass : Assumptions) →
∀ a {B} (x : El a B) → resp ass a Eq.id x ≡ x
-- An alternative definition of Is-isomorphism, (possibly) defined
-- using univalence.
Is-isomorphism′ : Assumptions →
∀ a {B C} → B ↔ C → El a B → El a C → Type₁
Is-isomorphism′ ass a B↔C x y = resp ass a (Eq.↔⇒≃ B↔C) x ≡ y
field
-- Is-isomorphism and Is-isomorphism′ are isomorphic (assuming
-- univalence).
isomorphism-definitions-isomorphic :
(ass : Assumptions) →
∀ a {B C} (B↔C : B ↔ C) {x y} →
Is-isomorphism a B↔C x y ↔ Is-isomorphism′ ass a B↔C x y
-- Another alternative definition of Is-isomorphism, defined using
-- univalence.
Is-isomorphism″ : Assumptions →
∀ a {B C} → B ↔ C → El a B → El a C → Type₁
Is-isomorphism″ ass a B↔C x y =
subst (El a) (≃⇒≡ univ (Eq.↔⇒≃ B↔C)) x ≡ y
where open Assumptions ass
abstract
-- Every element is isomorphic to itself, transported along the
-- isomorphism.
isomorphic-to-itself :
(ass : Assumptions) → let open Assumptions ass in
∀ a {B C} (B↔C : B ↔ C) x →
Is-isomorphism′ ass a B↔C x
(subst (El a) (≃⇒≡ univ (Eq.↔⇒≃ B↔C)) x)
isomorphic-to-itself ass a B↔C x =
transport-theorem (El a) (resp ass a) (resp-id ass a)
univ (Eq.↔⇒≃ B↔C) x
where open Assumptions ass
-- Is-isomorphism and Is-isomorphism″ are isomorphic (assuming
-- univalence).
isomorphism-definitions-isomorphic₂ :
(ass : Assumptions) →
∀ a {B C} (B↔C : B ↔ C) {x y} →
Is-isomorphism a B↔C x y ↔ Is-isomorphism″ ass a B↔C x y
isomorphism-definitions-isomorphic₂ ass a B↔C {x} {y} =
Is-isomorphism a B↔C x y ↝⟨ isomorphism-definitions-isomorphic ass a B↔C ⟩
Is-isomorphism′ ass a B↔C x y ↝⟨ ≡⇒↝ _ $ cong (λ z → z ≡ y) $ isomorphic-to-itself ass a B↔C x ⟩□
Is-isomorphism″ ass a B↔C x y □
------------------------------------------------------------------------
-- A universe-indexed family of classes of structures
module Class (Univ : Universe) where
open Universe Univ
-- Codes for structures.
Code : Type₃
Code =
-- A code.
Σ U λ a →
-- A proposition.
(C : Set (# 0)) → El a ⌞ C ⌟ → Σ Type₁ λ P →
-- The proposition should be propositional (assuming
-- univalence).
Assumptions → Is-proposition P
-- Interpretation of the codes. The elements of "Instance c" are
-- instances of the structure encoded by c.
Instance : Code → Type₁
Instance (a , P) =
-- A carrier set.
Σ (Set (# 0)) λ C →
-- An element.
Σ (El a ⌞ C ⌟) λ x →
-- The element should satisfy the proposition.
proj₁ (P C x)
-- The carrier type.
Carrier : ∀ c → Instance c → Type
Carrier _ I = ⌞ proj₁ I ⌟
-- The "element".
element : ∀ c (I : Instance c) → El (proj₁ c) (Carrier c I)
element _ I = proj₁ (proj₂ I)
-- One can prove that two instances of a structure are equal by
-- proving that the carrier types and "elements" (suitably
-- transported) are equal (assuming univalence).
instances-equal↔ :
Assumptions →
∀ c {I₁ I₂} →
(I₁ ≡ I₂) ↔
∃ λ (C-eq : Carrier c I₁ ≡ Carrier c I₂) →
subst (El (proj₁ c)) C-eq (element c I₁) ≡ element c I₂
instances-equal↔ ass (a , P)
{(C₁ , S₁) , x₁ , p₁} {(C₂ , S₂) , x₂ , p₂} =
((C₁ , λ {_ _} → S₁) , x₁ , p₁) ≡ ((C₂ , λ {_ _} → S₂) , x₂ , p₂) ↔⟨ inverse $ Eq.≃-≡ $ Eq.↔⇒≃ bij ⟩
((C₁ , x₁) , ((λ {_ _} → S₁) , p₁)) ≡
((C₂ , x₂) , ((λ {_ _} → S₂) , p₂)) ↝⟨ inverse $ ignore-propositional-component prop ⟩
((C₁ , x₁) ≡ (C₂ , x₂)) ↝⟨ inverse B.Σ-≡,≡↔≡ ⟩□
(∃ λ (C-eq : C₁ ≡ C₂) → subst (El a) C-eq x₁ ≡ x₂) □
where
bij : Instance (a , P) ↔
Σ (Σ Type (El a)) λ { (C , x) →
Σ (Is-set C) λ S → proj₁ (P (C , S) x) }
bij =
(Σ (Σ Type Is-set) λ { (C , S) →
Σ (El a C) λ x → proj₁ (P (C , S) x) }) ↝⟨ inverse Σ-assoc ⟩
(Σ Type λ C → Σ (Is-set C) λ S →
Σ (El a C) λ x → proj₁ (P (C , S) x)) ↝⟨ ∃-cong (λ _ → ∃-comm) ⟩
(Σ Type λ C → Σ (El a C) λ x →
Σ (Is-set C) λ S → proj₁ (P (C , S) x)) ↝⟨ Σ-assoc ⟩□
(Σ (Σ Type (El a)) λ { (C , x) →
Σ (Is-set C) λ S → proj₁ (P (C , S) x) }) □
prop : Is-proposition
(Σ (Is-set C₂) λ S₂ → proj₁ (P (C₂ , S₂) x₂))
prop =
Σ-closure 1
(H-level-propositional (Assumptions.ext₀ ass) 2)
(λ S₂ → proj₂ (P (C₂ , S₂) x₂) ass)
-- Structure isomorphisms.
Isomorphic : ∀ c → Instance c → Instance c → Type₁
Isomorphic (a , _) ((C₁ , _) , x₁ , _) ((C₂ , _) , x₂ , _) =
Σ (C₁ ↔ C₂) λ C₁↔C₂ → Is-isomorphism a C₁↔C₂ x₁ x₂
abstract
-- The type of isomorphisms between two instances of a structure
-- is isomorphic to the type of equalities between the same
-- instances (assuming univalence).
--
-- In short, isomorphism is isomorphic to equality.
isomorphic↔equal :
Assumptions →
∀ c {I₁ I₂} → Isomorphic c I₁ I₂ ↔ (I₁ ≡ I₂)
isomorphic↔equal ass c {I₁} {I₂} =
(∃ λ (C-eq : Carrier c I₁ ↔ Carrier c I₂) →
Is-isomorphism (proj₁ c) C-eq (element c I₁) (element c I₂)) ↝⟨ ∃-cong (λ C-eq → isomorphism-definitions-isomorphic₂
ass (proj₁ c) C-eq) ⟩
(∃ λ (C-eq : Carrier c I₁ ↔ Carrier c I₂) →
subst (El (proj₁ c)) (≃⇒≡ univ (Eq.↔⇒≃ C-eq)) (element c I₁) ≡
element c I₂) ↝⟨ Σ-cong (Eq.↔↔≃ ext₀ (proj₂ (proj₁ I₁))) (λ _ → _ □) ⟩
(∃ λ (C-eq : Carrier c I₁ ≃ Carrier c I₂) →
subst (El (proj₁ c)) (≃⇒≡ univ C-eq) (element c I₁) ≡
element c I₂) ↝⟨ inverse $
Σ-cong (≡≃≃ univ) (λ C-eq → ≡⇒↝ _ $ sym $
cong (λ eq → subst (El (proj₁ c)) eq (element c I₁) ≡
element c I₂)
(_≃_.left-inverse-of (≡≃≃ univ) C-eq)) ⟩
(∃ λ (C-eq : Carrier c I₁ ≡ Carrier c I₂) →
subst (El (proj₁ c)) C-eq (element c I₁) ≡ element c I₂) ↝⟨ inverse $ instances-equal↔ ass c ⟩□
(I₁ ≡ I₂) □
where open Assumptions ass
-- The first part of the from component of the preceding lemma is
-- extensionally equal to a simple function. (The codomain of the
-- second part is propositional whenever El (proj₁ c) applied to
-- either carrier type is a set.)
proj₁-from-isomorphic↔equal :
∀ ass c {I J} (I≡J : I ≡ J) →
proj₁ (_↔_.from (isomorphic↔equal ass c) I≡J) ≡
_≃_.bijection (≡⇒≃ (cong (proj₁ ∘ proj₁) I≡J))
proj₁-from-isomorphic↔equal ass (a , P) I≡J =
let A = Instance (a , P)
B = Σ (∃ (El a)) λ { (C , x) →
∃ λ (S : Is-set C) → proj₁ (P (C , S) x) }
in
cong (_≃_.bijection ∘ ≡⇒≃) (
proj₁ (Σ-≡,≡←≡ (proj₁ (Σ-≡,≡←≡ (cong {B = B}
(λ { ((C , S) , x , p) → (C , x) , S , p }) I≡J)))) ≡⟨ cong (proj₁ ∘ Σ-≡,≡←≡) $ proj₁-Σ-≡,≡←≡ _ ⟩
proj₁ (Σ-≡,≡←≡ (cong proj₁ (cong {B = B}
(λ { ((C , S) , x , p) → (C , x) , S , p }) I≡J))) ≡⟨ cong (proj₁ ∘ Σ-≡,≡←≡) $
cong-∘ {B = B} proj₁
(λ { ((C , S) , x , p) → (C , x) , S , p }) _ ⟩
proj₁ (Σ-≡,≡←≡ (cong {A = A}
(λ { ((C , S) , x , p) → C , x }) I≡J)) ≡⟨ proj₁-Σ-≡,≡←≡ _ ⟩
cong proj₁ (cong {A = A} (λ { ((C , S) , x , p) → C , x }) I≡J) ≡⟨ cong-∘ {A = A} proj₁ (λ { ((C , S) , x , p) → C , x }) _ ⟩∎
cong (proj₁ ∘ proj₁) I≡J ∎)
-- The type of (lifted) isomorphisms between two instances of a
-- structure is equal to the type of equalities between the same
-- instances (assuming univalence).
--
-- In short, isomorphism is equal to equality.
isomorphic≡equal :
Assumptions →
∀ c {I₁ I₂} → Isomorphic c I₁ I₂ ≡ (I₁ ≡ I₂)
isomorphic≡equal ass c {I₁} {I₂} =
≃⇒≡ univ₁ $ Eq.↔⇒≃ (isomorphic↔equal ass c)
where open Assumptions ass
------------------------------------------------------------------------
-- A universe of non-recursive, simple types
-- Codes for types.
infixr 20 _⊗_
infixr 15 _⊕_
infixr 10 _⇾_
data U : Type₁ where
id prop : U
k : Type → U
_⇾_ _⊕_ _⊗_ : U → U → U
-- Interpretation of types.
El : U → Type₁ → Type₁
El id B = B
El prop B = Proposition (# 0)
El (k A) B = ↑ _ A
El (a ⇾ b) B = El a B → El b B
El (a ⊕ b) B = El a B ⊎ El b B
El (a ⊗ b) B = El a B × El b B
-- El a preserves equivalences (assuming extensionality).
cast : Extensionality (# 1) (# 1) →
∀ a {B C} → B ≃ C → El a B ≃ El a C
cast ext id B≃C = B≃C
cast ext prop B≃C = Eq.id
cast ext (k A) B≃C = Eq.id
cast ext (a ⇾ b) B≃C = →-cong ext (cast ext a B≃C) (cast ext b B≃C)
cast ext (a ⊕ b) B≃C = cast ext a B≃C ⊎-cong cast ext b B≃C
cast ext (a ⊗ b) B≃C = cast ext a B≃C ×-cong cast ext b B≃C
abstract
-- The cast function respects identities (assuming extensionality).
cast-id : (ext : Extensionality (# 1) (# 1)) →
∀ a {B} → cast ext a (Eq.id {A = B}) ≡ Eq.id
cast-id ext id = refl _
cast-id ext prop = refl _
cast-id ext (k A) = refl _
cast-id ext (a ⇾ b) = Eq.lift-equality ext $ cong _≃_.to $
cong₂ (→-cong ext) (cast-id ext a) (cast-id ext b)
cast-id ext (a ⊗ b) = Eq.lift-equality ext $ cong _≃_.to $
cong₂ _×-cong_ (cast-id ext a) (cast-id ext b)
cast-id ext (a ⊕ b) =
cast ext a Eq.id ⊎-cong cast ext b Eq.id ≡⟨ cong₂ _⊎-cong_ (cast-id ext a) (cast-id ext b) ⟩
Eq.⟨ [ inj₁ , inj₂ ] , _ ⟩ ≡⟨ Eq.lift-equality ext (apply-ext ext [ refl ∘ inj₁ , refl ∘ inj₂ ]) ⟩∎
Eq.id ∎
-- The property of being an isomorphism between two elements.
Is-isomorphism : ∀ a {B C} → B ↔ C → El a B → El a C → Type₁
Is-isomorphism id B↔C = λ x y → _↔_.to B↔C x ≡ y
Is-isomorphism prop B↔C = λ { (P , _) (Q , _) → ↑ _ (P ⇔ Q) }
Is-isomorphism (k A) B↔C = λ x y → x ≡ y
Is-isomorphism (a ⇾ b) B↔C = Is-isomorphism a B↔C →-rel
Is-isomorphism b B↔C
Is-isomorphism (a ⊕ b) B↔C = Is-isomorphism a B↔C ⊎-rel
Is-isomorphism b B↔C
Is-isomorphism (a ⊗ b) B↔C = Is-isomorphism a B↔C ×-rel
Is-isomorphism b B↔C
-- Another definition of "being an isomorphism" (defined using
-- extensionality).
Is-isomorphism′ : Extensionality (# 1) (# 1) →
∀ a {B C} → B ↔ C → El a B → El a C → Type₁
Is-isomorphism′ ext a B↔C x y = _≃_.to (cast ext a (Eq.↔⇒≃ B↔C)) x ≡ y
abstract
-- The two definitions of "being an isomorphism" are "isomorphic"
-- (in bijective correspondence), assuming univalence.
isomorphism-definitions-isomorphic :
(ass : Assumptions) → let open Assumptions ass in
∀ a {B C} (B↔C : B ↔ C) {x y} →
Is-isomorphism a B↔C x y ↔ Is-isomorphism′ ext a B↔C x y
isomorphism-definitions-isomorphic ass id B↔C {x} {y} =
(_↔_.to B↔C x ≡ y) □
isomorphism-definitions-isomorphic ass prop B↔C {P} {Q} =
↑ _ (proj₁ P ⇔ proj₁ Q) ↝⟨ B.↑↔ ⟩
(proj₁ P ⇔ proj₁ Q) ↝⟨ Eq.⇔↔≃ ext₀ (proj₂ P) (proj₂ Q) ⟩
(proj₁ P ≃ proj₁ Q) ↔⟨ inverse $ ≡≃≃ univ ⟩
(proj₁ P ≡ proj₁ Q) ↝⟨ ignore-propositional-component (H-level-propositional ext₀ 1) ⟩□
(P ≡ Q) □
where open Assumptions ass
isomorphism-definitions-isomorphic ass (k A) B↔C {x} {y} =
(x ≡ y) □
isomorphism-definitions-isomorphic ass (a ⇾ b) B↔C {f} {g} =
let B≃C = Eq.↔⇒≃ B↔C in
(∀ x y → Is-isomorphism a B↔C x y →
Is-isomorphism b B↔C (f x) (g y)) ↝⟨ ∀-cong ext (λ _ → ∀-cong ext λ _ →
→-cong ext (isomorphism-definitions-isomorphic ass a B↔C)
(isomorphism-definitions-isomorphic ass b B↔C)) ⟩
(∀ x y → to (cast ext a B≃C) x ≡ y →
to (cast ext b B≃C) (f x) ≡ g y) ↝⟨ inverse $ ∀-cong ext (λ x →
∀-intro (λ y _ → to (cast ext b B≃C) (f x) ≡ g y) ext) ⟩
(∀ x → to (cast ext b B≃C) (f x) ≡ g (to (cast ext a B≃C) x)) ↔⟨ Eq.extensionality-isomorphism ext ⟩
(to (cast ext b B≃C) ∘ f ≡ g ∘ to (cast ext a B≃C)) ↝⟨ inverse $ ∘from≡↔≡∘to ext (cast ext a B≃C) ⟩□
(to (cast ext b B≃C) ∘ f ∘ from (cast ext a B≃C) ≡ g) □
where
open _≃_
open Assumptions ass
isomorphism-definitions-isomorphic ass (a ⊕ b) B↔C {inj₁ x} {inj₁ y} =
let B≃C = Eq.↔⇒≃ B↔C in
Is-isomorphism a B↔C x y ↝⟨ isomorphism-definitions-isomorphic ass a B↔C ⟩
(to (cast ext a B≃C) x ≡ y) ↝⟨ B.≡↔inj₁≡inj₁ ⟩□
(inj₁ (to (cast ext a B≃C) x) ≡ inj₁ y) □
where
open _≃_
open Assumptions ass
isomorphism-definitions-isomorphic ass (a ⊕ b) B↔C {inj₂ x} {inj₂ y} =
let B≃C = Eq.↔⇒≃ B↔C in
Is-isomorphism b B↔C x y ↝⟨ isomorphism-definitions-isomorphic ass b B↔C ⟩
(to (cast ext b B≃C) x ≡ y) ↝⟨ B.≡↔inj₂≡inj₂ ⟩□
(inj₂ (to (cast ext b B≃C) x) ≡ inj₂ y) □
where
open _≃_
open Assumptions ass
isomorphism-definitions-isomorphic ass (a ⊕ b) B↔C {inj₁ x} {inj₂ y} =
⊥ ↝⟨ B.⊥↔uninhabited ⊎.inj₁≢inj₂ ⟩□
(inj₁ _ ≡ inj₂ _) □
isomorphism-definitions-isomorphic ass (a ⊕ b) B↔C {inj₂ x} {inj₁ y} =
⊥ ↝⟨ B.⊥↔uninhabited (⊎.inj₁≢inj₂ ∘ sym) ⟩□
(inj₂ _ ≡ inj₁ _) □
isomorphism-definitions-isomorphic ass (a ⊗ b) B↔C {x , u} {y , v} =
let B≃C = Eq.↔⇒≃ B↔C in
Is-isomorphism a B↔C x y × Is-isomorphism b B↔C u v ↝⟨ isomorphism-definitions-isomorphic ass a B↔C ×-cong
isomorphism-definitions-isomorphic ass b B↔C ⟩
(to (cast ext a B≃C) x ≡ y × to (cast ext b B≃C) u ≡ v) ↝⟨ ≡×≡↔≡ ⟩□
((to (cast ext a B≃C) x , to (cast ext b B≃C) u) ≡ (y , v)) □
where
open _≃_
open Assumptions ass
-- The universe above is a "universe with some extra stuff".
simple : Universe
simple = record
{ U = U
; El = λ a → El a ∘ ↑ _
; Is-isomorphism = λ a B↔C → Is-isomorphism a (↑-cong B↔C)
; resp = λ ass a → _≃_.to ∘ cast (ext ass) a ∘ ↑-cong
; resp-id = λ ass a x → cong (λ f → _≃_.to f x) (
cast (ext ass) a (↑-cong Eq.id) ≡⟨ cong (cast (ext ass) a) $ Eq.lift-equality (ext ass) (refl _) ⟩
cast (ext ass) a Eq.id ≡⟨ cast-id (ext ass) a ⟩∎
Eq.id ∎)
; isomorphism-definitions-isomorphic = λ ass a B↔C {x y} →
Is-isomorphism a (↑-cong B↔C) x y ↝⟨ isomorphism-definitions-isomorphic ass a (↑-cong B↔C) ⟩
(_≃_.to (cast (ext ass) a (Eq.↔⇒≃ (↑-cong B↔C))) x ≡ y) ↝⟨ ≡⇒↝ _ $ cong (λ eq → _≃_.to (cast (ext ass) a eq) x ≡ y) $
Eq.lift-equality (ext ass) (refl _) ⟩□
(_≃_.to (cast (ext ass) a (↑-cong (Eq.↔⇒≃ B↔C))) x ≡ y) □
}
where open Assumptions
-- Let us use this universe in the examples below.
open Class simple
------------------------------------------------------------------------
-- An example: monoids
monoid : Code
monoid =
-- Binary operation.
(id ⇾ id ⇾ id) ⊗
-- Identity.
id ,
λ { (_ , M-set) (_∙_ , e) →
(-- Left and right identity laws.
(∀ x → (e ∙ x) ≡ x) ×
(∀ x → (x ∙ e) ≡ x) ×
-- Associativity.
(∀ x y z → (x ∙ (y ∙ z)) ≡ ((x ∙ y) ∙ z))) ,
-- The laws are propositional (assuming extensionality).
λ ass → let open Assumptions ass in
×-closure 1 (Π-closure ext 1 λ _ →
↑-closure 2 M-set)
(×-closure 1 (Π-closure ext 1 λ _ →
↑-closure 2 M-set)
(Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 M-set)) }
-- The interpretation of the code is reasonable.
Instance-monoid :
Instance monoid
≡
Σ (Set (# 0)) λ { (M , _) →
Σ ((↑ _ M → ↑ _ M → ↑ _ M) × ↑ _ M) λ { (_∙_ , e) →
(∀ x → (e ∙ x) ≡ x) ×
(∀ x → (x ∙ e) ≡ x) ×
(∀ x y z → (x ∙ (y ∙ z)) ≡ ((x ∙ y) ∙ z)) }}
Instance-monoid = refl _
-- The notion of isomorphism that we get is also reasonable.
Isomorphic-monoid :
∀ {M₁} {S₁ : Is-set M₁} {_∙₁_ e₁ laws₁}
{M₂} {S₂ : Is-set M₂} {_∙₂_ e₂ laws₂} →
Isomorphic monoid ((M₁ , S₁) , (_∙₁_ , e₁) , laws₁)
((M₂ , S₂) , (_∙₂_ , e₂) , laws₂)
≡
Σ (M₁ ↔ M₂) λ M₁↔M₂ → let open _↔_ (↑-cong M₁↔M₂) in
(∀ x y → to x ≡ y → ∀ u v → to u ≡ v → to (x ∙₁ u) ≡ (y ∙₂ v)) ×
to e₁ ≡ e₂
Isomorphic-monoid = refl _
-- Note that this definition of isomorphism is isomorphic to a more
-- standard one (assuming extensionality).
Isomorphism-monoid-isomorphic-to-standard :
Extensionality (# 1) (# 1) →
∀ {M₁} {S₁ : Is-set M₁} {_∙₁_ e₁ laws₁}
{M₂} {S₂ : Is-set M₂} {_∙₂_ e₂ laws₂} →
Isomorphic monoid ((M₁ , S₁) , (_∙₁_ , e₁) , laws₁)
((M₂ , S₂) , (_∙₂_ , e₂) , laws₂)
↔
Σ (M₁ ↔ M₂) λ M₁↔M₂ → let open _↔_ (↑-cong M₁↔M₂) in
(∀ x y → to (x ∙₁ y) ≡ (to x ∙₂ to y)) ×
to e₁ ≡ e₂
Isomorphism-monoid-isomorphic-to-standard ext
{M₁} {S₁} {_∙₁_} {e₁} {M₂ = M₂} {_∙₂_ = _∙₂_} {e₂} =
(Σ (M₁ ↔ M₂) λ M₁↔M₂ → let open _↔_ (↑-cong M₁↔M₂) in
(∀ x y → to x ≡ y → ∀ u v → to u ≡ v → to (x ∙₁ u) ≡ (y ∙₂ v)) ×
to e₁ ≡ e₂) ↝⟨ inverse $ ∃-cong (λ _ →
(∀-cong ext λ _ → ∀-intro (λ _ _ → _) ext) ×-cong (_ □)) ⟩
(Σ (M₁ ↔ M₂) λ M₁↔M₂ → let open _↔_ (↑-cong M₁↔M₂) in
(∀ x u v → to u ≡ v → to (x ∙₁ u) ≡ (to x ∙₂ v)) ×
to e₁ ≡ e₂) ↝⟨ inverse $ ∃-cong (λ _ →
(∀-cong ext λ _ → ∀-cong ext λ _ → ∀-intro (λ _ _ → _) ext)
×-cong
(_ □)) ⟩□
(Σ (M₁ ↔ M₂) λ M₁↔M₂ → let open _↔_ (↑-cong M₁↔M₂) in
(∀ x u → to (x ∙₁ u) ≡ (to x ∙₂ to u)) ×
to e₁ ≡ e₂) □
------------------------------------------------------------------------
-- An example: posets
poset : Code
poset =
-- The ordering relation.
(id ⇾ id ⇾ prop) ,
λ { (P , P-set) Le →
let _≤_ : ↑ _ P → ↑ _ P → Type
_≤_ x y = proj₁ (Le x y)
in
-- Reflexivity.
((∀ x → x ≤ x) ×
-- Transitivity.
(∀ x y z → x ≤ y → y ≤ z → x ≤ z) ×
-- Antisymmetry.
(∀ x y → x ≤ y → y ≤ x → x ≡ y)) ,
λ ass → let open Assumptions ass in
×-closure 1 (Π-closure (lower-ext (# 0) _ ext) 1 λ _ →
proj₂ (Le _ _))
(×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure (lower-ext (# 0) _ ext) 1 λ _ →
Π-closure ext₀ 1 λ _ →
Π-closure ext₀ 1 λ _ →
proj₂ (Le _ _))
(Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure (lower-ext _ (# 0) ext) 1 λ _ →
Π-closure (lower-ext _ (# 0) ext) 1 λ _ →
↑-closure 2 P-set)) }
-- The interpretation of the code is reasonable.
Instance-poset :
Instance poset
≡
Σ (Set (# 0)) λ { (P , _) →
Σ (↑ _ P → ↑ _ P → Proposition (# 0)) λ Le →
let _≤_ : ↑ _ P → ↑ _ P → Type
_≤_ x y = proj₁ (Le x y)
in
(∀ x → x ≤ x) ×
(∀ x y z → x ≤ y → y ≤ z → x ≤ z) ×
(∀ x y → x ≤ y → y ≤ x → x ≡ y) }
Instance-poset = refl _
-- The notion of isomorphism that we get is also reasonable. It is the
-- usual notion of "order isomorphism".
Isomorphic-poset :
∀ {P₁} {S₁ : Is-set P₁} {Le₁ laws₁}
{P₂} {S₂ : Is-set P₂} {Le₂ laws₂} →
let _≤₁_ : ↑ _ P₁ → ↑ _ P₁ → Type
_≤₁_ x y = proj₁ (Le₁ x y)
_≤₂_ : ↑ _ P₂ → ↑ _ P₂ → Type
_≤₂_ x y = proj₁ (Le₂ x y)
in
Isomorphic poset ((P₁ , S₁) , Le₁ , laws₁) ((P₂ , S₂) , Le₂ , laws₂)
≡
Σ (P₁ ↔ P₂) λ P₁↔P₂ → let open _↔_ (↑-cong P₁↔P₂) in
∀ a b → to a ≡ b → ∀ c d → to c ≡ d → ↑ _ ((a ≤₁ c) ⇔ (b ≤₂ d))
Isomorphic-poset = refl _
------------------------------------------------------------------------
-- An example: discrete fields
-- Discrete fields.
discrete-field : Code
discrete-field =
-- Addition.
(id ⇾ id ⇾ id) ⊗
-- Zero.
id ⊗
-- Multiplication.
(id ⇾ id ⇾ id) ⊗
-- One.
id ⊗
-- Minus.
(id ⇾ id) ⊗
-- Multiplicative inverse (a partial operation).
(id ⇾ k ⊤ ⊕ id) ,
λ { (_ , F-set) (_+_ , 0# , _*_ , 1# , -_ , _⁻¹) →
-- Associativity.
((∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) ×
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) ×
-- Commutativity.
(∀ x y → (x + y) ≡ (y + x)) ×
(∀ x y → (x * y) ≡ (y * x)) ×
-- Distributivity.
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) ×
-- Identity laws.
(∀ x → (x + 0#) ≡ x) ×
(∀ x → (x * 1#) ≡ x) ×
-- Zero and one are distinct.
0# ≢ 1# ×
-- Inverse laws.
(∀ x → (x + (- x)) ≡ 0#) ×
(∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#) ×
(∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#)) ,
λ ass → let open Assumptions ass in
×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 F-set)
(×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 F-set)
(×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 F-set)
(×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 F-set)
(×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 F-set)
(×-closure 1 (Π-closure ext 1 λ _ →
↑-closure 2 F-set)
(×-closure 1 (Π-closure ext 1 λ _ →
↑-closure 2 F-set)
(×-closure 1 (Π-closure (lower-ext (# 0) (# 1) ext) 1 λ _ →
⊥-propositional)
(×-closure 1 (Π-closure ext 1 λ _ →
↑-closure 2 F-set)
(×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 F-set)
(Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 F-set)))))))))) }
-- The interpretation of the code is reasonable.
Instance-discrete-field :
Instance discrete-field
≡
Σ (Set (# 0)) λ { (F , _) →
Σ ((↑ _ F → ↑ _ F → ↑ _ F) × ↑ _ F × (↑ _ F → ↑ _ F → ↑ _ F) ×
↑ _ F × (↑ _ F → ↑ _ F) × (↑ _ F → ↑ (# 1) ⊤ ⊎ ↑ _ F))
λ { (_+_ , 0# , _*_ , 1# , -_ , _⁻¹) →
(∀ x y z → (x + (y + z)) ≡ ((x + y) + z)) ×
(∀ x y z → (x * (y * z)) ≡ ((x * y) * z)) ×
(∀ x y → (x + y) ≡ (y + x)) ×
(∀ x y → (x * y) ≡ (y * x)) ×
(∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))) ×
(∀ x → (x + 0#) ≡ x) ×
(∀ x → (x * 1#) ≡ x) ×
0# ≢ 1# ×
(∀ x → (x + (- x)) ≡ 0#) ×
(∀ x → (x ⁻¹) ≡ inj₁ (lift tt) → x ≡ 0#) ×
(∀ x y → (x ⁻¹) ≡ inj₂ y → (x * y) ≡ 1#) }}
Instance-discrete-field = refl _
-- The notion of isomorphism that we get is also reasonable.
Isomorphic-discrete-field :
∀ {F₁} {S₁ : Is-set F₁} {_+₁_ 0₁ _*₁_ 1₁ -₁_ _⁻¹₁ laws₁}
{F₂} {S₂ : Is-set F₂} {_+₂_ 0₂ _*₂_ 1₂ -₂_ _⁻¹₂ laws₂} →
Isomorphic discrete-field
((F₁ , S₁) , (_+₁_ , 0₁ , _*₁_ , 1₁ , -₁_ , _⁻¹₁) , laws₁)
((F₂ , S₂) , (_+₂_ , 0₂ , _*₂_ , 1₂ , -₂_ , _⁻¹₂) , laws₂)
≡
Σ (F₁ ↔ F₂) λ F₁↔F₂ → let open _↔_ (↑-cong F₁↔F₂) in
(∀ x y → to x ≡ y → ∀ u v → to u ≡ v → to (x +₁ u) ≡ (y +₂ v)) ×
to 0₁ ≡ 0₂ ×
(∀ x y → to x ≡ y → ∀ u v → to u ≡ v → to (x *₁ u) ≡ (y *₂ v)) ×
to 1₁ ≡ 1₂ ×
(∀ x y → to x ≡ y → to (-₁ x) ≡ (-₂ y)) ×
(∀ x y → to x ≡ y →
((λ _ _ → lift tt ≡ lift tt) ⊎-rel (λ u v → to u ≡ v))
(x ⁻¹₁) (y ⁻¹₂))
Isomorphic-discrete-field = refl _
------------------------------------------------------------------------
-- An example: vector spaces over discrete fields
-- Vector spaces over a particular discrete field.
vector-space : Instance discrete-field → Code
vector-space ((F , _) , (_+F_ , _ , _*F_ , 1F , _ , _) , _) =
-- Addition.
(id ⇾ id ⇾ id) ⊗
-- Scalar multiplication.
(k F ⇾ id ⇾ id) ⊗
-- Zero vector.
id ⊗
-- Additive inverse.
(id ⇾ id) ,
λ { (_ , V-set) (_+_ , _*_ , 0V , -_) →
-- Associativity.
((∀ u v w → (u + (v + w)) ≡ ((u + v) + w)) ×
(∀ x y v → (x * (y * v)) ≡ ((x *F y) * v)) ×
-- Commutativity.
(∀ u v → (u + v) ≡ (v + u)) ×
-- Distributivity.
(∀ x u v → (x * (u + v)) ≡ ((x * u) + (x * v))) ×
(∀ x y v → ((x +F y) * v) ≡ ((x * v) + (y * v))) ×
-- Identity laws.
(∀ v → (v + 0V) ≡ v) ×
(∀ v → (1F * v) ≡ v) ×
-- Inverse law.
(∀ v → (v + (- v)) ≡ 0V)) ,
λ ass → let open Assumptions ass in
×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 V-set)
(×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 V-set)
(×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 V-set)
(×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 V-set)
(×-closure 1 (Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
↑-closure 2 V-set)
(×-closure 1 (Π-closure ext 1 λ _ →
↑-closure 2 V-set)
(×-closure 1 (Π-closure ext 1 λ _ →
↑-closure 2 V-set)
(Π-closure ext 1 λ _ →
↑-closure 2 V-set))))))) }
-- The interpretation of the code is reasonable.
Instance-vector-space :
∀ {F} {S : Is-set F} {_+F_ 0F _*F_ 1F -F_ _⁻¹F laws} →
Instance (vector-space
((F , S) , (_+F_ , 0F , _*F_ , 1F , -F_ , _⁻¹F) , laws))
≡
Σ (Set (# 0)) λ { (V , _) →
Σ ((↑ _ V → ↑ _ V → ↑ _ V) × (↑ _ F → ↑ _ V → ↑ _ V) × ↑ _ V ×
(↑ _ V → ↑ _ V))
λ { (_+_ , _*_ , 0V , -_) →
(∀ u v w → (u + (v + w)) ≡ ((u + v) + w)) ×
(∀ x y v → (x * (y * v)) ≡ ((x *F y) * v)) ×
(∀ u v → (u + v) ≡ (v + u)) ×
(∀ x u v → (x * (u + v)) ≡ ((x * u) + (x * v))) ×
(∀ x y v → ((x +F y) * v) ≡ ((x * v) + (y * v))) ×
(∀ v → (v + 0V) ≡ v) ×
(∀ v → (1F * v) ≡ v) ×
(∀ v → (v + (- v)) ≡ 0V) }}
Instance-vector-space = refl _
-- The notion of isomorphism that we get is also reasonable.
Isomorphic-vector-space :
∀ {F V₁} {S₁ : Is-set V₁} {_+₁_ _*₁_ 0₁ -₁_ laws₁}
{V₂} {S₂ : Is-set V₂} {_+₂_ _*₂_ 0₂ -₂_ laws₂} →
Isomorphic (vector-space F)
((V₁ , S₁) , (_+₁_ , _*₁_ , 0₁ , -₁_) , laws₁)
((V₂ , S₂) , (_+₂_ , _*₂_ , 0₂ , -₂_) , laws₂)
≡
Σ (V₁ ↔ V₂) λ V₁↔V₂ → let open _↔_ (↑-cong V₁↔V₂) in
(∀ a b → to a ≡ b → ∀ u v → to u ≡ v → to (a +₁ u) ≡ (b +₂ v)) ×
(∀ x y → x ≡ y → ∀ u v → to u ≡ v → to (x *₁ u) ≡ (y *₂ v)) ×
to 0₁ ≡ 0₂ ×
(∀ u v → to u ≡ v → to (-₁ u) ≡ (-₂ v))
Isomorphic-vector-space = refl _
------------------------------------------------------------------------
-- An example: sets equipped with fixpoint operators
set-with-fixpoint-operator : Code
set-with-fixpoint-operator =
(id ⇾ id) ⇾ id ,
λ { (_ , F-set) fix →
-- The fixpoint operator property.
(∀ f → f (fix f) ≡ fix f) ,
λ ass → let open Assumptions ass in
Π-closure ext 1 λ _ →
↑-closure 2 F-set }
-- The usual unfolding lemmas.
Instance-set-with-fixpoint-operator :
Instance set-with-fixpoint-operator
≡
Σ (Set (# 0)) λ { (F , _) →
Σ ((↑ _ F → ↑ _ F) → ↑ _ F) λ fix →
∀ f → f (fix f) ≡ fix f }
Instance-set-with-fixpoint-operator = refl _
Isomorphic-set-with-fixpoint-operator :
∀ {F₁} {S₁ : Is-set F₁} {fix₁ law₁}
{F₂} {S₂ : Is-set F₂} {fix₂ law₂} →
Isomorphic set-with-fixpoint-operator
((F₁ , S₁) , fix₁ , law₁) ((F₂ , S₂) , fix₂ , law₂)
≡
Σ (F₁ ↔ F₂) λ F₁↔F₂ → let open _↔_ (↑-cong F₁↔F₂) in
∀ f g → (∀ x y → to x ≡ y → to (f x) ≡ g y) → to (fix₁ f) ≡ fix₂ g
Isomorphic-set-with-fixpoint-operator = refl _
| {
"alphanum_fraction": 0.4544647232,
"avg_line_length": 34.0521376434,
"ext": "agda",
"hexsha": "a4d40ec61c6a585dc56e4458102e0d0ad16a71ef",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/Univalence-axiom/Isomorphism-is-equality/Simple/Variant.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/equality",
"max_issues_repo_path": "src/Univalence-axiom/Isomorphism-is-equality/Simple/Variant.agda",
"max_line_length": 135,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Univalence-axiom/Isomorphism-is-equality/Simple/Variant.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 12287,
"size": 32656
} |
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module LogicalFramework.Existential where
module LF where
postulate
D : Set
-- Disjunction.
_∨_ : Set → Set → Set
inj₁ : {A B : Set} → A → A ∨ B
inj₂ : {A B : Set} → B → A ∨ B
case : {A B C : Set} → (A → C) → (B → C) → A ∨ B → C
-- The existential quantifier type on D.
∃ : (A : D → Set) → Set
_,_ : {A : D → Set}(t : D) → A t → ∃ A
∃-proj₁ : {A : D → Set} → ∃ A → D
∃-proj₂ : {A : D → Set}(h : ∃ A) → A (∃-proj₁ h)
∃-elim : {A : D → Set}{B : Set} → ∃ A → (∀ {x} → A x → B) → B
syntax ∃ (λ x → e) = ∃[ x ] e
module FOL-Examples where
-- Using the projections.
∃∀₁ : {A : D → D → Set} → ∃[ x ](∀ y → A x y) → ∀ y → ∃[ x ] A x y
∃∀₁ h y = ∃-proj₁ h , (∃-proj₂ h) y
∃∨₁ : {A B : D → Set} → ∃[ x ](A x ∨ B x) → (∃[ x ] A x) ∨ (∃[ x ] B x)
∃∨₁ h = case (λ Ax → inj₁ (∃-proj₁ h , Ax))
(λ Bx → inj₂ (∃-proj₁ h , Bx))
(∃-proj₂ h)
-- Using the elimination.
∃∀₂ : {A : D → D → Set} → ∃[ x ](∀ y → A x y) → ∀ y → ∃[ x ] A x y
∃∀₂ h y = ∃-elim h (λ {x} ah → x , ah y)
∃∨₂ : {A B : D → Set} → ∃[ x ](A x ∨ B x) → (∃[ x ] A x) ∨ (∃[ x ] B x)
∃∨₂ h = ∃-elim h (λ {x} ah → case (λ Ax → inj₁ (x , Ax))
(λ Bx → inj₂ (x , Bx))
ah)
module NonFOL-Examples where
-- Using the projections.
non-FOL₁ : {A : D → Set} → ∃ A → D
non-FOL₁ h = ∃-proj₁ h
-- Using the elimination.
non-FOL₂ : {A : D → Set} → ∃ A → D
non-FOL₂ h = ∃-elim h (λ {x} _ → x)
module Inductive where
open import Common.FOL.FOL
-- The existential proyections.
∃-proj₁ : ∀ {A} → ∃ A → D
∃-proj₁ (x , _) = x
∃-proj₂ : ∀ {A} → (h : ∃ A) → A (∃-proj₁ h)
∃-proj₂ (_ , Ax) = Ax
-- The existential elimination.
∃-elim : {A : D → Set}{B : Set} → ∃ A → (∀ {x} → A x → B) → B
∃-elim (_ , Ax) h = h Ax
module FOL-Examples where
-- Using the projections.
∃∀₁ : {A : D → D → Set} → ∃[ x ](∀ y → A x y) → ∀ y → ∃[ x ] A x y
∃∀₁ h y = ∃-proj₁ h , (∃-proj₂ h) y
∃∨₁ : {A B : D → Set} → ∃[ x ](A x ∨ B x) → (∃[ x ] A x) ∨ (∃[ x ] B x)
∃∨₁ h = case (λ Ax → inj₁ (∃-proj₁ h , Ax))
(λ Bx → inj₂ (∃-proj₁ h , Bx))
(∃-proj₂ h)
-- Using the elimination.
∃∀₂ : {A : D → D → Set} → ∃[ x ](∀ y → A x y) → ∀ y → ∃[ x ] A x y
∃∀₂ h y = ∃-elim h (λ {x} ah → x , ah y)
∃∨₂ : {A B : D → Set} → ∃[ x ](A x ∨ B x) → (∃[ x ] A x) ∨ (∃[ x ] B x)
∃∨₂ h = ∃-elim h (λ {x} ah → case (λ Ax → inj₁ (x , Ax))
(λ Bx → inj₂ (x , Bx))
ah)
-- Using pattern matching.
∃∀₃ : {A : D → D → Set} → ∃[ x ](∀ y → A x y) → ∀ y → ∃[ x ] A x y
∃∀₃ (x , Ax) y = x , Ax y
∃∨₃ : {A B : D → Set} → ∃[ x ](A x ∨ B x) → (∃[ x ] A x) ∨ (∃[ x ] B x)
∃∨₃ (x , inj₁ Ax) = inj₁ (x , Ax)
∃∨₃ (x , inj₂ Bx) = inj₂ (x , Bx)
module NonFOL-Examples where
-- Using the projections.
non-FOL₁ : {A : D → Set} → ∃ A → D
non-FOL₁ h = ∃-proj₁ h
-- Using the elimination.
non-FOL₂ : {A : D → Set} → ∃ A → D
non-FOL₂ h = ∃-elim h (λ {x} _ → x)
-- Using the pattern matching.
non-FOL₃ : {A : D → Set} → ∃ A → D
non-FOL₃ (x , _) = x
| {
"alphanum_fraction": 0.388872874,
"avg_line_length": 31.2522522523,
"ext": "agda",
"hexsha": "1a06f1ca47dc9b4943297b138f9ba956e2d743d1",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/thesis/report/LogicalFramework/Existential.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/thesis/report/LogicalFramework/Existential.agda",
"max_line_length": 75,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/thesis/report/LogicalFramework/Existential.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 1547,
"size": 3469
} |
module Prelude where
open import Agda.Primitive public
using (_⊔_)
renaming (lsuc to ↑_)
-- Built-in implication.
id : ∀ {ℓ} {X : Set ℓ} → X → X
id x = x
const : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → X → Y → X
const x y = x
flip : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
(X → Y → Z) → Y → X → Z
flip P y x = P x y
ap : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
(X → Y → Z) → (X → Y) → X → Z
ap f g x = f x (g x)
infixr 9 _∘_
_∘_ : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
(Y → Z) → (X → Y) → X → Z
f ∘ g = λ x → f (g x)
refl→ : ∀ {ℓ} {X : Set ℓ} → X → X
refl→ = id
trans→ : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
(X → Y) → (Y → Z) → X → Z
trans→ = flip _∘_
-- Built-in verum.
open import Agda.Builtin.Unit public
using (⊤)
renaming (tt to ∙)
-- Falsum.
data ⊥ : Set where
{-# HASKELL data AgdaEmpty #-}
{-# COMPILED_DATA ⊥ MAlonzo.Code.Data.Empty.AgdaEmpty #-}
elim⊥ : ∀ {ℓ} {X : Set ℓ} → ⊥ → X
elim⊥ ()
-- Negation.
infix 3 ¬_
¬_ : ∀ {ℓ} → Set ℓ → Set ℓ
¬ X = X → ⊥
_↯_ : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → X → ¬ X → Y
p ↯ ¬p = elim⊥ (¬p p)
-- Built-in equality.
open import Agda.Builtin.Equality public
using (_≡_ ; refl)
infix 4 _≢_
_≢_ : ∀ {ℓ} {X : Set ℓ} → X → X → Set ℓ
x ≢ x′ = ¬ (x ≡ x′)
trans : ∀ {ℓ} {X : Set ℓ} {x x′ x″ : X} → x ≡ x′ → x′ ≡ x″ → x ≡ x″
trans refl refl = refl
sym : ∀ {ℓ} {X : Set ℓ} {x x′ : X} → x ≡ x′ → x′ ≡ x
sym refl = refl
subst : ∀ {ℓ ℓ′} {X : Set ℓ} → (P : X → Set ℓ′) →
∀ {x x′} → x ≡ x′ → P x → P x′
subst P refl p = p
cong : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → (f : X → Y) →
∀ {x x′} → x ≡ x′ → f x ≡ f x′
cong f refl = refl
cong² : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} → (f : X → Y → Z) →
∀ {x x′ y y′} → x ≡ x′ → y ≡ y′ → f x y ≡ f x′ y′
cong² f refl refl = refl
cong³ : ∀ {ℓ ℓ′ ℓ″ ℓ‴} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} {A : Set ℓ‴} →
(f : X → Y → Z → A) →
∀ {x x′ y y′ z z′} → x ≡ x′ → y ≡ y′ → z ≡ z′ → f x y z ≡ f x′ y′ z′
cong³ f refl refl refl = refl
-- Equational reasoning with built-in equality.
module ≡-Reasoning {ℓ} {X : Set ℓ} where
infix 1 begin_
begin_ : ∀ {x x′ : X} → x ≡ x′ → x ≡ x′
begin p = p
infixr 2 _≡⟨⟩_
_≡⟨⟩_ : ∀ (x {x′} : X) → x ≡ x′ → x ≡ x′
x ≡⟨⟩ p = p
infixr 2 _≡⟨_⟩_
_≡⟨_⟩_ : ∀ (x {x′ x″} : X) → x ≡ x′ → x′ ≡ x″ → x ≡ x″
x ≡⟨ p ⟩ q = trans p q
infix 3 _∎
_∎ : ∀ (x : X) → x ≡ x
x ∎ = refl
open ≡-Reasoning public
-- Constructive existence.
infixl 5 _,_
record Σ {ℓ ℓ′} (X : Set ℓ) (Y : X → Set ℓ′) : Set (ℓ ⊔ ℓ′) where
constructor _,_
field
π₁ : X
π₂ : Y π₁
open Σ public
-- Conjunction.
infixr 2 _∧_
_∧_ : ∀ {ℓ ℓ′} → Set ℓ → Set ℓ′ → Set (ℓ ⊔ ℓ′)
X ∧ Y = Σ X (λ x → Y)
-- Disjunction.
infixr 1 _∨_
data _∨_ {ℓ ℓ′} (X : Set ℓ) (Y : Set ℓ′) : Set (ℓ ⊔ ℓ′) where
ι₁ : X → X ∨ Y
ι₂ : Y → X ∨ Y
{-# HASKELL type AgdaEither _ _ x y = Either x y #-}
{-# COMPILED_DATA _∨_ MAlonzo.Code.Data.Sum.AgdaEither Left Right #-}
elim∨ : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
X ∨ Y → (X → Z) → (Y → Z) → Z
elim∨ (ι₁ x) f g = f x
elim∨ (ι₂ y) f g = g y
-- Equivalence.
infix 3 _↔_
_↔_ : ∀ {ℓ ℓ′} → (X : Set ℓ) (Y : Set ℓ′) → Set (ℓ ⊔ ℓ′)
X ↔ Y = (X → Y) ∧ (Y → X)
infix 3 _↮_
_↮_ : ∀ {ℓ ℓ′} → (X : Set ℓ) (Y : Set ℓ′) → Set (ℓ ⊔ ℓ′)
X ↮ Y = ¬ (X ↔ Y)
refl↔ : ∀ {ℓ} {X : Set ℓ} → X ↔ X
refl↔ = refl→ , refl→
trans↔ : ∀ {ℓ ℓ′ ℓ″} {X : Set ℓ} {Y : Set ℓ′} {Z : Set ℓ″} →
X ↔ Y → Y ↔ Z → X ↔ Z
trans↔ (P , Q) (P′ , Q′) = trans→ P P′ , trans→ Q′ Q
sym↔ : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → X ↔ Y → Y ↔ X
sym↔ (P , Q) = Q , P
antisym→ : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} →
((X → Y) ∧ (Y → X)) ≡ (X ↔ Y)
antisym→ = refl
≡→↔ : ∀ {ℓ} {X Y : Set ℓ} → X ≡ Y → X ↔ Y
≡→↔ refl = refl↔
-- Equational reasoning with equivalence.
module ↔-Reasoning where
infix 1 begin↔_
begin↔_ : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → X ↔ Y → X ↔ Y
begin↔ P = P
infixr 2 _↔⟨⟩_
_↔⟨⟩_ : ∀ {ℓ ℓ′} → (X : Set ℓ) → {Y : Set ℓ′} → X ↔ Y → X ↔ Y
X ↔⟨⟩ P = P
infixr 2 _≡→↔⟨⟩_
_≡→↔⟨⟩_ : ∀ {ℓ} → (X : Set ℓ) → {Y : Set ℓ} → X ≡ Y → X ↔ Y
X ≡→↔⟨⟩ P = ≡→↔ P
infixr 2 _↔⟨_⟩_
_↔⟨_⟩_ : ∀ {ℓ ℓ′ ℓ″} → (X : Set ℓ) → {Y : Set ℓ′} {Z : Set ℓ″} →
X ↔ Y → Y ↔ Z → X ↔ Z
X ↔⟨ P ⟩ Q = trans↔ P Q
infix 3 _∎↔
_∎↔ : ∀ {ℓ} → (X : Set ℓ) → X ↔ X
X ∎↔ = refl↔
open ↔-Reasoning public
-- Booleans.
open import Agda.Builtin.Bool public
using (Bool ; false ; true)
elimBool : ∀ {ℓ} {X : Set ℓ} → Bool → X → X → X
elimBool false z s = z
elimBool true z s = s
-- Conditionals.
data Maybe {ℓ} (X : Set ℓ) : Set ℓ where
nothing : Maybe X
just : X → Maybe X
{-# HASKELL type AgdaMaybe _ x = Maybe x #-}
{-# COMPILED_DATA Maybe MAlonzo.Code.Data.Maybe.Base.AgdaMaybe Just Nothing #-}
elimMaybe : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} → Maybe X → Y → (X → Y) → Y
elimMaybe nothing z f = z
elimMaybe (just x) z f = f x
-- Naturals.
open import Agda.Builtin.Nat public
using (Nat ; zero ; suc)
elimNat : ∀ {ℓ} {X : Set ℓ} → Nat → X → (Nat → X → X) → X
elimNat zero z f = z
elimNat (suc n) z f = f n (elimNat n z f)
-- Decidability.
data Dec {ℓ} (X : Set ℓ) : Set ℓ where
yes : X → Dec X
no : ¬ X → Dec X
mapDec : ∀ {ℓ ℓ′} {X : Set ℓ} {Y : Set ℓ′} →
(X → Y) → (Y → X) → Dec X → Dec Y
mapDec f g (yes x) = yes (f x)
mapDec f g (no ¬x) = no (λ y → g y ↯ ¬x)
⌊_⌋Dec : ∀ {ℓ} {X : Set ℓ} → Dec X → Bool
⌊ yes x ⌋Dec = true
⌊ no ¬x ⌋Dec = false
| {
"alphanum_fraction": 0.4485896269,
"avg_line_length": 21.2984496124,
"ext": "agda",
"hexsha": "fbaf3bb592fa76b0d48c2901503c515b4aaae46d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/nbe-correctness",
"max_forks_repo_path": "src/Prelude.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/nbe-correctness",
"max_issues_repo_path": "src/Prelude.agda",
"max_line_length": 79,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/nbe-correctness",
"max_stars_repo_path": "src/Prelude.agda",
"max_stars_repo_stars_event_max_datetime": "2017-03-23T18:51:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-03-23T06:25:23.000Z",
"num_tokens": 2841,
"size": 5495
} |
-- Andreas, 2014-01-08, following Maxime Denes 2014-01-06
-- This file demonstrates that size-based termination does
-- not lead to incompatibility with HoTT.
{-# OPTIONS --sized-types #-}
open import Common.Size
open import Common.Equality
data Empty : Set where
data Box : Size → Set where
wrap : ∀ i → (Empty → Box i) → Box (↑ i)
-- Box is inhabited at each stage > 0:
gift : ∀ {i} → Empty → Box i
gift ()
box : ∀ {i} → Box (↑ i)
box {i} = wrap i gift
-- wrap has an inverse:
unwrap : ∀ i → Box (↑ i) → (Empty → Box i)
unwrap .i (wrap i f) = f
-- There is an isomorphism between (Empty → Box ∞) and (Box ∞)
-- but none between (Empty → Box i) and (Box i).
-- We only get the following, but it is not sufficient to
-- produce the loop.
postulate iso : ∀ i → (Empty → Box i) ≡ Box (↑ i)
-- Since Agda's termination checker uses the structural order
-- in addition to sized types, we need to conceal the subterm.
conceal : {A : Set} → A → A
conceal x = x
mutual
loop : ∀ i → Box i → Empty
loop .(↑ i) (wrap i x) = loop' (↑ i) (Empty → Box i) (iso i) (conceal x)
-- We would like to write loop' i instead of loop' (↑ i)
-- but this is ill-typed. Thus, we cannot achieve something
-- well-founded wrt. to sized types.
loop' : ∀ i A → A ≡ Box i → A → Empty
loop' i .(Box i) refl x = loop i x
-- The termination checker complains here, rightfully!
bug : Empty
bug = loop ∞ box
| {
"alphanum_fraction": 0.6303116147,
"avg_line_length": 24.7719298246,
"ext": "agda",
"hexsha": "0f2c0ec59a1fb918739f2e54e610758ac0df14aa",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/HoTTCompatibleWithSizeBasedTerminationMaximeDenes.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/HoTTCompatibleWithSizeBasedTerminationMaximeDenes.agda",
"max_line_length": 74,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Fail/HoTTCompatibleWithSizeBasedTerminationMaximeDenes.agda",
"max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z",
"num_tokens": 450,
"size": 1412
} |
-- 2014-05-27 Jesper and Andreas
postulate
A : Set
R : A → A → Set
{-# BUILTIN REWRITE R #-}
{-# REWRITE R #-}
-- Expected error:
-- R does not target rewrite relation
-- when checking the pragma REWRITE R
| {
"alphanum_fraction": 0.6401869159,
"avg_line_length": 16.4615384615,
"ext": "agda",
"hexsha": "f236185c18397281cfa730723876f6a258a1bad9",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/RewriteRuleNotTargetRelation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/RewriteRuleNotTargetRelation.agda",
"max_line_length": 38,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/fail/RewriteRuleNotTargetRelation.agda",
"max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z",
"num_tokens": 64,
"size": 214
} |
open import FRP.JS.Nat using ( ℕ ; suc ; _+_ ) renaming ( _≟_ to _≟=_ )
open import FRP.JS.List using ( List ; [] ; _∷_ ; [_] ; _++_ ; map ; foldr ; foldl ; build ; _≟[_]_ )
open import FRP.JS.Bool using ( Bool ; not )
open import FRP.JS.QUnit using ( TestSuite ; ok ; ok! ; test ; _,_ )
module FRP.JS.Test.List where
infixr 2 _≟_
_≟_ : List ℕ → List ℕ → Bool
xs ≟ ys = xs ≟[ _≟=_ ] ys
tests : TestSuite
tests =
( test "≟"
( ok "[] ≟ []" ([] ≟ [])
, ok "[] ≟ [0]" (not ([] ≟ (0 ∷ [])))
, ok "[0] ≟ []" (not ((0 ∷ []) ≟ []))
, ok "[0] ≟ [0]" ((0 ∷ []) ≟ (0 ∷ []))
, ok "[] ≟ [0,1]" (not ([] ≟ (0 ∷ 1 ∷ [])))
, ok "[0,1] ≟ []" (not ((0 ∷ 1 ∷ []) ≟ []))
, ok "[1] ≟ [0,1]" (not ((1 ∷ []) ≟ (0 ∷ 1 ∷ [])))
, ok "[0] ≟ [0,1]" (not ((0 ∷ []) ≟ (0 ∷ 1 ∷ [])))
, ok "[0,1] ≟ [0,1]" ((0 ∷ 1 ∷ []) ≟ (0 ∷ 1 ∷ [])) )
, test "[_]"
( ok "[1] ≟ 1 ∷ []" ([ 1 ] ≟ 1 ∷ [])
, ok "[1] ≟ [0]" (not ([ 1 ] ≟ [ 0 ])) )
, test "++"
( ok "[] ++ []" ([] ++ [] ≟ [])
, ok "[] ++ [1]" ([] ++ [ 1 ] ≟ [ 1 ])
, ok "[0] ++ []" ([ 0 ] ++ [] ≟ [ 0 ])
, ok "[0] ++ [1]" ([ 0 ] ++ [ 1 ] ≟ 0 ∷ [ 1 ])
, ok "[0] ++ [1] ++ [2]" ([ 0 ] ++ [ 1 ] ++ [ 2 ] ≟ (0 ∷ 1 ∷ [ 2 ])) )
, test "foldl"
( ok "foldl + []" (foldl _+_ 0 [] ≟= 0)
, ok "foldl + [1]" (foldl _+_ 0 [ 1 ] ≟= 1)
, ok "foldl + [1,2]" (foldl _+_ 0 (1 ∷ [ 2 ]) ≟= 3) )
, test "foldr"
( ok "foldr + []" (foldr _+_ 0 [] ≟= 0)
, ok "foldr + [1]" (foldr _+_ 0 [ 1 ] ≟= 1)
, ok "foldr + [1,2]" (foldr _+_ 0 (1 ∷ [ 2 ]) ≟= 3) )
, test "map"
( ok "map suc []" (map suc [] ≟ [])
, ok "map suc [1]" (map suc [ 1 ] ≟ [ 2 ])
, ok "map suc [1,2]" (map suc (1 ∷ [ 2 ]) ≟ 2 ∷ [ 3 ]) )
, test "build"
( ok "build suc 0" (build suc 0 ≟ [])
, ok "build suc 1" (build suc 1 ≟ [ 1 ])
, ok "build suc 2" (build suc 2 ≟ 1 ∷ [ 2 ]) ) )
| {
"alphanum_fraction": 0.3397333333,
"avg_line_length": 37.5,
"ext": "agda",
"hexsha": "4f1d55035b7884d93c2f56fe9914e909dd6c5dab",
"lang": "Agda",
"max_forks_count": 7,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z",
"max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_forks_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_forks_repo_name": "agda/agda-frp-js",
"max_forks_repo_path": "test/agda/FRP/JS/Test/List.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_issues_repo_name": "agda/agda-frp-js",
"max_issues_repo_path": "test/agda/FRP/JS/Test/List.agda",
"max_line_length": 101,
"max_stars_count": 63,
"max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_stars_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_stars_repo_name": "agda/agda-frp-js",
"max_stars_repo_path": "test/agda/FRP/JS/Test/List.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z",
"num_tokens": 930,
"size": 1875
} |
module Numeral.Natural.Oper.Summation.Proofs where
import Lvl
open import Data.List
open import Data.List.Functions
open import Data.List.Equiv.Id
open import Numeral.Natural
open import Structure.Function
open import Structure.Operator.Field
open import Structure.Operator.Monoid
open import Structure.Operator
open import Structure.Setoid
open import Type
private variable ℓ ℓₑ : Lvl.Level
private variable T A B : Type{ℓ}
private variable _▫_ : T → T → T
open Data.List.Functions.LongOper
open import Data.List.Proofs
open import Functional as Fn using (_$_ ; _∘_ ; const)
import Function.Equals as Fn
open import Lang.Instance
import Numeral.Natural.Oper.Summation
open import Numeral.Natural.Oper.Summation.Range
open import Numeral.Natural.Oper.Summation.Range.Proofs
open import Numeral.Natural.Relation.Order
import Structure.Function.Names as Names
open import Structure.Operator.Properties
open import Structure.Operator.Proofs.Util
open import Structure.Relator.Properties
open import Syntax.Function
open import Syntax.Transitivity
module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ ⦃ monoid : Monoid{T = T}(_▫_) ⦄ where
open Numeral.Natural.Oper.Summation {I = ℕ} ⦃ monoid = monoid ⦄
open Monoid(monoid) using (id) renaming (binary-operator to [▫]-binary-operator)
open import Relator.Equals.Proofs.Equiv {T = ℕ}
private variable f g : ℕ → T
private variable x a b c k n : ℕ
private variable r r₁ r₂ : List(ℕ)
∑-empty : (∑(∅) f ≡ id)
∑-empty = reflexivity(Equiv._≡_ equiv)
∑-prepend : (∑(prepend x r) f ≡ f(x) ▫ ∑(r) f)
∑-prepend = reflexivity(Equiv._≡_ equiv)
∑-postpend : (∑(postpend x r) f ≡ ∑(r) f ▫ f(x))
∑-postpend {x = x} {r = ∅} {f = f} =
∑(postpend x empty) f 🝖[ _≡_ ]-[]
∑(prepend x empty) f 🝖[ _≡_ ]-[]
f(x) ▫ (∑(empty) f) 🝖[ _≡_ ]-[]
f(x) ▫ id 🝖[ _≡_ ]-[ identityᵣ(_▫_)(id) ]
f(x) 🝖[ _≡_ ]-[ identityₗ(_▫_)(id) ]-sym
id ▫ f(x) 🝖[ _≡_ ]-[]
(∑(empty) f) ▫ f(x) 🝖-end
∑-postpend {x = x} {r = r₀ ⊰ r} {f = f} =
f(r₀) ▫ ∑(postpend x r) f 🝖[ _≡_ ]-[ congruence₂ᵣ(_▫_)(f(r₀)) (∑-postpend {x = x}{r = r}{f = f}) ]
f(r₀) ▫ (∑(r) f ▫ f(x)) 🝖[ _≡_ ]-[ associativity(_▫_) {f(r₀)}{∑(r) f}{f(x)} ]-sym
(f(r₀) ▫ ∑(r) f) ▫ f(x) 🝖-end
∑-compose : ∀{f : ℕ → T}{g : ℕ → ℕ} → (∑(r) (f ∘ g) ≡ ∑(map g r) f)
∑-compose {r = r}{f = f}{g = g} =
∑(r) (f ∘ g) 🝖[ _≡_ ]-[]
foldᵣ(_▫_) id (map(f ∘ g) r) 🝖[ _≡_ ]-[ congruence₁(foldᵣ(_▫_) id) ⦃ foldᵣ-function ⦄ (map-preserves-[∘] {f = f}{g = g}{x = r}) ]
foldᵣ(_▫_) id (map f(map g r)) 🝖[ _≡_ ]-[]
∑(map g r) f 🝖-end
∑-singleton : (∑(singleton(a)) f ≡ f(a))
∑-singleton = identityᵣ ⦃ equiv ⦄ (_▫_)(id)
∑-concat : (∑(r₁ ++ r₂) f ≡ ∑(r₁) f ▫ ∑(r₂) f)
∑-concat {empty} {r₂} {f} = symmetry(_≡_) (identityₗ(_▫_)(id))
∑-concat {prepend x r₁} {r₂} {f} =
f(x) ▫ ∑(r₁ ++ r₂) f 🝖[ _≡_ ]-[ congruence₂ᵣ(_▫_)(f(x)) (∑-concat {r₁}{r₂}{f}) ]
f(x) ▫ (∑(r₁) f ▫ ∑ r₂ f) 🝖[ _≡_ ]-[ associativity(_▫_) {x = f(x)}{y = ∑(r₁) f}{z = ∑(r₂) f} ]-sym
(f(x) ▫ ∑(r₁) f) ▫ ∑ r₂ f 🝖-end
∑-const-id : (∑(r) (const id) ≡ id)
∑-const-id {empty} = reflexivity(Equiv._≡_ equiv)
∑-const-id {prepend x r} =
∑(prepend x r) (const id) 🝖[ _≡_ ]-[]
id ▫ (∑(r) (const id)) 🝖[ _≡_ ]-[ identityₗ(_▫_)(id) ]
∑(r) (const id) 🝖[ _≡_ ]-[ ∑-const-id {r} ]
id 🝖-end
module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where
private variable f g : ℕ → T
private variable k n : ℕ
private variable x a b c : T
private variable r r₁ r₂ : List(ℕ)
private variable _+_ _⋅_ : T → T → T
module _ ⦃ monoid : Monoid(_+_) ⦄ ⦃ comm : Commutativity(_+_) ⦄ where
open Numeral.Natural.Oper.Summation {I = ℕ} ⦃ monoid = monoid ⦄
open Monoid(monoid) using (id) renaming (binary-operator to [+]-binary-operator)
open import Relator.Equals.Proofs.Equiv {T = ℕ}
∑-add : (∑(r) f + ∑(r) g ≡ ∑(r) (x ↦ f(x) + g(x)))
∑-add {∅} {f} {g} = identityₗ(_+_)(id)
∑-add {r₀ ⊰ r} {f} {g} =
∑(prepend r₀ r) f + ∑(prepend r₀ r) g 🝖[ _≡_ ]-[]
(f(r₀) + ∑(r) f) + (g(r₀) + ∑(r) g) 🝖[ _≡_ ]-[ One.associate-commute4 {a = f(r₀)}{b = ∑(r) f}{c = g(r₀)}{d = ∑(r) g} (commutativity(_+_){∑(r) f}{g(r₀)}) ]
(f(r₀) + g(r₀)) + (∑(r) f + ∑(r) g) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(f(r₀) + g(r₀)) (∑-add {r} {f} {g}) ]
(f(r₀) + g(r₀)) + ∑(r) (x ↦ f(x) + g(x)) 🝖[ _≡_ ]-[]
∑(prepend r₀ r) (x ↦ f(x) + g(x)) 🝖-end
module _ ⦃ monoid : Monoid(_+_) ⦄ ⦃ distₗ : Distributivityₗ(_⋅_)(_+_) ⦄ ⦃ absorᵣ : Absorberᵣ(_⋅_)(Monoid.id monoid) ⦄ where
open Numeral.Natural.Oper.Summation {I = ℕ} ⦃ monoid = monoid ⦄
open Monoid(monoid) using (id) renaming (binary-operator to [+]-binary-operator)
open import Relator.Equals.Proofs.Equiv {T = ℕ}
∑-scalar-multₗ : (∑(r) (x ↦ c ⋅ f(x)) ≡ c ⋅ (∑(r) f))
∑-scalar-multₗ {empty} {c} {f} = symmetry(_≡_) (absorberᵣ(_⋅_)(id))
∑-scalar-multₗ {prepend r₀ r} {c} {f} =
(c ⋅ f(r₀)) + ∑(r) (x ↦ c ⋅ f(x)) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(c ⋅ f(r₀)) (∑-scalar-multₗ {r}{c}{f}) ]
(c ⋅ f(r₀)) + (c ⋅ (∑(r) f)) 🝖[ _≡_ ]-[ distributivityₗ(_⋅_)(_+_) {c}{f(r₀)}{∑(r) f} ]-sym
c ⋅ (f(r₀) + (∑(r) f)) 🝖-end
module _ ⦃ monoid : Monoid(_+_) ⦄ ⦃ distᵣ : Distributivityᵣ(_⋅_)(_+_) ⦄ ⦃ absorₗ : Absorberₗ(_⋅_)(Monoid.id monoid) ⦄ where
open Numeral.Natural.Oper.Summation {I = ℕ} ⦃ monoid = monoid ⦄
open Monoid(monoid) using (id) renaming (binary-operator to [+]-binary-operator)
open import Relator.Equals.Proofs.Equiv {T = ℕ}
∑-scalar-multᵣ : (∑(r) (x ↦ f(x) ⋅ c) ≡ (∑(r) f) ⋅ c)
∑-scalar-multᵣ {empty} {f} {c} = symmetry(_≡_) (absorberₗ(_⋅_)(id))
∑-scalar-multᵣ {prepend r₀ r} {f} {c} =
(f(r₀) ⋅ c) + ∑(r) (x ↦ f(x) ⋅ c) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(f(r₀) ⋅ c) (∑-scalar-multᵣ {r}{f}{c}) ]
(f(r₀) ⋅ c) + ((∑(r) f) ⋅ c) 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_+_) {f(r₀)}{∑(r) f}{c} ]-sym
(f(r₀) + (∑(r) f)) ⋅ c 🝖-end
module _ ⦃ field-structure : Field(_+_)(_⋅_) ⦄ where
open Field(field-structure)
open Numeral.Natural.Oper.Summation {I = ℕ} ⦃ monoid = [+]-monoid ⦄
open import Relator.Equals hiding (_≡_)
open import Relator.Equals.Proofs.Equiv
open import Numeral.Natural.Oper
open import Numeral.Natural.Oper.Proofs
open import Numeral.Natural.Oper.Proofs.Structure
open Numeral.Natural.Oper.Summation {I = ℕ} ⦃ monoid = [+]-monoid ⦄ -- TODO: Generalize all the proofs
private variable f g : ℕ → ℕ
private variable x a b c k n : ℕ
private variable r r₁ r₂ : List(ℕ)
∑-const : (∑(r) (const c) ≡ c ⋅ length(r))
∑-const {empty} {c} = reflexivity(_≡_)
∑-const {prepend x r}{c} = congruence₂ᵣ(_+_)(c) (∑-const {r}{c})
-- TODO: Σ-const-id is a generalization of this
∑-zero : (∑(r) (const 𝟎) ≡ 𝟎)
∑-zero {r} = ∑-const {r}{𝟎}
-- TODO: map-binaryOperator is on the equality setoid, which blocks the generalization of this
instance
∑-binaryOperator : BinaryOperator ⦃ equiv-A₂ = Fn.[⊜]-equiv ⦄ (∑)
BinaryOperator.congruence ∑-binaryOperator {r₁}{r₂}{f}{g} rr fg =
∑(r₁) f 🝖[ _≡_ ]-[]
foldᵣ(_+_) 𝟎 (map f(r₁)) 🝖[ _≡_ ]-[ congruence₁(foldᵣ(_+_) 𝟎) (congruence₂(map) ⦃ map-binaryOperator ⦄ fg rr) ]
foldᵣ(_+_) 𝟎 (map g(r₂)) 🝖[ _≡_ ]-[]
∑(r₂) g 🝖-end
∑-mult : ∀{r₁ r₂}{f g} → ((∑(r₁) f) ⋅ (∑(r₂) g) ≡ ∑(r₁) (x ↦ ∑(r₂) (y ↦ f(x) ⋅ g(y))))
∑-mult {empty} {_} {f} {g} = [≡]-intro
∑-mult {prepend x₁ r₁} {empty} {f} {g} =
𝟎 🝖[ _≡_ ]-[ ∑-zero {r = prepend x₁ r₁} ]-sym
∑(prepend x₁ r₁) (x ↦ 𝟎) 🝖[ _≡_ ]-[ congruence₂ᵣ(∑)(prepend x₁ r₁) (Fn.intro(\{x} → ∑-empty {f = y ↦ f(x) ⋅ g(y)})) ]-sym
∑(prepend x₁ r₁) (x ↦ ∑(empty) (y ↦ f(x) ⋅ g(y))) 🝖-end
∑-mult {prepend x₁ r₁} {prepend x₂ r₂} {f} {g} =
(∑(prepend x₁ r₁) f) ⋅ (∑(prepend x₂ r₂) g) 🝖[ _≡_ ]-[]
(f(x₁) + (∑(r₁) f)) ⋅ (g(x₂) + (∑(r₂) g)) 🝖[ _≡_ ]-[ OneTypeTwoOp.cross-distribute {a = f(x₁)}{b = ∑(r₁) f}{c = g(x₂)}{d = ∑(r₂) g} ]
((f(x₁) ⋅ g(x₂)) + ((∑(r₁) f) ⋅ g(x₂))) + ((f(x₁) ⋅ (∑(r₂) g)) + ((∑(r₁) f) ⋅ (∑(r₂) g))) 🝖[ _≡_ ]-[ One.associate-commute4 {a = f(x₁) ⋅ g(x₂)}{b = (∑(r₁) f) ⋅ g(x₂)}{c = f(x₁) ⋅ (∑(r₂) g)}{d = (∑(r₁) f) ⋅ (∑(r₂) g)} (commutativity(_+_) {(∑(r₁) f) ⋅ g(x₂)}{f(x₁) ⋅ (∑(r₂) g)}) ]
((f(x₁) ⋅ g(x₂)) + (f(x₁) ⋅ (∑(r₂) g))) + (((∑(r₁) f) ⋅ g(x₂)) + ((∑(r₁) f) ⋅ (∑(r₂) g))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_) ((f(x₁) ⋅ g(x₂)) + (f(x₁) ⋅ (∑(r₂) g))) p ]
((f(x₁) ⋅ g(x₂)) + (f(x₁) ⋅ (∑(r₂) g))) + (∑(r₁) (x ↦ (f(x) ⋅ g(x₂)) + (∑(r₂) (y ↦ f(x) ⋅ g(y))))) 🝖[ _≡_ ]-[ congruence₂ₗ(_+_) (∑(r₁) (x ↦ (f(x) ⋅ g(x₂)) + (∑(r₂) (y ↦ f(x) ⋅ g(y))))) (congruence₂ᵣ(_+_)(f(x₁) ⋅ g(x₂)) (∑-scalar-multₗ {r = r₂}{c = f(x₁)}{f = g})) ]-sym
((f(x₁) ⋅ g(x₂)) + (∑(r₂) (y ↦ f(x₁) ⋅ g(y)))) + (∑(r₁) (x ↦ (f(x) ⋅ g(x₂)) + (∑(r₂) (y ↦ f(x) ⋅ g(y))))) 🝖[ _≡_ ]-[]
(∑(prepend x₂ r₂) (y ↦ f(x₁) ⋅ g(y))) + (∑(r₁) (x ↦ ∑(prepend x₂ r₂) (y ↦ f(x) ⋅ g(y)))) 🝖[ _≡_ ]-[]
∑(prepend x₁ r₁) (x ↦ ∑(prepend x₂ r₂) (y ↦ f(x) ⋅ g(y))) 🝖-end
where
p =
((∑(r₁) f) ⋅ g(x₂)) + ((∑(r₁) f) ⋅ (∑(r₂) g)) 🝖[ _≡_ ]-[ distributivityₗ(_⋅_)(_+_) {x = ∑(r₁) f}{y = g(x₂)}{z = ∑(r₂) g} ]-sym
(∑(r₁) f) ⋅ (g(x₂) + (∑(r₂) g)) 🝖[ _≡_ ]-[ ∑-scalar-multᵣ {r = r₁}{f = f}{c = g(x₂) + (∑(r₂) g)} ]-sym
∑(r₁) (x ↦ f(x) ⋅ (g(x₂) + (∑(r₂) g))) 🝖[ _≡_ ]-[ congruence₂ᵣ(∑) r₁ (Fn.intro(\{x} → distributivityₗ(_⋅_)(_+_) {x = f(x)}{y = g(x₂)}{z = ∑(r₂) g})) ]
∑(r₁) (x ↦ (f(x) ⋅ g(x₂)) + (f(x) ⋅ (∑(r₂) g))) 🝖[ _≡_ ]-[ congruence₂ᵣ(∑) r₁ (Fn.intro(\{x} → congruence₂ᵣ(_+_) (f(x) ⋅ g(x₂)) (∑-scalar-multₗ {r = r₂}{c = f(x)}{f = g}))) ]-sym
∑(r₁) (x ↦ (f(x) ⋅ g(x₂)) + (∑(r₂) (y ↦ f(x) ⋅ g(y)))) 🝖-end
∑-swap-nested : ∀{f : ℕ → ℕ → _}{r₁ r₂} → (∑(r₁) (a ↦ ∑(r₂) (b ↦ f(a)(b))) ≡ ∑(r₂) (b ↦ ∑(r₁) (a ↦ f(a)(b))))
∑-swap-nested {f} {empty} {empty} = [≡]-intro
∑-swap-nested {f} {empty} {prepend x r₂} =
∑(∅)(a ↦ ∑(x ⊰ r₂) (b ↦ f(a)(b))) 🝖[ _≡_ ]-[]
𝟎 🝖[ _≡_ ]-[ ∑-zero {x ⊰ r₂} ]-sym
∑(x ⊰ r₂) (b ↦ 𝟎) 🝖[ _≡_ ]-[]
∑(x ⊰ r₂) (b ↦ ∑(∅) (a ↦ f(a)(b))) 🝖-end
∑-swap-nested {f} {prepend x r₁} {empty} =
∑(x ⊰ r₁) (a ↦ ∑(∅) (b ↦ f(a)(b))) 🝖[ _≡_ ]-[]
∑(x ⊰ r₁) (b ↦ 𝟎) 🝖[ _≡_ ]-[ ∑-zero {x ⊰ r₁} ]
𝟎 🝖[ _≡_ ]-[]
∑(∅) (b ↦ ∑(x ⊰ r₁) (a ↦ f(a)(b))) 🝖-end
∑-swap-nested {f} {prepend x₁ r₁} {prepend x₂ r₂} =
∑(x₁ ⊰ r₁) (a ↦ ∑(x₂ ⊰ r₂) (b ↦ f(a)(b))) 🝖[ _≡_ ]-[]
∑(x₁ ⊰ r₁) (a ↦ f(a)(x₂) + ∑(r₂) (b ↦ f(a)(b))) 🝖[ _≡_ ]-[]
(f(x₁)(x₂) + ∑(r₂) (b ↦ f(x₁)(b))) + ∑(r₁) (a ↦ f(a)(x₂) + ∑(r₂) (b ↦ f(a)(b))) 🝖[ _≡_ ]-[]
(f(x₁)(x₂) + ∑(r₂) (b ↦ f(x₁)(b))) + (∑(r₁) (a ↦ f(a)(x₂) + ∑(r₂) (b ↦ f(a)(b)))) 🝖[ _≡_ ]-[ associativity(_+_) {x = f(x₁)(x₂)}{y = ∑(r₂) (b ↦ f(x₁)(b))} ]
f(x₁)(x₂) + (∑(r₂) (b ↦ f(x₁)(b)) + (∑(r₁) (a ↦ f(a)(x₂) + ∑(r₂) (b ↦ f(a)(b))))) 🝖[ _≡_ ]-[]
f(x₁)(x₂) + (∑(r₂) (b ↦ f(x₁)(b)) + (∑(r₁) (a ↦ ∑(x₂ ⊰ r₂) (b ↦ f(a)(b))))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(f(x₁)(x₂)) (congruence₂ᵣ(_+_)(∑(r₂) (b ↦ f(x₁)(b))) (∑-swap-nested {f}{r₁}{x₂ ⊰ r₂})) ]
f(x₁)(x₂) + (∑(r₂) (b ↦ f(x₁)(b)) + (∑(x₂ ⊰ r₂) (b ↦ ∑(r₁) (a ↦ f(a)(b))))) 🝖[ _≡_ ]-[]
f(x₁)(x₂) + (∑(r₂) (b ↦ f(x₁)(b)) + (∑(r₁) (a ↦ f(a)(x₂)) + (∑(r₂) (b ↦ ∑(r₁) (a ↦ f(a)(b)))))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(f(x₁)(x₂)) (symmetry(_≡_) (associativity(_+_) {x = ∑(r₂) (b ↦ f(x₁)(b))}{y = ∑(r₁) (a ↦ f(a)(x₂))})) ]
f(x₁)(x₂) + ((∑(r₂) (b ↦ f(x₁)(b)) + ∑(r₁) (a ↦ f(a)(x₂))) + (∑(r₂) (b ↦ ∑(r₁) (a ↦ f(a)(b))))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(f(x₁)(x₂)) (congruence₂(_+_) (commutativity(_+_) {∑(r₂) (b ↦ f(x₁)(b))}{∑(r₁) (a ↦ f(a)(x₂))}) (symmetry(_≡_) (∑-swap-nested {f}{r₁}{r₂}))) ]
f(x₁)(x₂) + ((∑(r₁) (a ↦ f(a)(x₂)) + ∑(r₂) (b ↦ f(x₁)(b))) + ∑(r₁) (a ↦ ∑(r₂) (b ↦ f(a)(b)))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(f(x₁)(x₂)) (associativity(_+_) {x = ∑(r₁) (a ↦ f(a)(x₂))}{y = ∑(r₂) (b ↦ f(x₁)(b))}) ]
f(x₁)(x₂) + (∑(r₁) (a ↦ f(a)(x₂)) + (∑(r₂) (b ↦ f(x₁)(b)) + ∑(r₁) (a ↦ ∑(r₂) (b ↦ f(a)(b))))) 🝖[ _≡_ ]-[]
f(x₁)(x₂) + (∑(r₁) (a ↦ f(a)(x₂)) + (∑(x₁ ⊰ r₁) (a ↦ ∑(r₂) (b ↦ f(a)(b))))) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(f(x₁)(x₂)) (congruence₂ᵣ(_+_)(∑(r₁) (a ↦ f(a)(x₂))) (∑-swap-nested {f}{x₁ ⊰ r₁}{r₂})) ]
f(x₁)(x₂) + (∑(r₁) (a ↦ f(a)(x₂)) + (∑(r₂) (b ↦ ∑(x₁ ⊰ r₁) (a ↦ f(a)(b))))) 🝖[ _≡_ ]-[]
f(x₁)(x₂) + (∑(r₁) (a ↦ f(a)(x₂)) + (∑(r₂) (b ↦ f(x₁)(b) + ∑(r₁) (a ↦ f(a)(b))))) 🝖[ _≡_ ]-[ associativity(_+_) {x = f(x₁)(x₂)}{y = ∑(r₁) (a ↦ f(a)(x₂))} ]-sym
(f(x₁)(x₂) + ∑(r₁) (a ↦ f(a)(x₂))) + (∑(r₂) (b ↦ f(x₁)(b) + ∑(r₁) (a ↦ f(a)(b)))) 🝖[ _≡_ ]-[]
∑(x₂ ⊰ r₂) (b ↦ f(x₁)(b) + ∑(r₁) (a ↦ f(a)(b))) 🝖[ _≡_ ]-[]
∑(x₂ ⊰ r₂) (b ↦ ∑(x₁ ⊰ r₁) (a ↦ f(a)(b))) 🝖-end
∑-zero-range : (∑(a ‥ a) f ≡ 𝟎)
∑-zero-range {a}{f} = congruence₁ (r ↦ ∑(r) f) (Range-empty{a})
∑-single-range : (∑(a ‥ 𝐒(a)) f ≡ f(a))
∑-single-range {𝟎} {f} = reflexivity(_≡_)
∑-single-range {𝐒 a}{f} =
∑ (map 𝐒(a ‥ 𝐒(a))) f 🝖[ _≡_ ]-[ ∑-compose ⦃ monoid = [+]-monoid ⦄ {r = a ‥ 𝐒(a)}{f}{𝐒} ]-sym
∑ (a ‥ 𝐒(a)) (x ↦ f(𝐒(x))) 🝖[ _≡_ ]-[ ∑-single-range {a}{f ∘ 𝐒} ]
f(𝐒(a)) 🝖-end
∑-step-range : (∑(𝐒(a) ‥ 𝐒(b)) f ≡ ∑(a ‥ b) (f ∘ 𝐒))
∑-step-range {a}{b}{f} = symmetry(_≡_) (∑-compose {r = a ‥ b}{f = f}{g = 𝐒})
∑-stepₗ-range : ⦃ _ : (a < b) ⦄ → (∑(a ‥ b) f ≡ f(a) + ∑(𝐒(a) ‥ b) f)
∑-stepₗ-range {𝟎} {𝐒 b} {f} ⦃ succ ab ⦄ = reflexivity(_≡_)
∑-stepₗ-range {𝐒 a} {𝐒 b} {f} ⦃ succ ab ⦄ =
∑(𝐒(a) ‥ 𝐒(b)) f 🝖[ _≡_ ]-[ ∑-step-range {a}{b}{f} ]
∑(a ‥ b) (f ∘ 𝐒) 🝖[ _≡_ ]-[ ∑-stepₗ-range {a}{b}{f ∘ 𝐒} ]
(f ∘ 𝐒)(a) + ∑(𝐒(a) ‥ b) (f ∘ 𝐒) 🝖[ _≡_ ]-[ congruence₂(_+_) (reflexivity(_≡_) {x = f(𝐒(a))}) (symmetry(_≡_) (∑-step-range {𝐒 a}{b}{f})) ]
f(𝐒(a)) + ∑(𝐒(𝐒(a)) ‥ 𝐒(b)) f 🝖-end
where instance _ = ab
-- ∑-stepᵣ-range : ⦃ _ : (a < 𝐒(b)) ⦄ → (∑(a ‥ 𝐒(b)) f ≡ ∑(a ‥ b) f + f(b))
-- ∑-stepᵣ-range = ?
-- ∑-add-range : (∑(a ‥ a + b) f ≡ ∑(𝟎 ‥ b) (f ∘ (_+ a)))
∑-trans-range : ⦃ ab : (a ≤ b) ⦄ ⦃ bc : (b < c) ⦄ → (∑(a ‥ b) f + ∑(b ‥ c) f ≡ ∑(a ‥ c) f)
∑-trans-range {a}{b}{c} {f} =
∑(a ‥ b) f + ∑(b ‥ c) f 🝖[ _≡_ ]-[ ∑-concat{r₁ = a ‥ b}{r₂ = b ‥ c}{f = f} ]-sym
∑((a ‥ b) ++ (b ‥ c)) f 🝖[ _≡_ ]-[ congruence₁(r ↦ ∑(r) f) (Range-concat{a}{b}{c}) ]
∑(a ‥ c) f 🝖-end
-- TODO: Formulate ∑({(x,y). a ≤ x ≤ y ≤ b}) f ≡ ∑(a ‥ b) (x ↦ ∑(a ‥ x) (y ↦ f(x)(y))) ≡ ∑(a ‥ b) (x ↦ ∑(x ‥ b) (y ↦ f(x)(y))) ≡ ... and first prove a theorem stating that the order of a list does not matter
-- ∑-nested-dependent-range : ∀{f : ℕ → ℕ → _}{a b} → ?
∑-of-succ : (∑(r) (𝐒 ∘ f) ≡ (∑(r) f) + length(r))
∑-of-succ {empty} {f} = [≡]-intro
∑-of-succ {prepend x r}{f} =
∑(x ⊰ r) (𝐒 ∘ f) 🝖[ _≡_ ]-[]
𝐒(f(x)) + ∑(r) (𝐒 ∘ f) 🝖[ _≡_ ]-[]
𝐒(f(x) + ∑(r) (𝐒 ∘ f)) 🝖[ _≡_ ]-[ congruence₁(𝐒) (congruence₂ᵣ(_+_)(f(x)) (∑-of-succ {r}{f})) ]
𝐒(f(x) + ((∑(r) f) + length(r))) 🝖[ _≡_ ]-[ congruence₁(𝐒) (symmetry(_≡_) (associativity(_+_) {x = f(x)}{y = ∑(r) f}{z = length(r)})) ]
𝐒((f(x) + (∑(r) f)) + length(r)) 🝖[ _≡_ ]-[]
𝐒((∑(x ⊰ r) f) + length(r)) 🝖[ _≡_ ]-[]
(∑(x ⊰ r) f) + 𝐒(length(r)) 🝖[ _≡_ ]-[]
(∑(x ⊰ r) f) + length(x ⊰ r) 🝖-end
∑-even-sum : (∑(𝟎 ‥₌ n) (k ↦ 2 ⋅ k) ≡ n ⋅ 𝐒(n))
∑-even-sum {𝟎} = [≡]-intro
∑-even-sum {𝐒 n} =
∑(𝟎 ‥₌ 𝐒(n)) (k ↦ 2 ⋅ k) 🝖[ _≡_ ]-[]
(2 ⋅ 𝟎) + ∑(1 ‥₌ 𝐒(n)) (k ↦ 2 ⋅ k) 🝖[ _≡_ ]-[]
𝟎 + ∑(1 ‥₌ 𝐒(n)) (k ↦ 2 ⋅ k) 🝖[ _≡_ ]-[]
∑(1 ‥₌ 𝐒(n)) (k ↦ 2 ⋅ k) 🝖[ _≡_ ]-[]
∑(map 𝐒(𝟎 ‥₌ n)) (k ↦ 2 ⋅ k) 🝖[ _≡_ ]-[ ∑-step-range {a = 𝟎}{b = 𝐒 n}{f = 2 ⋅_} ]
∑(𝟎 ‥₌ n) (k ↦ 2 ⋅ 𝐒(k)) 🝖[ _≡_ ]-[]
∑(𝟎 ‥₌ n) (k ↦ 2 + (2 ⋅ k)) 🝖[ _≡_ ]-[ ∑-add {r = 0 ‥₌ n}{f = const 2}{g = 2 ⋅_} ]-sym
∑(𝟎 ‥₌ n) (const(2)) + ∑(𝟎 ‥₌ n) (k ↦ (2 ⋅ k)) 🝖[ _≡_ ]-[ congruence₂(_+_) (∑-const {r = 0 ‥₌ n}{c = 2}) (∑-even-sum {n}) ]
(2 ⋅ length(𝟎 ‥₌ n)) + (n ⋅ 𝐒(n)) 🝖[ _≡_ ]-[ congruence₂ₗ(_+_)(n ⋅ 𝐒(n)) (congruence₂ᵣ(_⋅_)(2) (Range-length-zero {𝐒(n)})) ]
(2 ⋅ 𝐒(n)) + (n ⋅ 𝐒(n)) 🝖[ _≡_ ]-[ distributivityᵣ(_⋅_)(_+_) {x = 2}{y = n}{z = 𝐒(n)} ]-sym
(2 + n) ⋅ 𝐒(n) 🝖[ _≡_ ]-[]
𝐒(𝐒(n)) ⋅ 𝐒(n) 🝖[ _≡_ ]-[ commutativity(_⋅_) {𝐒(𝐒(n))}{𝐒(n)} ]
𝐒(n) ⋅ 𝐒(𝐒(n)) 🝖[ _≡_ ]-end
∑-odd-sum : (∑(𝟎 ‥ n) (k ↦ 𝐒(2 ⋅ k)) ≡ n ^ 2)
∑-odd-sum {𝟎} = [≡]-intro
∑-odd-sum {𝐒 n} =
∑(𝟎 ‥ 𝐒(n)) (k ↦ 𝐒(2 ⋅ k)) 🝖[ _≡_ ]-[]
∑(𝟎 ‥₌ n) (k ↦ 𝐒(2 ⋅ k)) 🝖[ _≡_ ]-[ ∑-of-succ {r = 𝟎 ‥ 𝐒(n)}{f = 2 ⋅_} ]
∑(𝟎 ‥₌ n) (k ↦ 2 ⋅ k) + length(𝟎 ‥ 𝐒(n)) 🝖[ _≡_ ]-[ congruence₂(_+_) (∑-even-sum {n}) (Range-length-zero {𝐒(n)}) ]
(n ⋅ 𝐒(n)) + 𝐒(n) 🝖[ _≡_ ]-[ [⋅]-with-[𝐒]ₗ {x = n}{y = 𝐒(n)} ]-sym
𝐒(n) ⋅ 𝐒(n) 🝖[ _≡_ ]-[]
𝐒(n) ^ 2 🝖-end
open import Numeral.Natural.Combinatorics
module _ where
open import Data.List.Relation.Membership using (_∈_ ; use ; skip)
mapDep : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (l : List(A)) → ((elem : A) → ⦃ _ : (elem ∈ l) ⦄ → B) → List(B)
mapDep ∅ _ = ∅
mapDep (elem ⊰ l) f = (f elem ⦃ use [≡]-intro ⦄) ⊰ (mapDep l (\x → f x ⦃ _∈_.skip infer ⦄))
-- ∑dep : (r : List(ℕ)) → ((i : ℕ) → ⦃ _ : (i ∈ r) ⦄ → ℕ) → ℕ
-- ∑dep-test : ∑dep ∅ id ≡ 0
-- Also called: The binomial theorem
{-
binomial-power : ∀{n}{a b} → ((a + b) ^ n ≡ ∑(𝟎 ‥₌ n) (i ↦ 𝑐𝐶(n)(i) ⋅ (a ^ (n −₀ i)) ⋅ (b ^ i)))
binomial-power {𝟎} {a} {b} =
(a + b) ^ 𝟎 🝖[ _≡_ ]-[]
1 🝖[ _≡_ ]-[]
1 ⋅ 1 ⋅ 1 🝖[ _≡_ ]-[]
𝑐𝐶(𝟎)(𝟎) ⋅ (a ^ 𝟎) ⋅ (b ^ 𝟎) 🝖[ _≡_ ]-[]
𝑐𝐶(𝟎)(𝟎) ⋅ (a ^ (𝟎 −₀ 𝟎)) ⋅ (b ^ 𝟎) 🝖[ _≡_ ]-[]
∑(𝟎 ‥₌ 𝟎) (i ↦ 𝑐𝐶(𝟎)(i) ⋅ (a ^ (𝟎 −₀ i)) ⋅ (b ^ 𝟎)) 🝖-end
binomial-power {𝐒 n} {a} {b} = {!!}
{- (a + b) ^ 𝐒(n) 🝖[ _≡_ ]-[]
(a + b) ⋅ ((a + b) ^ n) 🝖[ _≡_ ]-[ congruence₂ᵣ(_⋅_)(a + b) (binomial-power{n}{a}{b}) ]
(a + b) ⋅ (∑(𝟎 ‥₌ n) (i ↦ 𝑐𝐶(n)(i) ⋅ (a ^ i) ⋅ (b ^ (n −₀ i)))) 🝖[ _≡_ ]-[ {!!} ]
(a ⋅ (∑(𝟎 ‥₌ n) (i ↦ 𝑐𝐶(n)(i) ⋅ (a ^ i) ⋅ (b ^ (n −₀ i))))) + (b ⋅ (∑(𝟎 ‥₌ n) (i ↦ 𝑐𝐶(n)(i) ⋅ (a ^ i) ⋅ (b ^ (n −₀ i))))) 🝖[ _≡_ ]-[ {!!} ]
a ⋅ (b ^ 𝐒(n)) ⋅ ∑(𝟎 ‥₌ n) (i ↦ 𝑐𝐶(𝐒(n))(𝐒(i)) ⋅ (a ^ i) ⋅ (b ^ (n −₀ i))) 🝖[ _≡_ ]-[ {!!} ]
(b ^ 𝐒(n)) ⋅ ∑(𝟎 ‥₌ n) (i ↦ 𝑐𝐶(𝐒(n))(𝐒(i)) ⋅ a ⋅ (a ^ i) ⋅ (b ^ (n −₀ i))) 🝖[ _≡_ ]-[ {!!} ]
(b ^ 𝐒(n)) ⋅ ∑(𝟎 ‥₌ n) (i ↦ 𝑐𝐶(𝐒(n))(𝐒(i)) ⋅ (a ^ 𝐒(i)) ⋅ (b ^ (n −₀ i))) 🝖[ _≡_ ]-[]
(b ^ 𝐒(n)) ⋅ ∑(𝟎 ‥₌ n) (i ↦ 𝑐𝐶(𝐒(n))(𝐒(i)) ⋅ (a ^ 𝐒(i)) ⋅ (b ^ (𝐒(n) −₀ 𝐒(i)))) 🝖[ _≡_ ]-[ {!!} ]
(b ^ 𝐒(n)) ⋅ ∑(1 ‥₌ 𝐒(n)) (i ↦ 𝑐𝐶(𝐒(n))(i) ⋅ (a ^ i) ⋅ (b ^ (𝐒(n) −₀ i))) 🝖[ _≡_ ]-[]
(1 ⋅ 1 ⋅ (b ^ 𝐒(n))) ⋅ ∑(1 ‥₌ 𝐒(n)) (i ↦ 𝑐𝐶(𝐒(n))(i) ⋅ (a ^ i) ⋅ (b ^ (𝐒(n) −₀ i))) 🝖[ _≡_ ]-[]
(𝑐𝐶(𝐒(n))(𝟎) ⋅ (a ^ 𝟎) ⋅ (b ^ (𝐒(n) −₀ 𝟎))) ⋅ ∑(1 ‥₌ 𝐒(n)) (i ↦ 𝑐𝐶(𝐒(n))(i) ⋅ (a ^ i) ⋅ (b ^ (𝐒(n) −₀ i))) 🝖[ _≡_ ]-[ {!!} ]
∑(𝟎 ‥₌ 𝐒(n)) (i ↦ 𝑐𝐶(𝐒(n))(i) ⋅ (a ^ i) ⋅ (b ^ (𝐒(n) −₀ i))) 🝖-end-}
where
left : _ ≡ _
left =
a ⋅ (∑(𝟎 ‥₌ n) (i ↦ 𝑐𝐶(n)(i) ⋅ (a ^ (n −₀ i)) ⋅ (b ^ i))) 🝖[ _≡_ ]-[ {!!} ]
∑(𝟎 ‥₌ n) (i ↦ a ⋅ 𝑐𝐶(n)(i) ⋅ (a ^ (n −₀ i)) ⋅ (b ^ i)) 🝖[ _≡_ ]-[ {!!} ]
∑(𝟎 ‥₌ n) (i ↦ 𝑐𝐶(n)(i) ⋅ (a ⋅ (a ^ (n −₀ i))) ⋅ (b ^ i)) 🝖[ _≡_ ]-[ {!!} ]
(𝑐𝐶(n)(𝟎) ⋅ (a ⋅ (a ^ (n −₀ 𝟎))) ⋅ (b ^ 𝟎)) + ∑(1 ‥₌ n) (i ↦ 𝑐𝐶(n)(i) ⋅ (a ⋅ (a ^ (n −₀ i))) ⋅ (b ^ i)) 🝖[ _≡_ ]-[ {!!} ]
(1 ⋅ (a ^ 𝐒(n)) ⋅ 1) + ∑(1 ‥₌ n) (i ↦ 𝑐𝐶(n)(i) ⋅ (a ⋅ (a ^ (n −₀ i))) ⋅ (b ^ i)) 🝖[ _≡_ ]-[ {!!} ]
(1 ⋅ (a ^ 𝐒(n))) + ∑(1 ‥₌ n) (i ↦ 𝑐𝐶(n)(i) ⋅ (a ⋅ (a ^ (n −₀ i))) ⋅ (b ^ i)) 🝖-end
-- TODO: Maybe need another variant of ∑ where the index has a proof of it being in the range? And it is in this case used for a ⋅ (a ^ (n −₀ i)) ≡ a ^ (𝐒(n) −₀ i)
-}
| {
"alphanum_fraction": 0.3867341203,
"avg_line_length": 61.1690544413,
"ext": "agda",
"hexsha": "809247d4ab1cd229cccb049cc508a55cd9230beb",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Numeral/Natural/Oper/Summation/Proofs.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Numeral/Natural/Oper/Summation/Proofs.agda",
"max_line_length": 296,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Numeral/Natural/Oper/Summation/Proofs.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 11531,
"size": 21348
} |
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}
module Cubical.Data.InfNat.Properties where
open import Cubical.Data.Nat as ℕ using (ℕ)
open import Cubical.Data.InfNat.Base
open import Cubical.Core.Primitives
open import Cubical.Foundations.Prelude
open import Cubical.Relation.Nullary
open import Cubical.Data.Unit
open import Cubical.Data.Empty
fromInf-def : ℕ → ℕ+∞ → ℕ
fromInf-def n ∞ = n
fromInf-def _ (fin n) = n
fin-inj : (n m : ℕ) → fin n ≡ fin m → n ≡ m
fin-inj x _ eq = cong (fromInf-def x) eq
discreteInfNat : Discrete ℕ+∞
discreteInfNat ∞ ∞ = yes (λ i → ∞)
discreteInfNat ∞ (fin _) = no λ p → subst (caseInfNat ⊥ Unit) p tt
discreteInfNat (fin _) ∞ = no λ p → subst (caseInfNat Unit ⊥) p tt
discreteInfNat (fin n) (fin m) with ℕ.discreteℕ n m
discreteInfNat (fin n) (fin m) | yes p = yes (cong fin p)
discreteInfNat (fin n) (fin m) | no ¬p = no (λ p → ¬p (fin-inj n m p))
| {
"alphanum_fraction": 0.6875687569,
"avg_line_length": 33.6666666667,
"ext": "agda",
"hexsha": "e2f2e10f1728e4828219ab6ac822167422d18088",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Data/InfNat/Properties.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Data/InfNat/Properties.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Data/InfNat/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 321,
"size": 909
} |
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.Category
open import Oscar.Class.Congruity
open import Oscar.Class.Functor
open import Oscar.Class.HasEquivalence
open import Oscar.Class.IsCategory
open import Oscar.Class.IsFunctor
open import Oscar.Class.IsPrecategory
open import Oscar.Class.IsPrefunctor
open import Oscar.Class.Precategory
open import Oscar.Class.Prefunctor
open import Oscar.Class.Reflexivity
open import Oscar.Class.Surjection
open import Oscar.Class.Smap
open import Oscar.Class.Surjextensionality
open import Oscar.Class.Surjidentity
open import Oscar.Class.Surjtranscommutativity
open import Oscar.Class.Transassociativity
open import Oscar.Class.Transextensionality
open import Oscar.Class.Transitivity
open import Oscar.Class.Transleftidentity
open import Oscar.Class.Transrightidentity
open import Oscar.Class.[IsExtensionB]
open import Oscar.Data.¶
open import Oscar.Data.Proposequality
open import Oscar.Data.Substitunction
open import Oscar.Data.Term
open import Oscar.Data.Vec
import Oscar.Property.Setoid.Proposequality
import Oscar.Property.Setoid.Proposextensequality
import Oscar.Property.Category.ExtensionProposextensequality
import Oscar.Property.Category.Function
import Oscar.Class.Congruity.Proposequality
import Oscar.Class.HasEquivalence.Substitunction
import Oscar.Class.Surjection.⋆
import Oscar.Class.Reflexivity.Function
module Oscar.Property.Functor.SubstitunctionExtensionTerm where
module _ {𝔭} {𝔓 : Ø 𝔭} where
open Substitunction 𝔓
open Term 𝔓
private
mutual
𝓼urjectivitySubstitunctionExtensionTerm : Smap!.type Substitunction (Extension Term)
𝓼urjectivitySubstitunctionExtensionTerm σ (i x) = σ x
𝓼urjectivitySubstitunctionExtensionTerm σ leaf = leaf
𝓼urjectivitySubstitunctionExtensionTerm σ (τ₁ fork τ₂) = 𝓼urjectivitySubstitunctionExtensionTerm σ τ₁ fork 𝓼urjectivitySubstitunctionExtensionTerm σ τ₂
𝓼urjectivitySubstitunctionExtensionTerm σ (function p τs) = function p (𝓼urjectivitySubstitunctionExtensionTerms σ τs)
𝓼urjectivitySubstitunctionExtensionTerms : ∀ {N} → Smap.type Substitunction (Extension $ Terms N) surjection surjection
𝓼urjectivitySubstitunctionExtensionTerms σ ∅ = ∅
𝓼urjectivitySubstitunctionExtensionTerms σ (τ , τs) = 𝓼urjectivitySubstitunctionExtensionTerm σ τ , 𝓼urjectivitySubstitunctionExtensionTerms σ τs
instance
𝓢urjectivitySubstitunctionExtensionTerm : Smap!.class Substitunction (Extension Term)
𝓢urjectivitySubstitunctionExtensionTerm .⋆ _ _ = 𝓼urjectivitySubstitunctionExtensionTerm
𝓢urjectivitySubstitunctionExtensionTerms : ∀ {N} → Smap!.class Substitunction (Extension $ Terms N)
𝓢urjectivitySubstitunctionExtensionTerms .⋆ _ _ = 𝓼urjectivitySubstitunctionExtensionTerms
instance
𝓣ransitivitySubstitunction : Transitivity.class Substitunction
𝓣ransitivitySubstitunction .⋆ f g = smap g ∘ f
[IsExtensionB]Term : [IsExtensionB] Term
[IsExtensionB]Term = ∁
[IsExtensionB]Terms : ∀ {N} → [IsExtensionB] (Terms N)
[IsExtensionB]Terms = ∁
private
mutual
𝓼urjextensionalitySubstitunctionExtensionTerm : Surjextensionality!.TYPE Substitunction _≈_ (Extension Term) _≈_
𝓼urjextensionalitySubstitunctionExtensionTerm p (i x) = p x
𝓼urjextensionalitySubstitunctionExtensionTerm p leaf = ∅
𝓼urjextensionalitySubstitunctionExtensionTerm p (s fork t) = congruity₂ _fork_ (𝓼urjextensionalitySubstitunctionExtensionTerm p s) (𝓼urjextensionalitySubstitunctionExtensionTerm p t)
𝓼urjextensionalitySubstitunctionExtensionTerm p (function fn ts) = congruity (function fn) (𝓼urjextensionalitySubstitunctionExtensionTerms p ts)
𝓼urjextensionalitySubstitunctionExtensionTerms : ∀ {N} → Surjextensionality!.TYPE Substitunction Proposextensequality (Extension $ Terms N) Proposextensequality
𝓼urjextensionalitySubstitunctionExtensionTerms p ∅ = ∅
𝓼urjextensionalitySubstitunctionExtensionTerms p (t , ts) = congruity₂ _,_ (𝓼urjextensionalitySubstitunctionExtensionTerm p t) (𝓼urjextensionalitySubstitunctionExtensionTerms p ts)
instance
𝓢urjextensionalitySubstitunction : Surjextensionality!.class Substitunction Proposextensequality (Extension Term) Proposextensequality
𝓢urjextensionalitySubstitunction .⋆ _ _ _ _ = 𝓼urjextensionalitySubstitunctionExtensionTerm
𝓢urjextensionalitySubstitunctions : ∀ {N} → Surjextensionality!.class Substitunction Proposextensequality (Extension $ Terms N) Proposextensequality
𝓢urjextensionalitySubstitunctions .⋆ _ _ _ _ = 𝓼urjextensionalitySubstitunctionExtensionTerms
private
mutual
𝓼urjtranscommutativitySubstitunctionExtensionTerm : Surjtranscommutativity.type Substitunction (Extension Term) Proposextensequality smap transitivity transitivity
𝓼urjtranscommutativitySubstitunctionExtensionTerm _ _ (i _) = !
𝓼urjtranscommutativitySubstitunctionExtensionTerm _ _ leaf = !
𝓼urjtranscommutativitySubstitunctionExtensionTerm _ _ (τ₁ fork τ₂) = congruity₂ _fork_ (𝓼urjtranscommutativitySubstitunctionExtensionTerm _ _ τ₁) (𝓼urjtranscommutativitySubstitunctionExtensionTerm _ _ τ₂)
𝓼urjtranscommutativitySubstitunctionExtensionTerm f g (function fn ts) = congruity (function fn) (𝓼urjtranscommutativitySubstitunctionExtensionTerms f g ts)
𝓼urjtranscommutativitySubstitunctionExtensionTerms : ∀ {N} → Surjtranscommutativity.type Substitunction (Extension $ Terms N) Proposextensequality smap transitivity transitivity
𝓼urjtranscommutativitySubstitunctionExtensionTerms _ _ ∅ = !
𝓼urjtranscommutativitySubstitunctionExtensionTerms _ _ (τ , τs) = congruity₂ _,_ (𝓼urjtranscommutativitySubstitunctionExtensionTerm _ _ τ) (𝓼urjtranscommutativitySubstitunctionExtensionTerms _ _ τs)
instance
𝓢urjtranscommutativitySubstitunctionExtensionTerm : Surjtranscommutativity.class Substitunction (Extension Term) Proposextensequality smap transitivity transitivity
𝓢urjtranscommutativitySubstitunctionExtensionTerm .⋆ = 𝓼urjtranscommutativitySubstitunctionExtensionTerm
𝓢urjtranscommutativitySubstitunctionExtensionTerms : ∀ {N} → Surjtranscommutativity.class Substitunction (Extension $ Terms N) Proposextensequality smap transitivity transitivity
𝓢urjtranscommutativitySubstitunctionExtensionTerms .⋆ = 𝓼urjtranscommutativitySubstitunctionExtensionTerms
instance
𝓣ransassociativitySubstitunction : Transassociativity!.class Substitunction _≈_
𝓣ransassociativitySubstitunction .⋆ f g h = surjtranscommutativity g h ∘ f
𝓣ransextensionalitySubstitunction : Transextensionality!.class Substitunction _≈_
𝓣ransextensionalitySubstitunction .⋆ {f₂ = f₂} f₁≡̇f₂ g₁≡̇g₂ x rewrite f₁≡̇f₂ x = surjextensionality g₁≡̇g₂ $ f₂ x
IsPrecategorySubstitunction : IsPrecategory Substitunction _≈_ transitivity
IsPrecategorySubstitunction = ∁
IsPrefunctorSubstitunctionExtensionTerm : IsPrefunctor Substitunction _≈_ transitivity (Extension Term) _≈_ transitivity smap
IsPrefunctorSubstitunctionExtensionTerm = ∁
IsPrefunctorSubstitunctionExtensionTerms : ∀ {N} → IsPrefunctor Substitunction _≈_ transitivity (Extension $ Terms N) _≈_ transitivity smap
IsPrefunctorSubstitunctionExtensionTerms = ∁
𝓡eflexivitySubstitunction : Reflexivity.class Substitunction
𝓡eflexivitySubstitunction .⋆ = i
private
mutual
𝓼urjidentitySubstitunctionExtensionTerm : Surjidentity.type Substitunction (Extension Term) _≈_ smap ε ε
𝓼urjidentitySubstitunctionExtensionTerm (i x) = ∅
𝓼urjidentitySubstitunctionExtensionTerm leaf = ∅
𝓼urjidentitySubstitunctionExtensionTerm (s fork t) = congruity₂ _fork_ (𝓼urjidentitySubstitunctionExtensionTerm s) (𝓼urjidentitySubstitunctionExtensionTerm t)
𝓼urjidentitySubstitunctionExtensionTerm (function fn ts) = congruity (function fn) (𝓼urjidentitySubstitunctionExtensionTerms ts)
𝓼urjidentitySubstitunctionExtensionTerms : ∀ {N} → Surjidentity.type Substitunction (Extension $ Terms N) _≈_ smap ε ε
𝓼urjidentitySubstitunctionExtensionTerms ∅ = ∅
𝓼urjidentitySubstitunctionExtensionTerms (t , ts) = congruity₂ _,_ (𝓼urjidentitySubstitunctionExtensionTerm t) (𝓼urjidentitySubstitunctionExtensionTerms ts)
instance
𝓢urjidentitySubstitunctionExtensionTerm : Surjidentity.class Substitunction (Extension Term) _≈_ smap ε ε
𝓢urjidentitySubstitunctionExtensionTerm .⋆ = 𝓼urjidentitySubstitunctionExtensionTerm
𝓢urjidentitySubstitunctionExtensionTerms : ∀ {N} → Surjidentity.class Substitunction (Extension $ Terms N) _≈_ smap ε ε
𝓢urjidentitySubstitunctionExtensionTerms .⋆ = 𝓼urjidentitySubstitunctionExtensionTerms
𝓣ransleftidentitySubstitunction : Transleftidentity!.class Substitunction _≈_
𝓣ransleftidentitySubstitunction .⋆ {f = f} = surjidentity ∘ f
𝓣ransrightidentitySubstitunction : Transrightidentity!.class Substitunction _≈_
𝓣ransrightidentitySubstitunction .⋆ _ = !
IsCategorySubstitunction : IsCategory Substitunction _≈_ ε transitivity
IsCategorySubstitunction = ∁
IsFunctorSubstitunctionExtensionTerm : IsFunctor Substitunction _≈_ ε transitivity (Extension Term) _≈_ ε transitivity smap
IsFunctorSubstitunctionExtensionTerm = ∁
IsFunctorSubstitunctionExtensionTerms : ∀ {N} → IsFunctor Substitunction _≈_ ε transitivity (Extension $ Terms N) _≈_ ε transitivity smap
IsFunctorSubstitunctionExtensionTerms = ∁
module _ {𝔭} (𝔓 : Ø 𝔭) where
open Substitunction 𝔓
open Term 𝔓
PrecategorySubstitunction : Precategory _ _ _
PrecategorySubstitunction = ∁ Substitunction _≈_ transitivity
PrefunctorSubstitunctionExtensionTerm : Prefunctor _ _ _ _ _ _
PrefunctorSubstitunctionExtensionTerm = ∁ Substitunction _≈_ transitivity (Extension Term) _≈_ transitivity smap
CategorySubstitunction : Category _ _ _
CategorySubstitunction = ∁ Substitunction _≈_ ε transitivity
FunctorSubstitunctionExtensionTerm : Functor _ _ _ _ _ _
FunctorSubstitunctionExtensionTerm = ∁ Substitunction _≈_ ε transitivity (Extension Term) _≈_ ε transitivity smap
module _ (N : ¶) where
FunctorSubstitunctionExtensionTerms : Functor _ _ _ _ _ _
FunctorSubstitunctionExtensionTerms = ∁ Substitunction _≈_ ε transitivity (Extension $ Terms N) _≈_ ε transitivity smap
| {
"alphanum_fraction": 0.8158665105,
"avg_line_length": 50.9850746269,
"ext": "agda",
"hexsha": "efbb1d50d71aee6e30b3deb9dd54e76b5b104d22",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/Oscar/Property/Functor/SubstitunctionExtensionTerm.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Property/Functor/SubstitunctionExtensionTerm.agda",
"max_line_length": 210,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-3/src/Oscar/Property/Functor/SubstitunctionExtensionTerm.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3026,
"size": 10248
} |
{-
Eilenberg–Mac Lane type K(G, 1)
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.EilenbergMacLane1.Properties where
open import Cubical.HITs.EilenbergMacLane1.Base
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Path
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Data.Sigma
open import Cubical.Algebra.Group.Base
open import Cubical.HITs.PropositionalTruncation as PropTrunc using (∥_∥; ∣_∣; squash)
open import Cubical.HITs.SetTruncation as SetTrunc using (∥_∥₂; ∣_∣₂; squash₂)
-- Type quotients
private
variable
ℓG ℓ : Level
module _ (G : Group {ℓG}) where
open Group G
elimEq : {B : EM₁ G → Type ℓ}
(Bprop : (x : EM₁ G) → isProp (B x))
{x y : EM₁ G}
(eq : x ≡ y)
(bx : B x)
(by : B y) →
PathP (λ i → B (eq i)) bx by
elimEq {B = B} Bprop {x = x} =
J (λ y eq → ∀ bx by → PathP (λ i → B (eq i)) bx by) (λ bx by → Bprop x bx by)
elimProp : {B : EM₁ G → Type ℓ}
→ ((x : EM₁ G) → isProp (B x))
→ B embase
→ (x : EM₁ G)
→ B x
elimProp Bprop b embase = b
elimProp Bprop b (emloop g i) = elimEq Bprop (emloop g) b b i
elimProp Bprop b (emcomp g h i j) =
isSet→isSetDep (λ x → isProp→isSet (Bprop x))
(emloop g) (emloop (g + h)) (λ j → embase) (emloop h) (emcomp g h)
(λ i → elimEq Bprop (emloop g) b b i)
(λ i → elimEq Bprop (emloop (g + h)) b b i)
(λ j → b) (λ j → elimEq Bprop (emloop h) b b j) i j
elimProp Bprop b (emsquash x y p q r s i j k) =
isOfHLevel→isOfHLevelDep 3 (λ x → isSet→isGroupoid (isProp→isSet (Bprop x)))
_ _ _ _ (λ j k → g (r j k)) (λ j k → g (s j k)) (emsquash x y p q r s) i j k
where
g = elimProp Bprop b
elimProp2 : {C : EM₁ G → EM₁ G → Type ℓ}
→ ((x y : EM₁ G) → isProp (C x y))
→ C embase embase
→ (x y : EM₁ G)
→ C x y
elimProp2 Cprop c = elimProp (λ x → isPropΠ (λ y → Cprop x y))
(elimProp (λ y → Cprop embase y) c)
elimSet : {B : EM₁ G → Type ℓ}
→ ((x : EM₁ G) → isSet (B x))
→ (b : B embase)
→ ((g : Carrier) → PathP (λ i → B (emloop g i)) b b)
→ (x : EM₁ G)
→ B x
elimSet Bset b bloop embase = b
elimSet Bset b bloop (emloop g i) = bloop g i
elimSet Bset b bloop (emcomp g h i j) =
isSet→isSetDep Bset (emloop g) (emloop (g + h)) (λ j → embase) (emloop h) (emcomp g h)
(bloop g) (bloop (g + h)) refl (bloop h) i j
elimSet Bset b bloop (emsquash x y p q r s i j k) =
isOfHLevel→isOfHLevelDep 3 (λ x → isSet→isGroupoid (Bset x))
_ _ _ _ (λ j k → g (r j k)) (λ j k → g (s j k)) (emsquash x y p q r s) i j k
where
g = elimSet Bset b bloop
elim : {B : EM₁ G → Type ℓ}
→ ((x : EM₁ G) → isGroupoid (B x))
→ (b : B embase)
→ (bloop : (g : Carrier) → PathP (λ i → B (emloop g i)) b b)
→ ((g h : Carrier) → SquareP (λ i j → B (emcomp g h i j))
(bloop g) (bloop (g + h)) (λ j → b) (bloop h))
→ (x : EM₁ G)
→ B x
elim Bgpd b bloop bcomp embase = b
elim Bgpd b bloop bcomp (emloop g i) = bloop g i
elim Bgpd b bloop bcomp (emcomp g h i j) = bcomp g h i j
elim Bgpd b bloop bcomp (emsquash x y p q r s i j k) =
isOfHLevel→isOfHLevelDep 3 Bgpd
_ _ _ _ (λ j k → g (r j k)) (λ j k → g (s j k)) (emsquash x y p q r s) i j k
where
g = elim Bgpd b bloop bcomp
rec : {B : Type ℓ}
→ isGroupoid B
→ (b : B)
→ (bloop : Carrier → b ≡ b)
→ ((g h : Carrier) → Square (bloop g) (bloop (g + h)) refl (bloop h))
→ (x : EM₁ G)
→ B
rec Bgpd = elim (λ _ → Bgpd)
rec' : {B : Type ℓ}
→ isGroupoid B
→ (b : B)
→ (bloop : Carrier → b ≡ b)
→ ((g h : Carrier) → (bloop g) ∙ (bloop h) ≡ bloop (g + h))
→ (x : EM₁ G)
→ B
rec' Bgpd b bloop p = rec Bgpd b bloop sq
where
module _ (g h : Carrier) where
abstract
sq : Square (bloop g) (bloop (g + h)) refl (bloop h)
sq =
transport (sym (Square≡doubleComp (bloop g) (bloop (g + h)) refl (bloop h)))
(refl ∙∙ bloop g ∙∙ bloop h
≡⟨ doubleCompPath-elim refl (bloop g) (bloop h) ⟩
(refl ∙ bloop g) ∙ bloop h
≡⟨ cong (_∙ bloop h) (sym (lUnit (bloop g))) ⟩
bloop g ∙ bloop h
≡⟨ p g h ⟩
bloop (g + h) ∎)
| {
"alphanum_fraction": 0.5288241415,
"avg_line_length": 33.3680555556,
"ext": "agda",
"hexsha": "22fbb59f4a0166177aa6aac8831a213fb89bcbc2",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Schippmunk/cubical",
"max_forks_repo_path": "Cubical/HITs/EilenbergMacLane1/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Schippmunk/cubical",
"max_issues_repo_path": "Cubical/HITs/EilenbergMacLane1/Properties.agda",
"max_line_length": 90,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Schippmunk/cubical",
"max_stars_repo_path": "Cubical/HITs/EilenbergMacLane1/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1823,
"size": 4805
} |
module Text.Greek.SBLGNT.1Thess where
open import Data.List
open import Text.Greek.Bible
open import Text.Greek.Script
open import Text.Greek.Script.Unicode
ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Α : List (Word)
ΠΡΟΣ-ΘΕΣΣΑΛΟΝΙΚΕΙΣ-Α =
word (Π ∷ α ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "1Thess.1.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.1"
∷ word (Σ ∷ ι ∷ ∙λ ∷ ο ∷ υ ∷ α ∷ ν ∷ ὸ ∷ ς ∷ []) "1Thess.1.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.1"
∷ word (Τ ∷ ι ∷ μ ∷ ό ∷ θ ∷ ε ∷ ο ∷ ς ∷ []) "1Thess.1.1"
∷ word (τ ∷ ῇ ∷ []) "1Thess.1.1"
∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ ᾳ ∷ []) "1Thess.1.1"
∷ word (Θ ∷ ε ∷ σ ∷ σ ∷ α ∷ ∙λ ∷ ο ∷ ν ∷ ι ∷ κ ∷ έ ∷ ω ∷ ν ∷ []) "1Thess.1.1"
∷ word (ἐ ∷ ν ∷ []) "1Thess.1.1"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "1Thess.1.1"
∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὶ ∷ []) "1Thess.1.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.1"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "1Thess.1.1"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.1.1"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "1Thess.1.1"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "1Thess.1.1"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.1.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.1"
∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "1Thess.1.1"
∷ word (Ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.1.2"
∷ word (τ ∷ ῷ ∷ []) "1Thess.1.2"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "1Thess.1.2"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "1Thess.1.2"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "1Thess.1.2"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "1Thess.1.2"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.1.2"
∷ word (μ ∷ ν ∷ ε ∷ ί ∷ α ∷ ν ∷ []) "1Thess.1.2"
∷ word (π ∷ ο ∷ ι ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.1.2"
∷ word (ἐ ∷ π ∷ ὶ ∷ []) "1Thess.1.2"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.1.2"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ υ ∷ χ ∷ ῶ ∷ ν ∷ []) "1Thess.1.2"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.1.2"
∷ word (ἀ ∷ δ ∷ ι ∷ α ∷ ∙λ ∷ ε ∷ ί ∷ π ∷ τ ∷ ω ∷ ς ∷ []) "1Thess.1.2"
∷ word (μ ∷ ν ∷ η ∷ μ ∷ ο ∷ ν ∷ ε ∷ ύ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.1.3"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.1.3"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.1.3"
∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ υ ∷ []) "1Thess.1.3"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.1.3"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "1Thess.1.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.3"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.1.3"
∷ word (κ ∷ ό ∷ π ∷ ο ∷ υ ∷ []) "1Thess.1.3"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.1.3"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ς ∷ []) "1Thess.1.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.3"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.1.3"
∷ word (ὑ ∷ π ∷ ο ∷ μ ∷ ο ∷ ν ∷ ῆ ∷ ς ∷ []) "1Thess.1.3"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.1.3"
∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ δ ∷ ο ∷ ς ∷ []) "1Thess.1.3"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.1.3"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.1.3"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.1.3"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.1.3"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.1.3"
∷ word (ἔ ∷ μ ∷ π ∷ ρ ∷ ο ∷ σ ∷ θ ∷ ε ∷ ν ∷ []) "1Thess.1.3"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.1.3"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.1.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.3"
∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.1.3"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.1.3"
∷ word (ε ∷ ἰ ∷ δ ∷ ό ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.1.4"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ὶ ∷ []) "1Thess.1.4"
∷ word (ἠ ∷ γ ∷ α ∷ π ∷ η ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.1.4"
∷ word (ὑ ∷ π ∷ ὸ ∷ []) "1Thess.1.4"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.1.4"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "1Thess.1.4"
∷ word (ἐ ∷ κ ∷ ∙λ ∷ ο ∷ γ ∷ ὴ ∷ ν ∷ []) "1Thess.1.4"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.1.4"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.1.5"
∷ word (τ ∷ ὸ ∷ []) "1Thess.1.5"
∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ι ∷ ο ∷ ν ∷ []) "1Thess.1.5"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.1.5"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "1Thess.1.5"
∷ word (ἐ ∷ γ ∷ ε ∷ ν ∷ ή ∷ θ ∷ η ∷ []) "1Thess.1.5"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.1.5"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.1.5"
∷ word (ἐ ∷ ν ∷ []) "1Thess.1.5"
∷ word (∙λ ∷ ό ∷ γ ∷ ῳ ∷ []) "1Thess.1.5"
∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "1Thess.1.5"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "1Thess.1.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.5"
∷ word (ἐ ∷ ν ∷ []) "1Thess.1.5"
∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ ι ∷ []) "1Thess.1.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.5"
∷ word (ἐ ∷ ν ∷ []) "1Thess.1.5"
∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "1Thess.1.5"
∷ word (ἁ ∷ γ ∷ ί ∷ ῳ ∷ []) "1Thess.1.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.5"
∷ word (π ∷ ∙λ ∷ η ∷ ρ ∷ ο ∷ φ ∷ ο ∷ ρ ∷ ί ∷ ᾳ ∷ []) "1Thess.1.5"
∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ῇ ∷ []) "1Thess.1.5"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.1.5"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "1Thess.1.5"
∷ word (ο ∷ ἷ ∷ ο ∷ ι ∷ []) "1Thess.1.5"
∷ word (ἐ ∷ γ ∷ ε ∷ ν ∷ ή ∷ θ ∷ η ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.1.5"
∷ word (ἐ ∷ ν ∷ []) "1Thess.1.5"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.1.5"
∷ word (δ ∷ ι ∷ []) "1Thess.1.5"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.1.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.6"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.1.6"
∷ word (μ ∷ ι ∷ μ ∷ η ∷ τ ∷ α ∷ ὶ ∷ []) "1Thess.1.6"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.1.6"
∷ word (ἐ ∷ γ ∷ ε ∷ ν ∷ ή ∷ θ ∷ η ∷ τ ∷ ε ∷ []) "1Thess.1.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.6"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.1.6"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.1.6"
∷ word (δ ∷ ε ∷ ξ ∷ ά ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.1.6"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.1.6"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ν ∷ []) "1Thess.1.6"
∷ word (ἐ ∷ ν ∷ []) "1Thess.1.6"
∷ word (θ ∷ ∙λ ∷ ί ∷ ψ ∷ ε ∷ ι ∷ []) "1Thess.1.6"
∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ῇ ∷ []) "1Thess.1.6"
∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "1Thess.1.6"
∷ word (χ ∷ α ∷ ρ ∷ ᾶ ∷ ς ∷ []) "1Thess.1.6"
∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "1Thess.1.6"
∷ word (ἁ ∷ γ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.1.6"
∷ word (ὥ ∷ σ ∷ τ ∷ ε ∷ []) "1Thess.1.7"
∷ word (γ ∷ ε ∷ ν ∷ έ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "1Thess.1.7"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.1.7"
∷ word (τ ∷ ύ ∷ π ∷ ο ∷ ν ∷ []) "1Thess.1.7"
∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.1.7"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "1Thess.1.7"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.1.7"
∷ word (ἐ ∷ ν ∷ []) "1Thess.1.7"
∷ word (τ ∷ ῇ ∷ []) "1Thess.1.7"
∷ word (Μ ∷ α ∷ κ ∷ ε ∷ δ ∷ ο ∷ ν ∷ ί ∷ ᾳ ∷ []) "1Thess.1.7"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.7"
∷ word (ἐ ∷ ν ∷ []) "1Thess.1.7"
∷ word (τ ∷ ῇ ∷ []) "1Thess.1.7"
∷ word (Ἀ ∷ χ ∷ α ∷ ΐ ∷ ᾳ ∷ []) "1Thess.1.7"
∷ word (ἀ ∷ φ ∷ []) "1Thess.1.8"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.1.8"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.1.8"
∷ word (ἐ ∷ ξ ∷ ή ∷ χ ∷ η ∷ τ ∷ α ∷ ι ∷ []) "1Thess.1.8"
∷ word (ὁ ∷ []) "1Thess.1.8"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ς ∷ []) "1Thess.1.8"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.1.8"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.1.8"
∷ word (ο ∷ ὐ ∷ []) "1Thess.1.8"
∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "1Thess.1.8"
∷ word (ἐ ∷ ν ∷ []) "1Thess.1.8"
∷ word (τ ∷ ῇ ∷ []) "1Thess.1.8"
∷ word (Μ ∷ α ∷ κ ∷ ε ∷ δ ∷ ο ∷ ν ∷ ί ∷ ᾳ ∷ []) "1Thess.1.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.8"
∷ word (Ἀ ∷ χ ∷ α ∷ ΐ ∷ ᾳ ∷ []) "1Thess.1.8"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "1Thess.1.8"
∷ word (ἐ ∷ ν ∷ []) "1Thess.1.8"
∷ word (π ∷ α ∷ ν ∷ τ ∷ ὶ ∷ []) "1Thess.1.8"
∷ word (τ ∷ ό ∷ π ∷ ῳ ∷ []) "1Thess.1.8"
∷ word (ἡ ∷ []) "1Thess.1.8"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ς ∷ []) "1Thess.1.8"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.1.8"
∷ word (ἡ ∷ []) "1Thess.1.8"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.1.8"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.1.8"
∷ word (θ ∷ ε ∷ ὸ ∷ ν ∷ []) "1Thess.1.8"
∷ word (ἐ ∷ ξ ∷ ε ∷ ∙λ ∷ ή ∷ ∙λ ∷ υ ∷ θ ∷ ε ∷ ν ∷ []) "1Thess.1.8"
∷ word (ὥ ∷ σ ∷ τ ∷ ε ∷ []) "1Thess.1.8"
∷ word (μ ∷ ὴ ∷ []) "1Thess.1.8"
∷ word (χ ∷ ρ ∷ ε ∷ ί ∷ α ∷ ν ∷ []) "1Thess.1.8"
∷ word (ἔ ∷ χ ∷ ε ∷ ι ∷ ν ∷ []) "1Thess.1.8"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.1.8"
∷ word (∙λ ∷ α ∷ ∙λ ∷ ε ∷ ῖ ∷ ν ∷ []) "1Thess.1.8"
∷ word (τ ∷ ι ∷ []) "1Thess.1.8"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὶ ∷ []) "1Thess.1.9"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.1.9"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "1Thess.1.9"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.1.9"
∷ word (ἀ ∷ π ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.1.9"
∷ word (ὁ ∷ π ∷ ο ∷ ί ∷ α ∷ ν ∷ []) "1Thess.1.9"
∷ word (ε ∷ ἴ ∷ σ ∷ ο ∷ δ ∷ ο ∷ ν ∷ []) "1Thess.1.9"
∷ word (ἔ ∷ σ ∷ χ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.1.9"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.1.9"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.1.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.9"
∷ word (π ∷ ῶ ∷ ς ∷ []) "1Thess.1.9"
∷ word (ἐ ∷ π ∷ ε ∷ σ ∷ τ ∷ ρ ∷ έ ∷ ψ ∷ α ∷ τ ∷ ε ∷ []) "1Thess.1.9"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.1.9"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.1.9"
∷ word (θ ∷ ε ∷ ὸ ∷ ν ∷ []) "1Thess.1.9"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "1Thess.1.9"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.1.9"
∷ word (ε ∷ ἰ ∷ δ ∷ ώ ∷ ∙λ ∷ ω ∷ ν ∷ []) "1Thess.1.9"
∷ word (δ ∷ ο ∷ υ ∷ ∙λ ∷ ε ∷ ύ ∷ ε ∷ ι ∷ ν ∷ []) "1Thess.1.9"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "1Thess.1.9"
∷ word (ζ ∷ ῶ ∷ ν ∷ τ ∷ ι ∷ []) "1Thess.1.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.9"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ι ∷ ν ∷ ῷ ∷ []) "1Thess.1.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.1.10"
∷ word (ἀ ∷ ν ∷ α ∷ μ ∷ έ ∷ ν ∷ ε ∷ ι ∷ ν ∷ []) "1Thess.1.10"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.1.10"
∷ word (υ ∷ ἱ ∷ ὸ ∷ ν ∷ []) "1Thess.1.10"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.1.10"
∷ word (ἐ ∷ κ ∷ []) "1Thess.1.10"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.1.10"
∷ word (ο ∷ ὐ ∷ ρ ∷ α ∷ ν ∷ ῶ ∷ ν ∷ []) "1Thess.1.10"
∷ word (ὃ ∷ ν ∷ []) "1Thess.1.10"
∷ word (ἤ ∷ γ ∷ ε ∷ ι ∷ ρ ∷ ε ∷ ν ∷ []) "1Thess.1.10"
∷ word (ἐ ∷ κ ∷ []) "1Thess.1.10"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.1.10"
∷ word (ν ∷ ε ∷ κ ∷ ρ ∷ ῶ ∷ ν ∷ []) "1Thess.1.10"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ν ∷ []) "1Thess.1.10"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.1.10"
∷ word (ῥ ∷ υ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ν ∷ []) "1Thess.1.10"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.1.10"
∷ word (ἐ ∷ κ ∷ []) "1Thess.1.10"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.1.10"
∷ word (ὀ ∷ ρ ∷ γ ∷ ῆ ∷ ς ∷ []) "1Thess.1.10"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.1.10"
∷ word (ἐ ∷ ρ ∷ χ ∷ ο ∷ μ ∷ έ ∷ ν ∷ η ∷ ς ∷ []) "1Thess.1.10"
∷ word (Α ∷ ὐ ∷ τ ∷ ο ∷ ὶ ∷ []) "1Thess.2.1"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.2.1"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "1Thess.2.1"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.2.1"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "1Thess.2.1"
∷ word (ε ∷ ἴ ∷ σ ∷ ο ∷ δ ∷ ο ∷ ν ∷ []) "1Thess.2.1"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.1"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "1Thess.2.1"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.2.1"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.2.1"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.2.1"
∷ word (ο ∷ ὐ ∷ []) "1Thess.2.1"
∷ word (κ ∷ ε ∷ ν ∷ ὴ ∷ []) "1Thess.2.1"
∷ word (γ ∷ έ ∷ γ ∷ ο ∷ ν ∷ ε ∷ ν ∷ []) "1Thess.2.1"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "1Thess.2.2"
∷ word (π ∷ ρ ∷ ο ∷ π ∷ α ∷ θ ∷ ό ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.2.2"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.2"
∷ word (ὑ ∷ β ∷ ρ ∷ ι ∷ σ ∷ θ ∷ έ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.2.2"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.2.2"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "1Thess.2.2"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.2"
∷ word (Φ ∷ ι ∷ ∙λ ∷ ί ∷ π ∷ π ∷ ο ∷ ι ∷ ς ∷ []) "1Thess.2.2"
∷ word (ἐ ∷ π ∷ α ∷ ρ ∷ ρ ∷ η ∷ σ ∷ ι ∷ α ∷ σ ∷ ά ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "1Thess.2.2"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.2"
∷ word (τ ∷ ῷ ∷ []) "1Thess.2.2"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "1Thess.2.2"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.2"
∷ word (∙λ ∷ α ∷ ∙λ ∷ ῆ ∷ σ ∷ α ∷ ι ∷ []) "1Thess.2.2"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.2.2"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.2.2"
∷ word (τ ∷ ὸ ∷ []) "1Thess.2.2"
∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ι ∷ ο ∷ ν ∷ []) "1Thess.2.2"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.2"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.2.2"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.2"
∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ῷ ∷ []) "1Thess.2.2"
∷ word (ἀ ∷ γ ∷ ῶ ∷ ν ∷ ι ∷ []) "1Thess.2.2"
∷ word (ἡ ∷ []) "1Thess.2.3"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.2.3"
∷ word (π ∷ α ∷ ρ ∷ ά ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ι ∷ ς ∷ []) "1Thess.2.3"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.3"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "1Thess.2.3"
∷ word (ἐ ∷ κ ∷ []) "1Thess.2.3"
∷ word (π ∷ ∙λ ∷ ά ∷ ν ∷ η ∷ ς ∷ []) "1Thess.2.3"
∷ word (ο ∷ ὐ ∷ δ ∷ ὲ ∷ []) "1Thess.2.3"
∷ word (ἐ ∷ ξ ∷ []) "1Thess.2.3"
∷ word (ἀ ∷ κ ∷ α ∷ θ ∷ α ∷ ρ ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "1Thess.2.3"
∷ word (ο ∷ ὐ ∷ δ ∷ ὲ ∷ []) "1Thess.2.3"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.3"
∷ word (δ ∷ ό ∷ ∙λ ∷ ῳ ∷ []) "1Thess.2.3"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "1Thess.2.4"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.2.4"
∷ word (δ ∷ ε ∷ δ ∷ ο ∷ κ ∷ ι ∷ μ ∷ ά ∷ σ ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "1Thess.2.4"
∷ word (ὑ ∷ π ∷ ὸ ∷ []) "1Thess.2.4"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.4"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.2.4"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ υ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "1Thess.2.4"
∷ word (τ ∷ ὸ ∷ []) "1Thess.2.4"
∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ι ∷ ο ∷ ν ∷ []) "1Thess.2.4"
∷ word (ο ∷ ὕ ∷ τ ∷ ω ∷ ς ∷ []) "1Thess.2.4"
∷ word (∙λ ∷ α ∷ ∙λ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.2.4"
∷ word (ο ∷ ὐ ∷ χ ∷ []) "1Thess.2.4"
∷ word (ὡ ∷ ς ∷ []) "1Thess.2.4"
∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ο ∷ ι ∷ ς ∷ []) "1Thess.2.4"
∷ word (ἀ ∷ ρ ∷ έ ∷ σ ∷ κ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.2.4"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "1Thess.2.4"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "1Thess.2.4"
∷ word (τ ∷ ῷ ∷ []) "1Thess.2.4"
∷ word (δ ∷ ο ∷ κ ∷ ι ∷ μ ∷ ά ∷ ζ ∷ ο ∷ ν ∷ τ ∷ ι ∷ []) "1Thess.2.4"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "1Thess.2.4"
∷ word (κ ∷ α ∷ ρ ∷ δ ∷ ί ∷ α ∷ ς ∷ []) "1Thess.2.4"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.4"
∷ word (ο ∷ ὔ ∷ τ ∷ ε ∷ []) "1Thess.2.5"
∷ word (γ ∷ ά ∷ ρ ∷ []) "1Thess.2.5"
∷ word (π ∷ ο ∷ τ ∷ ε ∷ []) "1Thess.2.5"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.5"
∷ word (∙λ ∷ ό ∷ γ ∷ ῳ ∷ []) "1Thess.2.5"
∷ word (κ ∷ ο ∷ ∙λ ∷ α ∷ κ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "1Thess.2.5"
∷ word (ἐ ∷ γ ∷ ε ∷ ν ∷ ή ∷ θ ∷ η ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.2.5"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.2.5"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "1Thess.2.5"
∷ word (ο ∷ ὔ ∷ τ ∷ ε ∷ []) "1Thess.2.5"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.5"
∷ word (π ∷ ρ ∷ ο ∷ φ ∷ ά ∷ σ ∷ ε ∷ ι ∷ []) "1Thess.2.5"
∷ word (π ∷ ∙λ ∷ ε ∷ ο ∷ ν ∷ ε ∷ ξ ∷ ί ∷ α ∷ ς ∷ []) "1Thess.2.5"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "1Thess.2.5"
∷ word (μ ∷ ά ∷ ρ ∷ τ ∷ υ ∷ ς ∷ []) "1Thess.2.5"
∷ word (ο ∷ ὔ ∷ τ ∷ ε ∷ []) "1Thess.2.6"
∷ word (ζ ∷ η ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.2.6"
∷ word (ἐ ∷ ξ ∷ []) "1Thess.2.6"
∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ω ∷ ν ∷ []) "1Thess.2.6"
∷ word (δ ∷ ό ∷ ξ ∷ α ∷ ν ∷ []) "1Thess.2.6"
∷ word (ο ∷ ὔ ∷ τ ∷ ε ∷ []) "1Thess.2.6"
∷ word (ἀ ∷ φ ∷ []) "1Thess.2.6"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.6"
∷ word (ο ∷ ὔ ∷ τ ∷ ε ∷ []) "1Thess.2.6"
∷ word (ἀ ∷ π ∷ []) "1Thess.2.6"
∷ word (ἄ ∷ ∙λ ∷ ∙λ ∷ ω ∷ ν ∷ []) "1Thess.2.6"
∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.2.7"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.7"
∷ word (β ∷ ά ∷ ρ ∷ ε ∷ ι ∷ []) "1Thess.2.7"
∷ word (ε ∷ ἶ ∷ ν ∷ α ∷ ι ∷ []) "1Thess.2.7"
∷ word (ὡ ∷ ς ∷ []) "1Thess.2.7"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.7"
∷ word (ἀ ∷ π ∷ ό ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ο ∷ ι ∷ []) "1Thess.2.7"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "1Thess.2.7"
∷ word (ἐ ∷ γ ∷ ε ∷ ν ∷ ή ∷ θ ∷ η ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.2.7"
∷ word (ἤ ∷ π ∷ ι ∷ ο ∷ ι ∷ []) "1Thess.2.7"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.7"
∷ word (μ ∷ έ ∷ σ ∷ ῳ ∷ []) "1Thess.2.7"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.7"
∷ word (ὡ ∷ ς ∷ []) "1Thess.2.7"
∷ word (ἐ ∷ ὰ ∷ ν ∷ []) "1Thess.2.7"
∷ word (τ ∷ ρ ∷ ο ∷ φ ∷ ὸ ∷ ς ∷ []) "1Thess.2.7"
∷ word (θ ∷ ά ∷ ∙λ ∷ π ∷ ῃ ∷ []) "1Thess.2.7"
∷ word (τ ∷ ὰ ∷ []) "1Thess.2.7"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῆ ∷ ς ∷ []) "1Thess.2.7"
∷ word (τ ∷ έ ∷ κ ∷ ν ∷ α ∷ []) "1Thess.2.7"
∷ word (ο ∷ ὕ ∷ τ ∷ ω ∷ ς ∷ []) "1Thess.2.8"
∷ word (ὁ ∷ μ ∷ ε ∷ ι ∷ ρ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.2.8"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.8"
∷ word (ε ∷ ὐ ∷ δ ∷ ο ∷ κ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.2.8"
∷ word (μ ∷ ε ∷ τ ∷ α ∷ δ ∷ ο ∷ ῦ ∷ ν ∷ α ∷ ι ∷ []) "1Thess.2.8"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.2.8"
∷ word (ο ∷ ὐ ∷ []) "1Thess.2.8"
∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "1Thess.2.8"
∷ word (τ ∷ ὸ ∷ []) "1Thess.2.8"
∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ι ∷ ο ∷ ν ∷ []) "1Thess.2.8"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.8"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.2.8"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "1Thess.2.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.8"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "1Thess.2.8"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "1Thess.2.8"
∷ word (ψ ∷ υ ∷ χ ∷ ά ∷ ς ∷ []) "1Thess.2.8"
∷ word (δ ∷ ι ∷ ό ∷ τ ∷ ι ∷ []) "1Thess.2.8"
∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ο ∷ ὶ ∷ []) "1Thess.2.8"
∷ word (ἡ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.2.8"
∷ word (ἐ ∷ γ ∷ ε ∷ ν ∷ ή ∷ θ ∷ η ∷ τ ∷ ε ∷ []) "1Thess.2.8"
∷ word (Μ ∷ ν ∷ η ∷ μ ∷ ο ∷ ν ∷ ε ∷ ύ ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.2.9"
∷ word (γ ∷ ά ∷ ρ ∷ []) "1Thess.2.9"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.2.9"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.2.9"
∷ word (κ ∷ ό ∷ π ∷ ο ∷ ν ∷ []) "1Thess.2.9"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.9"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.2.9"
∷ word (μ ∷ ό ∷ χ ∷ θ ∷ ο ∷ ν ∷ []) "1Thess.2.9"
∷ word (ν ∷ υ ∷ κ ∷ τ ∷ ὸ ∷ ς ∷ []) "1Thess.2.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.9"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "1Thess.2.9"
∷ word (ἐ ∷ ρ ∷ γ ∷ α ∷ ζ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.2.9"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.2.9"
∷ word (τ ∷ ὸ ∷ []) "1Thess.2.9"
∷ word (μ ∷ ὴ ∷ []) "1Thess.2.9"
∷ word (ἐ ∷ π ∷ ι ∷ β ∷ α ∷ ρ ∷ ῆ ∷ σ ∷ α ∷ ί ∷ []) "1Thess.2.9"
∷ word (τ ∷ ι ∷ ν ∷ α ∷ []) "1Thess.2.9"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.9"
∷ word (ἐ ∷ κ ∷ η ∷ ρ ∷ ύ ∷ ξ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.2.9"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.2.9"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.2.9"
∷ word (τ ∷ ὸ ∷ []) "1Thess.2.9"
∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ι ∷ ο ∷ ν ∷ []) "1Thess.2.9"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.9"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.2.9"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.2.10"
∷ word (μ ∷ ά ∷ ρ ∷ τ ∷ υ ∷ ρ ∷ ε ∷ ς ∷ []) "1Thess.2.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.10"
∷ word (ὁ ∷ []) "1Thess.2.10"
∷ word (θ ∷ ε ∷ ό ∷ ς ∷ []) "1Thess.2.10"
∷ word (ὡ ∷ ς ∷ []) "1Thess.2.10"
∷ word (ὁ ∷ σ ∷ ί ∷ ω ∷ ς ∷ []) "1Thess.2.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.10"
∷ word (δ ∷ ι ∷ κ ∷ α ∷ ί ∷ ω ∷ ς ∷ []) "1Thess.2.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.10"
∷ word (ἀ ∷ μ ∷ έ ∷ μ ∷ π ∷ τ ∷ ω ∷ ς ∷ []) "1Thess.2.10"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.2.10"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "1Thess.2.10"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.2.10"
∷ word (ἐ ∷ γ ∷ ε ∷ ν ∷ ή ∷ θ ∷ η ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.2.10"
∷ word (κ ∷ α ∷ θ ∷ ά ∷ π ∷ ε ∷ ρ ∷ []) "1Thess.2.11"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "1Thess.2.11"
∷ word (ὡ ∷ ς ∷ []) "1Thess.2.11"
∷ word (ἕ ∷ ν ∷ α ∷ []) "1Thess.2.11"
∷ word (ἕ ∷ κ ∷ α ∷ σ ∷ τ ∷ ο ∷ ν ∷ []) "1Thess.2.11"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.11"
∷ word (ὡ ∷ ς ∷ []) "1Thess.2.11"
∷ word (π ∷ α ∷ τ ∷ ὴ ∷ ρ ∷ []) "1Thess.2.11"
∷ word (τ ∷ έ ∷ κ ∷ ν ∷ α ∷ []) "1Thess.2.11"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.11"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.2.12"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.2.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.12"
∷ word (π ∷ α ∷ ρ ∷ α ∷ μ ∷ υ ∷ θ ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.2.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.12"
∷ word (μ ∷ α ∷ ρ ∷ τ ∷ υ ∷ ρ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.2.12"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.2.12"
∷ word (τ ∷ ὸ ∷ []) "1Thess.2.12"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ε ∷ ῖ ∷ ν ∷ []) "1Thess.2.12"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.2.12"
∷ word (ἀ ∷ ξ ∷ ί ∷ ω ∷ ς ∷ []) "1Thess.2.12"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.12"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.2.12"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.12"
∷ word (κ ∷ α ∷ ∙λ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ο ∷ ς ∷ []) "1Thess.2.12"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.2.12"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.2.12"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "1Thess.2.12"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.12"
∷ word (β ∷ α ∷ σ ∷ ι ∷ ∙λ ∷ ε ∷ ί ∷ α ∷ ν ∷ []) "1Thess.2.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.12"
∷ word (δ ∷ ό ∷ ξ ∷ α ∷ ν ∷ []) "1Thess.2.12"
∷ word (Κ ∷ α ∷ ὶ ∷ []) "1Thess.2.13"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "1Thess.2.13"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "1Thess.2.13"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.13"
∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.2.13"
∷ word (ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.2.13"
∷ word (τ ∷ ῷ ∷ []) "1Thess.2.13"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "1Thess.2.13"
∷ word (ἀ ∷ δ ∷ ι ∷ α ∷ ∙λ ∷ ε ∷ ί ∷ π ∷ τ ∷ ω ∷ ς ∷ []) "1Thess.2.13"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.2.13"
∷ word (π ∷ α ∷ ρ ∷ α ∷ ∙λ ∷ α ∷ β ∷ ό ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.2.13"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ν ∷ []) "1Thess.2.13"
∷ word (ἀ ∷ κ ∷ ο ∷ ῆ ∷ ς ∷ []) "1Thess.2.13"
∷ word (π ∷ α ∷ ρ ∷ []) "1Thess.2.13"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.13"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.13"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.2.13"
∷ word (ἐ ∷ δ ∷ έ ∷ ξ ∷ α ∷ σ ∷ θ ∷ ε ∷ []) "1Thess.2.13"
∷ word (ο ∷ ὐ ∷ []) "1Thess.2.13"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ν ∷ []) "1Thess.2.13"
∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ω ∷ ν ∷ []) "1Thess.2.13"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "1Thess.2.13"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.2.13"
∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ῶ ∷ ς ∷ []) "1Thess.2.13"
∷ word (ἐ ∷ σ ∷ τ ∷ ὶ ∷ ν ∷ []) "1Thess.2.13"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ν ∷ []) "1Thess.2.13"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.2.13"
∷ word (ὃ ∷ ς ∷ []) "1Thess.2.13"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.13"
∷ word (ἐ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ε ∷ ῖ ∷ τ ∷ α ∷ ι ∷ []) "1Thess.2.13"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.13"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.2.13"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "1Thess.2.13"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.2.13"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.2.14"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.2.14"
∷ word (μ ∷ ι ∷ μ ∷ η ∷ τ ∷ α ∷ ὶ ∷ []) "1Thess.2.14"
∷ word (ἐ ∷ γ ∷ ε ∷ ν ∷ ή ∷ θ ∷ η ∷ τ ∷ ε ∷ []) "1Thess.2.14"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.2.14"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.2.14"
∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ι ∷ ῶ ∷ ν ∷ []) "1Thess.2.14"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.14"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.2.14"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.2.14"
∷ word (ο ∷ ὐ ∷ σ ∷ ῶ ∷ ν ∷ []) "1Thess.2.14"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.14"
∷ word (τ ∷ ῇ ∷ []) "1Thess.2.14"
∷ word (Ἰ ∷ ο ∷ υ ∷ δ ∷ α ∷ ί ∷ ᾳ ∷ []) "1Thess.2.14"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.14"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "1Thess.2.14"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.2.14"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.2.14"
∷ word (τ ∷ ὰ ∷ []) "1Thess.2.14"
∷ word (α ∷ ὐ ∷ τ ∷ ὰ ∷ []) "1Thess.2.14"
∷ word (ἐ ∷ π ∷ ά ∷ θ ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.2.14"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.14"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.2.14"
∷ word (ὑ ∷ π ∷ ὸ ∷ []) "1Thess.2.14"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.2.14"
∷ word (ἰ ∷ δ ∷ ί ∷ ω ∷ ν ∷ []) "1Thess.2.14"
∷ word (σ ∷ υ ∷ μ ∷ φ ∷ υ ∷ ∙λ ∷ ε ∷ τ ∷ ῶ ∷ ν ∷ []) "1Thess.2.14"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.2.14"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.14"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὶ ∷ []) "1Thess.2.14"
∷ word (ὑ ∷ π ∷ ὸ ∷ []) "1Thess.2.14"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.2.14"
∷ word (Ἰ ∷ ο ∷ υ ∷ δ ∷ α ∷ ί ∷ ω ∷ ν ∷ []) "1Thess.2.14"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.2.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.15"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.2.15"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "1Thess.2.15"
∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ τ ∷ ε ∷ ι ∷ ν ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "1Thess.2.15"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ν ∷ []) "1Thess.2.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.15"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.2.15"
∷ word (π ∷ ρ ∷ ο ∷ φ ∷ ή ∷ τ ∷ α ∷ ς ∷ []) "1Thess.2.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.15"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.2.15"
∷ word (ἐ ∷ κ ∷ δ ∷ ι ∷ ω ∷ ξ ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "1Thess.2.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.15"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "1Thess.2.15"
∷ word (μ ∷ ὴ ∷ []) "1Thess.2.15"
∷ word (ἀ ∷ ρ ∷ ε ∷ σ ∷ κ ∷ ό ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "1Thess.2.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.15"
∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.2.15"
∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ο ∷ ι ∷ ς ∷ []) "1Thess.2.15"
∷ word (ἐ ∷ ν ∷ α ∷ ν ∷ τ ∷ ί ∷ ω ∷ ν ∷ []) "1Thess.2.15"
∷ word (κ ∷ ω ∷ ∙λ ∷ υ ∷ ό ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "1Thess.2.16"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.2.16"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "1Thess.2.16"
∷ word (ἔ ∷ θ ∷ ν ∷ ε ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.2.16"
∷ word (∙λ ∷ α ∷ ∙λ ∷ ῆ ∷ σ ∷ α ∷ ι ∷ []) "1Thess.2.16"
∷ word (ἵ ∷ ν ∷ α ∷ []) "1Thess.2.16"
∷ word (σ ∷ ω ∷ θ ∷ ῶ ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.2.16"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.2.16"
∷ word (τ ∷ ὸ ∷ []) "1Thess.2.16"
∷ word (ἀ ∷ ν ∷ α ∷ π ∷ ∙λ ∷ η ∷ ρ ∷ ῶ ∷ σ ∷ α ∷ ι ∷ []) "1Thess.2.16"
∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "1Thess.2.16"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "1Thess.2.16"
∷ word (ἁ ∷ μ ∷ α ∷ ρ ∷ τ ∷ ί ∷ α ∷ ς ∷ []) "1Thess.2.16"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "1Thess.2.16"
∷ word (ἔ ∷ φ ∷ θ ∷ α ∷ σ ∷ ε ∷ ν ∷ []) "1Thess.2.16"
∷ word (δ ∷ ὲ ∷ []) "1Thess.2.16"
∷ word (ἐ ∷ π ∷ []) "1Thess.2.16"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.2.16"
∷ word (ἡ ∷ []) "1Thess.2.16"
∷ word (ὀ ∷ ρ ∷ γ ∷ ὴ ∷ []) "1Thess.2.16"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.2.16"
∷ word (τ ∷ έ ∷ ∙λ ∷ ο ∷ ς ∷ []) "1Thess.2.16"
∷ word (Ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.2.17"
∷ word (δ ∷ έ ∷ []) "1Thess.2.17"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.2.17"
∷ word (ἀ ∷ π ∷ ο ∷ ρ ∷ φ ∷ α ∷ ν ∷ ι ∷ σ ∷ θ ∷ έ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.2.17"
∷ word (ἀ ∷ φ ∷ []) "1Thess.2.17"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.17"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.2.17"
∷ word (κ ∷ α ∷ ι ∷ ρ ∷ ὸ ∷ ν ∷ []) "1Thess.2.17"
∷ word (ὥ ∷ ρ ∷ α ∷ ς ∷ []) "1Thess.2.17"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ώ ∷ π ∷ ῳ ∷ []) "1Thess.2.17"
∷ word (ο ∷ ὐ ∷ []) "1Thess.2.17"
∷ word (κ ∷ α ∷ ρ ∷ δ ∷ ί ∷ ᾳ ∷ []) "1Thess.2.17"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ο ∷ τ ∷ έ ∷ ρ ∷ ω ∷ ς ∷ []) "1Thess.2.17"
∷ word (ἐ ∷ σ ∷ π ∷ ο ∷ υ ∷ δ ∷ ά ∷ σ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.2.17"
∷ word (τ ∷ ὸ ∷ []) "1Thess.2.17"
∷ word (π ∷ ρ ∷ ό ∷ σ ∷ ω ∷ π ∷ ο ∷ ν ∷ []) "1Thess.2.17"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.17"
∷ word (ἰ ∷ δ ∷ ε ∷ ῖ ∷ ν ∷ []) "1Thess.2.17"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.17"
∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ῇ ∷ []) "1Thess.2.17"
∷ word (ἐ ∷ π ∷ ι ∷ θ ∷ υ ∷ μ ∷ ί ∷ ᾳ ∷ []) "1Thess.2.17"
∷ word (δ ∷ ι ∷ ό ∷ τ ∷ ι ∷ []) "1Thess.2.18"
∷ word (ἠ ∷ θ ∷ ε ∷ ∙λ ∷ ή ∷ σ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.2.18"
∷ word (ἐ ∷ ∙λ ∷ θ ∷ ε ∷ ῖ ∷ ν ∷ []) "1Thess.2.18"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.2.18"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.2.18"
∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "1Thess.2.18"
∷ word (μ ∷ ὲ ∷ ν ∷ []) "1Thess.2.18"
∷ word (Π ∷ α ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "1Thess.2.18"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.18"
∷ word (ἅ ∷ π ∷ α ∷ ξ ∷ []) "1Thess.2.18"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.18"
∷ word (δ ∷ ί ∷ ς ∷ []) "1Thess.2.18"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.18"
∷ word (ἐ ∷ ν ∷ έ ∷ κ ∷ ο ∷ ψ ∷ ε ∷ ν ∷ []) "1Thess.2.18"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.2.18"
∷ word (ὁ ∷ []) "1Thess.2.18"
∷ word (Σ ∷ α ∷ τ ∷ α ∷ ν ∷ ᾶ ∷ ς ∷ []) "1Thess.2.18"
∷ word (τ ∷ ί ∷ ς ∷ []) "1Thess.2.19"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.2.19"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.19"
∷ word (ἐ ∷ ∙λ ∷ π ∷ ὶ ∷ ς ∷ []) "1Thess.2.19"
∷ word (ἢ ∷ []) "1Thess.2.19"
∷ word (χ ∷ α ∷ ρ ∷ ὰ ∷ []) "1Thess.2.19"
∷ word (ἢ ∷ []) "1Thess.2.19"
∷ word (σ ∷ τ ∷ έ ∷ φ ∷ α ∷ ν ∷ ο ∷ ς ∷ []) "1Thess.2.19"
∷ word (κ ∷ α ∷ υ ∷ χ ∷ ή ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "1Thess.2.19"
∷ word (ἢ ∷ []) "1Thess.2.19"
∷ word (ο ∷ ὐ ∷ χ ∷ ὶ ∷ []) "1Thess.2.19"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.19"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.2.19"
∷ word (ἔ ∷ μ ∷ π ∷ ρ ∷ ο ∷ σ ∷ θ ∷ ε ∷ ν ∷ []) "1Thess.2.19"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.19"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.2.19"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.19"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.2.19"
∷ word (ἐ ∷ ν ∷ []) "1Thess.2.19"
∷ word (τ ∷ ῇ ∷ []) "1Thess.2.19"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.2.19"
∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ ᾳ ∷ []) "1Thess.2.19"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.2.20"
∷ word (γ ∷ ά ∷ ρ ∷ []) "1Thess.2.20"
∷ word (ἐ ∷ σ ∷ τ ∷ ε ∷ []) "1Thess.2.20"
∷ word (ἡ ∷ []) "1Thess.2.20"
∷ word (δ ∷ ό ∷ ξ ∷ α ∷ []) "1Thess.2.20"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.2.20"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.2.20"
∷ word (ἡ ∷ []) "1Thess.2.20"
∷ word (χ ∷ α ∷ ρ ∷ ά ∷ []) "1Thess.2.20"
∷ word (Δ ∷ ι ∷ ὸ ∷ []) "1Thess.3.1"
∷ word (μ ∷ η ∷ κ ∷ έ ∷ τ ∷ ι ∷ []) "1Thess.3.1"
∷ word (σ ∷ τ ∷ έ ∷ γ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.3.1"
∷ word (ε ∷ ὐ ∷ δ ∷ ο ∷ κ ∷ ή ∷ σ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.3.1"
∷ word (κ ∷ α ∷ τ ∷ α ∷ ∙λ ∷ ε ∷ ι ∷ φ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "1Thess.3.1"
∷ word (ἐ ∷ ν ∷ []) "1Thess.3.1"
∷ word (Ἀ ∷ θ ∷ ή ∷ ν ∷ α ∷ ι ∷ ς ∷ []) "1Thess.3.1"
∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.3.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.2"
∷ word (ἐ ∷ π ∷ έ ∷ μ ∷ ψ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.3.2"
∷ word (Τ ∷ ι ∷ μ ∷ ό ∷ θ ∷ ε ∷ ο ∷ ν ∷ []) "1Thess.3.2"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.3.2"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ὸ ∷ ν ∷ []) "1Thess.3.2"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.2"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.2"
∷ word (σ ∷ υ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ὸ ∷ ν ∷ []) "1Thess.3.2"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.3.2"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.3.2"
∷ word (ἐ ∷ ν ∷ []) "1Thess.3.2"
∷ word (τ ∷ ῷ ∷ []) "1Thess.3.2"
∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ῳ ∷ []) "1Thess.3.2"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.3.2"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.3.2"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.3.2"
∷ word (τ ∷ ὸ ∷ []) "1Thess.3.2"
∷ word (σ ∷ τ ∷ η ∷ ρ ∷ ί ∷ ξ ∷ α ∷ ι ∷ []) "1Thess.3.2"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.3.2"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.2"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ έ ∷ σ ∷ α ∷ ι ∷ []) "1Thess.3.2"
∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "1Thess.3.2"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.3.2"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "1Thess.3.2"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.2"
∷ word (τ ∷ ὸ ∷ []) "1Thess.3.3"
∷ word (μ ∷ η ∷ δ ∷ έ ∷ ν ∷ α ∷ []) "1Thess.3.3"
∷ word (σ ∷ α ∷ ί ∷ ν ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "1Thess.3.3"
∷ word (ἐ ∷ ν ∷ []) "1Thess.3.3"
∷ word (τ ∷ α ∷ ῖ ∷ ς ∷ []) "1Thess.3.3"
∷ word (θ ∷ ∙λ ∷ ί ∷ ψ ∷ ε ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.3.3"
∷ word (τ ∷ α ∷ ύ ∷ τ ∷ α ∷ ι ∷ ς ∷ []) "1Thess.3.3"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὶ ∷ []) "1Thess.3.3"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.3.3"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "1Thess.3.3"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.3.3"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.3.3"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "1Thess.3.3"
∷ word (κ ∷ ε ∷ ί ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "1Thess.3.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.4"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.3.4"
∷ word (ὅ ∷ τ ∷ ε ∷ []) "1Thess.3.4"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.3.4"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.3.4"
∷ word (ἦ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.3.4"
∷ word (π ∷ ρ ∷ ο ∷ ε ∷ ∙λ ∷ έ ∷ γ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.3.4"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.3.4"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.3.4"
∷ word (μ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.3.4"
∷ word (θ ∷ ∙λ ∷ ί ∷ β ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "1Thess.3.4"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.3.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.4"
∷ word (ἐ ∷ γ ∷ έ ∷ ν ∷ ε ∷ τ ∷ ο ∷ []) "1Thess.3.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.4"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "1Thess.3.4"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "1Thess.3.5"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "1Thess.3.5"
∷ word (κ ∷ ἀ ∷ γ ∷ ὼ ∷ []) "1Thess.3.5"
∷ word (μ ∷ η ∷ κ ∷ έ ∷ τ ∷ ι ∷ []) "1Thess.3.5"
∷ word (σ ∷ τ ∷ έ ∷ γ ∷ ω ∷ ν ∷ []) "1Thess.3.5"
∷ word (ἔ ∷ π ∷ ε ∷ μ ∷ ψ ∷ α ∷ []) "1Thess.3.5"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.3.5"
∷ word (τ ∷ ὸ ∷ []) "1Thess.3.5"
∷ word (γ ∷ ν ∷ ῶ ∷ ν ∷ α ∷ ι ∷ []) "1Thess.3.5"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "1Thess.3.5"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "1Thess.3.5"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.5"
∷ word (μ ∷ ή ∷ []) "1Thess.3.5"
∷ word (π ∷ ω ∷ ς ∷ []) "1Thess.3.5"
∷ word (ἐ ∷ π ∷ ε ∷ ί ∷ ρ ∷ α ∷ σ ∷ ε ∷ ν ∷ []) "1Thess.3.5"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.3.5"
∷ word (ὁ ∷ []) "1Thess.3.5"
∷ word (π ∷ ε ∷ ι ∷ ρ ∷ ά ∷ ζ ∷ ω ∷ ν ∷ []) "1Thess.3.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.5"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.3.5"
∷ word (κ ∷ ε ∷ ν ∷ ὸ ∷ ν ∷ []) "1Thess.3.5"
∷ word (γ ∷ έ ∷ ν ∷ η ∷ τ ∷ α ∷ ι ∷ []) "1Thess.3.5"
∷ word (ὁ ∷ []) "1Thess.3.5"
∷ word (κ ∷ ό ∷ π ∷ ο ∷ ς ∷ []) "1Thess.3.5"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.5"
∷ word (Ἄ ∷ ρ ∷ τ ∷ ι ∷ []) "1Thess.3.6"
∷ word (δ ∷ ὲ ∷ []) "1Thess.3.6"
∷ word (ἐ ∷ ∙λ ∷ θ ∷ ό ∷ ν ∷ τ ∷ ο ∷ ς ∷ []) "1Thess.3.6"
∷ word (Τ ∷ ι ∷ μ ∷ ο ∷ θ ∷ έ ∷ ο ∷ υ ∷ []) "1Thess.3.6"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.3.6"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.3.6"
∷ word (ἀ ∷ φ ∷ []) "1Thess.3.6"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.6"
∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ι ∷ σ ∷ α ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ []) "1Thess.3.6"
∷ word (ἡ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.3.6"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "1Thess.3.6"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "1Thess.3.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.6"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "1Thess.3.6"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ν ∷ []) "1Thess.3.6"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.6"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.3.6"
∷ word (ἔ ∷ χ ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.3.6"
∷ word (μ ∷ ν ∷ ε ∷ ί ∷ α ∷ ν ∷ []) "1Thess.3.6"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.6"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ὴ ∷ ν ∷ []) "1Thess.3.6"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "1Thess.3.6"
∷ word (ἐ ∷ π ∷ ι ∷ π ∷ ο ∷ θ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.3.6"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.3.6"
∷ word (ἰ ∷ δ ∷ ε ∷ ῖ ∷ ν ∷ []) "1Thess.3.6"
∷ word (κ ∷ α ∷ θ ∷ ά ∷ π ∷ ε ∷ ρ ∷ []) "1Thess.3.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.6"
∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.3.6"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.3.6"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "1Thess.3.7"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "1Thess.3.7"
∷ word (π ∷ α ∷ ρ ∷ ε ∷ κ ∷ ∙λ ∷ ή ∷ θ ∷ η ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.3.7"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.3.7"
∷ word (ἐ ∷ φ ∷ []) "1Thess.3.7"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.3.7"
∷ word (ἐ ∷ π ∷ ὶ ∷ []) "1Thess.3.7"
∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "1Thess.3.7"
∷ word (τ ∷ ῇ ∷ []) "1Thess.3.7"
∷ word (ἀ ∷ ν ∷ ά ∷ γ ∷ κ ∷ ῃ ∷ []) "1Thess.3.7"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.7"
∷ word (θ ∷ ∙λ ∷ ί ∷ ψ ∷ ε ∷ ι ∷ []) "1Thess.3.7"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.7"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "1Thess.3.7"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.3.7"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.7"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "1Thess.3.7"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.3.8"
∷ word (ν ∷ ῦ ∷ ν ∷ []) "1Thess.3.8"
∷ word (ζ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.3.8"
∷ word (ἐ ∷ ὰ ∷ ν ∷ []) "1Thess.3.8"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.3.8"
∷ word (σ ∷ τ ∷ ή ∷ κ ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.3.8"
∷ word (ἐ ∷ ν ∷ []) "1Thess.3.8"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "1Thess.3.8"
∷ word (τ ∷ ί ∷ ν ∷ α ∷ []) "1Thess.3.9"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.3.9"
∷ word (ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ί ∷ α ∷ ν ∷ []) "1Thess.3.9"
∷ word (δ ∷ υ ∷ ν ∷ ά ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "1Thess.3.9"
∷ word (τ ∷ ῷ ∷ []) "1Thess.3.9"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "1Thess.3.9"
∷ word (ἀ ∷ ν ∷ τ ∷ α ∷ π ∷ ο ∷ δ ∷ ο ∷ ῦ ∷ ν ∷ α ∷ ι ∷ []) "1Thess.3.9"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "1Thess.3.9"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.9"
∷ word (ἐ ∷ π ∷ ὶ ∷ []) "1Thess.3.9"
∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "1Thess.3.9"
∷ word (τ ∷ ῇ ∷ []) "1Thess.3.9"
∷ word (χ ∷ α ∷ ρ ∷ ᾷ ∷ []) "1Thess.3.9"
∷ word (ᾗ ∷ []) "1Thess.3.9"
∷ word (χ ∷ α ∷ ί ∷ ρ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.3.9"
∷ word (δ ∷ ι ∷ []) "1Thess.3.9"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.3.9"
∷ word (ἔ ∷ μ ∷ π ∷ ρ ∷ ο ∷ σ ∷ θ ∷ ε ∷ ν ∷ []) "1Thess.3.9"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.3.9"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.3.9"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.9"
∷ word (ν ∷ υ ∷ κ ∷ τ ∷ ὸ ∷ ς ∷ []) "1Thess.3.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.10"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "1Thess.3.10"
∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ ε ∷ κ ∷ π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.3.10"
∷ word (δ ∷ ε ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.3.10"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.3.10"
∷ word (τ ∷ ὸ ∷ []) "1Thess.3.10"
∷ word (ἰ ∷ δ ∷ ε ∷ ῖ ∷ ν ∷ []) "1Thess.3.10"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.10"
∷ word (τ ∷ ὸ ∷ []) "1Thess.3.10"
∷ word (π ∷ ρ ∷ ό ∷ σ ∷ ω ∷ π ∷ ο ∷ ν ∷ []) "1Thess.3.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.10"
∷ word (κ ∷ α ∷ τ ∷ α ∷ ρ ∷ τ ∷ ί ∷ σ ∷ α ∷ ι ∷ []) "1Thess.3.10"
∷ word (τ ∷ ὰ ∷ []) "1Thess.3.10"
∷ word (ὑ ∷ σ ∷ τ ∷ ε ∷ ρ ∷ ή ∷ μ ∷ α ∷ τ ∷ α ∷ []) "1Thess.3.10"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.3.10"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "1Thess.3.10"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.10"
∷ word (Α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "1Thess.3.11"
∷ word (δ ∷ ὲ ∷ []) "1Thess.3.11"
∷ word (ὁ ∷ []) "1Thess.3.11"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "1Thess.3.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.11"
∷ word (π ∷ α ∷ τ ∷ ὴ ∷ ρ ∷ []) "1Thess.3.11"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.11"
∷ word (ὁ ∷ []) "1Thess.3.11"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "1Thess.3.11"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.11"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ς ∷ []) "1Thess.3.11"
∷ word (κ ∷ α ∷ τ ∷ ε ∷ υ ∷ θ ∷ ύ ∷ ν ∷ α ∷ ι ∷ []) "1Thess.3.11"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "1Thess.3.11"
∷ word (ὁ ∷ δ ∷ ὸ ∷ ν ∷ []) "1Thess.3.11"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.11"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.3.11"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.3.11"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.3.12"
∷ word (δ ∷ ὲ ∷ []) "1Thess.3.12"
∷ word (ὁ ∷ []) "1Thess.3.12"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "1Thess.3.12"
∷ word (π ∷ ∙λ ∷ ε ∷ ο ∷ ν ∷ ά ∷ σ ∷ α ∷ ι ∷ []) "1Thess.3.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.12"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ε ∷ ύ ∷ σ ∷ α ∷ ι ∷ []) "1Thess.3.12"
∷ word (τ ∷ ῇ ∷ []) "1Thess.3.12"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ ῃ ∷ []) "1Thess.3.12"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.3.12"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ή ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "1Thess.3.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.12"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.3.12"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "1Thess.3.12"
∷ word (κ ∷ α ∷ θ ∷ ά ∷ π ∷ ε ∷ ρ ∷ []) "1Thess.3.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.12"
∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.3.12"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.3.12"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.3.12"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.3.13"
∷ word (τ ∷ ὸ ∷ []) "1Thess.3.13"
∷ word (σ ∷ τ ∷ η ∷ ρ ∷ ί ∷ ξ ∷ α ∷ ι ∷ []) "1Thess.3.13"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.13"
∷ word (τ ∷ ὰ ∷ ς ∷ []) "1Thess.3.13"
∷ word (κ ∷ α ∷ ρ ∷ δ ∷ ί ∷ α ∷ ς ∷ []) "1Thess.3.13"
∷ word (ἀ ∷ μ ∷ έ ∷ μ ∷ π ∷ τ ∷ ο ∷ υ ∷ ς ∷ []) "1Thess.3.13"
∷ word (ἐ ∷ ν ∷ []) "1Thess.3.13"
∷ word (ἁ ∷ γ ∷ ι ∷ ω ∷ σ ∷ ύ ∷ ν ∷ ῃ ∷ []) "1Thess.3.13"
∷ word (ἔ ∷ μ ∷ π ∷ ρ ∷ ο ∷ σ ∷ θ ∷ ε ∷ ν ∷ []) "1Thess.3.13"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.3.13"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.3.13"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.3.13"
∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.3.13"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.13"
∷ word (ἐ ∷ ν ∷ []) "1Thess.3.13"
∷ word (τ ∷ ῇ ∷ []) "1Thess.3.13"
∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ ᾳ ∷ []) "1Thess.3.13"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.3.13"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.3.13"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.3.13"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.3.13"
∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "1Thess.3.13"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "1Thess.3.13"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.3.13"
∷ word (ἁ ∷ γ ∷ ί ∷ ω ∷ ν ∷ []) "1Thess.3.13"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.3.13"
∷ word (Λ ∷ ο ∷ ι ∷ π ∷ ὸ ∷ ν ∷ []) "1Thess.4.1"
∷ word (ο ∷ ὖ ∷ ν ∷ []) "1Thess.4.1"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.4.1"
∷ word (ἐ ∷ ρ ∷ ω ∷ τ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.4.1"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.4.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.1"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.4.1"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.1"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "1Thess.4.1"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.4.1"
∷ word (ἵ ∷ ν ∷ α ∷ []) "1Thess.4.1"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.4.1"
∷ word (π ∷ α ∷ ρ ∷ ε ∷ ∙λ ∷ ά ∷ β ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.4.1"
∷ word (π ∷ α ∷ ρ ∷ []) "1Thess.4.1"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.4.1"
∷ word (τ ∷ ὸ ∷ []) "1Thess.4.1"
∷ word (π ∷ ῶ ∷ ς ∷ []) "1Thess.4.1"
∷ word (δ ∷ ε ∷ ῖ ∷ []) "1Thess.4.1"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.4.1"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ε ∷ ῖ ∷ ν ∷ []) "1Thess.4.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.1"
∷ word (ἀ ∷ ρ ∷ έ ∷ σ ∷ κ ∷ ε ∷ ι ∷ ν ∷ []) "1Thess.4.1"
∷ word (θ ∷ ε ∷ ῷ ∷ []) "1Thess.4.1"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.4.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.1"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "1Thess.4.1"
∷ word (ἵ ∷ ν ∷ α ∷ []) "1Thess.4.1"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ε ∷ ύ ∷ η ∷ τ ∷ ε ∷ []) "1Thess.4.1"
∷ word (μ ∷ ᾶ ∷ ∙λ ∷ ∙λ ∷ ο ∷ ν ∷ []) "1Thess.4.1"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "1Thess.4.2"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.4.2"
∷ word (τ ∷ ί ∷ ν ∷ α ∷ ς ∷ []) "1Thess.4.2"
∷ word (π ∷ α ∷ ρ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ α ∷ ς ∷ []) "1Thess.4.2"
∷ word (ἐ ∷ δ ∷ ώ ∷ κ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.4.2"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.4.2"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "1Thess.4.2"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.4.2"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.4.2"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.4.2"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "1Thess.4.3"
∷ word (γ ∷ ά ∷ ρ ∷ []) "1Thess.4.3"
∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "1Thess.4.3"
∷ word (θ ∷ έ ∷ ∙λ ∷ η ∷ μ ∷ α ∷ []) "1Thess.4.3"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.4.3"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.4.3"
∷ word (ὁ ∷ []) "1Thess.4.3"
∷ word (ἁ ∷ γ ∷ ι ∷ α ∷ σ ∷ μ ∷ ὸ ∷ ς ∷ []) "1Thess.4.3"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.4.3"
∷ word (ἀ ∷ π ∷ έ ∷ χ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "1Thess.4.3"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.4.3"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "1Thess.4.3"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.4.3"
∷ word (π ∷ ο ∷ ρ ∷ ν ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "1Thess.4.3"
∷ word (ε ∷ ἰ ∷ δ ∷ έ ∷ ν ∷ α ∷ ι ∷ []) "1Thess.4.4"
∷ word (ἕ ∷ κ ∷ α ∷ σ ∷ τ ∷ ο ∷ ν ∷ []) "1Thess.4.4"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.4.4"
∷ word (τ ∷ ὸ ∷ []) "1Thess.4.4"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.4.4"
∷ word (σ ∷ κ ∷ ε ∷ ῦ ∷ ο ∷ ς ∷ []) "1Thess.4.4"
∷ word (κ ∷ τ ∷ ᾶ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "1Thess.4.4"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.4"
∷ word (ἁ ∷ γ ∷ ι ∷ α ∷ σ ∷ μ ∷ ῷ ∷ []) "1Thess.4.4"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.4"
∷ word (τ ∷ ι ∷ μ ∷ ῇ ∷ []) "1Thess.4.4"
∷ word (μ ∷ ὴ ∷ []) "1Thess.4.5"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.5"
∷ word (π ∷ ά ∷ θ ∷ ε ∷ ι ∷ []) "1Thess.4.5"
∷ word (ἐ ∷ π ∷ ι ∷ θ ∷ υ ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "1Thess.4.5"
∷ word (κ ∷ α ∷ θ ∷ ά ∷ π ∷ ε ∷ ρ ∷ []) "1Thess.4.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.5"
∷ word (τ ∷ ὰ ∷ []) "1Thess.4.5"
∷ word (ἔ ∷ θ ∷ ν ∷ η ∷ []) "1Thess.4.5"
∷ word (τ ∷ ὰ ∷ []) "1Thess.4.5"
∷ word (μ ∷ ὴ ∷ []) "1Thess.4.5"
∷ word (ε ∷ ἰ ∷ δ ∷ ό ∷ τ ∷ α ∷ []) "1Thess.4.5"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.4.5"
∷ word (θ ∷ ε ∷ ό ∷ ν ∷ []) "1Thess.4.5"
∷ word (τ ∷ ὸ ∷ []) "1Thess.4.6"
∷ word (μ ∷ ὴ ∷ []) "1Thess.4.6"
∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ β ∷ α ∷ ί ∷ ν ∷ ε ∷ ι ∷ ν ∷ []) "1Thess.4.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.6"
∷ word (π ∷ ∙λ ∷ ε ∷ ο ∷ ν ∷ ε ∷ κ ∷ τ ∷ ε ∷ ῖ ∷ ν ∷ []) "1Thess.4.6"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.6"
∷ word (τ ∷ ῷ ∷ []) "1Thess.4.6"
∷ word (π ∷ ρ ∷ ά ∷ γ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "1Thess.4.6"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.4.6"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ὸ ∷ ν ∷ []) "1Thess.4.6"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.4.6"
∷ word (δ ∷ ι ∷ ό ∷ τ ∷ ι ∷ []) "1Thess.4.6"
∷ word (ἔ ∷ κ ∷ δ ∷ ι ∷ κ ∷ ο ∷ ς ∷ []) "1Thess.4.6"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "1Thess.4.6"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "1Thess.4.6"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "1Thess.4.6"
∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ω ∷ ν ∷ []) "1Thess.4.6"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.4.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.6"
∷ word (π ∷ ρ ∷ ο ∷ ε ∷ ί ∷ π ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.4.6"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.4.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.6"
∷ word (δ ∷ ι ∷ ε ∷ μ ∷ α ∷ ρ ∷ τ ∷ υ ∷ ρ ∷ ά ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "1Thess.4.6"
∷ word (ο ∷ ὐ ∷ []) "1Thess.4.7"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.4.7"
∷ word (ἐ ∷ κ ∷ ά ∷ ∙λ ∷ ε ∷ σ ∷ ε ∷ ν ∷ []) "1Thess.4.7"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.4.7"
∷ word (ὁ ∷ []) "1Thess.4.7"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "1Thess.4.7"
∷ word (ἐ ∷ π ∷ ὶ ∷ []) "1Thess.4.7"
∷ word (ἀ ∷ κ ∷ α ∷ θ ∷ α ∷ ρ ∷ σ ∷ ί ∷ ᾳ ∷ []) "1Thess.4.7"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "1Thess.4.7"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.7"
∷ word (ἁ ∷ γ ∷ ι ∷ α ∷ σ ∷ μ ∷ ῷ ∷ []) "1Thess.4.7"
∷ word (τ ∷ ο ∷ ι ∷ γ ∷ α ∷ ρ ∷ ο ∷ ῦ ∷ ν ∷ []) "1Thess.4.8"
∷ word (ὁ ∷ []) "1Thess.4.8"
∷ word (ἀ ∷ θ ∷ ε ∷ τ ∷ ῶ ∷ ν ∷ []) "1Thess.4.8"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "1Thess.4.8"
∷ word (ἄ ∷ ν ∷ θ ∷ ρ ∷ ω ∷ π ∷ ο ∷ ν ∷ []) "1Thess.4.8"
∷ word (ἀ ∷ θ ∷ ε ∷ τ ∷ ε ∷ ῖ ∷ []) "1Thess.4.8"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "1Thess.4.8"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.4.8"
∷ word (θ ∷ ε ∷ ὸ ∷ ν ∷ []) "1Thess.4.8"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.4.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.8"
∷ word (δ ∷ ι ∷ δ ∷ ό ∷ ν ∷ τ ∷ α ∷ []) "1Thess.4.8"
∷ word (τ ∷ ὸ ∷ []) "1Thess.4.8"
∷ word (π ∷ ν ∷ ε ∷ ῦ ∷ μ ∷ α ∷ []) "1Thess.4.8"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.4.8"
∷ word (τ ∷ ὸ ∷ []) "1Thess.4.8"
∷ word (ἅ ∷ γ ∷ ι ∷ ο ∷ ν ∷ []) "1Thess.4.8"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.4.8"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.4.8"
∷ word (Π ∷ ε ∷ ρ ∷ ὶ ∷ []) "1Thess.4.9"
∷ word (δ ∷ ὲ ∷ []) "1Thess.4.9"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.4.9"
∷ word (φ ∷ ι ∷ ∙λ ∷ α ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ί ∷ α ∷ ς ∷ []) "1Thess.4.9"
∷ word (ο ∷ ὐ ∷ []) "1Thess.4.9"
∷ word (χ ∷ ρ ∷ ε ∷ ί ∷ α ∷ ν ∷ []) "1Thess.4.9"
∷ word (ἔ ∷ χ ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.4.9"
∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ε ∷ ι ∷ ν ∷ []) "1Thess.4.9"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.4.9"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὶ ∷ []) "1Thess.4.9"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.4.9"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.4.9"
∷ word (θ ∷ ε ∷ ο ∷ δ ∷ ί ∷ δ ∷ α ∷ κ ∷ τ ∷ ο ∷ ί ∷ []) "1Thess.4.9"
∷ word (ἐ ∷ σ ∷ τ ∷ ε ∷ []) "1Thess.4.9"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.4.9"
∷ word (τ ∷ ὸ ∷ []) "1Thess.4.9"
∷ word (ἀ ∷ γ ∷ α ∷ π ∷ ᾶ ∷ ν ∷ []) "1Thess.4.9"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ή ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "1Thess.4.9"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.10"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.4.10"
∷ word (π ∷ ο ∷ ι ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "1Thess.4.10"
∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ []) "1Thess.4.10"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.4.10"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "1Thess.4.10"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.4.10"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.4.10"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.4.10"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.10"
∷ word (ὅ ∷ ∙λ ∷ ῃ ∷ []) "1Thess.4.10"
∷ word (τ ∷ ῇ ∷ []) "1Thess.4.10"
∷ word (Μ ∷ α ∷ κ ∷ ε ∷ δ ∷ ο ∷ ν ∷ ί ∷ ᾳ ∷ []) "1Thess.4.10"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.4.10"
∷ word (δ ∷ ὲ ∷ []) "1Thess.4.10"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.4.10"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.4.10"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ε ∷ ύ ∷ ε ∷ ι ∷ ν ∷ []) "1Thess.4.10"
∷ word (μ ∷ ᾶ ∷ ∙λ ∷ ∙λ ∷ ο ∷ ν ∷ []) "1Thess.4.10"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.11"
∷ word (φ ∷ ι ∷ ∙λ ∷ ο ∷ τ ∷ ι ∷ μ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "1Thess.4.11"
∷ word (ἡ ∷ σ ∷ υ ∷ χ ∷ ά ∷ ζ ∷ ε ∷ ι ∷ ν ∷ []) "1Thess.4.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.11"
∷ word (π ∷ ρ ∷ ά ∷ σ ∷ σ ∷ ε ∷ ι ∷ ν ∷ []) "1Thess.4.11"
∷ word (τ ∷ ὰ ∷ []) "1Thess.4.11"
∷ word (ἴ ∷ δ ∷ ι ∷ α ∷ []) "1Thess.4.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.11"
∷ word (ἐ ∷ ρ ∷ γ ∷ ά ∷ ζ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "1Thess.4.11"
∷ word (τ ∷ α ∷ ῖ ∷ ς ∷ []) "1Thess.4.11"
∷ word (χ ∷ ε ∷ ρ ∷ σ ∷ ὶ ∷ ν ∷ []) "1Thess.4.11"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.4.11"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.4.11"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.4.11"
∷ word (π ∷ α ∷ ρ ∷ η ∷ γ ∷ γ ∷ ε ∷ ί ∷ ∙λ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.4.11"
∷ word (ἵ ∷ ν ∷ α ∷ []) "1Thess.4.12"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ῆ ∷ τ ∷ ε ∷ []) "1Thess.4.12"
∷ word (ε ∷ ὐ ∷ σ ∷ χ ∷ η ∷ μ ∷ ό ∷ ν ∷ ω ∷ ς ∷ []) "1Thess.4.12"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.4.12"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.4.12"
∷ word (ἔ ∷ ξ ∷ ω ∷ []) "1Thess.4.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.12"
∷ word (μ ∷ η ∷ δ ∷ ε ∷ ν ∷ ὸ ∷ ς ∷ []) "1Thess.4.12"
∷ word (χ ∷ ρ ∷ ε ∷ ί ∷ α ∷ ν ∷ []) "1Thess.4.12"
∷ word (ἔ ∷ χ ∷ η ∷ τ ∷ ε ∷ []) "1Thess.4.12"
∷ word (Ο ∷ ὐ ∷ []) "1Thess.4.13"
∷ word (θ ∷ έ ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.4.13"
∷ word (δ ∷ ὲ ∷ []) "1Thess.4.13"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.4.13"
∷ word (ἀ ∷ γ ∷ ν ∷ ο ∷ ε ∷ ῖ ∷ ν ∷ []) "1Thess.4.13"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.4.13"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "1Thess.4.13"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.4.13"
∷ word (κ ∷ ο ∷ ι ∷ μ ∷ ω ∷ μ ∷ έ ∷ ν ∷ ω ∷ ν ∷ []) "1Thess.4.13"
∷ word (ἵ ∷ ν ∷ α ∷ []) "1Thess.4.13"
∷ word (μ ∷ ὴ ∷ []) "1Thess.4.13"
∷ word (∙λ ∷ υ ∷ π ∷ ῆ ∷ σ ∷ θ ∷ ε ∷ []) "1Thess.4.13"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.4.13"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.13"
∷ word (ο ∷ ἱ ∷ []) "1Thess.4.13"
∷ word (∙λ ∷ ο ∷ ι ∷ π ∷ ο ∷ ὶ ∷ []) "1Thess.4.13"
∷ word (ο ∷ ἱ ∷ []) "1Thess.4.13"
∷ word (μ ∷ ὴ ∷ []) "1Thess.4.13"
∷ word (ἔ ∷ χ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.4.13"
∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ δ ∷ α ∷ []) "1Thess.4.13"
∷ word (ε ∷ ἰ ∷ []) "1Thess.4.14"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.4.14"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.4.14"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.4.14"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ς ∷ []) "1Thess.4.14"
∷ word (ἀ ∷ π ∷ έ ∷ θ ∷ α ∷ ν ∷ ε ∷ ν ∷ []) "1Thess.4.14"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.14"
∷ word (ἀ ∷ ν ∷ έ ∷ σ ∷ τ ∷ η ∷ []) "1Thess.4.14"
∷ word (ο ∷ ὕ ∷ τ ∷ ω ∷ ς ∷ []) "1Thess.4.14"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.14"
∷ word (ὁ ∷ []) "1Thess.4.14"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "1Thess.4.14"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.4.14"
∷ word (κ ∷ ο ∷ ι ∷ μ ∷ η ∷ θ ∷ έ ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "1Thess.4.14"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "1Thess.4.14"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.4.14"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.4.14"
∷ word (ἄ ∷ ξ ∷ ε ∷ ι ∷ []) "1Thess.4.14"
∷ word (σ ∷ ὺ ∷ ν ∷ []) "1Thess.4.14"
∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "1Thess.4.14"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "1Thess.4.15"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.4.15"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.4.15"
∷ word (∙λ ∷ έ ∷ γ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.4.15"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.15"
∷ word (∙λ ∷ ό ∷ γ ∷ ῳ ∷ []) "1Thess.4.15"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.4.15"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.4.15"
∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.4.15"
∷ word (ο ∷ ἱ ∷ []) "1Thess.4.15"
∷ word (ζ ∷ ῶ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.4.15"
∷ word (ο ∷ ἱ ∷ []) "1Thess.4.15"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ ∙λ ∷ ε ∷ ι ∷ π ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.4.15"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.4.15"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "1Thess.4.15"
∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ν ∷ []) "1Thess.4.15"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.4.15"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.4.15"
∷ word (ο ∷ ὐ ∷ []) "1Thess.4.15"
∷ word (μ ∷ ὴ ∷ []) "1Thess.4.15"
∷ word (φ ∷ θ ∷ ά ∷ σ ∷ ω ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.4.15"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.4.15"
∷ word (κ ∷ ο ∷ ι ∷ μ ∷ η ∷ θ ∷ έ ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "1Thess.4.15"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.4.16"
∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "1Thess.4.16"
∷ word (ὁ ∷ []) "1Thess.4.16"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "1Thess.4.16"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.16"
∷ word (κ ∷ ε ∷ ∙λ ∷ ε ∷ ύ ∷ σ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "1Thess.4.16"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.16"
∷ word (φ ∷ ω ∷ ν ∷ ῇ ∷ []) "1Thess.4.16"
∷ word (ἀ ∷ ρ ∷ χ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ο ∷ υ ∷ []) "1Thess.4.16"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.16"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.16"
∷ word (σ ∷ ά ∷ ∙λ ∷ π ∷ ι ∷ γ ∷ γ ∷ ι ∷ []) "1Thess.4.16"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.4.16"
∷ word (κ ∷ α ∷ τ ∷ α ∷ β ∷ ή ∷ σ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "1Thess.4.16"
∷ word (ἀ ∷ π ∷ []) "1Thess.4.16"
∷ word (ο ∷ ὐ ∷ ρ ∷ α ∷ ν ∷ ο ∷ ῦ ∷ []) "1Thess.4.16"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.16"
∷ word (ο ∷ ἱ ∷ []) "1Thess.4.16"
∷ word (ν ∷ ε ∷ κ ∷ ρ ∷ ο ∷ ὶ ∷ []) "1Thess.4.16"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.16"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "1Thess.4.16"
∷ word (ἀ ∷ ν ∷ α ∷ σ ∷ τ ∷ ή ∷ σ ∷ ο ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "1Thess.4.16"
∷ word (π ∷ ρ ∷ ῶ ∷ τ ∷ ο ∷ ν ∷ []) "1Thess.4.16"
∷ word (ἔ ∷ π ∷ ε ∷ ι ∷ τ ∷ α ∷ []) "1Thess.4.17"
∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.4.17"
∷ word (ο ∷ ἱ ∷ []) "1Thess.4.17"
∷ word (ζ ∷ ῶ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.4.17"
∷ word (ο ∷ ἱ ∷ []) "1Thess.4.17"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ ∙λ ∷ ε ∷ ι ∷ π ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.4.17"
∷ word (ἅ ∷ μ ∷ α ∷ []) "1Thess.4.17"
∷ word (σ ∷ ὺ ∷ ν ∷ []) "1Thess.4.17"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "1Thess.4.17"
∷ word (ἁ ∷ ρ ∷ π ∷ α ∷ γ ∷ η ∷ σ ∷ ό ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "1Thess.4.17"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.17"
∷ word (ν ∷ ε ∷ φ ∷ έ ∷ ∙λ ∷ α ∷ ι ∷ ς ∷ []) "1Thess.4.17"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.4.17"
∷ word (ἀ ∷ π ∷ ά ∷ ν ∷ τ ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.4.17"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.4.17"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.4.17"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.4.17"
∷ word (ἀ ∷ έ ∷ ρ ∷ α ∷ []) "1Thess.4.17"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.4.17"
∷ word (ο ∷ ὕ ∷ τ ∷ ω ∷ ς ∷ []) "1Thess.4.17"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "1Thess.4.17"
∷ word (σ ∷ ὺ ∷ ν ∷ []) "1Thess.4.17"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "1Thess.4.17"
∷ word (ἐ ∷ σ ∷ ό ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "1Thess.4.17"
∷ word (ὥ ∷ σ ∷ τ ∷ ε ∷ []) "1Thess.4.18"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "1Thess.4.18"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ή ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "1Thess.4.18"
∷ word (ἐ ∷ ν ∷ []) "1Thess.4.18"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "1Thess.4.18"
∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ι ∷ ς ∷ []) "1Thess.4.18"
∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "1Thess.4.18"
∷ word (Π ∷ ε ∷ ρ ∷ ὶ ∷ []) "1Thess.5.1"
∷ word (δ ∷ ὲ ∷ []) "1Thess.5.1"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.5.1"
∷ word (χ ∷ ρ ∷ ό ∷ ν ∷ ω ∷ ν ∷ []) "1Thess.5.1"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.1"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.5.1"
∷ word (κ ∷ α ∷ ι ∷ ρ ∷ ῶ ∷ ν ∷ []) "1Thess.5.1"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.5.1"
∷ word (ο ∷ ὐ ∷ []) "1Thess.5.1"
∷ word (χ ∷ ρ ∷ ε ∷ ί ∷ α ∷ ν ∷ []) "1Thess.5.1"
∷ word (ἔ ∷ χ ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.5.1"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.5.1"
∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "1Thess.5.1"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὶ ∷ []) "1Thess.5.2"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.5.2"
∷ word (ἀ ∷ κ ∷ ρ ∷ ι ∷ β ∷ ῶ ∷ ς ∷ []) "1Thess.5.2"
∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "1Thess.5.2"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.5.2"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ []) "1Thess.5.2"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.5.2"
∷ word (ὡ ∷ ς ∷ []) "1Thess.5.2"
∷ word (κ ∷ ∙λ ∷ έ ∷ π ∷ τ ∷ η ∷ ς ∷ []) "1Thess.5.2"
∷ word (ἐ ∷ ν ∷ []) "1Thess.5.2"
∷ word (ν ∷ υ ∷ κ ∷ τ ∷ ὶ ∷ []) "1Thess.5.2"
∷ word (ο ∷ ὕ ∷ τ ∷ ω ∷ ς ∷ []) "1Thess.5.2"
∷ word (ἔ ∷ ρ ∷ χ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "1Thess.5.2"
∷ word (ὅ ∷ τ ∷ α ∷ ν ∷ []) "1Thess.5.3"
∷ word (∙λ ∷ έ ∷ γ ∷ ω ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.5.3"
∷ word (Ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "1Thess.5.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.3"
∷ word (ἀ ∷ σ ∷ φ ∷ ά ∷ ∙λ ∷ ε ∷ ι ∷ α ∷ []) "1Thess.5.3"
∷ word (τ ∷ ό ∷ τ ∷ ε ∷ []) "1Thess.5.3"
∷ word (α ∷ ἰ ∷ φ ∷ ν ∷ ί ∷ δ ∷ ι ∷ ο ∷ ς ∷ []) "1Thess.5.3"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "1Thess.5.3"
∷ word (ἐ ∷ φ ∷ ί ∷ σ ∷ τ ∷ α ∷ τ ∷ α ∷ ι ∷ []) "1Thess.5.3"
∷ word (ὄ ∷ ∙λ ∷ ε ∷ θ ∷ ρ ∷ ο ∷ ς ∷ []) "1Thess.5.3"
∷ word (ὥ ∷ σ ∷ π ∷ ε ∷ ρ ∷ []) "1Thess.5.3"
∷ word (ἡ ∷ []) "1Thess.5.3"
∷ word (ὠ ∷ δ ∷ ὶ ∷ ν ∷ []) "1Thess.5.3"
∷ word (τ ∷ ῇ ∷ []) "1Thess.5.3"
∷ word (ἐ ∷ ν ∷ []) "1Thess.5.3"
∷ word (γ ∷ α ∷ σ ∷ τ ∷ ρ ∷ ὶ ∷ []) "1Thess.5.3"
∷ word (ἐ ∷ χ ∷ ο ∷ ύ ∷ σ ∷ ῃ ∷ []) "1Thess.5.3"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.3"
∷ word (ο ∷ ὐ ∷ []) "1Thess.5.3"
∷ word (μ ∷ ὴ ∷ []) "1Thess.5.3"
∷ word (ἐ ∷ κ ∷ φ ∷ ύ ∷ γ ∷ ω ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.5.3"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.5.4"
∷ word (δ ∷ έ ∷ []) "1Thess.5.4"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.5.4"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "1Thess.5.4"
∷ word (ἐ ∷ σ ∷ τ ∷ ὲ ∷ []) "1Thess.5.4"
∷ word (ἐ ∷ ν ∷ []) "1Thess.5.4"
∷ word (σ ∷ κ ∷ ό ∷ τ ∷ ε ∷ ι ∷ []) "1Thess.5.4"
∷ word (ἵ ∷ ν ∷ α ∷ []) "1Thess.5.4"
∷ word (ἡ ∷ []) "1Thess.5.4"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ []) "1Thess.5.4"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.5.4"
∷ word (ὡ ∷ ς ∷ []) "1Thess.5.4"
∷ word (κ ∷ ∙λ ∷ έ ∷ π ∷ τ ∷ η ∷ ς ∷ []) "1Thess.5.4"
∷ word (κ ∷ α ∷ τ ∷ α ∷ ∙λ ∷ ά ∷ β ∷ ῃ ∷ []) "1Thess.5.4"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.5.5"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.5.5"
∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.5.5"
∷ word (υ ∷ ἱ ∷ ο ∷ ὶ ∷ []) "1Thess.5.5"
∷ word (φ ∷ ω ∷ τ ∷ ό ∷ ς ∷ []) "1Thess.5.5"
∷ word (ἐ ∷ σ ∷ τ ∷ ε ∷ []) "1Thess.5.5"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.5"
∷ word (υ ∷ ἱ ∷ ο ∷ ὶ ∷ []) "1Thess.5.5"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "1Thess.5.5"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "1Thess.5.5"
∷ word (ἐ ∷ σ ∷ μ ∷ ὲ ∷ ν ∷ []) "1Thess.5.5"
∷ word (ν ∷ υ ∷ κ ∷ τ ∷ ὸ ∷ ς ∷ []) "1Thess.5.5"
∷ word (ο ∷ ὐ ∷ δ ∷ ὲ ∷ []) "1Thess.5.5"
∷ word (σ ∷ κ ∷ ό ∷ τ ∷ ο ∷ υ ∷ ς ∷ []) "1Thess.5.5"
∷ word (ἄ ∷ ρ ∷ α ∷ []) "1Thess.5.6"
∷ word (ο ∷ ὖ ∷ ν ∷ []) "1Thess.5.6"
∷ word (μ ∷ ὴ ∷ []) "1Thess.5.6"
∷ word (κ ∷ α ∷ θ ∷ ε ∷ ύ ∷ δ ∷ ω ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.5.6"
∷ word (ὡ ∷ ς ∷ []) "1Thess.5.6"
∷ word (ο ∷ ἱ ∷ []) "1Thess.5.6"
∷ word (∙λ ∷ ο ∷ ι ∷ π ∷ ο ∷ ί ∷ []) "1Thess.5.6"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "1Thess.5.6"
∷ word (γ ∷ ρ ∷ η ∷ γ ∷ ο ∷ ρ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.5.6"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.6"
∷ word (ν ∷ ή ∷ φ ∷ ω ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.5.6"
∷ word (ο ∷ ἱ ∷ []) "1Thess.5.7"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.5.7"
∷ word (κ ∷ α ∷ θ ∷ ε ∷ ύ ∷ δ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.5.7"
∷ word (ν ∷ υ ∷ κ ∷ τ ∷ ὸ ∷ ς ∷ []) "1Thess.5.7"
∷ word (κ ∷ α ∷ θ ∷ ε ∷ ύ ∷ δ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.5.7"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.7"
∷ word (ο ∷ ἱ ∷ []) "1Thess.5.7"
∷ word (μ ∷ ε ∷ θ ∷ υ ∷ σ ∷ κ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.5.7"
∷ word (ν ∷ υ ∷ κ ∷ τ ∷ ὸ ∷ ς ∷ []) "1Thess.5.7"
∷ word (μ ∷ ε ∷ θ ∷ ύ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.5.7"
∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.5.8"
∷ word (δ ∷ ὲ ∷ []) "1Thess.5.8"
∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "1Thess.5.8"
∷ word (ὄ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "1Thess.5.8"
∷ word (ν ∷ ή ∷ φ ∷ ω ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.5.8"
∷ word (ἐ ∷ ν ∷ δ ∷ υ ∷ σ ∷ ά ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "1Thess.5.8"
∷ word (θ ∷ ώ ∷ ρ ∷ α ∷ κ ∷ α ∷ []) "1Thess.5.8"
∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "1Thess.5.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.8"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ς ∷ []) "1Thess.5.8"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.8"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ κ ∷ ε ∷ φ ∷ α ∷ ∙λ ∷ α ∷ ί ∷ α ∷ ν ∷ []) "1Thess.5.8"
∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ δ ∷ α ∷ []) "1Thess.5.8"
∷ word (σ ∷ ω ∷ τ ∷ η ∷ ρ ∷ ί ∷ α ∷ ς ∷ []) "1Thess.5.8"
∷ word (ὅ ∷ τ ∷ ι ∷ []) "1Thess.5.9"
∷ word (ο ∷ ὐ ∷ κ ∷ []) "1Thess.5.9"
∷ word (ἔ ∷ θ ∷ ε ∷ τ ∷ ο ∷ []) "1Thess.5.9"
∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.5.9"
∷ word (ὁ ∷ []) "1Thess.5.9"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "1Thess.5.9"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.5.9"
∷ word (ὀ ∷ ρ ∷ γ ∷ ὴ ∷ ν ∷ []) "1Thess.5.9"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "1Thess.5.9"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.5.9"
∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ ο ∷ ί ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.5.9"
∷ word (σ ∷ ω ∷ τ ∷ η ∷ ρ ∷ ί ∷ α ∷ ς ∷ []) "1Thess.5.9"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "1Thess.5.9"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.5.9"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.5.9"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.5.9"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.5.9"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.5.9"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.5.10"
∷ word (ἀ ∷ π ∷ ο ∷ θ ∷ α ∷ ν ∷ ό ∷ ν ∷ τ ∷ ο ∷ ς ∷ []) "1Thess.5.10"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "1Thess.5.10"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.5.10"
∷ word (ἵ ∷ ν ∷ α ∷ []) "1Thess.5.10"
∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "1Thess.5.10"
∷ word (γ ∷ ρ ∷ η ∷ γ ∷ ο ∷ ρ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.5.10"
∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "1Thess.5.10"
∷ word (κ ∷ α ∷ θ ∷ ε ∷ ύ ∷ δ ∷ ω ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.5.10"
∷ word (ἅ ∷ μ ∷ α ∷ []) "1Thess.5.10"
∷ word (σ ∷ ὺ ∷ ν ∷ []) "1Thess.5.10"
∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "1Thess.5.10"
∷ word (ζ ∷ ή ∷ σ ∷ ω ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.5.10"
∷ word (δ ∷ ι ∷ ὸ ∷ []) "1Thess.5.11"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "1Thess.5.11"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ή ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "1Thess.5.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.11"
∷ word (ο ∷ ἰ ∷ κ ∷ ο ∷ δ ∷ ο ∷ μ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "1Thess.5.11"
∷ word (ε ∷ ἷ ∷ ς ∷ []) "1Thess.5.11"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.5.11"
∷ word (ἕ ∷ ν ∷ α ∷ []) "1Thess.5.11"
∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "1Thess.5.11"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.11"
∷ word (π ∷ ο ∷ ι ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "1Thess.5.11"
∷ word (Ἐ ∷ ρ ∷ ω ∷ τ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.5.12"
∷ word (δ ∷ ὲ ∷ []) "1Thess.5.12"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.5.12"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.5.12"
∷ word (ε ∷ ἰ ∷ δ ∷ έ ∷ ν ∷ α ∷ ι ∷ []) "1Thess.5.12"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.5.12"
∷ word (κ ∷ ο ∷ π ∷ ι ∷ ῶ ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "1Thess.5.12"
∷ word (ἐ ∷ ν ∷ []) "1Thess.5.12"
∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "1Thess.5.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.12"
∷ word (π ∷ ρ ∷ ο ∷ ϊ ∷ σ ∷ τ ∷ α ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "1Thess.5.12"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.5.12"
∷ word (ἐ ∷ ν ∷ []) "1Thess.5.12"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "1Thess.5.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.12"
∷ word (ν ∷ ο ∷ υ ∷ θ ∷ ε ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "1Thess.5.12"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.5.12"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.13"
∷ word (ἡ ∷ γ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "1Thess.5.13"
∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.5.13"
∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ ε ∷ κ ∷ π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.5.13"
∷ word (ἐ ∷ ν ∷ []) "1Thess.5.13"
∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ ῃ ∷ []) "1Thess.5.13"
∷ word (δ ∷ ι ∷ ὰ ∷ []) "1Thess.5.13"
∷ word (τ ∷ ὸ ∷ []) "1Thess.5.13"
∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ ν ∷ []) "1Thess.5.13"
∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "1Thess.5.13"
∷ word (ε ∷ ἰ ∷ ρ ∷ η ∷ ν ∷ ε ∷ ύ ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.5.13"
∷ word (ἐ ∷ ν ∷ []) "1Thess.5.13"
∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "1Thess.5.13"
∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "1Thess.5.14"
∷ word (δ ∷ ὲ ∷ []) "1Thess.5.14"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.5.14"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.5.14"
∷ word (ν ∷ ο ∷ υ ∷ θ ∷ ε ∷ τ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "1Thess.5.14"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.5.14"
∷ word (ἀ ∷ τ ∷ ά ∷ κ ∷ τ ∷ ο ∷ υ ∷ ς ∷ []) "1Thess.5.14"
∷ word (π ∷ α ∷ ρ ∷ α ∷ μ ∷ υ ∷ θ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ ε ∷ []) "1Thess.5.14"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.5.14"
∷ word (ὀ ∷ ∙λ ∷ ι ∷ γ ∷ ο ∷ ψ ∷ ύ ∷ χ ∷ ο ∷ υ ∷ ς ∷ []) "1Thess.5.14"
∷ word (ἀ ∷ ν ∷ τ ∷ έ ∷ χ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "1Thess.5.14"
∷ word (τ ∷ ῶ ∷ ν ∷ []) "1Thess.5.14"
∷ word (ἀ ∷ σ ∷ θ ∷ ε ∷ ν ∷ ῶ ∷ ν ∷ []) "1Thess.5.14"
∷ word (μ ∷ α ∷ κ ∷ ρ ∷ ο ∷ θ ∷ υ ∷ μ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "1Thess.5.14"
∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "1Thess.5.14"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "1Thess.5.14"
∷ word (ὁ ∷ ρ ∷ ᾶ ∷ τ ∷ ε ∷ []) "1Thess.5.15"
∷ word (μ ∷ ή ∷ []) "1Thess.5.15"
∷ word (τ ∷ ι ∷ ς ∷ []) "1Thess.5.15"
∷ word (κ ∷ α ∷ κ ∷ ὸ ∷ ν ∷ []) "1Thess.5.15"
∷ word (ἀ ∷ ν ∷ τ ∷ ὶ ∷ []) "1Thess.5.15"
∷ word (κ ∷ α ∷ κ ∷ ο ∷ ῦ ∷ []) "1Thess.5.15"
∷ word (τ ∷ ι ∷ ν ∷ ι ∷ []) "1Thess.5.15"
∷ word (ἀ ∷ π ∷ ο ∷ δ ∷ ῷ ∷ []) "1Thess.5.15"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "1Thess.5.15"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "1Thess.5.15"
∷ word (τ ∷ ὸ ∷ []) "1Thess.5.15"
∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ὸ ∷ ν ∷ []) "1Thess.5.15"
∷ word (δ ∷ ι ∷ ώ ∷ κ ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.5.15"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.5.15"
∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ή ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "1Thess.5.15"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.15"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.5.15"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "1Thess.5.15"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "1Thess.5.16"
∷ word (χ ∷ α ∷ ί ∷ ρ ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.5.16"
∷ word (ἀ ∷ δ ∷ ι ∷ α ∷ ∙λ ∷ ε ∷ ί ∷ π ∷ τ ∷ ω ∷ ς ∷ []) "1Thess.5.17"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ ύ ∷ χ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "1Thess.5.17"
∷ word (ἐ ∷ ν ∷ []) "1Thess.5.18"
∷ word (π ∷ α ∷ ν ∷ τ ∷ ὶ ∷ []) "1Thess.5.18"
∷ word (ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "1Thess.5.18"
∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "1Thess.5.18"
∷ word (γ ∷ ὰ ∷ ρ ∷ []) "1Thess.5.18"
∷ word (θ ∷ έ ∷ ∙λ ∷ η ∷ μ ∷ α ∷ []) "1Thess.5.18"
∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "1Thess.5.18"
∷ word (ἐ ∷ ν ∷ []) "1Thess.5.18"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "1Thess.5.18"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.5.18"
∷ word (ε ∷ ἰ ∷ ς ∷ []) "1Thess.5.18"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.5.18"
∷ word (τ ∷ ὸ ∷ []) "1Thess.5.19"
∷ word (π ∷ ν ∷ ε ∷ ῦ ∷ μ ∷ α ∷ []) "1Thess.5.19"
∷ word (μ ∷ ὴ ∷ []) "1Thess.5.19"
∷ word (σ ∷ β ∷ έ ∷ ν ∷ ν ∷ υ ∷ τ ∷ ε ∷ []) "1Thess.5.19"
∷ word (π ∷ ρ ∷ ο ∷ φ ∷ η ∷ τ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "1Thess.5.20"
∷ word (μ ∷ ὴ ∷ []) "1Thess.5.20"
∷ word (ἐ ∷ ξ ∷ ο ∷ υ ∷ θ ∷ ε ∷ ν ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "1Thess.5.20"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "1Thess.5.21"
∷ word (δ ∷ ὲ ∷ []) "1Thess.5.21"
∷ word (δ ∷ ο ∷ κ ∷ ι ∷ μ ∷ ά ∷ ζ ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.5.21"
∷ word (τ ∷ ὸ ∷ []) "1Thess.5.21"
∷ word (κ ∷ α ∷ ∙λ ∷ ὸ ∷ ν ∷ []) "1Thess.5.21"
∷ word (κ ∷ α ∷ τ ∷ έ ∷ χ ∷ ε ∷ τ ∷ ε ∷ []) "1Thess.5.21"
∷ word (ἀ ∷ π ∷ ὸ ∷ []) "1Thess.5.22"
∷ word (π ∷ α ∷ ν ∷ τ ∷ ὸ ∷ ς ∷ []) "1Thess.5.22"
∷ word (ε ∷ ἴ ∷ δ ∷ ο ∷ υ ∷ ς ∷ []) "1Thess.5.22"
∷ word (π ∷ ο ∷ ν ∷ η ∷ ρ ∷ ο ∷ ῦ ∷ []) "1Thess.5.22"
∷ word (ἀ ∷ π ∷ έ ∷ χ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "1Thess.5.22"
∷ word (Α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "1Thess.5.23"
∷ word (δ ∷ ὲ ∷ []) "1Thess.5.23"
∷ word (ὁ ∷ []) "1Thess.5.23"
∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "1Thess.5.23"
∷ word (τ ∷ ῆ ∷ ς ∷ []) "1Thess.5.23"
∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ ς ∷ []) "1Thess.5.23"
∷ word (ἁ ∷ γ ∷ ι ∷ ά ∷ σ ∷ α ∷ ι ∷ []) "1Thess.5.23"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.5.23"
∷ word (ὁ ∷ ∙λ ∷ ο ∷ τ ∷ ε ∷ ∙λ ∷ ε ∷ ῖ ∷ ς ∷ []) "1Thess.5.23"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.23"
∷ word (ὁ ∷ ∙λ ∷ ό ∷ κ ∷ ∙λ ∷ η ∷ ρ ∷ ο ∷ ν ∷ []) "1Thess.5.23"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.5.23"
∷ word (τ ∷ ὸ ∷ []) "1Thess.5.23"
∷ word (π ∷ ν ∷ ε ∷ ῦ ∷ μ ∷ α ∷ []) "1Thess.5.23"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.23"
∷ word (ἡ ∷ []) "1Thess.5.23"
∷ word (ψ ∷ υ ∷ χ ∷ ὴ ∷ []) "1Thess.5.23"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.23"
∷ word (τ ∷ ὸ ∷ []) "1Thess.5.23"
∷ word (σ ∷ ῶ ∷ μ ∷ α ∷ []) "1Thess.5.23"
∷ word (ἀ ∷ μ ∷ έ ∷ μ ∷ π ∷ τ ∷ ω ∷ ς ∷ []) "1Thess.5.23"
∷ word (ἐ ∷ ν ∷ []) "1Thess.5.23"
∷ word (τ ∷ ῇ ∷ []) "1Thess.5.23"
∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ ᾳ ∷ []) "1Thess.5.23"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.5.23"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.5.23"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.5.23"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.5.23"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.5.23"
∷ word (τ ∷ η ∷ ρ ∷ η ∷ θ ∷ ε ∷ ί ∷ η ∷ []) "1Thess.5.23"
∷ word (π ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "1Thess.5.24"
∷ word (ὁ ∷ []) "1Thess.5.24"
∷ word (κ ∷ α ∷ ∙λ ∷ ῶ ∷ ν ∷ []) "1Thess.5.24"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.5.24"
∷ word (ὃ ∷ ς ∷ []) "1Thess.5.24"
∷ word (κ ∷ α ∷ ὶ ∷ []) "1Thess.5.24"
∷ word (π ∷ ο ∷ ι ∷ ή ∷ σ ∷ ε ∷ ι ∷ []) "1Thess.5.24"
∷ word (Ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "1Thess.5.25"
∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ ύ ∷ χ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "1Thess.5.25"
∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "1Thess.5.25"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.5.25"
∷ word (ἀ ∷ σ ∷ π ∷ ά ∷ σ ∷ α ∷ σ ∷ θ ∷ ε ∷ []) "1Thess.5.26"
∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.5.26"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ὺ ∷ ς ∷ []) "1Thess.5.26"
∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "1Thess.5.26"
∷ word (ἐ ∷ ν ∷ []) "1Thess.5.26"
∷ word (φ ∷ ι ∷ ∙λ ∷ ή ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "1Thess.5.26"
∷ word (ἁ ∷ γ ∷ ί ∷ ῳ ∷ []) "1Thess.5.26"
∷ word (ἐ ∷ ν ∷ ο ∷ ρ ∷ κ ∷ ί ∷ ζ ∷ ω ∷ []) "1Thess.5.27"
∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "1Thess.5.27"
∷ word (τ ∷ ὸ ∷ ν ∷ []) "1Thess.5.27"
∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "1Thess.5.27"
∷ word (ἀ ∷ ν ∷ α ∷ γ ∷ ν ∷ ω ∷ σ ∷ θ ∷ ῆ ∷ ν ∷ α ∷ ι ∷ []) "1Thess.5.27"
∷ word (τ ∷ ὴ ∷ ν ∷ []) "1Thess.5.27"
∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ὴ ∷ ν ∷ []) "1Thess.5.27"
∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "1Thess.5.27"
∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "1Thess.5.27"
∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ῖ ∷ ς ∷ []) "1Thess.5.27"
∷ word (ἡ ∷ []) "1Thess.5.28"
∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "1Thess.5.28"
∷ word (τ ∷ ο ∷ ῦ ∷ []) "1Thess.5.28"
∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "1Thess.5.28"
∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.5.28"
∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "1Thess.5.28"
∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "1Thess.5.28"
∷ word (μ ∷ ε ∷ θ ∷ []) "1Thess.5.28"
∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "1Thess.5.28"
∷ []
| {
"alphanum_fraction": 0.3680153322,
"avg_line_length": 47.4663072776,
"ext": "agda",
"hexsha": "16e90ce981da620519e6bc334c4544eef9e5b7dd",
"lang": "Agda",
"max_forks_count": 5,
"max_forks_repo_forks_event_max_datetime": "2017-06-11T11:25:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-27T22:34:13.000Z",
"max_forks_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "scott-fleischman/GreekGrammar",
"max_forks_repo_path": "agda/Text/Greek/SBLGNT/1Thess.agda",
"max_issues_count": 13,
"max_issues_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7",
"max_issues_repo_issues_event_max_datetime": "2020-09-07T11:58:38.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-28T20:04:08.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "scott-fleischman/GreekGrammar",
"max_issues_repo_path": "agda/Text/Greek/SBLGNT/1Thess.agda",
"max_line_length": 87,
"max_stars_count": 44,
"max_stars_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "scott-fleischman/GreekGrammar",
"max_stars_repo_path": "agda/Text/Greek/SBLGNT/1Thess.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-06T15:41:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-29T14:48:51.000Z",
"num_tokens": 49943,
"size": 70440
} |
module Formalization.PredicateLogic.Signature where
import Lvl
open import Numeral.Natural
open import Type
-- A signature consists of a countable family of constant/function and relation symbols.
-- `Prop(n)` should be interpreted as the indices for relations of arity `n`.
-- `Obj(n)` should be interpreted as the indices for functions of arity `n` (constants if `n = 0`).
record Signature : Typeω where
constructor intro
field
{ℓₚ} : Lvl.Level
Prop : ℕ → Type{ℓₚ}
{ℓₒ} : Lvl.Level
Obj : ℕ → Type{ℓₒ}
| {
"alphanum_fraction": 0.7113207547,
"avg_line_length": 31.1764705882,
"ext": "agda",
"hexsha": "e4ba5089826763fdbf23f22bacfc843f0854b3f4",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Formalization/PredicateLogic/Signature.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Formalization/PredicateLogic/Signature.agda",
"max_line_length": 99,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Formalization/PredicateLogic/Signature.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 149,
"size": 530
} |
{-# OPTIONS --safe #-}
module Cubical.HITs.Ints.IsoInt where
open import Cubical.HITs.Ints.IsoInt.Base public
| {
"alphanum_fraction": 0.75,
"avg_line_length": 18.6666666667,
"ext": "agda",
"hexsha": "50c5caa452df11c3c6670e8b51749163b3876b38",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-03-12T20:08:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-03-12T20:08:45.000Z",
"max_forks_repo_head_hexsha": "94b474af2909727d04706d562d949928c19faf7b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jespercockx/cubical",
"max_forks_repo_path": "Cubical/HITs/Ints/IsoInt.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "94b474af2909727d04706d562d949928c19faf7b",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "jespercockx/cubical",
"max_issues_repo_path": "Cubical/HITs/Ints/IsoInt.agda",
"max_line_length": 48,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "94b474af2909727d04706d562d949928c19faf7b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jespercockx/cubical",
"max_stars_repo_path": "Cubical/HITs/Ints/IsoInt.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 33,
"size": 112
} |
{-# OPTIONS --without-K #-}
module sets.nat.ordering.leq.level where
open import sum
open import equality
open import function.isomorphism
open import function.extensionality
open import hott.level
open import sets.nat.core
open import sets.nat.ordering.leq.core
open import container.core
open import container.w
open import sets.empty
open import sets.unit
open import hott.level.sets public
using (nat-set)
module ≤-container where
I : Set
I = ℕ × ℕ
A A₁ A₂ : I → Set
A₁ (m , n) = m ≡ 0
A₂ (m , n) = ( Σ I λ { (m' , n')
→ m ≡ suc m'
× n ≡ suc n' } )
A i = A₁ i ⊎ A₂ i
A₂-struct-iso : ∀ m n
→ A₂ (m , n)
≅ (¬ (m ≡ 0) × ¬ (n ≡ 0))
A₂-struct-iso m n = iso f g α β
where
f : ∀ {m n} → A₂ (m , n) → ¬ (m ≡ 0) × ¬ (n ≡ 0)
f .{suc m}.{suc n}((m , n) , refl , refl) = (λ ()) , (λ ())
g : ∀ {m n} → ¬ (m ≡ 0) × ¬ (n ≡ 0) → A₂ (m , n)
g {m = zero} (u , v) = ⊥-elim (u refl)
g {n = zero} (u , v) = ⊥-elim (v refl)
g {suc m} {suc n} _ = ((m , n) , refl , refl)
α : ∀ {m n}(a : A₂ (m , n)) → g (f a) ≡ a
α .{suc m}.{suc n}((m , n) , refl , refl) = refl
β : ∀ {m n}(u : ¬ (m ≡ 0) × ¬ (n ≡ 0)) → f (g u) ≡ u
β {m = zero} (u , v) = ⊥-elim (u refl)
β {n = zero} (u , v) = ⊥-elim (v refl)
β {suc m} {suc n} _ = pair≡ (funext λ ()) (funext λ ())
A₂-h1 : ∀ i → h 1 (A₂ i)
A₂-h1 (m , n) = iso-level (sym≅ (A₂-struct-iso m n))
(×-level (Π-level λ _ → ⊥-prop) (Π-level λ _ → ⊥-prop))
A-disj : ∀ i → ¬ (A₁ i × A₂ i)
A-disj (.zero , n) (refl , (m' , n') , () , pn)
A-h1 : ∀ i → h 1 (A i)
A-h1 i = ⊎-h1 (nat-set _ zero) (A₂-h1 i) (A-disj i)
B : ∀ {i} → A i → Set
B (inj₁ _) = ⊥
B (inj₂ _) = ⊤
r : ∀ {i}{a : A i} → B a → I
r {a = inj₁ _} ()
r {a = inj₂ (mn' , _)} _ = mn'
c : Container _ _ _
c = container I A B r
open ≤-container using (c; A-h1)
≤-struct-iso : ∀ {n m}
→ n ≤ m
≅ W c (n , m)
≤-struct-iso = iso f g α β
where
f : ∀ {n m} → n ≤ m → W c (n , m)
f z≤n = sup (inj₁ refl) (λ ())
f (s≤s p) = sup (inj₂ (_ , (refl , refl))) (λ _ → f p)
g : ∀ {m n} → W c (m , n) → m ≤ n
g (sup (inj₁ refl) _) = z≤n
g (sup (inj₂ ((m' , n') , (refl , refl))) u)
= s≤s (g (u tt))
α : ∀ {n m}(p : n ≤ m) → g (f p) ≡ p
α z≤n = refl
α (s≤s p) = ap s≤s (α p)
β : ∀ {n m}(p : W c (m , n)) → f (g p) ≡ p
β (sup (inj₁ refl) u) = ap (sup (inj₁ refl)) (funext λ ())
β (sup (inj₂ ((m' , n') , (refl , refl))) u)
= ap (sup _) (funext λ { tt → β (u tt) })
≤-level : ∀ {m n} → h 1 (m ≤ n)
≤-level {m}{n} = iso-level (sym≅ ≤-struct-iso) (w-level A-h1 (m , n))
| {
"alphanum_fraction": 0.4351680827,
"avg_line_length": 27.3434343434,
"ext": "agda",
"hexsha": "8ce0f8ae27d3b362fc927e5ce1073c860b8335b7",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z",
"max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pcapriotti/agda-base",
"max_forks_repo_path": "src/sets/nat/ordering/leq/level.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/sets/nat/ordering/leq/level.agda",
"max_line_length": 69,
"max_stars_count": 20,
"max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pcapriotti/agda-base",
"max_stars_repo_path": "src/sets/nat/ordering/leq/level.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z",
"num_tokens": 1228,
"size": 2707
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Monoidal.Instance.Setoids where
open import Level
open import Data.Product
open import Data.Product.Relation.Binary.Pointwise.NonDependent
open import Data.Sum
open import Data.Sum.Relation.Binary.Pointwise
open import Function.Equality
open import Relation.Binary using (Setoid)
open import Categories.Category
open import Categories.Category.Instance.Setoids
open import Categories.Category.Cartesian
open import Categories.Category.Cocartesian
open import Categories.Category.Instance.SingletonSet
open import Categories.Category.Instance.EmptySet
module _ {o ℓ} where
Setoids-Cartesian : Cartesian (Setoids o ℓ)
Setoids-Cartesian = record
{ terminal = SingletonSetoid-⊤
; products = record
{ product = λ {A B} →
let module A = Setoid A
module B = Setoid B
in record
{ A×B = ×-setoid A B -- the stdlib doesn't provide projections!
; π₁ = record
{ _⟨$⟩_ = proj₁
; cong = proj₁
}
; π₂ = record
{ _⟨$⟩_ = proj₂
; cong = proj₂
}
; ⟨_,_⟩ = λ f g → record
{ _⟨$⟩_ = λ x → f ⟨$⟩ x , g ⟨$⟩ x
; cong = λ eq → cong f eq , cong g eq
}
; project₁ = λ {_ h i} eq → cong h eq
; project₂ = λ {_ h i} eq → cong i eq
; unique = λ {W h i j} eq₁ eq₂ eq → A.sym (eq₁ (Setoid.sym W eq)) , B.sym (eq₂ (Setoid.sym W eq))
}
}
}
module Setoids-Cartesian = Cartesian Setoids-Cartesian
open Setoids-Cartesian renaming (monoidal to Setoids-Monoidal) public
Setoids-Cocartesian : Cocartesian (Setoids o (o ⊔ ℓ))
Setoids-Cocartesian = record
{ initial = EmptySetoid-⊥
; coproducts = record
{ coproduct = λ {A} {B} → record
{ A+B = ⊎-setoid A B
; i₁ = record { _⟨$⟩_ = inj₁ ; cong = inj₁ }
; i₂ = record { _⟨$⟩_ = inj₂ ; cong = inj₂ }
; [_,_] = λ f g → record
{ _⟨$⟩_ = [ f ⟨$⟩_ , g ⟨$⟩_ ]
; cong = λ { (inj₁ x) → Π.cong f x ; (inj₂ x) → Π.cong g x }
}
; inject₁ = λ {_} {f} → Π.cong f
; inject₂ = λ {_} {_} {g} → Π.cong g
; unique = λ { {C} h≈f h≈g (inj₁ x) → Setoid.sym C (h≈f (Setoid.sym A x))
; {C} h≈f h≈g (inj₂ x) → Setoid.sym C (h≈g (Setoid.sym B x)) }
}
}
}
| {
"alphanum_fraction": 0.5499174917,
"avg_line_length": 33.6666666667,
"ext": "agda",
"hexsha": "d65a387589ef339c3dd16de3ba8947db73c632a1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bond15/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Monoidal/Instance/Setoids.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bond15/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Monoidal/Instance/Setoids.agda",
"max_line_length": 109,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bond15/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Monoidal/Instance/Setoids.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 769,
"size": 2424
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of the unit type
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- Disabled to prevent warnings from deprecation warnings for _≤_
{-# OPTIONS --warn=noUserWarning #-}
module Data.Unit.Properties where
open import Data.Sum.Base
open import Data.Unit.Base
open import Level using (0ℓ)
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------
-- Equality
infix 4 _≟_
_≟_ : Decidable {A = ⊤} _≡_
_ ≟ _ = yes refl
≡-setoid : Setoid 0ℓ 0ℓ
≡-setoid = setoid ⊤
≡-decSetoid : DecSetoid 0ℓ 0ℓ
≡-decSetoid = decSetoid _≟_
------------------------------------------------------------------------
-- Relational properties
≡-total : Total {A = ⊤} _≡_
≡-total _ _ = inj₁ refl
≡-antisym : Antisymmetric {A = ⊤} _≡_ _≡_
≡-antisym eq _ = eq
------------------------------------------------------------------------
-- Structures
≡-isPreorder : IsPreorder {A = ⊤} _≡_ _≡_
≡-isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = λ x → x
; trans = trans
}
≡-isPartialOrder : IsPartialOrder _≡_ _≡_
≡-isPartialOrder = record
{ isPreorder = ≡-isPreorder
; antisym = ≡-antisym
}
≡-isTotalOrder : IsTotalOrder _≡_ _≡_
≡-isTotalOrder = record
{ isPartialOrder = ≡-isPartialOrder
; total = ≡-total
}
≡-isDecTotalOrder : IsDecTotalOrder _≡_ _≡_
≡-isDecTotalOrder = record
{ isTotalOrder = ≡-isTotalOrder
; _≟_ = _≟_
; _≤?_ = _≟_
}
------------------------------------------------------------------------
-- Bundles
≡-poset : Poset 0ℓ 0ℓ 0ℓ
≡-poset = record
{ isPartialOrder = ≡-isPartialOrder
}
≡-decTotalOrder : DecTotalOrder 0ℓ 0ℓ 0ℓ
≡-decTotalOrder = record
{ isDecTotalOrder = ≡-isDecTotalOrder
}
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 1.2
≤-reflexive : _≡_ ⇒ _≤_
≤-reflexive _ = _
{-# WARNING_ON_USAGE ≤-reflexive
"Warning: ≤-reflexive was deprecated in v1.2.
Please use id from Function instead."
#-}
≤-trans : Transitive _≤_
≤-trans _ _ = _
{-# WARNING_ON_USAGE ≤-trans
"Warning: ≤-trans was deprecated in v1.2.
Please use trans from Relation.Binary.PropositionalEquality instead."
#-}
≤-antisym : Antisymmetric _≡_ _≤_
≤-antisym _ _ = refl
{-# WARNING_ON_USAGE ≤-antisym
"Warning: ≤-antisym was deprecated in v1.2.
Please use ≡-antisym instead."
#-}
≤-total : Total _≤_
≤-total _ _ = inj₁ _
{-# WARNING_ON_USAGE ≤-total
"Warning: ≤-total was deprecated in v1.2.
Please use ≡-total instead."
#-}
infix 4 _≤?_
_≤?_ : Decidable _≤_
_ ≤? _ = yes _
{-# WARNING_ON_USAGE _≤?_
"Warning: _≤_ was deprecated in v1.2.
Please use _≟_ instead."
#-}
≤-isPreorder : IsPreorder _≡_ _≤_
≤-isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = ≤-reflexive
; trans = ≤-trans
}
{-# WARNING_ON_USAGE ≤-isPreorder
"Warning: ≤-isPreorder was deprecated in v1.2.
Please use ≡-isPreorder instead."
#-}
≤-isPartialOrder : IsPartialOrder _≡_ _≤_
≤-isPartialOrder = record
{ isPreorder = ≤-isPreorder
; antisym = ≤-antisym
}
{-# WARNING_ON_USAGE ≤-isPartialOrder
"Warning: ≤-isPartialOrder was deprecated in v1.2.
Please use ≡-isPartialOrder instead."
#-}
≤-isTotalOrder : IsTotalOrder _≡_ _≤_
≤-isTotalOrder = record
{ isPartialOrder = ≤-isPartialOrder
; total = ≤-total
}
{-# WARNING_ON_USAGE ≤-isTotalOrder
"Warning: ≤-isTotalOrder was deprecated in v1.2.
Please use ≡-isTotalOrder instead."
#-}
≤-isDecTotalOrder : IsDecTotalOrder _≡_ _≤_
≤-isDecTotalOrder = record
{ isTotalOrder = ≤-isTotalOrder
; _≟_ = _≟_
; _≤?_ = _≤?_
}
{-# WARNING_ON_USAGE ≤-isDecTotalOrder
"Warning: ≤-isDecTotalOrder was deprecated in v1.2.
Please use ≡-isDecTotalOrder instead."
#-}
-- Bundles
≤-poset : Poset 0ℓ 0ℓ 0ℓ
≤-poset = record
{ isPartialOrder = ≤-isPartialOrder
}
{-# WARNING_ON_USAGE ≤-poset
"Warning: ≤-poset was deprecated in v1.2.
Please use ≡-poset instead."
#-}
≤-decTotalOrder : DecTotalOrder 0ℓ 0ℓ 0ℓ
≤-decTotalOrder = record
{ isDecTotalOrder = ≤-isDecTotalOrder
}
{-# WARNING_ON_USAGE ≤-decTotalOrder
"Warning: ≤-decTotalOrder was deprecated in v1.2.
Please use ≡-decTotalOrder instead."
#-}
| {
"alphanum_fraction": 0.5909190133,
"avg_line_length": 25.1703296703,
"ext": "agda",
"hexsha": "8f29b361a16971c515df88a1c51e1595bb8abda7",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/Unit/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/Unit/Properties.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Unit/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 1499,
"size": 4581
} |
module Function.Proofs where
import Lvl
open import Logic
open import Logic.Classical
open import Logic.Propositional
open import Logic.Propositional.Theorems
open import Logic.Predicate
open import Functional
open import Function.Inverseᵣ
open import Function.Names using (_⊜_)
open import Structure.Setoid using (Equiv) renaming (_≡_ to _≡ₛ_)
open import Structure.Setoid.Uniqueness
open import Structure.Relator.Properties
open import Structure.Relator
open import Structure.Function.Domain
open import Structure.Function.Domain.Proofs
open import Structure.Function
open import Structure.Operator
open import Syntax.Transitivity
open import Type
open import Type.Properties.Empty
private variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓₗ ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₒ₄ ℓₒ₅ ℓₒ₆ ℓₒ₇ ℓₑ ℓₑ₁ ℓₑ₂ ℓₑ₃ ℓₑ₄ ℓₑ₅ ℓₑ₆ ℓₑ₇ : Lvl.Level
module _ {T : Type{ℓₒ}} ⦃ eq : Equiv{ℓₑ}(T) ⦄ where
instance
-- Identity function is a function.
id-function : Function(id)
Function.congruence(id-function) = id
instance
-- Identity function is injective.
id-injective : Injective(id)
Injective.proof(id-injective) = id
instance
-- Identity function is surjective.
id-surjective : Surjective(id)
Surjective.proof(id-surjective) {y} = [∃]-intro (y) ⦃ reflexivity(_≡ₛ_) ⦄
instance
-- Identity function is bijective.
id-bijective : Bijective(id)
id-bijective = injective-surjective-to-bijective(id)
instance
id-idempotent : Idempotent(id)
id-idempotent = intro(reflexivity _)
instance
id-involution : Involution(id)
id-involution = intro(reflexivity _)
instance
id-inverseₗ : Inverseₗ(id)(id)
id-inverseₗ = intro(reflexivity _)
instance
id-inverseᵣ : Inverseᵣ(id)(id)
id-inverseᵣ = intro(reflexivity _)
instance
id-inverse : Inverse(id)(id)
id-inverse = [∧]-intro id-inverseₗ id-inverseᵣ
module _ {A : Type{ℓₒ₁}} ⦃ eq-a : Equiv{ℓₑ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ eq-b : Equiv{ℓₑ₂}(B) ⦄ where
instance
-- Constant functions are functions.
const-function : ∀{c : B} → Function {A = A}{B = B} (const(c))
Function.congruence(const-function) _ = reflexivity(_≡ₛ_)
instance
-- Constant functions are constant.
const-constant : ∀{c : B} → Constant {A = A}{B = B} (const(c))
Constant.proof const-constant = reflexivity(_≡ₛ_)
module _ {A : Type{ℓₒ₁}} ⦃ eq-a : Equiv{ℓₑ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ eq-b : Equiv{ℓₑ₂}(B) ⦄ where
open import Function.Equals
open import Function.Equals.Proofs
-- The constant function is extensionally a function.
instance
const-function-function : ∀{c : B} → Function {A = B}{B = A → B} const
Function.congruence const-function-function = [⊜]-abstract
module _ {a : Type{ℓₒ₁}}{b : Type{ℓₒ₂}}{c : Type{ℓₒ₃}}{d : Type{ℓₒ₄}} ⦃ _ : Equiv{ℓₑ}(a → d) ⦄ where
-- Function composition is associative.
[∘]-associativity : ∀{f : c → d}{g : b → c}{h : a → b} → ((f ∘ (g ∘ h)) ≡ₛ ((f ∘ g) ∘ h))
[∘]-associativity = reflexivity(_≡ₛ_)
module _ {a : Type{ℓₒ₁}}{b : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₑ}(a → b) ⦄ {f : a → b} where
-- Function composition has left identity element.
[∘]-identityₗ : (id ∘ f ≡ₛ f)
[∘]-identityₗ = reflexivity(_≡ₛ_)
-- Function composition has right identity element.
[∘]-identityᵣ : (f ∘ id ≡ₛ f)
[∘]-identityᵣ = reflexivity(_≡ₛ_)
module _ {a : Type{ℓₒ₁}} ⦃ _ : Equiv{ℓₑ₁}(a) ⦄ {b : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₑ₂}(b) ⦄ {c : Type{ℓₒ₃}} ⦃ _ : Equiv{ℓₑ₃}(c) ⦄ where
-- The composition of injective functions is injective.
-- Source: https://math.stackexchange.com/questions/2049511/is-the-composition-of-two-injective-functions-injective/2049521
-- Alternative proof: [∘]-associativity {f⁻¹}{g⁻¹}{g}{f} becomes id by inverseₗ-value injective equivalence
[∘]-injective : ∀{f : b → c}{g : a → b} → ⦃ inj-f : Injective(f) ⦄ → ⦃ inj-g : Injective(g) ⦄ → Injective(f ∘ g)
Injective.proof([∘]-injective {f = f}{g = g} ⦃ inj-f ⦄ ⦃ inj-g ⦄ ) {x₁}{x₂} = (injective(g) ⦃ inj-g ⦄ {x₁} {x₂}) ∘ (injective(f) ⦃ inj-f ⦄ {g(x₁)} {g(x₂)})
-- RHS of composition is injective if the composition is injective.
[∘]-injective-elim : ∀{f : b → c} → ⦃ func-f : Function(f) ⦄ → ∀{g : a → b} → ⦃ inj-fg : Injective(f ∘ g) ⦄ → Injective(g)
Injective.proof([∘]-injective-elim {f = f}{g = g} ⦃ inj-fg ⦄) {x₁}{x₂} (gx₁gx₂) = injective(f ∘ g) ⦃ inj-fg ⦄ {x₁} {x₂} (congruence₁(f) (gx₁gx₂))
module _ {a : Type{ℓₒ₁}} {b : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₑ₂}(b) ⦄ {c : Type{ℓₒ₃}} ⦃ _ : Equiv{ℓₑ₃}(c) ⦄ where
-- The composition of surjective functions is surjective.
[∘]-surjective : ∀{f : b → c} → ⦃ func-f : Function(f) ⦄ → ∀{g : a → b} → ⦃ surj-f : Surjective(f) ⦄ → ⦃ surj-g : Surjective(g) ⦄ → Surjective(f ∘ g)
Surjective.proof([∘]-surjective {f = f}{g = g}) {y}
with [∃]-intro (a) ⦃ fa≡y ⦄ ← surjective(f) {y}
with [∃]-intro (x) ⦃ gx≡a ⦄ ← surjective(g) {a}
= [∃]-intro (x) ⦃ congruence₁(f) gx≡a 🝖 fa≡y ⦄
-- LHS of composition is surjective if the composition is surjective.
[∘]-surjective-elim : ∀{f : b → c}{g : a → b} → ⦃ _ : Surjective(f ∘ g) ⦄ → Surjective(f)
Surjective.proof([∘]-surjective-elim {f = f}{g = g}) {y} with (surjective(f ∘ g) {y})
... | [∃]-intro (x) ⦃ fgx≡y ⦄ = [∃]-intro (g(x)) ⦃ fgx≡y ⦄
module _
{a : Type{ℓₒ₁}} ⦃ equiv-a : Equiv{ℓₑ₁}(a) ⦄
{b : Type{ℓₒ₂}} ⦃ equiv-b : Equiv{ℓₑ₂}(b) ⦄
{c : Type{ℓₒ₃}} ⦃ equiv-c : Equiv{ℓₑ₃}(c) ⦄
where
-- Bijective functions are closed under function composition.
-- The composition of bijective functions is bijective.
[∘]-bijective : ∀{f : b → c} → ⦃ func-f : Function(f) ⦄ → ∀{g : a → b} → ⦃ bij-f : Bijective(f) ⦄ → ⦃ bij-g : Bijective(g) ⦄ → Bijective(f ∘ g)
[∘]-bijective {f = f} {g = g} =
injective-surjective-to-bijective(f ∘ g)
⦃ [∘]-injective
⦃ inj-f = bijective-to-injective(f) ⦄
⦃ inj-g = bijective-to-injective(g) ⦄
⦄
⦃ [∘]-surjective
⦃ surj-f = bijective-to-surjective(f) ⦄
⦃ surj-g = bijective-to-surjective(g) ⦄
⦄
[∘]-inverseᵣ : ∀{f : b → c} ⦃ func-f : Function(f) ⦄ {f⁻¹ : b ← c}{g : a → b}{g⁻¹ : a ← b} → ⦃ inv-f : Inverseᵣ(f)(f⁻¹) ⦄ ⦃ inv-g : Inverseᵣ(g)(g⁻¹) ⦄ → Inverseᵣ(f ∘ g)(g⁻¹ ∘ f⁻¹)
Inverseᵣ.proof ([∘]-inverseᵣ {f} {f⁻¹} {g} {g⁻¹}) {x} =
((f ∘ g) ∘ (g⁻¹ ∘ f⁻¹))(x) 🝖[ _≡ₛ_ ]-[]
(f ∘ ((g ∘ g⁻¹) ∘ f⁻¹))(x) 🝖[ _≡ₛ_ ]-[ congruence₁(f) (inverseᵣ(g)(g⁻¹)) ]
(f ∘ (id ∘ f⁻¹))(x) 🝖[ _≡ₛ_ ]-[]
(f ∘ f⁻¹)(x) 🝖[ _≡ₛ_ ]-[ inverseᵣ(f)(f⁻¹) ]
x 🝖-end
-- The composition of functions is a function.
[∘]-function : ∀{f : b → c}{g : a → b} → ⦃ func-f : Function(f) ⦄ → ⦃ func-g : Function(g) ⦄ → Function(f ∘ g)
Function.congruence([∘]-function {f = f}{g = g}) = congruence₁(f) ∘ congruence₁(g)
module _
{a₁ : Type{ℓₒ₁}} ⦃ equiv-a₁ : Equiv{ℓₑ₁}(a₁) ⦄
{b₁ : Type{ℓₒ₂}} ⦃ equiv-b₁ : Equiv{ℓₑ₂}(b₁) ⦄
{a₂ : Type{ℓₒ₃}} ⦃ equiv-a₂ : Equiv{ℓₑ₃}(a₂) ⦄
{b₂ : Type{ℓₒ₄}} ⦃ equiv-b₂ : Equiv{ℓₑ₄}(b₂) ⦄
{c : Type{ℓₒ₅}} ⦃ equiv-c : Equiv{ℓₑ₅}(c) ⦄
{f : a₂ → b₂ → c} ⦃ func-f : BinaryOperator(f) ⦄
{g : a₁ → b₁ → a₂} ⦃ func-g : BinaryOperator(g) ⦄
{h : a₁ → b₁ → b₂} ⦃ func-h : BinaryOperator(h) ⦄
where
[∘]-binaryOperator : BinaryOperator(x ↦ y ↦ f(g x y)(h x y))
BinaryOperator.congruence [∘]-binaryOperator xy1 xy2 = congruence₂(f) (congruence₂(g) xy1 xy2) (congruence₂(h) xy1 xy2)
module _
{a : Type{ℓₒ₁}} ⦃ equiv-a : Equiv{ℓₑ₁}(a) ⦄
{b : Type{ℓₒ₂}} ⦃ equiv-b : Equiv{ℓₑ₂}(b) ⦄
{f : a → a → b} ⦃ func-f : BinaryOperator(f) ⦄
where
[$₂]-function : Function(f $₂_)
Function.congruence [$₂]-function = congruence₂(f) $₂_
module _ {X : Type{ℓ₁}} {Y : Type{ℓ₂}} {Z : Type{ℓ₃}} where
swap-involution : ⦃ _ : Equiv{ℓₑ}(X → Y → Z) ⦄ → ∀{f : X → Y → Z} → (swap(swap(f)) ≡ₛ f)
swap-involution = reflexivity(_≡ₛ_)
swap-involution-fn : ⦃ _ : Equiv{ℓₑ}((X → Y → Z) → (X → Y → Z)) ⦄ → (swap ∘ swap ≡ₛ id {T = X → Y → Z})
swap-involution-fn = reflexivity(_≡ₛ_)
swap-binaryOperator : ⦃ _ : Equiv{ℓₑ₁}(X) ⦄ ⦃ _ : Equiv{ℓₑ₂}(Y) ⦄ ⦃ _ : Equiv{ℓₑ₃}(Z) ⦄ → ∀{_▫_ : X → Y → Z} → ⦃ _ : BinaryOperator(_▫_) ⦄ → BinaryOperator(swap(_▫_))
BinaryOperator.congruence (swap-binaryOperator {_▫_ = _▫_} ⦃ intro p ⦄) x₁y₁ x₂y₂ = p x₂y₂ x₁y₁
module _ {X : Type{ℓ₁}} {Y : Type{ℓ₂}} where
s-combinator-const-id : ⦃ _ : Equiv{ℓₑ}(X → X) ⦄ → (_∘ₛ_ {X = X}{Y = Y → X}{Z = X} const const ≡ₛ id)
s-combinator-const-id = reflexivity(_≡ₛ_)
module _ {X : Type{ℓ₁}} {Y : Type{ℓ₂}} {Z : Type{ℓ₃}} ⦃ equiv-z : Equiv{ℓₑ₃}(Z) ⦄ where
s-combinator-const-eq : ∀{f}{a}{b} → (_∘ₛ_{X = X}{Y = Y}{Z = Z} f (const b) a ≡ₛ f a b)
s-combinator-const-eq = reflexivity(_≡ₛ_)
{- TODO: Maybe this is unprovable because types. https://plato.stanford.edu/entries/axiom-choice/#AxiChoLog https://plato.stanford.edu/entries/axiom-choice/choice-and-type-theory.html https://en.wikipedia.org/wiki/Diaconescu%27s_theorem
module _ {fn-ext : FunctionExtensionality} where
open import Function.Names
open import Data.Boolean
function-extensionality-to-classical : ∀{P} → (P ∨ (¬ P))
function-extensionality-to-classical{P} = where
A : Bool → Stmt
A(x) = (P ∨ (x ≡ 𝐹))
B : Bool → Stmt
B(x) = (P ∨ (x ≡ 𝑇))
C : (Bool → Stmt) → Stmt
C(F) = (F ⊜ A) ∨ (F ⊜ B)
-}
module _ {X : Type{ℓₒ₁}} ⦃ eq-x : Equiv{ℓₑ₁}(X) ⦄ {Y : Type{ℓₒ₂}} ⦃ eq-y : Equiv{ℓₑ₂}(Y) ⦄ {Z : Type{ℓₒ₃}} ⦃ eq-z : Equiv{ℓₑ₃}(Z) ⦄ where
open import Function.Equals
open import Function.Equals.Proofs
s-combinator-injective : Injective(_∘ₛ_ {X = X}{Y = Y}{Z = Z})
_⊜_.proof (Injective.proof s-combinator-injective {f} {g} sxsy) {x} = Function.Equals.intro(\{a} → [⊜]-apply([⊜]-apply sxsy {const(a)}){x})
s-combinator-inverseₗ : Inverseₗ(_∘ₛ_ {X = X}{Y = Y}{Z = Z})(f ↦ a ↦ b ↦ f (const b) a)
_⊜_.proof (Inverseᵣ.proof s-combinator-inverseₗ) = reflexivity(_≡ₛ_)
module _ {A : Type{ℓ}} ⦃ equiv-A : Equiv{ℓₑ}(A) ⦄ where
classical-constant-endofunction-existence : ⦃ classical : Classical(A) ⦄ → ∃{Obj = A → A}(Constant)
classical-constant-endofunction-existence with excluded-middle(A)
... | [∨]-introₗ a = [∃]-intro (const a)
... | [∨]-introᵣ na = [∃]-intro id ⦃ intro(\{a} → [⊥]-elim(na a)) ⦄
module _ {T : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where
open import Logic.Propositional.Theorems
open import Structure.Operator.Properties
proj₂ₗ-associativity : Associativity{T = T}(proj₂ₗ)
proj₂ₗ-associativity = intro(reflexivity(_))
proj₂ᵣ-associativity : Associativity{T = T}(proj₂ᵣ)
proj₂ᵣ-associativity = intro(reflexivity(_))
proj₂ₗ-identityₗ : ∀{id : T} → Identityₗ(proj₂ₗ)(id) ↔ (∀{x} → (Equiv._≡_ equiv id x))
proj₂ₗ-identityₗ = [↔]-intro intro Identityₗ.proof
proj₂ₗ-identityᵣ : ∀{id : T} → Identityᵣ(proj₂ₗ)(id)
proj₂ₗ-identityᵣ = intro(reflexivity(_))
proj₂ₗ-identity : ∀{id : T} → Identity(proj₂ₗ)(id) ↔ (∀{x} → (Equiv._≡_ equiv id x))
proj₂ₗ-identity =
[↔]-transitivity
([↔]-intro (l ↦ intro ⦃ left = l ⦄ ⦃ right = proj₂ₗ-identityᵣ ⦄) Identity.left)
proj₂ₗ-identityₗ
proj₂ᵣ-identityₗ : ∀{id : T} → Identityₗ(proj₂ᵣ)(id)
proj₂ᵣ-identityₗ = intro(reflexivity(_))
proj₂ᵣ-identityᵣ : ∀{id : T} → Identityᵣ(proj₂ᵣ)(id) ↔ (∀{x} → (Equiv._≡_ equiv id x))
proj₂ᵣ-identityᵣ = [↔]-intro intro Identityᵣ.proof
proj₂ᵣ-identity : ∀{id : T} → Identity(proj₂ᵣ)(id) ↔ (∀{x} → (Equiv._≡_ equiv id x))
proj₂ᵣ-identity =
[↔]-transitivity
([↔]-intro (r ↦ intro ⦃ left = proj₂ᵣ-identityₗ ⦄ ⦃ right = r ⦄) Identity.right)
proj₂ᵣ-identityᵣ
module _ {T : Type{ℓₒ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where
instance
id-inversePair : InversePair{A = T}([↔]-reflexivity)
id-inversePair = intro ⦃ left = intro(reflexivity(_≡ₛ_)) ⦄ ⦃ right = intro(reflexivity(_≡ₛ_)) ⦄
module _
{A : Type{ℓₒ₁}} ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄
{B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄
{p : A ↔ B}
where
sym-inversePair : ⦃ InversePair(p) ⦄ → InversePair([↔]-symmetry p)
sym-inversePair = intro
module _
{A : Type{ℓₒ₁}} ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄
{B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄
{C : Type{ℓₒ₃}} ⦃ equiv-C : Equiv{ℓₑ₃}(C) ⦄
{p₁ : A ↔ B} ⦃ func-p₁ₗ : Function([↔]-to-[←] p₁) ⦄
{p₂ : B ↔ C} ⦃ func-p₂ᵣ : Function([↔]-to-[→] p₂) ⦄
where
trans-inversePair : ⦃ inv₁ : InversePair(p₁) ⦄ → ⦃ inv₂ : InversePair(p₂) ⦄ → InversePair([↔]-transitivity p₁ p₂)
trans-inversePair = intro ⦃ left = [∘]-inverseᵣ {f = [↔]-to-[→] p₂} ⦄ ⦃ right = [∘]-inverseᵣ {f = [↔]-to-[←] p₁} ⦄
| {
"alphanum_fraction": 0.6025006089,
"avg_line_length": 42.6193771626,
"ext": "agda",
"hexsha": "82e0765b903bc30bb0b8ef0b7a3f306d1db63f87",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Function/Proofs.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Function/Proofs.agda",
"max_line_length": 236,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Function/Proofs.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 5588,
"size": 12317
} |
------------------------------------------------------------------------
-- Application of substitutions to terms
------------------------------------------------------------------------
import Level
open import Data.Universe
module README.DependentlyTyped.Term.Substitution
(Uni₀ : Universe Level.zero Level.zero) where
open import Data.Product as Prod renaming (curry to c; uncurry to uc)
open import deBruijn.Substitution.Data
open import Function as F using (_$_; _ˢ_) renaming (const to k)
import README.DependentlyTyped.Term as Term; open Term Uni₀
import Relation.Binary.PropositionalEquality as P
open P.≡-Reasoning
-- Code for applying substitutions.
--
-- Note that the _↦_ record ensures that we already have access to
-- operations such as lifting.
module Apply {T : Term-like Level.zero} (T↦Tm : T ↦ Tm) where
open _↦_ T↦Tm hiding (var)
mutual
infixl 8 _/⊢_ _/⊢-lemma_
-- Applies a substitution to a term. TODO: Generalise and allow
-- the codomain to be any suitable applicative structure?
_/⊢_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} → Γ ⊢ σ → Sub T ρ̂ → Δ ⊢ σ /̂ ρ̂
var x /⊢ ρ = trans ⊙ (x /∋ ρ)
ƛ t /⊢ ρ = ƛ (t /⊢ ρ ↑)
t₁ · t₂ /⊢ ρ = [ t₁ · t₂ ]/⊢ ρ
-- The body of the last case above. (At the time of writing the
-- termination checker complains if [ t₁ · t₂ ]/⊢ ρ is replaced by
-- t₁ · t₂ /⊢ ρ in the type signature of ·-/⊢ below.)
[_·_]/⊢ :
∀ {Γ Δ sp₁ sp₂ σ} {ρ̂ : Γ ⇨̂ Δ}
(t₁ : Γ ⊢ π sp₁ sp₂ , σ) (t₂ : Γ ⊢ fst σ) (ρ : Sub T ρ̂) →
Δ ⊢ snd σ /̂ ŝub ⟦ t₂ ⟧ /̂ ρ̂
[_·_]/⊢ {σ = σ} t₁ t₂ ρ =
P.subst (λ v → _ ⊢ snd σ /̂ ⟦ ρ ⟧⇨ ↑̂ /̂ ŝub v)
(≅-Value-⇒-≡ $ P.sym $ t₂ /⊢-lemma ρ)
((t₁ /⊢ ρ) · (t₂ /⊢ ρ))
abstract
-- An unfolding lemma.
·-/⊢ : ∀ {Γ Δ sp₁ sp₂ σ} {ρ̂ : Γ ⇨̂ Δ}
(t₁ : Γ ⊢ π sp₁ sp₂ , σ) (t₂ : Γ ⊢ fst σ) (ρ : Sub T ρ̂) →
[ t₁ · t₂ ]/⊢ ρ ≅-⊢ (t₁ /⊢ ρ) · (t₂ /⊢ ρ)
·-/⊢ {σ = σ} t₁ t₂ ρ =
drop-subst-⊢ (λ v → snd σ /̂ ⟦ ρ ⟧⇨ ↑̂ /̂ ŝub v)
(≅-Value-⇒-≡ $ P.sym $ t₂ /⊢-lemma ρ)
-- The application operation is well-behaved.
_/⊢-lemma_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (t : Γ ⊢ σ) (ρ : Sub T ρ̂) →
⟦ t ⟧ /Val ρ ≅-Value ⟦ t /⊢ ρ ⟧
var x /⊢-lemma ρ = /̂∋-⟦⟧⇨ x ρ
ƛ t /⊢-lemma ρ = begin
[ c ⟦ t ⟧ /Val ρ ] ≡⟨ P.refl ⟩
[ c (⟦ t ⟧ /Val ρ ↑) ] ≡⟨ curry-cong (t /⊢-lemma (ρ ↑)) ⟩
[ c ⟦ t /⊢ ρ ↑ ⟧ ] ∎
t₁ · t₂ /⊢-lemma ρ = begin
[ ⟦ t₁ · t₂ ⟧ /Val ρ ] ≡⟨ P.refl ⟩
[ (⟦ t₁ ⟧ /Val ρ) ˢ (⟦ t₂ ⟧ /Val ρ) ] ≡⟨ ˢ-cong (t₁ /⊢-lemma ρ) (t₂ /⊢-lemma ρ) ⟩
[ ⟦ t₁ /⊢ ρ ⟧ ˢ ⟦ t₂ /⊢ ρ ⟧ ] ≡⟨ P.refl ⟩
[ ⟦ (t₁ /⊢ ρ) · (t₂ /⊢ ρ) ⟧ ] ≡⟨ ⟦⟧-cong (P.sym $ ·-/⊢ t₁ t₂ ρ) ⟩
[ ⟦ t₁ · t₂ /⊢ ρ ⟧ ] ∎
app : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Sub T ρ̂ → [ Tm ⟶ Tm ] ρ̂
app ρ = record
{ function = λ _ t → t /⊢ ρ
; corresponds = λ _ t → t /⊢-lemma ρ
}
-- Application of substitutions to syntactic types. TODO: Remove?
infixl 8 _/⊢t_ _/⊢t⋆_
_/⊢t_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} → Γ ⊢ σ type → Sub T ρ̂ → Δ ⊢ σ /̂ ρ̂ type
⋆ /⊢t ρ = ⋆
el t /⊢t ρ = P.subst (λ v → _ ⊢ -, k U-el ˢ v type)
(≅-Value-⇒-≡ $ P.sym $ t /⊢-lemma ρ) $
el (t /⊢ ρ)
π σ′ τ′ /⊢t ρ = π (σ′ /⊢t ρ) (τ′ /⊢t ρ ↑)
_/⊢t⋆_ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} →
Γ ⊢ σ type → Subs T ρ̂ → Δ ⊢ σ /̂ ρ̂ type
σ′ /⊢t⋆ ε = σ′
σ′ /⊢t⋆ (ρs ▻ ρ) = σ′ /⊢t⋆ ρs /⊢t ρ
-- Congruence lemmas.
/⊢t-cong :
∀ {Γ₁ Δ₁ σ₁} {σ′₁ : Γ₁ ⊢ σ₁ type} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρ₁ : Sub T ρ̂₁}
{Γ₂ Δ₂ σ₂} {σ′₂ : Γ₂ ⊢ σ₂ type} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρ₂ : Sub T ρ̂₂} →
σ′₁ ≅-type σ′₂ → ρ₁ ≅-⇨ ρ₂ → σ′₁ /⊢t ρ₁ ≅-type σ′₂ /⊢t ρ₂
/⊢t-cong P.refl P.refl = P.refl
/⊢t⋆-cong :
∀ {Γ₁ Δ₁ σ₁} {σ′₁ : Γ₁ ⊢ σ₁ type} {ρ̂₁ : Γ₁ ⇨̂ Δ₁} {ρs₁ : Subs T ρ̂₁}
{Γ₂ Δ₂ σ₂} {σ′₂ : Γ₂ ⊢ σ₂ type} {ρ̂₂ : Γ₂ ⇨̂ Δ₂} {ρs₂ : Subs T ρ̂₂} →
σ′₁ ≅-type σ′₂ → ρs₁ ≅-⇨⋆ ρs₂ → σ′₁ /⊢t⋆ ρs₁ ≅-type σ′₂ /⊢t⋆ ρs₂
/⊢t⋆-cong P.refl P.refl = P.refl
substitution₁ : Substitution₁ Tm
substitution₁ = record
{ var = record { function = λ _ → var
; corresponds = λ _ _ → P.refl
}
; app′ = Apply.app
; app′-var = λ _ _ _ → P.refl
}
open Substitution₁ substitution₁ hiding (var)
-- Some unfolding lemmas.
module Unfolding-lemmas
{T : Term-like Level.zero}
(T↦Tm : Translation-from T)
where
open Translation-from T↦Tm
open Apply translation hiding (_/⊢_; app)
abstract
ƛ-/⊢⋆ : ∀ {Γ Δ σ τ} {ρ̂ : Γ ⇨̂ Δ} (t : Γ ▻ σ ⊢ τ) (ρs : Subs T ρ̂) →
ƛ t /⊢⋆ ρs ≅-⊢ ƛ (t /⊢⋆ ρs ↑⋆)
ƛ-/⊢⋆ t ε = P.refl
ƛ-/⊢⋆ t (ρs ▻ ρ) = begin
[ ƛ t /⊢⋆ ρs /⊢ ρ ] ≡⟨ /⊢-cong (ƛ-/⊢⋆ t ρs) (P.refl {x = [ ρ ]}) ⟩
[ ƛ (t /⊢⋆ ρs ↑⋆) /⊢ ρ ] ≡⟨ P.refl ⟩
[ ƛ (t /⊢⋆ (ρs ▻ ρ) ↑⋆) ] ∎
·-/⊢⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} {sp₁ sp₂ σ}
(t₁ : Γ ⊢ π sp₁ sp₂ , σ) (t₂ : Γ ⊢ fst σ) (ρs : Subs T ρ̂) →
t₁ · t₂ /⊢⋆ ρs ≅-⊢ (t₁ /⊢⋆ ρs) · (t₂ /⊢⋆ ρs)
·-/⊢⋆ t₁ t₂ ε = P.refl
·-/⊢⋆ t₁ t₂ (ρs ▻ ρ) = begin
[ t₁ · t₂ /⊢⋆ ρs /⊢ ρ ] ≡⟨ /⊢-cong (·-/⊢⋆ t₁ t₂ ρs) P.refl ⟩
[ (t₁ /⊢⋆ ρs) · (t₂ /⊢⋆ ρs) /⊢ ρ ] ≡⟨ ·-/⊢ (t₁ /⊢⋆ ρs) (t₂ /⊢⋆ ρs) ρ ⟩
[ (t₁ /⊢⋆ (ρs ▻ ρ)) · (t₂ /⊢⋆ (ρs ▻ ρ)) ] ∎
-- TODO: Remove the following lemmas?
⋆-/⊢t⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρs : Subs T ρ̂) →
⋆ /⊢t⋆ ρs ≅-type ⋆ {Γ = Δ}
⋆-/⊢t⋆ ε = P.refl
⋆-/⊢t⋆ (ρs ▻ ρ) = begin
[ ⋆ /⊢t⋆ ρs /⊢t ρ ] ≡⟨ /⊢t-cong (⋆-/⊢t⋆ ρs) (P.refl {x = [ ρ ]}) ⟩
[ ⋆ /⊢t ρ ] ≡⟨ P.refl ⟩
[ ⋆ ] ∎
el-/⊢t : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (t : Γ ⊢ -, k U-⋆) (ρ : Sub T ρ̂) →
el t /⊢t ρ ≅-type el (t /⊢ ρ)
el-/⊢t t ρ =
drop-subst-⊢-type (λ v → -, k U-el ˢ v)
(≅-Value-⇒-≡ $ P.sym $ t /⊢-lemma ρ)
el-/⊢t⋆ : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (t : Γ ⊢ -, k U-⋆) (ρs : Subs T ρ̂) →
el t /⊢t⋆ ρs ≅-type el (t /⊢⋆ ρs)
el-/⊢t⋆ t ε = P.refl
el-/⊢t⋆ t (ρs ▻ ρ) = begin
[ el t /⊢t⋆ ρs /⊢t ρ ] ≡⟨ /⊢t-cong (el-/⊢t⋆ t ρs) (P.refl {x = [ ρ ]}) ⟩
[ el (t /⊢⋆ ρs) /⊢t ρ ] ≡⟨ el-/⊢t (t /⊢⋆ ρs) ρ ⟩
[ el (t /⊢⋆ ρs /⊢ ρ) ] ∎
π-/⊢t⋆ : ∀ {Γ Δ σ τ} {ρ̂ : Γ ⇨̂ Δ}
(σ′ : Γ ⊢ σ type) (τ′ : Γ ▻ σ ⊢ τ type) (ρs : Subs T ρ̂) →
π σ′ τ′ /⊢t⋆ ρs ≅-type π (σ′ /⊢t⋆ ρs) (τ′ /⊢t⋆ ρs ↑⋆)
π-/⊢t⋆ σ′ τ′ ε = P.refl
π-/⊢t⋆ σ′ τ′ (ρs ▻ ρ) = begin
[ π σ′ τ′ /⊢t⋆ ρs /⊢t ρ ] ≡⟨ /⊢t-cong (π-/⊢t⋆ σ′ τ′ ρs) (P.refl {x = [ ρ ]}) ⟩
[ π (σ′ /⊢t⋆ ρs) (τ′ /⊢t⋆ ρs ↑⋆) /⊢t ρ ] ≡⟨ P.refl ⟩
[ π (σ′ /⊢t⋆ ρs /⊢t ρ) (τ′ /⊢t⋆ ρs ↑⋆ /⊢t ρ ↑) ] ∎
-- Another lemma.
module Apply-lemma
{T₁ T₂ : Term-like Level.zero}
(T₁↦T : Translation-from T₁) (T₂↦T : Translation-from T₂)
{Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρs₁ : Subs T₁ ρ̂) (ρs₂ : Subs T₂ ρ̂) where
open Translation-from T₁↦T
using () renaming (_↑⁺⋆_ to _↑⁺⋆₁_; _/⊢⋆_ to _/⊢⋆₁_)
open Apply (Translation-from.translation T₁↦T)
using () renaming (_/⊢t⋆_ to _/⊢t⋆₁_)
open Translation-from T₂↦T
using () renaming (_↑⁺⋆_ to _↑⁺⋆₂_; _/⊢⋆_ to _/⊢⋆₂_)
open Apply (Translation-from.translation T₂↦T)
using () renaming (_/⊢t⋆_ to _/⊢t⋆₂_)
abstract
var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ :
(∀ Γ⁺ {σ} (x : Γ ++⁺ Γ⁺ ∋ σ) →
var x /⊢⋆₁ ρs₁ ↑⁺⋆₁ Γ⁺ ≅-⊢ var x /⊢⋆₂ ρs₂ ↑⁺⋆₂ Γ⁺) →
∀ Γ⁺ {σ} (t : Γ ++⁺ Γ⁺ ⊢ σ) →
t /⊢⋆₁ ρs₁ ↑⁺⋆₁ Γ⁺ ≅-⊢ t /⊢⋆₂ ρs₂ ↑⁺⋆₂ Γ⁺
var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ hyp Γ⁺ (var x) = hyp Γ⁺ x
var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ hyp Γ⁺ (ƛ {σ = σ} t) = begin
[ ƛ t /⊢⋆₁ ρs₁ ↑⁺⋆₁ Γ⁺ ] ≡⟨ Unfolding-lemmas.ƛ-/⊢⋆ T₁↦T t (ρs₁ ↑⁺⋆₁ Γ⁺) ⟩
[ ƛ (t /⊢⋆₁ ρs₁ ↑⁺⋆₁ (Γ⁺ ▻ σ)) ] ≡⟨ ƛ-cong (var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ hyp (Γ⁺ ▻ σ) t) ⟩
[ ƛ (t /⊢⋆₂ ρs₂ ↑⁺⋆₂ (Γ⁺ ▻ σ)) ] ≡⟨ P.sym $ Unfolding-lemmas.ƛ-/⊢⋆ T₂↦T t (ρs₂ ↑⁺⋆₂ Γ⁺) ⟩
[ ƛ t /⊢⋆₂ ρs₂ ↑⁺⋆₂ Γ⁺ ] ∎
var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ hyp Γ⁺ (t₁ · t₂) = begin
[ t₁ · t₂ /⊢⋆₁ ρs₁ ↑⁺⋆₁ Γ⁺ ] ≡⟨ Unfolding-lemmas.·-/⊢⋆ T₁↦T t₁ t₂ (ρs₁ ↑⁺⋆₁ Γ⁺) ⟩
[ (t₁ /⊢⋆₁ ρs₁ ↑⁺⋆₁ Γ⁺) · (t₂ /⊢⋆₁ ρs₁ ↑⁺⋆₁ Γ⁺) ] ≡⟨ ·-cong (var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ hyp Γ⁺ t₁)
(var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ hyp Γ⁺ t₂) ⟩
[ (t₁ /⊢⋆₂ ρs₂ ↑⁺⋆₂ Γ⁺) · (t₂ /⊢⋆₂ ρs₂ ↑⁺⋆₂ Γ⁺) ] ≡⟨ P.sym $ Unfolding-lemmas.·-/⊢⋆ T₂↦T t₁ t₂ (ρs₂ ↑⁺⋆₂ Γ⁺) ⟩
[ t₁ · t₂ /⊢⋆₂ ρs₂ ↑⁺⋆₂ Γ⁺ ] ∎
-- Term substitutions, along with a number of lemmas.
substitution₂ : Substitution₂ Tm
substitution₂ = record
{ substitution₁ = substitution₁
; var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆′ = Apply-lemma.var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆
}
open Apply (Translation-from.translation no-translation) public
using (·-/⊢; _/⊢t_; /⊢t-cong; _/⊢t⋆_; /⊢t⋆-cong)
open Unfolding-lemmas no-translation public
open Substitution₂ substitution₂ public hiding (var; substitution₁)
| {
"alphanum_fraction": 0.4048093972,
"avg_line_length": 38.0759493671,
"ext": "agda",
"hexsha": "7c8d6097612f74732b55b5bfd414218ffdfa181c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/dependently-typed-syntax",
"max_forks_repo_path": "README/DependentlyTyped/Term/Substitution.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/dependently-typed-syntax",
"max_issues_repo_path": "README/DependentlyTyped/Term/Substitution.agda",
"max_line_length": 117,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "498f8aefc570f7815fd1d6616508eeb92c52abce",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/dependently-typed-syntax",
"max_stars_repo_path": "README/DependentlyTyped/Term/Substitution.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-08T22:51:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T12:14:44.000Z",
"num_tokens": 5386,
"size": 9024
} |
------------------------------------------------------------------------
-- Coinductive definition of subtyping
------------------------------------------------------------------------
module RecursiveTypes.Subtyping.Semantic.Coinductive where
open import Codata.Musical.Notation
open import Data.Nat using (ℕ; zero; suc)
open import Data.Fin using (Fin)
open import Function.Base
open import Data.Empty using (⊥-elim)
open import Relation.Nullary
open import Relation.Nullary.Negation hiding (stable)
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import RecursiveTypes.Syntax
open import RecursiveTypes.Substitution
open import RecursiveTypes.Semantics
infixr 10 _⟶_
infix 4 _≤∞_ _≤Coind_
infix 3 _∎
infixr 2 _≤⟨_⟩_
------------------------------------------------------------------------
-- Definition
-- The obvious definition of subtyping for trees.
data _≤∞_ {n} : Tree n → Tree n → Set where
⊥ : ∀ {τ} → ⊥ ≤∞ τ
⊤ : ∀ {σ} → σ ≤∞ ⊤
var : ∀ {x} → var x ≤∞ var x
_⟶_ : ∀ {σ₁ σ₂ τ₁ τ₂}
(τ₁≤σ₁ : ∞ (♭ τ₁ ≤∞ ♭ σ₁)) (σ₂≤τ₂ : ∞ (♭ σ₂ ≤∞ ♭ τ₂)) →
σ₁ ⟶ σ₂ ≤∞ τ₁ ⟶ τ₂
-- Subtyping for recursive types is defined in terms of subtyping for
-- trees.
_≤Coind_ : ∀ {n} → Ty n → Ty n → Set
σ ≤Coind τ = ⟦ σ ⟧ ≤∞ ⟦ τ ⟧
------------------------------------------------------------------------
-- A trick used to ensure guardedness of expressions using
-- transitivity
infix 4 _≤∞P_ _≤∞W_
data _≤∞P_ {n} : Tree n → Tree n → Set where
⊥ : ∀ {τ} → ⊥ ≤∞P τ
⊤ : ∀ {σ} → σ ≤∞P ⊤
var : ∀ {x} → var x ≤∞P var x
_⟶_ : ∀ {σ₁ σ₂ τ₁ τ₂}
(τ₁≤σ₁ : ∞ (♭ τ₁ ≤∞P ♭ σ₁)) (σ₂≤τ₂ : ∞ (♭ σ₂ ≤∞P ♭ τ₂)) →
σ₁ ⟶ σ₂ ≤∞P τ₁ ⟶ τ₂
-- Transitivity.
_≤⟨_⟩_ : ∀ τ₁ {τ₂ τ₃}
(τ₁≤τ₂ : τ₁ ≤∞P τ₂) (τ₂≤τ₃ : τ₂ ≤∞P τ₃) → τ₁ ≤∞P τ₃
data _≤∞W_ {n} : Tree n → Tree n → Set where
⊥ : ∀ {τ} → ⊥ ≤∞W τ
⊤ : ∀ {σ} → σ ≤∞W ⊤
var : ∀ {x} → var x ≤∞W var x
_⟶_ : ∀ {σ₁ σ₂ τ₁ τ₂}
(τ₁≤σ₁ : ♭ τ₁ ≤∞P ♭ σ₁) (σ₂≤τ₂ : ♭ σ₂ ≤∞P ♭ τ₂) →
σ₁ ⟶ σ₂ ≤∞W τ₁ ⟶ τ₂
transW : ∀ {n} {τ₁ τ₂ τ₃ : Tree n} →
τ₁ ≤∞W τ₂ → τ₂ ≤∞W τ₃ → τ₁ ≤∞W τ₃
transW ⊥ _ = ⊥
transW _ ⊤ = ⊤
transW var var = var
transW (τ₁≤σ₁ ⟶ σ₂≤τ₂) (χ₁≤τ₁ ⟶ τ₂≤χ₂) =
(_ ≤⟨ χ₁≤τ₁ ⟩ τ₁≤σ₁) ⟶ (_ ≤⟨ σ₂≤τ₂ ⟩ τ₂≤χ₂)
whnf : ∀ {n} {σ τ : Tree n} → σ ≤∞P τ → σ ≤∞W τ
whnf ⊥ = ⊥
whnf ⊤ = ⊤
whnf var = var
whnf (τ₁≤σ₁ ⟶ σ₂≤τ₂) = ♭ τ₁≤σ₁ ⟶ ♭ σ₂≤τ₂
whnf (σ ≤⟨ τ₁≤τ₂ ⟩ τ₂≤τ₃) = transW (whnf τ₁≤τ₂) (whnf τ₂≤τ₃)
mutual
⟦_⟧W : ∀ {n} {σ τ : Tree n} → σ ≤∞W τ → σ ≤∞ τ
⟦ ⊥ ⟧W = ⊥
⟦ ⊤ ⟧W = ⊤
⟦ var ⟧W = var
⟦ τ₁≤σ₁ ⟶ σ₂≤τ₂ ⟧W = ♯ ⟦ τ₁≤σ₁ ⟧P ⟶ ♯ ⟦ σ₂≤τ₂ ⟧P
⟦_⟧P : ∀ {n} {σ τ : Tree n} → σ ≤∞P τ → σ ≤∞ τ
⟦ σ≤τ ⟧P = ⟦ whnf σ≤τ ⟧W
⌜_⌝ : ∀ {n} {σ τ : Tree n} → σ ≤∞ τ → σ ≤∞P τ
⌜ ⊥ ⌝ = ⊥
⌜ ⊤ ⌝ = ⊤
⌜ var ⌝ = var
⌜ τ₁≤σ₁ ⟶ σ₂≤τ₂ ⌝ = ♯ ⌜ ♭ τ₁≤σ₁ ⌝ ⟶ ♯ ⌜ ♭ σ₂≤τ₂ ⌝
------------------------------------------------------------------------
-- Some lemmas
refl∞ : ∀ {n} (τ : Tree n) → τ ≤∞ τ
refl∞ ⊥ = ⊥
refl∞ ⊤ = ⊤
refl∞ (var x) = var
refl∞ (σ ⟶ τ) = ♯ refl∞ (♭ σ) ⟶ ♯ refl∞ (♭ τ)
_∎ : ∀ {n} (τ : Tree n) → τ ≤∞P τ
τ ∎ = ⌜ refl∞ τ ⌝
trans : ∀ {n} {τ₁ τ₂ τ₃ : Tree n} →
τ₁ ≤∞ τ₂ → τ₂ ≤∞ τ₃ → τ₁ ≤∞ τ₃
trans {τ₁ = τ₁} {τ₂} {τ₃} τ₁≤τ₂ τ₂≤τ₃ =
⟦ τ₁ ≤⟨ ⌜ τ₁≤τ₂ ⌝ ⟩
τ₂ ≤⟨ ⌜ τ₂≤τ₃ ⌝ ⟩
τ₃ ∎ ⟧P
unfold : ∀ {n} {τ₁ τ₂ : Ty (suc n)} →
μ τ₁ ⟶ τ₂ ≤Coind unfold[μ τ₁ ⟶ τ₂ ]
unfold = ♯ refl∞ _ ⟶ ♯ refl∞ _
fold : ∀ {n} {τ₁ τ₂ : Ty (suc n)} →
unfold[μ τ₁ ⟶ τ₂ ] ≤Coind μ τ₁ ⟶ τ₂
fold = ♯ refl∞ _ ⟶ ♯ refl∞ _
var:≤∞⟶≡ : ∀ {n} {x y : Fin n} →
var x ≤∞ var y → Ty.var x ≡ Ty.var y
var:≤∞⟶≡ var = refl
left-proj : ∀ {n} {σ₁ σ₂ τ₁ τ₂ : ∞ (Tree n)} →
σ₁ ⟶ σ₂ ≤∞ τ₁ ⟶ τ₂ → ♭ τ₁ ≤∞ ♭ σ₁
left-proj (τ₁≤σ₁ ⟶ σ₂≤τ₂) = ♭ τ₁≤σ₁
right-proj : ∀ {n} {σ₁ σ₂ τ₁ τ₂ : ∞ (Tree n)} →
σ₁ ⟶ σ₂ ≤∞ τ₁ ⟶ τ₂ → ♭ σ₂ ≤∞ ♭ τ₂
right-proj (τ₁≤σ₁ ⟶ σ₂≤τ₂) = ♭ σ₂≤τ₂
------------------------------------------------------------------------
-- _≤∞_ is stable under double-negation
stable : ∀ {n} (σ τ : Tree n) → Stable (σ ≤∞ τ)
stable ⊥ τ ¬≰ = ⊥
stable σ ⊤ ¬≰ = ⊤
stable (var x) (var y) ¬≰ with var x ≡? var y
stable (var x) (var .x) ¬≰ | yes refl = var
stable (var x) (var y) ¬≰ | no x≠y = ⊥-elim (¬≰ (x≠y ∘ var:≤∞⟶≡))
stable (σ₁ ⟶ σ₂) (τ₁ ⟶ τ₂) ¬≰ =
♯ stable (♭ τ₁) (♭ σ₁) (λ ≰ → ¬≰ (≰ ∘ left-proj)) ⟶
♯ stable (♭ σ₂) (♭ τ₂) (λ ≰ → ¬≰ (≰ ∘ right-proj))
stable ⊤ ⊥ ¬≰ = ⊥-elim (¬≰ (λ ()))
stable ⊤ (var x) ¬≰ = ⊥-elim (¬≰ (λ ()))
stable ⊤ (τ₁ ⟶ τ₂) ¬≰ = ⊥-elim (¬≰ (λ ()))
stable (var x) ⊥ ¬≰ = ⊥-elim (¬≰ (λ ()))
stable (var x) (τ₁ ⟶ τ₂) ¬≰ = ⊥-elim (¬≰ (λ ()))
stable (σ₁ ⟶ σ₂) ⊥ ¬≰ = ⊥-elim (¬≰ (λ ()))
stable (σ₁ ⟶ σ₂) (var x) ¬≰ = ⊥-elim (¬≰ (λ ()))
| {
"alphanum_fraction": 0.3986704271,
"avg_line_length": 31.2201257862,
"ext": "agda",
"hexsha": "b4894d66bc6efda9d6c9596cd2231cc1438412d7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/codata",
"max_forks_repo_path": "RecursiveTypes/Subtyping/Semantic/Coinductive.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/codata",
"max_issues_repo_path": "RecursiveTypes/Subtyping/Semantic/Coinductive.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/codata",
"max_stars_repo_path": "RecursiveTypes/Subtyping/Semantic/Coinductive.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z",
"num_tokens": 2480,
"size": 4964
} |
import Lvl
open import Type
module Structure.Logic.Constructive.Predicate
{ℓₗ} {Formula : Type{ℓₗ}}
{ℓₘₗ} (Proof : Formula → Type{ℓₘₗ})
{ℓₚ} {Predicate : Type{ℓₚ}}
{ℓₒ} {Domain : Type{ℓₒ}}
(_$_ : Predicate → Domain → Formula)
where
import Logic.Predicate as Meta
import Structure.Logic.Constructive.Propositional as Propositional
open import Type.Properties.Inhabited using (◊)
private variable P : Predicate
private variable X Y Q : Formula
private variable x y z : Domain
-- Rules of universal quantification (for all).
record Universal(∀ₗ : Predicate → Formula) : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where
field
intro : (∀{x} → Proof(P $ x)) → Proof(∀ₗ P)
elim : Proof(∀ₗ P) → ∀{x} → Proof(P $ x)
∀ₗ = \ ⦃(Meta.[∃]-intro ▫) : Meta.∃(Universal)⦄ → ▫
module ∀ₗ {▫} ⦃ p ⦄ = Universal {▫} p
-- Rules of existential quantification (exists).
record Existential(∃ : Predicate → Formula) : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where
field
intro : Proof(P $ x) → Proof(∃ P)
elim : (∀{x} → Proof(P $ x) → Proof(Q)) → (Proof(∃ P) → Proof(Q))
∃ = \ ⦃(Meta.[∃]-intro ▫) : Meta.∃(Existential)⦄ → ▫
module ∃ {▫} ⦃ p ⦄ = Existential {▫} p
record ExistentialWitness(∃ : Predicate → Formula) : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where
field
witness : Proof(∃ P) → Domain
proof : (p : Proof(∃ P)) → Proof(P $ witness p)
NonEmptyDomain = ◊ Domain
record Equality(_≡_ : Domain → Domain → Formula) : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Domain)} where
field
reflexivity : Proof(x ≡ x)
substitute : (P : Domain → Formula) → Proof(x ≡ y) → (Proof(P(x)) → Proof(P(y)))
record Logic : Type{ℓₘₗ Lvl.⊔ Lvl.of(Formula) Lvl.⊔ Lvl.of(Domain) Lvl.⊔ Lvl.of(Predicate)} where
field
⦃ propositional ⦄ : Propositional.Logic(Proof)
⦃ universal ⦄ : Meta.∃(Universal)
⦃ existential ⦄ : Meta.∃(Existential)
| {
"alphanum_fraction": 0.6316049383,
"avg_line_length": 38.2075471698,
"ext": "agda",
"hexsha": "ffae660923f91cdb35493798d7f41f6b91c45396",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Structure/Logic/Constructive/Predicate.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Structure/Logic/Constructive/Predicate.agda",
"max_line_length": 135,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Structure/Logic/Constructive/Predicate.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 815,
"size": 2025
} |
{-# OPTIONS --rewriting #-}
-- Set-theoretic interpretation and consistency
open import Library
module Interpretation (Base : Set) (B⦅_⦆ : Base → Set) where
import Formulas ; open module Form = Formulas Base
import Derivations; open module Der = Derivations Base
T⦅_⦆ : (A : Form) → Set
T⦅ Atom P ⦆ = B⦅ P ⦆
T⦅ True ⦆ = ⊤
T⦅ False ⦆ = ⊥
T⦅ A ∨ B ⦆ = T⦅ A ⦆ ⊎ T⦅ B ⦆
T⦅ A ∧ B ⦆ = T⦅ A ⦆ × T⦅ B ⦆
T⦅ A ⇒ B ⦆ = T⦅ A ⦆ → T⦅ B ⦆
C⦅_⦆ : (Γ : Cxt) → Set
C⦅ ε ⦆ = ⊤
C⦅ Γ ∙ A ⦆ = C⦅ Γ ⦆ × T⦅ A ⦆
Fun' : (Γ : Cxt) (S : Set) → Set
Fun' Γ S = (γ : C⦅ Γ ⦆) → S
Fun : (Γ : Cxt) (A : Form) → Set
Fun Γ A = Fun' Γ T⦅ A ⦆
Mor : (Γ Δ : Cxt) → Set
Mor Γ Δ = Fun' Γ C⦅ Δ ⦆
H⦅_⦆ : ∀{Γ A} (x : Hyp A Γ) → Fun Γ A
H⦅ top ⦆ = proj₂
H⦅ pop x ⦆ = H⦅ x ⦆ ∘ proj₁
D⦅_⦆ : ∀{Γ A} (t : Γ ⊢ A) → Fun Γ A
D⦅ hyp x ⦆ = H⦅ x ⦆
D⦅ impI t ⦆ = curry D⦅ t ⦆
D⦅ impE t u ⦆ = apply D⦅ t ⦆ D⦅ u ⦆
D⦅ andI t u ⦆ = < D⦅ t ⦆ , D⦅ u ⦆ >
D⦅ andE₁ t ⦆ = proj₁ ∘ D⦅ t ⦆
D⦅ andE₂ t ⦆ = proj₂ ∘ D⦅ t ⦆
D⦅ orI₁ t ⦆ = inj₁ ∘ D⦅ t ⦆
D⦅ orI₂ t ⦆ = inj₂ ∘ D⦅ t ⦆
D⦅ orE t u v ⦆ = caseof D⦅ t ⦆ D⦅ u ⦆ D⦅ v ⦆
D⦅ falseE t ⦆ = ⊥-elim ∘ D⦅ t ⦆
D⦅ trueI ⦆ = _
consistency : (t : ε ⊢ False) → ⊥
consistency t = D⦅ t ⦆ _
Ne⦅_⦆ : ∀{Γ A} (t : Ne Γ A) → Fun Γ A
Ne⦅_⦆ = D⦅_⦆ ∘ ne[_]
Nf⦅_⦆ : ∀{Γ A} (t : Nf Γ A) → Fun Γ A
Nf⦅_⦆ = D⦅_⦆ ∘ nf[_]
-- Functor
R⦅_⦆ : ∀{Γ Δ} (τ : Γ ≤ Δ) → Mor Γ Δ
R⦅ ε ⦆ = _
R⦅ weak τ ⦆ = R⦅ τ ⦆ ∘ proj₁
R⦅ lift τ ⦆ = R⦅ τ ⦆ ×̇ id
R-id : ∀ Γ (γ : C⦅ Γ ⦆)→ R⦅ id≤ {Γ} ⦆ γ ≡ γ
R-id ε γ = refl
R-id (Γ ∙ A) γ = cong₂ _,_ (R-id Γ (proj₁ γ)) refl
{-# REWRITE R-id #-}
-- Kripke application
kapp : ∀ A B {Γ} (f : Fun Γ (A ⇒ B)) {Δ} (τ : Δ ≤ Γ) (a : Fun Δ A) → Fun Δ B
kapp A B f τ a δ = f (R⦅ τ ⦆ δ) (a δ)
-- Naturality
natH : ∀{Γ Δ A} (τ : Δ ≤ Γ) (x : Hyp A Γ) → H⦅ monH τ x ⦆ ≡ H⦅ x ⦆ ∘ R⦅ τ ⦆
natH ε ()
natH (weak τ) x = cong (_∘ proj₁) (natH τ x)
natH (lift τ) top = refl
natH (lift τ) (pop x) = cong (_∘ proj₁) (natH τ x)
{-# REWRITE natH #-}
natR : ∀{Γ Δ Φ} (σ : Φ ≤ Δ) (τ : Δ ≤ Γ) → R⦅ σ • τ ⦆ ≡ R⦅ τ ⦆ ∘ R⦅ σ ⦆
natR ε τ = refl
natR (weak σ) τ = cong (_∘ proj₁) (natR σ τ)
natR (lift σ) (weak τ) = cong (_∘ proj₁) (natR σ τ)
natR (lift σ) (lift τ) = cong (_×̇ id) (natR σ τ)
{-# REWRITE natR #-}
natD : ∀{Γ Δ A} (τ : Δ ≤ Γ) (t : Γ ⊢ A) → D⦅ monD τ t ⦆ ≡ D⦅ t ⦆ ∘ R⦅ τ ⦆
natD τ (hyp x) = natH τ x
natD τ (impI t) = cong curry (natD (lift τ) t)
natD τ (impE t u) = cong₂ apply (natD τ t) (natD τ u)
natD τ (andI t u) = cong₂ <_,_> (natD τ t) (natD τ u)
natD τ (andE₁ t) = cong (proj₁ ∘_) (natD τ t)
natD τ (andE₂ t) = cong (proj₂ ∘_) (natD τ t)
natD τ (orI₁ t) = cong (inj₁ ∘_) (natD τ t)
natD τ (orI₂ t) = cong (inj₂ ∘_) (natD τ t)
natD τ (orE t u v) = cong₃ caseof (natD τ t) (natD (lift τ) u) (natD (lift τ) v)
natD τ (falseE t) = cong (⊥-elim ∘_) (natD τ t)
natD τ trueI = funExt λ _ → refl
{-# REWRITE natD #-}
-- -}
| {
"alphanum_fraction": 0.4755415793,
"avg_line_length": 25.7837837838,
"ext": "agda",
"hexsha": "c6737b1d7ece3068c66668459f059f9ddfec8c4d",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z",
"max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "andreasabel/ipl",
"max_forks_repo_path": "src/Interpretation.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "andreasabel/ipl",
"max_issues_repo_path": "src/Interpretation.agda",
"max_line_length": 80,
"max_stars_count": 19,
"max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "andreasabel/ipl",
"max_stars_repo_path": "src/Interpretation.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z",
"num_tokens": 1719,
"size": 2862
} |
module Implicits.Resolution.Embedding.Lemmas where
open import Prelude
open import Data.Fin.Substitution
open import Data.Vec hiding ([_]; _∈_)
open import Data.List as List hiding ([_]; map)
open import Data.List.Properties
open import Data.List.Any hiding (map)
open Membership-≡
open import Extensions.Vec
open import Data.Vec.Properties as VP using ()
open import Relation.Binary.HeterogeneousEquality as H using ()
module HR = H.≅-Reasoning
open import Implicits.Syntax
open import SystemF.Everything as F using ()
open import Implicits.Substitutions
open import Implicits.Substitutions.Lemmas
open import Implicits.Resolution.Embedding
open TypeSubst hiding (subst)
private
module TS = TypeSubst
length-weaken-Δ : ∀ {ν} (Δ : ICtx ν) →
(List.length (List.map ⟦_⟧tp→ (ictx-weaken Δ))) ≡ (List.length (List.map ⟦_⟧tp→ Δ))
length-weaken-Δ Δ = begin
(List.length (List.map ⟦_⟧tp→ (List.map (λ s → s / wk) Δ)))
≡⟨ cong List.length (sym $ map-compose Δ) ⟩
(List.length (List.map (⟦_⟧tp→ ∘ (λ s → s / wk)) Δ))
≡⟨ length-map _ Δ ⟩
List.length Δ
≡⟨ sym $ length-map _ Δ ⟩
(List.length (List.map ⟦_⟧tp→ Δ)) ∎
tp→← : ∀ {ν} (a : Type ν) → ⟦ ⟦ a ⟧tp→ ⟧tp← ≡ a
tp→← (simpl (tc x)) = refl
tp→← (simpl (tvar n)) = refl
tp→← (simpl (x →' x₁)) = cong₂ (λ u v → simpl (u →' v)) (tp→← x) (tp→← x₁)
tp→← (a ⇒ b) = cong₂ _⇒_ (tp→← a) (tp→← b)
tp→← (∀' a) = cong ∀' (tp→← a)
tp←→ : ∀ {ν} (a : F.Type ν) → ⟦ ⟦ a ⟧tp← ⟧tp→ ≡ a
tp←→ (F.tc x) = refl
tp←→ (F.tvar n) = refl
tp←→ (x F.→' x₁) = cong₂ F._→'_ (tp←→ x) (tp←→ x₁)
tp←→ (a F.⟶ b) = cong₂ F._⟶_ (tp←→ a) (tp←→ b)
tp←→ (F.∀' a) = cong F.∀' (tp←→ a)
ctx→← : ∀ {ν} (Δ : ICtx ν) → ⟦ ⟦ Δ ⟧ctx→ ⟧ctx← ≡ Δ
ctx→← [] = refl
ctx→← (x ∷ xs) = begin
⟦ ⟦ x ∷ xs ⟧ctx→ ⟧ctx←
≡⟨ refl ⟩
toList (map ⟦_⟧tp← (fromList (List.map ⟦_⟧tp→ (x List.∷ xs))))
≡⟨ refl ⟩
⟦ ⟦ x ⟧tp→ ⟧tp← List.∷ (toList (map ⟦_⟧tp← (fromList (List.map ⟦_⟧tp→ xs))))
≡⟨ cong₂ List._∷_ (tp→← x) (ctx→← xs) ⟩
(x List.∷ xs) ∎
Γ-cong₂ : ∀ {ν n n'} {x x' : F.Type ν} {xs : F.Ctx ν n} {xs' : F.Ctx ν n'} →
n ≡ n' → x ≡ x' → xs H.≅ xs' → (x Vec.∷ xs) H.≅ (x' Vec.∷ xs')
Γ-cong₂ refl refl H.refl = H.refl
ctx←→ : ∀ {ν n} (Γ : F.Ctx ν n) → ⟦ ⟦ Γ ⟧ctx← ⟧ctx→ H.≅ Γ
ctx←→ [] = H.refl
ctx←→ {ν = ν} (x ∷ xs) = HR.begin
⟦ ⟦ x ∷ xs ⟧ctx← ⟧ctx→
HR.≡⟨ refl ⟩
⟦ ⟦ x ⟧tp← ⟧tp→ ∷ ⟦ ⟦ xs ⟧ctx← ⟧ctx→
HR.≅⟨ Γ-cong₂ (length-map-toList (map ⟦_⟧tp← xs)) (tp←→ x) (ctx←→ xs) ⟩
(x ∷ xs) HR.∎
⟦a/var⟧tp← : ∀ {ν ν'} (a : F.Type ν) (s : Vec (Fin ν') ν) → ⟦ a F./Var s ⟧tp← ≡ ⟦ a ⟧tp← /Var s
⟦a/var⟧tp← (F.tc x) s = refl
⟦a/var⟧tp← (F.tvar n) s = refl
⟦a/var⟧tp← (a F.→' b) s = cong₂ _⇒_ (⟦a/var⟧tp← a s) (⟦a/var⟧tp← b s)
⟦a/var⟧tp← (a F.⟶ b) s = cong₂ (λ u v → simpl (u →' v)) (⟦a/var⟧tp← a s) (⟦a/var⟧tp← b s)
⟦a/var⟧tp← (F.∀' a) s = cong ∀' (⟦a/var⟧tp← a (s VarSubst.↑))
⟦a/var⟧tp→ : ∀ {ν ν'} (a : Type ν) (s : Vec (Fin ν') ν) → ⟦ a /Var s ⟧tp→ ≡ ⟦ a ⟧tp→ F./Var s
⟦a/var⟧tp→ (simpl (tc x)) s = refl
⟦a/var⟧tp→ (simpl (tvar n)) s = refl
⟦a/var⟧tp→ (simpl (a →' b)) s = cong₂ F._⟶_ (⟦a/var⟧tp→ a s) (⟦a/var⟧tp→ b s)
⟦a/var⟧tp→ (a ⇒ b) s = cong₂ F._→'_ (⟦a/var⟧tp→ a s) (⟦a/var⟧tp→ b s)
⟦a/var⟧tp→ (∀' a) s = cong F.∀' (⟦a/var⟧tp→ a (s VarSubst.↑))
⟦weaken⟧tp← : ∀ {ν} (a : F.Type ν) → ⟦ F.weaken a ⟧tp← ≡ weaken ⟦ a ⟧tp←
⟦weaken⟧tp← x = ⟦a/var⟧tp← x VarSubst.wk
⟦weaken⟧tp→ : ∀ {ν} (a : Type ν) → ⟦ weaken a ⟧tp→ ≡ F.weaken ⟦ a ⟧tp→
⟦weaken⟧tp→ x = ⟦a/var⟧tp→ x VarSubst.wk
-- helper lemma on mapping type-semantics over weakend substitutions
⟦⟧tps←⋆weaken : ∀ {ν n} (xs : Vec (F.Type ν) n) →
⟦ (map F.weaken xs) ⟧tps← ≡ (map weaken ⟦ xs ⟧tps←)
⟦⟧tps←⋆weaken xs = begin
(map ⟦_⟧tp← ∘ map F.weaken) xs
≡⟨ sym $ (VP.map-∘ ⟦_⟧tp← F.weaken) xs ⟩
map (⟦_⟧tp← ∘ F.weaken) xs
≡⟨ (VP.map-cong ⟦weaken⟧tp←) xs ⟩
map (TS.weaken ∘ ⟦_⟧tp←) xs
≡⟨ (VP.map-∘ TS.weaken ⟦_⟧tp←) xs ⟩
map TS.weaken (map ⟦_⟧tp← xs) ∎
-- helper lemma on mapping type-semantics over weakend substitutions
⟦⟧tps→⋆weaken : ∀ {ν n} (xs : Vec (Type ν) n) →
⟦ (map TS.weaken xs) ⟧tps→ ≡ (map F.weaken ⟦ xs ⟧tps→)
⟦⟧tps→⋆weaken xs = begin
(map ⟦_⟧tp→ ∘ map TS.weaken) xs
≡⟨ sym $ (VP.map-∘ ⟦_⟧tp→ TS.weaken) xs ⟩
map (⟦_⟧tp→ ∘ TS.weaken) xs
≡⟨ (VP.map-cong ⟦weaken⟧tp→) xs ⟩
map (F.weaken ∘ ⟦_⟧tp→) xs
≡⟨ (VP.map-∘ F.weaken ⟦_⟧tp→) xs ⟩
map F.weaken (map ⟦_⟧tp→ xs) ∎
-- the semantics of identity type-substitution is exactly
-- system-f's identity type substitution
⟦id⟧tp← : ∀ {n} → map ⟦_⟧tp← (F.id {n}) ≡ TS.id
⟦id⟧tp← {zero} = refl
⟦id⟧tp← {suc n} = begin
map ⟦_⟧tp← (F.tvar zero ∷ map F.weaken (F.id {n}))
≡⟨ refl ⟩
(simpl (tvar zero)) ∷ (map ⟦_⟧tp← (map F.weaken (F.id {n})))
≡⟨ cong (_∷_ (simpl (tvar zero))) (⟦⟧tps←⋆weaken (F.id {n})) ⟩
(simpl (tvar zero)) ∷ (map TS.weaken (map ⟦_⟧tp← (F.id {n})))
≡⟨ cong (λ e → simpl (tvar zero) ∷ (map TS.weaken e)) ⟦id⟧tp← ⟩
(simpl (tvar zero)) ∷ (map TS.weaken (TS.id {n}))
≡⟨ refl ⟩
TS.id ∎
-- the semantics of identity type-substitution is exactly
-- system-f's identity type substitution
⟦id⟧tp→ : ∀ {n} → map ⟦_⟧tp→ (TS.id {n}) ≡ F.id
⟦id⟧tp→ {zero} = refl
⟦id⟧tp→ {suc n} = begin
map ⟦_⟧tp→ (simpl (tvar zero) ∷ map TS.weaken (TS.id {n}))
≡⟨ refl ⟩
F.tvar zero ∷ (map ⟦_⟧tp→ (map TS.weaken (TS.id {n})))
≡⟨ cong (_∷_ (F.tvar zero)) (⟦⟧tps→⋆weaken (TS.id {n})) ⟩
F.tvar zero ∷ (map F.weaken (map ⟦_⟧tp→ (TS.id {n})))
≡⟨ cong (λ e → F.tvar zero ∷ (map F.weaken e)) ⟦id⟧tp→ ⟩
F.tvar zero ∷ (map F.weaken (F.id {n}))
≡⟨ refl ⟩
F.id ∎
-- the semantics of type weakening is exactly system-f's type weakening
⟦wk⟧tp← : ∀ {n} → map ⟦_⟧tp← (F.wk {n}) ≡ TS.wk {n}
⟦wk⟧tp← = begin
map ⟦_⟧tp← F.wk
≡⟨ ⟦⟧tps←⋆weaken F.id ⟩
map TS.weaken (map ⟦_⟧tp← F.id)
≡⟨ cong (map TS.weaken) ⟦id⟧tp← ⟩
TS.wk ∎
-- the semantics of type weakening is exactly system-f's type weakening
⟦wk⟧tp→ : ∀ {n} → map ⟦_⟧tp→ (TS.wk {n}) ≡ F.wk {n}
⟦wk⟧tp→ = begin
map ⟦_⟧tp→ TS.wk
≡⟨ ⟦⟧tps→⋆weaken TS.id ⟩
map F.weaken (map ⟦_⟧tp→ TS.id)
≡⟨ cong (map F.weaken) ⟦id⟧tp→ ⟩
F.wk ∎
⟦⟧tps←⋆↑ : ∀ {ν n} (v : Vec (F.Type ν) n) → ⟦ v F.↑ ⟧tps← ≡ ⟦ v ⟧tps← TS.↑
⟦⟧tps←⋆↑ xs = begin
(simpl (tvar zero)) ∷ (map ⟦_⟧tp← (map F.weaken xs))
≡⟨ cong (_∷_ (simpl (tvar zero))) (⟦⟧tps←⋆weaken xs) ⟩
(simpl (tvar zero)) ∷ (map TS.weaken (map ⟦_⟧tp← xs))
≡⟨ refl ⟩
(map ⟦_⟧tp← xs) TS.↑ ∎
⟦⟧tps→⋆↑ : ∀ {ν n} (v : Vec (Type ν) n) → ⟦ v TS.↑ ⟧tps→ ≡ ⟦ v ⟧tps→ F.↑
⟦⟧tps→⋆↑ xs = begin
F.tvar zero ∷ (map ⟦_⟧tp→ (map TS.weaken xs))
≡⟨ cong (_∷_ (F.tvar zero)) (⟦⟧tps→⋆weaken xs) ⟩
F.tvar zero ∷ (map F.weaken (map ⟦_⟧tp→ xs))
≡⟨ refl ⟩
(map ⟦_⟧tp→ xs) F.↑ ∎
-- type substitution commutes with interpreting types
/⋆⟦⟧tp← : ∀ {ν μ} (tp : F.Type ν) (σ : Sub F.Type ν μ) → ⟦ tp F./ σ ⟧tp← ≡ ⟦ tp ⟧tp← TS./ (map ⟦_⟧tp← σ)
/⋆⟦⟧tp← (F.tc c) σ = refl
/⋆⟦⟧tp← (F.tvar n) σ = begin
⟦ lookup n σ ⟧tp←
≡⟨ lookup⋆map σ ⟦_⟧tp← n ⟩
⟦ F.tvar n ⟧tp← TS./ (map ⟦_⟧tp← σ) ∎
/⋆⟦⟧tp← (l F.→' r) σ = cong₂ _⇒_ (/⋆⟦⟧tp← l σ) (/⋆⟦⟧tp← r σ)
/⋆⟦⟧tp← (l F.⟶ r) σ = cong₂ (λ u v → simpl (u →' v)) (/⋆⟦⟧tp← l σ) (/⋆⟦⟧tp← r σ)
/⋆⟦⟧tp← (F.∀' a) σ = begin
∀' ⟦ (a F./ σ F.↑) ⟧tp←
≡⟨ cong ∀' (/⋆⟦⟧tp← a (σ F.↑)) ⟩
∀' (⟦ a ⟧tp← / ⟦ σ F.↑ ⟧tps←)
≡⟨ cong (λ u → ∀' (⟦ a ⟧tp← TS./ u)) ((⟦⟧tps←⋆↑ σ)) ⟩
⟦ F.∀' a ⟧tp← / (map ⟦_⟧tp← σ) ∎
-- type substitution commutes with interpreting types
/⋆⟦⟧tp→ : ∀ {ν μ} (tp : Type ν) (σ : Sub Type ν μ) → ⟦ tp TS./ σ ⟧tp→ ≡ ⟦ tp ⟧tp→ F./ (map ⟦_⟧tp→ σ)
/⋆⟦⟧tp→ (simpl (tc c)) σ = refl
/⋆⟦⟧tp→ (simpl (tvar n)) σ = begin
⟦ lookup n σ ⟧tp→
≡⟨ lookup⋆map σ ⟦_⟧tp→ n ⟩
⟦ simpl (tvar n) ⟧tp→ F./ (map ⟦_⟧tp→ σ) ∎
/⋆⟦⟧tp→ (l ⇒ r) σ = cong₂ F._→'_ (/⋆⟦⟧tp→ l σ) (/⋆⟦⟧tp→ r σ)
/⋆⟦⟧tp→ (simpl (l →' r)) σ = cong₂ F._⟶_ (/⋆⟦⟧tp→ l σ) (/⋆⟦⟧tp→ r σ)
/⋆⟦⟧tp→ (∀' a) σ = begin
F.∀' ⟦ (a TS./ σ TS.↑) ⟧tp→
≡⟨ cong F.∀' (/⋆⟦⟧tp→ a (σ TS.↑)) ⟩
F.∀' (⟦ a ⟧tp→ F./ ⟦ σ TS.↑ ⟧tps→)
≡⟨ cong (λ u → F.∀' (⟦ a ⟧tp→ F./ u)) ((⟦⟧tps→⋆↑ σ)) ⟩
⟦ ∀' a ⟧tp→ F./ (map ⟦_⟧tp→ σ) ∎
⟦a/sub⟧tp← : ∀ {ν} (a : F.Type (suc ν)) b → ⟦ a F./ (F.sub b) ⟧tp← ≡ ⟦ a ⟧tp← TS./ (TS.sub ⟦ b ⟧tp←)
⟦a/sub⟧tp← a b = begin
⟦ a F./ (F.sub b) ⟧tp←
≡⟨ /⋆⟦⟧tp← a (b ∷ F.id) ⟩
(⟦ a ⟧tp← TS./ (map ⟦_⟧tp← (b ∷ F.id)) )
≡⟨ refl ⟩
(⟦ a ⟧tp← TS./ (⟦ b ⟧tp← ∷ (map ⟦_⟧tp← F.id)) )
≡⟨ cong (λ s → ⟦ a ⟧tp← TS./ (⟦ b ⟧tp← ∷ s)) ⟦id⟧tp← ⟩
(⟦ a ⟧tp← TS./ (TS.sub ⟦ b ⟧tp←)) ∎
⟦a/wk⟧tp← : ∀ {ν} → (a : F.Type ν) → ⟦ a F./ F.wk ⟧tp← ≡ ⟦ a ⟧tp← / wk
⟦a/wk⟧tp← tp = begin
⟦ tp F./ F.wk ⟧tp←
≡⟨ /⋆⟦⟧tp← tp F.wk ⟩
⟦ tp ⟧tp← / (map ⟦_⟧tp← F.wk)
≡⟨ cong (λ e → ⟦ tp ⟧tp← / e) ⟦wk⟧tp← ⟩
⟦ tp ⟧tp← / wk ∎
⟦a/wk⟧tp→ : ∀ {ν} → (a : Type ν) → ⟦ a / wk ⟧tp→ ≡ ⟦ a ⟧tp→ F./ F.wk
⟦a/wk⟧tp→ tp = begin
⟦ tp TS./ TS.wk ⟧tp→
≡⟨ /⋆⟦⟧tp→ tp TS.wk ⟩
⟦ tp ⟧tp→ F./ (map ⟦_⟧tp→ TS.wk)
≡⟨ cong (λ e → ⟦ tp ⟧tp→ F./ e) ⟦wk⟧tp→ ⟩
⟦ tp ⟧tp→ F./ F.wk ∎
⟦weaken⟧ctx← : ∀ {ν n} (Γ : F.Ctx ν n) → ⟦ F.ctx-weaken Γ ⟧ctx← ≡ ictx-weaken ⟦ Γ ⟧ctx←
⟦weaken⟧ctx← [] = refl
⟦weaken⟧ctx← (x ∷ xs) = begin
⟦ F.ctx-weaken (x ∷ xs) ⟧ctx←
≡⟨ refl ⟩
toList (map ⟦_⟧tp← (map (flip F._/_ F.wk) (x ∷ xs)))
≡⟨ cong toList (sym (VP.map-∘ _ _ (x ∷ xs))) ⟩
(⟦ x F./ F.wk ⟧tp← List.∷ (toList (map (⟦_⟧tp← ∘ (flip F._/_ F.wk)) xs)))
≡⟨ cong (λ u → ⟦ F._/_ x F.wk ⟧tp← List.∷ toList u) (VP.map-∘ _ _ xs) ⟩
(⟦ x F./ F.wk ⟧tp← List.∷ ⟦ F.ctx-weaken xs ⟧ctx←)
≡⟨ cong (λ u → ⟦ F._/_ x F.wk ⟧tp← List.∷ u) (⟦weaken⟧ctx← xs) ⟩
(⟦ x F./ F.wk ⟧tp← List.∷ (ictx-weaken ⟦ xs ⟧ctx←))
≡⟨ cong (flip List._∷_ (ictx-weaken ⟦ xs ⟧ctx←)) (⟦a/wk⟧tp← x) ⟩
ictx-weaken ⟦ x ∷ xs ⟧ctx← ∎
⟦weaken⟧ctx→ : ∀ {ν} (Δ : ICtx ν) → F.ctx-weaken ⟦ Δ ⟧ctx→ H.≅ ⟦ ictx-weaken Δ ⟧ctx→
⟦weaken⟧ctx→ List.[] = H.refl
⟦weaken⟧ctx→ (x List.∷ xs) = HR.begin
F.ctx-weaken ⟦ x List.∷ xs ⟧ctx→
HR.≅⟨ H.refl ⟩
(⟦ x ⟧tp→ F./ F.wk) Vec.∷ F.ctx-weaken ⟦ xs ⟧ctx→
HR.≅⟨ ∷-cong (sym (length-weaken-Δ xs)) (⟦weaken⟧ctx→ xs) ⟩
(⟦ x ⟧tp→ F./ F.wk) Vec.∷ ⟦ ictx-weaken xs ⟧ctx→
HR.≅⟨ H.cong (flip Vec._∷_ ⟦ ictx-weaken xs ⟧ctx→) (H.≡-to-≅ $ sym $ ⟦a/wk⟧tp→ x) ⟩
⟦ x / wk ⟧tp→ ∷ ⟦ ictx-weaken xs ⟧ctx→
HR.≅⟨ H.cong (λ u → ⟦ x / wk ⟧tp→ Vec.∷ fromList u) (H.≡-to-≅ (sym (map-compose xs))) ⟩
(fromList (List.map (⟦_⟧tp→ ∘ (λ s → s / wk)) (x List.∷ xs)))
HR.≅⟨ H.cong fromList (H.≡-to-≅ (map-compose (x List.∷ xs))) ⟩
⟦ ictx-weaken (x List.∷ xs) ⟧ctx→ HR.∎
⟦a/sub⟧tp→ : ∀ {ν} (a : Type (suc ν)) b → ⟦ a TS./ (TS.sub b) ⟧tp→ ≡ ⟦ a ⟧tp→ F./ (F.sub ⟦ b ⟧tp→)
⟦a/sub⟧tp→ a b = begin
⟦ a TS./ (TS.sub b) ⟧tp→
≡⟨ /⋆⟦⟧tp→ a (b ∷ TS.id) ⟩
(⟦ a ⟧tp→ F./ (map ⟦_⟧tp→ (b ∷ TS.id)) )
≡⟨ refl ⟩
(⟦ a ⟧tp→ F./ (⟦ b ⟧tp→ ∷ (map ⟦_⟧tp→ TS.id)) )
≡⟨ cong (λ s → ⟦ a ⟧tp→ F./ (⟦ b ⟧tp→ ∷ s)) ⟦id⟧tp→ ⟩
(⟦ a ⟧tp→ F./ (F.sub ⟦ b ⟧tp→)) ∎
⊢subst-n : ∀ {ν n n'} {Γ : F.Ctx ν n} {Γ' : F.Ctx ν n'} {t a} → (n-eq : n ≡ n') →
Γ H.≅ Γ' → Γ F.⊢ t ∈ a →
Γ' F.⊢ (subst (F.Term ν) n-eq t) ∈ a
⊢subst-n refl H.refl p = p
lookup-subst-n : ∀ {n n' l} {A : Set l} {v : Vec A n} {v' : Vec A n'} {i : Fin n} →
(n-eq : n ≡ n') →
(v H.≅ v') →
(lookup i v) ≡ (lookup (subst Fin n-eq i) v')
lookup-subst-n refl H.refl = refl
lookup⟦⟧ : ∀ {ν} (Δ : ICtx ν) {r} i → lookup i (fromList Δ) ≡ r →
(lookup (subst Fin (sym $ length-map _ Δ) i) ⟦ Δ ⟧ctx→) ≡ ⟦ r ⟧tp→
lookup⟦⟧ Δ {r = r} i eq = begin
(lookup (subst Fin (sym $ length-map _ Δ) i) ⟦ Δ ⟧ctx→)
≡⟨ refl ⟩
(lookup (subst Fin (sym $ length-map _ Δ) i) (fromList $ (List.map ⟦_⟧tp→ Δ)))
≡⟨ sym $ lookup-subst-n (sym $ length-map _ Δ) (H.sym $ fromList-map _ Δ) ⟩
(lookup i (map ⟦_⟧tp→ (fromList Δ)))
≡⟨ sym $ lookup⋆map (fromList Δ) ⟦_⟧tp→ i ⟩
⟦ lookup i (fromList Δ) ⟧tp→
≡⟨ cong ⟦_⟧tp→ eq ⟩
⟦ r ⟧tp→ ∎
lookup-∈ : ∀ {ν n} → (x : Fin n) → (v : F.Ctx ν n) → ⟦ lookup x v ⟧tp← ∈ ⟦ v ⟧ctx←
lookup-∈ zero (x ∷ xs) = here refl
lookup-∈ (suc x) (v ∷ vs) = there (lookup-∈ x vs)
⇑-subst-n : ∀ {ν n n'} {Γ : F.Ctx ν n} {Γ' : F.Ctx ν n'} {t a} → (n-eq : n ≡ n') →
Γ H.≅ Γ' → Γ F.⊢ t ⇑ a →
Γ' F.⊢ (subst (F.Term ν) n-eq t) ⇑ a
⇑-subst-n refl H.refl p = p
⟦base⟧tp← : ∀ {ν} {a : F.Type ν} → F.Base a → ∃ λ τ → ⟦ a ⟧tp← ≡ (simpl τ)
⟦base⟧tp← (F.tc n) = tc n , refl
⟦base⟧tp← (F.tvar n) = tvar n , refl
⟦base⟧tp← (a F.⟶ b) = ⟦ a ⟧tp← →' ⟦ b ⟧tp← , refl
⟦simpl⟧tp→ : ∀ {ν} (τ : SimpleType ν) → F.Base ⟦ simpl τ ⟧tp→
⟦simpl⟧tp→ (tc x) = F.tc x
⟦simpl⟧tp→ (tvar n) = F.tvar n
⟦simpl⟧tp→ (x →' x₁) = ⟦ x ⟧tp→ F.⟶ ⟦ x₁ ⟧tp→
open import Function.Inverse
tp-iso : ∀ {ν} → (→-to-⟶ (⟦_⟧tp→ {ν = ν})) InverseOf (→-to-⟶ (⟦_⟧tp← {ν = ν}))
tp-iso = record { left-inverse-of = tp←→ ; right-inverse-of = tp→← }
| {
"alphanum_fraction": 0.4879092999,
"avg_line_length": 38.5718654434,
"ext": "agda",
"hexsha": "26c2b85a62e32709d86962b40d862b8efebaec54",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "metaborg/ts.agda",
"max_forks_repo_path": "src/Implicits/Resolution/Embedding/Lemmas.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "metaborg/ts.agda",
"max_issues_repo_path": "src/Implicits/Resolution/Embedding/Lemmas.agda",
"max_line_length": 104,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "metaborg/ts.agda",
"max_stars_repo_path": "src/Implicits/Resolution/Embedding/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z",
"num_tokens": 6957,
"size": 12613
} |
{-
This second-order equational theory was created from the following second-order syntax description:
syntax Monoid | M
type
* : 0-ary
term
unit : * | ε
add : * * -> * | _⊕_ l20
theory
(εU⊕ᴸ) a |> add (unit, a) = a
(εU⊕ᴿ) a |> add (a, unit) = a
(⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c))
-}
module Monoid.Equality where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Variable
open import SOAS.Families.Core
open import SOAS.Families.Build
open import SOAS.ContextMaps.Inductive
open import Monoid.Signature
open import Monoid.Syntax
open import SOAS.Metatheory.SecondOrder.Metasubstitution M:Syn
open import SOAS.Metatheory.SecondOrder.Equality M:Syn
private
variable
α β γ τ : *T
Γ Δ Π : Ctx
infix 1 _▹_⊢_≋ₐ_
-- Axioms of equality
data _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ M) α Γ → (𝔐 ▷ M) α Γ → Set where
εU⊕ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ ε ⊕ 𝔞 ≋ₐ 𝔞
εU⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ ε ≋ₐ 𝔞
⊕A : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ⊕ 𝔟) ⊕ 𝔠 ≋ₐ 𝔞 ⊕ (𝔟 ⊕ 𝔠)
open EqLogic _▹_⊢_≋ₐ_
open ≋-Reasoning
| {
"alphanum_fraction": 0.592142189,
"avg_line_length": 21.8163265306,
"ext": "agda",
"hexsha": "bf255b53c09970f2f5da4c41fa76f276264b3512",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z",
"max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JoeyEremondi/agda-soas",
"max_forks_repo_path": "out/Monoid/Equality.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JoeyEremondi/agda-soas",
"max_issues_repo_path": "out/Monoid/Equality.agda",
"max_line_length": 99,
"max_stars_count": 39,
"max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JoeyEremondi/agda-soas",
"max_stars_repo_path": "out/Monoid/Equality.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z",
"num_tokens": 499,
"size": 1069
} |
------------------------------------------------------------------------
-- Sums of binary relations
------------------------------------------------------------------------
module Relation.Binary.Sum where
open import Data.Function
open import Data.Sum as Sum
open import Data.Product
open import Data.Unit using (⊤)
open import Data.Empty
open import Relation.Nullary
open import Relation.Binary
infixr 1 _⊎-Rel_ _⊎-<_
------------------------------------------------------------------------
-- Sums of relations
-- Generalised sum.
data ⊎ʳ (P : Set) {a₁ : Set} (_∼₁_ : Rel a₁)
{a₂ : Set} (_∼₂_ : Rel a₂)
: a₁ ⊎ a₂ → a₁ ⊎ a₂ → Set where
₁∼₂ : ∀ {x y} (p : P) → ⊎ʳ P _∼₁_ _∼₂_ (inj₁ x) (inj₂ y)
₁∼₁ : ∀ {x y} (x∼₁y : x ∼₁ y) → ⊎ʳ P _∼₁_ _∼₂_ (inj₁ x) (inj₁ y)
₂∼₂ : ∀ {x y} (x∼₂y : x ∼₂ y) → ⊎ʳ P _∼₁_ _∼₂_ (inj₂ x) (inj₂ y)
-- Pointwise sum.
_⊎-Rel_ : ∀ {a₁} (_∼₁_ : Rel a₁) →
∀ {a₂} (_∼₂_ : Rel a₂) →
Rel (a₁ ⊎ a₂)
_⊎-Rel_ = ⊎ʳ ⊥
-- All things to the left are smaller than (or equal to, depending on
-- the underlying equality) all things to the right.
_⊎-<_ : ∀ {a₁} (_∼₁_ : Rel a₁) →
∀ {a₂} (_∼₂_ : Rel a₂) →
Rel (a₁ ⊎ a₂)
_⊎-<_ = ⊎ʳ ⊤
------------------------------------------------------------------------
-- Helpers
private
₁≁₂ : ∀ {a₁} {∼₁ : Rel a₁} →
∀ {a₂} {∼₂ : Rel a₂} →
∀ {x y} → ¬ (inj₁ x ⟨ ∼₁ ⊎-Rel ∼₂ ⟩₁ inj₂ y)
₁≁₂ (₁∼₂ ())
drop-inj₁ : ∀ {a₁} {∼₁ : Rel a₁} →
∀ {a₂} {∼₂ : Rel a₂} →
∀ {P x y} → inj₁ x ⟨ ⊎ʳ P ∼₁ ∼₂ ⟩₁ inj₁ y → ∼₁ x y
drop-inj₁ (₁∼₁ x∼y) = x∼y
drop-inj₂ : ∀ {a₁} {∼₁ : Rel a₁} →
∀ {a₂} {∼₂ : Rel a₂} →
∀ {P x y} → inj₂ x ⟨ ⊎ʳ P ∼₁ ∼₂ ⟩₁ inj₂ y → ∼₂ x y
drop-inj₂ (₂∼₂ x∼y) = x∼y
------------------------------------------------------------------------
-- Some properties which are preserved by the relation formers above
_⊎-reflexive_ : ∀ {a₁} {≈₁ ∼₁ : Rel a₁} → ≈₁ ⇒ ∼₁ →
∀ {a₂} {≈₂ ∼₂ : Rel a₂} → ≈₂ ⇒ ∼₂ →
∀ {P} → (≈₁ ⊎-Rel ≈₂) ⇒ (⊎ʳ P ∼₁ ∼₂)
refl₁ ⊎-reflexive refl₂ = refl
where
refl : (_ ⊎-Rel _) ⇒ (⊎ʳ _ _ _)
refl (₁∼₁ x₁≈y₁) = ₁∼₁ (refl₁ x₁≈y₁)
refl (₂∼₂ x₂≈y₂) = ₂∼₂ (refl₂ x₂≈y₂)
refl (₁∼₂ ())
_⊎-refl_ : ∀ {a₁} {∼₁ : Rel a₁} → Reflexive ∼₁ →
∀ {a₂} {∼₂ : Rel a₂} → Reflexive ∼₂ →
Reflexive (∼₁ ⊎-Rel ∼₂)
refl₁ ⊎-refl refl₂ = refl
where
refl : Reflexive (_ ⊎-Rel _)
refl {x = inj₁ _} = ₁∼₁ refl₁
refl {x = inj₂ _} = ₂∼₂ refl₂
_⊎-irreflexive_ : ∀ {a₁} {≈₁ <₁ : Rel a₁} → Irreflexive ≈₁ <₁ →
∀ {a₂} {≈₂ <₂ : Rel a₂} → Irreflexive ≈₂ <₂ →
∀ {P} → Irreflexive (≈₁ ⊎-Rel ≈₂) (⊎ʳ P <₁ <₂)
irrefl₁ ⊎-irreflexive irrefl₂ = irrefl
where
irrefl : Irreflexive (_ ⊎-Rel _) (⊎ʳ _ _ _)
irrefl (₁∼₁ x₁≈y₁) (₁∼₁ x₁<y₁) = irrefl₁ x₁≈y₁ x₁<y₁
irrefl (₂∼₂ x₂≈y₂) (₂∼₂ x₂<y₂) = irrefl₂ x₂≈y₂ x₂<y₂
irrefl (₁∼₂ ()) _
_⊎-symmetric_ : ∀ {a₁} {∼₁ : Rel a₁} → Symmetric ∼₁ →
∀ {a₂} {∼₂ : Rel a₂} → Symmetric ∼₂ →
Symmetric (∼₁ ⊎-Rel ∼₂)
sym₁ ⊎-symmetric sym₂ = sym
where
sym : Symmetric (_ ⊎-Rel _)
sym (₁∼₁ x₁∼y₁) = ₁∼₁ (sym₁ x₁∼y₁)
sym (₂∼₂ x₂∼y₂) = ₂∼₂ (sym₂ x₂∼y₂)
sym (₁∼₂ ())
_⊎-transitive_ : ∀ {a₁} {∼₁ : Rel a₁} → Transitive ∼₁ →
∀ {a₂} {∼₂ : Rel a₂} → Transitive ∼₂ →
∀ {P} → Transitive (⊎ʳ P ∼₁ ∼₂)
trans₁ ⊎-transitive trans₂ = trans
where
trans : Transitive (⊎ʳ _ _ _)
trans (₁∼₁ x∼y) (₁∼₁ y∼z) = ₁∼₁ (trans₁ x∼y y∼z)
trans (₂∼₂ x∼y) (₂∼₂ y∼z) = ₂∼₂ (trans₂ x∼y y∼z)
trans (₁∼₂ p) (₂∼₂ _) = ₁∼₂ p
trans (₁∼₁ _) (₁∼₂ p) = ₁∼₂ p
_⊎-antisymmetric_ : ∀ {a₁} {≈₁ ≤₁ : Rel a₁} → Antisymmetric ≈₁ ≤₁ →
∀ {a₂} {≈₂ ≤₂ : Rel a₂} → Antisymmetric ≈₂ ≤₂ →
∀ {P} → Antisymmetric (≈₁ ⊎-Rel ≈₂) (⊎ʳ P ≤₁ ≤₂)
antisym₁ ⊎-antisymmetric antisym₂ = antisym
where
antisym : Antisymmetric (_ ⊎-Rel _) (⊎ʳ _ _ _)
antisym (₁∼₁ x≤y) (₁∼₁ y≤x) = ₁∼₁ (antisym₁ x≤y y≤x)
antisym (₂∼₂ x≤y) (₂∼₂ y≤x) = ₂∼₂ (antisym₂ x≤y y≤x)
antisym (₁∼₂ _) ()
_⊎-asymmetric_ : ∀ {a₁} {<₁ : Rel a₁} → Asymmetric <₁ →
∀ {a₂} {<₂ : Rel a₂} → Asymmetric <₂ →
∀ {P} → Asymmetric (⊎ʳ P <₁ <₂)
asym₁ ⊎-asymmetric asym₂ = asym
where
asym : Asymmetric (⊎ʳ _ _ _)
asym (₁∼₁ x<y) (₁∼₁ y<x) = asym₁ x<y y<x
asym (₂∼₂ x<y) (₂∼₂ y<x) = asym₂ x<y y<x
asym (₁∼₂ _) ()
_⊎-≈-respects₂_ : ∀ {a₁} {≈₁ ∼₁ : Rel a₁} → ∼₁ Respects₂ ≈₁ →
∀ {a₂} {≈₂ ∼₂ : Rel a₂} → ∼₂ Respects₂ ≈₂ →
∀ {P} → (⊎ʳ P ∼₁ ∼₂) Respects₂ (≈₁ ⊎-Rel ≈₂)
_⊎-≈-respects₂_ {≈₁ = ≈₁} {∼₁ = ∼₁} resp₁
{≈₂ = ≈₂} {∼₂ = ∼₂} resp₂ {P} =
(λ {_ _ _} → resp¹) ,
(λ {_ _ _} → resp²)
where
resp¹ : ∀ {x} → ((⊎ʳ P ∼₁ ∼₂) x) Respects (≈₁ ⊎-Rel ≈₂)
resp¹ (₁∼₁ y≈y') (₁∼₁ x∼y) = ₁∼₁ (proj₁ resp₁ y≈y' x∼y)
resp¹ (₂∼₂ y≈y') (₂∼₂ x∼y) = ₂∼₂ (proj₁ resp₂ y≈y' x∼y)
resp¹ (₂∼₂ y≈y') (₁∼₂ p) = (₁∼₂ p)
resp¹ (₁∼₂ ()) _
resp² : ∀ {y}
→ (flip₁ (⊎ʳ P ∼₁ ∼₂) y) Respects (≈₁ ⊎-Rel ≈₂)
resp² (₁∼₁ x≈x') (₁∼₁ x∼y) = ₁∼₁ (proj₂ resp₁ x≈x' x∼y)
resp² (₂∼₂ x≈x') (₂∼₂ x∼y) = ₂∼₂ (proj₂ resp₂ x≈x' x∼y)
resp² (₁∼₁ x≈x') (₁∼₂ p) = (₁∼₂ p)
resp² (₁∼₂ ()) _
_⊎-substitutive_ : ∀ {a₁} {∼₁ : Rel a₁} → Substitutive ∼₁ →
∀ {a₂} {∼₂ : Rel a₂} → Substitutive ∼₂ →
Substitutive (∼₁ ⊎-Rel ∼₂)
subst₁ ⊎-substitutive subst₂ = subst
where
subst : Substitutive (_ ⊎-Rel _)
subst P (₁∼₁ x∼y) Px = subst₁ (λ z → P (inj₁ z)) x∼y Px
subst P (₂∼₂ x∼y) Px = subst₂ (λ z → P (inj₂ z)) x∼y Px
subst P (₁∼₂ ()) Px
⊎-decidable : ∀ {a₁} {∼₁ : Rel a₁} → Decidable ∼₁ →
∀ {a₂} {∼₂ : Rel a₂} → Decidable ∼₂ →
∀ {P} → (∀ {x y} → Dec (inj₁ x ⟨ ⊎ʳ P ∼₁ ∼₂ ⟩₁ inj₂ y)) →
Decidable (⊎ʳ P ∼₁ ∼₂)
⊎-decidable {∼₁ = ∼₁} dec₁ {∼₂ = ∼₂} dec₂ {P} dec₁₂ = dec
where
dec : Decidable (⊎ʳ P ∼₁ ∼₂)
dec (inj₁ x) (inj₁ y) with dec₁ x y
... | yes x∼y = yes (₁∼₁ x∼y)
... | no x≁y = no (x≁y ∘ drop-inj₁)
dec (inj₂ x) (inj₂ y) with dec₂ x y
... | yes x∼y = yes (₂∼₂ x∼y)
... | no x≁y = no (x≁y ∘ drop-inj₂)
dec (inj₁ x) (inj₂ y) = dec₁₂
dec (inj₂ x) (inj₁ y) = no (λ())
_⊎-<-total_ : ∀ {a₁} {≤₁ : Rel a₁} → Total ≤₁ →
∀ {a₂} {≤₂ : Rel a₂} → Total ≤₂ →
Total (≤₁ ⊎-< ≤₂)
total₁ ⊎-<-total total₂ = total
where
total : Total (_ ⊎-< _)
total (inj₁ x) (inj₁ y) = Sum.map ₁∼₁ ₁∼₁ $ total₁ x y
total (inj₂ x) (inj₂ y) = Sum.map ₂∼₂ ₂∼₂ $ total₂ x y
total (inj₁ x) (inj₂ y) = inj₁ (₁∼₂ _)
total (inj₂ x) (inj₁ y) = inj₂ (₁∼₂ _)
_⊎-<-trichotomous_ : ∀ {a₁} {≈₁ <₁ : Rel a₁} → Trichotomous ≈₁ <₁ →
∀ {a₂} {≈₂ <₂ : Rel a₂} → Trichotomous ≈₂ <₂ →
Trichotomous (≈₁ ⊎-Rel ≈₂) (<₁ ⊎-< <₂)
_⊎-<-trichotomous_ {≈₁ = ≈₁} {<₁ = <₁} tri₁
{≈₂ = ≈₂} {<₂ = <₂} tri₂ = tri
where
tri : Trichotomous (≈₁ ⊎-Rel ≈₂) (<₁ ⊎-< <₂)
tri (inj₁ x) (inj₂ y) = tri< (₁∼₂ _) ₁≁₂ (λ())
tri (inj₂ x) (inj₁ y) = tri> (λ()) (λ()) (₁∼₂ _)
tri (inj₁ x) (inj₁ y) with tri₁ x y
... | tri< x<y x≉y x≯y =
tri< (₁∼₁ x<y) (x≉y ∘ drop-inj₁) (x≯y ∘ drop-inj₁)
... | tri≈ x≮y x≈y x≯y =
tri≈ (x≮y ∘ drop-inj₁) (₁∼₁ x≈y) (x≯y ∘ drop-inj₁)
... | tri> x≮y x≉y x>y =
tri> (x≮y ∘ drop-inj₁) (x≉y ∘ drop-inj₁) (₁∼₁ x>y)
tri (inj₂ x) (inj₂ y) with tri₂ x y
... | tri< x<y x≉y x≯y =
tri< (₂∼₂ x<y) (x≉y ∘ drop-inj₂) (x≯y ∘ drop-inj₂)
... | tri≈ x≮y x≈y x≯y =
tri≈ (x≮y ∘ drop-inj₂) (₂∼₂ x≈y) (x≯y ∘ drop-inj₂)
... | tri> x≮y x≉y x>y =
tri> (x≮y ∘ drop-inj₂) (x≉y ∘ drop-inj₂) (₂∼₂ x>y)
------------------------------------------------------------------------
-- Some collections of properties which are preserved
_⊎-isEquivalence_ : ∀ {a₁} {≈₁ : Rel a₁} → IsEquivalence ≈₁ →
∀ {a₂} {≈₂ : Rel a₂} → IsEquivalence ≈₂ →
IsEquivalence (≈₁ ⊎-Rel ≈₂)
eq₁ ⊎-isEquivalence eq₂ = record
{ refl = refl eq₁ ⊎-refl refl eq₂
; sym = sym eq₁ ⊎-symmetric sym eq₂
; trans = trans eq₁ ⊎-transitive trans eq₂
}
where open IsEquivalence
_⊎-isPreorder_ : ∀ {a₁} {≈₁ ∼₁ : Rel a₁} → IsPreorder ≈₁ ∼₁ →
∀ {a₂} {≈₂ ∼₂ : Rel a₂} → IsPreorder ≈₂ ∼₂ →
∀ {P} → IsPreorder (≈₁ ⊎-Rel ≈₂) (⊎ʳ P ∼₁ ∼₂)
pre₁ ⊎-isPreorder pre₂ = record
{ isEquivalence = isEquivalence pre₁ ⊎-isEquivalence
isEquivalence pre₂
; reflexive = reflexive pre₁ ⊎-reflexive reflexive pre₂
; trans = trans pre₁ ⊎-transitive trans pre₂
; ∼-resp-≈ = ∼-resp-≈ pre₁ ⊎-≈-respects₂ ∼-resp-≈ pre₂
}
where open IsPreorder
_⊎-isDecEquivalence_ : ∀ {a₁} {≈₁ : Rel a₁} → IsDecEquivalence ≈₁ →
∀ {a₂} {≈₂ : Rel a₂} → IsDecEquivalence ≈₂ →
IsDecEquivalence (≈₁ ⊎-Rel ≈₂)
eq₁ ⊎-isDecEquivalence eq₂ = record
{ isEquivalence = isEquivalence eq₁ ⊎-isEquivalence
isEquivalence eq₂
; _≟_ = ⊎-decidable (_≟_ eq₁) (_≟_ eq₂) (no ₁≁₂)
}
where open IsDecEquivalence
_⊎-isPartialOrder_ : ∀ {a₁} {≈₁ ≤₁ : Rel a₁} → IsPartialOrder ≈₁ ≤₁ →
∀ {a₂} {≈₂ ≤₂ : Rel a₂} → IsPartialOrder ≈₂ ≤₂ →
∀ {P} → IsPartialOrder (≈₁ ⊎-Rel ≈₂) (⊎ʳ P ≤₁ ≤₂)
po₁ ⊎-isPartialOrder po₂ = record
{ isPreorder = isPreorder po₁ ⊎-isPreorder isPreorder po₂
; antisym = antisym po₁ ⊎-antisymmetric antisym po₂
}
where open IsPartialOrder
_⊎-isStrictPartialOrder_ :
∀ {a₁} {≈₁ <₁ : Rel a₁} → IsStrictPartialOrder ≈₁ <₁ →
∀ {a₂} {≈₂ <₂ : Rel a₂} → IsStrictPartialOrder ≈₂ <₂ →
∀ {P} → IsStrictPartialOrder (≈₁ ⊎-Rel ≈₂) (⊎ʳ P <₁ <₂)
spo₁ ⊎-isStrictPartialOrder spo₂ = record
{ isEquivalence = isEquivalence spo₁ ⊎-isEquivalence
isEquivalence spo₂
; irrefl = irrefl spo₁ ⊎-irreflexive irrefl spo₂
; trans = trans spo₁ ⊎-transitive trans spo₂
; <-resp-≈ = <-resp-≈ spo₁ ⊎-≈-respects₂ <-resp-≈ spo₂
}
where open IsStrictPartialOrder
_⊎-<-isTotalOrder_ : ∀ {a₁} {≈₁ ≤₁ : Rel a₁} → IsTotalOrder ≈₁ ≤₁ →
∀ {a₂} {≈₂ ≤₂ : Rel a₂} → IsTotalOrder ≈₂ ≤₂ →
IsTotalOrder (≈₁ ⊎-Rel ≈₂) (≤₁ ⊎-< ≤₂)
to₁ ⊎-<-isTotalOrder to₂ = record
{ isPartialOrder = isPartialOrder to₁ ⊎-isPartialOrder
isPartialOrder to₂
; total = total to₁ ⊎-<-total total to₂
}
where open IsTotalOrder
_⊎-<-isDecTotalOrder_ :
∀ {a₁} {≈₁ ≤₁ : Rel a₁} → IsDecTotalOrder ≈₁ ≤₁ →
∀ {a₂} {≈₂ ≤₂ : Rel a₂} → IsDecTotalOrder ≈₂ ≤₂ →
IsDecTotalOrder (≈₁ ⊎-Rel ≈₂) (≤₁ ⊎-< ≤₂)
to₁ ⊎-<-isDecTotalOrder to₂ = record
{ isTotalOrder = isTotalOrder to₁ ⊎-<-isTotalOrder isTotalOrder to₂
; _≟_ = ⊎-decidable (_≟_ to₁) (_≟_ to₂) (no ₁≁₂)
; _≤?_ = ⊎-decidable (_≤?_ to₁) (_≤?_ to₂) (yes (₁∼₂ _))
}
where open IsDecTotalOrder
------------------------------------------------------------------------
-- The game can be taken even further...
_⊎-setoid_ : Setoid → Setoid → Setoid
s₁ ⊎-setoid s₂ = record
{ isEquivalence = isEquivalence s₁ ⊎-isEquivalence isEquivalence s₂
} where open Setoid
_⊎-preorder_ : Preorder → Preorder → Preorder
p₁ ⊎-preorder p₂ = record
{ _∼_ = _∼_ p₁ ⊎-Rel _∼_ p₂
; isPreorder = isPreorder p₁ ⊎-isPreorder isPreorder p₂
} where open Preorder
_⊎-decSetoid_ : DecSetoid → DecSetoid → DecSetoid
ds₁ ⊎-decSetoid ds₂ = record
{ isDecEquivalence = isDecEquivalence ds₁ ⊎-isDecEquivalence
isDecEquivalence ds₂
} where open DecSetoid
_⊎-poset_ : Poset → Poset → Poset
po₁ ⊎-poset po₂ = record
{ _≤_ = _≤_ po₁ ⊎-Rel _≤_ po₂
; isPartialOrder = isPartialOrder po₁ ⊎-isPartialOrder
isPartialOrder po₂
} where open Poset
_⊎-<-poset_ : Poset → Poset → Poset
po₁ ⊎-<-poset po₂ = record
{ _≤_ = _≤_ po₁ ⊎-< _≤_ po₂
; isPartialOrder = isPartialOrder po₁ ⊎-isPartialOrder
isPartialOrder po₂
} where open Poset
_⊎-<-strictPartialOrder_ :
StrictPartialOrder → StrictPartialOrder → StrictPartialOrder
spo₁ ⊎-<-strictPartialOrder spo₂ = record
{ _<_ = _<_ spo₁ ⊎-< _<_ spo₂
; isStrictPartialOrder = isStrictPartialOrder spo₁
⊎-isStrictPartialOrder
isStrictPartialOrder spo₂
} where open StrictPartialOrder
_⊎-<-totalOrder_ : TotalOrder → TotalOrder → TotalOrder
to₁ ⊎-<-totalOrder to₂ = record
{ isTotalOrder = isTotalOrder to₁ ⊎-<-isTotalOrder isTotalOrder to₂
} where open TotalOrder
_⊎-<-decTotalOrder_ : DecTotalOrder → DecTotalOrder → DecTotalOrder
to₁ ⊎-<-decTotalOrder to₂ = record
{ isDecTotalOrder = isDecTotalOrder to₁ ⊎-<-isDecTotalOrder
isDecTotalOrder to₂
} where open DecTotalOrder
| {
"alphanum_fraction": 0.4909940983,
"avg_line_length": 37.2771428571,
"ext": "agda",
"hexsha": "3dcf085852969381a79840cd62f631be7e677cbd",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/Sum.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/Sum.agda",
"max_line_length": 72,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/Sum.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 5993,
"size": 13047
} |
{-# OPTIONS --without-K #-}
module FinVec where
-- This is the second step in building a representation of
-- permutations. We use permutations expressed as equivalences (in
-- FinVec) to construct one-line notation for permutations. We have
-- enough structure to model a commutative semiring EXCEPT for
-- symmetry. This will be addressed in ConcretePermutation.
import Level using (zero)
open import Data.Nat using (ℕ; _+_; _*_)
open import Data.Fin using (Fin)
open import Data.Sum
using (_⊎_; inj₁; inj₂)
renaming (map to map⊎)
open import Data.Product using (_×_; proj₁; proj₂; _,′_)
open import Data.Vec
using (Vec; allFin; tabulate; _>>=_)
renaming (_++_ to _++V_; map to mapV)
open import Algebra using (CommutativeSemiring)
open import Algebra.Structures using
(IsSemigroup; IsCommutativeMonoid; IsCommutativeSemiring)
open import Relation.Binary using (IsEquivalence)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; cong; cong₂; module ≡-Reasoning)
open import Function using (_∘_; id)
--
open import Equiv using (_∼_; p∘!p≡id)
open import TypeEquiv using (swap₊)
open import FinEquivPlusTimes using (module Plus; module Times)
open import FinEquivTypeEquiv using (module PlusE; module TimesE; module PlusTimesE)
open import Proofs using (
-- FiniteFunctions
finext;
-- VectorLemmas
_!!_; tabulate-split
)
------------------------------------------------------------------------------
-- The main goal is to represent permutations in the one-line notation
-- and to develop all the infrastructure to get a commutative
-- semiring, e.g., we can take unions and products of such one-line
-- notations of permutations, etc.
-- This is the type representing permutations in the one-line
-- notation. We will show that it is a commutative semiring
FinVec : ℕ → ℕ → Set
FinVec m n = Vec (Fin m) n
-- The additive and multiplicative units are trivial
1C : {n : ℕ} → FinVec n n
1C {n} = allFin n
-- corresponds to ⊥ ≃ ⊥ × A and other impossibilities but don't use
-- it, as it is abstract and will confuse external proofs!
abstract
0C : FinVec 0 0
0C = 1C {0}
-- sequential composition (transitivity)
_∘̂_ : {n₀ n₁ n₂ : ℕ} → Vec (Fin n₁) n₀ → Vec (Fin n₂) n₁ → Vec (Fin n₂) n₀
π₁ ∘̂ π₂ = tabulate (_!!_ π₂ ∘ _!!_ π₁)
------------------------------------------------------------------------------
-- Additive monoid
private
_⊎v_ : ∀ {m n} {A B : Set} → Vec A m → Vec B n → Vec (A ⊎ B) (m + n)
α ⊎v β = tabulate (inj₁ ∘ _!!_ α) ++V tabulate (inj₂ ∘ _!!_ β)
-- Parallel additive composition
-- conceptually, what we want is
_⊎c'_ : ∀ {m₁ n₁ m₂ n₂} → FinVec m₁ m₂ → FinVec n₁ n₂ →
FinVec (m₁ + n₁) (m₂ + n₂)
_⊎c'_ α β = mapV Plus.fwd (α ⊎v β)
-- but the above is tedious to work with. Instead, inline a bit to get
_⊎c_ : ∀ {m₁ n₁ m₂ n₂} → FinVec m₁ m₂ → FinVec n₁ n₂ →
FinVec (m₁ + n₁) (m₂ + n₂)
_⊎c_ {m₁} α β = tabulate (Plus.fwd ∘ inj₁ ∘ _!!_ α) ++V
tabulate (Plus.fwd {m₁} ∘ inj₂ ∘ _!!_ β)
-- see ⊎c≡⊎c' lemma below
_⊎fv_ : ∀ {m₁ n₁ m₂ n₂} → FinVec m₁ m₂ → FinVec n₁ n₂ →
FinVec (m₁ + n₁) (m₂ + n₂)
_⊎fv_ {m₁} α β =
tabulate (λ j → Plus.fwd (map⊎ (_!!_ α) (_!!_ β) (Plus.bwd j)))
⊎-equiv : ∀ {m₁ n₁ m₂ n₂} → (α : FinVec m₁ m₂) → (β : FinVec n₁ n₂) →
α ⊎c β ≡ α ⊎fv β
⊎-equiv {m₁} {n₁} {m₂} {n₂} α β =
let mm s = map⊎ (_!!_ α) (_!!_ β) s in
let g = Plus.fwd ∘ mm ∘ Plus.bwd in
begin (
tabulate (λ j → Plus.fwd (inj₁ (α !! j))) ++V
tabulate (λ j → Plus.fwd {m₁} (inj₂ (β !! j)))
≡⟨ refl ⟩ -- map⊎ evaluates on inj₁/inj₂
tabulate (Plus.fwd ∘ mm ∘ inj₁) ++V tabulate (Plus.fwd ∘ mm ∘ inj₂)
≡⟨ cong₂ _++V_
(finext (λ i → cong (Plus.fwd ∘ mm)
(sym (Plus.bwd∘fwd~id (inj₁ i)))))
(finext (λ i → cong (Plus.fwd ∘ mm)
(sym (Plus.bwd∘fwd~id (inj₂ i))))) ⟩
tabulate {m₂} (g ∘ Plus.fwd ∘ inj₁) ++V
tabulate {n₂} (g ∘ Plus.fwd {m₂} ∘ inj₂)
≡⟨ sym (tabulate-split {m₂} {n₂} {f = g}) ⟩
tabulate g ∎)
where
open ≡-Reasoning
-- additive units
unite+ : {m : ℕ} → FinVec m (0 + m)
unite+ {m} = tabulate (proj₁ (PlusE.unite+ {m}))
uniti+ : {m : ℕ} → FinVec (0 + m) m
uniti+ {m} = tabulate (proj₁ (PlusE.uniti+ {m}))
unite+r : {m : ℕ} → FinVec m (m + 0)
unite+r {m} = tabulate (proj₁ (PlusE.unite+r {m}))
-- unite+r' : {m : ℕ} → FinVec m (m + 0)
-- unite+r' {m} = tabulate (proj₁ (PlusE.unite+r' {m}))
uniti+r : {m : ℕ} → FinVec (m + 0) m
uniti+r {m} = tabulate (proj₁ (PlusE.uniti+r {m}))
-- commutativity
-- swap the first m elements with the last n elements
-- [ v₀ , v₁ , v₂ , ... , vm-1 , vm , vm₊₁ , ... , vm+n-1 ]
-- ==>
-- [ vm , vm₊₁ , ... , vm+n-1 , v₀ , v₁ , v₂ , ... , vm-1 ]
-- swap+cauchy : (m n : ℕ) → FinVec (n + m) (m + n)
-- swap+cauchy m n = tabulate (Plus.swapper m n)
-- associativity
assocl+ : {m n o : ℕ} → FinVec ((m + n) + o) (m + (n + o))
assocl+ {m} {n} {o} = tabulate (proj₁ (PlusE.assocl+ {m} {n} {o}))
assocr+ : {m n o : ℕ} → FinVec (m + (n + o)) (m + n + o)
assocr+ {m} {n} {o} = tabulate (proj₁ (PlusE.assocr+ {m} {n} {o}))
------------------------------------------------------------------------------
-- Multiplicative monoid
private
_×v_ : ∀ {m n} {A B : Set} → Vec A m → Vec B n → Vec (A × B) (m * n)
α ×v β = α >>= (λ b → mapV (_,′_ b) β)
-- Tensor multiplicative composition
-- Transpositions in α correspond to swapping entire rows
-- Transpositions in β correspond to swapping entire columns
_×c_ : ∀ {m₁ n₁ m₂ n₂} → FinVec m₁ m₂ → FinVec n₁ n₂ →
FinVec (m₁ * n₁) (m₂ * n₂)
α ×c β = mapV Times.fwd (α ×v β)
-- multiplicative units
unite* : {m : ℕ} → FinVec m (1 * m)
unite* {m} = tabulate (proj₁ (TimesE.unite* {m}))
uniti* : {m : ℕ} → FinVec (1 * m) m
uniti* {m} = tabulate (proj₁ (TimesE.uniti* {m}))
unite*r : {m : ℕ} → FinVec m (m * 1)
unite*r {m} = tabulate (proj₁ (TimesE.unite*r {m}))
uniti*r : {m : ℕ} → FinVec (m * 1) m
uniti*r {m} = tabulate (proj₁ (TimesE.uniti*r {m}))
-- commutativity
-- swap⋆
--
-- This is essentially the classical problem of in-place matrix transpose:
-- "http://en.wikipedia.org/wiki/In-place_matrix_transposition"
-- Given m and n, the desired permutation in Cauchy representation is:
-- P(i) = m*n-1 if i=m*n-1
-- = m*i mod m*n-1 otherwise
-- transposeIndex : {m n : ℕ} → Fin m × Fin n → Fin (n * m)
-- transposeIndex = Times.fwd ∘ swap
-- inject≤ (fromℕ (toℕ d * m + toℕ b)) (i*n+k≤m*n d b)
-- swap⋆cauchy : (m n : ℕ) → FinVec (n * m) (m * n)
-- swap⋆cauchy m n = tabulate (Times.swapper m n)
-- mapV transposeIndex (V.tcomp 1C 1C)
-- associativity
assocl* : {m n o : ℕ} → FinVec ((m * n) * o) (m * (n * o))
assocl* {m} {n} {o} = tabulate (proj₁ (TimesE.assocl* {m} {n} {o}))
assocr* : {m n o : ℕ} → FinVec (m * (n * o)) (m * n * o)
assocr* {m} {n} {o} = tabulate (proj₁ (TimesE.assocr* {m} {n} {o}))
------------------------------------------------------------------------------
-- Distributivity
dist*+ : ∀ {m n o} → FinVec (m * o + n * o) ((m + n) * o)
dist*+ {m} {n} {o} = tabulate (proj₁ (PlusTimesE.dist {m} {n} {o}))
factor*+ : ∀ {m n o} → FinVec ((m + n) * o) (m * o + n * o)
factor*+ {m} {n} {o} = tabulate (proj₁ (PlusTimesE.factor {m} {n} {o}))
distl*+ : ∀ {m n o} → FinVec (m * n + m * o) (m * (n + o))
distl*+ {m} {n} {o} = tabulate (proj₁ (PlusTimesE.distl {m} {n} {o}))
factorl*+ : ∀ {m n o} → FinVec (m * (n + o)) (m * n + m * o)
factorl*+ {m} {n} {o} = tabulate (proj₁ (PlusTimesE.factorl {m} {n} {o}))
right-zero*l : ∀ {m} → FinVec 0 (m * 0)
right-zero*l {m} = tabulate (proj₁ (PlusTimesE.distzr {m}))
right-zero*r : ∀ {m} → FinVec (m * 0) 0
right-zero*r {m} = tabulate (proj₁ (PlusTimesE.factorzr {m}))
------------------------------------------------------------------------------
-- Putting it all together, we have a commutative semiring structure
-- (modulo symmetry)
_cauchy≃_ : (m n : ℕ) → Set
m cauchy≃ n = FinVec m n
id-iso : {m : ℕ} → FinVec m m
id-iso = 1C
-- This is only here to show that we do have everything for a
-- commutative semiring structure EXCEPT for symmetry; this is
-- addressed in ConcretePermutation
postulate sym-iso : {m n : ℕ} → FinVec m n → FinVec n m
trans-iso : {m n o : ℕ} → FinVec m n → FinVec n o → FinVec m o
trans-iso c₁ c₂ = c₂ ∘̂ c₁
cauchy≃IsEquiv : IsEquivalence {Level.zero} {Level.zero} {ℕ} _cauchy≃_
cauchy≃IsEquiv = record {
refl = id-iso ;
sym = sym-iso ;
trans = trans-iso
}
cauchyPlusIsSG : IsSemigroup {Level.zero} {Level.zero} {ℕ} _cauchy≃_ _+_
cauchyPlusIsSG = record {
isEquivalence = cauchy≃IsEquiv ;
assoc = λ m n o → assocl+ {m} {n} {o} ;
∙-cong = _⊎c_
}
cauchyTimesIsSG : IsSemigroup {Level.zero} {Level.zero} {ℕ} _cauchy≃_ _*_
cauchyTimesIsSG = record {
isEquivalence = cauchy≃IsEquiv ;
assoc = λ m n o → assocl* {m} {n} {o} ;
∙-cong = _×c_
}
{--
cauchyPlusIsCM : IsCommutativeMonoid _cauchy≃_ _+_ 0
cauchyPlusIsCM = record {
isSemigroup = cauchyPlusIsSG ;
identityˡ = λ m → 1C ;
comm = λ m n → swap+cauchy n m
}
cauchyTimesIsCM : IsCommutativeMonoid _cauchy≃_ _*_ 1
cauchyTimesIsCM = record {
isSemigroup = cauchyTimesIsSG ;
identityˡ = λ m → uniti* {m} ;
comm = λ m n → swap⋆cauchy n m
}
cauchyIsCSR : IsCommutativeSemiring _cauchy≃_ _+_ _*_ 0 1
cauchyIsCSR = record {
+-isCommutativeMonoid = cauchyPlusIsCM ;
*-isCommutativeMonoid = cauchyTimesIsCM ;
distribʳ = λ o m n → factor*+ {m} {n} {o} ;
zeroˡ = λ m → 0C
}
cauchyCSR : CommutativeSemiring Level.zero Level.zero
cauchyCSR = record {
Carrier = ℕ ;
_≈_ = _cauchy≃_ ;
_+_ = _+_ ;
_*_ = _*_ ;
0# = 0 ;
1# = 1 ;
isCommutativeSemiring = cauchyIsCSR
}
--}
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.571501794,
"avg_line_length": 30.8702531646,
"ext": "agda",
"hexsha": "d6c2a01b9c270add0ab1648b935fe280fb614e7e",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "Univalence/FinVec.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "Univalence/FinVec.agda",
"max_line_length": 84,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "Univalence/FinVec.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
"num_tokens": 3731,
"size": 9755
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- List Zippers, basic types and operations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Zipper where
open import Data.Nat.Base
open import Data.Maybe.Base as Maybe using (Maybe ; just ; nothing)
open import Data.List.Base as List using (List ; [] ; _∷_)
open import Function
-- Definition
------------------------------------------------------------------------
-- A List Zipper represents a List together with a particular sub-List
-- in focus. The user can attempt to move the focus left or right, with
-- a risk of failure if one has already reached the corresponding end.
-- To make these operations efficient, the `context` the sub List in
-- focus lives in is stored *backwards*. This is made formal by `toList`
-- which returns the List a Zipper represents.
record Zipper {a} (A : Set a) : Set a where
constructor mkZipper
field context : List A
value : List A
toList : List A
toList = List.reverse context List.++ value
open Zipper public
-- Embedding Lists as Zippers without any context
fromList : ∀ {a} {A : Set a} → List A → Zipper A
fromList = mkZipper []
-- Fundamental operations of a Zipper: Moving around
------------------------------------------------------------------------
module _ {a} {A : Set a} where
left : Zipper A → Maybe (Zipper A)
left (mkZipper [] val) = nothing
left (mkZipper (x ∷ ctx) val) = just (mkZipper ctx (x ∷ val))
right : Zipper A → Maybe (Zipper A)
right (mkZipper ctx []) = nothing
right (mkZipper ctx (x ∷ val)) = just (mkZipper (x ∷ ctx) val)
-- Focus-respecting operations
------------------------------------------------------------------------
module _ {a} {A : Set a} where
reverse : Zipper A → Zipper A
reverse (mkZipper ctx val) = mkZipper val ctx
-- If we think of a List [x₁⋯xₘ] split into a List [xₙ₊₁⋯xₘ] in focus
-- of another list [x₁⋯xₙ] then there are 4 places (marked {k} here) in
-- which we can insert new values: [{1}x₁⋯xₙ{2}][{3}xₙ₊₁⋯xₘ{4}]
-- The following 4 functions implement these 4 insertions.
-- `xs ˢ++ zp` inserts `xs` on the `s` side of the context of the Zipper `zp`
-- `zp ++ˢ xs` insert `xs` on the `s` side of the value in focus of the Zipper `zp`
infixr 5 _ˡ++_ _ʳ++_
infixl 5 _++ˡ_ _++ʳ_
-- {1}
_ˡ++_ : List A → Zipper A → Zipper A
xs ˡ++ mkZipper ctx val = mkZipper (ctx List.++ List.reverse xs) val
-- {2}
_ʳ++_ : List A → Zipper A → Zipper A
xs ʳ++ mkZipper ctx val = mkZipper (List.reverse xs List.++ ctx) val
-- {3}
_++ˡ_ : Zipper A → List A → Zipper A
mkZipper ctx val ++ˡ xs = mkZipper ctx (xs List.++ val)
-- {4}
_++ʳ_ : Zipper A → List A → Zipper A
mkZipper ctx val ++ʳ xs = mkZipper ctx (val List.++ xs)
-- List-like operations
------------------------------------------------------------------------
module _ {a} {A : Set a} where
length : Zipper A → ℕ
length (mkZipper ctx val) = List.length ctx + List.length val
module _ {a b} {A : Set a} {B : Set b} where
map : (A → B) → Zipper A → Zipper B
map f (mkZipper ctx val) = (mkZipper on List.map f) ctx val
foldr : (A → B → B) → B → Zipper A → B
foldr c n (mkZipper ctx val) = List.foldl (flip c) (List.foldr c n val) ctx
-- Generating all the possible foci of a list
------------------------------------------------------------------------
module _ {a} {A : Set a} where
allFociIn : List A → List A → List (Zipper A)
allFociIn ctx [] = List.[ mkZipper ctx [] ]
allFociIn ctx xxs@(x ∷ xs) = mkZipper ctx xxs ∷ allFociIn (x ∷ ctx) xs
allFoci : List A → List (Zipper A)
allFoci = allFociIn []
| {
"alphanum_fraction": 0.5629014989,
"avg_line_length": 31.3949579832,
"ext": "agda",
"hexsha": "51e24e14a42645846e1ef7c9be8fc290d7a5438d",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Zipper.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Zipper.agda",
"max_line_length": 84,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Zipper.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 1100,
"size": 3736
} |
-- AIM XXIII, Andreas, 2016-04-24
-- Overloaded projections and projection patterns
-- {-# OPTIONS -v tc.proj.amb:30 #-}
-- {-# OPTIONS -v tc.lhs.split:20 #-}
module _ where
import Common.Level
open import Common.Prelude hiding (map)
open import Common.Equality
module M (A : Set) where
record Stream : Set where
coinductive
field
head : A
tail : Stream
open M using (Stream)
open module S = M.Stream public
-- This is a bit trickier for overloading projections
-- as it has a parameter with is of a record type
-- with the same projections.
record _≈_ {A : Set}(s t : Stream A) : Set where
coinductive
field
head : head s ≡ head t
tail : tail s ≈ tail t
open module B = _≈_ public
≈refl : ∀{A} {s : Stream A} → s ≈ s
head ≈refl = refl
tail ≈refl = ≈refl
≈sym : ∀{A} {s t : Stream A} → s ≈ t → t ≈ s
head (≈sym p) = sym (head p)
tail (≈sym p) = ≈sym (tail p)
module N (A : Set) (s : Stream A) where
open module SS = Stream s public
myhead : A
myhead = SS.head -- cannot use ambiguous head here
map : {A B : Set} → (A → B) → Stream A → Stream B
head (map f s) = f (head s)
tail (map f s) = map f (tail s)
map_id : {A : Set}(s : Stream A) → map (λ x → x) s ≈ s
head (map_id s) = refl
tail (map_id s) = map_id (tail s)
repeat : {A : Set}(a : A) → Stream A
head (repeat a) = a
tail (repeat a) = repeat a
repeat₂ : {A : Set}(a₁ a₂ : A) → Stream A
( (head (repeat₂ a₁ a₂))) = a₁
(head (tail (repeat₂ a₁ a₂))) = a₂
(tail (tail (repeat₂ a₁ a₂))) = repeat₂ a₁ a₂
repeat≈repeat₂ : {A : Set}(a : A) → repeat a ≈ repeat₂ a a
( (head (repeat≈repeat₂ a))) = refl
(head (tail (repeat≈repeat₂ a))) = refl
(tail (tail (repeat≈repeat₂ a))) = repeat≈repeat₂ a
| {
"alphanum_fraction": 0.6158357771,
"avg_line_length": 25.0735294118,
"ext": "agda",
"hexsha": "dc4e0198522b7723157fe9303e35c9d38eb6263a",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Succeed/Issue1944-Stream.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Succeed/Issue1944-Stream.agda",
"max_line_length": 58,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Succeed/Issue1944-Stream.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 617,
"size": 1705
} |
{-# OPTIONS --rewriting --without-K #-}
open import Agda.Primitive
open import Prelude
import GSeTT.Typed-Syntax
import Globular-TT.Syntax
{- Structure of CwF of a globular type theory : Cut admissibility is significantly harder and has to be proved together with it -}
module Globular-TT.CwF-Structure {l} (index : Set l) (rule : index → GSeTT.Typed-Syntax.Ctx × (Globular-TT.Syntax.Pre-Ty index)) where
open import Globular-TT.Syntax index
open import Globular-TT.Rules index rule
A∈Γ→Γ⊢A : ∀ {Γ x A} → Γ ⊢C → x # A ∈ Γ → Γ ⊢T A
A∈Γ→Γ⊢A Γ+⊢@(cc Γ⊢ Γ⊢B idp) (inl A∈Γ) = wkT (A∈Γ→Γ⊢A Γ⊢ A∈Γ) Γ+⊢
A∈Γ→Γ⊢A Γ+⊢@(cc Γ⊢ Γ⊢A idp) (inr (idp , idp)) = wkT Γ⊢A Γ+⊢
{- cut-admissibility -}
-- notational shortcut : if A = B a term of type A is also of type B
trT : ∀ {Γ A B t} → A == B → Γ ⊢t t # A → Γ ⊢t t # B
trT idp Γ⊢t:A = Γ⊢t:A
{- action on weakened types and terms -}
n∉Γ : ∀ {Γ A n} → Γ ⊢C → (C-length Γ ≤ n) → ¬ (n # A ∈ Γ)
n∉Γ (cc Γ⊢ _ idp) l+1≤n (inl n∈Γ) = n∉Γ Γ⊢ (Sn≤m→n≤m l+1≤n) n∈Γ
n∉Γ (cc Γ⊢ _ idp) Sn≤n (inr (idp , idp)) = Sn≰n _ Sn≤n
lΓ∉Γ : ∀ {Γ A} → Γ ⊢C → ¬ ((C-length Γ) # A ∈ Γ)
lΓ∉Γ Γ⊢ = n∉Γ Γ⊢ (n≤n _)
wk[]T : ∀ {Γ Δ γ x u A B} → Γ ⊢T A → Δ ⊢S < γ , x ↦ u > > (Γ ∙ x # B) → (A [ < γ , x ↦ u > ]Pre-Ty) == (A [ γ ]Pre-Ty)
wk[]t : ∀ {Γ Δ γ x u A t B} → Γ ⊢t t # A → Δ ⊢S < γ , x ↦ u > > (Γ ∙ x # B) → (t [ < γ , x ↦ u > ]Pre-Tm) == (t [ γ ]Pre-Tm)
wk[]S : ∀ {Γ Δ γ x u B Θ θ} → Γ ⊢S θ > Θ → Δ ⊢S < γ , x ↦ u > > (Γ ∙ x # B) → (θ ∘ < γ , x ↦ u >) == (θ ∘ γ)
[]T : ∀ {Γ A Δ γ} → Γ ⊢T A → Δ ⊢S γ > Γ → Δ ⊢T (A [ γ ]Pre-Ty)
[]t : ∀ {Γ A t Δ γ} → Γ ⊢t t # A → Δ ⊢S γ > Γ → Δ ⊢t (t [ γ ]Pre-Tm) # (A [ γ ]Pre-Ty)
[∘]T : ∀ {Γ Δ Θ A γ δ} → Γ ⊢T A → Δ ⊢S γ > Γ → Θ ⊢S δ > Δ → ((A [ γ ]Pre-Ty) [ δ ]Pre-Ty) == (A [ γ ∘ δ ]Pre-Ty)
[∘]t : ∀ {Γ Δ Θ A t γ δ} → Γ ⊢t t # A → Δ ⊢S γ > Γ → Θ ⊢S δ > Δ → ((t [ γ ]Pre-Tm) [ δ ]Pre-Tm) == (t [ γ ∘ δ ]Pre-Tm)
∘-admissibility : ∀ {Γ Δ Θ γ δ} → Δ ⊢S γ > Γ → Θ ⊢S δ > Δ → Θ ⊢S (γ ∘ δ) > Γ
∘-associativity : ∀ {Γ Δ Θ Ξ γ δ θ} → Δ ⊢S γ > Γ → Θ ⊢S δ > Δ → Ξ ⊢S θ > Θ → ((γ ∘ δ) ∘ θ) == (γ ∘ (δ ∘ θ))
wk[]T (ob Γ⊢) _ = idp
wk[]T (ar Γ⊢A Γ⊢t:A Γ⊢u:A) Δ⊢γ+:Γ+ = ⇒= (wk[]T Γ⊢A Δ⊢γ+:Γ+) (wk[]t Γ⊢t:A Δ⊢γ+:Γ+) (wk[]t Γ⊢u:A Δ⊢γ+:Γ+)
wk[]t {x = x} (var {x = y} Γ⊢ y∈Γ) Δ⊢γ+:Γ+ with (eqdecℕ y x)
... | inr _ = idp
wk[]t (var Γ⊢ l∈Γ) (sc Δ⊢γ:Γ (cc _ _ idp) _ _) | inl idp = ⊥-elim (lΓ∉Γ Γ⊢ l∈Γ)
wk[]t (tm _ Γ⊢θ:Θ idp) Δ⊢γ+:Γ+ = Tm-constructor= idp (wk[]S Γ⊢θ:Θ Δ⊢γ+:Γ+)
wk[]S (es _) _ = idp
wk[]S (sc Γ⊢θ:Θ _ Γ⊢t:A[θ] idp) Δ⊢γ+:Γ+ = <,>= (wk[]S Γ⊢θ:Θ Δ⊢γ+:Γ+) idp (wk[]t Γ⊢t:A[θ] Δ⊢γ+:Γ+)
[]T (ob Γ⊢) Δ⊢γ:Γ = ob (Δ⊢γ:Γ→Δ⊢ Δ⊢γ:Γ)
[]T (ar Γ⊢A Γ⊢t:A Γ⊢u:A) Δ⊢γ:Γ = ar ([]T Γ⊢A Δ⊢γ:Γ) ([]t Γ⊢t:A Δ⊢γ:Γ) ([]t Γ⊢u:A Δ⊢γ:Γ)
[]t {t = Tm-constructor i _} (tm Ci⊢Ti x idp) Δ⊢γ:Γ = trT ([∘]T Ci⊢Ti x Δ⊢γ:Γ ^) (tm Ci⊢Ti (∘-admissibility x Δ⊢γ:Γ) idp)
[]t {Γ = (Γ ∙ _ # _)} {t = Var x} (var Γ+⊢@(cc Γ⊢ _ idp) (inl x∈Γ)) Δ⊢γ+:Γ+@(sc Δ⊢γ:Γ _ _ idp) with (eqdecℕ x (C-length Γ))
... | inl idp = ⊥-elim (lΓ∉Γ Γ⊢ x∈Γ)
... | inr _ = trT (wk[]T (A∈Γ→Γ⊢A Γ⊢ x∈Γ) Δ⊢γ+:Γ+ ^) ([]t (var Γ⊢ x∈Γ) Δ⊢γ:Γ)
[]t {Γ = (Γ ∙ _ # _)} {t = Var x} (var Γ+⊢@(cc Γ⊢ Γ⊢A idp) (inr (idp , idp))) Δ⊢γ+:Γ+@(sc Δ⊢γ:Γ x₁ Δ⊢t:A[γ] idp) with (eqdecℕ x (C-length Γ))
... | inl p = trT (wk[]T Γ⊢A Δ⊢γ+:Γ+ ^) Δ⊢t:A[γ]
... | inr x≠x = ⊥-elim (x≠x idp)
[∘]T (ob _) _ _ = idp
[∘]T (ar Γ⊢A Γ⊢t:A Γ⊢u:A) Δ⊢γ:Γ Θ⊢δ:Δ = ⇒= ([∘]T Γ⊢A Δ⊢γ:Γ Θ⊢δ:Δ) ([∘]t Γ⊢t:A Δ⊢γ:Γ Θ⊢δ:Δ) ([∘]t Γ⊢u:A Δ⊢γ:Γ Θ⊢δ:Δ)
[∘]t (tm Ci⊢Ti x idp) Δ⊢γ:Γ Θ⊢δ:Δ = Tm-constructor= idp (∘-associativity x Δ⊢γ:Γ Θ⊢δ:Δ )
[∘]t (var {x = x} Γ,y:A⊢ x∈Γ+) (sc {x = y} Δ⊢γ:Γ _ Δ⊢t:A[γ] idp) Θ⊢δ:Δ with (eqdecℕ x y )
... | inl idp = idp
[∘]t (var Γ,y:A⊢ (inr (idp , idp))) (sc Δ⊢γ:Γ _ Δ⊢t:A[γ] idp) Θ⊢δ:Δ | inr x≠x = ⊥-elim (x≠x idp)
[∘]t (var (cc Γ⊢ _ idp) (inl x∈Γ)) (sc Δ⊢γ:Γ _ Δ⊢t:A[γ] idp) Θ⊢δ:Δ | inr _ = [∘]t (var Γ⊢ x∈Γ) Δ⊢γ:Γ Θ⊢δ:Δ
∘-admissibility (es Δ⊢) Θ⊢δ:Δ = es (Δ⊢γ:Γ→Δ⊢ Θ⊢δ:Δ)
∘-admissibility (sc Δ⊢γ:Γ Γ,x:A⊢@(cc _ Γ⊢A idp) Δ⊢t:A[γ] idp) Θ⊢δ:Δ = sc (∘-admissibility Δ⊢γ:Γ Θ⊢δ:Δ) Γ,x:A⊢ (trT ([∘]T Γ⊢A Δ⊢γ:Γ Θ⊢δ:Δ) ([]t Δ⊢t:A[γ] Θ⊢δ:Δ)) idp
∘-associativity (es _) _ _ = idp
∘-associativity (sc Δ⊢γ:Γ _ Δ⊢t:A[γ] idp) Θ⊢δ:Δ Ξ⊢θ:Θ = <,>= (∘-associativity Δ⊢γ:Γ Θ⊢δ:Δ Ξ⊢θ:Θ) idp ([∘]t Δ⊢t:A[γ] Θ⊢δ:Δ Ξ⊢θ:Θ)
Γ⊢t:A→Γ⊢A : ∀ {Γ A t} → Γ ⊢t t # A → Γ ⊢T A
Γ⊢t:A→Γ⊢A (var Γ,x:A⊢@(cc Γ⊢ Γ⊢A idp) (inl y∈Γ)) = wkT (Γ⊢t:A→Γ⊢A (var Γ⊢ y∈Γ)) Γ,x:A⊢
Γ⊢t:A→Γ⊢A (var Γ,x:A⊢@(cc _ _ idp) (inr (idp , idp))) = Γ,x:A⊢→Γ,x:A⊢A Γ,x:A⊢
Γ⊢t:A→Γ⊢A (tm Ci⊢Ti Γ⊢γ:Δ idp) = []T Ci⊢Ti Γ⊢γ:Δ
{- action of identity on types terms and substitutions is trivial (true on syntax) -}
[id]T : ∀ Γ A → (A [ Pre-id Γ ]Pre-Ty) == A
[id]t : ∀ Γ t → (t [ Pre-id Γ ]Pre-Tm) == t
∘-right-unit : ∀ {Δ γ} → (γ ∘ Pre-id Δ) == γ
[id]T Γ ∗ = idp
[id]T Γ (⇒ A t u) = ⇒= ([id]T Γ A) ([id]t Γ t) ([id]t Γ u)
[id]t Γ (Tm-constructor i γ) = Tm-constructor= idp ∘-right-unit
[id]t ⊘ (Var x) = idp
[id]t (Γ ∙ y # B) (Var x) with (eqdecℕ x y)
... | inl x=y = Var= (x=y ^)
... | inr _ = [id]t Γ (Var x)
∘-right-unit {Δ} {<>} = idp
∘-right-unit {Δ} {< γ , y ↦ t >} = <,>= ∘-right-unit idp ([id]t Δ t) -- ::= ∘-right-unit (×= idp ([id]t Δ t))
{- identity is well-formed -}
Γ⊢id:Γ : ∀ {Γ} → Γ ⊢C → Γ ⊢S Pre-id Γ > Γ
Γ⊢id:Γ ec = es ec
Γ⊢id:Γ Γ,x:A⊢@(cc Γ⊢ Γ⊢A idp) = sc (wkS (Γ⊢id:Γ Γ⊢) Γ,x:A⊢) Γ,x:A⊢ (var Γ,x:A⊢ (inr (idp , [id]T _ _))) idp
{- composition is associative -}
∘-left-unit : ∀{Γ Δ γ} → Δ ⊢S γ > Γ → (Pre-id Γ ∘ γ) == γ
∘-left-unit (es _) = idp
∘-left-unit Δ⊢γ+:Γ+@(sc {x = x} Δ⊢γ:Γ (cc Γ⊢ _ idp) _ idp) with (eqdecℕ x x)
... | inl p = <,>= (wk[]S (Γ⊢id:Γ Γ⊢) Δ⊢γ+:Γ+ >> ∘-left-unit Δ⊢γ:Γ) idp idp
... | inr x≠x = ⊥-elim (x≠x idp)
{- Structure of CwF -}
Γ,x:A⊢π:Γ : ∀ {Γ x A} → (Γ ∙ x # A) ⊢C → (Γ ∙ x # A) ⊢S Pre-π Γ x A > Γ
Γ,x:A⊢π:Γ Γ,x:A⊢@(cc Γ⊢ _ idp) = wkS (Γ⊢id:Γ Γ⊢) Γ,x:A⊢
-- TODO : finish
| {
"alphanum_fraction": 0.4173071011,
"avg_line_length": 55.6068376068,
"ext": "agda",
"hexsha": "f40c8ffe79f9489d7bb94584a62d61d2d9d1038c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thibautbenjamin/catt-formalization",
"max_forks_repo_path": "Globular-TT/CwF-Structure.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thibautbenjamin/catt-formalization",
"max_issues_repo_path": "Globular-TT/CwF-Structure.agda",
"max_line_length": 165,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thibautbenjamin/catt-formalization",
"max_stars_repo_path": "Globular-TT/CwF-Structure.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3921,
"size": 6506
} |
{-# OPTIONS --rewriting #-}
module Properties where
import Properties.Contradiction
import Properties.Dec
import Properties.Equality
import Properties.Remember
import Properties.Step
import Properties.StrictMode
import Properties.TypeCheck
| {
"alphanum_fraction": 0.8429752066,
"avg_line_length": 20.1666666667,
"ext": "agda",
"hexsha": "8b30ce12150aa29ab4ebd3259fc4754b2af6963b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "XanderYZZ/luau",
"max_forks_repo_path": "prototyping/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "XanderYZZ/luau",
"max_issues_repo_path": "prototyping/Properties.agda",
"max_line_length": 31,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "3f69d3a4f2b74dac8ecff2ef8ec851c8636324b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "gideros/luau",
"max_stars_repo_path": "prototyping/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-18T04:10:20.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-18T04:10:20.000Z",
"num_tokens": 44,
"size": 242
} |
------------------------------------------------------------------------
-- A simple tactic for proving equality of equality proofs
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Equality
module Equality.Tactic
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open Derived-definitions-and-properties eq
open import Prelude hiding (Level; lift; lower)
private
variable
a : Prelude.Level
A B : Type a
ℓ x y z : A
x≡y y≡z : x ≡ y
------------------------------------------------------------------------
-- Equality expressions
-- Equality expressions.
--
-- Note that the presence of the Refl constructor means that Eq is a
-- definition of equality with a concrete, evaluating eliminator.
data Eq {A : Type a} : A → A → Type (lsuc a) where
Lift : (x≡y : x ≡ y) → Eq x y
Refl : Eq x x
Sym : (x≈y : Eq x y) → Eq y x
Trans : (x≈y : Eq x y) (y≈z : Eq y z) → Eq x z
Cong : ∀ {B : Type a} {x y}
(f : B → A) (x≈y : Eq x y) → Eq (f x) (f y)
-- Semantics.
⟦_⟧ : Eq x y → x ≡ y
⟦ Lift x≡y ⟧ = x≡y
⟦ Refl ⟧ = refl _
⟦ Sym x≈y ⟧ = sym ⟦ x≈y ⟧
⟦ Trans x≈y y≈z ⟧ = trans ⟦ x≈y ⟧ ⟦ y≈z ⟧
⟦ Cong f x≈y ⟧ = cong f ⟦ x≈y ⟧
-- A derived combinator.
Cong₂ : {A B C : Type a} (f : A → B → C) {x y : A} {u v : B} →
Eq x y → Eq u v → Eq (f x u) (f y v)
Cong₂ f {y = y} {u} x≈y u≈v =
Trans (Cong (flip f u) x≈y) (Cong (f y) u≈v)
private
Cong₂-correct :
{A B C : Type a} (f : A → B → C) {x y : A} {u v : B}
(x≈y : Eq x y) (u≈v : Eq u v) →
⟦ Cong₂ f x≈y u≈v ⟧ ≡ cong₂ f ⟦ x≈y ⟧ ⟦ u≈v ⟧
Cong₂-correct f x≈y u≈v = refl _
------------------------------------------------------------------------
-- Simplified expressions
private
-- The simplified expressions are stratified into three levels.
data Level : Type where
upper middle lower : Level
data EqS {A : Type a} : Level → A → A → Type (lsuc a) where
-- Bottom layer: a single use of congruence applied to an actual
-- equality.
Cong : {B : Type a} {x y : B} (f : B → A) (x≡y : x ≡ y) →
EqS lower (f x) (f y)
-- Middle layer: at most one use of symmetry.
No-Sym : (x≈y : EqS lower x y) → EqS middle x y
Sym : (x≈y : EqS lower x y) → EqS middle y x
-- Uppermost layer: a sequence of equalities, combined using
-- transitivity and a single use of reflexivity.
Refl : EqS upper x x
Cons : (x≈y : EqS middle x y) (y≈z : EqS upper y z) →
EqS upper x z
-- Semantics of simplified expressions.
⟦_⟧S : EqS ℓ x y → x ≡ y
⟦ Cong f x≡y ⟧S = cong f x≡y
⟦ No-Sym x≈y ⟧S = ⟦ x≈y ⟧S
⟦ Sym x≈y ⟧S = sym ⟦ x≈y ⟧S
⟦ Refl ⟧S = refl _
⟦ Cons x≈y y≈z ⟧S = trans ⟦ x≈y ⟧S ⟦ y≈z ⟧S
------------------------------------------------------------------------
-- Manipulation of expressions
private
lift : x ≡ y → EqS upper x y
lift x≡y = Cons (No-Sym (Cong id x≡y)) Refl
abstract
lift-correct : (x≡y : x ≡ y) → x≡y ≡ ⟦ lift x≡y ⟧S
lift-correct x≡y =
x≡y ≡⟨ cong-id _ ⟩
cong id x≡y ≡⟨ sym (trans-reflʳ _) ⟩∎
trans (cong id x≡y) (refl _) ∎
snoc : EqS upper x y → EqS middle y z → EqS upper x z
snoc Refl y≈z = Cons y≈z Refl
snoc (Cons x≈y y≈z) z≈u = Cons x≈y (snoc y≈z z≈u)
abstract
snoc-correct :
(z≈y : EqS upper z y) (y≈x : EqS middle y x) →
sym y≡z ≡ ⟦ z≈y ⟧S → sym x≡y ≡ ⟦ y≈x ⟧S →
sym (trans x≡y y≡z) ≡ ⟦ snoc z≈y y≈x ⟧S
snoc-correct {y≡z = y≡z} {x≡y = x≡y} Refl y≈z h₁ h₂ =
sym (trans x≡y y≡z) ≡⟨ sym-trans _ _ ⟩
trans (sym y≡z) (sym x≡y) ≡⟨ cong₂ trans h₁ h₂ ⟩
trans (refl _) ⟦ y≈z ⟧S ≡⟨ trans-reflˡ _ ⟩
⟦ y≈z ⟧S ≡⟨ sym (trans-reflʳ _) ⟩∎
trans ⟦ y≈z ⟧S (refl _) ∎
snoc-correct {y≡z = y≡z} {x≡y = x≡y} (Cons x≈y y≈z) z≈u h₁ h₂ =
sym (trans x≡y y≡z) ≡⟨ sym-trans _ _ ⟩
trans (sym y≡z) (sym x≡y) ≡⟨ cong₂ trans h₁ (refl (sym x≡y)) ⟩
trans (trans ⟦ x≈y ⟧S ⟦ y≈z ⟧S) (sym x≡y) ≡⟨ trans-assoc _ _ _ ⟩
trans ⟦ x≈y ⟧S (trans ⟦ y≈z ⟧S (sym x≡y)) ≡⟨ cong (trans ⟦ x≈y ⟧S) $
cong₂ trans (sym (sym-sym ⟦ y≈z ⟧S)) (refl (sym x≡y)) ⟩
trans ⟦ x≈y ⟧S (trans (sym (sym ⟦ y≈z ⟧S)) (sym x≡y)) ≡⟨ cong (trans _) $ sym (sym-trans x≡y (sym ⟦ y≈z ⟧S)) ⟩
trans ⟦ x≈y ⟧S (sym (trans x≡y (sym ⟦ y≈z ⟧S))) ≡⟨ cong (trans _) $ snoc-correct y≈z z≈u (sym-sym _) h₂ ⟩∎
trans ⟦ x≈y ⟧S ⟦ snoc y≈z z≈u ⟧S ∎
append : EqS upper x y → EqS upper y z → EqS upper x z
append Refl x≈y = x≈y
append (Cons x≈y y≈z) z≈u = Cons x≈y (append y≈z z≈u)
abstract
append-correct :
(x≈y : EqS upper x y) (y≈z : EqS upper y z) →
x≡y ≡ ⟦ x≈y ⟧S → y≡z ≡ ⟦ y≈z ⟧S →
trans x≡y y≡z ≡ ⟦ append x≈y y≈z ⟧S
append-correct {x≡y = x≡y} {y≡z} Refl x≈y h₁ h₂ =
trans x≡y y≡z ≡⟨ cong₂ trans h₁ h₂ ⟩
trans (refl _) ⟦ x≈y ⟧S ≡⟨ trans-reflˡ _ ⟩∎
⟦ x≈y ⟧S ∎
append-correct {x≡y = x≡z} {z≡u} (Cons x≈y y≈z) z≈u h₁ h₂ =
trans x≡z z≡u ≡⟨ cong₂ trans h₁ (refl z≡u) ⟩
trans (trans ⟦ x≈y ⟧S ⟦ y≈z ⟧S) z≡u ≡⟨ trans-assoc _ _ _ ⟩
trans ⟦ x≈y ⟧S (trans ⟦ y≈z ⟧S z≡u) ≡⟨ cong (trans _) $ append-correct y≈z z≈u (refl _) h₂ ⟩∎
trans ⟦ x≈y ⟧S ⟦ append y≈z z≈u ⟧S ∎
map-sym : EqS middle x y → EqS middle y x
map-sym (No-Sym x≈y) = Sym x≈y
map-sym (Sym x≈y) = No-Sym x≈y
abstract
map-sym-correct :
(x≈y : EqS middle x y) →
x≡y ≡ ⟦ x≈y ⟧S → sym x≡y ≡ ⟦ map-sym x≈y ⟧S
map-sym-correct {x≡y = x≡y} (No-Sym x≈y) h =
sym x≡y ≡⟨ cong sym h ⟩∎
sym ⟦ x≈y ⟧S ∎
map-sym-correct {x≡y = x≡y} (Sym x≈y) h =
sym x≡y ≡⟨ cong sym h ⟩
sym (sym ⟦ x≈y ⟧S) ≡⟨ sym-sym _ ⟩∎
⟦ x≈y ⟧S ∎
reverse : EqS upper x y → EqS upper y x
reverse Refl = Refl
reverse (Cons x≈y y≈z) = snoc (reverse y≈z) (map-sym x≈y)
abstract
reverse-correct :
(x≈y : EqS upper x y) →
x≡y ≡ ⟦ x≈y ⟧S → sym x≡y ≡ ⟦ reverse x≈y ⟧S
reverse-correct {x≡y = x≡y} Refl h =
sym x≡y ≡⟨ cong sym h ⟩
sym (refl _) ≡⟨ sym-refl ⟩∎
refl _ ∎
reverse-correct {x≡y = x≡y} (Cons x≈y y≈z) h =
sym x≡y ≡⟨ cong sym h ⟩
sym (trans ⟦ x≈y ⟧S ⟦ y≈z ⟧S) ≡⟨ snoc-correct (reverse y≈z) _
(reverse-correct y≈z (refl _))
(map-sym-correct x≈y (refl _)) ⟩∎
⟦ snoc (reverse y≈z) (map-sym x≈y) ⟧S ∎
map-cong : {A B : Type a} {x y : A} (f : A → B) →
EqS ℓ x y → EqS ℓ (f x) (f y)
map-cong {ℓ = lower} f (Cong g x≡y) = Cong (f ∘ g) x≡y
map-cong {ℓ = middle} f (No-Sym x≈y) = No-Sym (map-cong f x≈y)
map-cong {ℓ = middle} f (Sym y≈x) = Sym (map-cong f y≈x)
map-cong {ℓ = upper} f Refl = Refl
map-cong {ℓ = upper} f (Cons x≈y y≈z) =
Cons (map-cong f x≈y) (map-cong f y≈z)
abstract
map-cong-correct :
(f : A → B) (x≈y : EqS ℓ x y) →
x≡y ≡ ⟦ x≈y ⟧S → cong f x≡y ≡ ⟦ map-cong f x≈y ⟧S
map-cong-correct {ℓ = lower} {x≡y = gx≡gy} f (Cong g x≡y) h =
cong f gx≡gy ≡⟨ cong (cong f) h ⟩
cong f (cong g x≡y) ≡⟨ cong-∘ f g _ ⟩∎
cong (f ∘ g) x≡y ∎
map-cong-correct {ℓ = middle} {x≡y = x≡y} f (No-Sym x≈y) h =
cong f x≡y ≡⟨ map-cong-correct f x≈y h ⟩∎
⟦ map-cong f x≈y ⟧S ∎
map-cong-correct {ℓ = middle} {x≡y = x≡y} f (Sym y≈x) h =
cong f x≡y ≡⟨ cong (cong f) h ⟩
cong f (sym ⟦ y≈x ⟧S) ≡⟨ cong-sym f _ ⟩
sym (cong f ⟦ y≈x ⟧S) ≡⟨ cong sym (map-cong-correct f y≈x (refl _)) ⟩∎
sym ⟦ map-cong f y≈x ⟧S ∎
map-cong-correct {ℓ = upper} {x≡y = x≡y} f Refl h =
cong f x≡y ≡⟨ cong (cong f) h ⟩
cong f (refl _) ≡⟨ cong-refl f ⟩∎
refl _ ∎
map-cong-correct {ℓ = upper} {x≡y = x≡y} f (Cons x≈y y≈z) h =
cong f x≡y ≡⟨ cong (cong f) h ⟩
cong f (trans ⟦ x≈y ⟧S ⟦ y≈z ⟧S) ≡⟨ cong-trans f _ _ ⟩
trans (cong f ⟦ x≈y ⟧S) (cong f ⟦ y≈z ⟧S) ≡⟨ cong₂ trans (map-cong-correct f x≈y (refl _))
(map-cong-correct f y≈z (refl _)) ⟩∎
trans ⟦ map-cong f x≈y ⟧S ⟦ map-cong f y≈z ⟧S ∎
-- Equality-preserving simplifier.
simplify : Eq x y → EqS upper x y
simplify (Lift x≡y) = lift x≡y
simplify Refl = Refl
simplify (Sym x≡y) = reverse (simplify x≡y)
simplify (Trans x≡y y≡z) = append (simplify x≡y) (simplify y≡z)
simplify (Cong f x≡y) = map-cong f (simplify x≡y)
abstract
simplify-correct :
(x≈y : Eq x y) → ⟦ x≈y ⟧ ≡ ⟦ simplify x≈y ⟧S
simplify-correct (Lift x≡y) = lift-correct x≡y
simplify-correct Refl = refl _
simplify-correct (Sym x≈y) = reverse-correct (simplify x≈y)
(simplify-correct x≈y)
simplify-correct (Trans x≈y y≈z) = append-correct (simplify x≈y) _
(simplify-correct x≈y)
(simplify-correct y≈z)
simplify-correct (Cong f x≈y) = map-cong-correct f (simplify x≈y)
(simplify-correct x≈y)
------------------------------------------------------------------------
-- Tactic
abstract
-- Simple tactic for proving equality of equality proofs.
prove : (x≡y x≡y′ : Eq x y) →
⟦ simplify x≡y ⟧S ≡ ⟦ simplify x≡y′ ⟧S →
⟦ x≡y ⟧ ≡ ⟦ x≡y′ ⟧
prove x≡y x≡y′ hyp =
⟦ x≡y ⟧ ≡⟨ simplify-correct x≡y ⟩
⟦ simplify x≡y ⟧S ≡⟨ hyp ⟩
⟦ simplify x≡y′ ⟧S ≡⟨ sym (simplify-correct x≡y′) ⟩∎
⟦ x≡y′ ⟧ ∎
------------------------------------------------------------------------
-- Some examples
private
module Examples (x≡y : x ≡ y) where
ex₁ : trans (refl x) (sym (sym x≡y)) ≡ x≡y
ex₁ = prove (Trans Refl (Sym (Sym (Lift x≡y)))) (Lift x≡y) (refl _)
ex₂ : cong proj₂ (sym (cong (_,_ x) x≡y)) ≡ sym x≡y
ex₂ = prove (Cong proj₂ (Sym (Cong (_,_ x) (Lift x≡y))))
(Sym (Lift x≡y))
(refl _)
-- Non-examples: The tactic cannot prove trans-symˡ or trans-symʳ.
| {
"alphanum_fraction": 0.450490381,
"avg_line_length": 36.439862543,
"ext": "agda",
"hexsha": "7808a04e77c9f879666b623f9e68416b2487617d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/Equality/Tactic.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/equality",
"max_issues_repo_path": "src/Equality/Tactic.agda",
"max_line_length": 121,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Equality/Tactic.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 4591,
"size": 10604
} |
module HelloWorld where
open import IO
open import Data.String
open import Data.Unit
open import Level using (0ℓ)
main = run {0ℓ} (putStrLn "Hello World!")
| {
"alphanum_fraction": 0.7594936709,
"avg_line_length": 17.5555555556,
"ext": "agda",
"hexsha": "27cc63b91cd7ee4f09fec10c89b43f75eb9d64b4",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "guilhermehas/agda",
"max_forks_repo_path": "test/Compiler/with-stdlib/HelloWorld.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "guilhermehas/agda",
"max_issues_repo_path": "test/Compiler/with-stdlib/HelloWorld.agda",
"max_line_length": 41,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "guilhermehas/agda",
"max_stars_repo_path": "test/Compiler/with-stdlib/HelloWorld.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 42,
"size": 158
} |
{-# OPTIONS --universe-polymorphism #-}
module Categories.Coproduct where
open import Level
open import Data.Empty
open import Data.Sum
open import Relation.Binary.Core
open import Categories.Category
module _ {a a′ ℓ ℓ′} {A : Set a} (_∼_ : Rel A ℓ) where
lift-∼ : Rel (Lift {ℓ = a′} A) (ℓ ⊔ ℓ′)
lift-∼ (lift x) (lift y) = Lift {ℓ = ℓ′} (x ∼ y)
lift-equiv : IsEquivalence _∼_ → IsEquivalence lift-∼
lift-equiv record { refl = refl-∼ ; sym = sym-∼ ; trans = trans-∼ } =
record { refl = lift refl-∼
; sym = λ { {lift x} {lift y} {lift x∼y} → lift (sym-∼ x∼y) }
; trans = λ { {lift x} {lift y} {lift z} {lift x∼y} {lift y∼z} → lift (trans-∼ x∼y y∼z) }
}
Coproduct : ∀ {o ℓ e o′ ℓ′ e′} (C : Category o ℓ e) (D : Category o′ ℓ′ e′) → Category (o ⊔ o′) (ℓ ⊔ ℓ′) (e ⊔ e′)
Coproduct {o} {ℓ} {e} {o′} {ℓ′} {e′} C D = record
{ Obj = C.Obj ⊎ D.Obj
; _⇒_ = λ { (inj₁ c₁) (inj₁ c₂) → Lift {ℓ = ℓ′} (C._⇒_ c₁ c₂)
; (inj₁ _) (inj₂ _) → Lift ⊥
; (inj₂ _) (inj₁ _) → Lift ⊥
; (inj₂ d₁) (inj₂ d₂) → Lift {ℓ = ℓ} (D._⇒_ d₁ d₂)
}
; _≡_ = λ { {inj₁ _} {inj₁ _} → lift-∼ {ℓ′ = e′} C._≡_
; {inj₁ _} {inj₂ _} (lift ()) (lift ())
; {inj₂ _} {inj₁ _} (lift ()) (lift ())
; {inj₂ _} {inj₂ _} → lift-∼ {ℓ′ = e} D._≡_
}
; _∘_ = λ { {inj₁ _} {inj₁ _} {inj₁ _} (lift f) (lift g) → lift (C._∘_ f g)
; {inj₁ _} {inj₁ _} {inj₂ _} (lift ()) _
; {inj₁ _} {inj₂ _} {inj₁ _} _ (lift ())
; {inj₁ _} {inj₂ _} {inj₂ _} _ (lift ())
; {inj₂ _} {inj₁ _} {inj₁ _} _ (lift ())
; {inj₂ _} {inj₁ _} {inj₂ _} (lift ()) _
; {inj₂ _} {inj₂ _} {inj₁ _} (lift ()) _
; {inj₂ _} {inj₂ _} {inj₂ _} (lift f) (lift g) → lift (D._∘_ f g)
}
; id = λ { {inj₁ _} → lift C.id ; {inj₂ _} → lift D.id }
; assoc = λ { {inj₁ _} {inj₁ _} {inj₁ _} {inj₁ _} → lift C.assoc
; {inj₁ _} {inj₁ _} {inj₁ _} {inj₂ _} {_} {_} {lift ()}
; {inj₁ _} {inj₁ _} {inj₂ _} {inj₁ _} {_} {lift ()} {_}
; {inj₁ _} {inj₁ _} {inj₂ _} {inj₂ _} {_} {lift ()} {_}
; {inj₁ _} {inj₂ _} {inj₁ _} {inj₁ _} {lift ()} {_} {_}
; {inj₁ _} {inj₂ _} {inj₁ _} {inj₂ _} {lift ()} {_} {_}
; {inj₁ _} {inj₂ _} {inj₂ _} {inj₁ _} {lift ()} {_} {_}
; {inj₁ _} {inj₂ _} {inj₂ _} {inj₂ _} {lift ()} {_} {_}
; {inj₂ _} {inj₁ _} {inj₁ _} {inj₁ _} {lift ()} {_} {_}
; {inj₂ _} {inj₁ _} {inj₁ _} {inj₂ _} {lift ()} {_} {_}
; {inj₂ _} {inj₁ _} {inj₂ _} {inj₁ _} {lift ()} {_} {_}
; {inj₂ _} {inj₁ _} {inj₂ _} {inj₂ _} {lift ()} {_} {_}
; {inj₂ _} {inj₂ _} {inj₁ _} {inj₁ _} {_} {lift ()} {_}
; {inj₂ _} {inj₂ _} {inj₁ _} {inj₂ _} {_} {lift ()} {_}
; {inj₂ _} {inj₂ _} {inj₂ _} {inj₁ _} {_} {_} {lift ()}
; {inj₂ _} {inj₂ _} {inj₂ _} {inj₂ _} → lift D.assoc
}
; identityˡ = λ { {inj₁ _} {inj₁ _} → lift C.identityˡ
; {inj₁ _} {inj₂ _} {lift ()}
; {inj₂ _} {inj₁ _} {lift ()}
; {inj₂ _} {inj₂ _} → lift D.identityˡ
}
; identityʳ = λ { {inj₁ _} {inj₁ _} → lift C.identityʳ
; {inj₁ _} {inj₂ _} {lift ()}
; {inj₂ _} {inj₁ _} {lift ()}
; {inj₂ _} {inj₂ _} → lift D.identityʳ
}
; equiv = λ { {inj₁ _} {inj₁ _} → lift-equiv _ C.equiv
; {inj₁ _} {inj₂ _} → record { refl = λ { {lift ()} }
; sym = λ { {lift ()} }
; trans = λ { {lift ()} }
}
; {inj₂ _} {inj₁ _} → record { refl = λ { {lift ()} }
; sym = λ { {lift ()} }
; trans = λ { {lift ()} }
}
; {inj₂ _} {inj₂ _} → lift-equiv _ D.equiv
}
; ∘-resp-≡ = λ { {inj₁ _} {inj₁ _} {inj₁ _} → λ { (lift f) (lift g) → lift (C.∘-resp-≡ f g) }
; {inj₁ _} {inj₁ _} {inj₂ _} {lift ()} {_} {_}
; {inj₁ _} {inj₂ _} {inj₁ _} {lift ()} {_} {_}
; {inj₁ _} {inj₂ _} {inj₂ _} {_} {_} {lift ()}
; {inj₂ _} {inj₁ _} {inj₁ _} {_} {_} {lift ()}
; {inj₂ _} {inj₁ _} {inj₂ _} {lift ()} {_} {_}
; {inj₂ _} {inj₂ _} {inj₁ _} {lift ()} {_} {_}
; {inj₂ _} {inj₂ _} {inj₂ _} → λ { (lift f) (lift g) → lift (D.∘-resp-≡ f g) }
}
}
where
module C = Category C
module D = Category D
| {
"alphanum_fraction": 0.3885977782,
"avg_line_length": 49.6979166667,
"ext": "agda",
"hexsha": "420968f516ed4ffd0c5aeeb215b53019cc09d76d",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "copumpkin/categories",
"max_forks_repo_path": "Categories/Coproduct.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "copumpkin/categories",
"max_issues_repo_path": "Categories/Coproduct.agda",
"max_line_length": 113,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Coproduct.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 2032,
"size": 4771
} |
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}
module Cubical.Data.Queue.Untruncated2List where
open import Cubical.Foundations.Everything
open import Cubical.Foundations.SIP
open import Cubical.Structures.Queue
open import Cubical.Data.Maybe
open import Cubical.Data.List
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation
open import Cubical.Data.Queue.1List
module Untruncated2List {ℓ} (A : Type ℓ) (Aset : isSet A) where
open Queues-on A Aset
-- Untruncated 2Lists
data Q : Type ℓ where
Q⟨_,_⟩ : (xs ys : List A) → Q
tilt : ∀ xs ys z → Q⟨ xs ++ [ z ] , ys ⟩ ≡ Q⟨ xs , ys ++ [ z ] ⟩
-- enq into the first list, deq from the second if possible
flushEq' : (xs ys : List A) → Q⟨ xs ++ ys , [] ⟩ ≡ Q⟨ xs , rev ys ⟩
flushEq' xs [] = cong Q⟨_, [] ⟩ (++-unit-r xs)
flushEq' xs (z ∷ ys) j =
hcomp
(λ i → λ
{ (j = i0) → Q⟨ ++-assoc xs [ z ] ys i , [] ⟩
; (j = i1) → tilt xs (rev ys) z i
})
(flushEq' (xs ++ [ z ]) ys j)
flushEq : (xs ys : List A) → Q⟨ xs ++ rev ys , [] ⟩ ≡ Q⟨ xs , ys ⟩
flushEq xs ys = flushEq' xs (rev ys) ∙ cong Q⟨ xs ,_⟩ (rev-rev ys)
emp : Q
emp = Q⟨ [] , [] ⟩
enq : A → Q → Q
enq a Q⟨ xs , ys ⟩ = Q⟨ a ∷ xs , ys ⟩
enq a (tilt xs ys z i) = tilt (a ∷ xs) ys z i
deqFlush : List A → Maybe (Q × A)
deqFlush [] = nothing
deqFlush (x ∷ xs) = just (Q⟨ [] , xs ⟩ , x)
deq : Q → Maybe (Q × A)
deq Q⟨ xs , [] ⟩ = deqFlush (rev xs)
deq Q⟨ xs , y ∷ ys ⟩ = just (Q⟨ xs , ys ⟩ , y)
deq (tilt xs [] z i) = path i
where
path : deqFlush (rev (xs ++ [ z ])) ≡ just (Q⟨ xs , [] ⟩ , z)
path =
cong deqFlush (rev-snoc xs z)
∙ cong (λ q → just (q , z)) (sym (flushEq' [] xs))
deq (tilt xs (y ∷ ys) z i) = just (tilt xs ys z i , y)
Raw : RawQueue
Raw = (Q , emp , enq , deq)
-- We construct an equivalence Q₁≃Q and prove that this is an equivalence of queue structures
private
module One = 1List A Aset
open One renaming (Q to Q₁; emp to emp₁; enq to enq₁; deq to deq₁) using ()
quot : Q₁ → Q
quot xs = Q⟨ xs , [] ⟩
eval : Q → Q₁
eval Q⟨ xs , ys ⟩ = xs ++ rev ys
eval (tilt xs ys z i) =
hcomp
(λ j → λ
{ (i = i0) → (xs ++ [ z ]) ++ rev ys
; (i = i1) → xs ++ rev-snoc ys z (~ j)
})
(++-assoc xs [ z ] (rev ys) i)
quot∘eval : ∀ q → quot (eval q) ≡ q
quot∘eval Q⟨ xs , ys ⟩ = flushEq xs ys
quot∘eval (tilt xs ys z i) j =
hcomp
(λ k → λ
{ (i = i0) →
compPath-filler (flushEq' (xs ++ [ z ]) (rev ys)) (cong Q⟨ xs ++ [ z ] ,_⟩ (rev-rev ys)) k j
; (i = i1) → helper k
; (j = i0) →
Q⟨ compPath-filler (++-assoc xs [ z ] (rev ys)) (cong (xs ++_) (sym (rev-snoc ys z))) k i , [] ⟩
; (j = i1) → tilt xs (rev-rev ys k) z i
})
flushEq'-filler
where
flushEq'-filler : Q
flushEq'-filler =
hfill
(λ i → λ
{ (j = i0) → Q⟨ ++-assoc xs [ z ] (rev ys) i , [] ⟩
; (j = i1) → tilt xs (rev (rev ys)) z i
})
(inS (flushEq' (xs ++ [ z ]) (rev ys) j))
i
helper : I → Q
helper k =
hcomp
(λ l → λ
{ (j = i0) → Q⟨ xs ++ rev-snoc ys z (l ∧ ~ k) , [] ⟩
; (j = i1) → Q⟨ xs , rev-rev-snoc ys z l k ⟩
; (k = i0) → flushEq' xs (rev-snoc ys z l) j
; (k = i1) → flushEq xs (ys ++ [ z ]) j
})
(compPath-filler (flushEq' xs (rev (ys ++ [ z ]))) (cong Q⟨ xs ,_⟩ (rev-rev (ys ++ [ z ]))) k j)
eval∘quot : ∀ xs → eval (quot xs) ≡ xs
eval∘quot = ++-unit-r
-- We get our desired equivalence
quotEquiv : Q₁ ≃ Q
quotEquiv = isoToEquiv (iso quot eval quot∘eval eval∘quot)
-- Now it only remains to prove that this is an equivalence of queue structures
quot∘emp : quot emp₁ ≡ emp
quot∘emp = refl
quot∘enq : ∀ x xs → quot (enq₁ x xs) ≡ enq x (quot xs)
quot∘enq x xs = refl
quot∘deq : ∀ xs → deqMap quot (deq₁ xs) ≡ deq (quot xs)
quot∘deq [] = refl
quot∘deq (x ∷ []) = refl
quot∘deq (x ∷ x' ∷ xs) =
deqMap-∘ quot (enq₁ x) (deq₁ (x' ∷ xs))
∙ sym (deqMap-∘ (enq x) quot (deq₁ (x' ∷ xs)))
∙ cong (deqMap (enq x)) (quot∘deq (x' ∷ xs))
∙ lemma x x' (rev xs)
where
lemma : ∀ x x' ys
→ deqMap (enq x) (deqFlush (ys ++ [ x' ]))
≡ deqFlush ((ys ++ [ x' ]) ++ [ x ])
lemma x x' [] i = just (tilt [] [] x i , x')
lemma x x' (y ∷ ys) i = just (tilt [] (ys ++ [ x' ]) x i , y)
quotEquivHasQueueEquivStr : RawQueueEquivStr One.Raw Raw quotEquiv
quotEquivHasQueueEquivStr = quot∘emp , quot∘enq , quot∘deq
-- And we get a path between the raw 1Lists and 2Lists
Raw-1≡2 : One.Raw ≡ Raw
Raw-1≡2 = sip rawQueueUnivalentStr _ _ (quotEquiv , quotEquivHasQueueEquivStr)
-- We derive the axioms for 2List from those for 1List
WithLaws : Queue
WithLaws = Q , str Raw , subst (uncurry QueueAxioms) Raw-1≡2 (snd (str One.WithLaws))
-- In particular, the untruncated queue type is a set
isSetQ : isSet Q
isSetQ = str WithLaws .snd .fst
WithLaws-1≡2 : One.WithLaws ≡ WithLaws
WithLaws-1≡2 = sip queueUnivalentStr _ _ (quotEquiv , quotEquivHasQueueEquivStr)
Finite : FiniteQueue
Finite = Q , str WithLaws , subst (uncurry FiniteQueueAxioms) WithLaws-1≡2 (snd (str One.Finite))
| {
"alphanum_fraction": 0.5454721362,
"avg_line_length": 30.9461077844,
"ext": "agda",
"hexsha": "f8472bbdecfd921c57a8785989d5557501696131",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Data/Queue/Untruncated2List.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Data/Queue/Untruncated2List.agda",
"max_line_length": 105,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Data/Queue/Untruncated2List.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2062,
"size": 5168
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Indexed binary relations
------------------------------------------------------------------------
-- The contents of this module should be accessed via
-- `Relation.Binary.Indexed.Heterogeneous`.
{-# OPTIONS --without-K --safe #-}
module Relation.Binary.Indexed.Heterogeneous.Core where
open import Level
import Relation.Binary.Core as B
import Relation.Binary.Definitions as B
import Relation.Binary.PropositionalEquality.Core as P
------------------------------------------------------------------------
-- Indexed binary relations
-- Heterogeneous types
IREL : ∀ {i₁ i₂ a₁ a₂} {I₁ : Set i₁} {I₂ : Set i₂} →
(I₁ → Set a₁) → (I₂ → Set a₂) → (ℓ : Level) → Set _
IREL A₁ A₂ ℓ = ∀ {i₁ i₂} → A₁ i₁ → A₂ i₂ → Set ℓ
-- Homogeneous types
IRel : ∀ {i a} {I : Set i} → (I → Set a) → (ℓ : Level) → Set _
IRel A ℓ = IREL A A ℓ
------------------------------------------------------------------------
-- Generalised implication.
infixr 4 _=[_]⇒_
_=[_]⇒_ : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : A → Set b} →
B.Rel A ℓ₁ → ((x : A) → B x) → IRel B ℓ₂ → Set _
P =[ f ]⇒ Q = ∀ {i j} → P i j → Q (f i) (f j)
| {
"alphanum_fraction": 0.4663934426,
"avg_line_length": 29.756097561,
"ext": "agda",
"hexsha": "8487830ede31f7d564a35e40379bb77fff75a83e",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Indexed/Heterogeneous/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Indexed/Heterogeneous/Core.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Indexed/Heterogeneous/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 350,
"size": 1220
} |
-- Andreas, 2017-10-04, ignore irrelevant arguments during with-abstraction
-- Feature request by xekoukou
{-# OPTIONS --allow-unsolved-metas --show-irrelevant #-}
-- {-# OPTIONS -v tc.abstract:100 #-}
open import Agda.Builtin.Equality
open import Agda.Builtin.Bool
not : Bool → Bool
not true = false
not false = true
but : Bool → .(Bool → Bool) → Bool
but true f = false
but false f = true
test : (x : Bool) → but x not ≡ true
test x with but x not' where
not' : Bool → Bool
not' true = false
not' false = true
test x | true = refl
test x | false = _ -- unsolved meta ok
| {
"alphanum_fraction": 0.6683673469,
"avg_line_length": 22.6153846154,
"ext": "agda",
"hexsha": "621b42286a55668ff7c7d448633da07b3cc62535",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue2775.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue2775.agda",
"max_line_length": 75,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue2775.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 182,
"size": 588
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
module homotopy.ConstantToSetExtendsToProp {i j}
{A : Type i} {B : Type j} (B-is-set : is-set B)
(f : A → B) (f-is-const : ∀ a₁ a₂ → f a₁ == f a₂) where
private
Skel = SetQuot {A = A} (λ _ _ → Unit)
abstract
Skel-has-all-paths : has-all-paths Skel
Skel-has-all-paths =
SetQuot-elim (λ _ → Π-is-set λ _ → =-preserves-set SetQuot-is-set)
(λ a₁ →
SetQuot-elim {P = λ s₂ → q[ a₁ ] == s₂}
(λ _ → =-preserves-set SetQuot-is-set)
(λ _ → quot-rel _)
(λ _ → prop-has-all-paths-↓ (SetQuot-is-set _ _)))
(λ {a₁ a₂} _ → ↓-Π-cst-app-in λ s₂ →
prop-has-all-paths-↓ (SetQuot-is-set _ _))
Skel-is-prop : is-prop Skel
Skel-is-prop = all-paths-is-prop Skel-has-all-paths
Skel-lift : Skel → B
Skel-lift = SetQuot-rec B-is-set f (λ {a₁ a₂} _ → f-is-const a₁ a₂)
ext : Trunc -1 A → B
ext = Skel-lift ∘ Trunc-rec Skel-is-prop q[_]
abstract
ext-is-const : ∀ a₁ a₂ → ext a₁ == ext a₂
ext-is-const = Trunc-elim
(λ a₁ → Π-is-prop λ a₂ → B-is-set _ _)
(λ a₁ → Trunc-elim (λ a₂ → B-is-set _ _)
(λ a₂ → f-is-const a₁ a₂))
private
abstract
-- The beta rule.
-- This is definitionally true, so you don't need it.
β : ext ∘ [_] == f
β = idp
| {
"alphanum_fraction": 0.5330428468,
"avg_line_length": 29.9347826087,
"ext": "agda",
"hexsha": "42062b5717b9b00ad29d94acaa5934116d12f017",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mikeshulman/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/ConstantToSetExtendsToProp.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mikeshulman/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/ConstantToSetExtendsToProp.agda",
"max_line_length": 74,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mikeshulman/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/ConstantToSetExtendsToProp.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 510,
"size": 1377
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.AssocList where
open import Cubical.HITs.AssocList.Base public
open import Cubical.HITs.AssocList.Properties public
| {
"alphanum_fraction": 0.7830687831,
"avg_line_length": 27,
"ext": "agda",
"hexsha": "4e5f90ee81f2910c5485e0a2d7514d31ee852b52",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/HITs/AssocList.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/HITs/AssocList.agda",
"max_line_length": 52,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/HITs/AssocList.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 51,
"size": 189
} |
-- Andreas, 2015-09-18 Andreas, issue reported by Gillaume Brunerie
{- Problem WAS
The following code doesn’t typecheck but it should. I have no idea what’s going on.
Replacing the definition of PathOver-rewr by a question mark and
asking for full normalisation of the goal (C-u C-u C-c C-t), I obtain
HetEq idp u v == (u == v), so it seems that the term PathOver (λ _ →
B) p u v) is rewritten as HetEq idp u v using ap-cst (as expected),
but then for some reason HetEq idp u v isn’t reduced to u == v. -}
{-# OPTIONS --rewriting #-}
-- {-# OPTIONS --show-implicit #-}
data _==_ {i} {A : Set i} (a : A) : A → Set where
idp : a == a
{-# BUILTIN REWRITE _==_ #-}
ap : ∀ {i j} {A : Set i} {B : Set j} (f : A → B) {x y : A}
→ x == y → f x == f y
ap f idp = idp
ap-cst : {A B : Set} (b : B) {x y : A} (p : x == y)
→ ap (λ _ → b) p == idp
ap-cst b idp = idp
{-# REWRITE ap-cst #-}
HetEq : {A B : Set} (e : A == B) (a : A) (b : B) → Set
HetEq idp a b = (a == b)
PathOver : {A : Set} (B : A → Set)
{x y : A} (p : x == y) (u : B x) (v : B y) → Set
PathOver B p u v = HetEq (ap B p) u v
PathOver-rewr : {A B : Set} {x y : A} (p : x == y) (u v : B)
→ (PathOver (λ _ → B) p u v) == (u == v)
PathOver-rewr p u v = idp
| {
"alphanum_fraction": 0.5530179445,
"avg_line_length": 30.65,
"ext": "agda",
"hexsha": "eafe69c33311e0da9cbe58a5ed2eb2e5f5883b67",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Succeed/Issue1648.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Succeed/Issue1648.agda",
"max_line_length": 83,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Succeed/Issue1648.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 482,
"size": 1226
} |
--------------------------------------------------------------------------------
-- This is part of Agda Inference Systems
{-# OPTIONS --sized-types #-}
module is-lib.SInfSys {𝓁} where
open import is-lib.InfSys.Base {𝓁} public
open import is-lib.InfSys.Induction {𝓁} public
open import is-lib.InfSys.SCoinduction {𝓁} public
open import is-lib.InfSys.FlexSCoinduction {𝓁} public
open MetaRule public
open FinMetaRule public
open IS public | {
"alphanum_fraction": 0.6087912088,
"avg_line_length": 35,
"ext": "agda",
"hexsha": "efc39f5497dcd652dbd43ee8172216913b8c72b7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "boystrange/FairSubtypingAgda",
"max_forks_repo_path": "src/is-lib/SInfSys.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "boystrange/FairSubtypingAgda",
"max_issues_repo_path": "src/is-lib/SInfSys.agda",
"max_line_length": 80,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "boystrange/FairSubtypingAgda",
"max_stars_repo_path": "src/is-lib/SInfSys.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-24T14:38:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-29T14:32:30.000Z",
"num_tokens": 120,
"size": 455
} |
module Q where
import AlonzoPrelude
open AlonzoPrelude -- , using(Bool,False,True,String,showBool)
import PreludeNat
open PreludeNat
import PreludeBool
open PreludeBool
import PreludeShow
open PreludeShow
pred : Nat -> Nat
pred (zero) = zero
pred (suc n) = n
mplus : Nat -> Nat -> Nat
mplus zero y = y
mplus (suc n) y = suc (mplus n y )
Q : Bool -> Set
Q true = Nat
Q false = Bool
f : (b : Bool) -> Q b
f true = pred 3
f false = true
mid : {A : Set} -> A -> A
mid x = x
mainS : String
mainS = showBool (f (const false true))
| {
"alphanum_fraction": 0.6635687732,
"avg_line_length": 15.8235294118,
"ext": "agda",
"hexsha": "0f1e5a7a3997edbf4cd2fbcc0d832af00a052a7d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/Alonzo/Q.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/Alonzo/Q.agda",
"max_line_length": 62,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "examples/outdated-and-incorrect/Alonzo/Q.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 182,
"size": 538
} |
module TooManyArgumentsInLHS where
F : Set -> Set
F X Y = Y
| {
"alphanum_fraction": 0.6825396825,
"avg_line_length": 9,
"ext": "agda",
"hexsha": "b4a56663776fd3aa4c56e02786beb42fd303da75",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/TooManyArgumentsInLHS.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/TooManyArgumentsInLHS.agda",
"max_line_length": 34,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/TooManyArgumentsInLHS.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 22,
"size": 63
} |
{-# OPTIONS --postfix-projections #-}
module StateSizedIO.cellStateDependent where
open import Data.Product
open import Data.String.Base
{-
open import SizedIO.Object
open import SizedIO.ConsoleObject
-}
open import SizedIO.Console hiding (main)
open import SizedIO.Base
open import NativeIO
open import StateSizedIO.Object
open import StateSizedIO.IOObject
open import Size
data CellStateˢ : Set where
empty full : CellStateˢ
data CellMethodEmpty A : Set where
put : A → CellMethodEmpty A
data CellMethodFull A : Set where
get : CellMethodFull A
put : A → CellMethodFull A
CellMethodˢ : (A : Set) → CellStateˢ → Set
CellMethodˢ A empty = CellMethodEmpty A
CellMethodˢ A full = CellMethodFull A
putGen : {A : Set} → {i : CellStateˢ} → A → CellMethodˢ A i
putGen {i = empty} = put
putGen {i = full} = put
CellResultFull : ∀{A} → CellMethodFull A → Set
CellResultFull {A} get = A
CellResultFull (put _) = Unit
CellResultEmpty : ∀{A} → CellMethodEmpty A → Set
CellResultEmpty (put _) = Unit
CellResultˢ : (A : Set) → (s : CellStateˢ) → CellMethodˢ A s → Set
CellResultˢ A empty = CellResultEmpty{A}
CellResultˢ A full = CellResultFull{A}
nˢ : ∀{A} → (s : CellStateˢ) → (c : CellMethodˢ A s) → (CellResultˢ A s c) → CellStateˢ
nˢ _ _ _ = full
CellInterfaceˢ : (A : Set) → Interfaceˢ
Stateˢ (CellInterfaceˢ A) = CellStateˢ
Methodˢ (CellInterfaceˢ A) = CellMethodˢ A
Resultˢ (CellInterfaceˢ A) = CellResultˢ A
nextˢ (CellInterfaceˢ A) = nˢ
mutual
cellPempty : (i : Size) → IOObjectˢ consoleI (CellInterfaceˢ String) i empty
method (cellPempty i) {j} (put str) = do (putStrLn ("put (" ++ str ++ ")")) λ _ →
return (unit , cellPfull j str)
cellPfull : (i : Size) → (str : String) → IOObjectˢ consoleI (CellInterfaceˢ String) i full
method (cellPfull i str) {j} get = do (putStrLn ("get (" ++ str ++ ")")) λ _ →
return (str , cellPfull j str)
method (cellPfull i str) {j} (put str') = do (putStrLn ("put (" ++ str' ++ ")")) λ _ →
return (unit , cellPfull j str')
-- UNSIZED Version, without IO
mutual
cellPempty' : ∀{A} → Objectˢ (CellInterfaceˢ A) empty
cellPempty' .objectMethod (put a) = (_ , cellPfull' a)
cellPfull' : ∀{A} → A → Objectˢ (CellInterfaceˢ A) full
cellPfull' a .objectMethod get = (a , cellPfull' a)
cellPfull' a .objectMethod (put a') = (_ , cellPfull' a')
| {
"alphanum_fraction": 0.642370845,
"avg_line_length": 28.7011494253,
"ext": "agda",
"hexsha": "656b236a10b7aba686c2db50c4f6aed52cce878d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "stephanadls/state-dependent-gui",
"max_forks_repo_path": "src/StateSizedIO/cellStateDependent.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "stephanadls/state-dependent-gui",
"max_issues_repo_path": "src/StateSizedIO/cellStateDependent.agda",
"max_line_length": 94,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "stephanadls/state-dependent-gui",
"max_stars_repo_path": "src/StateSizedIO/cellStateDependent.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z",
"num_tokens": 814,
"size": 2497
} |
{-# OPTIONS --allow-unsolved-metas #-}
module AgdaFeatureNeedHiddenVariableTypeConstructorWrapper where
Unwrapped : {A : Set} → (A → Set) → Set₁
Unwrapped B = ∀ {x} → B x → Set
record Unindexed : Set₁ where
field
{A} : Set
{B} : A → Set
unwrap : Unwrapped B
record Indexed {A : Set} (B : A → Set) : Set₁ where
field
unwrap : Unwrapped B
record Generic (A : Set₁) : Set₁ where
field
unwrap : A
record Foo (F : Set₁) : Set₁ where
field
foo : F → Set
open Foo {{...}}
postulate
A : Set
B : A → Set
unwrapped : Unwrapped B
indexed : Indexed B
unindexed : Unindexed
generic : Generic (Unwrapped B)
postulate
instance FooUnwrapped : Foo (Unwrapped B)
instance FooIndexed : Foo (Indexed B)
instance FooUnindexed : Foo Unindexed
instance FooGeneric : Foo (Generic (Unwrapped B))
test-unwrapped-lambda-unhide-works : Set
test-unwrapped-lambda-unhide-works = foo (λ {_} → unwrapped)
test-unwrapped-help-instance-works : Set
test-unwrapped-help-instance-works = foo {F = ∀ {_} → _} unwrapped
test-unindexed-works : Set
test-unindexed-works = foo unindexed
test-indexed-works : Set
test-indexed-works = foo indexed
test-generic-works : Set
test-generic-works = foo generic
test-unwrapped-fails : Set
test-unwrapped-fails = {!foo unwrapped!}
{-
No instance of type Foo (B _x_48 → Set) was found in scope.
when checking that unwrapped is a valid argument to a function of
type {F : Set₁} {{r : Foo F}} → F → Set
-}
-- tests for unwrapping
unwrap-test-generic : Unwrapped B
unwrap-test-generic = let instance _ = generic in let open Generic ⦃ … ⦄ in unwrap {A = Unwrapped _}
unwrap-test-index : Unwrapped B
unwrap-test-index = let instance _ = indexed in let open Indexed ⦃ … ⦄ in unwrap
| {
"alphanum_fraction": 0.6916905444,
"avg_line_length": 23.5810810811,
"ext": "agda",
"hexsha": "639bdff407bac5db4eb94eb8db7a147d80d4ee21",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/AgdaFeatureNeedHiddenVariableTypeConstructorWrapper.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/AgdaFeatureNeedHiddenVariableTypeConstructorWrapper.agda",
"max_line_length": 100,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-3/src/AgdaFeatureNeedHiddenVariableTypeConstructorWrapper.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 521,
"size": 1745
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Indexed binary relations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Relation.Binary.Indexed.Heterogeneous where
open import Function
open import Level using (suc; _⊔_)
open import Relation.Binary using (_⇒_)
open import Relation.Binary.PropositionalEquality.Core as P using (_≡_)
------------------------------------------------------------------------
-- Publically export core definitions
open import Relation.Binary.Indexed.Heterogeneous.Core public
------------------------------------------------------------------------
-- Equivalences
record IsIndexedEquivalence {i a ℓ} {I : Set i} (A : I → Set a)
(_≈_ : IRel A ℓ) : Set (i ⊔ a ⊔ ℓ) where
field
refl : Reflexive A _≈_
sym : Symmetric A _≈_
trans : Transitive A _≈_
reflexive : ∀ {i} → _≡_ ⟨ _⇒_ ⟩ _≈_ {i}
reflexive P.refl = refl
record IndexedSetoid {i} (I : Set i) c ℓ : Set (suc (i ⊔ c ⊔ ℓ)) where
infix 4 _≈_
field
Carrier : I → Set c
_≈_ : IRel Carrier ℓ
isEquivalence : IsIndexedEquivalence Carrier _≈_
open IsIndexedEquivalence isEquivalence public
------------------------------------------------------------------------
-- Preorders
record IsIndexedPreorder {i a ℓ₁ ℓ₂} {I : Set i} (A : I → Set a)
(_≈_ : IRel A ℓ₁) (_∼_ : IRel A ℓ₂) :
Set (i ⊔ a ⊔ ℓ₁ ⊔ ℓ₂) where
field
isEquivalence : IsIndexedEquivalence A _≈_
reflexive : ∀ {i j} → (_≈_ {i} {j}) ⟨ _⇒_ ⟩ _∼_
trans : Transitive A _∼_
module Eq = IsIndexedEquivalence isEquivalence
refl : Reflexive A _∼_
refl = reflexive Eq.refl
record IndexedPreorder {i} (I : Set i) c ℓ₁ ℓ₂ :
Set (suc (i ⊔ c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _∼_
field
Carrier : I → Set c
_≈_ : IRel Carrier ℓ₁ -- The underlying equality.
_∼_ : IRel Carrier ℓ₂ -- The relation.
isPreorder : IsIndexedPreorder Carrier _≈_ _∼_
open IsIndexedPreorder isPreorder public
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 0.17
REL = IREL
{-# WARNING_ON_USAGE REL
"Warning: REL was deprecated in v0.17.
Please use IREL instead."
#-}
Rel = IRel
{-# WARNING_ON_USAGE Rel
"Warning: Rel was deprecated in v0.17.
Please use IRel instead."
#-}
Setoid = IndexedSetoid
{-# WARNING_ON_USAGE Setoid
"Warning: Setoid was deprecated in v0.17.
Please use IndexedSetoid instead."
#-}
IsEquivalence = IsIndexedEquivalence
{-# WARNING_ON_USAGE IsEquivalence
"Warning: IsEquivalence was deprecated in v0.17.
Please use IsIndexedEquivalence instead."
#-}
| {
"alphanum_fraction": 0.5341216216,
"avg_line_length": 30.2040816327,
"ext": "agda",
"hexsha": "ffadc8c9549413ac17b043482f2c01f7c9da0279",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Heterogeneous.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Heterogeneous.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Heterogeneous.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 808,
"size": 2960
} |
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- From the technical manual of TPTP
-- (http://www.cs.miami.edu/~tptp/TPTP/TR/TPTPTR.shtml)
-- ... variables start with upper case letters, ... predicates and
-- functors either start with lower case and contain alphanumerics and
-- underscore ...
module Issue1.Functions where
postulate
D : Set
NAME : D → Set
nAME : D → Set
postulate foo : ∀ a → NAME a
{-# ATP axiom foo #-}
-- This conjecture should not be proved.
postulate bar : ∀ a → nAME a
{-# ATP prove bar #-}
| {
"alphanum_fraction": 0.619266055,
"avg_line_length": 25.1538461538,
"ext": "agda",
"hexsha": "c0e6a7f2289f0b165a5267f565353fad73d9778b",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z",
"max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/apia",
"max_forks_repo_path": "test/Fail/non-theorems/Issue1/Functions.agda",
"max_issues_count": 121,
"max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/apia",
"max_issues_repo_path": "test/Fail/non-theorems/Issue1/Functions.agda",
"max_line_length": 70,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/apia",
"max_stars_repo_path": "test/Fail/non-theorems/Issue1/Functions.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z",
"num_tokens": 166,
"size": 654
} |
open import Agda.Builtin.Maybe
open import Agda.Builtin.Char
open import Agda.Builtin.String
open import Agda.Builtin.Sigma
open import Agda.Builtin.Equality
_ : primStringUncons "abcd" ≡ just ('a', "bcd")
_ = refl
| {
"alphanum_fraction": 0.7731481481,
"avg_line_length": 24,
"ext": "agda",
"hexsha": "01cff839bf1ebdff7de84b775285c47814769983",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/uncons.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/uncons.agda",
"max_line_length": 47,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/uncons.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 64,
"size": 216
} |
{-# OPTIONS --rewriting --confluence-check #-}
module Issue4333.N1 where
open import Issue4333.M
{-# REWRITE p₁ #-}
b₁' : B a₁'
b₁' = b
| {
"alphanum_fraction": 0.652173913,
"avg_line_length": 15.3333333333,
"ext": "agda",
"hexsha": "d64138ed45e155c2b4d5697da6fc10bab5121a0c",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue4333/N1.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue4333/N1.agda",
"max_line_length": 46,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue4333/N1.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 45,
"size": 138
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.Polynomials.UnivariateList.Poly1-1Poly where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Data.Nat renaming (_+_ to _+n_; _·_ to _·n_)
open import Cubical.Data.Vec renaming ( [] to <> ; _∷_ to _::_)
open import Cubical.Data.Vec.OperationsNat
open import Cubical.Algebra.DirectSum.DirectSumHIT.Base
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Polynomials.UnivariateList.Base renaming (Poly to Poly:)
open import Cubical.Algebra.Polynomials.UnivariateList.Properties
open import Cubical.Algebra.CommRing.Instances.Polynomials.UnivariatePolyList
open import Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly
private variable
ℓ : Level
module Equiv-Poly1-Poly:
(Acr@(A , Astr) : CommRing ℓ) where
private
PA = PolyCommRing Acr 1
PAstr = snd PA
PA: = UnivariatePolyList Acr
PA:str = snd PA:
open PolyMod Acr using (ElimProp)
open PolyModTheory Acr
using ( prod-Xn ; prod-Xn-sum ; prod-Xn-∷ ; prod-Xn-prod)
renaming
(prod-Xn-0P to prod-Xn-0P:)
open CommRingStr
open RingTheory
-- Notation P, Q, R... for Poly 1
-- x, y, w... for Poly:
-- a,b,c... for A
-----------------------------------------------------------------------------
-- direct
trad-base : (v : Vec ℕ 1) → A → Poly: Acr
trad-base (n :: <>) a = prod-Xn n (a ∷ [])
trad-base-neutral : (v : Vec ℕ 1) → trad-base v (0r Astr) ≡ []
trad-base-neutral (n :: <>) = cong (prod-Xn n) drop0 ∙ prod-Xn-0P: n
trad-base-add : (v : Vec ℕ 1) → (a b : A) → _+_ PA:str (trad-base v a) (trad-base v b) ≡ trad-base v (_+_ Astr a b)
trad-base-add (n :: <>) a b = prod-Xn-sum n (a ∷ []) (b ∷ [])
Poly1→Poly: : Poly Acr 1 → Poly: Acr
Poly1→Poly: = DS-Rec-Set.f _ _ _ _ (is-set PA:str)
[]
trad-base
(_+_ PA:str)
(+Assoc PA:str)
(+IdR PA:str)
(+Comm PA:str)
trad-base-neutral
trad-base-add
Poly1→Poly:-pres+ : (P Q : Poly Acr 1) → Poly1→Poly: (_+_ PAstr P Q) ≡ _+_ PA:str (Poly1→Poly: P) (Poly1→Poly: Q)
Poly1→Poly:-pres+ P Q = refl
-----------------------------------------------------------------------------
-- converse
Poly:→Poly1-int : (n : ℕ) → Poly: Acr → Poly Acr 1
Poly:→Poly1-int n [] = 0r PAstr
Poly:→Poly1-int n (a ∷ x) = _+_ PAstr (base (n :: <>) a) (Poly:→Poly1-int (suc n) x)
Poly:→Poly1-int n (drop0 i) = ((cong (λ X → _+_ PAstr X (0r PAstr)) (base-neutral (n :: <>))) ∙ (+IdR PAstr _)) i
Poly:→Poly1 : Poly: Acr → Poly Acr 1
Poly:→Poly1 x = Poly:→Poly1-int 0 x
Poly:→Poly1-int-pres+ : (x y : Poly: Acr) → (n : ℕ) →
Poly:→Poly1-int n (_+_ PA:str x y) ≡ _+_ PAstr (Poly:→Poly1-int n x) (Poly:→Poly1-int n y)
Poly:→Poly1-int-pres+ = ElimProp _
(λ y n → cong (Poly:→Poly1-int n) (+IdL PA:str y) ∙ sym (+IdL PAstr _))
(λ a x ind-x → ElimProp _
(λ n → sym (+IdR PAstr (Poly:→Poly1-int n (a ∷ x))))
(λ b y ind-y n → sym (+ShufflePairs (CommRing→Ring PA) _ _ _ _
∙ cong₂ (_+_ PAstr) (base-add _ _ _) (sym (ind-x y (suc n)))))
(isPropΠ (λ _ → is-set PAstr _ _)))
(isPropΠ2 (λ _ _ → is-set PAstr _ _))
Poly:→Poly1-pres+ : (x y : Poly: Acr) → Poly:→Poly1 (_+_ PA:str x y) ≡ _+_ PAstr (Poly:→Poly1 x) (Poly:→Poly1 y)
Poly:→Poly1-pres+ x y = Poly:→Poly1-int-pres+ x y 0
-----------------------------------------------------------------------------
-- section
e-sect-int : (x : Poly: Acr) → (n : ℕ) → Poly1→Poly: (Poly:→Poly1-int n x) ≡ prod-Xn n x
e-sect-int = ElimProp _
(λ n → sym (prod-Xn-0P: n))
(λ a x ind-x n → cong (λ X → _+_ PA:str (prod-Xn n (a ∷ [])) X) (ind-x (suc n))
∙ prod-Xn-∷ n a x)
(isPropΠ (λ _ → is-set PA:str _ _))
e-sect : (x : Poly: Acr) → Poly1→Poly: (Poly:→Poly1 x) ≡ x
e-sect x = e-sect-int x 0
-----------------------------------------------------------------------------
-- retraction
idde : (m n : ℕ) → (a : A) → Poly:→Poly1-int n (prod-Xn m (a ∷ [])) ≡ base ((n +n m) :: <>) a
idde zero n a = +IdR PAstr (base (n :: <>) a)
∙ cong (λ X → base (X :: <>) a) (sym (+-zero n))
idde (suc m) n a = cong (λ X → _+_ PAstr X (Poly:→Poly1-int (suc n) (prod-Xn m (a ∷ [])))) (base-neutral (n :: <>))
∙ +IdL PAstr (Poly:→Poly1-int (suc n) (prod-Xn m (a ∷ [])))
∙ idde m (suc n) a
∙ cong (λ X → base (X :: <>) a) (sym (+-suc n m))
idde-v : (v : Vec ℕ 1) → (a : A) → Poly:→Poly1-int 0 (trad-base v a) ≡ base v a
idde-v (n :: <>) a = (idde n 0 a)
e-retr : (P : Poly Acr 1) → Poly:→Poly1 (Poly1→Poly: P) ≡ P
e-retr = DS-Ind-Prop.f _ _ _ _ (λ _ → trunc _ _)
refl
(λ v a → idde-v v a)
λ {P Q} ind-P ind-Q → cong Poly:→Poly1 (Poly1→Poly:-pres+ P Q)
∙ Poly:→Poly1-pres+ (Poly1→Poly: P) (Poly1→Poly: Q)
∙ cong₂ (_+_ PAstr) ind-P ind-Q
-----------------------------------------------------------------------------
-- Ring morphism
Poly1→Poly:-pres1 : Poly1→Poly: (1r PAstr) ≡ 1r PA:str
Poly1→Poly:-pres1 = refl
trad-base-prod : (v v' : Vec ℕ 1) → (a a' : A) → trad-base (v +n-vec v') (Astr ._·_ a a') ≡
_·_ PA:str (trad-base v a) (trad-base v' a')
trad-base-prod (k :: <>) (l :: <>) a a' = sym ((prod-Xn-prod k l [ a ] [ a' ]) ∙ cong (λ X → prod-Xn (k +n l) [ X ]) (+IdR Astr _))
Poly1→Poly:-pres· : (P Q : Poly Acr 1) → Poly1→Poly: (_·_ PAstr P Q) ≡ _·_ PA:str (Poly1→Poly: P) (Poly1→Poly: Q)
Poly1→Poly:-pres· = DS-Ind-Prop.f _ _ _ _ (λ _ → isPropΠ λ _ → is-set PA:str _ _)
(λ Q → refl)
(λ v a → DS-Ind-Prop.f _ _ _ _ (λ _ → is-set PA:str _ _)
(sym (0RightAnnihilates (CommRing→Ring PA:) _))
(λ v' a' → trad-base-prod v v' a a')
λ {U V} ind-U ind-V → (cong₂ (_+_ PA:str) ind-U ind-V)
∙ sym (·DistR+ PA:str _ _ _))
λ {U V} ind-U ind-V Q → (cong₂ (_+_ PA:str) (ind-U Q) (ind-V Q))
∙ sym (·DistL+ PA:str _ _ _)
-----------------------------------------------------------------------------
-- Ring Equivalences
module _ (Acr : CommRing ℓ) where
open Equiv-Poly1-Poly: Acr
CRE-Poly1-Poly: : CommRingEquiv (PolyCommRing Acr 1) (UnivariatePolyList Acr)
fst CRE-Poly1-Poly: = isoToEquiv is
where
is : Iso _ _
Iso.fun is = Poly1→Poly:
Iso.inv is = Poly:→Poly1
Iso.rightInv is = e-sect
Iso.leftInv is = e-retr
snd CRE-Poly1-Poly: = makeIsRingHom
Poly1→Poly:-pres1
Poly1→Poly:-pres+
Poly1→Poly:-pres·
| {
"alphanum_fraction": 0.4750609921,
"avg_line_length": 40.7624309392,
"ext": "agda",
"hexsha": "8ee0ab46845ca02da5af0611e5d22668b6dbc724",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Algebra/Polynomials/UnivariateList/Poly1-1Poly.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/Polynomials/UnivariateList/Poly1-1Poly.agda",
"max_line_length": 134,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Algebra/Polynomials/UnivariateList/Poly1-1Poly.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2409,
"size": 7378
} |
------------------------------------------------------------------------------
-- Testing the translation of universal quantified propositional functions
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module PropositionalFunction where
postulate D : Set
postulate id₁ : {A : D → Set}{x : D} → A x → A x
{-# ATP prove id₁ #-}
postulate id₂ : {A : D → D → Set}{x y : D} → A x y → A x y
{-# ATP prove id₂ #-}
| {
"alphanum_fraction": 0.4243902439,
"avg_line_length": 32.3684210526,
"ext": "agda",
"hexsha": "5b477b6ef668a45c884624ffc2a6454188308c83",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z",
"max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/apia",
"max_forks_repo_path": "test/Succeed/non-fol-theorems/PropositionalFunction.agda",
"max_issues_count": 121,
"max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/apia",
"max_issues_repo_path": "test/Succeed/non-fol-theorems/PropositionalFunction.agda",
"max_line_length": 78,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/apia",
"max_stars_repo_path": "test/Succeed/non-fol-theorems/PropositionalFunction.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z",
"num_tokens": 123,
"size": 615
} |
--------------------------------------------------------------------------------
-- This file generates the environment that the interpreter starts with. In
-- particular, it contains the grammar that is loaded initially.
--------------------------------------------------------------------------------
module Bootstrap.InitEnv where
open import Class.Map
open import Data.Char.Ranges
open import Data.List using (dropWhile; takeWhile)
open import Data.SimpleMap
open import Data.String using (fromList; toList)
open import Prelude
open import Prelude.Strings
open import Parse.Escape
open import Bootstrap.SimpleInductive
private
nameSymbols : List Char
nameSymbols = "$='-/!@&^"
nameInits : List Char
nameInits = letters ++ "_"
nameTails : List Char
nameTails = nameInits ++ nameSymbols ++ digits
parseConstrToNonTerminals : String → List String
parseConstrToNonTerminals = (map fromList) ∘ parseConstrToNonTerminals' ∘ toList
where
parseConstrToNonTerminals' : List Char → List (List Char)
parseConstrToNonTerminals' =
takeEven ∘ (map concat) ∘ (splitMulti "_") ∘ groupEscaped -- don't split on escaped underscores!
-- this also ignores ignored non-terminals automatically
grammar : List (List Char)
grammar =
"space'$" ∷ "space'$=newline=_space'_" ∷ "space'$=space=_space'_" ∷
"space$=newline=_space'_" ∷ "space$=space=_space'_" ∷
"index'$" ∷ map (λ c → "index'$" ++ [ c ] ++ "_index'_") digits ++
map (λ c → "index$" ++ [ c ] ++ "_index'_") digits ++
"var$_string_" ∷ "var$_index_" ∷
"sort$=ast=" ∷ "sort$=sq=" ∷
"const$Char" ∷
"term$_var_" ∷
"term$_sort_" ∷
"term$=Kappa=_const_" ∷
"term$=pi=^space^_term_" ∷
"term$=psi=^space^_term_" ∷
"term$=beta=^space^_term_^space^_term_" ∷
"term$=delta=^space^_term_^space^_term_" ∷
"term$=sigma=^space^_term_" ∷
"term$=lsquare=^space'^_term_^space^_term_^space'^=rsquare=" ∷
"term$=langle=^space'^_term_^space^_term_^space'^=rangle=" ∷
"term$=rho=^space^_term_^space^_string_^space'^=dot=^space'^_term_^space^_term_" ∷
"term$=forall=^space^_string_^space'^=colon=^space'^_term_^space^_term_" ∷
"term$=Pi=^space^_string_^space'^=colon=^space'^_term_^space^_term_" ∷
"term$=iota=^space^_string_^space'^=colon=^space'^_term_^space^_term_" ∷
"term$=lambda=^space^_string_^space'^=colon=^space'^_term_^space^_term_" ∷
"term$=Lambda=^space^_string_^space'^=colon=^space'^_term_^space^_term_" ∷
"term$=lbrace=^space'^_term_^space'^=comma=^space'^_term_^space^_string_^space'^=dot=^space'^_term_^space'^=rbrace=" ∷
"term$=phi=^space^_term_^space^_term_^space^_term_" ∷
"term$=equal=^space^_term_^space^_term_" ∷
"term$=omega=^space^_term_" ∷ -- this is M
"term$=mu=^space^_term_^space^_term_" ∷
"term$=epsilon=^space^_term_" ∷
"term$=zeta=EvalStmt^space^_term_" ∷
"term$=zeta=ShellCmd^space^_term_^space^_term_" ∷
"term$=zeta=CheckTerm^space^_term_^space^_term_" ∷
"term$=zeta=Parse^space^_term_^space^_term_^space^_term_" ∷
"term$=zeta=Normalize^space^_term_" ∷
"term$=zeta=HeadNormalize^space^_term_" ∷
"term$=zeta=InferType^space^_term_" ∷
"term$=zeta=CatchErr^space^_term_^space^_term_" ∷ -- this is not actually in PrimMeta
"term$=kappa=_char_" ∷ -- this constructs a Char
"term$=gamma=^space^_term_^space^_term_" ∷ -- charEq
"lettail$=dot=" ∷ "lettail$=colon=^space'^_term_^space'^=dot=" ∷
"stmt'$let^space^_string_^space'^=colon==equal=^space'^_term_^space'^_lettail_" ∷
"stmt'$ass^space^_string_^space'^=colon=^space'^_term_^space'^=dot=" ∷
"stmt'$seteval^space^_term_^space^_string_^space^_string_^space'^=dot=" ∷
"stmt'$import^space^_string_^space'^=dot=" ∷
"stmt'$" ∷
"stmt$^space'^_stmt'_" ∷
[]
sortGrammar : List (List Char) → SimpleMap (List Char) (List (List Char))
sortGrammar G = mapSnd (map (dropHeadIfAny ∘ dropWhile (¬? ∘ _≟ '$'))) $
mapFromList (takeWhile (¬? ∘ _≟ '$')) G
toInductiveData : String → String → List String → InductiveData
toInductiveData namespace name constrs =
(namespace + "$" + name
, map (λ c → (namespace + "$" + name + "$" + c , map (toConstrData' name) (parseConstrToNonTerminals c)))
constrs)
where
toConstrData' : String → String → ConstrData'
toConstrData' self l = if self ≣ l then Self else Other (namespace + "$" + l)
stringData : InductiveData
stringData =
("init$string"
, ("init$string$cons" , (Other "ΚChar" ∷ Self ∷ [])) ∷ ("init$string$nil" , []) ∷ []) -- capital kappa
stringListData : InductiveData
stringListData =
("init$stringList" ,
("init$stringList$nil" , []) ∷ ("init$stringList$cons" , (Other "init$string" ∷ Self ∷ [])) ∷ [])
termListData : InductiveData
termListData =
("init$termList"
, ("init$termList$nil" , []) ∷ ("init$termList$cons" , (Other "init$term" ∷ Self ∷ [])) ∷ [])
metaResultData : InductiveData
metaResultData =
("init$metaResult"
, ("init$metaResult$pair" , (Other "init$stringList" ∷ Other "init$termList" ∷ [])) ∷ [])
charDataConstructor : Char → String → String
charDataConstructor c prefix =
"let " + prefix + fromList (escapeChar c) + " := κ" + show c + "."
nameInitConstrs : List String
nameInitConstrs = map (flip charDataConstructor "init$nameInitChar$") nameInits
nameTailConstrs : List String
nameTailConstrs = map (flip charDataConstructor "init$nameTailChar$") nameTails
initEnvConstrs : List InductiveData
initEnvConstrs = stringData ∷
(map
(λ { (name , rule) → toInductiveData "init" (fromList name) (map fromList rule) }) $
sortGrammar grammar)
otherInit : List String
otherInit =
map simpleInductive (stringListData ∷ termListData ∷ metaResultData ∷ [])
++ "let init$string$_nameInitChar__string'_ := init$string$cons."
∷ "let init$string'$_nameTailChar__string'_ := init$string$cons."
∷ "let init$string'$ := init$string$nil."
∷ "let init$product := λ A : * λ B : * ∀ X : * Π _ : Π _ : A Π _ : B X X."
∷ "let init$pair := λ A : * λ B : * λ a : A λ b : B Λ X : * λ p : Π _ : A Π _ : B X [[p a] b]."
∷ "let eval := λ s : init$stmt ζEvalStmt s." ∷ "seteval eval init stmt." ∷ []
grammarWithChars : List (List Char)
grammarWithChars = grammar ++
map ("nameTailChar$" ++_) (map escapeChar nameTails) ++
map ("nameInitChar$" ++_) (map escapeChar nameInits) ++
"char$!!" ∷
"string'$_nameTailChar__string'_" ∷ "string'$" ∷
"string$_nameInitChar__string'_" ∷
"var$_string_" ∷ "var$_index_" ∷ []
--------------------------------------------------------------------------------
initEnv : String
initEnv = "let init$char := ΚChar." + Data.String.concat
(map simpleInductive initEnvConstrs ++ nameInitConstrs ++ nameTailConstrs ++ otherInit)
-- a map from non-terminals to their possible expansions
parseRuleMap : SimpleMap (List Char) (List (List Char))
parseRuleMap = from-just $ sequence $ map (λ { (fst , snd) → do
snd' ← sequence (map (λ x → translate $ fst ++ "$" ++ x) snd)
return (fst , reverse snd') }) $ sortGrammar grammarWithChars
coreGrammarGenerator : List (List Char)
coreGrammarGenerator = from-just $ sequence $ map translate grammarWithChars
| {
"alphanum_fraction": 0.6322900869,
"avg_line_length": 41.4457142857,
"ext": "agda",
"hexsha": "400d05218a766147298ff27d3d4c57490c47b599",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z",
"max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "WhatisRT/meta-cedille",
"max_forks_repo_path": "src/Bootstrap/InitEnv.agda",
"max_issues_count": 10,
"max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "WhatisRT/meta-cedille",
"max_issues_repo_path": "src/Bootstrap/InitEnv.agda",
"max_line_length": 122,
"max_stars_count": 35,
"max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "WhatisRT/meta-cedille",
"max_stars_repo_path": "src/Bootstrap/InitEnv.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z",
"num_tokens": 2426,
"size": 7253
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cw.CW
open import homotopy.SphereEndomorphism
open import homotopy.PinSn
open import groups.CoefficientExtensionality
module cw.DegreeBySquashing {i} where
module DegreeAboveOne {n : ℕ} (skel : Skeleton {i} (S (S n)))
(dec : has-cells-with-dec-eq skel)
-- the cells at the upper and lower dimensions
(upper : cells-last skel)
(lower : cells-last (cw-init skel))
where
private
lower-skel = cw-init skel
lower-dec = init-has-cells-with-dec-eq skel dec
lower-cells = cells-last lower-skel
lower-cells-has-dec-eq = cells-last-has-dec-eq lower-skel lower-dec
-- squash the lower CW complex except one of its cells [lower]
cw-squash-lower-to-Sphere : ⟦ lower-skel ⟧ → Sphere (S n)
cw-squash-lower-to-Sphere = Attached-rec (λ _ → north) squash-hubs squash-spokes where
-- squash cells except [lower]
squash-hubs : lower-cells → Sphere (S n)
squash-hubs c with lower-cells-has-dec-eq c lower
... | (inl _) = south
... | (inr _) = north
-- squash cells except [lower]
squash-spokes : (c : lower-cells) → Sphere n
→ north == squash-hubs c
squash-spokes c s with lower-cells-has-dec-eq c lower
... | (inl _) = merid s
... | (inr _) = idp
degree-map : Sphere (S n) → Sphere (S n)
degree-map = cw-squash-lower-to-Sphere ∘ attaching-last skel upper
degree-map' : ℤ-group →ᴳ ℤ-group
degree-map' = –>ᴳ (πS-SphereS-iso-ℤ n)
∘ᴳ Trunc-rec →ᴳ-level (πS-fmap n)
(⊙SphereS-endo-in n [ degree-map ])
∘ᴳ <–ᴳ (πS-SphereS-iso-ℤ n)
degree' : ℤ → ℤ
degree' = GroupHom.f degree-map'
degree : ℤ
degree = degree' 1
module DegreeAtOne (skel : Skeleton {i} 1)
(dec : has-cells-with-dec-eq skel)
-- the cells at the upper and lower dimensions
(line : cells-last skel)
(point : cells-last (cw-init skel)) where
private
points-dec-eq = cells-nth-has-dec-eq (inr ltS) skel dec
endpoint = attaching-last skel
-- Maybe [true] can or should be mapped to [-1]. Not sure.
degree : ℤ
degree with points-dec-eq (endpoint line true) point
degree | inl _ = 1
degree | inr _ with points-dec-eq (endpoint line false) point
degree | inr _ | inl _ = -1
degree | inr _ | inr _ = 0
degree-last : ∀ {n} (skel : Skeleton {i} (S n))
→ has-cells-with-dec-eq skel
→ cells-last skel → cells-last (cw-init skel) → ℤ
degree-last {n = O} = DegreeAtOne.degree
degree-last {n = S _} = DegreeAboveOne.degree
degree-nth : ∀ {m n} (Sm≤n : S m ≤ n) (skel : Skeleton {i} n)
→ has-cells-with-dec-eq skel
→ cells-nth Sm≤n skel → cells-last (cw-init (cw-take Sm≤n skel)) → ℤ
degree-nth Sm≤n skel dec = degree-last (cw-take Sm≤n skel) (take-has-cells-with-dec-eq Sm≤n skel dec)
has-degrees-with-finite-support : ∀ {n} (skel : Skeleton {i} n)
→ has-cells-with-dec-eq skel → Type i
has-degrees-with-finite-support {n = O} _ _ = Lift ⊤
has-degrees-with-finite-support {n = S n} skel dec =
has-degrees-with-finite-support (cw-init skel) (init-has-cells-with-dec-eq skel dec) ×
∀ upper → has-finite-support (cells-nth-has-dec-eq (inr ltS) skel dec) (degree-last skel dec upper)
init-has-degrees-with-finite-support : ∀ {n} (skel : Skeleton {i} (S n)) dec
→ has-degrees-with-finite-support skel dec
→ has-degrees-with-finite-support (cw-init skel) (init-has-cells-with-dec-eq skel dec)
init-has-degrees-with-finite-support skel dec fin-sup = fst fin-sup
take-has-degrees-with-finite-support : ∀ {m n} (m≤n : m ≤ n) (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ has-degrees-with-finite-support (cw-take m≤n skel) (take-has-cells-with-dec-eq m≤n skel dec)
take-has-degrees-with-finite-support (inl idp) skel dec fin-sup = fin-sup
take-has-degrees-with-finite-support (inr ltS) skel dec fin-sup =
init-has-degrees-with-finite-support skel dec fin-sup
take-has-degrees-with-finite-support (inr (ltSR lt)) skel dec fin-sup =
take-has-degrees-with-finite-support (inr lt) (cw-init skel)
(init-has-cells-with-dec-eq skel dec)
(init-has-degrees-with-finite-support skel dec fin-sup)
degree-last-has-finite-support : ∀ {n} (skel : Skeleton {i} (S n)) dec
→ has-degrees-with-finite-support skel dec
→ ∀ upper → has-finite-support
(cells-last-has-dec-eq (cw-init skel) (init-has-cells-with-dec-eq skel dec))
(degree-last skel dec upper)
degree-last-has-finite-support skel dec fin-sup = snd fin-sup
degree-nth-has-finite-support : ∀ {m n} (Sm≤n : S m ≤ n) (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ ∀ upper → has-finite-support
(cells-last-has-dec-eq
(cw-init (cw-take Sm≤n skel))
(init-has-cells-with-dec-eq (cw-take Sm≤n skel) (take-has-cells-with-dec-eq Sm≤n skel dec)))
(degree-nth Sm≤n skel dec upper)
degree-nth-has-finite-support Sm≤n skel dec fin-sup =
degree-last-has-finite-support (cw-take Sm≤n skel)
(take-has-cells-with-dec-eq Sm≤n skel dec)
(take-has-degrees-with-finite-support Sm≤n skel dec fin-sup)
-- the following are named [boundary'] because it is not extended to the free groups
boundary'-last : ∀ {n} (skel : Skeleton {i} (S n)) dec
→ has-degrees-with-finite-support skel dec
→ cells-last skel → FreeAbGroup.El (cells-last (cw-init skel))
boundary'-last skel dec fin-sup upper = fst ((snd fin-sup) upper)
boundary'-nth : ∀ {m n} (Sm≤n : S m ≤ n) (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ cells-nth Sm≤n skel → FreeAbGroup.El (cells-last (cw-init (cw-take Sm≤n skel)))
boundary'-nth Sm≤n skel dec fin-sup =
boundary'-last (cw-take Sm≤n skel)
(take-has-cells-with-dec-eq Sm≤n skel dec)
(take-has-degrees-with-finite-support Sm≤n skel dec fin-sup)
| {
"alphanum_fraction": 0.6435045317,
"avg_line_length": 42.8633093525,
"ext": "agda",
"hexsha": "6fe55737d4b483f9505e349472dd5e29c0e4fc86",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mikeshulman/HoTT-Agda",
"max_forks_repo_path": "theorems/cw/DegreeBySquashing.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mikeshulman/HoTT-Agda",
"max_issues_repo_path": "theorems/cw/DegreeBySquashing.agda",
"max_line_length": 103,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mikeshulman/HoTT-Agda",
"max_stars_repo_path": "theorems/cw/DegreeBySquashing.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2001,
"size": 5958
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Monoidal.Instance.Rels where
-- The category of relations is cartesian and (by self-duality) co-cartesian.
-- Perhaps slightly counter-intuitively if you're used to categories which act
-- like Sets, the product acts on objects as the disjoint union.
open import Data.Empty.Polymorphic using (⊥; ⊥-elim)
import Data.Product as ×
open × using (_,_)
open import Data.Sum using (_⊎_; inj₁; inj₂; [_,_]′)
open import Function using (case_of_; flip)
open import Level using (Lift; lift)
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Categories.Category.Cartesian using (Cartesian; module CartesianMonoidal)
open import Categories.Category.Core using (Category)
open import Categories.Category.Cocartesian using (Cocartesian)
open import Categories.Category.Instance.Rels using (Rels)
module _ {o ℓ} where
Rels-Cartesian : Cartesian (Rels o ℓ)
Rels-Cartesian = record
{ terminal = record
{ ⊤ = ⊥
; ⊤-is-terminal = record
{ ! = λ { _ (lift ()) }
; !-unique = λ _ → (λ { {_} {lift ()} }) , (λ { {_} {lift ()} })
}
}
; products = record
{ product = λ {A} {B} → record
{ A×B = A ⊎ B
; π₁ = [ (λ x y → Lift ℓ (x ≡ y) ) , (λ _ _ → ⊥) ]′
; π₂ = [ (λ _ _ → ⊥) , (λ x y → Lift ℓ (x ≡ y)) ]′
; ⟨_,_⟩ = λ L R c → [ L c , R c ]′
; project₁ = (λ { (inj₁ x , r , lift refl) → r})
, λ r → inj₁ _ , r , lift refl
; project₂ = (λ { (inj₂ _ , r , lift refl) → r })
, (λ r → inj₂ _ , r , lift refl)
; unique =
λ { (p , q) (p′ , q′) → (λ { {_} {inj₁ a} r → case (q {_} {a} r) of λ { (inj₁ .a , s , lift refl) → s}
; {_} {inj₂ b} r → case (q′ {_} {b} r) of λ { (inj₂ .b , s , lift refl) → s} })
, λ { {_} {inj₁ a} hxa → p (inj₁ a , hxa , lift refl)
; {_} {inj₂ b} hxb → p′ (inj₂ b , hxb , lift refl) } }
}
}
}
module Rels-CartesianMonoidal = CartesianMonoidal _ Rels-Cartesian
open Rels-CartesianMonoidal renaming (monoidal to Rels-Monoidal) public
-- because Rels is dual to itself, the proof that it is cocartesian resembles the proof that it's cartesian
-- Rels is not self-dual 'on the nose', so we can't use duality proper.
Rels-Cocartesian : Cocartesian (Rels o ℓ)
Rels-Cocartesian = record
{ initial = record
{ ⊥ = ⊥
; ⊥-is-initial = record
{ ! = λ ()
; !-unique = λ _ → (λ { {()} }) , (λ { {()} })
}
}
; coproducts = record
{ coproduct = λ {A} {B} → record
{ A+B = A ⊎ B
; i₁ = λ a → [ (λ a′ → Lift ℓ (a ≡ a′)) , (λ _ → ⊥) ]′
; i₂ = λ b → [ (λ _ → ⊥) , (λ b′ → Lift ℓ (b ≡ b′)) ]′
; [_,_] = λ L R a+b c → [ flip L c , flip R c ]′ a+b
; inject₁ = (λ { (inj₁ x , lift refl , fxy) → fxy})
, λ r → inj₁ _ , lift refl , r
; inject₂ = (λ { (inj₂ _ , lift refl , r) → r })
, (λ r → inj₂ _ , lift refl , r)
; unique = λ { (p , q) (p′ , q′) → (λ { {inj₁ a} r → case (q {a} r) of λ { (inj₁ .a , lift refl , s) → s}
; {inj₂ b} r → case (q′ {b} r) of λ { (inj₂ .b , lift refl , s) → s} })
, λ { {inj₁ a} hxa → p (inj₁ a , lift refl , hxa)
; {inj₂ b} hxb → p′ (inj₂ b , lift refl , hxb) } }
}
}
}
| {
"alphanum_fraction": 0.4885690093,
"avg_line_length": 43.2073170732,
"ext": "agda",
"hexsha": "72bf57ee45be2920e4680d9dceaccd107133eeae",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "d07746023503cc8f49670e309a6170dc4b404b95",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejbauer/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Monoidal/Instance/Rels.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d07746023503cc8f49670e309a6170dc4b404b95",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "andrejbauer/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Monoidal/Instance/Rels.agda",
"max_line_length": 118,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "TOTBWF/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Monoidal/Instance/Rels.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-18T18:21:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-18T18:21:47.000Z",
"num_tokens": 1197,
"size": 3543
} |
module Common.MAlonzo where
open import Common.Prelude
open import Common.Coinduction
postulate
putStrLn : ∞ String → IO Unit
{-# COMPILED putStrLn putStrLn #-}
main = putStrLn (♯ "This is a dummy main routine.")
mainPrint : String → _
mainPrint s = putStrLn (♯ s)
postulate
natToString : Nat → String
{-# COMPILED natToString show #-}
mainPrintNat : Nat → _
mainPrintNat n = putStrLn (♯ (natToString n))
| {
"alphanum_fraction": 0.7129186603,
"avg_line_length": 17.4166666667,
"ext": "agda",
"hexsha": "6b7e6a1d2a5852ce3e3cf95544dbd0e3396591fd",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/Common/MAlonzo.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/Common/MAlonzo.agda",
"max_line_length": 51,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/Common/MAlonzo.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 112,
"size": 418
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Relations between properties of functions, such as associativity and
-- commutativity
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary using (Rel; Setoid; Substitutive; Symmetric; Total)
module Algebra.FunctionProperties.Consequences
{a ℓ} (S : Setoid a ℓ) where
open Setoid S renaming (Carrier to A)
open import Algebra.FunctionProperties _≈_
open import Data.Sum using (inj₁; inj₂)
open import Data.Product using (_,_)
import Relation.Binary.Consequences as Bin
open import Relation.Binary.Reasoning.Setoid S
open import Relation.Unary using (Pred)
------------------------------------------------------------------------
-- Re-export core properties
open import Algebra.FunctionProperties.Consequences.Core public
------------------------------------------------------------------------
-- Magma-like structures
module _ {_•_ : Op₂ A} (comm : Commutative _•_) where
comm+cancelˡ⇒cancelʳ : LeftCancellative _•_ → RightCancellative _•_
comm+cancelˡ⇒cancelʳ cancelˡ {x} y z eq = cancelˡ x (begin
x • y ≈⟨ comm x y ⟩
y • x ≈⟨ eq ⟩
z • x ≈⟨ comm z x ⟩
x • z ∎)
comm+cancelʳ⇒cancelˡ : RightCancellative _•_ → LeftCancellative _•_
comm+cancelʳ⇒cancelˡ cancelʳ x {y} {z} eq = cancelʳ y z (begin
y • x ≈⟨ comm y x ⟩
x • y ≈⟨ eq ⟩
x • z ≈⟨ comm x z ⟩
z • x ∎)
------------------------------------------------------------------------
-- Monoid-like structures
module _ {_•_ : Op₂ A} (comm : Commutative _•_) {e : A} where
comm+idˡ⇒idʳ : LeftIdentity e _•_ → RightIdentity e _•_
comm+idˡ⇒idʳ idˡ x = begin
x • e ≈⟨ comm x e ⟩
e • x ≈⟨ idˡ x ⟩
x ∎
comm+idʳ⇒idˡ : RightIdentity e _•_ → LeftIdentity e _•_
comm+idʳ⇒idˡ idʳ x = begin
e • x ≈⟨ comm e x ⟩
x • e ≈⟨ idʳ x ⟩
x ∎
comm+zeˡ⇒zeʳ : LeftZero e _•_ → RightZero e _•_
comm+zeˡ⇒zeʳ zeˡ x = begin
x • e ≈⟨ comm x e ⟩
e • x ≈⟨ zeˡ x ⟩
e ∎
comm+zeʳ⇒zeˡ : RightZero e _•_ → LeftZero e _•_
comm+zeʳ⇒zeˡ zeʳ x = begin
e • x ≈⟨ comm e x ⟩
x • e ≈⟨ zeʳ x ⟩
e ∎
------------------------------------------------------------------------
-- Group-like structures
module _ {_•_ : Op₂ A} {_⁻¹ : Op₁ A} {e} (comm : Commutative _•_) where
comm+invˡ⇒invʳ : LeftInverse e _⁻¹ _•_ → RightInverse e _⁻¹ _•_
comm+invˡ⇒invʳ invˡ x = begin
x • (x ⁻¹) ≈⟨ comm x (x ⁻¹) ⟩
(x ⁻¹) • x ≈⟨ invˡ x ⟩
e ∎
comm+invʳ⇒invˡ : RightInverse e _⁻¹ _•_ → LeftInverse e _⁻¹ _•_
comm+invʳ⇒invˡ invʳ x = begin
(x ⁻¹) • x ≈⟨ comm (x ⁻¹) x ⟩
x • (x ⁻¹) ≈⟨ invʳ x ⟩
e ∎
module _ {_•_ : Op₂ A} {_⁻¹ : Op₁ A} {e} (cong : Congruent₂ _•_) where
assoc+id+invʳ⇒invˡ-unique : Associative _•_ →
Identity e _•_ → RightInverse e _⁻¹ _•_ →
∀ x y → (x • y) ≈ e → x ≈ (y ⁻¹)
assoc+id+invʳ⇒invˡ-unique assoc (idˡ , idʳ) invʳ x y eq = begin
x ≈⟨ sym (idʳ x) ⟩
x • e ≈⟨ cong refl (sym (invʳ y)) ⟩
x • (y • (y ⁻¹)) ≈⟨ sym (assoc x y (y ⁻¹)) ⟩
(x • y) • (y ⁻¹) ≈⟨ cong eq refl ⟩
e • (y ⁻¹) ≈⟨ idˡ (y ⁻¹) ⟩
y ⁻¹ ∎
assoc+id+invˡ⇒invʳ-unique : Associative _•_ →
Identity e _•_ → LeftInverse e _⁻¹ _•_ →
∀ x y → (x • y) ≈ e → y ≈ (x ⁻¹)
assoc+id+invˡ⇒invʳ-unique assoc (idˡ , idʳ) invˡ x y eq = begin
y ≈⟨ sym (idˡ y) ⟩
e • y ≈⟨ cong (sym (invˡ x)) refl ⟩
((x ⁻¹) • x) • y ≈⟨ assoc (x ⁻¹) x y ⟩
(x ⁻¹) • (x • y) ≈⟨ cong refl eq ⟩
(x ⁻¹) • e ≈⟨ idʳ (x ⁻¹) ⟩
x ⁻¹ ∎
----------------------------------------------------------------------
-- Bisemigroup-like structures
module _ {_•_ _◦_ : Op₂ A}
(◦-cong : Congruent₂ _◦_)
(•-comm : Commutative _•_)
where
comm+distrˡ⇒distrʳ : _•_ DistributesOverˡ _◦_ → _•_ DistributesOverʳ _◦_
comm+distrˡ⇒distrʳ distrˡ x y z = begin
(y ◦ z) • x ≈⟨ •-comm (y ◦ z) x ⟩
x • (y ◦ z) ≈⟨ distrˡ x y z ⟩
(x • y) ◦ (x • z) ≈⟨ ◦-cong (•-comm x y) (•-comm x z) ⟩
(y • x) ◦ (z • x) ∎
comm+distrʳ⇒distrˡ : _•_ DistributesOverʳ _◦_ → _•_ DistributesOverˡ _◦_
comm+distrʳ⇒distrˡ distrˡ x y z = begin
x • (y ◦ z) ≈⟨ •-comm x (y ◦ z) ⟩
(y ◦ z) • x ≈⟨ distrˡ x y z ⟩
(y • x) ◦ (z • x) ≈⟨ ◦-cong (•-comm y x) (•-comm z x) ⟩
(x • y) ◦ (x • z) ∎
comm⇒sym[distribˡ] : ∀ x → Symmetric (λ y z → (x ◦ (y • z)) ≈ ((x ◦ y) • (x ◦ z)))
comm⇒sym[distribˡ] x {y} {z} prf = begin
x ◦ (z • y) ≈⟨ ◦-cong refl (•-comm z y) ⟩
x ◦ (y • z) ≈⟨ prf ⟩
(x ◦ y) • (x ◦ z) ≈⟨ •-comm (x ◦ y) (x ◦ z) ⟩
(x ◦ z) • (x ◦ y) ∎
----------------------------------------------------------------------
-- Ring-like structures
module _ {_+_ _*_ : Op₂ A}
{_⁻¹ : Op₁ A} {0# : A}
(+-cong : Congruent₂ _+_)
(*-cong : Congruent₂ _*_)
where
assoc+distribʳ+idʳ+invʳ⇒zeˡ : Associative _+_ → _*_ DistributesOverʳ _+_ →
RightIdentity 0# _+_ → RightInverse 0# _⁻¹ _+_ →
LeftZero 0# _*_
assoc+distribʳ+idʳ+invʳ⇒zeˡ +-assoc distribʳ idʳ invʳ x = begin
0# * x ≈⟨ sym (idʳ _) ⟩
(0# * x) + 0# ≈⟨ +-cong refl (sym (invʳ _)) ⟩
(0# * x) + ((0# * x) + ((0# * x)⁻¹)) ≈⟨ sym (+-assoc _ _ _) ⟩
((0# * x) + (0# * x)) + ((0# * x)⁻¹) ≈⟨ +-cong (sym (distribʳ _ _ _)) refl ⟩
((0# + 0#) * x) + ((0# * x)⁻¹) ≈⟨ +-cong (*-cong (idʳ _) refl) refl ⟩
(0# * x) + ((0# * x)⁻¹) ≈⟨ invʳ _ ⟩
0# ∎
assoc+distribˡ+idʳ+invʳ⇒zeʳ : Associative _+_ → _*_ DistributesOverˡ _+_ →
RightIdentity 0# _+_ → RightInverse 0# _⁻¹ _+_ →
RightZero 0# _*_
assoc+distribˡ+idʳ+invʳ⇒zeʳ +-assoc distribˡ idʳ invʳ x = begin
x * 0# ≈⟨ sym (idʳ _) ⟩
(x * 0#) + 0# ≈⟨ +-cong refl (sym (invʳ _)) ⟩
(x * 0#) + ((x * 0#) + ((x * 0#)⁻¹)) ≈⟨ sym (+-assoc _ _ _) ⟩
((x * 0#) + (x * 0#)) + ((x * 0#)⁻¹) ≈⟨ +-cong (sym (distribˡ _ _ _)) refl ⟩
(x * (0# + 0#)) + ((x * 0#)⁻¹) ≈⟨ +-cong (*-cong refl (idʳ _)) refl ⟩
((x * 0#) + ((x * 0#)⁻¹)) ≈⟨ invʳ _ ⟩
0# ∎
------------------------------------------------------------------------
-- Without Loss of Generality
module _ {p} {f : Op₂ A} {P : Pred A p}
(≈-subst : Substitutive _≈_ p)
(comm : Commutative f)
where
subst+comm⇒sym : Symmetric (λ a b → P (f a b))
subst+comm⇒sym = ≈-subst P (comm _ _)
wlog : ∀ {r} {_R_ : Rel _ r} → Total _R_ →
(∀ a b → a R b → P (f a b)) →
∀ a b → P (f a b)
wlog r-total = Bin.wlog r-total subst+comm⇒sym
| {
"alphanum_fraction": 0.4331120215,
"avg_line_length": 36.3025641026,
"ext": "agda",
"hexsha": "a5cfd5b7eb2b9dbdb99979c345d1a8f15f470237",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Algebra/FunctionProperties/Consequences.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Algebra/FunctionProperties/Consequences.agda",
"max_line_length": 84,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Algebra/FunctionProperties/Consequences.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2951,
"size": 7079
} |
{-# OPTIONS --rewriting #-}
open import prelude renaming (_≟Nat_ to _≟_)
-- Copied pretty much verbatim
Var = Nat
data Term : Set where
var : Var → Term
fun : Term → Term
_$_ : Term → Term → Term
true : Term
false : Term
if_then_else_end : Term → Term → Term → Term
data VarHeaded : Term → Set
data Value : Term → Set
data VarHeaded where
var : (x : Var) → VarHeaded(var x)
_$_ : ∀ {t} → VarHeaded(t) → (u : Term) → VarHeaded(t $ u)
if_then_else_end : ∀ {t₀} → VarHeaded(t₀) → (t₁ t₂ : Term) → VarHeaded(if t₀ then t₁ else t₂ end)
data Value where
var : (x : Var) → Value(var x)
fun : (t : Term) → Value(fun t)
_$_ : ∀ {t} → VarHeaded(t) → (u : Term) → Value(t $ u)
if_then_else_end : ∀ {t₀} → VarHeaded(t₀) → (t₁ t₂ : Term) → Value(if t₀ then t₁ else t₂ end)
true : Value true
false : Value false
-- Substitution
shift : Var → Var → Term → Term
shift c d (var x) = if (c ≤? x) (var (d + x)) (var x)
shift c d (fun t) = fun (shift (1 + c) d t)
shift c d (t₁ $ t₂) = (shift c d t₁) $ (shift c d t₂)
shift c d true = true
shift c d false = false
shift c d if t₀ then t₁ else t₂ end = if shift c d t₀ then shift c d t₁ else shift c d t₂ end
[_↦_]_ : Var → Term → Term → Term
[ x ↦ s ] var y = if (x ≟ y) (shift 0 x s) (if (x ≤? y) (var (y - 1)) (var y))
[ x ↦ s ] fun t = fun ([ (1 + x) ↦ s ] t)
[ x ↦ s ] (t₁ $ t₂) = ([ x ↦ s ] t₁) $ ([ x ↦ s ] t₂)
[ x ↦ s ] true = true
[ x ↦ s ] false = false
[ x ↦ s ] if t₀ then t₁ else t₂ end = if [ x ↦ s ] t₀ then [ x ↦ s ] t₁ else [ x ↦ s ] t₂ end
-- Reduction
data _⟶_ : Term → Term → Set where
E─IfTrue : ∀ {t₂ t₃} →
-----------------------------------
if true then t₂ else t₃ end ⟶ t₂
E─IfFalse : ∀ {t₂ t₃} →
-----------------------------------
if false then t₂ else t₃ end ⟶ t₃
E─IfCong : ∀ {t₁ t₁′ t₂ t₃} →
(t₁ ⟶ t₁′) →
----------------------------------------------------------
(if t₁ then t₂ else t₃ end ⟶ if t₁′ then t₂ else t₃ end)
E─App1 : ∀ {t₁ t₁′ t₂} →
(t₁ ⟶ t₁′) →
------------------------
(t₁ $ t₂) ⟶ (t₁′ $ t₂)
E─App2 : ∀ {t₁ t₂ t₂′} →
(t₂ ⟶ t₂′) →
------------------------
(t₁ $ t₂) ⟶ (t₁ $ t₂′)
E─AppAbs : ∀ {t₁ t₂} →
---------------------------------
(fun t₁ $ t₂) ⟶ ([ 0 ↦ t₂ ] t₁)
data Redex : Term → Set where
redex : ∀ {t t′} →
t ⟶ t′ →
--------
Redex(t)
-- Types
data Type : Set where
bool : Type
_⇒_ : Type → Type → Type
data Context : Set where
ε : Context
_,_ : Context → Type → Context
data _∋_⦂_ : Context → Nat → Type → Set where
zero : ∀ {Γ S} → (Γ , S) ∋ zero ⦂ S
suc : ∀ {Γ S T n} → (Γ ∋ n ⦂ T) → (Γ , S) ∋ suc n ⦂ T
data _⊢_⦂_ : Context → Term → Type → Set where
T-True : ∀ {Γ} →
-----------
Γ ⊢ true ⦂ bool
T-False : ∀ {Γ} →
-----------
Γ ⊢ false ⦂ bool
T-If : ∀ {Γ t₁ t₂ t₃ T} →
Γ ⊢ t₁ ⦂ bool →
Γ ⊢ t₂ ⦂ T →
Γ ⊢ t₃ ⦂ T →
-----------------------------
Γ ⊢ if t₁ then t₂ else t₃ end ⦂ T
T-Var : ∀ {Γ n T} →
Γ ∋ n ⦂ T →
------------------------
Γ ⊢ var n ⦂ T
T-Abs : ∀ {Γ t T₁ T₂} →
(Γ , T₁) ⊢ t ⦂ T₂ →
-----------------------
Γ ⊢ (fun t) ⦂ (T₁ ⇒ T₂)
T-App : ∀ {Γ t₁ t₂ T₁₁ T₁₂} →
Γ ⊢ t₁ ⦂ (T₁₁ ⇒ T₁₂) →
Γ ⊢ t₂ ⦂ T₁₁ →
-----------------------
Γ ⊢ (t₁ $ t₂) ⦂ T₁₂
-- Proving that well-typed terms stay well-typed
# : Context → Nat
# ε = 0
# (Γ , x) = 1 + # Γ
_,,_ : Context → Context → Context
Γ ,, ε = Γ
Γ ,, (Δ , T) = (Γ ,, Δ) , T
T-Eq : ∀ {Γ s S T} → (Γ ⊢ s ⦂ S) → (S ≡ T) → (Γ ⊢ s ⦂ T)
T-Eq p refl = p
hit : ∀ {Γ Δ S T} → (((Γ , S) ,, Δ) ∋ # Δ ⦂ T) → (S ≡ T)
hit {Δ = ε} zero = refl
hit {Δ = Δ , R} (suc p) = hit p
left : ∀ {Γ Δ S T n} → (# Δ < n) → (((Γ , S) ,, Δ) ∋ n ⦂ T) → ((Γ ,, Δ) ∋ (n - 1) ⦂ T)
left {n = zero} p q = CONTRADICTION (p zero)
left {Δ = ε} {n = suc n} p (suc q) = q
left {Δ = Δ , R} {n = suc zero} p (suc q) = CONTRADICTION (p (suc zero))
left {Δ = Δ , R} {n = suc (suc n)} p (suc q) = suc (left (λ a → p (suc a)) q)
right : ∀ {Γ Δ S T n} → (n < # Δ) → (((Γ , S) ,, Δ) ∋ n ⦂ T) → ((Γ ,, Δ) ∋ n ⦂ T)
right {Δ = ε} p q = CONTRADICTION (p zero)
right {Δ = Δ , R} p zero = zero
right {Δ = Δ , R} p (suc q) = suc (right (λ z → p (suc z)) q)
this : ∀ {Γ T} n Δ Ξ → (# Ξ ≤ n) → ((Γ ,, Ξ) ∋ n ⦂ T) → (((Γ ,, Δ) ,, Ξ) ∋ (# Δ + n) ⦂ T)
this n ε ε p q = q
this n (Δ , R) ε p q = suc (this n Δ ε p q)
this (suc n) Δ (Ξ , S) (suc p) (suc q) = suc (this n Δ Ξ p q)
that : ∀ {Γ T} n Δ Ξ → (n < # Ξ) → ((Γ ,, Ξ) ∋ n ⦂ T) → (((Γ ,, Δ) ,, Ξ) ∋ n ⦂ T)
that n Δ ε p q = CONTRADICTION (p zero)
that zero Δ (Ξ , S) p zero = zero
that (suc n) Δ (Ξ , S) p (suc q) = suc (that n Δ Ξ (λ z → p (suc z)) q)
preservation-shift : ∀ {Γ s S} Δ Ξ → ((Γ ,, Ξ) ⊢ s ⦂ S) → (((Γ ,, Δ) ,, Ξ) ⊢ shift (# Ξ) (# Δ) s ⦂ S)
preservation-shift Δ Ξ T-True = T-True
preservation-shift Δ Ξ T-False = T-False
preservation-shift Δ Ξ (T-If p p₁ p₂) = T-If (preservation-shift Δ Ξ p) (preservation-shift Δ Ξ p₁)
(preservation-shift Δ Ξ p₂)
preservation-shift {Γ} {var n} {S} Δ Ξ (T-Var p) = helper (# Ξ ≤? n) where
helper : (q : Dec(# Ξ ≤ n)) → ((Γ ,, Δ) ,, Ξ) ⊢ if q (var (# Δ + n)) (var n) ⦂ S
helper (yes q) = T-Var (this n Δ Ξ q p)
helper (no q) = T-Var (that n Δ Ξ q p)
preservation-shift Δ Ξ (T-Abs p) = T-Abs (preservation-shift Δ (Ξ , _) p)
preservation-shift Δ Ξ (T-App p p₁) = T-App (preservation-shift Δ Ξ p) (preservation-shift Δ Ξ p₁)
preservation-substitution : ∀ {Γ s t S T} → (Γ ⊢ s ⦂ S) → (Δ : Context) → (((Γ , S) ,, Δ) ⊢ t ⦂ T) → ((Γ ,, Δ) ⊢ [ # Δ ↦ s ] t ⦂ T)
preservation-substitution {Γ} {s} {t} {S} {T} p Δ (T-Var {n = n} q) = helper (# Δ ≟ n) (# Δ ≤? n) where
helper : (p : Dec(# Δ ≡ n)) → (q : Dec(# Δ ≤ n)) → (Γ ,, Δ) ⊢ if p (shift 0 (# Δ) s) (if q (var (n - 1)) (var n)) ⦂ T
helper (yes refl) _ = T-Eq (preservation-shift Δ ε p) (hit q)
helper (no a) (yes b) = T-Var (left (λ c → a (asym b c)) q)
helper (no a) (no b) = T-Var (right b q)
preservation-substitution p Δ T-True = T-True
preservation-substitution p Δ T-False = T-False
preservation-substitution p Δ (T-If q q₁ q₂) = T-If (preservation-substitution p Δ q)
(preservation-substitution p Δ q₁)
(preservation-substitution p Δ q₂)
preservation-substitution p Δ (T-Abs q) = T-Abs (preservation-substitution p (Δ , _) q)
preservation-substitution p Δ (T-App q q₁) = T-App (preservation-substitution p Δ q)
(preservation-substitution p Δ q₁)
preservation : ∀ {Γ t t′ T} → (Γ ⊢ t ⦂ T) → (t ⟶ t′) → (Γ ⊢ t′ ⦂ T)
preservation (T-If p₁ p₂ p₃) E─IfTrue = p₂
preservation (T-If p₁ p₂ p₃) E─IfFalse = p₃
preservation (T-If p₁ p₂ p₃) (E─IfCong q) = T-If (preservation p₁ q) p₂ p₃
preservation (T-App p₁ p₂) (E─App1 q) = T-App (preservation p₁ q) p₂
preservation (T-App p₁ p₂) (E─App2 q) = T-App p₁ (preservation p₂ q)
preservation (T-App (T-Abs p₁) p₂) E─AppAbs = preservation-substitution p₂ ε p₁
-- Proving that every term is a value or a redex
data ValueOrRedex : Term → Set where
value : ∀ {t} →
(Value(t)) →
---------------
ValueOrRedex(t)
redex : ∀ {t t′} →
t ⟶ t′ →
---------------
ValueOrRedex(t)
progress : ∀ {Γ t T} → (Γ ⊢ t ⦂ T) → ValueOrRedex(t)
progress T-True = value true
progress T-False = value false
progress (T-If p₁ p₂ p₃) = helper (progress p₁) p₁ where
helper : ∀ {Γ t₀ t₁ t₂} → ValueOrRedex(t₀) → (Γ ⊢ t₀ ⦂ bool) → ValueOrRedex(if t₀ then t₁ else t₂ end)
helper (value true) p = redex E─IfTrue
helper (value false) p = redex E─IfFalse
helper (value (var x)) p = value (if var x then _ else _ end)
helper (value (if t₃ then t₄ else t₅ end)) p = value if if t₃ then t₄ else t₅ end then _ else _ end
helper (value (t₁ $ t₂)) p = value if (t₁ $ t₂) then _ else _ end
helper (redex r) p = redex (E─IfCong r)
progress (T-Var {n = n} p) = value (var n)
progress (T-Abs {t = t} p) = value (fun t)
progress (T-App p₁ p₂) = helper (progress p₁) p₁ where
helper : ∀ {Γ t₁ t₂ T₁₁ T₁₂} → ValueOrRedex(t₁) → (Γ ⊢ t₁ ⦂ (T₁₁ ⇒ T₁₂)) → ValueOrRedex(t₁ $ t₂)
helper (value (var x)) p = value (var x $ _)
helper (value (fun t)) p = redex E─AppAbs
helper (value (t₃ $ t₄)) p = value ((t₃ $ t₄) $ _)
helper (value (if t₃ then t₄ else t₅ end)) p = value (if t₃ then t₄ else t₅ end $ _)
helper (redex r) p = redex (E─App1 r)
-- Interpreter
data _⟶*_ : Term → Term → Set where
done : ∀ {t} →
--------
t ⟶* t
redex : ∀ {t t′ t″} →
t ⟶ t′ →
t′ ⟶* t″ →
----------
t ⟶* t″
-- An interpreter result
data Result : Term → Set where
result : ∀ {t t′} →
t ⟶* t′ →
Value(t′) →
---------
Result(t)
-- The interpreter just calls `progress` until it is a value.
-- This might bot terminate!
{-# NON_TERMINATING #-}
interp : ∀ {Γ t T} → (Γ ⊢ t ⦂ T) → Result(t)
interp p = helper₂ p (progress p) where
helper₁ : ∀ {t t′} → (t ⟶ t′) → Result(t′) → Result(t)
helper₁ r (result s v) = result (redex r s) v
helper₂ : ∀ {Γ t T} → (Γ ⊢ t ⦂ T) → ValueOrRedex(t) → Result(t)
helper₂ p (value v) = result done v
helper₂ p (redex r) = helper₁ r (interp (preservation p r))
| {
"alphanum_fraction": 0.4971161171,
"avg_line_length": 29.8344155844,
"ext": "agda",
"hexsha": "cfc0f4b3e21dbe5cfe42a4df6f1b1fb21a9affd2",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "asajeffrey/tapl",
"max_forks_repo_path": "ch9.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "asajeffrey/tapl",
"max_issues_repo_path": "ch9.agda",
"max_line_length": 131,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "de2ae6c24d001b85a5032c9e06cc731557dbc5e5",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "asajeffrey/tapl",
"max_stars_repo_path": "ch9.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-15T12:09:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-03-12T22:44:19.000Z",
"num_tokens": 3860,
"size": 9189
} |
module PublicWithoutOpen2 where
import Imports.A public
| {
"alphanum_fraction": 0.8596491228,
"avg_line_length": 14.25,
"ext": "agda",
"hexsha": "5262cddd3a72b46377fa43aae459f7a8255a3998",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/PublicWithoutOpen2.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/PublicWithoutOpen2.agda",
"max_line_length": 31,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/PublicWithoutOpen2.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 12,
"size": 57
} |
open import Oscar.Prelude
open import Oscar.Data.¶
module Oscar.Data.Fin where
data ¶⟨<_⟩ : ¶ → Ø₀ where
∅ : ∀ {n} → ¶⟨< ↑ n ⟩
↑_ : ∀ {n} → ¶⟨< n ⟩ → ¶⟨< ↑ n ⟩
Fin = ¶⟨<_⟩
module Fin = ¶⟨<_⟩
| {
"alphanum_fraction": 0.48,
"avg_line_length": 14.2857142857,
"ext": "agda",
"hexsha": "e25a1e9c6f9e3e49a1123b105b4c67d60b5fd3ab",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/Oscar/Data/Fin.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Data/Fin.agda",
"max_line_length": 34,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-3/src/Oscar/Data/Fin.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 95,
"size": 200
} |
-- Tests for withNormalisation
module _ where
open import Agda.Builtin.Reflection
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
open import Agda.Builtin.Bool
open import Agda.Builtin.Unit
open import Agda.Builtin.List
infixl 4 _>>=_
_>>=_ = bindTC
F : Bool → Set
F false = Nat
F true = Bool
data D (b : Bool) : Set where
_&&_ : Bool → Bool → Bool
true && x = x
false && _ = false
postulate
reflected : ∀ {a} {A : Set a} → Term → A
pattern vArg x = arg (arg-info visible relevant) x
useReflected : Term → Term → TC ⊤
useReflected hole goal =
quoteTC goal >>= λ `goal →
unify hole (def (quote reflected) (vArg `goal ∷ []))
macro
error : Term → TC ⊤
error hole =
inferType hole >>= λ goal → typeError (termErr goal ∷ [])
reflect : Term → TC ⊤
reflect hole = inferType hole >>= useReflected hole
reflectN : Term → TC ⊤
reflectN hole = withNormalisation true (inferType hole) >>= useReflected hole
test₁ : D (true && false)
test₁ = reflect
test₂ : D (true && false)
test₂ = reflectN
pattern `D x = def (quote D) (vArg x ∷ [])
pattern `true = con (quote true) []
pattern `false = con (quote false) []
pattern _`&&_ x y = def (quote _&&_) (vArg x ∷ vArg y ∷ [])
check₁ : test₁ ≡ reflected (`D (`true `&& `false))
check₁ = refl
check₂ : test₂ ≡ reflected (`D `false)
check₂ = refl
| {
"alphanum_fraction": 0.6546546547,
"avg_line_length": 21.1428571429,
"ext": "agda",
"hexsha": "492caddb55d3cd0306396257b0dd97b8e2ed553d",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/TCFlags.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/TCFlags.agda",
"max_line_length": 79,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/TCFlags.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 424,
"size": 1332
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Group.Semidirect where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Structure
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Morphism
open import Cubical.Algebra.Group.Notation
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.Action
open import Cubical.Data.Sigma
private
variable
ℓ ℓ' : Level
module _ where
semidirectProd : (G : Group {ℓ}) (H : Group {ℓ'}) (Act : GroupAction H G) → Group {ℓ-max ℓ ℓ'}
semidirectProd G H Act = makeGroup-left {A = sd-carrier} sd-0 _+sd_ -sd_ sd-set sd-assoc sd-lId sd-lCancel
where
open ActionNotationα Act
open ActionLemmas Act
open GroupNotationG G
open GroupNotationᴴ H
-- sd stands for semidirect
sd-carrier = ⟨ G ⟩ × ⟨ H ⟩
sd-0 = 0ᴳ , 0ᴴ
module _ ((g , h) : sd-carrier) where
-sd_ = (-ᴴ h) α (-ᴳ g) , -ᴴ h
_+sd_ = λ (g' , h') → g +ᴳ (h α g') , h +ᴴ h'
abstract
sd-set = isSetΣ setᴳ (λ _ → setᴴ)
sd-lId = λ ((g , h) : sd-carrier) → ΣPathP (lIdᴳ (0ᴴ α g) ∙ (α-id g) , lIdᴴ h)
sd-lCancel = λ ((g , h) : sd-carrier) → ΣPathP ((sym (α-hom (-ᴴ h) (-ᴳ g) g) ∙∙ cong ((-ᴴ h) α_) (lCancelᴳ g) ∙∙ actOnUnit (-ᴴ h)) , lCancelᴴ h)
sd-assoc = λ (a , x) (b , y) (c , z) → ΣPathP ((a +ᴳ (x α (b +ᴳ (y α c)))
≡⟨ cong (a +ᴳ_) (α-hom x b (y α c)) ⟩
a +ᴳ ((x α b) +ᴳ (x α (y α c)))
≡⟨ assocᴳ a (x α b) (x α (y α c)) ⟩
(a +ᴳ (x α b)) +ᴳ (x α (y α c))
≡⟨ cong ((a +ᴳ (x α b)) +ᴳ_) (sym (α-assoc x y c)) ⟩
(a +ᴳ (x α b)) +ᴳ ((x +ᴴ y) α c) ∎) , assocᴴ x y z)
-- this syntax declaration is the reason we can't unify semidirectProd with
-- the projections module
syntax semidirectProd G H α = G ⋊⟨ α ⟩ H
module _ {G : Group {ℓ}} {H : Group {ℓ'}} (Act : GroupAction H G) where
open ActionNotationα Act
open ActionLemmas Act
open GroupNotationG G
open GroupNotationᴴ H
π₁ : ⟨ G ⋊⟨ Act ⟩ H ⟩ → ⟨ G ⟩
π₁ = fst
ι₁ : GroupHom G (G ⋊⟨ Act ⟩ H)
ι₁ = grouphom (λ g → g , 0ᴴ) λ g g' → ΣPathP (cong (g +ᴳ_) (sym (α-id g')), sym (lIdᴴ 0ᴴ))
π₂ : GroupHom (G ⋊⟨ Act ⟩ H) H
-- π₂ = grouphom snd λ _ _ → refl
π₂ = grouphom snd λ (g , h) (g' , h') → refl {x = h +ᴴ h'}
ι₂ : GroupHom H (G ⋊⟨ Act ⟩ H)
ι₂ = grouphom (λ h → 0ᴳ , h) λ h h' → ΣPathP (sym (actOnUnit h) ∙ sym (lIdᴳ (h α 0ᴳ)) , refl)
π₂-hasSec : isGroupSplitEpi ι₂ π₂
π₂-hasSec = GroupMorphismExt (λ _ → refl)
| {
"alphanum_fraction": 0.5429403202,
"avg_line_length": 36.1578947368,
"ext": "agda",
"hexsha": "3ecaecf6262036d2db2e79ab7e10f4c9b51b48fe",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Schippmunk/cubical",
"max_forks_repo_path": "Cubical/Algebra/Group/Semidirect.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Schippmunk/cubical",
"max_issues_repo_path": "Cubical/Algebra/Group/Semidirect.agda",
"max_line_length": 152,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Schippmunk/cubical",
"max_stars_repo_path": "Cubical/Algebra/Group/Semidirect.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1136,
"size": 2748
} |
------------------------------------------------------------------------
-- The delay monad is a monad up to strong bisimilarity
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
module Delay-monad.Monad where
open import Equality.Propositional
open import Prelude
open import Prelude.Size
open import Conat equality-with-J as Conat using (zero; suc; force)
open import Monad equality-with-J
open import Delay-monad
open import Delay-monad.Bisimilarity as B
------------------------------------------------------------------------
-- Map, join and bind
-- A universe-polymorphic variant of map.
map′ : ∀ {i a b} {A : Type a} {B : Type b} →
(A → B) → Delay A i → Delay B i
map′ f (now x) = now (f x)
map′ f (later x) = later λ { .force → map′ f (force x) }
-- Join.
join : ∀ {i a} {A : Type a} →
Delay (Delay A i) i → Delay A i
join (now x) = x
join (later x) = later λ { .force → join (force x) }
-- A universe-polymorphic variant of bind.
infixl 5 _>>=′_
_>>=′_ : ∀ {i a b} {A : Type a} {B : Type b} →
Delay A i → (A → Delay B i) → Delay B i
x >>=′ f = join (map′ f x)
instance
-- A raw monad instance.
delay-raw-monad : ∀ {a i} → Raw-monad (λ (A : Type a) → Delay A i)
Raw-monad.return delay-raw-monad = now
Raw-monad._>>=_ delay-raw-monad = _>>=′_
------------------------------------------------------------------------
-- Monad laws
left-identity′ :
∀ {a b} {A : Type a} {B : Type b} x (f : A → Delay B ∞) →
return x >>=′ f ∼ f x
left-identity′ x f = reflexive (f x)
right-identity′ : ∀ {a i} {A : Type a} (x : Delay A ∞) →
[ i ] x >>= return ∼ x
right-identity′ (now x) = now
right-identity′ (later x) = later λ { .force →
right-identity′ (force x) }
associativity′ :
∀ {a b c i} {A : Type a} {B : Type b} {C : Type c} →
(x : Delay A ∞) (f : A → Delay B ∞) (g : B → Delay C ∞) →
[ i ] x >>=′ (λ x → f x >>=′ g) ∼ x >>=′ f >>=′ g
associativity′ (now x) f g = reflexive (f x >>=′ g)
associativity′ (later x) f g = later λ { .force →
associativity′ (force x) f g }
-- The delay monad is a monad (assuming extensionality).
delay-monad :
∀ {a} → B.Extensionality a → Monad (λ (A : Type a) → Delay A ∞)
Monad.raw-monad (delay-monad ext) = delay-raw-monad
Monad.left-identity (delay-monad ext) x f = ext (left-identity′ x f)
Monad.right-identity (delay-monad ext) x = ext (right-identity′ x)
Monad.associativity (delay-monad ext) x f g = ext (associativity′ x f g)
------------------------------------------------------------------------
-- The functions map′, join and _>>=′_ preserve strong and weak
-- bisimilarity and expansion
map-cong : ∀ {k i a b} {A : Type a} {B : Type b}
(f : A → B) {x y : Delay A ∞} →
[ i ] x ⟨ k ⟩ y → [ i ] map′ f x ⟨ k ⟩ map′ f y
map-cong f now = now
map-cong f (later p) = later λ { .force → map-cong f (force p) }
map-cong f (laterˡ p) = laterˡ (map-cong f p)
map-cong f (laterʳ p) = laterʳ (map-cong f p)
join-cong : ∀ {k i a} {A : Type a} {x y : Delay (Delay A ∞) ∞} →
[ i ] x ⟨ k ⟩ y → [ i ] join x ⟨ k ⟩ join y
join-cong now = reflexive _
join-cong (later p) = later λ { .force → join-cong (force p) }
join-cong (laterˡ p) = laterˡ (join-cong p)
join-cong (laterʳ p) = laterʳ (join-cong p)
infixl 5 _>>=-cong_
_>>=-cong_ :
∀ {k i a b} {A : Type a} {B : Type b}
{x y : Delay A ∞} {f g : A → Delay B ∞} →
[ i ] x ⟨ k ⟩ y → (∀ z → [ i ] f z ⟨ k ⟩ g z) →
[ i ] x >>=′ f ⟨ k ⟩ y >>=′ g
now >>=-cong q = q _
later p >>=-cong q = later λ { .force → force p >>=-cong q }
laterˡ p >>=-cong q = laterˡ (p >>=-cong q)
laterʳ p >>=-cong q = laterʳ (p >>=-cong q)
------------------------------------------------------------------------
-- A lemma
-- The function map′ can be expressed using _>>=′_ and now.
map∼>>=-now :
∀ {i a b} {A : Type a} {B : Type b} {f : A → B} (x : Delay A ∞) →
[ i ] map′ f x ∼ x >>=′ now ∘ f
map∼>>=-now (now x) = now
map∼>>=-now (later x) = later λ { .force → map∼>>=-now (x .force) }
------------------------------------------------------------------------
-- Some lemmas relating monadic combinators to steps
-- Use of map′ does not affect the number of steps in the computation.
steps-map′ :
∀ {i a b} {A : Type a} {B : Type b} {f : A → B}
(x : Delay A ∞) →
Conat.[ i ] steps (map′ f x) ∼ steps x
steps-map′ (now x) = zero
steps-map′ (later x) = suc λ { .force → steps-map′ (x .force) }
-- Use of _⟨$⟩_ does not affect the number of steps in the
-- computation.
steps-⟨$⟩ :
∀ {i ℓ} {A B : Type ℓ} {f : A → B}
(x : Delay A ∞) →
Conat.[ i ] steps (f ⟨$⟩ x) ∼ steps x
steps-⟨$⟩ (now x) = zero
steps-⟨$⟩ (later x) = suc λ { .force → steps-⟨$⟩ (x .force) }
| {
"alphanum_fraction": 0.4860508369,
"avg_line_length": 33.1438356164,
"ext": "agda",
"hexsha": "3ca82384cd5f4110f88c91af29a02018dc3a833a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/delay-monad",
"max_forks_repo_path": "src/Delay-monad/Monad.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/delay-monad",
"max_issues_repo_path": "src/Delay-monad/Monad.agda",
"max_line_length": 73,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/delay-monad",
"max_stars_repo_path": "src/Delay-monad/Monad.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1658,
"size": 4839
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.