Search is not available for this dataset
text
string | meta
dict |
---|---|
{-# OPTIONS --without-K --safe #-}
open import Algebra.Structures.Bundles.Field
module Algebra.Linear.Construct.Vector
{k ℓ} (K : Field k ℓ)
where
open import Level using (_⊔_)
open import Data.Product using (_×_; _,_)
open import Data.Vec public hiding (sum)
import Data.Vec.Properties as VP
import Data.Vec.Relation.Binary.Pointwise.Inductive as PW
open import Data.Nat hiding (_⊔_) renaming (_+_ to _+ℕ_)
open import Data.Fin using (Fin)
open import Relation.Binary
open import Algebra.Linear.Core
open import Algebra.FunctionProperties
open import Relation.Binary.PropositionalEquality as P
using (_≡_; subst; subst-subst-sym)
renaming
( refl to ≡-refl
; sym to ≡-sym
; trans to ≡-trans
)
open import Algebra.Structures.Field.Utils K
import Algebra.Linear.Structures.VectorSpace as VS
open VS.VectorSpaceField K
open import Data.Nat.Properties
using
( ≤-refl
; ≤-reflexive
; ≤-antisym
; n∸n≡0
; m+[n∸m]≡n
; m≤m+n
; suc-injective
)
renaming
( +-identityˡ to +ℕ-identityˡ
; +-identityʳ to +ℕ-identityʳ
)
private
V : ℕ -> Set k
V = Vec K'
splitAt' : ∀ {n} (i : ℕ) (j : ℕ) -> i +ℕ j ≡ n -> V n → V i × V j
splitAt' {0} 0 0 r [] = ([] , [])
splitAt' {suc n} 0 (suc j) r u = ([] , subst V (≡-sym r) u)
splitAt' {suc n} (suc i) j r (x ∷ xs) =
let (xs₁ , xs₂) = splitAt' {n} i j (suc-injective r) xs
in (x ∷ xs₁ , xs₂)
open PW public
using ()
renaming
( _∷_ to ≈-cons
; [] to ≈-null
; head to ≈-head
; tail to ≈-tail
; uncons to ≈-uncons
; lookup to ≈-lookup
; map to ≈-map
)
_≈ʰ_ : ∀ {m n} (xs : Vec K' m) (ys : Vec K' n) → Set (k ⊔ ℓ)
_≈ʰ_ = PW.Pointwise _≈ᵏ_
_≈_ : ∀ {n} (xs : Vec K' n) (ys : Vec K' n) → Set (k ⊔ ℓ)
_≈_ = _≈ʰ_
≈-isEquiv : ∀ {n} -> IsEquivalence (_≈_ {n})
≈-isEquiv {n} = PW.isEquivalence ≈ᵏ-isEquiv n
setoid : ℕ -> Setoid k (k ⊔ ℓ)
setoid n = record { isEquivalence = ≈-isEquiv {n} }
module _ {n} where
open IsEquivalence (≈-isEquiv {n}) public
using ()
renaming
( refl to ≈-refl
; sym to ≈-sym
; trans to ≈-trans
; reflexive to ≈-reflexive
)
0# : ∀ {n} → V n
0# {0} = []
0# {suc n} = 0ᵏ ∷ 0# {n}
-_ : ∀ {n} → V n → V n
-_ = map (-ᵏ_)
infixr 25 _+_
_+_ : ∀ {n} → Op₂ (V n)
_+_ = zipWith _+ᵏ_
infixr 35 _∙_
_∙_ : ∀ {n} → K' → V n → V n
_∙_ k = map (k *ᵏ_)
{-
module HeterogeneousEquivalence where
import Relation.Binary.Indexed.Heterogeneous as IH
data _≈ʰ_ : IH.IRel V (k ⊔ ℓ) where
≈ʰ-null : ∀ {n p} {u : V n} {v : V p} -> n ≡ 0 -> p ≡ 0 -> u ≈ʰ v
≈ʰ-cons : ∀ {n p} {x y : K'} {u : V n} {v : V p} -> n ≡ p -> x ≈ᵏ y -> u ≈ʰ v -> (x ∷ u) ≈ʰ (y ∷ v)
pattern ≈ʰ-zero = ≈ʰ-null ≡-refl ≡-refl
≈ʰ-refl : IH.Reflexive V _≈ʰ_
≈ʰ-refl {0} {[]} = ≈ʰ-zero
≈ʰ-refl {suc n} {x ∷ xs} = ≈ʰ-cons (≡-refl) ≈ᵏ-refl (≈ʰ-refl {n} {xs})
≈ʰ-sym : IH.Symmetric V _≈ʰ_
≈ʰ-sym {0} ≈ʰ-zero = ≈ʰ-zero
≈ʰ-sym {suc n} (≈ʰ-cons rn r rs) = ≈ʰ-cons (≡-sym rn) (≈ᵏ-sym r) (≈ʰ-sym rs)
≈ʰ-trans : IH.Transitive V _≈ʰ_
≈ʰ-trans (≈ʰ-null rn rp) (≈ʰ-null rn' rp') = ≈ʰ-null rn rp'
≈ʰ-trans (≈ʰ-cons rn r rs) (≈ʰ-cons rn' r' rs') = ≈ʰ-cons (≡-trans rn rn') (≈ᵏ-trans r r') (≈ʰ-trans rs rs')
≈ʰ-isEquiv : IH.IsIndexedEquivalence V _≈ʰ_
≈ʰ-isEquiv = record
{ refl = ≈ʰ-refl
; sym = ≈ʰ-sym
; trans = ≈ʰ-trans
}
≈-to-≈ʰ : ∀ {n} {u v : V n} -> u ≈ v -> u ≈ʰ v
≈-to-≈ʰ {0} ≈-null = ≈ʰ-zero
≈-to-≈ʰ {suc n} (≈-cons r rs) = ≈ʰ-cons ≡-refl r (≈-to-≈ʰ rs)
≈ʰ-to-≈ : ∀ {n} {u v : V n} -> u ≈ʰ v -> u ≈ v
≈ʰ-to-≈ {0} {[]} {[]} ≈ʰ-zero = ≈-null
≈ʰ-to-≈ {suc n} (≈ʰ-cons _ r rs) = ≈-cons r (≈ʰ-to-≈ rs)
≈ʰ-tail : ∀ {n p} {x y : K'} {u : V n} {v : V p} -> (x ∷ u) ≈ʰ (x ∷ v) -> u ≈ʰ v
≈ʰ-tail (≈ʰ-cons _ _ r) = r
indexedSetoid : IH.IndexedSetoid ℕ k (ℓ ⊔ k)
indexedSetoid = record
{ Carrier = V
; _≈_ = _≈ʰ_
; isEquivalence = ≈ʰ-isEquiv
}
setoid : ℕ -> Setoid k (k ⊔ ℓ)
setoid n = record
{ Carrier = V n
; _≈_ = _≈_
; isEquivalence = ≈-isEquiv
}
-}
++-identityˡ : ∀ {n} (u : V n) -> ([] ++ u) ≈ u
++-identityˡ _ = ≈-refl
++-cong : ∀ {n p} {u₁ v₁ : V n} {u₂ v₂ : V p}
-> u₁ ≈ v₁ -> u₂ ≈ v₂ -> (u₁ ++ u₂) ≈ (v₁ ++ v₂)
++-cong ≈-null r₂ = r₂
++-cong (≈-cons r₁ rs₁) r₂ = ≈-cons r₁ (++-cong rs₁ r₂)
++-split : ∀ {n p} {u₁ v₁ : V n} {u₂ v₂ : V p}
-> (u₁ ++ u₂) ≈ (v₁ ++ v₂) -> (u₁ ≈ v₁ × u₂ ≈ v₂)
++-split {0} {p} {[]} {[]} r = ≈-null , r
++-split {suc n} {p} {x ∷ xs} {y ∷ ys} (≈-cons r rs) =
let (r₁ , r₂) = ++-split {n} {p} rs
in (≈-cons r r₁) , r₂
0++0≈0 : ∀ {n p} -> (0# {n} ++ 0# {p}) ≈ 0# {n +ℕ p}
0++0≈0 {zero} = ++-identityˡ 0#
0++0≈0 {suc n} = ≈-cons ≈ᵏ-refl (0++0≈0 {n})
{-
open HeterogeneousEquivalence
++-identityʳ-≈ʰ : ∀ {n} (u : V n) -> (u ++ []) ≈ʰ u
++-identityʳ-≈ʰ [] = ≈ʰ-refl
++-identityʳ-≈ʰ {suc n} (x ∷ xs) = ≈ʰ-cons (+ℕ-identityʳ n) ≈ᵏ-refl (++-identityʳ-≈ʰ {n} xs)
++-cong-≈ʰ : ∀ {n p} {u₁ v₁ : V n} {u₂ v₂ : V p}
-> u₁ ≈ʰ v₁ -> u₂ ≈ʰ v₂ -> (u₁ ++ u₂) ≈ʰ (v₁ ++ v₂)
++-cong-≈ʰ r₁ r₂ = ≈-to-≈ʰ (++-cong (≈ʰ-to-≈ r₁) (≈ʰ-to-≈ r₂))
splitAt-identityˡ : ∀ {n} (u : V n) -> let (x₁ , x₂) = splitAt 0 z≤n u in (x₁ ≈ʰ []) × (x₂ ≈ʰ u)
splitAt-identityˡ {0}_ = ≈ʰ-zero , ≈ʰ-zero
splitAt-identityˡ {suc n} _ = ≈ʰ-zero , ≈ʰ-refl
splitAt-identityʳ : ∀ {n} (u : V n) -> let (x₁ , x₂) = splitAt n ≤-refl u in (x₁ ≈ʰ u) × (x₂ ≈ʰ [])
splitAt-identityʳ {0} [] = ≈ʰ-refl , ≈ʰ-refl
splitAt-identityʳ {suc n} (x ∷ xs) = ≈ʰ-cons ≡-refl ≈ᵏ-refl (proj₁ (splitAt-identityʳ xs))
, ≈ʰ-null (n∸n≡0 (suc n)) ≡-refl
++-splitAt : ∀ {n} (k : ℕ) (r : k ≤ n) (u : V n) -> let (x₁ , x₂, _) = splitAt n u in (x₁ ++ x₂) ≡ u
++-splitAt {0} 0 r u = ≈ʰ-null (m+[n∸m]≡n r) ≡-refl
++-splitAt {suc n} 0 r (x ∷ xs) = ≈ʰ-refl
++-splitAt {suc n} (suc k) sk≤sn (x ∷ xs) =
let k≤n = ≤-pred sk≤sn
in ≈ʰ-cons (m+[n∸m]≡n k≤n) ≈ᵏ-refl (++-splitAt k k≤n xs)
splitAt-++ : ∀ {n p} (u : Vec n) (v : Vec p) ->
let (u' , v') = splitAt n (m≤m+n n p) (u ++ v) in (u ≈ʰ u') × (v ≈ʰ v')
splitAt-++ {0} {0} [] [] = ≈ʰ-zero , ≈ʰ-zero
splitAt-++ {0} {suc p} [] (y ∷ ys) = ≈ʰ-zero , ≈ʰ-refl
splitAt-++ {suc n} {0} (x ∷ xs) [] =
let (rxs , rv) = splitAt-++ xs []
in ≈ʰ-cons ≡-refl ≈ᵏ-refl rxs , rv
splitAt-++ {suc n} {suc p} (x ∷ xs) (y ∷ ys) =
let (u' , v') = splitAt (suc n) (m≤m+n (suc n) (suc p)) (x ∷ xs ++ y ∷ ys)
(ru , rys) = splitAt-++ {suc n} {p} (x ∷ xs) ys
(rxs , rv) = splitAt-++ {n} {suc p} xs (y ∷ ys)
in ≈ʰ-cons ≡-refl ≈ᵏ-refl rxs , rv
++-splitAt' : ∀ {n p} (u : Vec (n +ℕ p)) -> let (x₁ , x₂) = splitAt' n p ≡-refl u in x₁ ++ x₂ ≈ u
++-splitAt' {0} [] = ≈-null
++-splitAt' {0} (x ∷ xs) = ≈-refl
++-splitAt' {suc n} (x ∷ xs) = ≈-cons ≈ᵏ-refl (++-splitAt' {n} xs)
splitAt'-++ : ∀ {n p} (u : Vec n) (v : Vec p) ->
let (u' , v') = splitAt' n p ≡-refl (u ++ v) in (u ≈ u') × (v ≈ v')
splitAt'-++ {0} {0} [] [] = ≈-null , ≈-null
splitAt'-++ {0} {suc p} [] (y ∷ ys) = ≈-null , ≈-refl
splitAt'-++ {suc n} {0} (x ∷ xs) [] =
let (rxs , rv) = splitAt'-++ xs []
in ≈-cons ≈ᵏ-refl rxs , rv
splitAt'-++ {suc n} {suc p} (x ∷ xs) (y ∷ ys) =
let (u' , v') = splitAt' (suc n) (suc p) ≡-refl (x ∷ xs ++ y ∷ ys)
(ru , rys) = splitAt'-++ {suc n} {p} (x ∷ xs) ys
(rxs , rv) = splitAt'-++ {n} {suc p} xs (y ∷ ys)
in ≈-cons ≈ᵏ-refl rxs , rv
-}
+-cong : ∀ {n} → Congruent₂ (_≈_ {n}) _+_
+-cong ≈-null ≈-null = ≈-null
+-cong (≈-cons r₁ rs₁) (≈-cons r₂ rs₂) = ≈-cons (+ᵏ-cong r₁ r₂) (+-cong rs₁ rs₂)
+-assoc : ∀ {n} → Associative (_≈_ {n}) _+_
+-assoc [] [] [] = ≈-null
+-assoc (x ∷ xs) (y ∷ ys) (z ∷ zs) = ≈-cons (+ᵏ-assoc x y z) (+-assoc xs ys zs)
+-identityˡ : ∀ {n} → LeftIdentity (_≈_ {n}) 0# _+_
+-identityˡ [] = ≈-null
+-identityˡ (x ∷ xs) = ≈-cons (+ᵏ-identityˡ x) (+-identityˡ xs)
+-identityʳ : ∀ {n} → RightIdentity (_≈_ {n}) 0# _+_
+-identityʳ [] = ≈-null
+-identityʳ (x ∷ xs) = ≈-cons (+ᵏ-identityʳ x) (+-identityʳ xs)
+-identity : ∀ {n} → Identity (_≈_ {n}) 0# _+_
+-identity = +-identityˡ , +-identityʳ
+-comm : ∀ {n} -> Commutative (_≈_ {n}) _+_
+-comm [] [] = ≈-null
+-comm (x ∷ xs) (y ∷ ys) = ≈-cons (+ᵏ-comm x y) (+-comm xs ys)
*ᵏ-∙-compat : ∀ {n} (a b : K') (u : V n) -> ((a *ᵏ b) ∙ u) ≈ (a ∙ (b ∙ u))
*ᵏ-∙-compat a b [] = ≈-null
*ᵏ-∙-compat a b (x ∷ xs) = ≈-cons (*ᵏ-assoc a b x) (*ᵏ-∙-compat a b xs)
∙-+-distrib : ∀ {n} (a : K') (u v : V n) -> (a ∙ (u + v)) ≈ ((a ∙ u) + (a ∙ v))
∙-+-distrib a [] [] = ≈-null
∙-+-distrib a (x ∷ xs) (y ∷ ys) = ≈-cons (*ᵏ-+ᵏ-distribˡ a x y) (∙-+-distrib a xs ys)
∙-+ᵏ-distrib : ∀ {n} (a b : K') (u : V n) -> ((a +ᵏ b) ∙ u) ≈ ((a ∙ u) + (b ∙ u))
∙-+ᵏ-distrib a b [] = ≈-null
∙-+ᵏ-distrib a b (x ∷ u) = ≈-cons (*ᵏ-+ᵏ-distribʳ x a b) (∙-+ᵏ-distrib a b u)
∙-cong : ∀ {n} {a b : K'} {u v : V n} → a ≈ᵏ b -> u ≈ v -> (a ∙ u) ≈ (b ∙ v)
∙-cong rᵏ ≈-null = ≈-null
∙-cong rᵏ (≈-cons r rs) = ≈-cons (*ᵏ-cong rᵏ r) (∙-cong rᵏ rs)
∙-identity : ∀ {n} (x : V n) → (1ᵏ ∙ x) ≈ x
∙-identity [] = ≈-null
∙-identity (x ∷ xs) = ≈-cons (*ᵏ-identityˡ x) (∙-identity xs)
∙-absorbˡ : ∀ {n} (x : V n) → (0ᵏ ∙ x) ≈ 0#
∙-absorbˡ [] = ≈-null
∙-absorbˡ (x ∷ xs) = ≈-cons (*ᵏ-zeroˡ x) (∙-absorbˡ xs)
-‿inverseˡ : ∀ {n} → LeftInverse (_≈_ {n}) 0# -_ _+_
-‿inverseˡ [] = ≈-null
-‿inverseˡ (x ∷ xs) = ≈-cons (-ᵏ‿inverseˡ x) (-‿inverseˡ xs)
-‿inverseʳ : ∀ {n} → RightInverse (_≈_ {n}) 0# -_ _+_
-‿inverseʳ [] = ≈-null
-‿inverseʳ (x ∷ xs) = ≈-cons (-ᵏ‿inverseʳ x) (-‿inverseʳ xs)
-‿inverse : ∀ {n} → Inverse (_≈_ {n}) 0# -_ _+_
-‿inverse = -‿inverseˡ , -‿inverseʳ
-‿cong : ∀ {n} -> Congruent₁ (_≈_ {n}) -_
-‿cong ≈-null = ≈-null
-‿cong (≈-cons r rs) = ≈-cons (-ᵏ‿cong r) (-‿cong rs)
+-++-distrib : ∀ {n p}
(u₁ : V n) (u₂ : V p)
(v₁ : V n) (v₂ : V p)
-> ((u₁ ++ u₂) + (v₁ ++ v₂)) ≈ ((u₁ + v₁) ++ (u₂ + v₂))
+-++-distrib [] [] [] [] = ≈-null
+-++-distrib (x₁ ∷ xs₁) [] (y₁ ∷ ys₁) [] = ++-cong ≈-refl (+-++-distrib xs₁ [] ys₁ [])
+-++-distrib {0} {suc p} [] (x₂ ∷ xs₂) [] (y₂ ∷ ys₂) = ++-identityˡ ((x₂ +ᵏ y₂) ∷ (xs₂ + ys₂))
+-++-distrib (x₁ ∷ xs₁) u₂ (y₁ ∷ ys₁) v₂ =
≈-cons ≈ᵏ-refl (++-cong ≈-refl (+-++-distrib xs₁ u₂ ys₁ v₂))
∙-++-distrib : ∀ {n p} (a : K') (u : V n) (v : V p) -> (a ∙ (u ++ v)) ≈ ((a ∙ u) ++ (a ∙ v))
∙-++-distrib a [] v = ≈-refl
∙-++-distrib a (x ∷ xs) v = ≈-cons ≈ᵏ-refl (∙-++-distrib a xs v)
sum : ∀ {n} -> V n -> K'
sum = foldr _ _+ᵏ_ 0ᵏ
sum-tab : ∀ {n} -> (Fin n -> K') -> K'
sum-tab f = sum (tabulate f)
sum-cong : ∀ {n} {u v : V n} -> u ≈ v -> sum u ≈ᵏ sum v
sum-cong {0} PW.[] = ≈ᵏ-refl
sum-cong {suc n} (r PW.∷ rs) = +ᵏ-cong r (sum-cong {n} rs)
tabulate-cong-≡ : ∀ {n} {f g : Fin n -> K'} -> (∀ i -> f i ≡ g i) -> tabulate f ≡ tabulate g
tabulate-cong-≡ = VP.tabulate-cong
tabulate-cong : ∀ {n} {f g : Fin n -> K'} -> (∀ i -> f i ≈ᵏ g i) -> tabulate f ≈ tabulate g
tabulate-cong {0} r = PW.[]
tabulate-cong {suc n} r = r Fin.zero PW.∷ tabulate-cong (λ i → r (Fin.suc i))
sum-tab-cong : ∀ {n} {f g : Fin n -> K'} -> (∀ i -> f i ≈ᵏ g i) -> sum-tab f ≈ᵏ sum-tab g
sum-tab-cong r = sum-cong (tabulate-cong r)
*ᵏ-sum-tab-distribʳ : ∀ {n} (a : K') (f : Fin n -> K')
→ (sum-tab f *ᵏ a) ≈ᵏ sum-tab (λ k -> f k *ᵏ a)
*ᵏ-sum-tab-distribʳ {0} a f = *ᵏ-zeroˡ a
*ᵏ-sum-tab-distribʳ {suc n} a f =
begin
sum-tab f *ᵏ a
≈⟨ *ᵏ-+ᵏ-distribʳ a (f Fin.zero) (sum-tab (λ k -> f (Fin.suc k))) ⟩
(f Fin.zero *ᵏ a) +ᵏ (sum-tab (λ k -> f (Fin.suc k)) *ᵏ a)
≈⟨ +ᵏ-cong ≈ᵏ-refl (*ᵏ-sum-tab-distribʳ a (λ k -> f (Fin.suc k))) ⟩
sum-tab (λ k -> f k *ᵏ a)
∎
where open import Relation.Binary.EqReasoning (Field.setoid K)
sum-assoc : ∀ {n} (f g : Fin n -> K')
-> (sum-tab f +ᵏ sum-tab g) ≈ᵏ sum-tab (λ k -> f k +ᵏ g k)
sum-assoc {0} f g = +ᵏ-identityˡ 0ᵏ
sum-assoc {suc n} f g =
begin
sum-tab f +ᵏ sum-tab g
≡⟨⟩
(f Fin.zero +ᵏ sum-tab {n} (λ k -> f (Fin.suc k))) +ᵏ (g Fin.zero +ᵏ sum-tab {n} (λ k -> g (Fin.suc k)))
≈⟨ +ᵏ-assoc (f Fin.zero) (sum-tab {n} (λ k -> f (Fin.suc k))) (g Fin.zero +ᵏ sum-tab {n} (λ k -> g (Fin.suc k))) ⟩
f Fin.zero +ᵏ (sum-tab (λ k → f (Fin.suc k)) +ᵏ (g Fin.zero +ᵏ sum-tab (λ k → g (Fin.suc k))))
≈⟨ +ᵏ-cong ≈ᵏ-refl (+ᵏ-comm (sum-tab (λ k -> f (Fin.suc k))) ((g Fin.zero +ᵏ sum-tab (λ k → g (Fin.suc k))))) ⟩
f Fin.zero +ᵏ ((g Fin.zero +ᵏ sum-tab (λ k → g (Fin.suc k))) +ᵏ sum-tab (λ k → f (Fin.suc k)))
≈⟨ +ᵏ-cong ≈ᵏ-refl (+ᵏ-assoc (g Fin.zero) (sum-tab (λ k -> g (Fin.suc k))) (sum-tab (λ k -> f (Fin.suc k)))) ⟩
f Fin.zero +ᵏ (g Fin.zero +ᵏ (sum-tab (λ k → g (Fin.suc k)) +ᵏ sum-tab (λ k → f (Fin.suc k))))
≈⟨ ≈ᵏ-sym (+ᵏ-assoc (f Fin.zero) (g Fin.zero) (sum-tab (λ k → g (Fin.suc k)) +ᵏ sum-tab (λ k → f (Fin.suc k)))) ⟩
(f Fin.zero +ᵏ g Fin.zero) +ᵏ (sum-tab (λ k → g (Fin.suc k)) +ᵏ sum-tab (λ k → f (Fin.suc k)))
≈⟨ +ᵏ-cong ≈ᵏ-refl (+ᵏ-comm (sum-tab λ k -> g (Fin.suc k)) (sum-tab λ k -> f (Fin.suc k))) ⟩
(f Fin.zero +ᵏ g Fin.zero) +ᵏ (sum-tab (λ k → f (Fin.suc k)) +ᵏ sum-tab (λ k → g (Fin.suc k)))
≈⟨ +ᵏ-cong ≈ᵏ-refl (sum-assoc {n} (λ k -> f (Fin.suc k)) (λ k -> g (Fin.suc k))) ⟩
sum-tab (λ k -> f k +ᵏ g k)
∎
where open import Relation.Binary.EqReasoning (Field.setoid K)
sum-tab-0ᵏ : ∀ {n} -> sum-tab {n} (λ k -> 0ᵏ) ≈ᵏ 0ᵏ
sum-tab-0ᵏ {0} = ≈ᵏ-refl
sum-tab-0ᵏ {suc n} = ≈ᵏ-trans (+ᵏ-identityˡ (sum-tab {n} λ k -> 0ᵏ)) (sum-tab-0ᵏ {n})
sum-tab-swap : ∀ {n p} (f : Fin n -> Fin p -> K') (g : Fin n -> K')
-> sum-tab (λ k′ -> sum-tab λ k -> f k k′ *ᵏ g k)
≈ᵏ sum-tab (λ k -> sum-tab λ k′ -> f k k′ *ᵏ g k)
sum-tab-swap {n} {0} f g = ≈ᵏ-sym (sum-tab-0ᵏ {n})
sum-tab-swap {n} {suc p} f g =
begin
sum-tab (λ k′ -> sum-tab λ k -> f k k′ *ᵏ g k)
≡⟨⟩
(sum-tab λ k -> f k Fin.zero *ᵏ g k) +ᵏ (sum-tab λ k′ -> sum-tab λ k -> f k (Fin.suc k′) *ᵏ g k)
≈⟨ +ᵏ-cong ≈ᵏ-refl (sum-tab-swap {n} {p} (λ k k′ -> f k (Fin.suc k′)) g) ⟩
sum-tab (λ k → f k Fin.zero *ᵏ g k) +ᵏ sum-tab (λ k → sum-tab (λ k′ → f k (Fin.suc k′) *ᵏ g k))
≈⟨ +ᵏ-cong ≈ᵏ-refl (sum-tab-cong λ k -> ≈ᵏ-sym (*ᵏ-sum-tab-distribʳ {p} (g k) λ k′ -> f k (Fin.suc k′))) ⟩
sum-tab (λ k → f k Fin.zero *ᵏ g k) +ᵏ sum-tab (λ k → sum-tab (λ k′ → f k (Fin.suc k′)) *ᵏ g k)
≈⟨ sum-assoc (λ k -> f k Fin.zero *ᵏ g k) (λ k -> sum-tab (λ k′ -> f k (Fin.suc k′)) *ᵏ g k) ⟩
sum-tab (λ k -> (f k Fin.zero *ᵏ g k) +ᵏ (sum-tab (λ k′ -> f k (Fin.suc k′)) *ᵏ g k))
≈⟨ sum-tab-cong (λ k -> ≈ᵏ-sym (*ᵏ-+ᵏ-distribʳ (g k) (f k Fin.zero) (sum-tab λ k′ -> f k (Fin.suc k′)))) ⟩
sum-tab (λ k -> sum-tab (λ k′ -> f k k′) *ᵏ g k)
≈⟨ sum-tab-cong (λ k -> *ᵏ-sum-tab-distribʳ {suc p} (g k) (λ k′ -> f k k′)) ⟩
sum-tab (λ k -> sum-tab λ k′ -> f k k′ *ᵏ g k)
∎
where open import Relation.Binary.EqReasoning (Field.setoid K)
sum-tab-δ : ∀ {n} (f : Fin n -> K') (i : Fin n) -> sum-tab (λ k -> δ i k *ᵏ f k) ≈ᵏ f i
sum-tab-δ {suc n} f [email protected] =
begin
sum-tab (λ k -> δ i k *ᵏ f k)
≡⟨⟩
(δ i i *ᵏ f i) +ᵏ sum-tab (λ k -> δ i (Fin.suc k) *ᵏ f (Fin.suc k))
≈⟨ +ᵏ-cong (*ᵏ-identityˡ (f i))
(sum-tab-cong (λ k -> ≈ᵏ-trans (*ᵏ-cong (δ-cancelˡ {n} k) ≈ᵏ-refl) (*ᵏ-zeroˡ (f (Fin.suc k))))) ⟩
f i +ᵏ sum-tab {n} (λ k -> 0ᵏ)
≈⟨ ≈ᵏ-trans (+ᵏ-cong ≈ᵏ-refl (sum-tab-0ᵏ {n})) (+ᵏ-identityʳ (f i)) ⟩
f i
∎
where open import Relation.Binary.EqReasoning (Field.setoid K)
sum-tab-δ {suc n} f (Fin.suc i) =
begin
sum-tab (λ k -> δ (Fin.suc i) k *ᵏ f k)
≡⟨⟩
(δ (Fin.suc i) (Fin.zero {suc n}) *ᵏ f Fin.zero) +ᵏ sum-tab (λ k -> δ (Fin.suc i) (Fin.suc k) *ᵏ f (Fin.suc k))
≈⟨ +ᵏ-cong (≈ᵏ-trans (*ᵏ-cong (δ-cancelʳ {p = suc n} (Fin.suc i)) ≈ᵏ-refl) (*ᵏ-zeroˡ (f Fin.zero))) ≈ᵏ-refl ⟩
0ᵏ +ᵏ sum-tab (λ k → δ (Fin.suc i) (Fin.suc k) *ᵏ f (Fin.suc k))
≈⟨ +ᵏ-identityˡ (sum-tab λ k -> δ (Fin.suc i) (Fin.suc k) *ᵏ f (Fin.suc k)) ⟩
sum-tab (λ k → δ (Fin.suc i) (Fin.suc k) *ᵏ f (Fin.suc k))
≈⟨ sum-tab-δ (λ k -> f (Fin.suc k)) i ⟩
f (Fin.suc i)
∎
where open import Relation.Binary.EqReasoning (Field.setoid K)
module _ {n} where
open import Algebra.Structures (_≈_ {n})
open import Algebra.Linear.Structures.Bundles
isMagma : IsMagma _+_
isMagma = record
{ isEquivalence = ≈-isEquiv
; ∙-cong = +-cong
}
isSemigroup : IsSemigroup _+_
isSemigroup = record
{ isMagma = isMagma
; assoc = +-assoc
}
isMonoid : IsMonoid _+_ 0#
isMonoid = record
{ isSemigroup = isSemigroup
; identity = +-identity
}
isGroup : IsGroup _+_ 0# -_
isGroup = record
{ isMonoid = isMonoid
; inverse = -‿inverse
; ⁻¹-cong = -‿cong
}
isAbelianGroup : IsAbelianGroup _+_ 0# -_
isAbelianGroup = record
{ isGroup = isGroup
; comm = +-comm
}
open VS K
isVectorSpace : VS.IsVectorSpace K (_≈_ {n}) _+_ _∙_ -_ 0#
isVectorSpace = record
{ isAbelianGroup = isAbelianGroup
; *ᵏ-∙-compat = *ᵏ-∙-compat
; ∙-+-distrib = ∙-+-distrib
; ∙-+ᵏ-distrib = ∙-+ᵏ-distrib
; ∙-cong = ∙-cong
; ∙-identity = ∙-identity
; ∙-absorbˡ = ∙-absorbˡ
}
vectorSpace : VectorSpace K k (k ⊔ ℓ)
vectorSpace = record { isVectorSpace = isVectorSpace }
open import Algebra.Linear.Morphism.VectorSpace K
open import Algebra.Linear.Morphism.Bundles K
open import Function
embed : LinearIsomorphism vectorSpace vectorSpace
embed = record
{ ⟦_⟧ = id
; isLinearIsomorphism = record
{ isLinearMonomorphism = record
{ isLinearMap = record
{ isAbelianGroupMorphism = record
{ gp-homo = record
{ mn-homo = record
{ sm-homo = record
{ ⟦⟧-cong = id
; ∙-homo = λ x y → ≈-refl
}
; ε-homo = ≈-refl
}
}
}
; ∙-homo = λ c u → ≈-refl
}
; injective = id
}
; surjective = λ y → y , ≈-refl
}
}
| {
"alphanum_fraction": 0.4882087306,
"avg_line_length": 35.3786982249,
"ext": "agda",
"hexsha": "a498026e396e5eadd84c927dd4bd93a6ef85d189",
"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": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "felko/linear-algebra",
"max_forks_repo_path": "src/Algebra/Linear/Construct/Vector.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"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": "felko/linear-algebra",
"max_issues_repo_path": "src/Algebra/Linear/Construct/Vector.agda",
"max_line_length": 116,
"max_stars_count": 15,
"max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "felko/linear-algebra",
"max_stars_repo_path": "src/Algebra/Linear/Construct/Vector.agda",
"max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z",
"num_tokens": 8975,
"size": 17937
} |
{-# OPTIONS --without-K #-}
open import lib.Base
module test.succeed.Test1 where
module _ where
private
data #I : Type₀ where
#zero : #I
#one : #I
I : Type₀
I = #I
zero : I
zero = #zero
one : I
one = #one
postulate
seg : zero == one
absurd : zero ≠ one
absurd ()
| {
"alphanum_fraction": 0.5551948052,
"avg_line_length": 11,
"ext": "agda",
"hexsha": "845009ea07ae1f20cb944c3e5151bca8c1670806",
"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": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nicolaikraus/HoTT-Agda",
"max_forks_repo_path": "test/succeed/Test1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"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": "nicolaikraus/HoTT-Agda",
"max_issues_repo_path": "test/succeed/Test1.agda",
"max_line_length": 31,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "test/succeed/Test1.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z",
"num_tokens": 104,
"size": 308
} |
module ForallForParameters
(F : Set -> Set -> Set) X {Y} (Z : F X Y) where
data List A : Set where
[] : List A
_::_ : A -> List A -> List A
module M A {B} (C : F A B) where
data D : Set -> Set where
d : A -> D A
data P A : D A -> Set where
data Q {A} X : P A X -> Set where
module N I J K = M I {J} K
open module O I J K = N I J K
record R {I J} (K : F I J) : Set where
| {
"alphanum_fraction": 0.515,
"avg_line_length": 19.0476190476,
"ext": "agda",
"hexsha": "06a08ba9862731a9ae77d15a9df058acf412901b",
"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": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/succeed/ForallForParameters.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/succeed/ForallForParameters.agda",
"max_line_length": 56,
"max_stars_count": 3,
"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/ForallForParameters.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": 154,
"size": 400
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of homogeneous binary relations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Relation.Binary where
------------------------------------------------------------------------
-- Re-export various components of the binary relation hierarchy
open import Relation.Binary.Core public
open import Relation.Binary.Definitions public
open import Relation.Binary.Structures public
open import Relation.Binary.Bundles public
| {
"alphanum_fraction": 0.5099009901,
"avg_line_length": 33.6666666667,
"ext": "agda",
"hexsha": "cfbad7d56dbb93f2fb317bf054247d2643858089",
"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.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.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.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": 77,
"size": 606
} |
-- 2012-03-08 Andreas
module NoTerminationCheck2 where
{-# NON_TERMINATING #-}
data D : Set where
lam : (D -> D) -> D
-- error: works only for function definitions
| {
"alphanum_fraction": 0.6845238095,
"avg_line_length": 18.6666666667,
"ext": "agda",
"hexsha": "10931b7314d8dc41b12d1f56b7726357c9e8a332",
"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/Fail/NoTerminationCheck2.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/Fail/NoTerminationCheck2.agda",
"max_line_length": 45,
"max_stars_count": 3,
"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/NoTerminationCheck2.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": 49,
"size": 168
} |
module ModusPonens where
modusPonens : ∀ {P Q : Set} → (P → Q) → P → Q
modusPonens x = x
| {
"alphanum_fraction": 0.6111111111,
"avg_line_length": 18,
"ext": "agda",
"hexsha": "134173843db3e47e142372e1bf1149abcfdf9fec",
"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": "ece25bed081a24f02e9f85056d05933eae2afabf",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "danr/agder",
"max_forks_repo_path": "tests/ModusPonens-solution.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf",
"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": "danr/agder",
"max_issues_repo_path": "tests/ModusPonens-solution.agda",
"max_line_length": 45,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ece25bed081a24f02e9f85056d05933eae2afabf",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "danr/agder",
"max_stars_repo_path": "tests/ModusPonens-solution.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-17T12:07:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-05-17T12:07:03.000Z",
"num_tokens": 41,
"size": 90
} |
module Data.Var where
open import Data.List using (List; []; _∷_; map)
open import Data.List.Relation.Unary.All using (All; []; _∷_)
open import Function using (const; _∘_)
open import Level using (Level; 0ℓ)
open import Relation.Unary using (IUniversal; _⇒_; _⊢_)
-- ------------------------------------------------------------------------
-- Vars and Contexts
private
variable
a b : Level
_-Scoped[_] : Set a → (b : Level) → Set _
I -Scoped[ b ] = I → List I → Set b
private
variable
I J : Set a
i j : I
Γ : List I
data Var : I -Scoped[ 0ℓ ] where
zero : ∀[ (i ∷_) ⊢ Var i ]
suc : ∀[ Var i ⇒ (j ∷_) ⊢ Var i ]
get : {P : I → Set b} → ∀[ Var i ⇒ All P ⇒ const (P i) ]
get zero (p ∷ _) = p
get (suc v) (_ ∷ ps) = get v ps
_<$>_ : (f : I → J) → ∀[ Var i ⇒ map f ⊢ Var (f i) ]
f <$> zero = zero
f <$> suc v = suc (f <$> v)
tabulate : {P : I → Set b} → (∀ {i} → Var i Γ → P i) → All P Γ
tabulate {Γ = []} f = []
tabulate {Γ = i ∷ Γ} f = f zero ∷ tabulate (f ∘ suc) | {
"alphanum_fraction": 0.497995992,
"avg_line_length": 23.7619047619,
"ext": "agda",
"hexsha": "cecd05df33f9f331a6904c38eb1def39734cea18",
"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": "27fd49914d5ce1cc90d319089686861b33e8f19f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "johnyob/agda-desc",
"max_forks_repo_path": "src/Data/Var.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "27fd49914d5ce1cc90d319089686861b33e8f19f",
"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": "johnyob/agda-desc",
"max_issues_repo_path": "src/Data/Var.agda",
"max_line_length": 75,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "27fd49914d5ce1cc90d319089686861b33e8f19f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "johnyob/agda-desc",
"max_stars_repo_path": "src/Data/Var.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 369,
"size": 998
} |
{-# OPTIONS --cubical --safe #-}
module Data.Fin where
open import Data.Fin.Base public
| {
"alphanum_fraction": 0.7,
"avg_line_length": 15,
"ext": "agda",
"hexsha": "fbf7fbecf565bdab48c2e5cc9cd1ac6e323439c0",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Data/Fin.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"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": "oisdk/combinatorics-paper",
"max_issues_repo_path": "agda/Data/Fin.agda",
"max_line_length": 32,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Data/Fin.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 23,
"size": 90
} |
-- notes-05-friday.agda
open import mylib
-- Π-types = dependent function types
Π : (A : Set)(B : A → Set) → Set
Π A B = (x : A) → B x
syntax Π A (λ x → P) = Π[ x ∈ A ] P
-- Σ-types = dependent pair type
record Σ(A : Set)(B : A → Set) : Set where
constructor _,_
field
proj₁ : A
proj₂ : B proj₁
open Σ
syntax Σ A (λ x → P) = Σ[ x ∈ A ] P
List' : Set → Set
List' A = Σ[ n ∈ ℕ ] Vec A n
List'' : Set → Set -- ex: show that this is isomorphic to lists
List'' A = Σ[ n ∈ ℕ ] Fin n → A
{-
Container representation of lists.
Set of shapes S = ℕ.
Family of positions P : ℕ → Set, P = Fin.
All strictly positive types can be represented as containers ( ~ polynomial
functors) !
-}
{-
A → B = Π[ _ ∈ A ] B
A × B = Σ[ _ ∈ A ] B
-}
_⊎'_ : Set → Set → Set
A ⊎' B = Σ[ b ∈ Bool ] F b
where F : Bool → Set
F true = A
F false = B
_×'_ : Set → Set → Set -- exercise: show that this equivalent to ⊎
A ×' B = Π[ b ∈ Bool ] F b
where F : Bool → Set
F true = A
F false = B
{-
"Propositions as types": for predicate logic
P : A → prop = dependent type
-}
All : (A : Set)(P : A → prop) → prop
All A P = Π[ x ∈ A ] P x
Ex : (A : Set)(P : A → prop) → prop
Ex A P = Σ[ x ∈ A ] P x
syntax All A (λ x → P) = ∀[ x ∈ A ] P
infix 0 All
syntax Ex A (λ x → P) = ∃[ x ∈ A ] P
infix 0 Ex
variable PP QQ : A → prop
taut : (∀[ x ∈ A ] PP x ⇒ Q) ⇔ (∃[ x ∈ A ] PP x) ⇒ Q
proj₁ taut f (a , pa) = f a pa
proj₂ taut g a pa = g (a , pa)
data _≡_ : A → A → prop where
refl : {a : A} → a ≡ a
infix 4 _≡_
-- inductive definition of equality: _≡_ is an equivalence relation
sym : (a b : A) → a ≡ b → b ≡ a
sym a .a refl = refl
trans : {a b c : A} → a ≡ b → b ≡ c → a ≡ c
trans refl q = q
cong : {a b : A}(f : A → B) → a ≡ b → f a ≡ f b
cong f refl = refl
{-
Proving that + is associative
_+_ : ℕ → ℕ → ℕ
zero + n = n
suc m + n = suc (m + n)
-}
assoc : (i j k : ℕ) → (i + j) + k ≡ i + (j + k)
assoc zero j k = refl
assoc (suc i) j k = cong suc (assoc i j k)
-- proof by induction = pattern matching + recursion
ind : (P : ℕ → Set)
→ P 0
→ ((n : ℕ) → P n → P (suc n))
→ (n : ℕ) → P n
ind P z s zero = z
ind P z s (suc n) = s n (ind P z s n)
-- eliminator for ℕ = induction/dependent recursion
{-
data _≡_ : A → A → prop where
refl : {a : A} → a ≡ a
What is ind for equality?
-}
ind≡ : (P : (a b : A) → a ≡ b → prop)
(r : (a : A) → P a a refl)
→ (a b : A)(p : a ≡ b) → P a b p
ind≡ P r a .a refl = r a
-- Ex. derive sym, trans, cong from ind≡ (= J)
uip : (a b : A)(p q : a ≡ b) → p ≡ q
uip = ind≡ (λ a b p → (q : a ≡ b) → p ≡ q) λ a q →
{!!}
--uip refl refl = refl
{-
Is uip derivable from J ? Hofmann & Streicher: groupoid model of type theory.
Restricted version of HoTT (infinity groupoid model of TT); observed: version
of univalence in this theory. Voevodsky formulated HoTT, which supports full
univalence.
-}
| {
"alphanum_fraction": 0.5176946411,
"avg_line_length": 21.1928571429,
"ext": "agda",
"hexsha": "7b2f10ba22f0263ea55d21b13b7230bb0f77867d",
"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": "f328e596d98a7d052b34144447dd14de0f57e534",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "FoxySeta/mgs-2021",
"max_forks_repo_path": "Type Theory/notes-05-friday.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534",
"max_issues_repo_issues_event_max_datetime": "2021-07-14T20:35:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-07-14T20:34:53.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "FoxySeta/mgs-2021",
"max_issues_repo_path": "Type Theory/notes-05-friday.agda",
"max_line_length": 79,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f328e596d98a7d052b34144447dd14de0f57e534",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FoxySeta/mgs-2021",
"max_stars_repo_path": "Type Theory/notes-05-friday.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1172,
"size": 2967
} |
module PatternSynonymImports2 where
open import PatternSynonyms hiding (test)
open import PatternSynonymImports
myzero' = z
myzero'' = myzero
list2 : List _
list2 = 1 ∷ []
test : ℕ → ℕ
test myzero = 0
test sz = 1
test (ss x) = x
| {
"alphanum_fraction": 0.7004219409,
"avg_line_length": 14.8125,
"ext": "agda",
"hexsha": "bad57bbedaed7a57ac7df67204608ac3696cf86e",
"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/Succeed/PatternSynonymImports2.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/Succeed/PatternSynonymImports2.agda",
"max_line_length": 41,
"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/Succeed/PatternSynonymImports2.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": 78,
"size": 237
} |
------------------------------------------------------------------------------
-- Sort a list
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- This module define the program which sorts a list by converting it
-- into an ordered tree and then back to a list (Burstall 1969,
-- pp. 45-46).
module FOTC.Program.SortList.SortList where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.Bool
open import FOTC.Data.List
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.Nat.Type
------------------------------------------------------------------------------
-- Tree terms.
postulate
nil : D
tip : D → D
node : D → D → D → D
-- The tree type.
data Tree : D → Set where
tnil : Tree nil
ttip : ∀ {i} → N i → Tree (tip i)
tnode : ∀ {t₁ i t₂} → Tree t₁ → N i → Tree t₂ → Tree (node t₁ i t₂)
{-# ATP axioms tnil ttip tnode #-}
------------------------------------------------------------------------------
-- Inequalites on lists and trees
-- Note from Burstall (p. 46): "The relation ≤ between lists is only an
-- ordering if nil is excluded, similarly for trees. This is untidy but
-- will not cause trouble."
postulate
le-ItemList : D → D → D
le-ItemList-[] : ∀ item → le-ItemList item [] ≡ true
le-ItemList-∷ : ∀ item i is →
le-ItemList item (i ∷ is) ≡ le item i && le-ItemList item is
{-# ATP axioms le-ItemList-[] le-ItemList-∷ #-}
≤-ItemList : D → D → Set
≤-ItemList item is = le-ItemList item is ≡ true
{-# ATP definition ≤-ItemList #-}
postulate
le-Lists : D → D → D
le-Lists-[] : ∀ is → le-Lists [] is ≡ true
le-Lists-∷ : ∀ i is js →
le-Lists (i ∷ is) js ≡ le-ItemList i js && le-Lists is js
{-# ATP axioms le-Lists-[] le-Lists-∷ #-}
≤-Lists : D → D → Set
≤-Lists is js = le-Lists is js ≡ true
{-# ATP definition ≤-Lists #-}
postulate
le-ItemTree : D → D → D
le-ItemTree-nil : ∀ item → le-ItemTree item nil ≡ true
le-ItemTree-tip : ∀ item i → le-ItemTree item (tip i) ≡ le item i
le-ItemTree-node : ∀ item t₁ i t₂ →
le-ItemTree item (node t₁ i t₂) ≡
le-ItemTree item t₁ && le-ItemTree item t₂
{-# ATP axioms le-ItemTree-nil le-ItemTree-tip le-ItemTree-node #-}
≤-ItemTree : D → D → Set
≤-ItemTree item t = le-ItemTree item t ≡ true
{-# ATP definition ≤-ItemTree #-}
-- This function is not defined in the paper.
postulate
le-TreeItem : D → D → D
le-TreeItem-nil : ∀ item → le-TreeItem nil item ≡ true
le-TreeItem-tip : ∀ i item → le-TreeItem (tip i) item ≡ le i item
le-TreeItem-node : ∀ t₁ i t₂ item →
le-TreeItem (node t₁ i t₂) item ≡
le-TreeItem t₁ item && le-TreeItem t₂ item
{-# ATP axioms le-TreeItem-nil le-TreeItem-tip le-TreeItem-node #-}
≤-TreeItem : D → D → Set
≤-TreeItem t item = le-TreeItem t item ≡ true
{-# ATP definition ≤-TreeItem #-}
------------------------------------------------------------------------------
-- Auxiliary functions
postulate
-- The foldr function with the last two args flipped.
lit : D → D → D → D
lit-[] : ∀ f n → lit f [] n ≡ n
lit-∷ : ∀ f d ds n → lit f (d ∷ ds) n ≡ f · d · (lit f ds n)
{-# ATP axioms lit-[] lit-∷ #-}
------------------------------------------------------------------------------
-- Ordering functions and predicates on lists and trees
postulate
ordList : D → D
ordList-[] : ordList [] ≡ true
ordList-∷ : ∀ i is → ordList (i ∷ is) ≡ le-ItemList i is && ordList is
{-# ATP axioms ordList-[] ordList-∷ #-}
OrdList : D → Set
OrdList is = ordList is ≡ true
{-# ATP definition OrdList #-}
postulate
ordTree : D → D
ordTree-nil : ordTree nil ≡ true
ordTree-tip : ∀ i → ordTree (tip i) ≡ true
ordTree-node : ∀ t₁ i t₂ →
ordTree (node t₁ i t₂) ≡
ordTree t₁ && ordTree t₂ && le-TreeItem t₁ i && le-ItemTree i t₂
{-# ATP axioms ordTree-nil ordTree-tip ordTree-node #-}
OrdTree : D → Set
OrdTree t = ordTree t ≡ true
{-# ATP definition OrdTree #-}
------------------------------------------------------------------------------
-- The program
-- The function toTree adds an item to a tree.
-- The items have an ordering ≤ defined over them. The item held at a
-- node of the tree is chosen so that the left subtree has items not
-- greater than it and the right subtree has items not less than it.
postulate
toTree : D
toTree-nil : ∀ item → toTree · item · nil ≡ tip item
toTree-tip : ∀ item i → toTree · item · (tip i) ≡
(if (le i item)
then (node (tip i) item (tip item))
else (node (tip item) i (tip i)))
toTree-node : ∀ item t₁ i t₂ →
toTree · item · (node t₁ i t₂) ≡
(if (le i item)
then (node t₁ i (toTree · item · t₂))
else (node (toTree · item · t₁) i t₂))
{-# ATP axioms toTree-nil toTree-tip toTree-node #-}
-- The function makeTree converts a list to a tree.
makeTree : D → D
makeTree is = lit toTree is nil
{-# ATP definition makeTree #-}
-- The function flatten converts a tree to a list.
postulate
flatten : D → D
flatten-nil : flatten nil ≡ []
flatten-tip : ∀ i → flatten (tip i) ≡ i ∷ []
flatten-node : ∀ t₁ i t₂ → flatten (node t₁ i t₂) ≡ flatten t₁ ++ flatten t₂
{-# ATP axioms flatten-nil flatten-tip flatten-node #-}
-- The function which sorts the list
sort : D → D
sort is = flatten (makeTree is)
{-# ATP definition sort #-}
------------------------------------------------------------------------------
-- References
--
-- Burstall, R. M. (1969). Proving properties of programs by
-- structural induction. The Computer Journal 12.1, pp. 41–48.
| {
"alphanum_fraction": 0.5314980578,
"avg_line_length": 33.8342857143,
"ext": "agda",
"hexsha": "7112d82f47d61b28c9ae8d3778f502f225951b87",
"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": "src/fot/FOTC/Program/SortList/SortList.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": "src/fot/FOTC/Program/SortList/SortList.agda",
"max_line_length": 81,
"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": "src/fot/FOTC/Program/SortList/SortList.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": 1697,
"size": 5921
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Category.Monoidal
open import Categories.Category.Monoidal.Closed
module Categories.Category.Monoidal.Closed.IsClosed
{o ℓ e} {C : Category o ℓ e} {M : Monoidal C} (Cl : Closed M) where
open import Data.Product using (Σ; _,_)
open import Function using (_$_) renaming (_∘_ to _∙_)
open import Function.Equality as Π using (Π)
open import Categories.Category.Product
open import Categories.Category.Monoidal.Properties M
open import Categories.Morphism C
open import Categories.Morphism.Properties C
open import Categories.Morphism.Reasoning C
open import Categories.Functor renaming (id to idF)
open import Categories.Functor.Bifunctor
open import Categories.Functor.Bifunctor.Properties
open import Categories.NaturalTransformation hiding (id)
open import Categories.NaturalTransformation.Dinatural hiding (_∘ʳ_)
open import Categories.NaturalTransformation.NaturalIsomorphism as NI hiding (refl)
import Categories.Category.Closed as Cls
open Closed Cl
private
module C = Category C
open Category C
open Commutation
module ℱ = Functor
open HomReasoning
open Π.Π
open adjoint renaming (unit to η; counit to ε)
-- and here we use sub-modules in the hopes of making things go faster
open import Categories.Category.Monoidal.Closed.IsClosed.Identity Cl
open import Categories.Category.Monoidal.Closed.IsClosed.L Cl
open import Categories.Category.Monoidal.Closed.IsClosed.Dinatural Cl
open import Categories.Category.Monoidal.Closed.IsClosed.Diagonal Cl
open import Categories.Category.Monoidal.Closed.IsClosed.Pentagon Cl
private
id² : {S T : Obj} → [ S , T ]₀ ⇒ [ S , T ]₀
id² = [ id , id ]₁
L-natural-comm : {X Y′ Z′ Y Z : Obj} {f : Y′ ⇒ Y} {g : Z ⇒ Z′} →
L X Y′ Z′ ∘ [ f , g ]₁ ≈ [ [ id , f ]₁ , [ id , g ]₁ ]₁ ∘ L X Y Z
L-natural-comm {X} {Y′} {Z′} {Y} {Z} {f} {g} =
let I = [-,-].identity in begin
L X Y′ Z′ ∘ [ f , g ]₁ ≈⟨ refl⟩∘⟨ [ [-,-] ]-decompose₂ ⟩
L X Y′ Z′ ∘ [ id , g ]₁ ∘ [ f , id ]₁ ≈⟨ pullˡ L-g-swap ⟩
([ id² , [ id , g ]₁ ]₁ ∘ L X Y′ Z) ∘ [ f , id ]₁ ≈⟨ pullʳ L-f-swap ⟩
[ id² , [ id , g ]₁ ]₁ ∘ [ [ id , f ]₁ , id² ]₁ ∘ L X Y Z ≈˘⟨ pushˡ ([-,-].F-resp-≈ (introʳ I , introʳ I) ○ [-,-].homomorphism) ⟩
[ [ id , f ]₁ , [ id , g ]₁ ]₁ ∘ L X Y Z
∎
closed : Cls.Closed C
closed = record
{ [-,-] = [-,-]
; unit = unit
; identity = identity
; diagonal = diagonal
; L = L
; L-natural-comm = L-natural-comm
; L-dinatural-comm = L-dinatural-comm
; Lj≈j = Lj≈j
; jL≈i = jL≈i
; iL≈i = iL≈i
; pentagon = pentagon′
; γ⁻¹ = λ {X Y} → record
{ _⟨$⟩_ = λ f → Radjunct f ∘ unitorˡ.to
; cong = λ eq → ∘-resp-≈ˡ (∘-resp-≈ʳ (ℱ.F-resp-≈ (-⊗ X) eq))
}
; γ-inverseOf-γ⁻¹ = λ {X Y} → record
{ left-inverse-of = λ f → begin
[ id , Radjunct f ∘ unitorˡ.to ]₁ ∘ [ id , unitorˡ.from ]₁ ∘ η.η unit
≈⟨ ℱ.homomorphism [ X ,-] ⟩∘⟨ refl ⟩∘⟨ refl ⟩
([ id , Radjunct f ]₁ ∘ [ id , unitorˡ.to ]₁) ∘ [ id , unitorˡ.from ]₁ ∘ η.η unit
≈⟨ cancelInner (⟺ (ℱ.homomorphism [ X ,-]) ○ ℱ.F-resp-≈ [ X ,-] unitorˡ.isoˡ ○ [-,-].identity) ⟩
Ladjunct (Radjunct f) ≈⟨ LRadjunct≈id ⟩
f
∎
; right-inverse-of = λ f → begin
Radjunct ([ id , f ]₁ ∘ [ id , unitorˡ.from ]₁ ∘ η.η unit) ∘ unitorˡ.to
≈˘⟨ ∘-resp-≈ʳ (ℱ.F-resp-≈ (-⊗ X) (pushˡ (ℱ.homomorphism [ X ,-]))) ⟩∘⟨refl ⟩
Radjunct (Ladjunct (f ∘ unitorˡ.from)) ∘ unitorˡ.to
≈⟨ RLadjunct≈id ⟩∘⟨refl ⟩
(f ∘ unitorˡ.from) ∘ unitorˡ.to
≈⟨ cancelʳ unitorˡ.isoʳ ⟩
f
∎
}
}
| {
"alphanum_fraction": 0.5835095137,
"avg_line_length": 38.612244898,
"ext": "agda",
"hexsha": "836c4cd2241d6914e1a9de7bb7de825b9a54ebf1",
"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": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Monoidal/Closed/IsClosed.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"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": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Monoidal/Closed/IsClosed.agda",
"max_line_length": 134,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Monoidal/Closed/IsClosed.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1394,
"size": 3784
} |
module Numeral.Natural.Relation.Proofs where
open import Data
open import Functional
open import Numeral.Natural
open import Numeral.Natural.Relation
open import Numeral.Natural.Relation.Order
open import Numeral.Natural.Relation.Order.Proofs
open import Logic.Propositional
open import Logic.Propositional.Theorems
import Lvl
open import Relator.Equals
open import Type
private variable n : ℕ
Positive-non-zero : Positive(n) ↔ (n ≢ 𝟎)
Positive-non-zero {𝟎} = [↔]-intro (apply [≡]-intro) \()
Positive-non-zero {𝐒 n} = [↔]-intro (const <>) (const \())
Positive-greater-than-zero : Positive(n) ↔ (n > 𝟎)
Positive-greater-than-zero = [↔]-transitivity Positive-non-zero ([↔]-intro [>]-to-[≢] [≢]-to-[<]-of-0ᵣ)
| {
"alphanum_fraction": 0.7280334728,
"avg_line_length": 31.1739130435,
"ext": "agda",
"hexsha": "86982095a116a7730cdb31eb2c06bbf48f9b48ba",
"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/Relation/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/Relation/Proofs.agda",
"max_line_length": 103,
"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/Relation/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": 221,
"size": 717
} |
-- Isomorphism of indexed families
module SOAS.Families.Isomorphism {T} where
open import SOAS.Common
open import SOAS.Context {T}
open import SOAS.Families.Core {T}
open import Categories.Morphism 𝔽amilies public using ()
renaming ( _≅_ to _≅ₘ_ ; module ≅ to ≅ₘ ; ≅-setoid to ≅ₘ-setoid)
-- Isomorphism between two families
record FamIso (X Y : Family) : Set where
-- Prove isomorphism of the families X and Y in the category 𝔽am from
-- a proof of isomorphism of the sets X Γ and Y Γ for all contexts Γ.
field iso : (Γ : Ctx) → X Γ ≅ₛ Y Γ
-- Two directions of the isomorphism.
iso⇒ : X ⇾ Y
iso⇒ {Γ} = _≅ₛ_.from (iso Γ)
iso⇐ : Y ⇾ X
iso⇐ {Γ} = _≅ₛ_.to (iso Γ)
-- Construct the isomorphism of families
≅ₘ : X ≅ₘ Y
≅ₘ = record
{ from = iso⇒
; to = iso⇐
; iso = record
{ isoˡ = λ {Γ}{x} → _≅ₛ_.isoˡ (iso Γ)
; isoʳ = λ {Γ}{x} → _≅ₛ_.isoʳ (iso Γ)
}
}
≅ₘ→FamIso : {X Y : Family} → X ≅ₘ Y → FamIso X Y
≅ₘ→FamIso p = record { iso = λ Γ → record
{ from = _≅ₘ_.from p
; to = _≅ₘ_.to p
; iso = record { isoˡ = _≅ₘ_.isoˡ p ; isoʳ = _≅ₘ_.isoʳ p }
} }
-- | Isomorphism of sorted families
open import Categories.Morphism 𝔽amiliesₛ public
using () renaming ( _≅_ to _≅̣ₘ_ ; module ≅ to ≅̣ₘ)
-- Sorted family isomorphism gives a family isomorphism at each sort
≅̣ₘ→≅ₘ : {τ : T}{𝒳 𝒴 : Familyₛ} → 𝒳 ≅̣ₘ 𝒴 → 𝒳 τ ≅ₘ 𝒴 τ
≅̣ₘ→≅ₘ {τ} p = record { from = _≅̣ₘ_.from p ; to = _≅̣ₘ_.to p
; iso = record { isoˡ = _≅̣ₘ_.isoˡ p ; isoʳ = _≅̣ₘ_.isoʳ p } }
-- Family isomorphism at each sort gives sorted family isomorphism
≅ₘ→≅̣ₘ : {𝒳 𝒴 : Familyₛ} → ({τ : T} → 𝒳 τ ≅ₘ 𝒴 τ) → 𝒳 ≅̣ₘ 𝒴
≅ₘ→≅̣ₘ p = record { from = _≅ₘ_.from p ; to = _≅ₘ_.to p
; iso = record { isoˡ = _≅ₘ_.isoˡ p ; isoʳ = _≅ₘ_.isoʳ p } }
| {
"alphanum_fraction": 0.5831473214,
"avg_line_length": 31.4385964912,
"ext": "agda",
"hexsha": "8b36c7f8da193d376790466aa9e558b2f97187bb",
"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": "SOAS/Families/Isomorphism.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": "SOAS/Families/Isomorphism.agda",
"max_line_length": 83,
"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": "SOAS/Families/Isomorphism.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": 834,
"size": 1792
} |
module Numeral.Finite.Oper.Comparisons.Proofs where
import Lvl
open import Data
open import Data.Boolean
import Data.Boolean.Operators
open Data.Boolean.Operators.Programming
open import Logic.Propositional
open import Logic.Predicate
open import Numeral.Finite
open import Numeral.Finite.Oper.Comparisons
open import Numeral.Sign
open import Numeral.Sign.Oper0
open import Relator.Equals
open import Relator.Equals.Proofs.Equivalence
import Structure.Operator.Names as Names
open import Structure.Operator.Properties
open import Syntax.Number
⋚-of-𝟎-not-+ : ∀{an bn}{b : 𝕟(bn)} → ⦃ _ : 𝟎 {an} ⋚? b ≡ ➕ ⦄ → ⊥
⋚-of-𝟎-not-+ {b = 𝟎} ⦃ ⦄
⋚-of-𝟎-not-+ {b = 𝐒(_)} ⦃ ⦄
⋚-of-𝟎-not-− : ∀{an bn}{a : 𝕟(an)} → ⦃ _ : a ⋚? 𝟎 {bn} ≡ ➖ ⦄ → ⊥
⋚-of-𝟎-not-− {a = 𝟎} ⦃ ⦄
⋚-of-𝟎-not-− {a = 𝐒(_)} ⦃ ⦄
⋚-of-𝐒𝟎-not-𝟎 : ∀{an bn}{a : 𝕟(an)} → ⦃ _ : 𝐒(a) ⋚? 𝟎 {bn} ≡ 𝟎 ⦄ → ⊥
⋚-of-𝐒𝟎-not-𝟎 {a = 𝟎} ⦃ ⦄
⋚-of-𝐒𝟎-not-𝟎 {a = 𝐒(_)} ⦃ ⦄
⋚-of-𝟎𝐒-not-𝟎 : ∀{an bn}{b : 𝕟(bn)} → ⦃ _ : 𝟎 {an} ⋚? 𝐒(b) ≡ 𝟎 ⦄ → ⊥
⋚-of-𝟎𝐒-not-𝟎 {b = 𝟎} ⦃ ⦄
⋚-of-𝟎𝐒-not-𝟎 {b = 𝐒(_)} ⦃ ⦄
⋚-surjective : ∀{an bn}{a : 𝕟(an)}{b : 𝕟(bn)} → ∃{Obj = (−|0|+)} (a ⋚? b ≡_)
⋚-surjective {a = 𝟎} {𝟎} = [∃]-intro 𝟎
⋚-surjective {a = 𝟎} {𝐒 b} = [∃]-intro ➖
⋚-surjective {a = 𝐒 a} {𝟎} = [∃]-intro ➕
⋚-surjective {a = 𝐒 a} {𝐒 b} = ⋚-surjective {a = a} {b}
⋚-to-< : ∀{an bn}{a : 𝕟(an)}{b : 𝕟(bn)} → ⦃ _ : a ⋚? b ≡ ➕ ⦄ → (a >? b ≡ 𝑇)
⋚-to-< {a = 𝐒 a} {𝟎} = [≡]-intro
⋚-to-< {a = 𝐒 a} {𝐒 b} = ⋚-to-< {a = a} {b}
⋚-to-> : ∀{an bn}{a : 𝕟(an)}{b : 𝕟(bn)} → ⦃ _ : a ⋚? b ≡ ➖ ⦄ → (a <? b ≡ 𝑇)
⋚-to-> {a = 𝟎} {𝐒 b} = [≡]-intro
⋚-to-> {a = 𝐒 a} {𝐒 b} = ⋚-to-> {a = a} {b}
⋚-to-≡ : ∀{an bn}{a : 𝕟(an)}{b : 𝕟(bn)} → ⦃ _ : a ⋚? b ≡ 𝟎 ⦄ → (a ≡? b ≡ 𝑇)
⋚-to-≡ {a = 𝟎} {𝟎} = [≡]-intro
⋚-to-≡ {a = 𝐒 a} {𝐒 b} = ⋚-to-≡ {a = a} {b}
instance
[≡?]-commutativity : ∀{n} → Commutativity{T₁ = 𝕟(n)} ⦃ [≡]-equiv ⦄ (_≡?_)
[≡?]-commutativity{n} = intro(\{x y} → p{n}{x}{y}) where
p : ∀{n} → Names.Commutativity{T₁ = 𝕟(n)} ⦃ [≡]-equiv ⦄ (_≡?_)
p{_}{𝟎} {𝟎} = [≡]-intro
p{_}{𝟎} {𝐒 y} = [≡]-intro
p{_}{𝐒 x}{𝟎} = [≡]-intro
p{_}{𝐒 x}{𝐒 y} = p{_}{x}{y}
⋚-anticommutativity : ∀{xn yn}{x : 𝕟(xn)}{y : 𝕟(yn)} → (−(x ⋚? y) ≡ y ⋚? x)
⋚-anticommutativity {x = 𝟎} {y = 𝟎} = [≡]-intro
⋚-anticommutativity {x = 𝟎} {y = 𝐒 y} = [≡]-intro
⋚-anticommutativity {x = 𝐒 x}{y = 𝟎} = [≡]-intro
⋚-anticommutativity {x = 𝐒 x}{y = 𝐒 y} = ⋚-anticommutativity {x = x}{y = y}
⋚-elim₃-negation-flip : ∀{xn yn}{x : 𝕟(xn)}{y : 𝕟(yn)}{b₁ b₂ b₃} → (elim₃{P = \_ → Bool} b₁ b₂ b₃ (−(x ⋚? y)) ≡ elim₃ b₃ b₂ b₁ (x ⋚? y))
⋚-elim₃-negation-flip {x = 𝟎} {y = 𝟎} = [≡]-intro
⋚-elim₃-negation-flip {x = 𝟎} {y = 𝐒 y} = [≡]-intro
⋚-elim₃-negation-flip {x = 𝐒 x}{y = 𝟎} = [≡]-intro
⋚-elim₃-negation-flip {x = 𝐒 x}{y = 𝐒 y} = ⋚-elim₃-negation-flip {x = x}{y = y}
⋚-elim₃-negation-distribution : ∀{xn yn}{x : 𝕟(xn)}{y : 𝕟(yn)}{b₁ b₂ b₃ : Bool} → (!(elim₃ b₁ b₂ b₃ (x ⋚? y)) ≡ elim₃ (! b₁) (! b₂) (! b₃) (x ⋚? y))
⋚-elim₃-negation-distribution {x = 𝟎} {y = 𝟎} = [≡]-intro
⋚-elim₃-negation-distribution {x = 𝟎} {y = 𝐒 y} = [≡]-intro
⋚-elim₃-negation-distribution {x = 𝐒 x}{y = 𝟎} = [≡]-intro
⋚-elim₃-negation-distribution {x = 𝐒 x}{y = 𝐒 y} = ⋚-elim₃-negation-distribution {x = x}{y = y}
| {
"alphanum_fraction": 0.4933744222,
"avg_line_length": 40.5625,
"ext": "agda",
"hexsha": "7c41f0bb54350b0e35707f73b2383ef367014faf",
"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/Finite/Oper/Comparisons/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/Finite/Oper/Comparisons/Proofs.agda",
"max_line_length": 148,
"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/Finite/Oper/Comparisons/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": 2044,
"size": 3245
} |
module STLC.Term.Reduction where
open import STLC.Term as Term
open Term.Substitution using () renaming (_[/_] to _[/t_])
open import Data.Nat using (ℕ; _+_)
open import Relation.Binary.Construct.Closure.ReflexiveTransitive
using (Star)
infix 4 _—→_
data _—→_ { n : ℕ } : Term n -> Term n -> Set where
β-·₁ : ∀ { t₁ t₂ l : Term n }
-> t₁ —→ t₂
-- ----------------
-> t₁ · l —→ t₂ · l
β-·₂ : ∀ { v t₁ t₂ : Term n }
-> Value v
-> t₁ —→ t₂
-- ----------------
-> v · t₁ —→ v · t₂
β-ƛ : ∀ { t : Term (1 + n) } {v : Term n }
-> Value v
-- --------------------
-> (ƛ t) · v —→ (t [/t v ])
infix 2 _—↠_
_—↠_ : { n : ℕ } -> Term n -> Term n -> Set
_—↠_ = Star (_—→_)
| {
"alphanum_fraction": 0.4519230769,
"avg_line_length": 18.6666666667,
"ext": "agda",
"hexsha": "5f953ccec54b52e2ba182ce88cd41744d6321da7",
"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": "aeb2be63381d891fabe5317e3c27553deb6bca6d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "johnyob/agda-types",
"max_forks_repo_path": "src/STLC/Term/Reduction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d",
"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": "johnyob/agda-types",
"max_issues_repo_path": "src/STLC/Term/Reduction.agda",
"max_line_length": 66,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "johnyob/agda-types",
"max_stars_repo_path": "src/STLC/Term/Reduction.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 278,
"size": 728
} |
------------------------------------------------------------------------
-- The univalence axiom
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- Partly based on Voevodsky's work on so-called univalent
-- foundations.
open import Equality
module Univalence-axiom
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open import Bijection eq as Bijection using (_↔_)
open import Bool eq
open Derived-definitions-and-properties eq
open import Equality.Decision-procedures eq
open import Equivalence eq as Eq
using (_≃_; ⟨_,_⟩; Is-equivalence) renaming (_∘_ to _⊚_)
import Equivalence.Contractible-preimages eq as CP
import Equivalence.Half-adjoint eq as HA
open import Function-universe eq as F hiding (id; _∘_)
open import Groupoid eq
open import H-level eq as H-level
open import H-level.Closure eq
open import Injection eq using (Injective)
open import Logical-equivalence using (_⇔_)
import Nat eq as Nat
open import Prelude hiding (swap)
open import Surjection eq using (_↠_)
------------------------------------------------------------------------
-- The univalence axiom
-- If two sets are equal, then they are equivalent.
≡⇒≃ : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → A ≃ B
≡⇒≃ = ≡⇒↝ equivalence
-- The univalence axiom states that ≡⇒≃ is an equivalence.
record Univalence′ {ℓ} (A B : Type ℓ) : Type (lsuc ℓ) where
no-eta-equality
pattern
field
univalence : Is-equivalence (≡⇒≃ {A = A} {B = B})
Univalence : ∀ ℓ → Type (lsuc ℓ)
Univalence ℓ = {A B : Type ℓ} → Univalence′ A B
-- An immediate consequence is that equalities are equivalent to
-- equivalences.
≡≃≃ : ∀ {ℓ} {A B : Type ℓ} → Univalence′ A B → (A ≡ B) ≃ (A ≃ B)
≡≃≃ univ = ⟨ ≡⇒≃ , Univalence′.univalence univ ⟩
-- In the case of sets equalities are equivalent to bijections (if we
-- add the assumption of extensionality).
≡≃↔ : ∀ {ℓ} {A B : Type ℓ} →
Univalence′ A B →
Extensionality ℓ ℓ →
Is-set A →
(A ≡ B) ≃ (A ↔ B)
≡≃↔ {A = A} {B} univ ext A-set =
(A ≡ B) ↝⟨ ≡≃≃ univ ⟩
(A ≃ B) ↔⟨ inverse $ Eq.↔↔≃ ext A-set ⟩□
(A ↔ B) □
-- Some abbreviations.
≡⇒→ : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → A → B
≡⇒→ = _≃_.to ∘ ≡⇒≃
≡⇒← : ∀ {ℓ} {A B : Type ℓ} → A ≡ B → B → A
≡⇒← = _≃_.from ∘ ≡⇒≃
≃⇒≡ : ∀ {ℓ} {A B : Type ℓ} → Univalence′ A B → A ≃ B → A ≡ B
≃⇒≡ univ = _≃_.from (≡≃≃ univ)
-- Univalence′ can be expressed without the record type.
Univalence′≃Is-equivalence-≡⇒≃ :
∀ {ℓ} {A B : Type ℓ} →
Univalence′ A B ≃ Is-equivalence (≡⇒≃ {A = A} {B = B})
Univalence′≃Is-equivalence-≡⇒≃ =
Eq.↔→≃
Univalence′.univalence
(λ eq → record { univalence = eq })
refl
(λ { (record { univalence = _ }) → refl _ })
------------------------------------------------------------------------
-- Propositional extensionality
-- Propositional extensionality.
--
-- Basically as defined by Chapman, Uustalu and Veltri in "Quotienting
-- the Delay Monad by Weak Bisimilarity".
Propositional-extensionality : (ℓ : Level) → Type (lsuc ℓ)
Propositional-extensionality ℓ =
{A B : Type ℓ} → Is-proposition A → Is-proposition B → A ⇔ B → A ≡ B
-- Propositional extensionality is equivalent to univalence restricted
-- to propositions (assuming extensionality).
--
-- I took the statement of this result from Chapman, Uustalu and
-- Veltri's "Quotienting the Delay Monad by Weak Bisimilarity", and
-- Nicolai Kraus helped me with the proof.
Propositional-extensionality-is-univalence-for-propositions :
∀ {ℓ} →
Extensionality (lsuc ℓ) (lsuc ℓ) →
Propositional-extensionality ℓ
≃
({A B : Type ℓ} →
Is-proposition A → Is-proposition B → Univalence′ A B)
Propositional-extensionality-is-univalence-for-propositions {ℓ} ext =
Propositional-extensionality ℓ ↝⟨ lemma ⟩
({A B : Type ℓ} →
Is-proposition A → Is-proposition B →
Is-equivalence (≡⇒≃ {A = A} {B = B})) ↝⟨ (implicit-∀-cong ext $
implicit-∀-cong ext $
∀-cong ext′ λ _ →
∀-cong ext′ λ _ →
inverse Univalence′≃Is-equivalence-≡⇒≃) ⟩□
({A B : Type ℓ} →
Is-proposition A → Is-proposition B → Univalence′ A B) □
where
ext′ : Extensionality ℓ (lsuc ℓ)
ext′ = lower-extensionality _ lzero ext
ext″ : Extensionality ℓ ℓ
ext″ = lower-extensionality _ _ ext
⇔≃≡ :
Propositional-extensionality ℓ →
{A B : Type ℓ} →
Is-proposition A → Is-proposition B →
(A ⇔ B) ≃ (A ≡ B)
⇔≃≡ prop-ext {A} {B} A-prop B-prop =
A ⇔ B ↝⟨ proj₂ (Eq.propositional-identity≃≡
(λ (A B : Proposition ℓ) → proj₁ A ⇔ proj₁ B)
(λ { (A , A-prop) (B , B-prop) →
⇔-closure ext″ 1 A-prop B-prop })
(λ _ → F.id)
(λ { (A , A-prop) (B , B-prop) A⇔B →
Σ-≡,≡→≡ (prop-ext A-prop B-prop A⇔B)
(H-level-propositional ext″ 1 _ _) }))
ext ⟩
(A , A-prop) ≡ (B , B-prop) ↔⟨ inverse $ ignore-propositional-component
(H-level-propositional ext″ 1) ⟩□
A ≡ B □
≡-closure :
Propositional-extensionality ℓ →
{A B : Type ℓ} →
Is-proposition A → Is-proposition B → Is-proposition (A ≡ B)
≡-closure prop-ext A-prop B-prop =
H-level.respects-surjection
(_≃_.surjection (⇔≃≡ prop-ext A-prop B-prop))
1
(⇔-closure ext″ 1 A-prop B-prop)
lemma =
Eq.⇔→≃
([inhabited⇒+]⇒+ 0 λ prop-ext →
implicit-Π-closure ext 1 λ _ →
implicit-Π-closure ext 1 λ _ →
Π-closure ext′ 1 λ A-prop →
Π-closure ext′ 1 λ B-prop →
Π-closure ext′ 1 λ _ →
≡-closure (prop-ext {_}) A-prop B-prop)
(implicit-Π-closure ext 1 λ _ →
implicit-Π-closure ext 1 λ _ →
Π-closure ext′ 1 λ _ →
Π-closure ext′ 1 λ _ →
Eq.propositional ext _)
(λ prop-ext A-prop B-prop →
_⇔_.from HA.Is-equivalence⇔Is-equivalence-CP $ λ A≃B →
( prop-ext A-prop B-prop (_≃_.logical-equivalence A≃B)
, Eq.left-closure ext″ 0 A-prop _ _
) , λ _ → Σ-≡,≡→≡
(≡-closure prop-ext A-prop B-prop _ _)
(mono₁ 1 (Eq.left-closure ext″ 0 A-prop) _ _))
(λ univ {A B} A-prop B-prop →
A ⇔ B ↔⟨ Eq.⇔↔≃ ext″ A-prop B-prop ⟩
A ≃ B ↔⟨ inverse ⟨ _ , univ A-prop B-prop ⟩ ⟩□
A ≡ B □)
------------------------------------------------------------------------
-- An alternative formulation of univalence
-- First some supporting lemmas.
-- A variant of a part of Theorem 5.8.2 from the HoTT book.
flip-subst-is-equivalence↔∃-is-contractible :
∀ {a pℓ} {A : Type a} {P : A → Type pℓ} {x : A} {p : P x} →
(∀ y → Is-equivalence (flip (subst {y = y} P) p))
↝[ a ⊔ pℓ ∣ a ⊔ pℓ ]
Contractible (∃ P)
flip-subst-is-equivalence↔∃-is-contractible
{pℓ = pℓ} {P = P} {x = x} {p = p} =
generalise-ext?-prop
lemma
(λ ext → Π-closure (lower-extensionality pℓ lzero ext) 1 λ _ →
Eq.propositional ext _)
Contractible-propositional
where
lemma :
(∀ y → Is-equivalence (flip (subst {y = y} P) p))
⇔
Contractible (∃ P)
lemma = record
{ to = λ eq → $⟨ other-singleton-contractible x ⟩
Contractible (Other-singleton x) ↝⟨ id ⟩
Contractible (∃ (x ≡_)) ↝⟨ H-level.respects-surjection (∃-cong λ y → _≃_.surjection ⟨ _ , eq y ⟩) 0 ⟩□
Contractible (∃ P) □
; from = λ { ((y , q) , u) z →
_≃_.is-equivalence (Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ from = λ r →
x ≡⟨ cong proj₁ $ sym $ u (x , p) ⟩
y ≡⟨ cong proj₁ $ u (z , r) ⟩∎
z ∎
}
; right-inverse-of = λ r →
subst P (trans (cong proj₁ (sym (u (x , p))))
(cong proj₁ (u (z , r)))) p ≡⟨ sym $ subst-subst _ _ _ _ ⟩
subst P (cong proj₁ (u (z , r)))
(subst P (cong proj₁ (sym (u (x , p)))) p) ≡⟨ cong (subst P _) $ cong (λ p → subst P p _) $ sym $ proj₁-Σ-≡,≡←≡ _ ⟩
subst P (cong proj₁ (u (z , r)))
(subst P (proj₁ (Σ-≡,≡←≡ (sym (u (x , p))))) p) ≡⟨ cong (subst P _) $ proj₂ $ Σ-≡,≡←≡ (sym (u (x , p))) ⟩
subst P (cong proj₁ (u (z , r))) q ≡⟨ cong (λ p → subst P p _) $ sym $ proj₁-Σ-≡,≡←≡ _ ⟩
subst P (proj₁ (Σ-≡,≡←≡ (u (z , r)))) q ≡⟨ proj₂ $ Σ-≡,≡←≡ (u (z , r)) ⟩∎
r ∎
}
; left-inverse-of = elim¹
(λ {z} x≡z → trans (cong proj₁ (sym (u (x , p))))
(cong proj₁ (u (z , subst P x≡z p))) ≡
x≡z)
(trans (cong proj₁ (sym (u (x , p))))
(cong proj₁ (u (x , subst P (refl x) p))) ≡⟨ cong₂ trans (cong-sym _ _)
(cong (λ p → cong proj₁ (u (x , p))) $ subst-refl _ _) ⟩
trans (sym (cong proj₁ (u (x , p))))
(cong proj₁ (u (x , p))) ≡⟨ trans-symˡ _ ⟩∎
refl x ∎)
})) }
}
-- If f is an equivalence, then f ∘ sym is also an equivalence.
∘-sym-preserves-equivalences :
∀ {a b} {A : Type a} {B : Type b} {x y : A} {f : x ≡ y → B} →
Is-equivalence f ↝[ a ⊔ b ∣ a ⊔ b ] Is-equivalence (f ∘ sym)
∘-sym-preserves-equivalences {A = A} {B} =
Is-equivalence≃Is-equivalence-∘ʳ
(_≃_.is-equivalence $ Eq.↔⇒≃ ≡-comm)
-- An alternative formulation of univalence, due to Martin Escardo
-- (see the following post to the Homotopy Type Theory group from
-- 2018-04-05:
-- https://groups.google.com/forum/#!msg/homotopytypetheory/HfCB_b-PNEU/Ibb48LvUMeUJ).
Other-univalence : ∀ ℓ → Type (lsuc ℓ)
Other-univalence ℓ =
{B : Type ℓ} → Contractible (∃ λ (A : Type ℓ) → A ≃ B)
-- Univalence and Other-univalence are pointwise isomorphic (assuming
-- extensionality).
Univalence↔Other-univalence :
∀ {ℓ} →
Univalence ℓ ↝[ lsuc ℓ ∣ lsuc ℓ ] Other-univalence ℓ
Univalence↔Other-univalence {ℓ = ℓ} ext =
Univalence ℓ ↝⟨ implicit-∀-cong ext $ implicit-∀-cong ext $
from-equivalence Univalence′≃Is-equivalence-≡⇒≃ ⟩
({A B : Type ℓ} → Is-equivalence (≡⇒≃ {A = A} {B = B})) ↔⟨ Bijection.implicit-Π↔Π ⟩
((A {B} : Type ℓ) → Is-equivalence (≡⇒≃ {A = A} {B = B})) ↝⟨ (∀-cong ext λ _ → from-bijection Bijection.implicit-Π↔Π) ⟩
((A B : Type ℓ) → Is-equivalence (≡⇒≃ {A = A} {B = B})) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → ∘-sym-preserves-equivalences ext) ⟩
((A B : Type ℓ) → Is-equivalence (≡⇒≃ {A = A} {B = B} ∘ sym)) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ B →
Is-equivalence-cong ext (λ B≡A →
≡⇒≃ (sym B≡A) ≡⟨ ≡⇒↝-in-terms-of-subst-sym _ _ ⟩
subst (_≃ B) (sym (sym B≡A)) Eq.id ≡⟨ cong (flip (subst _) _) $ sym-sym _ ⟩∎
subst (_≃ B) B≡A Eq.id ∎)) ⟩
((A B : Type ℓ) → Is-equivalence (flip (subst {y = A} (_≃ B)) F.id)) ↔⟨ Π-comm ⟩
((B A : Type ℓ) → Is-equivalence (flip (subst {y = A} (_≃ B)) F.id)) ↝⟨ (∀-cong ext λ _ → flip-subst-is-equivalence↔∃-is-contractible ext) ⟩
((B : Type ℓ) → Contractible (∃ λ (A : Type ℓ) → A ≃ B)) ↔⟨ inverse Bijection.implicit-Π↔Π ⟩□
({B : Type ℓ} → Contractible (∃ λ (A : Type ℓ) → A ≃ B)) □
------------------------------------------------------------------------
-- Some simple lemmas
abstract
-- "Evaluation rule" for ≡⇒≃.
≡⇒≃-refl : ∀ {a} {A : Type a} →
≡⇒≃ (refl A) ≡ Eq.id
≡⇒≃-refl = ≡⇒↝-refl
-- "Evaluation rule" for ≡⇒→.
≡⇒→-refl : ∀ {a} {A : Type a} →
≡⇒→ (refl A) ≡ id
≡⇒→-refl = cong _≃_.to ≡⇒≃-refl
-- "Evaluation rule" for ≡⇒←.
≡⇒←-refl : ∀ {a} {A : Type a} →
≡⇒← (refl A) ≡ id
≡⇒←-refl = cong _≃_.from ≡⇒≃-refl
-- "Evaluation rule" (?) for ≃⇒≡.
≃⇒≡-id : ∀ {a} {A : Type a}
(univ : Univalence′ A A) →
≃⇒≡ univ Eq.id ≡ refl A
≃⇒≡-id univ =
≃⇒≡ univ Eq.id ≡⟨ sym $ cong (≃⇒≡ univ) ≡⇒≃-refl ⟩
≃⇒≡ univ (≡⇒≃ (refl _)) ≡⟨ _≃_.left-inverse-of (≡≃≃ univ) _ ⟩∎
refl _ ∎
-- A simplification lemma for ≃⇒≡.
≡⇒→-≃⇒≡ : ∀ k {ℓ} {A B : Type ℓ} {eq : A ≃ B}
(univ : Univalence′ A B) →
to-implication (≡⇒↝ k (≃⇒≡ univ eq)) ≡ _≃_.to eq
≡⇒→-≃⇒≡ k {eq = eq} univ =
to-implication (≡⇒↝ k (≃⇒≡ univ eq)) ≡⟨ to-implication-≡⇒↝ k _ ⟩
≡⇒↝ implication (≃⇒≡ univ eq) ≡⟨ sym $ to-implication-≡⇒↝ equivalence _ ⟩
≡⇒→ (≃⇒≡ univ eq) ≡⟨ cong _≃_.to (_≃_.right-inverse-of (≡≃≃ univ) _) ⟩∎
_≃_.to eq ∎
------------------------------------------------------------------------
-- Another alternative formulation of univalence
-- Univalence′ A B is pointwise equivalent to CP.Univalence′ A B
-- (assuming extensionality).
Univalence′≃Univalence′-CP :
∀ {ℓ} {A B : Type ℓ} →
Extensionality (lsuc ℓ) (lsuc ℓ) →
Univalence′ A B ≃ CP.Univalence′ A B
Univalence′≃Univalence′-CP {ℓ = ℓ} {A = A} {B = B} ext =
Univalence′ A B ↝⟨ Univalence′≃Is-equivalence-≡⇒≃ ⟩
Is-equivalence ≡⇒≃ ↝⟨ Is-equivalence-cong ext $
elim
(λ A≡B → ≡⇒≃ A≡B ≡ _≃_.from ≃≃≃ (CP.≡⇒≃ A≡B))
(λ C →
≡⇒≃ (refl _) ≡⟨ ≡⇒≃-refl ⟩
Eq.id ≡⟨ Eq.lift-equality ext′ (refl _) ⟩
_≃_.from ≃≃≃ CP.id ≡⟨ cong (_≃_.from ≃≃≃) $ sym CP.≡⇒≃-refl ⟩∎
_≃_.from ≃≃≃ (CP.≡⇒≃ (refl _)) ∎) ⟩
Is-equivalence (_≃_.from ≃≃≃ ∘ CP.≡⇒≃) ↝⟨ Eq.⇔→≃
(Eq.propositional ext _)
(Eq.propositional ext _)
(Eq.Two-out-of-three.g-g∘f (Eq.two-out-of-three _ _)
(_≃_.is-equivalence (inverse ≃≃≃)))
(flip (Eq.Two-out-of-three.f-g (Eq.two-out-of-three _ _))
(_≃_.is-equivalence (inverse ≃≃≃))) ⟩
Is-equivalence CP.≡⇒≃ ↝⟨ Is-equivalence≃Is-equivalence-CP ext ⟩□
CP.Is-equivalence CP.≡⇒≃ □
where
ext′ : Extensionality ℓ ℓ
ext′ = lower-extensionality _ _ ext
≃≃≃ : {A B : Type ℓ} → (A ≃ B) ≃ (A CP.≃ B)
≃≃≃ = ≃≃≃-CP ext′
-- Univalence ℓ is pointwise equivalent to CP.Univalence ℓ (assuming
-- extensionality).
Univalence≃Univalence-CP :
∀ {ℓ} →
Extensionality (lsuc ℓ) (lsuc ℓ) →
Univalence ℓ ≃ CP.Univalence ℓ
Univalence≃Univalence-CP {ℓ = ℓ} ext =
implicit-∀-cong ext $ implicit-∀-cong ext $
Univalence′≃Univalence′-CP ext
------------------------------------------------------------------------
-- A consequence: Type is not a set
-- The univalence axiom implies that Type is not a set. (This was
-- pointed out to me by Thierry Coquand.)
module _ (univ : Univalence′ Bool Bool) where
-- First note that the univalence axiom implies that there is an
-- inhabitant of Bool ≡ Bool that is not equal to refl.
swap-as-an-equality : Bool ≡ Bool
swap-as-an-equality = ≃⇒≡ univ (Eq.↔⇒≃ swap)
abstract
swap≢refl : swap-as-an-equality ≢ refl Bool
swap≢refl =
swap-as-an-equality ≡ refl _ ↝⟨ cong ≡⇒→ ⟩
≡⇒→ swap-as-an-equality ≡ ≡⇒→ (refl _) ↝⟨ subst (uncurry _≡_) (cong₂ _,_ (≡⇒→-≃⇒≡ equivalence univ) ≡⇒→-refl) ⟩
not ≡ id ↝⟨ cong (_$ false) ⟩
true ≡ false ↝⟨ Bool.true≢false ⟩□
⊥ □
-- This implies that Type is not a set.
¬-Type-set : ¬ Is-set Type
¬-Type-set =
Is-set Type ↝⟨ (λ h → h _ _) ⟩
swap-as-an-equality ≡ refl Bool ↝⟨ swap≢refl ⟩□
⊥ □
abstract
-- The result can be generalised to arbitrary universe levels.
¬-Type-set-↑ : ∀ {ℓ} →
Univalence′ (↑ ℓ Bool) (↑ ℓ Bool) →
¬ Is-set (Type ℓ)
¬-Type-set-↑ {ℓ} univ =
Is-set (Type ℓ) ↝⟨ (λ h → h _ _) ⟩
swap-as-an-equality-↑ ≡ refl (↑ ℓ Bool) ↝⟨ swap-↑≢refl ⟩□
⊥ □
where
swap-as-an-equality-↑ : ↑ ℓ Bool ≡ ↑ ℓ Bool
swap-as-an-equality-↑ =
≃⇒≡ univ $
Eq.↔⇒≃ $
(Bijection.inverse Bijection.↑↔
Bijection.∘
swap
Bijection.∘
Bijection.↑↔)
swap-↑≢refl : swap-as-an-equality-↑ ≢ refl (↑ ℓ Bool)
swap-↑≢refl =
swap-as-an-equality-↑ ≡ refl _ ↝⟨ cong ≡⇒→ ⟩
≡⇒→ swap-as-an-equality-↑ ≡ ≡⇒→ (refl _) ↝⟨ subst (uncurry _≡_) (cong₂ _,_ (≡⇒→-≃⇒≡ equivalence univ) ≡⇒→-refl) ⟩
lift ∘ not ∘ lower ≡ id ↝⟨ cong (lower ∘ (_$ lift false)) ⟩
true ≡ false ↝⟨ Bool.true≢false ⟩□
⊥ □
------------------------------------------------------------------------
-- A consequence: some equality types have infinitely many inhabitants
abstract
-- Some equality types have infinitely many inhabitants (assuming
-- univalence).
equality-can-have-infinitely-many-inhabitants :
Univalence′ ℕ ℕ →
∃ λ (A : Type) → ∃ λ (B : Type) →
∃ λ (p : ℕ → A ≡ B) → Injective p
equality-can-have-infinitely-many-inhabitants univ =
(ℕ , ℕ , cast ∘ p , cast-preserves-injections p p-injective)
where
cast : ℕ ≃ ℕ → ℕ ≡ ℕ
cast = ≃⇒≡ univ
cast-preserves-injections :
{A : Type} (f : A → ℕ ≃ ℕ) →
Injective f → Injective (cast ∘ f)
cast-preserves-injections f inj {x = x} {y = y} cast-f-x≡cast-f-y =
inj (f x ≡⟨ sym $ _≃_.right-inverse-of (≡≃≃ univ) (f x) ⟩
≡⇒≃ (cast (f x)) ≡⟨ cong ≡⇒≃ cast-f-x≡cast-f-y ⟩
≡⇒≃ (cast (f y)) ≡⟨ _≃_.right-inverse-of (≡≃≃ univ) (f y) ⟩∎
f y ∎)
swap_and-0 : ℕ → ℕ → ℕ
swap i and-0 zero = i
swap i and-0 (suc n) with i Nat.≟ suc n
... | yes i≡1+n = zero
... | no i≢1+n = suc n
swap∘swap : ∀ i n → swap i and-0 (swap i and-0 n) ≡ n
swap∘swap zero zero = refl zero
swap∘swap (suc i) zero with i Nat.≟ i
... | yes _ = refl 0
... | no i≢i = ⊥-elim $ i≢i (refl i)
swap∘swap i (suc n) with i Nat.≟ suc n
... | yes i≡1+n = i≡1+n
... | no i≢1+n with i Nat.≟ suc n
... | yes i≡1+n = ⊥-elim $ i≢1+n i≡1+n
... | no _ = refl (suc n)
p : ℕ → ℕ ≃ ℕ
p i = Eq.↔⇒≃ record
{ surjection = record
{ logical-equivalence = record { to = swap i and-0
; from = swap i and-0
}
; right-inverse-of = swap∘swap i
}
; left-inverse-of = swap∘swap i
}
p-injective : Injective p
p-injective {x = i₁} {y = i₂} p-i₁≡p-i₂ =
i₁ ≡⟨ refl i₁ ⟩
swap i₁ and-0 0 ≡⟨ cong (λ f → f 0) swap-i₁≡swap-i₂ ⟩
swap i₂ and-0 0 ≡⟨ refl i₂ ⟩∎
i₂ ∎
where
swap-i₁≡swap-i₂ : swap i₁ and-0 ≡ swap i₂ and-0
swap-i₁≡swap-i₂ = cong _≃_.to p-i₁≡p-i₂
------------------------------------------------------------------------
-- A consequence: extensionality for functions
-- The transport theorem.
transport-theorem :
∀ {p₁ p₂} (P : Type p₁ → Type p₂) →
(resp : ∀ {A B} → A ≃ B → P A → P B) →
(∀ {A} (p : P A) → resp Eq.id p ≡ p) →
∀ {A B} (univ : Univalence′ A B) →
(A≃B : A ≃ B) (p : P A) →
resp A≃B p ≡ subst P (≃⇒≡ univ A≃B) p
transport-theorem P resp resp-id univ A≃B p =
resp A≃B p ≡⟨ sym $ cong (λ q → resp q p) (right-inverse-of A≃B) ⟩
resp (to (from A≃B)) p ≡⟨ elim (λ {A B} A≡B → ∀ p →
resp (≡⇒≃ A≡B) p ≡ subst P A≡B p)
(λ A p →
resp (≡⇒≃ (refl A)) p ≡⟨ trans (cong (λ q → resp q p) ≡⇒↝-refl) (resp-id p) ⟩
p ≡⟨ sym $ subst-refl P p ⟩∎
subst P (refl A) p ∎) _ _ ⟩∎
subst P (from A≃B) p ∎
where open _≃_ (≡≃≃ univ)
abstract
-- If the univalence axiom holds, then any "resp" function that
-- preserves identity is an equivalence family.
resp-is-equivalence :
∀ {p₁ p₂} (P : Type p₁ → Type p₂) →
(resp : ∀ {A B} → A ≃ B → P A → P B) →
(∀ {A} (p : P A) → resp Eq.id p ≡ p) →
∀ {A B} (univ : Univalence′ A B) →
(A≃B : A ≃ B) → Is-equivalence (resp A≃B)
resp-is-equivalence P resp resp-id univ A≃B =
Eq.respects-extensional-equality
(λ p → sym $ transport-theorem P resp resp-id univ A≃B p)
(Eq.subst-is-equivalence P (≃⇒≡ univ A≃B))
-- If f is an equivalence, then (non-dependent) precomposition with
-- f is also an equivalence (assuming univalence).
precomposition-is-equivalence :
∀ {ℓ c} {A B : Type ℓ} {C : Type c} →
Univalence′ B A → (A≃B : A ≃ B) →
Is-equivalence (λ (g : B → C) → g ∘ _≃_.to A≃B)
precomposition-is-equivalence {ℓ} {c} {C = C} univ A≃B =
resp-is-equivalence P resp refl univ (Eq.inverse A≃B)
where
P : Type ℓ → Type (ℓ ⊔ c)
P X = X → C
resp : ∀ {A B} → A ≃ B → P A → P B
resp A≃B p = p ∘ _≃_.from A≃B
-- If h is an equivalence, then one can cancel (non-dependent)
-- precompositions with h (assuming univalence).
precompositions-cancel :
∀ {ℓ c} {A B : Type ℓ} {C : Type c} →
Univalence′ B A → (A≃B : A ≃ B) {f g : B → C} →
let open _≃_ A≃B in
f ∘ to ≡ g ∘ to → f ≡ g
precompositions-cancel univ A≃B {f} {g} f∘to≡g∘to =
f ≡⟨ sym $ left-inverse-of f ⟩
from (to f) ≡⟨ cong from f∘to≡g∘to ⟩
from (to g) ≡⟨ left-inverse-of g ⟩∎
g ∎
where open _≃_ (⟨ _ , precomposition-is-equivalence univ A≃B ⟩)
-- Pairs of equal elements.
_²/≡ : ∀ {ℓ} → Type ℓ → Type ℓ
A ²/≡ = ∃ λ (x : A) → ∃ λ (y : A) → x ≡ y
-- The set of such pairs is isomorphic to the underlying type.
-²/≡↔- : ∀ {a} {A : Type a} → (A ²/≡) ↔ A
-²/≡↔- {A = A} =
(∃ λ (x : A) → ∃ λ (y : A) → x ≡ y) ↝⟨ ∃-cong (λ _ → _⇔_.to contractible⇔↔⊤ (other-singleton-contractible _)) ⟩
A × ⊤ ↝⟨ ×-right-identity ⟩□
A □
abstract
-- The univalence axiom implies non-dependent functional
-- extensionality.
extensionality :
∀ {a b} {A : Type a} {B : Type b} →
Univalence′ (B ²/≡) B →
{f g : A → B} → (∀ x → f x ≡ g x) → f ≡ g
extensionality {A = A} {B} univ {f} {g} f≡g =
f ≡⟨ refl f ⟩
f′ ∘ pair ≡⟨ cong (λ (h : B ²/≡ → B) → h ∘ pair) f′≡g′ ⟩
g′ ∘ pair ≡⟨ refl g ⟩∎
g ∎
where
f′ : B ²/≡ → B
f′ = proj₁
g′ : B ²/≡ → B
g′ = proj₁ ∘ proj₂
f′≡g′ : f′ ≡ g′
f′≡g′ = precompositions-cancel
univ
(Eq.↔⇒≃ $ Bijection.inverse -²/≡↔-)
(refl id)
pair : A → B ²/≡
pair x = (f x , g x , f≡g x)
-- The univalence axiom implies that contractibility is closed under
-- Π A.
Π-closure-contractible :
∀ {b} → Univalence′ (Type b ²/≡) (Type b) →
∀ {a} {A : Type a} {B : A → Type b} →
(∀ x → Univalence′ (↑ b ⊤) (B x)) →
(∀ x → Contractible (B x)) → Contractible ((x : A) → B x)
Π-closure-contractible {b} univ₁ {A = A} {B} univ₂ contr =
subst Contractible A→⊤≡[x:A]→Bx →⊤-contractible
where
const-⊤≡B : const (↑ b ⊤) ≡ B
const-⊤≡B = extensionality univ₁ λ x →
_≃_.from (≡≃≃ (univ₂ x)) $ Eq.↔⇒≃ $
Bijection.contractible-isomorphic
(↑-closure 0 ⊤-contractible) (contr x)
A→⊤≡[x:A]→Bx : (A → ↑ b ⊤) ≡ ((x : A) → B x)
A→⊤≡[x:A]→Bx = cong (λ X → (x : A) → X x) const-⊤≡B
→⊤-contractible : Contractible (A → ↑ b ⊤)
→⊤-contractible = (_ , λ _ → refl _)
-- Thus we also get extensionality for dependent functions.
dependent-extensionality′ :
∀ {b} → Univalence′ (Type b ²/≡) (Type b) →
∀ {a} {A : Type a} →
(∀ {B : A → Type b} x → Univalence′ (↑ b ⊤) (B x)) →
{B : A → Type b} → Extensionality′ A B
dependent-extensionality′ univ₁ univ₂ =
_⇔_.to Π-closure-contractible⇔extensionality
(Π-closure-contractible univ₁ univ₂)
dependent-extensionality :
∀ {b} →
Univalence (lsuc b) →
Univalence b →
∀ {a} → Extensionality a b
apply-ext (dependent-extensionality univ₁ univ₂) =
dependent-extensionality′ univ₁ (λ _ → univ₂)
------------------------------------------------------------------------
-- Pow and Fam
-- Slightly different variants of Pow and Fam are described in
-- "Specifying interactions with dependent types" by Peter Hancock and
-- Anton Setzer (in APPSEM Workshop on Subtyping & Dependent Types in
-- Programming, DTP'00). The fact that Pow and Fam are logically
-- equivalent is proved in "Programming Interfaces and Basic Topology"
-- by Peter Hancock and Pierre Hyvernat (Annals of Pure and Applied
-- Logic, 2006). The results may be older than this.
-- Pow.
Pow : ∀ ℓ {a} → Type a → Type (lsuc (a ⊔ ℓ))
Pow ℓ {a} A = A → Type (a ⊔ ℓ)
-- Fam.
Fam : ∀ ℓ {a} → Type a → Type (lsuc (a ⊔ ℓ))
Fam ℓ {a} A = ∃ λ (I : Type (a ⊔ ℓ)) → I → A
-- Pow and Fam are pointwise logically equivalent.
Pow⇔Fam : ∀ ℓ {a} {A : Type a} →
Pow ℓ A ⇔ Fam ℓ A
Pow⇔Fam _ = record
{ to = λ P → ∃ P , proj₁
; from = λ { (I , f) a → ∃ λ i → f i ≡ a }
}
-- Pow and Fam are pointwise isomorphic (assuming extensionality and
-- univalence).
Pow↔Fam : ∀ ℓ {a} {A : Type a} →
Extensionality a (lsuc (a ⊔ ℓ)) →
Univalence (a ⊔ ℓ) →
Pow ℓ A ↔ Fam ℓ A
Pow↔Fam ℓ {A = A} ext univ = record
{ surjection = record
{ logical-equivalence = Pow⇔Fam ℓ
; right-inverse-of = λ { (I , f) →
let lemma₁ =
(∃ λ a → ∃ λ i → f i ≡ a) ↔⟨ ∃-comm ⟩
(∃ λ i → ∃ λ a → f i ≡ a) ↔⟨ ∃-cong (λ _ → _⇔_.to contractible⇔↔⊤ (other-singleton-contractible _)) ⟩
I × ⊤ ↔⟨ ×-right-identity ⟩□
I □
lemma₂ =
subst (λ I → I → A) (≃⇒≡ univ lemma₁) proj₁ ≡⟨ sym $ transport-theorem (λ I → I → A) (λ eq → _∘ _≃_.from eq) refl univ _ _ ⟩
proj₁ ∘ _≃_.from lemma₁ ≡⟨ refl _ ⟩∎
f ∎
in
(∃ λ a → ∃ λ i → f i ≡ a) , proj₁ ≡⟨ Σ-≡,≡→≡ (≃⇒≡ univ lemma₁) lemma₂ ⟩∎
I , f ∎ }
}
; left-inverse-of = λ P →
let lemma = λ a →
(∃ λ (i : ∃ P) → proj₁ i ≡ a) ↔⟨ inverse Σ-assoc ⟩
(∃ λ a′ → P a′ × a′ ≡ a) ↔⟨ inverse $ ∃-intro _ _ ⟩□
P a □
in
(λ a → ∃ λ (i : ∃ P) → proj₁ i ≡ a) ≡⟨ apply-ext ext (λ a → ≃⇒≡ univ (lemma a)) ⟩∎
P ∎
}
-- An isomorphism that follows from Pow↔Fam.
--
-- This isomorphism was suggested to me by Paolo Capriotti.
→↔Σ≃Σ :
∀ ℓ {a b} {A : Type a} {B : Type b} →
Extensionality (a ⊔ b ⊔ ℓ) (lsuc (a ⊔ b ⊔ ℓ)) →
Univalence (a ⊔ b ⊔ ℓ) →
(A → B) ↔ ∃ λ (P : B → Type (a ⊔ b ⊔ ℓ)) → A ≃ Σ B P
→↔Σ≃Σ ℓ {a} {b} {A} {B} ext univ =
(A → B) ↝⟨ →-cong₁ (lower-extensionality lzero _ ext) (inverse Bijection.↑↔) ⟩
(↑ (b ⊔ ℓ) A → B) ↝⟨ inverse ×-left-identity ⟩
⊤ × (↑ _ A → B) ↝⟨ inverse $ _⇔_.to contractible⇔↔⊤ (singleton-contractible _) ×-cong F.id ⟩
(∃ λ (A′ : Type ℓ′) → A′ ≡ ↑ _ A) × (↑ _ A → B) ↝⟨ inverse Σ-assoc ⟩
(∃ λ (A′ : Type ℓ′) → A′ ≡ ↑ _ A × (↑ _ A → B)) ↝⟨ (∃-cong λ _ → ∃-cong λ eq → →-cong₁ (lower-extensionality lzero _ ext) (≡⇒≃ (sym eq))) ⟩
(∃ λ (A′ : Type ℓ′) → A′ ≡ ↑ _ A × (A′ → B)) ↝⟨ (∃-cong λ _ → ×-comm) ⟩
(∃ λ (A′ : Type ℓ′) → (A′ → B) × A′ ≡ ↑ _ A) ↝⟨ Σ-assoc ⟩
(∃ λ (p : ∃ λ (A′ : Type ℓ′) → A′ → B) → proj₁ p ≡ ↑ _ A) ↝⟨ inverse $ Σ-cong (Pow↔Fam (a ⊔ ℓ) (lower-extensionality ℓ′ lzero ext) univ) (λ _ → F.id) ⟩
(∃ λ (P : B → Type ℓ′) → ∃ P ≡ ↑ _ A) ↔⟨ (∃-cong λ _ → ≡≃≃ univ) ⟩
(∃ λ (P : B → Type ℓ′) → ∃ P ≃ ↑ _ A) ↝⟨ (∃-cong λ _ → Groupoid.⁻¹-bijection (Eq.groupoid (lower-extensionality ℓ′ _ ext))) ⟩
(∃ λ (P : B → Type ℓ′) → ↑ _ A ≃ ∃ P) ↔⟨ (∃-cong λ _ →
Eq.≃-preserves (lower-extensionality lzero _ ext) (Eq.↔⇒≃ Bijection.↑↔) F.id) ⟩□
(∃ λ (P : B → Type ℓ′) → A ≃ ∃ P) □
where
ℓ′ = a ⊔ b ⊔ ℓ
------------------------------------------------------------------------
-- More lemmas
abstract
-- The univalence axiom is propositional (assuming extensionality).
Univalence′-propositional :
∀ {ℓ} → Extensionality (lsuc ℓ) (lsuc ℓ) →
{A B : Type ℓ} → Is-proposition (Univalence′ A B)
Univalence′-propositional ext {A = A} {B = B} = $⟨ Eq.propositional ext ≡⇒≃ ⟩
Is-proposition (Is-equivalence (≡⇒≃ {A = A} {B = B})) ↝⟨ H-level-cong _ 1 (inverse Univalence′≃Is-equivalence-≡⇒≃) ⦂ (_ → _) ⟩□
Is-proposition (Univalence′ A B) □
Univalence-propositional :
∀ {ℓ} → Extensionality (lsuc ℓ) (lsuc ℓ) →
Is-proposition (Univalence ℓ)
Univalence-propositional ext =
implicit-Π-closure ext 1 λ _ →
implicit-Π-closure ext 1 λ _ →
Univalence′-propositional ext
-- ≡⇒≃ commutes with sym/Eq.inverse (assuming extensionality).
≡⇒≃-sym :
∀ {ℓ} → Extensionality ℓ ℓ →
{A B : Type ℓ} (A≡B : A ≡ B) →
≡⇒≃ (sym A≡B) ≡ Eq.inverse (≡⇒≃ A≡B)
≡⇒≃-sym ext = elim¹
(λ eq → ≡⇒≃ (sym eq) ≡ Eq.inverse (≡⇒≃ eq))
(≡⇒≃ (sym (refl _)) ≡⟨ cong ≡⇒≃ sym-refl ⟩
≡⇒≃ (refl _) ≡⟨ ≡⇒≃-refl ⟩
Eq.id ≡⟨ sym $ Groupoid.identity (Eq.groupoid ext) ⟩
Eq.inverse Eq.id ≡⟨ cong Eq.inverse $ sym ≡⇒≃-refl ⟩∎
Eq.inverse (≡⇒≃ (refl _)) ∎)
-- ≃⇒≡ univ commutes with Eq.inverse/sym (assuming extensionality).
≃⇒≡-inverse :
∀ {ℓ} (univ : Univalence ℓ) → Extensionality ℓ ℓ →
{A B : Type ℓ} (A≃B : A ≃ B) →
≃⇒≡ univ (Eq.inverse A≃B) ≡ sym (≃⇒≡ univ A≃B)
≃⇒≡-inverse univ ext A≃B =
≃⇒≡ univ (Eq.inverse A≃B) ≡⟨ sym $ cong (λ p → ≃⇒≡ univ (Eq.inverse p)) (_≃_.right-inverse-of (≡≃≃ univ) _) ⟩
≃⇒≡ univ (Eq.inverse (≡⇒≃ (≃⇒≡ univ A≃B))) ≡⟨ cong (≃⇒≡ univ) $ sym $ ≡⇒≃-sym ext _ ⟩
≃⇒≡ univ (≡⇒≃ (sym (≃⇒≡ univ A≃B))) ≡⟨ _≃_.left-inverse-of (≡≃≃ univ) _ ⟩∎
sym (≃⇒≡ univ A≃B) ∎
-- ≡⇒≃ commutes with trans/_⊚_ (assuming extensionality).
≡⇒≃-trans :
∀ {ℓ} → Extensionality ℓ ℓ →
{A B C : Type ℓ} (A≡B : A ≡ B) (B≡C : B ≡ C) →
≡⇒≃ (trans A≡B B≡C) ≡ ≡⇒≃ B≡C ⊚ ≡⇒≃ A≡B
≡⇒≃-trans ext A≡B = elim¹
(λ eq → ≡⇒≃ (trans A≡B eq) ≡ ≡⇒≃ eq ⊚ ≡⇒≃ A≡B)
(≡⇒≃ (trans A≡B (refl _)) ≡⟨ cong ≡⇒≃ $ trans-reflʳ _ ⟩
≡⇒≃ A≡B ≡⟨ sym $ Groupoid.left-identity (Eq.groupoid ext) _ ⟩
Eq.id ⊚ ≡⇒≃ A≡B ≡⟨ sym $ cong (λ eq → eq ⊚ ≡⇒≃ A≡B) ≡⇒≃-refl ⟩∎
≡⇒≃ (refl _) ⊚ ≡⇒≃ A≡B ∎)
-- ≃⇒≡ univ commutes with _⊚_/flip trans (assuming extensionality).
≃⇒≡-∘ :
∀ {ℓ} (univ : Univalence ℓ) → Extensionality ℓ ℓ →
{A B C : Type ℓ} (A≃B : A ≃ B) (B≃C : B ≃ C) →
≃⇒≡ univ (B≃C ⊚ A≃B) ≡ trans (≃⇒≡ univ A≃B) (≃⇒≡ univ B≃C)
≃⇒≡-∘ univ ext A≃B B≃C =
≃⇒≡ univ (B≃C ⊚ A≃B) ≡⟨ sym $ cong₂ (λ p q → ≃⇒≡ univ (p ⊚ q)) (_≃_.right-inverse-of (≡≃≃ univ) _)
(_≃_.right-inverse-of (≡≃≃ univ) _) ⟩
≃⇒≡ univ (≡⇒≃ (≃⇒≡ univ B≃C) ⊚ ≡⇒≃ (≃⇒≡ univ A≃B)) ≡⟨ cong (≃⇒≡ univ) $ sym $ ≡⇒≃-trans ext _ _ ⟩
≃⇒≡ univ (≡⇒≃ (trans (≃⇒≡ univ A≃B) (≃⇒≡ univ B≃C))) ≡⟨ _≃_.left-inverse-of (≡≃≃ univ) _ ⟩∎
trans (≃⇒≡ univ A≃B) (≃⇒≡ univ B≃C) ∎
-- A variant of the transport theorem.
transport-theorem′ :
∀ {a p r} {A : Type a}
(P : A → Type p) (R : A → A → Type r)
(≡↠R : ∀ {x y} → (x ≡ y) ↠ R x y)
(resp : ∀ {x y} → R x y → P x → P y) →
(∀ x p → resp (_↠_.to ≡↠R (refl x)) p ≡ p) →
∀ {x y} (r : R x y) (p : P x) →
resp r p ≡ subst P (_↠_.from ≡↠R r) p
transport-theorem′ P R ≡↠R resp hyp r p =
resp r p ≡⟨ sym $ cong (λ r → resp r p) (right-inverse-of r) ⟩
resp (to (from r)) p ≡⟨ elim (λ {x y} x≡y → ∀ p →
resp (_↠_.to ≡↠R x≡y) p ≡ subst P x≡y p)
(λ x p →
resp (_↠_.to ≡↠R (refl x)) p ≡⟨ hyp x p ⟩
p ≡⟨ sym $ subst-refl P p ⟩∎
subst P (refl x) p ∎) _ _ ⟩∎
subst P (from r) p ∎
where open _↠_ ≡↠R
-- Simplification (?) lemma for transport-theorem′.
transport-theorem′-refl :
∀ {a p r} {A : Type a}
(P : A → Type p) (R : A → A → Type r)
(≡≃R : ∀ {x y} → (x ≡ y) ≃ R x y)
(resp : ∀ {x y} → R x y → P x → P y) →
(resp-refl : ∀ x p → resp (_≃_.to ≡≃R (refl x)) p ≡ p) →
∀ {x} (p : P x) →
transport-theorem′ P R (_≃_.surjection ≡≃R) resp resp-refl
(_≃_.to ≡≃R (refl x)) p ≡
trans (trans (resp-refl x p) (sym $ subst-refl P p))
(sym $ cong (λ eq → subst P eq p)
(_≃_.left-inverse-of ≡≃R (refl x)))
transport-theorem′-refl P R ≡≃R resp resp-refl {x} p =
let body = λ x p → trans (resp-refl x p) (sym $ subst-refl P p)
lemma =
trans (sym $ cong (λ r → resp (to r) p) $ refl (refl x))
(elim (λ {x y} x≡y →
∀ p → resp (_≃_.to ≡≃R x≡y) p ≡ subst P x≡y p)
(λ x p → trans (resp-refl x p)
(sym $ subst-refl P p))
(refl x) p) ≡⟨ cong₂ (λ q r → trans q (r p))
(sym $ cong-sym (λ r → resp (to r) p) _)
(elim-refl (λ {x y} x≡y → ∀ p →
resp (_≃_.to ≡≃R x≡y) p ≡ subst P x≡y p) _) ⟩
trans (cong (λ r → resp (to r) p) $ sym $ refl (refl x))
(body x p) ≡⟨ cong (λ q → trans (cong (λ r → resp (to r) p) q) (body x p))
sym-refl ⟩
trans (cong (λ r → resp (to r) p) $ refl (refl x)) (body x p) ≡⟨ cong (λ q → trans q (body x p)) $
cong-refl (λ r → resp (to r) p) ⟩
trans (refl (resp (to (refl x)) p)) (body x p) ≡⟨ trans-reflˡ _ ⟩
body x p ≡⟨ sym $ trans-reflʳ _ ⟩
trans (body x p) (refl (subst P (refl x) p)) ≡⟨ cong (trans (body x p)) $ sym $
cong-refl (λ eq → subst P eq p) ⟩
trans (body x p)
(cong (λ eq → subst P eq p) (refl (refl x))) ≡⟨ cong (trans (body x p) ∘ cong (λ eq → subst P eq p)) $
sym sym-refl ⟩
trans (body x p)
(cong (λ eq → subst P eq p) (sym (refl (refl x)))) ≡⟨ cong (trans (body x p)) $ cong-sym (λ eq → subst P eq p) _ ⟩∎
trans (body x p)
(sym $ cong (λ eq → subst P eq p) (refl (refl x))) ∎
in
trans (sym $ cong (λ r → resp r p) $ right-inverse-of (to (refl x)))
(elim (λ {x y} x≡y →
∀ p → resp (_≃_.to ≡≃R x≡y) p ≡ subst P x≡y p)
body (from (to (refl x))) p) ≡⟨ cong (λ eq → trans (sym $ cong (λ r → resp r p) eq)
(elim (λ {x y} x≡y → ∀ p →
resp (_≃_.to ≡≃R x≡y) p ≡ subst P x≡y p)
body (from (to (refl x))) p)) $
sym $ left-right-lemma (refl x) ⟩
trans (sym $ cong (λ r → resp r p) $ cong to $
left-inverse-of (refl x))
(elim (λ {x y} x≡y →
∀ p → resp (_≃_.to ≡≃R x≡y) p ≡ subst P x≡y p)
body (from (to (refl x))) p) ≡⟨ cong (λ eq → trans (sym eq)
(elim (λ {x y} x≡y → ∀ p →
resp (_≃_.to ≡≃R x≡y) p ≡ subst P x≡y p)
body (from (to (refl x))) p)) $
cong-∘ (λ r → resp r p) to _ ⟩
trans (sym $ cong (λ r → resp (to r) p) $ left-inverse-of (refl x))
(elim (λ {x y} x≡y →
∀ p → resp (_≃_.to ≡≃R x≡y) p ≡ subst P x≡y p)
body (from (to (refl x))) p) ≡⟨ elim₁ (λ {q} eq → trans (sym $ cong (λ r → resp (to r) p) eq)
(elim (λ {x y} x≡y → ∀ p →
resp (_≃_.to ≡≃R x≡y) p ≡
subst P x≡y p)
body q p) ≡
trans (body x p)
(sym $ cong (λ eq → subst P eq p) eq))
lemma
(left-inverse-of (refl x)) ⟩∎
trans (body x p)
(sym $ cong (λ eq → subst P eq p) (left-inverse-of (refl x))) ∎
where open _≃_ ≡≃R
-- Simplification (?) lemma for transport-theorem.
transport-theorem-≡⇒≃-refl :
∀ {p₁ p₂} (P : Type p₁ → Type p₂)
(resp : ∀ {A B} → A ≃ B → P A → P B)
(resp-id : ∀ {A} (p : P A) → resp Eq.id p ≡ p)
(univ : Univalence p₁) {A} (p : P A) →
transport-theorem P resp resp-id univ (≡⇒≃ (refl A)) p ≡
trans (trans (trans (cong (λ eq → resp eq p) ≡⇒≃-refl)
(resp-id p))
(sym $ subst-refl P p))
(sym $ cong (λ eq → subst P eq p)
(_≃_.left-inverse-of (≡≃≃ univ) (refl A)))
transport-theorem-≡⇒≃-refl P resp resp-id univ {A} p =
transport-theorem′-refl P _≃_ (≡≃≃ univ) resp
(λ _ p → trans (cong (λ eq → resp eq p) ≡⇒≃-refl) (resp-id p)) p
-- A variant of resp-is-equivalence.
resp-is-equivalence′ :
∀ {a p r} {A : Type a}
(P : A → Type p) (R : A → A → Type r)
(≡↠R : ∀ {x y} → (x ≡ y) ↠ R x y)
(resp : ∀ {x y} → R x y → P x → P y) →
(∀ x p → resp (_↠_.to ≡↠R (refl x)) p ≡ p) →
∀ {x y} (r : R x y) → Is-equivalence (resp r)
resp-is-equivalence′ P R ≡↠R resp hyp r =
Eq.respects-extensional-equality
(λ p → sym $ transport-theorem′ P R ≡↠R resp hyp r p)
(Eq.subst-is-equivalence P (_↠_.from ≡↠R r))
-- A lemma relating ≃⇒≡, →-cong and cong₂.
≃⇒≡-→-cong :
∀ {ℓ} {A₁ A₂ B₁ B₂ : Type ℓ}
(ext : Extensionality ℓ ℓ) →
(univ : Univalence ℓ)
(A₁≃A₂ : A₁ ≃ A₂) (B₁≃B₂ : B₁ ≃ B₂) →
≃⇒≡ univ (→-cong ext A₁≃A₂ B₁≃B₂) ≡
cong₂ (λ A B → A → B) (≃⇒≡ univ A₁≃A₂) (≃⇒≡ univ B₁≃B₂)
≃⇒≡-→-cong {A₂ = A₂} {B₁} ext univ A₁≃A₂ B₁≃B₂ =
≃⇒≡ univ (→-cong ext A₁≃A₂ B₁≃B₂) ≡⟨ cong (≃⇒≡ univ) (Eq.lift-equality ext lemma) ⟩
≃⇒≡ univ (≡⇒≃ (cong₂ (λ A B → A → B) (≃⇒≡ univ A₁≃A₂)
(≃⇒≡ univ B₁≃B₂))) ≡⟨ left-inverse-of (≡≃≃ univ) _ ⟩∎
cong₂ (λ A B → A → B) (≃⇒≡ univ A₁≃A₂) (≃⇒≡ univ B₁≃B₂) ∎
where
open _≃_
lemma :
(λ f → to B₁≃B₂ ∘ f ∘ from A₁≃A₂) ≡
to (≡⇒≃ (cong₂ (λ A B → A → B) (≃⇒≡ univ A₁≃A₂)
(≃⇒≡ univ B₁≃B₂)))
lemma =
(λ f → to B₁≃B₂ ∘ f ∘ from A₁≃A₂) ≡⟨ apply-ext ext (λ _ → transport-theorem (λ B → A₂ → B) (λ A≃B g → _≃_.to A≃B ∘ g)
refl univ B₁≃B₂ _) ⟩
subst (λ B → A₂ → B) (≃⇒≡ univ B₁≃B₂) ∘
(λ f → f ∘ from A₁≃A₂) ≡⟨ cong (_∘_ (subst (λ B → A₂ → B) (≃⇒≡ univ B₁≃B₂))) (apply-ext ext λ f →
transport-theorem (λ A → A → B₁) (λ A≃B g → g ∘ _≃_.from A≃B) refl univ A₁≃A₂ f) ⟩
subst (λ B → A₂ → B) (≃⇒≡ univ B₁≃B₂) ∘
subst (λ A → A → B₁) (≃⇒≡ univ A₁≃A₂) ≡⟨ cong₂ (λ g h f → g (h f))
(apply-ext ext $ subst-in-terms-of-≡⇒↝ equivalence _ (λ B → A₂ → B))
(apply-ext ext $ subst-in-terms-of-≡⇒↝ equivalence _ (λ A → A → B₁)) ⟩
to (≡⇒≃ (cong (λ B → A₂ → B) (≃⇒≡ univ B₁≃B₂))) ∘
to (≡⇒≃ (cong (λ A → A → B₁) (≃⇒≡ univ A₁≃A₂))) ≡⟨⟩
to (≡⇒≃ (cong (λ B → A₂ → B) (≃⇒≡ univ B₁≃B₂)) ⊚
≡⇒≃ (cong (λ A → A → B₁) (≃⇒≡ univ A₁≃A₂))) ≡⟨ cong to $ sym $ ≡⇒≃-trans ext _ _ ⟩∎
to (≡⇒≃ (cong₂ (λ A B → A → B) (≃⇒≡ univ A₁≃A₂)
(≃⇒≡ univ B₁≃B₂))) ∎
-- One can sometimes push cong through ≃⇒≡ (assuming
-- extensionality).
cong-≃⇒≡ :
∀ {ℓ p} {A B : Type ℓ} {A≃B : A ≃ B} →
Extensionality p p →
(univ₁ : Univalence ℓ)
(univ₂ : Univalence p)
(P : Type ℓ → Type p)
(P-cong : ∀ {A B} → A ≃ B → P A ≃ P B) →
(∀ {A} (p : P A) → _≃_.to (P-cong Eq.id) p ≡ p) →
cong P (≃⇒≡ univ₁ A≃B) ≡ ≃⇒≡ univ₂ (P-cong A≃B)
cong-≃⇒≡ {A≃B = A≃B} ext univ₁ univ₂ P P-cong P-cong-id =
cong P (≃⇒≡ univ₁ A≃B) ≡⟨ sym $ _≃_.left-inverse-of (≡≃≃ univ₂) _ ⟩
≃⇒≡ univ₂ (≡⇒≃ (cong P (≃⇒≡ univ₁ A≃B))) ≡⟨ cong (≃⇒≡ univ₂) $ Eq.lift-equality ext lemma ⟩∎
≃⇒≡ univ₂ (P-cong A≃B) ∎
where
lemma : ≡⇒→ (cong P (≃⇒≡ univ₁ A≃B)) ≡ _≃_.to (P-cong A≃B)
lemma = apply-ext ext λ x →
≡⇒→ (cong P (≃⇒≡ univ₁ A≃B)) x ≡⟨ sym $ subst-in-terms-of-≡⇒↝ equivalence _ P x ⟩
subst P (≃⇒≡ univ₁ A≃B) x ≡⟨ sym $ transport-theorem P (_≃_.to ∘ P-cong) P-cong-id univ₁ A≃B x ⟩∎
_≃_.to (P-cong A≃B) x ∎
-- Any "resp" function that preserves identity also preserves
-- compositions (assuming univalence and extensionality).
resp-preserves-compositions :
∀ {p₁ p₂} (P : Type p₁ → Type p₂) →
(resp : ∀ {A B} → A ≃ B → P A → P B) →
(∀ {A} (p : P A) → resp Eq.id p ≡ p) →
Univalence p₁ → Extensionality p₁ p₁ →
∀ {A B C} (A≃B : A ≃ B) (B≃C : B ≃ C) p →
resp (B≃C ⊚ A≃B) p ≡ (resp B≃C ∘ resp A≃B) p
resp-preserves-compositions P resp resp-id univ ext A≃B B≃C p =
resp (B≃C ⊚ A≃B) p ≡⟨ transport-theorem P resp resp-id univ _ _ ⟩
subst P (≃⇒≡ univ (B≃C ⊚ A≃B)) p ≡⟨ cong (λ eq → subst P eq p) $ ≃⇒≡-∘ univ ext A≃B B≃C ⟩
subst P (trans (≃⇒≡ univ A≃B) (≃⇒≡ univ B≃C)) p ≡⟨ sym $ subst-subst P _ _ _ ⟩
subst P (≃⇒≡ univ B≃C) (subst P (≃⇒≡ univ A≃B) p) ≡⟨ sym $ transport-theorem P resp resp-id univ _ _ ⟩
resp B≃C (subst P (≃⇒≡ univ A≃B) p) ≡⟨ sym $ cong (resp _) $ transport-theorem P resp resp-id univ _ _ ⟩∎
resp B≃C (resp A≃B p) ∎
-- Any "resp" function that preserves identity also preserves
-- inverses (assuming univalence and extensionality).
resp-preserves-inverses :
∀ {p₁ p₂} (P : Type p₁ → Type p₂) →
(resp : ∀ {A B} → A ≃ B → P A → P B) →
(∀ {A} (p : P A) → resp Eq.id p ≡ p) →
Univalence p₁ → Extensionality p₁ p₁ →
∀ {A B} (A≃B : A ≃ B) p q →
resp A≃B p ≡ q → resp (inverse A≃B) q ≡ p
resp-preserves-inverses P resp resp-id univ ext A≃B p q eq =
let lemma =
q ≡⟨ sym eq ⟩
resp A≃B p ≡⟨ transport-theorem P resp resp-id univ _ _ ⟩
subst P (≃⇒≡ univ A≃B) p ≡⟨ cong (λ eq → subst P eq p) $ sym $ sym-sym _ ⟩∎
subst P (sym (sym (≃⇒≡ univ A≃B))) p ∎
in
resp (inverse A≃B) q ≡⟨ transport-theorem P resp resp-id univ _ _ ⟩
subst P (≃⇒≡ univ (inverse A≃B)) q ≡⟨ cong (λ eq → subst P eq q) $ ≃⇒≡-inverse univ ext A≃B ⟩
subst P (sym (≃⇒≡ univ A≃B)) q ≡⟨ cong (subst P (sym (≃⇒≡ univ A≃B))) lemma ⟩
subst P (sym (≃⇒≡ univ A≃B)) (subst P (sym (sym (≃⇒≡ univ A≃B))) p) ≡⟨ subst-subst-sym P _ _ ⟩∎
p ∎
-- Equality preserves equivalences (assuming extensionality and
-- univalence).
≡-preserves-≃ :
∀ {ℓ₁ ℓ₂}
{A₁ : Type ℓ₁} {A₂ : Type ℓ₂} {B₁ : Type ℓ₁} {B₂ : Type ℓ₂} →
Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) →
Univalence′ A₁ B₁ →
Univalence′ A₂ B₂ →
A₁ ≃ A₂ → B₁ ≃ B₂ → (A₁ ≡ B₁) ≃ (A₂ ≡ B₂)
≡-preserves-≃ {ℓ₁} {ℓ₂} {A₁} {A₂} {B₁} {B₂}
ext univ₁ univ₂ A₁≃A₂ B₁≃B₂ = Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ to = to
; from = from
}
; right-inverse-of = to∘from
}
; left-inverse-of = from∘to
})
where
to = λ A₁≡B₁ → ≃⇒≡ univ₂ (
A₂ ↝⟨ inverse A₁≃A₂ ⟩
A₁ ↝⟨ ≡⇒≃ A₁≡B₁ ⟩
B₁ ↝⟨ B₁≃B₂ ⟩□
B₂ □)
from = λ A₂≡B₂ → ≃⇒≡ univ₁ (
A₁ ↝⟨ A₁≃A₂ ⟩
A₂ ↝⟨ ≡⇒≃ A₂≡B₂ ⟩
B₂ ↝⟨ inverse B₁≃B₂ ⟩□
B₁ □)
abstract
to∘from : ∀ eq → to (from eq) ≡ eq
to∘from A₂≡B₂ =
let ext₂ = lower-extensionality ℓ₁ ℓ₁ ext in
_≃_.to (Eq.≃-≡ (≡≃≃ univ₂)) (Eq.lift-equality ext₂ (
≡⇒→ (≃⇒≡ univ₂ ((B₁≃B₂ ⊚ ≡⇒≃ (≃⇒≡ univ₁ ((inverse B₁≃B₂ ⊚
≡⇒≃ A₂≡B₂) ⊚ A₁≃A₂))) ⊚ inverse A₁≃A₂)) ≡⟨ cong _≃_.to $ _≃_.right-inverse-of (≡≃≃ univ₂) _ ⟩
(_≃_.to B₁≃B₂ ∘
≡⇒→ (≃⇒≡ univ₁ ((inverse B₁≃B₂ ⊚ ≡⇒≃ A₂≡B₂) ⊚ A₁≃A₂)) ∘
_≃_.from A₁≃A₂) ≡⟨ cong (λ eq → _≃_.to B₁≃B₂ ∘ _≃_.to eq ∘ _≃_.from A₁≃A₂) $
_≃_.right-inverse-of (≡≃≃ univ₁) _ ⟩
((_≃_.to B₁≃B₂ ∘ _≃_.from B₁≃B₂) ∘ ≡⇒→ A₂≡B₂ ∘
(_≃_.to A₁≃A₂ ∘ _≃_.from A₁≃A₂)) ≡⟨ cong₂ (λ f g → f ∘ ≡⇒→ A₂≡B₂ ∘ g)
(apply-ext ext₂ $ _≃_.right-inverse-of B₁≃B₂)
(apply-ext ext₂ $ _≃_.right-inverse-of A₁≃A₂) ⟩∎
≡⇒→ A₂≡B₂ ∎))
from∘to : ∀ eq → from (to eq) ≡ eq
from∘to A₁≡B₁ =
let ext₁ = lower-extensionality ℓ₂ ℓ₂ ext in
_≃_.to (Eq.≃-≡ (≡≃≃ univ₁)) (Eq.lift-equality ext₁ (
≡⇒→ (≃⇒≡ univ₁ ((inverse B₁≃B₂ ⊚ ≡⇒≃ (≃⇒≡ univ₂ ((B₁≃B₂ ⊚
≡⇒≃ A₁≡B₁) ⊚ inverse A₁≃A₂))) ⊚ A₁≃A₂)) ≡⟨ cong _≃_.to $ _≃_.right-inverse-of (≡≃≃ univ₁) _ ⟩
(_≃_.from B₁≃B₂ ∘
≡⇒→ (≃⇒≡ univ₂ ((B₁≃B₂ ⊚ ≡⇒≃ A₁≡B₁) ⊚ inverse A₁≃A₂)) ∘
_≃_.to A₁≃A₂) ≡⟨ cong (λ eq → _≃_.from B₁≃B₂ ∘ _≃_.to eq ∘ _≃_.to A₁≃A₂) $
_≃_.right-inverse-of (≡≃≃ univ₂) _ ⟩
((_≃_.from B₁≃B₂ ∘ _≃_.to B₁≃B₂) ∘ ≡⇒→ A₁≡B₁ ∘
(_≃_.from A₁≃A₂ ∘ _≃_.to A₁≃A₂)) ≡⟨ cong₂ (λ f g → f ∘ ≡⇒→ A₁≡B₁ ∘ g)
(apply-ext ext₁ $ _≃_.left-inverse-of B₁≃B₂)
(apply-ext ext₁ $ _≃_.left-inverse-of A₁≃A₂) ⟩∎
≡⇒→ A₁≡B₁ ∎))
-- Singletons expressed using equivalences instead of equalities,
-- where the types are required to live in the same universe, are
-- contractible (assuming univalence).
singleton-with-≃-contractible :
∀ {b} {B : Type b} →
Univalence b →
Contractible (∃ λ (A : Type b) → A ≃ B)
singleton-with-≃-contractible univ =
H-level.respects-surjection
(∃-cong λ _ → _≃_.surjection (≡≃≃ univ))
0
(singleton-contractible _)
other-singleton-with-≃-contractible :
∀ {a} {A : Type a} →
Univalence a →
Contractible (∃ λ (B : Type a) → A ≃ B)
other-singleton-with-≃-contractible univ =
H-level.respects-surjection
(∃-cong λ _ → _≃_.surjection (≡≃≃ univ))
0
(other-singleton-contractible _)
-- Singletons expressed using equivalences instead of equalities are
-- isomorphic to the unit type (assuming extensionality and
-- univalence).
singleton-with-≃-↔-⊤ :
∀ {a b} {B : Type b} →
Extensionality (a ⊔ b) (a ⊔ b) →
Univalence (a ⊔ b) →
(∃ λ (A : Type (a ⊔ b)) → A ≃ B) ↔ ⊤
singleton-with-≃-↔-⊤ {a} {B = B} ext univ =
(∃ λ A → A ≃ B) ↝⟨ inverse (∃-cong λ _ → Eq.≃-preserves-bijections ext F.id Bijection.↑↔) ⟩
(∃ λ A → A ≃ ↑ a B) ↔⟨ inverse (∃-cong λ _ → ≡≃≃ univ) ⟩
(∃ λ A → A ≡ ↑ a B) ↝⟨ _⇔_.to contractible⇔↔⊤ (singleton-contractible _) ⟩□
⊤ □
other-singleton-with-≃-↔-⊤ :
∀ {a b} {A : Type a} →
Extensionality (a ⊔ b) (a ⊔ b) →
Univalence (a ⊔ b) →
(∃ λ (B : Type (a ⊔ b)) → A ≃ B) ↔ ⊤
other-singleton-with-≃-↔-⊤ {b = b} {A} ext univ =
(∃ λ B → A ≃ B) ↝⟨ (∃-cong λ _ → Eq.inverse-isomorphism ext) ⟩
(∃ λ B → B ≃ A) ↝⟨ singleton-with-≃-↔-⊤ {a = b} ext univ ⟩□
⊤ □
-- Variants of the two lemmas above.
singleton-with-Π-≃-≃-⊤ :
∀ {a q} {A : Type a} {Q : A → Type q} →
Extensionality a (lsuc q) →
Univalence q →
(∃ λ (P : A → Type q) → ∀ x → P x ≃ Q x) ≃ ⊤
singleton-with-Π-≃-≃-⊤ {a = a} {q = q} {A = A} {Q = Q} ext univ =
(∃ λ (P : A → Type q) → ∀ x → P x ≃ Q x) ↝⟨ (inverse $ ∃-cong λ _ → ∀-cong ext λ _ → ≡≃≃ univ) ⟩
(∃ λ (P : A → Type q) → ∀ x → P x ≡ Q x) ↝⟨ (∃-cong λ _ → Eq.extensionality-isomorphism ext) ⟩
(∃ λ (P : A → Type q) → P ≡ Q) ↔⟨ _⇔_.to contractible⇔↔⊤ (singleton-contractible _) ⟩□
⊤ □
other-singleton-with-Π-≃-≃-⊤ :
∀ {a p} {A : Type a} {P : A → Type p} →
Extensionality a (lsuc p) →
Univalence p →
(∃ λ (Q : A → Type p) → ∀ x → P x ≃ Q x) ≃ ⊤
other-singleton-with-Π-≃-≃-⊤ {a = a} {p = p} {A = A} {P = P} ext univ =
(∃ λ (Q : A → Type p) → ∀ x → P x ≃ Q x) ↝⟨ (inverse $ ∃-cong λ _ → ∀-cong ext λ _ → ≡≃≃ univ) ⟩
(∃ λ (Q : A → Type p) → ∀ x → P x ≡ Q x) ↝⟨ (∃-cong λ _ → Eq.extensionality-isomorphism ext) ⟩
(∃ λ (Q : A → Type p) → P ≡ Q) ↔⟨ _⇔_.to contractible⇔↔⊤ (other-singleton-contractible _) ⟩□
⊤ □
-- ∃ Contractible is isomorphic to the unit type (assuming
-- extensionality and univalence).
∃Contractible↔⊤ :
∀ {a} →
Extensionality a a →
Univalence a →
(∃ λ (A : Type a) → Contractible A) ↔ ⊤
∃Contractible↔⊤ ext univ =
(∃ λ A → Contractible A) ↝⟨ (∃-cong λ _ → contractible↔≃⊤ ext) ⟩
(∃ λ A → A ≃ ⊤) ↝⟨ singleton-with-≃-↔-⊤ ext univ ⟩
⊤ □
-- If two types have a certain h-level, then the type of equalities
-- between these types also has the given h-level (assuming
-- extensionality and univalence).
H-level-H-level-≡ :
∀ {a} {A₁ A₂ : Type a} →
Extensionality a a →
Univalence′ A₁ A₂ →
∀ n → H-level n A₁ → H-level n A₂ → H-level n (A₁ ≡ A₂)
H-level-H-level-≡ {A₁ = A₁} {A₂} ext univ n = curry (
H-level n A₁ × H-level n A₂ ↝⟨ uncurry (Eq.h-level-closure ext n) ⟩
H-level n (A₁ ≃ A₂) ↝⟨ H-level.respects-surjection (_≃_.surjection $ inverse $ ≡≃≃ univ) n ⟩
H-level n (A₁ ≡ A₂) □)
-- If a type has a certain positive h-level, then the types of
-- equalities between this type and other types also has the given
-- h-level (assuming extensionality and univalence).
H-level-H-level-≡ˡ :
∀ {a} {A₁ A₂ : Type a} →
Extensionality a a →
Univalence′ A₁ A₂ →
∀ n → H-level (1 + n) A₁ → H-level (1 + n) (A₁ ≡ A₂)
H-level-H-level-≡ˡ {A₁ = A₁} {A₂} ext univ n =
H-level (1 + n) A₁ ↝⟨ Eq.left-closure ext n ⟩
H-level (1 + n) (A₁ ≃ A₂) ↝⟨ H-level.respects-surjection (_≃_.surjection $ inverse $ ≡≃≃ univ) (1 + n) ⟩
H-level (1 + n) (A₁ ≡ A₂) □
H-level-H-level-≡ʳ :
∀ {a} {A₁ A₂ : Type a} →
Extensionality a a →
Univalence′ A₁ A₂ →
∀ n → H-level (1 + n) A₂ → H-level (1 + n) (A₁ ≡ A₂)
H-level-H-level-≡ʳ {A₁ = A₁} {A₂} ext univ n =
H-level (1 + n) A₂ ↝⟨ Eq.right-closure ext n ⟩
H-level (1 + n) (A₁ ≃ A₂) ↝⟨ H-level.respects-surjection (_≃_.surjection $ inverse $ ≡≃≃ univ) (1 + n) ⟩
H-level (1 + n) (A₁ ≡ A₂) □
-- ∃ λ A → H-level n A has h-level 1 + n (assuming extensionality and
-- univalence).
∃-H-level-H-level-1+ :
∀ {a} →
Extensionality a a →
Univalence a →
∀ n → H-level (1 + n) (∃ λ (A : Type a) → H-level n A)
∃-H-level-H-level-1+ ext univ n = ≡↔+ _ _ λ { (A₁ , h₁) (A₂ , h₂) →
$⟨ h₁ , h₂ ⟩
H-level n A₁ × H-level n A₂ ↝⟨ uncurry (H-level-H-level-≡ ext univ n) ⟩
H-level n (A₁ ≡ A₂) ↝⟨ H-level.respects-surjection
(_↔_.surjection $ ignore-propositional-component
(H-level-propositional ext _)) n ⟩□
H-level n ((A₁ , h₁) ≡ (A₂ , h₂)) □ }
-- ∃ λ A → Is-proposition A is a set (assuming extensionality and
-- propositional extensionality).
Is-set-∃-Is-proposition :
∀ {a} →
Extensionality (lsuc a) (lsuc a) →
Propositional-extensionality a →
Is-set (∃ λ (A : Type a) → Is-proposition A)
Is-set-∃-Is-proposition {a} ext prop-ext
{x = A₁ , A₁-prop} {y = A₂ , A₂-prop} =
$⟨ _≃_.to (Propositional-extensionality-is-univalence-for-propositions ext)
prop-ext A₁-prop A₂-prop ⟩
Univalence′ A₁ A₂ ↝⟨ (λ univ → H-level-H-level-≡ ext′ univ 1 A₁-prop A₂-prop) ⟩
Is-proposition (A₁ ≡ A₂) ↝⟨ H-level.respects-surjection
(_↔_.surjection $ ignore-propositional-component
(H-level-propositional ext′ 1)) 1 ⟩□
Is-proposition ((A₁ , A₁-prop) ≡ (A₂ , A₂-prop)) □
where
ext′ = lower-extensionality _ _ ext
-- ∃ λ A → H-level n A does not in general have h-level n.
--
-- (Kraus and Sattler show that, for all n,
-- ∃ λ (A : Set (# n)) → H-level (2 + n) A does not have h-level
-- 2 + n, assuming univalence. See "Higher Homotopies in a Hierarchy
-- of Univalent Universes".)
¬-∃-H-level-H-level :
∀ {a} →
∃ λ n → ¬ H-level n (∃ λ (A : Type a) → H-level n A)
¬-∃-H-level-H-level =
1 ,
( Is-proposition (∃ λ A → Is-proposition A) ↔⟨⟩
((p q : ∃ λ A → Is-proposition A) → p ≡ q) ↝⟨ (λ f p q → cong proj₁ (f p q)) ⟩
((p q : ∃ λ A → Is-proposition A) → proj₁ p ≡ proj₁ q) ↝⟨ (_$ (⊥ , ⊥-propositional)) ∘
(_$ (↑ _ ⊤ , ↑-closure 1 (mono₁ 0 ⊤-contractible))) ⟩
↑ _ ⊤ ≡ ⊥ ↝⟨ flip (subst id) _ ⟩
⊥ ↝⟨ ⊥-elim ⟩□
⊥₀ □)
-- A certain type of uninhabited types is isomorphic to the unit type
-- (assuming extensionality and univalence).
∃¬↔⊤ :
∀ {a} →
Extensionality a a →
Univalence a →
(∃ λ (A : Type a) → ¬ A) ↔ ⊤
∃¬↔⊤ ext univ =
(∃ λ A → ¬ A) ↔⟨ inverse (∃-cong λ _ → ≃⊥≃¬ ext) ⟩
(∃ λ A → A ≃ ⊥₀) ↔⟨ singleton-with-≃-↔-⊤ ext univ ⟩
⊤ □
-- The following three proofs are taken from or variants of proofs in
-- "Higher Homotopies in a Hierarchy of Univalent Universes" by Kraus
-- and Sattler (Section 3).
-- There is a function which, despite having the same type, is not
-- equal to a certain instance of reflexivity (assuming extensionality
-- and univalence).
∃≢refl :
Extensionality (# 1) (# 1) →
Univalence (# 0) →
∃ λ (A : Type₁) → ∃ λ (f : (x : A) → x ≡ x) → f ≢ refl
∃≢refl ext univ =
(∃ λ (A : Type) → A ≡ A)
, _↔_.from iso f
, (_↔_.from iso f ≡ refl ↝⟨ cong (_↔_.to iso) ⟩
_↔_.to iso (_↔_.from iso f) ≡ _↔_.to iso refl ↝⟨ (λ eq → f ≡⟨ sym (_↔_.right-inverse-of iso f) ⟩
_↔_.to iso (_↔_.from iso f) ≡⟨ eq ⟩∎
_↔_.to iso refl ∎) ⟩
f ≡ _↔_.to iso refl ↝⟨ cong (λ f → proj₁ (f Bool (swap-as-an-equality univ))) ⟩
swap-as-an-equality univ ≡ proj₁ (_↔_.to iso refl Bool _) ↝⟨ (λ eq → swap-as-an-equality univ ≡⟨ eq ⟩
proj₁ (_↔_.to iso refl Bool _) ≡⟨ cong proj₁ Σ-≡,≡←≡-refl ⟩∎
refl Bool ∎) ⟩
swap-as-an-equality univ ≡ refl Bool ↝⟨ swap≢refl univ ⟩□
⊥ □)
where
f = λ A p → p , refl (trans p p)
iso =
((p : ∃ λ A → A ≡ A) → p ≡ p) ↝⟨ currying ⟩
(∀ A (p : A ≡ A) → (A , p) ≡ (A , p)) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ →
inverse $ Bijection.Σ-≡,≡↔≡ {a = # 1}) ⟩
((A : Type) (p : A ≡ A) →
∃ λ (q : A ≡ A) → subst (λ A → A ≡ A) q p ≡ p) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ →
∃-cong λ _ → ≡⇒↝ _ [subst≡]≡[trans≡trans]) ⟩□
((A : Type) (p : A ≡ A) →
∃ λ (q : A ≡ A) → trans p q ≡ trans q p) □
-- The type (a : A) → a ≡ a is not necessarily a proposition (assuming
-- extensionality and univalence).
¬-type-of-refl-propositional :
Extensionality (# 1) (# 1) →
Univalence (# 0) →
∃ λ (A : Type₁) → ¬ Is-proposition ((a : A) → a ≡ a)
¬-type-of-refl-propositional ext univ =
let A , f , f≢refl = ∃≢refl ext univ in
A ,
(Is-proposition (∀ x → x ≡ x) ↝⟨ (λ irr → irr _ _) ⟩
f ≡ refl ↝⟨ f≢refl ⟩□
⊥ □)
-- Type₁ does not have h-level 3 (assuming extensionality and
-- univalence).
¬-Type₁-groupoid :
Extensionality (# 1) (# 1) →
Univalence (# 1) →
Univalence (# 0) →
¬ H-level 3 Type₁
¬-Type₁-groupoid ext univ₁ univ₀ =
let L = _ in
H-level 3 Type₁ ↝⟨ (λ h → h) ⟩
Is-set (L ≡ L) ↝⟨ H-level.respects-surjection (_≃_.surjection $ ≡≃≃ univ₁) 2 ⟩
Is-set (L ≃ L) ↝⟨ (λ h → h) ⟩
Is-proposition (F.id ≡ F.id) ↝⟨ H-level.respects-surjection (_≃_.surjection $ inverse $ Eq.≃-≡ $ Eq.↔⇒≃ Eq.≃-as-Σ) 1 ⟩
Is-proposition ((id , _) ≡ (id , _)) ↝⟨ H-level.respects-surjection
(_↔_.surjection $ inverse $ ignore-propositional-component (Eq.propositional ext id)) 1 ⟩
Is-proposition (id ≡ id) ↝⟨ H-level.respects-surjection (_≃_.surjection $ inverse $ Eq.extensionality-isomorphism ext) 1 ⟩
Is-proposition ((l : L) → l ≡ l) ↝⟨ proj₂ $ ¬-type-of-refl-propositional ext univ₀ ⟩□
⊥ □
-- For propositional types there is a split surjection from equality
-- to logical equivalence (assuming univalence).
≡↠⇔ : ∀ {ℓ} {A B : Type ℓ} →
Univalence′ A B →
Is-proposition A → Is-proposition B →
(A ≡ B) ↠ (A ⇔ B)
≡↠⇔ {A = A} {B} univ A-prop B-prop =
A ≡ B ↔⟨ ≡≃≃ univ ⟩
A ≃ B ↝⟨ Eq.≃↠⇔ A-prop B-prop ⟩□
A ⇔ B □
-- For propositional types logical equivalence is isomorphic to
-- equality (assuming extensionality and univalence).
⇔↔≡ : ∀ {ℓ} {A B : Type ℓ} →
Extensionality ℓ ℓ →
Univalence′ A B →
Is-proposition A → Is-proposition B →
(A ⇔ B) ↔ (A ≡ B)
⇔↔≡ {A = A} {B} ext univ A-prop B-prop =
A ⇔ B ↝⟨ Eq.⇔↔≃ ext A-prop B-prop ⟩
A ≃ B ↔⟨ inverse $ ≡≃≃ univ ⟩□
A ≡ B □
-- A variant of the previous statement.
⇔↔≡′ : ∀ {ℓ} {A B : Proposition ℓ} →
Extensionality ℓ ℓ →
Univalence′ (proj₁ A) (proj₁ B) →
(proj₁ A ⇔ proj₁ B) ↔ (A ≡ B)
⇔↔≡′ {A = A} {B} ext univ =
proj₁ A ⇔ proj₁ B ↝⟨ ⇔↔≡ ext univ (proj₂ A) (proj₂ B) ⟩
proj₁ A ≡ proj₁ B ↝⟨ ignore-propositional-component (H-level-propositional ext 1) ⟩□
A ≡ B □
-- A variant of the previous statement.
⇔↔≡″ : ∀ {ℓ} {A B : Proposition ℓ} →
Extensionality (lsuc ℓ) (lsuc ℓ) →
Propositional-extensionality ℓ →
(proj₁ A ⇔ proj₁ B) ↔ (A ≡ B)
⇔↔≡″ {ℓ} {A} {B} ext =
Propositional-extensionality ℓ ↝⟨ (λ prop-ext → _≃_.to (Propositional-extensionality-is-univalence-for-propositions ext)
prop-ext (proj₂ A) (proj₂ B)) ⟩
Univalence′ (proj₁ A) (proj₁ B) ↝⟨ ⇔↔≡′ (lower-extensionality _ _ ext) ⟩□
(proj₁ A ⇔ proj₁ B) ↔ (A ≡ B) □
------------------------------------------------------------------------
-- Variants of J for equivalences
-- Two variants of the J rule for equivalences, along with
-- "computation" rules.
--
-- The types of the eliminators are similar to the statement of
-- Corollary 5.8.5 from the HoTT book (where the motive takes two type
-- arguments). The type and code of ≃-elim₁ are based on code from the
-- cubical library written by Matthew Yacavone, which was possibly
-- based on code written by Anders Mörtberg.
≃-elim₁ :
∀ {ℓ p} {A B : Type ℓ} →
Univalence ℓ →
(P : {A : Type ℓ} → A ≃ B → Type p) →
P (Eq.id {A = B}) →
(A≃B : A ≃ B) → P A≃B
≃-elim₁ univ P p A≃B =
subst
(λ (_ , A≃B) → P A≃B)
(mono₁ 0 (singleton-with-≃-contractible univ) _ _)
p
≃-elim₁-id :
∀ {ℓ p} {B : Type ℓ}
(univ : Univalence ℓ)
(P : {A : Type ℓ} → A ≃ B → Type p)
(p : P (Eq.id {A = B})) →
≃-elim₁ univ P p Eq.id ≡ p
≃-elim₁-id univ P p =
subst
(λ (_ , A≃B) → P A≃B)
(mono₁ 0 (singleton-with-≃-contractible univ) _ _)
p ≡⟨ cong (λ eq → subst (λ (_ , A≃B) → P A≃B) eq _) $
mono₁ 1 (mono₁ 0 (singleton-with-≃-contractible univ)) _ _ ⟩
subst (λ (_ , A≃B) → P A≃B) (refl _) p ≡⟨ subst-refl _ _ ⟩∎
p ∎
≃-elim¹ :
∀ {ℓ p} {A B : Type ℓ} →
Univalence ℓ →
(P : {B : Type ℓ} → A ≃ B → Type p) →
P (Eq.id {A = A}) →
(A≃B : A ≃ B) → P A≃B
≃-elim¹ univ P p A≃B =
subst
(λ (_ , A≃B) → P A≃B)
(mono₁ 0 (other-singleton-with-≃-contractible univ) _ _)
p
≃-elim¹-id :
∀ {ℓ p} {A : Type ℓ}
(univ : Univalence ℓ)
(P : {B : Type ℓ} → A ≃ B → Type p)
(p : P (Eq.id {A = A})) →
≃-elim¹ univ P p Eq.id ≡ p
≃-elim¹-id univ P p =
subst
(λ (_ , A≃B) → P A≃B)
(mono₁ 0 (other-singleton-with-≃-contractible univ) _ _)
p ≡⟨ cong (λ eq → subst (λ (_ , A≃B) → P A≃B) eq _) $
mono₁ 1 (mono₁ 0 (other-singleton-with-≃-contractible univ)) _ _ ⟩
subst (λ (_ , A≃B) → P A≃B) (refl _) p ≡⟨ subst-refl _ _ ⟩∎
p ∎
| {
"alphanum_fraction": 0.4353024976,
"avg_line_length": 42.4061696658,
"ext": "agda",
"hexsha": "4643aa89c889d4665cbd01e8b44c6c1fe8ea1a39",
"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.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.agda",
"max_line_length": 154,
"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.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": 25658,
"size": 65984
} |
{-# OPTIONS --without-K --rewriting #-}
module lib.groups.Groups where
open import lib.groups.CommutingSquare public
open import lib.groups.FreeAbelianGroup public
open import lib.groups.FreeGroup public
open import lib.groups.GroupProduct public
open import lib.groups.Homomorphism public
open import lib.groups.HomotopyGroup public
open import lib.groups.Int public
open import lib.groups.Isomorphism public
open import lib.groups.Lift public
open import lib.groups.LoopSpace public
open import lib.groups.QuotientGroup public
open import lib.groups.PullbackGroup public
open import lib.groups.Subgroup public
open import lib.groups.SubgroupProp public
open import lib.groups.TruncationGroup public
open import lib.groups.Unit public
| {
"alphanum_fraction": 0.8376184032,
"avg_line_length": 33.5909090909,
"ext": "agda",
"hexsha": "cbf6f55823aa454cd4a80e7c727f07197c041911",
"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": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "core/lib/groups/Groups.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": "core/lib/groups/Groups.agda",
"max_line_length": 46,
"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": "core/lib/groups/Groups.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 159,
"size": 739
} |
A : Set₁
A = Set
{-# POLARITY A #-}
| {
"alphanum_fraction": 0.4864864865,
"avg_line_length": 7.4,
"ext": "agda",
"hexsha": "23042b00c90f1d74174c53c29e36a99e08a3993c",
"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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pthariensflame/agda",
"max_forks_repo_path": "test/Fail/Polarity-pragma-for-defined-name.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"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": "pthariensflame/agda",
"max_issues_repo_path": "test/Fail/Polarity-pragma-for-defined-name.agda",
"max_line_length": 18,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pthariensflame/agda",
"max_stars_repo_path": "test/Fail/Polarity-pragma-for-defined-name.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": 15,
"size": 37
} |
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness
--no-subtyping #-}
module Agda.Builtin.Float where
open import Agda.Builtin.Bool
open import Agda.Builtin.Int
open import Agda.Builtin.Maybe
open import Agda.Builtin.Nat
open import Agda.Builtin.Sigma
open import Agda.Builtin.String
open import Agda.Builtin.Word
postulate Float : Set
{-# BUILTIN FLOAT Float #-}
primitive
-- Relations
primFloatInequality : Float → Float → Bool
primFloatEquality : Float → Float → Bool
primFloatLess : Float → Float → Bool
primFloatIsInfinite : Float → Bool
primFloatIsNaN : Float → Bool
primFloatIsNegativeZero : Float → Bool
primFloatIsSafeInteger : Float → Bool
-- Conversions
primFloatToWord64 : Float → Word64
primNatToFloat : Nat → Float
primIntToFloat : Int → Float
primFloatRound : Float → Maybe Int
primFloatFloor : Float → Maybe Int
primFloatCeiling : Float → Maybe Int
primFloatToRatio : Float → (Σ Int λ _ → Int)
primRatioToFloat : Int → Int → Float
primFloatDecode : Float → Maybe (Σ Int λ _ → Int)
primFloatEncode : Int → Int → Maybe Float
primShowFloat : Float → String
-- Operations
primFloatPlus : Float → Float → Float
primFloatMinus : Float → Float → Float
primFloatTimes : Float → Float → Float
primFloatDiv : Float → Float → Float
primFloatPow : Float → Float → Float
primFloatNegate : Float → Float
primFloatSqrt : Float → Float
primFloatExp : Float → Float
primFloatLog : Float → Float
primFloatSin : Float → Float
primFloatCos : Float → Float
primFloatTan : Float → Float
primFloatASin : Float → Float
primFloatACos : Float → Float
primFloatATan : Float → Float
primFloatATan2 : Float → Float → Float
primFloatSinh : Float → Float
primFloatCosh : Float → Float
primFloatTanh : Float → Float
primFloatASinh : Float → Float
primFloatACosh : Float → Float
primFloatATanh : Float → Float
{-# COMPILE JS
primFloatRound = function(x) {
x = agdaRTS._primFloatRound(x);
if (x === null) {
return z_jAgda_Agda_Builtin_Maybe["Maybe"]["nothing"];
}
else {
return z_jAgda_Agda_Builtin_Maybe["Maybe"]["just"](x);
}
};
#-}
{-# COMPILE JS
primFloatFloor = function(x) {
x = agdaRTS._primFloatFloor(x);
if (x === null) {
return z_jAgda_Agda_Builtin_Maybe["Maybe"]["nothing"];
}
else {
return z_jAgda_Agda_Builtin_Maybe["Maybe"]["just"](x);
}
};
#-}
{-# COMPILE JS
primFloatCeiling = function(x) {
x = agdaRTS._primFloatCeiling(x);
if (x === null) {
return z_jAgda_Agda_Builtin_Maybe["Maybe"]["nothing"];
}
else {
return z_jAgda_Agda_Builtin_Maybe["Maybe"]["just"](x);
}
};
#-}
{-# COMPILE JS
primFloatToRatio = function(x) {
x = agdaRTS._primFloatToRatio(x);
return z_jAgda_Agda_Builtin_Sigma["_,_"](x.numerator)(x.denominator);
};
#-}
{-# COMPILE JS
primFloatDecode = function(x) {
x = agdaRTS._primFloatDecode(x);
if (x === null) {
return z_jAgda_Agda_Builtin_Maybe["Maybe"]["nothing"];
}
else {
return z_jAgda_Agda_Builtin_Maybe["Maybe"]["just"](
z_jAgda_Agda_Builtin_Sigma["_,_"](x.mantissa)(x.exponent));
}
};
#-}
{-# COMPILE JS
primFloatEncode = function(x) {
return function (y) {
x = agdaRTS.uprimFloatEncode(x, y);
if (x === null) {
return z_jAgda_Agda_Builtin_Maybe["Maybe"]["nothing"];
}
else {
return z_jAgda_Agda_Builtin_Maybe["Maybe"]["just"](x);
}
}
};
#-}
primFloatNumericalEquality = primFloatEquality
{-# WARNING_ON_USAGE primFloatNumericalEquality
"Warning: primFloatNumericalEquality was deprecated in Agda v2.6.2.
Please use primFloatEquality instead."
#-}
primFloatNumericalLess = primFloatLess
{-# WARNING_ON_USAGE primFloatNumericalLess
"Warning: primFloatNumericalLess was deprecated in Agda v2.6.2.
Please use primFloatLess instead."
#-}
primRound = primFloatRound
{-# WARNING_ON_USAGE primRound
"Warning: primRound was deprecated in Agda v2.6.2.
Please use primFloatRound instead."
#-}
primFloor = primFloatFloor
{-# WARNING_ON_USAGE primFloor
"Warning: primFloor was deprecated in Agda v2.6.2.
Please use primFloatFloor instead."
#-}
primCeiling = primFloatCeiling
{-# WARNING_ON_USAGE primCeiling
"Warning: primCeiling was deprecated in Agda v2.6.2.
Please use primFloatCeiling instead."
#-}
primExp = primFloatExp
{-# WARNING_ON_USAGE primExp
"Warning: primExp was deprecated in Agda v2.6.2.
Please use primFloatExp instead."
#-}
primLog = primFloatLog
{-# WARNING_ON_USAGE primLog
"Warning: primLog was deprecated in Agda v2.6.2.
Please use primFloatLog instead."
#-}
primSin = primFloatSin
{-# WARNING_ON_USAGE primSin
"Warning: primSin was deprecated in Agda v2.6.2.
Please use primFloatSin instead."
#-}
primCos = primFloatCos
{-# WARNING_ON_USAGE primCos
"Warning: primCos was deprecated in Agda v2.6.2.
Please use primFloatCos instead."
#-}
primTan = primFloatTan
{-# WARNING_ON_USAGE primTan
"Warning: primTan was deprecated in Agda v2.6.2.
Please use primFloatTan instead."
#-}
primASin = primFloatASin
{-# WARNING_ON_USAGE primASin
"Warning: primASin was deprecated in Agda v2.6.2.
Please use primFloatASin instead."
#-}
primACos = primFloatACos
{-# WARNING_ON_USAGE primACos
"Warning: primACos was deprecated in Agda v2.6.2.
Please use primFloatACos instead."
#-}
primATan = primFloatATan
{-# WARNING_ON_USAGE primATan
"Warning: primATan was deprecated in Agda v2.6.2.
Please use primFloatATan instead."
#-}
primATan2 = primFloatATan2
{-# WARNING_ON_USAGE primATan2
"Warning: primATan2 was deprecated in Agda v2.6.2.
Please use primFloatATan2 instead."
#-}
| {
"alphanum_fraction": 0.6325272641,
"avg_line_length": 29.9857819905,
"ext": "agda",
"hexsha": "da1e0b2fe00e732205c1e079b3f8a53311e3b690",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z",
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Float.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": "src/data/lib/prim/Agda/Builtin/Float.agda",
"max_line_length": 77,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Float.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-26T09:35:17.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-26T09:35:17.000Z",
"num_tokens": 1729,
"size": 6327
} |
------------------------------------------------------------------------------
-- Testing the translation of definitions
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module Issue4 where
postulate
D : Set
_≡_ : D → D → Set
refl : ∀ {a} → a ≡ a
P : D → Set
-- We test the translation of a definition where we need to erase proof terms.
foo : ∀ {a} → P a → ∀ {b} → P b → a ≡ a
foo {a} Pa {b} Pb = bar
where
c : D
c = a
{-# ATP definition c #-}
postulate bar : c ≡ a
{-# ATP prove bar #-}
| {
"alphanum_fraction": 0.40802213,
"avg_line_length": 25.8214285714,
"ext": "agda",
"hexsha": "fb58454c15d9717fb84a3c839a2feea72ac8c9a5",
"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": "issues/Issue4.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": "issues/Issue4.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": "issues/Issue4.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": 179,
"size": 723
} |
module WarningOnUsage where
id : {A : Set} → A → A
id x = x
-- Deprecated names
λx→x = id
{-# WARNING_ON_USAGE λx→x "DEPRECATED: Use `id` instead of `λx→x`" #-}
open import Agda.Builtin.Equality
_ : {A : Set} {x : A} → λx→x x ≡ x
_ = refl
| {
"alphanum_fraction": 0.6032388664,
"avg_line_length": 13.7222222222,
"ext": "agda",
"hexsha": "cffe6cd45c3a2abb89a03d668ace46188840f676",
"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/Succeed/WarningOnUsage.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/Succeed/WarningOnUsage.agda",
"max_line_length": 70,
"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/Succeed/WarningOnUsage.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": 95,
"size": 247
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Morphisms between algebraic structures
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Algebra.Morphism where
import Algebra.Morphism.Definitions as MorphismDefinitions
open import Relation.Binary
open import Algebra
import Algebra.Properties.Group as GroupP
open import Function
open import Level
import Relation.Binary.Reasoning.Setoid as EqR
private
variable
a b ℓ₁ ℓ₂ : Level
A : Set a
B : Set b
------------------------------------------------------------------------
--
module Definitions {a b ℓ₁} (A : Set a) (B : Set b) (_≈_ : Rel B ℓ₁) where
open MorphismDefinitions A B _≈_ public
open import Algebra.Morphism.Structures public
------------------------------------------------------------------------
-- Bundle homomorphisms
module _ {c₁ ℓ₁ c₂ ℓ₂}
(From : Semigroup c₁ ℓ₁)
(To : Semigroup c₂ ℓ₂) where
private
module F = Semigroup From
module T = Semigroup To
open Definitions F.Carrier T.Carrier T._≈_
record IsSemigroupMorphism (⟦_⟧ : Morphism) :
Set (c₁ ⊔ ℓ₁ ⊔ c₂ ⊔ ℓ₂) where
field
⟦⟧-cong : ⟦_⟧ Preserves F._≈_ ⟶ T._≈_
∙-homo : Homomorphic₂ ⟦_⟧ F._∙_ T._∙_
IsSemigroupMorphism-syntax = IsSemigroupMorphism
syntax IsSemigroupMorphism-syntax From To F = F Is From -Semigroup⟶ To
module _ {c₁ ℓ₁ c₂ ℓ₂}
(From : Monoid c₁ ℓ₁)
(To : Monoid c₂ ℓ₂) where
private
module F = Monoid From
module T = Monoid To
open Definitions F.Carrier T.Carrier T._≈_
record IsMonoidMorphism (⟦_⟧ : Morphism) :
Set (c₁ ⊔ ℓ₁ ⊔ c₂ ⊔ ℓ₂) where
field
sm-homo : IsSemigroupMorphism F.semigroup T.semigroup ⟦_⟧
ε-homo : Homomorphic₀ ⟦_⟧ F.ε T.ε
open IsSemigroupMorphism sm-homo public
IsMonoidMorphism-syntax = IsMonoidMorphism
syntax IsMonoidMorphism-syntax From To F = F Is From -Monoid⟶ To
module _ {c₁ ℓ₁ c₂ ℓ₂}
(From : CommutativeMonoid c₁ ℓ₁)
(To : CommutativeMonoid c₂ ℓ₂) where
private
module F = CommutativeMonoid From
module T = CommutativeMonoid To
open Definitions F.Carrier T.Carrier T._≈_
record IsCommutativeMonoidMorphism (⟦_⟧ : Morphism) :
Set (c₁ ⊔ ℓ₁ ⊔ c₂ ⊔ ℓ₂) where
field
mn-homo : IsMonoidMorphism F.monoid T.monoid ⟦_⟧
open IsMonoidMorphism mn-homo public
IsCommutativeMonoidMorphism-syntax = IsCommutativeMonoidMorphism
syntax IsCommutativeMonoidMorphism-syntax From To F = F Is From -CommutativeMonoid⟶ To
module _ {c₁ ℓ₁ c₂ ℓ₂}
(From : IdempotentCommutativeMonoid c₁ ℓ₁)
(To : IdempotentCommutativeMonoid c₂ ℓ₂) where
private
module F = IdempotentCommutativeMonoid From
module T = IdempotentCommutativeMonoid To
open Definitions F.Carrier T.Carrier T._≈_
record IsIdempotentCommutativeMonoidMorphism (⟦_⟧ : Morphism) :
Set (c₁ ⊔ ℓ₁ ⊔ c₂ ⊔ ℓ₂) where
field
mn-homo : IsMonoidMorphism F.monoid T.monoid ⟦_⟧
open IsMonoidMorphism mn-homo public
isCommutativeMonoidMorphism :
IsCommutativeMonoidMorphism F.commutativeMonoid T.commutativeMonoid ⟦_⟧
isCommutativeMonoidMorphism = record { mn-homo = mn-homo }
IsIdempotentCommutativeMonoidMorphism-syntax = IsIdempotentCommutativeMonoidMorphism
syntax IsIdempotentCommutativeMonoidMorphism-syntax From To F = F Is From -IdempotentCommutativeMonoid⟶ To
module _ {c₁ ℓ₁ c₂ ℓ₂}
(From : Group c₁ ℓ₁)
(To : Group c₂ ℓ₂) where
private
module F = Group From
module T = Group To
open Definitions F.Carrier T.Carrier T._≈_
record IsGroupMorphism (⟦_⟧ : Morphism) :
Set (c₁ ⊔ ℓ₁ ⊔ c₂ ⊔ ℓ₂) where
field
mn-homo : IsMonoidMorphism F.monoid T.monoid ⟦_⟧
open IsMonoidMorphism mn-homo public
⁻¹-homo : Homomorphic₁ ⟦_⟧ F._⁻¹ T._⁻¹
⁻¹-homo x = let open EqR T.setoid in T.uniqueˡ-⁻¹ ⟦ x F.⁻¹ ⟧ ⟦ x ⟧ $ begin
⟦ x F.⁻¹ ⟧ T.∙ ⟦ x ⟧ ≈⟨ T.sym (∙-homo (x F.⁻¹) x) ⟩
⟦ x F.⁻¹ F.∙ x ⟧ ≈⟨ ⟦⟧-cong (F.inverseˡ x) ⟩
⟦ F.ε ⟧ ≈⟨ ε-homo ⟩
T.ε ∎
IsGroupMorphism-syntax = IsGroupMorphism
syntax IsGroupMorphism-syntax From To F = F Is From -Group⟶ To
module _ {c₁ ℓ₁ c₂ ℓ₂}
(From : AbelianGroup c₁ ℓ₁)
(To : AbelianGroup c₂ ℓ₂) where
private
module F = AbelianGroup From
module T = AbelianGroup To
open Definitions F.Carrier T.Carrier T._≈_
record IsAbelianGroupMorphism (⟦_⟧ : Morphism) :
Set (c₁ ⊔ ℓ₁ ⊔ c₂ ⊔ ℓ₂) where
field
gp-homo : IsGroupMorphism F.group T.group ⟦_⟧
open IsGroupMorphism gp-homo public
IsAbelianGroupMorphism-syntax = IsAbelianGroupMorphism
syntax IsAbelianGroupMorphism-syntax From To F = F Is From -AbelianGroup⟶ To
module _ {c₁ ℓ₁ c₂ ℓ₂}
(From : Ring c₁ ℓ₁)
(To : Ring c₂ ℓ₂) where
private
module F = Ring From
module T = Ring To
open Definitions F.Carrier T.Carrier T._≈_
record IsRingMorphism (⟦_⟧ : Morphism) :
Set (c₁ ⊔ ℓ₁ ⊔ c₂ ⊔ ℓ₂) where
field
+-abgp-homo : ⟦_⟧ Is F.+-abelianGroup -AbelianGroup⟶ T.+-abelianGroup
*-mn-homo : ⟦_⟧ Is F.*-monoid -Monoid⟶ T.*-monoid
IsRingMorphism-syntax = IsRingMorphism
syntax IsRingMorphism-syntax From To F = F Is From -Ring⟶ To
| {
"alphanum_fraction": 0.6309790732,
"avg_line_length": 30.0674157303,
"ext": "agda",
"hexsha": "fa43aed9d05ae29ce2794e6d79a6f3f45c50b6e1",
"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/Algebra/Morphism.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/Algebra/Morphism.agda",
"max_line_length": 108,
"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/Algebra/Morphism.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": 1859,
"size": 5352
} |
module Issue1760b where
-- Skipping an old-style mutual block: Somewhere within a `mutual`
-- block before a record definition.
mutual
data D : Set where
lam : (D → D) → D
{-# NO_POSITIVITY_CHECK #-}
record U : Set where
field ap : U → U
| {
"alphanum_fraction": 0.6614173228,
"avg_line_length": 21.1666666667,
"ext": "agda",
"hexsha": "46ce511742d67003e8342b568daac4b44c88ac14",
"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/Issue1760b.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/Issue1760b.agda",
"max_line_length": 66,
"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/Issue1760b.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": 75,
"size": 254
} |
module Mutual2 where
data Bool
: Set
where
false
: Bool
true
: Bool
data ℕ
: Set
where
zero
: ℕ
suc
: ℕ
→ ℕ
is-even
: ℕ
→ Bool
is-odd
: ℕ
→ Bool
is-even zero
= true
is-even (suc n)
= is-odd n
is-odd zero
= false
is-odd (suc n)
= is-even n
is-even'
: ℕ
→ Bool
is-even'
= is-even
| {
"alphanum_fraction": 0.5114942529,
"avg_line_length": 7.25,
"ext": "agda",
"hexsha": "e26e2843f2113ab629525f5b121805c4c0b9485e",
"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/Mutual2.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/Mutual2.agda",
"max_line_length": 20,
"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/Mutual2.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": 144,
"size": 348
} |
{-# OPTIONS --without-K --safe #-}
open import Level
-- Kan Complexes
--
-- These are technically "Algebraic" Kan Complexes, as they come with a choice of fillers
-- However, this notion is far easier than the more geometric flavor,
-- as we can sidestep questions about choice.
module Categories.Category.Construction.KanComplex (o ℓ : Level) where
open import Data.Nat using (ℕ)
open import Data.Fin using (Fin; inject₁)
open import Categories.Category using (Category)
open import Categories.Category.Instance.SimplicialSet using (SimplicialSet)
open import Categories.Category.Instance.SimplicialSet.Properties o ℓ using (ΔSet; Δ[_]; Λ[_,_]; Λ-inj)
open Category (SimplicialSet o ℓ)
-- A Kan complex is a simplicial set where every k-horn has a filler.
record IsKanComplex (X : ΔSet) : Set (o ⊔ ℓ) where
field
filler : ∀ {n} {k} → Λ[ n , k ] ⇒ X → Δ[ n ] ⇒ X
filler-cong : ∀ {n} {k} → {f g : Λ[ n , k ] ⇒ X} → f ≈ g → filler {n} f ≈ filler g
is-filler : ∀ {n} {k} → (f : Λ[ n , k ] ⇒ X) → filler f ∘ Λ-inj k ≈ f
-- 'inner k' will embed 'k : Fin n' into the "inner" portion of 'Fin (n + 2)'
-- Visually, it looks a little something like:
--
-- * * *
-- | | |
-- v v v
-- * * * * *
--
-- Note that this is set up in such a way that we can normalize
-- as far as possible without pattern matching on 'i' in proofs.
inner : ∀ {n} → Fin n → Fin (ℕ.suc (ℕ.suc n))
inner i = Fin.suc (inject₁ i)
-- A Weak Kan complex is similar to a Kan Complex, but where only "inner horns" have fillers.
--
-- The indexing here is tricky, but it lets us avoid extra proof conditions that the horn is an inner horn.
-- The basic idea is that if we want an n-dimensional inner horn, then we only want to allow the faces {1,2,3...n-1}
-- to be missing. We could do this by requiring proofs that the missing face is greater than 0 and less than n, but
-- this makes working with the definition _extremely_ difficult.
--
-- To avoid this, we only allow an missing face index that ranges from 0 to n-2, and then embed that index
-- into the full range of face indexes via 'inner'. This does require us to shift our indexes around a bit.
-- To make this indexing more obvious, we use the suggestively named variable 'n-2'.
record IsWeakKanComplex (X : ΔSet) : Set (o ⊔ ℓ) where
field
filler : ∀ {n-2} {k : Fin n-2} → Λ[ ℕ.suc (ℕ.suc n-2) , inner k ] ⇒ X → Δ[ ℕ.suc (ℕ.suc n-2) ] ⇒ X
filler-cong : ∀ {n-2} {k : Fin n-2} → {f g : Λ[ ℕ.suc (ℕ.suc n-2) , inner k ] ⇒ X} → f ≈ g → filler f ≈ filler g
is-filler : ∀ {n-2} {k : Fin n-2} → (f : Λ[ ℕ.suc (ℕ.suc n-2) , inner k ] ⇒ X) → filler f ∘ Λ-inj (inner k) ≈ f
KanComplex⇒WeakKanComplex : ∀ {X} → IsKanComplex X → IsWeakKanComplex X
KanComplex⇒WeakKanComplex complex = record { IsKanComplex complex }
| {
"alphanum_fraction": 0.6557788945,
"avg_line_length": 44.935483871,
"ext": "agda",
"hexsha": "55a5cb5d400c7e2360851dfc04916403479c8ccc",
"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/Category/Construction/KanComplex.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/Category/Construction/KanComplex.agda",
"max_line_length": 117,
"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/Category/Construction/KanComplex.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": 917,
"size": 2786
} |
import Lvl
open import Structure.Setoid
open import Type
module Automaton.Deterministic.Finite where
open import Automaton.Deterministic
open import Data.Boolean
open import Data.Boolean.Stmt
open import Data.List renaming (∅ to ε ; _⊰_ to _·_)
open import Data.List.Setoid
open import Data.List.Functions using (postpend ; _++_)
open import Data.List.Proofs
open import Functional
open import Logic.Propositional
open import Logic
open import Sets.ExtensionalPredicateSet using (PredSet ; intro ; _∈_ ; _∋_ ; ⊶ ; [∋]-binaryRelator)
import Structure.Function.Names as Names
open import Structure.Operator
open import Structure.Relator.Properties
open import Type.Size.Finite
private variable ℓₚ ℓₛ ℓₑ₁ ℓₐ ℓₑ₂ : Lvl.Level
module _
{ℓₚ}
(State : Type{ℓₛ}) ⦃ equiv-state : Equiv{ℓₑ₁}(State) ⦄
(Alphabet : Type{ℓₐ}) ⦃ equiv-alphabet : Equiv{ℓₑ₂}(Alphabet) ⦄
where
record DFA : Type{ℓₛ Lvl.⊔ ℓₑ₁ Lvl.⊔ ℓₑ₂ Lvl.⊔ ℓₐ Lvl.⊔ Lvl.𝐒(ℓₚ)} where
field
⦃ State-finite ⦄ : Finite(State)
⦃ Alphabet-finite ⦄ : Finite(Alphabet)
automata : Deterministic{ℓₚ = ℓₚ}(State)(Alphabet)
open Deterministic(automata) hiding (transitionedAutomaton ; wordTransitionedAutomaton) public
transitionedAutomaton : Alphabet → DFA
transitionedAutomaton c = record{automata = Deterministic.transitionedAutomaton(automata) c}
wordTransitionedAutomaton : Word → DFA
wordTransitionedAutomaton w = record{automata = Deterministic.wordTransitionedAutomaton(automata) w}
postulate isFinal : State → Bool
postulate isFinal-correctness : ∀{s} → IsTrue(isFinal s) ↔ (s ∈ Final)
isWordAccepted : Word → Bool
isWordAccepted(w) = isFinal(wordTransition(start)(w))
pattern dfa {fin-Q} {fin-Σ} δ {δ-op} q₀ F = record{State-finite = fin-Q ; Alphabet-finite = fin-Σ ; automata = deterministic δ ⦃ δ-op ⦄ q₀ F}
| {
"alphanum_fraction": 0.7321428571,
"avg_line_length": 36.2352941176,
"ext": "agda",
"hexsha": "ac426f2af553f6813c636fd6360964004826e517",
"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": "Automaton/Deterministic/Finite.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": "Automaton/Deterministic/Finite.agda",
"max_line_length": 143,
"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": "Automaton/Deterministic/Finite.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": 606,
"size": 1848
} |
-- Andreas, 2017-05-13, issue reported by nad
module Issue2579 where
open import Common.Bool
open import Issue2579.Import
import Issue2579.Instance Bool true as I
-- without the "as I" the instance is not in scope
-- (and you get a parse error)
theWrapped : {{w : Wrap Bool}} → Bool
theWrapped {{w}} = Wrap.wrapped w
test : Bool
test = theWrapped
| {
"alphanum_fraction": 0.7272727273,
"avg_line_length": 20.7058823529,
"ext": "agda",
"hexsha": "ddc3aa60d9ab5bac8510093eea5187b64ec4d351",
"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/Succeed/Issue2579.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/Succeed/Issue2579.agda",
"max_line_length": 50,
"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/Succeed/Issue2579.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": 99,
"size": 352
} |
{-# OPTIONS --universe-polymorphism #-}
module Issue248 where
open import Common.Level
data ⊥ : Set where
-- This type checks:
Foo : ⊥ → (l : Level) → Set
Foo x l with x
Foo x l | ()
-- This didn't (but now it does):
Bar : ⊥ → (l : Level) → Set l → Set
Bar x l A with x
Bar x l A | ()
-- Bug.agda:25,1-15
-- ⊥ !=< Level of type Set
-- when checking that the expression w has type Level
| {
"alphanum_fraction": 0.614213198,
"avg_line_length": 16.4166666667,
"ext": "agda",
"hexsha": "32b000e7bc7d10ac83c9c63c81f4867ca1e6320f",
"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/Issue248.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/Issue248.agda",
"max_line_length": 53,
"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/Issue248.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": 126,
"size": 394
} |
module Structure.Operator.Vector.LinearMaps where
open import Functional
open import Function.Proofs
open import Logic.Predicate
import Lvl
open import Structure.Function
open import Structure.Function.Multi
open import Structure.Operator.Properties
open import Structure.Operator.Vector.LinearMap
open import Structure.Operator.Vector.Proofs
open import Structure.Operator.Vector
open import Structure.Relator.Properties
open import Structure.Setoid
open import Syntax.Transitivity
open import Type
private variable ℓ ℓᵥ ℓᵥₗ ℓᵥᵣ ℓᵥ₁ ℓᵥ₂ ℓᵥ₃ ℓₛ ℓᵥₑ ℓᵥₑₗ ℓᵥₑᵣ ℓᵥₑ₁ ℓᵥₑ₂ ℓᵥₑ₃ ℓₛₑ : Lvl.Level
private variable V Vₗ Vᵣ V₁ V₂ V₃ S : Type{ℓ}
private variable _+ᵥ_ _+ᵥₗ_ _+ᵥᵣ_ _+ᵥ₁_ _+ᵥ₂_ _+ᵥ₃_ : V → V → V
private variable _⋅ₛᵥ_ _⋅ₛᵥₗ_ _⋅ₛᵥᵣ_ _⋅ₛᵥ₁_ _⋅ₛᵥ₂_ _⋅ₛᵥ₃_ : S → V → V
private variable _+ₛ_ _⋅ₛ_ : S → S → S
private variable f g : Vₗ → Vᵣ
open VectorSpace ⦃ … ⦄
module _
⦃ equiv-Vₗ : Equiv{ℓᵥₑₗ}(Vₗ) ⦄
⦃ equiv-Vᵣ : Equiv{ℓᵥₑᵣ}(Vᵣ) ⦄
⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄
(vectorSpaceₗ : VectorSpace{V = Vₗ}{S = S}(_+ᵥₗ_)(_⋅ₛᵥₗ_)(_+ₛ_)(_⋅ₛ_))
(vectorSpaceᵣ : VectorSpace{V = Vᵣ}{S = S}(_+ᵥᵣ_)(_⋅ₛᵥᵣ_)(_+ₛ_)(_⋅ₛ_))
where
instance _ = vectorSpaceₗ
instance _ = vectorSpaceᵣ
zero : LinearMap(vectorSpaceₗ)(vectorSpaceᵣ)(const 𝟎ᵥ)
Preserving.proof (LinearMap.preserves-[+ᵥ] zero) {x} {y} =
const 𝟎ᵥ (x +ᵥₗ y) 🝖[ _≡_ ]-[]
𝟎ᵥ 🝖[ _≡_ ]-[ identityₗ(_+ᵥᵣ_)(𝟎ᵥ) ]-sym
𝟎ᵥ +ᵥᵣ 𝟎ᵥ 🝖[ _≡_ ]-[]
(const 𝟎ᵥ x) +ᵥᵣ (const 𝟎ᵥ y) 🝖-end
Preserving.proof (LinearMap.preserves-[⋅ₛᵥ] zero {s}) {x} =
const 𝟎ᵥ (s ⋅ₛᵥₗ x) 🝖[ _≡_ ]-[]
𝟎ᵥ 🝖[ _≡_ ]-[ [⋅ₛᵥ]-absorberᵣ ]-sym
s ⋅ₛᵥᵣ 𝟎ᵥ 🝖[ _≡_ ]-[]
s ⋅ₛᵥᵣ (const 𝟎ᵥ x) 🝖-end
module _
⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄
⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄
(vectorSpace : VectorSpace{V = V}{S = S}(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_))
where
instance _ = vectorSpace
identity : LinearOperator(vectorSpace)(id)
Preserving.proof (LinearMap.preserves-[+ᵥ] identity) = reflexivity(_≡_)
Preserving.proof (LinearMap.preserves-[⋅ₛᵥ] identity) = reflexivity(_≡_)
module _
⦃ equiv-V₁ : Equiv{ℓᵥₑ₁}(V₁) ⦄
⦃ equiv-V₂ : Equiv{ℓᵥₑ₂}(V₂) ⦄
⦃ equiv-V₂ : Equiv{ℓᵥₑ₃}(V₃) ⦄
⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄
(vectorSpace₁ : VectorSpace{V = V₁}{S = S}(_+ᵥ₁_)(_⋅ₛᵥ₁_)(_+ₛ_)(_⋅ₛ_))
(vectorSpace₂ : VectorSpace{V = V₂}{S = S}(_+ᵥ₂_)(_⋅ₛᵥ₂_)(_+ₛ_)(_⋅ₛ_))
(vectorSpace₃ : VectorSpace{V = V₃}{S = S}(_+ᵥ₃_)(_⋅ₛᵥ₃_)(_+ₛ_)(_⋅ₛ_))
where
instance _ = vectorSpace₁
instance _ = vectorSpace₂
instance _ = vectorSpace₃
compose : LinearMap(vectorSpace₂)(vectorSpace₃)(f) → LinearMap(vectorSpace₁)(vectorSpace₂)(g) → LinearMap(vectorSpace₁)(vectorSpace₃)(f ∘ g)
LinearMap.function (compose {f} {g} F G) = [∘]-function {f = f}{g = g}
Preserving.proof (LinearMap.preserves-[+ᵥ] (compose {f} {g} F G)) {x}{y} =
(f ∘ g)(x +ᵥ₁ y) 🝖[ _≡_ ]-[]
f(g(x +ᵥ₁ y)) 🝖[ _≡_ ]-[ congruence₁(f) (preserving₂(g) (_+ᵥ₁_)(_+ᵥ₂_)) ]
f(g(x) +ᵥ₂ g(y)) 🝖[ _≡_ ]-[ preserving₂(f) (_+ᵥ₂_)(_+ᵥ₃_) ]
f(g(x)) +ᵥ₃ f(g(y)) 🝖[ _≡_ ]-[]
(f ∘ g)(x) +ᵥ₃ (f ∘ g)(y) 🝖-end
Preserving.proof (LinearMap.preserves-[⋅ₛᵥ] (compose {f} {g} F G) {s}) {v} =
(f ∘ g) (s ⋅ₛᵥ₁ v) 🝖[ _≡_ ]-[]
f(g(s ⋅ₛᵥ₁ v)) 🝖[ _≡_ ]-[ congruence₁(f) (preserving₁(g) (s ⋅ₛᵥ₁_)(s ⋅ₛᵥ₂_)) ]
f(s ⋅ₛᵥ₂ g(v)) 🝖[ _≡_ ]-[ preserving₁(f) (s ⋅ₛᵥ₂_)(s ⋅ₛᵥ₃_) ]
s ⋅ₛᵥ₃ f(g(v)) 🝖[ _≡_ ]-[]
s ⋅ₛᵥ₃ (f ∘ g)(v) 🝖-end
module _ ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ {_+ₛ_ _⋅ₛ_ : S → S → S} where
private variable A B C : VectorSpaceVObject {ℓᵥ}{_}{ℓᵥₑ}{ℓₛₑ} ⦃ equiv-S ⦄ (_+ₛ_)(_⋅ₛ_)
open VectorSpaceVObject hiding (𝟎ᵥ)
𝟎ˡⁱⁿᵉᵃʳᵐᵃᵖ : A →ˡⁱⁿᵉᵃʳᵐᵃᵖ B
𝟎ˡⁱⁿᵉᵃʳᵐᵃᵖ {A = A}{B = B} = [∃]-intro (const 𝟎ᵥ) ⦃ zero (vectorSpace A) (vectorSpace B) ⦄
idˡⁱⁿᵉᵃʳᵐᵃᵖ : A →ˡⁱⁿᵉᵃʳᵐᵃᵖ A
idˡⁱⁿᵉᵃʳᵐᵃᵖ {A = A} = [∃]-intro id ⦃ identity(vectorSpace A) ⦄
_∘ˡⁱⁿᵉᵃʳᵐᵃᵖ_ : let _ = A in (B →ˡⁱⁿᵉᵃʳᵐᵃᵖ C) → (A →ˡⁱⁿᵉᵃʳᵐᵃᵖ B) → (A →ˡⁱⁿᵉᵃʳᵐᵃᵖ C)
_∘ˡⁱⁿᵉᵃʳᵐᵃᵖ_ {A = A}{B = B}{C = C} ([∃]-intro f ⦃ linmap-f ⦄) ([∃]-intro g ⦃ linmap-g ⦄) = [∃]-intro (f ∘ g) ⦃ compose (vectorSpace A) (vectorSpace B) (vectorSpace C) linmap-f linmap-g ⦄
| {
"alphanum_fraction": 0.6017805582,
"avg_line_length": 40.3495145631,
"ext": "agda",
"hexsha": "a2c722fdc14c6d3e057ec17469120e41544d0299",
"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/Operator/Vector/LinearMaps.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/Operator/Vector/LinearMaps.agda",
"max_line_length": 188,
"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/Operator/Vector/LinearMaps.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": 2540,
"size": 4156
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Setoids.Setoids
open import Rings.Definition
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Modules.Definition
open import Vectors
open import Sets.EquivalenceRelations
open import Sets.FinSet.Definition
open import Modules.Span
open import Groups.Definition
module Modules.VectorModule {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where
open import Rings.Definition
open import Rings.Lemmas R
open import Groups.Vector (Ring.additiveGroup R)
open Ring R
open Group additiveGroup
open Setoid S
open Equivalence eq
ringModule : {n : ℕ} → Module R (abelianVectorGroup {n = n} abelianUnderlyingGroup) λ a v → vecMap (_* a) v
Module.dotWellDefined (ringModule) {r} {s} {[]} {[]} r=s t=u = record {}
Module.dotWellDefined (ringModule) {r} {s} {t ,- ts} {u ,- us} r=s (t=u ,, ts=us) = Ring.*WellDefined R t=u r=s ,, Module.dotWellDefined (ringModule) {r} {s} {ts} {us} r=s ts=us
Module.dotDistributesLeft (ringModule) {a} {[]} {[]} = record {}
Module.dotDistributesLeft (ringModule) {a} {y ,- ys} {z ,- zs} = Ring.*DistributesOver+' R ,, Module.dotDistributesLeft (ringModule) {a} {ys} {zs}
Module.dotDistributesRight (ringModule) {a} {b} {[]} = record {}
Module.dotDistributesRight (ringModule) {a} {b} {z ,- zs} = Ring.*DistributesOver+ R ,, Module.dotDistributesRight (ringModule) {a} {b} {zs}
Module.dotAssociative (ringModule) {r} {s} {[]} = record {}
Module.dotAssociative (ringModule) {r} {s} {x ,- xs} = transitive (Ring.*WellDefined R reflexive (Ring.*Commutative R)) (Ring.*Associative R) ,, Module.dotAssociative (ringModule) {r} {s} {xs}
Module.dotIdentity (ringModule) {[]} = record {}
Module.dotIdentity (ringModule) {x ,- xs} = transitive (Ring.*Commutative R) (Ring.identIsIdent R) ,, Module.dotIdentity ringModule {xs}
vecModuleBasis : {n : ℕ} → FinSet n → Vec A n
vecModuleBasis {succ n} fzero = (Ring.1R R) ,- vecPure (Ring.0R R)
vecModuleBasis {succ n} (fsucc i) = (Ring.0R R) ,- vecModuleBasis i
vecTimesZero : {n : ℕ} (a : A) → vecEquiv {n} (vecMap (_* a) (vecPure 0G)) (vecPure 0G)
vecTimesZero {zero} a = record {}
vecTimesZero {succ n} a = transitive *Commutative timesZero ,, vecTimesZero a
--private
-- lemma2 : {n : ℕ} → (f : _ → _) → (j : _) → vecEquiv (dot ringModule (vecMap (λ i → 0G ,- f i)) j) ?
-- lemma2 = ?
allEntries : (n : ℕ) → Vec (FinSet n) n
allEntries zero = []
allEntries (succ n) = fzero ,- vecMap fsucc (allEntries n)
extractZero : {n m : ℕ} → (y : Vec A m) (xs : Vec (FinSet n) m) (f : FinSet n → Vec A n) → vecEquiv (dot ringModule (vecMap (λ i → 0G ,- f i) xs) y) (0G ,- dot ringModule (vecMap f xs) y)
extractZero {zero} {zero} [] [] f = Equivalence.reflexive (Setoid.eq (vectorSetoid _))
extractZero {zero} {succ m} (y ,- ys) (() ,- xs) f
extractZero {succ n} {zero} [] [] f = reflexive ,, (reflexive ,, Equivalence.reflexive (Setoid.eq (vectorSetoid _)))
extractZero {succ n} {succ m} (y ,- ys) (x ,- xs) f = Equivalence.transitive (Setoid.eq (vectorSetoid _)) (Group.+WellDefined vectorGroup (transitive *Commutative timesZero ,, Equivalence.reflexive (Setoid.eq (vectorSetoid _))) (extractZero ys xs f)) (identLeft ,, Equivalence.reflexive (Setoid.eq (vectorSetoid _)))
identityMatrixProduct : {n : ℕ} → (b : Vec A n) → vecEquiv (dot ringModule (vecMap vecModuleBasis (allEntries n)) b) b
identityMatrixProduct [] = record {}
identityMatrixProduct {succ n} (x ,- b) rewrite vecMapCompose fsucc vecModuleBasis (allEntries n) = Equivalence.transitive (Setoid.eq (vectorSetoid _)) (Group.+WellDefined vectorGroup (identIsIdent ,, vecTimesZero x) (extractZero b (allEntries n) vecModuleBasis)) (identRight ,, Equivalence.transitive (Setoid.eq (vectorSetoid _)) (Group.identLeft vectorGroup) (identityMatrixProduct b))
rearrangeBasis : {n : ℕ} → (coeffs : Vec A n) → (r : Vec (FinSet (succ n)) n) → (eq : vecEquiv (dot ringModule (vecMap vecModuleBasis r) coeffs) (vecPure 0G)) → (uniq : {a : ℕ} {b : ℕ} (a<n : a <N n) (b<n : b <N n) → vecIndex r a a<n ≡ vecIndex r b b<n → a ≡ b) → {!!}
rearrangeBasis coeffs r eq uniq = {!!}
vecModuleBasisSpans : {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) {n : ℕ} → Spans (ringModule {n}) (vecModuleBasis {n})
vecModuleBasisSpans R {n} m = n , ((allEntries n ,, m) , identityMatrixProduct m)
vecModuleBasisIndependent : {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) {n : ℕ} → Independent (ringModule {n}) (vecModuleBasis {n})
vecModuleBasisIndependent R {zero} [] _ [] x = record {}
vecModuleBasisIndependent R {succ n} r _ [] x = record {}
vecModuleBasisIndependent R {succ n} r uniq coeffs x = {!!}
| {
"alphanum_fraction": 0.6742376446,
"avg_line_length": 64.2567567568,
"ext": "agda",
"hexsha": "eb0171c5fed968d752b3adacccf0e48ae1746611",
"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": "Modules/VectorModule.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": "Modules/VectorModule.agda",
"max_line_length": 387,
"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": "Modules/VectorModule.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": 1607,
"size": 4755
} |
{-# OPTIONS --rewriting #-}
module Properties.TypeCheck where
open import Agda.Builtin.Equality using (_≡_; refl)
open import Agda.Builtin.Bool using (Bool; true; false)
open import FFI.Data.Maybe using (Maybe; just; nothing)
open import FFI.Data.Either using (Either)
open import Luau.TypeCheck using (_⊢ᴱ_∈_; _⊢ᴮ_∈_; ⊢ᴼ_; ⊢ᴴ_; _⊢ᴴᴱ_▷_∈_; _⊢ᴴᴮ_▷_∈_; nil; var; addr; number; bool; string; app; function; block; binexp; done; return; local; nothing; orUnknown; tgtBinOp)
open import Luau.Syntax using (Block; Expr; Value; BinaryOperator; yes; nil; addr; number; bool; string; val; var; binexp; _$_; function_is_end; block_is_end; _∙_; return; done; local_←_; _⟨_⟩; _⟨_⟩∈_; var_∈_; name; fun; arg; +; -; *; /; <; >; ==; ~=; <=; >=)
open import Luau.Type using (Type; nil; unknown; never; number; boolean; string; _⇒_; src; tgt)
open import Luau.RuntimeType using (RuntimeType; nil; number; function; string; valueType)
open import Luau.VarCtxt using (VarCtxt; ∅; _↦_; _⊕_↦_; _⋒_; _⊝_) renaming (_[_] to _[_]ⱽ)
open import Luau.Addr using (Addr)
open import Luau.Var using (Var; _≡ⱽ_)
open import Luau.Heap using (Heap; Object; function_is_end) renaming (_[_] to _[_]ᴴ)
open import Properties.Contradiction using (CONTRADICTION)
open import Properties.Dec using (yes; no)
open import Properties.Equality using (_≢_; sym; trans; cong)
open import Properties.Product using (_×_; _,_)
open import Properties.Remember using (Remember; remember; _,_)
typeOfᴼ : Object yes → Type
typeOfᴼ (function f ⟨ var x ∈ S ⟩∈ T is B end) = (S ⇒ T)
typeOfᴹᴼ : Maybe(Object yes) → Maybe Type
typeOfᴹᴼ nothing = nothing
typeOfᴹᴼ (just O) = just (typeOfᴼ O)
typeOfⱽ : Heap yes → Value → Maybe Type
typeOfⱽ H nil = just nil
typeOfⱽ H (bool b) = just boolean
typeOfⱽ H (addr a) = typeOfᴹᴼ (H [ a ]ᴴ)
typeOfⱽ H (number n) = just number
typeOfⱽ H (string x) = just string
typeOfᴱ : Heap yes → VarCtxt → (Expr yes) → Type
typeOfᴮ : Heap yes → VarCtxt → (Block yes) → Type
typeOfᴱ H Γ (var x) = orUnknown(Γ [ x ]ⱽ)
typeOfᴱ H Γ (val v) = orUnknown(typeOfⱽ H v)
typeOfᴱ H Γ (M $ N) = tgt(typeOfᴱ H Γ M)
typeOfᴱ H Γ (function f ⟨ var x ∈ S ⟩∈ T is B end) = S ⇒ T
typeOfᴱ H Γ (block var b ∈ T is B end) = T
typeOfᴱ H Γ (binexp M op N) = tgtBinOp op
typeOfᴮ H Γ (function f ⟨ var x ∈ S ⟩∈ T is C end ∙ B) = typeOfᴮ H (Γ ⊕ f ↦ (S ⇒ T)) B
typeOfᴮ H Γ (local var x ∈ T ← M ∙ B) = typeOfᴮ H (Γ ⊕ x ↦ T) B
typeOfᴮ H Γ (return M ∙ B) = typeOfᴱ H Γ M
typeOfᴮ H Γ done = nil
mustBeFunction : ∀ H Γ v → (never ≢ src (typeOfᴱ H Γ (val v))) → (function ≡ valueType(v))
mustBeFunction H Γ nil p = CONTRADICTION (p refl)
mustBeFunction H Γ (addr a) p = refl
mustBeFunction H Γ (number n) p = CONTRADICTION (p refl)
mustBeFunction H Γ (bool true) p = CONTRADICTION (p refl)
mustBeFunction H Γ (bool false) p = CONTRADICTION (p refl)
mustBeFunction H Γ (string x) p = CONTRADICTION (p refl)
mustBeNumber : ∀ H Γ v → (typeOfᴱ H Γ (val v) ≡ number) → (valueType(v) ≡ number)
mustBeNumber H Γ (addr a) p with remember (H [ a ]ᴴ)
mustBeNumber H Γ (addr a) p | (just O , q) with trans (cong orUnknown (cong typeOfᴹᴼ (sym q))) p
mustBeNumber H Γ (addr a) p | (just function f ⟨ var x ∈ T ⟩∈ U is B end , q) | ()
mustBeNumber H Γ (addr a) p | (nothing , q) with trans (cong orUnknown (cong typeOfᴹᴼ (sym q))) p
mustBeNumber H Γ (addr a) p | nothing , q | ()
mustBeNumber H Γ (number n) p = refl
mustBeString : ∀ H Γ v → (typeOfᴱ H Γ (val v) ≡ string) → (valueType(v) ≡ string)
mustBeString H Γ (addr a) p with remember (H [ a ]ᴴ)
mustBeString H Γ (addr a) p | (just O , q) with trans (cong orUnknown (cong typeOfᴹᴼ (sym q))) p
mustBeString H Γ (addr a) p | (just function f ⟨ var x ∈ T ⟩∈ U is B end , q) | ()
mustBeString H Γ (addr a) p | (nothing , q) with trans (cong orUnknown (cong typeOfᴹᴼ (sym q))) p
mustBeString H Γ (addr a) p | (nothing , q) | ()
mustBeString H Γ (string x) p = refl
typeCheckᴱ : ∀ H Γ M → (Γ ⊢ᴱ M ∈ (typeOfᴱ H Γ M))
typeCheckᴮ : ∀ H Γ B → (Γ ⊢ᴮ B ∈ (typeOfᴮ H Γ B))
typeCheckᴱ H Γ (var x) = var refl
typeCheckᴱ H Γ (val nil) = nil
typeCheckᴱ H Γ (val (addr a)) = addr (orUnknown (typeOfᴹᴼ (H [ a ]ᴴ)))
typeCheckᴱ H Γ (val (number n)) = number
typeCheckᴱ H Γ (val (bool b)) = bool
typeCheckᴱ H Γ (val (string x)) = string
typeCheckᴱ H Γ (M $ N) = app (typeCheckᴱ H Γ M) (typeCheckᴱ H Γ N)
typeCheckᴱ H Γ (function f ⟨ var x ∈ T ⟩∈ U is B end) = function (typeCheckᴮ H (Γ ⊕ x ↦ T) B)
typeCheckᴱ H Γ (block var b ∈ T is B end) = block (typeCheckᴮ H Γ B)
typeCheckᴱ H Γ (binexp M op N) = binexp (typeCheckᴱ H Γ M) (typeCheckᴱ H Γ N)
typeCheckᴮ H Γ (function f ⟨ var x ∈ T ⟩∈ U is C end ∙ B) = function (typeCheckᴮ H (Γ ⊕ x ↦ T) C) (typeCheckᴮ H (Γ ⊕ f ↦ (T ⇒ U)) B)
typeCheckᴮ H Γ (local var x ∈ T ← M ∙ B) = local (typeCheckᴱ H Γ M) (typeCheckᴮ H (Γ ⊕ x ↦ T) B)
typeCheckᴮ H Γ (return M ∙ B) = return (typeCheckᴱ H Γ M) (typeCheckᴮ H Γ B)
typeCheckᴮ H Γ done = done
typeCheckᴼ : ∀ H O → (⊢ᴼ O)
typeCheckᴼ H nothing = nothing
typeCheckᴼ H (just function f ⟨ var x ∈ T ⟩∈ U is B end) = function (typeCheckᴮ H (x ↦ T) B)
typeCheckᴴ : ∀ H → (⊢ᴴ H)
typeCheckᴴ H a {O} p = typeCheckᴼ H (O)
typeCheckᴴᴱ : ∀ H Γ M → (Γ ⊢ᴴᴱ H ▷ M ∈ typeOfᴱ H Γ M)
typeCheckᴴᴱ H Γ M = (typeCheckᴴ H , typeCheckᴱ H Γ M)
typeCheckᴴᴮ : ∀ H Γ M → (Γ ⊢ᴴᴮ H ▷ M ∈ typeOfᴮ H Γ M)
typeCheckᴴᴮ H Γ M = (typeCheckᴴ H , typeCheckᴮ H Γ M)
| {
"alphanum_fraction": 0.6579046899,
"avg_line_length": 48.962962963,
"ext": "agda",
"hexsha": "0726a4be8f755e884e96b5c90f7746335db992a4",
"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": "5bb9f379b07e378db0a170e7c4030e3a943b2f14",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MeltzDev/luau",
"max_forks_repo_path": "prototyping/Properties/TypeCheck.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5bb9f379b07e378db0a170e7c4030e3a943b2f14",
"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": "MeltzDev/luau",
"max_issues_repo_path": "prototyping/Properties/TypeCheck.agda",
"max_line_length": 259,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5bb9f379b07e378db0a170e7c4030e3a943b2f14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MeltzDev/luau",
"max_stars_repo_path": "prototyping/Properties/TypeCheck.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2250,
"size": 5288
} |
open import Oscar.Prelude
open import Oscar.Data.¶
open import Oscar.Data.Descender
open import Oscar.Data.Fin
open import Oscar.Data.Term
module Oscar.Data.Substitist where
module Substitist {𝔭} (𝔓 : Ø 𝔭) where
open Term 𝔓
Substitist = flip Descender⟨ (λ n-o → Fin (↑ n-o) × Term n-o) ⟩
| {
"alphanum_fraction": 0.7239057239,
"avg_line_length": 19.8,
"ext": "agda",
"hexsha": "4590aa586a4779c6c3349515dd5ee52c0a7af7da",
"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/Substitist.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/Substitist.agda",
"max_line_length": 65,
"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/Substitist.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 99,
"size": 297
} |
module Type where
open import Type.Core public
open import Type.NbE public
open import Type.Lemmas public
| {
"alphanum_fraction": 0.7857142857,
"avg_line_length": 18.6666666667,
"ext": "agda",
"hexsha": "d0b74f91299c53bfac300cabd6fc521a21172e82",
"lang": "Agda",
"max_forks_count": 399,
"max_forks_repo_forks_event_max_datetime": "2022-03-31T11:18:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-10-05T09:36:10.000Z",
"max_forks_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "AriFordsham/plutus",
"max_forks_repo_path": "papers/unraveling-recursion/code/src/Type.agda",
"max_issues_count": 2493,
"max_issues_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T15:31:31.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-09-28T19:28:17.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "AriFordsham/plutus",
"max_issues_repo_path": "papers/unraveling-recursion/code/src/Type.agda",
"max_line_length": 30,
"max_stars_count": 1299,
"max_stars_repo_head_hexsha": "f7d34336cd3d65f62b0da084a16f741dc9156413",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "AriFordsham/plutus",
"max_stars_repo_path": "papers/unraveling-recursion/code/src/Type.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-28T01:10:02.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-02T13:41:39.000Z",
"num_tokens": 28,
"size": 112
} |
{-# OPTIONS --cubical --safe #-}
module Data.Sigma where
open import Data.Sigma.Base public
| {
"alphanum_fraction": 0.7127659574,
"avg_line_length": 15.6666666667,
"ext": "agda",
"hexsha": "a5d879e98b0562370892002794a279062d8568a5",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Data/Sigma.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"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": "oisdk/combinatorics-paper",
"max_issues_repo_path": "agda/Data/Sigma.agda",
"max_line_length": 34,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Data/Sigma.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z",
"num_tokens": 23,
"size": 94
} |
{-# OPTIONS --sized-types #-}
module SOList.Lower {A : Set}(_≤_ : A → A → Set) where
open import Data.List
open import Bound.Lower A
open import Bound.Lower.Order _≤_
open import Size
data SOList : {ι : Size} → Bound → Set where
onil : {ι : Size}{b : Bound}
→ SOList {↑ ι} b
:< : {ι : Size}{b : Bound}{x : A}
→ LeB b (val x)
→ SOList {ι} (val x)
→ SOList {↑ ι} b
forget : {b : Bound} → SOList b → List A
forget onil = []
forget (:< {x = x} _ xs) = x ∷ forget xs
| {
"alphanum_fraction": 0.4963898917,
"avg_line_length": 24.0869565217,
"ext": "agda",
"hexsha": "96ace83966b2cd91e5bb521178689ce1b64a8827",
"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": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/SOList/Lower.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"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": "bgbianchi/sorting",
"max_issues_repo_path": "agda/SOList/Lower.agda",
"max_line_length": 55,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/SOList/Lower.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 187,
"size": 554
} |
{-# OPTIONS --cubical #-}
module Cubical.Categories.Type where
open import Cubical.Foundations.Prelude
open import Cubical.Categories.Category
module _ ℓ where
TYPE : Precategory (ℓ-suc ℓ) ℓ
TYPE .ob = Type ℓ
TYPE .hom A B = A → B
TYPE .idn A = λ x → x
TYPE .seq f g = λ x → g (f x)
TYPE .seq-λ f = refl
TYPE .seq-ρ f = refl
TYPE .seq-α f g h = refl
| {
"alphanum_fraction": 0.6432432432,
"avg_line_length": 21.7647058824,
"ext": "agda",
"hexsha": "6014f34db649d8fbf5a3ceefcdab9a18681761fc",
"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": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "borsiemir/cubical",
"max_forks_repo_path": "Cubical/Categories/Type.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"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": "borsiemir/cubical",
"max_issues_repo_path": "Cubical/Categories/Type.agda",
"max_line_length": 39,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "borsiemir/cubical",
"max_stars_repo_path": "Cubical/Categories/Type.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 133,
"size": 370
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
module homotopy.WedgeExtension
{i j} {A : Type i} {a₀ : A} {B : Type j} {b₀ : B} where
-- easier to keep track of than a long list of arguments
record args : Type (lmax (lsucc i) (lsucc j)) where
field
n m : ℕ₋₂
{{cA}} : is-connected (S n) A
{{cB}} : is-connected (S m) B
P : A → B → (n +2+ m) -Type (lmax i j)
f : (a : A) → fst (P a b₀)
g : (b : B) → fst (P a₀ b)
p : f a₀ == g b₀
private
module _ (r : args) where
open args r
Q : A → n -Type (lmax i j)
Q a = ((Σ (∀ b → fst (P a b)) (λ k → (k ∘ cst b₀) == cst (f a)) ,
conn-extend-general (pointed-conn-out B b₀)
(P a) (cst (f a))))
l : Π A (fst ∘ Q)
l = conn-extend (pointed-conn-out A a₀)
Q (λ (_ : Unit) → (g , ap cst (! p)))
module _ (r : args) where
open args r
ext : ∀ a → ∀ b → fst (P a b)
ext a = fst (l r a)
module _ {r : args} where
open args r
abstract
β-l : ∀ a → ext r a b₀ == f a
β-l a = ap (λ t → t unit) (snd (l r a))
private
abstract
β-r-aux : fst (l r a₀) == g
β-r-aux = fst= (conn-extend-β
(pointed-conn-out A a₀)
(Q r) (λ (_ : Unit) → (g , ap cst (! p))) unit)
abstract
β-r : ∀ b → ext r a₀ b == g b
β-r = app= β-r-aux
abstract
coh : ! (β-l a₀) ∙ β-r b₀ == p
coh =
! (β-l a₀) ∙ β-r b₀
=⟨ ! lemma₂ |in-ctx (λ w → ! w ∙ β-r b₀) ⟩
! (β-r b₀ ∙ ! p) ∙ β-r b₀
=⟨ !-∙ (β-r b₀) (! p) |in-ctx (λ w → w ∙ β-r b₀) ⟩
(! (! p) ∙ ! (β-r b₀)) ∙ β-r b₀
=⟨ ∙-assoc (! (! p)) (! (β-r b₀)) (β-r b₀) ⟩
! (! p) ∙ (! (β-r b₀) ∙ β-r b₀)
=⟨ ap2 _∙_ (!-! p) (!-inv-l (β-r b₀)) ⟩
p ∙ idp
=⟨ ∙-unit-r p ⟩
p =∎
where
lemma₁ : β-l a₀ == ap (λ s → s unit) (ap cst (! p))
[ (λ k → k b₀ == f a₀) ↓ β-r-aux ]
lemma₁ = ap↓ (ap (λ s → s unit)) $
snd= (conn-extend-β (pointed-conn-out A a₀)
(Q r) (λ (_ : Unit) → (g , ap cst (! p))) unit)
lemma₂ : β-r b₀ ∙ ! p == β-l a₀
lemma₂ = ap (λ w → β-r b₀ ∙ w)
(! (ap-idf (! p)) ∙ ap-∘ (λ s → s unit) cst (! p))
∙ (! (↓-app=cst-out lemma₁))
| {
"alphanum_fraction": 0.3911960133,
"avg_line_length": 29.0120481928,
"ext": "agda",
"hexsha": "54d72360f429fcddd92b55dc92096671032360cb",
"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/WedgeExtension.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/WedgeExtension.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/WedgeExtension.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 950,
"size": 2408
} |
{-
This file contains a proof of the following fact:
for a commutative ring R with elements f and g s.t.
⟨f,g⟩ = R, we get a get a pullback square
_/1
R ----> R[1/f]
⌟
_/1 | | χ₁
v v
R[1/g] -> R[1/fg]
χ₂
where the morphisms χ are induced by the universal property
of localization.
-}
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.CommRing.Localisation.PullbackSquare where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Powerset renaming (_∈_ to _∈ₚ_)
open import Cubical.Foundations.Transport
open import Cubical.Functions.FunExtEquiv
import Cubical.Data.Empty as ⊥
open import Cubical.Data.Bool
open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; _^_ to _^ℕ_
; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc
; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm)
open import Cubical.Data.Nat.Order
open import Cubical.Data.Vec
open import Cubical.Data.Sigma.Base
open import Cubical.Data.Sigma.Properties
open import Cubical.Data.FinData
open import Cubical.Relation.Nullary
open import Cubical.Relation.Binary
open import Cubical.Algebra.Group
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.Localisation.Base
open import Cubical.Algebra.CommRing.Localisation.UniversalProperty
open import Cubical.Algebra.CommRing.Localisation.InvertingElements
open import Cubical.Algebra.CommRing.Ideal
open import Cubical.Algebra.CommRing.FGIdeal
open import Cubical.Algebra.CommRing.RadicalIdeal
open import Cubical.Algebra.RingSolver.Reflection
open import Cubical.HITs.SetQuotients as SQ
open import Cubical.HITs.PropositionalTruncation as PT
open import Cubical.Categories.Category.Base
open import Cubical.Categories.Instances.CommRings
open import Cubical.Categories.Limits.Pullback
open Iso
private
variable
ℓ ℓ' : Level
A : Type ℓ
module _ (R' : CommRing ℓ) (f g : (fst R')) where
open IsRingHom
open isMultClosedSubset
open CommRingTheory R'
open RingTheory (CommRing→Ring R')
open CommIdeal R'
open RadicalIdeal R'
open Exponentiation R'
open InvertingElementsBase R'
open CommRingStr ⦃...⦄
private
R = R' .fst
⟨_⟩ : {n : ℕ} → FinVec R n → CommIdeal
⟨ V ⟩ = ⟨ V ⟩[ R' ]
fgVec : FinVec R 2
fgVec zero = f
fgVec (suc zero) = g
⟨f,g⟩ = ⟨ fgVec ⟩
fⁿgⁿVec : (n : ℕ) → FinVec R 2
fⁿgⁿVec n zero = f ^ n
fⁿgⁿVec n (suc zero) = g ^ n
⟨fⁿ,gⁿ⟩ : (n : ℕ) → CommIdeal
⟨fⁿ,gⁿ⟩ n = ⟨ (fⁿgⁿVec n) ⟩
instance
_ = R' .snd
_ = R[1/ f ]AsCommRing .snd
_ = R[1/ g ]AsCommRing .snd
_ = R[1/ (R' .snd .CommRingStr._·_ f g) ]AsCommRing .snd
open Loc R' [ f ⁿ|n≥0] (powersFormMultClosedSubset f)
renaming (_≈_ to _≈ᶠ_ ; locIsEquivRel to locIsEquivRelᶠ ; S to Sᶠ)
open S⁻¹RUniversalProp R' [ f ⁿ|n≥0] (powersFormMultClosedSubset f)
renaming ( _/1 to _/1ᶠ ; /1AsCommRingHom to /1ᶠAsCommRingHom
; S⁻¹RHasUniversalProp to R[1/f]HasUniversalProp)
open Loc R' [ g ⁿ|n≥0] (powersFormMultClosedSubset g)
renaming (_≈_ to _≈ᵍ_ ; locIsEquivRel to locIsEquivRelᵍ ; S to Sᵍ)
open S⁻¹RUniversalProp R' [ g ⁿ|n≥0] (powersFormMultClosedSubset g)
renaming ( _/1 to _/1ᵍ ; /1AsCommRingHom to /1ᵍAsCommRingHom
; S⁻¹RHasUniversalProp to R[1/g]HasUniversalProp)
open Loc R' [ (f · g) ⁿ|n≥0] (powersFormMultClosedSubset (f · g))
renaming (_≈_ to _≈ᶠᵍ_ ; locIsEquivRel to locIsEquivRelᶠᵍ ; S to Sᶠᵍ)
open S⁻¹RUniversalProp R' [ (f · g) ⁿ|n≥0] (powersFormMultClosedSubset (f · g))
renaming ( _/1 to _/1ᶠᵍ ; /1AsCommRingHom to /1ᶠᵍAsCommRingHom)
-- the pullback legs
private
-- using RadicalLemma doesn't compute...
χ₁ : CommRingHom R[1/ f ]AsCommRing R[1/ (f · g) ]AsCommRing
χ₁ = R[1/f]HasUniversalProp _ /1ᶠᵍAsCommRingHom unitHelper .fst .fst
where
unitHelper : ∀ s → s ∈ₚ [ f ⁿ|n≥0] → s /1ᶠᵍ ∈ₚ (R[1/ (f · g) ]AsCommRing) ˣ
unitHelper = powersPropElim (λ s → Units.inverseUniqueness _ (s /1ᶠᵍ))
λ n → [ g ^ n , (f · g) ^ n , ∣ n , refl ∣ ]
, eq/ _ _ ((1r , powersFormMultClosedSubset (f · g) .containsOne)
, path n)
where
useSolver1 : ∀ a b → 1r · (a · b) · 1r ≡ a · b
useSolver1 = solve R'
useSolver2 : ∀ a → a ≡ (1r · 1r) · (1r · a)
useSolver2 = solve R'
path : (n : ℕ) → 1r · (f ^ n · g ^ n) · 1r ≡ (1r · 1r) · (1r · ((f · g) ^ n))
path n = useSolver1 _ _ ∙ sym (^-ldist-· f g n) ∙ useSolver2 _
χ₂ : CommRingHom R[1/ g ]AsCommRing R[1/ (f · g) ]AsCommRing
χ₂ = R[1/g]HasUniversalProp _ /1ᶠᵍAsCommRingHom unitHelper .fst .fst
where
unitHelper : ∀ s → s ∈ₚ [ g ⁿ|n≥0] → s /1ᶠᵍ ∈ₚ (R[1/ (f · g) ]AsCommRing) ˣ
unitHelper = powersPropElim (λ s → Units.inverseUniqueness _ (s /1ᶠᵍ))
λ n → [ f ^ n , (f · g) ^ n , ∣ n , refl ∣ ]
, eq/ _ _ ((1r , powersFormMultClosedSubset (f · g) .containsOne)
, path n)
where
useSolver1 : ∀ a b → 1r · (a · b) · 1r ≡ b · a
useSolver1 = solve R'
useSolver2 : ∀ a → a ≡ (1r · 1r) · (1r · a)
useSolver2 = solve R'
path : (n : ℕ) → 1r · (g ^ n · f ^ n) · 1r ≡ (1r · 1r) · (1r · ((f · g) ^ n))
path n = useSolver1 _ _ ∙ sym (^-ldist-· f g n) ∙ useSolver2 _
injectivityLemma : 1r ∈ ⟨f,g⟩ → ∀ (x : R) → x /1ᶠ ≡ 0r → x /1ᵍ ≡ 0r → x ≡ 0r
injectivityLemma 1∈⟨f,g⟩ x x≡0overF x≡0overG =
PT.rec2 (is-set _ _) annihilatorHelper exAnnihilatorF exAnnihilatorG
where
exAnnihilatorF : ∃[ s ∈ Sᶠ ] (fst s · x · 1r ≡ fst s · 0r · 1r)
exAnnihilatorF = isEquivRel→TruncIso locIsEquivRelᶠ _ _ .fun x≡0overF
exAnnihilatorG : ∃[ s ∈ Sᵍ ] (fst s · x · 1r ≡ fst s · 0r · 1r)
exAnnihilatorG = isEquivRel→TruncIso locIsEquivRelᵍ _ _ .fun x≡0overG
annihilatorHelper : Σ[ s ∈ Sᶠ ] (fst s · x · 1r ≡ fst s · 0r · 1r)
→ Σ[ s ∈ Sᵍ ] (fst s · x · 1r ≡ fst s · 0r · 1r)
→ x ≡ 0r
annihilatorHelper ((u , u∈[fⁿ]) , p) ((v , v∈[gⁿ]) , q) =
PT.rec2 (is-set _ _) exponentHelper u∈[fⁿ] v∈[gⁿ]
where
ux≡0 : u · x ≡ 0r
ux≡0 = sym (·Rid _) ∙ p ∙ cong (_· 1r) (0RightAnnihilates _) ∙ (·Rid _)
vx≡0 : v · x ≡ 0r
vx≡0 = sym (·Rid _) ∙ q ∙ cong (_· 1r) (0RightAnnihilates _) ∙ (·Rid _)
exponentHelper : Σ[ n ∈ ℕ ] u ≡ f ^ n
→ Σ[ n ∈ ℕ ] v ≡ g ^ n
→ x ≡ 0r
exponentHelper (n , u≡fⁿ) (m , v≡gᵐ) =
PT.rec (is-set _ _) Σhelper (GeneratingPowers.thm R' l _ fgVec 1∈⟨f,g⟩)
where
l = max n m
fˡx≡0 : f ^ l · x ≡ 0r
fˡx≡0 = f ^ l · x ≡⟨ cong (λ k → f ^ k · x) (sym (≤-∸-+-cancel left-≤-max)) ⟩
f ^ ((l ∸ n) +ℕ n) · x ≡⟨ cong (_· x) (sym (·-of-^-is-^-of-+ _ _ _)) ⟩
f ^ (l ∸ n) · f ^ n · x ≡⟨ cong (λ y → f ^ (l ∸ n) · y · x) (sym u≡fⁿ) ⟩
f ^ (l ∸ n) · u · x ≡⟨ sym (·Assoc _ _ _) ⟩
f ^ (l ∸ n) · (u · x) ≡⟨ cong (f ^ (l ∸ n) ·_) ux≡0 ⟩
f ^ (l ∸ n) · 0r ≡⟨ 0RightAnnihilates _ ⟩
0r ∎
gˡx≡0 : g ^ l · x ≡ 0r
gˡx≡0 = g ^ l · x ≡⟨ cong (λ k → g ^ k · x) (sym (≤-∸-+-cancel right-≤-max)) ⟩
g ^ ((l ∸ m) +ℕ m) · x ≡⟨ cong (_· x) (sym (·-of-^-is-^-of-+ _ _ _)) ⟩
g ^ (l ∸ m) · g ^ m · x ≡⟨ cong (λ y → g ^ (l ∸ m) · y · x) (sym v≡gᵐ) ⟩
g ^ (l ∸ m) · v · x ≡⟨ sym (·Assoc _ _ _) ⟩
g ^ (l ∸ m) · (v · x) ≡⟨ cong (g ^ (l ∸ m) ·_) vx≡0 ⟩
g ^ (l ∸ m) · 0r ≡⟨ 0RightAnnihilates _ ⟩
0r ∎
Σhelper : Σ[ α ∈ FinVec R 2 ] 1r ≡ α zero · f ^ l + (α (suc zero) · g ^ l + 0r)
→ x ≡ 0r
Σhelper (α , 1≡α₀fˡ+α₁gˡ+0) = path
where
α₀ = α zero
α₁ = α (suc zero)
1≡α₀fˡ+α₁gˡ : 1r ≡ α₀ · f ^ l + α₁ · g ^ l
1≡α₀fˡ+α₁gˡ = 1≡α₀fˡ+α₁gˡ+0 ∙ cong (α₀ · f ^ l +_) (+Rid _)
path : x ≡ 0r
path = x ≡⟨ sym (·Lid _) ⟩
1r · x ≡⟨ cong (_· x) 1≡α₀fˡ+α₁gˡ ⟩
(α₀ · f ^ l + α₁ · g ^ l) · x ≡⟨ ·Ldist+ _ _ _ ⟩
α₀ · f ^ l · x + α₁ · g ^ l · x ≡⟨ cong₂ _+_ (sym (·Assoc _ _ _))
(sym (·Assoc _ _ _)) ⟩
α₀ · (f ^ l · x) + α₁ · (g ^ l · x) ≡⟨ cong₂ (λ y z → α₀ · y + α₁ · z)
fˡx≡0 gˡx≡0 ⟩
α₀ · 0r + α₁ · 0r ≡⟨ cong₂ _+_ (0RightAnnihilates _)
(0RightAnnihilates _) ∙ +Rid _ ⟩
0r ∎
equalizerLemma : 1r ∈ ⟨f,g⟩
→ ∀ (x : R[1/ f ]) (y : R[1/ g ])
→ χ₁ .fst x ≡ χ₂ .fst y
→ ∃![ z ∈ R ] (z /1ᶠ ≡ x) × (z /1ᵍ ≡ y)
equalizerLemma 1∈⟨f,g⟩ = invElPropElim2 (λ _ _ → isPropΠ (λ _ → isProp∃!)) baseCase
where
baseCase : ∀ (x y : R) (n : ℕ)
→ fst χ₁ ([ x , f ^ n , ∣ n , refl ∣ ]) ≡ fst χ₂ ([ y , g ^ n , ∣ n , refl ∣ ])
→ ∃![ z ∈ R ] ((z /1ᶠ ≡ [ x , f ^ n , ∣ n , refl ∣ ])
× (z /1ᵍ ≡ [ y , g ^ n , ∣ n , refl ∣ ]))
baseCase x y n χ₁[x/fⁿ]≡χ₂[y/gⁿ] = PT.rec isProp∃! annihilatorHelper exAnnihilator
where
-- doesn't compute that well but at least it computes...
exAnnihilator : ∃[ s ∈ Sᶠᵍ ] -- s.t.
(fst s · (x · transport refl (g ^ n)) · (1r · transport refl ((f · g) ^ n))
≡ fst s · (y · transport refl (f ^ n)) · (1r · transport refl ((f · g) ^ n)))
exAnnihilator = isEquivRel→TruncIso locIsEquivRelᶠᵍ _ _ .fun χ₁[x/fⁿ]≡χ₂[y/gⁿ]
annihilatorHelper : Σ[ s ∈ Sᶠᵍ ]
(fst s · (x · transport refl (g ^ n)) · (1r · transport refl ((f · g) ^ n))
≡ fst s · (y · transport refl (f ^ n)) · (1r · transport refl ((f · g) ^ n)))
→ ∃![ z ∈ R ] ((z /1ᶠ ≡ [ x , f ^ n , ∣ n , refl ∣ ])
× (z /1ᵍ ≡ [ y , g ^ n , ∣ n , refl ∣ ]))
annihilatorHelper ((s , s∈[fgⁿ]) , p) = PT.rec isProp∃! exponentHelper s∈[fgⁿ]
where
sxgⁿ[fg]ⁿ≡syfⁿ[fg]ⁿ : s · x · g ^ n · (f · g) ^ n ≡ s · y · f ^ n · (f · g) ^ n
sxgⁿ[fg]ⁿ≡syfⁿ[fg]ⁿ =
s · x · g ^ n · (f · g) ^ n
≡⟨ transpHelper _ _ _ _ ⟩
s · x · transport refl (g ^ n) · transport refl ((f · g) ^ n)
≡⟨ useSolver _ _ _ _ ⟩
s · (x · transport refl (g ^ n)) · (1r · transport refl ((f · g) ^ n))
≡⟨ p ⟩
s · (y · transport refl (f ^ n)) · (1r · transport refl ((f · g) ^ n))
≡⟨ sym (useSolver _ _ _ _) ⟩
s · y · transport refl (f ^ n) · transport refl ((f · g) ^ n)
≡⟨ sym (transpHelper _ _ _ _) ⟩
s · y · f ^ n · (f · g) ^ n ∎
where
transpHelper : ∀ a b c d → a · b · c · d
≡ a · b · transport refl c · transport refl d
transpHelper a b c d i = a · b · transportRefl c (~ i) · transportRefl d (~ i)
useSolver : ∀ a b c d → a · b · c · d ≡ a · (b · c) · (1r · d)
useSolver = solve R'
exponentHelper : Σ[ m ∈ ℕ ] s ≡ (f · g) ^ m
→ ∃![ z ∈ R ] ((z /1ᶠ ≡ [ x , f ^ n , ∣ n , refl ∣ ])
× (z /1ᵍ ≡ [ y , g ^ n , ∣ n , refl ∣ ]))
exponentHelper (m , s≡[fg]ᵐ) =
PT.rec isProp∃! Σhelper (GeneratingPowers.thm R' 2n+m _ fgVec 1∈⟨f,g⟩)
where
-- the path we'll actually work with
xgⁿ[fg]ⁿ⁺ᵐ≡yfⁿ[fg]ⁿ⁺ᵐ : x · g ^ n · (f · g) ^ (n +ℕ m) ≡ y · f ^ n · (f · g) ^ (n +ℕ m)
xgⁿ[fg]ⁿ⁺ᵐ≡yfⁿ[fg]ⁿ⁺ᵐ =
x · g ^ n · (f · g) ^ (n +ℕ m)
≡⟨ cong (x · (g ^ n) ·_) (sym (·-of-^-is-^-of-+ _ _ _)) ⟩
x · g ^ n · ((f · g) ^ n · (f · g) ^ m)
≡⟨ useSolver _ _ _ _ ⟩
(f · g) ^ m · x · g ^ n · (f · g) ^ n
≡⟨ cong (λ a → a · x · g ^ n · (f · g) ^ n) (sym s≡[fg]ᵐ) ⟩
s · x · g ^ n · (f · g) ^ n
≡⟨ sxgⁿ[fg]ⁿ≡syfⁿ[fg]ⁿ ⟩
s · y · f ^ n · (f · g) ^ n
≡⟨ cong (λ a → a · y · f ^ n · (f · g) ^ n) s≡[fg]ᵐ ⟩
(f · g) ^ m · y · f ^ n · (f · g) ^ n
≡⟨ sym (useSolver _ _ _ _) ⟩
y · f ^ n · ((f · g) ^ n · (f · g) ^ m)
≡⟨ cong (y · (f ^ n) ·_) (·-of-^-is-^-of-+ _ _ _) ⟩
y · f ^ n · (f · g) ^ (n +ℕ m) ∎
where
useSolver : ∀ a b c d → a · b · (c · d) ≡ d · a · b · c
useSolver = solve R'
-- critical exponent
2n+m = n +ℕ (n +ℕ m)
-- extracting information from the fact that R=⟨f,g⟩
Σhelper : Σ[ α ∈ FinVec R 2 ] 1r ≡ linearCombination R' α (fⁿgⁿVec 2n+m)
→ ∃![ z ∈ R ] ((z /1ᶠ ≡ [ x , f ^ n , ∣ n , refl ∣ ])
× (z /1ᵍ ≡ [ y , g ^ n , ∣ n , refl ∣ ]))
Σhelper (α , linCombi) = uniqueExists z (z/1≡x/fⁿ , z/1≡y/gⁿ)
(λ _ → isProp× (is-set _ _) (is-set _ _))
uniqueness
where
α₀ = α zero
α₁ = α (suc zero)
1≡α₀f²ⁿ⁺ᵐ+α₁g²ⁿ⁺ᵐ : 1r ≡ α₀ · f ^ 2n+m + α₁ · g ^ 2n+m
1≡α₀f²ⁿ⁺ᵐ+α₁g²ⁿ⁺ᵐ = linCombi ∙ cong (α₀ · f ^ 2n+m +_) (+Rid _)
-- definition of the element
z = α₀ · x · f ^ (n +ℕ m) + α₁ · y · g ^ (n +ℕ m)
z/1≡x/fⁿ : (z /1ᶠ) ≡ [ x , f ^ n , ∣ n , refl ∣ ]
z/1≡x/fⁿ = eq/ _ _ ((f ^ (n +ℕ m) , ∣ n +ℕ m , refl ∣) , path)
where
useSolver1 : ∀ x y α₀ α₁ fⁿ⁺ᵐ gⁿ⁺ᵐ fⁿ
→ fⁿ⁺ᵐ · (α₀ · x · fⁿ⁺ᵐ + α₁ · y · gⁿ⁺ᵐ) · fⁿ
≡ fⁿ⁺ᵐ · (α₀ · x · (fⁿ · fⁿ⁺ᵐ)) + α₁ · (y · fⁿ · (fⁿ⁺ᵐ · gⁿ⁺ᵐ))
useSolver1 = solve R'
useSolver2 : ∀ x α₀ α₁ fⁿ⁺ᵐ g²ⁿ⁺ᵐ f²ⁿ⁺ᵐ
→ fⁿ⁺ᵐ · (α₀ · x · f²ⁿ⁺ᵐ) + α₁ · (x · fⁿ⁺ᵐ · g²ⁿ⁺ᵐ)
≡ fⁿ⁺ᵐ · x · (α₀ · f²ⁿ⁺ᵐ + α₁ · g²ⁿ⁺ᵐ)
useSolver2 = solve R'
path : f ^ (n +ℕ m) · z · f ^ n ≡ f ^ (n +ℕ m) · x · 1r
path =
f ^ (n +ℕ m) · z · f ^ n
≡⟨ useSolver1 _ _ _ _ _ _ _ ⟩
f ^ (n +ℕ m) · (α₀ · x · (f ^ n · f ^ (n +ℕ m))) + α₁ · (y · f ^ n · (f ^ (n +ℕ m) · g ^ (n +ℕ m)))
≡⟨ cong₂ (λ a b → f ^ (n +ℕ m) · (α₀ · x · a) + α₁ · ((y · f ^ n) · b))
(·-of-^-is-^-of-+ _ _ _) (sym (^-ldist-· _ _ _)) ⟩
f ^ (n +ℕ m) · (α₀ · x · (f ^ 2n+m)) + α₁ · (y · f ^ n · (f · g) ^ (n +ℕ m))
≡⟨ cong (λ a → f ^ (n +ℕ m) · (α₀ · x · f ^ 2n+m) + α₁ · a)
(sym xgⁿ[fg]ⁿ⁺ᵐ≡yfⁿ[fg]ⁿ⁺ᵐ) ⟩
f ^ (n +ℕ m) · (α₀ · x · (f ^ 2n+m)) + α₁ · (x · g ^ n · (f · g) ^ (n +ℕ m))
≡⟨ cong (λ a → f ^ (n +ℕ m) · (α₀ · x · (f ^ 2n+m)) + α₁ · (x · g ^ n · a)) (^-ldist-· _ _ _) ⟩
f ^ (n +ℕ m) · (α₀ · x · (f ^ 2n+m)) + α₁ · (x · g ^ n · (f ^ (n +ℕ m) · g ^ (n +ℕ m)))
≡⟨ cong (λ a → f ^ (n +ℕ m) · (α₀ · x · (f ^ 2n+m)) + α₁ · a) (·CommAssocSwap _ _ _ _) ⟩
f ^ (n +ℕ m) · (α₀ · x · (f ^ 2n+m)) + α₁ · (x · f ^ (n +ℕ m) · (g ^ n · g ^ (n +ℕ m)))
≡⟨ cong (λ a → f ^ (n +ℕ m) · (α₀ · x · (f ^ 2n+m)) + α₁ · (x · f ^ (n +ℕ m) · a))
(·-of-^-is-^-of-+ _ _ _) ⟩
f ^ (n +ℕ m) · (α₀ · x · (f ^ 2n+m)) + α₁ · (x · f ^ (n +ℕ m) · g ^ 2n+m)
≡⟨ useSolver2 _ _ _ _ _ _ ⟩
f ^ (n +ℕ m) · x · (α₀ · f ^ 2n+m + α₁ · g ^ 2n+m)
≡⟨ cong (f ^ (n +ℕ m) · x ·_) (sym 1≡α₀f²ⁿ⁺ᵐ+α₁g²ⁿ⁺ᵐ) ⟩
f ^ (n +ℕ m) · x · 1r ∎
z/1≡y/gⁿ : (z /1ᵍ) ≡ [ y , g ^ n , ∣ n , refl ∣ ]
z/1≡y/gⁿ = eq/ _ _ ((g ^ (n +ℕ m) , ∣ n +ℕ m , refl ∣) , path)
where
useSolver1 : ∀ x y α₀ α₁ fⁿ⁺ᵐ gⁿ⁺ᵐ gⁿ
→ gⁿ⁺ᵐ · (α₀ · x · fⁿ⁺ᵐ + α₁ · y · gⁿ⁺ᵐ) · gⁿ
≡ α₀ · (x · gⁿ · (fⁿ⁺ᵐ · gⁿ⁺ᵐ)) + gⁿ⁺ᵐ · (α₁ · y · (gⁿ · gⁿ⁺ᵐ))
useSolver1 = solve R'
useSolver2 : ∀ y α₀ α₁ gⁿ⁺ᵐ g²ⁿ⁺ᵐ f²ⁿ⁺ᵐ
→ α₀ · (y · f²ⁿ⁺ᵐ · gⁿ⁺ᵐ) + gⁿ⁺ᵐ · (α₁ · y · g²ⁿ⁺ᵐ)
≡ gⁿ⁺ᵐ · y · (α₀ · f²ⁿ⁺ᵐ + α₁ · g²ⁿ⁺ᵐ)
useSolver2 = solve R'
path : g ^ (n +ℕ m) · z · g ^ n ≡ g ^ (n +ℕ m) · y · 1r
path =
g ^ (n +ℕ m) · z · g ^ n
≡⟨ useSolver1 _ _ _ _ _ _ _ ⟩
α₀ · (x · g ^ n · (f ^ (n +ℕ m) · g ^ (n +ℕ m))) + g ^ (n +ℕ m) · (α₁ · y · (g ^ n · g ^ (n +ℕ m)))
≡⟨ cong₂ (λ a b → α₀ · (x · g ^ n · a) + g ^ (n +ℕ m) · (α₁ · y · b))
(sym (^-ldist-· _ _ _)) (·-of-^-is-^-of-+ _ _ _) ⟩
α₀ · (x · g ^ n · (f · g) ^ (n +ℕ m)) + g ^ (n +ℕ m) · (α₁ · y · g ^ 2n+m)
≡⟨ cong (λ a → α₀ · a + g ^ (n +ℕ m) · (α₁ · y · g ^ 2n+m))
xgⁿ[fg]ⁿ⁺ᵐ≡yfⁿ[fg]ⁿ⁺ᵐ ⟩
α₀ · (y · f ^ n · (f · g) ^ (n +ℕ m)) + g ^ (n +ℕ m) · (α₁ · y · g ^ 2n+m)
≡⟨ cong (λ a → α₀ · (y · f ^ n · a) + g ^ (n +ℕ m) · (α₁ · y · g ^ 2n+m)) (^-ldist-· _ _ _) ⟩
α₀ · (y · f ^ n · (f ^ (n +ℕ m) · g ^ (n +ℕ m))) + g ^ (n +ℕ m) · (α₁ · y · g ^ 2n+m)
≡⟨ cong (λ a → α₀ · a + g ^ (n +ℕ m) · (α₁ · y · g ^ 2n+m)) (·-assoc2 _ _ _ _) ⟩
α₀ · (y · (f ^ n · f ^ (n +ℕ m)) · g ^ (n +ℕ m)) + g ^ (n +ℕ m) · (α₁ · y · g ^ 2n+m)
≡⟨ cong (λ a → α₀ · (y · a · g ^ (n +ℕ m)) + g ^ (n +ℕ m) · (α₁ · y · g ^ 2n+m))
(·-of-^-is-^-of-+ _ _ _) ⟩
α₀ · (y · f ^ 2n+m · g ^ (n +ℕ m)) + g ^ (n +ℕ m) · (α₁ · y · g ^ 2n+m)
≡⟨ useSolver2 _ _ _ _ _ _ ⟩
g ^ (n +ℕ m) · y · (α₀ · f ^ 2n+m + α₁ · g ^ 2n+m)
≡⟨ cong (g ^ (n +ℕ m) · y ·_) (sym 1≡α₀f²ⁿ⁺ᵐ+α₁g²ⁿ⁺ᵐ) ⟩
g ^ (n +ℕ m) · y · 1r ∎
uniqueness : ∀ a → ((a /1ᶠ) ≡ [ x , f ^ n , ∣ n , refl ∣ ])
× ((a /1ᵍ) ≡ [ y , g ^ n , ∣ n , refl ∣ ])
→ z ≡ a
uniqueness a (a/1≡x/fⁿ , a/1≡y/gⁿ) = equalByDifference _ _
(injectivityLemma 1∈⟨f,g⟩ (z - a) [z-a]/1≡0overF [z-a]/1≡0overG)
where
[z-a]/1≡0overF : (z - a) /1ᶠ ≡ 0r
[z-a]/1≡0overF = (z - a) /1ᶠ
≡⟨ /1ᶠAsCommRingHom .snd .pres+ _ _ ⟩ -- (-a)/1=-(a/1) by refl!
(z /1ᶠ) - (a /1ᶠ)
≡⟨ cong₂ _-_ z/1≡x/fⁿ a/1≡x/fⁿ ⟩
[ x , f ^ n , ∣ n , refl ∣ ] - [ x , f ^ n , ∣ n , refl ∣ ]
≡⟨ +Rinv ([ x , f ^ n , ∣ n , refl ∣ ]) ⟩
0r ∎
[z-a]/1≡0overG : (z - a) /1ᵍ ≡ 0r
[z-a]/1≡0overG = (z - a) /1ᵍ
≡⟨ /1ᵍAsCommRingHom .snd .pres+ _ _ ⟩ -- (-a)/1=-(a/1) by refl!
(z /1ᵍ) - (a /1ᵍ)
≡⟨ cong₂ _-_ z/1≡y/gⁿ a/1≡y/gⁿ ⟩
[ y , g ^ n , ∣ n , refl ∣ ] - [ y , g ^ n , ∣ n , refl ∣ ]
≡⟨ +Rinv ([ y , g ^ n , ∣ n , refl ∣ ]) ⟩
0r ∎
{-
putting everything together with the pullback machinery:
If ⟨f,g⟩ = R then we get a square
_/1ᶠ
R ----> R[1/f]
⌟
_/1ᵍ | | χ₁
v v
R[1/g] -> R[1/fg]
χ₂
-}
open Category (CommRingsCategory {ℓ})
open Cospan
fgCospan : Cospan CommRingsCategory
l fgCospan = R[1/ g ]AsCommRing
m fgCospan = R[1/ (f · g) ]AsCommRing
r fgCospan = R[1/ f ]AsCommRing
s₁ fgCospan = χ₂
s₂ fgCospan = χ₁
-- the commutative square
private
/1χComm : ∀ (x : R) → χ₂ .fst (x /1ᵍ) ≡ χ₁ .fst (x /1ᶠ)
/1χComm x = eq/ _ _ ((1r , powersFormMultClosedSubset (f · g) .containsOne) , refl)
/1χHomComm : /1ᵍAsCommRingHom ⋆ χ₂ ≡ /1ᶠAsCommRingHom ⋆ χ₁
/1χHomComm = RingHom≡ (funExt /1χComm)
fgSquare : 1r ∈ ⟨f,g⟩
→ isPullback _ fgCospan /1ᵍAsCommRingHom /1ᶠAsCommRingHom /1χHomComm
fgSquare 1∈⟨f,g⟩ {d = A} ψ φ ψχ₂≡φχ₁ = (χ , χCoh) , χUniqueness
where
instance
_ = snd A
applyEqualizerLemma : ∀ a → ∃![ χa ∈ R ] (χa /1ᶠ ≡ fst φ a) × (χa /1ᵍ ≡ fst ψ a)
applyEqualizerLemma a =
equalizerLemma 1∈⟨f,g⟩ (fst φ a) (fst ψ a) (cong (_$ a) (sym ψχ₂≡φχ₁))
χ : CommRingHom A R'
fst χ a = applyEqualizerLemma a .fst .fst
snd χ = makeIsRingHom
(cong fst (applyEqualizerLemma 1r .snd (1r , 1Coh)))
(λ x y → cong fst (applyEqualizerLemma (x + y) .snd (_ , +Coh x y)))
(λ x y → cong fst (applyEqualizerLemma (x · y) .snd (_ , ·Coh x y)))
where
open IsRingHom
1Coh : (1r /1ᶠ ≡ fst φ 1r) × (1r /1ᵍ ≡ fst ψ 1r)
1Coh = (sym (φ .snd .pres1)) , sym (ψ .snd .pres1)
+Coh : ∀ x y → ((fst χ x + fst χ y) /1ᶠ ≡ fst φ (x + y))
× ((fst χ x + fst χ y) /1ᵍ ≡ fst ψ (x + y))
fst (+Coh x y) = /1ᶠAsCommRingHom .snd .pres+ _ _
∙∙ cong₂ _+_ (applyEqualizerLemma x .fst .snd .fst)
(applyEqualizerLemma y .fst .snd .fst)
∙∙ sym (φ .snd .pres+ x y)
snd (+Coh x y) = /1ᵍAsCommRingHom .snd .pres+ _ _
∙∙ cong₂ _+_ (applyEqualizerLemma x .fst .snd .snd)
(applyEqualizerLemma y .fst .snd .snd)
∙∙ sym (ψ .snd .pres+ x y)
·Coh : ∀ x y → ((fst χ x · fst χ y) /1ᶠ ≡ fst φ (x · y))
× ((fst χ x · fst χ y) /1ᵍ ≡ fst ψ (x · y))
fst (·Coh x y) = /1ᶠAsCommRingHom .snd .pres· _ _
∙∙ cong₂ _·_ (applyEqualizerLemma x .fst .snd .fst)
(applyEqualizerLemma y .fst .snd .fst)
∙∙ sym (φ .snd .pres· x y)
snd (·Coh x y) = /1ᵍAsCommRingHom .snd .pres· _ _
∙∙ cong₂ _·_ (applyEqualizerLemma x .fst .snd .snd)
(applyEqualizerLemma y .fst .snd .snd)
∙∙ sym (ψ .snd .pres· x y)
χCoh : (ψ ≡ χ ⋆ /1ᵍAsCommRingHom) × (φ ≡ χ ⋆ /1ᶠAsCommRingHom)
fst χCoh = RingHom≡ (funExt (λ a → sym (applyEqualizerLemma a .fst .snd .snd)))
snd χCoh = RingHom≡ (funExt (λ a → sym (applyEqualizerLemma a .fst .snd .fst)))
χUniqueness : (y : Σ[ θ ∈ CommRingHom A R' ]
(ψ ≡ θ ⋆ /1ᵍAsCommRingHom) × (φ ≡ θ ⋆ /1ᶠAsCommRingHom))
→ (χ , χCoh) ≡ y
χUniqueness (θ , θCoh) = Σ≡Prop (λ _ → isProp× (isSetRingHom _ _ _ _)
(isSetRingHom _ _ _ _))
(RingHom≡ (funExt (λ a → cong fst (applyEqualizerLemma a .snd (θtriple a)))))
where
θtriple : ∀ a → Σ[ x ∈ R ] (x /1ᶠ ≡ fst φ a) × (x /1ᵍ ≡ fst ψ a)
θtriple a = fst θ a , sym (cong (_$ a) (θCoh .snd))
, sym (cong (_$ a) (θCoh .fst))
-- packaging it all up
open Pullback
fgPullback : 1r ∈ ⟨f,g⟩ → Pullback _ fgCospan
pbOb (fgPullback 1r∈⟨f,g⟩) = _
pbPr₁ (fgPullback 1r∈⟨f,g⟩) = _
pbPr₂ (fgPullback 1r∈⟨f,g⟩) = _
pbCommutes (fgPullback 1r∈⟨f,g⟩) = /1χHomComm
univProp (fgPullback 1r∈⟨f,g⟩) = fgSquare 1r∈⟨f,g⟩
| {
"alphanum_fraction": 0.4507289654,
"avg_line_length": 38.1440536013,
"ext": "agda",
"hexsha": "6dae945fcecc247ac17aaa6ae8140d394aecd1fb",
"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": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "howsiyu/cubical",
"max_forks_repo_path": "Cubical/Algebra/CommRing/Localisation/PullbackSquare.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"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": "howsiyu/cubical",
"max_issues_repo_path": "Cubical/Algebra/CommRing/Localisation/PullbackSquare.agda",
"max_line_length": 110,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "howsiyu/cubical",
"max_stars_repo_path": "Cubical/Algebra/CommRing/Localisation/PullbackSquare.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 10334,
"size": 22772
} |
module IndexInference where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
data Vec (A : Set) : Nat -> Set where
[] : Vec A zero
_::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n)
infixr 40 _::_
-- The length of the vector can be inferred from the pattern.
foo : Vec Nat _ -> Nat
foo (a :: b :: c :: []) = c
| {
"alphanum_fraction": 0.5630769231,
"avg_line_length": 19.1176470588,
"ext": "agda",
"hexsha": "a0a9173e15cbac47451a37938f53011897d99e13",
"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": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/agda-kanso",
"max_forks_repo_path": "test/succeed/IndexInference.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"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": "asr/agda-kanso",
"max_issues_repo_path": "test/succeed/IndexInference.agda",
"max_line_length": 61,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/IndexInference.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 111,
"size": 325
} |
module ImplArg2 where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
data Vec (A : Set) : Nat -> Set where
vnil : Vec A zero
vcons : {n : Nat} -> A -> Vec A n -> Vec A (suc n)
cons : {A : Set} (a : A) {n : Nat} -> Vec A n -> Vec A (suc n)
cons a = vcons a
| {
"alphanum_fraction": 0.5350553506,
"avg_line_length": 20.8461538462,
"ext": "agda",
"hexsha": "5b3b7669eeeb3da3206ad7aabc6230d41f3ade7a",
"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": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andrejtokarcik/agda-semantics",
"max_forks_repo_path": "tests/covered/ImplArg2.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"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": "andrejtokarcik/agda-semantics",
"max_issues_repo_path": "tests/covered/ImplArg2.agda",
"max_line_length": 62,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andrejtokarcik/agda-semantics",
"max_stars_repo_path": "tests/covered/ImplArg2.agda",
"max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z",
"num_tokens": 106,
"size": 271
} |
------------------------------------------------------------------------------
-- First-order logic with equality
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- This module exported all the logical constants and the
-- propositional equality. This module is re-exported by the "base"
-- modules whose theories are defined on first-order logic + equality.
module Common.FOL.FOL-Eq where
-- First-order logic (without equality).
open import Common.FOL.FOL public
-- Propositional equality.
open import Common.FOL.Relation.Binary.PropositionalEquality public
| {
"alphanum_fraction": 0.5520833333,
"avg_line_length": 36.5714285714,
"ext": "agda",
"hexsha": "5e30bc20cf17ed2db0399c26a9291d5dc1445cf6",
"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": "src/fot/Common/FOL/FOL-Eq.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": "src/fot/Common/FOL/FOL-Eq.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": "src/fot/Common/FOL/FOL-Eq.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": 129,
"size": 768
} |
open import Categories
open import Functors
open import RMonads
module RMonads.CatofRAdj.TermRAdjObj {a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}
{J : Fun C D}(M : RMonad J) where
open import Library
open import Naturals
open import RAdjunctions
open import RMonads.CatofRAdj M
open import Categories.Terminal
open import RMonads.REM M
open import RMonads.REM.Adjunction M
open import RAdjunctions.RAdj2RMon
open Cat
open Fun
open NatT
open RAdj
lemX : R REMAdj ○ L REMAdj ≅ TFun M
lemX = FunctorEq _ _ refl refl
EMObj : Obj CatofAdj
EMObj = record {
E = EM;
adj = REMAdj;
law = lemX;
ηlaw = idl D;
bindlaw = λ{X}{Y}{f} →
cong bind
(stripsubst (Hom D (OMap J X))
f
(fcong Y (cong OMap (sym lemX))))} where open RMonad M
| {
"alphanum_fraction": 0.6198347107,
"avg_line_length": 23.5277777778,
"ext": "agda",
"hexsha": "99b95f4a49ffb503695b51b33616c3bbeee84b6e",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z",
"max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jmchapman/Relative-Monads",
"max_forks_repo_path": "RMonads/CatofRAdj/TermRAdjObj.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "jmchapman/Relative-Monads",
"max_issues_repo_path": "RMonads/CatofRAdj/TermRAdjObj.agda",
"max_line_length": 78,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jmchapman/Relative-Monads",
"max_stars_repo_path": "RMonads/CatofRAdj/TermRAdjObj.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z",
"num_tokens": 279,
"size": 847
} |
{-# OPTIONS --without-K #-}
open import function.extensionality.core
module hott.equivalence.alternative where
open import sum
open import equality.core
open import equality.calculus
open import function.core
open import function.extensionality.proof
open import function.isomorphism.core
open import function.isomorphism.coherent
open import function.isomorphism.utils
open import hott.level.core
open import hott.equivalence.core
open import hott.univalence
module _ {i j}{X : Set i}{Y : Set j} where
open ≅-Reasoning
private
we-split-iso : (f : X → Y) → _
we-split-iso f = begin
weak-equiv f
≅⟨ ΠΣ-swap-iso ⟩
( Σ ((y : Y) → f ⁻¹ y) λ gβ
→ (y : Y)(u : f ⁻¹ y) → gβ y ≡ u )
≅⟨ Σ-ap-iso₁ ΠΣ-swap-iso ⟩
( Σ (Σ (Y → X) λ g → (y : Y) → f (g y) ≡ y) λ { (g , β)
→ (y : Y)(u : f ⁻¹ y) → (g y , β y) ≡ u } )
≅⟨ Σ-assoc-iso ⟩
( Σ (Y → X) λ g
→ Σ ((y : Y) → f (g y) ≡ y) λ β
→ (y : Y)(u : f ⁻¹ y) → (g y , β y) ≡ u )
≅⟨ ( Σ-ap-iso₂ λ g
→ Σ-ap-iso₂ λ β
→ Π-ap-iso refl≅ λ y
→ curry-iso (λ x p → (g y , β y) ≡ (x , p)) ) ⟩
( Σ (Y → X) λ g
→ Σ ((y : Y) → f (g y) ≡ y) λ β
→ (y : Y)(x : X)(p : f x ≡ y)
→ (g y , β y) ≡ (x , p) )
≅⟨ ( Σ-ap-iso₂ λ g
→ Σ-ap-iso₂ λ β
→ Π-ap-iso refl≅ λ y
→ Π-ap-iso refl≅ λ x
→ Π-ap-iso refl≅ λ p
→ sym≅ Σ-split-iso ) ⟩
( Σ (Y → X) λ g
→ Σ ((y : Y) → f (g y) ≡ y) λ β
→ (y : Y)(x : X)(p : f x ≡ y)
→ Σ (g y ≡ x) λ q
→ subst (λ x' → f x' ≡ y) q (β y) ≡ p )
≅⟨ ( Σ-ap-iso₂ λ g
→ Σ-ap-iso₂ λ β
→ Π-ap-iso refl≅ λ y
→ Π-ap-iso refl≅ λ x
→ Π-ap-iso refl≅ λ p
→ Σ-ap-iso₂ λ q
→ sym≅ ( trans≡-iso (
subst-naturality (λ x' → x' ≡ y) f q (β y)
· subst-eq (ap f q) (β y)) )) ⟩
( Σ (Y → X) λ g
→ Σ ((y : Y) → f (g y) ≡ y) λ β
→ (y : Y)(x : X)(p : f x ≡ y)
→ Σ (g y ≡ x) λ q
→ sym (ap f q) · β y ≡ p )
≅⟨ ( Σ-ap-iso₂ λ g
→ Σ-ap-iso₂ λ β
→ Π-comm-iso ) ⟩
( Σ (Y → X) λ g
→ Σ ((y : Y) → f (g y) ≡ y) λ β
→ (x : X)(y : Y)(p : f x ≡ y)
→ Σ (g y ≡ x) λ q
→ sym (ap f q) · β y ≡ p )
≅⟨ ( Σ-ap-iso₂ λ g
→ Σ-ap-iso₂ λ β
→ Π-ap-iso refl≅ λ x
→ sym≅ J-iso ) ⟩
( Σ (Y → X) λ g
→ Σ ((y : Y) → f (g y) ≡ y) λ β
→ (x : X)
→ Σ (g (f x) ≡ x) λ q
→ sym (ap f q) · β (f x) ≡ refl )
≅⟨ ( Σ-ap-iso₂ λ g
→ Σ-ap-iso₂ λ β
→ ΠΣ-swap-iso ) ⟩
( Σ (Y → X) λ g
→ Σ ((y : Y) → f (g y) ≡ y) λ β
→ Σ ((x : X) → g (f x) ≡ x) λ α
→ (x : X) → sym (ap f (α x)) · β (f x) ≡ refl )
≅⟨ ( Σ-ap-iso₂ λ g
→ Σ-ap-iso₂ λ β
→ Σ-ap-iso₂ λ α
→ Π-ap-iso refl≅ λ x
→ sym≅ (trans≅ (trans≡-iso (left-unit (ap f (α x))))
(move-≡-iso (ap f (α x)) refl (β (f x)))) ) ⟩
( Σ (Y → X) λ g
→ Σ ((y : Y) → f (g y) ≡ y) λ β
→ Σ ((x : X) → g (f x) ≡ x) λ α
→ (x : X) → ap f (α x) ≡ β (f x) )
≅⟨ ( Σ-ap-iso₂ λ g → Σ-comm-iso ) ⟩
( Σ (Y → X) λ g
→ Σ ((x : X) → g (f x) ≡ x) λ α
→ Σ ((y : Y) → f (g y) ≡ y) λ β
→ ((x : X) → ap f (α x) ≡ β (f x)) )
∎
≈⇔≅' : (X ≈ Y) ≅ (X ≅' Y)
≈⇔≅' = begin
(X ≈ Y)
≅⟨ Σ-ap-iso₂ we-split-iso ⟩
( Σ (X → Y) λ f
→ Σ (Y → X) λ g
→ Σ ((x : X) → g (f x) ≡ x) λ α
→ Σ ((y : Y) → f (g y) ≡ y) λ β
→ ((x : X) → ap f (α x) ≡ β (f x)) )
≅⟨ record
{ to = λ {(f , g , α , β , γ) → iso f g α β , γ }
; from = λ { (iso f g α β , γ) → f , g , α , β , γ }
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl } ⟩
(X ≅' Y)
∎
open _≅_ ≈⇔≅' public using ()
renaming ( to to ≈⇒≅'
; from to ≅'⇒≈ )
≅⇒≈ : (X ≅ Y) → (X ≈ Y)
≅⇒≈ = ≅'⇒≈ ∘ ≅⇒≅'
| {
"alphanum_fraction": 0.359196827,
"avg_line_length": 30.5606060606,
"ext": "agda",
"hexsha": "cba93fdf19702f0a18ee0a488c516849ea2bf7e3",
"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/hott/equivalence/alternative.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/hott/equivalence/alternative.agda",
"max_line_length": 70,
"max_stars_count": 27,
"max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "HoTT/M-types",
"max_stars_repo_path": "hott/equivalence/alternative.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z",
"num_tokens": 1880,
"size": 4034
} |
{-# OPTIONS --prop --safe #-}
open import Agda.Builtin.Equality
open import Agda.Builtin.Nat hiding (_<_)
data _<_ : Nat → Nat → Set where
zero-< : ∀ {n} → zero < suc n
suc-< : ∀ {m n} → m < n → suc m < suc n
record Acc (a : Nat) : Prop where
inductive
pattern
constructor acc
field acc< : (∀ b → b < a → Acc b)
open Acc
AccRect : ∀ {P : Nat → Set} → (∀ a → (∀ b → b < a → Acc b) → (∀ b → b < a → P b) → P a) → ∀ a → Acc a → P a
AccRect f a (acc p) = f a p (λ b b<a → AccRect f b (p b b<a))
AccRectProp : ∀ {P : Nat → Prop} → (∀ a → (∀ b → b < a → Acc b) → (∀ b → b < a → P b) → P a) → ∀ a → Acc a → P a
AccRectProp f a (acc p) = f a p (λ b b<a → AccRectProp f b (p b b<a))
AccInv : ∀ a → Acc a → ∀ b → b < a → Acc b
AccInv = AccRectProp (λ _ p _ → p)
example : ∀ {P : Nat → Set} → (f : ∀ a → (∀ b → b < a → P b) → P a) → ∀ a → (access : Acc a) →
AccRect {P} (λ a _ r → f a r) a access ≡ f a (λ b b<a → AccRect {P} (λ a _ r → f a r) b (AccInv a access b b<a))
example f a access = ?
| {
"alphanum_fraction": 0.4950298211,
"avg_line_length": 33.5333333333,
"ext": "agda",
"hexsha": "4f9b6089162cccaf8661bd67eb48acf055c4c44b",
"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": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "cagix/agda",
"max_forks_repo_path": "test/Fail/Issue5481.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"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-2-Clause"
],
"max_issues_repo_name": "cagix/agda",
"max_issues_repo_path": "test/Fail/Issue5481.agda",
"max_line_length": 114,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "cagix/agda",
"max_stars_repo_path": "test/Fail/Issue5481.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": 418,
"size": 1006
} |
{-
This second-order equational theory was created from the following second-order syntax description:
syntax GroupAction | GA
type
* : 0-ary
X : 0-ary
term
unit : * | ε
add : * * -> * | _⊕_ l20
neg : * -> * | ⊖_ r40
act : * X -> X | _⊙_ r30
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))
(⊖N⊕ᴸ) a |> add (neg (a), a) = unit
(⊖N⊕ᴿ) a |> add (a, neg (a)) = unit
(εU⊙) x : X |> act (unit, x) = x
(⊕A⊙) g h x : X |> act (add(g, h), x) = act (g, act(h, x))
-}
module GroupAction.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 GroupAction.Signature
open import GroupAction.Syntax
open import SOAS.Metatheory.SecondOrder.Metasubstitution GA:Syn
open import SOAS.Metatheory.SecondOrder.Equality GA:Syn
private
variable
α β γ τ : GAT
Γ Δ Π : Ctx
infix 1 _▹_⊢_≋ₐ_
-- Axioms of equality
data _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ GA) α Γ → (𝔐 ▷ GA) α Γ → Set where
εU⊕ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ ε ⊕ 𝔞 ≋ₐ 𝔞
εU⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ ε ≋ₐ 𝔞
⊕A : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ⊕ 𝔟) ⊕ 𝔠 ≋ₐ 𝔞 ⊕ (𝔟 ⊕ 𝔠)
⊖N⊕ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ (⊖ 𝔞) ⊕ 𝔞 ≋ₐ ε
⊖N⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ (⊖ 𝔞) ≋ₐ ε
εU⊙ : ⁅ X ⁆̣ ▹ ∅ ⊢ ε ⊙ 𝔞 ≋ₐ 𝔞
⊕A⊙ : ⁅ * ⁆ ⁅ * ⁆ ⁅ X ⁆̣ ▹ ∅ ⊢ (𝔞 ⊕ 𝔟) ⊙ 𝔠 ≋ₐ 𝔞 ⊙ (𝔟 ⊙ 𝔠)
open EqLogic _▹_⊢_≋ₐ_
open ≋-Reasoning
| {
"alphanum_fraction": 0.4967989757,
"avg_line_length": 26.0333333333,
"ext": "agda",
"hexsha": "7b7f18189796e68119f61d1b7b1cc1146d8f943f",
"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/GroupAction/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/GroupAction/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/GroupAction/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": 847,
"size": 1562
} |
-- A variant of code reported by Andreas Abel, due to Andreas Abel and
-- Nicolas Pouillard.
-- npouillard, 2011-10-04
{-# OPTIONS --guardedness --sized-types #-}
open import Common.Coinduction renaming (∞ to co)
open import Common.Size
data ⊥ : Set where
data Mu-co : Size → Set where
inn : ∀ {i} → co (Mu-co i) → Mu-co (↑ i)
iter : ∀ {i} → Mu-co i → ⊥
iter (inn t) = iter (♭ t)
bla : Mu-co ∞
bla = inn (♯ bla)
false : ⊥
false = iter bla
| {
"alphanum_fraction": 0.6213808463,
"avg_line_length": 18.7083333333,
"ext": "agda",
"hexsha": "de83f278065cb1df5419dc37bbb208a286cd15f1",
"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/Succeed/Issue1209-3.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/Succeed/Issue1209-3.agda",
"max_line_length": 70,
"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/Succeed/Issue1209-3.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": 149,
"size": 449
} |
------------------------------------------------------------------------
-- Properties of functions, such as associativity and commutativity
------------------------------------------------------------------------
-- This file contains some core definitions which are reexported by
-- Algebra.FunctionProperties. They are placed here because
-- Algebra.FunctionProperties is a parameterised module, and the
-- parameters are irrelevant for these definitions.
module Algebra.FunctionProperties.Core where
------------------------------------------------------------------------
-- Unary and binary operations
Op₁ : Set → Set
Op₁ A = A → A
Op₂ : Set → Set
Op₂ A = A → A → A
| {
"alphanum_fraction": 0.5169867061,
"avg_line_length": 33.85,
"ext": "agda",
"hexsha": "a9facc431815593651ae6282d4284ce92961efc7",
"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/Algebra/FunctionProperties/Core.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/Algebra/FunctionProperties/Core.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/Algebra/FunctionProperties/Core.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": 111,
"size": 677
} |
module sn-calculus-confluence.helper where
open import Data.List.All
open import Function
using (_∘_)
open import Data.List.Any using (Any ; here ; there)
open import Data.Nat using (_+_)
open import utility
open import Esterel.Lang
open import Esterel.Lang.Properties
open import Esterel.Environment as Env
open import Esterel.Context
open import Data.Product
open import Data.Sum
open import Data.Bool
open import Data.List
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Data.Empty
open import sn-calculus
open import context-properties
open import Esterel.Lang.Binding
open import Data.List.Any.Properties
renaming ( ++⁺ˡ to ++ˡ ; ++⁺ʳ to ++ʳ )
open import Data.FiniteMap
import Data.OrderedListMap as OMap
open import Data.Nat as Nat using (ℕ)
open import Esterel.Variable.Signal as Signal
using (Signal)
open import Esterel.Variable.Shared as SharedVar
using (SharedVar)
open import Esterel.Variable.Sequential as SeqVar
set-dist' : ∀{key value inject surject} → ∀{inject-injective : ∀{k1 : key} → ∀{k2 : key} → (inject k1) ≡ (inject k2) → k1 ≡ k2}
→ ∀{surject-inject : ∀{k} → inject (surject k) ≡ k}
→ ∀{A : Map {key} inject surject inject-injective surject-inject value} → ∀{B : Map {key} inject surject inject-injective surject-inject value}
→ distinct' (keys {key} inject surject inject-injective surject-inject {value} A) (keys {key} inject surject inject-injective surject-inject {value} B)
→ (union {key} inject surject inject-injective surject-inject {value} A B) ≡ (union {key} inject surject inject-injective surject-inject {value} B A)
set-dist'{key}{value}{inject}{surject}{inject-injective}{surject-inject}{A}{B} d = OMap.U-comm key inject value {A} {B} d
set-dist : ∀{θ θ'} → distinct (Dom θ) (Dom θ') → (θ ← θ') ≡ (θ' ← θ)
set-dist {Θ sig₁ shr₁ var₁} {Θ sig₂ shr₂ var₂} (a , b , c)
rewrite set-dist'{inject = _}{Signal.wrap}{inject-injective = Signal.unwrap-injective}{Signal.bijective}{sig₁}{sig₂} a
| set-dist'{inject = _}{SharedVar.wrap}{inject-injective = SharedVar.unwrap-injective}{SharedVar.bijective}{shr₁}{shr₂} b
| set-dist'{inject = _}{SeqVar.wrap}{inject-injective = SeqVar.unwrap-injective}{SeqVar.bijective}{var₁}{var₂} c = refl
done≠rho : ∀{p E θ q A} → done p → (p ≐ E ⟦ (ρ⟨ θ , A ⟩· q) ⟧e) → ⊥
done≠rho (dhalted hnothin) ()
done≠rho (dhalted (hexit n)) ()
done≠rho (dpaused p/paused) p≐E⟦ρθq⟧ with paused-⟦⟧e p/paused p≐E⟦ρθq⟧
... | ()
plug≡ : ∀{r q E w} → r ≐ E ⟦ w ⟧e → q ≐ E ⟦ w ⟧e → r ≡ q
plug≡ r≐E⟦w⟧ q≐E⟦w⟧ = trans (sym (unplug r≐E⟦w⟧)) (unplug q≐E⟦w⟧)
RE-split : ∀{p θ p' E E' q A}
→ p ≐ E ⟦ ρ⟨ θ , A ⟩· p' ⟧e
→ p ≐ E' ⟦ q ⟧e
→ E a~ E'
→ ∃ (λ d → ∃ (λ Eout → d ≐ E ⟦ p' ⟧e × d ≐ Eout ⟦ q ⟧e × E' ~ Eout × Eout a~ E ))
RE-split {.(ρ⟨ _ , _ ⟩· _)} dehole dehole ()
RE-split {.(_ ∥ _)} (depar₁ eq1) dehole ()
RE-split {.(_ >> _)} (deseq eq1) dehole ()
RE-split {.(trap _)} (detrap eq1) dehole ()
RE-split {.(_ ∥ _)} (depar₂ eq1) dehole ()
RE-split {.(suspend _ _)} (desuspend eq1) dehole ()
RE-split {(pin ∥ qin)}{θ}{p'}{((epar₁ _) ∷ E)}{(epar₂ _) ∷ E'} (depar₁ eq1) (depar₂ eq2) par2
= (t ∥ qin) , (epar₂ t) ∷ E' , (depar₁ (plug refl) , depar₂ eq2 , parl (~ref E') , par) where t = (E ⟦ p' ⟧e)
RE-split {(pin ∥ qin)}{θ}{p'}{((epar₂ _) ∷ E)}{(epar₁ _) ∷ E'} (depar₂ eq1) (depar₁ eq2) par
= (pin ∥ t) , ((epar₁ t) ∷ E' , (depar₂ (plug refl) , depar₁ eq2 , parr (~ref E') , par2)) where t = (E ⟦ p' ⟧e)
RE-split {(pin ∥ qin)} (depar₁ eq1) (depar₁ eq2) (parr neg) with RE-split eq1 eq2 neg
... | (d , Eout , (eqd , eqo , ~ , a~)) = d ∥ qin , (epar₁ qin) ∷ Eout , (depar₁ eqd , depar₁ eqo , parr ~ , parr a~)
RE-split {(pin ∥ qin)} (depar₂ eq1) (depar₂ eq2) (parl neg) with RE-split eq1 eq2 neg
... | (d , Eout , (eqd , eqo , ~ , a~)) = pin ∥ d , (epar₂ pin) ∷ Eout , (depar₂ eqd , depar₂ eqo , parl ~ , parl a~)
RE-split {(loopˢ _ q)} (deloopˢ eq1) (deloopˢ eq2) (loopˢ neg) with RE-split eq1 eq2 neg
... | (d , Eout , (eqd , eqo , ~ , a~)) = (loopˢ d q) , (eloopˢ q) ∷ Eout , (deloopˢ eqd , deloopˢ eqo , loopˢ ~ , loopˢ a~)
RE-split {(._ >> q)} (deseq eq1) (deseq eq2) (seq neg) with RE-split eq1 eq2 neg
... | (d , Eout , (eqd , eqo , ~ , a~)) = (d >> q) , (eseq q) ∷ Eout , (deseq eqd , deseq eqo , seq ~ , seq a~)
RE-split {(suspend ._ S)} (desuspend eq1) (desuspend eq2) (susp neg) with RE-split eq1 eq2 neg
... | (d , Eout , (eqd , eqo , ~ , a~)) = (suspend d S) , ((esuspend S) ∷ Eout) , (desuspend eqd , desuspend eqo , susp ~ , susp a~)
RE-split {.(trap _)} (detrap eq1) (detrap eq2) (trp neg) with RE-split eq1 eq2 neg
... | (d , Eout , (eqd , eqo , ~ , a~)) = (trap d) , (etrap ∷ Eout) , (detrap eqd , detrap eqo , trp ~ , trp a~)
ready-maint : ∀{θ e} → (S : Signal) → (S∈ : (Env.isSig∈ S θ)) → (stat : Signal.Status) → all-ready e θ
→ all-ready e (Env.set-sig{S} θ S∈ stat)
ready-maint {θ} {.(plus [])} S S∈ stat (aplus []) = aplus []
ready-maint {θ} {.(plus (num _ ∷ _))} S S∈ stat (aplus (brnum ∷ x₁)) with ready-maint S S∈ stat (aplus x₁)
... | (aplus r) = aplus (brnum ∷ r)
ready-maint {θ} {.(plus (seq-ref _ ∷ _))} S S∈ stat (aplus (brseq x₁ ∷ x₂)) with ready-maint S S∈ stat (aplus x₂)
... | (aplus r) = aplus (brseq x₁ ∷ r)
ready-maint {θ} {.(plus (shr-ref _ ∷ _))} S S∈ stat (aplus (brshr s∈ x ∷ x₁)) with ready-maint S S∈ stat (aplus x₁)
... | (aplus r) = aplus (brshr s∈ x ∷ r)
ready-irr : ∀{θ e} → (S : Signal) → (S∈ : (Env.isSig∈ S θ)) → (stat : Signal.Status)
→ (e' : all-ready e θ)
→ (e'' : all-ready e (Env.set-sig{S} θ S∈ stat))
→ δ e' ≡ δ e''
ready-irr {θ} {.(plus [])} S S∈ stat (aplus []) (aplus []) = refl
ready-irr {θ} {.(plus (num _ ∷ _))} S S∈ stat (aplus (brnum ∷ x₁)) (aplus (brnum ∷ x₂))
rewrite ready-irr S S∈ stat (aplus x₁) (aplus x₂) = refl
ready-irr {θ@(Θ Ss ss xs)} {.(plus (seq-ref _ ∷ _))} S S∈ stat (aplus (brseq{_}{x} x₁ ∷ x₂)) (aplus (brseq x₃ ∷ x₄))
rewrite ready-irr S S∈ stat (aplus x₂) (aplus x₄) | seq∈-eq'{x}{xs} x₁ x₃ = refl
ready-irr {θ@(Θ Ss ss xs)} {.(plus (shr-ref _ ∷ _))} S S∈ stat (aplus (brshr{_}{s} s∈ x ∷ x₁)) (aplus (brshr s∈₁ x₂ ∷ x₃))
rewrite ready-irr S S∈ stat (aplus x₁) (aplus x₃) | shr∈-eq'{s}{ss} s∈ s∈₁ = refl
ready-maint/irr : ∀{θ e} → (S : Signal) → (S∈ : (Env.isSig∈ S θ)) → (stat : Signal.Status)
→ (e' : all-ready e θ)
→ Σ[ e'' ∈ all-ready e (Env.set-sig{S} θ S∈ stat) ] δ e' ≡ δ e''
ready-maint/irr {θ}{e} S S∈ stat e' with ready-maint{θ}{e} S S∈ stat e'
... | e'' = e'' , (ready-irr{θ}{e} S S∈ stat e' e'')
ready-maint/x : ∀{θ e} → (x : SeqVar) → (x∈ : (Env.isVar∈ x θ)) → (n : ℕ) → all-ready e θ
→ all-ready e (Env.set-var{x} θ x∈ n)
ready-maint/x {θ} {.(plus [])} x x∈ n (aplus []) = aplus []
ready-maint/x {θ} {.(plus (num _ ∷ _))} x₁ x∈ n (aplus (brnum ∷ x₂)) with ready-maint/x x₁ x∈ n (aplus x₂)
... | (aplus r) = aplus (brnum ∷ r)
ready-maint/x {θ} {.(plus (seq-ref _ ∷ _))} x₁ x∈ n (aplus (brseq{x = x2} x₂ ∷ x₃)) with ready-maint/x x₁ x∈ n (aplus x₃)
... | (aplus r) = aplus ((brseq (seq-set-mono'{x2}{x₁}{θ}{n}{x∈} x₂)) ∷ r)
ready-maint/x {θ} {.(plus (shr-ref _ ∷ _))} x₁ x∈ n (aplus (brshr s∈ x ∷ x₂)) with ready-maint/x x₁ x∈ n (aplus x₂)
... | (aplus r) = aplus (brshr s∈ x ∷ r)
ready-maint-s : ∀{θ e} → (s : SharedVar) → (n : ℕ) → (s∈ : Env.isShr∈ s θ) → ¬ (Env.shr-stats {s} θ s∈ ≡ SharedVar.ready) → (e' : all-ready e θ)
→ all-ready e (Env.set-shr{s = s} θ s∈ SharedVar.new n)
ready-maint-s {e = .(plus [])} s n s∈ ¬≡ (aplus []) = aplus []
ready-maint-s {e = .(plus (num _ ∷ _))} s n₁ s∈ ¬≡ (aplus (brnum ∷ x₁)) with ready-maint-s s n₁ s∈ ¬≡ (aplus x₁)
... | aplus rec = aplus (brnum ∷ rec)
ready-maint-s {e = .(plus (seq-ref _ ∷ _))} s n s∈ ¬≡ (aplus (brseq x₁ ∷ x₂)) with ready-maint-s s n s∈ ¬≡ (aplus x₂)
... | aplus rec = aplus (brseq x₁ ∷ rec)
ready-maint-s{θ} {e = (plus (shr-ref s ∷ ._))} s₁ n s∈ ¬≡ (aplus (brshr s∈₁ x ∷ x₁)) with ready-maint-s s₁ n s∈ ¬≡ (aplus x₁) | s SharedVar.≟ s₁
... | aplus rec | yes refl with shr-stats-∈-irr{s}{θ} s∈ s∈₁
... | eq rewrite eq = ⊥-elim (¬≡ x)
ready-maint-s{θ = θ} {e = (plus (shr-ref s ∷ ._))} s₁ n s∈ ¬≡ (aplus (brshr s∈₁ x ∷ x₁)) | aplus rec | no ¬s≡s₁
with shr-putputget{θ = θ}{v2l = SharedVar.new}{n} ¬s≡s₁ s∈₁ s∈ (shr-set-mono'{s}{s₁}{θ}{n = n}{s∈} s∈₁) x refl
... | (eq1 , eq2) = aplus (brshr ((shr-set-mono'{s}{s₁}{θ}{n = n}{s∈} s∈₁)) eq1 ∷ rec)
ready-irr-on-irr-s-helper : ∀{θ e} → (s : SharedVar) → (n : ℕ) → (s∈ : Env.isShr∈ s θ) → ¬ (Env.shr-stats {s} θ s∈ ≡ SharedVar.ready) → (e' : all-ready e θ)
→ (e'' : all-ready e (Env.set-shr{s = s} θ s∈ SharedVar.new n)) → δ e' ≡ δ e''
ready-irr-on-irr-s-helper {θ} {.(plus [])} s n s∈ ¬≡ (aplus []) (aplus []) = refl
ready-irr-on-irr-s-helper {θ} {.(plus (num _ ∷ _))} s n s∈ ¬≡ (aplus (brnum ∷ x₁)) (aplus (brnum ∷ x'))
rewrite ready-irr-on-irr-s-helper s n s∈ ¬≡ (aplus x₁) (aplus x') = refl
ready-irr-on-irr-s-helper {θ@(Θ Ss ss xs)} {(plus (seq-ref x ∷ _))} s n s∈ ¬≡ (aplus (brseq x₁ ∷ x₂)) (aplus (brseq x₃ ∷ x'))
rewrite ready-irr-on-irr-s-helper s n s∈ ¬≡ (aplus x₂) (aplus x') | seq∈-eq'{x}{xs} x₁ x₃ = refl
ready-irr-on-irr-s-helper {θ@(Θ Ss ss xs)} {(plus (shr-ref sₑ ∷ _))} s n s∈ ¬≡ (aplus (brshr s∈₁ x ∷ x₁)) (aplus (brshr s∈₂ x₂ ∷ x'))
with sₑ SharedVar.≟ s
... | yes sₑ≡s rewrite sₑ≡s | shr∈-eq'{s}{ss} s∈ s∈₁ = ⊥-elim (¬≡ x)
... | no ¬sₑ≡s with shr-putputget{θ = θ}{v2l = SharedVar.new}{n} ¬sₑ≡s s∈₁ s∈ s∈₂ x refl
... | (eq1 , eq2) rewrite ready-irr-on-irr-s-helper s n s∈ ¬≡ (aplus x₁) (aplus x') | eq2 = refl
ready-irr-on-irr-s : ∀{θ e} → (s : SharedVar) → (n : ℕ) → (s∈ : Env.isShr∈ s θ) → ¬ (Env.shr-stats {s} θ s∈ ≡ SharedVar.ready) → (e' : all-ready e θ)
→ Σ[ e'' ∈ all-ready e (Env.set-shr{s = s} θ s∈ SharedVar.new n) ] δ e' ≡ δ e''
ready-irr-on-irr-s s n s∈ ¬≡ e' = e'' , (ready-irr-on-irr-s-helper s n s∈ ¬≡ e' e'')
where e'' = ready-maint-s s n s∈ ¬≡ e'
-- copied and pasted form above
-- TODO: maybe someday abstract over SharedVar.new/SharedVar.ready to sharedvar-status
ready-maint-s/ready : ∀{θ e} → (s : SharedVar) → (n : ℕ) → (s∈ : Env.isShr∈ s θ) → ¬ (Env.shr-stats {s} θ s∈ ≡ SharedVar.ready) → (e' : all-ready e θ)
→ all-ready e (Env.set-shr{s = s} θ s∈ SharedVar.ready n)
ready-maint-s/ready {e = .(plus [])} s n s∈ ¬≡ (aplus []) = aplus []
ready-maint-s/ready {e = .(plus (num _ ∷ _))} s n₁ s∈ ¬≡ (aplus (brnum ∷ x₁)) with ready-maint-s/ready s n₁ s∈ ¬≡ (aplus x₁)
... | aplus rec = aplus (brnum ∷ rec)
ready-maint-s/ready {e = .(plus (seq-ref _ ∷ _))} s n s∈ ¬≡ (aplus (brseq x₁ ∷ x₂)) with ready-maint-s/ready s n s∈ ¬≡ (aplus x₂)
... | aplus rec = aplus (brseq x₁ ∷ rec)
ready-maint-s/ready{θ} {e = (plus (shr-ref s ∷ ._))} s₁ n s∈ ¬≡ (aplus (brshr s∈₁ x ∷ x₁)) with ready-maint-s/ready s₁ n s∈ ¬≡ (aplus x₁) | s SharedVar.≟ s₁
... | aplus rec | yes refl with shr-stats-∈-irr{s}{θ} s∈ s∈₁
... | eq rewrite eq = ⊥-elim (¬≡ x)
ready-maint-s/ready{θ = θ} {e = (plus (shr-ref s ∷ ._))} s₁ n s∈ ¬≡ (aplus (brshr s∈₁ x ∷ x₁)) | aplus rec | no ¬s≡s₁
with shr-putputget{θ = θ}{v2l = SharedVar.ready}{n} ¬s≡s₁ s∈₁ s∈ (shr-set-mono'{s}{s₁}{θ}{n = n}{s∈} s∈₁) x refl
... | (eq1 , eq2) = aplus (brshr ((shr-set-mono'{s}{s₁}{θ}{n = n}{s∈} s∈₁)) eq1 ∷ rec)
ready-irr-on-irr-s-helper/ready : ∀{θ e} → (s : SharedVar) → (n : ℕ) → (s∈ : Env.isShr∈ s θ) → ¬ (Env.shr-stats {s} θ s∈ ≡ SharedVar.ready) → (e' : all-ready e θ)
→ (e'' : all-ready e (Env.set-shr{s = s} θ s∈ SharedVar.ready n)) → δ e' ≡ δ e''
ready-irr-on-irr-s-helper/ready {θ} {.(plus [])} s n s∈ ¬≡ (aplus []) (aplus []) = refl
ready-irr-on-irr-s-helper/ready {θ} {.(plus (num _ ∷ _))} s n s∈ ¬≡ (aplus (brnum ∷ x₁)) (aplus (brnum ∷ x'))
rewrite ready-irr-on-irr-s-helper/ready s n s∈ ¬≡ (aplus x₁) (aplus x') = refl
ready-irr-on-irr-s-helper/ready {θ@(Θ Ss ss xs)} {(plus (seq-ref x ∷ _))} s n s∈ ¬≡ (aplus (brseq x₁ ∷ x₂)) (aplus (brseq x₃ ∷ x'))
rewrite ready-irr-on-irr-s-helper/ready s n s∈ ¬≡ (aplus x₂) (aplus x') | seq∈-eq'{x}{xs} x₁ x₃ = refl
ready-irr-on-irr-s-helper/ready {θ@(Θ Ss ss xs)} {(plus (shr-ref sₑ ∷ _))} s n s∈ ¬≡ (aplus (brshr s∈₁ x ∷ x₁)) (aplus (brshr s∈₂ x₂ ∷ x'))
with sₑ SharedVar.≟ s
... | yes sₑ≡s rewrite sₑ≡s | shr∈-eq'{s}{ss} s∈ s∈₁ = ⊥-elim (¬≡ x)
... | no ¬sₑ≡s with shr-putputget{θ = θ}{v2l = SharedVar.ready}{n} ¬sₑ≡s s∈₁ s∈ s∈₂ x refl
... | (eq1 , eq2) rewrite ready-irr-on-irr-s-helper/ready s n s∈ ¬≡ (aplus x₁) (aplus x') | eq2 = refl
ready-irr-on-irr-s/ready : ∀{θ e} → (s : SharedVar) → (n : ℕ) → (s∈ : Env.isShr∈ s θ) → ¬ (Env.shr-stats {s} θ s∈ ≡ SharedVar.ready) → (e' : all-ready e θ)
→ Σ[ e'' ∈ all-ready e (Env.set-shr{s = s} θ s∈ SharedVar.ready n) ] δ e' ≡ δ e''
ready-irr-on-irr-s/ready s n s∈ ¬≡ e' = e'' , (ready-irr-on-irr-s-helper/ready s n s∈ ¬≡ e' e'')
where e'' = ready-maint-s/ready s n s∈ ¬≡ e'
ready-irr-on-irr-x-help : ∀{θ e} x n → (x∈ : Env.isVar∈ x θ) → (e' : all-ready e θ) → (SeqVar.unwrap x) ∉ (Xs (FVₑ e))
→ (e'' : all-ready e (Env.set-var{x = x} θ x∈ n))
→ δ e' ≡ δ e''
ready-irr-on-irr-x-help x n x∈ (aplus []) x∉FV (aplus []) = refl
ready-irr-on-irr-x-help x₁ n x∈ (aplus (brnum ∷ a)) x∉FV (aplus (brnum ∷ b)) rewrite ready-irr-on-irr-x-help x₁ n x∈ (aplus a) x∉FV (aplus b) = refl
ready-irr-on-irr-x-help{θ}{e} x₁ n x∈ (aplus (brseq{x = x} x₂ ∷ a)) x∉FV (aplus (brseq x₃ ∷ b))
with x SeqVar.≟ x₁
... | yes refl = ⊥-elim (x∉FV (here refl))
... | no ¬x≡x₁ rewrite seq-putputget{θ = θ} ¬x≡x₁ x₂ x∈ x₃ refl
| ready-irr-on-irr-x-help x₁ n x∈ (aplus a) (λ x → x∉FV (there x)) (aplus b) = refl
ready-irr-on-irr-x-help{θ} x₁ n x∈ (aplus (brshr{s = s} s∈ x ∷ a)) x∉FV (aplus (brshr s∈₁ x₂ ∷ b))
rewrite ready-irr-on-irr-x-help x₁ n x∈ (aplus a) x∉FV (aplus b)
| shr∈-eq'{s = s}{θ = (shr θ)} s∈ s∈₁
= refl
ready-maint-x : ∀{θ e} x n → (x∈ : Env.isVar∈ x θ) → (e' : all-ready e θ) → (SeqVar.unwrap x) ∉ (Xs (FVₑ e))
→ all-ready e (Env.set-var{x = x} θ x∈ n)
ready-maint-x x n x∈ (aplus []) x∉FV = aplus []
ready-maint-x x₁ n₁ x∈ (aplus (brnum ∷ a)) x∉FV with ready-maint-x x₁ n₁ x∈ (aplus a) x∉FV
... | (aplus r) = aplus (brnum ∷ r)
ready-maint-x{θ} x₁ n x∈ (aplus (brseq{x = x} x₂ ∷ a)) x∉FV with ready-maint-x x₁ n x∈ (aplus a) (λ x₃ → x∉FV (there x₃))
... | (aplus r) = aplus ((brseq ((seq-set-mono'{x}{x₁}{θ}{n}{x∈} x₂))) ∷ r)
ready-maint-x x₁ n x∈ (aplus (brshr s∈ x ∷ a)) x∉FV with ready-maint-x x₁ n x∈ (aplus a) x∉FV
... | (aplus r) = aplus ((brshr s∈ x) ∷ r)
ready-irr-on-irr-x : ∀{θ e} x n → (x∈ : Env.isVar∈ x θ) → (e' : all-ready e θ) → (SeqVar.unwrap x) ∉ (Xs (FVₑ e))
→ Σ[ e'' ∈ all-ready e (Env.set-var{x = x} θ x∈ n) ] δ e' ≡ δ e''
ready-irr-on-irr-x x n x∈ e' x∉FV = _ , ready-irr-on-irr-x-help x n x∈ e' x∉FV (ready-maint-x x n x∈ e' x∉FV)
ready-maint-θˡ : ∀{θ e} θ' → (e' : all-ready e θ) → (distinct (Dom θ') (FVₑ e)) → (all-ready e (θ ← θ'))
ready-maint-θˡ θ' (aplus []) Domθ'≠FVe = aplus []
ready-maint-θˡ θ' (aplus (brnum ∷ x₁)) Domθ'≠FVe with ready-maint-θˡ θ' (aplus x₁) Domθ'≠FVe
... | (aplus f) = (aplus (brnum ∷ f))
ready-maint-θˡ{θ} θ' (aplus (brseq{x = x} x₁ ∷ x₂)) Domθ'≠FVe with ready-maint-θˡ θ' (aplus x₂) ((proj₁ Domθ'≠FVe) , (proj₁ (proj₂ Domθ'≠FVe)) , dist':: (proj₂ (proj₂ Domθ'≠FVe)))
... | (aplus f) = aplus (brseq (Env.seq-←-monoˡ x θ θ' x₁) ∷ f)
ready-maint-θˡ{θ} θ' (aplus (brshr{s = s} s∈ s≡ ∷ x₁)) Domθ'≠FVe with ready-maint-θˡ θ' (aplus x₁) (((proj₁ Domθ'≠FVe) , dist':: (proj₁ (proj₂ Domθ'≠FVe)) , (proj₂ (proj₂ Domθ'≠FVe))))
| shr-←-irr-get{θ}{θ'}{s} s∈ (λ x → (proj₁ (proj₂ Domθ'≠FVe)) _ x (here refl))
... | (aplus f) | (s∈2 , eq) rewrite eq = aplus ((brshr s∈2 s≡) ∷ f)
ready-irr-on-irr-θˡ-help : ∀{θ e} θ' → (e' : all-ready e θ) → (distinct (Dom θ') (FVₑ e))
→ (e'' : (all-ready e (θ ← θ'))) → δ e' ≡ δ e''
ready-irr-on-irr-θˡ-help θ' (aplus []) Domθ'≠FVe (aplus []) = refl
ready-irr-on-irr-θˡ-help θ' (aplus (brnum ∷ x₁)) Domθ'≠FVe (aplus (brnum ∷ x₂))
rewrite ready-irr-on-irr-θˡ-help θ' (aplus x₁) Domθ'≠FVe (aplus x₂)
= refl
ready-irr-on-irr-θˡ-help{θ} θ' (aplus (brseq{x = x} x₁ ∷ x₂)) Domθ'≠FVe (aplus (brseq x₃ ∷ x₄))
rewrite ready-irr-on-irr-θˡ-help θ' (aplus x₂) ((proj₁ Domθ'≠FVe) , (proj₁ (proj₂ Domθ'≠FVe)) , dist':: (proj₂ (proj₂ Domθ'≠FVe))) (aplus x₄)
| seq-←-irr-get'{θ}{θ'}{x} x₁ (λ x → (proj₂ (proj₂ Domθ'≠FVe)) _ x (here refl)) x₃
= refl
ready-irr-on-irr-θˡ-help{θ} θ' (aplus (brshr{s = s} s∈ x ∷ x₁)) Domθ'≠FVe (aplus (brshr s∈₁ x₂ ∷ x₃))
rewrite ready-irr-on-irr-θˡ-help θ' (aplus x₁) ((proj₁ Domθ'≠FVe) , dist':: (proj₁ (proj₂ Domθ'≠FVe)) , (proj₂ (proj₂ Domθ'≠FVe))) (aplus x₃)
| shr-←-irr-get/vals'{θ}{θ'}{s} s∈ (λ x → (proj₁ (proj₂ Domθ'≠FVe)) _ x (here refl)) s∈₁
= refl
ready-irr-on-irr-θˡ : ∀{θ e} θ' → (e' : all-ready e θ) → (distinct (Dom θ') (FVₑ e))
→ Σ[ e'' ∈ (all-ready e (θ ← θ')) ] δ e' ≡ δ e''
ready-irr-on-irr-θˡ θ' e' Domθ'≠FVe = _ , ready-irr-on-irr-θˡ-help θ' e' Domθ'≠FVe (ready-maint-θˡ θ' e' Domθ'≠FVe)
ready-maint-θʳ : ∀ {θ' e} θ → (e' : all-ready e θ') → all-ready e (θ ← θ')
ready-maint-θʳ θ (aplus []) = aplus []
ready-maint-θʳ θ (aplus (brnum ∷ bound-readys))
with ready-maint-θʳ θ (aplus bound-readys)
... | aplus bound-readys' = aplus (brnum ∷ bound-readys')
ready-maint-θʳ {θ'} θ (aplus (brseq {x = x} x∈Domθ' ∷ bound-readys))
with ready-maint-θʳ θ (aplus bound-readys)
... | aplus bound-readys' = aplus (brseq (seq-←-monoʳ x θ' θ x∈Domθ') ∷ bound-readys')
ready-maint-θʳ {θ'} θ (aplus (brshr {s = s} s∈Domθ' θ's≡ready ∷ bound-readys))
with ready-maint-θʳ θ (aplus bound-readys)
... | aplus bound-readys' =
aplus (brshr (shr-←-monoʳ s θ' θ s∈Domθ')
(trans
(shr-stats-←-right-irr' s θ θ' s∈Domθ'
(shr-←-monoʳ s θ' θ s∈Domθ'))
θ's≡ready) ∷
bound-readys')
ready-irr-on-irr-θʳ-help : ∀ {θ' e} θ →
(e' : all-ready e θ') →
(e'' : all-ready e (θ ← θ')) →
δ e' ≡ δ e''
ready-irr-on-irr-θʳ-help {θ'} θ (aplus []) (aplus []) = refl
ready-irr-on-irr-θʳ-help {θ'} θ (aplus (brnum ∷ bound-readys')) (aplus (brnum ∷ bound-readys''))
with ready-irr-on-irr-θʳ-help θ (aplus bound-readys') (aplus bound-readys'')
... | δe'≡δe'' rewrite δe'≡δe'' = refl
ready-irr-on-irr-θʳ-help {θ'} θ
(aplus (brseq {x = x} x∈Domθ' ∷ bound-readys'))
(aplus (brseq {x = .x} x∈Domθ←θ' ∷ bound-readys''))
with ready-irr-on-irr-θʳ-help θ (aplus bound-readys') (aplus bound-readys'')
... | δe'≡δe'' rewrite δe'≡δe'' | var-vals-←-right-irr' x θ θ' x∈Domθ' x∈Domθ←θ' = refl
ready-irr-on-irr-θʳ-help {θ'} θ
(aplus (brshr {s = s} s∈Domθ' θ's≡ready ∷ bound-readys'))
(aplus (brshr {s = .s} s∈Domθ←θ' ⟨θ←θ'⟩s≡ready ∷ bound-readys''))
with ready-irr-on-irr-θʳ-help θ (aplus bound-readys') (aplus bound-readys'')
... | δe'≡δe'' rewrite δe'≡δe'' | shr-vals-←-right-irr' s θ θ' s∈Domθ' s∈Domθ←θ' = refl
ready-irr-on-irr-θʳ : ∀ {θ' e} θ →
(e' : all-ready e θ') →
Σ[ e'' ∈ all-ready e (θ ← θ') ] δ e' ≡ δ e''
ready-irr-on-irr-θʳ θ e' = _ , ready-irr-on-irr-θʳ-help θ e' (ready-maint-θʳ θ e')
CBE⟦p⟧=>CBp : ∀{BV FV E p} → CorrectBinding (E ⟦ p ⟧e) BV FV → ∃ (λ BV → ∃ (λ FV → (CorrectBinding p BV FV)))
CBE⟦p⟧=>CBp{BV}{FV} {E = []} CB = BV , FV , CB
CBE⟦p⟧=>CBp {E = epar₁ q ∷ E} (CBpar CB CB₁ x x₁ x₂ x₃) = CBE⟦p⟧=>CBp{E = E} CB
CBE⟦p⟧=>CBp {E = epar₂ p ∷ E} (CBpar CB CB₁ x x₁ x₂ x₃) = CBE⟦p⟧=>CBp{E = E} CB₁
CBE⟦p⟧=>CBp {E = eloopˢ q ∷ E} (CBloopˢ CB CB₁ x _) = CBE⟦p⟧=>CBp{E = E} CB
CBE⟦p⟧=>CBp {E = eseq q ∷ E} (CBseq CB CB₁ x) = CBE⟦p⟧=>CBp{E = E} CB
CBE⟦p⟧=>CBp {E = esuspend S ∷ E} (CBsusp CB x) = CBE⟦p⟧=>CBp{E = E} CB
CBE⟦p⟧=>CBp {E = etrap ∷ E} (CBtrap CB) = CBE⟦p⟧=>CBp{E = E} CB
CBE⟦p⟧=>CBp' : ∀{BV FV E p p'} → p ≐ E ⟦ p' ⟧e → CorrectBinding (p) BV FV → ∃ (λ BV → ∃ (λ FV → (CorrectBinding p' BV FV)))
CBE⟦p⟧=>CBp'{E = E}{p' = p'} peq cb = CBE⟦p⟧=>CBp{E = E}{p = p'} (subst (λ x → CorrectBinding x _ _) (sym (unplug peq)) cb)
-- , (BV⊆S , BV⊆s , BV⊆x)
CBp⊆CBE⟦p⟧ : ∀{BVp FVp BVE FVE} → (E : EvaluationContext ) → (p : Term) → CorrectBinding p BVp FVp → CorrectBinding (E ⟦ p ⟧e) BVE FVE → (FVp ⊆ FVE × BVp ⊆ BVE)
CBp⊆CBE⟦p⟧ [] p CBp CBE with binding-is-function CBp CBE
... | (e1 , e2) rewrite e1 | e2 = (((λ x z → z) , (λ x z → z) , (λ x z → z))) , (((λ x z → z) , (λ x z → z) , (λ x z → z)))
CBp⊆CBE⟦p⟧ (epar₁ q ∷ E) p CBp (CBpar CBE CBE₁ x x₁ x₂ x₃) with CBp⊆CBE⟦p⟧ E p CBp CBE
... | (FV⊆S , FV⊆s , FV⊆x) , (BV⊆S , BV⊆s , BV⊆x) = ((λ x y → ++ˡ (FV⊆S x y)) , ((λ x y → ++ˡ (FV⊆s x y))) , ((λ x y → ++ˡ (FV⊆x x y)))) , (((λ x y → ++ˡ (BV⊆S x y))) , ((λ x y → ++ˡ (BV⊆s x y))) , ((λ x y → ++ˡ (BV⊆x x y))))
CBp⊆CBE⟦p⟧ (epar₂ p ∷ E) p₁ CBp (CBpar{BVp = BVp}{FVp = FVp} CBE CBE₁ x x₁ x₂ x₃) with CBp⊆CBE⟦p⟧ E p₁ CBp CBE₁
... | (FV⊆S , FV⊆s , FV⊆x) , (BV⊆S , BV⊆s , BV⊆x)
= ((λ x z → ++ʳ (proj₁ FVp) (FV⊆S x z)) , (λ x → (++ʳ (proj₁ (proj₂ FVp))) ∘ (FV⊆s x)) , ((λ x → (++ʳ (proj₂ (proj₂ FVp))) ∘ (FV⊆x x))))
, ((λ x z → ++ʳ (proj₁ BVp) (BV⊆S x z)) , (λ x → (++ʳ (proj₁ (proj₂ BVp))) ∘ (BV⊆s x)) , ((λ x → (++ʳ (proj₂ (proj₂ BVp))) ∘ (BV⊆x x))))
CBp⊆CBE⟦p⟧ (eloopˢ q ∷ E) p CBp (CBloopˢ CBE CBE₁ x _) with CBp⊆CBE⟦p⟧ E p CBp CBE
... | (FV⊆S , FV⊆s , FV⊆x) , (BV⊆S , BV⊆s , BV⊆x) = ((λ x y → ++ˡ (FV⊆S x y)) , ((λ x → ++ˡ ∘ (FV⊆s x)) ) , get FV⊆x) , (get BV⊆S , get BV⊆s , get BV⊆x)
where
get : ∀{a b c} → a ⊆¹ b → a ⊆¹ (b ++ c)
get f = λ x y → ++ˡ (f x y)
CBp⊆CBE⟦p⟧ (eseq q ∷ E) p CBp (CBseq CBE CBE₁ x) with CBp⊆CBE⟦p⟧ E p CBp CBE
... | (FV⊆S , FV⊆s , FV⊆x) , (BV⊆S , BV⊆s , BV⊆x) = ((λ x y → ++ˡ (FV⊆S x y)) , ((λ x → ++ˡ ∘ (FV⊆s x)) ) , get FV⊆x) , (get BV⊆S , get BV⊆s , get BV⊆x)
where
get : ∀{a b c} → a ⊆¹ b → a ⊆¹ (b ++ c)
get f = λ x y → ++ˡ (f x y)
--(λ x₁ x₂ → {!there x₂!})
CBp⊆CBE⟦p⟧ (esuspend S ∷ E) p CBp (CBsusp CBE x) with CBp⊆CBE⟦p⟧ E p CBp CBE
... | (FV⊆S , FV⊆s , FV⊆x) , BV⊆ = (((λ x y → there (FV⊆S x y)) , FV⊆s , FV⊆x)) , BV⊆
CBp⊆CBE⟦p⟧ (etrap ∷ E) p CBp (CBtrap CBE) = CBp⊆CBE⟦p⟧ E p CBp CBE
CBp⊆CBE⟦p⟧' : ∀{BVp FVp BVE FVE} E p p' → p ≐ E ⟦ p' ⟧e → CorrectBinding p' BVp FVp → CorrectBinding p BVE FVE → (FVp ⊆ FVE × BVp ⊆ BVE)
CBp⊆CBE⟦p⟧' E p p' peq cbp' cbp = CBp⊆CBE⟦p⟧ E p' cbp' (subst (λ x → CorrectBinding x _ _) (sym (unplug peq)) cbp)
inspecting-cb-distinct-double-unplug : ∀{p q Ep Eq p' q' BV FV} → CorrectBinding (p ∥ q) BV FV
→ p ≐ Ep ⟦ p' ⟧e → q ≐ Eq ⟦ q' ⟧e
→
Σ (Term × VarList × VarList)
λ {(o , BVo , FVo)
→ CorrectBinding o BVo FVo
× o ≡ (p' ∥ q')}
inspecting-cb-distinct-double-unplug{p' = p'}{q'} (CBpar CBp CBq BVp≠BVq FVp≠BVq BVp≠FVq Xp≠Xq) p=Ep⟦p'⟧ q=Eq⟦q'⟧
with CBE⟦p⟧=>CBp' p=Ep⟦p'⟧ CBp | CBE⟦p⟧=>CBp' q=Eq⟦q'⟧ CBq
... | (BVp' , FVp' , CBp') | (BVq' , FVq' , CBq')
with CBp⊆CBE⟦p⟧' _ _ _ p=Ep⟦p'⟧ CBp' CBp | CBp⊆CBE⟦p⟧' _ _ _ q=Eq⟦q'⟧ CBq' CBq
... | (FVp'⊆FVp , BVp'⊆BVp) | (FVq'⊆FVq , BVq'⊆BVq)
= (_ , _ , _) , CBpar CBp' CBq' (⊆-rep-dist-both BVp'⊆BVp BVq'⊆BVq BVp≠BVq) (⊆-rep-dist-both FVp'⊆FVp BVq'⊆BVq FVp≠BVq) (⊆-rep-dist-both BVp'⊆BVp FVq'⊆FVq BVp≠FVq) (⊆¹-rep-dist-both (proj₂ (proj₂ FVp'⊆FVp)) (proj₂ (proj₂ FVq'⊆FVq)) Xp≠Xq) , refl
where
⊆¹-rep-dist-both : ∀{a b c d} → a ⊆¹ b → c ⊆¹ d → distinct' b d → distinct' a c
⊆¹-rep-dist-both sub1 sub2 dist = λ z z₁ z₂ → dist z (sub1 z z₁) (sub2 z z₂)
⊆-rep-dist-both : ∀{a b c d} → a ⊆ b → c ⊆ d → distinct b d → distinct a c
⊆-rep-dist-both a b c = (⊆¹-rep-dist-both , ⊆¹-rep-dist-both , ⊆¹-rep-dist-both) # a # b # c
| {
"alphanum_fraction": 0.5440786984,
"avg_line_length": 67.3852691218,
"ext": "agda",
"hexsha": "b849eb6bfa42f10d960860bf5a445b8c8771cf52",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z",
"max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "florence/esterel-calculus",
"max_forks_repo_path": "agda/sn-calculus-confluence/helper.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"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": "florence/esterel-calculus",
"max_issues_repo_path": "agda/sn-calculus-confluence/helper.agda",
"max_line_length": 247,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "florence/esterel-calculus",
"max_stars_repo_path": "agda/sn-calculus-confluence/helper.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z",
"num_tokens": 11629,
"size": 23787
} |
module Fail.TupleType where
open import Haskell.Prelude
idT : ∀ {as} → Tuple as → Tuple as
idT x = x
{-# COMPILE AGDA2HS idT #-}
| {
"alphanum_fraction": 0.6691729323,
"avg_line_length": 13.3,
"ext": "agda",
"hexsha": "2a304b5c71fe08d2fc585db25227a8d490846dc4",
"lang": "Agda",
"max_forks_count": 18,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z",
"max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "seanpm2001/agda2hs",
"max_forks_repo_path": "test/Fail/TupleType.agda",
"max_issues_count": 63,
"max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6",
"max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "seanpm2001/agda2hs",
"max_issues_repo_path": "test/Fail/TupleType.agda",
"max_line_length": 34,
"max_stars_count": 55,
"max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dxts/agda2hs",
"max_stars_repo_path": "test/Fail/TupleType.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z",
"num_tokens": 44,
"size": 133
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Adjoint.Equivalents where
-- Theorems about equivalent formulations to Adjoint
-- (though some have caveats)
open import Level
open import Data.Product using (_,_; _×_)
open import Function using (_$_) renaming (_∘_ to _∙_)
open import Function.Equality using (Π; _⟶_)
import Function.Inverse as FI
open import Relation.Binary using (Rel; IsEquivalence; Setoid)
-- be explicit in imports to 'see' where the information comes from
open import Categories.Adjoint using (Adjoint; _⊣_)
open import Categories.Category.Core using (Category)
open import Categories.Category.Product using (Product; _⁂_)
open import Categories.Category.Instance.Setoids
open import Categories.Morphism
open import Categories.Functor using (Functor; _∘F_) renaming (id to idF)
open import Categories.Functor.Bifunctor using (Bifunctor)
open import Categories.Functor.Hom using (Hom[_][-,-])
open import Categories.Functor.Construction.LiftSetoids
open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper; _∘ₕ_; _∘ᵥ_; _∘ˡ_; _∘ʳ_)
renaming (id to idN)
open import Categories.NaturalTransformation.NaturalIsomorphism
using (NaturalIsomorphism; unitorˡ; unitorʳ; associator; _≃_)
import Categories.Morphism.Reasoning as MR
private
variable
o o′ o″ ℓ ℓ′ ℓ″ e e′ e″ : Level
C D E : Category o ℓ e
-- a special case of the natural isomorphism in which homsets in C and D have the same
-- universe level. therefore there is no need to lift Setoids to the same level.
-- this is helpful when combining with Yoneda lemma.
module _ {C : Category o ℓ e} {D : Category o′ ℓ e} {L : Functor C D} {R : Functor D C} where
private
module C = Category C
module D = Category D
module L = Functor L
module R = Functor R
module _ (adjoint : L ⊣ R) where
open Adjoint adjoint
-- in this case, the hom functors are naturally isomorphism directly
Hom-NI′ : NaturalIsomorphism Hom[L-,-] Hom[-,R-]
Hom-NI′ = record
{ F⇒G = ntHelper record
{ η = λ _ → Hom-inverse.to
; commute = λ _ eq → Ladjunct-comm eq
}
; F⇐G = ntHelper record
{ η = λ _ → Hom-inverse.from
; commute = λ _ eq → Radjunct-comm eq
}
; iso = λ _ → record
{ isoˡ = λ eq → let open D.HomReasoning in RLadjunct≈id ○ eq
; isoʳ = λ eq → let open C.HomReasoning in LRadjunct≈id ○ eq
}
}
-- now goes from natural isomorphism back to adjoint.
-- for simplicity, just construct the case in which homsetoids of C and D
-- are compatible.
private
Hom[L-,-] : Bifunctor C.op D (Setoids _ _)
Hom[L-,-] = Hom[ D ][-,-] ∘F (L.op ⁂ idF)
Hom[-,R-] : Bifunctor C.op D (Setoids _ _)
Hom[-,R-] = Hom[ C ][-,-] ∘F (idF ⁂ R)
module _ (Hni : NaturalIsomorphism Hom[L-,-] Hom[-,R-]) where
open NaturalIsomorphism Hni
open NaturalTransformation
open Functor
open Π
private
unitη : ∀ X → F₀ Hom[L-,-] (X , L.F₀ X) ⟶ F₀ Hom[-,R-] (X , L.F₀ X)
unitη X = ⇒.η (X , L.F₀ X)
unit : NaturalTransformation idF (R ∘F L)
unit = ntHelper record
{ η = λ X → unitη X ⟨$⟩ D.id
; commute = λ {X} {Y} f → begin
(unitη Y ⟨$⟩ D.id) ∘ f ≈⟨ introˡ R.identity ⟩
R.F₁ D.id ∘ (unitη Y ⟨$⟩ D.id) ∘ f ≈˘⟨ ⇒.commute (f , D.id) D.Equiv.refl ⟩
⇒.η (X , L.F₀ Y) ⟨$⟩ (D.id D.∘ D.id D.∘ L.F₁ f) ≈⟨ cong (⇒.η (X , L.F₀ Y)) (D.Equiv.trans D.identityˡ D.identityˡ) ⟩
⇒.η (X , L.F₀ Y) ⟨$⟩ L.F₁ f ≈⟨ cong (⇒.η (X , L.F₀ Y)) (MR.introʳ D (MR.elimʳ D L.identity)) ⟩
⇒.η (X , L.F₀ Y) ⟨$⟩ (L.F₁ f D.∘ D.id D.∘ L.F₁ id) ≈⟨ ⇒.commute (C.id , L.F₁ f) D.Equiv.refl ⟩
R.F₁ (L.F₁ f) ∘ (unitη X ⟨$⟩ D.id) ∘ id ≈⟨ refl⟩∘⟨ identityʳ ⟩
R.F₁ (L.F₁ f) ∘ (unitη X ⟨$⟩ D.id) ∎
}
where open C
open HomReasoning
open MR C
counitη : ∀ X → F₀ Hom[-,R-] (R.F₀ X , X) ⟶ F₀ Hom[L-,-] (R.F₀ X , X)
counitη X = ⇐.η (R.F₀ X , X)
counit : NaturalTransformation (L ∘F R) idF
counit = ntHelper record
{ η = λ X → counitη X ⟨$⟩ C.id
; commute = λ {X} {Y} f → begin
(counitη Y ⟨$⟩ C.id) ∘ L.F₁ (R.F₁ f) ≈˘⟨ identityˡ ⟩
id ∘ (counitη Y ⟨$⟩ C.id) ∘ L.F₁ (R.F₁ f) ≈˘⟨ ⇐.commute (R.F₁ f , D.id) C.Equiv.refl ⟩
⇐.η (R.F₀ X , Y) ⟨$⟩ (R.F₁ id C.∘ C.id C.∘ R.F₁ f) ≈⟨ cong (⇐.η (R.F₀ X , Y)) (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ) ⟩
⇐.η (R.F₀ X , Y) ⟨$⟩ R.F₁ f ≈⟨ cong (⇐.η (R.F₀ X , Y)) (MR.introʳ C C.identityˡ) ⟩
⇐.η (R.F₀ X , Y) ⟨$⟩ (R.F₁ f C.∘ C.id C.∘ C.id) ≈⟨ ⇐.commute (C.id , f) C.Equiv.refl ⟩
f ∘ (counitη X ⟨$⟩ C.id) ∘ L.F₁ C.id ≈⟨ refl⟩∘⟨ elimʳ L.identity ⟩
f ∘ (counitη X ⟨$⟩ C.id) ∎
}
where open D
open HomReasoning
open MR D
Hom-NI⇒Adjoint : L ⊣ R
Hom-NI⇒Adjoint = record
{ unit = unit
; counit = counit
; zig = λ {A} →
let open D
open HomReasoning
open Equiv
open MR D
in begin
η counit (L.F₀ A) ∘ L.F₁ (η unit A) ≈˘⟨ identityˡ ⟩
id ∘ η counit (L.F₀ A) ∘ L.F₁ (η unit A) ≈˘⟨ ⇐.commute (η unit A , id) C.Equiv.refl ⟩
⇐.η (A , L.F₀ A) ⟨$⟩ (R.F₁ id C.∘ C.id C.∘ η unit A)
≈⟨ cong (⇐.η (A , L.F₀ A)) (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ) ⟩
⇐.η (A , L.F₀ A) ⟨$⟩ η unit A ≈⟨ isoˡ refl ⟩
id
∎
; zag = λ {B} →
let open C
open HomReasoning
open Equiv
open MR C
in begin
R.F₁ (η counit B) ∘ η unit (R.F₀ B) ≈˘⟨ refl⟩∘⟨ identityʳ ⟩
R.F₁ (η counit B) ∘ η unit (R.F₀ B) ∘ id ≈˘⟨ ⇒.commute (id , η counit B) D.Equiv.refl ⟩
⇒.η (R.F₀ B , B) ⟨$⟩ (η counit B D.∘ D.id D.∘ L.F₁ id)
≈⟨ cong (⇒.η (R.F₀ B , B)) (MR.elimʳ D (MR.elimʳ D L.identity)) ⟩
⇒.η (R.F₀ B , B) ⟨$⟩ η counit B ≈⟨ isoʳ refl ⟩
id ∎
}
where module i {X} = Iso (iso X)
open i
-- the general case from isomorphic Hom setoids to adjoint functors
module _ {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {L : Functor C D} {R : Functor D C} where
private
module C = Category C
module D = Category D
module L = Functor L
module R = Functor R
open Functor
open Π
Hom[L-,-] : Bifunctor C.op D (Setoids _ _)
Hom[L-,-] = LiftSetoids ℓ e ∘F Hom[ D ][-,-] ∘F (L.op ⁂ idF)
Hom[-,R-] : Bifunctor C.op D (Setoids _ _)
Hom[-,R-] = LiftSetoids ℓ′ e′ ∘F Hom[ C ][-,-] ∘F (idF ⁂ R)
module _ (Hni : Hom[L-,-] ≃ Hom[-,R-]) where
open NaturalIsomorphism Hni using (module ⇒; module ⇐; iso)
private
unitη : ∀ X → F₀ Hom[L-,-] (X , L.F₀ X) ⟶ F₀ Hom[-,R-] (X , L.F₀ X)
unitη X = ⇒.η (X , L.F₀ X)
unit : NaturalTransformation idF (R ∘F L)
unit = ntHelper record
{ η = λ X → lower (unitη X ⟨$⟩ lift D.id)
; commute = λ {X Y} f → begin
lower (unitη Y ⟨$⟩ lift D.id) ∘ f
≈⟨ introˡ R.identity ⟩
R.F₁ D.id ∘ lower (unitη Y ⟨$⟩ lift D.id) ∘ f
≈˘⟨ lower (⇒.commute (f , D.id) (lift D.Equiv.refl)) ⟩
lower (⇒.η (X , L.F₀ Y) ⟨$⟩ lift (D.id D.∘ D.id D.∘ L.F₁ f))
≈⟨ lower (cong (⇒.η (X , L.F₀ Y)) (lift (D.Equiv.trans D.identityˡ D.identityˡ))) ⟩
lower (⇒.η (X , L.F₀ Y) ⟨$⟩ lift (L.F₁ f))
≈⟨ lower (cong (⇒.η (X , L.F₀ Y)) (lift (MR.introʳ D (MR.elimʳ D L.identity)))) ⟩
lower (⇒.η (X , L.F₀ Y) ⟨$⟩ lift (L.F₁ f D.∘ D.id D.∘ L.F₁ id))
≈⟨ lower (⇒.commute (C.id , L.F₁ f) (lift D.Equiv.refl)) ⟩
R.F₁ (L.F₁ f) ∘ lower (⇒.η (X , L.F₀ X) ⟨$⟩ lift D.id) ∘ id
≈⟨ refl⟩∘⟨ identityʳ ⟩
F₁ (R ∘F L) f ∘ lower (unitη X ⟨$⟩ lift D.id) ∎
}
where open C
open HomReasoning
open MR C
counitη : ∀ X → F₀ Hom[-,R-] (R.F₀ X , X) ⟶ F₀ Hom[L-,-] (R.F₀ X , X)
counitη X = ⇐.η (R.F₀ X , X)
counit : NaturalTransformation (L ∘F R) idF
counit = ntHelper record
{ η = λ X → lower (counitη X ⟨$⟩ lift C.id)
; commute = λ {X} {Y} f → begin
lower (⇐.η (R.F₀ Y , Y) ⟨$⟩ lift C.id) ∘ L.F₁ (R.F₁ f)
≈˘⟨ identityˡ ⟩
id ∘ lower (⇐.η (R.F₀ Y , Y) ⟨$⟩ lift C.id) ∘ L.F₁ (R.F₁ f)
≈˘⟨ lower (⇐.commute (R.F₁ f , D.id) (lift C.Equiv.refl)) ⟩
lower (⇐.η (R.F₀ X , Y) ⟨$⟩ lift (R.F₁ id C.∘ C.id C.∘ R.F₁ f))
≈⟨ lower (cong (⇐.η (R.F₀ X , Y)) (lift (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ))) ⟩
lower (⇐.η (R.F₀ X , Y) ⟨$⟩ lift (R.F₁ f))
≈⟨ lower (cong (⇐.η (R.F₀ X , Y)) (lift (MR.introʳ C C.identityˡ))) ⟩
lower (⇐.η (R.F₀ X , Y) ⟨$⟩ lift (R.F₁ f C.∘ C.id C.∘ C.id))
≈⟨ lower (⇐.commute (C.id , f) (lift C.Equiv.refl)) ⟩
f ∘ lower (⇐.η (R.F₀ X , X) ⟨$⟩ lift C.id) ∘ L.F₁ C.id
≈⟨ refl⟩∘⟨ elimʳ L.identity ⟩
f ∘ lower (⇐.η (R.F₀ X , X) ⟨$⟩ lift C.id)
∎
}
where open D
open HomReasoning
open MR D
Hom-NI′⇒Adjoint : L ⊣ R
Hom-NI′⇒Adjoint = record
{ unit = unit
; counit = counit
; zig = λ {A} →
let open D
open HomReasoning
open Equiv
open MR D
in begin
lower (counitη (L.F₀ A) ⟨$⟩ lift C.id) ∘ L.F₁ (η unit A)
≈˘⟨ identityˡ ⟩
id ∘ lower (counitη (L.F₀ A) ⟨$⟩ lift C.id) ∘ L.F₁ (η unit A)
≈˘⟨ lower (⇐.commute (η unit A , id) (lift C.Equiv.refl)) ⟩
lower (⇐.η (A , L.F₀ A) ⟨$⟩ lift (R.F₁ id C.∘ C.id C.∘ lower (⇒.η (A , L.F₀ A) ⟨$⟩ lift id)))
≈⟨ lower (cong (⇐.η (A , L.F₀ A)) (lift (C.Equiv.trans (MR.elimˡ C R.identity) C.identityˡ))) ⟩
lower (⇐.η (A , L.F₀ A) ⟨$⟩ (⇒.η (A , L.F₀ A) ⟨$⟩ lift id))
≈⟨ lower (isoˡ (lift refl)) ⟩
id ∎
; zag = λ {B} →
let open C
open HomReasoning
open Equiv
open MR C
in begin
R.F₁ (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id)) ∘ lower (⇒.η (R.F₀ B , L.F₀ (R.F₀ B)) ⟨$⟩ lift D.id)
≈˘⟨ refl⟩∘⟨ identityʳ ⟩
R.F₁ (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id)) ∘ lower (⇒.η (R.F₀ B , L.F₀ (R.F₀ B)) ⟨$⟩ lift D.id) ∘ id
≈˘⟨ lower (⇒.commute (id , η counit B) (lift D.Equiv.refl)) ⟩
lower (⇒.η (R.F₀ B , B) ⟨$⟩ lift (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id) D.∘ D.id D.∘ L.F₁ id))
≈⟨ lower (cong (⇒.η (R.F₀ B , B)) (lift (MR.elimʳ D (MR.elimʳ D L.identity)))) ⟩
lower (⇒.η (R.F₀ B , B) ⟨$⟩ lift (lower (⇐.η (R.F₀ B , B) ⟨$⟩ lift id)))
≈⟨ lower (isoʳ (lift refl)) ⟩
id ∎
}
where open NaturalTransformation
module _ {X} where
open Iso (iso X) public
| {
"alphanum_fraction": 0.48819733,
"avg_line_length": 43.0076045627,
"ext": "agda",
"hexsha": "7577ee37659e5c9040218bf50c349198287ea273",
"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/Adjoint/Equivalents.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/Adjoint/Equivalents.agda",
"max_line_length": 141,
"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/Adjoint/Equivalents.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": 4453,
"size": 11311
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Groups.DirectSum.Definition
open import Setoids.Setoids
open import Rings.Definition
module Rings.DirectSum {a b c d : _} {A : Set a} {S : Setoid {a} {b} A} {_+1_ : A → A → A} {_*1_ : A → A → A} {C : Set c} {T : Setoid {c} {d} C} {_+2_ : C → C → C} {_*2_ : C → C → C} (R1 : Ring S _+1_ _*1_) (R2 : Ring T _+2_ _*2_) where
open import Setoids.Product S T
pairPlus : A && C → A && C → A && C
pairPlus (a ,, b) (c ,, d) = (a +1 c) ,, (b +2 d)
pairTimes : A && C → A && C → A && C
pairTimes (a ,, b) (c ,, d) = (a *1 c) ,, (b *2 d)
directSumRing : Ring productSetoid pairPlus pairTimes
Ring.additiveGroup directSumRing = directSumGroup (Ring.additiveGroup R1) (Ring.additiveGroup R2)
Ring.*WellDefined directSumRing r=t s=u = productLift (Ring.*WellDefined R1 (_&&_.fst r=t) (_&&_.fst s=u)) (Ring.*WellDefined R2 (_&&_.snd r=t) (_&&_.snd s=u))
Ring.1R directSumRing = Ring.1R R1 ,, Ring.1R R2
Ring.groupIsAbelian directSumRing = productLift (Ring.groupIsAbelian R1) (Ring.groupIsAbelian R2)
Ring.*Associative directSumRing = productLift (Ring.*Associative R1) (Ring.*Associative R2)
Ring.*Commutative directSumRing = productLift (Ring.*Commutative R1) (Ring.*Commutative R2)
Ring.*DistributesOver+ directSumRing = productLift (Ring.*DistributesOver+ R1) (Ring.*DistributesOver+ R2)
Ring.identIsIdent directSumRing = productLift (Ring.identIsIdent R1) (Ring.identIsIdent R2)
| {
"alphanum_fraction": 0.6811989101,
"avg_line_length": 52.4285714286,
"ext": "agda",
"hexsha": "edcc63954904aa07fed01286450fa5446055269b",
"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": "Rings/DirectSum.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": "Rings/DirectSum.agda",
"max_line_length": 236,
"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": "Rings/DirectSum.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": 522,
"size": 1468
} |
{-# OPTIONS --without-K #-}
open import Prelude
import GSeTT.Typed-Syntax
import Globular-TT.Syntax
import Globular-TT.Rules
module Globular-TT.Globular-TT {l} (index : Set l) (rule : index → GSeTT.Typed-Syntax.Ctx × (Globular-TT.Syntax.Pre-Ty index))
(assumption : Globular-TT.Rules.well-founded index rule)
(eqdec-index : eqdec index)
where
open import Globular-TT.Syntax index
open import Globular-TT.Eqdec-syntax index eqdec-index
open import Globular-TT.Rules index rule
open import Globular-TT.CwF-Structure index rule
open import Globular-TT.Uniqueness-Derivations index rule eqdec-index
open import Globular-TT.Disks index rule eqdec-index
open import Globular-TT.Typed-Syntax index rule eqdec-index
open import Globular-TT.Dec-Type-Checking index rule assumption eqdec-index
| {
"alphanum_fraction": 0.6558577406,
"avg_line_length": 45.5238095238,
"ext": "agda",
"hexsha": "871126fef253e24d8d90e990dda998f5f9b92782",
"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": "ed45935b38d6a86fa662f561866140122ee3dcef",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ThiBen/catt-formalization",
"max_forks_repo_path": "Globular-TT/Globular-TT.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ed45935b38d6a86fa662f561866140122ee3dcef",
"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": "ThiBen/catt-formalization",
"max_issues_repo_path": "Globular-TT/Globular-TT.agda",
"max_line_length": 126,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thibautbenjamin/catt-formalization",
"max_stars_repo_path": "Globular-TT/Globular-TT.agda",
"max_stars_repo_stars_event_max_datetime": "2020-05-20T00:41:09.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-01T08:26:53.000Z",
"num_tokens": 230,
"size": 956
} |
-- {-# OPTIONS -v interaction:50 #-}
x : Set → Set
x = {!λ x → x!}
-- "refine" (C-c C-r) should behave the same as "give" here
-- Old, bad result:
-- x = λ x₁ → x₁
-- New, expected result:
-- x = λ x → x
-- Expected interaction test case behavior:
--
-- (agda2-give-action 0 'no-paren)
| {
"alphanum_fraction": 0.5773195876,
"avg_line_length": 19.4,
"ext": "agda",
"hexsha": "f82906722517a86578b6151591f3580cb09e6660",
"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/Issue994.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/Issue994.agda",
"max_line_length": 59,
"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/Issue994.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": 100,
"size": 291
} |
module Luau.Type where
data Type : Set where
nil : Type
_⇒_ : Type → Type → Type
none : Type
any : Type
_∪_ : Type → Type → Type
_∩_ : Type → Type → Type
| {
"alphanum_fraction": 0.5892857143,
"avg_line_length": 15.2727272727,
"ext": "agda",
"hexsha": "8da3a985f93f5e07086c03afa6a6f0b6a6186324",
"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": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "FreakingBarbarians/luau",
"max_forks_repo_path": "prototyping/Luau/Type.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"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": "FreakingBarbarians/luau",
"max_issues_repo_path": "prototyping/Luau/Type.agda",
"max_line_length": 26,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FreakingBarbarians/luau",
"max_stars_repo_path": "prototyping/Luau/Type.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-11T21:30:17.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-11T21:30:17.000Z",
"num_tokens": 64,
"size": 168
} |
------------------------------------------------------------------------------
-- FOCT list terms properties
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Base.List.PropertiesATP where
open import FOTC.Base
open import FOTC.Base.List
------------------------------------------------------------------------------
-- Congruence properties
postulate ∷-leftCong : ∀ {x y xs} → x ≡ y → x ∷ xs ≡ y ∷ xs
{-# ATP prove ∷-leftCong #-}
postulate ∷-rightCong : ∀ {x xs ys} → xs ≡ ys → x ∷ xs ≡ x ∷ ys
{-# ATP prove ∷-rightCong #-}
postulate ∷-Cong : ∀ {x y xs ys} → x ≡ y → xs ≡ ys → x ∷ xs ≡ y ∷ ys
{-# ATP prove ∷-Cong #-}
postulate headCong : ∀ {xs ys} → xs ≡ ys → head₁ xs ≡ head₁ ys
{-# ATP prove headCong #-}
postulate tailCong : ∀ {xs ys} → xs ≡ ys → tail₁ xs ≡ tail₁ ys
{-# ATP prove tailCong #-}
------------------------------------------------------------------------------
-- Injective properties
postulate ∷-injective : ∀ {x y xs ys} → x ∷ xs ≡ y ∷ ys → x ≡ y ∧ xs ≡ ys
{-# ATP prove ∷-injective #-}
| {
"alphanum_fraction": 0.4219512195,
"avg_line_length": 32.3684210526,
"ext": "agda",
"hexsha": "348efacd28c3e80214bd09d418ee339fdd6a87ef",
"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": "src/fot/FOTC/Base/List/PropertiesATP.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": "src/fot/FOTC/Base/List/PropertiesATP.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": "src/fot/FOTC/Base/List/PropertiesATP.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": 316,
"size": 1230
} |
module 030-semigroup where
-- We need equivalence.
open import 020-equivalence
-- Semigroups are basically a set with equality and some binary
-- operator which is associative and respects equality.
record SemiGroup
{M : Set}
(_==_ : M -> M -> Set)
(_*_ : M -> M -> M)
: Set1 where
field
equiv : Equivalence _==_
assoc : ∀ {r s t} -> ((r * s) * t) == (r * (s * t))
cong : ∀ {r s u v} -> (r == s) -> (u == v) -> (r * u) == (s * v)
-- The next line brings all fields and declarations of Equivalence
-- into this record's namespace so we can refer to them in an
-- unqualified way in proofs (for example, we can write "refl" for
-- "Equivalence.symm equiv" and so on).
open Equivalence equiv public
-- No theorems here yet.
| {
"alphanum_fraction": 0.6186107471,
"avg_line_length": 26.3103448276,
"ext": "agda",
"hexsha": "38e65ddf8b5cfa869a5dc916239b944440ec16ac",
"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": "76fe404b25210258810641cc6807feecf0ff8d6c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mcmtroffaes/agda-proofs",
"max_forks_repo_path": "030-semigroup.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c",
"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": "mcmtroffaes/agda-proofs",
"max_issues_repo_path": "030-semigroup.agda",
"max_line_length": 68,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "76fe404b25210258810641cc6807feecf0ff8d6c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mcmtroffaes/agda-proofs",
"max_stars_repo_path": "030-semigroup.agda",
"max_stars_repo_stars_event_max_datetime": "2016-08-17T16:15:42.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-09T22:51:55.000Z",
"num_tokens": 230,
"size": 763
} |
{-# OPTIONS --sized-types #-}
open import Relation.Binary.Core
module SOList.Total.Properties {A : Set}
(_≤_ : A → A → Set)
(trans≤ : Transitive _≤_) where
open import Bound.Total A
open import Bound.Total.Order _≤_
open import Bound.Total.Order.Properties _≤_ trans≤
open import List.Order.Bounded _≤_
open import List.Order.Bounded.Properties _≤_ trans≤
open import List.Sorted _≤_
open import Size
open import SOList.Total _≤_
lemma-solist≤ : {ι : Size}{b t : Bound} → SOList {ι} b t → LeB b t
lemma-solist≤ (onil b≤t) = b≤t
lemma-solist≤ (ocons x xs ys) = transLeB (lemma-solist≤ xs) (lemma-solist≤ ys)
lemma-solist≤* : {ι : Size}{b : Bound}{x : A} → (xs : SOList {ι} b (val x)) → forget xs ≤* (val x)
lemma-solist≤* (onil _) = lenx
lemma-solist≤* (ocons x xs ys) = lemma-++≤* (lemma-solist≤ ys) (lemma-solist≤* xs) (lemma-solist≤* ys)
lemma-solist*≤ : {ι : Size}{b t : Bound} → (xs : SOList {ι} b t) → b *≤ forget xs
lemma-solist*≤ (onil _) = genx
lemma-solist*≤ (ocons x xs ys) = lemma-++*≤ (lemma-solist≤ xs) (lemma-solist*≤ xs) (lemma-solist*≤ ys)
lemma-solist-sorted : {ι : Size}{b t : Bound}(xs : SOList {ι} b t) → Sorted (forget xs)
lemma-solist-sorted (onil _) = nils
lemma-solist-sorted (ocons x xs ys) = lemma-sorted++ (lemma-solist≤* xs) (lemma-solist*≤ ys) (lemma-solist-sorted xs) (lemma-solist-sorted ys)
| {
"alphanum_fraction": 0.6444769568,
"avg_line_length": 37.9722222222,
"ext": "agda",
"hexsha": "f94618406025c1ea958cfa475757dc26d354579f",
"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": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/SOList/Total/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"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": "bgbianchi/sorting",
"max_issues_repo_path": "agda/SOList/Total/Properties.agda",
"max_line_length": 142,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/SOList/Total/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 506,
"size": 1367
} |
module test.AddInteger where
open import Type
open import Declarative
open import Builtin
open import Builtin.Constant.Type
open import Builtin.Constant.Term Ctx⋆ Kind * # _⊢⋆_ con size⋆
open import Agda.Builtin.Sigma
-- zerepoch/zerepoch-core/test/data/addInteger.plc
addI : ∀{Γ} →
Γ ⊢ con integer (size⋆ 8) ⇒ con integer (size⋆ 8) ⇒ con integer (size⋆ 8)
addI =
ƛ (ƛ (builtin addInteger (λ { Z → size⋆ 8 ; (S ())}) (` (S Z) Σ., ` Z Σ., _)))
| {
"alphanum_fraction": 0.68,
"avg_line_length": 28.125,
"ext": "agda",
"hexsha": "7cbf8000ab8ca91c9e2fbe658074d9b8a1489536",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-02-21T16:38:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-13T21:25:19.000Z",
"max_forks_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "Quantum-One-DLT/zerepoch",
"max_forks_repo_path": "zerepoch-metatheory/test/AddInteger.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177",
"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": "Quantum-One-DLT/zerepoch",
"max_issues_repo_path": "zerepoch-metatheory/test/AddInteger.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c8cf4619e6e496930c9092cf6d64493eff300177",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "Quantum-One-DLT/zerepoch",
"max_stars_repo_path": "zerepoch-metatheory/test/AddInteger.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 173,
"size": 450
} |
-- {-# OPTIONS -v tc.proj.like:10 #-} {-# OPTIONS -v tc.conv:10 #-}
import Common.Level
module ProjectionLikeAndModules1 (A : Set) (a : A) where
record ⊤ : Set where
constructor tt
data Wrap (W : Set) : Set where
wrap : W → Wrap W
data Bool : Set where
true false : Bool
-- `or' should be projection like in the module parameters
if : Bool → {B : Set} → B → B → B
if true a b = a
if false a b = b
postulate
u v : ⊤
P : Wrap ⊤ -> Set
test : (y : Bool)
-> P (if y (wrap u) (wrap tt))
-> P (if y (wrap tt) (wrap v))
test y h = h
-- Error:
-- u != tt of type Set
-- when checking that the expression h has type
-- P (if y (wrap tt) (wrap v))
| {
"alphanum_fraction": 0.5930408472,
"avg_line_length": 20.0303030303,
"ext": "agda",
"hexsha": "524e8ec8405264df078464f0aacc05c6b2fbf527",
"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/ProjectionLikeAndModules1.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/ProjectionLikeAndModules1.agda",
"max_line_length": 67,
"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/ProjectionLikeAndModules1.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": 225,
"size": 661
} |
open import Everything
module Test.SurjidentityP where
module _
{𝔬₁} {𝔒₁ : Ø 𝔬₁}
{𝔯₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁)
{𝔬₂} {𝔒₂ : Ø 𝔬₂}
{𝔯₂} (_∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂)
(_∼₂2_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂)
{𝔯₂'} (_∼₂'_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂')
{ℓ₂} (_∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂)
(_∼̇₂'_ : ∀ {x y} → x ∼₂' y → x ∼₂' y → Ø ℓ₂)
(_∼̇₂2_ : ∀ {x y} → x ∼₂2 y → x ∼₂2 y → Ø ℓ₂)
⦃ _ : Surjection.class 𝔒₁ 𝔒₂ ⦄
⦃ _ : Smap!.class _∼₁_ _∼₂_ ⦄
⦃ _ : Smap!.class _∼₁_ _∼₂'_ ⦄
⦃ _ : Smap!.class _∼₁_ _∼₂2_ ⦄
⦃ _ : Reflexivity.class _∼₁_ ⦄
⦃ _ : Reflexivity.class _∼₂_ ⦄
⦃ _ : Reflexivity.class _∼₂'_ ⦄
⦃ _ : Reflexivity.class _∼₂2_ ⦄
⦃ _ : Surjidentity!.class _∼₁_ _∼₂_ _∼̇₂_ ⦄
⦃ _ : Surjidentity!.class _∼₁_ _∼₂'_ _∼̇₂'_ ⦄
⦃ _ : Surjidentity!.class _∼₁_ _∼₂2_ _∼̇₂2_ ⦄
where
test-surj : Surjidentity!.type _∼₁_ _∼₂_ _∼̇₂_
test-surj = surjidentity
test-surj[] : Surjidentity!.type _∼₁_ _∼₂_ _∼̇₂_
test-surj[] = surjidentity[ _∼₁_ , _∼̇₂_ ]
| {
"alphanum_fraction": 0.4023529412,
"avg_line_length": 37.5,
"ext": "agda",
"hexsha": "418d5c59e9d71912c141b7f7720e4a8dd31d0b99",
"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/Test/SurjidentityP.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/Test/SurjidentityP.agda",
"max_line_length": 70,
"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/Test/SurjidentityP.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 637,
"size": 1275
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Definitions where
open import Cubical.Core.Everything
open import Cubical.Relation.Binary
open import Cubical.Data.Sigma using (_×_)
open import Cubical.Data.Sum using (_⊎_)
open import Cubical.HITs.PropositionalTruncation using (∥_∥)
open import Cubical.Algebra.Base
private
variable
a b c ℓ : Level
A : Type a
B : Type b
C : Type c
------------------------------------------------------------------------
-- Properties of operations
Congruent₁ : Rel A ℓ → Op₁ A → Type _
Congruent₁ R f = f Preserves R ⟶ R
Congruent₂ : Rel A ℓ → Op₂ A → Type _
Congruent₂ R • = • Preserves₂ R ⟶ R ⟶ R
LeftCongruent : Rel A ℓ → Op₂ A → Type _
LeftCongruent R _•_ = ∀ {x} → (x •_) Preserves R ⟶ R
RightCongruent : Rel A ℓ → Op₂ A → Type _
RightCongruent R _•_ = ∀ {x} → (_• x) Preserves R ⟶ R
Homomorphic₀ : (A → B) → A → B → Type _
Homomorphic₀ ⟦_⟧ x y = ⟦ x ⟧ ≡ y
Homomorphic₁ : (A → B) → Op₁ A → Op₁ B → Type _
Homomorphic₁ ⟦_⟧ f g = ∀ x → ⟦ f x ⟧ ≡ g ⟦ x ⟧
Homomorphic₂ : (A → B) → Op₂ A → Op₂ B → Type _
Homomorphic₂ ⟦_⟧ _•_ _◦_ = ∀ x y → ⟦ x • y ⟧ ≡ ⟦ x ⟧ ◦ ⟦ y ⟧
Contramorphic₂ : (A → B) → Op₂ A → Op₂ B → Type _
Contramorphic₂ ⟦_⟧ _•_ _◦_ = ∀ x y → ⟦ x • y ⟧ ≡ ⟦ y ⟧ ◦ ⟦ x ⟧
Associative : Op₂ A → Type _
Associative _•_ = ∀ x y z → (x • y) • z ≡ x • (y • z)
Commutative : Op₂ A → Type _
Commutative _•_ = ∀ x y → x • y ≡ y • x
LeftIdentity : A → Opₗ A B → Type _
LeftIdentity e _•_ = ∀ x → e • x ≡ x
RightIdentity : A → Opᵣ A B → Type _
RightIdentity e _•_ = ∀ x → x • e ≡ x
Identity : A → Op₂ A → Type _
Identity e • = (LeftIdentity e •) × (RightIdentity e •)
LeftZero : A → Opᵣ B A → Type _
LeftZero z _•_ = ∀ x → z • x ≡ z
RightZero : A → Opₗ B A → Type _
RightZero z _•_ = ∀ x → x • z ≡ z
Zero : A → Op₂ A → Type _
Zero z • = (LeftZero z •) × (RightZero z •)
LeftInverse : C → (A → B) → (B → A → C) → Type _
LeftInverse e _⁻¹ _•_ = ∀ x → (x ⁻¹) • x ≡ e
RightInverse : C → (A → B) → (A → B → C) → Type _
RightInverse e _⁻¹ _•_ = ∀ x → x • (x ⁻¹) ≡ e
Inverse : A → Op₁ A → Op₂ A → Type _
Inverse e ⁻¹ • = (LeftInverse e ⁻¹ •) × (RightInverse e ⁻¹ •)
LeftConical : B → Opᵣ A B → Type _
LeftConical e _•_ = ∀ x y → x • y ≡ e → x ≡ e
RightConical : B → Opₗ A B → Type _
RightConical e _•_ = ∀ x y → x • y ≡ e → y ≡ e
Conical : A → Op₂ A → Type _
Conical e • = (LeftConical e •) × (RightConical e •)
_DistributesOverˡ_ : Opₗ A B → Op₂ B → Type _
_*_ DistributesOverˡ _+_ =
∀ x y z → (x * (y + z)) ≡ ((x * y) + (x * z))
_DistributesOverʳ_ : Opᵣ A B → Op₂ B → Type _
_*_ DistributesOverʳ _+_ =
∀ x y z → ((y + z) * x) ≡ ((y * x) + (z * x))
_DistributesOver_ : Op₂ A → Op₂ A → Type _
* DistributesOver + = (* DistributesOverˡ +) × (* DistributesOverʳ +)
_IdempotentOn_ : Op₂ A → A → Type _
_•_ IdempotentOn x = (x • x) ≡ x
Idempotent : Op₂ A → Type _
Idempotent • = ∀ x → • IdempotentOn x
IdempotentFun : Op₁ A → Type _
IdempotentFun f = ∀ x → f (f x) ≡ f x
Selective : Op₂ A → Type _
Selective _•_ = ∀ x y → ∥ (x • y ≡ x) ⊎ (x • y ≡ y) ∥
_Absorbs_ : Op₂ A → Op₂ A → Type _
_∧_ Absorbs _∨_ = ∀ x y → (x ∧ (x ∨ y)) ≡ x
Absorptive : Op₂ A → Op₂ A → Type _
Absorptive ∧ ∨ = (∧ Absorbs ∨) × (∨ Absorbs ∧)
Involutive : Op₁ A → Type _
Involutive f = ∀ x → f (f x) ≡ x
LeftCancellative : (A → B → C) → Type _
LeftCancellative _•_ = ∀ x {y z} → (x • y) ≡ (x • z) → y ≡ z
RightCancellative : (A → B → C) → Type _
RightCancellative _•_ = ∀ {x y} z → (x • z) ≡ (y • z) → x ≡ y
Cancellative : (A → A → B) → Type _
Cancellative • = (LeftCancellative •) × (RightCancellative •)
Interchangeable : Op₂ A → Op₂ A → Type _
Interchangeable _•_ _◦_ = ∀ w x y z → ((w • x) ◦ (y • z)) ≡ ((w ◦ y) • (x ◦ z))
| {
"alphanum_fraction": 0.556244942,
"avg_line_length": 28.2977099237,
"ext": "agda",
"hexsha": "e8db90c242593ea31627fbe0c3f24d67f1afc18b",
"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": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bijan2005/univalent-foundations",
"max_forks_repo_path": "Cubical/Algebra/Definitions.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"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": "bijan2005/univalent-foundations",
"max_issues_repo_path": "Cubical/Algebra/Definitions.agda",
"max_line_length": 79,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bijan2005/univalent-foundations",
"max_stars_repo_path": "Cubical/Algebra/Definitions.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1553,
"size": 3707
} |
{-# OPTIONS --rewriting #-}
module Luau.Heap where
open import Agda.Builtin.Equality using (_≡_; refl)
open import FFI.Data.Maybe using (Maybe; just; nothing)
open import FFI.Data.Vector using (Vector; length; snoc; empty; lookup-snoc-not)
open import Luau.Addr using (Addr; _≡ᴬ_)
open import Luau.Var using (Var)
open import Luau.Syntax using (Block; Expr; Annotated; FunDec; nil; function_is_end)
open import Properties.Equality using (_≢_; trans)
open import Properties.Remember using (remember; _,_)
open import Properties.Dec using (yes; no)
-- Heap-allocated objects
data Object (a : Annotated) : Set where
function_is_end : FunDec a → Block a → Object a
Heap : Annotated → Set
Heap a = Vector (Object a)
data _≡_⊕_↦_ {a} : Heap a → Heap a → Addr → Object a → Set where
defn : ∀ {H val} →
-----------------------------------
(snoc H val) ≡ H ⊕ (length H) ↦ val
_[_] : ∀ {a} → Heap a → Addr → Maybe (Object a)
_[_] = FFI.Data.Vector.lookup
∅ : ∀ {a} → Heap a
∅ = empty
data AllocResult a (H : Heap a) (V : Object a) : Set where
ok : ∀ b H′ → (H′ ≡ H ⊕ b ↦ V) → AllocResult a H V
alloc : ∀ {a} H V → AllocResult a H V
alloc H V = ok (length H) (snoc H V) defn
next : ∀ {a} → Heap a → Addr
next = length
allocated : ∀ {a} → Heap a → Object a → Heap a
allocated = snoc
lookup-not-allocated : ∀ {a} {H H′ : Heap a} {b c O} → (H′ ≡ H ⊕ b ↦ O) → (c ≢ b) → (H [ c ] ≡ H′ [ c ])
lookup-not-allocated {H = H} {O = O} defn p = lookup-snoc-not O H p
| {
"alphanum_fraction": 0.6177868296,
"avg_line_length": 29.46,
"ext": "agda",
"hexsha": "713b0a1aea19f35a8121f5ab0dec50fd337fa8c9",
"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/Luau/Heap.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/Luau/Heap.agda",
"max_line_length": 104,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "TheGreatSageEqualToHeaven/luau",
"max_stars_repo_path": "prototyping/Luau/Heap.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z",
"num_tokens": 499,
"size": 1473
} |
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Paths
open import lib.types.Pi
open import lib.types.Unit
open import lib.types.Nat
open import lib.types.TLevel
open import lib.types.Pointed
open import lib.types.Sigma
open import lib.NType2
open import lib.types.PathSeq
open import nicolai.pseudotruncations.Liblemmas
open import nicolai.pseudotruncations.SeqColim
{- The main work is done in two separate files.
The first defines some general lemmas
and constructs what is overline(i) in the paper.
The second is the 'heptagon-argument', a very
tedious calculation with paths, which constructs
what is overline(g) in the paper -- the coherence
laws for overline (i). -}
open import nicolai.pseudotruncations.wconst-preparation
open import nicolai.pseudotruncations.heptagon
module nicolai.pseudotruncations.wconstSequence where
{- As a first step, assume we are given a weakly constant
sequence with an inhabitant of the first type. -}
module _ {i} {C : Sequence {i}} (wc : wconst-chain C) (a₀ : fst C O) where
{- We want to show that the colimit of this sequence is
contractible.
The heart of the argument are the definitions of the data
that is needed in order to apply the induction principle
of the sequential colimit.
We call these î and ĝ. They are not constructed here, but
in two separate files; the construction of ĝ is very tedious.
Here, we just load them from the files where they are defined.
-}
{- First, some preliminary lemmas and the definition of î,
defined in the following module: -}
open wconst-init {i} {C} wc a₀
î : (n : ℕ) → (a : A n) → (ins {C = C} n a) =-= (ins O a₀)
î = î-def
{- from î, we get the 'real' overline(i) just by applying ↯,
i.e. by getting the path out of the sequence î -}
ins-n-O : (n : ℕ) → (a : A n) → ins {C = C} n a == ins O a₀
ins-n-O n a = ↯ (î-def n a)
{- The difficult part is ĝ, in the paper called 'overline(g)'.
It is defined in heptagon.agda and just loaded here. -}
ĝ : (n : ℕ) → (a : A n)
→ (↯ ((î (S n) (f n a)) ⋯ (‼ (î n a) ⋯ toSeq (glue n a)))) == idp
ĝ n a = ĝ-def wc a₀ n a
-- from ĝ, we should be able to get this postulate:
postulate
ins-glue-coh : (n : ℕ) (a : A n)
→ ins-n-O (S n) (f n a) ∙ ! (ins-n-O n a) ∙ glue n a == idp
-- ins-glue-coh n a = {!ins-n-O n a !} -- {!ĝ n a!}
{- Now, we define the 'real' overline(g) from the text;
this is just the 'unwrapped' version of ĝ, and not much happens
here!
All we are doing is showing that commutativity of the 'triangle'
is really enough. The hard part is the commutativity of the
'triangle' which, is shown via commutativity of the 'heptagon',
which we have already done! -}
glue-n-O : (n : ℕ) (a : A n)
→ (ins-n-O n a)
==
(ins-n-O (S n) (f n a)) [ (λ w → w == ins O a₀) ↓ glue n a ]
glue-n-O n a = from-transp _ (glue n a)
-- now, let use calculate...
(transport (λ w → w == ins O a₀) (glue n a) (ins-n-O n a)
-- we use the version of trans-ap where the second function is constant
=⟨ trans-ap₁ (idf _) (ins O a₀) (glue n a) (ins-n-O n a) ⟩
! (ap (idf _) (glue n a)) ∙ (ins-n-O n a)
=⟨ ap (λ p → (! p) ∙ (ins-n-O n a)) (ap-idf (glue n a)) ⟩
! (glue n a) ∙ (ins-n-O n a)
-- we use the adhoc lemma to 're-order' paths
=⟨ ! (adhoc-lemma (ins-n-O (S n) (f n a)) (ins-n-O n a) (glue n a) (ins-glue-coh n a)) ⟩
ins-n-O (S n) (f n a)
∎)
-- We combine 'overline(i)' and 'overline(g)' to conclude:
equal-n-O : (w : SC) → w == ins O a₀
equal-n-O = SeqCo-ind ins-n-O glue-n-O
-- Thus, the sequential colimit is contractible:
SC-contr : is-contr SC
SC-contr = ins O a₀ , (λ w → ! (equal-n-O w))
{- This completes the proof that the sequential colimit of a weakly constant
sequence with *inhabited first type* is contractible.
Let us now work with general weakly constant sequences again.
First, let us now show that removing the first map from a weakly constant sequence
gives a weakly constant sequence.
Then, we show that we can remove any finite initial sequence.
Of course, this is trivial; the conclusion of the statement asks for weak
constancy of nearly all of the maps, while the assumption gives weak constancy
of all maps. -}
removeFst-preserves-wconst : ∀ {i} → (C : Sequence {i}) → wconst-chain C → wconst-chain (removeFst C)
removeFst-preserves-wconst C wc n = wc (S n)
removeInit-preserves-wconst : ∀ {i} → (C : Sequence {i}) → (n : ℕ) → wconst-chain C → wconst-chain (removeInit C n)
removeInit-preserves-wconst C O wc = wc
removeInit-preserves-wconst C (S n) wc =
removeInit-preserves-wconst (removeFst C) n
(removeFst-preserves-wconst C wc)
{- THE FIRST MAIN RESULT:
the colimit of a weakly constant sequence is propositional. -}
wconst-prop : ∀ {i} → (C : Sequence {i}) → wconst-chain C → is-prop (SeqCo C)
wconst-prop C wc = inhab-to-contr-is-prop (SeqCo-rec wc-prp-ins automatic) where
A = fst C
f = snd C
wc-prp-ins : (n : ℕ) → A n → is-contr (SeqCo C)
wc-prp-ins n a = equiv-preserves-level {n = ⟨-2⟩} (ignore-init C n ⁻¹) C'-contr where
C' = removeInit C n
A' = fst C'
f' = snd C'
a₀' : A' O
a₀' = new-initial C n a
wc' : wconst-chain C'
wc' = removeInit-preserves-wconst C n wc
C'-contr : is-contr (SeqCo C')
C'-contr = SC-contr wc' a₀'
automatic : (n : ℕ) (a : fst C n) → wc-prp-ins n a == wc-prp-ins (S n) (snd C n a)
automatic n a = prop-has-all-paths (has-level-is-prop {n = ⟨-2⟩} {A = SeqCo C}) _ _
| {
"alphanum_fraction": 0.61263266,
"avg_line_length": 35.6219512195,
"ext": "agda",
"hexsha": "fc181a3889af458d693526258738656760b7f00d",
"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": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nicolaikraus/HoTT-Agda",
"max_forks_repo_path": "nicolai/pseudotruncations/wconstSequence.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"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": "nicolaikraus/HoTT-Agda",
"max_issues_repo_path": "nicolai/pseudotruncations/wconstSequence.agda",
"max_line_length": 115,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nicolaikraus/HoTT-Agda",
"max_stars_repo_path": "nicolai/pseudotruncations/wconstSequence.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z",
"num_tokens": 1876,
"size": 5842
} |
module _ where
module M where
record S : Set₁ where
open M
field
F1 : Set
F2 : {!!}
| {
"alphanum_fraction": 0.5757575758,
"avg_line_length": 9,
"ext": "agda",
"hexsha": "128600e3f8e0d5ef252223b50f42d97f7ae9b4d0",
"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/Issue2420.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/Issue2420.agda",
"max_line_length": 21,
"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/Issue2420.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": 35,
"size": 99
} |
{-# OPTIONS --without-K --no-pattern-matching #-}
module Ch2-9 where
open import Level hiding (lift)
open import Ch2-1
open import Ch2-2
open import Ch2-3
open import Ch2-4
open import Ch2-5
open import Ch2-6
open import Ch2-7
open import Ch2-8
open import Data.Product
open import Function using (id; _∘_)
-- happly (Definition 2.9.2)
happly : ∀ {a} {b} {A : Set a} {B : A → Set b}
→ {f g : (x : A) → B x}
→ (f ≡ g) → (f ~ g)
happly {_} {_} {A} {B} {f} {g} p = J ((x : A) → B x) D d f g p
where
D : (f g : (x : A) → B x) (p : f ≡ g) → Set _
D f g p = f ~ g
d : (x : (x : A) → B x) → D x x refl
d f x = refl
postulate
funext : ∀ {a} {b} {A : Set a} {B : A → Set b}
→ {f g : (x : A) → B x}
→ (f ~ g) → (f ≡ g)
Theorem-2-9-1 : ∀ {a} {b} {A : Set a} {B : A → Set b}
→ (f g : (x : A) → B x)
→ (f ≡ g) ≅ (f ~ g)
Theorem-2-9-1 {_} {_} {A} {B} f g = happly , (funext , α) , (funext , {! !})
where
α : happly ∘ funext ~ id
α p = J {! !} D {! !} f g (funext p)
-- J ((x : A) → B x) D d f g (funext p)
--
where
D : (f g : (x : A) → B x) (p : {! !}) → Set _
D f g p = {! !}
-- ((λ {x} → happly) ∘ funext) p ≡ id p
-- ((λ {x} → happly) ∘ funext) p ≡ id p
-- happly ∘ funext ~ id
-- d : (x : (x : A) → B x) → D x x refl
-- d x = refl
-- happly-isequiv : isequiv (happly f g)
-- happly-isequiv =
-- where
-- f : x ≡ y → ⊤
-- f p = tt
--
-- f' : ⊤ → x ≡ y
-- f' x = refl
--
-- α : (λ _ → f refl) ~ id
-- α w = refl
--
-- β : (λ _ → refl) ~ id
-- β w = J ⊤ D d x y w
-- where
-- D : (x y : ⊤) (p : x ≡ y) → Set _
-- D x y p = refl ≡ id p
--
-- d : (x : ⊤) → D x x refl
-- d x = refl
--
-- f-isequiv : isequiv f
-- f-isequiv = (f' , α) , f' , β
| {
"alphanum_fraction": 0.4037333333,
"avg_line_length": 23.1481481481,
"ext": "agda",
"hexsha": "e394e437d1650a478d27e3946469284ff1737840",
"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": "75eea99a879e100304bd48c538c9d2db0b4a4ff3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/hott",
"max_forks_repo_path": "src/Ch2-9.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3",
"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/hott",
"max_issues_repo_path": "src/Ch2-9.agda",
"max_line_length": 78,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/hott",
"max_stars_repo_path": "src/Ch2-9.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 839,
"size": 1875
} |
module Unique where
open import Category
module Uniq (ℂ : Cat) where
private open module C = Cat ℂ
-- We say that f ∈! P iff f is the unique arrow satisfying P.
data _∈!_ {A B : Obj}(f : A ─→ B)(P : A ─→ B -> Set) : Set where
unique : (forall g -> P g -> f == g) -> f ∈! P
itsUnique : {A B : Obj}{f : A ─→ B}{P : A ─→ B -> Set} ->
f ∈! P -> (g : A ─→ B) -> P g -> f == g
itsUnique (unique h) = h
data ∃! {A B : Obj}(P : A ─→ B -> Set) : Set where
witness : (f : A ─→ B) -> f ∈! P -> ∃! P
getWitness : {A B : Obj}{P : A ─→ B -> Set} -> ∃! P -> A ─→ B
getWitness (witness w _) = w
uniqueWitness : {A B : Obj}{P : A ─→ B -> Set}(u : ∃! P) ->
getWitness u ∈! P
uniqueWitness (witness _ u) = u
witnessEqual : {A B : Obj}{P : A ─→ B -> Set} -> ∃! P ->
{f g : A ─→ B} -> P f -> P g -> f == g
witnessEqual u {f} {g} pf pg = trans (sym hf) hg
where
h = getWitness u
hf : h == f
hf = itsUnique (uniqueWitness u) f pf
hg : h == g
hg = itsUnique (uniqueWitness u) g pg
| {
"alphanum_fraction": 0.4775977121,
"avg_line_length": 26.8974358974,
"ext": "agda",
"hexsha": "eadeb8244134885ab00e0f2545506b009d97431a",
"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": "examples/outdated-and-incorrect/cat/Unique.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/cat/Unique.agda",
"max_line_length": 66,
"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/cat/Unique.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": 422,
"size": 1049
} |
module MLib.Fin.Parts.Nat.Simple.Properties where
open import MLib.Prelude
open import MLib.Fin.Parts.Nat
import MLib.Fin.Parts.Nat.Simple as S
module P a b = Partsℕ (S.repl a b)
open Nat using (_*_; _+_; _<_)
open Fin using (toℕ; fromℕ≤)
open List
fromAny : ∀ a b → Any Fin (S.repl a b) → ℕ × ℕ
fromAny zero b ()
fromAny (suc a) b (here j) = 0 , Fin.toℕ j
fromAny (suc a) b (there js) =
let i , j = fromAny a b js
in suc i , j
intoPart-prop : ∀ a b {ps : Any Fin (S.repl a b)} → P.intoPart a b ps ≡ S.intoPart a b (fromAny a b ps)
intoPart-prop zero b {()}
intoPart-prop (suc a) b {here px} = ≡.sym (Nat.+-identityʳ _)
intoPart-prop (suc a) b {there ps} =
let ind = intoPart-prop a b {ps}
i , j = fromAny a b ps
open ≡.Reasoning
open Nat.SemiringSolver
in begin
b + Impl.intoPart ps ≡⟨ ≡.cong₂ _+_ ≡.refl ind ⟩
b + (j + i * b) ≡⟨ solve 3 (λ b j ib → b :+ (j :+ ib) := j :+ (b :+ ib)) ≡.refl b j (i * b) ⟩
j + (b + i * b) ∎
lem : ∀ a b {k} → k < a * b → k < sum (S.repl a b)
lem a b p = Nat.≤-trans p (Nat.≤-reflexive (≡.sym (S.sum-replicate-* a b)))
fromPart-prop : ∀ a b {k} → k < a * b → Maybe.map (fromAny a b) (Impl.fromPart (S.repl a b) k) ≡ just (S.fromPart a b k)
fromPart-prop zero b ()
fromPart-prop (suc a) b {k} p with Impl.compare′ k b
fromPart-prop (suc a) .(suc (m + k)) {.m} p | Impl.less m k = ≡.cong just (Σ.≡×≡⇒≡ (≡.refl , Fin.toℕ-fromℕ≤ _))
fromPart-prop (suc a) b {.(b + k)} p | Impl.gte .b k with Impl.fromPart (S.repl a b) k | fromPart-prop a b {k} (Nat.+-cancelˡ-< b p)
fromPart-prop (suc a) b {.(b + k)} p | Impl.gte .b k | just x | ind =
let e1 , e2 = Σ.≡⇒≡×≡ (Maybe.just-injective ind)
in ≡.cong just (Σ.≡×≡⇒≡ (≡.cong suc e1 , e2))
fromPart-prop (suc a) b {.(b + k)} p | Impl.gte .b k | nothing | ()
fromPart′-prop : ∀ a b {k} (p : k < a * b) → fromAny a b (P.fromPart a b {k} (lem a b p)) ≡ S.fromPart a b k
fromPart′-prop a b {k} p with Impl.fromPart (S.repl a b) k | Impl.fromPart-prop (S.repl a b) (lem a b p) | fromPart-prop a b p
fromPart′-prop a b {k} p | just x | y | z = Maybe.just-injective z
fromPart′-prop a b {k} p | nothing | () | z
| {
"alphanum_fraction": 0.5759700795,
"avg_line_length": 41.9411764706,
"ext": "agda",
"hexsha": "50fc40fbd27301798899163254b37bff654c6097",
"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": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bch29/agda-matrices",
"max_forks_repo_path": "src/MLib/Fin/Parts/Nat/Simple/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"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": "bch29/agda-matrices",
"max_issues_repo_path": "src/MLib/Fin/Parts/Nat/Simple/Properties.agda",
"max_line_length": 132,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bch29/agda-matrices",
"max_stars_repo_path": "src/MLib/Fin/Parts/Nat/Simple/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 917,
"size": 2139
} |
module Luau.Substitution where
open import Luau.Syntax using (Expr; Stat; Block; nil; addr; var; function_is_end; _$_; block_is_end; local_←_; _∙_; done; return; _⟨_⟩ ; name; fun; arg; number; binexp)
open import Luau.Value using (Value; val)
open import Luau.Var using (Var; _≡ⱽ_)
open import Properties.Dec using (Dec; yes; no)
_[_/_]ᴱ : ∀ {a} → Expr a → Value → Var → Expr a
_[_/_]ᴮ : ∀ {a} → Block a → Value → Var → Block a
var_[_/_]ᴱwhenever_ : ∀ {a P} → Var → Value → Var → (Dec P) → Expr a
_[_/_]ᴮunless_ : ∀ {a P} → Block a → Value → Var → (Dec P) → Block a
nil [ v / x ]ᴱ = nil
var y [ v / x ]ᴱ = var y [ v / x ]ᴱwhenever (x ≡ⱽ y)
addr a [ v / x ]ᴱ = addr a
(number y) [ v / x ]ᴱ = number y
(M $ N) [ v / x ]ᴱ = (M [ v / x ]ᴱ) $ (N [ v / x ]ᴱ)
function F is C end [ v / x ]ᴱ = function F is C [ v / x ]ᴮunless (x ≡ⱽ name(arg F)) end
block b is C end [ v / x ]ᴱ = block b is C [ v / x ]ᴮ end
(binexp e₁ op e₂) [ v / x ]ᴱ = binexp (e₁ [ v / x ]ᴱ) op (e₂ [ v / x ]ᴱ)
(function F is C end ∙ B) [ v / x ]ᴮ = function F is (C [ v / x ]ᴮunless (x ≡ⱽ name(arg F))) end ∙ (B [ v / x ]ᴮunless (x ≡ⱽ fun F))
(local y ← M ∙ B) [ v / x ]ᴮ = local y ← (M [ v / x ]ᴱ) ∙ (B [ v / x ]ᴮunless (x ≡ⱽ name y))
(return M ∙ B) [ v / x ]ᴮ = return (M [ v / x ]ᴱ) ∙ (B [ v / x ]ᴮ)
done [ v / x ]ᴮ = done
var y [ v / x ]ᴱwhenever yes p = val v
var y [ v / x ]ᴱwhenever no p = var y
B [ v / x ]ᴮunless yes p = B
B [ v / x ]ᴮunless no p = B [ v / x ]ᴮ
| {
"alphanum_fraction": 0.5402777778,
"avg_line_length": 45,
"ext": "agda",
"hexsha": "61287d36c4ed35655474484ad654b934ba3e9b9c",
"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": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Tr4shh/Roblox-Luau",
"max_forks_repo_path": "prototyping/Luau/Substitution.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734",
"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": "Tr4shh/Roblox-Luau",
"max_issues_repo_path": "prototyping/Luau/Substitution.agda",
"max_line_length": 169,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Tr4shh/Roblox-Luau",
"max_stars_repo_path": "prototyping/Luau/Substitution.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 682,
"size": 1440
} |
{-# OPTIONS --without-K #-}
open import M-types.Base.Core
open import M-types.Base.Sum
open import M-types.Base.Prod
open import M-types.Base.Eq
module M-types.Base.Contr where
IsContr : ∏[ X ∈ Ty ℓ ] Ty ℓ
IsContr X = ∑[ x ∈ X ] ∏[ x′ ∈ X ] x′ ≡ x
Contr : Ty (ℓ-suc ℓ)
Contr {ℓ} = ∑[ X ∈ Ty ℓ ] IsContr X
| {
"alphanum_fraction": 0.5907692308,
"avg_line_length": 21.6666666667,
"ext": "agda",
"hexsha": "bc080a2d3999845099e5c8209e80e9268e8b37ba",
"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": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DDOtten/M-types",
"max_forks_repo_path": "Base/Contr.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369",
"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": "DDOtten/M-types",
"max_issues_repo_path": "Base/Contr.agda",
"max_line_length": 45,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DDOtten/M-types",
"max_stars_repo_path": "Base/Contr.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 119,
"size": 325
} |
{-# OPTIONS --without-K #-}
module Model.Product where
open import Cats.Category
open import Data.Product using (<_,_>)
open import Model.Type.Core
open import Util.HoTT.HLevel
open import Util.Prelude hiding (_×_)
infixr 5 _×_
_×_ : ∀ {Γ} (T U : ⟦Type⟧ Γ) → ⟦Type⟧ Γ
T × U = record
{ ObjHSet = λ δ → T .ObjHSet δ ×-HSet U .ObjHSet δ
; eqHProp = λ where
γ≈γ′ (x , x′) (y , y′) → T .eqHProp γ≈γ′ x y ×-HProp U .eqHProp γ≈γ′ x′ y′
; eq-refl = λ where
(x , y) → T .eq-refl x , U .eq-refl y
}
π₁ : ∀ {Γ} {T} (U : ⟦Type⟧ Γ) → T × U ⇒ T
π₁ U = record
{ fobj = proj₁
; feq = λ p → proj₁
}
π₂ : ∀ {Γ} T {U : ⟦Type⟧ Γ} → T × U ⇒ U
π₂ T = record
{ fobj = proj₂
; feq = λ p → proj₂
}
⟨_,_⟩ : ∀ {Γ} {X T U : ⟦Type⟧ Γ}
→ X ⇒ T → X ⇒ U → X ⇒ T × U
⟨ f , g ⟩ = record
{ fobj = < f .fobj , g .fobj >
; feq = λ γ≈γ′ → < f .feq γ≈γ′ , g .feq γ≈γ′ >
}
instance
hasBinaryProducts : ∀ {Γ} → HasBinaryProducts (⟦Types⟧ Γ)
hasBinaryProducts .HasBinaryProducts._×′_ T U = record
{ prod = T × U
; proj = λ where
true → π₁ U
false → π₂ T
; isProduct = λ π′ → record
{ arr = ⟨ π′ true , π′ false ⟩
; prop = λ where
true → ≈⁺ λ γ x → refl
false → ≈⁺ λ γ x → refl
; unique = λ {f} f-prop → ≈⁺ λ γ x
→ cong₂ _,_ (f-prop true .≈⁻ γ x) (f-prop false .≈⁻ γ x)
}
}
open module ⟦Types⟧× {Γ}
= HasBinaryProducts (hasBinaryProducts {Γ})
public using
( ⟨_×_⟩ ) renaming
( ×-resp-≅ to ×-resp-≈⟦Type⟧ )
| {
"alphanum_fraction": 0.5042847726,
"avg_line_length": 21.6714285714,
"ext": "agda",
"hexsha": "2d71d90f49dedc595a77c4d4a8868f066228c552",
"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": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JLimperg/msc-thesis-code",
"max_forks_repo_path": "src/Model/Product.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"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": "JLimperg/msc-thesis-code",
"max_issues_repo_path": "src/Model/Product.agda",
"max_line_length": 80,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JLimperg/msc-thesis-code",
"max_stars_repo_path": "src/Model/Product.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z",
"num_tokens": 660,
"size": 1517
} |
{-
This file contains:
Properties of the FreeGroup:
- FreeGroup A is Set, SemiGroup, Monoid, Group
- Recursion principle for the FreeGroup
- Induction principle for the FreeGroup on hProps
- Condition for the equality of Group Homomorphisms from FreeGroup
- Equivalence of the types (A → Group .fst) (GroupHom (freeGroupGroup A) Group)
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.FreeGroup.Properties where
open import Cubical.HITs.FreeGroup.Base
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Path
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.BiInvertible
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Monoid.Base
open import Cubical.Algebra.Semigroup.Base
private
variable
ℓ ℓ' : Level
A : Type ℓ
freeGroupIsSet : isSet (FreeGroup A)
freeGroupIsSet = trunc
freeGroupIsSemiGroup : IsSemigroup {A = FreeGroup A} _·_
freeGroupIsSemiGroup = issemigroup freeGroupIsSet assoc
freeGroupIsMonoid : IsMonoid {A = FreeGroup A} ε _·_
freeGroupIsMonoid = ismonoid freeGroupIsSemiGroup (λ x → sym (idr x)) (λ x → sym (idl x))
freeGroupIsGroup : IsGroup {G = FreeGroup A} ε _·_ inv
freeGroupIsGroup = isgroup freeGroupIsMonoid invr invl
freeGroupGroupStr : GroupStr (FreeGroup A)
freeGroupGroupStr = groupstr ε _·_ inv freeGroupIsGroup
-- FreeGroup is indeed a group
freeGroupGroup : Type ℓ → Group ℓ
freeGroupGroup A = FreeGroup A , freeGroupGroupStr
-- The recursion principle for the FreeGroup
rec : {Group : Group ℓ'} → (A → Group .fst) → GroupHom (freeGroupGroup A) Group
rec {Group = G , groupstr 1g _·g_ invg (isgroup (ismonoid isSemigroupg ·gIdR ·gIdL) ·gInvR ·gInvL)} f = f' , isHom
where
f' : FreeGroup _ → G
f' (η a) = f a
f' (g1 · g2) = (f' g1) ·g (f' g2)
f' ε = 1g
f' (inv g) = invg (f' g)
f' (assoc g1 g2 g3 i) = IsSemigroup.·Assoc isSemigroupg (f' g1) (f' g2) (f' g3) i
f' (idr g i) = sym (·gIdR (f' g)) i
f' (idl g i) = sym (·gIdL (f' g)) i
f' (invr g i) = ·gInvR (f' g) i
f' (invl g i) = ·gInvL (f' g) i
f' (trunc g1 g2 p q i i₁) = IsSemigroup.is-set isSemigroupg (f' g1) (f' g2) (cong f' p) (cong f' q) i i₁
isHom : IsGroupHom freeGroupGroupStr f' _
IsGroupHom.pres· isHom = λ g1 g2 → refl
IsGroupHom.pres1 isHom = refl
IsGroupHom.presinv isHom = λ g → refl
-- The induction principle for the FreeGroup for hProps
elimProp : {B : FreeGroup A → Type ℓ'}
→ ((x : FreeGroup A) → isProp (B x))
→ ((a : A) → B (η a))
→ ((g1 g2 : FreeGroup A) → B g1 → B g2 → B (g1 · g2))
→ (B ε)
→ ((g : FreeGroup A) → B g → B (inv g))
→ (x : FreeGroup A)
→ B x
elimProp {B = B} Bprop η-ind ·-ind ε-ind inv-ind = induction where
induction : ∀ g → B g
induction (η a) = η-ind a
induction (g1 · g2) = ·-ind g1 g2 (induction g1) (induction g2)
induction ε = ε-ind
induction (inv g) = inv-ind g (induction g)
induction (assoc g1 g2 g3 i) = path i where
p1 : B g1
p1 = induction g1
p2 : B g2
p2 = induction g2
p3 : B g3
p3 = induction g3
path : PathP (λ i → B (assoc g1 g2 g3 i)) (·-ind g1 (g2 · g3) p1 (·-ind g2 g3 p2 p3))
(·-ind (g1 · g2) g3 (·-ind g1 g2 p1 p2) p3)
path = isProp→PathP (λ i → Bprop (assoc g1 g2 g3 i)) (·-ind g1 (g2 · g3) p1 (·-ind g2 g3 p2 p3))
(·-ind (g1 · g2) g3 (·-ind g1 g2 p1 p2) p3)
induction (idr g i) = path i where
p : B g
p = induction g
pε : B ε
pε = induction ε
path : PathP (λ i → B (idr g i)) p (·-ind g ε p pε)
path = isProp→PathP (λ i → Bprop (idr g i)) p (·-ind g ε p pε)
induction (idl g i) = path i where
p : B g
p = induction g
pε : B ε
pε = induction ε
path : PathP (λ i → B (idl g i)) p (·-ind ε g pε p)
path = isProp→PathP (λ i → Bprop (idl g i)) p (·-ind ε g pε p)
induction (invr g i) = path i where
p : B g
p = induction g
pinv : B (inv g)
pinv = inv-ind g p
pε : B ε
pε = induction ε
path : PathP (λ i → B (invr g i)) (·-ind g (inv g) p pinv) pε
path = isProp→PathP (λ i → Bprop (invr g i)) (·-ind g (inv g) p pinv) pε
induction (invl g i) = path i where
p : B g
p = induction g
pinv : B (inv g)
pinv = inv-ind g p
pε : B ε
pε = induction ε
path : PathP (λ i → B (invl g i)) (·-ind (inv g) g pinv p) pε
path = isProp→PathP (λ i → Bprop (invl g i)) (·-ind (inv g) g pinv p) pε
induction (trunc g1 g2 q1 q2 i i₁) = square i i₁ where
p1 : B g1
p1 = induction g1
p2 : B g2
p2 = induction g2
dq1 : PathP (λ i → B (q1 i)) p1 p2
dq1 = cong induction q1
dq2 : PathP (λ i → B (q2 i)) p1 p2
dq2 = cong induction q2
square : SquareP (λ i i₁ → B (trunc g1 g2 q1 q2 i i₁))
{a₀₀ = p1} {a₀₁ = p2} dq1
{a₁₀ = p1} {a₁₁ = p2} dq2
(cong induction (refl {x = g1})) (cong induction (refl {x = g2}))
square = isProp→SquareP (λ i i₁ → Bprop (trunc g1 g2 q1 q2 i i₁))
(cong induction (refl {x = g1})) (cong induction (refl {x = g2}))
dq1 dq2
-- Two group homomorphisms from FreeGroup to G are the same if they agree on every a : A
freeGroupHom≡ : {Group : Group ℓ'}{f g : GroupHom (freeGroupGroup A) Group}
→ (∀ a → (fst f) (η a) ≡ (fst g) (η a)) → f ≡ g
freeGroupHom≡ {Group = G , (groupstr 1g _·g_ invg isGrp)} {f} {g} eqOnA = GroupHom≡ (funExt pointwise) where
B : ∀ x → Type _
B x = (fst f) x ≡ (fst g) x
Bprop : ∀ x → isProp (B x)
Bprop x = (isSetGroup (G , groupstr 1g _·g_ invg isGrp)) ((fst f) x) ((fst g) x)
η-ind : ∀ a → B (η a)
η-ind = eqOnA
·-ind : ∀ g1 g2 → B g1 → B g2 → B (g1 · g2)
·-ind g1 g2 ind1 ind2 =
(fst f) (g1 · g2)
≡⟨ IsGroupHom.pres· (f .snd) g1 g2 ⟩
((fst f) g1) ·g ((fst f) g2)
≡⟨ cong (λ x → x ·g ((fst f) g2)) ind1 ⟩
((fst g) g1) ·g ((fst f) g2)
≡⟨ cong (λ x → ((fst g) g1) ·g x) ind2 ⟩
((fst g) g1) ·g ((fst g) g2)
≡⟨ sym (IsGroupHom.pres· (g .snd) g1 g2) ⟩
(fst g) (g1 · g2) ∎
ε-ind : B ε
ε-ind =
(fst f) ε
≡⟨ IsGroupHom.pres1 (f .snd) ⟩
1g
≡⟨ sym (IsGroupHom.pres1 (g .snd)) ⟩
(fst g) ε ∎
inv-ind : ∀ x → B x → B (inv x)
inv-ind x ind =
(fst f) (inv x)
≡⟨ IsGroupHom.presinv (f .snd) x ⟩
invg ((fst f) x)
≡⟨ cong invg ind ⟩
invg ((fst g) x)
≡⟨ sym (IsGroupHom.presinv (g .snd) x) ⟩
(fst g) (inv x) ∎
pointwise : ∀ x → (fst f) x ≡ (fst g) x
pointwise = elimProp Bprop η-ind ·-ind ε-ind inv-ind
-- The type of Group Homomorphisms from the FreeGroup A into G
-- is equivalent to the type of functions from A into G .fst
A→Group≃GroupHom : {Group : Group ℓ'} → (A → Group .fst) ≃ GroupHom (freeGroupGroup A) Group
A→Group≃GroupHom {Group = Group} = biInvEquiv→Equiv-right biInv where
biInv : BiInvEquiv (A → Group .fst) (GroupHom (freeGroupGroup A) Group)
BiInvEquiv.fun biInv = rec
BiInvEquiv.invr biInv (hom , _) a = hom (η a)
BiInvEquiv.invr-rightInv biInv hom = freeGroupHom≡ (λ a → refl)
BiInvEquiv.invl biInv (hom , _) a = hom (η a)
BiInvEquiv.invl-leftInv biInv f = funExt (λ a → refl)
| {
"alphanum_fraction": 0.5809536638,
"avg_line_length": 36.9353233831,
"ext": "agda",
"hexsha": "d3bdc748c8327b91f74285393fe8798fd4d4bbea",
"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/HITs/FreeGroup/Properties.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/HITs/FreeGroup/Properties.agda",
"max_line_length": 114,
"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/HITs/FreeGroup/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2910,
"size": 7424
} |
-- Andreas, 2013-11-11 Better error for wrongly named implicit arg.
module Issue949 where
postulate
S : Set
F : {A : Set} → Set
ok : F {A = S}
err : F {B = S}
-- Old error:
--
-- Set should be a function type, but it isn't
-- when checking that {B = S} are valid arguments to a function of
-- type Set
-- New error (after fixing also issue 951):
--
-- Function does not accept argument {B = _}
-- when checking that {B = S} are valid arguments to a function of
-- type {A : Set} → Set
| {
"alphanum_fraction": 0.6387225549,
"avg_line_length": 23.8571428571,
"ext": "agda",
"hexsha": "0db25d3a3a7b826e6650189c8a2b5212a7870e6d",
"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/Issue949.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/Issue949.agda",
"max_line_length": 67,
"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/Issue949.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": 152,
"size": 501
} |
open import Common.Prelude
open import Common.Reflect
module TermSplicingLooping where
mutual
f : Set -> Set
f = unquote (def (quote f) [])
| {
"alphanum_fraction": 0.7260273973,
"avg_line_length": 16.2222222222,
"ext": "agda",
"hexsha": "bc75450a996b1739f799ec25ca35dadfe5c84869",
"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/TermSplicingLooping.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/TermSplicingLooping.agda",
"max_line_length": 32,
"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/fail/TermSplicingLooping.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": 42,
"size": 146
} |
module Lec1Start where
-- the -- mark introduces a "comment to end of line"
------------------------------------------------------------------------------
-- some basic "logical" types
------------------------------------------------------------------------------
data Zero : Set where
-- to give a value in a data, choose one constructor
-- there are no constructors
-- so that's impossible
record One : Set where
-- to give a value in a record type, fill all its fields
-- there are no fields
-- so that's trivial
-- (can we have a constructor, for convenience?)
data _+_ (S : Set)(T : Set) : Set where -- "where" wants an indented block
-- to offer a choice of constructors, list them with their types
inl : S -> S + T -- constructors can pack up stuff
inr : T -> S + T
-- in Haskell, this was called "Either S T"
record _*_ (S : Set)(T : Set) : Set where
field -- introduces a bunch of fields, listed with their types
fst : S
snd : T
-- in Haskell, this was called "(S, T)"
------------------------------------------------------------------------------
-- some simple proofs
------------------------------------------------------------------------------
{-+}
comm-* : {A : Set}{B : Set} -> A * B -> B * A
comm-* x = ?
{+-}
{-+}
assocLR-+ : {A B C : Set} -> (A + B) + C -> A + (B + C)
assocLR-+ x = ?
{+-}
{-+}
_$*_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A * B -> A' * B'
(f $* g) x = r?
{+-}
-- record syntax is rather ugly for small stuff; can we have constructors?
{-+}
_$+_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A + B -> A' + B'
(f $+ g) x = ?
{+-}
{-+}
combinatorK : {A E : Set} -> A -> E -> A
combinatorK = ?
combinatorS : {S T E : Set} -> (E -> S -> T) -> (E -> S) -> E -> T
combinatorS = ?
{+-}
{-+}
id : {X : Set} -> X -> X
-- id x = x -- is the easy way; let's do it a funny way to make a point
id = ?
{+-}
{-+}
naughtE : {X : Set} -> Zero -> X
naughtE x = ?
{+-}
------------------------------------------------------------------------------
-- from logic to data
------------------------------------------------------------------------------
data Nat : Set where
zero : Nat
suc : Nat -> Nat -- recursive data type
{-# BUILTIN NATURAL Nat #-}
-- ^^^^^^^^^^^^^^^^^^^ this pragma lets us use decimal notation
{-+}
_+N_ : Nat -> Nat -> Nat
x +N y = ?
four : Nat
four = 2 +N 2
{+-}
------------------------------------------------------------------------------
-- and back to logic
------------------------------------------------------------------------------
{-+}
data _==_ {X : Set} : X -> X -> Set where
refl : (x : X) -> x == x -- the relation that's "only reflexive"
{-# BUILTIN EQUALITY _==_ #-} -- we'll see what that's for, later
_=$=_ : {X Y : Set}{f f' : X -> Y}{x x' : X} ->
f == f' -> x == x' -> f x == f' x'
fq =$= xq = ?
{+-}
{-+}
zero-+N : (n : Nat) -> (zero +N n) == n
zero-+N n = ?
+N-zero : (n : Nat) -> (n +N zero) == n
+N-zero n = ?
assocLR-+N : (x y z : Nat) -> ((x +N y) +N z) == (x +N (y +N z))
assocLR-+N x y z = ?
{+-}
------------------------------------------------------------------------------
-- computing types
------------------------------------------------------------------------------
{-+}
_>=_ : Nat -> Nat -> Set
x >= zero = One
zero >= suc y = Zero
suc x >= suc y = x >= y
refl->= : (n : Nat) -> n >= n
refl->= n = {!!}
trans->= : (x y z : Nat) -> x >= y -> y >= z -> x >= z
trans->= x y z x>=y y>=z = {!!}
{+-}
------------------------------------------------------------------------------
-- construction by proof
------------------------------------------------------------------------------
{-+}
record Sg (S : Set)(T : S -> Set) : Set where -- Sg is short for "Sigma"
constructor _,_
field -- introduces a bunch of fields, listed with their types
fst : S
snd : T fst
-- make _*_ from Sg ?
difference : (m n : Nat) -> m >= n -> Sg Nat \ d -> m == (n +N d)
-- ( )
difference m zero m>=n = m , refl m
difference zero (suc n) ()
difference (suc m) (suc n) m>=n with difference m n m>=n
difference (suc m) (suc n) m>=n | d , q = d , (refl suc =$= q)
tryMe = difference 42 37 _
don'tTryMe = difference 37 42 {!!}
{+-}
------------------------------------------------------------------------------
-- things to remember to say
------------------------------------------------------------------------------
-- why the single colon?
-- what's with all the spaces?
-- what's with identifiers mixing letters and symbols?
-- what's with all the braces?
-- what is Set?
-- are there any lowercase/uppercase conventions?
-- what's with all the underscores?
-- (i) placeholders in mixfix operators
-- (ii) don't care (on the left)
-- (iii) go figure (on the right)
-- why use arithmetic operators for types?
-- what's the difference between = and == ?
-- can't we leave out cases?
-- can't we loop?
-- the function type is both implication and universal quantification,
-- but why is it called Pi?
-- why is Sigma called Sigma?
-- B or nor B?
| {
"alphanum_fraction": 0.4112621359,
"avg_line_length": 25.6218905473,
"ext": "agda",
"hexsha": "65ac624aabaac0e8e680a44d78a805d6b190eab7",
"lang": "Agda",
"max_forks_count": 8,
"max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z",
"max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc",
"max_forks_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/nowyoutry/Lec1Start.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"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": "haroldcarr/learn-haskell-coq-ml-etc",
"max_issues_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/nowyoutry/Lec1Start.agda",
"max_line_length": 78,
"max_stars_count": 36,
"max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc",
"max_stars_repo_path": "agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec1Start.agda",
"max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z",
"num_tokens": 1395,
"size": 5150
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Comonad.Relative where
open import Level
open import Categories.Category using (Category)
open import Categories.Functor using (Functor; Endofunctor; _∘F_) renaming (id to idF)
import Categories.Morphism.Reasoning as MR
open import Categories.NaturalTransformation renaming (id to idN)
open import Categories.NaturalTransformation.NaturalIsomorphism hiding (_≃_)
open import Categories.NaturalTransformation.Equivalence
open NaturalIsomorphism
private
variable
o ℓ e o′ ℓ′ e′ : Level
C : Category o ℓ e
D : Category o′ ℓ′ e′
record Comonad {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (J : Functor C D) : Set (o ⊔ o′ ⊔ ℓ′ ⊔ e′) where
private
module C = Category C
module D = Category D
module J = Functor J
open D using (_⇒_; _∘_; _≈_)
field
F₀ : C.Obj → D.Obj
counit : {c : C.Obj} → F₀ c ⇒ J.₀ c
cobind : {x y : C.Obj} → (F₀ x ⇒ J.₀ y) → F₀ x ⇒ F₀ y
identityʳ : {x y : C.Obj} { k : F₀ x ⇒ J.₀ y} → counit ∘ cobind k ≈ k
identityˡ : {x : C.Obj} → cobind {x} counit ≈ D.id
assoc : {x y z : C.Obj} {k : F₀ x ⇒ J.₀ y} {l : F₀ y ⇒ J.₀ z} →
cobind (l ∘ cobind k) ≈ cobind l ∘ cobind k
cobind-≈ : {x y : C.Obj} {k h : F₀ x ⇒ J.₀ y} → k ≈ h → cobind k ≈ cobind h
-- From a Relative Comonad, we can extract a functor
RComonad⇒Functor : {J : Functor C D} → Comonad J → Functor C D
RComonad⇒Functor {C = C} {D = D} {J = J} r = record
{ F₀ = F₀
; F₁ = λ f → cobind (J.₁ f ∘ counit)
; identity = identity′
; homomorphism = hom′
; F-resp-≈ = λ f≈g → cobind-≈ (∘-resp-≈ˡ (J.F-resp-≈ f≈g))
}
where
open Comonad r
module C = Category C
module D = Category D
module J = Functor J
open Category D hiding (identityˡ; identityʳ; assoc)
open HomReasoning
open MR D
identity′ : {c : C.Obj} → cobind {c} (J.₁ C.id ∘ counit) ≈ id
identity′ = begin
cobind (J.₁ C.id ∘ counit) ≈⟨ cobind-≈ (elimˡ J.identity) ⟩
cobind counit ≈⟨ identityˡ ⟩
id ∎
hom′ : {X Y Z : C.Obj} {f : X C.⇒ Y} {g : Y C.⇒ Z} →
cobind (J.₁ (g C.∘ f) ∘ counit) ≈ cobind (J.₁ g ∘ counit) ∘ cobind (J.₁ f ∘ counit)
hom′ {f = f} {g} = begin
cobind (J.₁ (g C.∘ f) ∘ counit) ≈⟨ cobind-≈ (pushˡ J.homomorphism) ⟩
cobind (J.₁ g ∘ J.₁ f ∘ counit) ≈⟨ cobind-≈ (pushʳ (⟺ identityʳ)) ⟩
cobind ((J.₁ g ∘ counit) ∘ (cobind (J.F₁ f ∘ counit))) ≈⟨ assoc ⟩
cobind (J.₁ g ∘ counit) ∘ cobind (J.F₁ f ∘ counit) ∎
| {
"alphanum_fraction": 0.5748218527,
"avg_line_length": 38.8615384615,
"ext": "agda",
"hexsha": "6a3de7f851509dd5b8d894711ef5df5180c91b43",
"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/Comonad/Relative.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/Comonad/Relative.agda",
"max_line_length": 108,
"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/Comonad/Relative.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": 1029,
"size": 2526
} |
-- This is an implementation of the equality type for Sets. Agda's
-- standard equality is more powerful. The main idea here is to
-- illustrate the equality type.
module Equality where
open import Level
-- The equality of two elements of type A. The type a ≡ b is a family
-- of types which captures the statement of equality in A. Not all of
-- the types are inhabited as in general not all elements are equal
-- here. The only type that are inhabited are a ≡ a by the element
-- that we call definition. This is called refl (for reflection in
-- agda).
data _≡_ {ℓ} {A : Set ℓ} : (a b : A) → Set ℓ where
refl : {x : A} → x ≡ x
-- ≡ is a symmetric relation.
sym : ∀{ℓ} {A : Set ℓ} {a b : A} → a ≡ b → b ≡ a
sym refl = refl
-- ≡ is a transitive relation.
trans : ∀ {ℓ} {A : Set ℓ} {a b c : A} → a ≡ b → b ≡ c → a ≡ c
trans pAB refl = pAB
-- trans refl pBC = pBC -- alternate proof of transitivity.
-- Congruence. If we apply f to equals the result are also equal.
cong : ∀{ℓ₀ ℓ₁} {A : Set ℓ₀} {B : Set ℓ₁}
{a₀ a₁ : A} → (f : A → B) → a₀ ≡ a₁ → f a₀ ≡ f a₁
cong f refl = refl
-- Pretty way of doing equational reasoning. If we want to prove a₀ ≡
-- b through an intermediate set of equations use this. The general
-- form will look like.
--
-- begin a ≈ a₀ by p₀
-- ≈ a₁ by p₁
-- ...
-- ≈ b by p
-- ∎
begin : ∀{ℓ} {A : Set ℓ} (a : A) → a ≡ a
_≈_by_ : ∀{ℓ} {A : Set ℓ} {a b : A} → a ≡ b → (c : A) → b ≡ c → a ≡ c
_∎ : ∀{ℓ} {A : Set ℓ} (a : A) → A
begin a = refl
aEb ≈ c by bEc = trans aEb bEc
x ∎ = x
infixl 1 _≈_by_
infixl 1 _≡_
| {
"alphanum_fraction": 0.5946801773,
"avg_line_length": 31.58,
"ext": "agda",
"hexsha": "b2abf91ccddbac58a0b6ed8b5c3b5d66df0c9109",
"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": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "piyush-kurur/sample-code",
"max_forks_repo_path": "agda/Equality.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8",
"max_issues_repo_issues_event_max_datetime": "2017-11-01T05:48:28.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-11-01T05:48:28.000Z",
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "piyush-kurur/sample-code",
"max_issues_repo_path": "agda/Equality.agda",
"max_line_length": 70,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "piyush-kurur/sample-code",
"max_stars_repo_path": "agda/Equality.agda",
"max_stars_repo_stars_event_max_datetime": "2017-06-20T02:19:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-06-19T12:34:08.000Z",
"num_tokens": 597,
"size": 1579
} |
{-# OPTIONS --copatterns --sized-types #-}
open import Level
open import Algebra.Structures
open import Relation.Binary
open import Algebra.FunctionProperties
module Comb (K : Set) (_≈_ : Rel K zero)
(_+_ _⋆_ : Op₂ K) (-_ : Op₁ K) (0# 1# : K)
(isRing : IsRing _≈_ _+_ _⋆_ -_ 0# 1#) where
open import Size
open import Function hiding (const)
open import Relation.Nullary
open import Stream
open import Data.Nat renaming (_+_ to _+ℕ_)
open import Data.Fin hiding (_+_)
open import Data.Product hiding (_×_)
open import Data.Empty
open import Relation.Binary.PropositionalEquality as P
using (_≡_) --; refl; sym; trans; cong; module ≡-Reasoning)
K-setoid : Setoid _ _
K-setoid = record { Carrier = K
; _≈_ = _≈_
; isEquivalence = IsRing.isEquivalence isRing }
open Bisim K-setoid
import Relation.Binary.EqReasoning as EqR
open EqR (K-setoid) public hiding (_≡⟨_⟩_)
--open IsEquivalence (IsRing.isEquivalence isRing)
open ∼-Reasoning renaming (begin_ to begin∼_; _∎ to _∎∼)
open IsRing isRing -- using (+-cong ; +-identity)
+-identityˡ = proj₁ +-identity
+-identityʳ = proj₂ +-identity
-- zeroʳ : RightZero 0# _⋆_
-- zeroʳ = ?
----------------------
--- Basic operators --
----------------------
const : ∀ {A} → A → Str A
hd (const x) = x
tl (const x) = const x
-- | Point-wise unary operations
pw₁ : ∀ {A i} → Op₁ A → Op₁ (Str {i} A)
hd (pw₁ f σ) = f (hd σ)
tl (pw₁ f σ) = pw₁ f (tl σ)
-- | Point-wise binary operations
pw₂ : ∀ {A i} → Op₂ A → Op₂ (Str {i} A)
hd (pw₂ f σ τ) = f (hd σ) (hd τ)
tl (pw₂ f σ τ) = pw₂ f (tl σ) (tl τ)
[_] : K → Str K
hd [ r ] = r
tl [ r ] = [ 0# ]
-- | Can, in conjunction with _×_, delay stream.
X : Str K
hd X = 0#
tl X = [ 1# ]
_⊕_ : ∀{i} → Str {i} K → Str {i} K → Str {i} K
_⊕_ = pw₂ _+_
⊝_ : ∀{i} → Str {i} K → Str {i} K
⊝_ = pw₁ (-_)
_×_ : ∀ {i} → Str {i} K → Str {i} K → Str {i} K
hd (σ × τ) = hd σ ⋆ hd τ
tl (σ × τ) = (tl σ × τ) ⊕ ([ hd σ ] × tl τ)
-- | We restrict attention to the case where the head is 1,
-- which is trivially invertible in any ring.
hasInv : ∀ {i} → Str {i} K → Set
hasInv σ = hd σ ≈ 1#
-- | Construct convolution inverse, if it exists.
inv : ∀ {i} → (σ : Str {i} K) → hasInv σ → Str {i} K
hd (inv σ p) = hd σ
tl (inv σ p) = ⊝ (tl σ × inv σ p)
-- | Powers of delay stream
X^_ : ℕ → Str K
X^ 0 = [ 1# ]
X^ (suc k) = X × (X^ k)
{-
record Summable (σ : Str (Str K)) : Set where
coinductive
field
hd-smble : ∃ λ n → δ n (hd σ) ∼ [ 0# ]
tl-smble : Summable (tl σ)
open Summable
-}
SummableDiag : {A : Set} (f : A → K) → Set
SummableDiag {A} f =
∃ λ n →
Σ (Fin n → A) (λ g →
(a : A) → ¬ ((f a) ≈ 0#) → ∃ λ i → a ≡ g i)
record Summable {A : Set} (f : A → Str K) : Set where
coinductive
field
hd-smble : SummableDiag (hd ∘ f)
tl-smble : Summable (tl' ∘ f)
open Summable
-- | Sum a finitely indexed family of elements of K.
-- This relies on commutativity etc. of addition in K.
sum : {n : ℕ} → (Fin n → K) → K
sum {ℕ.zero} f = 0#
sum {ℕ.suc n} f = f Fin.zero + sum (f ∘ Fin.suc)
-- | Sum a family of streams.
∑ : ∀ {A} → (f : A → Str K) → Summable f → Str K
hd (∑ f p) =
let (_ , g , _) = hd-smble p
in sum (hd ∘ f ∘ g)
tl (∑ f p) = ∑ (tl' ∘ f) (tl-smble p)
-- | Constant family of zero streams is summable
zero-summable : Summable {ℕ} (λ n → [ 0# ])
hd-smble zero-summable
= (0 , f , q)
where
f : Fin 0 → ℕ
f ()
q : (n : ℕ) → ¬ (hd [ 0# ] ≈ 0#) → ∃ λ i → n ≡ f i
q n p = ⊥-elim (p (IsRing.refl isRing))
tl-smble zero-summable = zero-summable
polySeq : ∀{i} → Str {i} (Str K) → Str {i} (Str K)
hd (polySeq σ) = hd σ × (X^ 0)
tl (polySeq σ) = pw₂ _×_ (polySeq (tl σ)) (const X)
polySeq₁ : Str (Str K) → (ℕ → Str K)
polySeq₁ σ = _at_ (polySeq σ)
polySeq₂ : (ℕ → Str K) → (ℕ → Str K)
polySeq₂ f = polySeq₁ (toStr f)
polySeq-summable : (σ : Str (Str K)) → Summable (polySeq₁ σ)
hd-smble (polySeq-summable σ) = q
where
q : SummableDiag (hd ∘ polySeq₁ σ)
q = {!!}
tl-smble (polySeq-summable σ) = {!!}
{-
polySeq-expl : (σ : Str (Str K)) → (i : ℕ) → (polySeq σ at i) ≡ (σ at i) × (X^ i)
polySeq-expl σ zero = refl
polySeq-expl σ (suc i) =
polySeq σ at (ℕ.suc i)
≡⟨ ? ⟩
(σ at (ℕ.suc i)) × (X × (X^ i))
∎
-}
-- lem : {f : ℕ → Str K} {k n : ℕ} → ¬ (polySeq f k at n) ≈ 0# → k ≡ n
-- lem = {!!}
{-
polySeq-summable-aux : {f : ℕ → Str K} →
(n : ℕ) → (g : ℕ → Str K) → Summable (polySeq f)
hd-smble (polySeq-summable-aux f n) = (1 , supp , {!!})
where
p = polySeq f
supp : Fin 1 → ℕ
supp Fin.zero = n
supp (Fin.suc ())
is-supp : (k : ℕ) → ¬ (hd (p k) ≈ 0#) → ∃ λ i → k ≡ supp i
is-supp k q = (Fin.zero , {!!})
tl-smble (polySeq-summable-aux f n) = {!!}
-}
hd-delay-zero : (σ : Str K) → hd (X × σ) ≈ 0#
hd-delay-zero σ = zeroˡ (hd σ)
where
open IsNearSemiring (IsRing.isNearSemiring isRing)
⊕-cong : ∀ {i s t u v} → s ∼[ i ] t → u ∼[ i ] v → (s ⊕ u) ∼[ i ] (t ⊕ v)
hd≈ (⊕-cong s~t u~v) = +-cong (hd≈ s~t) (hd≈ u~v)
tl∼ (⊕-cong s~t u~v) = ⊕-cong (tl∼ s~t) (tl∼ u~v)
⊕-unitˡ : ∀ {i} → LeftIdentity (_∼_ {i}) [ 0# ] _⊕_
hd≈ (⊕-unitˡ s) = proj₁ +-identity (hd s)
tl∼ (⊕-unitˡ s) = ⊕-unitˡ (tl s)
⊕-comm : ∀ {i} → Commutative (_∼_ {i}) _⊕_
hd≈ (⊕-comm s t) = +-comm (hd s) (hd t)
tl∼ (⊕-comm s t) = ⊕-comm (tl s) (tl t)
⊕-unitʳ : ∀ {i} → RightIdentity (_∼_ {i}) [ 0# ] _⊕_
⊕-unitʳ s =
s-bisim-trans
(⊕-comm s [ 0# ])
(⊕-unitˡ s)
×-zeroˡ : ∀ {i} → LeftZero (_∼_ {i}) [ 0# ] _×_
hd≈ (×-zeroˡ s) = zeroˡ (hd s)
where
open IsNearSemiring (IsRing.isNearSemiring isRing)
tl∼ (×-zeroˡ s) {j} =
s-bisim-trans
(⊕-cong {j} (×-zeroˡ s) (×-zeroˡ (tl s)))
(⊕-unitˡ [ 0# ])
×-unitˡ : ∀ {i} → LeftIdentity (_∼_ {i}) [ 1# ] _×_
hd≈ (×-unitˡ s) = proj₁ *-identity (hd s)
tl∼ (×-unitˡ s) {j} =
s-bisim-trans
(⊕-cong {j} (×-zeroˡ s) (×-unitˡ (tl s)))
(⊕-unitˡ (tl s))
tl-delay-id : (σ : Str K) → tl (X × σ) ∼ σ
tl-delay-id σ =
begin∼
tl (X × σ)
∼⟨ S.refl ⟩
(tl X × σ) ⊕ ([ hd X ] × tl σ)
∼⟨ S.refl ⟩
([ 1# ] × σ) ⊕ ([ 0# ] × tl σ)
∼⟨ ⊕-cong (×-unitˡ σ) (×-zeroˡ (tl σ)) ⟩
σ ⊕ [ 0# ]
∼⟨ ⊕-unitʳ σ ⟩
σ
∎∼
where
module S = Setoid stream-setoid
-- | The analogue of the fundamental theorem
decomp-str : (σ : Str K) → σ ∼ ([ hd σ ] ⊕ (X × tl σ))
hd≈ (decomp-str σ) =
begin
hd σ
≈⟨ sym (+-identityʳ (hd σ)) ⟩
hd σ + 0#
≈⟨ sym (+-cong refl (hd-delay-zero (tl σ))) ⟩
hd [ hd σ ] + hd (X × tl σ)
≈⟨ refl ⟩
hd ([ hd σ ] ⊕ (X × tl σ))
∎
tl∼ (decomp-str σ) =
begin∼
tl σ
∼⟨ S.sym (tl-delay-id (tl σ)) ⟩
tl (X × tl σ)
∼⟨ S.sym (⊕-unitˡ (tl (X × tl σ))) ⟩
[ 0# ] ⊕ tl (X × tl σ)
∼⟨ S.refl ⟩
tl ([ hd σ ] ⊕ (X × tl σ))
∎∼
where
module S = Setoid stream-setoid
| {
"alphanum_fraction": 0.5208519511,
"avg_line_length": 25.2406015038,
"ext": "agda",
"hexsha": "9e8f7a9eade634175e4afd56f87022ed48c235a7",
"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": "Languages/Comb.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": "Languages/Comb.agda",
"max_line_length": 81,
"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": "Languages/Comb.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3012,
"size": 6714
} |
-- We apply the theory of quasi equivalence relations (QERs) to finite multisets and association lists.
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Relation.ZigZag.Applications.MultiSet where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.RelationalStructure
open import Cubical.Foundations.Structure
open import Cubical.Foundations.SIP
open import Cubical.Foundations.Univalence
open import Cubical.Data.Unit
open import Cubical.Data.Empty
open import Cubical.Data.Nat
open import Cubical.Data.List hiding ([_])
open import Cubical.Data.Sigma
open import Cubical.HITs.SetQuotients
open import Cubical.HITs.FiniteMultiset as FMS hiding ([_])
open import Cubical.HITs.FiniteMultiset.CountExtensionality
open import Cubical.Relation.Nullary
open import Cubical.Relation.ZigZag.Base
open import Cubical.Structures.MultiSet
open import Cubical.Structures.Relational.Macro
-- we define simple association lists without any higher constructors
data AList {ℓ} (A : Type ℓ) : Type ℓ where
⟨⟩ : AList A
⟨_,_⟩∷_ : A → ℕ → AList A → AList A
infixr 5 ⟨_,_⟩∷_
private
variable
ℓ : Level
A : Type ℓ
-- We have a CountStructure on List and AList and use these to get a QER between the two
module Lists&ALists {A : Type ℓ} (discA : Discrete A) where
module S = RelMacro ℓ (param A (recvar (constant (ℕ , isSetℕ))))
ι = CountEquivStr A (Discrete→isSet discA)
-- the CountStructures
aux : (a x : A) → Dec (a ≡ x) → ℕ → ℕ
aux a x (yes a≡x) n = suc n
aux a x (no a≢x) n = n
Lcount : S.structure (List A)
Lcount a [] = zero
Lcount a (x ∷ xs) = aux a x (discA a x) (Lcount a xs)
ALcount : S.structure (AList A)
ALcount a ⟨⟩ = zero
ALcount a (⟨ x , zero ⟩∷ xs) = ALcount a xs
ALcount a (⟨ x , suc n ⟩∷ xs) = aux a x (discA a x) (ALcount a (⟨ x , n ⟩∷ xs))
-- now for the QER between List and Alist
R : List A → AList A → Type ℓ
R xs ys = ∀ a → Lcount a xs ≡ ALcount a ys
φ : List A → AList A
φ [] = ⟨⟩
φ (x ∷ xs) = ⟨ x , 1 ⟩∷ φ xs
ψ : AList A → List A
ψ ⟨⟩ = []
ψ (⟨ x , zero ⟩∷ xs) = ψ xs
ψ (⟨ x , suc n ⟩∷ xs) = x ∷ ψ (⟨ x , n ⟩∷ xs)
η : ∀ x → R x (φ x)
η [] a = refl
η (x ∷ xs) a with (discA a x)
... | yes a≡x = cong suc (η xs a)
... | no a≢x = η xs a
-- for the other direction we need a little helper function
ε : ∀ y → R (ψ y) y
ε' : (x : A) (n : ℕ) (xs : AList A) (a : A)
→ Lcount a (ψ (⟨ x , n ⟩∷ xs)) ≡ ALcount a (⟨ x , n ⟩∷ xs)
ε ⟨⟩ a = refl
ε (⟨ x , n ⟩∷ xs) a = ε' x n xs a
ε' x zero xs a = ε xs a
ε' x (suc n) xs a with discA a x
... | yes a≡x = cong suc (ε' x n xs a)
... | no a≢x = ε' x n xs a
-- Induced quotients and equivalence
open isQuasiEquivRel
-- R is a QER
QuasiR : QuasiEquivRel _ _ ℓ
QuasiR .fst .fst = R
QuasiR .fst .snd _ _ = isPropΠ λ _ → isSetℕ _ _
QuasiR .snd .zigzag r r' r'' a = (r a) ∙∙ sym (r' a) ∙∙ (r'' a)
QuasiR .snd .fwd = φ
QuasiR .snd .fwdRel = η
QuasiR .snd .bwd = ψ
QuasiR .snd .bwdRel = ε
module E = QER→Equiv QuasiR
open E renaming (Rᴸ to Rᴸ; Rᴿ to Rᴬᴸ)
List/Rᴸ = (List A) / Rᴸ
AList/Rᴬᴸ = (AList A) / Rᴬᴸ
List/Rᴸ≃AList/Rᴬᴸ : List/Rᴸ ≃ AList/Rᴬᴸ
List/Rᴸ≃AList/Rᴬᴸ = E.Thm
main : QERDescends _ S.relation (List A , Lcount) (AList A , ALcount) QuasiR
main = structuredQER→structuredEquiv _ S.suitable _ _ QuasiR (λ a r → r a)
open QERDescends
LQcount : S.structure List/Rᴸ
LQcount = main .quoᴸ .fst
ALQcount : S.structure AList/Rᴬᴸ
ALQcount = main .quoᴿ .fst
-- We get a path between CountStructures over the equivalence directly from the fact that the QER
-- is structured
List/Rᴸ≡AList/Rᴬᴸ :
Path (TypeWithStr ℓ S.structure) (List/Rᴸ , LQcount) (AList/Rᴬᴸ , ALQcount)
List/Rᴸ≡AList/Rᴬᴸ =
sip S.univalent _ _ (E.Thm , (S.matches _ _ E.Thm .fst (main .rel)))
-- We now show that List/Rᴸ≃FMSet
_∷/_ : A → List/Rᴸ → List/Rᴸ
a ∷/ [ xs ] = [ a ∷ xs ]
a ∷/ eq/ xs xs' r i = eq/ (a ∷ xs) (a ∷ xs') r' i
where
r' : Rᴸ (a ∷ xs) (a ∷ xs')
r' a' = cong (aux a' a (discA a' a)) (r a')
a ∷/ squash/ xs xs₁ p q i j = squash/ (a ∷/ xs) (a ∷/ xs₁) (cong (a ∷/_) p) (cong (a ∷/_) q) i j
infixr 5 _∷/_
μ : FMSet A → List/Rᴸ
μ = FMS.Rec.f squash/ [ [] ] _∷/_ β
where
β : ∀ a b [xs] → a ∷/ b ∷/ [xs] ≡ b ∷/ a ∷/ [xs]
β a b = elimProp (λ _ → squash/ _ _) (λ xs → eq/ _ _ (γ xs))
where
γ : ∀ xs → Rᴸ (a ∷ b ∷ xs) (b ∷ a ∷ xs)
γ xs c = δ c ∙ η (b ∷ a ∷ xs) c
where
δ : ∀ c → Lcount c (a ∷ b ∷ xs) ≡ Lcount c (b ∷ a ∷ xs)
δ c with discA c a | discA c b
δ c | yes _ | yes _ = refl
δ c | yes _ | no _ = refl
δ c | no _ | yes _ = refl
δ c | no _ | no _ = refl
-- The inverse is induced by the standard projection of lists into finite multisets,
-- which is a morphism of CountStructures
-- Moreover, we need 'count-extensionality' for finite multisets
List→FMSet : List A → FMSet A
List→FMSet [] = []
List→FMSet (x ∷ xs) = x ∷ List→FMSet xs
List→FMSet-count : ∀ a xs → Lcount a xs ≡ FMScount discA a (List→FMSet xs)
List→FMSet-count a [] = refl
List→FMSet-count a (x ∷ xs) with discA a x
... | yes _ = cong suc (List→FMSet-count a xs)
... | no _ = List→FMSet-count a xs
ν : List/Rᴸ → FMSet A
ν [ xs ] = List→FMSet xs
ν (eq/ xs ys r i) = path i
where
countsAgree : ∀ a → Lcount a xs ≡ Lcount a ys
countsAgree a = r a ∙ sym (η ys a)
θ : ∀ a → FMScount discA a (List→FMSet xs) ≡ FMScount discA a (List→FMSet ys)
θ a = sym (List→FMSet-count a xs) ∙∙ countsAgree a ∙∙ List→FMSet-count a ys
path : List→FMSet xs ≡ List→FMSet ys
path = FMScountExt.Thm discA _ _ θ
ν (squash/ xs/ xs/' p q i j) = trunc (ν xs/) (ν xs/') (cong ν p) (cong ν q) i j
σ : section μ ν
σ = elimProp (λ _ → squash/ _ _) θ
where
θ : (xs : List A) → μ (ν [ xs ]) ≡ [ xs ]
θ [] = refl
θ (x ∷ xs) = cong (x ∷/_) (θ xs)
ν-∷/-commute : (x : A) (ys : List/Rᴸ) → ν (x ∷/ ys) ≡ x ∷ ν ys
ν-∷/-commute x = elimProp (λ _ → FMS.trunc _ _) λ xs → refl
τ : retract μ ν
τ = FMS.ElimProp.f (FMS.trunc _ _) refl θ
where
θ : ∀ x {xs} → ν (μ xs) ≡ xs → ν (μ (x ∷ xs)) ≡ x ∷ xs
θ x {xs} p = ν-∷/-commute x (μ xs) ∙ cong (x ∷_) p
List/Rᴸ≃FMSet : List/Rᴸ ≃ FMSet A
List/Rᴸ≃FMSet = isoToEquiv (iso ν μ τ σ)
List/Rᴸ≃FMSet-is-CountEquivStr : ι (List/Rᴸ , LQcount) (FMSet A , FMScount discA) List/Rᴸ≃FMSet
List/Rᴸ≃FMSet-is-CountEquivStr a = elimProp (λ _ → isSetℕ _ _) (List→FMSet-count a)
{-
Putting everything together we get:
≃
List/Rᴸ ------------> AList/Rᴬᴸ
|
|≃
|
∨
≃
FMSet A ------------> AssocList A
We thus get that AList/Rᴬᴸ≃AssocList.
Constructing such an equivalence directly requires count extensionality for association lists,
which should be even harder to prove than for finite multisets.
This strategy should work for all implementations of multisets with HITs.
We just have to show that:
∙ The HIT is equivalent to FMSet (like AssocList)
∙ There is a QER between lists and the basic data type of the HIT
with the higher constructors removed (like AList)
Then we get that this HIT is equivalent to the corresponding set quotient that identifies elements
that give the same count on each a : A.
TODO: Show that all the equivalences are indeed isomorphisms of multisets not only of CountStructures!
-}
| {
"alphanum_fraction": 0.6120712576,
"avg_line_length": 31.4728033473,
"ext": "agda",
"hexsha": "5be3ff3433835fdf0787d791f8a98e9c1a1e9ef2",
"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": "d13941587a58895b65f714f1ccc9c1f5986b109c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "RobertHarper/cubical",
"max_forks_repo_path": "Cubical/Relation/ZigZag/Applications/MultiSet.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c",
"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": "RobertHarper/cubical",
"max_issues_repo_path": "Cubical/Relation/ZigZag/Applications/MultiSet.agda",
"max_line_length": 103,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "RobertHarper/cubical",
"max_stars_repo_path": "Cubical/Relation/ZigZag/Applications/MultiSet.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2944,
"size": 7522
} |
{-# OPTIONS --warning=error #-}
{-# POLARITY F #-}
{-# POLARITY G #-}
| {
"alphanum_fraction": 0.5211267606,
"avg_line_length": 14.2,
"ext": "agda",
"hexsha": "a89705ac7fdae94e804993f5fc612d246161f18a",
"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/Unknown-names-in-polarity-pragmas.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/Unknown-names-in-polarity-pragmas.agda",
"max_line_length": 31,
"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/Unknown-names-in-polarity-pragmas.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": 19,
"size": 71
} |
------------------------------------------------------------------------
-- An alternative definition of equality
------------------------------------------------------------------------
module TotalParserCombinators.CoinductiveEquality where
open import Codata.Musical.Notation
open import Data.List
open import Data.List.Membership.Propositional using (_∈_)
open import Data.List.Relation.Binary.BagAndSetEquality
using () renaming (_∼[_]_ to _List-∼[_]_)
open import Function.Equivalence as Eq using (_⇔_)
import Function.Related as Related
open Related using (SK-sym)
open Related.EquationalReasoning
open import TotalParserCombinators.Parser
open import TotalParserCombinators.Semantics
import TotalParserCombinators.InitialBag as I
open import TotalParserCombinators.Derivative as D using (D)
infix 5 _∷_
infix 4 _∼[_]c_
-- Two recognisers/languages are equal if their nullability indices
-- are equal (according to _List-∼[_]_) and all their derivatives are
-- equal (coinductively). Note that the inhabitants of this type are
-- bisimulations (if the Kind stands for a symmetric relation).
data _∼[_]c_ {Tok R xs₁ xs₂}
(p₁ : Parser Tok R xs₁) (k : Kind)
(p₂ : Parser Tok R xs₂) : Set where
_∷_ : (init : xs₁ List-∼[ k ] xs₂)
(rest : ∀ t → ∞ (D t p₁ ∼[ k ]c D t p₂)) →
p₁ ∼[ k ]c p₂
-- The two definitions of parser/language equivalence are equivalent.
sound : ∀ {k Tok R xs₁ xs₂}
{p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂} →
p₁ ∼[ k ]c p₂ → p₁ ∼[ k ] p₂
sound {xs₁ = xs₁} {xs₂} {p₁} {p₂} (xs₁≈xs₂ ∷ rest) {x} {[]} =
x ∈ p₁ · [] ↔⟨ I.correct ⟩
(x ∈ xs₁) ∼⟨ xs₁≈xs₂ ⟩
(x ∈ xs₂) ↔⟨ SK-sym I.correct ⟩
x ∈ p₂ · [] ∎
sound {xs₁ = xs₁} {xs₂} {p₁} {p₂} (xs₁≈xs₂ ∷ rest) {x} {t ∷ s} =
x ∈ p₁ · t ∷ s ↔⟨ SK-sym D.correct ⟩
x ∈ D t p₁ · s ∼⟨ sound (♭ (rest t)) ⟩
x ∈ D t p₂ · s ↔⟨ D.correct ⟩
x ∈ p₂ · t ∷ s ∎
complete : ∀ {k Tok R xs₁ xs₂}
{p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂} →
p₁ ∼[ k ] p₂ → p₁ ∼[ k ]c p₂
complete p₁≈p₂ =
(λ {_} → I.cong p₁≈p₂) ∷ λ t → ♯ complete (D.cong p₁≈p₂)
correct : ∀ {k Tok R xs₁ xs₂}
{p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂} →
p₁ ∼[ k ]c p₂ ⇔ p₁ ∼[ k ] p₂
correct = Eq.equivalence sound complete
| {
"alphanum_fraction": 0.5776048422,
"avg_line_length": 36.140625,
"ext": "agda",
"hexsha": "d7b6f2577cb07e4ee7e09387d4436b2e34dacf2a",
"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": "76774f54f466cfe943debf2da731074fe0c33644",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/parser-combinators",
"max_forks_repo_path": "TotalParserCombinators/CoinductiveEquality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"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/parser-combinators",
"max_issues_repo_path": "TotalParserCombinators/CoinductiveEquality.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/parser-combinators",
"max_stars_repo_path": "TotalParserCombinators/CoinductiveEquality.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z",
"num_tokens": 823,
"size": 2313
} |
{-# OPTIONS --type-in-type --guardedness #-}
module IO.Instance where
open import Class.Monad using (Monad)
open import Class.Monad.IO
open import Class.Monoid
open import Data.Product
open import Data.Sum
open import IO
open import Monads.ExceptT
open import Monads.StateT
open import Monads.WriterT
open import Level
instance
IO-Monad : Monad IO
IO-Monad = record { _>>=_ = _>>=_ ; return = return }
IO-MonadIO : MonadIO IO
IO-MonadIO = record { liftIO = λ x -> x }
module _ {a} {M : Set a -> Set a} {{_ : Monad M}} {{_ : MonadIO M}} where
ExceptT-MonadIO : ∀ {E} -> MonadIO (ExceptT M E) {{ExceptT-Monad}}
ExceptT-MonadIO = record { liftIO = λ x -> liftIO (x >>= λ a -> return (inj₂ a)) }
StateT-MonadIO : ∀ {S} -> MonadIO (StateT M S)
StateT-MonadIO = record { liftIO = λ x -> λ s -> liftIO (x >>= (λ a -> return (a , s))) }
WriterT-MonadIO : ∀ {W} {{_ : Monoid W}} -> MonadIO (WriterT M W) {{WriterT-Monad}}
WriterT-MonadIO = record { liftIO = λ x -> liftIO (x >>= λ a -> return (a , mzero)) }
| {
"alphanum_fraction": 0.6293436293,
"avg_line_length": 30.4705882353,
"ext": "agda",
"hexsha": "eb27a2e69170c71f7fc171b767682ef57f655570",
"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": "stdlib-exts/IO/Instance.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": "stdlib-exts/IO/Instance.agda",
"max_line_length": 91,
"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": "stdlib-exts/IO/Instance.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": 349,
"size": 1036
} |
------------------------------------------------------------------------------
-- The FOTC lists type
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- N.B. This module is re-exported by FOTC.Data.List.
module FOTC.Data.List.Type where
open import FOTC.Base
open import FOTC.Base.List
------------------------------------------------------------------------------
-- The FOTC lists type (inductive predicate for total lists).
data List : D → Set where
lnil : List []
lcons : ∀ x {xs} → List xs → List (x ∷ xs)
{-# ATP axioms lnil lcons #-}
-- Induction principle.
List-ind : (A : D → Set) →
A [] →
(∀ x {xs} → A xs → A (x ∷ xs)) →
∀ {xs} → List xs → A xs
List-ind A A[] h lnil = A[]
List-ind A A[] h (lcons x Lxs) = h x (List-ind A A[] h Lxs)
| {
"alphanum_fraction": 0.413,
"avg_line_length": 32.2580645161,
"ext": "agda",
"hexsha": "d2fff1174b47869ad5b40cd71b7e96e39a1d4dc8",
"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": "src/fot/FOTC/Data/List/Type.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": "src/fot/FOTC/Data/List/Type.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": "src/fot/FOTC/Data/List/Type.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": 238,
"size": 1000
} |
-- Andreas, 2012-10-18
module Issue481 where
as = Set
open import Common.Issue481ParametrizedModule as as -- as clause
open import Common.Issue481ParametrizedModule as as as -- as clause, duplicate def.
| {
"alphanum_fraction": 0.7740384615,
"avg_line_length": 18.9090909091,
"ext": "agda",
"hexsha": "9a98c291144800cf917ec0a337e0def54c0b5350",
"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": "test/fail/Issue481.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/Issue481.agda",
"max_line_length": 83,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "np/agda-git-experiment",
"max_stars_repo_path": "test/fail/Issue481.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": 56,
"size": 208
} |
open import MLib.Algebra.PropertyCode
open import MLib.Algebra.PropertyCode.Structures
module MLib.Matrix.SemiTensor.Associativity {c ℓ} (struct : Struct bimonoidCode c ℓ) where
open import MLib.Prelude
open import MLib.Matrix.Core
open import MLib.Matrix.Equality struct
open import MLib.Matrix.Mul struct
open import MLib.Matrix.Tensor struct
open import MLib.Matrix.SemiTensor.Core struct
open import MLib.Algebra.Operations struct
open Nat using () renaming (_+_ to _+ℕ_; _*_ to _*ℕ_)
open import MLib.Fin.Parts.Simple
open import Data.Nat.LCM
open import Data.Nat.Divisibility
module _ ⦃ props : Has (1# is rightIdentity for * ∷ associative on * ∷ []) ⦄ where
open _≃_
{-
m *ℕ (lcm n (p * (lcm q r) / q))/n ≡ m *ℕ (lcm n p)/n *ℕ (lcm (q *ℕ (lcm n p)/p) r) / r
m * lcm(n, p * lcm(q, r) / q) / n =
m * (lcm(n, p) / n) * lcm (q * lcm(n, p) / p, r) / r
lcm(n, p * lcm(q, r) / q) = lcm (q * lcm(n, p) / p, r) * p / q
f(a, b) = lcm(a, b) / a
lcm(n, p * f(q, r)) = lcm(r, q * f(p, n)) * p / q
-}
module _ {m n p q r s} (A : Matrix S m n) (B : Matrix S p q) (C : Matrix S r s) where
t₁ = lcm n p .proj₁
lcm-n-p=t₁ = lcm n p .proj₂
open Defn lcm-n-p=t₁ using () renaming (t/n to t₁/n; t/p to t₁/p)
t₂ = lcm q r .proj₁
lcm-q-r=t₂ = lcm q r .proj₂
open Defn lcm-q-r=t₂ using () renaming (t/n to t₂/q; t/p to t₂/r)
t₃ = lcm n (p *ℕ t₂/q) .proj₁
lcm-n-pt₂/q=t₃ = lcm n (p *ℕ t₂/q) .proj₂
open Defn lcm-n-pt₂/q=t₃ using () renaming (t/n to t₃/n; t/p to t₃/[p*t₂/q])
t₄ = lcm (q *ℕ t₁/p) r .proj₁
lcm-qt₁/p-r=t₄ = lcm (q *ℕ t₁/p) r .proj₂
open Defn lcm-qt₁/p-r=t₄ using () renaming (t/n to t₄/[q*t₁/p]; t/p to t₄/r)
-- module D₁ = Defn {n} {p} {q}
-- module D₂ = Defn {q} {r} {s}
⋉-associative : A ⋉ (B ⋉ C) ≃ (A ⋉ B) ⋉ C
⋉-associative .m≡p = {!!}
⋉-associative .n≡q = {!!}
⋉-associative .equal = {!!}
| {
"alphanum_fraction": 0.5813221406,
"avg_line_length": 29.78125,
"ext": "agda",
"hexsha": "76f110ef3d8cd665e9d090f57e185fe08a684f9e",
"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": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bch29/agda-matrices",
"max_forks_repo_path": "src/MLib/Matrix/SemiTensor/Associativity.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"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": "bch29/agda-matrices",
"max_issues_repo_path": "src/MLib/Matrix/SemiTensor/Associativity.agda",
"max_line_length": 90,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bch29/agda-matrices",
"max_stars_repo_path": "src/MLib/Matrix/SemiTensor/Associativity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 801,
"size": 1906
} |
{-# OPTIONS -v interaction.case:65 #-}
data Bool : Set where
true false : Bool
test : Bool → Bool
test x = {!x!}
| {
"alphanum_fraction": 0.6153846154,
"avg_line_length": 14.625,
"ext": "agda",
"hexsha": "046db4e252b79bfed7551ff4edf5f3eb01ce9186",
"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/interaction/Issue1842.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/interaction/Issue1842.agda",
"max_line_length": 38,
"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/interaction/Issue1842.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 34,
"size": 117
} |
module CTL.Modalities where
open import CTL.Modalities.AF public
open import CTL.Modalities.AG public
open import CTL.Modalities.AN public
-- open import CTL.Modalities.AU public -- TODO Unfinished
open import CTL.Modalities.EF public
open import CTL.Modalities.EG public
open import CTL.Modalities.EN public
-- open import CTL.Modalities.EU public -- TODO Unfinished
| {
"alphanum_fraction": 0.8130081301,
"avg_line_length": 33.5454545455,
"ext": "agda",
"hexsha": "e9aee848a0d6eeefad0c981a9ea8758808ae834a",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-12-13T15:56:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-12-13T15:56:38.000Z",
"max_forks_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "zimbatm/condatis",
"max_forks_repo_path": "CTL/Modalities.agda",
"max_issues_count": 5,
"max_issues_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446",
"max_issues_repo_issues_event_max_datetime": "2020-09-01T16:52:07.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-06-03T20:02:22.000Z",
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "zimbatm/condatis",
"max_issues_repo_path": "CTL/Modalities.agda",
"max_line_length": 58,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "64d95885579395f641e9a9cb1b9487cf79280446",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "Aerate/condatis",
"max_stars_repo_path": "CTL/Modalities.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-13T16:52:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-13T16:52:28.000Z",
"num_tokens": 95,
"size": 369
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Agda.Primitive
module Basic where
data False : Set where
record True : Set where
data _||_ {a b : _} (A : Set a) (B : Set b) : Set (a ⊔ b) where
inl : A → A || B
inr : B → A || B
infix 1 _||_
| {
"alphanum_fraction": 0.5833333333,
"avg_line_length": 17.6,
"ext": "agda",
"hexsha": "c08a95f2521f1c4f21fe02995126202479f51389",
"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": "3d56e649152d2cd906281943860ca19da1d1f344",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/CubicalTutorial",
"max_forks_repo_path": "Basic.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3d56e649152d2cd906281943860ca19da1d1f344",
"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": "Smaug123/CubicalTutorial",
"max_issues_repo_path": "Basic.agda",
"max_line_length": 63,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "3d56e649152d2cd906281943860ca19da1d1f344",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/CubicalTutorial",
"max_stars_repo_path": "Basic.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-16T23:14:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-26T17:02:42.000Z",
"num_tokens": 94,
"size": 264
} |
------------------------------------------------------------------------
-- A formalisation of some definitions and laws from Section 3 of Ralf
-- Hinze's paper "Streams and Unique Fixed Points"
------------------------------------------------------------------------
module Hinze.Section3 where
open import Stream.Programs
open import Stream.Equality
open import Stream.Pointwise
open import Hinze.Section2-4
open import Hinze.Lemmas
open import Codata.Musical.Notation hiding (∞)
open import Data.Product
open import Data.Bool
open import Data.Vec hiding (_⋎_)
open import Data.Nat
import Data.Nat.Properties as Nat
import Relation.Binary.PropositionalEquality as P
open import Algebra.Structures
private
module CS = IsCommutativeSemiring Nat.+-*-isCommutativeSemiring
------------------------------------------------------------------------
-- Definitions
pot : Prog Bool
pot = true ≺ ♯ (pot ⋎ false ∞)
msb : Prog ℕ
msb = 1 ≺ ♯ (2 ∞ ⟨ _*_ ⟩ msb ⋎ 2 ∞ ⟨ _*_ ⟩ msb)
ones′ : Prog ℕ
ones′ = 1 ≺ ♯ (ones′ ⋎ ones′ ⟨ _+_ ⟩ 1 ∞)
ones : Prog ℕ
ones = 0 ≺♯ ones′
carry : Prog ℕ
carry = 0 ≺ ♯ (carry ⟨ _+_ ⟩ 1 ∞ ⋎ 0 ∞)
carry-folded : carry ≊ 0 ∞ ⋎ carry ⟨ _+_ ⟩ 1 ∞
carry-folded = carry ∎
2^carry : Prog ℕ
2^carry = 2 ∞ ⟨ _^_ ⟩ carry
turn-length : ℕ → ℕ
turn-length zero = zero
turn-length (suc n) = ℓ + suc ℓ
where ℓ = turn-length n
turn : (n : ℕ) → Vec ℕ (turn-length n)
turn zero = []
turn (suc n) = turn n ++ [ n ] ++ turn n
tree : ℕ → Prog ℕ
tree n = n ≺ ♯ (turn n ≺≺ tree (suc n))
frac : Prog ℕ
frac = 0 ≺ ♯ (frac ⋎ nat ⟨ _+_ ⟩ 1 ∞)
frac-folded : frac ≊ nat ⋎ frac
frac-folded = frac ∎
god : Prog ℕ
god = (2 ∞ ⟨ _*_ ⟩ frac) ⟨ _+_ ⟩ 1 ∞
------------------------------------------------------------------------
-- Laws and properties
god-lemma : god ≊ 2*nat+1 ⋎ god
god-lemma =
god
≡⟨ P.refl ⟩
(2 ∞ ⟨ _*_ ⟩ (nat ⋎ frac)) ⟨ _+_ ⟩ 1 ∞
≊⟨ ⟨ _+_ ⟩-cong (2 ∞ ⟨ _*_ ⟩ (nat ⋎ frac))
(2*nat ⋎ 2 ∞ ⟨ _*_ ⟩ frac)
(zip-const-⋎ _*_ 2 nat frac)
(1 ∞) (1 ∞) (1 ∞ ∎) ⟩
(2*nat ⋎ 2 ∞ ⟨ _*_ ⟩ frac) ⟨ _+_ ⟩ 1 ∞
≊⟨ zip-⋎-const _+_ 2*nat (2 ∞ ⟨ _*_ ⟩ frac) 1 ⟩
2*nat+1 ⋎ god
∎
carry-god-nat : 2^carry ⟨ _*_ ⟩ god ≊ tailP nat
carry-god-nat =
2^carry ⟨ _*_ ⟩ god
≡⟨ P.refl ⟩
(2 ∞ ⟨ _^_ ⟩ (0 ∞ ⋎ carry ⟨ _+_ ⟩ 1 ∞)) ⟨ _*_ ⟩ god
≊⟨ ⟨ _*_ ⟩-cong (2 ∞ ⟨ _^_ ⟩ (0 ∞ ⋎ carry ⟨ _+_ ⟩ 1 ∞))
(1 ∞ ⋎ 2 ∞ ⟨ _*_ ⟩ 2^carry) lemma
god (2*nat+1 ⋎ god) god-lemma ⟩
(1 ∞ ⋎ 2 ∞ ⟨ _*_ ⟩ 2^carry) ⟨ _*_ ⟩ (2*nat+1 ⋎ god)
≊⟨ ≅-sym (abide-law _*_ (1 ∞) 2*nat+1
(2 ∞ ⟨ _*_ ⟩ 2^carry) god) ⟩
1 ∞ ⟨ _*_ ⟩ 2*nat+1 ⋎ (2 ∞ ⟨ _*_ ⟩ 2^carry) ⟨ _*_ ⟩ god
≊⟨ ⋎-cong (1 ∞ ⟨ _*_ ⟩ 2*nat+1) 2*nat+1
(pointwise 1 (λ s → 1 ∞ ⟨ _*_ ⟩ s) (λ s → s)
(proj₁ CS.*-identity) 2*nat+1)
((2 ∞ ⟨ _*_ ⟩ 2^carry) ⟨ _*_ ⟩ god)
(2 ∞ ⟨ _*_ ⟩ (2^carry ⟨ _*_ ⟩ god))
(pointwise 3 (λ s t u → (s ⟨ _*_ ⟩ t) ⟨ _*_ ⟩ u)
(λ s t u → s ⟨ _*_ ⟩ (t ⟨ _*_ ⟩ u))
CS.*-assoc (2 ∞) 2^carry god) ⟩
2*nat+1 ⋎ 2 ∞ ⟨ _*_ ⟩ (2^carry ⟨ _*_ ⟩ god)
≊⟨ P.refl ≺ coih ⟩
2*nat+1 ⋎ 2 ∞ ⟨ _*_ ⟩ tailP nat
≊⟨ ≅-sym (tailP-cong nat (2*nat ⋎ 2*nat+1) nat-lemma₂) ⟩
tailP nat
∎
where
coih = ♯ ⋎-cong (2 ∞ ⟨ _*_ ⟩ (2^carry ⟨ _*_ ⟩ god))
(2 ∞ ⟨ _*_ ⟩ (tailP nat))
(⟨ _*_ ⟩-cong (2 ∞) (2 ∞) (2 ∞ ∎)
(2^carry ⟨ _*_ ⟩ god) (tailP nat)
carry-god-nat)
(tailP 2*nat+1) (tailP 2*nat+1) (tailP 2*nat+1 ∎)
lemma =
2^carry
≡⟨ P.refl ⟩
2 ∞ ⟨ _^_ ⟩ (0 ∞ ⋎ carry ⟨ _+_ ⟩ 1 ∞)
≊⟨ zip-const-⋎ _^_ 2 (0 ∞) (carry ⟨ _+_ ⟩ 1 ∞) ⟩
2 ∞ ⟨ _^_ ⟩ 0 ∞ ⋎ 2 ∞ ⟨ _^_ ⟩ (carry ⟨ _+_ ⟩ 1 ∞)
≊⟨ ⋎-cong (2 ∞ ⟨ _^_ ⟩ 0 ∞) (1 ∞)
(pointwise 0 (2 ∞ ⟨ _^_ ⟩ 0 ∞) (1 ∞) P.refl)
(2 ∞ ⟨ _^_ ⟩ (carry ⟨ _+_ ⟩ 1 ∞))
(2 ∞ ⟨ _*_ ⟩ 2^carry)
(pointwise 1 (λ s → 2 ∞ ⟨ _^_ ⟩ (s ⟨ _+_ ⟩ 1 ∞))
(λ s → 2 ∞ ⟨ _*_ ⟩ (2 ∞ ⟨ _^_ ⟩ s))
(λ x → P.cong (_^_ 2) (CS.+-comm x 1))
carry) ⟩
1 ∞ ⋎ 2 ∞ ⟨ _*_ ⟩ 2^carry
∎
| {
"alphanum_fraction": 0.2944087086,
"avg_line_length": 44.2554744526,
"ext": "agda",
"hexsha": "f1220b355128a90dc3c6f126e10ecfbc7dd41e9d",
"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": "Hinze/Section3.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": "Hinze/Section3.agda",
"max_line_length": 117,
"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": "Hinze/Section3.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": 1864,
"size": 6063
} |
------------------------------------------------------------------------
-- The one-sided Step function, used to define similarity and the
-- two-sided Step function
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Prelude
open import Labelled-transition-system
module Similarity.Step
{ℓ}
(lts : LTS ℓ)
(open LTS lts)
(_[_]↝_ : Proc → Label → Proc → Type ℓ)
where
open import Equality.Propositional
open import Logical-equivalence using (_⇔_)
open import Bijection equality-with-J as Bijection using (_↔_)
import Equivalence equality-with-J as Eq
open import Function-universe equality-with-J as F hiding (id; _∘_)
open import H-level equality-with-J
open import H-level.Closure equality-with-J
open import Indexed-container hiding (⟨_⟩)
open import Relation
private
module Temporarily-private where
-- If _[_]↝_ is instantiated with _[_]⟶_, then this is basically the
-- function s from Section 6.3.4.2 in Pous and Sangiorgi's
-- "Enhancements of the bisimulation proof method", except that
-- clause (3) is omitted.
--
-- Similarly, if _[_]↝_ is instantiated with _[_]⇒̂_, then this is
-- basically the function w from Section 6.5.2.4, except that
-- "P R Q" is omitted.
record Step {r} (R : Rel₂ r Proc) (pq : Proc × Proc) :
Type (ℓ ⊔ r) where
constructor ⟨_⟩
private
p = proj₁ pq
q = proj₂ pq
field
challenge : ∀ {p′ μ} →
p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]↝ q′ × R (p′ , q′)
open Temporarily-private using (Step)
-- Used to aid unification. Note that this type is parametrised (see
-- the module telescope above). The inclusion of a value of this type
-- in the definition of StepC below makes it easier for Agda to infer
-- the LTS parameter from the types ν StepC i (p , q) and
-- ν′ StepC i (p , q).
record Magic : Type where
-- The Magic type is isomorphic to the unit type.
Magic↔⊤ : Magic ↔ ⊤
Magic↔⊤ = record
{ surjection = record
{ right-inverse-of = λ _ → refl
}
; left-inverse-of = λ _ → refl
}
-- The Step function, expressed as an indexed container.
StepC : Container (Proc × Proc) (Proc × Proc)
StepC =
(λ { (p , q) → Magic -- Included in order to aid type inference.
×
(∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]↝ q′)
})
◁
(λ { {o = p , q} (_ , lr) (p′ , q′) →
∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ p′) → proj₁ (lr p⟶p′) ≡ q′
})
-- The definition of Step in terms of a container is pointwise
-- logically equivalent to the direct definition, and in the presence
-- of extensionality it is pointwise isomorphic to the direct
-- definition.
Step↔StepC :
∀ {k r} {R : Rel₂ r Proc} {pq} →
Extensionality? k ℓ (ℓ ⊔ r) →
Step R pq ↝[ k ] ⟦ StepC ⟧ R pq
Step↔StepC {r = r} {R} {pq} =
generalise-ext?
Step⇔StepC
(λ ext →
(λ (_ , f) →
Σ-≡,≡→≡ refl $
implicit-extensionality ext λ _ →
apply-ext (lower-extensionality lzero ℓ ext) $
to₂∘from f)
, (λ _ → refl))
where
to₁ : Step R pq → Container.Shape StepC pq
to₁ Temporarily-private.⟨ lr ⟩ =
_
, (λ p⟶p′ → Σ-map id proj₁ (lr p⟶p′))
to₂ :
(s : Step R pq) →
Container.Position StepC (to₁ s) ⊆ R
to₂ Temporarily-private.⟨ lr ⟩ (_ , p⟶p′ , refl) =
proj₂ (proj₂ (lr p⟶p′))
from : ⟦ StepC ⟧ R pq → Step R pq
from ((_ , lr) , f) =
Temporarily-private.⟨ (λ p⟶p′ →
let q′ , q⟶q′ = lr p⟶p′
in q′ , q⟶q′ , f (_ , p⟶p′ , refl))
⟩
Step⇔StepC : Step R pq ⇔ ⟦ StepC ⟧ R pq
Step⇔StepC = record
{ to = λ s → to₁ s , to₂ s
; from = from
}
to₂∘from :
∀ {p′q′} {s : Container.Shape StepC pq}
(f : Container.Position StepC s ⊆ R) →
(pos : Container.Position StepC s p′q′) →
proj₂ (_⇔_.to Step⇔StepC (_⇔_.from Step⇔StepC (s , f))) pos ≡ f pos
to₂∘from f (_ , _ , refl) = refl
module StepC {r} {R : Rel₂ r Proc} {p q} where
-- A "constructor".
⟨_⟩ :
(∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]↝ q′ × R (p′ , q′)) →
⟦ StepC ⟧ R (p , q)
⟨ lr ⟩ = _⇔_.to (Step↔StepC _) Temporarily-private.⟨ lr ⟩
-- A "projection".
challenge :
⟦ StepC ⟧ R (p , q) →
∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ λ q′ → q [ μ ]↝ q′ × R (p′ , q′)
challenge = Step.challenge ∘ _⇔_.from (Step↔StepC _)
open Temporarily-private public
-- An unfolding lemma for ⟦ StepC ⟧₂.
⟦StepC⟧₂↔ :
∀ {x} {X : Rel₂ x Proc} →
Extensionality ℓ ℓ →
(R : ∀ {o} → Rel₂ ℓ (X o)) →
∀ {p q} (p∼q₁ p∼q₂ : ⟦ StepC ⟧ X (p , q)) →
⟦ StepC ⟧₂ R (p∼q₁ , p∼q₂)
↔
(∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
let q′₁ , q⟶q′₁ , p′≤q′₁ = StepC.challenge p∼q₁ p⟶p′
q′₂ , q⟶q′₂ , p′≤q′₂ = StepC.challenge p∼q₂ p⟶p′
in ∃ λ (q′₁≡q′₂ : q′₁ ≡ q′₂) →
subst (q [ μ ]↝_) q′₁≡q′₂ q⟶q′₁ ≡ q⟶q′₂
×
R (subst (X ∘ (p′ ,_)) q′₁≡q′₂ p′≤q′₁ , p′≤q′₂))
⟦StepC⟧₂↔ {X = X} ext R {p} {q}
(s₁@(_ , ch₁) , f₁) (s₂@(_ , ch₂) , f₂) =
(∃ λ (eq : s₁ ≡ s₂) →
∀ {o} (p : Container.Position StepC s₁ o) →
R (f₁ p , f₂ (subst (λ s → Container.Position StepC s o) eq p))) ↝⟨ inverse $ Σ-cong ≡×≡↔≡ (λ _ → F.id) ⟩
(∃ λ (eq : proj₁ s₁ ≡ proj₁ s₂ × (λ {_ _} → ch₁) ≡ ch₂) →
∀ {o} (p : Container.Position StepC s₁ o) →
R (f₁ p , f₂ (subst (λ s → Container.Position StepC s o)
(cong₂ _,_ (proj₁ eq) (proj₂ eq)) p))) ↝⟨ inverse Σ-assoc ⟩
(∃ λ (eq₁ : proj₁ s₁ ≡ proj₁ s₂) →
∃ λ (eq₂ : (λ {_ _} → ch₁) ≡ ch₂) →
∀ {o} (p : Container.Position StepC s₁ o) →
R (f₁ p , f₂ (subst (λ s → Container.Position StepC s o)
(cong₂ _,_ eq₁ eq₂) p))) ↝⟨ drop-⊤-left-Σ $ _⇔_.to contractible⇔↔⊤ $
+⇒≡ $ mono₁ 0 (_⇔_.from contractible⇔↔⊤ Magic↔⊤) ⟩
(∃ λ (eq : (λ {_ _} → ch₁) ≡ ch₂) →
∀ {o} (p : Container.Position StepC s₁ o) →
R (f₁ p , f₂ (subst (λ s → Container.Position StepC s o)
(cong₂ _,_ refl eq) p))) ↝⟨ (∃-cong λ eq → implicit-∀-cong ext $ ∀-cong ext λ _ →
≡⇒↝ _ $
cong (λ (eq : s₁ ≡ s₂) →
R (f₁ _ ,
f₂ (subst (λ s → Container.Position StepC s _) eq _))) $
trans-reflˡ (cong (_ ,_) eq)) ⟩
(∃ λ (eq : (λ {_ _} → ch₁) ≡ ch₂) →
∀ {o} (p : Container.Position StepC s₁ o) →
R (f₁ p , f₂ (subst (λ (s : _ × _) → Container.Position StepC s o)
(cong (_ ,_) eq) p))) ↝⟨ (∃-cong λ eq → implicit-∀-cong ext λ {o} → ∀-cong ext λ p →
≡⇒↝ _ $ cong (λ p → R {o = o} (f₁ _ , f₂ p)) $ sym $
subst-∘ (λ (s : Container.Shape StepC _) → Container.Position StepC s o)
_ eq) ⟩
(∃ λ (eq : (λ {_ _} → ch₁) ≡ ch₂) →
∀ {o} (p : Container.Position StepC s₁ o) →
R (f₁ p , f₂ (subst (λ (ch : ∀ {_ _} → _) →
Container.Position StepC (_ , ch) o)
eq p))) ↔⟨⟩
(∃ λ (eq : _≡_ {A = ∀ {p′ μ} → _} ch₁ ch₂) →
∀ {p′q′} →
(pos : ∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ proj₁ p′q′) →
proj₁ (ch₁ p⟶p′) ≡ proj₂ p′q′) →
R (f₁ pos ,
f₂ (subst (λ ch → ∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ proj₁ p′q′) →
proj₁ (ch p⟶p′) ≡ proj₂ p′q′)
eq pos))) ↝⟨ (∃-cong λ _ → Bijection.implicit-Π↔Π) ⟩
(∃ λ (eq : _≡_ {A = ∀ {p′ μ} → _} ch₁ ch₂) →
∀ p′q′ →
(pos : ∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ proj₁ p′q′) →
proj₁ (ch₁ p⟶p′) ≡ proj₂ p′q′) →
R (f₁ pos ,
f₂ (subst (λ ch → ∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ proj₁ p′q′) →
proj₁ (ch p⟶p′) ≡ proj₂ p′q′)
eq pos))) ↝⟨ (∃-cong λ _ → currying) ⟩
(∃ λ (eq : _≡_ {A = ∀ {p′ μ} → _} ch₁ ch₂) →
∀ p′ q′ →
(pos : ∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ p′) → proj₁ (ch₁ p⟶p′) ≡ q′) →
R (f₁ pos ,
f₂ (subst (λ ch → ∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′) ≡ q′)
eq pos))) ↝⟨ (∃-cong λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → currying) ⟩
(∃ λ (eq : _≡_ {A = ∀ {p′ μ} → _} ch₁ ch₂) →
∀ p′ q′ μ →
(pos : ∃ λ (p⟶p′ : p [ μ ]⟶ p′) → proj₁ (ch₁ p⟶p′) ≡ q′) →
R (f₁ (μ , pos) ,
f₂ (subst (λ ch → ∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′) ≡ q′)
eq (μ , pos)))) ↝⟨ (∃-cong λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ →
currying) ⟩
(∃ λ (eq : _≡_ {A = ∀ {p′ μ} → _} ch₁ ch₂) →
∀ p′ q′ μ (p⟶p′ : p [ μ ]⟶ p′) (≡q′ : proj₁ (ch₁ p⟶p′) ≡ q′) →
R (f₁ (μ , p⟶p′ , ≡q′) ,
f₂ (subst (λ ch → ∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′) ≡ q′)
eq (μ , p⟶p′ , ≡q′)))) ↝⟨ (∃-cong λ _ → ∀-cong ext λ _ → Π-comm) ⟩
(∃ λ (eq : _≡_ {A = ∀ {p′ μ} → _} ch₁ ch₂) →
∀ p′ μ q′ (p⟶p′ : p [ μ ]⟶ p′) (≡q′ : proj₁ (ch₁ p⟶p′) ≡ q′) →
R (f₁ (μ , p⟶p′ , ≡q′) ,
f₂ (subst (λ ch → ∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′) ≡ q′)
eq (μ , p⟶p′ , ≡q′)))) ↝⟨ (∃-cong λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → Π-comm) ⟩
(∃ λ (eq : _≡_ {A = ∀ {p′ μ} → _} ch₁ ch₂) →
∀ p′ μ (p⟶p′ : p [ μ ]⟶ p′) q′ (≡q′ : proj₁ (ch₁ p⟶p′) ≡ q′) →
R (f₁ (μ , p⟶p′ , ≡q′) ,
f₂ (subst (λ ch → ∃ λ μ → ∃ λ (p⟶p′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′) ≡ q′)
eq (μ , p⟶p′ , ≡q′)))) ↝⟨ (∃-cong λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ →
inverse $ ∀-intro _ ext) ⟩
(∃ λ (eq : _≡_ {A = ∀ {p′ μ} → _} ch₁ ch₂) →
∀ p′ μ (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (subst (λ ch → ∃ λ μ → ∃ λ (p⟶p′′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′′) ≡ proj₁ (ch₁ p⟶p′))
eq (μ , p⟶p′ , refl)))) ↝⟨ (∃-cong λ eq → ∀-cong ext λ _ → ∀-cong ext λ _ → ∀-cong ext λ _ →
≡⇒↝ _ $ cong (R ∘ (f₁ _ ,_) ∘ f₂) $ lemma₁ eq) ⟩
(∃ λ (eq : _≡_ {A = ∀ {p′ μ} → _} ch₁ ch₂) →
∀ p′ μ (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong (λ ch → proj₁ (ch p⟶p′)) eq)))) ↝⟨ (∃-cong λ eq → ∀-cong ext λ _ → inverse Bijection.implicit-Π↔Π) ⟩
(∃ λ (eq : _≡_ {A = ∀ {p′ μ} → _} ch₁ ch₂) →
∀ p′ {μ} (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong (λ ch → proj₁ (ch p⟶p′)) eq)))) ↝⟨ (∃-cong λ eq → inverse Bijection.implicit-Π↔Π) ⟩
(∃ λ (eq : _≡_ {A = ∀ {p′ μ} → _} ch₁ ch₂) →
∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong (λ ch → proj₁ (ch p⟶p′)) eq)))) ↝⟨ (Σ-cong (inverse $ implicit-extensionality-isomorphism
{k = bijection} ext) λ eq →
implicit-∀-cong ext $ implicit-∀-cong ext $ ∀-cong ext λ p⟶p′ →
≡⇒↝ _ $ sym $ cong (λ eq →
R (f₁ _ , f₂ (_ , p⟶p′ , sym (cong (λ ch → proj₁ (ch p⟶p′)) eq)))) $
_↔_.right-inverse-of (implicit-extensionality-isomorphism ext) eq) ⟩
(∃ λ (eq : ∀ p′ → (λ {μ} → ch₁ {p′ = p′} {μ = μ}) ≡ ch₂) →
let eq′ = _↔_.to (implicit-extensionality-isomorphism ext) eq in
∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong (λ ch → proj₁ (ch p⟶p′)) eq′)))) ↝⟨ (∃-cong λ eq →
implicit-∀-cong ext $ implicit-∀-cong ext $ ∀-cong ext λ p⟶p′ →
≡⇒↝ _ $ cong (λ eq → R (f₁ _ , f₂ (_ , p⟶p′ , sym eq))) $
lemma₂ eq) ⟩
(∃ λ (eq : ∀ p′ → (λ {μ} → ch₁ {p′ = p′} {μ = μ}) ≡ ch₂) →
∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong (λ ch → proj₁ (ch p′ p⟶p′))
(apply-ext (Eq.good-ext ext) eq))))) ↝⟨ (Σ-cong (inverse $ ∀-cong ext λ _ →
implicit-extensionality-isomorphism
{k = bijection} ext) λ eq →
implicit-∀-cong ext $ implicit-∀-cong ext $ ∀-cong ext λ p⟶p′ →
≡⇒↝ _ $ sym $ cong (λ eq →
R (f₁ _ , f₂ (_ , p⟶p′ , sym (cong (λ ch → proj₁ (ch _ p⟶p′))
(apply-ext (Eq.good-ext ext) eq))))) $
apply-ext ext $
_↔_.right-inverse-of (implicit-extensionality-isomorphism ext) ∘ eq) ⟩
(∃ λ (eq : ∀ p′ μ → ch₁ {p′ = p′} {μ = μ} ≡ ch₂) →
let eq′ = implicit-extensionality (Eq.good-ext ext) ∘ eq in
∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong (λ ch → proj₁ (ch p′ p⟶p′))
(apply-ext (Eq.good-ext ext) eq′))))) ↝⟨ (∃-cong λ _ →
implicit-∀-cong ext $ implicit-∀-cong ext $ ∀-cong ext λ _ →
≡⇒↝ _ $ cong (λ eq → R (f₁ _ , f₂ (_ , _ , sym eq))) $
lemma₃ _) ⟩
(∃ λ (eq : ∀ p′ μ → ch₁ {p′ = p′} {μ = μ} ≡ ch₂) →
∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong (λ ch → proj₁ (ch p⟶p′)) (eq p′ μ))))) ↝⟨ Σ-cong (inverse Bijection.implicit-Π↔Π) (λ _ → F.id) ⟩
(∃ λ (eq : ∀ {p′} μ → ch₁ {p′ = p′} {μ = μ} ≡ ch₂) →
∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong (λ ch → proj₁ (ch p⟶p′)) (eq μ))))) ↝⟨ Σ-cong (implicit-∀-cong ext $ inverse Bijection.implicit-Π↔Π)
(λ _ → F.id) ⟩
(∃ λ (eq : ∀ {p′ μ} → ch₁ {p′ = p′} {μ = μ} ≡ ch₂) →
∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong (λ ch → proj₁ (ch p⟶p′)) eq)))) ↝⟨ (∃-cong λ eq →
implicit-∀-cong ext $ implicit-∀-cong ext $ ∀-cong ext λ p⟶p′ →
≡⇒↝ _ $ cong (λ eq → R (f₁ _ , f₂ (_ , _ , sym eq))) $ sym $
cong-∘ proj₁ (_$ p⟶p′) (eq {μ = _})) ⟩
(∃ λ (eq : ∀ {p′ μ} → ch₁ {p′ = p′} {μ = μ} ≡ ch₂) →
∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong proj₁ $ cong (_$ p⟶p′) eq)))) ↝⟨ Σ-cong (implicit-∀-cong ext $ implicit-∀-cong ext $ inverse $
Eq.extensionality-isomorphism ext)
(λ _ → F.id) ⟩
(∃ λ (eq : ∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) → ch₁ p⟶p′ ≡ ch₂ p⟶p′) →
∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong proj₁ (eq p⟶p′))))) ↝⟨ inverse implicit-ΠΣ-comm ⟩
(∀ {p′} →
∃ λ (eq : ∀ {μ} (p⟶p′ : p [ μ ]⟶ p′) → ch₁ p⟶p′ ≡ ch₂ p⟶p′) →
∀ {μ} (p⟶p′ : p [ μ ]⟶ p′) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong proj₁ (eq p⟶p′))))) ↝⟨ implicit-∀-cong ext $ inverse implicit-ΠΣ-comm ⟩
(∀ {p′ μ} →
∃ λ (eq : (p⟶p′ : p [ μ ]⟶ p′) → ch₁ p⟶p′ ≡ ch₂ p⟶p′) →
∀ p⟶p′ → R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong proj₁ (eq p⟶p′))))) ↝⟨ implicit-∀-cong ext $ implicit-∀-cong ext $ inverse ΠΣ-comm ⟩
(∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
∃ λ (eq : ch₁ p⟶p′ ≡ ch₂ p⟶p′) →
R (f₁ (μ , p⟶p′ , refl) , f₂ (μ , p⟶p′ , sym (cong proj₁ eq)))) ↝⟨ (inverse $ implicit-∀-cong ext $ implicit-∀-cong ext $ ∀-cong ext λ _ →
Σ-cong Bijection.Σ-≡,≡↔≡ λ _ → F.id) ⟩
(∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
let q′₁ , q⟶q′₁ = ch₁ p⟶p′
q′₂ , q⟶q′₂ = ch₂ p⟶p′
in ∃ λ (eq : ∃ λ (q′₁≡q′₂ : q′₁ ≡ q′₂) →
subst (q [ μ ]↝_) q′₁≡q′₂ q⟶q′₁ ≡ q⟶q′₂) →
R (f₁ (μ , p⟶p′ , refl) ,
f₂ (μ , p⟶p′ , sym (cong proj₁ (uncurry Σ-≡,≡→≡ eq))))) ↝⟨ (implicit-∀-cong ext $ implicit-∀-cong ext $ ∀-cong ext λ _ →
∃-cong λ eq →
≡⇒↝ _ $ cong (λ eq → R (f₁ _ , f₂ (_ , _ , sym eq))) $
proj₁-Σ-≡,≡→≡ (proj₁ eq) (proj₂ eq)) ⟩
(∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
let q′₁ , q⟶q′₁ = ch₁ p⟶p′
q′₂ , q⟶q′₂ = ch₂ p⟶p′
in ∃ λ (eq : ∃ λ (q′₁≡q′₂ : q′₁ ≡ q′₂) →
subst (q [ μ ]↝_) q′₁≡q′₂ q⟶q′₁ ≡ q⟶q′₂) →
R (f₁ (μ , p⟶p′ , refl) , f₂ (μ , p⟶p′ , sym (proj₁ eq)))) ↝⟨ (implicit-∀-cong ext $ implicit-∀-cong ext $ ∀-cong ext λ _ →
inverse Σ-assoc) ⟩
(∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
let q′₁ , q⟶q′₁ = ch₁ p⟶p′
q′₂ , q⟶q′₂ = ch₂ p⟶p′
in ∃ λ (q′₁≡q′₂ : q′₁ ≡ q′₂) →
subst (q [ μ ]↝_) q′₁≡q′₂ q⟶q′₁ ≡ q⟶q′₂
×
R (f₁ (μ , p⟶p′ , refl) , f₂ (μ , p⟶p′ , sym q′₁≡q′₂))) ↝⟨ (implicit-∀-cong ext $ implicit-∀-cong ext $ ∀-cong ext λ p⟶p′ →
∃-cong λ q′₁≡q′₂ → ∃-cong λ _ → ≡⇒↝ _ $
lemma₄ q′₁≡q′₂) ⟩
(∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
let q′₁ , q⟶q′₁ = ch₁ p⟶p′
q′₂ , q⟶q′₂ = ch₂ p⟶p′
in ∃ λ (q′₁≡q′₂ : q′₁ ≡ q′₂) →
subst (q [ μ ]↝_) q′₁≡q′₂ q⟶q′₁ ≡ q⟶q′₂
×
R (subst (X ∘ (p′ ,_)) q′₁≡q′₂ (f₁ (_ , p⟶p′ , refl)) ,
f₂ (_ , p⟶p′ , refl))) ↔⟨⟩
(∀ {p′ μ} (p⟶p′ : p [ μ ]⟶ p′) →
let q′₁ , q⟶q′₁ , p′≤q′₁ = StepC.challenge (s₁ , f₁) p⟶p′
q′₂ , q⟶q′₂ , p′≤q′₂ = StepC.challenge (s₂ , f₂) p⟶p′
in ∃ λ (q′₁≡q′₂ : q′₁ ≡ q′₂) →
subst (q [ μ ]↝_) q′₁≡q′₂ q⟶q′₁ ≡ q⟶q′₂
×
R (subst (X ∘ (p′ ,_)) q′₁≡q′₂ p′≤q′₁ , p′≤q′₂)) □
where
lemma₁ :
∀ {p q} {f g : ∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ (q [ μ ]↝_)}
(eq : (λ {p′ μ} → f {p′ = p′} {μ = μ}) ≡ g)
{p′ μ} {p⟶p′ : p [ μ ]⟶ p′} →
_
lemma₁ {p} {q} {f} {g} eq {p′} {μ} {p⟶p′} =
subst (λ ch →
∃ λ μ → ∃ λ (p⟶p′′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′′) ≡ proj₁ (f p⟶p′))
eq (μ , p⟶p′ , refl) ≡⟨ push-subst-pair′ {y≡z = eq} _ _ _ ⟩
( μ
, subst₂ (λ { (ch , μ) →
∃ λ (p⟶p′′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′′) ≡ proj₁ (f p⟶p′) })
eq (subst-const eq) (p⟶p′ , refl)
) ≡⟨ cong (μ ,_) $
cong (λ eq → subst (λ { (ch , μ) →
∃ λ (p⟶p′′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′′) ≡ proj₁ (f p⟶p′) })
eq (p⟶p′ , refl)) $
Σ-≡,≡→≡-subst-const eq refl ⟩
( μ
, subst (λ { (ch , μ) →
∃ λ (p⟶p′′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′′) ≡ proj₁ (f p⟶p′) })
(cong₂ _,_ eq refl) (p⟶p′ , refl)
) ≡⟨⟩
( μ
, subst (λ { (ch , μ) →
∃ λ (p⟶p′′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′′) ≡ proj₁ (f p⟶p′) })
(cong (_, _) eq) (p⟶p′ , refl)
) ≡⟨ cong (μ ,_) $ sym $
subst-∘ _ _ eq ⟩
( μ
, subst (λ ch →
∃ λ (p⟶p′′ : p [ μ ]⟶ p′) →
proj₁ (ch p⟶p′′) ≡ proj₁ (f p⟶p′))
eq (p⟶p′ , refl)
) ≡⟨ cong (μ ,_) $
push-subst-pair′ {y≡z = eq} _ _ _ ⟩
( μ
, p⟶p′
, subst₂ (λ { (ch , p⟶p′′) →
proj₁ (ch p⟶p′′) ≡ proj₁ (f p⟶p′) })
eq (subst-const eq) refl
) ≡⟨ cong (λ eq → (_ , p⟶p′ , subst (λ { (ch , p⟶p′′) → proj₁ (ch p⟶p′′) ≡ proj₁ (f p⟶p′) })
eq refl)) $
Σ-≡,≡→≡-subst-const eq refl ⟩
( μ
, p⟶p′
, subst (λ { (ch , p⟶p′′) →
proj₁ (ch p⟶p′′) ≡ proj₁ (f p⟶p′) })
(cong (_, _) eq) refl
) ≡⟨ cong (λ eq → (_ , p⟶p′ , eq)) $ sym $
subst-∘ _ _ eq ⟩
( μ
, p⟶p′
, subst (λ ch → proj₁ (ch p⟶p′) ≡ proj₁ (f p⟶p′))
eq refl
) ≡⟨ cong (λ eq → (_ , p⟶p′ , eq)) $
subst-∘ _ _ eq ⟩
( μ
, p⟶p′
, subst (_≡ proj₁ (f p⟶p′))
(cong (λ ch → proj₁ (ch p⟶p′)) eq) refl
) ≡⟨ cong (λ eq → (_ , p⟶p′ , subst (_≡ _) eq refl)) $
sym $ sym-sym (cong (λ ch → proj₁ (ch p⟶p′)) eq) ⟩
( μ
, p⟶p′
, subst (_≡ proj₁ (f p⟶p′))
(sym $ sym $
cong (λ ch → proj₁ (ch p⟶p′)) eq)
refl
) ≡⟨ cong (λ eq → (_ , p⟶p′ , eq)) $
subst-trans (sym $ cong (λ ch → proj₁ (ch p⟶p′)) eq) ⟩∎
( μ
, p⟶p′
, sym (cong (λ ch → proj₁ (ch p⟶p′)) eq)
) ∎
lemma₂ :
∀ {p q} {f g : ∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ (q [ μ ]↝_)}
(eq : ∀ p′ → (λ {μ} → f {p′ = p′} {μ = μ}) ≡ g)
{p′ μ} {p⟶p′ : p [ μ ]⟶ p′} →
_
lemma₂ {p} {q} {f} {g} eq {p′} {μ} {p⟶p′} =
cong (λ ch → proj₁ (ch p⟶p′))
(_↔_.to (implicit-extensionality-isomorphism ext) eq) ≡⟨⟩
cong (λ ch → proj₁ (ch p⟶p′))
(implicit-extensionality (Eq.good-ext ext) eq) ≡⟨ cong-∘ _ _ (apply-ext (Eq.good-ext ext) eq) ⟩∎
cong (λ ch → proj₁ (ch p′ p⟶p′)) (apply-ext (Eq.good-ext ext) eq) ∎
lemma₃ :
∀ {p q} {f g : ∀ {p′ μ} → p [ μ ]⟶ p′ → ∃ (q [ μ ]↝_)}
(eq : ∀ p′ μ → f {p′ = p′} {μ = μ} ≡ g) {p′ μ p⟶p′} →
_
lemma₃ {p} {q} {f} {g} eq {p′} {μ} {p⟶p′} =
cong (λ (ch : ∀ _ {μ} → _) → proj₁ (ch p′ {μ = μ} p⟶p′))
(apply-ext (Eq.good-ext ext)
(implicit-extensionality (Eq.good-ext ext) ∘ eq)) ≡⟨⟩
cong (λ ch → proj₁ (ch p′ p⟶p′))
(apply-ext (Eq.good-ext ext)
(cong (λ f {x} → f x) ∘ (apply-ext (Eq.good-ext ext) ∘ eq))) ≡⟨ cong (cong (λ ch → proj₁ (ch p′ p⟶p′))) $ sym $
Eq.cong-post-∘-good-ext {h = λ f {x} → f x} ext ext
(apply-ext (Eq.good-ext ext) ∘ eq) ⟩
cong (λ ch → proj₁ (ch p′ p⟶p′))
(cong (λ f x {y} → f x y)
(apply-ext (Eq.good-ext ext)
(apply-ext (Eq.good-ext ext) ∘ eq))) ≡⟨ cong-∘ _ _ (apply-ext (Eq.good-ext ext)
(apply-ext (Eq.good-ext ext) ∘ eq)) ⟩
cong (λ ch → proj₁ (ch p′ μ p⟶p′))
(apply-ext (Eq.good-ext ext)
(apply-ext (Eq.good-ext ext) ∘ eq)) ≡⟨ sym $ cong-∘ _ _ (apply-ext (Eq.good-ext ext)
(apply-ext (Eq.good-ext ext) ∘ eq)) ⟩
cong (λ ch → proj₁ (ch μ p⟶p′))
(cong (_$ p′) (apply-ext (Eq.good-ext ext)
(apply-ext (Eq.good-ext ext) ∘ eq))) ≡⟨ cong (cong (λ ch → proj₁ (ch μ p⟶p′))) $ Eq.cong-good-ext ext _ ⟩
cong (λ ch → proj₁ (ch μ p⟶p′))
(apply-ext (Eq.good-ext ext) (eq p′)) ≡⟨ sym $ cong-∘ _ _ (apply-ext (Eq.good-ext ext) (eq p′)) ⟩
cong (λ ch → proj₁ (ch p⟶p′))
(cong (_$ μ) (apply-ext (Eq.good-ext ext) (eq p′))) ≡⟨ cong (cong (λ ch → proj₁ (ch p⟶p′))) $ Eq.cong-good-ext ext _ ⟩∎
cong (λ ch → proj₁ (ch p⟶p′)) (eq p′ μ) ∎
lemma₄ :
∀ {p′ μ} {p⟶p′ : p [ μ ]⟶ p′}
(q′₁≡q′₂ : proj₁ (ch₁ p⟶p′) ≡ proj₁ (ch₂ p⟶p′)) →
R (f₁ (μ , p⟶p′ , refl) , f₂ (μ , p⟶p′ , sym q′₁≡q′₂))
≡
R (subst (X ∘ (p′ ,_)) q′₁≡q′₂ (f₁ (_ , p⟶p′ , refl)) ,
f₂ (_ , p⟶p′ , refl))
lemma₄ {p′} {μ} {p⟶p′} q′₁≡q′₂ =
R (f₁ (μ , p⟶p′ , refl) , f₂ (μ , p⟶p′ , sym q′₁≡q′₂)) ≡⟨ cong (R ∘ (f₁ _ ,_)) $ lemma′ q′₁≡q′₂ ⟩
R (f₁ (μ , p⟶p′ , refl) ,
subst (X ∘ (p′ ,_)) (sym q′₁≡q′₂) (f₂ (_ , p⟶p′ , refl))) ≡⟨ lemma″ q′₁≡q′₂ ⟩∎
R (subst (X ∘ (p′ ,_)) q′₁≡q′₂ (f₁ (_ , p⟶p′ , refl)) ,
f₂ (_ , p⟶p′ , refl)) ∎
where
lemma′ :
∀ {q′₁} (q′₁≡q′₂ : q′₁ ≡ proj₁ (ch₂ p⟶p′)) →
f₂ (μ , p⟶p′ , sym q′₁≡q′₂)
≡
subst (X ∘ (p′ ,_)) (sym q′₁≡q′₂) (f₂ (_ , p⟶p′ , refl))
lemma′ refl = refl
lemma″ :
∀ {q′₂ x} (q′₁≡q′₂ : proj₁ (ch₁ p⟶p′) ≡ q′₂) →
R (f₁ (μ , p⟶p′ , refl) , subst (X ∘ (p′ ,_)) (sym q′₁≡q′₂) x)
≡
R (subst (X ∘ (p′ ,_)) q′₁≡q′₂ (f₁ (_ , p⟶p′ , refl)) , x)
lemma″ refl = refl
| {
"alphanum_fraction": 0.3368020669,
"avg_line_length": 48.0482758621,
"ext": "agda",
"hexsha": "4ea91df4d393f12d0971ab2be47d05d4bd04403d",
"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": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/up-to",
"max_forks_repo_path": "src/Similarity/Step.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"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/up-to",
"max_issues_repo_path": "src/Similarity/Step.agda",
"max_line_length": 147,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/up-to",
"max_stars_repo_path": "src/Similarity/Step.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 10858,
"size": 27868
} |
module Holes.Util where
open import Holes.Prelude
private
Rel : ∀ {a} → Set a → ∀ ℓ → Set (a ⊔ lsuc ℓ)
Rel A ℓ = A → A → Set ℓ
module CongSplit {ℓ x} {X : Set x} (_≈_ : Rel X ℓ) (reflexive : ∀ {x} → x ≈ x) where
two→one₁ : {_+_ : X → X → X}
→ (∀ {x x′ y y′} → x ≈ x′ → y ≈ y′ → (x + y) ≈ (x′ + y′))
→ (∀ x y {x′} → x ≈ x′ → (x + y) ≈ (x′ + y))
two→one₁ cong² _ _ eq = cong² eq reflexive
two→one₂ : {_+_ : X → X → X}
→ (∀ {x x′ y y′} → x ≈ x′ → y ≈ y′ → (x + y) ≈ (x′ + y′))
→ (∀ x y {y′} → y ≈ y′ → (x + y) ≈ (x + y′))
two→one₂ cong² _ _ eq = cong² reflexive eq
| {
"alphanum_fraction": 0.4064,
"avg_line_length": 31.25,
"ext": "agda",
"hexsha": "6a5c38021efe605e86987f7f3e0ac2d75d69baef",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-02-02T18:57:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-01-27T14:57:39.000Z",
"max_forks_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bch29/agda-holes",
"max_forks_repo_path": "src/Holes/Util.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4",
"max_issues_repo_issues_event_max_datetime": "2020-08-31T20:58:33.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-16T10:47:58.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bch29/agda-holes",
"max_issues_repo_path": "src/Holes/Util.agda",
"max_line_length": 84,
"max_stars_count": 24,
"max_stars_repo_head_hexsha": "b5537c29e69febd7e89580398fac38d619aab3b4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bch29/agda-holes",
"max_stars_repo_path": "src/Holes/Util.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-03T15:02:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-01-28T10:56:46.000Z",
"num_tokens": 297,
"size": 625
} |
{-# OPTIONS --without-K #-}
open import HoTT
open import homotopy.CircleHSpace
open import homotopy.LoopSpaceCircle
open import homotopy.Pi2HSusp
open import homotopy.IterSuspensionStable
-- This summerizes all [πₙ Sⁿ]
module homotopy.PinSn where
private
-- another way is to use path induction to prove the other direction,
-- but personally I do not feel it is easier.
abstract
-- proved in LoopSpaceCircle
-- loop^succ : ∀ (z : ℤ) → loop^ z ∙ loop == loop^ (succ z)
-- mimicking [loop^pred]
loop^pred : ∀ (z : ℤ) → loop^ z ∙ ! loop == loop^ (pred z)
loop^pred (negsucc n) = idp
loop^pred (pos O) = idp
loop^pred (pos (S n)) =
(loop^ (pos n) ∙ loop) ∙ ! loop
=⟨ ∙-assoc (loop^ (pos n)) loop (! loop) ⟩
loop^ (pos n) ∙ (loop ∙ ! loop)
=⟨ !-inv-r loop |in-ctx loop^ (pos n) ∙_ ⟩
loop^ (pos n) ∙ idp
=⟨ ∙-unit-r $ loop^ (pos n) ⟩
loop^ (pos n)
∎
-- because of how [loop^] is defined,
-- it is easier to prove the swapped version
loop^-ℤ+' : ∀ (z₁ z₂ : ℤ) →
loop^ (z₁ ℤ+ z₂) == loop^ z₂ ∙ loop^ z₁
loop^-ℤ+' (pos O) z₂ = ! $ ∙-unit-r (loop^ z₂)
loop^-ℤ+' (pos (S n₁)) z₂ =
loop^ (succ (pos n₁ ℤ+ z₂))
=⟨ ! $ loop^succ (pos n₁ ℤ+ z₂) ⟩
loop^ (pos n₁ ℤ+ z₂) ∙ loop
=⟨ loop^-ℤ+' (pos n₁) z₂ |in-ctx _∙ loop ⟩
(loop^ z₂ ∙ loop^ (pos n₁)) ∙ loop
=⟨ ∙-assoc (loop^ z₂) (loop^ (pos n₁)) loop ⟩
loop^ z₂ ∙ (loop^ (pos n₁) ∙ loop)
∎
loop^-ℤ+' (negsucc O) z₂ = ! $ loop^pred z₂
loop^-ℤ+' (negsucc (S n₁)) z₂ =
loop^ (pred (negsucc n₁ ℤ+ z₂))
=⟨ ! $ loop^pred (negsucc n₁ ℤ+ z₂) ⟩
loop^ (negsucc n₁ ℤ+ z₂) ∙ ! loop
=⟨ loop^-ℤ+' (negsucc n₁) z₂ |in-ctx _∙ ! loop ⟩
(loop^ z₂ ∙ loop^ (negsucc n₁)) ∙ ! loop
=⟨ ∙-assoc (loop^ z₂) (loop^ (negsucc n₁)) (! loop) ⟩
loop^ z₂ ∙ (loop^ (negsucc n₁) ∙ ! loop)
∎
loop^-ℤ+ : ∀ (z₁ z₂ : ℤ) →
loop^ (z₁ ℤ+ z₂) == loop^ z₁ ∙ loop^ z₂
loop^-ℤ+ z₁ z₂ = ap loop^ (ℤ+-comm z₁ z₂) ∙ loop^-ℤ+' z₂ z₁
ℤ-to-π₁S¹ : ℤ-group →ᴳ πS 0 ⊙S¹
ℤ-to-π₁S¹ =
record { f = [_] ∘ loop^
; pres-comp = λ z₁ z₂ → ap [_] $ loop^-ℤ+ z₁ z₂
}
ℤ-to-π₁S¹-equiv : ℤ-group ≃ᴳ πS 0 ⊙S¹
ℤ-to-π₁S¹-equiv = ℤ-to-π₁S¹ , snd (unTrunc-equiv (Ω^ 1 ⊙S¹) (ΩS¹-is-set base) ⁻¹ ∘e ΩS¹≃ℤ ⁻¹)
π₁S¹ : πS 0 ⊙S¹ == ℤ-group
π₁S¹ = ! $ group-ua ℤ-to-π₁S¹-equiv
π₂S² : πS 1 ⊙S² == ℤ-group
π₂S² =
πS 1 ⊙S²
=⟨ Pi2HSusp.π₂-Suspension S¹ S¹-level S¹-connected S¹-hSpace ⟩
πS 0 ⊙S¹
=⟨ π₁S¹ ⟩
ℤ-group
∎
private
πₙ₊₂Sⁿ⁺² : ∀ n → πS (S n) (⊙Susp^ (S n) ⊙S¹) == ℤ-group
πₙ₊₂Sⁿ⁺² 0 = π₂S²
πₙ₊₂Sⁿ⁺² (S n) =
πS (S (S n)) (⊙Susp^ (S (S n)) ⊙S¹)
=⟨ Susp^StableSucc.stable ⊙S¹ S¹-connected
(S n) (S n) (≤-ap-S $ ≤-ap-S $ *2-increasing n) ⟩
πS (S n) (⊙Susp^ (S n) ⊙S¹)
=⟨ πₙ₊₂Sⁿ⁺² n ⟩
ℤ-group
∎
lemma : ∀ n → ⊙Susp^ n ⊙S¹ == ⊙Sphere (S n)
lemma n = ⊙Susp^-+ n 1 ∙ ap ⊙Sphere (+-comm n 1)
πₙ₊₁Sⁿ⁺¹ : ∀ n → πS n (⊙Sphere (S n)) == ℤ-group
πₙ₊₁Sⁿ⁺¹ 0 = π₁S¹
πₙ₊₁Sⁿ⁺¹ (S n) = ap (πS (S n)) (! $ lemma (S n)) ∙ πₙ₊₂Sⁿ⁺² n
| {
"alphanum_fraction": 0.4867660481,
"avg_line_length": 32.5445544554,
"ext": "agda",
"hexsha": "9609e37e42d15b2496069dc35accf41d75998828",
"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": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmknapp/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/PinSn.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"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": "cmknapp/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/PinSn.agda",
"max_line_length": 97,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmknapp/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/PinSn.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1537,
"size": 3287
} |
open import MLib.Algebra.PropertyCode
open import MLib.Algebra.PropertyCode.Structures
module MLib.Matrix.Bimonoid {c ℓ} (struct : Struct bimonoidCode c ℓ) where
open import MLib.Prelude
open import MLib.Matrix.Core
open import MLib.Matrix.Equality struct
open import MLib.Matrix.Mul struct
open import MLib.Matrix.Plus struct
open import MLib.Algebra.Operations struct
open import MLib.Algebra.PropertyCode.Dependent struct
open FunctionProperties
matrixRawStruct : ∀ n → RawStruct BimonoidK _ _
matrixRawStruct n = record
{ appOp = λ
{ + (A ∷ B ∷ []) → A ⊕ B
; * (A ∷ B ∷ []) → A ⊗ B
; 0# [] → 0●
; 1# [] → 1●
}
; isRawStruct = record
{ isEquivalence = isEquivalence {n} {n}
; congⁿ = λ
{ + (p ∷ q ∷ []) i j → cong + (p i j) (q i j)
; * (p ∷ q ∷ []) → ⊗-cong p q
; 0# [] _ _ → S.refl
; 1# [] _ _ → S.refl
}
}
}
matrixStruct : ∀ n → Struct bimonoidCode _ _
matrixStruct n = dependentStruct (matrixRawStruct n)
( (commutative on + , _ , ⊕-comm)
∷ (associative on + , _ , ⊕-assoc)
∷ (0# is leftIdentity for + , _ , ⊕-identityˡ)
∷ (0# is rightIdentity for + , _ , ⊕-identityʳ)
∷ (associative on * , _ , ⊗-assoc)
∷ (* ⟨ distributesOverˡ ⟩ₚ + , _ , ⊗-distributesOverˡ-⊕)
∷ [])
| {
"alphanum_fraction": 0.6087301587,
"avg_line_length": 28.6363636364,
"ext": "agda",
"hexsha": "e97c5728d755f0e7ad3a4d96373df352925916a9",
"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": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bch29/agda-matrices",
"max_forks_repo_path": "src/MLib/Matrix/Bimonoid.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"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": "bch29/agda-matrices",
"max_issues_repo_path": "src/MLib/Matrix/Bimonoid.agda",
"max_line_length": 74,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bch29/agda-matrices",
"max_stars_repo_path": "src/MLib/Matrix/Bimonoid.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 460,
"size": 1260
} |
open import Common.Prelude
record IsNumber (A : Set) : Set where
field fromNat : Nat → A
open IsNumber {{...}} public
{-# BUILTIN FROMNAT fromNat #-}
instance
IsNumberNat : IsNumber Nat
IsNumberNat = record { fromNat = λ n → n }
record IsNegative (A : Set) : Set where
field fromNeg : Nat → A
open IsNegative {{...}} public
{-# BUILTIN FROMNEG fromNeg #-}
data Int : Set where
pos : Nat → Int
neg : Nat → Int
instance
IsNumberInt : IsNumber Int
IsNumberInt = record { fromNat = pos }
IsNegativeInt : IsNegative Int
IsNegativeInt = record { fromNeg = neg }
fiveN : Nat
fiveN = 5
fiveZ : Int
fiveZ = 5
minusFive : Int
minusFive = -5
open import Common.Equality
thm : pos 5 ≡ 5
thm = refl
thm′ : neg 5 ≡ -5
thm′ = refl
| {
"alphanum_fraction": 0.6573705179,
"avg_line_length": 15.3673469388,
"ext": "agda",
"hexsha": "4c10782873d7d2bb0ecff4d43fccaf2b95e06e47",
"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/OverloadedNat.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/OverloadedNat.agda",
"max_line_length": 44,
"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/OverloadedNat.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": 245,
"size": 753
} |
{-# OPTIONS --cubical #-}
module Cubical.Categories.Category where
open import Cubical.Foundations.Prelude
record Precategory ℓ ℓ' : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
no-eta-equality
field
ob : Type ℓ
hom : ob → ob → Type ℓ'
idn : ∀ x → hom x x
seq : ∀ {x y z} (f : hom x y) (g : hom y z) → hom x z
seq-λ : ∀ {x y : ob} (f : hom x y) → seq (idn x) f ≡ f
seq-ρ : ∀ {x y} (f : hom x y) → seq f (idn y) ≡ f
seq-α : ∀ {u v w x} (f : hom u v) (g : hom v w) (h : hom w x) → seq (seq f g) h ≡ seq f (seq g h)
open Precategory public
record isCategory {ℓ ℓ'} (𝒞 : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where
field
homIsSet : ∀ {x y} → isSet (𝒞 .hom x y)
open isCategory public
_^op : ∀ {ℓ ℓ'} → Precategory ℓ ℓ' → Precategory ℓ ℓ'
(𝒞 ^op) .ob = 𝒞 .ob
(𝒞 ^op) .hom x y = 𝒞 .hom y x
(𝒞 ^op) .idn = 𝒞 .idn
(𝒞 ^op) .seq f g = 𝒞 .seq g f
(𝒞 ^op) .seq-λ = 𝒞 .seq-ρ
(𝒞 ^op) .seq-ρ = 𝒞 .seq-λ
(𝒞 ^op) .seq-α f g h = sym (𝒞 .seq-α _ _ _)
| {
"alphanum_fraction": 0.5352697095,
"avg_line_length": 28.3529411765,
"ext": "agda",
"hexsha": "1aad90e551c04c0fbcf5d12ed8c213ce6e23e597",
"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": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "borsiemir/cubical",
"max_forks_repo_path": "Cubical/Categories/Category.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"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": "borsiemir/cubical",
"max_issues_repo_path": "Cubical/Categories/Category.agda",
"max_line_length": 101,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "borsiemir/cubical",
"max_stars_repo_path": "Cubical/Categories/Category.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 464,
"size": 964
} |
------------------------------------------------------------------------
-- Acyclic precedence graphs
------------------------------------------------------------------------
module Mixfix.Acyclic.PrecedenceGraph where
open import Data.List
open import Data.Product
open import Mixfix.Fixity
open import Mixfix.Operator
open import Mixfix.Expr
-- Precedence graphs are represented by their unfoldings as forests
-- (one tree for every node in the graph). This does not take into
-- account the sharing of the precedence graphs, but this code is
-- not aimed at efficiency.
-- Precedence trees.
data Precedence : Set where
precedence : (o : (fix : Fixity) → List (∃ (Operator fix)))
(s : List Precedence) →
Precedence
-- Precedence forests.
PrecedenceGraph : Set
PrecedenceGraph = List Precedence
-- The operators of the given precedence.
ops : Precedence → (fix : Fixity) → List (∃ (Operator fix))
ops (precedence o s) = o
-- The immediate successors of the precedence level.
↑ : Precedence → List Precedence
↑ (precedence o s) = s
-- Acyclic precedence graphs.
acyclic : PrecedenceGraphInterface
acyclic = record
{ PrecedenceGraph = PrecedenceGraph
; Precedence = λ _ → Precedence
; ops = λ _ → ops
; ↑ = λ _ → ↑
; anyPrecedence = λ g → g
}
| {
"alphanum_fraction": 0.6091522881,
"avg_line_length": 26.137254902,
"ext": "agda",
"hexsha": "ff797ccd41a7b62116c8ee2ac5ae20e1594a1ebc",
"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": "76774f54f466cfe943debf2da731074fe0c33644",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/parser-combinators",
"max_forks_repo_path": "Mixfix/Acyclic/PrecedenceGraph.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/parser-combinators",
"max_issues_repo_path": "Mixfix/Acyclic/PrecedenceGraph.agda",
"max_line_length": 72,
"max_stars_count": 7,
"max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "yurrriq/parser-combinators",
"max_stars_repo_path": "Mixfix/Acyclic/PrecedenceGraph.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z",
"num_tokens": 326,
"size": 1333
} |
{-# OPTIONS --cubical --no-import-sorts --guardedness --safe #-}
module Cubical.Codata.M.AsLimit.helper where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv using (_≃_)
open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Data.Unit
open import Cubical.Data.Prod
open import Cubical.Data.Nat as ℕ using (ℕ ; suc ; _+_ )
open import Cubical.Data.Sigma hiding (_×_)
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Path
open import Cubical.Functions.Embedding
open import Cubical.Functions.FunExtEquiv
open Iso
-- General
iso→fun-Injection :
∀ {ℓ} {A B C : Type ℓ} (isom : Iso A B)
→ ∀ {f g : C -> A}
→ (x : C) → (Iso.fun isom (f x) ≡ Iso.fun isom (g x)) ≡ (f x ≡ g x)
iso→fun-Injection {A = A} {B} {C} isom {f = f} {g} =
isEmbedding→Injection {A = A} {B} {C} (Iso.fun isom) (iso→isEmbedding {A = A} {B} isom) {f = f} {g = g}
abstract
iso→Pi-fun-Injection :
∀ {ℓ} {A B C : Type ℓ} (isom : Iso A B)
→ ∀ {f g : C -> A}
→ Iso (∀ x → (fun isom) (f x) ≡ (fun isom) (g x)) (∀ x → f x ≡ g x)
iso→Pi-fun-Injection {A = A} {B} {C} isom {f = f} {g} =
pathToIso (cong (λ k → ∀ x → k x) (funExt (iso→fun-Injection isom {f = f} {g = g})))
iso→fun-Injection-Iso :
∀ {ℓ} {A B C : Type ℓ} (isom : Iso A B)
→ ∀ {f g : C -> A}
→ Iso (fun isom ∘ f ≡ fun isom ∘ g) (f ≡ g)
iso→fun-Injection-Iso {A = A} {B} {C} isom {f = f} {g} =
(fun isom) ∘ f ≡ (fun isom) ∘ g
Iso⟨ invIso funExtIso ⟩
(∀ x → (fun isom) (f x) ≡ (fun isom) (g x))
Iso⟨ iso→Pi-fun-Injection isom ⟩
(∀ x → f x ≡ g x)
Iso⟨ funExtIso ⟩
f ≡ g ∎Iso
iso→fun-Injection-Path :
∀ {ℓ} {A B C : Type ℓ} (isom : Iso A B)
→ ∀ {f g : C -> A}
→ (fun isom ∘ f ≡ fun isom ∘ g) ≡ (f ≡ g)
iso→fun-Injection-Path {A = A} {B} {C} isom {f = f} {g} =
isoToPath (iso→fun-Injection-Iso isom)
iso→inv-Injection-Path :
∀ {ℓ} {A B C : Type ℓ} (isom : Iso A B) →
∀ {f g : C -> B} →
-----------------------
((inv isom) ∘ f ≡ (inv isom) ∘ g) ≡ (f ≡ g)
iso→inv-Injection-Path {A = A} {B} {C} isom {f = f} {g} = iso→fun-Injection-Path (invIso isom)
iso→fun-Injection-Iso-x :
∀ {ℓ} {A B : Type ℓ}
→ (isom : Iso A B)
→ ∀ {x y : A}
→ Iso ((fun isom) x ≡ (fun isom) y) (x ≡ y)
iso→fun-Injection-Iso-x isom {x} {y} =
let tempx = λ {(lift tt) → x}
tempy = λ {(lift tt) → y} in
fun isom x ≡ fun isom y
Iso⟨ iso (λ x₁ t → x₁)
(λ x₁ → x₁ (lift tt))
(λ x → refl)
(λ x → refl) ⟩
(∀ (t : Lift Unit) -> (((fun isom) ∘ tempx) t ≡ ((fun isom) ∘ tempy) t))
Iso⟨ iso→Pi-fun-Injection isom ⟩
(∀ (t : Lift Unit) -> tempx t ≡ tempy t)
Iso⟨ iso (λ x₁ → x₁ (lift tt))
(λ x₁ t → x₁)
(λ x → refl)
(λ x → refl) ⟩
x ≡ y ∎Iso
iso→inv-Injection-Iso-x :
∀ {ℓ} {A B : Type ℓ}
→ (isom : Iso A B)
→ ∀ {x y : B}
→ Iso ((inv isom) x ≡ (inv isom) y) (x ≡ y)
iso→inv-Injection-Iso-x {A = A} {B = B} isom =
iso→fun-Injection-Iso-x {A = B} {B = A} (invIso isom)
iso→fun-Injection-Path-x :
∀ {ℓ} {A B : Type ℓ}
→ (isom : Iso A B)
→ ∀ {x y : A}
→ ((fun isom) x ≡ (fun isom) y) ≡ (x ≡ y)
iso→fun-Injection-Path-x isom {x} {y} =
isoToPath (iso→fun-Injection-Iso-x isom)
iso→inv-Injection-Path-x :
∀ {ℓ} {A B : Type ℓ}
→ (isom : Iso A B)
→ ∀ {x y : B}
→ ((inv isom) x ≡ (inv isom) y) ≡ (x ≡ y)
iso→inv-Injection-Path-x isom =
isoToPath (iso→inv-Injection-Iso-x isom)
| {
"alphanum_fraction": 0.5489027364,
"avg_line_length": 31.547008547,
"ext": "agda",
"hexsha": "a60caf8525926ac5b9adb3d5086e614c8711b5e1",
"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/Codata/M/AsLimit/helper.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/Codata/M/AsLimit/helper.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/Codata/M/AsLimit/helper.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1538,
"size": 3691
} |
-- Andreas, 2016-07-13, issue reported by Mietek Bak
-- {-# OPTIONS -v tc.size:20 #-}
-- {-# OPTIONS -v tc.meta.assign:30 #-}
open import Agda.Builtin.Size
data Cx (U : Set) : Set where
⌀ : Cx U
_,_ : Cx U → U → Cx U
data _∈_ {U : Set} (A : U) : Cx U → Set where
top : ∀ {Γ} → A ∈ (Γ , A)
pop : ∀ {C Γ} → A ∈ Γ → A ∈ (Γ , C)
infixr 3 _⊃_
data Ty : Set where
ι : Ty
_⊃_ : Ty → Ty → Ty
infix 1 _⊢⟨_⟩_
data _⊢⟨_⟩_ (Γ : Cx Ty) : Size → Ty → Set where
var : ∀ {m A} → A ∈ Γ → Γ ⊢⟨ m ⟩ A
lam : ∀ {m A B} {m′ : Size< m} → Γ , A ⊢⟨ m′ ⟩ B → Γ ⊢⟨ m ⟩ A ⊃ B
app : ∀ {m A B} {m′ m″ : Size< m} → Γ ⊢⟨ m′ ⟩ A ⊃ B → Γ ⊢⟨ m″ ⟩ A → Γ ⊢⟨ m ⟩ B
works : ∀ {m A B Γ} → Γ ⊢⟨ ↑ ↑ ↑ ↑ m ⟩ (A ⊃ A ⊃ B) ⊃ A ⊃ B
works = lam (lam (app (app (var (pop top)) (var top)) (var top)))
test : ∀ {m A B Γ} → Γ ⊢⟨ {!↑ ↑ ↑ ↑ m!} ⟩ (A ⊃ A ⊃ B) ⊃ A ⊃ B
test = lam (lam (app (app (var (pop top)) (var top)) (var top)))
-- This interaction meta should be solvable with
-- ↑ ↑ ↑ ↑ m
-- Give should succeed.
-- The problem was: premature instantiation to ∞.
| {
"alphanum_fraction": 0.4608208955,
"avg_line_length": 28.972972973,
"ext": "agda",
"hexsha": "4a03bce441942d977b4fb675b1b8a4b44115dde1",
"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/interaction/Issue2095.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/interaction/Issue2095.agda",
"max_line_length": 80,
"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/interaction/Issue2095.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": 505,
"size": 1072
} |
{-# OPTIONS --type-in-type #-}
module Data where
open import Prelude
data Sigma (A : Set)(B : A -> Set) : Set
data Sigma A B where
pair : (x : A) -> B x -> Sigma A B
fst : {A : _} {B : _} -> Sigma A B -> A
fst (pair x y) = x
snd : {A : _} {B : _} (p : Sigma A B) -> B (fst p)
snd (pair x y) = y
data Unit : Set
data Unit where
tt : Unit
Cat : Set
Cat =
Sigma Set (\ Obj ->
Sigma (Obj -> Obj -> Set) (\ Hom ->
Sigma ((X : _) -> Hom X X) (\ id ->
Sigma ((X Y Z : _) -> Hom Y Z -> Hom X Y -> Hom X Z) (\ comp ->
Sigma ((X Y : _)(f : Hom X Y) -> comp _ _ _ (id Y) f == f) (\ idl ->
Sigma ((X Y : _)(f : Hom X Y) -> comp _ _ _ f (id X) == f) (\ idr ->
Sigma ((W X Y Z : _)
(f : Hom W X)(g : Hom X Y)(h : Hom Y Z) ->
comp _ _ _ (comp _ _ _ h g) f ==
comp _ _ _ h (comp _ _ _ g f)) (\ assoc ->
Unit)))))))
Obj : (C : Cat) -> Set
Obj C = fst C
Hom : (C : Cat) -> Obj C -> Obj C -> Set
Hom C = fst (snd C)
id : (C : Cat) -> (X : _) -> Hom C X X
id C = fst (snd (snd C))
comp : (C : Cat) -> (X Y Z : _) -> Hom C Y Z -> Hom C X Y -> Hom C X Z
comp C = fst (snd (snd (snd C)))
idl : (C : Cat) -> (X Y : _)(f : Hom C X Y) ->
comp C _ _ _ (id C Y) f == f
idl C = fst (snd (snd (snd (snd C))))
idr : (C : Cat) -> (X Y : _)(f : Hom C X Y) ->
comp C _ _ _ f (id C X) == f
idr C = fst (snd (snd (snd (snd (snd C)))))
assoc : (C : Cat) ->
(W X Y Z : _) (f : Hom C W X)(g : Hom C X Y)(h : Hom C Y Z) ->
comp C _ _ _ (comp C _ _ _ h g) f ==
comp C _ _ _ h (comp C _ _ _ g f)
assoc C = fst (snd (snd (snd (snd (snd (snd C))))))
| {
"alphanum_fraction": 0.4137535817,
"avg_line_length": 29.5762711864,
"ext": "agda",
"hexsha": "a6bb4b62b32a01f2c46803ed02ab2f00fec34467",
"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": "src/prototyping/term/examples/Data.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": "src/prototyping/term/examples/Data.agda",
"max_line_length": 72,
"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": "src/prototyping/term/examples/Data.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": 633,
"size": 1745
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- The lifting of a strict order to incorporate new extrema
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- This module is designed to be used with
-- Relation.Nullary.Construct.Add.Extrema
open import Relation.Binary
module Relation.Binary.Construct.Add.Extrema.Strict
{a ℓ} {A : Set a} (_<_ : Rel A ℓ) where
open import Level
open import Function
open import Relation.Nullary
import Relation.Nullary.Construct.Add.Infimum as I
open import Relation.Nullary.Construct.Add.Extrema
import Relation.Binary.Construct.Add.Infimum.Strict as AddInfimum
import Relation.Binary.Construct.Add.Supremum.Strict as AddSupremum
import Relation.Binary.Construct.Add.Extrema.Equality as Equality
import Relation.Binary.Construct.Add.Extrema.NonStrict as NonStrict
------------------------------------------------------------------------
-- Definition
private
module Inf = AddInfimum _<_
module Sup = AddSupremum Inf._<₋_
open Sup using () renaming (_<⁺_ to _<±_) public
------------------------------------------------------------------------
-- Useful pattern synonyms
pattern ⊥±<[_] l = Sup.[ Inf.⊥₋<[ l ] ]
pattern [_] p = Sup.[ Inf.[ p ] ]
pattern ⊥±<⊤± = Sup.[ I.⊥₋ ]<⊤⁺
pattern [_]<⊤± k = Sup.[ I.[ k ] ]<⊤⁺
------------------------------------------------------------------------
-- Relational properties
[<]-injective : ∀ {k l} → [ k ] <± [ l ] → k < l
[<]-injective = Inf.[<]-injective ∘′ Sup.[<]-injective
<±-asym : Asymmetric _<_ → Asymmetric _<±_
<±-asym = Sup.<⁺-asym ∘′ Inf.<₋-asym
<±-trans : Transitive _<_ → Transitive _<±_
<±-trans = Sup.<⁺-trans ∘′ Inf.<₋-trans
<±-dec : Decidable _<_ → Decidable _<±_
<±-dec = Sup.<⁺-dec ∘′ Inf.<₋-dec
<±-irrelevant : Irrelevant _<_ → Irrelevant _<±_
<±-irrelevant = Sup.<⁺-irrelevant ∘′ Inf.<₋-irrelevant
module _ {e} {_≈_ : Rel A e} where
open Equality _≈_
<±-cmp : Trichotomous _≈_ _<_ → Trichotomous _≈±_ _<±_
<±-cmp = Sup.<⁺-cmp ∘′ Inf.<₋-cmp
<±-irrefl : Irreflexive _≈_ _<_ → Irreflexive _≈±_ _<±_
<±-irrefl = Sup.<⁺-irrefl ∘′ Inf.<₋-irrefl
<±-respˡ-≈± : _<_ Respectsˡ _≈_ → _<±_ Respectsˡ _≈±_
<±-respˡ-≈± = Sup.<⁺-respˡ-≈⁺ ∘′ Inf.<₋-respˡ-≈₋
<±-respʳ-≈± : _<_ Respectsʳ _≈_ → _<±_ Respectsʳ _≈±_
<±-respʳ-≈± = Sup.<⁺-respʳ-≈⁺ ∘′ Inf.<₋-respʳ-≈₋
<±-resp-≈± : _<_ Respects₂ _≈_ → _<±_ Respects₂ _≈±_
<±-resp-≈± = Sup.<⁺-resp-≈⁺ ∘′ Inf.<₋-resp-≈₋
module _ {r} {_≤_ : Rel A r} where
open NonStrict _≤_
<±-transʳ : Trans _≤_ _<_ _<_ → Trans _≤±_ _<±_ _<±_
<±-transʳ = Sup.<⁺-transʳ ∘′ Inf.<₋-transʳ
<±-transˡ : Trans _<_ _≤_ _<_ → Trans _<±_ _≤±_ _<±_
<±-transˡ = Sup.<⁺-transˡ ∘′ Inf.<₋-transˡ
------------------------------------------------------------------------
-- Structures
module _ {e} {_≈_ : Rel A e} where
open Equality _≈_
<±-isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_ →
IsStrictPartialOrder _≈±_ _<±_
<±-isStrictPartialOrder =
Sup.<⁺-isStrictPartialOrder ∘′ Inf.<₋-isStrictPartialOrder
<±-isDecStrictPartialOrder : IsDecStrictPartialOrder _≈_ _<_ →
IsDecStrictPartialOrder _≈±_ _<±_
<±-isDecStrictPartialOrder =
Sup.<⁺-isDecStrictPartialOrder ∘′ Inf.<₋-isDecStrictPartialOrder
<±-isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_ →
IsStrictTotalOrder _≈±_ _<±_
<±-isStrictTotalOrder =
Sup.<⁺-isStrictTotalOrder ∘′ Inf.<₋-isStrictTotalOrder
| {
"alphanum_fraction": 0.5492125984,
"avg_line_length": 31.4690265487,
"ext": "agda",
"hexsha": "8c66fbf033df809cd409947b78809bccfbdf1d97",
"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/Construct/Add/Extrema/Strict.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/Construct/Add/Extrema/Strict.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/Construct/Add/Extrema/Strict.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1280,
"size": 3556
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.