Search is not available for this dataset
text
				 
			string  | meta
				 
			dict  | 
|---|---|
	-- Andreas, 2012-03-08
module NoNoTerminationCheck where
{-# NO_TERMINATION_CHECK #-}
f : Set
f = f
-- the pragma should not extend to the following definition
g : Set
g = g
-- error: non-termination
 
 | 
	{
  "alphanum_fraction": 0.7073170732,
  "avg_line_length": 13.6666666667,
  "ext": "agda",
  "hexsha": "5a328ab58e749a72850ccff292b5d82894a53e4f",
  "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/NoNoTerminationCheck.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/NoNoTerminationCheck.agda",
  "max_line_length": 59,
  "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/NoNoTerminationCheck.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": 59,
  "size": 205
} 
 | 
					
	-- {-# OPTIONS -v tc.meta:30 #-}
{-# OPTIONS --show-implicit --show-irrelevant #-}
module Issue629a where
record ∃ {A : Set} (B : A → Set) : Set where
  constructor _,_
  field
    proj₁ : A
    proj₂ : B proj₁
uncurry : {A : Set} {B : A → Set} {C : ∃ B → Set} →
          ((x : A) (y : B x) → C (x , y)) →
          ((p : ∃ B) → C p)
uncurry f (x , y) = f x y
foo : {A : Set} {B : A → Set} → ∃ B → ∃ B
foo = uncurry λ x y → (x , y)
 
 | 
	{
  "alphanum_fraction": 0.4633027523,
  "avg_line_length": 24.2222222222,
  "ext": "agda",
  "hexsha": "735195499075960d6d96d835e69baa5d3d10f92f",
  "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/Issue629a.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/Issue629a.agda",
  "max_line_length": 51,
  "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/Issue629a.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": 178,
  "size": 436
} 
 | 
					
	
module Fin where
import Nat
import Bool
open Nat hiding (_==_; _<_)
open Bool
data FZero : Set where
data FSuc (A : Set) : Set where
  fz : FSuc A
  fs : A -> FSuc A
mutual
  Fin' : Nat -> Set
  Fin' zero    = FZero
  Fin' (suc n) = FSuc (Fin n)
  data Fin (n : Nat) : Set where
    fin : Fin' n -> Fin n
fzero : {n : Nat} -> Fin (suc n)
fzero = fin fz
fsuc : {n : Nat} -> Fin n -> Fin (suc n)
fsuc n = fin (fs n)
_==_ : {n : Nat} -> Fin n -> Fin n -> Bool
_==_ {zero}  (fin ())     (fin ())
_==_ {suc n} (fin fz)     (fin fz)     = true
_==_ {suc n} (fin (fs i)) (fin (fs j)) = i == j
_==_ {suc n} (fin fz)     (fin (fs j)) = false
_==_ {suc n} (fin (fs i)) (fin fz)     = false
subst : {n : Nat}{i j : Fin n} -> (P : Fin n -> Set) -> IsTrue (i == j) -> P i -> P j
subst {zero}  {fin ()}     {fin ()}     P _  _
subst {suc n} {fin fz}     {fin fz}     P eq pi = pi
subst {suc n} {fin (fs i)} {fin (fs j)} P eq pi = subst (\z -> P (fsuc z)) eq pi
subst {suc n} {fin fz}     {fin (fs j)} P () _
subst {suc n} {fin (fs i)} {fin fz}     P () _
_<_ : {n : Nat} -> Fin n -> Fin n -> Bool
_<_ {zero}  (fin ())     (fin ())
_<_ {suc n} _            (fin fz)     = false
_<_ {suc n} (fin fz)     (fin (fs j)) = true
_<_ {suc n} (fin (fs i)) (fin (fs j)) = i < j
fromNat : (n : Nat) -> Fin (suc n)
fromNat  zero   = fzero
fromNat (suc n) = fsuc (fromNat n)
liftSuc : {n : Nat} -> Fin n -> Fin (suc n)
liftSuc {zero}  (fin ())
liftSuc {suc n} (fin fz)     = fin fz
liftSuc {suc n} (fin (fs i)) = fsuc (liftSuc i)
lift+ : {n : Nat}(m : Nat) -> Fin n -> Fin (m + n)
lift+  zero   i = i
lift+ (suc m) i = liftSuc (lift+ m i)
 
 | 
	{
  "alphanum_fraction": 0.4917127072,
  "avg_line_length": 25.453125,
  "ext": "agda",
  "hexsha": "9b3543414a036d325c1e3d62ad9a644e9c514568",
  "lang": "Agda",
  "max_forks_count": 371,
  "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
  "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
  "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
  "max_forks_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_forks_repo_name": "Agda-zh/agda",
  "max_forks_repo_path": "benchmark/ac/Fin.agda",
  "max_issues_count": 4066,
  "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
  "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
  "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
  "max_issues_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_issues_repo_name": "shlevy/agda",
  "max_issues_repo_path": "benchmark/ac/Fin.agda",
  "max_line_length": 85,
  "max_stars_count": 1989,
  "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
  "max_stars_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_stars_repo_name": "shlevy/agda",
  "max_stars_repo_path": "benchmark/ac/Fin.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": 681,
  "size": 1629
} 
 | 
					
	{-
Definition of the Klein bottle as a HIT
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.KleinBottle.Base where
open import Cubical.Core.Everything
data KleinBottle : Type where
  point : KleinBottle
  line1 : point ≡ point
  line2 : point ≡ point
  square : PathP (λ i → line1 (~ i) ≡ line1 i) line2 line2
 
 | 
	{
  "alphanum_fraction": 0.6961651917,
  "avg_line_length": 21.1875,
  "ext": "agda",
  "hexsha": "9c27c61447d39a120fabdd13ab2a539d786ceb25",
  "lang": "Agda",
  "max_forks_count": 1,
  "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
  "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
  "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "dan-iel-lee/cubical",
  "max_forks_repo_path": "Cubical/HITs/KleinBottle/Base.agda",
  "max_issues_count": 1,
  "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
  "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
  "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "dan-iel-lee/cubical",
  "max_issues_repo_path": "Cubical/HITs/KleinBottle/Base.agda",
  "max_line_length": 58,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "dan-iel-lee/cubical",
  "max_stars_repo_path": "Cubical/HITs/KleinBottle/Base.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 107,
  "size": 339
} 
 | 
					
	{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
   Copyright (c) 2020, 2021, Oracle and/or its affiliates.
   Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
-- LBFT monad used by implementation,
-- and functions to facilitate reasoning about it.
module LibraBFT.ImplShared.LBFT where
open import Dijkstra.RWS
open import Haskell.Modules.RWS public
open import Haskell.Modules.RWS.Lens public
open import Haskell.Modules.RWS.RustAnyHow
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Interface.Output
open import Util.Prelude
----------------
-- LBFT Monad --
----------------
-- Global 'LBFT'; works over the whole state.
LBFT : Set → Set₁
LBFT = RWS Unit Output RoundManager
act : Output → LBFT Unit
act x = tell (x ∷ [])
LBFT-run : ∀ {A} → LBFT A → RoundManager → (A × RoundManager × List Output)
LBFT-run m = RWS-run m unit
LBFT-result : ∀ {A} → LBFT A → RoundManager → A
LBFT-result m rm = proj₁ (LBFT-run m rm)
LBFT-post : ∀ {A} → LBFT A → RoundManager → RoundManager
LBFT-post m rm = proj₁ (proj₂ (LBFT-run m rm))
LBFT-outs : ∀ {A} → LBFT A → RoundManager → List Output
LBFT-outs m rm = proj₂ (proj₂ (LBFT-run m rm))
LBFT-Pre  = RoundManager → Set
LBFT-Post = RWS-Post Output RoundManager
LBFT-Post-True : ∀ {A} → LBFT-Post A → LBFT A → RoundManager → Set
LBFT-Post-True Post m pre =
  let (x , post , outs) = LBFT-run m pre in
  Post x post outs
LBFT-weakestPre : ∀ {A} (m : LBFT A)
                  → LBFT-Post A → LBFT-Pre
LBFT-weakestPre m Post pre = RWS-weakestPre m Post unit pre
LBFT-Contract : ∀ {A} (m : LBFT A) → Set₁
LBFT-Contract{A} m =
  (Post : RWS-Post Output RoundManager A)
  → (pre : RoundManager) → LBFT-weakestPre m Post pre
  → LBFT-Post-True Post m pre
LBFT-contract : ∀ {A} (m : LBFT A) → LBFT-Contract m
LBFT-contract m Post pre pf = RWS-contract m Post unit pre pf
LBFT-⇒
  : ∀ {A} {P Q : LBFT-Post A}
  → ∀ m pre → LBFT-weakestPre m P pre
  → RWS-Post-⇒ P Q
  → LBFT-weakestPre m Q pre
LBFT-⇒ m pre pf f = RWS-⇒ m unit pre pf f
LBFT-⇒-bind
  : ∀ {A B} (P : LBFT-Post A) (Q : LBFT-Post B) (f : A → LBFT B)
  → (RWS-Post-⇒ P (RWS-weakestPre-bindPost unit f Q))
  → ∀ m st → LBFT-weakestPre m P st → LBFT-weakestPre (m >>= f) Q st
LBFT-⇒-bind Post Q f pf m st con = RWS-⇒-bind {P = Post} {Q} {f} m unit st con pf
LBFT-⇒-ebind
  : ∀ {A B C} {P : LBFT-Post (Either C A)} {Q : LBFT-Post (Either C B)}
  → {f : A → LBFT (Either C B)}
  → ∀ m st → LBFT-weakestPre m P st
  → RWS-Post-⇒ P (RWS-weakestPre-ebindPost unit f Q)
  → LBFT-weakestPre (m ∙?∙ f) Q st
LBFT-⇒-ebind {P = Post} {Q} {f} m st con pf =
  RWS-⇒-ebind m unit st con pf
 
 | 
	{
  "alphanum_fraction": 0.6535899334,
  "avg_line_length": 31.7882352941,
  "ext": "agda",
  "hexsha": "4c7b1f87c82e2ad173d93c9f9c2172792b282066",
  "lang": "Agda",
  "max_forks_count": null,
  "max_forks_repo_forks_event_max_datetime": null,
  "max_forks_repo_forks_event_min_datetime": null,
  "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
  "max_forks_repo_licenses": [
    "UPL-1.0"
  ],
  "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
  "max_forks_repo_path": "src/LibraBFT/ImplShared/LBFT.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "UPL-1.0"
  ],
  "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
  "max_issues_repo_path": "src/LibraBFT/ImplShared/LBFT.agda",
  "max_line_length": 111,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
  "max_stars_repo_licenses": [
    "UPL-1.0"
  ],
  "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
  "max_stars_repo_path": "src/LibraBFT/ImplShared/LBFT.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 987,
  "size": 2702
} 
 | 
					
	{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.EilenbergMacLane
open import homotopy.EilenbergMacLane1
open import homotopy.SmashFmapConn
open import homotopy.IterSuspSmash
open import homotopy.EilenbergMacLaneFunctor
open import cohomology.CupProduct.OnEM.InLowDegrees
open import cohomology.CupProduct.OnEM.InLowDegrees2
open import cohomology.CupProduct.OnEM.InAllDegrees
open import cohomology.CupProduct.OnEM.CommutativityInLowDegrees using (⊙×-cp₀₀-comm)
open import cohomology.CupProduct.OnEM.CommutativityInLowDegrees2
module cohomology.CupProduct.OnEM.CommutativityInAllDegrees where
module _ {i} {j} (G : AbGroup i) (H : AbGroup j) where
  open EMExplicit
  private
    module G = AbGroup G
    module H = AbGroup H
    module G⊗H = TensorProduct G H
    module H⊗G = TensorProduct H G
  private
    ⊙×-cp₀ₕ'-comm : ∀ (n : ℕ)
      → ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S n) ◃⊙∘
        ⊙×-cp₀ₕ' G H n ◃⊙idf
        =⊙∘
        ⊙×-cpₕ₀' H G n ◃⊙∘
        ⊙×-swap ◃⊙idf
    ⊙×-cp₀ₕ'-comm n = =⊙∘-in $
      →-⊙→-uncurry (λ g → ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S n) ⊙∘
                          ⊙EM-fmap H G⊗H.abgroup (G⊗H.ins-r-hom g) (S n))
        =⟨ (ap →-⊙→-uncurry $ λ= $ λ g →
           ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S n) ⊙∘
           ⊙EM-fmap H G⊗H.abgroup (G⊗H.ins-r-hom g) (S n)
             =⟨ ! (⊙EM-fmap-∘ H G⊗H.abgroup H⊗G.abgroup G⊗H.swap (G⊗H.ins-r-hom g) (S n)) ⟩
           ⊙EM-fmap H H⊗G.abgroup (G⊗H.swap ∘ᴳ G⊗H.ins-r-hom g) (S n)
             =⟨ ap (λ φ → ⊙EM-fmap H H⊗G.abgroup φ (S n)) $
                group-hom= {φ = G⊗H.swap ∘ᴳ G⊗H.ins-r-hom g} {ψ = H⊗G.ins-l-hom g} $
                λ= $ G⊗H.swap-β g ⟩
           ⊙EM-fmap H H⊗G.abgroup (H⊗G.ins-l-hom g) (S n) =∎)
         ⟩
      →-⊙→-uncurry (λ g → ⊙EM-fmap H H⊗G.abgroup (H⊗G.ins-l-hom g) (S n)) =∎
  ⊙×-cp₀ₕ-comm : ∀ (n : ℕ)
    → ⊙transport (⊙EM H⊗G.abgroup) (+-comm O (S n)) ◃⊙∘
      ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S n) ◃⊙∘
      ⊙×-cp₀ₕ G H n ◃⊙idf
      =⊙∘
      ⊙×-cpₕ₀ H G n ◃⊙∘
      ⊙×-swap ◃⊙idf
  ⊙×-cp₀ₕ-comm n =
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm O (S n)) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S n) ◃⊙∘
    ⊙×-cp₀ₕ G H n ◃⊙idf
      =⊙∘⟨ 2 & 1 & ⊙expand (⊙×-cp₀ₕ-seq G H n) ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm O (S n)) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S n) ◃⊙∘
    ⊙×-cp₀ₕ' G H n ◃⊙∘
    ⊙×-fmap (⊙<– (⊙emloop-equiv G.grp)) (⊙idf (⊙EM H (S n))) ◃⊙idf
      =⊙∘⟨ 1 & 2 & ⊙×-cp₀ₕ'-comm n ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm O (S n)) ◃⊙∘
    ⊙×-cpₕ₀' H G n ◃⊙∘
    ⊙×-swap ◃⊙∘
    ⊙×-fmap (⊙<– (⊙emloop-equiv G.grp)) (⊙idf (⊙EM H (S n))) ◃⊙idf
      =⊙∘₁⟨ 0 & 1 & ap (⊙transport (⊙EM H⊗G.abgroup)) $
                    set-path ℕ-level (+-comm O (S n)) (! (+-unit-r (S n))) ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-unit-r (S n))) ◃⊙∘
    ⊙×-cpₕ₀' H G n ◃⊙∘
    ⊙×-swap ◃⊙∘
    ⊙×-fmap (⊙<– (⊙emloop-equiv G.grp)) (⊙idf (⊙EM H (S n))) ◃⊙idf
      =⊙∘⟨ 2 & 2 &
           =⊙∘-in {gs = ⊙×-fmap (⊙idf (⊙EM H (S n))) (⊙<– (⊙emloop-equiv G.grp)) ◃⊙∘
                        ⊙×-swap ◃⊙idf} $ ! $ ⊙λ= $
           ⊙×-swap-natural (⊙<– (⊙emloop-equiv G.grp)) (⊙idf (⊙EM H (S n))) ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-unit-r (S n))) ◃⊙∘
    ⊙×-cpₕ₀' H G n ◃⊙∘
    ⊙×-fmap (⊙idf (⊙EM H (S n))) (⊙<– (⊙emloop-equiv G.grp)) ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘⟨ 0 & 3 & ⊙contract ⟩
    ⊙×-cpₕ₀ H G n ◃⊙∘
    ⊙×-swap ◃⊙idf ∎⊙∘
module _ {i} {j} (G : AbGroup i) (H : AbGroup j) where
  open EMExplicit
  private
    module G = AbGroup G
    module H = AbGroup H
    module G⊗H = TensorProduct G H
    module H⊗G = TensorProduct H G
  ⊙∧-cpₕₕ'-comm : ∀ (m n : ℕ)
    → ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
      ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m + S n) ◃⊙∘
      ⊙∧-cpₕₕ' G H m n ◃⊙idf
      =⊙∘
      ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) ◃⊙∘
      ⊙∧-cpₕₕ' H G n m ◃⊙∘
      ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
  ⊙∧-cpₕₕ'-comm m n =
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m + S n) ◃⊙∘
    ⊙∧-cpₕₕ' G H m n ◃⊙idf
      =⊙∘₁⟨ 1 & 1 & ! $ ⊙transport-⊙EM-uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative (S m + S n) ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
    ⊙transport (λ K → ⊙EM K (S (m + S n))) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative) ◃⊙∘
    ⊙∧-cpₕₕ' G H m n ◃⊙idf
      =⊙∘⟨ 2 & 1 & ⊙expand (⊙∧-cpₕₕ'-seq G H m n) ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
    ⊙transport (λ K → ⊙EM K (S (m + S n))) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative) ◃⊙∘
    ⊙cpₕₕ'' G⊗H.abgroup m n ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ G H) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘⟨ 1 & 2 & !⊙∘ $ ⊙transport-natural-=⊙∘
             (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative)
             (λ K → ⊙cpₕₕ'' K m n) ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
    ⊙cpₕₕ'' H⊗G.abgroup m n ◃⊙∘
    ⊙transport (λ K → ⊙Susp^ (m + n) (⊙EM K 2)) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ G H) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘₁⟨ 2 & 1 & p₁ ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
    ⊙cpₕₕ'' H⊗G.abgroup m n ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙Trunc-fmap (⊙Susp^-fmap 1 (⊙EM₁-fmap G⊗H.swap))) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ G H) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘⟨ 1 & 1 & ⊙expand (⊙cpₕₕ''-seq H⊗G.abgroup m n) ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
    ⊙cond-neg H⊗G.abgroup (S m + S n) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S m) n)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (m + n) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙Trunc-fmap (⊙Susp^-fmap 1 (⊙EM₁-fmap G⊗H.swap))) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ G H) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘⟨ 0 & 2 & !⊙∘ $ ⊙transport-natural-=⊙∘
             (+-comm (S m) (S n))
             (λ k → ⊙cond-neg H⊗G.abgroup k (odd n)) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S m) n)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (m + n) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙Trunc-fmap (⊙Susp^-fmap 1 (⊙EM₁-fmap G⊗H.swap))) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ G H) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘⟨ 1 & 2 & !⊙∘ $ ⊙transport-∙ (⊙EM H⊗G.abgroup) (! (+-βr (S m) n)) (+-comm (S m) (S n)) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S m) n) ∙ +-comm (S m) (S n)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (m + n) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙Trunc-fmap (⊙Susp^-fmap 1 (⊙EM₁-fmap G⊗H.swap))) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ G H) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘₁⟨ 1 & 1 & ap (⊙transport (⊙EM H⊗G.abgroup)) $
            set-path ℕ-level (! (+-βr (S m) n) ∙ +-comm (S m) (S n))
                             (ap (λ k → S (S k)) (+-comm m n) ∙ ! (+-βr (S n) m)) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (ap (λ k → S (S k)) (+-comm m n) ∙ ! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (m + n) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙Trunc-fmap (⊙Susp^-fmap 1 (⊙EM₁-fmap G⊗H.swap))) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ G H) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘⟨ 1 & 1 & ⊙transport-∙ (⊙EM H⊗G.abgroup)
             (ap (λ k → S (S k)) (+-comm m n))
             (! (+-βr (S n) m)) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (ap (λ k → S (S k)) (+-comm m n)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (m + n) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙Trunc-fmap (⊙Susp^-fmap 1 (⊙EM₁-fmap G⊗H.swap))) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ G H) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘₁⟨ 2 & 1 & ⊙transport-⊙coe (⊙EM H⊗G.abgroup) (ap (λ k → S (S k)) (+-comm m n)) ∙
                    ap ⊙coe (∘-ap (⊙EM H⊗G.abgroup) (λ k → S (S k)) (+-comm m n)) ∙
                    ! (⊙transport-⊙coe (λ k → ⊙EM H⊗G.abgroup (S (S k))) (+-comm m n)) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙transport (λ k → ⊙EM H⊗G.abgroup (S (S k))) (+-comm m n) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (m + n) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙Trunc-fmap (⊙Susp^-fmap 1 (⊙EM₁-fmap G⊗H.swap))) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ G H) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘⟨ 4 & 2 & ⊙Susp^-fmap-seq-=⊙∘ (m + n) (⊙∧-cp₁₁-comm G H) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙transport (λ k → ⊙EM H⊗G.abgroup (S (S k))) (+-comm m n) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (m + n) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙EM-neg H⊗G.abgroup 2) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘⟨ 2 & 2 & !⊙∘ $ ⊙transport-natural-=⊙∘ (+-comm m n) (⊙EM2-Susp H⊗G.abgroup) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙transport (λ k → ⊙Susp^ k (⊙EM H⊗G.abgroup 2)) (+-comm m n) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙EM-neg H⊗G.abgroup 2) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘⟨ 3 & 2 & !⊙∘ $ ⊙transport-natural-=⊙∘
             (+-comm m n)
             (λ k → ⊙Susp^-fmap k (⊙EM-neg H⊗G.abgroup 2)) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙EM-neg H⊗G.abgroup 2) ◃⊙∘
    ⊙transport (λ k → ⊙Susp^ k (⊙EM H⊗G.abgroup 2)) (+-comm m n) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘⟨ 4 & 2 & !⊙∘ $ ⊙transport-natural-=⊙∘
             (+-comm m n)
             (λ k → ⊙Susp^-fmap k (⊙∧-cp₁₁ H G)) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙EM-neg H⊗G.abgroup 2) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙transport (λ k → ⊙Susp^ k (⊙EM₁ H.grp ⊙∧ ⊙EM₁ G.grp)) (+-comm m n) ◃⊙∘
    ⊙Susp^-fmap (m + n) (⊙∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ◃⊙idf
      =⊙∘⟨ 5 & 3 & ⊙Σ^∧Σ^-out-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp) m n ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙EM-neg H⊗G.abgroup 2) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙maybe-Susp^-flip (n + m) (and (odd n) (odd m)) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 4 & 2 & ⊙maybe-Susp^-flip-natural-=⊙∘ (⊙∧-cp₁₁ H G) (n + m) (and (odd n) (odd m)) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙EM-neg H⊗G.abgroup 2) ◃⊙∘
    ⊙maybe-Susp^-flip (n + m) (and (odd n) (odd m)) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘₁⟨ 3 & 1 & ! p₂ ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙transport (λ K → ⊙Susp^ (n + m) (⊙EM K 2)) (inv-path H⊗G.abgroup) ◃⊙∘
    ⊙maybe-Susp^-flip (n + m) (and (odd n) (odd m)) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 2 & 2 & ⊙transport-natural-=⊙∘ (inv-path H⊗G.abgroup) (λ K → ⊙EM2-Susp K (n + m)) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙transport (λ K → ⊙EM K (S (S (n + m)))) (inv-path H⊗G.abgroup) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙maybe-Susp^-flip (n + m) (and (odd n) (odd m)) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 1 & 2 & ⊙transport-natural-=⊙∘
             (inv-path H⊗G.abgroup)
             (λ K → ⊙transport (⊙EM K) (! (+-βr (S n) m))) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (λ K → ⊙EM K (S n + S m)) (inv-path H⊗G.abgroup) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙maybe-Susp^-flip (n + m) (and (odd n) (odd m)) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 3 & 2 & ⊙EM2-Susp-⊙maybe-Susp^-flip H⊗G.abgroup (n + m) (and (odd n) (odd m)) h₁ ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (λ K → ⊙EM K (S n + S m)) (inv-path H⊗G.abgroup) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙Trunc-fmap (⊙maybe-Susp-flip (⊙Susp^ (n + m) (⊙EM₁ H⊗G.grp)) (and (odd n) (odd m))) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘₁⟨ 3 & 1 & ⊙maybe-Susp^-flip-⊙cond-neg
              H⊗G.abgroup (S n + m) (and (odd n) (odd m)) h₂ ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (λ K → ⊙EM K (S n + S m)) (inv-path H⊗G.abgroup) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙cond-neg H⊗G.abgroup (S (S (n + m))) (and (odd n) (odd m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 2 & 2 & !⊙∘ $ ⊙transport-natural-=⊙∘
             (! (+-βr (S n) m))
             (λ k → ⊙cond-neg H⊗G.abgroup k (and (odd n) (odd m))) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙transport (λ K → ⊙EM K (S n + S m)) (inv-path H⊗G.abgroup) ◃⊙∘
    ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd n) (odd m)) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 1 & 2 & ⊙cond-neg-∘ H⊗G.abgroup (S n + S m) true (and (odd n) (odd m)) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd n) ◃⊙∘
    ⊙cond-neg H⊗G.abgroup (S (n + S m)) (negate (and (odd n) (odd m))) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 0 & 2 & ⊙cond-neg-∘ H⊗G.abgroup (S n + S m) (odd n) (negate (and (odd n) (odd m))) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (xor (odd n) (negate (and (odd n) (odd m)))) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘₁⟨ 0 & 1 & ap (⊙cond-neg H⊗G.abgroup (S n + S m)) (bp (odd n) (odd m)) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (xor (and (negate (odd m)) (negate (odd n))) (odd m)) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 0 & 1 & !⊙∘ $ ⊙cond-neg-∘ H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) (odd m) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) ◃⊙∘
    ⊙cond-neg H⊗G.abgroup (S n + S m) (odd m) ◃⊙∘
    ⊙transport (⊙EM H⊗G.abgroup) (! (+-βr (S n) m)) ◃⊙∘
    ⊙EM2-Susp H⊗G.abgroup (n + m) ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 1 & 3 & ⊙contract ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) ◃⊙∘
    ⊙cpₕₕ'' H⊗G.abgroup n m ◃⊙∘
    ⊙Susp^-fmap (n + m) (⊙∧-cp₁₁ H G) ◃⊙∘
    ⊙Σ^∧Σ^-out (⊙EM₁ H.grp) (⊙EM₁ G.grp) n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 1 & 3 & ⊙contract ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) ◃⊙∘
    ⊙∧-cpₕₕ' H G n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf ∎⊙∘
    where
      p₁ : ⊙transport (λ K → ⊙Susp^ (m + n) (⊙EM K 2)) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative)
           == ⊙Susp^-fmap (m + n) (⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap 2)
      p₁ =
        ⊙transport (λ K → ⊙Susp^ (m + n) (⊙EM K 2)) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative)
          =⟨ ⊙transport-⊙coe
               (λ K → ⊙Susp^ (m + n) (⊙EM K 2))
               (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative) ⟩
        ⊙coe (ap (λ K → ⊙Susp^ (m + n) (⊙EM K 2)) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative))
          =⟨ ap ⊙coe (ap-∘ (⊙Susp^ (m + n)) (λ K → ⊙EM K 2) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative)) ⟩
        ⊙coe (ap (⊙Susp^ (m + n)) (ap (λ K → ⊙EM K 2) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative)))
          =⟨ ! $ ⊙transport-⊙coe
               (⊙Susp^ (m + n))
               (ap (λ K → ⊙EM K 2) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative)) ⟩
        ⊙transport (⊙Susp^ (m + n)) (ap (λ K → ⊙EM K 2) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative))
          =⟨ ⊙transport-⊙Susp^ (m + n) (ap (λ K → ⊙EM K 2) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative)) ⟩
        ⊙Susp^-fmap (m + n) (⊙coe (ap (λ K → ⊙EM K 2) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative)))
          =⟨ ap (⊙Susp^-fmap (m + n)) $ ! $
             ⊙transport-⊙coe (λ K → ⊙EM K 2) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative) ⟩
        ⊙Susp^-fmap (m + n) (⊙transport (λ K → ⊙EM K 2) (uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative))
          =⟨ ap (⊙Susp^-fmap (m + n)) (⊙transport-⊙EM-uaᴬᴳ G⊗H.abgroup H⊗G.abgroup G⊗H.commutative 2) ⟩
        ⊙Susp^-fmap (m + n) (⊙Trunc-fmap (⊙Susp^-fmap 1 (⊙EM₁-fmap (–>ᴳ G⊗H.commutative)))) =∎
      p₂ : ⊙transport (λ K → ⊙Susp^ (n + m) (⊙EM K 2)) (inv-path H⊗G.abgroup)
           == ⊙Susp^-fmap (n + m) (⊙EM-neg H⊗G.abgroup 2)
      p₂ =
        ⊙transport (λ K → ⊙Susp^ (n + m) (⊙EM K 2)) (inv-path H⊗G.abgroup)
          =⟨ ⊙transport-⊙coe (λ K → ⊙Susp^ (n + m) (⊙EM K 2)) (inv-path H⊗G.abgroup) ⟩
        ⊙coe (ap (λ K → ⊙Susp^ (n + m) (⊙EM K 2)) (inv-path H⊗G.abgroup))
          =⟨ ap ⊙coe (ap-∘ (⊙Susp^ (n + m)) (λ K → ⊙EM K 2) (inv-path H⊗G.abgroup)) ⟩
        ⊙coe (ap (⊙Susp^ (n + m)) (ap (λ K → ⊙EM K 2) (inv-path H⊗G.abgroup)))
          =⟨ ! $ ⊙transport-⊙coe (⊙Susp^ (n + m)) (ap (λ K → ⊙EM K 2) (inv-path H⊗G.abgroup)) ⟩
        ⊙transport (⊙Susp^ (n + m)) (ap (λ K → ⊙EM K 2) (inv-path H⊗G.abgroup))
          =⟨ ⊙transport-⊙Susp^ (n + m) (ap (λ K → ⊙EM K 2) (inv-path H⊗G.abgroup)) ⟩
        ⊙Susp^-fmap (n + m) (⊙coe (ap (λ K → ⊙EM K 2) (inv-path H⊗G.abgroup)))
          =⟨ ap (⊙Susp^-fmap (n + m)) $ ! $
             ⊙transport-⊙coe (λ K → ⊙EM K 2) (inv-path H⊗G.abgroup) ⟩
        ⊙Susp^-fmap (n + m) (⊙transport (λ K → ⊙EM K 2) (inv-path H⊗G.abgroup))
          =⟨ ap (⊙Susp^-fmap (n + m)) $
             ⊙transport-⊙EM-uaᴬᴳ H⊗G.abgroup H⊗G.abgroup (inv-iso H⊗G.abgroup) 2 ⟩
        ⊙Susp^-fmap (n + m) (⊙EM-neg H⊗G.abgroup 2) =∎
      h₁ : n + m == 0 → and (odd n) (odd m) == false
      h₁ p = ap (λ k → and (odd k) (odd m)) (fst (+-0 n m p))
      h₂ : S (n + m) == 0 → and (odd n) (odd m) == inr unit
      h₂ p = ⊥-elim (ℕ-S≠O (n + m) p)
      bp : ∀ (b c : Bool) → xor b (negate (and b c)) == xor (and (negate c) (negate b)) c
      bp true  true  = idp
      bp true  false = idp
      bp false true  = idp
      bp false false = idp
  ⊙∧-cpₕₕ-comm : ∀ (m n : ℕ)
    → ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
      ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m + S n) ◃⊙∘
      ⊙∧-cpₕₕ G H m n ◃⊙idf
      =⊙∘
      ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) ◃⊙∘
      ⊙∧-cpₕₕ H G n m ◃⊙∘
      ⊙∧-swap (⊙EM G (S m)) (⊙EM H (S n)) ◃⊙idf
  ⊙∧-cpₕₕ-comm m n =
    =⊙∘-in $
    –>-is-inj ⊙Ext.⊙restr-equiv _ _ $
    =⊙∘-out
      {fs = ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
            ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m + S n) ◃⊙∘
            ⊙∧-cpₕₕ G H m n ◃⊙∘
            ⊙smash-truncate G H m n ◃⊙idf}
      {gs = ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) ◃⊙∘
            ⊙∧-cpₕₕ H G n m ◃⊙∘
            ⊙∧-swap (⊙EM G (S m)) (⊙EM H (S n)) ◃⊙∘
            ⊙smash-truncate G H m n ◃⊙idf} $
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m + S n) ◃⊙∘
    ⊙∧-cpₕₕ G H m n ◃⊙∘
    ⊙smash-truncate G H m n ◃⊙idf
      =⊙∘₁⟨ 2 & 2 & SmashCPₕₕ.⊙ext-β G H m n (⊙∧-cpₕₕ' G H m n) ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m + S n) ◃⊙∘
    ⊙∧-cpₕₕ' G H m n ◃⊙idf
      =⊙∘⟨ ⊙∧-cpₕₕ'-comm m n ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) ◃⊙∘
    ⊙∧-cpₕₕ' H G n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 1 & 1 & =⊙∘-in {gs = ⊙∧-cpₕₕ H G n m ◃⊙∘
                                ⊙smash-truncate H G n m ◃⊙idf} $
           ! $ SmashCPₕₕ.⊙ext-β H G n m (⊙∧-cpₕₕ' H G n m) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) ◃⊙∘
    ⊙∧-cpₕₕ H G n m ◃⊙∘
    ⊙smash-truncate H G n m ◃⊙∘
    ⊙∧-swap (⊙Susp^ m (⊙EM₁ G.grp)) (⊙Susp^ n (⊙EM₁ H.grp)) ◃⊙idf
      =⊙∘⟨ 2 & 2 & =⊙∘-in {gs = ⊙∧-swap (⊙EM G (S m)) (⊙EM H (S n)) ◃⊙∘
                                ⊙smash-truncate G H m n ◃⊙idf} $
           ⊙∧-swap-naturality
             ([_] {n = ⟨ S m ⟩} {A = Susp^ m (EM₁ G.grp)} , idp)
             ([_] {n = ⟨ S n ⟩} {A = Susp^ n (EM₁ H.grp)} , idp) ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) ◃⊙∘
    ⊙∧-cpₕₕ H G n m ◃⊙∘
    ⊙∧-swap (⊙EM G (S m)) (⊙EM H (S n)) ◃⊙∘
    ⊙smash-truncate G H m n ◃⊙idf ∎⊙∘
    where
    module ⊙Ext = ⊙ConnExtend
      {Z = ⊙EM H⊗G.abgroup (S n + S m)}
      {n = ⟨ S n + S m ⟩}
      (⊙smash-truncate G H m n)
      (transport (λ l → has-conn-fibers l (smash-truncate G H m n))
                 (ap ⟨_⟩ (+-comm (S m) (S n)))
                 (smash-truncate-conn G H m n))
      (EM-level H⊗G.abgroup (S n + S m))
  ⊙×-cpₕₕ-comm : ∀ (m n : ℕ)
    → ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
      ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m + S n) ◃⊙∘
      ⊙×-cpₕₕ G H m n ◃⊙idf
      =⊙∘
      ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) ◃⊙∘
      ⊙×-cpₕₕ H G n m ◃⊙∘
      ⊙×-swap ◃⊙idf
  ⊙×-cpₕₕ-comm m n =
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m + S n) ◃⊙∘
    ⊙×-cpₕₕ G H m n ◃⊙idf
      =⊙∘⟨ 2 & 1 & ⊙expand (⊙×-cpₕₕ-seq G H m n) ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) (S n)) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S (m + S n)) ◃⊙∘
    ⊙∧-cpₕₕ G H m n ◃⊙∘
    ×-⊙to-∧ ◃⊙idf
      =⊙∘⟨ 0 & 3 & ⊙∧-cpₕₕ-comm m n ⟩
    ⊙cond-neg H⊗G.abgroup (S n + S m) (and (odd (S m)) (odd (S n))) ◃⊙∘
    ⊙∧-cpₕₕ H G n m ◃⊙∘
    ⊙∧-swap (⊙EM G (S m)) (⊙EM H (S n)) ◃⊙∘
    ×-⊙to-∧ ◃⊙idf
      =⊙∘⟨ 2 & 2 & ×-⊙to-∧-swap (⊙EM G (S m)) (⊙EM H (S n)) ⟩
    ⊙cond-neg H⊗G.abgroup (S (n + S m)) (and (odd (S m)) (odd (S n))) ◃⊙∘
    ⊙∧-cpₕₕ H G n m ◃⊙∘
    ×-⊙to-∧ ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘⟨ 1 & 2 & ⊙contract ⟩
    ⊙cond-neg H⊗G.abgroup (S (n + S m)) (and (odd (S m)) (odd (S n))) ◃⊙∘
    ⊙×-cpₕₕ H G n m ◃⊙∘
    ⊙×-swap ◃⊙idf ∎⊙∘
  ⊙×-cp-comm : ∀ (m n : ℕ)
    → ⊙transport (⊙EM H⊗G.abgroup) (+-comm m n) ◃⊙∘
      ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (m + n) ◃⊙∘
      ⊙×-cp G H m n ◃⊙idf
      =⊙∘
      ⊙cond-neg H⊗G.abgroup (n + m) (and (odd m) (odd n)) ◃⊙∘
      ⊙×-cp H G n m ◃⊙∘
      ⊙×-swap ◃⊙idf
  ⊙×-cp-comm 0 0 =
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm 0 0) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap 0 ◃⊙∘
    ⊙×-cp G H 0 0 ◃⊙idf
      =⊙∘⟨ 0 & 1 & =⊙∘-in {gs = ⊙idf-seq} $
           ap (⊙transport (⊙EM H⊗G.abgroup)) (set-path ℕ-level (+-comm 0 0) idp) ⟩
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap 0 ◃⊙∘
    ⊙×-cp G H 0 0 ◃⊙idf
      =⊙∘⟨ ⊙×-cp₀₀-comm G H ⟩
    ⊙×-cp H G 0 0 ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘⟨ 0 & 0 & ⊙contract ⟩
    ⊙cond-neg H⊗G.abgroup 0 false ◃⊙∘
    ⊙×-cp H G 0 0 ◃⊙∘
    ⊙×-swap ◃⊙idf ∎⊙∘
  ⊙×-cp-comm 0 (S n) =
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm O (S n)) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S n) ◃⊙∘
    ⊙×-cp₀ₕ G H n ◃⊙idf
      =⊙∘⟨ ⊙×-cp₀ₕ-comm G H n ⟩
    ⊙×-cpₕ₀ H G n ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘⟨ 0 & 0 & ⊙contract ⟩
    ⊙cond-neg H⊗G.abgroup (S n + O) false ◃⊙∘
    ⊙×-cpₕ₀ H G n ◃⊙∘
    ⊙×-swap ◃⊙idf ∎⊙∘
  ⊙×-cp-comm (S m) 0 =
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) O) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S (m + O)) ◃⊙∘
    ⊙×-cpₕ₀ G H m ◃⊙idf
      =⊙∘⟨ 3 & 0 & =⊙∘-in {gs = ⊙×-swap ◃⊙∘ ⊙×-swap ◃⊙idf} idp ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) O) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m + O) ◃⊙∘
    ⊙×-cpₕ₀ G H m ◃⊙∘
    ⊙×-swap ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘⟨ 2 & 2 & !⊙∘ (⊙×-cp₀ₕ-comm H G m) ⟩
    ⊙transport (⊙EM H⊗G.abgroup) (+-comm (S m) O) ◃⊙∘
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m + O) ◃⊙∘
    ⊙transport (⊙EM G⊗H.abgroup) (+-comm O (S m)) ◃⊙∘
    ⊙EM-fmap H⊗G.abgroup G⊗H.abgroup H⊗G.swap (S m) ◃⊙∘
    ⊙×-cp₀ₕ H G m ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘⟨ 0 & 2 & !⊙∘ $
           ⊙transport-natural-=⊙∘
             (+-comm (S m) O)
             (⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap) ⟩
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m) ◃⊙∘
    ⊙transport (⊙EM G⊗H.abgroup) (+-comm (S m) O) ◃⊙∘
    ⊙transport (⊙EM G⊗H.abgroup) (+-comm O (S m)) ◃⊙∘
    ⊙EM-fmap H⊗G.abgroup G⊗H.abgroup H⊗G.swap (S m) ◃⊙∘
    ⊙×-cp₀ₕ H G m ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘⟨ 1 & 2 & !⊙∘ $ ⊙transport-∙
             (⊙EM G⊗H.abgroup) (+-comm 0 (S m)) (+-comm (S m) O) ⟩
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m) ◃⊙∘
    ⊙transport (⊙EM G⊗H.abgroup) (+-comm 0 (S m) ∙ +-comm (S m) O) ◃⊙∘
    ⊙EM-fmap H⊗G.abgroup G⊗H.abgroup H⊗G.swap (S m) ◃⊙∘
    ⊙×-cp₀ₕ H G m ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘⟨ 1 & 1 & =⊙∘-in {gs = ⊙idf-seq} $
           ap (⊙transport (⊙EM G⊗H.abgroup)) $
           set-path ℕ-level (+-comm 0 (S m) ∙ +-comm (S m) O) idp ⟩
    ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S m) ◃⊙∘
    ⊙EM-fmap H⊗G.abgroup G⊗H.abgroup H⊗G.swap (S m) ◃⊙∘
    ⊙×-cp₀ₕ H G m ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘₁⟨ 0 & 2 & ! $
            ⊙EM-fmap-∘ H⊗G.abgroup G⊗H.abgroup H⊗G.abgroup G⊗H.swap H⊗G.swap (S m) ⟩
    ⊙EM-fmap H⊗G.abgroup H⊗G.abgroup (G⊗H.swap ∘ᴳ H⊗G.swap) (S m) ◃⊙∘
    ⊙×-cp₀ₕ H G m ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘₁⟨ 0 & 1 & ap (λ φ → ⊙EM-fmap H⊗G.abgroup H⊗G.abgroup φ (S m))
                       H⊗G.swap-swap-idhom ⟩
    ⊙EM-fmap H⊗G.abgroup H⊗G.abgroup (idhom H⊗G.grp) (S m) ◃⊙∘
    ⊙×-cp₀ₕ H G m ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘⟨ 0 & 1 & =⊙∘-in {gs = ⊙idf-seq} $ ⊙EM-fmap-idhom H⊗G.abgroup (S m) ⟩
    ⊙×-cp₀ₕ H G m ◃⊙∘
    ⊙×-swap ◃⊙idf
      =⊙∘₁⟨ 0 & 0 & ap (⊙cond-neg H⊗G.abgroup (S m)) (! (and-false-r (odd (S m)))) ⟩
    ⊙cond-neg H⊗G.abgroup (S m) (and (odd (S m)) (odd O)) ◃⊙∘
    ⊙×-cp₀ₕ H G m ◃⊙∘
    ⊙×-swap ◃⊙idf ∎⊙∘
  ⊙×-cp-comm (S m) (S n) = ⊙×-cpₕₕ-comm m n
 
 | 
	{
  "alphanum_fraction": 0.4557677943,
  "avg_line_length": 48.6384083045,
  "ext": "agda",
  "hexsha": "a9453230ffaec90df670bd246bf9fcb9f8a1f4eb",
  "lang": "Agda",
  "max_forks_count": 50,
  "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
  "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
  "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "AntoineAllioux/HoTT-Agda",
  "max_forks_repo_path": "theorems/cohomology/CupProduct/OnEM/CommutativityInAllDegrees.agda",
  "max_issues_count": 31,
  "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
  "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
  "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "AntoineAllioux/HoTT-Agda",
  "max_issues_repo_path": "theorems/cohomology/CupProduct/OnEM/CommutativityInAllDegrees.agda",
  "max_line_length": 109,
  "max_stars_count": 294,
  "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "AntoineAllioux/HoTT-Agda",
  "max_stars_repo_path": "theorems/cohomology/CupProduct/OnEM/CommutativityInAllDegrees.agda",
  "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
  "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
  "num_tokens": 17657,
  "size": 28113
} 
 | 
					
	-- Σ type (also used as existential) and
-- cartesian product (also used as conjunction).
{-# OPTIONS --safe #-}
import Tools.PropositionalEquality as PE
module Tools.Product where
infixr 4 _,_
infixr 2 _×_
-- Dependent pair type (aka dependent sum, Σ type).
record Σ (A : Set) (B : A → Set) : Set where
  constructor _,_
  field
    proj₁ : A
    proj₂ : B proj₁
open Σ public
-- Existential quantification.
∃ : {A : Set} → (A → Set) → Set
∃ = Σ _
∃₂ : {A : Set} {B : A → Set}
     (C : (x : A) → B x → Set) → Set
∃₂ C = ∃ λ a → ∃ λ b → C a b
-- Cartesian product.
_×_ : (A B : Set) → Set
A × B = Σ A (λ x → B)
×-eq : ∀ {A B : Set} {x x' : A} {y y' : B} → x PE.≡ x' × y PE.≡ y' → (x , y) PE.≡ ( x' , y' )
×-eq ( PE.refl , PE.refl ) = PE.refl
 
 | 
	{
  "alphanum_fraction": 0.541005291,
  "avg_line_length": 19.3846153846,
  "ext": "agda",
  "hexsha": "fa7a96baecee2cb2b8f60909597419dfaf09d26d",
  "lang": "Agda",
  "max_forks_count": 2,
  "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z",
  "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z",
  "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "CoqHott/logrel-mltt",
  "max_forks_repo_path": "Tools/Product.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
  "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": "CoqHott/logrel-mltt",
  "max_issues_repo_path": "Tools/Product.agda",
  "max_line_length": 93,
  "max_stars_count": 2,
  "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "CoqHott/logrel-mltt",
  "max_stars_repo_path": "Tools/Product.agda",
  "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z",
  "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z",
  "num_tokens": 301,
  "size": 756
} 
 | 
					
	{-# OPTIONS --without-K #-}
module 3to2 where
open import Type using (★; ★₁)
open import Function.NP using (id; const; _∘_; Π)
open import Data.Nat.NP
open import Data.Bool.NP renaming (Bool to 𝟚; true to 1b; false to 0b; toℕ to 𝟚▹ℕ)
open import Data.Product
open import Data.Maybe.NP
open import Relation.Binary.PropositionalEquality
open import Search.Type renaming (Search₀ to Explore₀; SearchInd to ExploreInd)
open import Search.Searchable
open import Search.Searchable.Product renaming (_×-search-ind_ to _×-explore-ind_)
open import Search.Searchable.Sum renaming (searchBit-ind to explore𝟚-ind)
record _→⁇_ (A B : ★) : ★ where
  constructor ⟨_∥_⟩
  field
    run    : A → B
    valid? : A → 𝟚
  to→? : A →? B
  to→? x = if valid? x then just (run x) else nothing
data 𝟛 : ★ where
  0t 1t 2t : 𝟛
explore𝟛 : Explore₀ 𝟛
explore𝟛 _∙_ f = f 0t ∙ (f 1t ∙ f 2t)
explore𝟛-ind : ∀ {ℓ} → ExploreInd ℓ explore𝟛
explore𝟛-ind _ _∙_ f = f 0t ∙ (f 1t ∙ f 2t)
module |𝟛| = Searchable₀ explore𝟛-ind
module |𝟛×𝟚| = Searchable₀ (explore𝟛-ind ×-explore-ind explore𝟚-ind)
𝟛▹𝟚 : 𝟛 → 𝟚
𝟛▹𝟚 0t = 0b
𝟛▹𝟚 1t = 1b
𝟛▹𝟚 2t = 0b
𝟛▹𝟚-valid? : 𝟛 → 𝟚
𝟛▹𝟚-valid? 0t = 1b
𝟛▹𝟚-valid? 1t = 1b
𝟛▹𝟚-valid? 2t = 0b
𝟛▹𝟚⁇ : 𝟛 →⁇ 𝟚
𝟛▹𝟚⁇ = ⟨ 𝟛▹𝟚 ∥ 𝟛▹𝟚-valid? ⟩
𝟛▹𝟚? : 𝟛 →? 𝟚
𝟛▹𝟚? 0t = just 0b
𝟛▹𝟚? 1t = just 1b
𝟛▹𝟚? 2t = nothing
-- here success? implies validity
success? : Maybe 𝟚 → 𝟚
success? (just x) = x
success? nothing  = 0b
valid? : Maybe 𝟚 → 𝟚
valid? (just _) = 1b
valid? nothing  = 0b
invalid? : Maybe 𝟚 → 𝟚
invalid? = not ∘ valid?
record Fraction : ★ where
  constructor _/_
  field
    numerator denominator : ℕ
open Fraction public
_≡Frac_ : (x y : Fraction) → ★
_≡Frac_ x y =
  numerator x * denominator y ≡ numerator y * denominator x
{- Pr[A|B] = Pr[A∧B] / Pr[B] = #(A∧B) / #B -}
module FromCount {R : ★} (#_ : (R → 𝟚) → ℕ) where
  module Using→? where
    module _ (f : R →? 𝟚) where
      Pr[success|valid] = # (success? ∘ f) / # (valid? ∘ f)
    module _ (f g : R →? 𝟚) where
      _≈_ = Pr[success|valid] f ≡Frac Pr[success|valid] g 
  module Using→⁇ where
    module _ (f⁇ : R →⁇ 𝟚) where
      {- Pr[A|B] = Pr[A∧B] / Pr[B] = #(A∧B) / #B -}
      module f = _→⁇_ f⁇
      Pr[success|valid] = # f.run / # f.valid?
    module _ (f g : R →⁇ 𝟚) where
      _≈_ = Pr[success|valid] f ≡Frac Pr[success|valid] g
open FromCount |𝟛×𝟚|.count
module Test? where
    open Using→?
    ⅁₀ : 𝟛 × 𝟚 →? 𝟚
    ⅁₀ = 𝟛▹𝟚? ∘ proj₁
    ⅁₁ : 𝟛 × 𝟚 →? 𝟚
    ⅁₁ = just ∘ proj₂
    ⅁₀≈⅁₁ : ⅁₀ ≈ ⅁₁
    ⅁₀≈⅁₁ = refl
module Test⁇ where
    open Using→⁇
    ⅁₀ : 𝟛 × 𝟚 → 𝟚
    ⅁₀ = 𝟛▹𝟚 ∘ proj₁
    ⅁₀-valid? : 𝟛 × 𝟚 → 𝟚
    ⅁₀-valid? = 𝟛▹𝟚-valid? ∘ proj₁
    ⅁₁ : 𝟛 × 𝟚 → 𝟚
    ⅁₁ = proj₂
    ⅁₁-valid? : 𝟛 × 𝟚 → 𝟚
    ⅁₁-valid? _ = 1b
    ⅁₀≈⅁₁ : ⟨ ⅁₀ ∥ ⅁₀-valid? ⟩ ≈ ⟨ ⅁₁ ∥ ⅁₁-valid? ⟩
    ⅁₀≈⅁₁ = refl
-- -}
-- -}
-- -}
-- -}
 
 | 
	{
  "alphanum_fraction": 0.5705173636,
  "avg_line_length": 20.598540146,
  "ext": "agda",
  "hexsha": "e9d4e307ba57cb5e7953bb8b39c675d8e35b1264",
  "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": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
  "max_forks_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_forks_repo_name": "crypto-agda/explore",
  "max_forks_repo_path": "lib/Explore/Experimental/3to2.agda",
  "max_issues_count": 1,
  "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
  "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z",
  "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z",
  "max_issues_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_issues_repo_name": "crypto-agda/explore",
  "max_issues_repo_path": "lib/Explore/Experimental/3to2.agda",
  "max_line_length": 82,
  "max_stars_count": 2,
  "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
  "max_stars_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_stars_repo_name": "crypto-agda/explore",
  "max_stars_repo_path": "lib/Explore/Experimental/3to2.agda",
  "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z",
  "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z",
  "num_tokens": 1492,
  "size": 2822
} 
 | 
					
	open import Relation.Binary.Core
module BBHeap.Insert.Properties {A : Set}
                  (_≤_ : A → A → Set)
                  (tot≤ : Total _≤_) 
                  (trans≤ : Transitive _≤_) where
open import BBHeap _≤_
open import BBHeap.Insert _≤_ tot≤ trans≤
open import BBHeap.Subtyping.Properties _≤_ trans≤
open import Bound.Lower A
open import Bound.Lower.Order _≤_ 
open import Data.List
open import Data.Sum 
open import List.Permutation.Base A
open import List.Permutation.Base.Concatenation A
open import List.Permutation.Base.Equivalence A
open import Order.Total _≤_ tot≤ 
lemma-insert∼ : {b : Bound}{x : A}(b≤x : LeB b (val x))(h : BBHeap b) → (x ∷ flatten h) ∼ (flatten (insert b≤x h))
lemma-insert∼ b≤x leaf = refl∼
lemma-insert∼ {x = x} b≤x (left {x = y} {l = l} {r = r} b≤y l⋘r) 
    with tot≤ x y
... | inj₁ x≤y 
    with lemma-insert⋘ (lexy refl≤) l⋘r
... | inj₁ lᵢ⋘r 
           rewrite lemma-subtyping≡ {val y} {val x} (lexy x≤y) (insert {val y} {y} (lexy refl≤) l) 
                     | lemma-subtyping≡ {val y} {val x} (lexy x≤y) r 
                     = ∼x /head /head (lemma++∼r (lemma-insert∼ (lexy refl≤) l)) 
... | inj₂ lᵢ⋗r 
           rewrite  lemma-subtyping≡ {val y} {val x} (lexy x≤y) (insert {val y} {y} (lexy refl≤) l) 
                      | lemma-subtyping≡ {val y} {val x} (lexy x≤y) r 
                      = ∼x /head /head (lemma++∼r (lemma-insert∼ (lexy refl≤) l))
lemma-insert∼ {x = x} b≤x (left {x = y} {l = l} {r = r} b≤y l⋘r) | inj₂ y≤x 
    with lemma-insert⋘ (lexy y≤x) l⋘r
... | inj₁ lᵢ⋘r = ∼x (/tail /head) /head (lemma++∼r (lemma-insert∼ (lexy y≤x) l)) 
... | inj₂ lᵢ⋗r = ∼x (/tail /head) /head (lemma++∼r (lemma-insert∼ (lexy y≤x) l)) 
lemma-insert∼ {x = x} b≤x (right {x = y} {l = l} {r = r} b≤y l⋙r) 
    with tot≤ x y
... | inj₁ x≤y 
    with lemma-insert⋙ (lexy refl≤) l⋙r
... | inj₁ l⋙rᵢ 
           rewrite lemma-subtyping≡ {val y} {val x} (lexy x≤y) (insert {val y} {y} (lexy refl≤) r) 
                     | lemma-subtyping≡ {val y} {val x} (lexy x≤y) l 
                     = ∼x /head /head (trans∼ (∼x /head (lemma++/ {xs = flatten l}) refl∼) (lemma++∼l {xs = flatten l} (lemma-insert∼ (lexy refl≤) r)))
... | inj₂ l≃rᵢ 
           rewrite lemma-subtyping≡ {val y} {val x} (lexy x≤y) (insert {val y} {y} (lexy refl≤) r) 
                     | lemma-subtyping≡ {val y} {val x} (lexy x≤y) l 
                     = ∼x /head /head (trans∼ (∼x /head (lemma++/ {xs = flatten l}) refl∼) (lemma++∼l {xs = flatten l} (lemma-insert∼ (lexy refl≤) r)))
lemma-insert∼ {x = x} b≤x (right {x = y} {l = l} {r = r} b≤y l⋙r) | inj₂ y≤x 
    with lemma-insert⋙ (lexy y≤x) l⋙r
... | inj₁ l⋙rᵢ = ∼x (/tail /head) /head (trans∼ (∼x /head (lemma++/ {xs = flatten l}) refl∼) (lemma++∼l {xs = flatten l} (lemma-insert∼ (lexy y≤x) r)))
... | inj₂ l≃rᵢ = ∼x (/tail /head) /head (trans∼ (∼x /head (lemma++/ {xs = flatten l}) refl∼) (lemma++∼l {xs = flatten l} (lemma-insert∼ (lexy y≤x) r)))
 
 | 
	{
  "alphanum_fraction": 0.5399523971,
  "avg_line_length": 54.462962963,
  "ext": "agda",
  "hexsha": "6f4f064c21f8c6cd317f8a92b0a25cff33a54b89",
  "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/BBHeap/Insert/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/BBHeap/Insert/Properties.agda",
  "max_line_length": 152,
  "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/BBHeap/Insert/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": 1256,
  "size": 2941
} 
 | 
					
	{-# OPTIONS --without-K #-}
module NTypes.Empty where
open import NTypes
open import Types
0-isSet : isSet ⊥
0-isSet x = 0-elim x
 
 | 
	{
  "alphanum_fraction": 0.696969697,
  "avg_line_length": 14.6666666667,
  "ext": "agda",
  "hexsha": "e0b315f157d9500e04077851799665c1d950c35d",
  "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": "7730385adfdbdda38ee8b124be3cdeebb7312c65",
  "max_forks_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_forks_repo_name": "vituscze/HoTT-lectures",
  "max_forks_repo_path": "src/NTypes/Empty.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65",
  "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": "vituscze/HoTT-lectures",
  "max_issues_repo_path": "src/NTypes/Empty.agda",
  "max_line_length": 27,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65",
  "max_stars_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_stars_repo_name": "vituscze/HoTT-lectures",
  "max_stars_repo_path": "src/NTypes/Empty.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 41,
  "size": 132
} 
 | 
					
	module Lang.Instance where
import      Lvl
open import Type
private variable ℓ : Lvl.Level
private variable T X Y Z : Type{ℓ}
-- Infers/resolves/(searches for) an instance/proof of the specified type/statement
resolve : (T : Type{ℓ}) →  ⦃ _ : T ⦄ → T
resolve (_) ⦃ x ⦄ = x
-- Infers/resolves/(searches for) an instance/proof of an inferred type/statement
infer : ⦃ _ : T ⦄ → T
infer ⦃ x ⦄ = x
inst-fn : (X → Y) → (⦃ inst : X ⦄ → Y)
inst-fn P ⦃ x ⦄ = P(x)
inst-fn₂ : (X → Y → Z) → (⦃ inst₁ : X ⦄ → ⦃ inst₂ : Y ⦄ → Z)
inst-fn₂ P ⦃ x ⦄ ⦃ y ⦄ = P(x)(y)
inst-fnᵢ : ({_ : X} → Y → Z) → ({_ : X} → ⦃ _ : Y ⦄ → Z)
inst-fnᵢ P {x} ⦃ y ⦄ = P{x}(y)
impl-to-expl : ({ _ : X} → Y) → (X → Y)
impl-to-expl f(x) = f{x}
expl-to-impl : (X → Y) → ({ _ : X} → Y)
expl-to-impl f{x} = f(x)
 
 | 
	{
  "alphanum_fraction": 0.5335051546,
  "avg_line_length": 25.0322580645,
  "ext": "agda",
  "hexsha": "41e6912b0c4054e9580615d48fd887dd9f411b0d",
  "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": "Lang/Instance.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": "Lang/Instance.agda",
  "max_line_length": 83,
  "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": "Lang/Instance.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": 358,
  "size": 776
} 
 | 
					
	{-# OPTIONS --sized-types --guardedness --cubical #-}
-- Note: This module is not meant to be imported.
module All where
-- import All
import Automaton.Deterministic.Accessible
import Automaton.Deterministic.Finite
-- import Automaton.Deterministic.FormalLanguage
import Automaton.Deterministic.Oper
import Automaton.Deterministic
-- import Automaton.NonDeterministic
-- import Automaton.Pushdown
-- import Automaton.TuringMachine
import Data.Any
import Data.BinaryTree.Heap
import Data.BinaryTree.Properties
import Data.BinaryTree
import Data.Boolean.Equiv.Path
import Data.Boolean.Functions
import Data.Boolean.NaryOperators
import Data.Boolean.Numeral
import Data.Boolean.Operators
import Data.Boolean.Proofs
import Data.Boolean.Stmt.Proofs
import Data.Boolean.Stmt
import Data.Boolean
import Data.DependentWidthTree
import Data.DynamicTree
import Data.Either.Equiv.Id
import Data.Either.Equiv
import Data.Either.Multi
import Data.Either.Proofs
import Data.Either.Setoid
import Data.Either
import Data.FixedTree.Properties
import Data.FixedTree
import Data.IndexedList
import Data.Iterator
import Data.List.Categorical
import Data.List.Combinatorics.Proofs
import Data.List.Combinatorics
import Data.List.Decidable
import Data.List.Equiv.Id
import Data.List.Equiv
import Data.List.Functions.Multi
import Data.List.Functions.Positional
import Data.List.Functions
import Data.List.FunctionsProven
import Data.List.Iterable
import Data.List.Proofs.Length
import Data.List.Proofs
import Data.List.Relation.Membership.Proofs
import Data.List.Relation.Membership
import Data.List.Relation.Pairwise.Proofs
import Data.List.Relation.Pairwise
import Data.List.Relation.Permutation
import Data.List.Relation.Quantification.Proofs
import Data.List.Relation.Quantification
import Data.List.Relation.Sublist.Proofs
import Data.List.Relation.Sublist
import Data.List.Relation
import Data.List.Setoid
import Data.List.Size
import Data.List.SizeOrdering
import Data.List.Sorting.Functions
import Data.List.Sorting.HeapSort
import Data.List.Sorting.InsertionSort
import Data.List.Sorting.MergeSort
import Data.List.Sorting.Proofs
import Data.List.Sorting.QuickSort
import Data.List.Sorting.SelectionSort
import Data.List.Sorting
import Data.List
import Data.ListNonEmpty
import Data.ListSized.Functions
import Data.ListSized.Proofs
import Data.ListSized
import Data.Option.Categorical
import Data.Option.Equiv.Id
import Data.Option.Equiv.Path
import Data.Option.Equiv
import Data.Option.Functions
import Data.Option.Iterable
import Data.Option.Proofs
import Data.Option.Setoid
import Data.Option
import Data.Proofs
import Data.Tuple.Category
import Data.Tuple.Equiv.Id
import Data.Tuple.Equiv
import Data.Tuple.Equivalence
import Data.Tuple.Function
import Data.Tuple.List
import Data.Tuple.Proofs
import Data.Tuple.Raise
import Data.Tuple.RaiseTypeᵣ.Functions
import Data.Tuple.RaiseTypeᵣ
import Data.Tuple.Raiseᵣ.Functions
import Data.Tuple.Raiseᵣ.Iterable
import Data.Tuple.Raiseᵣ.Proofs
import Data.Tuple.Raiseᵣ
import Data.Tuple.Raiseₗ
import Data.Tuple
import Data
import FFI.IO
import FFI.MachineWord
import Float
-- import FormalLanguage.ContextFreeGrammar
-- import FormalLanguage.Equals
-- import FormalLanguage.Proofs
-- import FormalLanguage.RegularExpression
-- import FormalLanguage
import Formalization.ClassicalPredicateLogic.Semantics
import Formalization.ClassicalPredicateLogic.Syntax.Substitution
import Formalization.ClassicalPredicateLogic.Syntax
import Formalization.ClassicalPropositionalLogic.NaturalDeduction.Consistency
import Formalization.ClassicalPropositionalLogic.NaturalDeduction.Proofs
-- import Formalization.ClassicalPropositionalLogic.NaturalDeduction.Tree
import Formalization.ClassicalPropositionalLogic.NaturalDeduction
import Formalization.ClassicalPropositionalLogic.Place
import Formalization.ClassicalPropositionalLogic.Semantics.Proofs
import Formalization.ClassicalPropositionalLogic.Semantics
-- import Formalization.ClassicalPropositionalLogic.SequentCalculus
import Formalization.ClassicalPropositionalLogic.Syntax.Proofs
import Formalization.ClassicalPropositionalLogic.Syntax
import Formalization.ClassicalPropositionalLogic.TruthTable
-- import Formalization.ClassicalPropositionalLogic
-- import Formalization.FunctionalML
import Formalization.ImperativePL
import Formalization.LambdaCalculus.Semantics.CallByName
import Formalization.LambdaCalculus.Semantics.CallByValue
import Formalization.LambdaCalculus.Semantics.Reduction
import Formalization.LambdaCalculus.Semantics
import Formalization.LambdaCalculus.SyntaxTransformation
import Formalization.LambdaCalculus.Terms.Combinators
import Formalization.LambdaCalculus
import Formalization.Monoid
import Formalization.Polynomial
import Formalization.PredicateLogic.Classical.NaturalDeduction
-- import Formalization.PredicateLogic.Classical.Semantics.Homomorphism
import Formalization.PredicateLogic.Classical.Semantics.Satisfaction
import Formalization.PredicateLogic.Classical.Semantics
import Formalization.PredicateLogic.Classical.SequentCalculus
import Formalization.PredicateLogic.Constructive.NaturalDeduction
-- import Formalization.PredicateLogic.Constructive.SequentCalculus
-- import Formalization.PredicateLogic.Minimal.NaturalDeduction.NegativeTranslations
import Formalization.PredicateLogic.Minimal.NaturalDeduction.Tree
import Formalization.PredicateLogic.Minimal.NaturalDeduction
-- import Formalization.PredicateLogic.Minimal.SequentCalculus
import Formalization.PredicateLogic.Signature
import Formalization.PredicateLogic.Syntax.NegativeTranslations
import Formalization.PredicateLogic.Syntax.Substitution
import Formalization.PredicateLogic.Syntax.Tree
import Formalization.PredicateLogic.Syntax
import Formalization.PrimitiveRecursion
-- import Formalization.PureTypeSystem
import Formalization.RecursiveFunction
import Formalization.SKICombinatorCalculus
import Formalization.SimplyTypedLambdaCalculus
import Function.Axioms
import Function.DomainRaise
import Function.Domains.Functions
import Function.Domains.Id
import Function.Domains.Proofs
import Function.Domains
import Function.Equals.Multi
import Function.Equals.Proofs
import Function.Equals
import Function.Inverse
import Function.Inverseᵣ
import Function.Inverseₗ
import Function.Iteration.Order
import Function.Iteration.Proofs
import Function.Iteration
import Function.Multi.Functions
import Function.Multi
import Function.Multi₌.Functions
import Function.Multi₌
import Function.Names
import Function.PointwiseStructure
import Function.Proofs
import Function
import Functional.Combinations
import Functional.Dependent
import Functional
-- import Geometry.Axioms
-- import Geometry.HilbertAxioms
import Graph.Category
import Graph.Oper
import Graph.Properties.Proofs
import Graph.Properties
import Graph.Walk.Functions.Proofs
import Graph.Walk.Functions
import Graph.Walk.Proofs
import Graph.Walk.Properties
import Graph.Walk
import Graph
import Iterator
import Js
import Lang.Function
import Lang.Inspect
import Lang.Instance
import Lang.Irrelevance
import Lang.Reflection
import Lang.Size
import Lang.Vars.Structure.Operator
import Logic.Classical.DoubleNegated
import Logic.Classical
import Logic.DiagonalMethod
import Logic.IntroInstances
import Logic.Names
import Logic.Predicate.Equiv
import Logic.Predicate.Multi
import Logic.Predicate.Theorems
import Logic.Predicate
import Logic.Propositional.Equiv
import Logic.Propositional.Proofs.Structures
import Logic.Propositional.Theorems
import Logic.Propositional.Xor
import Logic.Propositional
import Logic.WeaklyClassical
import Logic
import Lvl.Decidable
import Lvl.Functions
import Lvl.MultiFunctions.Proofs
import Lvl.MultiFunctions
import Lvl.Proofs
import Lvl
import Main
import Numeral.CoordinateVector.Proofs
import Numeral.CoordinateVector
import Numeral.Finite.Bound
import Numeral.Finite.Category
import Numeral.Finite.Conversions
import Numeral.Finite.Equiv
import Numeral.Finite.Functions
import Numeral.Finite.LinearSearch
import Numeral.Finite.Oper.Comparisons.Proofs
import Numeral.Finite.Oper.Comparisons
import Numeral.Finite.Oper
import Numeral.Finite.Proofs
import Numeral.Finite.Relation.Order
import Numeral.Finite.Sequence
import Numeral.Finite
import Numeral.FixedPositional
import Numeral.Integer.Function
import Numeral.Integer.Oper
import Numeral.Integer.Proofs
import Numeral.Integer.Relation.Divisibility.Proofs
import Numeral.Integer.Relation.Divisibility
import Numeral.Integer.Relation.Order
-- import Numeral.Integer.Relation
import Numeral.Integer.Sign
import Numeral.Integer
-- import Numeral.Matrix.OverField
import Numeral.Matrix.Proofs
-- import Numeral.Matrix.Relations
import Numeral.Matrix
import Numeral.Natural.Combinatorics.Proofs
import Numeral.Natural.Combinatorics
import Numeral.Natural.Coprime.Proofs
import Numeral.Natural.Coprime
import Numeral.Natural.Decidable
import Numeral.Natural.Equiv.Path
import Numeral.Natural.Function.Coprimalize
import Numeral.Natural.Function.FlooredLogarithm
import Numeral.Natural.Function.GreatestCommonDivisor.Extended
import Numeral.Natural.Function.GreatestCommonDivisor.Proofs
import Numeral.Natural.Function.GreatestCommonDivisor
import Numeral.Natural.Function.Proofs
import Numeral.Natural.Function
import Numeral.Natural.Induction
import Numeral.Natural.Inductions
import Numeral.Natural.LinearSearch
-- import Numeral.Natural.LinearSearchDecidable
import Numeral.Natural.Oper.Comparisons.Proofs
import Numeral.Natural.Oper.Comparisons
import Numeral.Natural.Oper.DivMod.Proofs
import Numeral.Natural.Oper.Divisibility
import Numeral.Natural.Oper.FlooredDivision.Proofs.DivisibilityWithRemainder
import Numeral.Natural.Oper.FlooredDivision.Proofs.Inverse
import Numeral.Natural.Oper.FlooredDivision.Proofs
import Numeral.Natural.Oper.FlooredDivision
import Numeral.Natural.Oper.Modulo.Proofs.Algorithm
import Numeral.Natural.Oper.Modulo.Proofs.DivisibilityWithRemainder
import Numeral.Natural.Oper.Modulo.Proofs.Elim
import Numeral.Natural.Oper.Modulo.Proofs
import Numeral.Natural.Oper.Modulo
-- import Numeral.Natural.Oper.Proofs.Elemantary
-- import Numeral.Natural.Oper.Proofs.Iteration
import Numeral.Natural.Oper.Proofs.Multiplication
import Numeral.Natural.Oper.Proofs.Order
import Numeral.Natural.Oper.Proofs.Rewrite
-- import Numeral.Natural.Oper.Proofs.Structure
import Numeral.Natural.Oper.Proofs
import Numeral.Natural.Oper.Summation.Proofs
import Numeral.Natural.Oper.Summation.Range.Proofs
import Numeral.Natural.Oper.Summation.Range
import Numeral.Natural.Oper.Summation
import Numeral.Natural.Oper
import Numeral.Natural.Prime.Proofs.Product
import Numeral.Natural.Prime.Proofs.Representation
import Numeral.Natural.Prime.Proofs
import Numeral.Natural.Prime
import Numeral.Natural.Proofs
import Numeral.Natural.Relation.Divisibility.Proofs.Modulo
import Numeral.Natural.Relation.Divisibility.Proofs.Product
import Numeral.Natural.Relation.Divisibility.Proofs
import Numeral.Natural.Relation.Divisibility
import Numeral.Natural.Relation.DivisibilityWithRemainder.Proofs
import Numeral.Natural.Relation.DivisibilityWithRemainder
import Numeral.Natural.Relation.ModuloCongruence
import Numeral.Natural.Relation.Order.Category
import Numeral.Natural.Relation.Order.Classical
import Numeral.Natural.Relation.Order.Decidable
import Numeral.Natural.Relation.Order.Existence.Proofs
import Numeral.Natural.Relation.Order.Existence
import Numeral.Natural.Relation.Order.Proofs
import Numeral.Natural.Relation.Order
import Numeral.Natural.Relation.Proofs
import Numeral.Natural.Relation.Properties
import Numeral.Natural.Relation
import Numeral.Natural.Sequence.Proofs
import Numeral.Natural.Sequence
import Numeral.Natural.TotalOper
import Numeral.Natural.UnclosedOper
import Numeral.Natural
import Numeral.Ordinal
import Numeral.PositiveInteger.Oper.Proofs
import Numeral.PositiveInteger.Oper
import Numeral.PositiveInteger
-- import Numeral.Rational.AlterAdd
-- import Numeral.Rational.SternBrocot
import Numeral.Sign.Oper.Proofs
import Numeral.Sign.Oper
import Numeral.Sign.Oper0
import Numeral.Sign.Proofs
import Numeral.Sign
import Operator.Equals
import ReductionSystem
import Relator.Category
import Relator.Congruence.Proofs
import Relator.Congruence
import Relator.Converse
import Relator.Equals.Category
import Relator.Equals.Proofs.Equiv
import Relator.Equals.Proofs.Equivalence
import Relator.Equals.Proofs
import Relator.Equals
import Relator.Ordering.Proofs
import Relator.Ordering
import Relator.ReflexiveTransitiveClosure
import Relator.Sets
import Sets.BoolSet
-- import Sets.ExtensionalPredicateSet.SetLike
import Sets.ExtensionalPredicateSet
import Sets.ImageSet.Oper
-- import Sets.ImageSet.SetLike
import Sets.ImageSet
import Sets.IterativeSet.Oper.Proofs
import Sets.IterativeSet.Oper
import Sets.IterativeSet.Relator.Proofs
import Sets.IterativeSet.Relator
import Sets.IterativeSet
import Sets.IterativeUSet
import Sets.PredicateSet.Listable
import Sets.PredicateSet
import Sized.Data.List
import Stream.Iterable
import Stream
import String
-- import Structure.Categorical.Multi
import Structure.Categorical.Names
import Structure.Categorical.Proofs
import Structure.Categorical.Properties
import Structure.Category.Action
import Structure.Category.Categories
import Structure.Category.Category
import Structure.Category.CoMonad
import Structure.Category.Dual
-- import Structure.Category.Equiv
import Structure.Category.Functor.Category
import Structure.Category.Functor.Contravariant
import Structure.Category.Functor.Equiv
import Structure.Category.Functor.Functors.Proofs
import Structure.Category.Functor.Functors
import Structure.Category.Functor.Proofs
import Structure.Category.Functor
import Structure.Category.Monad.Category
import Structure.Category.Monad.ExtensionSystem
import Structure.Category.Monad
import Structure.Category.Monoid
-- import Structure.Category.Monoidal
import Structure.Category.Morphism.IdTransport
import Structure.Category.Morphism.Transport
import Structure.Category.NaturalTransformation.Equiv
import Structure.Category.NaturalTransformation.NaturalTransformations
import Structure.Category.NaturalTransformation
import Structure.Category.Proofs
import Structure.Category
import Structure.Container.IndexedIterable
import Structure.Container.Iterable
-- import Structure.Container.SetLike.Proofs
-- import Structure.Container.SetLike
import Structure.Function.Domain.Proofs
import Structure.Function.Domain
import Structure.Function.Linear
-- import Structure.Function.Metric
import Structure.Function.Multi
import Structure.Function.Names
import Structure.Function.Ordering
import Structure.Function.Proofs
import Structure.Function
import Structure.Groupoid.Functor
import Structure.Groupoid.Groupoids
import Structure.Groupoid
import Structure.Logic.Constructive.BoundedPredicate
import Structure.Logic.Constructive.Predicate
import Structure.Logic.Constructive.Proofs
import Structure.Logic.Constructive.Propositional
import Structure.Logic
-- import Structure.Numeral.Integer.Proofs
import Structure.Numeral.Integer
import Structure.Numeral.Natural
import Structure.Operator.Algebra
import Structure.Operator.Field.VectorSpace
import Structure.Operator.Field
import Structure.Operator.Functions
import Structure.Operator.Group.Proofs
import Structure.Operator.Group
import Structure.Operator.IntegralDomain
-- import Structure.Operator.Iteration
import Structure.Operator.Lattice
import Structure.Operator.Monoid.Category
import Structure.Operator.Monoid.Homomorphism
import Structure.Operator.Monoid.Invertible.Proofs
import Structure.Operator.Monoid.Invertible
import Structure.Operator.Monoid.Monoids.Coset
import Structure.Operator.Monoid.Monoids.Function
import Structure.Operator.Monoid.Proofs
import Structure.Operator.Monoid.Submonoid
import Structure.Operator.Monoid
import Structure.Operator.Names
import Structure.Operator.Proofs.Util
import Structure.Operator.Proofs
import Structure.Operator.Properties
import Structure.Operator.Ring.Characteristic
import Structure.Operator.Ring.Homomorphism
import Structure.Operator.Ring.Proofs
import Structure.Operator.Ring.Rings
import Structure.Operator.Ring
import Structure.Operator.SetAlgebra
import Structure.Operator.Vector.Eigen
-- import Structure.Operator.Vector.Equiv
import Structure.Operator.Vector.FiniteDimensional.LinearMaps.ChangeOfBasis
-- import Structure.Operator.Vector.FiniteDimensional.Proofs
import Structure.Operator.Vector.FiniteDimensional
import Structure.Operator.Vector.InfiniteDimensional
-- import Structure.Operator.Vector.LinearCombination.Proofs
import Structure.Operator.Vector.LinearCombination
-- import Structure.Operator.Vector.LinearMap.Category
-- import Structure.Operator.Vector.LinearMap.Equiv
import Structure.Operator.Vector.LinearMap
import Structure.Operator.Vector.LinearMaps
import Structure.Operator.Vector.Proofs
-- import Structure.Operator.Vector.Subspace.Proofs
-- import Structure.Operator.Vector.Subspace
-- import Structure.Operator.Vector.Subspaces.DirectSum
-- import Structure.Operator.Vector.Subspaces.Image
-- import Structure.Operator.Vector.Subspaces.Kernel
-- import Structure.Operator.Vector.Subspaces.Span
import Structure.Operator.Vector
import Structure.Operator
import Structure.OrderedField.AbsoluteValue
import Structure.OrderedField
import Structure.Real.Abs
-- import Structure.Real.Continuity
-- import Structure.Real.Derivative
-- import Structure.Real.Limit
import Structure.Real
import Structure.Relator.Apartness.Proofs
import Structure.Relator.Apartness
import Structure.Relator.Equivalence.Proofs
import Structure.Relator.Equivalence
import Structure.Relator.Function.Multi
import Structure.Relator.Function.Proofs
import Structure.Relator.Function
import Structure.Relator.Names
import Structure.Relator.Ordering.Lattice
import Structure.Relator.Ordering.Proofs
import Structure.Relator.Ordering
import Structure.Relator.Proofs
import Structure.Relator.Properties.Proofs
import Structure.Relator.Properties
import Structure.Relator
import Structure.Semicategory
import Structure.Setoid.Category.HomFunctor
import Structure.Setoid.Category
import Structure.Setoid.Names
import Structure.Setoid.Proofs
import Structure.Setoid.Size.Proofs
import Structure.Setoid.Size
import Structure.Setoid.Uniqueness.Proofs
import Structure.Setoid.Uniqueness
import Structure.Setoid
import Structure.Sets.Names
import Structure.Sets.Operator
import Structure.Sets.Quantifiers.Proofs
import Structure.Sets.Quantifiers
import Structure.Sets.Relator
import Structure.Sets.Relators
import Structure.Sets.ZFC.Classical
import Structure.Sets.ZFC.Inductive
import Structure.Sets.ZFC.Oper
import Structure.Sets.ZFC
import Structure.Sets
import Structure.Signature
-- import Structure.Topology.Proofs
-- import Structure.Topology.Properties
import Structure.Topology
import Structure.Type.Identity.Proofs.Eliminator
-- import Structure.Type.Identity.Proofs.Multi
import Structure.Type.Identity.Proofs
import Structure.Type.Identity
import Structure.Type.Quotient
import Syntax.Do
import Syntax.Function
import Syntax.Idiom
import Syntax.Implication.Dependent
import Syntax.Implication
import Syntax.List
import Syntax.Number
import Syntax.Transitivity
import Syntax.Type
import TestProp
import Type.Category.ExtensionalFunctionsCategory.HomFunctor
import Type.Category.ExtensionalFunctionsCategory
-- import Type.Category.IntensionalFunctionsCategory.HomFunctor
import Type.Category.IntensionalFunctionsCategory.LvlUpFunctor
import Type.Category.IntensionalFunctionsCategory
import Type.Category
import Type.Cubical.Equiv
import Type.Cubical.HTrunc₁
import Type.Cubical.InductiveInterval
import Type.Cubical.InductivePath
import Type.Cubical.Logic
import Type.Cubical.Path.Category
import Type.Cubical.Path.Equality
import Type.Cubical.Path.Proofs
import Type.Cubical.Path
import Type.Cubical.Quotient
import Type.Cubical.SubtypeSet
import Type.Cubical.Univalence
import Type.Cubical
import Type.Dependent.Functions
import Type.Dependent
import Type.Equiv
import Type.Identity.Heterogenous
import Type.Identity.Proofs
import Type.Identity
import Type.Isomorphism
import Type.Proofs
import Type.Properties.Decidable.Proofs
import Type.Properties.Decidable
import Type.Properties.Empty.Proofs
import Type.Properties.Empty
-- import Type.Properties.Homotopy.Proofs
import Type.Properties.Homotopy
import Type.Properties.Inhabited
import Type.Properties.MereProposition
import Type.Properties.Singleton.Proofs
import Type.Properties.Singleton
import Type.Singleton.Proofs
import Type.Singleton
import Type.Size.Countable
import Type.Size.Finite
import Type.Size.Proofs
import Type.Size
import Type.WellOrdering
import Type
 
 | 
	{
  "alphanum_fraction": 0.8725209717,
  "avg_line_length": 35.4347079038,
  "ext": "agda",
  "hexsha": "6e75687652fb514e602752ac2ed91a29dc2c3d9b",
  "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": "All.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": "All.agda",
  "max_line_length": 84,
  "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": "All.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": 4589,
  "size": 20623
} 
 | 
					
	------------------------------------------------------------------------
-- The Agda standard library
--
-- String Literals
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.String.Literals where
open import Agda.Builtin.FromString
open import Data.Unit
open import Agda.Builtin.String
isString : IsString String
isString = record
  { Constraint = λ _ → ⊤
  ; fromString = λ s → s
  }
 
 | 
	{
  "alphanum_fraction": 0.4814814815,
  "avg_line_length": 22.95,
  "ext": "agda",
  "hexsha": "42d1c5af72d849b2919d570d8379528ea5840c30",
  "lang": "Agda",
  "max_forks_count": 1,
  "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
  "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
  "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "omega12345/agda-mode",
  "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/String/Literals.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "omega12345/agda-mode",
  "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/String/Literals.agda",
  "max_line_length": 72,
  "max_stars_count": 5,
  "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "omega12345/agda-mode",
  "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/String/Literals.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": 88,
  "size": 459
} 
 | 
					
	module Logic.Predicate.Equiv where
import      Lvl
open import Logic
open import Logic.Predicate
open import Structure.Setoid
open import Structure.Relator.Equivalence
open import Structure.Relator.Properties
open import Type
private variable ℓ ℓₑ : Lvl.Level
private variable Obj : Type{ℓ}
private variable Pred : Obj → Stmt{ℓ}
module _ ⦃ _ : Equiv{ℓₑ}(Obj) ⦄ where
  _≡∃_ : ∃{Obj = Obj}(Pred) → ∃{Obj = Obj}(Pred) → Stmt
  [∃]-intro x ≡∃ [∃]-intro y = x ≡ y
  instance
    [≡∃]-reflexivity : Reflexivity(_≡∃_ {Pred = Pred})
    Reflexivity.proof [≡∃]-reflexivity = reflexivity(_≡_)
  instance
    [≡∃]-symmetry : Symmetry(_≡∃_ {Pred = Pred})
    Symmetry.proof [≡∃]-symmetry = symmetry(_≡_)
  instance
    [≡∃]-transitivity : Transitivity(_≡∃_ {Pred = Pred})
    Transitivity.proof [≡∃]-transitivity = transitivity(_≡_)
  instance
    [≡∃]-equivalence : Equivalence(_≡∃_ {Pred = Pred})
    [≡∃]-equivalence = intro
  instance
    [≡∃]-equiv : Equiv{ℓₑ}(∃{Obj = Obj} Pred)
    [≡∃]-equiv = intro(_≡∃_) ⦃ [≡∃]-equivalence ⦄
 
 | 
	{
  "alphanum_fraction": 0.6472868217,
  "avg_line_length": 27.1578947368,
  "ext": "agda",
  "hexsha": "5b9ea78ed7996225f4d8b6c4aa99236e312d0289",
  "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": "Logic/Predicate/Equiv.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": "Logic/Predicate/Equiv.agda",
  "max_line_length": 60,
  "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": "Logic/Predicate/Equiv.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": 394,
  "size": 1032
} 
 | 
					
	-- Andreas, 2016-01-08 allow --type-in-type with universe polymorphism
{-# OPTIONS --type-in-type #-}
-- {-# OPTIONS --v tc:30 #-}
-- {-# OPTIONS --v tc.conv.level:60 #-}
open import Common.Level
open import Common.Equality
Type : Set
Type = Set
data E α β : Set β where
  e : Set α → E α β
data D {α} (A : Set α) : Set where
  d : A → D A
-- Make sure we do not get unsolved level metas
id : ∀{a}{A : Set a} → A → A
id x = x
test = id Set
data Unit : Set where
  unit : Unit
test1 = id unit
data UnitP {α} : Set α where
  unitP : UnitP
test2 = id unitP
-- All levels are equal
-- (need not be for --type-in-type, but this is how it is implemented):
level0≡1 : lzero ≡ lsuc lzero
level0≡1 = refl
levelTrivial : ∀{a b : Level} → a ≡ b
levelTrivial = refl
 
 | 
	{
  "alphanum_fraction": 0.6233766234,
  "avg_line_length": 17.1111111111,
  "ext": "agda",
  "hexsha": "655bd02a9345f9c05ea1c2d9cc0317f2390f9634",
  "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/Issue1764.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/Issue1764.agda",
  "max_line_length": 71,
  "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/Issue1764.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": 262,
  "size": 770
} 
 | 
					
	-- Andreas, 2014-02-17, reported by pumpkingod
{-# OPTIONS --allow-unsolved-metas #-}
data Bool : Set where true false : Bool
-- Equality
infix 4 _≡_
data _≡_ {a} {A : Set a} (x : A) : A → Set a where
  refl : x ≡ x
{-# BUILTIN EQUALITY _≡_  #-}
{-# BUILTIN REFL     refl #-}
subst : ∀ {a p}{A : Set a}(P : A → Set p){x y : A} → x ≡ y → P x → P y
subst P refl t = t
cong : ∀ {a b}{A : Set a}{B : Set b}(f : A → B){x y : A} → x ≡ y → f x ≡ f y
cong f refl = refl
sym : ∀ {a}{A : Set a}{x y : A} → x ≡ y → y ≡ x
sym refl = refl
trans : ∀ {a}{A : Set a}{x y z : A} → x ≡ y → y ≡ z → x ≡ z
trans refl refl = refl
infix  3 _∎
infixr 2 _≡⟨_⟩_
infix  1 begin_
data _IsRelatedTo_ (x y : Bool) : Set where
  relTo : (x≡y : x ≡ y) → x IsRelatedTo y
begin_ : ∀ {x y} → x IsRelatedTo y → x ≡ y
begin relTo x≡y = x≡y
_≡⟨_⟩_ : ∀ x {y z} → x ≡ y → y IsRelatedTo z → x IsRelatedTo z
_ ≡⟨ x≡y ⟩ relTo y≡z = relTo (trans x≡y y≡z)
_∎ : ∀ x → x IsRelatedTo x
_∎ _ = relTo refl
-- Test
proof : true ≡ true
proof =
  begin
    {!!}
  ≡⟨ {!!} ⟩
    {!!} -- If you do C-c C-s, it will fill in the first and last boxes, but it will also fill this one in with an underscore!
  ≡⟨ {!!} ⟩
    {!!}
  ∎
-- C-c C-s should only solve for ?0 and ?4, not for ?2.
-- Constraints are
-- ?0 := true
-- ?2 := _y_38
-- ?4 := true
-- Metas are
--
-- ?0 : Bool
-- ?1 : true ≡ _y_38
-- ?2 : Bool
-- ?3 : _y_38 ≡ true
-- ?4 : Bool
-- _y_38 : Bool  [ at /home/abel/tmp/Agda2/test/bugs/Issue1060.agda:23,5-24,12 ]
 
 | 
	{
  "alphanum_fraction": 0.5284661755,
  "avg_line_length": 19.9066666667,
  "ext": "agda",
  "hexsha": "b6507a8ae5626566baf8d78a12fad03aeac0996b",
  "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/Issue1060.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/Issue1060.agda",
  "max_line_length": 126,
  "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/Issue1060.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 659,
  "size": 1493
} 
 | 
					
	{-# OPTIONS --no-auto-inline #-}
-- Basic things needed by other primitive modules.
module Haskell.Prim where
open import Agda.Primitive
open import Agda.Builtin.Bool
open import Agda.Builtin.Nat
open import Agda.Builtin.Unit       public
open import Agda.Builtin.List
open import Agda.Builtin.String
open import Agda.Builtin.Equality
open import Agda.Builtin.FromNat    public
open import Agda.Builtin.FromNeg    public
open import Agda.Builtin.FromString public
variable
  ℓ : Level
  a b c d e : Set
  f m s t : Set → Set
--------------------------------------------------
-- Functions
id : a → a
id x = x
infixr 9 _∘_
_∘_ : (b → c) → (a → b) → a → c
(f ∘ g) x = f (g x)
flip : (a → b → c) → b → a → c
flip f x y = f y x
const : a → b → a
const x _ = x
infixr 0 _$_
_$_ : (a → b) → a → b
f $ x = f x
--------------------------------------------------
-- Language constructs
infix -1 case_of_
case_of_ : a → (a → b) → b
case x of f = f x
infix -2 if_then_else_
if_then_else_ : {a : Set ℓ} → Bool → a → a → a
if false then x else y = y
if true  then x else y = x
--------------------------------------------------
-- Agda strings
instance
  iIsStringAgdaString : IsString String
  iIsStringAgdaString .IsString.Constraint _ = ⊤
  iIsStringAgdaString .fromString s = s
--------------------------------------------------
-- Numbers
instance
  iNumberNat : Number Nat
  iNumberNat .Number.Constraint _ = ⊤
  iNumberNat .fromNat n = n
--------------------------------------------------
-- Lists
lengthNat : List a → Nat
lengthNat []       = 0
lengthNat (_ ∷ xs) = 1 + lengthNat xs
--------------------------------------------------
-- Proof things
data ⊥ : Set where
-- Use to bundle up constraints
data All {a b} {A : Set a} (B : A → Set b) : List A → Set (a ⊔ b) where
  instance
    allNil  : All B []
    allCons : ∀ {x xs} ⦃ i : B x ⦄ ⦃ is : All B xs ⦄ → All B (x ∷ xs)
data IsTrue : Bool → Set where
  instance itsTrue : IsTrue true
data IsFalse : Bool → Set where
  instance itsFalse : IsFalse false
data NonEmpty {a : Set} : List a → Set where
  instance itsNonEmpty : ∀ {x xs} → NonEmpty (x ∷ xs)
data TypeError (err : String) : Set where
it : ∀ {ℓ} {a : Set ℓ} → ⦃ a ⦄ → a
it ⦃ x ⦄ = x
 
 | 
	{
  "alphanum_fraction": 0.5478651685,
  "avg_line_length": 20.7943925234,
  "ext": "agda",
  "hexsha": "498fe77f1a64555cd95df78ee1bff89e305d642f",
  "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": "lib/Haskell/Prim.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": "lib/Haskell/Prim.agda",
  "max_line_length": 71,
  "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": "lib/Haskell/Prim.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": 693,
  "size": 2225
} 
 | 
					
	------------------------------------------------------------------------
-- A labelled transition system for the delay monad
------------------------------------------------------------------------
{-# OPTIONS --sized-types #-}
open import Prelude
module Labelled-transition-system.Delay-monad {a} (A : Type a) where
open import Delay-monad hiding (steps)
open import Equality.Propositional
open import Prelude.Size
open import Labelled-transition-system
------------------------------------------------------------------------
-- Transitions
infix 4 _[_]⟶_
data _[_]⟶_ : Delay A ∞ → Maybe A → Delay A ∞ → Type a where
  now   : ∀ {x} → now   x [ just x  ]⟶ now   x
  later : ∀ {x} → later x [ nothing ]⟶ force x
delay-monad : LTS a
delay-monad = record
  { Proc      = Delay A ∞
  ; Label     = Maybe A
  ; _[_]⟶_    = _[_]⟶_
  ; is-silent = if_then true else false
  }
open LTS delay-monad public hiding (_[_]⟶_)
------------------------------------------------------------------------
-- Some simple lemmas
-- If now x can make a sequence of silent transitions to y, then y
-- is equal to now x.
now[nothing]⟶ : ∀ {x y} → now x [ nothing ]⟶ y → y ≡ now x
now[nothing]⟶ ()
now⇒ : ∀ {x y} → now x ⇒ y → y ≡ now x
now⇒ done            = refl
now⇒ (step () now _)
now[nothing]⇒ : ∀ {x y} → now x [ nothing ]⇒ y → y ≡ now x
now[nothing]⇒ (steps nx⇒x′ x′⟶x″ x″⇒y)
  rewrite now⇒ nx⇒x′ | now[nothing]⟶ x′⟶x″ = now⇒ x″⇒y
now[nothing]⇒̂ : ∀ {x y} → now x [ nothing ]⇒̂ y → y ≡ now x
now[nothing]⇒̂ (silent _ tr)     = now⇒ tr
now[nothing]⇒̂ (non-silent ¬s _) = ⊥-elim (¬s _)
now[nothing]⟶̂ : ∀ {x y} → now x [ nothing ]⟶̂ y → y ≡ now x
now[nothing]⟶̂ (done _)  = refl
now[nothing]⟶̂ (step tr) = now[nothing]⟶ tr
-- If now x can make a just y-transition, then x is equal to y.
now[just]⟶ : ∀ {x y z} → now x [ just y ]⟶ z → x ≡ y
now[just]⟶ now = refl
now[just]⇒ : ∀ {x y z} → now x [ just y ]⇒ z → x ≡ y
now[just]⇒ (steps tr₁ tr₂ _) =
  now[just]⟶ (subst (_[ _ ]⟶ _) (now⇒ tr₁) tr₂)
now[just]⇒̂ : ∀ {x y z} → now x [ just y ]⇒̂ z → x ≡ y
now[just]⇒̂ (silent () _)
now[just]⇒̂ (non-silent _ tr) = now[just]⇒ tr
now[just]⟶̂ : ∀ {x y z} → now x [ just y ]⟶̂ z → x ≡ y
now[just]⟶̂ (done ())
now[just]⟶̂ (step tr) = now[just]⟶ tr
-- The computation never can only transition to itself.
never⟶never : ∀ {μ x} → never [ μ ]⟶ x → x ≡ never
never⟶never later = refl
never⇒never : ∀ {x} → never ⇒ x → x ≡ never
never⇒never done               = refl
never⇒never (step _ later ne⇒) = never⇒never ne⇒
never[]⇒never : ∀ {μ x} → never [ μ ]⇒ x → x ≡ never
never[]⇒never (steps ne⇒x x⟶y y⇒z)
  rewrite never⇒never ne⇒x | never⟶never x⟶y = never⇒never y⇒z
never⇒̂never : ∀ {μ x} → never [ μ ]⇒̂ x → x ≡ never
never⇒̂never (silent     _ ne⇒) = never⇒never ne⇒
never⇒̂never (non-silent _ ne⇒) = never[]⇒never ne⇒
never⟶̂never : ∀ {μ x} → never [ μ ]⟶̂ x → x ≡ never
never⟶̂never (done _)   = refl
never⟶̂never (step ne⟶) = never⟶never ne⟶
-- If never can make a μ-transition, then μ is silent.
never⟶→silent : ∀ {μ x} → never [ μ ]⟶ x → Silent μ
never⟶→silent later = _
never[]⇒→silent : ∀ {μ x} → never [ μ ]⇒ x → Silent μ
never[]⇒→silent (steps ne⇒x  x⟶  _) with never⇒never ne⇒x
never[]⇒→silent (steps ne⇒ne ne⟶ _) | refl = never⟶→silent ne⟶
never⇒̂→silent : ∀ {μ x} → never [ μ ]⇒̂ x → Silent μ
never⇒̂→silent (silent s _)       = s
never⇒̂→silent (non-silent _ ne⇒) = never[]⇒→silent ne⇒
never⟶̂→silent : ∀ {μ x} → never [ μ ]⟶̂ x → Silent μ
never⟶̂→silent (done s)   = s
never⟶̂→silent (step ne⟶) = never⟶→silent ne⟶
-- If x can make a non-silent transition, with label just y, to z,
-- then z is equal to now y.
[just]⟶ : ∀ {x y z} → x [ just y ]⟶ z → z ≡ now y
[just]⟶ now = refl
[just]⇒ : ∀ {x y z} → x [ just y ]⇒ z → z ≡ now y
[just]⇒ (steps _ now ny⇒z) = now⇒ ny⇒z
[just]⇒̂ : ∀ {x y z} → x [ just y ]⇒̂ z → z ≡ now y
[just]⇒̂ (silent () _)
[just]⇒̂ (non-silent _ x⇒z) = [just]⇒ x⇒z
[just]⟶̂ : ∀ {x y z} → x [ just y ]⟶̂ z → z ≡ now y
[just]⟶̂ (done ())
[just]⟶̂ (step x⟶z) = [just]⟶ x⟶z
-- In some cases x is also equal to now y.
[just]⟶→≡now : ∀ {x y z} → x [ just y ]⟶ z → x ≡ now y
[just]⟶→≡now now = refl
[just]⟶̂→≡now : ∀ {x y z} → x [ just y ]⟶̂ z → x ≡ now y
[just]⟶̂→≡now (done ())
[just]⟶̂→≡now (step x⟶z) = [just]⟶→≡now x⟶z
-- If force x can make a weak μ-transition (_[_]⇒_ or _[_]⇒̂_) to y,
-- then later x can also make a weak μ-transition (of the same kind)
-- to y.
later[]⇒ : ∀ {μ x y} → force x [ μ ]⇒ y → later x [ μ ]⇒ y
later[]⇒ = ⇒[]⇒-transitive (⟶→⇒ _ later)
later⇒̂ : ∀ {μ x y} → force x [ μ ]⇒̂ y → later x [ μ ]⇒̂ y
later⇒̂ = ⇒⇒̂-transitive (⟶→⇒ _ later)
-- The process x can make a silent transition to drop-later x.
⇒drop-later : ∀ {x} → x ⇒ drop-later x
⇒drop-later {now x}   = done
⇒drop-later {later x} = step _ later done
-- If x can make a transition to y, then drop-later x can in some
-- cases make a transition of the same kind to drop-later y.
drop-later-cong⟶ :
  ∀ {x μ y} →
  ¬ Silent μ → x [ μ ]⟶ y → drop-later x [ μ ]⟶ drop-later y
drop-later-cong⟶ _  now   = now
drop-later-cong⟶ ¬s later = ⊥-elim (¬s _)
drop-later-cong⇒ : ∀ {x y} → x ⇒ y → drop-later x ⇒ drop-later y
drop-later-cong⇒ done                = done
drop-later-cong⇒ (step () now   _)
drop-later-cong⇒ (step _  later x⇒y) =
  ⇒-transitive ⇒drop-later (drop-later-cong⇒ x⇒y)
drop-later-cong[]⇒ :
  ∀ {x μ y} →
  ¬ Silent μ → x [ μ ]⇒ y → drop-later x [ μ ]⇒ drop-later y
drop-later-cong[]⇒ ¬s (steps x⇒y y⟶z z⇒u) =
  steps (drop-later-cong⇒ x⇒y) (drop-later-cong⟶ ¬s y⟶z)
        (drop-later-cong⇒ z⇒u)
drop-later-cong⇒̂ :
  ∀ {x μ y} → x [ μ ]⇒̂ y → drop-later x [ μ ]⇒̂ drop-later y
drop-later-cong⇒̂ (silent s x⇒y)      = silent s (drop-later-cong⇒ x⇒y)
drop-later-cong⇒̂ (non-silent ¬s x⇒y) =
  non-silent ¬s (drop-later-cong[]⇒ ¬s x⇒y)
drop-later-cong⟶̂ :
  ∀ {x μ y} →
  ¬ Silent μ → x [ μ ]⟶̂ y → drop-later x [ μ ]⟶̂ drop-later y
drop-later-cong⟶̂ _  (done s)   = done s
drop-later-cong⟶̂ ¬s (step x⟶y) = step (drop-later-cong⟶ ¬s x⟶y)
-- If later x can make a transition to later y, then force x can
-- make a transition (of the same kind) to force y.
drop-later⟶ :
  ∀ {μ x y} → later x [ μ ]⟶ later y → force x [ μ ]⟶ force y
drop-later⟶ lx⟶ly = helper lx⟶ly refl refl
  where
  helper : ∀ {μ x x′ y y′} →
           later x [ μ ]⟶ y′ →
           y′ ≡ later y →
           x′ ≡ force x →
           x′ [ μ ]⟶ force y
  helper {x = x} {x′} {y} later x≡ly x′≡x =
    subst (_[ _ ]⟶ _) ly≡x′ later
    where
    ly≡x′ =
      later y  ≡⟨ sym x≡ly ⟩
      force x  ≡⟨ sym x′≡x ⟩∎
      x′       ∎
drop-later⇒ : ∀ {x y} → later x ⇒ later y → force x ⇒ force y
drop-later⇒ = drop-later-cong⇒
drop-later[]⇒ :
  ∀ {μ x y} → later x [ μ ]⇒ later y → force x [ μ ]⇒ force y
drop-later[]⇒ (steps lx⇒ly later y⇒lz) =
  ⇒[]⇒-transitive (⇒-transitive (drop-later⇒ lx⇒ly) y⇒lz)
                  (⟶→[]⇒ later)
drop-later[]⇒ (steps _ now ny⇒lz) with now⇒ ny⇒lz
... | ()
drop-later⇒̂ :
  ∀ {μ x y} → later x [ μ ]⇒̂ later y → force x [ μ ]⇒̂ force y
drop-later⇒̂ = drop-later-cong⇒̂
drop-later⟶̂ :
  ∀ {μ x y} → later x [ μ ]⟶̂ later y → force x [ μ ]⟶̂ force y
drop-later⟶̂ (done s)     = done s
drop-later⟶̂ (step lx⟶ly) = step (drop-later⟶ lx⟶ly)
-- If x makes silent transitions to both y and z, then one of y and
-- z makes silent transitions to the other.
⇒×⇒→… : ∀ {x y z} → x ⇒ y → x ⇒ z → y ⇒ z ⊎ z ⇒ y
⇒×⇒→… done               x⇒z                = inj₁ x⇒z
⇒×⇒→… x⇒y                done               = inj₂ x⇒y
⇒×⇒→… (step _ later x⇒y) (step _ later x⇒z) = ⇒×⇒→… x⇒y x⇒z
⇒×⇒→… (step () now _)
-- If x makes silent transitions to y and a non-silent weak
-- μ-transition (of one kind) to z, then y makes a weak μ-transition
-- to z.
⇒×⇒[]→… :
  ∀ {x y z μ} →
  ¬ Silent μ → x ⇒ y → x [ μ ]⇒ z → y [ μ ]⇒ z
⇒×⇒[]→… _ x⇒y (steps x⇒x′ x′⟶x″ x″⇒z) with ⇒×⇒→… x⇒y x⇒x′
⇒×⇒[]→… _ _   (steps _    x′⟶x″ x″⇒z) | inj₁ y⇒x′ = steps y⇒x′ x′⟶x″ x″⇒z
⇒×⇒[]→… _ _   (steps _    now   n⇒z)  | inj₂ done = steps done now   n⇒z
⇒×⇒[]→… _  _  _                 | inj₂ (step () now _)
⇒×⇒[]→… ¬s _  (steps _ later _) | _ = ⊥-elim (¬s _)
-- If x makes silent transitions to y and a weak μ-transition (of
-- one kind) to z, then either y makes a weak μ-transition to z, or
-- μ is silent and z makes silent transitions to y.
⇒×⇒̂→… :
  ∀ {x y z μ} → x ⇒ y → x [ μ ]⇒̂ z → y [ μ ]⇒̂ z ⊎ Silent μ × z ⇒ y
⇒×⇒̂→… x⇒y (silent     s  x⇒z) = ⊎-map (silent s) (s ,_)
                                      (⇒×⇒→… x⇒y x⇒z)
⇒×⇒̂→… x⇒y (non-silent ¬s x⇒z) =
  inj₁ (non-silent ¬s (⇒×⇒[]→… ¬s x⇒y x⇒z))
 
 | 
	{
  "alphanum_fraction": 0.5195733708,
  "avg_line_length": 32.1962264151,
  "ext": "agda",
  "hexsha": "4889121a36b177789e5def9448241823e3c2e31f",
  "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/Labelled-transition-system/Delay-monad.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/Labelled-transition-system/Delay-monad.agda",
  "max_line_length": 73,
  "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/Labelled-transition-system/Delay-monad.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 3952,
  "size": 8532
} 
 | 
					
	--------------------------------------------------------------------------------
-- This file contains functions to turn the tree of parse results into the agda
-- data structures they represent.
--------------------------------------------------------------------------------
{-# OPTIONS --type-in-type #-}
module Parse.TreeConvert where
import Data.Sum
open import Class.Map
open import Class.Monad.Except
open import Data.SimpleMap
open import Data.String using (fromList; toList; fromChar; uncons)
open import Data.Tree
open import Data.Tree.Instance
open import Data.Word using (fromℕ)
open import Prelude
open import Prelude.Strings
open import CoreTheory
open import Bootstrap.InitEnv
open import Parse.MultiChar
open import Parse.LL1
open import Parse.Generate
open import Parse.Escape
continueIfInit : ∀ {a} {A : Set a} → List Char → List Char → (List Char → A) → Maybe A
continueIfInit {A = A} init s = helper init s
  where
    helper : List Char → List Char → (List Char → A) → Maybe A
    helper [] s f = just $ f s
    helper (x₁ ∷ init) [] f = nothing
    helper (x₁ ∷ init) (x ∷ s) f with x ≟ x₁
    ... | yes p = helper init s f
    ... | no ¬p = nothing
ruleId : List Char → List Char → Maybe (ℕ ⊎ Char)
ruleId nonterm rule = do
  rules ← lookup nonterm parseRuleMap
  i ← findIndexList (_≟ (nonterm + "$" + rule)) rules
  return $ inj₁ i
_≡ᴹ_ : ℕ ⊎ Char → Maybe (ℕ ⊎ Char) → Bool
x ≡ᴹ y = just x ≣ y
toSort : Tree (ℕ ⊎ Char) → Maybe Sort
toSort (Node x x₁) =
  if x ≡ᴹ ruleId "sort" "*"
    then return ⋆
    else if x ≡ᴹ ruleId "sort" "□"
      then return □
      else nothing
toConst : Tree (ℕ ⊎ Char) → Maybe Const
toConst (Node x x₁) =
  if x ≡ᴹ ruleId "const" "Char"
    then return CharT
    else nothing
toChar : Tree (ℕ ⊎ Char) → Maybe Char
toChar (Node (inj₁ x) x₁) = nothing
toChar (Node (inj₂ y) x₁) = just y
toChar' : Tree (ℕ ⊎ Char) → Maybe Char
toChar' (Node x x₁) =
  if x ≡ᴹ ruleId "char" "!!"
    then (case x₁ of λ { (y ∷ []) → toChar y ; _ → nothing })
    else nothing
toName : Tree (ℕ ⊎ Char) → Maybe String
toName (Node x x₁) = case x₁ of λ
  { (y ∷ y' ∷ _) → do
    c ← toChar y
    n ← toName y'
    return (fromChar c + n)
  ; [] → if x ≡ᴹ ruleId "string'" ""
      then return ""
      else nothing
  ; _ → nothing }
toNameList : Tree (ℕ ⊎ Char) → Maybe (List String)
toNameList (Node x []) = just []
toNameList (Node x (x₁ ∷ x₂ ∷ _)) = do
  n ← toName x₁
  rest ← toNameList x₂
  return $ n ∷ rest
{-# CATCHALL #-}
toNameList _ = nothing
toIndex : Tree (ℕ ⊎ Char) → Maybe ℕ
toIndex t = do
  res ← helper t
  foldl {A = Maybe ℕ} (λ x c → (λ x' → 10 * x' + c) <$> x) (just 0) res
  where
    helper' : Tree (ℕ ⊎ Char) → Maybe (List ℕ)
    helper' (Node x []) =
      if x ≡ᴹ ruleId "index'" ""
        then return []
        else nothing
    helper' (Node x (x₁ ∷ _)) = do
      rest ← helper' x₁
      decCase (just x) of
        (ruleId "index'" "0_index'_" , return (0 ∷ rest)) ∷
        (ruleId "index'" "1_index'_" , return (1 ∷ rest)) ∷
        (ruleId "index'" "2_index'_" , return (2 ∷ rest)) ∷
        (ruleId "index'" "3_index'_" , return (3 ∷ rest)) ∷
        (ruleId "index'" "4_index'_" , return (4 ∷ rest)) ∷
        (ruleId "index'" "5_index'_" , return (5 ∷ rest)) ∷
        (ruleId "index'" "6_index'_" , return (6 ∷ rest)) ∷
        (ruleId "index'" "7_index'_" , return (7 ∷ rest)) ∷
        (ruleId "index'" "8_index'_" , return (8 ∷ rest)) ∷
        (ruleId "index'" "9_index'_" , return (9 ∷ rest)) ∷ []
        default nothing
    helper : Tree (ℕ ⊎ Char) → Maybe (List ℕ)
    helper (Node x []) = nothing
    helper (Node x (x₁ ∷ _)) = do
      rest ← helper' x₁
      decCase just x of
        (ruleId "index" "0_index'_" , return (0 ∷ rest)) ∷
        (ruleId "index" "1_index'_" , return (1 ∷ rest)) ∷
        (ruleId "index" "2_index'_" , return (2 ∷ rest)) ∷
        (ruleId "index" "3_index'_" , return (3 ∷ rest)) ∷
        (ruleId "index" "4_index'_" , return (4 ∷ rest)) ∷
        (ruleId "index" "5_index'_" , return (5 ∷ rest)) ∷
        (ruleId "index" "6_index'_" , return (6 ∷ rest)) ∷
        (ruleId "index" "7_index'_" , return (7 ∷ rest)) ∷
        (ruleId "index" "8_index'_" , return (8 ∷ rest)) ∷
        (ruleId "index" "9_index'_" , return (9 ∷ rest)) ∷ []
        default nothing
toTerm : Tree (ℕ ⊎ Char) → Maybe AnnTerm
toTerm = helper []
  where
    helper : List String → Tree (ℕ ⊎ Char) → Maybe AnnTerm
    helper accu (Node x x₁) =
      decCase just x of
      
        (ruleId "term" "_var_" , (case x₁ of λ
          { ((Node y (n ∷ [])) ∷ []) →
            decCase just y of
              (ruleId "var" "_string_" , do
                n' ← toName n
                return $ case findIndexList (n' ≟_) accu of λ
                  { (just x) → BoundVar $ fromℕ x
                  ; nothing → FreeVar n' }) ∷
              (ruleId "var" "_index_" , do
                n' ← toIndex n
                return $ BoundVar $ fromℕ n') ∷ []
            default nothing
          ; _ → nothing })) ∷
        (ruleId "term" "_sort_" , do
          s ← head x₁ >>= toSort
          return $ Sort-A s) ∷
        (ruleId "term" "π^space^_term_" , (case x₁ of λ
          { (y ∷ []) → do
            y' ← helper accu y
            return $ Pr1-A y'
          ; _ → nothing })) ∷
        (ruleId "term" "ψ^space^_term_" , (case x₁ of λ
          { (y ∷ []) → do
            y' ← helper accu y
            return $ Pr2-A y'
          ; _ → nothing })) ∷
        (ruleId "term" "β^space^_term_^space^_term_" , (case x₁ of λ
          { (y ∷ y' ∷ []) → do
            t ← helper accu y
            t' ← helper accu y'
            return $ Beta-A t t'
          ; _ → nothing })) ∷
        (ruleId "term" "δ^space^_term_^space^_term_" , (case x₁ of λ
          { (y ∷ y' ∷ []) → do
            t ← helper accu y
            t' ← helper accu y'
            return $ Delta-A t t'
          ; _ → nothing })) ∷
        (ruleId "term" "σ^space^_term_" , (case x₁ of λ
          { (y ∷ []) → helper accu y >>= λ y' → return (Sigma-A y') ; _ → nothing })) ∷
        (ruleId "term" "[^space'^_term_^space^_term_^space'^]" , (case x₁ of λ
          { (y ∷ y' ∷ []) → do
            t ← helper accu y
            t' ← helper accu y'
            return $ App-A t t'
          ; _ → nothing })) ∷
        (ruleId "term" "<^space'^_term_^space^_term_^space'^>" , (case x₁ of λ
          { (y ∷ y' ∷ []) → do
            t ← helper accu y
            t' ← helper accu y'
            return $ AppE-A t t'
          ; _ → nothing })) ∷
        (ruleId "term"
          "ρ^space^_term_^space^_string_^space'^.^space'^_term_^space^_term_" , (case x₁ of λ
          { (y ∷ n' ∷ y' ∷ y'' ∷ []) → do
            t ← helper accu y
            n ← toName n'
            t' ← helper (n ∷ accu) y'
            t'' ← helper accu y''
            return $ Rho-A t t' t''
          ; _ → nothing })) ∷
        (ruleId "term"
          "∀^space^_string_^space'^:^space'^_term_^space^_term_" , (case x₁ of λ
          { (n' ∷ y ∷ y' ∷ []) → do
            n ← toName n'
            t ← helper accu y
            t' ← helper (n ∷ accu) y'
            return $ All-A n t t'
          ; _ → nothing })) ∷
        (ruleId "term"
          "Π^space^_string_^space'^:^space'^_term_^space^_term_" , (case x₁ of λ
          { (n' ∷ y ∷ y' ∷ []) → do
            n ← toName n'
            t ← helper accu y
            t' ← helper (n ∷ accu) y'
            return $ Pi-A n t t'
          ; _ → nothing })) ∷
        (ruleId "term"
          "ι^space^_string_^space'^:^space'^_term_^space^_term_" , (case x₁ of λ
          { (n' ∷ y ∷ y' ∷ []) → do
            n ← toName n'
            t ← helper accu y
            t' ← helper (n ∷ accu) y'
            return $ Iota-A n t t'
          ; _ → nothing })) ∷
        (ruleId "term"
          "λ^space^_string_^space'^:^space'^_term_^space^_term_" , (case x₁ of λ
          { (n' ∷ y ∷ y' ∷ []) → do
            n ← toName n'
            t ← helper accu y
            t' ← helper (n ∷ accu) y'
            return $ Lam-A n t t'
          ; _ → nothing })) ∷
        (ruleId "term"
          "Λ^space^_string_^space'^:^space'^_term_^space^_term_" , (case x₁ of λ
          { (n' ∷ y ∷ y' ∷ []) → do
            n ← toName n'
            t ← helper accu y
            t' ← helper (n ∷ accu) y'
            return $ LamE-A n t t'
          ; _ → nothing })) ∷
        (ruleId "term"
          "{^space'^_term_^space'^,^space'^_term_^space^_string_^space'^.^space'^_term_^space'^}" ,
          (case x₁ of λ
          { (y ∷ y' ∷ n' ∷ y'' ∷ []) → do
            t ← helper accu y
            t' ← helper accu y'
            n ← toName n'
            t'' ← helper (n ∷ accu) y''
            return $ Pair-A t t' t''
          ; _ → nothing })) ∷
        (ruleId "term" "φ^space^_term_^space^_term_^space^_term_" , (case x₁ of λ
          { (y ∷ y' ∷ y'' ∷ []) → do
            t ← helper accu y
            t' ← helper accu y'
            t'' ← helper accu y''
            return $ Phi-A t t' t''
          ; _ → nothing })) ∷
        (ruleId "term" "=^space^_term_^space^_term_" , (case x₁ of λ
          { (y ∷ y' ∷ []) → do
            t ← helper accu y
            t' ← helper accu y'
            return $ Eq-A t t'
          ; _ → nothing })) ∷
        (ruleId "term" "ω^space^_term_" , (case x₁ of λ
          { (y ∷ []) → do
            t ← helper accu y
            return $ M-A t
          ; _ → nothing })) ∷
        (ruleId "term" "μ^space^_term_^space^_term_" , (case x₁ of λ
          { (y ∷ y' ∷ []) → do
            t ← helper accu y
            t' ← helper accu y'
            return $ Mu-A t t'
          ; _ → nothing })) ∷
        (ruleId "term" "ε^space^_term_" , (case x₁ of λ
          { (y ∷ []) → do
            t ← helper accu y
            return $ Epsilon-A t
          ; _ → nothing })) ∷
        (ruleId "term" "ζEvalStmt^space^_term_" , (case x₁ of λ
          { (z ∷ []) → do
            t ← helper accu z
            return $ Ev-A EvalStmt t
          ; _ → nothing })) ∷
        (ruleId "term" "ζShellCmd^space^_term_^space^_term_" , (case x₁ of λ
          { (z ∷ z' ∷ []) → do
            t ← helper accu z
            t' ← helper accu z'
            return $ Ev-A ShellCmd (t , t')
          ; _ → nothing })) ∷
        (ruleId "term" "ζCheckTerm^space^_term_^space^_term_" , (case x₁ of λ
          { (z ∷ z' ∷ []) → do
            t ← helper accu z
            t' ← helper accu z'
            return $ Ev-A CheckTerm (t , t')
          ; _ → nothing })) ∷
        (ruleId "term" "ζParse^space^_term_^space^_term_^space^_term_" , (case x₁ of λ
          { (z ∷ z' ∷ z'' ∷ []) → do
            t ← helper accu z
            t' ← helper accu z'
            t'' ← helper accu z''
            return $ Ev-A Parse (t , t' , t'')
          ; _ → nothing })) ∷
        (ruleId "term" "ζCatchErr^space^_term_^space^_term_" , (case x₁ of λ
          { (z ∷ z' ∷ []) → do
            t ← helper accu z
            t' ← helper accu z'
            return $ Gamma-A t t'
          ; _ → nothing })) ∷
        (ruleId "term" "ζNormalize^space^_term_" , (case x₁ of λ
          { (z ∷ []) → do
            t ← helper accu z
            return $ Ev-A Normalize t
          ; _ → nothing })) ∷
        (ruleId "term" "ζHeadNormalize^space^_term_" , (case x₁ of λ
          { (z ∷ []) → do
            t ← helper accu z
            return $ Ev-A HeadNormalize t
          ; _ → nothing })) ∷
        (ruleId "term" "ζInferType^space^_term_" , (case x₁ of λ
          { (z ∷ []) → do
            t ← helper accu z
            return $ Ev-A InferType t
          ; _ → nothing })) ∷
        (ruleId "term" "Κ_const_" , (case x₁ of λ
          { (z ∷ []) → do
            c ← toConst z
            return $ Const-A c
          ; _ → nothing })) ∷
        (ruleId "term" "κ_char_" , (case x₁ of λ
          { (z ∷ []) → do
            c ← toChar z <∣> toChar' z
            return $ Char-A c
          ; _ → nothing })) ∷
        (ruleId "term" "γ^space^_term_^space^_term_" , (case x₁ of λ
          { (z ∷ z' ∷ []) → do
            t ← helper accu z
            t' ← helper accu z'
            return $ CharEq-A t t'
          ; _ → nothing })) ∷
        []
        default nothing
data Stmt : Set where
  Let           : GlobalName → AnnTerm → Maybe AnnTerm → Stmt
  Ass           : GlobalName → AnnTerm → Stmt
  SetEval       : AnnTerm → String → String → Stmt
  Import        : String → Stmt
  Empty         : Stmt
instance
  Stmt-Show : Show Stmt
  Stmt-Show = record { show = helper }
    where
      helper : Stmt → String
      helper (Let x x₁ (just x₂)) = "let " + x + " := " + show x₁ + " : " + show x₂
      helper (Let x x₁ nothing)   = "let " + x + " := " + show x₁
      helper (Ass x x₁)           = "ass " + x + " : " + show x₁
      helper (SetEval x n n')     = "seteval " + show x + " " + n + " " + n'
      helper (Import s)           = "import " + s
      helper Empty                = "Empty"
toStmt : Tree (ℕ ⊎ Char) → Maybe Stmt
toStmt (Node x ((Node x' x₂) ∷ [])) =
  if x ≡ᴹ ruleId "stmt" "^space'^_stmt'_"
    then
      decCase just x' of
        (ruleId "stmt'" "let^space^_string_^space'^:=^space'^_term_^space'^_lettail_" ,
          (case x₂ of λ
            { (y ∷ y' ∷ y'' ∷ []) → do
              n ← toName y
              t ← toTerm y'
              return $ Let n t $ toLetTail y''
            ; _ → nothing })) ∷
        (ruleId "stmt'"
          "ass^space^_string_^space'^:^space'^_term_^space'^." ,
          (case x₂ of λ
            { (y ∷ y₁ ∷ []) → do
              n ← toName y
              t ← toTerm y₁
              return $ Ass n t
            ; _ → nothing })) ∷
        (ruleId "stmt'" "seteval^space^_term_^space^_string_^space^_string_^space'^." ,
          (case x₂ of λ
            { (y ∷ y' ∷ y'' ∷ []) → do
              t ← toTerm y
              n ← toName y'
              n' ← toName y''
              return $ SetEval t n n'
            ; _ → nothing })) ∷
        (ruleId "stmt'" "import^space^_string_^space'^." ,
          (case x₂ of λ
            { (y ∷ []) → do
              n ← toName y
              return $ Import n
            ; _ → nothing })) ∷
        (ruleId "stmt'" "" ,
          return Empty) ∷
        []
      default nothing
    else nothing
  where
    toLetTail : Tree (ℕ ⊎ Char) → Maybe AnnTerm
    toLetTail (Node x x₁) =
      decCase just x of
        (ruleId "lettail" ":^space'^_term_^space'^." ,
          (case x₁ of λ
            { (y ∷ []) → toTerm y
            ; _ → nothing })) ∷
        []
      default nothing
{-# CATCHALL #-}
toStmt _ = nothing
private
  -- Folds a tree of constructors back into a term by properly applying the
  -- constructors and prefixing the namespace
  {-# TERMINATING #-}
  foldConstrTree : String → Tree (String ⊎ Char) → AnnTerm
  foldConstrTree namespace (Node x x₁) =
    foldl (λ t t' → t ⟪$⟫ t') (ruleToTerm x) (foldConstrTree namespace <$> x₁)
      where
        ruleToTerm : String ⊎ Char → AnnTerm
        ruleToTerm (inj₁ x) = FreeVar (namespace + "$" + ruleToConstr x)
        ruleToTerm (inj₂ y) = Char-A y
  convertIfChar : Tree (String ⊎ Char) → Maybe (Tree (ℕ ⊎ Char))
  convertIfChar (Node (inj₁ x) x₁) = do
    rest ← stripPrefix "nameInitChar$" x <∣> stripPrefix "nameTailChar$" x
    (c , s) ← uncons rest
    just $ Node (inj₂ $ unescape c s) []
  convertIfChar (Node (inj₂ x) x₁) = nothing
module _ {M} {{_ : Monad M}} {{_ : MonadExcept M String}} where
  preCoreGrammar : M Grammar
  preCoreGrammar = generateCFGNonEscaped "stmt" (map fromList coreGrammarGenerator)
  private
    parseToConstrTree : (G : Grammar) → NonTerminal G → String → M (Tree (String ⊎ Char) × String)
    parseToConstrTree (_ , G , (showRule , showNT)) S s = do
      (t , rest) ← parseWithInitNT showNT matchMulti show G M S s
      return (_<$>_ {{Tree-Functor}} (Data.Sum.map₁ showRule) t , rest)
    parsePreCoreGrammar : String → M (Tree (String ⊎ Char) × String)
    parsePreCoreGrammar s = do
      G ← preCoreGrammar
      parseToConstrTree G (initNT G) s
    {-# TERMINATING #-} -- cannot just use sequence here because of the char special case
    synTreeToℕTree : Tree (String ⊎ Char) → M (Tree (ℕ ⊎ Char))
    synTreeToℕTree t@(Node (inj₁ x) x₁) with convertIfChar t
    ... | (just t') = return t'
    ... | nothing = do
      id ← fullRuleId x
      ids ← sequence $ map synTreeToℕTree x₁
      return (Node id ids)
      where
        fullRuleId : String → M (ℕ ⊎ Char)
        fullRuleId l with break (_≟ '$') (toList l) -- split at '$'
        ... | (x , []) = throwError "No '$' character found!"
        ... | (x , _ ∷ y) = maybeToError (ruleId x y) ("Rule " + l + "doesn't exist!")
    synTreeToℕTree (Node (inj₂ x) x₁) = return $ Node (inj₂ x) []
  -- Parse the next top-level non-terminal symbol from a string, and return a
  -- term representing the result of the parse, as well as the unparsed rest of
  -- the string
  parse : (G : Grammar) → NonTerminal G → String → String → M (AnnTerm × String)
  parse G S namespace s = do
    (t , rest) ← parseToConstrTree G S s
    return (foldConstrTree namespace t , rest)
  -- Used for bootstrapping
  parseStmt : String → M (Stmt × String)
  parseStmt s = do
    (y' , rest) ← parsePreCoreGrammar s
    y ← synTreeToℕTree y'
    case toStmt y of λ where
      (just x) → return (x , rest)
      nothing → throwError ("Error while converting syntax tree to statement!\nTree:\n" + show y
                             + "\nRemaining: " + s)
 
 | 
	{
  "alphanum_fraction": 0.4848052096,
  "avg_line_length": 33.4722753346,
  "ext": "agda",
  "hexsha": "e6e39d0cada84cc5c798f5370a2f77f7b0920529",
  "lang": "Agda",
  "max_forks_count": 2,
  "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z",
  "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z",
  "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "WhatisRT/meta-cedille",
  "max_forks_repo_path": "src/Parse/TreeConvert.agda",
  "max_issues_count": 10,
  "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
  "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z",
  "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z",
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "WhatisRT/meta-cedille",
  "max_issues_repo_path": "src/Parse/TreeConvert.agda",
  "max_line_length": 99,
  "max_stars_count": 35,
  "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "WhatisRT/meta-cedille",
  "max_stars_repo_path": "src/Parse/TreeConvert.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": 5781,
  "size": 17506
} 
 | 
					
	{-
Basic properties about Σ-types
- Action of Σ on functions ([map-fst], [map-snd])
- Characterization of equality in Σ-types using dependent paths ([ΣPath{Iso,≃,≡}PathΣ], [Σ≡Prop])
- Proof that discrete types are closed under Σ ([discreteΣ])
- Commutativity and associativity ([Σ-swap-*, Σ-assoc-*])
- Distributivity of Π over Σ ([Σ-Π-*])
- Action of Σ on isomorphisms, equivalences, and paths ([Σ-cong-fst], [Σ-cong-snd], ...)
- Characterization of equality in Σ-types using transport ([ΣPathTransport{≃,≡}PathΣ])
- Σ with a contractible base is its fiber ([Σ-contractFst, ΣUnit])
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.Sigma.Properties where
open import Cubical.Data.Sigma.Base
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Path
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Univalence
open import Cubical.Relation.Nullary
open import Cubical.Data.Unit.Base
open import Cubical.Reflection.StrictEquiv
open Iso
private
  variable
    ℓ ℓ' ℓ'' : Level
    A A' : Type ℓ
    B B' : (a : A) → Type ℓ
    C : (a : A) (b : B a) → Type ℓ
map-fst : {B : Type ℓ} → (f : A → A') → A × B → A' × B
map-fst f (a , b) = (f a , b)
map-snd : (∀ {a} → B a → B' a) → Σ A B → Σ A B'
map-snd f (a , b) = (a , f b)
map-× : {B : Type ℓ} {B' : Type ℓ'} → (A → A') → (B → B') → A × B → A' × B'
map-× f g (a , b) = (f a , g b)
≡-× : {A : Type ℓ} {B : Type ℓ'} {x y : A × B} → fst x ≡ fst y → snd x ≡ snd y → x ≡ y
≡-× p q i = (p i) , (q i)
-- Characterization of paths in Σ using dependent paths
module _ {A : I → Type ℓ} {B : (i : I) → A i → Type ℓ'}
  {x : Σ (A i0) (B i0)} {y : Σ (A i1) (B i1)}
  where
  ΣPathP : Σ[ p ∈ PathP A (fst x) (fst y) ] PathP (λ i → B i (p i)) (snd x) (snd y)
         → PathP (λ i → Σ (A i) (B i)) x y
  ΣPathP eq i = fst eq i , snd eq i
  PathPΣ : PathP (λ i → Σ (A i) (B i)) x y
         → Σ[ p ∈ PathP A (fst x) (fst y) ] PathP (λ i → B i (p i)) (snd x) (snd y)
  PathPΣ eq = (λ i → fst (eq i)) , (λ i → snd (eq i))
  -- allows one to write
  -- open PathPΣ somePathInΣAB renaming (fst ... )
  module PathPΣ (p : PathP (λ i → Σ (A i) (B i)) x y) where
    open Σ (PathPΣ p) public
  ΣPathIsoPathΣ : Iso (Σ[ p ∈ PathP A (fst x) (fst y) ] (PathP (λ i → B i (p i)) (snd x) (snd y)))
                      (PathP (λ i → Σ (A i) (B i)) x y)
  fun ΣPathIsoPathΣ        = ΣPathP
  inv ΣPathIsoPathΣ        = PathPΣ
  rightInv ΣPathIsoPathΣ _ = refl
  leftInv ΣPathIsoPathΣ _  = refl
  unquoteDecl ΣPath≃PathΣ = declStrictIsoToEquiv ΣPath≃PathΣ ΣPathIsoPathΣ
  ΣPath≡PathΣ : (Σ[ p ∈ PathP A (fst x) (fst y) ] (PathP (λ i → B i (p i)) (snd x) (snd y)))
              ≡ (PathP (λ i → Σ (A i) (B i)) x y)
  ΣPath≡PathΣ = ua ΣPath≃PathΣ
×≡Prop : isProp A' → {u v : A × A'} → u .fst ≡ v .fst → u ≡ v
×≡Prop pB {u} {v} p i = (p i) , (pB (u .snd) (v .snd) i)
-- Characterization of dependent paths in Σ
module _ {A : I → Type ℓ} {B : (i : I) → (a : A i) → Type ℓ'}
  {x : Σ (A i0) (B i0)} {y : Σ (A i1) (B i1)}
  where
  ΣPathPIsoPathPΣ :
    Iso (Σ[ p ∈ PathP A (x .fst) (y .fst) ] PathP (λ i → B i (p i)) (x .snd) (y .snd))
        (PathP (λ i → Σ (A i) (B i)) x y)
  ΣPathPIsoPathPΣ .fun (p , q) i = p i , q i
  ΣPathPIsoPathPΣ .inv pq .fst i = pq i .fst
  ΣPathPIsoPathPΣ .inv pq .snd i = pq i .snd
  ΣPathPIsoPathPΣ .rightInv _ = refl
  ΣPathPIsoPathPΣ .leftInv _ = refl
  unquoteDecl ΣPathP≃PathPΣ = declStrictIsoToEquiv ΣPathP≃PathPΣ ΣPathPIsoPathPΣ
  ΣPathP≡PathPΣ = ua ΣPathP≃PathPΣ
-- Σ of discrete types
discreteΣ : Discrete A → ((a : A) → Discrete (B a)) → Discrete (Σ A B)
discreteΣ {B = B} Adis Bdis (a0 , b0) (a1 , b1) = discreteΣ' (Adis a0 a1)
  where
    discreteΣ' : Dec (a0 ≡ a1) → Dec ((a0 , b0) ≡ (a1 , b1))
    discreteΣ' (yes p) = J (λ a1 p → ∀ b1 → Dec ((a0 , b0) ≡ (a1 , b1))) (discreteΣ'') p b1
      where
        discreteΣ'' : (b1 : B a0) → Dec ((a0 , b0) ≡ (a0 , b1))
        discreteΣ'' b1 with Bdis a0 b0 b1
        ... | (yes q) = yes (transport ΣPath≡PathΣ (refl , q))
        ... | (no ¬q) = no (λ r → ¬q (subst (λ X → PathP (λ i → B (X i)) b0 b1) (Discrete→isSet Adis a0 a0 (cong fst r) refl) (cong snd r)))
    discreteΣ' (no ¬p) = no (λ r → ¬p (cong fst r))
module _ {A : Type ℓ} {A' : Type ℓ'} where
  Σ-swap-Iso : Iso (A × A') (A' × A)
  fun Σ-swap-Iso (x , y) = (y , x)
  inv Σ-swap-Iso (x , y) = (y , x)
  rightInv Σ-swap-Iso _ = refl
  leftInv Σ-swap-Iso _  = refl
  unquoteDecl Σ-swap-≃ = declStrictIsoToEquiv Σ-swap-≃ Σ-swap-Iso
module _ {A : Type ℓ} {B : A → Type ℓ'} {C : ∀ a → B a → Type ℓ''} where
  Σ-assoc-Iso : Iso (Σ[ (a , b) ∈ Σ A B ] C a b) (Σ[ a ∈ A ] Σ[ b ∈ B a ] C a b)
  fun Σ-assoc-Iso ((x , y) , z) = (x , (y , z))
  inv Σ-assoc-Iso (x , (y , z)) = ((x , y) , z)
  rightInv Σ-assoc-Iso _ = refl
  leftInv Σ-assoc-Iso _  = refl
  unquoteDecl Σ-assoc-≃ = declStrictIsoToEquiv Σ-assoc-≃ Σ-assoc-Iso
  Σ-Π-Iso : Iso ((a : A) → Σ[ b ∈ B a ] C a b) (Σ[ f ∈ ((a : A) → B a) ] ∀ a → C a (f a))
  fun Σ-Π-Iso f         = (fst ∘ f , snd ∘ f)
  inv Σ-Π-Iso (f , g) x = (f x , g x)
  rightInv Σ-Π-Iso _    = refl
  leftInv Σ-Π-Iso _     = refl
  unquoteDecl Σ-Π-≃ = declStrictIsoToEquiv Σ-Π-≃ Σ-Π-Iso
Σ-cong-iso-fst : (isom : Iso A A') → Iso (Σ A (B ∘ fun isom)) (Σ A' B)
fun (Σ-cong-iso-fst isom) x = fun isom (x .fst) , x .snd
inv (Σ-cong-iso-fst {B = B} isom) x = inv isom (x .fst) , subst B (sym (ε (x .fst))) (x .snd)
  where
  ε = isHAEquiv.rinv (snd (iso→HAEquiv isom))
rightInv (Σ-cong-iso-fst {B = B} isom) (x , y) = ΣPathP (ε x , toPathP goal)
  where
  ε = isHAEquiv.rinv (snd (iso→HAEquiv isom))
  goal : subst B (ε x) (subst B (sym (ε x)) y) ≡ y
  goal = sym (substComposite B (sym (ε x)) (ε x) y)
      ∙∙ cong (λ x → subst B x y) (lCancel (ε x))
      ∙∙ substRefl {B = B} y
leftInv (Σ-cong-iso-fst {A = A} {B = B} isom) (x , y) = ΣPathP (leftInv isom x , toPathP goal)
  where
  ε = isHAEquiv.rinv (snd (iso→HAEquiv isom))
  γ = isHAEquiv.com (snd (iso→HAEquiv isom))
  lem : (x : A) → sym (ε (fun isom x)) ∙ cong (fun isom) (leftInv isom x) ≡ refl
  lem x = cong (λ a → sym (ε (fun isom x)) ∙ a) (γ x) ∙ lCancel (ε (fun isom x))
  goal : subst B (cong (fun isom) (leftInv isom x)) (subst B (sym (ε (fun isom x))) y) ≡ y
  goal = sym (substComposite B (sym (ε (fun isom x))) (cong (fun isom) (leftInv isom x)) y)
      ∙∙ cong (λ a → subst B a y) (lem x)
      ∙∙ substRefl {B = B} y
Σ-cong-equiv-fst : (e : A ≃ A') → Σ A (B ∘ equivFun e) ≃ Σ A' B
-- we could just do this:
-- Σ-cong-equiv-fst e = isoToEquiv (Σ-cong-iso-fst (equivToIso e))
-- but the following reduces slightly better
Σ-cong-equiv-fst {A = A} {A' = A'} {B = B} e = intro , isEqIntro
 where
  intro : Σ A (B ∘ equivFun e) → Σ A' B
  intro (a , b) = equivFun e a , b
  isEqIntro : isEquiv intro
  isEqIntro .equiv-proof x = ctr , isCtr where
    PB : ∀ {x y} → x ≡ y → B x → B y → Type _
    PB p = PathP (λ i → B (p i))
    open Σ x renaming (fst to a'; snd to b)
    open Σ (equivCtr e a') renaming (fst to ctrA; snd to α)
    ctrB : B (equivFun e ctrA)
    ctrB = subst B (sym α) b
    ctrP : PB α ctrB b
    ctrP = symP (transport-filler (λ i → B (sym α i)) b)
    ctr : fiber intro x
    ctr = (ctrA , ctrB) , ΣPathP (α , ctrP)
    isCtr : ∀ y → ctr ≡ y
    isCtr ((r , s) , p) = λ i → (a≡r i , b!≡s i) , ΣPathP (α≡ρ i , coh i) where
      open PathPΣ p renaming (fst to ρ; snd to σ)
      open PathPΣ (equivCtrPath e a' (r , ρ)) renaming (fst to a≡r; snd to α≡ρ)
      b!≡s : PB (cong (equivFun e) a≡r) ctrB s
      b!≡s i = comp (λ k → B (α≡ρ i (~ k))) (λ k → (λ
        { (i = i0) → ctrP (~ k)
        ; (i = i1) → σ (~ k)
        })) b
      coh : PathP (λ i → PB (α≡ρ i) (b!≡s i) b) ctrP σ
      coh i j = fill (λ k → B (α≡ρ i (~ k))) (λ k → (λ
        { (i = i0) → ctrP (~ k)
        ; (i = i1) → σ (~ k)
        })) (inS b) (~ j)
Σ-cong-fst : (p : A ≡ A') → Σ A (B ∘ transport p) ≡ Σ A' B
Σ-cong-fst {B = B} p i = Σ (p i) (B ∘ transp (λ j → p (i ∨ j)) i)
Σ-cong-iso-snd : ((x : A) → Iso (B x) (B' x)) → Iso (Σ A B) (Σ A B')
fun (Σ-cong-iso-snd isom) (x , y) = x , fun (isom x) y
inv (Σ-cong-iso-snd isom) (x , y') = x , inv (isom x) y'
rightInv (Σ-cong-iso-snd isom) (x , y) = ΣPathP (refl , rightInv (isom x) y)
leftInv (Σ-cong-iso-snd isom) (x , y') = ΣPathP (refl , leftInv (isom x) y')
Σ-cong-equiv-snd : (∀ a → B a ≃ B' a) → Σ A B ≃ Σ A B'
Σ-cong-equiv-snd h = isoToEquiv (Σ-cong-iso-snd (equivToIso ∘ h))
Σ-cong-snd : ((x : A) → B x ≡ B' x) → Σ A B ≡ Σ A B'
Σ-cong-snd {A = A} p i = Σ[ x ∈ A ] (p x i)
Σ-cong-iso : (isom : Iso A A')
           → ((x : A) → Iso (B x) (B' (fun isom x)))
           → Iso (Σ A B) (Σ A' B')
Σ-cong-iso isom isom' = compIso (Σ-cong-iso-snd isom') (Σ-cong-iso-fst isom)
Σ-cong-equiv : (e : A ≃ A')
             → ((x : A) → B x ≃ B' (equivFun e x))
             → Σ A B ≃ Σ A' B'
Σ-cong-equiv e e' = isoToEquiv (Σ-cong-iso (equivToIso e) (equivToIso ∘ e'))
Σ-cong' : (p : A ≡ A') → PathP (λ i → p i → Type ℓ') B B' → Σ A B ≡ Σ A' B'
Σ-cong' p p' = cong₂ (λ (A : Type _) (B : A → Type _) → Σ A B) p p'
-- Alternative version for path in Σ-types, as in the HoTT book
ΣPathTransport : (a b : Σ A B) → Type _
ΣPathTransport {B = B} a b = Σ[ p ∈ (fst a ≡ fst b) ] transport (λ i → B (p i)) (snd a) ≡ snd b
IsoΣPathTransportPathΣ : (a b : Σ A B) → Iso (ΣPathTransport a b) (a ≡ b)
IsoΣPathTransportPathΣ {B = B} a b = compIso (Σ-cong-iso-snd (λ p → invIso (equivToIso (PathP≃Path (λ i → B (p i)) _ _))))
         ΣPathIsoPathΣ
ΣPathTransport≃PathΣ : (a b : Σ A B) → ΣPathTransport a b ≃ (a ≡ b)
ΣPathTransport≃PathΣ {B = B} a b = isoToEquiv (IsoΣPathTransportPathΣ a b)
ΣPathTransport→PathΣ : (a b : Σ A B) → ΣPathTransport a b → (a ≡ b)
ΣPathTransport→PathΣ a b = Iso.fun (IsoΣPathTransportPathΣ a b)
PathΣ→ΣPathTransport : (a b : Σ A B) → (a ≡ b) → ΣPathTransport a b
PathΣ→ΣPathTransport a b = Iso.inv (IsoΣPathTransportPathΣ a b)
ΣPathTransport≡PathΣ : (a b : Σ A B) → ΣPathTransport a b ≡ (a ≡ b)
ΣPathTransport≡PathΣ a b = ua (ΣPathTransport≃PathΣ a b)
Σ-contractFst : (c : isContr A) → Σ A B ≃ B (c .fst)
Σ-contractFst {B = B} c = isoToEquiv isom
  where
  isom : Iso _ _
  isom .fun (a , b) = subst B (sym (c .snd a)) b
  isom .inv b = (c .fst , b)
  isom .rightInv b =
    cong (λ p → subst B p b) (isProp→isSet (isContr→isProp c) _ _ _ _) ∙ transportRefl _
  isom .leftInv (a , b) =
    ΣPathTransport≃PathΣ _ _ .fst (c .snd a , transportTransport⁻ (cong B (c .snd a)) _)
-- a special case of the above
module _ (A : Unit → Type ℓ) where
  ΣUnit : Σ Unit A ≃ A tt
  unquoteDef ΣUnit = defStrictEquiv ΣUnit snd (λ { x → (tt , x) })
Σ-contractSnd : ((a : A) → isContr (B a)) → Σ A B ≃ A
Σ-contractSnd c = isoToEquiv isom
  where
  isom : Iso _ _
  isom .fun = fst
  isom .inv a = a , c a .fst
  isom .rightInv _ = refl
  isom .leftInv (a , b) = cong (a ,_) (c a .snd b)
isEmbeddingFstΣProp : ((x : A) → isProp (B x))
                    → {u v : Σ A B}
                    → isEquiv (λ (p : u ≡ v) → cong fst p)
isEmbeddingFstΣProp {B = B} pB {u = u} {v = v} .equiv-proof x = ctr , isCtr
  where
  ctrP : u ≡ v
  ctrP = ΣPathP (x , isProp→PathP (λ _ → pB _) _ _)
  ctr  : fiber (λ (p : u ≡ v) → cong fst p) x
  ctr  = ctrP , refl
  isCtr : ∀ z → ctr ≡ z
  isCtr (z , p) = ΣPathP (ctrP≡ , cong (sym ∘ snd) fzsingl) where
    fzsingl : Path (singl x) (x , refl) (cong fst z , sym p)
    fzsingl = isContrSingl x .snd (cong fst z , sym p)
    ctrSnd : SquareP (λ i j → B (fzsingl i .fst j)) (cong snd ctrP) (cong snd z) _ _
    ctrSnd = isProp→SquareP (λ _ _ → pB _) _ _ _ _
    ctrP≡ : ctrP ≡ z
    ctrP≡ i = ΣPathP (fzsingl i .fst , ctrSnd i)
Σ≡PropEquiv : ((x : A) → isProp (B x)) → {u v : Σ A B}
            → (u .fst ≡ v .fst) ≃ (u ≡ v)
Σ≡PropEquiv pB = invEquiv (_ , isEmbeddingFstΣProp pB)
Σ≡Prop : ((x : A) → isProp (B x)) → {u v : Σ A B}
       → (p : u .fst ≡ v .fst) → u ≡ v
Σ≡Prop pB p = equivFun (Σ≡PropEquiv pB) p
≃-× : ∀ {ℓ'' ℓ'''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''} {D : Type ℓ'''} → A ≃ C → B ≃ D → A × B ≃ C × D
≃-× eq1 eq2 =
    map-× (fst eq1) (fst eq2)
  , record
     { equiv-proof
       = λ {(c , d) → ((eq1⁻ c .fst .fst
                        , eq2⁻ d .fst .fst)
                          , ≡-× (eq1⁻ c .fst .snd)
                                (eq2⁻ d .fst .snd))
                     , λ {((a , b) , p) → ΣPathP (≡-× (cong fst (eq1⁻ c .snd (a , cong fst p)))
                                                       (cong fst (eq2⁻ d .snd (b , cong snd p)))
                                                , λ i → ≡-× (snd ((eq1⁻ c .snd (a , cong fst p)) i))
                                                             (snd ((eq2⁻ d .snd (b , cong snd p)) i)))}}}
  where
  eq1⁻ = equiv-proof (eq1 .snd)
  eq2⁻ = equiv-proof (eq2 .snd)
{- Some simple ismorphisms -}
prodIso : ∀ {ℓ ℓ' ℓ'' ℓ'''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''} {D : Type ℓ'''}
       → Iso A C
       → Iso B D
       → Iso (A × B) (C × D)
Iso.fun (prodIso iAC iBD) (a , b) = (Iso.fun iAC a) , Iso.fun iBD b
Iso.inv (prodIso iAC iBD) (c , d) = (Iso.inv iAC c) , Iso.inv iBD d
Iso.rightInv (prodIso iAC iBD) (c , d) = ΣPathP ((Iso.rightInv iAC c) , (Iso.rightInv iBD d))
Iso.leftInv (prodIso iAC iBD) (a , b) = ΣPathP ((Iso.leftInv iAC a) , (Iso.leftInv iBD b))
toProdIso : {B C : A → Type ℓ}
          → Iso ((a : A) → B a × C a) (((a : A) → B a) × ((a : A) → C a))
Iso.fun toProdIso = λ f → (λ a → fst (f a)) , (λ a → snd (f a))
Iso.inv toProdIso (f , g) = λ a → (f a) , (g a)
Iso.rightInv toProdIso (f , g) = refl
Iso.leftInv toProdIso b = refl
module _ {A : Type ℓ} {B : A → Type ℓ'} {C : ∀ a → B a → Type ℓ''} where
  curryIso : Iso (((a , b) : Σ A B) → C a b) ((a : A) → (b : B a) → C a b)
  Iso.fun curryIso f a b = f (a , b)
  Iso.inv curryIso f a = f (fst a) (snd a)
  Iso.rightInv curryIso a = refl
  Iso.leftInv curryIso f = refl
  unquoteDecl curryEquiv = declStrictIsoToEquiv curryEquiv curryIso
 
 | 
	{
  "alphanum_fraction": 0.5394923426,
  "avg_line_length": 39.1777777778,
  "ext": "agda",
  "hexsha": "d9a93a05ce1a7c291f00d288cc42ddab279d2ec4",
  "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": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "Edlyr/cubical",
  "max_forks_repo_path": "Cubical/Data/Sigma/Properties.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
  "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": "Edlyr/cubical",
  "max_issues_repo_path": "Cubical/Data/Sigma/Properties.agda",
  "max_line_length": 140,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "Edlyr/cubical",
  "max_stars_repo_path": "Cubical/Data/Sigma/Properties.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 6248,
  "size": 14104
} 
 | 
					
	{-# OPTIONS --cubical --no-import-sorts --guardedness --safe #-}
module Cubical.Codata.M.AsLimit.Container 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.Foundations.Transport
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Function
open import Cubical.Data.Sum
open import Cubical.Foundations.Structure
open import Cubical.Codata.M.AsLimit.helper
-------------------------------------
-- Container and Container Functor --
-------------------------------------
-- Σ[ A ∈ (Type ℓ) ] (A → Type ℓ)
Container : ∀ ℓ -> Type (ℓ-suc ℓ)
Container ℓ = TypeWithStr ℓ (λ x → x → Type ℓ)
-- Polynomial functor (P₀ , P₁)  defined over a container
-- https://ncatlab.org/nlab/show/polynomial+functor
-- P₀ object part of functor
P₀ : ∀ {ℓ} (S : Container ℓ) -> Type ℓ -> Type ℓ
P₀ (A , B) X  = Σ[ a ∈ A ] (B a -> X)
-- P₁ morphism part of functor
P₁ : ∀ {ℓ} {S : Container ℓ} {X Y} (f : X -> Y) -> P₀ S X -> P₀ S Y
P₁ {S = S} f = λ { (a , g) ->  a , f ∘ g }
-----------------------
-- Chains and Limits --
-----------------------
record Chain ℓ : Type (ℓ-suc ℓ) where
  constructor _,,_
  field
    X : ℕ -> Type ℓ
    π : {n : ℕ} -> X (suc n) -> X n
open Chain public
limit-of-chain : ∀ {ℓ} -> Chain ℓ → Type ℓ
limit-of-chain (x ,, pi) = Σ[ x ∈ ((n : ℕ) → x n) ] ((n : ℕ) → pi {n = n} (x (suc n)) ≡ x n)
shift-chain : ∀ {ℓ} -> Chain ℓ -> Chain ℓ
shift-chain = λ X,π -> ((λ x → X X,π (suc x)) ,, λ {n} → π X,π {suc n})
------------------------------------------------------
-- Limit type of a Container , and Shift of a Limit --
------------------------------------------------------
Wₙ : ∀ {ℓ} -> Container ℓ -> ℕ -> Type ℓ
Wₙ S 0 = Lift Unit
Wₙ S (suc n) = P₀ S (Wₙ S n)
πₙ : ∀ {ℓ} -> (S : Container ℓ) -> {n : ℕ} -> Wₙ S (suc n) -> Wₙ S n
πₙ {ℓ} S {0} _ = lift tt
πₙ S {suc n} = P₁ (πₙ S {n})
sequence : ∀ {ℓ} -> Container ℓ -> Chain ℓ
X (sequence S) n = Wₙ S n
π (sequence S) {n} = πₙ S {n}
PX,Pπ : ∀ {ℓ} (S : Container ℓ) -> Chain ℓ
PX,Pπ {ℓ} S =
  (λ n → P₀ S (X (sequence S) n)) ,,
  (λ {n : ℕ} x → P₁ (λ z → z) (π (sequence S) {n = suc n} x ))
-----------------------------------
-- M type is limit of a sequence --
-----------------------------------
M : ∀ {ℓ} -> Container ℓ → Type ℓ
M = limit-of-chain ∘ sequence
 
 | 
	{
  "alphanum_fraction": 0.5294579733,
  "avg_line_length": 28.606741573,
  "ext": "agda",
  "hexsha": "faefb7e660db43baa2cc0ea8347af1ab09a9f1e7",
  "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/Container.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/Container.agda",
  "max_line_length": 92,
  "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/Container.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 878,
  "size": 2546
} 
 | 
					
	module Issue1078.A where
open import Common.Level using (Level)
 
 | 
	{
  "alphanum_fraction": 0.8,
  "avg_line_length": 16.25,
  "ext": "agda",
  "hexsha": "7c0afb15c2cf8e76936a053dfeabf98846a453b9",
  "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/Issue1078/A.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/Issue1078/A.agda",
  "max_line_length": 38,
  "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/Issue1078/A.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": 15,
  "size": 65
} 
 | 
					
	-- This module contains various line-ending characters in order
-- to test that they don't affect module source hash calculation.
module C where
-- CR --
--
-- LF --
--
-- CRLF --
--
-- LFCR --
--
-- FF ----
-- NEXT LINE --
--
-- LINE SEPARATOR --
--
-- PARAGRAPH SEPARATOR --
--
 
 | 
	{
  "alphanum_fraction": 0.593639576,
  "avg_line_length": 18.8666666667,
  "ext": "agda",
  "hexsha": "79a4e988a7126dbc7c50aa5890adccd6c8bdd0c8",
  "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": "examples/uptodate/C.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": "examples/uptodate/C.agda",
  "max_line_length": 65,
  "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": "examples/uptodate/C.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": 80,
  "size": 283
} 
 | 
					
	
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.Unit
module Oscar.Class.SimilaritySingleton where
module SimilaritySingleton
  {𝔞} {𝔄 : Ø 𝔞}
  {𝔟} {𝔅 : Ø 𝔟}
  {𝔣} {𝔉 : Ø 𝔣}
  {𝔞̇ 𝔟̇}
  (∼₁ : Ø 𝔞̇)
  (_∼₂_ : 𝔅 → 𝔅 → Ø 𝔟̇) (let _∼₂_ = _∼₂_; infix 4 _∼₂_)
  (_◃_ : 𝔉 → 𝔄 → 𝔅) (let _◃_ = _◃_; infix 16 _◃_)
  (x y : 𝔄)
  (f : 𝔉)
  = ℭLASS (_◃_ , _∼₂_ , x , y) (∼₁ → f ◃ x ∼₂ f ◃ y)
module _
  {𝔞} {𝔄 : Ø 𝔞}
  {𝔟} {𝔅 : Ø 𝔟}
  {𝔣} {𝔉 : Ø 𝔣}
  {𝔞̇ 𝔟̇}
  {∼₁ : Ø 𝔞̇}
  {_∼₂_ : 𝔅 → 𝔅 → Ø 𝔟̇} (let _∼₂_ = _∼₂_; infix 4 _∼₂_)
  {_◃_ : 𝔉 → 𝔄 → 𝔅} (let _◃_ = _◃_; infix 16 _◃_)
  {x y : 𝔄}
  {f : 𝔉}
  where
  similaritySingleton = SimilaritySingleton.method ∼₁ _∼₂_ _◃_ x y f
  module _ ⦃ _ : SimilaritySingleton.class ∼₁ _∼₂_ _◃_ x y f ⦄ where
    instance
      toUnit : Unit.class (∼₁ → f ◃ x ∼₂ f ◃ y)
      toUnit .⋆ = similaritySingleton
 
 | 
	{
  "alphanum_fraction": 0.5220417633,
  "avg_line_length": 23.9444444444,
  "ext": "agda",
  "hexsha": "a5f0c48973b975d5bea1d546cc42f0427b11fd32",
  "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/Class/SimilaritySingleton.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/Class/SimilaritySingleton.agda",
  "max_line_length": 68,
  "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/Class/SimilaritySingleton.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 499,
  "size": 862
} 
 | 
					
	{-# OPTIONS --without-K --rewriting #-}
open import HoTT
import homotopy.RelativelyConstantToSetExtendsViaSurjection as SurjExt
module homotopy.VanKampen {i j k l}
  (span : Span {i} {j} {k})
  {D : Type l} (h : D → Span.C span) (h-is-surj : is-surj h) where
  open Span span
  open import homotopy.vankampen.CodeAP span h h-is-surj
  open import homotopy.vankampen.CodeBP span h h-is-surj
  open import homotopy.vankampen.Code span h h-is-surj
  -- favonia: [pPP] means path from [P] to [P].
  encode-idp : ∀ p → code p p
  encode-idp = Pushout-elim {P = λ p → code p p}
    (λ a → q[ ⟧a idp₀ ]) (λ b → q[ ⟧b idp₀ ]) lemma where
    abstract
      lemma : ∀ c → q[ ⟧a idp₀ ] == q[ ⟧b idp₀ ] [ (λ p → code p p) ↓ glue c ]
      lemma = SurjExt.ext
        {{↓-preserves-level ⟨⟩}}
        h h-is-surj
        (λ d → from-transp (λ p → code p p) (glue (h d)) $
          transport (λ p → code p p) (glue (h d)) q[ ⟧a idp₀ ]
            =⟨ ap (λ pPP → coe pPP q[ pc-a idp₀ ]) ((! (ap2-diag code (glue (h d)))) ∙ ap2-out code (glue (h d)) (glue (h d))) ⟩
          coe (ap (λ p₀ → code p₀ (left (f (h d)))) (glue (h d)) ∙ ap (codeBP (g (h d))) (glue (h d))) q[ ⟧a idp₀ ]
            =⟨ coe-∙ (ap (λ p₀ → code p₀ (left (f (h d)))) (glue (h d))) (ap (codeBP (g (h d))) (glue (h d))) q[ pc-a idp₀ ] ⟩
          transport (codeBP (g (h d))) (glue (h d)) (transport (λ p₀ → code p₀ (left (f (h d)))) (glue (h d)) q[ ⟧a idp₀ ])
            =⟨ transp-cPA-glue d (⟧a idp₀) |in-ctx transport (λ p₁ → code (right (g (h d))) p₁) (glue (h d)) ⟩
          transport (codeBP (g (h d))) (glue (h d)) q[ ⟧b idp₀ bb⟦ d ⟧a idp₀ ]
            =⟨ transp-cBP-glue d (⟧b idp₀ bb⟦ d ⟧a idp₀) ⟩
          q[ ⟧b idp₀ bb⟦ d ⟧a idp₀ ba⟦ d ⟧b idp₀ ]
            =⟨ quot-rel (pcBBr-idp₀-idp₀ (pc-b idp₀)) ⟩
          q[ ⟧b idp₀ ]
            =∎)
        (λ _ _ _ → prop-has-all-paths-↓ {{↓-level ⟨⟩}})
  encode : ∀ {p₀ p₁} → p₀ =₀ p₁ → code p₀ p₁
  encode {p₀} {p₁} pPP = transport₀ (code p₀) {{code-is-set {p₀} {p₁}}} pPP (encode-idp p₀)
  abstract
    decode-encode-idp : ∀ p → decode {p} {p} (encode-idp p) == idp₀
    decode-encode-idp = Pushout-elim
      {P = λ p → decode {p} {p} (encode-idp p) == idp₀}
      (λ _ → idp) (λ _ → idp)
      (λ c → prop-has-all-paths-↓)
    decode-encode' : ∀ {p₀ p₁} (pPP : p₀ == p₁) → decode {p₀} {p₁} (encode [ pPP ]) == [ pPP ]
    decode-encode' idp = decode-encode-idp _
    decode-encode : ∀ {p₀ p₁} (pPP : p₀ =₀ p₁) → decode {p₀} {p₁} (encode pPP) == pPP
    decode-encode = Trunc-elim decode-encode'
  abstract
    transp-idcAA-r : ∀ {a₀ a₁} (p : a₀ == a₁) -- [idc] = identity code
      → transport (codeAA a₀) p q[ ⟧a idp₀ ] == q[ ⟧a [ p ] ]
    transp-idcAA-r idp = idp
    encode-decodeAA : ∀ {a₀ a₁} (c : precodeAA a₀ a₁)
      → encode (decodeAA q[ c ]) == q[ c ]
    encode-decodeAB : ∀ {a₀ b₁} (c : precodeAB a₀ b₁)
      → encode (decodeAB q[ c ]) == q[ c ]
    encode-decodeAA {a₀} (pc-a pA) = Trunc-elim
      {P = λ pA → encode (decodeAA q[ ⟧a pA ]) == q[ ⟧a pA ]}
      (λ pA →
        transport (codeAP a₀) (ap left pA) q[ ⟧a idp₀ ]
          =⟨ ap (λ e → coe e q[ ⟧a idp₀ ]) (∘-ap (codeAP a₀) left pA) ⟩
        transport (codeAA a₀) pA q[ ⟧a idp₀ ]
          =⟨ transp-idcAA-r pA ⟩
        q[ ⟧a [ pA ] ]
          =∎)
      pA
    encode-decodeAA {a₀} (pc-aba d pc pA) = Trunc-elim
      {P = λ pA → encode (decodeAA q[ pc ab⟦ d ⟧a pA ]) == q[ pc ab⟦ d ⟧a pA ]}
      (λ pA →
        encode (decodeAB q[ pc ] ∙₀' [ ! (glue (h d)) ∙' ap left pA ])
          =⟨ transp₀-∙₀' {{λ {p₁} → code-is-set {left a₀} {p₁}}} (decodeAB q[ pc ]) [ ! (glue (h d)) ∙' ap left pA ] (encode-idp (left a₀)) ⟩
        transport (codeAP a₀) (! (glue (h d)) ∙' ap left pA) (encode (decodeAB q[ pc ]))
          =⟨ ap (transport (codeAP a₀) (! (glue (h d)) ∙' ap left pA)) (encode-decodeAB pc) ⟩
        transport (codeAP a₀) (! (glue (h d)) ∙' ap left pA) q[ pc ]
          =⟨ transp-∙' {B = codeAP a₀} (! (glue (h d))) (ap left pA) q[ pc ] ⟩
        transport (codeAP a₀) (ap left pA) (transport (codeAP a₀) (! (glue (h d))) q[ pc ])
          =⟨ ap (transport (codeAP a₀) (ap left pA)) (transp-cAP-!glue d pc) ⟩
        transport (codeAP a₀) (ap left pA) q[ pc ab⟦ d ⟧a idp₀ ]
          =⟨ ap (λ e → coe e q[ pc ab⟦ d ⟧a idp₀ ]) (∘-ap (codeAP a₀) left pA) ⟩
        transport (codeAA a₀) pA q[ pc ab⟦ d ⟧a idp₀ ]
          =⟨ transp-cAA-r d pA (pc ab⟦ d ⟧a idp₀) ⟩
        q[ pc ab⟦ d ⟧a idp₀ aa⟦ d ⟧b idp₀ ab⟦ d ⟧a [ pA ] ]
          =⟨ quot-rel (pcAAr-cong (pcABr-idp₀-idp₀ pc) [ pA ]) ⟩
        q[ pc ab⟦ d ⟧a [ pA ] ]
          =∎)
      pA
    encode-decodeAB {a₀} (pc-aab d pc pB) = Trunc-elim
      {P = λ pB → encode (decodeAB q[ pc aa⟦ d ⟧b pB ]) == q[ pc aa⟦ d ⟧b pB ]}
      (λ pB →
        encode (decodeAA q[ pc ] ∙₀' [ glue (h d) ∙' ap right pB ])
          =⟨ transp₀-∙₀' {{λ {p₁} → code-is-set {left a₀} {p₁}}} (decodeAA q[ pc ]) [ glue (h d) ∙' ap right pB ] (encode-idp (left a₀)) ⟩
        transport (codeAP a₀) (glue (h d) ∙' ap right pB) (encode (decodeAA q[ pc ]))
          =⟨ ap (transport (codeAP a₀) (glue (h d) ∙' ap right pB)) (encode-decodeAA pc) ⟩
        transport (codeAP a₀) (glue (h d) ∙' ap right pB) q[ pc ]
          =⟨ transp-∙' {B = codeAP a₀} (glue (h d)) (ap right pB) q[ pc ] ⟩
        transport (codeAP a₀) (ap right pB) (transport (codeAP a₀) (glue (h d)) q[ pc ])
          =⟨ ap (transport (codeAP a₀) (ap right pB)) (transp-cAP-glue d pc) ⟩
        transport (codeAP a₀) (ap right pB) q[ pc aa⟦ d ⟧b idp₀ ]
          =⟨ ap (λ e → coe e q[ pc aa⟦ d ⟧b idp₀ ]) (∘-ap (codeAP a₀) right pB) ⟩
        transport (codeAB a₀) pB q[ pc aa⟦ d ⟧b idp₀ ]
          =⟨ transp-cAB-r d pB (pc aa⟦ d ⟧b idp₀) ⟩
        q[ pc aa⟦ d ⟧b idp₀ ab⟦ d ⟧a idp₀ aa⟦ d ⟧b [ pB ] ]
          =⟨ quot-rel (pcABr-cong (pcAAr-idp₀-idp₀ pc) [ pB ]) ⟩
        q[ pc aa⟦ d ⟧b [ pB ] ]
          =∎)
      pB
  abstract
    transp-idcBB-r : ∀ {b₀ b₁} (p : b₀ == b₁) -- [idc] = identity code
      → transport (codeBB b₀) p q[ ⟧b idp₀ ] == q[ ⟧b [ p ] ]
    transp-idcBB-r idp = idp
    encode-decodeBA : ∀ {b₀ a₁} (c : precodeBA b₀ a₁)
      → encode (decodeBA q[ c ]) == q[ c ]
    encode-decodeBB : ∀ {b₀ b₁} (c : precodeBB b₀ b₁)
      → encode (decodeBB q[ c ]) == q[ c ]
    encode-decodeBA {b₀} (pc-bba d pc pA) = Trunc-elim
      {P = λ pA → encode (decodeBA q[ pc bb⟦ d ⟧a pA ]) == q[ pc bb⟦ d ⟧a pA ]}
      (λ pA →
        encode (decodeBB q[ pc ] ∙₀' [ ! (glue (h d)) ∙' ap left pA ])
          =⟨ transp₀-∙₀' {{λ {p₁} → code-is-set {right b₀} {p₁}}} (decodeBB q[ pc ]) [ ! (glue (h d)) ∙' ap left pA ] (encode-idp (right b₀)) ⟩
        transport (codeBP b₀) (! (glue (h d)) ∙' ap left pA) (encode (decodeBB q[ pc ]))
          =⟨ ap (transport (codeBP b₀) (! (glue (h d)) ∙' ap left pA)) (encode-decodeBB pc) ⟩
        transport (codeBP b₀) (! (glue (h d)) ∙' ap left pA) q[ pc ]
          =⟨ transp-∙' {B = codeBP b₀} (! (glue (h d))) (ap left pA) q[ pc ] ⟩
        transport (codeBP b₀) (ap left pA) (transport (codeBP b₀) (! (glue (h d))) q[ pc ])
          =⟨ ap (transport (codeBP b₀) (ap left pA)) (transp-cBP-!glue d pc) ⟩
        transport (codeBP b₀) (ap left pA) q[ pc bb⟦ d ⟧a idp₀ ]
          =⟨ ap (λ e → coe e q[ pc bb⟦ d ⟧a idp₀ ]) (∘-ap (codeBP b₀) left pA) ⟩
        transport (codeBA b₀) pA q[ pc bb⟦ d ⟧a idp₀ ]
          =⟨ transp-cBA-r d pA (pc bb⟦ d ⟧a idp₀) ⟩
        q[ pc bb⟦ d ⟧a idp₀ ba⟦ d ⟧b idp₀ bb⟦ d ⟧a [ pA ] ]
          =⟨ quot-rel (pcBAr-cong (pcBBr-idp₀-idp₀ pc) [ pA ]) ⟩
        q[ pc bb⟦ d ⟧a [ pA ] ]
          =∎)
      pA
    encode-decodeBB {b₀} (pc-b pB) = Trunc-elim
      {P = λ pB → encode (decodeBB q[ ⟧b pB ]) == q[ ⟧b pB ]}
      (λ pB →
        transport (codeBP b₀) (ap right pB) q[ ⟧b idp₀ ]
          =⟨ ap (λ e → coe e q[ ⟧b idp₀ ]) (∘-ap (codeBP b₀) right pB) ⟩
        transport (codeBB b₀) pB q[ ⟧b idp₀ ]
          =⟨ transp-idcBB-r pB ⟩
        q[ ⟧b [ pB ] ]
          =∎)
      pB
    encode-decodeBB {b₀} (pc-bab d pc pB) = Trunc-elim
      {P = λ pB → encode (decodeBB q[ pc ba⟦ d ⟧b pB ]) == q[ pc ba⟦ d ⟧b pB ]}
      (λ pB →
        encode (decodeBA q[ pc ] ∙₀' [ glue (h d) ∙' ap right pB ])
          =⟨ transp₀-∙₀' {{λ {p₁} → code-is-set {right b₀} {p₁}}} (decodeBA q[ pc ]) [ glue (h d) ∙' ap right pB ] (encode-idp (right b₀)) ⟩
        transport (codeBP b₀) (glue (h d) ∙' ap right pB) (encode (decodeBA q[ pc ]))
          =⟨ ap (transport (codeBP b₀) (glue (h d) ∙' ap right pB)) (encode-decodeBA pc) ⟩
        transport (codeBP b₀) (glue (h d) ∙' ap right pB) q[ pc ]
          =⟨ transp-∙' {B = codeBP b₀} (glue (h d)) (ap right pB) q[ pc ] ⟩
        transport (codeBP b₀) (ap right pB) (transport (codeBP b₀) (glue (h d)) q[ pc ])
          =⟨ ap (transport (codeBP b₀) (ap right pB)) (transp-cBP-glue d pc) ⟩
        transport (codeBP b₀) (ap right pB) q[ pc ba⟦ d ⟧b idp₀ ]
          =⟨ ap (λ e → coe e q[ pc ba⟦ d ⟧b idp₀ ]) (∘-ap (codeBP b₀) right pB) ⟩
        transport (codeBB b₀) pB q[ pc ba⟦ d ⟧b idp₀ ]
          =⟨ transp-cBB-r d pB (pc ba⟦ d ⟧b idp₀) ⟩
        q[ pc ba⟦ d ⟧b idp₀ bb⟦ d ⟧a idp₀ ba⟦ d ⟧b [ pB ] ]
          =⟨ quot-rel (pcBBr-cong (pcBAr-idp₀-idp₀ pc) [ pB ]) ⟩
        q[ pc ba⟦ d ⟧b [ pB ] ]
          =∎)
      pB
  abstract
    encode-decode : ∀ {p₀ p₁} (cPP : code p₀ p₁)
      → encode {p₀} {p₁} (decode {p₀} {p₁} cPP) == cPP
    encode-decode {p₀} {p₁} = Pushout-elim
      {P = λ p₀ → ∀ p₁ → (cPP : code p₀ p₁) → encode (decode {p₀} {p₁} cPP) == cPP}
      (λ a₀ → Pushout-elim
        (λ a₁ → SetQuot-elim
          {P = λ cPP → encode (decodeAA cPP) == cPP}
          (encode-decodeAA {a₀} {a₁})
          (λ _ → prop-has-all-paths-↓))
        (λ b₁ → SetQuot-elim
          {P = λ cPP → encode (decodeAB cPP) == cPP}
          (encode-decodeAB {a₀} {b₁})
          (λ _ → prop-has-all-paths-↓))
        (λ _ → prop-has-all-paths-↓))
      (λ b₀ → Pushout-elim
        (λ a₁ → SetQuot-elim
          {P = λ cPP → encode (decodeBA cPP) == cPP}
          (encode-decodeBA {b₀} {a₁})
          (λ _ → prop-has-all-paths-↓))
        (λ b₁ → SetQuot-elim
          {P = λ cPP → encode (decodeBB cPP) == cPP}
          (encode-decodeBB {b₀} {b₁})
          (λ _ → prop-has-all-paths-↓))
        (λ _ → prop-has-all-paths-↓))
      (λ _ → prop-has-all-paths-↓ {{Π-level (λ p₁ → Π-level (λ cPP → has-level-apply (codeBP-is-set {p₁ = p₁}) _ _))}})
      p₀ p₁
  vankampen : ∀ p₀ p₁ → (p₀ =₀ p₁) ≃ code p₀ p₁
  vankampen p₀ p₁ = equiv (encode {p₀} {p₁}) (decode {p₀} {p₁}) (encode-decode {p₀} {p₁}) (decode-encode {p₀} {p₁})
 
 | 
	{
  "alphanum_fraction": 0.4972813126,
  "avg_line_length": 50.8883495146,
  "ext": "agda",
  "hexsha": "aee8c42f499aeac68a4b43f481f251608aea28a8",
  "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/VanKampen.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/VanKampen.agda",
  "max_line_length": 143,
  "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/VanKampen.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 4591,
  "size": 10483
} 
 | 
					
	module evenodd where
mutual
  data Even : Set where
    Z  : Even
    S  : Odd -> Even
  data Odd : Set where
    S' : Even -> Odd 
  
 
 | 
	{
  "alphanum_fraction": 0.5547445255,
  "avg_line_length": 12.4545454545,
  "ext": "agda",
  "hexsha": "2f4d8611d38cf2c388a2b0a08339dec3e55c45e2",
  "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/beyond/evenodd.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/beyond/evenodd.agda",
  "max_line_length": 23,
  "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/beyond/evenodd.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": 44,
  "size": 137
} 
 | 
					
	------------------------------------------------------------------------
-- The Agda standard library
--
-- Predicate lifting for refinement types
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Refinement.Relation.Unary.All where
open import Level
open import Data.Refinement
open import Function.Base
open import Relation.Unary
private
  variable
    a b p q : Level
    A : Set a
    B : Set b
module _ {P : A → Set p} where
  All : (A → Set q) → Refinement A P → Set q
  All P (a , _) = P a
 
 | 
	{
  "alphanum_fraction": 0.4956369983,
  "avg_line_length": 22.0384615385,
  "ext": "agda",
  "hexsha": "4fe994de7ba79b1b5e2c76ffe9298cc5355eacc5",
  "lang": "Agda",
  "max_forks_count": 1,
  "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
  "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
  "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "DreamLinuxer/popl21-artifact",
  "max_forks_repo_path": "agda-stdlib/src/Data/Refinement/Relation/Unary/All.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "DreamLinuxer/popl21-artifact",
  "max_issues_repo_path": "agda-stdlib/src/Data/Refinement/Relation/Unary/All.agda",
  "max_line_length": 72,
  "max_stars_count": 5,
  "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "DreamLinuxer/popl21-artifact",
  "max_stars_repo_path": "agda-stdlib/src/Data/Refinement/Relation/Unary/All.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": 127,
  "size": 573
} 
 | 
					
	{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
   Copyright (c) 2020, 2021, Oracle and/or its affiliates.
   Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import Optics.All
open import LibraBFT.Prelude
open import LibraBFT.Base.Types
open import LibraBFT.Impl.Consensus.Types
open import LibraBFT.Impl.NetworkMsg
open import LibraBFT.Impl.Util.Crypto
open import LibraBFT.Impl.Handle sha256 sha256-cr
open        EpochConfig
open import LibraBFT.Yasm.Base (ℓ+1 0ℓ) EpochConfig epochId authorsN
-- In this module, we instantiate the system model with parameters to
-- model a system using the simple implementation model we have so
-- far, which aims to obey the VotesOnceRule, but not LockedRoundRule
-- yet.  This will evolve as we build out a model of a real
-- implementation.
module LibraBFT.Concrete.System.Parameters where
 ConcSysParms : SystemParameters
 ConcSysParms = mkSysParms
                 NodeId
                 _≟NodeId_
                 EventProcessor
                 fakeEP
                 NetworkMsg
                 Vote
                 sig-Vote
                 _⊂Msg_
                 (_^∙ vEpoch)
                 initialEventProcessorAndMessages
                 peerStepWrapper
 
 | 
	{
  "alphanum_fraction": 0.6867838044,
  "avg_line_length": 36.3611111111,
  "ext": "agda",
  "hexsha": "580c1caf1c0dc1691c654c29770b0a102c6489bb",
  "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": "34e4627855fb198665d0c98f377403a906ba75d7",
  "max_forks_repo_licenses": [
    "UPL-1.0"
  ],
  "max_forks_repo_name": "haroldcarr/bft-consensus-agda",
  "max_forks_repo_path": "LibraBFT/Concrete/System/Parameters.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "UPL-1.0"
  ],
  "max_issues_repo_name": "haroldcarr/bft-consensus-agda",
  "max_issues_repo_path": "LibraBFT/Concrete/System/Parameters.agda",
  "max_line_length": 111,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7",
  "max_stars_repo_licenses": [
    "UPL-1.0"
  ],
  "max_stars_repo_name": "haroldcarr/bft-consensus-agda",
  "max_stars_repo_path": "LibraBFT/Concrete/System/Parameters.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 319,
  "size": 1309
} 
 | 
					
	module Ag11 where
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Data.Nat using (ℕ; zero; suc)
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (_×_)
open import Ag09 using (_≃_; extensionality)
open import Relation.Nullary using (¬_)
open import Relation.Nullary.Negation using (contraposition)
open import Ag03 using (_⟨_)
⟨-irreflexive : ∀ (n : ℕ) → ¬ (n ⟨ n)
⟨-irreflexive (suc n) (_⟨_.s⟨s H) = ⟨-irreflexive n H
⊎-dual-× : ∀ {A B : Set} → ¬ (A ⊎ B) ≃ (¬ A) × (¬ B)
⊎-dual-× =
  record
  { to = λ z → (λ x → z (inj₁ x)) Data.Product., (λ x → z (inj₂ x))
  ; from = λ{ (fst Data.Product., snd) → λ {(inj₁ x) → fst x; (inj₂ y) → snd y} }
  ; from∘to = λ x → extensionality λ { (inj₁ y) → refl ; (inj₂ z) → refl }
  ; to∘from = λ {(fst Data.Product., snd) → refl}
  }
-- ×-dual-⊎ : ∀ {A B : Set} → ¬ (A × B) ≃ (¬ A) ⊎ (¬ B)
-- ×-dual-⊎ =
--  record
--  { to = λ x → inj₁ λ y → {!!} 
--  ; from = λ { (inj₁ x) → λ z → x (Data.Product.proj₁ z) ; (inj₂ y) → λ z → y (Data.Product.proj₂ z)}
--  ; from∘to = {!!}
--  ; to∘from = {!!}
--  }
postulate
  em : ∀ {A : Set} → A ⊎ ¬ A
em-irrefutable : ∀ {A : Set} → ¬ ¬ (A ⊎ ¬ A)
em-irrefutable k = k (inj₂ (λ x → k (inj₁ x)))
postulate
  dne : ∀ {A : Set} → ¬ ¬ A → A
em-dne : ∀ {A : Set} → (A ⊎ ¬ A) → (¬ ¬ A → A)
em-dne (inj₁ x) ¬¬A = x
em-dne (inj₂ y) ¬¬A = ⊥-elim (¬¬A y)
dne-em : (∀ (A : Set) → ¬ ¬ A → A) → (∀ (A : Set) → A ⊎ ¬ A)
dne-em H = λ a → H (a ⊎ ((x : a) → ⊥)) (λ z → z (inj₂ (λ x → z (inj₁ x))))
 
 | 
	{
  "alphanum_fraction": 0.5163147793,
  "avg_line_length": 31.8979591837,
  "ext": "agda",
  "hexsha": "45499d732eb383dcb54da30daacda49cff6ce719",
  "lang": "Agda",
  "max_forks_count": 1,
  "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z",
  "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z",
  "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "Brethland/LEARNING-STUFF",
  "max_forks_repo_path": "Agda/Ag11.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
  "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": "Brethland/LEARNING-STUFF",
  "max_issues_repo_path": "Agda/Ag11.agda",
  "max_line_length": 103,
  "max_stars_count": 2,
  "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "Brethland/LEARNING-STUFF",
  "max_stars_repo_path": "Agda/Ag11.agda",
  "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z",
  "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z",
  "num_tokens": 694,
  "size": 1563
} 
 | 
					
	-- Andreas, Jesper, 2015-07-02 Error in copyScope
{-# OPTIONS -v tc.decl:5 #-} -- KEEP, this forced Agda to look at A.Decls and loop
-- To trigger the bug, it is important that
-- the main module is in a subdirectory of the imported module.
module Issue1597.Main2 where
open import Issue1597   -- external import is needed
module B where
  open A public  -- public is needed
module C = B
  -- hanged when trying to print the Syntax.Abstract.Declarations
 
 | 
	{
  "alphanum_fraction": 0.7298474946,
  "avg_line_length": 28.6875,
  "ext": "agda",
  "hexsha": "4353bda76d0c98c3b10ed4cc70c570e46ef5e439",
  "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/Issue1597/Main2.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/Issue1597/Main2.agda",
  "max_line_length": 82,
  "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/Issue1597/Main2.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": 123,
  "size": 459
} 
 | 
					
	------------------------------------------------------------------------
-- Aczel's structure identity principle (for 1-categories), more or
-- less as found in "Homotopy Type Theory: Univalent Foundations of
-- Mathematics" (first edition)
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Equality
module Structure-identity-principle
  {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open import Bijection eq using (_↔_; Σ-≡,≡↔≡)
open import Category eq
open Derived-definitions-and-properties eq
open import Equality.Decidable-UIP eq
open import Equivalence eq hiding (id; _∘_; inverse; lift-equality)
open import Function-universe eq hiding (id) renaming (_∘_ to _⊚_)
open import H-level eq
open import H-level.Closure eq
open import Logical-equivalence using (_⇔_)
open import Prelude hiding (id)
-- Standard notions of structure.
record Standard-notion-of-structure
         {c₁ c₂} ℓ₁ ℓ₂ (C : Precategory c₁ c₂) :
         Type (c₁ ⊔ c₂ ⊔ lsuc (ℓ₁ ⊔ ℓ₂)) where
  open Precategory C
  field
    P               : Obj → Type ℓ₁
    H               : ∀ {X Y} (p : P X) (q : P Y) → Hom X Y → Type ℓ₂
    H-prop          : ∀ {X Y} {p : P X} {q : P Y}
                      (f : Hom X Y) → Is-proposition (H p q f)
    H-id            : ∀ {X} {p : P X} → H p p id
    H-∘             : ∀ {X Y Z} {p : P X} {q : P Y} {r : P Z} {f g} →
                      H p q f → H q r g → H p r (g ∙ f)
    H-antisymmetric : ∀ {X} (p q : P X) →
                      H p q id → H q p id → p ≡ q
  -- P constructs sets. (The proof was suggested by Michael Shulman in
  -- a mailing list post.)
  P-set : ∀ A → Is-set (P A)
  P-set A = propositional-identity⇒set
    (λ p q → H p q id × H q p id)
    (λ _ _ → ×-closure 1 (H-prop id) (H-prop id))
    (λ _ → H-id , H-id)
    (λ p q → uncurry (H-antisymmetric p q))
  -- Two Str morphisms (see below) of equal type are equal if their
  -- first components are equal.
  lift-equality : {X Y : ∃ P} {f g : ∃ (H (proj₂ X) (proj₂ Y))} →
                  proj₁ f ≡ proj₁ g → f ≡ g
  lift-equality eq = Σ-≡,≡→≡ eq (H-prop _ _ _)
  -- A derived precategory.
  Str : Precategory (c₁ ⊔ ℓ₁) (c₂ ⊔ ℓ₂)
  Str = record { precategory =
    ∃ P ,
    (λ { (X , p) (Y , q) →
         ∃ (H p q) ,
         Σ-closure 2 Hom-is-set (λ f → mono₁ 1 (H-prop f)) }) ,
    (id , H-id) ,
    (λ { (f , hf) (g , hg) → f ∙ g , H-∘ hg hf }) ,
    lift-equality left-identity ,
    lift-equality right-identity ,
    lift-equality assoc }
  module Str = Precategory Str
  -- A rearrangement lemma.
  proj₁-≡→≅-¹ :
    ∀ {X Y} (X≡Y : X ≡ Y) →
    proj₁ (Str.≡→≅ X≡Y Str.¹) ≡
    elim (λ {X Y} _ → Hom X Y) (λ _ → id) (cong proj₁ X≡Y)
  proj₁-≡→≅-¹ {X , p} = elim¹
    (λ X≡Y → proj₁ (Str.≡→≅ X≡Y Str.¹) ≡
             elim (λ {X Y} _ → Hom X Y) (λ _ → id) (cong proj₁ X≡Y))
    (proj₁ (Str.≡→≅ (refl (X , p)) Str.¹)                               ≡⟨ cong (proj₁ ∘ Str._¹) $ elim-refl (λ {X Y} _ → X Str.≅ Y) _ ⟩
     proj₁ (Str.id {X = X , p})                                         ≡⟨⟩
     id {X = X}                                                         ≡⟨ sym $ elim-refl (λ {X Y} _ → Hom X Y) _ ⟩
     elim (λ {X Y} _ → Hom X Y) (λ _ → id) (refl X)                     ≡⟨ cong (elim (λ {X Y} _ → Hom X Y) _) $ sym $ cong-refl proj₁ ⟩∎
     elim (λ {X Y} _ → Hom X Y) (λ _ → id) (cong proj₁ (refl (X , p)))  ∎)
-- The structure identity principle states that the precategory Str is
-- a category (assuming extensionality).
--
-- The proof below is based on (but not quite identical to) the one in
-- "Homotopy Type Theory: Univalent Foundations of Mathematics" (first
-- edition).
abstract
  structure-identity-principle :
    ∀ {c₁ c₂ ℓ₁ ℓ₂} →
    Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) →
    (C : Category c₁ c₂) →
    (S : Standard-notion-of-structure ℓ₁ ℓ₂ (Category.precategory C)) →
    ∀ {X Y} → Is-equivalence
                (Precategory.≡→≅ (Standard-notion-of-structure.Str S)
                                 {X} {Y})
  structure-identity-principle ext C S =
    Str.≡→≅-equivalence-lemma ≡≃≅ ≡≃≅-refl
    where
    open Standard-notion-of-structure S
    module C = Category C
    -- _≡_ is pointwise equivalent to Str._≅_.
    module ≅HH≃≅ where
      to : ∀ {X Y} {p : P X} {q : P Y} →
           (∃ λ (f : X C.≅ Y) → H p q (f C.¹) × H q p (f C.⁻¹)) →
           (X , p) Str.≅ (Y , q)
      to ((f , f⁻¹ , f∙f⁻¹ , f⁻¹∙f) , Hf , Hf⁻¹) =
        (f , Hf) , (f⁻¹ , Hf⁻¹) ,
        lift-equality f∙f⁻¹ ,
        lift-equality f⁻¹∙f
    ≅HH≃≅ : ∀ {X Y} {p : P X} {q : P Y} →
            (∃ λ (f : X C.≅ Y) → H p q (f C.¹) × H q p (f C.⁻¹)) ≃
            ((X , p) Str.≅ (Y , q))
    ≅HH≃≅ {X} {Y} {p} {q} = ↔⇒≃ (record
      { surjection = record
        { logical-equivalence = record
          { to   = ≅HH≃≅.to
          ; from = from
          }
        ; right-inverse-of = to∘from
        }
      ; left-inverse-of = from∘to
      })
      where
      from : (X , p) Str.≅ (Y , q) →
             ∃ λ (f : X C.≅ Y) → H p q (f C.¹) × H q p (f C.⁻¹)
      from ((f , Hf) , (f⁻¹ , Hf⁻¹) , f∙f⁻¹ , f⁻¹∙f) =
        (f , f⁻¹ , cong proj₁ f∙f⁻¹ , cong proj₁ f⁻¹∙f) , Hf , Hf⁻¹
      to∘from : ∀ p → ≅HH≃≅.to (from p) ≡ p
      to∘from ((f , Hf) , (f⁻¹ , Hf⁻¹) , f∙f⁻¹ , f⁻¹∙f) =
        cong₂ (λ f∙f⁻¹ f⁻¹∙f →
                 (f , Hf) , (f⁻¹ , Hf⁻¹) , f∙f⁻¹ , f⁻¹∙f)
              (Str.Hom-is-set _ _)
              (Str.Hom-is-set _ _)
      from∘to : ∀ p → from (≅HH≃≅.to p) ≡ p
      from∘to ((f , f⁻¹ , f∙f⁻¹ , f⁻¹∙f) , Hf , Hf⁻¹) =
        cong₂ (λ f∙f⁻¹ f⁻¹∙f → (f , f⁻¹ , f∙f⁻¹ , f⁻¹∙f) , Hf , Hf⁻¹)
              (C.Hom-is-set _ _)
              (C.Hom-is-set _ _)
    module ≡≡≃≅HH where
      to : ∀ {X Y} {p : P X} {q : P Y} →
           (X≡Y : X ≡ Y) → subst P X≡Y p ≡ q →
           H p q (C.≡→≅ X≡Y C.¹) × H q p (C.≡→≅ X≡Y C.⁻¹)
      to {X} {p = p} X≡Y p≡q = elim¹
        (λ X≡Y → ∀ {q} → subst P X≡Y p ≡ q →
                 H p q (C.≡→≅ X≡Y C.¹) × H q p (C.≡→≅ X≡Y C.⁻¹))
        (elim¹
           (λ {q} _ → H p q (C.≡→≅ (refl X) C.¹) ×
                      H q p (C.≡→≅ (refl X) C.⁻¹))
           ( subst (λ { (q , f) → H p q f })
                   (sym $ cong₂ _,_
                            (subst P (refl X) p  ≡⟨ subst-refl P _ ⟩∎
                             p                   ∎)
                            (C.≡→≅ (refl X) C.¹  ≡⟨ cong C._¹ C.≡→≅-refl ⟩∎
                             C.id                ∎))
                   H-id
           , subst (λ { (q , f) → H q p f })
                   (sym $ cong₂ _,_
                            (subst P (refl X) p  ≡⟨ subst-refl P _ ⟩∎
                             p                   ∎)
                            (C.≡→≅ (refl X) C.⁻¹  ≡⟨ cong C._⁻¹ C.≡→≅-refl ⟩∎
                             C.id                 ∎))
                   H-id
           ))
        X≡Y p≡q
      to-refl : ∀ {X} {p : P X} →
                subst (λ f → H p p (f C.¹) × H p p (f C.⁻¹))
                      C.≡→≅-refl
                      (to (refl X) (subst-refl P p)) ≡
                (H-id , H-id)
      to-refl = cong₂ _,_ (H-prop _ _ _) (H-prop _ _ _)
    ≡≡≃≅HH : ∀ {X Y} {p : P X} {q : P Y} →
             (∃ λ (eq : X ≡ Y) → subst P eq p ≡ q) ≃
             (∃ λ (f : X C.≅ Y) → H p q (f C.¹) × H q p (f C.⁻¹))
    ≡≡≃≅HH {X} {p = p} {q} =
      Σ-preserves C.≡≃≅ λ X≡Y →
        _↔_.to (⇔↔≃ ext (P-set _) (×-closure 1 (H-prop _) (H-prop _)))
               (record { to = ≡≡≃≅HH.to X≡Y ; from = from X≡Y })
      where
      from : ∀ X≡Y → H p q (C.≡→≅ X≡Y C.¹) × H q p (C.≡→≅ X≡Y C.⁻¹) →
             subst P X≡Y p ≡ q
      from X≡Y (H¹ , H⁻¹) = elim¹
        (λ {Y} X≡Y → ∀ {q} →
                     H p q (C.≡→≅ X≡Y C.¹) → H q p (C.≡→≅ X≡Y C.⁻¹) →
                     subst P X≡Y p ≡ q)
        (λ {q} H¹ H⁻¹ →
           subst P (refl X) p  ≡⟨ subst-refl P _ ⟩
           p                   ≡⟨ H-antisymmetric p q
                                    (subst (H p q) (cong C._¹  C.≡→≅-refl) H¹)
                                    (subst (H q p) (cong C._⁻¹ C.≡→≅-refl) H⁻¹) ⟩∎
           q                   ∎)
        X≡Y H¹ H⁻¹
    ≡≃≅ : ∀ {X Y} {p : P X} {q : P Y} →
          _≡_ {A = ∃ P} (X , p) (Y , q) ≃ ((X , p) Str.≅ (Y , q))
    ≡≃≅ = ≅HH≃≅ ⊚ ≡≡≃≅HH ⊚ ↔⇒≃ (inverse Σ-≡,≡↔≡)
    -- …and the proof maps reflexivity to the identity morphism.
    ≡≃≅-refl : ∀ {Xp} → _≃_.to ≡≃≅ (refl Xp) Str.¹ ≡ Str.id
    ≡≃≅-refl {X , p} = cong Str._¹ (
      ≅HH≃≅.to (_≃_.to ≡≡≃≅HH (Σ-≡,≡←≡ (refl (_,_ {B = P} X p))))      ≡⟨ cong (≅HH≃≅.to ∘ _≃_.to ≡≡≃≅HH) $ Σ-≡,≡←≡-refl {B = P} ⟩
      ≅HH≃≅.to (_≃_.to ≡≡≃≅HH (refl X , subst-refl P p))               ≡⟨⟩
      ≅HH≃≅.to (C.≡→≅ (refl X) , ≡≡≃≅HH.to (refl X) (subst-refl P p))  ≡⟨ cong ≅HH≃≅.to $ Σ-≡,≡→≡ C.≡→≅-refl ≡≡≃≅HH.to-refl ⟩
      ≅HH≃≅.to (C.id≅ , H-id , H-id)                                   ≡⟨ refl _ ⟩∎
      Str.id≅                                                          ∎)
 
 | 
	{
  "alphanum_fraction": 0.4028150134,
  "avg_line_length": 39.2631578947,
  "ext": "agda",
  "hexsha": "38f2e464a66d2a02a7e2bad8fb52b6971cb68246",
  "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/Structure-identity-principle.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/Structure-identity-principle.agda",
  "max_line_length": 137,
  "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/Structure-identity-principle.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": 3809,
  "size": 8952
} 
 | 
					
	module container.m.core where
open import level
open import sum
open import equality.core
open import equality.calculus
open import function.core
open import function.isomorphism
open import function.extensionality
open import container.core
open import container.equality
open import container.fixpoint
infix 1000 ♯_
postulate
  ∞  : ∀ {a} (A : Set a) → Set a
  ♯_ : ∀ {a} {A : Set a} → A → ∞ A
  ♭  : ∀ {a} {A : Set a} → ∞ A → A
{-# BUILTIN INFINITY ∞  #-}
{-# BUILTIN SHARP    ♯_ #-}
{-# BUILTIN FLAT     ♭  #-}
module Definition {li la lb}(c : Container li la lb) where
  open Container c public
  -- definition of indexed M-types using native Agda coinduction
  data M (i : I) : Set (la ⊔ lb) where
    inf : (a : A i) → ((b : B a) → ∞ (M (r b))) → M i
  -- the terminal coalgebra
  out : M →ⁱ F M
  out i (inf a f) = a , ♭ ∘' f
  -- normally, the constructor can be defined in terms of out and unfold, but
  -- Agda provides it natively, together with a definitional β rule
  inM' : F M →ⁱ M
  inM' i (a , f) = inf a (λ x → ♯ (f x))
  inM'-β : {i : I}(x : F M i) → out i (inM' i x) ≡ x
  inM'-β x = refl
  module Elim {lx}{X : I → Set lx}
              (α : X →ⁱ F X) where
    -- anamorphisms
    unfold : X →ⁱ M
    unfold i x = inf a f
      where
        u : F X i
        u = α i x
        a : A i
        a = proj₁ u
        f : (b : B a) → ∞ (M (r b))
        f b = ♯ unfold (r b) (proj₂ u b)
    -- computational rule for anamorphisms
    -- this holds definitionally
    unfold-β : {i : I}(x : X i)
             → out i (unfold i x) ≡ imap unfold i (α i x)
    unfold-β x = refl
    -- the corresponding η rule doesn't hold, so we postulate it
    postulate
      unfold-η : (h : X →ⁱ M)
               → (∀ {i} (x : X i) → out i (h i x) ≡ imap h i (α i x))
               → ∀ {i} (x : X i) → h i x ≡ unfold i x
  open Elim public
  -- using η, we can prove that the unfolding of out is the identity
  unfold-id : ∀ {i} (x : M i) → unfold out i x ≡ x
  unfold-id x = sym (unfold-η out idⁱ (λ _ → refl) x)
  -- the usual definition of the constructor
  inM : F M →ⁱ M
  inM = unfold (imap out)
  -- the constructor is the inverse of the destructor
  inM-η : ∀ {i} (x : M i) → inM i (out i x) ≡ x
  inM-η x = unfold-η out (inM ∘ⁱ out) (λ _ → refl) x · unfold-id x
  inM-β : ∀ {i} (x : F M i) → out i (inM i x) ≡ x
  inM-β {i} x = ap u (funext (λ i → funext inM-η))
    where
      u : (M →ⁱ M) → F M i
      u h = imap h i x
  fixpoint : ∀ i → M i ≅ F M i
  fixpoint i = iso (out i) (inM i) inM-η inM-β
  -- now we can prove that the constructor provided by Agda is equal to the
  -- usual one
  inM-alt : ∀ {i} (x : F M i) → inM' i x ≡ inM i x
  inM-alt {i} x = sym (inM-η (inM' i x))
 
 | 
	{
  "alphanum_fraction": 0.5502022803,
  "avg_line_length": 28.0309278351,
  "ext": "agda",
  "hexsha": "8efc7279cabdfa5a7ecf629b61a9948897fae628",
  "lang": "Agda",
  "max_forks_count": 4,
  "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z",
  "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z",
  "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
  "max_forks_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_forks_repo_name": "HoTT/M-types",
  "max_forks_repo_path": "container/m/core.agda",
  "max_issues_count": 2,
  "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
  "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z",
  "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z",
  "max_issues_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_issues_repo_name": "HoTT/M-types",
  "max_issues_repo_path": "container/m/core.agda",
  "max_line_length": 77,
  "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": "container/m/core.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": 1020,
  "size": 2719
} 
 | 
					
	{-# OPTIONS --without-K --safe #-}
open import Level
record Category (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where
  eta-equality
  infix  4 _≈_ _⇒_
  infixr 9 _∘_
  field
    Obj : Set o
    _⇒_ : Obj → Obj → Set ℓ
    _≈_ : ∀ {A B} → (A ⇒ B) → (A ⇒ B) → Set e
    _∘_ : ∀ {A B C} → (B ⇒ C) → (A ⇒ B) → (A ⇒ C)
  CommutativeSquare : ∀ {A B C D} → (f : A ⇒ B) (g : A ⇒ C) (h : B ⇒ D) (i : C ⇒ D) → Set _
  CommutativeSquare f g h i = h ∘ f ≈ i ∘ g
infix 10  _[_,_]
_[_,_] : ∀ {o ℓ e} → (C : Category o ℓ e) → (X : Category.Obj C) → (Y : Category.Obj C) → Set ℓ
_[_,_] = Category._⇒_
module Inner {x₁ x₂ x₃} (CC : Category x₁ x₂ x₃) where
  open import Level
  private
    variable
      o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ : Level
  open import Data.Product using (_×_; Σ; _,_; curry′; proj₁; proj₂; zip; map; <_,_>; swap)
  zipWith : ∀ {a b c p q r s} {A : Set a} {B : Set b} {C : Set c} {P : A → Set p} {Q : B → Set q} {R : C → Set r} {S : (x : C) → R x → Set s} (_∙_ : A → B → C) → (_∘_ : ∀ {x y} → P x → Q y → R (x ∙ y)) → (_*_ : (x : C) → (y : R x) → S x y) → (x : Σ A P) → (y : Σ B Q) → S (proj₁ x ∙ proj₁ y) (proj₂ x ∘ proj₂ y)
  zipWith _∙_ _∘_ _*_ (a , p) (b , q) = (a ∙ b) * (p ∘ q)
  syntax zipWith f g h = f -< h >- g
  record Functor (C : Category o ℓ e) (D : Category o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
    eta-equality
    private module C = Category C
    private module D = Category D
    field
      F₀ : C.Obj → D.Obj
      F₁ : ∀ {A B} (f : C [ A , B ]) → D [ F₀ A , F₀ B ]
  Product : (C : Category o ℓ e) (D : Category o′ ℓ′ e′) → Category (o ⊔ o′) (ℓ ⊔ ℓ′) (e ⊔ e′)
  Product C D = record
    { Obj       = C.Obj × D.Obj
    ; _⇒_       = C._⇒_ -< _×_ >- D._⇒_
    ; _≈_       = C._≈_ -< _×_ >- D._≈_
    ; _∘_       = zip C._∘_ D._∘_
    }
    where module C = Category C
          module D = Category D
  Bifunctor : Category o ℓ e → Category o′ ℓ′ e′ → Category o″ ℓ″ e″ → Set _
  Bifunctor C D E = Functor (Product C D) E
  private
    module CC = Category CC
  open CC
  infix 4 _≅_
  record _≅_ (A B : Obj) : Set (x₂) where
    field
      from : A ⇒ B
      to   : B ⇒ A
  private
    variable
      X Y Z W : Obj
      f g h : X ⇒ Y
  record Monoidal : Set (x₁ ⊔ x₂ ⊔ x₃) where
    infixr 10 _⊗₀_ _⊗₁_
    field
      ⊗  : Bifunctor CC CC CC
    module ⊗ = Functor ⊗
    open Functor ⊗
    _⊗₀_ : Obj → Obj → Obj
    _⊗₀_ = curry′ F₀
    -- this is also 'curry', but a very-dependent version
    _⊗₁_ : X ⇒ Y → Z ⇒ W → X ⊗₀ Z ⇒ Y ⊗₀ W
    f ⊗₁ g = F₁ (f , g)
    field
      associator : (X ⊗₀ Y) ⊗₀ Z ≅ X ⊗₀ (Y ⊗₀ Z)
    module associator {X} {Y} {Z} = _≅_ (associator {X} {Y} {Z})
    -- for exporting, it makes sense to use the above long names, but for
    -- internal consumption, the traditional (short!) categorical names are more
    -- convenient. However, they are not symmetric, even though the concepts are, so
    -- we'll use ⇒ and ⇐ arrows to indicate that
    private
      α⇒ = associator.from
      α⇐ = λ {X} {Y} {Z} → associator.to {X} {Y} {Z}
    field
      assoc-commute-from   : CommutativeSquare ((f ⊗₁ g) ⊗₁ h) α⇒ α⇒ (f ⊗₁ (g ⊗₁ h))
      assoc-commute-to     : CommutativeSquare (f ⊗₁ (g ⊗₁ h)) α⇐ α⇐ ((f ⊗₁ g) ⊗₁ h)
 
 | 
	{
  "alphanum_fraction": 0.498128509,
  "avg_line_length": 29.4128440367,
  "ext": "agda",
  "hexsha": "18e948affb321af2fda685b7f446991e06a725a6",
  "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": "7f58030124fa99dfbf8db376659416f3ad8384de",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "cruhland/agda",
  "max_forks_repo_path": "test/LibSucceed/Issue4312.agda",
  "max_issues_count": 3,
  "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
  "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": [
    "MIT"
  ],
  "max_issues_repo_name": "cruhland/agda",
  "max_issues_repo_path": "test/LibSucceed/Issue4312.agda",
  "max_line_length": 311,
  "max_stars_count": 1,
  "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "cruhland/agda",
  "max_stars_repo_path": "test/LibSucceed/Issue4312.agda",
  "max_stars_repo_stars_event_max_datetime": "2016-05-20T13:58:52.000Z",
  "max_stars_repo_stars_event_min_datetime": "2016-05-20T13:58:52.000Z",
  "num_tokens": 1401,
  "size": 3206
} 
 | 
					
	------------------------------------------------------------------------
-- The Agda standard library
--
-- Containers, based on the work of Abbott and others
------------------------------------------------------------------------
module Data.Container where
open import Data.M
open import Data.Product as Prod hiding (map)
open import Data.W
open import Function renaming (id to ⟨id⟩; _∘_ to _⟨∘⟩_)
open import Function.Equality using (_⟨$⟩_)
open import Function.Inverse using (_↔_; module Inverse)
import Function.Related as Related
open import Level
open import Relation.Binary
  using (Setoid; module Setoid; Preorder; module Preorder)
open import Relation.Binary.PropositionalEquality as P
  using (_≡_; _≗_; refl)
open import Relation.Unary using (_⊆_)
------------------------------------------------------------------------
-- Containers
-- A container is a set of shapes, and for every shape a set of
-- positions.
infix 5 _▷_
record Container (ℓ : Level) : Set (suc ℓ) where
  constructor _▷_
  field
    Shape    : Set ℓ
    Position : Shape → Set ℓ
open Container public
-- The semantics ("extension") of a container.
⟦_⟧ : ∀ {ℓ} → Container ℓ → Set ℓ → Set ℓ
⟦ C ⟧ X = Σ[ s ∈ Shape C ] (Position C s → X)
-- The least and greatest fixpoints of a container.
μ : ∀ {ℓ} → Container ℓ → Set ℓ
μ C = W (Shape C) (Position C)
ν : ∀ {ℓ} → Container ℓ → Set ℓ
ν C = M (Shape C) (Position C)
-- Equality, parametrised on an underlying relation.
Eq : ∀ {c ℓ} {C : Container c} {X Y : Set c} →
     (X → Y → Set ℓ) → ⟦ C ⟧ X → ⟦ C ⟧ Y → Set (c ⊔ ℓ)
Eq {C = C} _≈_ (s , f) (s′ , f′) =
  Σ[ eq ∈ s ≡ s′ ] (∀ p → f p ≈ f′ (P.subst (Position C) eq p))
private
  -- Note that, if propositional equality were extensional, then
  -- Eq _≡_ and _≡_ would coincide.
  Eq⇒≡ : ∀ {c} {C : Container c} {X : Set c} {xs ys : ⟦ C ⟧ X} →
         P.Extensionality c c → Eq _≡_ xs ys → xs ≡ ys
  Eq⇒≡ {xs = s , f} {ys = .s , f′} ext (refl , f≈f′) =
    P.cong (_,_ s) (ext f≈f′)
setoid : ∀ {ℓ} → Container ℓ → Setoid ℓ ℓ → Setoid ℓ ℓ
setoid C X = record
  { Carrier       = ⟦ C ⟧ X.Carrier
  ; _≈_           = _≈_
  ; isEquivalence = record
    { refl  = (refl , λ _ → X.refl)
    ; sym   = sym
    ; trans = λ {_ _ zs} → trans zs
    }
  }
  where
  module X = Setoid X
  _≈_ = Eq X._≈_
  sym : {xs ys : ⟦ C ⟧ X.Carrier} → xs ≈ ys → ys ≈ xs
  sym {_ , _} {._ , _} (refl , f) = (refl , X.sym ⟨∘⟩ f)
  trans : ∀ {xs ys : ⟦ C ⟧ X.Carrier} zs → xs ≈ ys → ys ≈ zs → xs ≈ zs
  trans {_ , _} {._ , _} (._ , _) (refl , f₁) (refl , f₂) =
    (refl , λ p → X.trans (f₁ p) (f₂ p))
------------------------------------------------------------------------
-- Functoriality
-- Containers are functors.
map : ∀ {c} {C : Container c} {X Y} → (X → Y) → ⟦ C ⟧ X → ⟦ C ⟧ Y
map f = Prod.map ⟨id⟩ (λ g → f ⟨∘⟩ g)
module Map where
  identity : ∀ {c} {C : Container c} X →
             let module X = Setoid X in
             (xs : ⟦ C ⟧ X.Carrier) → Eq X._≈_ (map ⟨id⟩ xs) xs
  identity {C = C} X xs = Setoid.refl (setoid C X)
  composition : ∀ {c} {C : Container c} {X Y : Set c} Z →
                let module Z = Setoid Z in
                (f : Y → Z.Carrier) (g : X → Y) (xs : ⟦ C ⟧ X) →
                Eq Z._≈_ (map f (map g xs)) (map (f ⟨∘⟩ g) xs)
  composition {C = C} Z f g xs = Setoid.refl (setoid C Z)
------------------------------------------------------------------------
-- Container morphisms
-- Representation of container morphisms.
record _⇒_ {c} (C₁ C₂ : Container c) : Set c where
  field
    shape    : Shape C₁ → Shape C₂
    position : ∀ {s} → Position C₂ (shape s) → Position C₁ s
open _⇒_ public
-- Interpretation of _⇒_.
⟪_⟫ : ∀ {c} {C₁ C₂ : Container c} →
      C₁ ⇒ C₂ → ∀ {X} → ⟦ C₁ ⟧ X → ⟦ C₂ ⟧ X
⟪ m ⟫ xs = (shape m (proj₁ xs) , proj₂ xs ⟨∘⟩ position m)
module Morphism where
  -- Naturality.
  Natural : ∀ {c} {C₁ C₂ : Container c} →
            (∀ {X} → ⟦ C₁ ⟧ X → ⟦ C₂ ⟧ X) → Set (suc c)
  Natural {c} {C₁} m =
    ∀ {X} (Y : Setoid c c) → let module Y = Setoid Y in
    (f : X → Y.Carrier) (xs : ⟦ C₁ ⟧ X) →
    Eq Y._≈_ (m $ map f xs) (map f $ m xs)
  -- Natural transformations.
  NT : ∀ {c} (C₁ C₂ : Container c) → Set (suc c)
  NT C₁ C₂ = ∃ λ (m : ∀ {X} → ⟦ C₁ ⟧ X → ⟦ C₂ ⟧ X) → Natural m
  -- Container morphisms are natural.
  natural : ∀ {c} {C₁ C₂ : Container c}
            (m : C₁ ⇒ C₂) → Natural ⟪ m ⟫
  natural {C₂ = C₂} m Y f xs = Setoid.refl (setoid C₂ Y)
  -- In fact, all natural functions of the right type are container
  -- morphisms.
  complete : ∀ {c} {C₁ C₂ : Container c} →
             (nt : NT C₁ C₂) →
             ∃ λ m → (X : Setoid c c) →
                     let module X = Setoid X in
                     (xs : ⟦ C₁ ⟧ X.Carrier) →
                     Eq X._≈_ (proj₁ nt xs) (⟪ m ⟫ xs)
  complete (nt , nat) =
    (m , λ X xs → nat X (proj₂ xs) (proj₁ xs , ⟨id⟩))
    where
    m = record { shape    = λ  s  → proj₁ (nt (s , ⟨id⟩))
               ; position = λ {s} → proj₂ (nt (s , ⟨id⟩))
               }
  -- Identity.
  id : ∀ {c} (C : Container c) → C ⇒ C
  id _ = record {shape = ⟨id⟩; position = ⟨id⟩}
  -- Composition.
  infixr 9 _∘_
  _∘_ : ∀ {c} {C₁ C₂ C₃ : Container c} → C₂ ⇒ C₃ → C₁ ⇒ C₂ → C₁ ⇒ C₃
  f ∘ g = record
    { shape    = shape    f ⟨∘⟩ shape    g
    ; position = position g ⟨∘⟩ position f
    }
  -- Identity and composition commute with ⟪_⟫.
  id-correct : ∀ {c} {C : Container c} {X : Set c} →
               ⟪ id C ⟫ {X} ≗ ⟨id⟩
  id-correct xs = refl
  ∘-correct : ∀ {c} {C₁ C₂ C₃ : Container c}
              (f : C₂ ⇒ C₃) (g : C₁ ⇒ C₂) {X : Set c} →
              ⟪ f ∘ g ⟫ {X} ≗ (⟪ f ⟫ ⟨∘⟩ ⟪ g ⟫)
  ∘-correct f g xs = refl
------------------------------------------------------------------------
-- Linear container morphisms
record _⊸_ {c} (C₁ C₂ : Container c) : Set c where
  field
    shape⊸    : Shape C₁ → Shape C₂
    position⊸ : ∀ {s} → Position C₂ (shape⊸ s) ↔ Position C₁ s
  morphism : C₁ ⇒ C₂
  morphism = record
    { shape    = shape⊸
    ; position = _⟨$⟩_ (Inverse.to position⊸)
    }
  ⟪_⟫⊸ : ∀ {X} → ⟦ C₁ ⟧ X → ⟦ C₂ ⟧ X
  ⟪_⟫⊸ = ⟪ morphism ⟫
open _⊸_ public using (shape⊸; position⊸; ⟪_⟫⊸)
------------------------------------------------------------------------
-- All and any
-- All.
□ : ∀ {c} {C : Container c} {X : Set c} →
    (X → Set c) → (⟦ C ⟧ X → Set c)
□ P (s , f) = ∀ p → P (f p)
□-map : ∀ {c} {C : Container c} {X : Set c} {P Q : X → Set c} →
        P ⊆ Q → □ {C = C} P ⊆ □ Q
□-map P⊆Q = _⟨∘⟩_ P⊆Q
-- Any.
◇ : ∀ {c} {C : Container c} {X : Set c} →
    (X → Set c) → (⟦ C ⟧ X → Set c)
◇ P (s , f) = ∃ λ p → P (f p)
◇-map : ∀ {c} {C : Container c} {X : Set c} {P Q : X → Set c} →
        P ⊆ Q → ◇ {C = C} P ⊆ ◇ Q
◇-map P⊆Q = Prod.map ⟨id⟩ P⊆Q
-- Membership.
infix 4 _∈_
_∈_ : ∀ {c} {C : Container c} {X : Set c} →
      X → ⟦ C ⟧ X → Set c
x ∈ xs = ◇ (_≡_ x) xs
-- Bag and set equality and related preorders. Two containers xs and
-- ys are equal when viewed as sets if, whenever x ∈ xs, we also have
-- x ∈ ys, and vice versa. They are equal when viewed as bags if,
-- additionally, the sets x ∈ xs and x ∈ ys have the same size.
open Related public
  using (Kind; Symmetric-kind)
  renaming ( implication         to subset
           ; reverse-implication to superset
           ; equivalence         to set
           ; injection           to subbag
           ; reverse-injection   to superbag
           ; bijection           to bag
           )
[_]-Order : ∀ {ℓ} → Kind → Container ℓ → Set ℓ → Preorder ℓ ℓ ℓ
[ k ]-Order C X = Related.InducedPreorder₂ k (_∈_ {C = C} {X = X})
[_]-Equality : ∀ {ℓ} → Symmetric-kind → Container ℓ → Set ℓ → Setoid ℓ ℓ
[ k ]-Equality C X = Related.InducedEquivalence₂ k (_∈_ {C = C} {X = X})
infix 4 _∼[_]_
_∼[_]_ : ∀ {c} {C : Container c} {X : Set c} →
         ⟦ C ⟧ X → Kind → ⟦ C ⟧ X → Set c
_∼[_]_ {C = C} {X} xs k ys = Preorder._∼_ ([ k ]-Order C X) xs ys
 
 | 
	{
  "alphanum_fraction": 0.4830917874,
  "avg_line_length": 29.1333333333,
  "ext": "agda",
  "hexsha": "3d1909ffd83ded3eb9dffb63cb5e609ca23c58be",
  "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": "9d4c43b1609d3f085636376fdca73093481ab882",
  "max_forks_repo_licenses": [
    "Apache-2.0"
  ],
  "max_forks_repo_name": "qwe2/try-agda",
  "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Container.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
  "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": "qwe2/try-agda",
  "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Container.agda",
  "max_line_length": 72,
  "max_stars_count": 1,
  "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
  "max_stars_repo_licenses": [
    "Apache-2.0"
  ],
  "max_stars_repo_name": "qwe2/try-agda",
  "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Container.agda",
  "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
  "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
  "num_tokens": 2971,
  "size": 7866
} 
 | 
					
	{-# OPTIONS --prop --rewriting #-}
module index where
-- Calf language implementation:
import Calf
-- Case studies:
import Examples
 
 | 
	{
  "alphanum_fraction": 0.7185185185,
  "avg_line_length": 13.5,
  "ext": "agda",
  "hexsha": "5921223fb5fac4f403f9c3e122a6b21f0de96b89",
  "lang": "Agda",
  "max_forks_count": 2,
  "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z",
  "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z",
  "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
  "max_forks_repo_licenses": [
    "Apache-2.0"
  ],
  "max_forks_repo_name": "jonsterling/agda-calf",
  "max_forks_repo_path": "src/index.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
  "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": "jonsterling/agda-calf",
  "max_issues_repo_path": "src/index.agda",
  "max_line_length": 34,
  "max_stars_count": 29,
  "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
  "max_stars_repo_licenses": [
    "Apache-2.0"
  ],
  "max_stars_repo_name": "jonsterling/agda-calf",
  "max_stars_repo_path": "src/index.agda",
  "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z",
  "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z",
  "num_tokens": 29,
  "size": 135
} 
 | 
					
	{-# OPTIONS --allow-unsolved-metas #-}
module AgdaFeatureNoInstanceFromHidden where
postulate
  A : Set
  R : A → A → Set
Alrighty : A → Set₁
Alrighty l = ∀ {r} → R l r → Set
record Foo (Q : A → Set₁) : Set₁ where field foo : ∀ {x y} → R x y → Q x → Q y
open Foo {{...}}
postulate
  instance theInstance : Foo Alrighty
works1 : ∀ {x y} → R x y → Alrighty x → Alrighty y
works1 r = foo r
works2 : ∀ {x y} → R x y → Alrighty x → Alrighty y
works2 r ax = works1 r ax
works3 : ∀ {x y} → R x y → Alrighty x → Alrighty y
works3 r ax = foo {{theInstance}} r ax
works4 : ∀ {x y} → R x y → Alrighty x → Alrighty y
works4 r ax = foo r (λ {v} → ax {v})
fails : ∀ {x y} → R x y → Alrighty x → Alrighty y
fails r ax = {!foo r ax!}
{-
No instance of type Foo (λ v → R v _r_81 → Set) was found in scope.
when checking that r ax are valid arguments to a function of type
{Q : A → Set₁} {{r = r₁ : Foo Q}} {x y : A} → R x y → Q x → Q y
-}
 
 | 
	{
  "alphanum_fraction": 0.5948553055,
  "avg_line_length": 24.5526315789,
  "ext": "agda",
  "hexsha": "5ba31ffeafd0bd619d7e7b2f75892b3112658d0f",
  "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/AgdaFeatureNoInstanceFromHidden.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/AgdaFeatureNoInstanceFromHidden.agda",
  "max_line_length": 78,
  "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/AgdaFeatureNoInstanceFromHidden.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 346,
  "size": 933
} 
 | 
					
	
module Issue157 where
X : Set
X = _
error : Set
error = Set
 
 | 
	{
  "alphanum_fraction": 0.6507936508,
  "avg_line_length": 7,
  "ext": "agda",
  "hexsha": "44c7e405e367613e5bbc7a2d9f7c4c43f777aa17",
  "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/interaction/Issue157.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/interaction/Issue157.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/interaction/Issue157.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": 21,
  "size": 63
} 
 | 
					
	{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}
module Light.Implementation.Relation.Boolean where
open import Light.Library.Data.Boolean as Boolean using (Boolean)
open import Light.Package using (Package)
open import Light.Level using (_⊔_ ; Lifted)
open import Light.Variable.Levels
open import Light.Variable.Sets
open import Light.Library.Data.Unit as Unit using (Unit ; unit)
open import Light.Library.Data.Empty as Empty using (Empty)
open import Light.Library.Relation using (Style)
open import Light.Implementation.Data.Boolean
open import Light.Implementation.Data.Unit
open import Light.Implementation.Data.Empty
instance relation : Style record { Proposition = λ _ → Boolean ; Index = Unit }
relation = record { Implementation }
      where
      module Implementation where
            open Boolean using (true ; false ; ¬_ ; _∧_ ; _∨_ ; _⇢_) public
            
            True = Boolean.if_then Unit else Empty
            False = Boolean.if_then Empty else Unit
 
 | 
	{
  "alphanum_fraction": 0.7357001972,
  "avg_line_length": 40.56,
  "ext": "agda",
  "hexsha": "ec3cf8725889cc31edb5358095c32dd44836bdb5",
  "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": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
  "max_forks_repo_licenses": [
    "0BSD"
  ],
  "max_forks_repo_name": "Zambonifofex/lightlib",
  "max_forks_repo_path": "Light/Implementation/Relation/Boolean.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "0BSD"
  ],
  "max_issues_repo_name": "Zambonifofex/lightlib",
  "max_issues_repo_path": "Light/Implementation/Relation/Boolean.agda",
  "max_line_length": 79,
  "max_stars_count": 1,
  "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
  "max_stars_repo_licenses": [
    "0BSD"
  ],
  "max_stars_repo_name": "zamfofex/lightlib",
  "max_stars_repo_path": "Light/Implementation/Relation/Boolean.agda",
  "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z",
  "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z",
  "num_tokens": 215,
  "size": 1014
} 
 | 
					
	------------------------------------------------------------------------
-- The syntax of, and a type system for, an untyped λ-calculus with
-- booleans and recursive unary function calls
------------------------------------------------------------------------
open import Prelude
module Lambda.Syntax (Name : Type) where
open import Equality.Propositional
open import Prelude.Size
open import Vec.Data equality-with-J
------------------------------------------------------------------------
-- Terms
-- Variables are represented using de Bruijn indices.
infixl 9 _·_
data Tm (n : ℕ) : Type where
  var  : Fin n → Tm n
  lam  : Tm (suc n) → Tm n
  _·_  : Tm n → Tm n → Tm n
  call : Name → Tm n → Tm n
  con  : Bool → Tm n
  if   : Tm n → Tm n → Tm n → Tm n
------------------------------------------------------------------------
-- Closure-based definition of values
-- Environments and values. Defined in a module parametrised by the
-- type of terms.
module Closure (Tm : ℕ → Type) where
  mutual
    -- Environments.
    Env : ℕ → Type
    Env n = Vec Value n
    -- Values. Lambdas are represented using closures, so values do
    -- not contain any free variables.
    data Value : Type where
      lam : ∀ {n} → Tm (suc n) → Env n → Value
      con : Bool → Value
------------------------------------------------------------------------
-- Type system
-- Recursive, simple types, defined coinductively.
infixr 8 _⇾_ _⇾′_
mutual
  data Ty (i : Size) : Type where
    bool : Ty i
    _⇾′_ : (σ τ : Ty′ i) → Ty i
  record Ty′ (i : Size) : Type where
    coinductive
    field
      force : {j : Size< i} → Ty j
open Ty′ public
-- Some type formers.
_⇾_ : ∀ {i} → Ty i → Ty i → Ty i
σ ⇾ τ = (λ { .force → σ }) ⇾′ (λ { .force → τ })
-- Contexts.
Ctxt : ℕ → Type
Ctxt n = Vec (Ty ∞) n
-- Type system.
infix 4 _,_⊢_∈_
data _,_⊢_∈_ (Σ : Name → Ty ∞ × Ty ∞) {n} (Γ : Ctxt n) :
             Tm n → Ty ∞ → Type where
  var  : ∀ {x} → Σ , Γ ⊢ var x ∈ index Γ x
  lam  : ∀ {t σ τ} →
         Σ , force σ ∷ Γ ⊢ t ∈ force τ →
         Σ , Γ ⊢ lam t ∈ σ ⇾′ τ
  _·_  : ∀ {t₁ t₂ σ τ} →
         Σ , Γ ⊢ t₁ ∈ σ ⇾′ τ →
         Σ , Γ ⊢ t₂ ∈ force σ →
         Σ , Γ ⊢ t₁ · t₂ ∈ force τ
  call : ∀ {f t} →
         Σ , Γ ⊢ t ∈ proj₁ (Σ f) →
         Σ , Γ ⊢ call f t ∈ proj₂ (Σ f)
  con  : ∀ {b} → Σ , Γ ⊢ con b ∈ bool
  if   : ∀ {t₁ t₂ t₃ σ} →
         Σ , Γ ⊢ t₁ ∈ bool →
         Σ , Γ ⊢ t₂ ∈ σ →
         Σ , Γ ⊢ t₃ ∈ σ →
         Σ , Γ ⊢ if t₁ t₂ t₃ ∈ σ
------------------------------------------------------------------------
-- Examples
-- A non-terminating term.
ω-body : Tm 1
ω-body = var fzero · var fzero
ω : Tm 0
ω = lam ω-body
Ω : Tm 0
Ω = ω · ω
-- Ω is well-typed.
Ω-well-typed : ∀ {Σ} (τ : Ty ∞) → Σ , [] ⊢ Ω ∈ τ
Ω-well-typed τ =
  _·_ {σ = σ} {τ = λ { .force → τ }} (lam (var · var)) (lam (var · var))
  where
  σ : ∀ {i} → Ty′ i
  force σ = σ ⇾′ λ { .force → τ }
-- A call-by-value fixpoint combinator.
Z : Tm 0
Z = lam (t · t)
  where
  t = lam (var (fsuc fzero) ·
         lam (var (fsuc fzero) · var (fsuc fzero) · var fzero))
-- This combinator is also well-typed.
Z-well-typed :
  ∀ {Σ} {σ τ : Ty ∞} →
  Σ , [] ⊢ Z ∈ ((σ ⇾ τ) ⇾ (σ ⇾ τ)) ⇾ (σ ⇾ τ)
Z-well-typed {σ = σ} {τ = τ} =
  lam (_·_ {σ = υ} {τ = λ { .force → σ ⇾ τ }}
           (lam (var · lam (var · var · var)))
           (lam (var · lam (var · var · var))))
  where
  υ : ∀ {i} → Ty′ i
  force υ = υ ⇾′ λ { .force → σ ⇾ τ }
 
 | 
	{
  "alphanum_fraction": 0.4419213974,
  "avg_line_length": 23.0536912752,
  "ext": "agda",
  "hexsha": "f753640494b7bd746d881dd9983d30452aff9cea",
  "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": "dec8cd2d2851340840de25acb0feb78f7b5ffe96",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "nad/definitional-interpreters",
  "max_forks_repo_path": "src/Lambda/Syntax.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96",
  "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/definitional-interpreters",
  "max_issues_repo_path": "src/Lambda/Syntax.agda",
  "max_line_length": 72,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "nad/definitional-interpreters",
  "max_stars_repo_path": "src/Lambda/Syntax.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 1244,
  "size": 3435
} 
 | 
					
	open import Relation.Binary.Core
module Mergesort.Impl2 {A : Set}
                  (_≤_ : A → A → Set)
                  (tot≤ : Total _≤_)  where
open import Bound.Lower A
open import Bound.Lower.Order  _≤_
open import Data.List
open import Data.Sum
open import Function
open import LRTree {A}
open import OList _≤_ 
mutual 
  merge' : {b : Bound} → OList b → OList b → OList b
  merge' onil ys = ys
  merge' xs onil = xs
  merge' (:< {x = x} b≤x xs) (:< {x = y} b≤y ys) 
      with tot≤ x y
  ... | inj₁ x≤y  = :< b≤x (merge' xs (:< (lexy x≤y) ys))
  ... | inj₂ y≤x = :< b≤y (merge'xs (lexy y≤x) xs ys)
  merge'xs : {b : Bound}{x : A} → LeB b (val x) → OList (val x) → OList b → OList b
  merge'xs b≤x xs onil = :< b≤x xs
  merge'xs {x = x} b≤x xs (:< {x = y} b≤y ys) 
      with tot≤ x y
  ... | inj₁ x≤y = :< b≤x (merge' xs (:< (lexy x≤y) ys))
  ... | inj₂ y≤x = :< b≤y (merge'xs (lexy y≤x) xs ys)
deal : List A → LRTree
deal = foldr insert empty
merge : LRTree → OList bot
merge empty = onil
merge (leaf x) = :< (lebx {val x}) onil
merge (node t l r) = merge' (merge l) (merge r)
mergesort : List A → OList bot
mergesort = merge ∘ deal
 
 | 
	{
  "alphanum_fraction": 0.5587467363,
  "avg_line_length": 28.0243902439,
  "ext": "agda",
  "hexsha": "5579215cd662ff286535f8b0b581c7b168028780",
  "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/Mergesort/Impl2.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/Mergesort/Impl2.agda",
  "max_line_length": 83,
  "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/Mergesort/Impl2.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": 484,
  "size": 1149
} 
 | 
					
	{-# OPTIONS --without-K #-}
module Hmm where
  -- using the HoTT-Agda library leads to highlighting error (missing metadata)
  -- open import lib.Base
  -- open import lib.types.Nat
  -- using this library does not, yet the code is copied/pasted from HoTT-Agda
  open import Base
  S= : {m n : ℕ} → m == n → S m == S n
  S= idp = idp
 
 | 
	{
  "alphanum_fraction": 0.6460176991,
  "avg_line_length": 22.6,
  "ext": "agda",
  "hexsha": "8778765fd42e056c6d5677e44bb2fa981f167048",
  "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": "f8b6b11fb7ee0c54ce91a19338c5069a69a51dc7",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "aerskine/hott-ex",
  "max_forks_repo_path": "Hmm.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "f8b6b11fb7ee0c54ce91a19338c5069a69a51dc7",
  "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": "aerskine/hott-ex",
  "max_issues_repo_path": "Hmm.agda",
  "max_line_length": 79,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "f8b6b11fb7ee0c54ce91a19338c5069a69a51dc7",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "aerskine/hott-ex",
  "max_stars_repo_path": "Hmm.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 101,
  "size": 339
} 
 | 
					
	{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Core
open import Categories.Category.Monoidal.Core
-- This module defines the category of monoids internal to a given monoidal
-- category.
module Categories.Category.Construction.Monoids {o ℓ e} {𝒞 : Category o ℓ e} (C : Monoidal 𝒞) where
open import Level
open import Categories.Functor using (Functor)
open import Categories.Morphism.Reasoning 𝒞
open import Categories.Object.Monoid C
open Category 𝒞
open Monoidal C
open HomReasoning
open Monoid using (η; μ)
open Monoid⇒
Monoids : Category (o ⊔ ℓ ⊔ e) (ℓ ⊔ e) e
Monoids = record
  { Obj = Monoid
  ; _⇒_ = Monoid⇒
  ; _≈_ = λ f g → arr f ≈ arr g
  ; id = record
    { arr = id
    ; preserves-μ = identityˡ ○ introʳ (Functor.identity ⊗)
    ; preserves-η = identityˡ
    }
  ; _∘_ = λ f g → record
    { arr = arr f ∘ arr g
    ; preserves-μ = glue (preserves-μ f) (preserves-μ g) ○ ∘-resp-≈ʳ (⟺ (Functor.homomorphism ⊗))
    ; preserves-η = glueTrianglesˡ (preserves-η f) (preserves-η g)
    }
  ; assoc = assoc
  ; sym-assoc = sym-assoc
  ; identityˡ = identityˡ
  ; identityʳ = identityʳ
  ; identity² = identity²
  -- We cannot define equiv = equiv here, because _⇒_ of this category is a
  -- different level to the _⇒_ of 𝒞.
  ; equiv = record
    { refl = refl
    ; sym = sym
    ; trans = trans
    }
  ; ∘-resp-≈ = ∘-resp-≈
  } where open Equiv
 
 | 
	{
  "alphanum_fraction": 0.6550976139,
  "avg_line_length": 27.1176470588,
  "ext": "agda",
  "hexsha": "3e9c6ca8e7131a1f749702c7beb9f0094891d483",
  "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": "d9e4f578b126313058d105c61707d8c8ae987fa8",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "Code-distancing/agda-categories",
  "max_forks_repo_path": "src/Categories/Category/Construction/Monoids.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
  "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": "Code-distancing/agda-categories",
  "max_issues_repo_path": "src/Categories/Category/Construction/Monoids.agda",
  "max_line_length": 99,
  "max_stars_count": 5,
  "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/Monoids.agda",
  "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z",
  "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z",
  "num_tokens": 482,
  "size": 1383
} 
 | 
					
	------------------------------------------------------------------------
-- The Agda standard library
--
-- Homogeneously-indexed binary relations
------------------------------------------------------------------------
-- The contents of this module should be accessed via
-- `Relation.Binary.Indexed.Homogeneous`.
{-# OPTIONS --without-K --safe #-}
module Relation.Binary.Indexed.Homogeneous.Definitions where
open import Data.Product using (_×_)
open import Level using (Level)
import Relation.Binary as B
open import Relation.Unary.Indexed using (IPred)
open import Relation.Binary.Indexed.Homogeneous.Core
private
  variable
    i a ℓ ℓ₁ ℓ₂ : Level
    I : Set i
------------------------------------------------------------------------
-- Definitions
module _ (A : I → Set a) where
  syntax Implies A _∼₁_ _∼₂_ = _∼₁_ ⇒[ A ] _∼₂_
  Implies : IRel A ℓ₁ → IRel A ℓ₂ → Set _
  Implies _∼₁_ _∼₂_ = ∀ {i} → _∼₁_ B.⇒ (_∼₂_ {i})
  Reflexive : IRel A ℓ → Set _
  Reflexive _∼_ = ∀ {i} → B.Reflexive (_∼_ {i})
  Symmetric : IRel A ℓ → Set _
  Symmetric _∼_ = ∀ {i} → B.Symmetric (_∼_ {i})
  Transitive : IRel A ℓ → Set _
  Transitive _∼_ = ∀ {i} → B.Transitive (_∼_ {i})
  Antisymmetric : IRel A ℓ₁ → IRel A ℓ₂ → Set _
  Antisymmetric _≈_ _∼_ = ∀ {i} → B.Antisymmetric _≈_ (_∼_ {i})
  Decidable : IRel A ℓ → Set _
  Decidable _∼_ = ∀ {i} → B.Decidable (_∼_ {i})
  Respects : IPred A ℓ₁ → IRel A ℓ₂ → Set _
  Respects P _∼_ = ∀ {i} {x y : A i} → x ∼ y → P x → P y
  Respectsˡ : IRel A ℓ₁ → IRel A ℓ₂ → Set _
  Respectsˡ P _∼_  = ∀ {i} {x y z : A i} → x ∼ y → P x z → P y z
  Respectsʳ : IRel A ℓ₁ → IRel A ℓ₂ → Set _
  Respectsʳ P _∼_ = ∀ {i} {x y z : A i} → x ∼ y → P z x → P z y
  Respects₂ : IRel A ℓ₁ → IRel A ℓ₂ → Set _
  Respects₂ P _∼_ = (Respectsʳ P _∼_) × (Respectsˡ P _∼_)
 
 | 
	{
  "alphanum_fraction": 0.5375626043,
  "avg_line_length": 28.9838709677,
  "ext": "agda",
  "hexsha": "2bb21d31960f8759deef6a00ea111f31f0437e7c",
  "lang": "Agda",
  "max_forks_count": 1,
  "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
  "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
  "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "DreamLinuxer/popl21-artifact",
  "max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Indexed/Homogeneous/Definitions.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "DreamLinuxer/popl21-artifact",
  "max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Indexed/Homogeneous/Definitions.agda",
  "max_line_length": 72,
  "max_stars_count": 5,
  "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "DreamLinuxer/popl21-artifact",
  "max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Indexed/Homogeneous/Definitions.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": 655,
  "size": 1797
} 
 | 
					
	{-# OPTIONS --rewriting #-}
module Luau.ResolveOverloads where
open import FFI.Data.Either using (Left; Right)
open import Luau.Subtyping using (_<:_; _≮:_; Language; witness; scalar; unknown; never; function-ok)
open import Luau.Type using (Type ; _⇒_; _∩_; _∪_; unknown; never)
open import Luau.TypeSaturation using (saturate)
open import Luau.TypeNormalization using (normalize)
open import Properties.Contradiction using (CONTRADICTION)
open import Properties.DecSubtyping using (dec-subtyping; dec-subtypingⁿ; <:-impl-<:ᵒ)
open import Properties.Functions using (_∘_)
open import Properties.Subtyping using (<:-refl; <:-trans; <:-trans-≮:; ≮:-trans-<:; <:-∩-left; <:-∩-right; <:-∩-glb; <:-impl-¬≮:; <:-unknown; <:-function; function-≮:-never; <:-never; unknown-≮:-function; scalar-≮:-function; ≮:-∪-right; scalar-≮:-never; <:-∪-left; <:-∪-right)
open import Properties.TypeNormalization using (Normal; FunType; normal; _⇒_; _∩_; _∪_; never; unknown; <:-normalize; normalize-<:; fun-≮:-never; unknown-≮:-fun; scalar-≮:-fun)
open import Properties.TypeSaturation using (Overloads; Saturated; _⊆ᵒ_; _<:ᵒ_; normal-saturate; saturated; <:-saturate; saturate-<:; defn; here; left; right)
-- The domain of a normalized type
srcⁿ : Type → Type
srcⁿ (S ⇒ T) = S
srcⁿ (S ∩ T) = srcⁿ S ∪ srcⁿ T
srcⁿ never = unknown
srcⁿ T = never
-- To get the domain of a type, we normalize it first We need to do
-- this, since if we try to use it on non-normalized types, we get
--
-- src(number ∩ string) = src(number) ∪ src(string) = never ∪ never
-- src(never) = unknown
--
-- so src doesn't respect type equivalence.
src : Type → Type
src (S ⇒ T) = S
src T = srcⁿ(normalize T)
-- Calculate the result of applying a function type `F` to an argument type `V`.
-- We do this by finding an overload of `F` that has the most precise type,
-- that is an overload `(Sʳ ⇒ Tʳ)` where `V <: Sʳ` and moreover
-- for any other such overload `(S ⇒ T)` we have that `Tʳ <: T`.
-- For example if `F` is `(number -> number) & (nil -> nil) & (number? -> number?)`
-- then to resolve `F` with argument type `number`, we pick the `number -> number`
-- overload, but if the argument is `number?`, we pick `number? -> number?`./
-- Not all types have such a most precise overload, but saturated ones do.
data ResolvedTo F G V : Set where
  yes : ∀ Sʳ Tʳ →
    Overloads F (Sʳ ⇒ Tʳ) →
    (V <: Sʳ) → 
    (∀ {S T} → Overloads G (S ⇒ T) → (V <: S) → (Tʳ <: T)) →
    --------------------------------------------
    ResolvedTo F G V
  no :
    (∀ {S T} → Overloads G (S ⇒ T) → (V ≮: S)) →
    --------------------------------------------
    ResolvedTo F G V
Resolved : Type → Type → Set
Resolved F V = ResolvedTo F F V
target : ∀ {F V} → Resolved F V → Type
target (yes _ T _ _ _) = T
target (no _) = unknown
-- We can resolve any saturated function type
resolveˢ : ∀ {F G V} → FunType G → Saturated F → Normal V → (G ⊆ᵒ F) → ResolvedTo F G V
resolveˢ (Sⁿ ⇒ Tⁿ) (defn sat-∩ sat-∪) Vⁿ G⊆F with dec-subtypingⁿ Vⁿ Sⁿ
resolveˢ (Sⁿ ⇒ Tⁿ) (defn sat-∩ sat-∪) Vⁿ G⊆F | Left V≮:S = no (λ { here → V≮:S })
resolveˢ (Sⁿ ⇒ Tⁿ) (defn sat-∩ sat-∪) Vⁿ G⊆F | Right V<:S = yes _ _ (G⊆F here) V<:S (λ { here _ → <:-refl })
resolveˢ (Gᶠ ∩ Hᶠ) (defn sat-∩ sat-∪) Vⁿ G⊆F with resolveˢ Gᶠ (defn sat-∩ sat-∪) Vⁿ (G⊆F ∘ left) | resolveˢ Hᶠ (defn sat-∩ sat-∪) Vⁿ (G⊆F ∘ right)
resolveˢ (Gᶠ ∩ Hᶠ) (defn sat-∩ sat-∪) Vⁿ G⊆F | yes S₁ T₁ o₁ V<:S₁ tgt₁ | yes S₂ T₂ o₂ V<:S₂ tgt₂ with sat-∩ o₁ o₂
resolveˢ (Gᶠ ∩ Hᶠ) (defn sat-∩ sat-∪) Vⁿ G⊆F | yes S₁ T₁ o₁ V<:S₁ tgt₁ | yes S₂ T₂ o₂ V<:S₂ tgt₂ | defn o p₁ p₂ =
  yes _ _ o (<:-trans (<:-∩-glb V<:S₁ V<:S₂) p₁) (λ { (left o) p → <:-trans p₂ (<:-trans <:-∩-left (tgt₁ o p)) ; (right o) p → <:-trans p₂ (<:-trans <:-∩-right (tgt₂ o p)) })
resolveˢ (Gᶠ ∩ Hᶠ) (defn sat-∩ sat-∪) Vⁿ G⊆F | yes S₁ T₁ o₁ V<:S₁ tgt₁ | no src₂ =
  yes _ _ o₁ V<:S₁ (λ { (left o) p → tgt₁ o p ; (right o) p → CONTRADICTION (<:-impl-¬≮: p (src₂ o)) })
resolveˢ (Gᶠ ∩ Hᶠ) (defn sat-∩ sat-∪) Vⁿ G⊆F | no src₁ | yes S₂ T₂ o₂ V<:S₂ tgt₂ =
  yes _ _ o₂ V<:S₂ (λ { (left o) p → CONTRADICTION (<:-impl-¬≮: p (src₁ o)) ; (right o) p → tgt₂ o p })
resolveˢ (Gᶠ ∩ Hᶠ) (defn sat-∩ sat-∪) Vⁿ G⊆F | no src₁ | no src₂ =
  no (λ { (left o) → src₁ o ; (right o) → src₂ o })
-- Which means we can resolve any normalized type, by saturating it first
resolveᶠ : ∀ {F V} → FunType F → Normal V → Type
resolveᶠ Fᶠ Vⁿ = target (resolveˢ (normal-saturate Fᶠ) (saturated Fᶠ) Vⁿ (λ o → o))
resolveⁿ : ∀ {F V} → Normal F → Normal V → Type
resolveⁿ (Sⁿ ⇒ Tⁿ) Vⁿ = resolveᶠ (Sⁿ ⇒ Tⁿ) Vⁿ
resolveⁿ (Fᶠ ∩ Gᶠ) Vⁿ = resolveᶠ (Fᶠ ∩ Gᶠ) Vⁿ
resolveⁿ (Sⁿ ∪ Tˢ) Vⁿ = unknown
resolveⁿ unknown Vⁿ = unknown
resolveⁿ never Vⁿ = never
-- Which means we can resolve any type, by normalizing it first
resolve : Type → Type → Type
resolve F V = resolveⁿ (normal F) (normal V)
 
 | 
	{
  "alphanum_fraction": 0.6148240683,
  "avg_line_length": 48.5151515152,
  "ext": "agda",
  "hexsha": "6717517632c45d7d6b9085c6473af39648b7e4a1",
  "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": "39fbd2146a379fb0878369b48764cd7e8772c0fb",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "sthagen/Roblox-luau",
  "max_forks_repo_path": "prototyping/Luau/ResolveOverloads.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "39fbd2146a379fb0878369b48764cd7e8772c0fb",
  "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": "sthagen/Roblox-luau",
  "max_issues_repo_path": "prototyping/Luau/ResolveOverloads.agda",
  "max_line_length": 277,
  "max_stars_count": 1,
  "max_stars_repo_head_hexsha": "f1b46f4b967f11fabe666da1de0e71b225368260",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "Libertus-Lab/luau",
  "max_stars_repo_path": "prototyping/Luau/ResolveOverloads.agda",
  "max_stars_repo_stars_event_max_datetime": "2021-11-06T08:03:00.000Z",
  "max_stars_repo_stars_event_min_datetime": "2021-11-06T08:03:00.000Z",
  "num_tokens": 1984,
  "size": 4803
} 
 | 
					
	------------------------------------------------------------------------
-- The Agda standard library
--
-- Sum combinators for propositional equality preserving functions
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Sum.Function.Propositional where
open import Data.Sum
open import Data.Sum.Function.Setoid
open import Data.Sum.Relation.Binary.Pointwise using (Pointwise-≡↔≡)
open import Function.Equivalence as Eq using (_⇔_; module Equivalence)
open import Function.Injection as Inj using (_↣_; module Injection)
open import Function.Inverse as Inv using (_↔_; module Inverse)
open import Function.LeftInverse as LeftInv
  using (_↞_; _LeftInverseOf_; module LeftInverse)
open import Function.Related
open import Function.Surjection as Surj using (_↠_; module Surjection)
------------------------------------------------------------------------
-- Combinators for various function types
module _ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} where
  _⊎-⇔_ : A ⇔ B → C ⇔ D → (A ⊎ C) ⇔ (B ⊎ D)
  _⊎-⇔_ A⇔B C⇔D =
    Inverse.equivalence (Pointwise-≡↔≡ B D) ⟨∘⟩
    (A⇔B ⊎-equivalence C⇔D) ⟨∘⟩
    Eq.sym (Inverse.equivalence (Pointwise-≡↔≡ A C))
    where open Eq using () renaming (_∘_ to _⟨∘⟩_)
  _⊎-↣_ : A ↣ B → C ↣ D → (A ⊎ C) ↣ (B ⊎ D)
  _⊎-↣_ A↣B C↣D =
    Inverse.injection (Pointwise-≡↔≡ B D) ⟨∘⟩
    (A↣B ⊎-injection C↣D) ⟨∘⟩
    Inverse.injection (Inv.sym (Pointwise-≡↔≡ A C))
    where open Inj using () renaming (_∘_ to _⟨∘⟩_)
  _⊎-↞_ : A ↞ B → C ↞ D → (A ⊎ C) ↞ (B ⊎ D)
  _⊎-↞_ A↞B C↞D =
    Inverse.left-inverse (Pointwise-≡↔≡ B D) ⟨∘⟩
    (A↞B ⊎-left-inverse C↞D) ⟨∘⟩
    Inverse.left-inverse (Inv.sym (Pointwise-≡↔≡ A C))
    where open LeftInv using () renaming (_∘_ to _⟨∘⟩_)
  _⊎-↠_ : A ↠ B → C ↠ D → (A ⊎ C) ↠ (B ⊎ D)
  _⊎-↠_ A↠B C↠D =
    Inverse.surjection (Pointwise-≡↔≡ B D) ⟨∘⟩
    (A↠B ⊎-surjection C↠D) ⟨∘⟩
    Inverse.surjection (Inv.sym (Pointwise-≡↔≡ A C))
    where open Surj using () renaming (_∘_ to _⟨∘⟩_)
  _⊎-↔_ : A ↔ B → C ↔ D → (A ⊎ C) ↔ (B ⊎ D)
  _⊎-↔_ A↔B C↔D =
    Pointwise-≡↔≡ B D ⟨∘⟩
    (A↔B ⊎-inverse C↔D) ⟨∘⟩
    Inv.sym (Pointwise-≡↔≡ A C)
    where open Inv using () renaming (_∘_ to _⟨∘⟩_)
module _ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} where
  _⊎-cong_ : ∀ {k} → A ∼[ k ] B → C ∼[ k ] D → (A ⊎ C) ∼[ k ] (B ⊎ D)
  _⊎-cong_ {implication}         = map
  _⊎-cong_ {reverse-implication} = λ f g → lam (map (app-← f) (app-← g))
  _⊎-cong_ {equivalence}         = _⊎-⇔_
  _⊎-cong_ {injection}           = _⊎-↣_
  _⊎-cong_ {reverse-injection}   = λ f g → lam (app-↢ f ⊎-↣ app-↢ g)
  _⊎-cong_ {left-inverse}        = _⊎-↞_
  _⊎-cong_ {surjection}          = _⊎-↠_
  _⊎-cong_ {bijection}           = _⊎-↔_
 
 | 
	{
  "alphanum_fraction": 0.5252890173,
  "avg_line_length": 37.9178082192,
  "ext": "agda",
  "hexsha": "f0f5586f94e6ca1897018e738ef719fed361a6da",
  "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/Data/Sum/Function/Propositional.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "omega12345/agda-mode",
  "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/Function/Propositional.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/Data/Sum/Function/Propositional.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 1185,
  "size": 2768
} 
 | 
					
	module product where
open import level
open import unit public
----------------------------------------------------------------------
-- types
----------------------------------------------------------------------
data Σ {ℓ ℓ'} (A : Set ℓ) (B : A → Set ℓ') : Set (ℓ ⊔ ℓ') where
  _,_ : (a : A) → (b : B a) → Σ A B
data Σi {ℓ ℓ'} (A : Set ℓ) (B : A → Set ℓ') : Set (ℓ ⊔ ℓ') where
  ,_ : {a : A} → (b : B a) → Σi A B
_×_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ')
A × B = Σ A (λ x → B)
_i×_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ')
A i× B = Σi A (λ x → B)
----------------------------------------------------------------------
-- syntax
----------------------------------------------------------------------
infix 2 Σ-syntax
infixr 3 _×_ _i×_ _∧_
infixr 4 _,_ 
infix  4 ,_
-- This provides the syntax: Σ[ x ∈ A ] B it is taken from the Agda
-- standard library. This style is nice when working in Set.
Σ-syntax : ∀ {a b} (A : Set a) → (A → Set b) → Set (a ⊔ b)
Σ-syntax = Σ
syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B
----------------------------------------------------------------------
-- operations
----------------------------------------------------------------------
fst : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → A × B → A
fst (a , b) = a
snd : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → A × B → B
snd (a , b) = b
trans-× : ∀{ℓ₁ ℓ₂ ℓ₃}
         {A : Set ℓ₁}{B : Set ℓ₂}
         {C : Set ℓ₃}
       → (C → A)
       → (C → B)
       → (C → A × B)
trans-× f g c = f c , g c
⟨_,_⟩ : ∀{ℓ₁ ℓ₂ ℓ₃ ℓ₄}
         {A : Set ℓ₁}{B : Set ℓ₂}
         {C : Set ℓ₃}{D : Set ℓ₄}
       → (A → C)
       → (B → D)
       → (A × B → C × D)
⟨ f , g ⟩ (a , b) = f a , g b
twist-× : ∀{ℓ₁ ℓ₂}
     {A : Set ℓ₁}{B : Set ℓ₂}
    → A × B
    → B × A
twist-× (a , b) = (b , a)       
rl-assoc-× : ∀{ℓ₁ ℓ₂ ℓ₃}
             {A : Set ℓ₁}{B : Set ℓ₂}
             {C : Set ℓ₃}
           → A × (B × C)
           → (A × B) × C
rl-assoc-× (a , b , c) =  ((a , b) , c)
lr-assoc-× : ∀{ℓ₁ ℓ₂ ℓ₃}
             {A : Set ℓ₁}{B : Set ℓ₂}
             {C : Set ℓ₃}
           → (A × B) × C
           → A × (B × C)
lr-assoc-× ((a , b) , c) = (a , b , c)
func-× : ∀{ℓ₁ ℓ₂ ℓ₃ ℓ₄}{A : Set ℓ₁}{B : Set ℓ₂}{C : Set ℓ₃}{D : Set ℓ₄} → (A → C) → (B → D) → (A × B) → (C × D)
func-× f g (x , y) = (f x , g y)
×-diag : ∀{ℓ}{X : Set ℓ} → X → X × X
×-diag x = (x , x)
----------------------------------------------------------------------
-- some logical notation
----------------------------------------------------------------------
_∧_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ')
_∧_ = _×_
∃ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : A → Set ℓ') → Set (ℓ ⊔ ℓ')
∃ = Σ
∃i : ∀ {ℓ ℓ'} (A : Set ℓ) (B : A → Set ℓ') → Set (ℓ ⊔ ℓ')
∃i = Σi
 
 | 
	{
  "alphanum_fraction": 0.3068978237,
  "avg_line_length": 27.11,
  "ext": "agda",
  "hexsha": "0241a38273fde17e6b0735efff5e914edd374790",
  "lang": "Agda",
  "max_forks_count": null,
  "max_forks_repo_forks_event_max_datetime": null,
  "max_forks_repo_forks_event_min_datetime": null,
  "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "heades/AUGL",
  "max_forks_repo_path": "product.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "heades/AUGL",
  "max_issues_repo_path": "product.agda",
  "max_line_length": 111,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "heades/AUGL",
  "max_stars_repo_path": "product.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 1130,
  "size": 2711
} 
 | 
					
	
open import Common.Nat
open import Common.IO
open import Common.Unit
record Test : Set where
  field
    a b c : Nat
f : Test -> Nat
f r = a + b + c
  where open Test r
open Test
g : Nat
g = (f (record {a = 100; b = 120; c = 140})) + a m + b m + c m
  where m = record {c = 400; a = 200; b = 300}
main : IO Unit
main = printNat g
-- Expected Output: 1260
 
 | 
	{
  "alphanum_fraction": 0.5966850829,
  "avg_line_length": 15.0833333333,
  "ext": "agda",
  "hexsha": "c1cccf86ecec4004315966a49e66ed2f8d6534b2",
  "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/Compiler/simple/NoRecordConstructor.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/Compiler/simple/NoRecordConstructor.agda",
  "max_line_length": 62,
  "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/Compiler/simple/NoRecordConstructor.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": 133,
  "size": 362
} 
 | 
					
	{-# OPTIONS --without-K #-}
open import M-types.Base
module M-types.Coalg.Bisim (A : Ty ℓ) (B : A → Ty ℓ) where
    open import M-types.Coalg.Core A B
    TyBisim : Coalg → Ty (ℓ-suc ℓ)
    TyBisim X =
        ∑[ coalg ∈ Coalg ]
        CoalgMor coalg X × CoalgMor coalg X
    coalg = pr₀
    spanRel : {X : Coalg} →
        ∏[ ∼ ∈ TyBisim X ] SpanRel (ty X)
    spanRel (coalg , ρ₀ , ρ₁) = (ty coalg , fun ρ₀ , fun ρ₁)
    tyLift : {X : Coalg} →
        ∏[ ∼ ∈ TyBisim X ] ∏[ x₀ ∈ ty X ] ∏[ x₁ ∈ ty X ]
        (x₀ ⟨ spanRel {X} ∼ ⟩ x₁ → (obs X x₀) ⟨ P-SpanRel (spanRel {X} ∼) ⟩ (obs X x₁))
    tyLift ∼ x₀ x₁ (s , refl , refl) =
        (
            obs (coalg ∼) s ,
            ≡-apply (com (ρ₀ ∼)⁻¹) s ,
            ≡-apply (com (ρ₁ ∼)⁻¹) s
        )
    ≡-TyBisim : {X : Coalg} →
        TyBisim X
    ≡-TyBisim {X} =
        (
            X ,
            (id , refl) ,
            (id , refl)
        )
    P-TyBisim : {X : Coalg} →
        TyBisim X → TyBisim (P-Coalg X)
    P-TyBisim {X} ∼ =
        (
            P-Coalg (coalg ∼) ,
            P-CoalgMor {coalg ∼} {X} (ρ₀ ∼) ,
            P-CoalgMor {coalg ∼} {X} (ρ₁ ∼)
        )
    TyBisimMor : {X : Coalg} →
        TyBisim X → TyBisim X → Ty ℓ
    TyBisimMor {X} ∼ ≈ =
        ∑[ mor ∈ SpanRelMor (spanRel {X} ∼) (spanRel {X} ≈) ]
        obs (coalg ≈) ∘ fun mor ≡ P-Fun (fun mor) ∘ obs (coalg ∼)
    FunBisim : Coalg → Ty (ℓ-suc ℓ)
    FunBisim X =
        ∑[ depRel ∈ (ty X → ty X → Ty ℓ) ]
        ∏[ x₀ ∈ ty X ] ∏[ x₁ ∈ ty X ]
        (depRel x₀ x₁ → (P-DepRel depRel) (obs X x₀) (obs X x₁))
    depRel : {X : Coalg} →
        ∏[ ∼ ∈ FunBisim X ] DepRel (ty X)
    depRel = pr₀
    funLift : {X : Coalg} →
        ∏[ ∼ ∈ FunBisim X ] ∏[ d₀ ∈ ty X ] ∏[ d₁ ∈ ty X ]
        (d₀ [ depRel ∼ ] d₁ → (obs X d₀) [ P-DepRel (depRel ∼) ] (obs X d₁))
    funLift = pr₁
    ≡-funLift : {X : Coalg} →
        ∏[ x₀ ∈ ty X ] ∏[ x₁ ∈ ty X ]
        (≡-depRel x₀ x₁ → P-DepRel ≡-depRel (obs X x₀) (obs X x₁))
    ≡-funLift x x refl = (refl , λ b → refl)
    ≡-funBisim : {X : Coalg} →
        FunBisim X
    ≡-funBisim {X} = (≡-depRel , ≡-funLift)
    P-FunBisim : {X : Coalg} →
        FunBisim X → FunBisim (P-Coalg X)
    P-FunBisim {X} ∼ =
        (
            P-DepRel (depRel ∼) ,
            λ (a₀ , d₀) → λ (a₁ , d₁) → λ (p , e) → (
                p ,
                λ b₀ → pr₁ ∼ (d₀ b₀) (d₁ (tra B p b₀)) (e b₀)
            )
        )
    FunBisimMor : {X : Coalg} →
        FunBisim X → FunBisim X → Ty ℓ
    FunBisimMor {X} ∼ ≈ =
        ∑[ mor ∈ DepRelMor (depRel ∼) (depRel ≈) ]
        ∏[ x₀ ∈ ty X ] ∏[ x₁ ∈ ty X ]
        funLift ≈ x₀ x₁ ∘ mor x₀ x₁ ≡
        P-DepRelMor mor (obs X x₀) (obs X x₁) ∘ funLift ∼ x₀ x₁
    fun-tra : {a₀ a₁ : A} {C : Ty ℓ} →
        ∏[ p ∈ a₀ ≡ a₁ ] ∏[ f₁ ∈ (B a₁ → C) ]
        tra (λ a → (B a → C)) p (f₁ ∘ (tra B p)) ≡ f₁
    fun-tra refl f₁ = refl
    apply-pr₁ : {X : Coalg} {(a₀ , d₀) (a₁ , d₁) : P (ty X)} →
        ∏[ p ∈ (a₀ , d₀) ≡ (a₁ , d₁) ] ∏[ b₀ ∈ B a₀ ]
        d₀ b₀ ≡ d₁ (tra B (ap pr₀ p) b₀)
    apply-pr₁ refl b = refl
    TyBisim→FunBisim : {X : Coalg} →
        TyBisim X → FunBisim X
    TyBisim→FunBisim {X} ∼ =
        (
            (λ x₀ → λ x₁ → x₀ ⟨ spanRel {X} ∼ ⟩ x₁) ,
            (λ x₀ → λ x₁ → λ {(s , refl , refl) → let
                q₀ :
                    obs X x₀ ≡ (
                        pr₀ (obs (coalg ∼) s) ,
                        fun (ρ₀ ∼) ∘ pr₁ (obs (coalg ∼) s)
                    )
                q₀ = ≡-apply (com (ρ₀ ∼)) s
                q₁ :
                    obs X x₁ ≡ (
                        pr₀ (obs (coalg ∼) s) ,
                        fun (ρ₁ ∼) ∘ pr₁ (obs (coalg ∼) s)
                    )
                q₁ = ≡-apply (com (ρ₁ ∼)) s
            in (
                 (ap pr₀ q₀) · (ap pr₀ q₁) ⁻¹ ,
                 λ b₀ → (
                     pr₁ (obs (coalg ∼) s) (tra B (ap pr₀ q₀) b₀) ,
                     (apply-pr₁ {X} q₀ b₀) ⁻¹ ,
                     (apply-pr₁ {X} (q₁ ⁻¹) (tra B (ap pr₀ q₀) b₀)) ·
                     ap (pr₁ (obs X x₁)) (≡-apply (
                         tra-con B (ap pr₀ q₀) (ap pr₀ (q₁ ⁻¹)) ·
                         ap (λ r → tra B (ap pr₀ q₀ · r)) ((ap-inv pr₀ q₁) ⁻¹)
                     ) b₀)
                 )
            )})
        )
    FunBisim→TyBisim : {X : Coalg} →
        FunBisim X → TyBisim X
    FunBisim→TyBisim {X} ∼ =
        (
            (
                (∑[ x₀ ∈ ty X ] ∑[ x₁ ∈ ty X ] x₀ [ depRel ∼ ] x₁) ,
                λ (x₀ , x₁ , s) → (
                    pr₀ (obs X x₀) ,
                    λ b₀ → (
                        pr₁ (obs X x₀) b₀ ,
                        pr₁ (obs X x₁) (tra B (pr₀ (funLift ∼ x₀ x₁ s)) b₀) ,
                        pr₁ (funLift ∼ x₀ x₁ s) b₀
                    )
                )
            ) , (
                pr₀ ,
                funext (λ (x₀ , x₁ , s) → refl)
            ) , (
                pr₀ ∘ pr₁ ,
                funext (λ (x₀ , x₁ , s) → ≡-pair (
                    pr₀ (funLift ∼ x₀ x₁ s) ,
                    fun-tra (pr₀ (funLift ∼ x₀ x₁ s)) (pr₁ (obs X x₁))
                ) ⁻¹)
            )
        )
    TyBisim→FunBisim-pres : {X : Coalg} →
        ∏[ ∼ ∈ TyBisim X ] ∏[ x₀ ∈ ty X ] ∏[ x₁ ∈ ty X ]
        (x₀ [ depRel {X} (TyBisim→FunBisim {X} ∼) ] x₁) ≡ (x₀ ⟨ spanRel {X} ∼ ⟩ x₁)
    TyBisim→FunBisim-pres {X} ∼ x₀ x₁ = SpanRel→DepRel-pres (spanRel {X} ∼) x₀ x₁
    FunBisim→TyBisim-pres : {X : Coalg} →
        ∏[ ∼ ∈ FunBisim X ] ∏[ x₀ ∈ ty X ] ∏[ x₁ ∈ ty X ]
        (x₀ ⟨ spanRel {X} (FunBisim→TyBisim {X} ∼) ⟩ x₁) ≃ (x₀ [ depRel {X} ∼ ] x₁)
    FunBisim→TyBisim-pres ∼ x₀ x₁ = DepRel→SpanRel-pres (depRel ∼) x₀ x₁
 
 | 
	{
  "alphanum_fraction": 0.378440367,
  "avg_line_length": 30.9726775956,
  "ext": "agda",
  "hexsha": "0cc12bfae1220fd6b8b0ed32489714fede55cf5e",
  "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": "Coalg/Bisim.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": "Coalg/Bisim.agda",
  "max_line_length": 87,
  "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": "Coalg/Bisim.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 2369,
  "size": 5668
} 
 | 
					
	module STypeCongruence where
open import Data.Fin
open import DualCoinductive
open import Direction
open COI
-- holes for session types
mutual
  data TypeH : Set where
      TPair-l : TypeH → (T₂ : Type) → TypeH
      TPair-r : (T₁ : Type) → TypeH → TypeH
      TChan   : (sh : STypeH) → TypeH
  data STypeH : Set where
    hole : STypeH
    transmit-s : (d : Dir) (T : Type) (sh : STypeH) → STypeH
    transmit-t : (d : Dir) (th : TypeH) (S : SType) → STypeH
-- apply a hole to a session type
apply-hole-T : TypeH → SType → Type
apply-hole-S : STypeH → SType → SType
apply-hole-T (TPair-l th T₂) S = TPair (apply-hole-T th S) T₂
apply-hole-T (TPair-r T₁ th) S = TPair T₁ (apply-hole-T th S)
apply-hole-T (TChan sh) S = TChan (apply-hole-S sh S)
apply-hole-S hole S = S
apply-hole-S (transmit-s d T sh) S = delay (transmit d T (apply-hole-S sh S))
apply-hole-S (transmit-t d th S₁) S = delay (transmit d (apply-hole-T th S) S₁)
-- test congruences
≈-cong-transmit : ∀ {d t S₁ S₂} → S₁ ≈ S₂ → transmit d t S₁ ≈' transmit d t S₂
≈-cong-transmit S1≈S2 = eq-transmit _ ≈ᵗ-refl S1≈S2
≈-cong-transmit-t : ∀ {d T₁ T₂ S} → T₁ ≈ᵗ T₂ → transmit d T₁ S ≈' transmit d T₂ S
≈-cong-transmit-t T1≈T2 = eq-transmit _ T1≈T2 ≈-refl
≈-cong-choice : ∀ {d m alt₁ alt₂} → ((i : Fin m) → alt₁ i ≈ alt₂ i) → choice d m alt₁ ≈' choice d m alt₂
≈-cong-choice f = eq-choice _ f
-- full congruences
≈-cong-hole-S : ∀ {sh S₁ S₂} → S₁ ≈ S₂ → apply-hole-S sh S₁ ≈ apply-hole-S sh S₂
≈-cong-hole-T : ∀ {th S₁ S₂} → S₁ ≈ S₂ → apply-hole-T th S₁ ≈ᵗ apply-hole-T th S₂
≈-cong-hole-S {hole} S1≈S2 = S1≈S2
≈-cong-hole-S {transmit-s d T sh} S1≈S2 =
  record { force = ≈-cong-transmit (≈-cong-hole-S S1≈S2 ) }
≈-cong-hole-S {transmit-t d th S} S1≈S2 =
  record { force = ≈-cong-transmit-t (≈-cong-hole-T S1≈S2) }
≈-cong-hole-T {TPair-l th T₂} S1≈S2 = eq-pair (≈-cong-hole-T S1≈S2) ≈ᵗ-refl
≈-cong-hole-T {TPair-r T₁ th} S1≈S2 = eq-pair ≈ᵗ-refl (≈-cong-hole-T S1≈S2)
≈-cong-hole-T {TChan sh} S1≈S2 = eq-chan (≈-cong-hole-S S1≈S2)
 
 | 
	{
  "alphanum_fraction": 0.625,
  "avg_line_length": 32.3870967742,
  "ext": "agda",
  "hexsha": "09eb3c29f45c353fe824eb37591b219b41ac3a08",
  "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": "cd41919582013e75463308c32750e2712cf2de86",
  "max_forks_repo_licenses": [
    "BSD-2-Clause"
  ],
  "max_forks_repo_name": "kcaliban/dual-session",
  "max_forks_repo_path": "src/STypeCongruence.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "cd41919582013e75463308c32750e2712cf2de86",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "BSD-2-Clause"
  ],
  "max_issues_repo_name": "kcaliban/dual-session",
  "max_issues_repo_path": "src/STypeCongruence.agda",
  "max_line_length": 104,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "cd41919582013e75463308c32750e2712cf2de86",
  "max_stars_repo_licenses": [
    "BSD-2-Clause"
  ],
  "max_stars_repo_name": "kcaliban/dual-session",
  "max_stars_repo_path": "src/STypeCongruence.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 887,
  "size": 2008
} 
 | 
					
	{-# OPTIONS --allow-unsolved-metas #-}
{-# OPTIONS --termination-depth=2  #-}
module _ where
open import Common.Prelude
module A where
  mutual
    f : Nat → Nat
    f zero = zero
    f (suc zero) = suc zero
    f (suc (suc x)) = g x
    g : Nat → Nat
    g x = f (suc ?)
  -- This should not fail termination checking,
  -- as ? := x is a terminating instance.
module B where
  mutual
    f : Nat → Nat
    f zero = zero
    f (suc zero) = suc zero
    f (suc (suc x)) = g ?
    g : Nat → Nat
    g x = f (suc x)
  -- This should not fail termination checking,
  -- as ? := x is a terminating instance.
 
 | 
	{
  "alphanum_fraction": 0.56726094,
  "avg_line_length": 16.2368421053,
  "ext": "agda",
  "hexsha": "197f2cfcce91b1d4c0df9db971e5bf574a7af0c3",
  "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/Issue1281.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/Issue1281.agda",
  "max_line_length": 47,
  "max_stars_count": 1989,
  "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "cruhland/agda",
  "max_stars_repo_path": "test/Succeed/Issue1281.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": 192,
  "size": 617
} 
 | 
					
	module Type.Properties.Singleton {ℓ ℓₑ} where
import      Lvl
open import Lang.Instance
open import Structure.Setoid
open import Type
-- A type is a singleton type when it has exactly one inhabitant (there is only one object with this type).
-- In other words: There is an unique inhabitant of type T.
-- Also called:
-- • "singleton type"
-- • "unit type"
-- • "contractible"
record IsUnit (T : Type{ℓ}) ⦃ _ : Equiv{ℓₑ}(T) ⦄ : Type{ℓ Lvl.⊔ ℓₑ} where
  constructor intro
  field
    unit : T
    uniqueness : ∀{x : T} → (x ≡ unit)
open IsUnit ⦃ ... ⦄ using (unit)
 
 | 
	{
  "alphanum_fraction": 0.6713780919,
  "avg_line_length": 28.3,
  "ext": "agda",
  "hexsha": "373230121e7b041d44642aa0f0d79e1432ac1912",
  "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": "Type/Properties/Singleton.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": "Type/Properties/Singleton.agda",
  "max_line_length": 107,
  "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": "Type/Properties/Singleton.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": 184,
  "size": 566
} 
 | 
					
	{-# OPTIONS --guarded #-}
module _ where
primitive
  primLockUniv : _
postulate
  A B : primLockUniv
  c : A → B
  foo : (@tick x y : B) → Set
bar2 : (@tick x : A) → Set
bar2 x = foo (c x) (c x)
 
 | 
	{
  "alphanum_fraction": 0.5656565657,
  "avg_line_length": 14.1428571429,
  "ext": "agda",
  "hexsha": "aebc55488318b2da86c544086ae572ecedbc7e78",
  "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/TickConstants.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/TickConstants.agda",
  "max_line_length": 29,
  "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/TickConstants.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": 198
} 
 | 
					
	------------------------------------------------------------------------
-- Equivalence of the two variants of declarative kinding of Fω with
-- interval kinds
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
module FOmegaInt.Kinding.Declarative.Equivalence where
open import Data.Product using (proj₁)
open import FOmegaInt.Syntax
import FOmegaInt.Typing                   as Original
open import FOmegaInt.Kinding.Declarative as Extended
open import FOmegaInt.Kinding.Declarative.Validity
private
  module O where
    open Original public
    open Typing   public
  module E where
    open Extended public
    open Kinding  public
open Syntax
open TermCtx
open Kinding
open KindedSubstitution
open Original.Typing
  hiding (_ctx; _⊢_wf; _⊢_kd; _⊢Tp_∈_; _⊢_<∷_; _⊢_<:_∈_; _⊢_≅_; _⊢_≃_∈_)
-- Soundness of extended declarative (sub)kinding w.r.t. original
-- declarative (sub)kinding.
--
-- This soundness proof simply forgets about all the validity
-- conditions in the extended rules.
mutual
  sound-wf : ∀ {n} {Γ : Ctx n} {a} → Γ ⊢ a wf → Γ O.⊢ a wf
  sound-wf (wf-kd k-kd) = wf-kd (sound-kd k-kd)
  sound-wf (wf-tp a∈*)  = wf-tp (sound-Tp∈ a∈*)
  sound-ctx : ∀ {n} {Γ : Ctx n} → Γ ctx → Γ O.ctx
  sound-ctx E.[]             = O.[]
  sound-ctx (a-wf E.∷ Γ-ctx) = sound-wf a-wf O.∷ sound-ctx Γ-ctx
  sound-kd : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ k kd → Γ O.⊢ k kd
  sound-kd (kd-⋯ a∈* b∈*)   = kd-⋯ (sound-Tp∈ a∈*) (sound-Tp∈ b∈*)
  sound-kd (kd-Π j-kd k-kd) = kd-Π (sound-kd j-kd) (sound-kd k-kd)
  sound-Tp∈ : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Tp a ∈ k → Γ O.⊢Tp a ∈ k
  sound-Tp∈ (∈-var x Γ-ctx Γ[x]≡kd-k) =
    ∈-var x (sound-ctx Γ-ctx) Γ[x]≡kd-k
  sound-Tp∈ (∈-⊥-f Γ-ctx)         = ∈-⊥-f (sound-ctx Γ-ctx)
  sound-Tp∈ (∈-⊤-f Γ-ctx)         = ∈-⊤-f (sound-ctx Γ-ctx)
  sound-Tp∈ (∈-∀-f k-kd a∈*)      = ∈-∀-f (sound-kd k-kd) (sound-Tp∈ a∈*)
  sound-Tp∈ (∈-→-f a∈* b∈*)       = ∈-→-f (sound-Tp∈ a∈*) (sound-Tp∈ b∈*)
  sound-Tp∈ (∈-Π-i j-kd a∈k k-kd) = ∈-Π-i (sound-kd j-kd) (sound-Tp∈ a∈k)
  sound-Tp∈ (∈-Π-e a∈Πjk b∈j k-kd k[b]-kd) =
    ∈-Π-e (sound-Tp∈ a∈Πjk) (sound-Tp∈ b∈j)
  sound-Tp∈ (∈-s-i a∈b⋯c)     = ∈-s-i (sound-Tp∈ a∈b⋯c)
  sound-Tp∈ (∈-⇑ a∈j j<∷k)    = ∈-⇑ (sound-Tp∈ a∈j) (sound-<∷ j<∷k)
  sound-<∷ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j <∷ k → Γ O.⊢ j <∷ k
  sound-<∷ (<∷-⋯ a₂<:a₁∈* b₁<:b₂∈*)      =
    <∷-⋯ (sound-<: a₂<:a₁∈*) (sound-<: b₁<:b₂∈*)
  sound-<∷ (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) =
    <∷-Π (sound-<∷ j₂<∷j₁) (sound-<∷ k₁<∷k₂) (sound-kd Πj₁k₁-kd)
  sound-<: : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a <: b ∈ k → Γ O.⊢ a <: b ∈ k
  sound-<: (<:-refl a∈k) = <:-refl (sound-Tp∈ a∈k)
  sound-<: (<:-trans a<:b∈k b<:c∈k) =
    <:-trans (sound-<: a<:b∈k) (sound-<: b<:c∈k)
  sound-<: (<:-β₁ a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) =
    <:-β₁ (sound-Tp∈ a∈k) (sound-Tp∈ b∈j)
  sound-<: (<:-β₂ a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) =
    <:-β₂ (sound-Tp∈ a∈k) (sound-Tp∈ b∈j)
  sound-<: (<:-η₁ a∈Πjk) = <:-η₁ (sound-Tp∈ a∈Πjk)
  sound-<: (<:-η₂ a∈Πjk) = <:-η₂ (sound-Tp∈ a∈Πjk)
  sound-<: (<:-⊥ a∈b⋯c)  = <:-⊥ (sound-Tp∈ a∈b⋯c)
  sound-<: (<:-⊤ a∈b⋯c)  = <:-⊤ (sound-Tp∈ a∈b⋯c)
  sound-<: (<:-∀ k₂<∷k₁ a₁<:a₂∈* ∀k₁a₁∈*) =
    <:-∀ (sound-<∷ k₂<∷k₁) (sound-<: a₁<:a₂∈*) (sound-Tp∈ ∀k₁a₁∈*)
  sound-<: (<:-→ a₂<:a₁∈* b₁<:b₂∈*) =
    <:-→ (sound-<: a₂<:a₁∈*) (sound-<: b₁<:b₂∈*)
  sound-<: (<:-λ a₁<:a₂∈Πjk Λj₁a₁∈Πjk Λj₂a₂∈Πjk) =
    <:-λ (sound-<: a₁<:a₂∈Πjk)
         (sound-Tp∈ Λj₁a₁∈Πjk) (sound-Tp∈ Λj₂a₂∈Πjk)
  sound-<: (<:-· a₁<:a₂∈Πjk b₁≃b₁∈j b₁∈j k-kd k[b₁]-kd) =
    <:-· (sound-<: a₁<:a₂∈Πjk) (sound-≃ b₁≃b₁∈j)
  sound-<: (<:-⟨| a∈b⋯c)        = <:-⟨| (sound-Tp∈ a∈b⋯c)
  sound-<: (<:-|⟩ a∈b⋯c)        = <:-|⟩ (sound-Tp∈ a∈b⋯c)
  sound-<: (<:-⋯-i a₁<:a₂∈b⋯c)  = <:-⋯-i (sound-<: a₁<:a₂∈b⋯c)
  sound-<: (<:-⇑ a₁<:a₂∈j j<∷k) =
    <:-⇑ (sound-<: a₁<:a₂∈j) (sound-<∷ j<∷k)
  sound-≃ : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a ≃ b ∈ k → Γ O.⊢ a ≃ b ∈ k
  sound-≃ (<:-antisym a<:b∈k b<:a∈k) =
    <:-antisym (sound-<: a<:b∈k) (sound-<: b<:a∈k)
sound-≅ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → Γ O.⊢ j ≅ k
sound-≅ (<∷-antisym j<∷k k<∷j) =
  <∷-antisym (sound-<∷ j<∷k) (sound-<∷ k<∷j)
-- Completeness of extended declarative (sub)kinding w.r.t. original
-- declarative (sub)kinding.
--
-- This proves that the validity conditions in the extended rules are
-- in fact redundant, i.e. they follow from validity properties of the
-- remaining premises (of the rules in question)
mutual
  complete-wf : ∀ {n} {Γ : Ctx n} {a} → Γ O.⊢ a wf → Γ ⊢ a wf
  complete-wf (wf-kd k-kd) = wf-kd (complete-kd k-kd)
  complete-wf (wf-tp a∈*)  = wf-tp (complete-Tp∈ a∈*)
  complete-ctx : ∀ {n} {Γ : Ctx n} → Γ O.ctx → Γ ctx
  complete-ctx O.[]             = E.[]
  complete-ctx (a-wf O.∷ Γ-ctx) = complete-wf a-wf E.∷ complete-ctx Γ-ctx
  complete-kd : ∀ {n} {Γ : Ctx n} {k} → Γ O.⊢ k kd → Γ ⊢ k kd
  complete-kd (kd-⋯ a∈* b∈*)   = kd-⋯ (complete-Tp∈ a∈*) (complete-Tp∈ b∈*)
  complete-kd (kd-Π j-kd k-kd) = kd-Π (complete-kd j-kd) (complete-kd k-kd)
  complete-Tp∈ : ∀ {n} {Γ : Ctx n} {a k} → Γ O.⊢Tp a ∈ k → Γ ⊢Tp a ∈ k
  complete-Tp∈ (∈-var x Γ-ctx Γ[x]≡kd-k) =
    ∈-var x (complete-ctx Γ-ctx) Γ[x]≡kd-k
  complete-Tp∈ (∈-⊥-f Γ-ctx)     = ∈-⊥-f (complete-ctx Γ-ctx)
  complete-Tp∈ (∈-⊤-f Γ-ctx)     = ∈-⊤-f (complete-ctx Γ-ctx)
  complete-Tp∈ (∈-∀-f k-kd a∈*)  = ∈-∀-f (complete-kd k-kd) (complete-Tp∈ a∈*)
  complete-Tp∈ (∈-→-f a∈* b∈*)   = ∈-→-f (complete-Tp∈ a∈*) (complete-Tp∈ b∈*)
  complete-Tp∈ (∈-Π-i j-kd a∈k)  =
    ∈-Π-i (complete-kd j-kd) a∈k′ k-kd
    where
      a∈k′ = complete-Tp∈ a∈k
      k-kd = Tp∈-valid a∈k′
  complete-Tp∈ (∈-Π-e a∈Πjk b∈j) with Tp∈-valid (complete-Tp∈ a∈Πjk)
  ... | (kd-Π j-kd k-kd) =
    ∈-Π-e (complete-Tp∈ a∈Πjk) b∈j′ k-kd k[b]-kd
    where
      b∈j′    = complete-Tp∈ b∈j
      k[b]-kd = kd-[] k-kd (∈-tp b∈j′)
  complete-Tp∈ (∈-s-i a∈b⋯c)     = ∈-s-i (complete-Tp∈ a∈b⋯c)
  complete-Tp∈ (∈-⇑ a∈j j<∷k)    = ∈-⇑ (complete-Tp∈ a∈j) (complete-<∷ j<∷k)
  complete-<∷ : ∀ {n} {Γ : Ctx n} {j k} → Γ O.⊢ j <∷ k → Γ ⊢ j <∷ k
  complete-<∷ (<∷-⋯ a₂<:a₁∈* b₁<:b₂∈*)      =
    <∷-⋯ (complete-<: a₂<:a₁∈*) (complete-<: b₁<:b₂∈*)
  complete-<∷ (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) =
    <∷-Π (complete-<∷ j₂<∷j₁) (complete-<∷ k₁<∷k₂) (complete-kd Πj₁k₁-kd)
  complete-<: : ∀ {n} {Γ : Ctx n} {a b k} → Γ O.⊢ a <: b ∈ k → Γ ⊢ a <: b ∈ k
  complete-<: (<:-refl a∈k) = <:-refl (complete-Tp∈ a∈k)
  complete-<: (<:-trans a<:b∈k b<:c∈k) =
    <:-trans (complete-<: a<:b∈k) (complete-<: b<:c∈k)
  complete-<: (<:-β₁ a∈k b∈j) =
    <:-β₁ a∈k′ b∈j′ a[b]∈k[b] k-kd k[b]-kd
    where
      a∈k′ = complete-Tp∈ a∈k
      b∈j′ = complete-Tp∈ b∈j
      k-kd = Tp∈-valid a∈k′
      a[b]∈k[b] = Tp∈-[] a∈k′ (∈-tp b∈j′)
      k[b]-kd   = kd-[] k-kd (∈-tp b∈j′)
  complete-<: (<:-β₂ a∈k b∈j) =
    <:-β₂ a∈k′ b∈j′ a[b]∈k[b] k-kd k[b]-kd
    where
      a∈k′ = complete-Tp∈ a∈k
      b∈j′ = complete-Tp∈ b∈j
      k-kd = Tp∈-valid a∈k′
      a[b]∈k[b] = Tp∈-[] a∈k′ (∈-tp b∈j′)
      k[b]-kd   = kd-[] k-kd (∈-tp b∈j′)
  complete-<: (<:-η₁ a∈Πjk) = <:-η₁ (complete-Tp∈ a∈Πjk)
  complete-<: (<:-η₂ a∈Πjk) = <:-η₂ (complete-Tp∈ a∈Πjk)
  complete-<: (<:-⊥ a∈b⋯c)  = <:-⊥ (complete-Tp∈ a∈b⋯c)
  complete-<: (<:-⊤ a∈b⋯c)  = <:-⊤ (complete-Tp∈ a∈b⋯c)
  complete-<: (<:-∀ k₂<∷k₁ a₁<:a₂∈* ∀k₁a₁∈*) =
    <:-∀ (complete-<∷ k₂<∷k₁) (complete-<: a₁<:a₂∈*) (complete-Tp∈ ∀k₁a₁∈*)
  complete-<: (<:-→ a₂<:a₁∈* b₁<:b₂∈*) =
    <:-→ (complete-<: a₂<:a₁∈*) (complete-<: b₁<:b₂∈*)
  complete-<: (<:-λ a₁<:a₂∈Πjk Λj₁a₁∈Πjk Λj₂a₂∈Πjk) =
    <:-λ (complete-<: a₁<:a₂∈Πjk)
         (complete-Tp∈ Λj₁a₁∈Πjk) (complete-Tp∈ Λj₂a₂∈Πjk)
  complete-<: (<:-· a₁<:a₂∈Πjk b₁≃b₁∈j)
    with <:-valid-kd (complete-<: a₁<:a₂∈Πjk)
  ... | (kd-Π j-kd k-kd) =
    <:-· (complete-<: a₁<:a₂∈Πjk) b₁≃b₂∈j′ b₁∈j k-kd k[b₁]-kd
    where
      b₁≃b₂∈j′ = complete-≃ b₁≃b₁∈j
      b₁∈j     = proj₁ (≃-valid b₁≃b₂∈j′)
      k[b₁]-kd = kd-[] k-kd (∈-tp b₁∈j)
  complete-<: (<:-⟨| a∈b⋯c)        = <:-⟨| (complete-Tp∈ a∈b⋯c)
  complete-<: (<:-|⟩ a∈b⋯c)        = <:-|⟩ (complete-Tp∈ a∈b⋯c)
  complete-<: (<:-⋯-i a₁<:a₂∈b⋯c)  = <:-⋯-i (complete-<: a₁<:a₂∈b⋯c)
  complete-<: (<:-⇑ a₁<:a₂∈j j<∷k) =
    <:-⇑ (complete-<: a₁<:a₂∈j) (complete-<∷ j<∷k)
  complete-≃ : ∀ {n} {Γ : Ctx n} {a b k} → Γ O.⊢ a ≃ b ∈ k → Γ ⊢ a ≃ b ∈ k
  complete-≃ (<:-antisym a<:b∈k b<:a∈k) =
    <:-antisym (complete-<: a<:b∈k) (complete-<: b<:a∈k)
complete-≅ : ∀ {n} {Γ : Ctx n} {j k} → Γ O.⊢ j ≅ k → Γ ⊢ j ≅ k
complete-≅ (<∷-antisym j<∷k k<∷j) =
  <∷-antisym (complete-<∷ j<∷k) (complete-<∷ k<∷j)
 
 | 
	{
  "alphanum_fraction": 0.4826040807,
  "avg_line_length": 40.7644230769,
  "ext": "agda",
  "hexsha": "39b8b50c3c1e4760ed880f06057f823d99fae931",
  "lang": "Agda",
  "max_forks_count": 2,
  "max_forks_repo_forks_event_max_datetime": "2021-05-14T10:25:05.000Z",
  "max_forks_repo_forks_event_min_datetime": "2021-05-13T22:29:48.000Z",
  "max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "Blaisorblade/f-omega-int-agda",
  "max_forks_repo_path": "src/FOmegaInt/Kinding/Declarative/Equivalence.agda",
  "max_issues_count": 1,
  "max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
  "max_issues_repo_issues_event_max_datetime": "2021-05-14T08:54:39.000Z",
  "max_issues_repo_issues_event_min_datetime": "2021-05-14T08:09:40.000Z",
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "Blaisorblade/f-omega-int-agda",
  "max_issues_repo_path": "src/FOmegaInt/Kinding/Declarative/Equivalence.agda",
  "max_line_length": 78,
  "max_stars_count": 12,
  "max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "Blaisorblade/f-omega-int-agda",
  "max_stars_repo_path": "src/FOmegaInt/Kinding/Declarative/Equivalence.agda",
  "max_stars_repo_stars_event_max_datetime": "2021-09-27T05:53:06.000Z",
  "max_stars_repo_stars_event_min_datetime": "2017-06-13T16:05:35.000Z",
  "num_tokens": 4833,
  "size": 8479
} 
 | 
					
	------------------------------------------------------------------------
-- Lists of identifiers
------------------------------------------------------------------------
-- This example is based on one in Swierstra and Chitil's "Linear,
-- bounded, functional pretty-printing".
{-# OPTIONS --guardedness #-}
module Examples.Identifier-list where
open import Codata.Musical.Notation
open import Data.List
import Data.List.NonEmpty as List⁺
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Examples.Identifier
open import Grammar.Infinite as Grammar
  using (Grammar) hiding (module Grammar)
open import Pretty using (Pretty-printer)
open import Renderer
open import Utilities
identifier-list-body : Grammar (List Identifier)
identifier-list-body =
    return []
  ∣ List⁺.toList <$> (identifier-w sep-by symbol′ ",")
  where open Grammar
identifier-list : Grammar (List Identifier)
identifier-list = symbol′ "[" ⊛> identifier-list-body <⊛ symbol′ "]"
  where open Grammar
open Pretty
identifier-list-printer : Pretty-printer identifier-list
identifier-list-printer ns = symbol ⊛> body ns <⊛ symbol
  where
  body : Pretty-printer identifier-list-body
  body []       = left nil
  body (n ∷ ns) =
    right (<$> (<$> identifier-w-printer n
                  ⊛
                map⋆ (λ n → group symbol-line ⊛>
                            identifier-w-printer n)
                     ns))
identifiers : List Identifier
identifiers = str⁺ "aaa" ∷ str⁺ "bbbbb" ∷ str⁺ "ccc" ∷
              str⁺ "dd" ∷ str⁺ "eee" ∷ []
test₁ : render 80 (identifier-list-printer identifiers) ≡
        "[aaa, bbbbb, ccc, dd, eee]"
test₁ = refl
test₂ : render 11 (identifier-list-printer identifiers) ≡
        "[aaa,\nbbbbb, ccc,\ndd, eee]"
test₂ = refl
test₃ : render 8 (identifier-list-printer identifiers) ≡
        "[aaa,\nbbbbb,\nccc, dd,\neee]"
test₃ = refl
 
 | 
	{
  "alphanum_fraction": 0.6135881104,
  "avg_line_length": 29.9047619048,
  "ext": "agda",
  "hexsha": "2eca80d5b5d669ab8e2069b589f364a4d5a25750",
  "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": "b956803ba90b6c5f57bbbaab01bb18485d948492",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "nad/pretty",
  "max_forks_repo_path": "Examples/Identifier-list.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492",
  "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/pretty",
  "max_issues_repo_path": "Examples/Identifier-list.agda",
  "max_line_length": 72,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "nad/pretty",
  "max_stars_repo_path": "Examples/Identifier-list.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 471,
  "size": 1884
} 
 | 
					
	{-
Comments of the following form are parsed automatically by [extract.py] in order
to convert them to LaTeX and include them in the pdf.
{-<nameofbloc>-}
code
code
code
{-</>-}
-}
{-# OPTIONS --without-K --rewriting #-}
open import PathInduction
open import Pushout
module JamesTwoMaps {i} (A : Type i) (⋆A : A) where
-- We first define [J], [ι], [α] and [β].
-- We need [JS] to make the termination checker happy.
{-<defJiab>-}
J   : ℕ → Type i
JS  : ℕ → Type i
ι   : (n : ℕ) → J n → JS n
α   : (n : ℕ) → A → J n → JS n
β   : (n : ℕ) (x : J n) → α n ⋆A x == ι n x
data J0 : Type i where
  ε : J0
J 0 = J0
J (S n) = JS n
JS 0 = A
JS (S n) = Pushout (span (A × JS n) (JS n) X f g)  module JS where
  X : Type i
  X = Pushout (span (A × J n) (JS n) (J n) (λ x → (⋆A , x)) (ι n))
  f : X → A × JS n
  f = Pushout-rec (λ {(a , x) → (a , ι n x)}) (λ y → (⋆A , y)) (λ x → idp)
  g : X → JS n
  g = Pushout-rec (λ {(a , x) → α n a x}) (λ y → y) (β n)
ι 0 ε = ⋆A
ι (S n) x = inr x
α 0 a ε = a
α (S n) a x = inl (a , x)
β 0 ε = idp
β (S n) x = push (inr x)
{-</>-}
-- We can now define [γ] and [η]
{-<defge>-}
γ : (n : ℕ) (a : A) (x : J n) → α (S n) a (ι n x) == ι (S n) (α n a x)
γ n a x = push (inl (a , x))
η : (n : ℕ) (x : J n)
  → Square (γ n ⋆A x) idp (ap (ι (S n)) (β n x)) (β (S n) (ι n x))
η n x = natural-square push (push x) α-f-push ι-g-push  where
  α-f-push : ap (uncurry (α (S n)) ∘ JS.f n) (push x) == idp
  α-f-push =  ap-∘ (uncurry (α (S n))) (JS.f n) (push x)
              ∙ ap (ap (uncurry (α (S n)))) (push-β _)
  ι-g-push : ap (ι (S n) ∘ JS.g n) (push x) == ap (ι (S n)) (β n x)
  ι-g-push =  ap-∘ (ι (S n)) (JS.g n) (push x)
              ∙ ap (ap (ι (S n))) (push-β _)
{-</>-}
-- We define the more convenient elimination principle for JSS n:
{-<JSSElim>-}
module _ {l} (n : ℕ) {P : JS (S n) → Type l}
  (ι* : (x : JS n) → P (ι (S n) x))
  (α* : (a : A) (x : JS n) → P (α (S n) a x))
  (β* : (x : JS n) → α* ⋆A x == ι* x [ P ↓ β (S n) x ])
  (γ* : (a : A) (x : J n) → α* a (ι n x) == ι* (α n a x) [ P ↓ γ n a x ])
  (η* : (x : J n) → SquareOver P (η n x)  (γ* ⋆A x)
                                          idp
                                          (↓-ap-in P inr (apd ι* (β n x)))
                                          (β* (ι n x)))
  where
  JSS-elim : (x : JS (S n)) → P x
  JSS-elim = Pushout-elim (uncurry α*) ι* JSS-elim-push  where
    JSS-elim-push : (x : JS.X n) → uncurry α* (JS.f n x) == ι* (JS.g n x) [ P ↓ push x ]
    JSS-elim-push = Pushout-elim (uncurry γ*) β*
          (λ x → ↓-PathOver-from-square
               (adapt-SquareOver
                 (↓-ap-in-coh P (uncurry α*)) (↓-ap-in-coh P ι*)
                 (η* x)))
{-</>-}
{-<JSSRec>-}
module _ {l} (n : ℕ) {X : Type l}
  (ι* : JS n → X)
  (α* : A → JS n → X)
  (β* : (x : JS n) → α* ⋆A x == ι* x)
  (γ* : (a : A) (x : J n) → α* a (ι n x) == ι* (α n a x))
  (η* : (x : J n) → Square (γ* ⋆A x) idp (ap ι* (β n x)) (β* (ι n x)))
  where
  JSS-rec : JS (S n) → X
  JSS-rec = Pushout-rec (uncurry α*) ι* JSS-rec-push  module _ where
    JSS-rec-push : (c : JS.X n) → uncurry α* (JS.f n c) == ι* (JS.g n c)
    JSS-rec-push = Pushout-elim (uncurry γ*) β* (λ x → ↓-='-from-square (α-f-push x) (ι-g-push x) (η* x))  where
      α-f-push : (x : J n) → ap ((uncurry α*) ∘ (JS.f n)) (push x) == idp
      α-f-push x = ap-∘ _ _ (push x) ∙ ap (ap (uncurry α*)) (push-β x)
      ι-g-push : (x : J n) → ap (ι* ∘ (JS.g n)) (push x) == ap ι* (β n x)
      ι-g-push x = ap-∘ ι* _ (push x) ∙ ap (ap ι*) (push-β x)
module _ {l} (n : ℕ) {X : Type l}
  {ι* : JS n → X}
  {α* : A → JS n → X}
  {β* : (x : JS n) → α* ⋆A x == ι* x}
  {γ* : (a : A) (x : J n) → α* a (ι n x) == ι* (α n a x)}
  {η* : (x : J n) → Square (γ* ⋆A x) idp (ap ι* (β n x)) (β* (ι n x))}
  where
  private JSS-rec' = JSS-rec n ι* α* β* γ* η*
  private JSS-rec-push' = JSS-rec-push n ι* α* β* γ* η*
  β-β : (x : JS n) → ap JSS-rec' (β (S n) x) == β* x
  β-β x = push-β (inr x)
  γ-β : (a : A) (x : J n) → ap JSS-rec' (γ n a x) == γ* a x
  γ-β a x = push-β (inl (a , x))
  η-β : (x : J n) → FlatCube (ap-square JSS-rec' (η n x))
                             (η* x)
                             (γ-β ⋆A x)
                             idp
                             (∘-ap JSS-rec' inr (β n x))
                             (β-β (ι n x))
  η-β x = adapt-flatcube ∙idp
                         (& coh (ap-∘3 JSS-rec' inl  _ (push x)) (natural-square (ap-∘ JSS-rec' inl)  (push-β x) idp (ap-∘ (ap JSS-rec') (ap inl)  _)) (ap-∙ _ _ _))
                         (& coh (ap-∘3 JSS-rec' inr _ (push x)) (natural-square (ap-∘ JSS-rec' inr) (push-β x) idp (ap-∘ (ap JSS-rec') (ap inr) _)) (ap-∙ _ _ _))
                         ∙idp
            ((& (ap-square-natural-square JSS-rec') (push x) push idp idp
            /∙³ & natural-square-homotopy push-β (push x)
            ∙fc & natural-square== JSS-rec-push' (push x) idp idp
            ∙³/ natural-square-β JSS-rec-push' (push x) (push-βd x)))  where
    coh : Coh ({A : Type l} {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} (sq1 : Square p q r s)
                {e : A} {t : c == e} {f : A} {u : d == f} {v : e == f} (sq2 : Square s t u v)
                {ru : b == f} (ru= : ru == r ∙ u)
                → idp ∙ ! (p ∙ ru) ∙ q ∙ t == ! v)
    coh = path-induction
{-</>-}
-- Let’s now define JA
{-<defJA>-}
postulate
  JA  : Type i
  εJ  : JA
  αJ  : A → JA → JA
  δJ  : (x : JA) → x == αJ ⋆A x
module _ {l} {P : JA → Type l}
  (εJ*  : P εJ)
  (αJ*  : (a : A) (x : JA) → P x → P (αJ a x))
  (δJ*  : (x : JA) (y : P x) → y == αJ* ⋆A x y [ P ↓ (δJ x)]) where
  postulate
    JA-elim  : (x : JA) → P x
    εJ-β     : JA-elim εJ ↦ εJ*
    αJ-β     : (a : A) (x : JA) → JA-elim (αJ a x) ↦ αJ* a x (JA-elim x)
    {-# REWRITE εJ-β #-}
    {-# REWRITE αJ-β #-}
    δJ-βd'   : (x : JA) → apd JA-elim (δJ x) == δJ* x (JA-elim x)
{-</>-}
δJ-βd : ∀ {l} {P : JA → Type l}
  {εJ* : P εJ}
  {αJ* : (a : A) (x : JA) → P x → P (αJ a x)}
  {δJ* : (x : JA) (y : P x) → y == αJ* ⋆A x y [ P ↓ (δJ x)]}
  → (x : JA) → apd (JA-elim εJ* αJ* δJ*) (δJ x) == δJ* x (JA-elim εJ* αJ* δJ* x)
δJ-βd = δJ-βd' _ _ _
JA-rec : ∀ {l} {P : Type l}
  (εJ* : P)
  (αJ* : (a : A) → P → P)
  (δJ* : (y : P) → y == αJ* ⋆A y)
  → JA → P
JA-rec εJ* αJ* δJ* = JA-elim εJ* (λ a x y → αJ* a y) (λ x y → ↓-cst-in (δJ* y))
δJ-β : ∀ {l} {P : Type l}
  {εJ* : P}
  {αJ* : (a : A) → P → P}
  {δJ* : (y : P) → y == αJ* ⋆A y}
  → (x : JA) → ap (JA-rec εJ* αJ* δJ*) (δJ x) == δJ* (JA-rec εJ* αJ* δJ* x)
δJ-β x = apd=cst-in (δJ-βd x)
-- We define the structure on JA
{-<defgJeJ>-}
module _ {i} {X : Type i} (α : A → X → X) (δ : (x : X) → x == α ⋆A x) where
  γ-ify : (a : A) (x : X) → α a (α ⋆A x) == α ⋆A (α a x)
  γ-ify a x = ! (ap (α a) (δ x)) ∙ δ (α a x)
  η-ify : (x : X) → γ-ify ⋆A x == idp
  η-ify = λ x → & coh (natural-square δ (δ x) (ap-idf (δ x)) idp)  module ηIfy where
    coh : Coh  ({A : Type i} {a b : A} {p : a == b}
               {c : A} {q r : b == c} (sq : Square p p q r)
               → ! q ∙ r == idp)
    coh = path-induction
γJ : (a : A) (x : JA) → αJ a (αJ ⋆A x) == αJ ⋆A (αJ a x)
γJ = γ-ify αJ δJ
ηJ : (x : JA) → γJ ⋆A x == idp
ηJ = η-ify αJ δJ
{-</>-}
-- The functions [inJS-ι], [inJS-α] and [inJS-β] are to be thought of as
-- reduction rules.
{-<definJpushJ>-}
inJ   : (n : ℕ) → J n → JA
inJS  : (n : ℕ) → J (S n) → JA
inJS-ι  : (n : ℕ) (x : J n) → inJS n (ι n x) == αJ ⋆A (inJ n x)
inJS-α  : (n : ℕ) (a : A) (x : J n) → inJS n (α n a x) == αJ a (inJ n x)
inJS-β  : (n : ℕ) (x : J n) → Square (ap (inJS n) (β n x)) (inJS-α n ⋆A x) (inJS-ι n x) idp
inJ 0 ε = εJ
inJ (S n) x = inJS n x
inJS 0 a = αJ a εJ
inJS (S n) = JSS-rec n ι* α* β* γ* η*  module InJS where
  ι* : JS n → JA
  ι* x = αJ ⋆A (inJS n x)
  α* : A → JS n → JA
  α* a x = αJ a (inJS n x)
  β* : (x : JS n) → α* ⋆A x == ι* x
  β* x = idp
  γ* : (a : A) (x : J n) → α* a (ι n x) == ι* (α n a x)
  γ* a x = ap (αJ a) (inJS-ι n x) ∙ γJ a (inJ n x) ∙ ! (ap (αJ ⋆A) (inJS-α n a x))
  η* : (x : J n) → Square (γ* ⋆A x) idp (ap (αJ ⋆A ∘ inJS n) (β n x)) (β* (ι n x))
  η* x = & coh  (ηJ (inJ n x))
                (ap-square (αJ ⋆A) (inJS-β n x))
                (ap-∘ (αJ ⋆A) (inJS n) _)  module η* where
        coh :  Coh  ({A : Type i} {a b : A} {p : a == b} {c : A} {r : c == b}
                    {q : b == b} (q= : q == idp) {t : c == a} (sq : Square t r p idp)
                    {t' : c == a} (t= : t' == t)
               → Square (p ∙ q ∙ ! r) idp t' idp)
        coh = path-induction
inJS-ι 0 ε = idp
inJS-ι (S n) x = idp
inJS-α 0 a ε = idp
inJS-α (S n) a x = idp
inJS-β 0 ε = ids
inJS-β (S n) x = horiz-degen-square (push-β _)
pushJ : (n : ℕ) (x : J n) → inJ n x == inJ (S n) (ι n x)
pushJ n x = δJ (inJ n x) ∙ ! (inJS-ι n x)
{-</>-}
-- [inJS-β] applied for [n = S n] gives a degenerate square.
-- It is sometimes more convenient to see it as a 2-path as belown.
inJS-βS : (n : ℕ) (x : J (S n)) → ap (inJS (S n)) (β (S n) x) == idp
inJS-βS n x = push-β _
-- We give reduction rules for [inJS (S n)] applied to [γ] and [η] which are
-- more convenient to use
inJSS-γ : (n : ℕ) (a : A) (x : J n) → Square (ap (inJS (S n)) (γ n a x)) (ap (αJ a) (inJS-ι n x)) (ap (αJ ⋆A) (inJS-α n a x)) (γJ a (inJ n x))
inJSS-γ n a x = & coh (γ-β n a x)  module InJSγ where
  coh : Coh ({A : Type i} {a c : A} {q : a == c} {d : A} {s : c == d} {b : A} {r : b == d} {p : a == b}
        → p == q ∙ s ∙ ! r
        → Square p q r s)
  coh = path-induction
ap-inJSS-ι : (n : ℕ) {x y : J (S n)} (p : x == y) → ap (inJS (S n)) (ap (ι (S n)) p) == ap (αJ ⋆A) (ap (inJS n) p)
ap-inJSS-ι n p = ∘-ap (inJS (S n)) (ι (S n)) p ∙ ap-∘ (αJ ⋆A) (inJS n) p
inJSS-η : (n : ℕ) (x : J n) → Cube (ap-square (inJS (S n)) (η n x))
                                   (horiz-degen-square (ηJ (inJ n x)))
                                   (inJSS-γ n ⋆A x)
                                   vid-square
                                   (ap-inJSS-ι n (β n x) |∙ ap-square (αJ ⋆A) (inJS-β n x))
                                   (inJS-βS n (ι n x) |∙ vid-square)
inJSS-η n x = & coh (η-β n x)  where
  coh : {A : Type i} {a : A} → Coh ({r : a == a} {right : r == idp}
        {b : A} {s : b == a} {c : A} {t : b == c} {u : c == c} {to : u == idp}
        {s' : b == a} {down : s == s'} {s'' : b == a} {down' : s' == s''}
        {p : a == c} {down2 : Square s'' t p idp}
        {q : a == b} {sq : q == p ∙ u ∙ ! t} {from : Square q idp s r}
        → FlatCube from (& (InJS.η*.coh n x) to down2 down') sq idp down right
        → Cube from (horiz-degen-square to) (& (InJSγ.coh n ⋆A x) sq) vid-square ((down ∙ down') |∙ down2) (right |∙ vid-square))
  coh = path-induction
-- This function is used to apply a function to the result of [inJSS-η]
ap-shapeInJSη : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a : A}
  → Coh ({r : a == a} {right : r == idp} {b : A} {q : a == b}
  {c : A} {p : a == c} {u : c == c} {to : u == idp} {t : b == c} {left : Square q p t u}
  {s' : b == a} {down3 : Square s' t p idp} {s : b == a} {down1 : s == s'}
  {from : Square q idp s r}
  → Cube from (horiz-degen-square to) left vid-square (down1 |∙ down3) (right |∙ vid-square)
  → {ft : f b == f c} (ft= : ap f t == ft) {fp : f a == f c} (fp= : ap f p == fp)
  → Cube (ap-square f from) (horiz-degen-square (ap (ap f) to))
         (adapt-square (ap-square f left) fp= ft=) vid-square
         (adapt-square (ap (ap f) down1 |∙ ap-square f down3) ft= fp=) (ap (ap f) right |∙ vid-square))
ap-shapeInJSη f = path-induction
-- Definition of J∞A
{-<defJiA>-}
postulate
  J∞A    : Type i
  in∞    : (n : ℕ) (x : J n) → J∞A
  push∞  : (n : ℕ) (x : J n) → in∞ n x == in∞ (S n) (ι n x)
module _ {l} {P : J∞A → Type l}
  (in∞*    : (n : ℕ) (x : J n) → P (in∞ n x))
  (push∞*  : (n : ℕ) (x : J n) → in∞* n x == in∞* (S n) (ι n x) [ P ↓ (push∞ n x) ])  where
  postulate
    J∞A-elim   : (x : J∞A) → P x
    in∞-β      : (n : ℕ) (x : J n) → J∞A-elim (in∞ n x) ↦ in∞* n x
    {-# REWRITE in∞-β #-}
    push∞-βd'  : (n : ℕ) (x : J n) → apd J∞A-elim (push∞ n x) == push∞* n x
{-</>-}
push∞-βd : ∀ {l} {P : J∞A → Type l}
  {in∞* : (n : ℕ) (x : J n) → P (in∞ n x)}
  {push∞* : (n : ℕ) (x : J n) → in∞* n x == in∞* (S n) (ι n x) [ P ↓ (push∞ n x) ]}
  → (n : ℕ) (x : J n) → apd (J∞A-elim in∞* push∞*) (push∞ n x) == push∞* n x
push∞-βd = push∞-βd' _ _
J∞A-rec : ∀ {l} {P : Type l}
  (in∞* : (n : ℕ) (x : J n) → P)
  (push∞* : (n : ℕ) (x : J n) → in∞* n x == in∞* (S n) (ι n x))
  → J∞A → P
J∞A-rec in∞* push∞* = J∞A-elim in∞* (λ n x → ↓-cst-in (push∞* n x))
push∞-β : ∀ {l} {P : Type l}
  {in∞* : (n : ℕ) (x : J n) → P}
  {push∞* : (n : ℕ) (x : J n) → in∞* n x == in∞* (S n) (ι n x)}
  → (n : ℕ) (x : J n) → ap (J∞A-rec in∞* push∞*) (push∞ n x) == push∞* n x
push∞-β n x = apd=cst-in (push∞-βd n x)
-- Structure on J∞A
{-<defstructinf>-}
ε∞ : J∞A
ε∞ = in∞ 0 ε
α∞ : A → J∞A → J∞A
α∞ a = J∞A-rec α∞-in∞ α∞-push∞  module _ where
  α∞-in∞ : (n : ℕ) (x : J n) → J∞A
  α∞-in∞ n x = in∞ (S n) (α n a x)
  α∞-push∞ : (n : ℕ) (x : J n) → α∞-in∞ n x == α∞-in∞ (S n) (ι n x)
  α∞-push∞ n x = push∞ (S n) (α n a x) ∙ ! (ap (in∞ (S (S n))) (γ n a x))
δ∞ : (x : J∞A) → x == α∞ ⋆A x
δ∞ = J∞A-elim δ∞-in∞ (λ n x → ↓-='-from-square (ap-idf (push∞ n x)) idp (δ∞-push∞ n x))
  module _ where
  δ∞-in∞ : (n : ℕ) (x : J n) → in∞ n x == α∞ ⋆A (in∞ n x)
  δ∞-in∞ n x = push∞ n x ∙ ! (ap (in∞ (S n)) (β n x))
  δ∞-push∞ : (n : ℕ) (x : J n) → Square  (δ∞-in∞ n x)
                                         (push∞ n x)
                                         (ap (α∞ ⋆A) (push∞ n x))
                                         (δ∞-in∞ (S n) (ι n x))
  δ∞-push∞ = λ n x →
    & coh  (push∞ n x)
           (ap-square (in∞ (S (S n))) (η n x))
           (natural-square (push∞ (S n)) (β n x) idp (ap-∘ _ _ _))
           (push∞-β n x)
             module δ∞Push∞ where
    coh : Coh  ({A : Type i} {a b : A} (p : a == b) {d : A} {s : d == b}
               {c : A} {r : b == c} {f : A} {u : f == c} {e : A} {t : e == c}
               {w : f == e} (eta : Square w idp t u)
               {v : d == e} (nat : Square v s t r)
               {vw : d == f} (vw= : vw == v ∙ ! w)
               → Square (p ∙ ! s) p vw (r ∙ ! u))
    coh = path-induction
{-</>-}
    ap-coh : {A B : Type i} (g : A → B) →
             Coh ({a b : A} {p : a == b} {d : A} {s : d == b}
                 {c : A} {r : b == c} {f : A} {u : f == c} {e : A} {t : e == c}
                 {w : f == e} {eta : Square w idp t u}
                 {v : d == e} {nat : Square v s t r}
                 {vw : d == f} {vw= : vw == v ∙ ! w}
                 → FlatCube (ap-square g (& coh p eta nat vw=))
                            (& coh (ap g p) (ap-square g eta) (ap-square g nat) (ap-shape-∙! g vw=))
                            (ap-∙! g p s) idp idp (ap-∙! g r u))
    ap-coh g = path-induction
ap-α∞-in∞ : (n : ℕ) (a : A) {x y : J n} (p : x == y) → ap (α∞ a) (ap (in∞ n) p) == ap (in∞ (S n)) (ap (α n a) p)
ap-α∞-in∞ n a p = ∘-ap _ _ _ ∙ ap-∘ _ _ _
δ∞-in∞-β : (n : ℕ) (x : J n) → Square (δ∞ (in∞ n x)) idp (ap (in∞ (S n)) (β n x)) (push∞ n x)
δ∞-in∞-β = λ n x → & coh  module δ∞Inβ where
  coh : Coh ({A : Type i} {a b : A} {p : a == b} {c : A} {q : c == b} → Square (p ∙ ! q) idp q p)
  coh = path-induction
-- [γ∞] and the reduction rule for [γ∞ a (in∞ n x)] (3.2.6)
{-<gammainfin>-}
γ∞ : (a : A) (x : J∞A) → α∞ a (α∞ ⋆A x) == α∞ ⋆A (α∞ a x)
γ∞ = γ-ify α∞ δ∞
γ∞-in  : (a : A) (n : ℕ) (x : J n)
       → Square  (γ∞ a (in∞ n x))
                 (ap (in∞ (S (S n))) (ap (α (S n) a) (β n x)))
                 (ap (in∞ (S (S n))) (β (S n) (α n a x)))
                 (ap (in∞ (S (S n))) (γ n a x))
γ∞-in = λ a n x → & coh (push∞-β n x) (ap-∙! _ _ _) (ap-α∞-in∞ (S n) a (β n x))
                  module γ∞In where
  coh : Coh  ({A : Type i} {a d : A} {r : a == d} {b : A} {s : b == d}
             {c : A} {t' : c == b} {e : A} {u : e == d}
             {rs' : a == b} (rs= : rs' == r ∙ ! s)
             {fpq : a == c} (fpq= : fpq == rs' ∙ ! t')
             {t : c == b} (t= : t' == t)
             → Square (! fpq ∙ (r ∙ ! u)) t u s)
  coh = path-induction
{-</>-}
-- [η∞] and the reduction rule for [η∞ a (in∞ n x)] (3.2.7)
comp-square : {A : Type i} {a b c : A} {p : a == b} {q : b == c} → Square idp p (p ∙ q) q
comp-square {p = idp} {q = idp} = ids
skew : ∀ {i} {A : Type i} {a b c d : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} → Square p q r s → Square idp q (p ∙ r) s
skew ids = ids
ope1 : {A B : Type i} (f : A → B) {a b c : A} {p : a == b} {q : c == b}
       {fp : _} (fp= : ap f p == fp)
       {fq : _} (fq= : ap f q == fq)
       {fpq : _} (fpq= : ap f (p ∙ ! q) == fpq)
       → fpq == fp ∙ ! fq
ope1 f {p = idp} {q = idp} idp idp idp = idp
_∙!²_ : {A : Type i} {a b c : A} {p p' : a == b} (p= : p == p') {q q' : c == b} (q= : q == q')
        → (p ∙ ! q) == (p' ∙ ! q')
idp ∙!² idp = idp
ope1-idf : {A B : Type i} (f : A → B) → Coh ({b c : A} {q : c == b} {a : B} {p : a == f b}
         → ope1 (λ z → z) (ap-idf p) (∘-ap (λ z → z) f q ∙ idp) (ap-idf (p ∙ ! (ap f q))) == idp)
ope1-idf f = path-induction
natural-square-∙! : {A B : Type i} {a b c : A} (p : a == b) (q : c == b) → Coh ({f g : A → B} (h : (a : A) → f a == g a)
         {fp : _} {fp= : ap f p == fp}
         {gp : _} {gp= : ap g p == gp}
         {fq : _} {fq= : ap f q == fq}
         {gq : _} {gq= : ap g q == gq}
         {fpq : _ } {fpq= : ap f (p ∙ ! q) == fpq}
         {gpq : _ } {gpq= : ap g (p ∙ ! q) == gpq}
         → FlatCube (natural-square h (p ∙ ! q) fpq= gpq=) (natural-square h p fp= gp= ∙□ !² (natural-square h q fq= gq=)) idp (ope1 f fp= fq= fpq=) (ope1 g gp= gq= gpq=) idp)
natural-square-∙! {a = a} idp idp = path-induction
vcomp! : {A : Type i} {a b c d e f : A} {p : a == b} {q : a == c} {r : b == d} {s : c == d} {t : e == b} {u : f == d} {v : e == f}
         (sq1 : Square p q r s) (sq2 : Square t v r u)
       → Square (p ∙ ! t) q v (s ∙ ! u)
vcomp! {t = idp} ids ids = ids
natural-square∙! : {A B : Type i} {a b : A} (p : a == b)
       → Coh ({f g : A → B} (k : (a : A) → f a == g a) {h : A → B} (l : (a : A) → h a == g a)
              {fp : _} {fp= : ap f p == fp}
              {gp : _} {gp= : ap g p == gp}
              {hp : _} {hp= : ap h p == hp}
             → natural-square (λ x → k x ∙ ! (l x)) p fp= hp= == vcomp! (natural-square k p fp= gp=) (natural-square l p hp= gp=))
natural-square∙! {a = a} idp = path-induction
η∞ : (x : J∞A) → γ∞ ⋆A x == idp
η∞ = η-ify α∞ δ∞
η∞-in  : (n : ℕ) (x : J n)
       → Cube  (horiz-degen-square (η∞ (in∞ n x)))
               (ap-square (in∞ (S (S n))) (η n x))
               (γ∞-in ⋆A n x)
               vid-square
               comp-square
               (skew (ap-square (in∞ (S (S n))) (natural-square (β (S n)) (β n x) idp idp)))
η∞-in n x = & coh  (push∞-β n x)
                   (& (coh-ope1 (α∞ ⋆A)))
                   (& (ope1-idf (in∞ (S n))))
                   (natural-square-β δ∞ (push∞ n x) (push∞-βd n x))
                   (& (ap-square-natural-square (in∞ (S (S n)))) (β n x) (β (S n)) ∙idp ∙idp)
                   (& (natural-square∙! (β n x)) (push∞ (S n)) (ap (in∞ (S (S n))) ∘ β (S n)))
                   (& (natural-square-∘ (β n x) (in∞ (S n))) δ∞ idp idp)
                   (& (natural-square-∙! (push∞ n x) (ap (in∞ (S n)) (β n x))) δ∞)
                where
  coh-ope1 : {A B : Type i} (f : A → B)
           → Coh ({x y : A} {p : x == y}
                  {z : A} {q : z == y} {fq : f z == f y} {r : ap f q == fq}
                  → ap-∙! f p q == ope1 f idp r idp ∙ (idp ∙!² ! r))
  coh-ope1 f = path-induction
  -- X = apin∞SS
  coh : Coh ({A : Type i} {a b : A} {push∞Sα : a == b} {c : A} {apin∞Sβ : a == c} {d : A} {XapιSβ : b == d}
        {f : A} {Xγ : f == b} {XβSι : f == d} {apinη : Square Xγ idp XapιSβ XβSι}
        {push∞Sι : c == d} {natpush∞Sβ : Square push∞Sα apin∞Sβ XapιSβ push∞Sι}
        {e : A} {XβSα : e == b} {XapαSβ : e == f} {natβSβ : Square XβSα XapαSβ XapιSβ XβSι}
        {g : A} {p : g == c}
        {rs : a == f}
        (rs= : rs == push∞Sα ∙ ! Xγ)
        {z : _}
        {z= : z == rs ∙ ! XapαSβ}
        {t : _} {t= : t == XapαSβ}
        {fpq= : z == rs ∙ ! t}
        (fpq== : fpq= == z= ∙ (idp ∙!² ! t=))
        {pq=' : _} (pq== : pq=' == idp)
        {α' : _} (α= : α' == (& δ∞Push∞.coh p apinη natpush∞Sβ rs=))
        {γ' : _} (γ= : natβSβ == γ')
        {βγ : _} (βγ=comp : βγ == vcomp! natpush∞Sβ γ')
        {βγ' : _} (βγ= : βγ == βγ')
        {sq : _} (sq= : FlatCube sq (α' ∙□ !² βγ') idp pq=' z= idp)
      → Cube (horiz-degen-square (& (ηIfy.coh α∞ δ∞) sq))
             apinη
             (& γ∞In.coh rs= fpq= t=)
             vid-square
             comp-square
             (skew natβSβ))
  coh = path-induction
-- The two maps
{-<twomaps>-}
to : J∞A → JA
to = J∞A-rec inJ pushJ
from : JA → J∞A
from = JA-rec ε∞ α∞ δ∞
{-</>-}
-- Rules which better match the intuitive definition of [pushJ n x]
to-push∞ : (n : ℕ) (x : J n) → Square (ap to (push∞ n x)) idp (inJS-ι n x) (δJ (inJ n x))
to-push∞ n x = & coh (push∞-β n x)  where
  coh : Coh ({A : Type i} {a b : A} {p : a == b} {c : A} {q : c == b} {r : a == c} (r= : r == p ∙ ! q) → Square r idp q p)
  coh = path-induction
to-push∞-S : (n : ℕ) (x : J (S n)) → ap to (push∞ (S n) x) == δJ (inJ (S n) x)
to-push∞-S n x = horiz-degen-path (to-push∞ (S n) x)
ap-from-αJ : (a : A) {x y : JA} (p : x == y) → ap from (ap (αJ a) p) == ap (α∞ a) (ap from p)
ap-from-αJ a p = ∘-ap _ _ _ ∙ ap-∘ _ _ _
ap-square-from-αJ : (a : A) {x y z t : JA} {p : x == y} {q : x == z} {r : y == t} {s : z == t} (sq : Square p q r s)
  → FlatCube (ap-square from (ap-square (αJ a) sq))
             (ap-square (α∞ a) (ap-square from sq))
             (ap-from-αJ _ _) (ap-from-αJ _ _)
             (ap-from-αJ _ _) (ap-from-αJ _ _)
ap-square-from-αJ a ids = idfc
-- Abbreviation for the natural square of [δJ]
ap-δJ : {x y : JA} (p : x == y) → Square (δJ x) p (ap (αJ ⋆A) p) (δJ y)
ap-δJ p = natural-square δJ p (ap-idf p) idp
 
 | 
	{
  "alphanum_fraction": 0.4047413205,
  "avg_line_length": 36.9361344538,
  "ext": "agda",
  "hexsha": "957a8f6e88d94ac677619d1fe28b8ec7ccff7076",
  "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": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "guillaumebrunerie/JamesConstruction",
  "max_forks_repo_path": "JamesTwoMaps.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b",
  "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": "guillaumebrunerie/JamesConstruction",
  "max_issues_repo_path": "JamesTwoMaps.agda",
  "max_line_length": 175,
  "max_stars_count": 5,
  "max_stars_repo_head_hexsha": "89fbc29473d2d1ed1a45c3c0e56288cdcf77050b",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "guillaumebrunerie/JamesConstruction",
  "max_stars_repo_path": "JamesTwoMaps.agda",
  "max_stars_repo_stars_event_max_datetime": "2018-11-16T22:10:16.000Z",
  "max_stars_repo_stars_event_min_datetime": "2016-12-07T04:34:52.000Z",
  "num_tokens": 10346,
  "size": 21977
} 
 | 
					
	
module Numeric.Nat.LCM where
open import Prelude
open import Numeric.Nat.Divide
open import Numeric.Nat.Divide.Properties
open import Numeric.Nat.GCD
open import Numeric.Nat.GCD.Extended
open import Numeric.Nat.GCD.Properties
open import Numeric.Nat.Properties
open import Tactic.Nat
--- Least common multiple ---
record IsLCM m a b : Set where
  no-eta-equality
  constructor is-lcm
  field
    a|m : a Divides m
    b|m : b Divides m
    l   : ∀ k → a Divides k → b Divides k → m Divides k
record LCM a b : Set where
  no-eta-equality
  constructor lcm-res
  field
    m : Nat
    isLCM : IsLCM m a b
open LCM using () renaming (m to get-lcm) public
eraseIsLCM : ∀ {a b m} → IsLCM m a b → IsLCM m a b
eraseIsLCM (is-lcm a|m b|m g) = is-lcm (fast-divides a|m) (fast-divides b|m)
                                       λ k a|k b|k → fast-divides (g k a|k b|k)
eraseLCM : ∀ {a b} → LCM a b → LCM a b
eraseLCM (lcm-res m p) = lcm-res m (eraseIsLCM p)
private
  lem-is-lcm : ∀ {a b d} (g : IsGCD d a b) →
               IsLCM (is-gcd-factor₁ g * b) a b
  lem-is-lcm {a} {b} {0} (is-gcd (factor q eq) d|b g)
             rewrite a ≡⟨ by eq ⟩ 0 ∎ | divides-zero d|b | q * 0 ≡⟨ auto ⟩ 0 ∎ =
    is-lcm divides-refl divides-refl (λ _ 0|k _ → 0|k)
  lem-is-lcm {a} {b} {d@(suc d′)} isg@(is-gcd (factor! q) d|b@(factor! q′) g) =
    is-lcm (divides-mul-cong-l q d|b)
           (divides-mul-r q divides-refl) least
    where
      lem : IsGCD d a b
      lem = is-gcd (factor! q) d|b g
      lem₂ : Coprime q q′
      lem₂ = is-gcd-factors-coprime lem
      least : ∀ k → a Divides k → b Divides k → (q * b) Divides k
      least k (factor qa qa=k) (factor qb qb=k) =
        case lem₄ of λ where
          (factor! qqb) → factor qqb (by qb=k)
        where
          lem₃ : qa * q ≡ q′ * qb
          lem₃ = mul-inj₁ (qa * q) (q′ * qb) (suc d′)
                 (by (qa=k ⟨≡⟩ʳ qb=k))
          lem₄ : q Divides qb
          lem₄ = coprime-divide-mul-l q q′ qb (is-gcd-factors-coprime isg)
                 (factor qa lem₃)
lcm : ∀ a b → LCM a b
lcm a b = eraseLCM $
  case gcd a b of λ where
    (gcd-res d g) →
      lcm-res (is-gcd-factor₁ g * b) (lem-is-lcm g)
lcm! : Nat → Nat → Nat
lcm! a b = get-lcm (lcm a b)
 
 | 
	{
  "alphanum_fraction": 0.5666066607,
  "avg_line_length": 29.2368421053,
  "ext": "agda",
  "hexsha": "8a4bd1c5c57b6bffd5ddc57ba6cd78334e24addd",
  "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": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "lclem/agda-prelude",
  "max_forks_repo_path": "src/Numeric/Nat/LCM.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
  "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": "lclem/agda-prelude",
  "max_issues_repo_path": "src/Numeric/Nat/LCM.agda",
  "max_line_length": 80,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "lclem/agda-prelude",
  "max_stars_repo_path": "src/Numeric/Nat/LCM.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 838,
  "size": 2222
} 
 | 
					
	module Vector where
infixr 10 _∷_
data ℕ : Set where
  zero : ℕ
  suc  : ℕ → ℕ
{-# BUILTIN NATURAL ℕ    #-}
{-# BUILTIN ZERO    zero #-}
{-# BUILTIN SUC     suc  #-}
infixl 6 _+_
_+_ : ℕ → ℕ → ℕ
0 + n = n
suc m + n = suc (m + n)
data Vec (A : Set) : ℕ → Set where
  []  : Vec A 0
  _∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
_++_ : ∀ {A n m} → Vec A n → Vec A m → Vec A (n + m)
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
infix 4 _≡_
data _≡_ {A : Set} (x : A) : A → Set where
  refl : x ≡ x
subst : {A : Set} → (P : A → Set) → ∀{x y} → x ≡ y → P x → P y
subst P refl p = p
cong : {A B : Set} (f : A → B) → {x y : A} → x ≡ y → f x ≡ f y
cong f refl = refl
vec : ∀ {A} (k : ℕ) → Set
vec {A} k = Vec A k
plus_zero : {n : ℕ} → n + 0 ≡ n 
plus_zero {zero}  = refl
plus_zero {suc n} = cong suc plus_zero
plus_suc : {n : ℕ} → n + (suc 0) ≡ suc n 
plus_suc {zero}  = refl
plus_suc {suc n} = cong suc (plus_suc {n})
reverse : ∀ {A n} → Vec A n → Vec A n
reverse []       = []
reverse {A} {suc n} (x ∷ xs) = subst vec (plus_suc {n}) (reverse xs ++ (x ∷ []))
 
 | 
	{
  "alphanum_fraction": 0.4788732394,
  "avg_line_length": 20.4807692308,
  "ext": "agda",
  "hexsha": "10381222abae558cfd1a3d3a5e6bf9cd74634bd7",
  "lang": "Agda",
  "max_forks_count": 339,
  "max_forks_repo_forks_event_max_datetime": "2022-03-26T17:55:39.000Z",
  "max_forks_repo_forks_event_min_datetime": "2015-01-01T19:23:43.000Z",
  "max_forks_repo_head_hexsha": "c64f5d26e299be85b85e1c370a7a5de6037e2e3e",
  "max_forks_repo_licenses": [
    "BSD-Source-Code"
  ],
  "max_forks_repo_name": "aavogt/wiwinwlh",
  "max_forks_repo_path": "src/17-promotion/Vector.agda",
  "max_issues_count": 151,
  "max_issues_repo_head_hexsha": "c64f5d26e299be85b85e1c370a7a5de6037e2e3e",
  "max_issues_repo_issues_event_max_datetime": "2021-06-29T15:20:06.000Z",
  "max_issues_repo_issues_event_min_datetime": "2015-01-16T07:43:41.000Z",
  "max_issues_repo_licenses": [
    "BSD-Source-Code"
  ],
  "max_issues_repo_name": "aavogt/wiwinwlh",
  "max_issues_repo_path": "src/17-promotion/Vector.agda",
  "max_line_length": 80,
  "max_stars_count": 2479,
  "max_stars_repo_head_hexsha": "c64f5d26e299be85b85e1c370a7a5de6037e2e3e",
  "max_stars_repo_licenses": [
    "BSD-Source-Code"
  ],
  "max_stars_repo_name": "aavogt/wiwinwlh",
  "max_stars_repo_path": "src/17-promotion/Vector.agda",
  "max_stars_repo_stars_event_max_datetime": "2022-03-29T15:34:03.000Z",
  "max_stars_repo_stars_event_min_datetime": "2015-01-01T14:39:03.000Z",
  "num_tokens": 475,
  "size": 1065
} 
 | 
					
	module Data.Vec.Exts where
open import Data.Fin
open import Data.Maybe
open import Data.Nat
open import Data.Vec using (Vec; []; _∷_)
open import Relation.Nullary
open import Relation.Unary
open import Data.Vec.Relation.Unary.Any
findIndex : {n : ℕ} {A : Set} {P : A -> Set} -> Decidable P -> Vec A n -> Maybe (Fin n)
findIndex P? xs with any? P? xs
... | yes ix = just (index ix)
... | no _ = nothing
 
 | 
	{
  "alphanum_fraction": 0.6806930693,
  "avg_line_length": 26.9333333333,
  "ext": "agda",
  "hexsha": "d0af7257e32b10848d04ecb3f0fdadf348b9f207",
  "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/Data/Vec/Exts.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/Data/Vec/Exts.agda",
  "max_line_length": 87,
  "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/Data/Vec/Exts.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": 125,
  "size": 404
} 
 | 
					
	module Ag10 where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl)
open Eq.≡-Reasoning
open import Data.Nat using (ℕ)
open import Function using (_∘_)
open import Ag09 using (_≃_; _≲_; extensionality; _⇔_)
open Ag09.≃-Reasoning
open import Data.Product using (_×_; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩)
open import Data.Unit using (⊤; tt)
open import Data.Sum using (_⊎_; inj₁; inj₂) renaming ([_,_] to case-⊎)
open import Data.Empty using (⊥; ⊥-elim)
import Function.Equivalence using (_⇔_)
⇔≃× : ∀ {A B : Set} → (A ⇔ B) ≃ ((A → B) × (B → A))
⇔≃× =
  record
  { to = λ{ x → ⟨ Ag09._⇔_.to x , Ag09._⇔_.from x ⟩}
  ; from = λ{ ⟨ x , y ⟩ → record { to = x ; from = y } }
  ; from∘to = λ{ x → refl }
  ; to∘from = λ{ x → refl }
  }
⊎-comm : ∀ {A B : Set} → (A ⊎ B) ≃ (B ⊎ A)
⊎-comm =
  record
  { to = λ{ (inj₁ x) → inj₂ x ; (inj₂ y) → inj₁ y }
  ; from =  λ{ (inj₁ x) → inj₂ x ; (inj₂ y) → inj₁ y}
  ; from∘to = λ{ (inj₁ x) → refl ; (inj₂ y) → refl }
  ; to∘from = λ{ (inj₁ x) → refl ; (inj₂ y) → refl}
  }
⊎-assoc : ∀ {A B C : Set} → (A ⊎ B) ⊎ C ≃ A ⊎ (B ⊎ C)
⊎-assoc =
  record
  { to = λ{ (inj₁ (inj₁ x)) → inj₁ x ; (inj₁ (inj₂ y)) → inj₂ (inj₁ y) ; (inj₂ z) → inj₂ (inj₂ z) }
  ; from = λ{ (inj₁ x) → inj₁ (inj₁ x) ; (inj₂ (inj₁ y)) → inj₁ (inj₂ y) ; (inj₂ (inj₂ z)) → inj₂ z }
  ; from∘to = λ{ (inj₁ (inj₁ x)) → refl ; (inj₁ (inj₂ y)) → refl ; (inj₂ z) → refl }
  ; to∘from = λ{ (inj₁ x) → refl ; (inj₂ (inj₁ y)) → refl ; (inj₂ (inj₂ z)) → refl }
  }
⊥-identityˡ : ∀ {A : Set} → ⊥ ⊎ A ≃ A
⊥-identityˡ = 
    record
    { to = λ{ (inj₂ a) → a }
    ; from = λ{ a → (inj₂ a) }
    ; from∘to = λ{ (inj₂ a) → refl }
    ; to∘from = λ{ a → refl }
    }
⊥-identityʳ : ∀ {A : Set} → A ⊎ ⊥ ≃ A
⊥-identityʳ {A} =
    ≃-begin
      (A ⊎ ⊥)
    ≃⟨ ⊎-comm ⟩
      (⊥ ⊎ A)
    ≃⟨ ⊥-identityˡ ⟩
      A
    ≃-∎
 
⊎-weak-× : ∀ {A B C : Set} → (A ⊎ B) × C → A ⊎ (B × C)
⊎-weak-× ⟨ inj₁ x , snd ⟩ = inj₁ x
⊎-weak-× ⟨ inj₂ y , snd ⟩ = inj₂ ⟨ y , snd ⟩
⊎×-implies-×⊎ : ∀ {A B C D : Set} → (A × B) ⊎ (C × D) → (A ⊎ C) × (B ⊎ D)
⊎×-implies-×⊎ (inj₁ ⟨ fst , snd ⟩) = ⟨ inj₁ fst , inj₁ snd ⟩
⊎×-implies-×⊎ (inj₂ ⟨ fst , snd ⟩) = ⟨ inj₂ fst , inj₂ snd ⟩
 
 | 
	{
  "alphanum_fraction": 0.4891655141,
  "avg_line_length": 30.9857142857,
  "ext": "agda",
  "hexsha": "47019599a9d30a9291ccb0cdfe58c390004dc1bd",
  "lang": "Agda",
  "max_forks_count": 1,
  "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z",
  "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z",
  "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "Brethland/LEARNING-STUFF",
  "max_forks_repo_path": "Agda/Ag10.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
  "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": "Brethland/LEARNING-STUFF",
  "max_issues_repo_path": "Agda/Ag10.agda",
  "max_line_length": 101,
  "max_stars_count": 2,
  "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "Brethland/LEARNING-STUFF",
  "max_stars_repo_path": "Agda/Ag10.agda",
  "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z",
  "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z",
  "num_tokens": 1088,
  "size": 2169
} 
 | 
					
	module Issue846.Imports where
open import Data.Nat public using (ℕ; zero; suc; _≤_; _∸_)
open import Data.List public using (List; []; _∷_)
open import Data.Bool public using (Bool; true; false; not)
open import Data.Nat.DivMod public using (_mod_)
open import Data.Fin public using (Fin; toℕ; zero; suc)
open import Relation.Binary.PropositionalEquality public using (_≡_; _≢_; cong)
open import Relation.Binary public using (nonEmpty) -- this is the bad guy
open import Issue846.DivModUtils public using (1'; lem-sub-p)
record Move : Set where
  constructor pick
  field
    picked : ℕ
    1≤n    : 1 ≤ picked
    n≤6    : picked ≤ 6
open Move using (picked)
Strategy = ℕ → Move
{-# NO_TERMINATION_CHECK #-}
play : ℕ → Strategy → Strategy → List ℕ
play 0 _ _ = []
play n p1 p2 = n ∷ play (n ∸ picked (p1 n)) p2 p1
postulate
  opt : Strategy
evenList : {A : Set} → List A → Bool
evenList [] = true
evenList (_ ∷ xs) = not (evenList xs)
winner : ℕ → Strategy → Strategy → Bool
winner n p1 p2 = evenList (play n p1 p2)
postulate
  opt-is-opt : ∀ n s → n mod 7 ≢ 1' → winner n opt s ≡ true 
 
 | 
	{
  "alphanum_fraction": 0.6757493188,
  "avg_line_length": 26.8536585366,
  "ext": "agda",
  "hexsha": "22c7187d0dbd8705989eca12068fdb360fa681f2",
  "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/lib-succeed/Issue846/Imports.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/lib-succeed/Issue846/Imports.agda",
  "max_line_length": 79,
  "max_stars_count": 1,
  "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "larrytheliquid/agda",
  "max_stars_repo_path": "test/lib-succeed/Issue846/Imports.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": 349,
  "size": 1101
} 
 | 
					
	------------------------------------------------------------------------------
-- FOTC terms properties
------------------------------------------------------------------------------
{-# OPTIONS --exact-split              #-}
{-# OPTIONS --no-sized-types           #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K                #-}
module FOTC.Base.PropertiesI where
open import Common.FOL.Relation.Binary.EqReasoning
open import FOTC.Base
------------------------------------------------------------------------------
-- Congruence properties
·-leftCong : ∀ {a b c} → a ≡ b → a · c ≡ b · c
·-leftCong refl = refl
·-rightCong : ∀ {a b c} → b ≡ c → a · b ≡ a · c
·-rightCong refl = refl
·-cong : ∀ {a b c d} → a ≡ b → c ≡ d → a · c ≡ b · d
·-cong refl refl = refl
succCong : ∀ {m n} → m ≡ n → succ₁ m ≡ succ₁ n
succCong refl = refl
predCong : ∀ {m n} → m ≡ n → pred₁ m ≡ pred₁ n
predCong refl = refl
ifCong₁ : ∀ {b b' t t'} → b ≡ b' →
          (if b then t else t') ≡ (if b' then t else t')
ifCong₁ refl = refl
ifCong₂ : ∀ {b t₁ t₂ t} → t₁ ≡ t₂ →
          (if b then t₁ else t) ≡ (if b then t₂ else t)
ifCong₂ refl = refl
ifCong₃ : ∀ {b t t₁ t₂} → t₁ ≡ t₂ →
          (if b then t else t₁) ≡ (if b then t else t₂)
ifCong₃ refl = refl
------------------------------------------------------------------------------
-- Injective properties
succInjective : ∀ {m n} → succ₁ m ≡ succ₁ n → m ≡ n
succInjective {m} {n} h =
  m                ≡⟨ sym (pred-S m) ⟩
  pred₁ (succ₁ m)  ≡⟨ predCong h ⟩
  pred₁ (succ₁ n)  ≡⟨ pred-S n ⟩
  n                ∎
------------------------------------------------------------------------------
-- Discrimination rules
S≢0 : ∀ {n} → succ₁ n ≢ zero
S≢0 S≡0 = 0≢S (sym S≡0)
 
 | 
	{
  "alphanum_fraction": 0.4137931034,
  "avg_line_length": 28.5245901639,
  "ext": "agda",
  "hexsha": "533d82fddcb738a650f198678b742d7d1631bf67",
  "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/PropertiesI.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/PropertiesI.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/PropertiesI.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": 543,
  "size": 1740
} 
 | 
					
	-- {-# OPTIONS -v interaction.case:20 -v tc.cover:20 #-}
-- Andreas, 2015-05-29, issue reported by Stevan Andjelkovic
record Cont : Set₁ where
  constructor _◃_
  field
    Sh  : Set
    Pos : Sh → Set
open Cont
data W (C : Cont) : Set where
  sup : (s : Sh C) (k : Pos C s → W C) → W C
-- If I case split on w:
bogus : {C : Cont} → W C → Set
bogus w = {!w!}
-- WAS internally :  bogus {Sh ◃ Pos} w = ?
-- WAS after split:  bogus {Sh ◃ Pos} (sup s k) = ?
-- NOW internally :  bogus {_} w = ?
-- NOW as expected:  bogus (sup s k) = ?
 
 | 
	{
  "alphanum_fraction": 0.5706319703,
  "avg_line_length": 23.3913043478,
  "ext": "agda",
  "hexsha": "c2c8d12dbeac6f7ee996f24804995c3e824da18b",
  "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/Issue635a.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/Issue635a.agda",
  "max_line_length": 60,
  "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/Issue635a.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": 197,
  "size": 538
} 
 | 
					
	{-# OPTIONS --safe #-}
module Cubical.Categories.Limits.Pullback where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.HITs.PropositionalTruncation.Base
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Categories.Category
open import Cubical.Categories.Functor
open import Cubical.Categories.Instances.Cospan
open import Cubical.Categories.Limits.Limits
private
  variable
    ℓ ℓ' : Level
module _ (C : Category ℓ ℓ') where
  open Category C
  open Functor
  record Cospan : Type (ℓ-max ℓ ℓ') where
    constructor cospan
    field
      l m r : ob
      s₁ : C [ l , m ]
      s₂ : C [ r , m ]
  open Cospan
  isPullback : (cspn : Cospan) →
    {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ])
    (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂) → Type (ℓ-max ℓ ℓ')
  isPullback cspn {c} p₁ p₂ H =
    ∀ {d} (h : C [ d , cspn .l ]) (k : C [ d , cspn .r ])
          (H' : h ⋆ cspn .s₁ ≡ k ⋆ cspn .s₂)
    → ∃![ hk ∈ C [ d , c ] ] (h ≡ hk ⋆ p₁) × (k ≡ hk ⋆ p₂)
  isPropIsPullback : (cspn : Cospan) →
    {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ])
    (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂) → isProp (isPullback cspn p₁ p₂ H)
  isPropIsPullback cspn p₁ p₂ H =
    isPropImplicitΠ (λ x → isPropΠ3 λ h k H' → isPropIsContr)
  record Pullback (cspn : Cospan) : Type (ℓ-max ℓ ℓ') where
    field
      pbOb  : ob
      pbPr₁ : C [ pbOb , cspn .l ]
      pbPr₂ : C [ pbOb , cspn .r ]
      pbCommutes : pbPr₁ ⋆ cspn .s₁ ≡ pbPr₂ ⋆ cspn .s₂
      univProp : isPullback cspn pbPr₁ pbPr₂ pbCommutes
  open Pullback
  pullbackArrow :
    {cspn : Cospan} (pb : Pullback cspn)
    {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ])
    (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂) → C [ c , pb . pbOb ]
  pullbackArrow pb p₁ p₂ H = pb .univProp p₁ p₂ H .fst .fst
  pullbackArrowPr₁ :
    {cspn : Cospan} (pb : Pullback cspn)
    {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ])
    (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂) →
    p₁ ≡ pullbackArrow pb p₁ p₂ H ⋆ pbPr₁ pb
  pullbackArrowPr₁ pb p₁ p₂ H = pb .univProp p₁ p₂ H .fst .snd .fst
  pullbackArrowPr₂ :
    {cspn : Cospan} (pb : Pullback cspn)
    {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ])
    (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂) →
    p₂ ≡ pullbackArrow pb p₁ p₂ H ⋆ pbPr₂ pb
  pullbackArrowPr₂ pb p₁ p₂ H = pb .univProp p₁ p₂ H .fst .snd .snd
  pullbackArrowUnique :
    {cspn : Cospan} (pb : Pullback cspn)
    {c : ob} (p₁ : C [ c , cspn .l ]) (p₂ : C [ c , cspn .r ])
    (H : p₁ ⋆ cspn .s₁ ≡ p₂ ⋆ cspn .s₂)
    (pbArrow' : C [ c , pb .pbOb ])
    (H₁ : p₁ ≡ pbArrow' ⋆ pbPr₁ pb) (H₂ : p₂ ≡ pbArrow' ⋆ pbPr₂ pb)
    → pullbackArrow pb p₁ p₂ H ≡ pbArrow'
  pullbackArrowUnique pb p₁ p₂ H pbArrow' H₁ H₂ =
    cong fst (pb .univProp p₁ p₂ H .snd (pbArrow' , (H₁ , H₂)))
  Pullbacks : Type (ℓ-max ℓ ℓ')
  Pullbacks = (cspn : Cospan) → Pullback cspn
  hasPullbacks : Type (ℓ-max ℓ ℓ')
  hasPullbacks = ∥ Pullbacks ∥₁
-- Pullbacks from limits
module _ {C : Category ℓ ℓ'} where
  open Category C
  open Functor
  open Pullback
  open LimCone
  open Cone
  open Cospan
  Cospan→Func : Cospan C → Functor CospanCat C
  Cospan→Func (cospan l m r f g) .F-ob ⓪ = l
  Cospan→Func (cospan l m r f g) .F-ob ① = m
  Cospan→Func (cospan l m r f g) .F-ob ② = r
  Cospan→Func (cospan l m r f g) .F-hom {⓪} {①} k = f
  Cospan→Func (cospan l m r f g) .F-hom {②} {①} k = g
  Cospan→Func (cospan l m r f g) .F-hom {⓪} {⓪} k = id
  Cospan→Func (cospan l m r f g) .F-hom {①} {①} k = id
  Cospan→Func (cospan l m r f g) .F-hom {②} {②} k = id
  Cospan→Func (cospan l m r f g) .F-id {⓪} = refl
  Cospan→Func (cospan l m r f g) .F-id {①} = refl
  Cospan→Func (cospan l m r f g) .F-id {②} = refl
  Cospan→Func (cospan l m r f g) .F-seq {⓪} {⓪} {⓪} φ ψ = sym (⋆IdL _)
  Cospan→Func (cospan l m r f g) .F-seq {⓪} {⓪} {①} φ ψ = sym (⋆IdL _)
  Cospan→Func (cospan l m r f g) .F-seq {⓪} {①} {①} φ ψ = sym (⋆IdR _)
  Cospan→Func (cospan l m r f g) .F-seq {①} {①} {①} φ ψ = sym (⋆IdL _)
  Cospan→Func (cospan l m r f g) .F-seq {②} {②} {②} φ ψ = sym (⋆IdL _)
  Cospan→Func (cospan l m r f g) .F-seq {②} {②} {①} φ ψ = sym (⋆IdL _)
  Cospan→Func (cospan l m r f g) .F-seq {②} {①} {①} φ ψ = sym (⋆IdR _)
  LimitsOfShapeCospanCat→Pullbacks : LimitsOfShape CospanCat C → Pullbacks C
  pbOb (LimitsOfShapeCospanCat→Pullbacks H cspn) = lim (H (Cospan→Func cspn))
  pbPr₁ (LimitsOfShapeCospanCat→Pullbacks H cspn) = limOut (H (Cospan→Func cspn)) ⓪
  pbPr₂ (LimitsOfShapeCospanCat→Pullbacks H cspn) = limOut (H (Cospan→Func cspn)) ②
  pbCommutes (LimitsOfShapeCospanCat→Pullbacks H cspn) = limOutCommutes (H (Cospan→Func cspn)) {v = ①} tt
                          ∙ sym (limOutCommutes (H (Cospan→Func cspn)) tt)
  univProp (LimitsOfShapeCospanCat→Pullbacks H cspn) {d = d} h k H' =
    uniqueExists (limArrow (H (Cospan→Func cspn)) d cc)
                 ( sym (limArrowCommutes (H (Cospan→Func cspn)) d cc ⓪)
                 , sym (limArrowCommutes (H (Cospan→Func cspn)) d cc ②))
                 (λ _ → isProp× (isSetHom _ _) (isSetHom _ _))
                 λ a' ha' → limArrowUnique (H (Cospan→Func cspn)) d cc a'
                               (λ { ⓪ → sym (ha' .fst)
                                  ; ① → cong (a' ⋆_) (sym (limOutCommutes (H (Cospan→Func cspn)) {⓪} {①} tt))
                                      ∙∙ sym (⋆Assoc _ _ _)
                                      ∙∙ cong (_⋆ cspn .s₁) (sym (ha' .fst))
                                  ; ② → sym (ha' .snd) })
    where
    cc : Cone (Cospan→Func cspn) d
    coneOut cc ⓪ = h
    coneOut cc ① = h ⋆ cspn .s₁
    coneOut cc ② = k
    coneOutCommutes cc {⓪} {⓪} e = ⋆IdR h
    coneOutCommutes cc {⓪} {①} e = refl
    coneOutCommutes cc {①} {①} e = ⋆IdR _
    coneOutCommutes cc {②} {①} e = sym H'
    coneOutCommutes cc {②} {②} e = ⋆IdR k
  Limits→Pullbacks : Limits C → Pullbacks C
  Limits→Pullbacks H = LimitsOfShapeCospanCat→Pullbacks (H CospanCat)
 
 | 
	{
  "alphanum_fraction": 0.5695608448,
  "avg_line_length": 38.7402597403,
  "ext": "agda",
  "hexsha": "a872212b80e5bc814d29102895e2594cbc2acbfa",
  "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/Categories/Limits/Pullback.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/Categories/Limits/Pullback.agda",
  "max_line_length": 109,
  "max_stars_count": 1,
  "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "thomas-lamiaux/cubical",
  "max_stars_repo_path": "Cubical/Categories/Limits/Pullback.agda",
  "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
  "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
  "num_tokens": 2650,
  "size": 5966
} 
 | 
					
	{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
   Copyright (c) 2020, 2021, Oracle and/or its affiliates.
   Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.ImplShared.Base.Types
open import LibraBFT.Abstract.Types.EpochConfig UID NodeId
open import LibraBFT.Concrete.System
open import LibraBFT.Concrete.System.Parameters
open import LibraBFT.Impl.Consensus.EpochManagerTypes
import      LibraBFT.Impl.Consensus.Liveness.RoundState as RoundState
import      LibraBFT.Impl.IO.OBM.GenKeyFile             as GenKeyFile
open import LibraBFT.Impl.IO.OBM.InputOutputHandlers
import      LibraBFT.Impl.IO.OBM.Start                  as Start
open import LibraBFT.Impl.OBM.Rust.RustTypes
open import LibraBFT.Impl.OBM.Time
import      LibraBFT.Impl.Types.BlockInfo               as BlockInfo
import      LibraBFT.Impl.Types.ValidatorSigner         as ValidatorSigner
open import LibraBFT.Impl.Consensus.RoundManager
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Consensus.Types.EpochIndep
open import LibraBFT.ImplShared.Interface.Output
open import LibraBFT.ImplShared.Util.Crypto
open import LibraBFT.ImplShared.Util.Dijkstra.All
open import Optics.All
open import Util.ByteString
open import Util.Encode
open import Util.Hash
open import Util.KVMap as KVMap
open import Util.Lemmas
open import Util.PKCS
open import Util.Prelude
open import Yasm.Base
import      Yasm.Types as YT
-- This module connects implementation handlers to the interface of the SystemModel.
module LibraBFT.Impl.Handle where
open EpochConfig
------------------------------------------------------------------------------
-- This function works with any implementation of a RoundManager.
-- NOTE: The system layer only cares about this step function.
-- 0 is given as a timestamp.
peerStep : NodeId → NetworkMsg → RoundManager → RoundManager × List (YT.Action NetworkMsg)
peerStep nid msg st = runHandler st (handle nid msg 0)
 where
  -- This invokes an implementation handler.
  runHandler : RoundManager → LBFT Unit → RoundManager × List (YT.Action NetworkMsg)
  runHandler st handler = ×-map₂ (outputsToActions {st}) (proj₂ (LBFT-run handler st))
------------------------------------------------------------------------------
-- This connects the implementation handler to the system model so it can be initialized.
module InitHandler where
  {-
  IMPL-DIFF: In Haskell, nodes are started with a filepath of a file containing
  - number of faults allowed
  - genesis LedgerInfoWithSignatures
  - network addresses/name and secret and public keys of all nodes in the genesis epoch
  Main reads/checks that file then calls a network specific 'run' functions (e.g., ZMQ.hs)
  that setup the network handlers then eventually call 'Start.startViaConsensusProvider'.
  That functions calls 'ConsensusProvider.startConsensus' which returns
  '(EpochManager, [Output]'.
  'Start.startViaConsensusProvider' then goes on to create and wire up internal communication
  channels and starts threads.  The most relevant thread starts up
  `(EpochManager.obmStartLoop epochManager output ...)' to handle the initialization output
  and then to handle new messages from the network.
  In Agda below,
  - we assume 'BootstrapInfo' known to all peers
    - i.e., the same info that Haskell creates via 'GenKeyFile.create'
    - the assumed info is given to 'mkSysInitAndHandlers' in 'InitAndHandlers'
  - System initialization calls 'initHandler'
  - 'initHandler' eventually calls 'initialize'
  - 'initialize' calls 'State.startViaConsensusProvider'
    when then calls 'ConsensusProvider.startConsensus' which returns
    '(EpochManager, List Output)', just like Haskell.
  - Since there is no network, internal channels and threads, this is the end of this process.
  Note: although both the Haskell and Agda version support non-uniform voting, the
  above initialization process assumes one-vote per peer.
  -}
  postulate -- TODO-2: Eliminate when/if timestamps are modeled
    now : Instant
  proposalGenerator : ProposalGenerator
  proposalGenerator = ProposalGenerator∙new 0
  initialize-ed : Instant → GenKeyFile.NfLiwsVsVvPe → EitherD ErrLog (EpochManager × List Output)
  initialize-ed now nfLiwsVsVvPe =
    Start.startViaConsensusProvider-ed-abs
      now nfLiwsVsVvPe
      (TxTypeDependentStuffForNetwork∙new
        proposalGenerator
        (StateComputer∙new BlockInfo.gENESIS_VERSION))
  abstract
    initialize-ed-abs  = initialize-ed
    initialize-ed-abs≡ : initialize-ed-abs ≡ initialize-ed
    initialize-ed-abs≡ = refl
  mkNfLiwsVsVvPe : BootstrapInfo → ValidatorSigner → GenKeyFile.NfLiwsVsVvPe
  mkNfLiwsVsVvPe bsi vs = (bsi ^∙ bsiNumFaults , bsi ^∙ bsiLIWS , vs , bsi ^∙ bsiVV , bsi ^∙ bsiPE)
  -- No need to break this one into steps, no decision points
  initEMWithOutput-ed : BootstrapInfo → ValidatorSigner
                      → EitherD ErrLog (EpochManager × List Output)
  initEMWithOutput-ed  bsi vs =
    initialize-ed-abs now (mkNfLiwsVsVvPe bsi vs)
  abstract
    initEMWithOutput-e-abs : BootstrapInfo → ValidatorSigner
                           → Either ErrLog (EpochManager × List Output)
    initEMWithOutput-e-abs bsi vs = toEither $ initEMWithOutput-ed bsi vs
    initEMWithOutput-ed-abs = initEMWithOutput-ed
    initEMWithOutput-ed-abs≡ : initEMWithOutput-ed-abs ≡ initEMWithOutput-ed
    initEMWithOutput-ed-abs≡ = refl
    -- This shows that the Either and EitherD versions are equivalent.
    -- This is a first step towards eliminating the painful VariantOf stuff,
    -- so we can have the version that looks (almost) exactly like the Haskell,
    -- and the EitherD variant, broken into explicit steps, etc. for proving.
    initEMWithOutput≡
      : ∀ {bsi : BootstrapInfo} {vs : ValidatorSigner}
      → initEMWithOutput-e-abs bsi vs ≡ EitherD-run (initEMWithOutput-ed-abs bsi vs)
    initEMWithOutput≡ {bsi} {vs} = refl
  getEmRm-ed : EpochManager → EitherD ErrLog RoundManager
  getEmRm-ed em =
    case em ^∙ emProcessor of λ where
      nothing  → LeftD fakeErr
      (just p) → case p of λ where
                   (RoundProcessorRecovery _) → LeftD fakeErr
                   (RoundProcessorNormal rm)  → RightD rm
  abstract
    getEmRm-ed-abs : EpochManager → EitherD ErrLog RoundManager
    getEmRm-ed-abs = getEmRm-ed
    getEmRm-ed-abs≡ : getEmRm-ed-abs ≡ getEmRm-ed
    getEmRm-ed-abs≡ = refl
    getEmRm-e-abs : EpochManager → Either ErrLog RoundManager
    getEmRm-e-abs = toEither ∘ getEmRm-ed-abs
  postulate -- TODO
   getEMRM≡
    : ∀ {em : EpochManager}
    → getEmRm-e-abs em ≡ EitherD-run (getEmRm-ed-abs em)
  -- Below is a small exploration in how we define, use, and prove properties about functions in the
  -- Either monad.  We would like to:
  --
  -- * use the EitherD-weakestPre machinery to help structure proofs
  -- * avoid functions being "unrolled" in proof states to make them more readable and proofs more
  --   robust to change
  -- * break functions in to smaller pieces with names and explicit type signatures, making it
  --   easier to employ the EitherD machinery, especially for those not yet fluent using it
  -- * be able to easily compare the Agda code to the Haskell code it models
  --
  -- These desires entail some tradeoffs.  The exploration below helps to illustrate the
  -- possibilities.  We first express the initRMWithOutput function in several different ways, with
  -- different suffixes to clarify which is which.
  --
  -- * initRMWithOutput-e
  --   - An Either version that is virtually identical to the Haskell
  -- * initRMWithOutput-ed
  --   - An EitherD version broken into steps
  -- * Abstract versions of each of these, two for initRMWithOutput-e (initRMWithOutput-e-abs and
  --   initRMWithOutput-e-abs1) and one for initRMWithOutput-ed (initRMWithOutput-ed-abs).
  --   initRMWithOutput-e-abs is defined simply using initRMWithOutput-ed and toEither, whereas
  --   initRMWithOutput-e-abs1 is defined using initRMWithOutput-e.  We also prove below a number of
  --   properties showing that these are all equivalent (in the sense that the Either versions
  --   return the same value as EitherD-run when given the EitherD version).  These proofs serve as
  --   useful rewrites in various proofs, as illustrated in the proof of
  --   initRMWithOutputSpec.contract and of initRMWithOutput-e-versions-≡ below.
  --
  -- While it is nice to have both versions and prove their equivalence (one for relating to Haskell
  -- code, one for proving using the EitherD machinery), it does entail extra work and may be
  -- overkill.  With a little experience, it's probably not too difficult in most cases to compare
  -- the original Haskell code to the EitherD version broken into steps, and to convince oneself
  -- that the latter faithfully reflects the former.  If we keep some examples (such as this one)
  -- showing a function written in Either and an "equivalent" one written in EitherD, broken into
  -- steps, etc. for proof convenience, then this may help people who are not (yet) comfortable with
  -- this translation to become more comfortable.
  --
  -- In some cases, the EitherD proof-friendly version may depart further from the Haskell-like
  -- version, and for such cases, it may be worthwhile to write the Haskell-equivalent version.
  -- This makes proving that the Either and EitherD versions are "equivalent" a bit more work
  -- (compare initRMWithOutput≡ and initRMWithOutput≡' below, and note in particular that the latter
  -- requires properties about the functions called as well).  Of course, writing both versions is
  -- too extra work too.  In general, it's question of judgement whether we're OK with considering
  -- that the Either version defined using toEither and the EitherD version is sufficiently
  -- obviously equivalent to the Haskell code we're modeling.
  --
  -- Tentative conclusion
  --
  -- Default to writing the proof-friendly EitherD version and defining the Either version in terms
  -- of it.  For cases in which the correspondence is judged not to be obvious enough, we can add an
  -- explicit Either version and prove that is is equivalent.
  --
  -- Calling convention
  --
  -- When calling a function within and EitherD function, we should call an abstract version of that
  -- function, which ensures modularity of proofs and readability of proof states by avoiding Agda
  -- "unrolling" defintions prematurely.  Similarly, for cases in which we do write an explicit
  -- Either version and prove it equivalent, we should also call an abstract version of Either
  -- functions.
  -- Relationship to "VariantFor"
  --
  -- We have previously defined variants for functions in EitherLike monads using EL-func (search
  -- for VariantFor).  In light of the above exploration, perhaps that machinery adds less value
  -- than it is worth?  It seems we can get everything we need from following simple conventions as
  -- outlined above.
  initRMWithOutput-e : BootstrapInfo → ValidatorSigner → Either ErrLog (RoundManager × List Output)
  initRMWithOutput-e bsi vs = do
    (em , lo) ← initEMWithOutput-e-abs bsi vs
    rm        ← getEmRm-e-abs em
    Right (rm , lo)
  module initRMWithOutput-ed (bsi : BootstrapInfo) (vs : ValidatorSigner) where
    step₀ : EitherD ErrLog (RoundManager × List Output)
    step₁ : EpochManager × List Output → EitherD ErrLog (RoundManager × List Output)
    step₀ = do
      (em , lo) ← initEMWithOutput-ed-abs bsi vs
      step₁ (em , lo)
    step₁ (em , lo) = do
      rm        ← getEmRm-ed-abs em
      RightD (rm , lo)
  abstract
    initRMWithOutput-e-abs initRMWithOutput-e-abs1
      : BootstrapInfo → ValidatorSigner
      → Either ErrLog (RoundManager × List Output)
    -- Avoids duplication, but eliminates version that looks exactly like the Haskell
    initRMWithOutput-e-abs bsi vs = toEither $ initRMWithOutput-ed.step₀ bsi vs
    initRMWithOutput-ed-abs  = initRMWithOutput-ed.step₀
    initRMWithOutput-ed-abs≡ : initRMWithOutput-ed-abs ≡ initRMWithOutput-ed.step₀
    initRMWithOutput-ed-abs≡ = refl
    initRMWithOutput-e-abs1 = initRMWithOutput-e
    initRMWithOutput-e-abs1≡ : initRMWithOutput-e-abs1 ≡ initRMWithOutput-e
    initRMWithOutput-e-abs1≡ = refl
    initRMWithOutput≡ :
      ∀ {bsi : BootstrapInfo} {vs : ValidatorSigner}
      → initRMWithOutput-e-abs bsi vs ≡ EitherD-run (initRMWithOutput-ed-abs bsi vs)
    initRMWithOutput≡ {bsi} {vs} = refl
  initRMWithOutput≡'
    : ∀ {bsi : BootstrapInfo} {vs : ValidatorSigner}
    → initRMWithOutput-e-abs1 bsi vs ≡ EitherD-run (initRMWithOutput-ed.step₀ bsi vs)
  initRMWithOutput≡' {bsi} {vs} rewrite initRMWithOutput-e-abs1≡ | initEMWithOutput≡ {bsi} {vs}
     with EitherD-run (initEMWithOutput-ed-abs bsi vs)
  ... | Left  x = refl
  ... | Right (em , lo) rewrite getEMRM≡ {em}
     with EitherD-run (getEmRm-ed-abs em)
  ... | Left x  = refl
  ... | Right y = refl
  -- Not used, just for satisfying ourselves that the versions really are equivalent, and
  -- demonstrating the use of the various equivalences for rewriting.
  initRMWithOutput-e-versions-≡ :
    ∀ {bsi} {vs}
    → initRMWithOutput-e-abs1 bsi vs ≡ initRMWithOutput-e-abs bsi vs
  initRMWithOutput-e-versions-≡ {bsi} {vs}
    rewrite initRMWithOutput≡' {bsi} {vs}
          | initRMWithOutput≡  {bsi} {vs}
          | initRMWithOutput-ed-abs≡ = refl
  initHandler : Author → BootstrapInfo → Maybe (RoundManager × List (YT.Action NetworkMsg))
  initHandler pid bsi =
   case ValidatorSigner.obmGetValidatorSigner pid (bsi ^∙ bsiVSS) of λ where
     (Left _)   → nothing
     (Right vs) →
       case initRMWithOutput-e-abs bsi vs of λ where
         (Left _)          → nothing
         (Right (rm , lo)) → just (rm , outputsToActions {State = rm} lo)
  initAndHandlers : SystemInitAndHandlers ℓ-RoundManager ConcSysParms
  initAndHandlers =
    mkSysInitAndHandlers
      fakeBootstrapInfo
      fakeInitRM
      initHandler
      peerStep
   where
    postulate -- TODO-1: eliminate by constructing inhabitants
      bs : BlockStore
      pe : ProposerElection
      rs : RoundState
      sr : SafetyRules
      vv : BootstrapInfo → ValidatorVerifier
    -- For uninitialised peers, so we know nothing about their state.
    -- Construct a value of type `RoundManager` to ensure it is inhabitable.
    fakeInitRM : RoundManager
    fakeInitRM = RoundManager∙new
      ObmNeedFetch∙new
      (EpochState∙new 1 (vv fakeBootstrapInfo))
      bs rs pe proposalGenerator sr false
 
 | 
	{
  "alphanum_fraction": 0.7233605153,
  "avg_line_length": 46.0347003155,
  "ext": "agda",
  "hexsha": "d2d7fb375af72afd8bddeec74e481935cb80f400",
  "lang": "Agda",
  "max_forks_count": null,
  "max_forks_repo_forks_event_max_datetime": null,
  "max_forks_repo_forks_event_min_datetime": null,
  "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
  "max_forks_repo_licenses": [
    "UPL-1.0"
  ],
  "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
  "max_forks_repo_path": "src/LibraBFT/Impl/Handle.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "UPL-1.0"
  ],
  "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
  "max_issues_repo_path": "src/LibraBFT/Impl/Handle.agda",
  "max_line_length": 111,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
  "max_stars_repo_licenses": [
    "UPL-1.0"
  ],
  "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
  "max_stars_repo_path": "src/LibraBFT/Impl/Handle.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 3809,
  "size": 14593
} 
 | 
					
	{-
This second-order equational theory was created from the following second-order syntax description:
syntax PDiff | PD
type
  * : 0-ary
term
  zero  : * | 𝟘
  add   : *  *  ->  * | _⊕_ l20
  one   : * | 𝟙
  mult  : *  *  ->  * | _⊗_ l20
  neg   : *  ->  * | ⊖_ r50
  pd : *.*  *  ->  * | ∂_∣_
theory
  (𝟘U⊕ᴸ) a |> add (zero, a) = a
  (𝟘U⊕ᴿ) a |> add (a, zero) = a
  (⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c))
  (⊕C) a b |> add(a, b) = add(b, a)
  (𝟙U⊗ᴸ) a |> mult (one, a) = a
  (𝟙U⊗ᴿ) a |> mult (a, one) = a
  (⊗A) a b c |> mult (mult(a, b), c) = mult (a, mult(b, c))
  (⊗D⊕ᴸ) a b c |> mult (a, add (b, c)) = add (mult(a, b), mult(a, c))
  (⊗D⊕ᴿ) a b c |> mult (add (a, b), c) = add (mult(a, c), mult(b, c))
  (𝟘X⊗ᴸ) a |> mult (zero, a) = zero
  (𝟘X⊗ᴿ) a |> mult (a, zero) = zero
  (⊖N⊕ᴸ) a |> add (neg (a), a) = zero
  (⊖N⊕ᴿ) a |> add (a, neg (a)) = zero
  (⊗C) a b |> mult(a, b) = mult(b, a)
  (∂⊕) a : * |> x : * |- d0 (add (x, a)) = one
  (∂⊗) a : * |> x : * |- d0 (mult(a, x)) = a
  (∂C) f : (*,*).* |> x : *  y : * |- d1 (d0 (f[x,y])) = d0 (d1 (f[x,y]))
  (∂Ch₂) f : (*,*).*  g h : *.* |> x : * |- d0 (f[g[x], h[x]]) = add (mult(pd(z. f[z, h[x]], g[x]), d0(g[x])), mult(pd(z. f[g[x], z], h[x]), d0(h[x])))
  (∂Ch₁) f g : *.* |> x : * |- d0 (f[g[x]]) = mult (pd (z. f[z], g[x]), d0(g[x]))
-}
module PDiff.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 PDiff.Signature
open import PDiff.Syntax
open import SOAS.Metatheory.SecondOrder.Metasubstitution PD:Syn
open import SOAS.Metatheory.SecondOrder.Equality PD:Syn
private
  variable
    α β γ τ : *T
    Γ Δ Π : Ctx
infix 1 _▹_⊢_≋ₐ_
-- Axioms of equality
data _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ PD) α Γ → (𝔐 ▷ PD) α Γ → Set where
  𝟘U⊕ᴸ : ⁅ * ⁆̣             ▹     ∅     ⊢               𝟘 ⊕ 𝔞 ≋ₐ 𝔞
  ⊕A   : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹     ∅     ⊢         (𝔞 ⊕ 𝔟) ⊕ 𝔠 ≋ₐ 𝔞 ⊕ (𝔟 ⊕ 𝔠)
  ⊕C   : ⁅ * ⁆ ⁅ * ⁆̣       ▹     ∅     ⊢               𝔞 ⊕ 𝔟 ≋ₐ 𝔟 ⊕ 𝔞
  𝟙U⊗ᴸ : ⁅ * ⁆̣             ▹     ∅     ⊢               𝟙 ⊗ 𝔞 ≋ₐ 𝔞
  ⊗A   : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹     ∅     ⊢         (𝔞 ⊗ 𝔟) ⊗ 𝔠 ≋ₐ 𝔞 ⊗ (𝔟 ⊗ 𝔠)
  ⊗D⊕ᴸ : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹     ∅     ⊢         𝔞 ⊗ (𝔟 ⊕ 𝔠) ≋ₐ (𝔞 ⊗ 𝔟) ⊕ (𝔞 ⊗ 𝔠)
  𝟘X⊗ᴸ : ⁅ * ⁆̣             ▹     ∅     ⊢               𝟘 ⊗ 𝔞 ≋ₐ 𝟘
  ⊖N⊕ᴸ : ⁅ * ⁆̣             ▹     ∅     ⊢           (⊖ 𝔞) ⊕ 𝔞 ≋ₐ 𝟘
  ⊗C   : ⁅ * ⁆ ⁅ * ⁆̣       ▹     ∅     ⊢               𝔞 ⊗ 𝔟 ≋ₐ 𝔟 ⊗ 𝔞
  ∂⊕   : ⁅ * ⁆̣             ▹   ⌊ * ⌋   ⊢         ∂₀ (x₀ ⊕ 𝔞) ≋ₐ 𝟙
  ∂⊗   : ⁅ * ⁆̣             ▹   ⌊ * ⌋   ⊢         ∂₀ (𝔞 ⊗ x₀) ≋ₐ 𝔞
  ∂C   : ⁅ * · * ⊩ * ⁆̣     ▹ ⌊ * ∙ * ⌋ ⊢  ∂₁ ∂₀ 𝔞⟨ x₀ ◂ x₁ ⟩ ≋ₐ ∂₀ ∂₁ 𝔞⟨ x₀ ◂ x₁ ⟩
  ∂Ch₂ : ⁅ * · * ⊩ * ⁆ ⁅ * ⊩ * ⁆ ⁅ * ⊩ * ⁆̣ ▹ ⌊ * ⌋
       ⊢ ∂₀ 𝔞⟨ (𝔟⟨ x₀ ⟩) ◂ (𝔠⟨ x₀ ⟩) ⟩ ≋ₐ ((∂ 𝔞⟨ x₀ ◂ (𝔠⟨ x₁ ⟩) ⟩ ∣ 𝔟⟨ x₀ ⟩) ⊗ (∂₀ 𝔟⟨ x₀ ⟩))
                                       ⊕ ((∂ 𝔞⟨ (𝔟⟨ x₁ ⟩) ◂ x₀ ⟩ ∣ 𝔠⟨ x₀ ⟩) ⊗ (∂₀ 𝔠⟨ x₀ ⟩))
open EqLogic _▹_⊢_≋ₐ_
open ≋-Reasoning
-- Derived equations
𝟘U⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ 𝟘 ≋ 𝔞
𝟘U⊕ᴿ = tr (ax ⊕C with《 𝔞 ◃ 𝟘 》) (ax 𝟘U⊕ᴸ with《 𝔞 》)
𝟙U⊗ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊗ 𝟙 ≋ 𝔞
𝟙U⊗ᴿ = tr (ax ⊗C with《 𝔞 ◃ 𝟙 》) (ax 𝟙U⊗ᴸ with《 𝔞 》)
⊗D⊕ᴿ : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ⊕ 𝔟) ⊗ 𝔠 ≋ (𝔞 ⊗ 𝔠) ⊕ (𝔟 ⊗ 𝔠)
⊗D⊕ᴿ = begin
  (𝔞 ⊕ 𝔟) ⊗ 𝔠       ≋⟨ ax ⊗C with《 𝔞 ⊕ 𝔟 ◃ 𝔠 》 ⟩
  𝔠 ⊗ (𝔞 ⊕ 𝔟)       ≋⟨ ax ⊗D⊕ᴸ with《 𝔠 ◃ 𝔞 ◃ 𝔟 》 ⟩
  (𝔠 ⊗ 𝔞) ⊕ (𝔠 ⊗ 𝔟)  ≋⟨ cong₂[ ax ⊗C with《 𝔠 ◃ 𝔞 》 ][ ax ⊗C with《 𝔠 ◃ 𝔟 》 ]inside ◌ᵈ ⊕ ◌ᵉ ⟩
  (𝔞 ⊗ 𝔠) ⊕ (𝔟 ⊗ 𝔠)  ∎
𝟘X⊗ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊗ 𝟘 ≋ 𝟘
𝟘X⊗ᴿ = tr (ax ⊗C with《 𝔞 ◃ 𝟘 》) (ax 𝟘X⊗ᴸ with《 𝔞 》)
⊖N⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ (⊖ 𝔞) ≋ 𝟘
⊖N⊕ᴿ = tr (ax ⊕C with《 𝔞 ◃ (⊖ 𝔞) 》) (ax ⊖N⊕ᴸ with《 𝔞 》)
-- Derivative of a variable is 1
∂id : ⁅⁆ ▹ ⌊ * ⌋ ⊢ ∂₀ x₀ ≋ 𝟙
∂id = begin
      ∂₀ x₀       ≋⟨ cong[ thm 𝟘U⊕ᴿ with《 x₀ 》 ]inside ∂₀ ◌ᵃ ⟩ₛ
      ∂₀ (x₀ ⊕ 𝟘) ≋⟨ ax ∂⊕ with《 𝟘 》 ⟩
      𝟙           ∎
-- Derivative of 0 is 0
∂𝟘 : ⁅⁆ ▹ ⌊ * ⌋ ⊢ ∂₀ 𝟘 ≋ 𝟘
∂𝟘 = begin
      ∂₀ 𝟘         ≋⟨ cong[ ax 𝟘X⊗ᴸ with《 x₀ 》 ]inside ∂₀ ◌ᵃ ⟩ₛ
      ∂₀ (𝟘 ⊗ x₀)  ≋⟨ ax ∂⊗ with《 𝟘 》 ⟩
      𝟘            ∎
-- Unary chain rule
∂Ch₁ : ⁅ * ⊩ * ⁆ ⁅ * ⊩ * ⁆̣ ▹ ⌊ * ⌋
     ⊢ ∂₀ 𝔞⟨ (𝔟⟨ x₀ ⟩) ⟩ ≋ (∂ 𝔞⟨ x₀ ⟩ ∣ 𝔟⟨ x₀ ⟩) ⊗ (∂₀ 𝔟⟨ x₀ ⟩)
∂Ch₁ = begin
      ∂₀ (𝔞⟨ (𝔟⟨ x₀ ⟩) ⟩)
  ≋⟨ ax ∂Ch₂ with《 𝔞⟨ x₀ ⟩ ◃ 𝔟⟨ x₀ ⟩ ◃ 𝟘 》 ⟩
        (∂ 𝔞⟨ x₀ ⟩ ∣ (𝔟⟨ x₀ ⟩)) ⊗ (∂₀ (𝔟⟨ x₀ ⟩))
      ⊕ ((∂ 𝔞⟨ (𝔟⟨ x₁ ⟩) ⟩ ∣ 𝟘) ⊗ (∂₀ 𝟘))
  ≋⟨ cong[ thm ∂𝟘 ]inside (∂ 𝔞⟨ x₀ ⟩ ∣ (𝔟⟨ x₀ ⟩)) ⊗ (∂₀ (𝔟⟨ x₀ ⟩)) ⊕
                          ((∂ 𝔞⟨ (𝔟⟨ x₁ ⟩) ⟩ ∣ 𝟘) ⊗ ◌ᶜ) ⟩
        (∂ 𝔞⟨ x₀ ⟩ ∣ (𝔟⟨ x₀ ⟩)) ⊗ (∂₀ (𝔟⟨ x₀ ⟩))
      ⊕ (∂ 𝔞⟨ (𝔟⟨ x₁ ⟩) ⟩ ∣ 𝟘) ⊗ 𝟘
  ≋⟨ cong[ thm 𝟘X⊗ᴿ with《 (∂ 𝔞⟨ (𝔟⟨ x₁ ⟩) ⟩ ∣ 𝟘) 》 ]inside (∂ 𝔞⟨ x₀ ⟩ ∣ (𝔟⟨ x₀ ⟩)) ⊗ (∂₀ (𝔟⟨ x₀ ⟩)) ⊕ ◌ᶜ ⟩
        (∂ 𝔞⟨ x₀ ⟩ ∣ (𝔟⟨ x₀ ⟩)) ⊗ (∂₀ (𝔟⟨ x₀ ⟩))
      ⊕ 𝟘
  ≋⟨ thm 𝟘U⊕ᴿ with《 (∂ 𝔞⟨ x₀ ⟩ ∣ (𝔟⟨ x₀ ⟩)) ⊗ (∂₀ (𝔟⟨ x₀ ⟩)) 》 ⟩
      (∂ 𝔞⟨ x₀ ⟩ ∣ 𝔟⟨ x₀ ⟩) ⊗ (∂₀ 𝔟⟨ x₀ ⟩)
  ∎
 
 | 
	{
  "alphanum_fraction": 0.341352136,
  "avg_line_length": 37.0923076923,
  "ext": "agda",
  "hexsha": "e97cd90599893217a0bdb158c688694201bddadd",
  "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/PDiff/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/PDiff/Equality.agda",
  "max_line_length": 151,
  "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/PDiff/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": 3450,
  "size": 4822
} 
 | 
					
	{-# OPTIONS  --safe #-}
module Definition.Typed.Reduction where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
-- Weak head expansion of type equality
reduction : ∀ {A A′ B B′ r Γ}
          → Γ ⊢ A ⇒* A′ ^ r
          → Γ ⊢ B ⇒* B′ ^ r
          → Whnf A′
          → Whnf B′
          → Γ ⊢ A′ ≡ B′ ^ r
          → Γ ⊢ A ≡ B ^ r
reduction D D′ whnfA′ whnfB′ A′≡B′ =
  trans (subset* D) (trans A′≡B′ (sym (subset* D′)))
reduction′ : ∀ {A A′ B B′ r Γ}
          → Γ ⊢ A ⇒* A′ ^ r
          → Γ ⊢ B ⇒* B′ ^ r
          → Whnf A′
          → Whnf B′
          → Γ ⊢ A ≡ B ^ r
          → Γ ⊢ A′ ≡ B′ ^ r
reduction′ D D′ whnfA′ whnfB′ A≡B =
  trans (sym (subset* D)) (trans A≡B (subset* D′))
-- Weak head expansion of term equality
reductionₜ : ∀ {a a′ b b′ A B l Γ}
           → Γ ⊢ A ⇒* B ^ [ ! , l ]
           → Γ ⊢ a ⇒* a′ ∷ B ^ l
           → Γ ⊢ b ⇒* b′ ∷ B ^ l
           → Whnf B
           → Whnf a′
           → Whnf b′
           → Γ ⊢ a′ ≡ b′ ∷ B ^ [ ! , l ]
           → Γ ⊢ a ≡ b ∷ A ^ [ ! , l ]
reductionₜ D d d′ whnfB whnfA′ whnfB′ a′≡b′ =
  conv (trans (subset*Term d)
              (trans a′≡b′ (sym (subset*Term d′))))
       (sym (subset* D))
reductionₜ′ : ∀ {a a′ b b′ A B l Γ}
           → Γ ⊢ A ⇒* B ^ [ ! , l ]
           → Γ ⊢ a ⇒* a′ ∷ B ^ l
           → Γ ⊢ b ⇒* b′ ∷ B ^ l
           → Whnf B
           → Whnf a′
           → Whnf b′
           → Γ ⊢ a ≡ b ∷ A ^ [ ! , l ]
           → Γ ⊢ a′ ≡ b′ ∷ B ^ [ ! , l ]
reductionₜ′ D d d′ whnfB whnfA′ whnfB′ a≡b =
  trans (sym (subset*Term d))
        (trans (conv a≡b (subset* D)) (subset*Term d′))
 
 | 
	{
  "alphanum_fraction": 0.4007352941,
  "avg_line_length": 28.1379310345,
  "ext": "agda",
  "hexsha": "edf1d5d042b176b66a6ab877835f79bb4daf29b9",
  "lang": "Agda",
  "max_forks_count": 2,
  "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z",
  "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z",
  "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "CoqHott/logrel-mltt",
  "max_forks_repo_path": "Definition/Typed/Reduction.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
  "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": "CoqHott/logrel-mltt",
  "max_issues_repo_path": "Definition/Typed/Reduction.agda",
  "max_line_length": 55,
  "max_stars_count": 2,
  "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "CoqHott/logrel-mltt",
  "max_stars_repo_path": "Definition/Typed/Reduction.agda",
  "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z",
  "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z",
  "num_tokens": 656,
  "size": 1632
} 
 | 
					
	open import Prelude
open import Data.Nat using (_≤?_)
open import Data.Maybe using (Maybe; just; nothing; is-just)
open import Reflection using (_≟-Lit_; _≟-Name_)
open import RW.Language.RTerm
open import RW.Utils.Monads
module RW.Language.RTermUtils where
  open Monad {{...}}
  --   The complexity annotations might require 
  --   a slight notational introduction.
  --
  --   If a variable name overlaps one in the corresponding type signature,
  --   this is intentional.
  --
  --   Sₜ is defined by (S t).
  --   #Fvₜ is defined by length (Fv t).
  --   Both measures are defined below.
  --
  --------------
  -- Measures --
  --------------
  -- The TERMINATING pragmas are required since Agda does not
  -- recognize a call to map as terminating.
  {-# TERMINATING #-}
  height : {A : Set} → RTerm A → ℕ
  height (ovar _)    = 0
  height (ivar _)    = 0
  height (rlit _)    = 0
  height (rlam t)    = 1 + height t
  height (rapp _ ts) = 1 + max* (map height ts) 
    where
      max : ℕ → ℕ → ℕ
      max a b with a ≤? b
      ...| yes _ = b
      ...| no  _ = a
      max* : List ℕ → ℕ
      max* [] = 0
      max* (h ∷ t) = max h (max* t)
  {-# TERMINATING #-}
  S : {A : Set} → RTerm A → ℕ
  S (ovar _) = 1
  S (ivar _) = 1
  S (rlit _) = 1
  S (rlam t) = 1 + S t
  S (rapp n ts) = 1 + sum (map S ts)
    where open import Data.List using (sum)
  {-# TERMINATING #-}
  Fv : {A : Set} → RTerm A → List A
  Fv (ovar a) = a ∷ []
  Fv (ivar _) = []
  Fv (rlit _) = []
  Fv (rlam t) = Fv t
  Fv (rapp _ ts) = concatMap Fv ts
    where open import Data.List using (concatMap)
  -------------------------------------------------------
  -- Terms with Context
  --
  --   Holes will be represented by a nothing;
  pattern hole = ovar nothing
  isHole : ∀{a}{A : Set a} → RTerm (Maybe A) → Bool
  isHole (ovar nothing) = true
  isHole _              = false
  -- Term Intersection
  --
  -- Complexity analisys follows below.
  {-# TERMINATING #-}
  _∩_ : ∀{A} ⦃ eqA : Eq A ⦄ 
      → RTerm A → RTerm A → RTerm (Maybe A)
  _∩_ (rapp x ax) (rapp y ay) with x ≟-RTermName y
  ...| no  _ = ovar nothing
  ...| yes _ = rapp x (map (uncurry _∩_) (zip ax ay))
  _∩_ (ivar x) (ivar y) with x ≟-ℕ y
  ...| no  _ = ovar nothing
  ...| yes _ = ivar x
  _∩_ ⦃ eq _≟_ ⦄ (ovar x) (ovar y) with x ≟ y
  ...| no  _ = ovar nothing
  ...| yes _ = ovar (just x)
  _∩_ (rlit x) (rlit y) with x ≟-Lit y
  ...| no  _ = ovar nothing
  ...| yes _ = rlit x
  _∩_ (rlam x) (rlam y) = rlam (x ∩ y)
  _∩_ _ _ = ovar nothing
  -- The wors case for a intersection is, of course, both terms being
  -- equal. But in that case, (t ∩ t) is just a (fmap just), as we
  -- can see below.
  --
  -- Therefore, t ∩ t ∈ O(Sₜ)
  --
  -- In case we have two different terms, the smaller of
  -- them will make _∩_ halt. Therefore,
  --
  -- t ∩ u ∈ O(min(Sₜ , Sᵤ))
  --
  private
    mutual
      t∩t≡t : {A : Set}⦃ eqA : Eq A ⦄{t : RTerm A}
            → t ∩ t ≡ replace-A (ovar ∘ just) t
      t∩t≡t ⦃ eq _≟_ ⦄ {t = ovar x} with x ≟ x
      ...| yes x≡x = refl
      ...| no  x≢x = ⊥-elim (x≢x refl)
      t∩t≡t {t = ivar n} with n ≟-ℕ n
      ...| yes n≡n = refl
      ...| no  n≢n = ⊥-elim (n≢n refl)
      t∩t≡t {t = rlit l} with l ≟-Lit l
      ...| yes l≡l = refl
      ...| no  l≢l = ⊥-elim (l≢l refl)
      t∩t≡t {A} {t = rlam t} 
        = trans (cong rlam (t∩t≡t {t = t})) 
                (sym (lemma-replace-rlam {A = A} {f = ovar ∘ just} {t = t}))
      t∩t≡t {t = rapp n ts} with n ≟-RTermName n
      ...| no  n≢n = ⊥-elim (n≢n refl)
      ...| yes n≡n = cong (rapp n) t∩t≡t*
      t∩t≡t* : {A : Set}⦃ eqA : Eq A ⦄{ts : List (RTerm A)}
             → map (uncurry _∩_) (zip ts ts) 
             ≡ map (replace-A (ovar ∘ just)) ts
      t∩t≡t* {ts = []} = refl
      t∩t≡t* {ts = t ∷ ts} 
        rewrite sym (t∩t≡t {t = t}) = cong (_∷_ (t ∩ t)) (t∩t≡t* {ts = ts})
  -- Lifting holes.
  --
  --  Will translate every definition with only holes as arguments
  --  into a single hole.
  -- 
  --  The worst case for lifting holes is to find a term t
  --  with no holes. Therefore _↑ ∈ O(Sₜ).
  {-# TERMINATING #-}
  _↑ : ∀{a}{A : Set a} → RTerm (Maybe A) → RTerm (Maybe A)
  _↑ (rapp x []) = rapp x []
  _↑ (rapp x ax) with all isHole ax
  ...| true   = ovar nothing
  ...| false  = rapp x (map _↑ ax)
  _↑ (rlam x) = rlam (x ↑)
  _↑ t        = t
  -- It is commom to need only "linear" intersections;
  --
  -- _∩↑_ ∈ O(Sₜ + Sₜ) ≈ O(Sₜ)
  --
  _∩↑_ : ∀{A} ⦃ eqA : Eq A ⦄ 
       → RTerm A → RTerm A → RTerm (Maybe A)
  v ∩↑ u = (v ∩ u) ↑
  -- Casting
  ⊥2UnitCast : RTerm (Maybe ⊥) → RTerm Unit
  ⊥2UnitCast = replace-A (maybe ⊥-elim (ovar unit))
  -- Converting Holes to Abstractions
  --
  --  Will replace holes for "var 0", 
  --  and increment every other non-captured variable.
  --
  {-# TERMINATING #-}
  holeElim : ℕ → RTerm Unit → RTerm ⊥
  holeElim d (ovar unit) = ivar zero
  holeElim d (ivar n) with suc n ≤? d
  ...| yes _ = ivar n
  ...| no  _ = ivar (suc n)
  holeElim d (rlit l) = rlit l
  holeElim d (rlam rt) = rlam (holeElim (suc d) rt)
  holeElim d (rapp n ts) = rapp n (map (holeElim d) ts)
  -- Specialized version for handling indexes.
  hole2Abs : RTerm Unit → RTerm ⊥
  hole2Abs = rlam ∘ holeElim 0
  hole2Absℕ : RTerm Unit → RTerm ℕ
  hole2Absℕ = replace-A ⊥-elim ∘ hole2Abs
  open import Data.String hiding (_++_)
  postulate
    err : ∀{a}{A : Set a} → String → A
  private
    joinInner : {A : Set} → List (Maybe (List A)) → Maybe (List A)
    joinInner [] = just []
    joinInner (nothing ∷ _) = nothing -- err "2"
    joinInner (just x ∷ xs) = maybe (λ l → just (x ++ l)) nothing (joinInner xs)
    lemma-joinInner : {A : Set}{x : List A}{l : List (Maybe (List A))}
                    → joinInner (just x ∷ l) 
                    ≡ maybe (λ l → just (x ++ l)) nothing (joinInner l)
    lemma-joinInner = refl
  -- Term Subtraction
  -- 
  -- Compelxity analisys follows below.
  --
  {-# TERMINATING #-}
  _-_ : ∀{A} ⦃ eqA : Eq A ⦄ → RTerm (Maybe A) → RTerm A → Maybe (List (RTerm A))
  hole - t = return (t ∷ [])
  (rapp x ax) - (rapp y ay) with x ≟-RTermName y
  ...| no  _ = nothing -- err "1"
  ...| yes _ = joinInner (map (uncurry _-_) (zip ax ay))       
  (rlam x) - (rlam y) = x - y
  x - y with x ≟-RTerm (replace-A (ovar ∘ just) y)
  ...| yes _ = just []
  ...| no  _ = nothing -- err "3"
  -- Similarly to _∩_, we will prove the worst case complexity
  -- based on lemma t-t≡Fvt. 
  -- That is, looking at term subtraction, the wors possible case
  -- is that our roadmap (RTerm (Maybe A)) perfectly matches the
  -- term we are looking for, and has all occurences of ovars as holes.
  -- (a simple drawing might help to see this).
  --
  -- Well, when this is the case, our lemma tells us that
  -- subtraction is the same as getting the free variables
  -- and mapping ovar over them.
  --
  -- It is clear that we have some additional complexity on
  -- the function joinInner, but we will ignore this for
  -- the sake of simplicity, for now.
  -- If we consider that most of the lemmas do not have more than 10
  -- free variables, joinInner is of negligible run-time
  -- (TODO: dangerous afirmation!!)
  -- 
  -- We'll then say that _-_ ∈ O(#Fvₜ).
  --
  private
    fmap-nothing : {A : Set} → RTerm A → RTerm (Maybe A)
    fmap-nothing = replace-A (const $ ovar nothing)
    mutual
      t-t≡Fvt : {A : Set}⦃ eqA : Eq A ⦄(t : RTerm A)
              → (fmap-nothing t) - t 
              ≡ just (map ovar (Fv t))
      t-t≡Fvt (ovar x) = refl
      t-t≡Fvt (ivar n) with n ≟-ℕ n
      ...| yes n≡n = refl
      ...| no  n≢n = ⊥-elim (n≢n refl)
      t-t≡Fvt (rlit l) with l ≟-Lit l
      ...| yes l≡l = refl
      ...| no  l≢l = ⊥-elim (l≢l refl)
      t-t≡Fvt (rlam t) = t-t≡Fvt t
      t-t≡Fvt (rapp n ts) with n ≟-RTermName n
      ...| yes n≡n = t-t≡Fvt* ts
      ...| no  n≢n = ⊥-elim (n≢n refl)
      t-t≡Fvt* : {A : Set}⦃ eqA : Eq A ⦄(ts : List (RTerm A))
               → joinInner (map (uncurry _-_) (zip (map fmap-nothing ts) ts)) 
               ≡ just (map ovar (concat (map Fv ts)))
      t-t≡Fvt* [] = refl
      t-t≡Fvt* (t ∷ ts) 
        rewrite t-t≡Fvt t
        with joinInner (map (uncurry _-_) (zip (map fmap-nothing ts) ts))
           | t-t≡Fvt* ts
      t-t≡Fvt* (t ∷ ts) | nothing | ()
      t-t≡Fvt* (t ∷ ts) | just .(map ovar (foldr _++_ [] (map Fv ts)))
                        | refl 
        = cong just (sym (map-++-commute ovar (Fv t) (concat (map Fv ts))))
        where open import Data.List.Properties using (map-++-commute)
      
  -- Term Subtraction, single result.
  --
  -- Disconsidering lazyness, (_-↓_ t) = fmap head ∘ (_-_ t)
  -- Therefore, _-↓_ ∈ O(#Fvₜ).
  -- 
  _-↓_ : ∀{A} ⦃ eqA : Eq A ⦄ → RTerm (Maybe A) → RTerm A → Maybe (RTerm A)
  t -↓ u with t - u
  ...| just []      = nothing
  ...| just (x ∷ _) = just x
  ...| nothing      = nothing
  -- Structural Manipulation
  {-# TERMINATING #-}
  map-ivar : {A : Set} → ℕ → (ℕ → RTerm A) → RTerm ⊥ → RTerm A
  map-ivar _ f (ovar ())
  map-ivar d f (ivar n) with d ≤? n
  ...| yes _ = f n
  ...| no  _ = ivar n
  map-ivar _ f (rlit l) = rlit l
  map-ivar d f (rlam t) = rlam (map-ivar (suc d) f t)
  map-ivar d f (rapp n ts) = rapp n (map (map-ivar d f) ts)
  
  -- Lift ivar's to ovar's
  lift-ivar : RTerm ⊥ → RTerm ℕ
  lift-ivar = map-ivar 0 ovar
  private
    last : {A : Set} → List A → Maybe A
    last [] = nothing
    last (x ∷ []) = just x
    last (_ ∷ xs) = last xs
    strip-last : {A : Set} → List A → List A
    strip-last [] = []
    strip-last (x ∷ []) = []
    strip-last (x ∷ xs) = x ∷ (strip-last xs)
    -- last argument
    larg : {B : Set} → RTerm B → Maybe (RTerm B)
    larg (rapp n []) = nothing
    larg (rapp n ts) = last ts
    larg _           = nothing
    dec : ℕ → ℕ
    dec zero = zero
    dec (suc x) = x
    strip-larg : {B : Set} → RTerm B → RTerm B
    strip-larg (rapp n ts) = rapp n (strip-last ts)
    strip-larg t           = t
    {-# TERMINATING #-}
    n-is-in : {B : Set} → ℕ → RTerm B → Bool
    n-is-in n (ivar k) = dec-elim (const true) (const false) (n ≟-ℕ k)
    n-is-in n (rapp _ ts) = foldr (λ h r → n-is-in n h or r) false ts
    n-is-in n (rlam t) = n-is-in (suc n) t
    n-is-in _ _ = false
  {-# TERMINATING #-}
  η : RTerm ⊥ → RTerm ⊥
  η (ovar x) = ovar x
  η (ivar n) = ivar n
  η (rlit l) = rlit l
  η (rlam t) with η t
  ...| t' with larg t'
  ...| just (ivar 0)
     = if n-is-in 0 (strip-larg t') 
       then rlam t'
       else map-ivar 0 (ivar ∘ dec) (strip-larg t')
  ...| _             = rlam t'
  η (rapp n ts) = rapp n (map η ts)
  
  -- Models a binary application
  RBinApp : ∀{a} → Set a → Set _
  RBinApp A = RTermName × RTerm A × RTerm A
  -- Opens a term representing a binary application.
  forceBinary : ∀{a}{A : Set a} 
              → RTerm A → Maybe (RBinApp A)
  forceBinary (rapp n (a₁ ∷ a₂ ∷ [])) = just (n , a₁ , a₂)
  forceBinary _                       = nothing
  -- Given a 'impl' chain, return it's result.
  typeResult : ∀{a}{A : Set a}
             → RTerm A → RTerm A
  typeResult (rapp impl (t1 ∷ t2 ∷ [])) = typeResult t2
  typeResult t = t
  -- Gives the length of a 'impl' chain.
  typeArity : ∀{a}{A : Set a} → RTerm A → ℕ
  typeArity (rapp impl (t1 ∷ t2 ∷ [])) = suc (typeArity t2)
  typeArity _                          = 0
  
 
 | 
	{
  "alphanum_fraction": 0.5248672566,
  "avg_line_length": 30.9589041096,
  "ext": "agda",
  "hexsha": "597123c617c07a6ce9e2a88bb08d8537cec05fd3",
  "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": "2856afd12b7dbbcc908482975638d99220f38bf2",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "VictorCMiraldo/agda-rw",
  "max_forks_repo_path": "RW/Language/RTermUtils.agda",
  "max_issues_count": 4,
  "max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2",
  "max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z",
  "max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z",
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "VictorCMiraldo/agda-rw",
  "max_issues_repo_path": "RW/Language/RTermUtils.agda",
  "max_line_length": 80,
  "max_stars_count": 16,
  "max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "VictorCMiraldo/agda-rw",
  "max_stars_repo_path": "RW/Language/RTermUtils.agda",
  "max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z",
  "max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z",
  "num_tokens": 4304,
  "size": 11300
} 
 | 
					
	------------------------------------------------------------------------
-- The Agda standard library
--
-- Some defined operations (multiplication by natural number and
-- exponentiation)
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Algebra
module Algebra.Operations.CommutativeMonoid
  {s₁ s₂} (CM : CommutativeMonoid s₁ s₂)
  where
open import Data.Nat.Base using (ℕ; zero; suc)
  renaming (_+_ to _ℕ+_; _*_ to _ℕ*_)
open import Data.List as List using (List; []; _∷_; _++_)
open import Data.Fin using (Fin; zero)
open import Data.Product using (proj₁; proj₂)
open import Data.Table.Base as Table using (Table)
open import Function using (_∘_; _⟨_⟩_)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open CommutativeMonoid CM
  renaming
  ( _∙_       to _+_
  ; ∙-cong    to +-cong
  ; identityˡ to +-identityˡ
  ; identityʳ to +-identityʳ
  ; assoc     to +-assoc
  ; comm      to +-comm
  ; ε         to 0#
  )
open import Relation.Binary.Reasoning.Setoid setoid
------------------------------------------------------------------------
-- Operations
-- Multiplication by natural number.
infixr 8 _×_ _×′_
_×_ : ℕ → Carrier → Carrier
0     × x = 0#
suc n × x = x + n × x
-- A variant that includes a "redundant" case which ensures that `1 × x`
-- is definitionally equal to `x`.
_×′_ : ℕ → Carrier → Carrier
0     ×′ x = 0#
1     ×′ x = x
suc n ×′ x = x + n ×′ x
-- Summation over lists/tables
sumₗ : List Carrier → Carrier
sumₗ = List.foldr _+_ 0#
sumₜ : ∀ {n} → Table Carrier n → Carrier
sumₜ = Table.foldr _+_ 0#
-- An alternative mathematical-style syntax for sumₜ
infixl 10 sumₜ-syntax
sumₜ-syntax : ∀ n → (Fin n → Carrier) → Carrier
sumₜ-syntax _ = sumₜ ∘ Table.tabulate
syntax sumₜ-syntax n (λ i → x) = ∑[ i < n ] x
------------------------------------------------------------------------
-- Properties of _×_
×-congʳ : ∀ n → (n ×_) Preserves _≈_ ⟶ _≈_
×-congʳ 0       x≈x′ = refl
×-congʳ (suc n) x≈x′ = x≈x′ ⟨ +-cong ⟩ ×-congʳ n x≈x′
×-cong : _×_ Preserves₂ _≡_ ⟶ _≈_ ⟶ _≈_
×-cong {u} P.refl x≈x′ = ×-congʳ u x≈x′
-- _×_ is homomorphic with respect to _ℕ+_/_+_.
×-homo-+ : ∀ c m n → (m ℕ+ n) × c ≈ m × c + n × c
×-homo-+ c 0       n = sym (+-identityˡ (n × c))
×-homo-+ c (suc m) n = begin
  c + (m ℕ+ n) × c     ≈⟨ +-cong refl (×-homo-+ c m n) ⟩
  c + (m × c + n × c)  ≈⟨ sym (+-assoc c (m × c) (n × c)) ⟩
  c + m × c + n × c    ∎
------------------------------------------------------------------------
-- Properties of _×′_
1+×′ : ∀ n x → suc n ×′ x ≈ x + n ×′ x
1+×′ 0       x = sym (+-identityʳ x)
1+×′ (suc n) x = refl
-- _×_ and _×′_ are extensionally equal (up to the setoid
-- equivalence).
×≈×′ : ∀ n x → n × x ≈ n ×′ x
×≈×′ 0       x = begin 0# ∎
×≈×′ (suc n) x = begin
  x + n × x   ≈⟨ +-cong refl (×≈×′ n x) ⟩
  x + n ×′ x  ≈⟨ sym (1+×′ n x) ⟩
  suc n ×′ x  ∎
-- _×′_ is homomorphic with respect to _ℕ+_/_+_.
×′-homo-+ : ∀ c m n → (m ℕ+ n) ×′ c ≈ m ×′ c + n ×′ c
×′-homo-+ c m n = begin
  (m ℕ+ n) ×′ c    ≈⟨ sym (×≈×′ (m ℕ+ n) c) ⟩
  (m ℕ+ n) ×  c    ≈⟨ ×-homo-+ c m n ⟩
  m ×  c + n ×  c  ≈⟨ +-cong (×≈×′ m c) (×≈×′ n c) ⟩
  m ×′ c + n ×′ c  ∎
-- _×′_ preserves equality.
×′-cong : _×′_ Preserves₂ _≡_ ⟶ _≈_ ⟶ _≈_
×′-cong {n} {_} {x} {y} P.refl x≈y = begin
  n  ×′ x ≈⟨ sym (×≈×′ n x) ⟩
  n  ×  x ≈⟨ ×-congʳ n x≈y ⟩
  n  ×  y ≈⟨ ×≈×′ n y ⟩
  n  ×′ y ∎
 
 | 
	{
  "alphanum_fraction": 0.4858641795,
  "avg_line_length": 27.0157480315,
  "ext": "agda",
  "hexsha": "91130b6193ba23bcb2de997aef3f8f9cf8d1effb",
  "lang": "Agda",
  "max_forks_count": null,
  "max_forks_repo_forks_event_max_datetime": null,
  "max_forks_repo_forks_event_min_datetime": null,
  "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "omega12345/agda-mode",
  "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Operations/CommutativeMonoid.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "omega12345/agda-mode",
  "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Algebra/Operations/CommutativeMonoid.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/Algebra/Operations/CommutativeMonoid.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 1377,
  "size": 3431
} 
 | 
					
	{-# OPTIONS --rewriting #-}
data _==_ {A : Set} (a : A) : A → Set where
  idp : a == a
{-# BUILTIN REWRITE _==_ #-}
ap : {A B : Set} (f : A → B) {x y : A}
  → x == y → f x == f y
ap f idp = idp
postulate
  Circle : Set
  base : Circle
  loop : base == base
module _ (A : Set) (base* : A) (loop* : base* == base*) where
  postulate
    Circle-rec : Circle → A
    Circle-base-β : Circle-rec base == base*
  {-# REWRITE Circle-base-β #-}
  postulate
    Circle-loop-β : ap Circle-rec loop == loop*
  {-# REWRITE Circle-loop-β #-}
test : (x : Circle) → ap (Circle-rec (Circle → Circle) (λ y → y) idp x) loop == idp
test x = idp
{-
An internal error has occurred. Please report this as a bug.
Location of the error: src/full/Agda/TypeChecking/Rewriting/NonLinMatch.hs:178
-}
 
 | 
	{
  "alphanum_fraction": 0.5881595882,
  "avg_line_length": 24.28125,
  "ext": "agda",
  "hexsha": "05c52e23095b7ffeac077c81543e3ce16200f613",
  "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/Issue1563-15.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/Issue1563-15.agda",
  "max_line_length": 83,
  "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/Issue1563-15.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": 268,
  "size": 777
} 
 | 
					
	{-# OPTIONS --type-in-type --no-pattern-matching #-}
open import Spire.IDarkwingDuck.Primitive
module Spire.IDarkwingDuck.Derived where
----------------------------------------------------------------------
ISet : Set → Set
ISet I = I → Set
Enum : Set
Enum = List String
Tag : Enum → Set
Tag xs = PointsTo String xs
proj₁ : ∀{A B} → Σ A B → A
proj₁ = elimPair _ (λ a b → a)
proj₂ : ∀{A B} (ab : Σ A B) → B (proj₁ ab)
proj₂ = elimPair _ (λ a b → b)
Branches : (E : List String) (P : Tag E → Set) → Set
Branches = elimList _
  (λ P → ⊤)
  (λ l E ih P → Σ (P here) (λ _ → ih (λ t → P (there t))))
case' : (E : List String) (t : Tag E) (P : Tag E → Set) (cs : Branches E P) → P t
case' = elimPointsTo _
  (λ l E P c,cs → proj₁ c,cs)
  (λ l E t ih P c,cs → ih (λ t → P (there t)) (proj₂ c,cs))
case : {E : List String} (P : Tag E → Set) (cs : Branches E P) (t : Tag E) → P t
case P cs t = case' _ t P cs
Elᵀ  : Tel → Set
Elᵀ = elimTel _ ⊤ (λ A B ih → Σ A ih) (λ A B ih → Σ A ih)
----------------------------------------------------------------------
UncurriedBranches : (E : Enum) (P : Tag E → Set) (X : Set)
  → Set
UncurriedBranches E P X = Branches E P → X
CurriedBranches : (E : Enum) (P : Tag E → Set) (X : Set)
  → Set
CurriedBranches = elimList _
  (λ P X → X)
  (λ l E ih P X → P here → ih (λ t → P (there t)) X)
curryBranches : (E : Enum) (P : Tag E → Set) (X : Set)
  → UncurriedBranches E P X → CurriedBranches E P X
curryBranches = elimList _
  (λ P X f → f tt)
  (λ l E ih P X f c → ih (λ t → P (there t)) X (λ cs → f (c , cs)))
----------------------------------------------------------------------
UncurriedElᵀ : (T : Tel) (X : Elᵀ T → Set) → Set
UncurriedElᵀ T X = (xs : Elᵀ T) → X xs
CurriedElᵀ : (T : Tel) (X : Elᵀ T → Set) → Set
CurriedElᵀ = elimTel _
  (λ X → X tt)
  (λ A B ih X → (a : A) → ih a (λ b → X (a , b)))
  (λ A B ih X → {a : A} → ih a (λ b → X (a , b)))
curryElᵀ : (T : Tel) (X : Elᵀ T → Set)
  → UncurriedElᵀ T X → CurriedElᵀ T X
curryElᵀ = elimTel _
  (λ X f → f tt)
  (λ A B ih X f a → ih a (λ b → X (a , b)) (λ b → f (a , b)))
  (λ A B ih X f {a} → ih a (λ b → X (a , b)) (λ b → f (a , b)))
uncurryElᵀ : (T : Tel) (X : Elᵀ T → Set)
  → CurriedElᵀ T X → UncurriedElᵀ T X
uncurryElᵀ = elimTel _
  (λ X x → elimUnit X x)
  (λ A B ih X f → elimPair X (λ a b → ih a (λ b → X (a , b)) (f a) b))
  (λ A B ih X f → elimPair X (λ a b → ih a (λ b → X (a , b)) f b))
ICurriedElᵀ : (T : Tel) (X : Elᵀ T → Set) → Set
ICurriedElᵀ = elimTel _
  (λ X → X tt)
  (λ A B ih X → {a : A} → ih a (λ b → X (a , b)))
  (λ A B ih X → {a : A} → ih a (λ b → X (a , b)))
icurryElᵀ : (T : Tel) (X : Elᵀ T → Set)
  → UncurriedElᵀ T X → ICurriedElᵀ T X
icurryElᵀ = elimTel _
  (λ X f → f tt)
  (λ A B ih X f {a} → ih a (λ b → X (a , b)) (λ b → f (a , b)))
  (λ A B ih X f {a} → ih a (λ b → X (a , b)) (λ b → f (a , b)))
----------------------------------------------------------------------
UncurriedElᴰ : {I : Set} (D : Desc I) (X : ISet I) → Set
UncurriedElᴰ D X = ∀{i} → Elᴰ D X i → X i
CurriedElᴰ : {I : Set} (D : Desc I) (X : ISet I) → Set
CurriedElᴰ = elimDesc _
  (λ i X → X i)
  (λ i D ih X → (x : X i) → ih X )
  (λ A B ih X → (a : A) → ih a X)
  (λ A B ih X → {a : A} → ih a X)
curryElᴰ : {I : Set} (D : Desc I) (X : ISet I)
  → UncurriedElᴰ D X → CurriedElᴰ D X
curryElᴰ = elimDesc _
  (λ i X cn → cn refl)
  (λ i D ih X cn x → ih X (λ xs → cn (x , xs)))
  (λ A B ih X cn a → ih a X (λ xs → cn (a , xs)))
  (λ A B ih X cn {a} → ih a X (λ xs → cn (a , xs)))
----------------------------------------------------------------------
UncurriedHyps : {I : Set} (D : Desc I) (X : ISet I)
  (P : (i : I) → X i → Set)
  (cn : UncurriedElᴰ D X)
  → Set
UncurriedHyps D X P cn =
  ∀ i (xs : Elᴰ D X i) (ihs : Hyps D X P i xs) → P i (cn xs)
CurriedHyps : {I : Set} (D : Desc I) (X : ISet I)
  (P : (i : I) → X i → Set)
  (cn : UncurriedElᴰ D X)
  → Set
CurriedHyps = elimDesc _
  (λ i X P cn → P i (cn refl))
  (λ i D ih X P cn → (x : X i) → P i x → ih X P (λ xs → cn (x , xs)))
  (λ A B ih X P cn → (a : A) → ih a X P (λ xs → cn (a , xs)))
  (λ A B ih X P cn → {a : A} → ih a X P (λ xs → cn (a , xs)))
uncurryHyps : {I : Set} (D : Desc I) (X : ISet I)
  (P : (i : I) → X i → Set)
  (cn : UncurriedElᴰ D X)
  → CurriedHyps D X P cn
  → UncurriedHyps D X P cn
uncurryHyps = elimDesc _
  (λ j X P cn pf →
    elimEq _ (λ u → pf))
  (λ j D ih X P cn pf i →
    elimPair _ (λ x xs ih,ihs →
      ih X P (λ ys → cn (x , ys)) (pf x (proj₁ ih,ihs)) i xs (proj₂ ih,ihs)))
  (λ A B ih X P cn pf i →
    elimPair _ (λ a xs → ih a X P (λ ys → cn (a , ys)) (pf a) i xs))
  (λ A B ih X P cn pf i →
    elimPair _ (λ a xs → ih a X P (λ ys → cn (a , ys)) pf i xs))
----------------------------------------------------------------------
record Data : Set where
  field
    P : Tel
    I : Elᵀ P → Tel
    E : Enum
    B : (A : Elᵀ P) → Branches E (λ _ → Desc (Elᵀ (I A)))
  C : (A : Elᵀ P) → Tag E → Desc (Elᵀ (I A))
  C A = case (λ _ → Desc (Elᵀ (I A))) (B A)
  D : (A : Elᵀ P) → Desc (Elᵀ (I A))
  D A = Arg (Tag E) (C A)
----------------------------------------------------------------------
Decl :
  (P : Tel)
  (I : CurriedElᵀ P (λ _ → Tel))
  (E : Enum)
  (B : let I = uncurryElᵀ P (λ _ → Tel) I
      in CurriedElᵀ P λ A → Branches E (λ _ → Desc (Elᵀ (I A))))
  → Data
Decl P I E B = record
  { P = P
  ; I = uncurryElᵀ P _ I
  ; E = E
  ; B = uncurryElᵀ P _ B
  }
----------------------------------------------------------------------
End[_] : (I : Tel)
  → CurriedElᵀ I (λ _ → Desc (Elᵀ I))
End[_] I = curryElᵀ I _ End
Rec[_] : (I : Tel)
  → CurriedElᵀ I (λ _ → Desc (Elᵀ I) → Desc (Elᵀ I))
Rec[_] I = curryElᵀ I _ Rec
----------------------------------------------------------------------
FormUncurried : (R : Data)
  → UncurriedElᵀ (Data.P R) λ p
  → UncurriedElᵀ (Data.I R p) λ i
  → Set
FormUncurried R p i = μ (Data.D R p) i
Form : (R : Data)
  → CurriedElᵀ (Data.P R) λ p
  → CurriedElᵀ (Data.I R p) λ i
  → Set
Form R =
  curryElᵀ (Data.P R) (λ p → CurriedElᵀ (Data.I R p) λ i → Set) λ p →
  curryElᵀ (Data.I R p) (λ i → Set) λ i →
  FormUncurried R p i
----------------------------------------------------------------------
injUncurried : (R : Data)
  → UncurriedElᵀ (Data.P R) λ p
  → let D = Data.D R p
  in CurriedElᴰ D (μ D)
injUncurried R p t = curryElᴰ (Data.C R p t)
  (μ (Data.D R p))
  (λ xs → init (t , xs))
inj : (R : Data)
  → ICurriedElᵀ (Data.P R) λ p
  → let D = Data.D R p
  in CurriedElᴰ D (μ D)
inj R = icurryElᵀ (Data.P R)
  (λ p → let D = Data.D R p in CurriedElᴰ D (μ D))
  (injUncurried R)
----------------------------------------------------------------------
indCurried : {I : Set} (D : Desc I)
  (M : (i : I) → μ D i → Set)
  (f : CurriedHyps D (μ D) M init)
  (i : I)
  (x : μ D i)
  → M i x
indCurried D M f i x =
  ind D M (uncurryHyps D (μ D) M init f) i x
SumCurriedHyps : (R : Data)
  → UncurriedElᵀ (Data.P R) λ p
  → let D = Data.D R p in
  (M : CurriedElᵀ (Data.I R p) (λ i → μ D i → Set))
  → Tag (Data.E R) → Set
SumCurriedHyps R p M t =
  let unM = uncurryElᵀ (Data.I R p) (λ i → μ (Data.D R p) i → Set) M in
  CurriedHyps (Data.C R p t) (μ (Data.D R p)) unM (λ xs → init (t , xs))
elimUncurried : (R : Data)
  → UncurriedElᵀ (Data.P R) λ p
  → let D = Data.D R p in
  (M : CurriedElᵀ (Data.I R p) (λ i → μ D i → Set))
  → let unM = uncurryElᵀ (Data.I R p) (λ i → μ D i → Set) M
  in UncurriedBranches (Data.E R)
     (SumCurriedHyps R p M)
     (CurriedElᵀ (Data.I R p) (λ i → (x : μ D i) → unM i x))
elimUncurried R p M cs =
  let D = Data.D R p
      unM = uncurryElᵀ (Data.I R p) (λ i → μ D i → Set) M
  in
  curryElᵀ (Data.I R p) (λ i → (x : μ D i) → unM i x) λ i x →
  indCurried (Data.D R p) unM
    (case (SumCurriedHyps R p M) cs)
    i x
elim : (R : Data)
  → ICurriedElᵀ (Data.P R) λ p
  → let D = Data.D R p in
  (M : CurriedElᵀ (Data.I R p) (λ i → μ D i → Set))
  → let unM = uncurryElᵀ (Data.I R p) (λ i → μ D i → Set) M
  in CurriedBranches (Data.E R)
     (SumCurriedHyps R p M)
     (CurriedElᵀ (Data.I R p) (λ i → (x : μ D i) → unM i x))
elim R = icurryElᵀ (Data.P R)
  (λ p → let D = Data.D R p in
    (M : CurriedElᵀ (Data.I R p) (λ i → μ D i → Set))
    → let unM = uncurryElᵀ (Data.I R p) (λ i → μ D i → Set) M
    in CurriedBranches (Data.E R)
       (SumCurriedHyps R p M)
       (CurriedElᵀ (Data.I R p) (λ i → (x : μ D i) → unM i x)))
  (λ p M → curryBranches (Data.E R) _ _
    (elimUncurried R p M))
----------------------------------------------------------------------
 
 | 
	{
  "alphanum_fraction": 0.4691809075,
  "avg_line_length": 30.1957295374,
  "ext": "agda",
  "hexsha": "00ffbac8c3ce054465a8028ce1706553b585cbe6",
  "lang": "Agda",
  "max_forks_count": 1,
  "max_forks_repo_forks_event_max_datetime": "2015-08-17T21:00:07.000Z",
  "max_forks_repo_forks_event_min_datetime": "2015-08-17T21:00:07.000Z",
  "max_forks_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353",
  "max_forks_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_forks_repo_name": "spire/spire",
  "max_forks_repo_path": "formalization/agda/Spire/IDarkwingDuck/Derived.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353",
  "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": "spire/spire",
  "max_issues_repo_path": "formalization/agda/Spire/IDarkwingDuck/Derived.agda",
  "max_line_length": 81,
  "max_stars_count": 43,
  "max_stars_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353",
  "max_stars_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_stars_repo_name": "spire/spire",
  "max_stars_repo_path": "formalization/agda/Spire/IDarkwingDuck/Derived.agda",
  "max_stars_repo_stars_event_max_datetime": "2022-03-08T17:10:59.000Z",
  "max_stars_repo_stars_event_min_datetime": "2015-05-28T23:25:33.000Z",
  "num_tokens": 3623,
  "size": 8485
} 
 | 
					
	module Relator.Equals.Proofs where
import      Lvl
open import Functional as Fn using (_→ᶠ_ ; _∘_)
open import Logic
open import Logic.Propositional
open import Logic.Propositional.Theorems
open import Logic.Propositional.Proofs.Structures
open import Relator.Equals
open import Relator.Equals.Proofs.Equiv public
open import Structure.Function.Names
open import Structure.Relator.Properties
open import Structure.Setoid using (Equiv ; intro) renaming (_≡_ to _≡ₛ_)
open import Structure.Type.Identity
open import Syntax.Function
open import Type
private variable ℓ ℓ₁ ℓ₂ ℓₑ₁ ℓₑ₂ ℓₑ ℓₚ : Lvl.Level
private variable T A B : Type{ℓ}
private variable x y : T
[≡]-coercion : (_≡_ {T = Type{ℓ}}) ⊆₂ (_→ᶠ_)
[≡]-coercion = [≡]-sub-of-reflexive
[≡]-unsubstitution : (∀{f : T → Stmt} → f(x) → f(y)) → (x ≡ y)
[≡]-unsubstitution {x = x} F = F {x ≡_} [≡]-intro
-- The statement that two functions are equal when all their values are equal are not provable.
-- Also called: Extensional equality, function extensionality.
-- [≡]-function : ∀{A B : Type}{f₁ f₂ : A → B) → (∀{x} → (f₁(x) ≡ f₂(x))) → (f₁ ≡ f₂)
[≡]-function-application : FunctionApplication A B
[≡]-function-application [≡]-intro = [≡]-intro
[≡]-with-specific : ∀{x y : A} → (f : (a : A) → ⦃ _ : (a ≡ x) ⦄ → ⦃ _ : (a ≡ y) ⦄ → B) → (p : (x ≡ y)) → (f(x) ⦃ [≡]-intro ⦄ ⦃ p ⦄ ≡ f(y) ⦃ symmetry(_≡_) p ⦄ ⦃ [≡]-intro ⦄)
[≡]-with-specific f [≡]-intro = [≡]-intro
 
 | 
	{
  "alphanum_fraction": 0.6551236749,
  "avg_line_length": 38.2432432432,
  "ext": "agda",
  "hexsha": "9637f02000b9908b0e166f344ffb7103d25cd26d",
  "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": "Relator/Equals/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": "Relator/Equals/Proofs.agda",
  "max_line_length": 172,
  "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": "Relator/Equals/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": 537,
  "size": 1415
} 
 | 
					
	module T where
open import Prelude
module GÖDEL-T where
  -- Core syntax
  infixr 30 _⇒_
  infixl 30 _$_
  data TTp : Set where
    nat : TTp
    _⇒_ : (A B : TTp) → TTp
  Ctx = List TTp
  data TExp (Γ : Ctx) : TTp → Set where
    var : ∀{A} (x : A ∈ Γ) → TExp Γ A
    Λ : ∀{A B} (e : TExp (A :: Γ) B) → TExp Γ (A ⇒ B)
    _$_ : ∀{A B} (e₁ : TExp Γ (A ⇒ B)) (e₂ : TExp Γ A) → TExp Γ B
    zero : TExp Γ nat
    suc : (e : TExp Γ nat) → TExp Γ nat
    rec : ∀{A} → (e : TExp Γ nat) → (e₀ : TExp Γ A) → (es : TExp (A :: Γ) A) →
               TExp Γ A
  TCExp = TExp []
  TNat = TCExp nat
  ---- denotational semantics
  interp : TTp → Set
  interp nat = Nat
  interp (A ⇒ B) = interp A → interp B
  meaningη : (Γ : Ctx) → Set
  meaningη Γ = ∀{A} (x : A ∈ Γ) → interp A
  emptyη : meaningη []
  emptyη ()
  extendη : ∀{Γ A} → meaningη Γ → interp A → meaningη (A :: Γ)
  extendη η M Z = M
  extendη η M (S n) = η n
  meaning : ∀{A Γ} → TExp Γ A → meaningη Γ → interp A
  meaning (var x) η = η x
  meaning (Λ e) η = λ x → meaning e (extendη η x)
  meaning (e₁ $ e₂) η = meaning e₁ η (meaning e₂ η)
  meaning zero η = Z
  meaning (suc e) η = S (meaning e η)
  meaning (rec e e₀ es) η = NAT.fold (meaning e₀ η)
                                     (λ n x → meaning es (extendη η x))
                                     (meaning e η)
  cmeaning : ∀{A} → TCExp A → interp A
  cmeaning e = meaning e emptyη
  ---- Definition related to substitution.
  -- Renamings
  TRen : Ctx → Ctx → Set
  TRen Γ Γ' = ∀ {A} → A ∈ Γ → A ∈ Γ'
  renId : ∀{Γ} → TRen Γ Γ
  renId = \ x -> x
  renComp : ∀{B Γ Δ} → TRen Γ Δ → TRen B Γ → TRen B Δ
  renComp f g = f o g
  wk : ∀{Γ Γ' A} → TRen Γ Γ' → TRen (A :: Γ) (A :: Γ')
  wk f Z = Z
  wk f (S n) = S (f n)
  ren : ∀{Γ Γ'} → TRen Γ Γ' → ∀ {A} → TExp Γ A → TExp Γ' A
  ren γ (var x) = var (γ x)
  ren γ (Λ e) = Λ (ren (wk γ) e)
  ren γ (e₁ $ e₂) = (ren γ e₁) $ (ren γ e₂)
  ren γ zero = zero
  ren γ (suc e) = suc (ren γ e)
  ren γ (rec e e₀ es) = rec (ren γ e) (ren γ e₀) (ren (wk γ) es)
  -- Substitutions
  TSubst : Ctx → Ctx → Set
  TSubst Γ Γ' = ∀ {A} → A ∈ Γ → TExp Γ' A
  emptyγ : ∀{Γ} → TSubst Γ Γ
  emptyγ = λ x → var x
  liftγ : ∀{Γ Γ' A} → TSubst Γ Γ' → TSubst (A :: Γ) (A :: Γ')
  liftγ γ Z = var Z
  liftγ γ (S n) = ren S (γ n)
  singγ : ∀{Γ A} → TExp Γ A → TSubst (A :: Γ) Γ
  singγ e Z = e
  singγ e (S n) = var n
  dropγ : ∀{Γ A Γ'} → TSubst (A :: Γ) Γ' → TSubst Γ Γ'
  dropγ γ n = γ (S n)
  closed-wkγ : {Γ : Ctx} → TRen [] Γ
  closed-wkγ ()
  ssubst : ∀{Γ Γ' C} →
           (γ : TSubst Γ Γ') →
           (e : TExp Γ C) →
           TExp Γ' C
  ssubst γ (var x) = γ x
  ssubst γ (Λ e) = Λ (ssubst (liftγ γ) e)
  ssubst γ (e₁ $ e₂) = (ssubst γ e₁) $ (ssubst γ e₂)
  ssubst γ zero = zero
  ssubst γ (suc e) = suc (ssubst γ e)
  ssubst γ (rec e e₀ es) = rec (ssubst γ e) (ssubst γ e₀) (ssubst (liftγ γ) es)
  subComp : ∀{B Γ Γ'} → TSubst Γ Γ' → TSubst B Γ → TSubst B Γ'
  subComp f g = ssubst f o g
  extendγ : ∀{Γ Γ' A} → TSubst Γ Γ' → TExp Γ' A → TSubst (A :: Γ) Γ'
  extendγ γ e = subComp (singγ e) (liftγ γ)
  -- substituting one thing in a closed term
  subst : ∀{A C} → (e' : TCExp A) → (e : TExp (A :: []) C) → TCExp C
  subst e' e = ssubst (singγ e') e
  weaken-closed : ∀{Γ B} → TCExp B → TExp Γ B
  weaken-closed e = ren closed-wkγ e
  ---- dynamic semantics (and, implicitly, preservation)
  data TVal : ∀{Γ A} → TExp Γ A → Set where
    val-zero : ∀{Γ} → TVal {Γ} zero
    val-suc : ∀{Γ e} → TVal {Γ} e → TVal {Γ} (suc e)
    val-lam : ∀{A B} {e : TExp (A :: []) B} → TVal (Λ e)
  -- only worry about closed steps; embed preservation in the statement
  -- We are call-by-name for function application, but call-by-value for natural evaluation.
  -- This is so that any value of type nat is a numeral.
  data _~>_ : ∀{A} → TCExp A → TCExp A → Set where
    step-app-l : ∀{A B} {e₁ e₁' : TCExp (A ⇒ B)} {e₂ : TCExp A} →
                  e₁ ~> e₁' → (e₁ $ e₂) ~> (e₁' $ e₂)
    step-beta  : ∀{A B} {e : TExp (A :: []) B} {e' : TCExp A} →
                  ((Λ e) $ e') ~> (subst e' e)
    step-suc   : ∀{e e' : TCExp nat} →
                  e ~> e' → (suc e) ~> (suc e')
    step-rec   : ∀{A} {e e' : TCExp nat} {e₀ : TCExp A} {es : TExp (A :: []) A} →
                  e ~> e' → (rec e e₀ es) ~> (rec e' e₀ es)
    step-rec-z : ∀{A} {e₀ : TCExp A} {es : TExp (A :: []) A} →
                  (rec zero e₀ es) ~> e₀
    step-rec-s : ∀{A} {e : TCExp nat} {e₀ : TCExp A} {es : TExp (A :: []) A} →
                  TVal e → (rec (suc e) e₀ es) ~> subst (rec e e₀ es) es
  -- iterated stepping
  data _~>*_ : ∀{A} → TCExp A → TCExp A → Set where
    eval-refl : ∀{A} {e : TCExp A} → e ~>* e
    eval-cons : ∀{A} {e e' e'' : TCExp A} →
               e ~> e' → e' ~>* e'' → e ~>* e''
  eval-step : ∀{A} {e e' : TCExp A} → e ~> e' → e ~>* e'
  eval-step s = eval-cons s eval-refl
  -- Should I use a record, or the product thing, or something else?
  data THalts : ∀{A} → TCExp A → Set where
    halts : {A : TTp} {e e' : TCExp A} → (eval : (e ~>* e')) → (val : TVal e') → THalts e
open GÖDEL-T public
 
 | 
	{
  "alphanum_fraction": 0.4908518591,
  "avg_line_length": 31.3765432099,
  "ext": "agda",
  "hexsha": "e50111759215996d5e63937db3b5609401cecc67",
  "lang": "Agda",
  "max_forks_count": 3,
  "max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z",
  "max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z",
  "max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "msullivan/godels-t",
  "max_forks_repo_path": "T.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91",
  "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": "msullivan/godels-t",
  "max_issues_repo_path": "T.agda",
  "max_line_length": 92,
  "max_stars_count": 4,
  "max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "msullivan/godels-t",
  "max_stars_repo_path": "T.agda",
  "max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z",
  "max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z",
  "num_tokens": 2169,
  "size": 5083
} 
 | 
					
	module Categories.Preorder where
 
 | 
	{
  "alphanum_fraction": 0.8787878788,
  "avg_line_length": 16.5,
  "ext": "agda",
  "hexsha": "14eb157b9126663cbc143cc0f5b2769ff3e92338",
  "lang": "Agda",
  "max_forks_count": 23,
  "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
  "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
  "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
  "max_forks_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_forks_repo_name": "p-pavel/categories",
  "max_forks_repo_path": "Categories/Preorder.agda",
  "max_issues_count": 19,
  "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
  "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
  "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
  "max_issues_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_issues_repo_name": "p-pavel/categories",
  "max_issues_repo_path": "Categories/Preorder.agda",
  "max_line_length": 32,
  "max_stars_count": 98,
  "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
  "max_stars_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_stars_repo_name": "copumpkin/categories",
  "max_stars_repo_path": "Categories/Preorder.agda",
  "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
  "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
  "num_tokens": 6,
  "size": 33
} 
 | 
					
	------------------------------------------------------------------------------
-- Totality properties respect to OrdList (flatten-OrdList-helper)
------------------------------------------------------------------------------
{-# OPTIONS --exact-split              #-}
{-# OPTIONS --no-sized-types           #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K                #-}
module FOTC.Program.SortList.Properties.Totality.OrdList.FlattenATP where
open import FOTC.Base
open import FOTC.Data.Bool.PropertiesATP
open import FOTC.Data.Nat.Inequalities
open import FOTC.Data.Nat.Inequalities.PropertiesATP
open import FOTC.Data.Nat.Type
open import FOTC.Program.SortList.Properties.Totality.BoolATP
open import FOTC.Program.SortList.Properties.Totality.ListN-ATP
open import FOTC.Program.SortList.Properties.Totality.OrdTreeATP
open import FOTC.Program.SortList.Properties.MiscellaneousATP
open import FOTC.Program.SortList.SortList
------------------------------------------------------------------------------
flatten-OrdList-helper : ∀ {t₁ i t₂} → Tree t₁ → N i → Tree t₂ →
                         OrdTree (node t₁ i t₂) →
                         ≤-Lists (flatten t₁) (flatten t₂)
flatten-OrdList-helper {t₂ = t₂} tnil Ni Tt₂ OTt =
  subst (λ t → ≤-Lists t (flatten t₂))
        (sym (flatten-nil))
        (le-Lists-[] (flatten t₂))
flatten-OrdList-helper (ttip {i₁} Ni₁) Tt₁ tnil OTt = prf
  where postulate prf : ≤-Lists (flatten (tip i₁)) (flatten nil)
        {-# ATP prove prf #-}
flatten-OrdList-helper {i = i} (ttip {i₁} Ni₁) Ni (ttip {i₂} Ni₂) OTt = prf
  where
  postulate lemma : i₁ ≤ i₂
  {-# ATP prove lemma ≤-trans &&-list₄-t le-ItemTree-Bool le-TreeItem-Bool ordTree-Bool #-}
  postulate prf : ≤-Lists (flatten (tip i₁)) (flatten (tip i₂))
  {-# ATP prove prf lemma #-}
flatten-OrdList-helper {i = i} (ttip {i₁} Ni₁) Ni
                       (tnode {t₂₁} {i₂} {t₂₂} Tt₂₁ Ni₂ Tt₂₂) OTt = prf
  where
  -- Helper terms to get the conjuncts from OTt.
  helper₁ = ordTree-Bool (ttip Ni₁)
  helper₂ = ordTree-Bool (tnode Tt₂₁ Ni₂ Tt₂₂)
  helper₃ = le-TreeItem-Bool (ttip Ni₁) Ni
  helper₄ = le-ItemTree-Bool Ni (tnode Tt₂₁ Ni₂ Tt₂₂)
  helper₅ = trans (sym (ordTree-node (tip i₁) i (node t₂₁ i₂ t₂₂))) OTt
  -- Helper terms to get the conjuncts from the fourth conjunct of OTt
  helper₆ = le-ItemTree-Bool Ni Tt₂₁
  helper₇ = le-ItemTree-Bool Ni Tt₂₂
  helper₈ = trans (sym (le-ItemTree-node i t₂₁ i₂ t₂₂))
                  (&&-list₄-t₄ helper₁ helper₂ helper₃ helper₄ helper₅)
  -- Common terms for the lemma₁ and lemma₂.
  -- The ATPs could not figure out them.
  OrdTree-tip-i₁ : OrdTree (tip i₁)
  OrdTree-tip-i₁ = &&-list₄-t₁ helper₁ helper₂ helper₃ helper₄ helper₅
  ≤-TreeItem-tip-i₁-i : ≤-TreeItem (tip i₁) i
  ≤-TreeItem-tip-i₁-i = &&-list₄-t₃ helper₁ helper₂ helper₃ helper₄ helper₅
  lemma₁ : ≤-Lists (flatten (tip i₁)) (flatten t₂₁)
  lemma₁ = flatten-OrdList-helper (ttip Ni₁) Ni Tt₂₁ OT
    where
    -- The ATPs could not figure these terms.
    OrdTree-t₂₁ : OrdTree t₂₁
    OrdTree-t₂₁ =
      leftSubTree-OrdTree Tt₂₁ Ni₂ Tt₂₂
                          (&&-list₄-t₂ helper₁ helper₂ helper₃ helper₄ helper₅)
    ≤-ItemTree-i-t₂₁ : ≤-ItemTree i t₂₁
    ≤-ItemTree-i-t₂₁ = &&-list₂-t₁ helper₆ helper₇ helper₈
    postulate OT : OrdTree (node (tip i₁) i t₂₁)
    {-# ATP prove OT ≤-TreeItem-tip-i₁-i ≤-ItemTree-i-t₂₁ OrdTree-tip-i₁ OrdTree-t₂₁ #-}
  lemma₂ : ≤-Lists (flatten (tip i₁)) (flatten t₂₂)
  lemma₂ = flatten-OrdList-helper (ttip Ni₁) Ni Tt₂₂ OT
    where
    -- The ATPs could not figure these terms.
    OrdTree-t₂₂ : OrdTree t₂₂
    OrdTree-t₂₂ =
      rightSubTree-OrdTree Tt₂₁ Ni₂ Tt₂₂
                           (&&-list₄-t₂ helper₁ helper₂ helper₃ helper₄ helper₅)
    ≤-ItemTree-i-t₂₂ : ≤-ItemTree i t₂₂
    ≤-ItemTree-i-t₂₂ = &&-list₂-t₂ helper₆ helper₇ helper₈
    postulate OT : OrdTree (node (tip i₁) i t₂₂)
    {-# ATP prove OT ≤-TreeItem-tip-i₁-i ≤-ItemTree-i-t₂₂ OrdTree-tip-i₁ OrdTree-t₂₂ #-}
  postulate prf : ≤-Lists (flatten (tip i₁)) (flatten (node t₂₁ i₂ t₂₂))
  {-# ATP prove prf xs≤ys→xs≤zs→xs≤ys++zs flatten-ListN lemma₁ lemma₂ #-}
flatten-OrdList-helper {i = i} (tnode {t₁₁} {i₁} {t₁₂} Tt₁₁ Ni₁ Tt₁₂)
                       Ni tnil OTt = prf
  where
  -- Helper terms to get the conjuncts from OTt.
  helper₁ = ordTree-Bool (tnode Tt₁₁ Ni₁ Tt₁₂)
  helper₂ = ordTree-Bool tnil
  helper₃ = le-TreeItem-Bool (tnode Tt₁₁ Ni₁ Tt₁₂) Ni
  helper₄ = le-ItemTree-Bool Ni tnil
  helper₅ = trans (sym (ordTree-node (node t₁₁ i₁ t₁₂) i nil)) OTt
  -- Helper terms to get the conjuncts from the third conjunct of OTt.
  helper₆ = le-TreeItem-Bool Tt₁₁ Ni
  helper₇ = le-TreeItem-Bool Tt₁₂ Ni
  helper₈ = trans (sym (le-TreeItem-node t₁₁ i₁ t₁₂ i))
                  (&&-list₄-t₃ helper₁ helper₂ helper₃ helper₄ helper₅)
  lemma₁ : ≤-Lists (flatten t₁₁) (flatten nil)
  lemma₁ = flatten-OrdList-helper Tt₁₁ Ni tnil OT
    where
    postulate OT : OrdTree (node t₁₁ i nil)
    {-# ATP prove OT leftSubTree-OrdTree &&-list₂-t &&-list₄-t helper₁ helper₂ helper₃ helper₄ helper₅ helper₆ helper₇ helper₈ #-}
  lemma₂ : ≤-Lists (flatten t₁₂) (flatten nil)
  lemma₂ = flatten-OrdList-helper Tt₁₂ Ni tnil OT
    where
    postulate OT : OrdTree (node t₁₂ i nil)
    {-# ATP prove OT rightSubTree-OrdTree &&-list₄-t helper₁ helper₂ helper₃ helper₄ helper₅ helper₆ helper₇ helper₈ #-}
  postulate prf : ≤-Lists (flatten (node t₁₁ i₁ t₁₂)) (flatten nil)
  {-# ATP prove prf xs≤zs→ys≤zs→xs++ys≤zs flatten-ListN lemma₁ lemma₂ #-}
flatten-OrdList-helper {i = i} (tnode {t₁₁} {i₁} {t₁₂} Tt₁₁ Ni₁ Tt₁₂) Ni
                       (ttip {i₂} Ni₂) OTt = prf
  where
  -- Helper terms to get the conjuncts from OTt.
  helper₁ = ordTree-Bool (tnode Tt₁₁ Ni₁ Tt₁₂)
  helper₂ = ordTree-Bool (ttip Ni₂)
  helper₃ = le-TreeItem-Bool (tnode Tt₁₁ Ni₁ Tt₁₂) Ni
  helper₄ = le-ItemTree-Bool Ni (ttip Ni₂)
  helper₅ = trans (sym (ordTree-node (node t₁₁ i₁ t₁₂) i (tip i₂))) OTt
  -- Helper terms to get the conjuncts from the third conjunct of OTt.
  helper₆ = le-TreeItem-Bool Tt₁₁ Ni
  helper₇ = le-TreeItem-Bool Tt₁₂ Ni
  helper₈ = trans (sym (le-TreeItem-node t₁₁ i₁ t₁₂ i))
                  (&&-list₄-t₃ helper₁ helper₂ helper₃ helper₄ helper₅)
  lemma₁ : ≤-Lists (flatten t₁₁) (flatten (tip i₂))
  lemma₁ = flatten-OrdList-helper Tt₁₁ Ni (ttip Ni₂) OT
    where
    postulate OT : OrdTree (node t₁₁ i (tip i₂))
    {-# ATP prove OT leftSubTree-OrdTree &&-list₂-t &&-list₄-t helper₁ helper₂ helper₃ helper₄ helper₅ helper₆ helper₇ helper₈ #-}
  lemma₂ : ≤-Lists (flatten t₁₂) (flatten (tip i₂))
  lemma₂ = flatten-OrdList-helper Tt₁₂ Ni (ttip Ni₂) OT
    where
    postulate OT : OrdTree (node t₁₂ i (tip i₂))
    {-# ATP prove OT rightSubTree-OrdTree &&-list₂-t &&-list₄-t helper₁ helper₂ helper₃ helper₄ helper₅ helper₆ helper₇ helper₈ #-}
  postulate prf : ≤-Lists (flatten (node t₁₁ i₁ t₁₂)) (flatten (tip i₂))
  {-# ATP prove prf xs≤zs→ys≤zs→xs++ys≤zs flatten-ListN lemma₁ lemma₂ #-}
flatten-OrdList-helper {i = i} (tnode {t₁₁} {i₁} {t₁₂} Tt₁₁ Ni₁ Tt₁₂) Ni
                       (tnode {t₂₁} {i₂} {t₂₂} Tt₂₁ Ni₂ Tt₂₂) OTt = prf
  where
  -- Helper terms to get the conjuncts from OTt.
  helper₁ = ordTree-Bool (tnode Tt₁₁ Ni₁ Tt₁₂)
  helper₂ = ordTree-Bool (tnode Tt₂₁ Ni₂ Tt₂₂)
  helper₃ = le-TreeItem-Bool (tnode Tt₁₁ Ni₁ Tt₁₂) Ni
  helper₄ = le-ItemTree-Bool Ni (tnode Tt₂₁ Ni₂ Tt₂₂)
  helper₅ = trans (sym (ordTree-node (node t₁₁ i₁ t₁₂) i (node t₂₁ i₂ t₂₂)))
                    OTt
  -- Helper terms to get the conjuncts from the third conjunct of OTt.
  helper₆ = le-TreeItem-Bool Tt₁₁ Ni
  helper₇ = le-TreeItem-Bool Tt₁₂ Ni
  helper₈ = trans (sym (le-TreeItem-node t₁₁ i₁ t₁₂ i))
                  (&&-list₄-t₃ helper₁ helper₂ helper₃ helper₄ helper₅)
  lemma₁ : ≤-Lists (flatten t₁₁) (flatten (node t₂₁ i₂ t₂₂))
  lemma₁ = flatten-OrdList-helper Tt₁₁ Ni (tnode Tt₂₁ Ni₂ Tt₂₂) OT
    where
    postulate OT : OrdTree (node t₁₁ i (node t₂₁ i₂ t₂₂))
    {-# ATP prove OT leftSubTree-OrdTree &&-list₂-t &&-list₄-t helper₁ helper₂ helper₃ helper₄ helper₅ helper₆ helper₇ helper₈ #-}
  lemma₂ : ≤-Lists (flatten t₁₂) (flatten (node t₂₁ i₂ t₂₂))
  lemma₂ = flatten-OrdList-helper Tt₁₂ Ni (tnode Tt₂₁ Ni₂ Tt₂₂) OT
    where
    postulate OT : OrdTree (node t₁₂ i (node t₂₁ i₂ t₂₂))
    {-# ATP prove OT rightSubTree-OrdTree &&-list₂-t &&-list₄-t helper₁ helper₂ helper₃ helper₄ helper₅ helper₆ helper₇ helper₈ #-}
  postulate prf : ≤-Lists (flatten (node t₁₁ i₁ t₁₂))
                  (flatten (node t₂₁ i₂ t₂₂))
  {-# ATP prove prf xs≤zs→ys≤zs→xs++ys≤zs flatten-ListN lemma₁ lemma₂ #-}
 
 | 
	{
  "alphanum_fraction": 0.6486360457,
  "avg_line_length": 43.5431472081,
  "ext": "agda",
  "hexsha": "22c42bec315e8ed9711b5f3d3b70a604bd06658b",
  "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/Properties/Totality/OrdList/FlattenATP.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/Properties/Totality/OrdList/FlattenATP.agda",
  "max_line_length": 131,
  "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/Properties/Totality/OrdList/FlattenATP.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": 3118,
  "size": 8578
} 
 | 
					
	{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.Rationals.SigmaQ.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.HITs.Ints.QuoInt
open import Cubical.Data.Nat as ℕ hiding (_·_)
open import Cubical.Data.NatPlusOne
open import Cubical.Data.Sigma
open import Cubical.Data.Nat.GCD
open import Cubical.Data.Nat.Coprime
-- ℚ as the set of coprime pairs in ℤ × ℕ₊₁
ℚ : Type₀
ℚ = Σ[ (a , b) ∈ ℤ × ℕ₊₁ ] areCoprime (abs a , ℕ₊₁→ℕ b)
isSetℚ : isSet ℚ
isSetℚ = isSetΣ (isSet× isSetℤ (subst isSet 1+Path isSetℕ)) (λ _ → isProp→isSet isPropIsGCD)
signedPair : Sign → ℕ × ℕ₊₁ → ℤ × ℕ₊₁
signedPair s (a , b) = (signed s a , b)
[_] : ℤ × ℕ₊₁ → ℚ
[ signed s a , b ] = signedPair s (toCoprime (a , b)) , toCoprimeAreCoprime (a , b)
[ posneg i   , b ] = (posneg i , 1) , toCoprimeAreCoprime (0 , b)
[]-cancelʳ : ∀ ((a , b) : ℤ × ℕ₊₁) k → [ a · pos (ℕ₊₁→ℕ k) , b ·₊₁ k ] ≡ [ a , b ]
[]-cancelʳ (signed s zero    , b) k =
  Σ≡Prop (λ _ → isPropIsGCD) (λ i → signed-zero spos s i , 1)
[]-cancelʳ (signed s (suc a) , b) k =
  Σ≡Prop (λ _ → isPropIsGCD) (λ i → signedPair (·S-comm s spos i)
                                               (toCoprime-cancelʳ (suc a , b) k i))
[]-cancelʳ (posneg i ,         b) k j =
  isSet→isSet' isSetℚ ([]-cancelʳ (pos zero , b) k) ([]-cancelʳ (neg zero , b) k)
                      (λ i → [ posneg i · pos (ℕ₊₁→ℕ k) , b ·₊₁ k ]) (λ i → [ posneg i , b ]) i j
-- Natural number and negative integer literals for ℚ
open import Cubical.Data.Nat.Literals public
instance
  fromNatℚ : HasFromNat ℚ
  fromNatℚ = record { Constraint = λ _ → Unit ; fromNat = λ n → (pos n , 1) , oneGCD n }
instance
  fromNegℚ : HasFromNeg ℚ
  fromNegℚ = record { Constraint = λ _ → Unit ; fromNeg = λ n → (neg n , 1) , oneGCD n }
 
 | 
	{
  "alphanum_fraction": 0.6029654036,
  "avg_line_length": 33.1090909091,
  "ext": "agda",
  "hexsha": "06c8305dab78e058c1377ddf174cb4e1171a8f35",
  "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": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "dan-iel-lee/cubical",
  "max_forks_repo_path": "Cubical/HITs/Rationals/SigmaQ/Base.agda",
  "max_issues_count": 1,
  "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
  "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
  "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "dan-iel-lee/cubical",
  "max_issues_repo_path": "Cubical/HITs/Rationals/SigmaQ/Base.agda",
  "max_line_length": 97,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "dan-iel-lee/cubical",
  "max_stars_repo_path": "Cubical/HITs/Rationals/SigmaQ/Base.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 727,
  "size": 1821
} 
 | 
					
	
-- Equality of terms
module Syntax.Equality where
open import Syntax.Types
open import Syntax.Context
open import Syntax.Terms
open import Syntax.Substitution.Kits
open import Syntax.Substitution.Instances
open import Syntax.Substitution.Lemmas
open Kit 𝒯erm
-- Shorthands for de Bruijn indices
x₁ : ∀{Γ A} -> Γ , A now ⊢ A now
x₁ = var top
x₂ : ∀{Γ A B} -> Γ , A now , B ⊢ A now
x₂ = var (pop top)
x₃ : ∀{Γ A B C} -> Γ , A now , B , C ⊢ A now
x₃ = var (pop (pop top))
x₄ : ∀{Γ A B C D} -> Γ , A now , B , C , D ⊢ A now
x₄ = var (pop (pop (pop top)))
s₁ : ∀{Γ A} -> Γ , A always ⊢ A always
s₁ = var top
s₂ : ∀{Γ A B} -> Γ , A always , B ⊢ A always
s₂ = var (pop top)
s₃ : ∀{Γ A B C} -> Γ , A always , B , C ⊢ A always
s₃ = var (pop (pop top))
s₄ : ∀{Γ A B C D} -> Γ , A always , B , C , D ⊢ A always
s₄ = var (pop (pop (pop top)))
-- β-η equality of terms
data Eq (Γ : Context) : (A : Judgement) -> Γ ⊢ A -> Γ ⊢ A -> Set
data Eq′ (Γ : Context) : (A : Judgement) -> Γ ⊨ A -> Γ ⊨ A -> Set
syntax Eq Γ A M N = Γ ⊢ M ≡ N ∷ A
syntax Eq′ Γ A M N = Γ ⊨ M ≡ N ∷ A
data Eq Γ where
    -- | Equivalence relation
    -- Reflexivity
    refl  : ∀{A}            ->               (M : Γ ⊢ A)
                                           ---------------
                            ->              Γ ⊢ M ≡ M ∷ A
    -- Symmetry
    sym   : ∀{A}{M₁ M₂ : Γ ⊢ A}
                            ->              Γ ⊢ M₁ ≡ M₂ ∷ A
                                           -----------------
                            ->              Γ ⊢ M₂ ≡ M₁ ∷ A
    -- Transitivity
    trans : ∀{A}{M₁ M₂ M₃ : Γ ⊢ A}
                            ->   Γ ⊢ M₁ ≡ M₂ ∷ A   ->   Γ ⊢ M₂ ≡ M₃ ∷ A
                                -----------------------------------------
                            ->               Γ ⊢ M₁ ≡ M₃ ∷ A
    -- | β-equality
    -- β-reduction for function application
    β-lam : ∀{A B}          ->  (N : Γ , A now ⊢ B now)   (M : Γ ⊢ A now)
                               -------------------------------------------
                            ->      Γ ⊢ (lam N) $ M ≡ [ M /] N ∷ B now
    -- β-reduction for first projection
    β-fst : ∀{A B}          ->        (M : Γ ⊢ A now)   (N : Γ ⊢ B now)
                                     -----------------------------------
                            ->          Γ ⊢ fst [ M ,, N ] ≡ M ∷ A now
    -- β-reduction for second projection
    β-snd : ∀{A B}          ->        (M : Γ ⊢ A now)   (N : Γ ⊢ B now)
                                     -----------------------------------
                            ->          Γ ⊢ snd [ M ,, N ] ≡ N ∷ B now
    -- β-reduction for case split on first injection
    β-inl : ∀{A B C}        ->                    (M : Γ ⊢ A now)
                                 (N₁ : Γ , A now ⊢ C now) (N₂ : Γ , B now ⊢ C now)
                                ---------------------------------------------------
                            ->       Γ ⊢ case (inl M) inl↦ N₁
                                                    ||inr↦ N₂ ≡ [ M /] N₁ ∷ C now
    -- β-reduction for case split on first injection
    β-inr : ∀{A B C}        ->                    (M : Γ ⊢ B now)
                                 (N₁ : Γ , A now ⊢ C now) (N₂ : Γ , B now ⊢ C now)
                                ---------------------------------------------------
                            ->       Γ ⊢ case (inr M) inl↦ N₁
                                                    ||inr↦ N₂ ≡ [ M /] N₂ ∷ C now
    -- β-reduction for signal binding
    β-sig : ∀{A B}          ->  (N : Γ , A always ⊢ B now)   (M : Γ ⊢ A always)
                               --------------------------------------------------
                            ->     Γ ⊢ letSig (sig M) In N ≡ [ M /] N ∷ B now
    -- | η-equality
    -- η-expansion for functions
    η-lam : ∀{A B}          ->              (M : Γ ⊢ A => B now)
                                   --------------------------------------
                            ->      Γ ⊢ M ≡ lam (𝓌 M $ x₁) ∷ A => B now
    -- η-expansion for pairs
    η-pair : ∀{A B}         ->               (M : Γ ⊢ A & B now)
                                   ----------------------------------------
                            ->      Γ ⊢ M ≡ [ fst M ,, snd M ] ∷ A & B now
    -- η-expansion for unit
    η-unit :                                 (M : Γ ⊢ Unit now)
                                          -------------------------
                            ->             Γ ⊢ M ≡ unit ∷ Unit now
    -- η-expansion for sums
    η-sum : ∀{A B}          ->                (M : Γ ⊢ A + B now)
                                    ------------------------------------------
                            ->        Γ ⊢ M ≡ case M inl↦ inl x₁
                                                   ||inr↦ inr x₁ ∷ A + B now
    -- η-expansion for signals
    η-sig : ∀{A}            ->                (M : Γ ⊢ Signal A now)
                                    -------------------------------------------
                            ->       Γ ⊢ M ≡ letSig M In (sig s₁) ∷ Signal A now
    -- η-expansion for events in computational terms
    η-evt : ∀{A}           ->                  (M : Γ ⊢ Event A now)
                                  ----------------------------------------------------
                            ->     Γ ⊢ M ≡ event (letEvt M In pure x₁) ∷ Event A now
    -- | Congruence rules
    -- Congruence in pairs
    cong-pair : ∀{A B}{M₁ M₂ : Γ ⊢ A now}{N₁ N₂ : Γ ⊢ B now}
                            ->   Γ ⊢ M₁ ≡ M₂ ∷ A now  ->   Γ ⊢ N₁ ≡ N₂ ∷ B now
                                ------------------------------------------------
                            ->    Γ ⊢ [ M₁ ,, N₁ ] ≡ [ M₂ ,, N₂ ] ∷ A & B now
    -- Congruence in first projection
    cong-fst : ∀{A B}{M₁ M₂ : Γ ⊢ A & B now}
                            ->             Γ ⊢ M₁ ≡ M₂ ∷ A & B now
                                        ------------------------------
                            ->           Γ ⊢ fst M₁ ≡ fst M₂ ∷ A now
    -- Congruence in second projection
    cong-snd : ∀{A B}{M₁ M₂ : Γ ⊢ A & B now}
                            ->             Γ ⊢ M₁ ≡ M₂ ∷ A & B now
                                        ------------------------------
                            ->           Γ ⊢ snd M₁ ≡ snd M₂ ∷ B now
    -- Congruence in lambda body
    cong-lam : ∀{A B}{M₁ M₂ : Γ , A now ⊢ B now}
                            ->            Γ , A now ⊢ M₁ ≡ M₂ ∷ B now
                                       ----------------------------------
                            ->          Γ ⊢ lam M₁ ≡ lam M₂ ∷ A => B now
    -- Congruence in application
    cong-app : ∀{A B}{N₁ N₂ : Γ ⊢ A => B now}{M₁ M₂ : Γ ⊢ A now}
                            ->   Γ ⊢ N₁ ≡ N₂ ∷ A => B now  ->  Γ ⊢ M₁ ≡ M₂ ∷ A now
                                ---------------------------------------------------
                            ->            Γ ⊢ N₁ $ M₁ ≡ N₂ $ M₂ ∷ B now
    -- Congruence in case split
    cong-case : ∀{A B C}{M₁ M₂ : Γ ⊢ A + B now}
                            ->               Γ ⊢ M₁ ≡ M₂ ∷ A + B now
                            ->   (N₁ : Γ , A now ⊢ C now) (N₂ : Γ , B now ⊢ C now)
                                ---------------------------------------------------
                            ->          Γ ⊢ case M₁ inl↦ N₁ ||inr↦ N₂
                                          ≡ case M₂ inl↦ N₁ ||inr↦ N₂ ∷ C now
    -- Congruence in first injection
    cong-inl : ∀{A B}{M₁ M₂ : Γ ⊢ A now}
                            ->              Γ ⊢ M₁ ≡ M₂ ∷ A now
                                      ------------------------------------
                            ->         Γ ⊢ inl M₁ ≡ inl M₂ ∷ A + B now
    -- Congruence in second injection
    cong-inr : ∀{A B}{M₁ M₂ : Γ ⊢ B now}
                            ->              Γ ⊢ M₁ ≡ M₂ ∷ B now
                                      ------------------------------------
                            ->         Γ ⊢ inr M₁ ≡ inr M₂ ∷ A + B now
    -- Congruence in signal constructor
    cong-sig : ∀{A}{M₁ M₂ : Γ ⊢ A always}
                            ->              Γ ⊢ M₁ ≡ M₂ ∷ A always
                                      ------------------------------------
                            ->         Γ ⊢ sig M₁ ≡ sig M₂ ∷ Signal A now
    -- Congruence in signal binding
    cong-letSig : ∀{A B}{S₁ S₂ : Γ ⊢ Signal A now}
                            ->          Γ ⊢ S₁ ≡ S₂ ∷ Signal A now
                            ->          (N : Γ , A always ⊢ B now)
                                ---------------------------------------------
                            ->   Γ ⊢ letSig S₁ In N ≡ letSig S₂ In N ∷ B now
    -- Congruence in sampling
    cong-sample : ∀{A}{M₁ M₂ : Γ ⊢ A always}
                            ->              Γ ⊢ M₁ ≡ M₂ ∷ A always
                                      -------------------------------------
                            ->         Γ ⊢ sample M₁ ≡ sample M₂ ∷ A now
    -- Congruence in stabilisation
    cong-stable : ∀{A}{M₁ M₂ : Γ ˢ ⊢ A now}
                            ->                 Γ ˢ ⊢ M₁ ≡ M₂ ∷ A now
                                      -------------------------------------
                            ->         Γ ⊢ stable M₁ ≡ stable M₂ ∷ A always
    -- Congruence in events
    cong-event : ∀{A}{E₁ E₂ : Γ ⊨ A now}
                            ->                 Γ ⊨ E₁ ≡ E₂ ∷ A now
                                      -------------------------------------
                            ->         Γ ⊢ event E₁ ≡ event E₂ ∷ Event A now
data Eq′ (Γ : Context) where
    -- | Equivalence relation
    -- Reflexivity
    refl  : ∀{A}            ->                (M : Γ ⊨ A)
                                            ---------------
                            ->               Γ ⊨ M ≡ M ∷ A
    -- Symmetry
    sym   : ∀{A}{M₁ M₂ : Γ ⊨ A}
                            ->              Γ ⊨ M₁ ≡ M₂ ∷ A
                                           -----------------
                            ->              Γ ⊨ M₂ ≡ M₁ ∷ A
    -- Transitivity
    trans : ∀{A}{M₁ M₂ M₃ : Γ ⊨ A}
                            ->   Γ ⊨ M₁ ≡ M₂ ∷ A   ->   Γ ⊨ M₂ ≡ M₃ ∷ A
                                -----------------------------------------
                            ->               Γ ⊨ M₁ ≡ M₃ ∷ A
    -- | β-equality
    -- β-reduction for signal binding in computational terms
    β-sig′ : ∀{A B}         ->  (C : Γ , A always ⊨ B now)   (M : Γ ⊢ A always)
                               --------------------------------------------------
                            ->     Γ ⊨ letSig (sig M) InC C ≡ [ M /′] C ∷ B now
    -- β-reduction for event binding in computational terms
    β-evt′ : ∀{A B}         ->     (C : Γ ˢ , A now ⊨ B now)   (D : Γ ⊨ A now)
                                 ---------------------------------------------
                            ->    Γ ⊨ letEvt (event D) In C ≡ ⟨ D /⟩ C ∷ B now
    -- β-reduction for event binding in computational terms
    β-selectₚ : ∀{A B C}    ->      (C₁ : Γ ˢ , A now , Event B now ⊨ C now)
                                    (C₂ : Γ ˢ , Event A now , B now ⊨ C now)
                                       (C₃ : Γ ˢ , A now , B now ⊨ C now)
                                      (M₁ : Γ ⊢ A now)   (M₂ : Γ ⊢ B now)
                                 ---------------------------------------------
                            ->    Γ ⊨ select event (pure M₁) ↦ C₁
                                          || event (pure M₂) ↦ C₂
                                          ||both↦ C₃
                                    ≡ [ M₁ /′] ([ 𝓌 M₂ /′]
                                        (weakening′ (keep (keep (Γˢ⊆Γ Γ))) C₃)) ∷ C now
    -- | η-equality
    -- η-expansion for signals in computational terms
    η-sig′ : ∀{A}           ->                  (M : Γ ⊢ Signal A now)
                               --------------------------------------------------------
                            ->  Γ ⊨ pure M ≡ letSig M InC (pure (sig s₁)) ∷ Signal A now
    -- | Congruence rules
    -- Congruence in pure computational term
    cong-pure′ : ∀{A}{M₁ M₂ : Γ ⊢ A}
                            ->                Γ ⊢ M₁ ≡ M₂ ∷ A
                                         ---------------------------
                            ->            Γ ⊨ pure M₁ ≡ pure M₂ ∷ A
    -- Congruence in signal binding
    cong-letSig′ : ∀{A B}{S₁ S₂ : Γ ⊢ Signal A now}
                            ->            Γ ⊢ S₁ ≡ S₂ ∷ Signal A now
                            ->            (N : Γ , A always ⊨ B now)
                                -----------------------------------------------
                            ->   Γ ⊨ letSig S₁ InC N ≡ letSig S₂ InC N ∷ B now
    -- Congruence in event binding
    cong-letEvt′ : ∀{A B}{E₁ E₂ : Γ ⊢ Event A now}
                            ->            Γ ⊢ E₁ ≡ E₂ ∷ Event A now
                            ->            (D : Γ ˢ , A now ⊨ B now)
                                -----------------------------------------------
                            ->   Γ ⊨ letEvt E₁ In D ≡ letEvt E₂ In D ∷ B now
test : ∀{A} -> ∙ ⊢ (Signal A => A) now
test = lam (letSig x₁ In sample s₁)
tes : ∀{A} -> ∙ ⊢ (Signal A => Signal (Signal A)) now
tes = lam (letSig x₁ In sig (stable (sig s₁)))
te : ∀{A} -> ∙ ⊢ (A => Event A) now
te = lam (event (pure x₁))
t2 : ∀{A} -> ∙ ⊢ (Signal A) now -> ∙ ⊢ A always
t2 M = stable (letSig M In sample s₁)
t : ∀{A} -> ∙ ⊢ (Event (Event A) => Event A) now
t = lam (event (letEvt x₁ In (letEvt x₁ In pure x₁)))
t3 : ∀{A B} -> ∙ ⊢ (Event A => Signal (A => Event B) => Event B) now
t3 = lam (lam
        (letSig x₁ In (event
        (letEvt x₃ In
        (letEvt (sample s₂ $ x₁) In pure x₁)))))
-- t4 : ∀{A B C} -> ∙ ⊢ (Event A => Event B => Signal (A => Event C) => Signal (B => Event C) => Event C) now
-- t4 = lam (lam (lam (lam (
--         letSig x₂ In (
--         letSig x₂ In (event (
--             select (var (pop (pop (pop (pop (pop top)))))) ↦ letEvt sample s₄ $ x₁ In pure x₁
--                 || (var (pop (pop (pop (pop top))))) ↦ letEvt (sample s₃ $ x₁) In pure x₁
--                 ||both↦ {!   !})))))))
t5 : ∀{A B} -> ∙ , Signal A now , Event (A => B) now ⊨ B now
t5 = letSig (var (pop top)) InC (letEvt (var (pop top)) In pure (x₁ $ sample s₂))
t6 : ∀{A B} -> ∙ , Event (Signal A) now , Signal B now ⊢ Event (Signal (A & B)) now
t6 = event (letSig x₁ InC (letEvt x₃ In (pure (letSig x₁ In (sig (stable [ sample s₁ ,, sample s₂ ]))))))
-- t6 = event (letSig x₁ InC (letEvt x₃ In (letSig x₁ InC (pure [ sample s₁ ,, sample s₃ ]))))
too : ∀{A B} -> ∙ ⊢ Signal (A => B) => (Event A => Event B) now
too = lam (lam (letSig x₂ In event (letEvt x₂ In pure (sample s₂ $ x₁))))
 
 | 
	{
  "alphanum_fraction": 0.2973046556,
  "avg_line_length": 45.6273291925,
  "ext": "agda",
  "hexsha": "261976b34afabb7cefed709fb50210a125d006dd",
  "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": "7d993ba55e502d5ef8707ca216519012121a08dd",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "DimaSamoz/temporal-type-systems",
  "max_forks_repo_path": "src/Syntax/Equality.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
  "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": "DimaSamoz/temporal-type-systems",
  "max_issues_repo_path": "src/Syntax/Equality.agda",
  "max_line_length": 109,
  "max_stars_count": 4,
  "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "DimaSamoz/temporal-type-systems",
  "max_stars_repo_path": "src/Syntax/Equality.agda",
  "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z",
  "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z",
  "num_tokens": 4114,
  "size": 14692
} 
 | 
					
	module All where
open import Basics
open import Ix
All : {X : Set} -> (X -> Set) -> (List X -> Set)
All P []        = One
All P (x ,- xs) = P x * All P xs
allPu : forall {X}{T : X -> Set} -> [ T ] -> [ All T ]
allPu t [] = <>
allPu t (x ,- xs) = t x , allPu t xs
allAp : forall {X}{S T : X -> Set} -> [ All (S -:> T) -:> All S -:> All T ]
allAp [] <> <> = <>
allAp (x ,- xs) (f , fs) (s , ss) = f s , allAp xs fs ss
all : {X : Set}{S T : X -> Set} ->
      [ S -:> T ] -> [ All S -:> All T ]
all f xs = allAp xs (allPu f xs)
allRe : forall {X Y}(f : X -> Y){P : Y -> Set}
        (xs : List X) -> All (\ x -> P (f x)) xs -> All P (list f xs)
allRe f [] <> = <>
allRe f (x ,- xs) (p , ps) = p , allRe f xs ps
collect : {I J : Set}(is : List I) -> All (\ i -> List J) is -> List J
collect [] <> = []
collect (i ,- is) (js , jss) = js +L collect is jss
 
 | 
	{
  "alphanum_fraction": 0.4504084014,
  "avg_line_length": 28.5666666667,
  "ext": "agda",
  "hexsha": "6b3033595ebf9de81e94a32700ea1f8fc426e92c",
  "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": "454cdd18f56db0b0d1643a1fcf36951b5ece395c",
  "max_forks_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_forks_repo_name": "pigworker/InteriorDesign",
  "max_forks_repo_path": "All.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c",
  "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": "pigworker/InteriorDesign",
  "max_issues_repo_path": "All.agda",
  "max_line_length": 75,
  "max_stars_count": 6,
  "max_stars_repo_head_hexsha": "454cdd18f56db0b0d1643a1fcf36951b5ece395c",
  "max_stars_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_stars_repo_name": "pigworker/InteriorDesign",
  "max_stars_repo_path": "All.agda",
  "max_stars_repo_stars_event_max_datetime": "2018-07-31T02:00:13.000Z",
  "max_stars_repo_stars_event_min_datetime": "2018-06-18T15:25:39.000Z",
  "num_tokens": 337,
  "size": 857
} 
 | 
					
	-- {-# OPTIONS --without-K #-}
module Evaluator where
open import Agda.Prim
open import Data.Unit
open import Data.Nat hiding (_⊔_)
open import Data.Sum 
open import Data.Product
open import Function
open import Relation.Binary.PropositionalEquality
open import Paths
------------------------------------------------------------------------------
-- For the usual situation, we can only establish one direction of univalence
swap₊ : {ℓ : Level} {A B : Set ℓ} → A ⊎ B → B ⊎ A
swap₊ (inj₁ a) = inj₂ a
swap₊ (inj₂ b) = inj₁ b
assocl₊ : {ℓ : Level} {A B C : Set ℓ} → A ⊎ (B ⊎ C) → (A ⊎ B) ⊎ C
assocl₊ (inj₁ a) = inj₁ (inj₁ a)
assocl₊ (inj₂ (inj₁ b)) = inj₁ (inj₂ b)
assocl₊ (inj₂ (inj₂ c)) = inj₂ c
assocr₊ : {ℓ : Level} {A B C : Set ℓ} → (A ⊎ B) ⊎ C → A ⊎ (B ⊎ C)
assocr₊ (inj₁ (inj₁ a)) = inj₁ a
assocr₊ (inj₁ (inj₂ b)) = inj₂ (inj₁ b)
assocr₊ (inj₂ c) = inj₂ (inj₂ c)
unite⋆ : {ℓ : Level} {A : Set ℓ} → ⊤ × A → A
unite⋆ (tt , a) = a
uniti⋆ : {ℓ : Level} {A : Set ℓ} → A → ⊤ × A 
uniti⋆ a = (tt , a)
swap⋆ : {ℓ : Level} {A B : Set ℓ} → A × B → B × A
swap⋆ (a , b) = (b , a) 
assocl⋆ : {ℓ : Level} {A B C : Set ℓ} → A × (B × C) → (A × B) × C
assocl⋆ (a , (b , c)) = ((a , b) , c) 
assocr⋆ : {ℓ : Level} {A B C : Set ℓ} → (A × B) × C → A × (B × C)
assocr⋆ ((a , b) , c) = (a , (b , c))
dist : {ℓ : Level} {A B C : Set ℓ} → (A ⊎ B) × C → (A × C ⊎ B × C)
dist (inj₁ a , c) = inj₁ (a , c)
dist (inj₂ b , c) = inj₂ (b , c)
fact : {ℓ : Level} {A B C : Set ℓ} → (A × C ⊎ B × C) → (A ⊎ B) × C
fact (inj₁ (a , c)) = (inj₁ a , c) 
fact (inj₂ (b , c)) = (inj₂ b , c) 
eval : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → Path a b → (A → B)
eval swap₁₊⇛              = swap₊ 
eval swap₂₊⇛              = swap₊ 
eval assocl₁₊⇛            = assocl₊ 
eval assocl₁₊⇛'           = assocl₊ 
{-- eval (assocl₂₁₊⇛ _)        = assocl₊ 
eval (assocl₂₂₊⇛ _)        = assocl₊ 
eval (assocr₁₁₊⇛ _)        = assocr₊
eval (assocr₁₂₊⇛ _)        = assocr₊
eval (assocr₂₊⇛ _)         = assocr₊
eval (unite⋆⇛ _)           = unite⋆
eval (uniti⋆⇛ _)           = uniti⋆
eval (swap⋆⇛ _ _)          = swap⋆ 
eval (assocl⋆⇛ _ _ _)      = assocl⋆
eval (assocr⋆⇛ _ _ _)      = assocr⋆
eval (dist₁⇛ _ _)          = dist
eval (dist₂⇛ _ _)          = dist
eval (factor₁⇛ _ _)        = fact
eval (factor₂⇛ _ _)        = fact
eval (id⇛ _)               = id
eval (trans⇛ c d)          = eval d ∘ eval c
eval (plus₁⇛ c d)          = Data.Sum.map (eval c) (eval d) 
eval (plus₂⇛ c d)          = Data.Sum.map (eval c) (eval d) 
eval (times⇛ c d)          = Data.Product.map (eval c) (eval d)
--}
-- Inverses
evalB : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → Path a b → (B → A) 
evalB swap₂₊⇛              = swap₊
evalB swap₁₊⇛          = swap₊
evalB assocl₁₊⇛        = assocr₊
evalB assocl₁₊⇛'        = assocr₊
{-- evalB (assocr₂₊⇛ _)        = assocl₊
evalB (assocr₁₂₊⇛ _)       = assocl₊
evalB (assocr₁₁₊⇛ _)       = assocl₊
evalB (assocl₂₂₊⇛ _)       = assocr₊
evalB (assocl₂₁₊⇛ _)       = assocr₊
evalB (uniti⋆⇛ _)          = unite⋆
evalB (unite⋆⇛ _)          = uniti⋆
evalB (swap⋆⇛ _ _)         = swap⋆
evalB (assocr⋆⇛ _ _ _)     = assocl⋆
evalB (assocl⋆⇛ _ _ _)     = assocr⋆
evalB (dist₁⇛ _ _)         = fact
evalB (dist₂⇛ _ _)         = fact
evalB (factor₁⇛ _ _)       = dist
evalB (factor₂⇛ _ _)       = dist
evalB (id⇛ _)              = id
evalB (trans⇛ c d)         = evalB c ∘ evalB d
evalB (plus₁⇛ c d)         = Data.Sum.map (evalB c) (evalB d) 
evalB (plus₂⇛ c d)         = Data.Sum.map (evalB c) (evalB d) 
evalB (times⇛ c d)         = Data.Product.map (evalB c) (evalB d) 
--}
------------------------------------------------------------------------------
-- Proving univalence•
eval-resp-• : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} →
              (c : Path a b) → eval c a ≡ b
eval-resp-• swap₁₊⇛ = refl
eval-resp-• swap₂₊⇛ = refl
eval-resp-• assocl₁₊⇛ = refl
eval-resp-• assocl₁₊⇛' = refl
{-- eval-resp-• (assocl₂₁₊⇛ b) = refl
eval-resp-• (assocl₂₂₊⇛ c) = refl
eval-resp-• (assocr₁₁₊⇛ a) = refl
eval-resp-• (assocr₁₂₊⇛ b) = refl
eval-resp-• (assocr₂₊⇛ c) = refl
eval-resp-• {b = b} (unite⋆⇛ .b) = refl
eval-resp-• {a = a} (uniti⋆⇛ .a) = refl
eval-resp-• (swap⋆⇛ a b) = refl
eval-resp-• (assocl⋆⇛ a b c) = refl
eval-resp-• (assocr⋆⇛ a b c) = refl
eval-resp-• (dist₁⇛ a c) = refl
eval-resp-• (dist₂⇛ b c) = refl
eval-resp-• (factor₁⇛ a c) = refl
eval-resp-• (factor₂⇛ b c) = refl
eval-resp-• {a = a} (id⇛ .a) = refl
eval-resp-• {a = a} (trans⇛ c d) rewrite eval-resp-• c | eval-resp-• d = refl
eval-resp-• (plus₁⇛ c d) rewrite eval-resp-• c = refl 
eval-resp-• (plus₂⇛ c d) rewrite eval-resp-• d = refl 
eval-resp-• (times⇛ c d) rewrite eval-resp-• c | eval-resp-• d = refl 
--}
evalB-resp-• : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} →
              (c : Path a b) → evalB c b ≡ a
evalB-resp-• swap₁₊⇛ = refl
evalB-resp-• swap₂₊⇛ = refl
evalB-resp-• assocl₁₊⇛ = refl
evalB-resp-• assocl₁₊⇛' = refl
{-- evalB-resp-• (assocl₂₁₊⇛ b) = refl
evalB-resp-• (assocl₂₂₊⇛ c) = refl
evalB-resp-• (assocr₁₁₊⇛ a) = refl
evalB-resp-• (assocr₁₂₊⇛ b) = refl
evalB-resp-• (assocr₂₊⇛ c) = refl
evalB-resp-• {b = b} (unite⋆⇛ .b) = refl
evalB-resp-• {a = a} (uniti⋆⇛ .a) = refl
evalB-resp-• (swap⋆⇛ a b) = refl
evalB-resp-• (assocl⋆⇛ a b c) = refl
evalB-resp-• (assocr⋆⇛ a b c) = refl
evalB-resp-• (dist₁⇛ a c) = refl
evalB-resp-• (dist₂⇛ b c) = refl
evalB-resp-• (factor₁⇛ a c) = refl
evalB-resp-• (factor₂⇛ b c) = refl
evalB-resp-• {a = a} (id⇛ .a) = refl
evalB-resp-• {a = a} (trans⇛ c d) rewrite evalB-resp-• d | evalB-resp-• c = refl
evalB-resp-• (plus₁⇛ c d) rewrite evalB-resp-• c = refl 
evalB-resp-• (plus₂⇛ c d) rewrite evalB-resp-• d = refl 
evalB-resp-• (times⇛ c d) rewrite evalB-resp-• c | evalB-resp-• d = refl 
--}
-- the proof that eval ∙ evalB x ≡ x will be useful below
eval∘evalB≡id :  {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → 
  (c : Path a b) → evalB c (eval c a) ≡ a
eval∘evalB≡id c rewrite eval-resp-• c | evalB-resp-• c = refl
{--
-- if this is useful, move it elsewhere
-- but it might not be, as it appears to be 'level raising'
cong⇚ : {ℓ : Level} {A B : Set ℓ} {a₁ a₂ : A}
       (f : Path a₁ a₂ ) → (x : A) → Path (evalB f x) (evalB f x)
cong⇚ f x = id⇛ (evalB f x)
--}
{--
eval∘evalB :  {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → 
  (c : Path a b) → (x : A) → Path (evalB c (eval c x)) x
eval∘evalB (swap₁₊⇛ a) (inj₁ x) = id⇛ (inj₁ x)
eval∘evalB (swap₁₊⇛ a) (inj₂ y) = id⇛ (inj₂ y)
eval∘evalB (swap₂₊⇛ b) (inj₁ x) = id⇛ (inj₁ x)
eval∘evalB (swap₂₊⇛ b) (inj₂ y) = id⇛ (inj₂ y)
eval∘evalB (assocl₁₊⇛ a) (inj₁ x) = id⇛ (inj₁ x)
eval∘evalB (assocl₁₊⇛ a) (inj₂ (inj₁ x)) = id⇛ (inj₂ (inj₁ x))
eval∘evalB (assocl₁₊⇛ a) (inj₂ (inj₂ y)) = id⇛ (inj₂ (inj₂ y))
eval∘evalB (assocl₂₁₊⇛ b) (inj₁ x) = id⇛ (inj₁ x)
eval∘evalB (assocl₂₁₊⇛ b) (inj₂ (inj₁ x)) = id⇛ (inj₂ (inj₁ x))
eval∘evalB (assocl₂₁₊⇛ b) (inj₂ (inj₂ y)) = id⇛ (inj₂ (inj₂ y))
eval∘evalB (assocl₂₂₊⇛ c) (inj₁ x) = id⇛ (inj₁ x)
eval∘evalB (assocl₂₂₊⇛ c) (inj₂ (inj₁ x)) = id⇛ (inj₂ (inj₁ x))
eval∘evalB (assocl₂₂₊⇛ c) (inj₂ (inj₂ y)) = id⇛ (inj₂ (inj₂ y))
eval∘evalB (assocr₁₁₊⇛ a) (inj₁ (inj₁ x)) = id⇛ (inj₁ (inj₁ x))
eval∘evalB (assocr₁₁₊⇛ a) (inj₁ (inj₂ y)) = id⇛ (inj₁ (inj₂ y))
eval∘evalB (assocr₁₁₊⇛ a) (inj₂ y) = id⇛ (inj₂ y)
eval∘evalB (assocr₁₂₊⇛ b) (inj₁ (inj₁ x)) = id⇛ (inj₁ (inj₁ x))
eval∘evalB (assocr₁₂₊⇛ b) (inj₁ (inj₂ y)) = id⇛ (inj₁ (inj₂ y))
eval∘evalB (assocr₁₂₊⇛ b) (inj₂ y) = id⇛ (inj₂ y)
eval∘evalB (assocr₂₊⇛ c) (inj₁ (inj₁ x)) = id⇛ (inj₁ (inj₁ x))
eval∘evalB (assocr₂₊⇛ c) (inj₁ (inj₂ y)) = id⇛ (inj₁ (inj₂ y))
eval∘evalB (assocr₂₊⇛ c) (inj₂ y) = id⇛ (inj₂ y)
eval∘evalB {b = b} (unite⋆⇛ .b) (tt , x) = id⇛ (tt , x)
eval∘evalB {a = a} (uniti⋆⇛ .a) x = id⇛ x
eval∘evalB (swap⋆⇛ a b) (x , y) = id⇛ (x , y)
eval∘evalB (assocl⋆⇛ a b c) (x , y , z) = id⇛ (x , y , z)
eval∘evalB (assocr⋆⇛ a b c) ((x , y) , z) = id⇛ ((x , y) , z)
eval∘evalB (dist₁⇛ a c) (inj₁ x , y) = id⇛ (inj₁ x , y)
eval∘evalB (dist₁⇛ a c) (inj₂ y , z) = id⇛ (inj₂ y , z)
eval∘evalB (dist₂⇛ b c) (inj₁ x , z) = id⇛ (inj₁ x , z)
eval∘evalB (dist₂⇛ b c) (inj₂ y , z) = id⇛ (inj₂ y , z)
eval∘evalB (factor₁⇛ a c) (inj₁ (x , y)) = id⇛ (inj₁ (x , y))
eval∘evalB (factor₁⇛ a c) (inj₂ (x , y)) = id⇛ (inj₂ (x , y))
eval∘evalB (factor₂⇛ b c) (inj₁ (x , y)) = id⇛ (inj₁ (x , y))
eval∘evalB (factor₂⇛ b c) (inj₂ (x , y)) = id⇛ (inj₂ (x , y))
eval∘evalB {a = a} (id⇛ .a) x = id⇛ x
eval∘evalB (trans⇛ {A = A} {B} {C} {a} {b} {c} c₁ c₂) x = trans⇛ {!cong⇚ ? (id⇛ (eval c₁ x))!} (eval∘evalB c₁ x) 
eval∘evalB (plus₁⇛ {b = b} c₁ c₂) (inj₁ x) = plus₁⇛ (eval∘evalB c₁ x) (id⇛ b)
eval∘evalB (plus₁⇛ {a = a} c₁ c₂) (inj₂ y) = plus₂⇛ (id⇛ a) (eval∘evalB c₂ y)
eval∘evalB (plus₂⇛ {b = b} c₁ c₂) (inj₁ x) = plus₁⇛ (eval∘evalB c₁ x) (id⇛ b)
eval∘evalB (plus₂⇛ {a = a} c₁ c₂) (inj₂ y) = plus₂⇛ (id⇛ a) (eval∘evalB c₂ y)
eval∘evalB (times⇛ c₁ c₂) (x , y) = times⇛ (eval∘evalB c₁ x) (eval∘evalB c₂ y) 
--}
{--
eval-gives-id⇛ : {ℓ : Level} {A B : Set ℓ} {a : A} {b : B} → 
  (c : Path a b) → Path (eval c a) b 
eval-gives-id⇛ {b = b} c rewrite eval-resp-• c = id⇛ b
--} 
 | 
	{
  "alphanum_fraction": 0.5237406872,
  "avg_line_length": 39.2707423581,
  "ext": "agda",
  "hexsha": "01bd91709fa09cab95f5f4e55e9e21d78a43da9a",
  "lang": "Agda",
  "max_forks_count": 3,
  "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
  "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
  "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
  "max_forks_repo_licenses": [
    "BSD-2-Clause"
  ],
  "max_forks_repo_name": "JacquesCarette/pi-dual",
  "max_forks_repo_path": "Evaluator.agda",
  "max_issues_count": 4,
  "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
  "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
  "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
  "max_issues_repo_licenses": [
    "BSD-2-Clause"
  ],
  "max_issues_repo_name": "JacquesCarette/pi-dual",
  "max_issues_repo_path": "Evaluator.agda",
  "max_line_length": 113,
  "max_stars_count": 14,
  "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
  "max_stars_repo_licenses": [
    "BSD-2-Clause"
  ],
  "max_stars_repo_name": "JacquesCarette/pi-dual",
  "max_stars_repo_path": "Evaluator.agda",
  "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
  "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
  "num_tokens": 4742,
  "size": 8993
} 
 | 
					
	open import Prelude
open import core
open import contexts
module synth-unicity where
  -- synthesis only produces equal types. note that there is no need for an
  -- analagous theorem for analytic positions because we think of
  -- the type as an input
  synthunicity : {Γ : tctx} {e : hexp} {t t' : htyp} →
                  (Γ ⊢ e => t)
                → (Γ ⊢ e => t')
                → t == t'
  synthunicity (SAsc _) (SAsc _) = refl
  synthunicity {Γ = G} (SVar in1) (SVar in2) = ctxunicity {Γ = G} in1 in2
  synthunicity (SAp _  D1 MAHole _) (SAp _ D2 MAHole y) = refl
  synthunicity (SAp _ D1 MAHole _) (SAp _ D2 MAArr y) with synthunicity D1 D2
  ... | ()
  synthunicity (SAp _ D1 MAArr _) (SAp _ D2 MAHole y) with synthunicity D1 D2
  ... | ()
  synthunicity (SAp _ D1 MAArr _) (SAp _ D2 MAArr y) with synthunicity D1 D2
  ... | refl = refl
  synthunicity SEHole SEHole = refl
  synthunicity (SNEHole _ _) (SNEHole _ _) = refl
  synthunicity SConst SConst = refl
  synthunicity (SLam _ D1) (SLam _ D2) with synthunicity D1 D2
  synthunicity (SLam x₁ D1) (SLam x₂ D2) | refl = refl
 
 | 
	{
  "alphanum_fraction": 0.6394495413,
  "avg_line_length": 40.3703703704,
  "ext": "agda",
  "hexsha": "a817078d577465e6bf23fd4016c877bf2e1d005b",
  "lang": "Agda",
  "max_forks_count": 1,
  "max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z",
  "max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z",
  "max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda",
  "max_forks_repo_path": "synth-unicity.agda",
  "max_issues_count": 54,
  "max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
  "max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z",
  "max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z",
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda",
  "max_issues_repo_path": "synth-unicity.agda",
  "max_line_length": 77,
  "max_stars_count": 16,
  "max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda",
  "max_stars_repo_path": "synth-unicity.agda",
  "max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z",
  "max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z",
  "num_tokens": 408,
  "size": 1090
} 
 | 
					
	{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.MappingCones where
open import Cubical.HITs.MappingCones.Base public
open import Cubical.HITs.MappingCones.Properties public
 
 | 
	{
  "alphanum_fraction": 0.7929292929,
  "avg_line_length": 28.2857142857,
  "ext": "agda",
  "hexsha": "301b90621d4a0f1322c69f97d4331f10821dbc3c",
  "lang": "Agda",
  "max_forks_count": 1,
  "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
  "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
  "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "dan-iel-lee/cubical",
  "max_forks_repo_path": "Cubical/HITs/MappingCones.agda",
  "max_issues_count": 1,
  "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
  "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
  "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "dan-iel-lee/cubical",
  "max_issues_repo_path": "Cubical/HITs/MappingCones.agda",
  "max_line_length": 55,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "dan-iel-lee/cubical",
  "max_stars_repo_path": "Cubical/HITs/MappingCones.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 51,
  "size": 198
} 
 | 
					
	module Web.Semantic.DL.Signature where
infixr 4 _,_
data Signature : Set₁ where
  _,_ : (CN RN : Set) → Signature
CN : Signature → Set
CN (CN , RN) = CN
RN : Signature → Set
RN (CN , RN) = RN
 
 | 
	{
  "alphanum_fraction": 0.6428571429,
  "avg_line_length": 15.0769230769,
  "ext": "agda",
  "hexsha": "e5bf243dbeba0850b76de300e97e7ddc6633d45c",
  "lang": "Agda",
  "max_forks_count": 3,
  "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z",
  "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z",
  "max_forks_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "agda/agda-web-semantic",
  "max_forks_repo_path": "src/Web/Semantic/DL/Signature.agda",
  "max_issues_count": 4,
  "max_issues_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
  "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z",
  "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z",
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "agda/agda-web-semantic",
  "max_issues_repo_path": "src/Web/Semantic/DL/Signature.agda",
  "max_line_length": 38,
  "max_stars_count": 9,
  "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "agda/agda-web-semantic",
  "max_stars_repo_path": "src/Web/Semantic/DL/Signature.agda",
  "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z",
  "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z",
  "num_tokens": 68,
  "size": 196
} 
 | 
					
	{-# OPTIONS --without-K #-}
open import HoTT
open import cohomology.Exactness
open import cohomology.FunctionOver
open import cohomology.ProductRepr
open import cohomology.Theory
open import cohomology.WedgeCofiber
{- For the cohomology group of a suspension ΣX, the group inverse has the
 - explicit form Cⁿ(flip-susp) : Cⁿ(ΣX) → Cⁿ(ΣX).
 -}
module cohomology.InverseInSusp {i} (CT : CohomologyTheory i)
  (n : ℤ) {X : Ptd i} where
open CohomologyTheory CT
open import cohomology.Functor CT
open import cohomology.BaseIndependence CT
open import cohomology.Wedge CT
private
  module CW = CWedge n (⊙Susp X) (⊙Susp X)
  module Subtract = SuspensionRec (fst X) {C = fst (⊙Susp X ⊙∨ ⊙Susp X)}
    (winl (south _))
    (winr (south _))
    (λ x → ap winl (! (merid _ x)) ∙ wglue ∙ ap winr (merid _ x))
  subtract = Subtract.f
  ⊙subtract : fst (⊙Susp X ⊙→ ⊙Susp X ⊙∨ ⊙Susp X)
  ⊙subtract = (subtract , ! (ap winl (merid _ (snd X))))
  projl-subtract : ∀ σ → projl _ _ (subtract σ) == flip-susp σ
  projl-subtract = Suspension-elim (fst X) idp idp $
    ↓-='-from-square ∘ vert-degen-square ∘ λ x →
      ap-∘ (projl _ _) subtract (merid _ x)
      ∙ ap (ap (projl _ _)) (Subtract.glue-β x)
      ∙ ap-∙ (projl _ _) (ap winl (! (merid _ x))) (wglue ∙ ap winr (merid _ x))
      ∙ ((∘-ap (projl _ _) winl (! (merid _ x))
          ∙ ap-idf _)
         ∙2 (ap-∙ (projl _ _) wglue (ap winr (merid _ x))
             ∙ (Projl.glue-β _ _
                ∙2 (∘-ap (projl _ _) winr (merid _ x) ∙ ap-cst _ _))))
      ∙ ∙-unit-r _
      ∙ ! (FlipSusp.glue-β x)
  projr-subtract : ∀ σ → projr _ _ (subtract σ) == σ
  projr-subtract = Suspension-elim (fst X) idp idp $
    ↓-∘=idf-in (projr _ _) subtract ∘ λ x →
      ap (ap (projr _ _)) (Subtract.glue-β x)
      ∙ ap-∙ (projr _ _) (ap winl (! (merid _ x))) (wglue ∙ ap winr (merid _ x))
      ∙ ((∘-ap (projr _ _) winl (! (merid _ x)) ∙ ap-cst _ _)
         ∙2 (ap-∙ (projr _ _) wglue (ap winr (merid _ x))
             ∙ (Projr.glue-β _ _
                ∙2 (∘-ap (projr _ _) winr (merid _ x) ∙ ap-idf _))))
  fold-subtract : ∀ σ → fold (subtract σ) == south _
  fold-subtract = Suspension-elim (fst X) idp idp $
    ↓-app=cst-in ∘ ! ∘ λ x →
      ∙-unit-r _
      ∙ ap-∘ fold subtract (merid _ x)
      ∙ ap (ap fold) (Subtract.glue-β x)
      ∙ ap-∙ fold (ap winl (! (merid _ x))) (wglue ∙ ap winr (merid _ x))
      ∙ ((∘-ap fold winl (! (merid _ x)) ∙ ap-idf _)
         ∙2 (ap-∙ fold wglue (ap winr (merid _ x))
             ∙ (Fold.glue-β
                ∙2 (∘-ap fold winr (merid _ x) ∙ ap-idf _))))
      ∙ !-inv-l (merid _ x)
  cancel :
    ×ᴳ-sum-hom (C-abelian n _) (CF-hom n (⊙flip-susp X)) (idhom _) ∘ᴳ ×ᴳ-diag
    == cst-hom
  cancel =
    ap2 (λ φ ψ → ×ᴳ-sum-hom (C-abelian n _) φ ψ ∘ᴳ ×ᴳ-diag)
        (! (CF-λ= n projl-subtract))
        (! (CF-ident n) ∙ ! (CF-λ= n projr-subtract))
    ∙ transport (λ {(G , φ , ψ) → φ ∘ᴳ ψ == cst-hom})
        (pair= (CW.path) $ ↓-×-in
          (CW.wedge-in-over ⊙subtract)
          (CW.⊙wedge-rec-over (⊙idf _) (⊙idf _)
           ▹ ap2 ×ᴳ-hom-in (CF-ident n) (CF-ident n)))
        (! (CF-comp n ⊙fold ⊙subtract)
         ∙ CF-λ= n (λ σ → fold-subtract σ ∙ ! (merid _ (snd X)))
         ∙ CF-cst n)
C-flip-susp-is-inv :
  CF-hom n (⊙flip-susp X) == inv-hom (C n (⊙Susp X)) (C-abelian _ _)
C-flip-susp-is-inv = hom= _ _ $ λ= $ λ g →
  ! (group-inv-unique-l (C n (⊙Susp X)) _ g (app= (ap GroupHom.f cancel) g))
 
 | 
	{
  "alphanum_fraction": 0.5466510676,
  "avg_line_length": 37.1630434783,
  "ext": "agda",
  "hexsha": "48a40f599b5c8d19f992e491b3735a0916f6a453",
  "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": "cohomology/InverseInSusp.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": "cohomology/InverseInSusp.agda",
  "max_line_length": 80,
  "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": "cohomology/InverseInSusp.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": 1396,
  "size": 3419
} 
 | 
					
	
open import Agda.Builtin.Nat
open import Agda.Builtin.List
open import Agda.Builtin.Reflection
open import Agda.Builtin.Sigma
open import Agda.Builtin.Equality
pattern vArg x = arg (arg-info visible relevant) x
pattern hArg x = arg (arg-info hidden  relevant) x
idClause-ok : Clause
idClause-ok = clause
             (("A" , hArg (agda-sort (lit 0))) ∷ ("x" , vArg (var 0 [])) ∷ [])
             (hArg (var 1) ∷ vArg (var 0) ∷ [])
             (var 0 [])
id-ok : {A : Set} → A → A
unquoteDef id-ok = defineFun id-ok (idClause-ok ∷ [])
idClause-fail : Clause
idClause-fail = clause
             (("A" , hArg (agda-sort (lit 0))) ∷ ("x" , vArg (var 0 [])) ∷ [])
             ({-hArg (var 1) ∷-} vArg (var 0) ∷ [])
             (var 0 [])
id-fail : {A : Set} → A → A
unquoteDef id-fail = defineFun id-fail (idClause-fail ∷ [])
-- Panic: unbound variable A (id: 191@9559440724209987811)
-- when checking that the expression A has type _7
 
 | 
	{
  "alphanum_fraction": 0.5914893617,
  "avg_line_length": 31.3333333333,
  "ext": "agda",
  "hexsha": "e115d2149072ca0494be0d47bb746b0db76c7203",
  "lang": "Agda",
  "max_forks_count": null,
  "max_forks_repo_forks_event_max_datetime": null,
  "max_forks_repo_forks_event_min_datetime": null,
  "max_forks_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1",
  "max_forks_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_forks_repo_name": "guilhermehas/agda",
  "max_forks_repo_path": "test/Fail/Issue5044.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_issues_repo_name": "guilhermehas/agda",
  "max_issues_repo_path": "test/Fail/Issue5044.agda",
  "max_line_length": 78,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1",
  "max_stars_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_stars_repo_name": "guilhermehas/agda",
  "max_stars_repo_path": "test/Fail/Issue5044.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 319,
  "size": 940
} 
 | 
					
	module L.Base.Empty.Properties where
-- There are no properties yet.
 
 | 
	{
  "alphanum_fraction": 0.7714285714,
  "avg_line_length": 17.5,
  "ext": "agda",
  "hexsha": "4921dd1ab92f8fcc3627a1bed26a053681007c85",
  "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": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
  "max_forks_repo_licenses": [
    "BSD-2-Clause"
  ],
  "max_forks_repo_name": "borszag/smallib",
  "max_forks_repo_path": "src/L/Base/Empty/Properties.agda",
  "max_issues_count": 10,
  "max_issues_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
  "max_issues_repo_issues_event_max_datetime": "2020-11-09T16:40:39.000Z",
  "max_issues_repo_issues_event_min_datetime": "2020-10-19T10:13:16.000Z",
  "max_issues_repo_licenses": [
    "BSD-2-Clause"
  ],
  "max_issues_repo_name": "borszag/smallib",
  "max_issues_repo_path": "src/L/Base/Empty/Properties.agda",
  "max_line_length": 36,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "83707537b182ba8906228ac0bcb9ccef972eaaa3",
  "max_stars_repo_licenses": [
    "BSD-2-Clause"
  ],
  "max_stars_repo_name": "borszag/smallib",
  "max_stars_repo_path": "src/L/Base/Empty/Properties.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 14,
  "size": 70
} 
 | 
					
	------------------------------------------------------------------------------
-- Reasoning about a function without a termination proof
------------------------------------------------------------------------------
{-# OPTIONS --allow-unsolved-metas     #-}
{-# OPTIONS --exact-split              #-}
{-# OPTIONS --no-sized-types           #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K                #-}
module FOT.FOTC.Program.Collatz.CollatzSL where
open import Data.Bool.Base
open import Data.Empty
open import Data.Nat renaming ( suc to succ )
open import Data.Nat.Properties
open import Data.Product
open import Data.Sum
open import Relation.Binary.PropositionalEquality hiding ( [_] )
open import Relation.Nullary
------------------------------------------------------------------------------
isEven : ℕ → Bool
isEven 0               = true
isEven 1               = false
isEven (succ (succ n)) = isEven n
{-# TERMINATING #-}
collatz : ℕ → ℕ
collatz zero        = 1
collatz (succ zero) = 1
{-# CATCHALL #-}
collatz n with isEven n
... | true  = collatz ⌊ n /2⌋
... | false = collatz (3 * n + 1)
-- 25 April 2014: Failed with Andreas' --without-K.
xy≡0→x≡0∨y≡0 : (m n : ℕ) → m * n ≡ zero → m ≡ zero ⊎ n ≡ zero
xy≡0→x≡0∨y≡0 zero     n        h = inj₁ refl
xy≡0→x≡0∨y≡0 (succ m) zero     h = inj₂ refl
xy≡0→x≡0∨y≡0 (succ m) (succ n) ()
+∸2 : ∀ {n} → n ≢ zero → n ≢ 1 → n ≡ succ (succ (n ∸ 2))
+∸2 {zero}          0≢0 _   = ⊥-elim (0≢0 refl)
+∸2 {succ zero}     _   1≢1 = ⊥-elim (1≢1 refl)
+∸2 {succ (succ n)} _   _   = refl
2^x≢0 : (n : ℕ) → 2 ^ n ≢ zero
2^x≢0 zero ()
2^x≢0 (succ n) h = [ (λ ())
                   , (λ 2^n≡0 → ⊥-elim (2^x≢0 n 2^n≡0))
                   ]′ (xy≡0→x≡0∨y≡0 2 (2 ^ n) h)
2^[x+1]/2≡2^x : ∀ n → ⌊ 2 ^ succ n /2⌋ ≡ 2 ^ n
2^[x+1]/2≡2^x zero            = refl
2^[x+1]/2≡2^x (succ zero)     = refl
2^[x+1]/2≡2^x (succ (succ n)) = {!!}
collatz-2^x : ∀ n → Σ ℕ (λ k → n ≡ 2 ^ k) → collatz n ≡ 1
collatz-2^x zero     h                = refl
collatz-2^x (succ n) (zero , proj₂)   = subst (λ t → collatz t ≡ 1) (sym proj₂) refl
collatz-2^x (succ n) (succ k , proj₂) = subst (λ t → collatz t ≡ 1) (sym proj₂) {!!}
succInjective : ∀ {m n} → succ m ≡ succ n → m ≡ n
succInjective refl = refl
Sx≡x→⊥ : ∀ n → succ n ≢ n
Sx≡x→⊥ zero ()
Sx≡x→⊥ (succ n) h = ⊥-elim (Sx≡x→⊥ n (succInjective h))
2^[x+1]≢1 : ∀ n → 2 ^ (succ n) ≢ 1
2^[x+1]≢1 n h = Sx≡x→⊥ 1 (i*j≡1⇒i≡1 2 (2 ^ n) h)
 
 | 
	{
  "alphanum_fraction": 0.4753492194,
  "avg_line_length": 32.8918918919,
  "ext": "agda",
  "hexsha": "7926cae74a0e6c18c6a9bd3d5bebaf346c7d1899",
  "lang": "Agda",
  "max_forks_count": 3,
  "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
  "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
  "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "asr/fotc",
  "max_forks_repo_path": "notes/FOT/FOTC/Program/Collatz/CollatzSL.agda",
  "max_issues_count": 2,
  "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
  "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
  "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "asr/fotc",
  "max_issues_repo_path": "notes/FOT/FOTC/Program/Collatz/CollatzSL.agda",
  "max_line_length": 84,
  "max_stars_count": 11,
  "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "asr/fotc",
  "max_stars_repo_path": "notes/FOT/FOTC/Program/Collatz/CollatzSL.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": 967,
  "size": 2434
} 
 | 
					
	{-# OPTIONS --without-K --safe #-}
module Categories.Bicategory where
open import Level
open import Data.Product using (Σ; _,_)
open import Relation.Binary using (Rel)
open import Categories.Category
open import Categories.Category.Monoidal.Instance.Cats using (module Product)
open import Categories.Category.Instance.Cats
open import Categories.Enriched.Category renaming (Category to Enriched)
open import Categories.Functor using (Functor)
open import Categories.Functor.Bifunctor
open import Categories.Functor.Bifunctor.Properties
open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism)
import Categories.Morphism as Mor
import Categories.Morphism.Reasoning as MR
-- https://ncatlab.org/nlab/show/bicategory
-- notice that some axioms in nLab is inconsistent. they have been fixed in this definition.
record Bicategory o ℓ e t : Set (suc (o ⊔ ℓ ⊔ e ⊔ t)) where
  field
    enriched : Enriched (Product.Cats-Monoidal {o} {ℓ} {e}) t
  open Enriched enriched public
  module hom {A B} = Category (hom A B)
  open Functor
  module ⊚ {A B C}          = Functor (⊚ {A} {B} {C})
  module ⊚-assoc {A B C D}  = NaturalIsomorphism (⊚-assoc {A} {B} {C} {D})
  module unitˡ {A B}        = NaturalIsomorphism (unitˡ {A} {B})
  module unitʳ {A B}        = NaturalIsomorphism (unitʳ {A} {B})
  module id {A}             = Functor (id {A})
  infix 4 _⇒₁_ _⇒₂_ _≈_
  infixr 7 _∘ᵥ_ _∘ₕ_
  infixr 9 _▷_
  infixl 9 _◁_
  infixr 11 _⊚₀_ _⊚₁_
  _⇒₁_ : Obj → Obj → Set o
  A ⇒₁ B = Category.Obj (hom A B)
  _⇒₂_ : {A B : Obj} → A ⇒₁ B → A ⇒₁ B → Set ℓ
  _⇒₂_ = hom._⇒_
  _⊚₀_ : {A B C : Obj} → B ⇒₁ C → A ⇒₁ B → A ⇒₁ C
  f ⊚₀ g = ⊚.F₀ (f , g)
  _⊚₁_ : {A B C : Obj} {f h : B ⇒₁ C} {g i : A ⇒₁ B} → f ⇒₂ h → g ⇒₂ i → f ⊚₀ g ⇒₂ h ⊚₀ i
  α ⊚₁ β = ⊚.F₁ (α , β)
  _≈_ : {A B : Obj} {f g : A ⇒₁ B} → Rel (f ⇒₂ g) e
  _≈_ = hom._≈_
  id₁ : {A : Obj} → A ⇒₁ A
  id₁ {_} = id.F₀ _
  id₂ : {A B : Obj} {f : A ⇒₁ B} → f ⇒₂ f
  id₂ = hom.id
  -- horizontal composition
  _∘ₕ_ : {A B C : Obj} → B ⇒₁ C → A ⇒₁ B → A ⇒₁ C
  _∘ₕ_ = _⊚₀_
  -- vertical composition
  _∘ᵥ_ : {A B : Obj} {f g h : A ⇒₁ B} (α : g ⇒₂ h) (β : f ⇒₂ g) → f ⇒₂ h
  _∘ᵥ_ = hom._∘_
  _◁_ : {A B C : Obj} {g h : B ⇒₁ C} (α : g ⇒₂ h) (f : A ⇒₁ B) → g ∘ₕ f ⇒₂ h ∘ₕ f
  α ◁ f = α ⊚₁ id₂
  _▷_ : {A B C : Obj} {f g : A ⇒₁ B} (h : B ⇒₁ C) (α : f ⇒₂ g) → h ∘ₕ f ⇒₂ h ∘ₕ g
  h ▷ α = id₂ ⊚₁ α
  unitorˡ : {A B : Obj} {f : A ⇒₁ B} → Mor._≅_ (hom A B) (id₁ ∘ₕ f) f
  unitorˡ {_} {_} {f} = record
    { from = unitˡ.⇒.η (_ , f)
    ; to   = unitˡ.⇐.η (_ , f)
    ; iso  = unitˡ.iso (_ , f)
    }
  module unitorˡ {A B f} = Mor._≅_ (unitorˡ {A} {B} {f})
  unitorʳ : {A B : Obj} {f : A ⇒₁ B} → Mor._≅_ (hom A B) (f ∘ₕ id₁) f
  unitorʳ {_} {_} {f} = record
    { from = unitʳ.⇒.η (f , _)
    ; to   = unitʳ.⇐.η (f , _)
    ; iso  = unitʳ.iso (f , _)
    }
  module unitorʳ {A B f} = Mor._≅_ (unitorʳ {A} {B} {f})
  associator : {A B C D : Obj} {f : D ⇒₁ B} {g : C ⇒₁ D} {h : A ⇒₁ C} →  Mor._≅_ (hom A B) ((f ∘ₕ g) ∘ₕ h) (f ∘ₕ g ∘ₕ h)
  associator {_} {_} {_} {_} {f} {g} {h} = record
    { from = ⊚-assoc.⇒.η ((f , g) , h)
    ; to   = ⊚-assoc.⇐.η ((f , g) , h)
    ; iso  = ⊚-assoc.iso ((f , g) , h)
    }
  module associator {A B C D} {f : C ⇒₁ B} {g : D ⇒₁ C} {h} = Mor._≅_ (associator {A = A} {B = B} {f = f} {g = g} {h = h})
  open hom.Commutation
  field
    triangle : {A B C : Obj} {f : A ⇒₁ B} {g : B ⇒₁ C} →
                 [ (g ∘ₕ id₁) ∘ₕ f ⇒ g ∘ₕ f ]⟨
                   associator.from          ⇒⟨ g ∘ₕ id₁ ∘ₕ f ⟩
                   g ▷ unitorˡ.from
                 ≈ unitorʳ.from ◁ f
                 ⟩
    pentagon : {A B C D E : Obj} {f : A ⇒₁ B} {g : B ⇒₁ C} {h : C ⇒₁ D} {i : D ⇒₁ E} →
                 [ ((i ∘ₕ h) ∘ₕ g) ∘ₕ f ⇒ i ∘ₕ h ∘ₕ g ∘ₕ f ]⟨
                   associator.from ◁ f                     ⇒⟨ (i ∘ₕ h ∘ₕ g) ∘ₕ f ⟩
                   associator.from                         ⇒⟨ i ∘ₕ (h ∘ₕ g) ∘ₕ f ⟩
                   i ▷ associator.from
                 ≈ associator.from                         ⇒⟨ (i ∘ₕ h) ∘ₕ g ∘ₕ f ⟩
                   associator.from
                 ⟩
  private
    variable
      A B C D : Obj
      f g h i : A ⇒₁ B
      α β γ : f ⇒₂ g
  -⊚_ : C ⇒₁ A → Functor (hom A B) (hom C B)
  -⊚_ = appʳ ⊚
  _⊚- : B ⇒₁ C → Functor (hom A B) (hom A C)
  _⊚- = appˡ ⊚
  identity₂ˡ : id₂ ∘ᵥ α ≈ α
  identity₂ˡ = hom.identityˡ
  identity₂ʳ : α ∘ᵥ id₂ ≈ α
  identity₂ʳ = hom.identityʳ
  assoc₂ : (α ∘ᵥ β) ∘ᵥ γ ≈ α ∘ᵥ β ∘ᵥ γ
  assoc₂ = hom.assoc
  id₂◁ : id₂ {f = g} ◁ f ≈ id₂
  id₂◁ = ⊚.identity
  ▷id₂ : f ▷ id₂ {f = g} ≈ id₂
  ▷id₂ = ⊚.identity
  open hom.HomReasoning
  private
    module MR′ {A} {B} where
      open MR (hom A B) public
      open Mor (hom A B) public
    open MR′
  ∘ᵥ-distr-◁ : (α ◁ f) ∘ᵥ (β ◁ f) ≈ (α ∘ᵥ β) ◁ f
  ∘ᵥ-distr-◁ {f = f} = ⟺ (Functor.homomorphism (-⊚ f))
  ∘ᵥ-distr-▷ : (f ▷ α) ∘ᵥ (f ▷ β) ≈ f ▷ (α ∘ᵥ β)
  ∘ᵥ-distr-▷ {f = f} = ⟺ (Functor.homomorphism (f ⊚-))
  ρ-∘ᵥ-▷ : unitorˡ.from ∘ᵥ (id₁ ▷ α) ≈ α ∘ᵥ unitorˡ.from
  ρ-∘ᵥ-▷ {α = α} = begin
    unitorˡ.from ∘ᵥ (id₁ ▷ α)    ≈˘⟨ hom.∘-resp-≈ʳ (⊚.F-resp-≈ (id.identity , refl)) ⟩
    unitorˡ.from ∘ᵥ id.F₁ _ ⊚₁ α ≈⟨ unitˡ.⇒.commute (_ , α) ⟩
    α ∘ᵥ unitorˡ.from            ∎
  ▷-∘ᵥ-ρ⁻¹ : (id₁ ▷ α) ∘ᵥ unitorˡ.to ≈ unitorˡ.to ∘ᵥ α
  ▷-∘ᵥ-ρ⁻¹ = conjugate-to (≅.sym unitorˡ) (≅.sym unitorˡ) ρ-∘ᵥ-▷
  λ-∘ᵥ-◁ : unitorʳ.from ∘ᵥ (α ◁ id₁) ≈ α ∘ᵥ unitorʳ.from
  λ-∘ᵥ-◁ {α = α} = begin
    unitorʳ.from ∘ᵥ (α ◁ id₁)      ≈˘⟨ hom.∘-resp-≈ʳ (⊚.F-resp-≈ (refl , id.identity)) ⟩
    unitorʳ.from ∘ᵥ (α ⊚₁ id.F₁ _) ≈⟨ unitʳ.⇒.commute (α , _) ⟩
    α ∘ᵥ unitorʳ.from              ∎
  ◁-∘ᵥ-λ⁻¹ : (α ◁ id₁) ∘ᵥ unitorʳ.to ≈ unitorʳ.to ∘ᵥ α
  ◁-∘ᵥ-λ⁻¹ = conjugate-to (≅.sym unitorʳ) (≅.sym unitorʳ) λ-∘ᵥ-◁
  assoc⁻¹-◁-∘ₕ : associator.to ∘ᵥ (α ◁ (g ∘ₕ f)) ≈ ((α ◁ g) ◁ f) ∘ᵥ associator.to
  assoc⁻¹-◁-∘ₕ {α = α} {g = g} {f = f} = begin
    associator.to ∘ᵥ (α ◁ (g ∘ₕ f))    ≈˘⟨ hom.∘-resp-≈ʳ (⊚.F-resp-≈ (refl , ⊚.identity)) ⟩
    associator.to ∘ᵥ (α ⊚₁ id₂ ⊚₁ id₂) ≈⟨ ⊚-assoc.⇐.commute ((α , id₂) , id₂) ⟩
    ((α ◁ g) ◁ f) ∘ᵥ associator.to     ∎
  assoc⁻¹-▷-◁ : associator.to ∘ᵥ (f ▷ (α ◁ g)) ≈ ((f ▷ α) ◁ g) ∘ᵥ associator.to
  assoc⁻¹-▷-◁ {f = f} {α = α} {g = g} = ⊚-assoc.⇐.commute ((id₂ , α) , id₂)
  assoc⁻¹-▷-∘ₕ : associator.to ∘ᵥ (g ▷ (f ▷ α)) ≈ ((g ∘ₕ f) ▷ α) ∘ᵥ associator.to
  assoc⁻¹-▷-∘ₕ {g = g} {f = f} {α = α} = begin
    associator.to ∘ᵥ (g ▷ (f ▷ α))       ≈⟨ ⊚-assoc.⇐.commute ((id₂ , id₂) , α) ⟩
    ((id₂ ⊚₁ id₂) ⊚₁ α) ∘ᵥ associator.to ≈⟨ hom.∘-resp-≈ˡ (⊚.F-resp-≈ (⊚.identity , refl)) ⟩
    ((g ∘ₕ f) ▷ α) ∘ᵥ associator.to      ∎
  ◁-▷-exchg : ∀ {α : f ⇒₂ g} {β : h ⇒₂ i} → (i ▷ α) ∘ᵥ (β ◁ f) ≈ (β ◁ g) ∘ᵥ (h ▷ α)
  ◁-▷-exchg = [ ⊚ ]-commute
 
 | 
	{
  "alphanum_fraction": 0.4867495134,
  "avg_line_length": 33.7323232323,
  "ext": "agda",
  "hexsha": "afadb522b7c1207a0c2517a3810a496dd061d890",
  "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/Bicategory.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/Bicategory.agda",
  "max_line_length": 122,
  "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/Bicategory.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 3455,
  "size": 6679
} 
 | 
					
	{-# OPTIONS --cubical #-}
module Agda.Builtin.Cubical.Id where
  open import Agda.Primitive.Cubical
  open import Agda.Builtin.Cubical.Path
  postulate
    Id : ∀ {ℓ} {A : Set ℓ} → A → A → Set ℓ
  {-# BUILTIN ID           Id       #-}
  {-# BUILTIN CONID        conid    #-}
  primitive
    primDepIMin : _
    primIdFace : ∀ {ℓ} {A : Set ℓ} {x y : A} → Id x y → I
    primIdPath : ∀ {ℓ} {A : Set ℓ} {x y : A} → Id x y → x ≡ y
  primitive
    primIdJ : ∀ {ℓ ℓ'} {A : Set ℓ} {x : A} (P : ∀ y → Id x y → Set ℓ') →
                P x (conid i1 (λ i → x)) → ∀ {y} (p : Id x y) → P y p
 
 | 
	{
  "alphanum_fraction": 0.4838160136,
  "avg_line_length": 27.9523809524,
  "ext": "agda",
  "hexsha": "c2b4e06a821280cae5114a7b57a8f5373236ef4e",
  "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": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
  "max_forks_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_forks_repo_name": "alhassy/agda",
  "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Id.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_issues_repo_name": "alhassy/agda",
  "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Id.agda",
  "max_line_length": 72,
  "max_stars_count": 1,
  "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
  "max_stars_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_stars_repo_name": "alhassy/agda",
  "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Cubical/Id.agda",
  "max_stars_repo_stars_event_max_datetime": "2021-07-07T10:49:57.000Z",
  "max_stars_repo_stars_event_min_datetime": "2021-07-07T10:49:57.000Z",
  "num_tokens": 238,
  "size": 587
} 
 | 
					
	module FixityOutOfScopeInRecord where
record R : Set where
  infixl 30 _+_
-- Should complain that _+_ is not in scope
-- in its fixity declaration.
 
 | 
	{
  "alphanum_fraction": 0.7549668874,
  "avg_line_length": 18.875,
  "ext": "agda",
  "hexsha": "89f65f6e6f930e20b31b3d2d7d3151048c24a163",
  "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/FixityOutOfScopeInRecord.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/FixityOutOfScopeInRecord.agda",
  "max_line_length": 43,
  "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/FixityOutOfScopeInRecord.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": 41,
  "size": 151
} 
 | 
					
	------------------------------------------------------------------------------
-- Non-intuitionistic logic theorems
------------------------------------------------------------------------------
{-# OPTIONS --exact-split              #-}
{-# OPTIONS --no-sized-types           #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K                #-}
module FOL.NonIntuitionistic.TheoremsI where
-- The theorems below are valid with an empty domain.
open import FOL.Base hiding ( D≢∅ )
------------------------------------------------------------------------------
-- The principle of indirect proof (proof by contradiction).
¬-elim : ∀ {A} → (¬ A → ⊥) → A
¬-elim h = case (λ a → a) (λ ¬a → ⊥-elim (h ¬a)) pem
-- Double negation elimination.
¬¬-elim : ∀ {A} → ¬ ¬ A → A
¬¬-elim {A} h = ¬-elim h
-- The reductio ab absurdum rule. (Some authors uses this name for the
-- principle of indirect proof).
raa : ∀ {A} → (¬ A → A) → A
raa h = case (λ a → a) h pem
-- ∃ in terms of ∀ and ¬.
¬∃¬→∀ : {A : D → Set} → ¬ (∃[ x ] ¬ A x) → ∀ {x} → A x
¬∃¬→∀ h {x} = ¬-elim (λ ah → h (x , ah))
 
 | 
	{
  "alphanum_fraction": 0.4277929155,
  "avg_line_length": 34.40625,
  "ext": "agda",
  "hexsha": "5fe69200eb927300f025b6494ab8157235d8ad75",
  "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/FOL/NonIntuitionistic/TheoremsI.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/FOL/NonIntuitionistic/TheoremsI.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/FOL/NonIntuitionistic/TheoremsI.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": 307,
  "size": 1101
} 
 | 
					
	module GGT.Group.Definitions
  {a ℓ}
  where
open import Relation.Unary using (Pred)
open import Algebra.Bundles using (Group)
open import Level
IsOpInvClosed : {l : Level} → (G : Group a ℓ) → (Pred (Group.Carrier G) l) → Set (a ⊔ l)
IsOpInvClosed G P = ∀ {x y : Carrier} → P x → P y → P (x - y) where open Group G
 
 | 
	{
  "alphanum_fraction": 0.6593059937,
  "avg_line_length": 28.8181818182,
  "ext": "agda",
  "hexsha": "4261e0827fa4de7dad780b34100c94aeafec2fe8",
  "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": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "zampino/ggt",
  "max_forks_repo_path": "src/ggt/group/Definitions.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af",
  "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": "zampino/ggt",
  "max_issues_repo_path": "src/ggt/group/Definitions.agda",
  "max_line_length": 88,
  "max_stars_count": 2,
  "max_stars_repo_head_hexsha": "e2d6b5f9bea15dd67817bf67e273f6b9a14335af",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "zampino/ggt",
  "max_stars_repo_path": "src/ggt/group/Definitions.agda",
  "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:48:39.000Z",
  "max_stars_repo_stars_event_min_datetime": "2020-04-17T11:10:00.000Z",
  "num_tokens": 109,
  "size": 317
} 
 | 
					
	{-# OPTIONS --prop --rewriting --confluence-check #-}
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
{-# BUILTIN REWRITE _≡_ #-}
data _≐_ {ℓ} {A : Set ℓ} (x : A) : A → Prop ℓ where
  refl : x ≐ x
postulate
  subst : ∀ {ℓ ℓ′} {A : Set ℓ} (P : A → Set ℓ′)
        → (x y : A) → x ≐ y → P x → P y
  subst-rew : ∀ {ℓ ℓ′} {A : Set ℓ} (P : A → Set ℓ′)
            → {x : A} (e : x ≐ x) (p : P x) → subst P x x e p ≡ p
{-# REWRITE subst-rew #-}
data Box (A : Prop) : Set where
  box : A -> Box A
foo : (A : Prop)(x y : A)(P : Box A → Set)(p : P (box x)) → subst P (box x) (box y) refl p ≐ p
foo A x y P p = refl -- refl does not type check
 
 | 
	{
  "alphanum_fraction": 0.5053435115,
  "avg_line_length": 28.4782608696,
  "ext": "agda",
  "hexsha": "e3bb4b0ba417e2338b9e28063e5208715f47d6fb",
  "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/Issue3525.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/Issue3525.agda",
  "max_line_length": 94,
  "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/Issue3525.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": 274,
  "size": 655
} 
 | 
					
	------------------------------------------------------------------------
-- Polymorphic and iso-recursive lambda terms
------------------------------------------------------------------------
module SystemF.Term where
open import Data.Fin using (Fin; zero; suc; inject+)
open import Data.Fin.Substitution
open import Data.Fin.Substitution.Lemmas
open import Data.Nat using (ℕ; suc; _+_; _∸_)
open import Data.Product using (Σ; _,_)
open import Data.Vec using (Vec; []; _∷_; lookup; map)
open import Function as Fun hiding (id)
open import Relation.Binary.PropositionalEquality as PropEq
  using (refl; _≡_; cong; cong₂; sym)
open PropEq.≡-Reasoning
open import SystemF.Type
------------------------------------------------------------------------
-- Untyped terms and values
infixl 9 _[_] _·_
-- Untyped terms with up to m free term variables and up to n free
-- type variables
data Term (m n : ℕ) : Set where
  var     : (x : Fin m)                   → Term m n  -- term variable
  Λ       : Term m (1 + n)                → Term m n  -- type abstraction
  λ'      : Type n       → Term (1 + m) n → Term m n  -- term abstraction
  μ       : Type n       → Term (1 + m) n → Term m n  -- recursive term
  _[_]    : Term m n     → Type n         → Term m n  -- type application
  _·_     : Term m n     → Term m n       → Term m n  -- term application
  fold    : Type (1 + n) → Term m n       → Term m n  -- fold recursive type
  unfold  : Type (1 + n) → Term m n       → Term m n  -- unfold recursive type
-- Untyped values with up to m free term variables and up to n free
-- type variables
data Val (m n : ℕ) : Set where
  Λ       : Term m (1 + n)                → Val m n   -- type abstraction
  λ'      : Type n       → Term (1 + m) n → Val m n   -- term abstraction
  fold    : Type (1 + n) → Val m n        → Val m n   -- fold recursive type
-- Conversion from values to terms
⌜_⌝  : ∀ {m n} → Val m n → Term m n
⌜ Λ x      ⌝ = Λ x
⌜ λ' a t   ⌝ = λ' a t
⌜ fold a t ⌝ = fold a ⌜ t ⌝
------------------------------------------------------------------------
-- Substitutions in terms
-- Type substitutions in terms
module TermTypeSubst where
  module TermTypeApp {T : ℕ → Set} (l : Lift T Type) where
    open Lift l hiding (var)
    open TypeSubst.TypeApp l renaming (_/_ to _/tp_)
    infixl 8 _/_
    -- Apply a type substitution to a term
    _/_ : ∀ {m n k} → Term m n → Sub T n k → Term m k
    var x      / σ = var x
    Λ t        / σ = Λ (t / σ ↑)
    λ' a t     / σ = λ' (a /tp σ) (t / σ)
    μ a t      / σ = μ (a /tp σ) (t / σ)
    t [ a ]    / σ = (t / σ) [ a /tp σ ]
    s · t      / σ = (s / σ) · (t / σ)
    fold a t   / σ = fold (a /tp σ ↑) (t / σ)
    unfold a t / σ = unfold (a /tp σ ↑) (t / σ)
  open TypeSubst using (varLift; termLift; sub)
  module Lifted {T} (lift : Lift T Type) {m} where
    application : Application (Term m) T
    application = record { _/_ = TermTypeApp._/_ lift {m = m} }
    open Application application public
  open Lifted termLift public
  -- Apply a type variable substitution (renaming) to a term
  _/Var_ : ∀ {m n k} → Term m n → Sub Fin n k → Term m k
  _/Var_ = TermTypeApp._/_ varLift
  -- Weaken a term with an additional type variable
  weaken : ∀ {m n} → Term m n → Term m (suc n)
  weaken t = t /Var VarSubst.wk
  infix 8 _[/_]
  -- Shorthand for single-variable type substitutions in terms
  _[/_] : ∀ {m n} → Term m (1 + n) → Type n → Term m n
  t [/ b ] = t / sub b
-- Lemmas about type substitutions in terms.
module TermTypeLemmas where
  open TermTypeSubst public
  private module T = TypeLemmas
  private module V = VarLemmas
  /-↑⋆ :
    ∀ {T₁ T₂} {lift₁ : Lift T₁ Type} {lift₂ : Lift T₂ Type} →
    let open T.Lifted lift₁ using () renaming (_↑⋆_ to _↑⋆₁_; _/_ to _/tp₁_)
        open   Lifted lift₁ using () renaming (_/_  to _/₁_)
        open T.Lifted lift₂ using () renaming (_↑⋆_ to _↑⋆₂_; _/_ to _/tp₂_)
        open   Lifted lift₂ using () renaming (_/_  to _/₂_)
    in
    ∀ {n k} (ρ₁ : Sub T₁ n k) (ρ₂ : Sub T₂ n k) →
    (∀ i x → Type.var x /tp₁ ρ₁ ↑⋆₁ i ≡ Type.var x /tp₂ ρ₂ ↑⋆₂ i) →
     ∀ i {m} (t : Term m (i + n))  → t /₁ ρ₁ ↑⋆₁ i ≡ t /₂ ρ₂ ↑⋆₂ i
  /-↑⋆ ρ₁ ρ₂ hyp i (var x)      = refl
  /-↑⋆ ρ₁ ρ₂ hyp i (Λ t)        = cong Λ      (/-↑⋆ ρ₁ ρ₂ hyp (1 + i) t)
  /-↑⋆ ρ₁ ρ₂ hyp i (λ' a t)     =
    cong₂ λ'     (T./-↑⋆ ρ₁ ρ₂ hyp i a)       (/-↑⋆ ρ₁ ρ₂ hyp i t)
  /-↑⋆ ρ₁ ρ₂ hyp i (μ a t)      =
    cong₂ μ      (T./-↑⋆ ρ₁ ρ₂ hyp i a)       (/-↑⋆ ρ₁ ρ₂ hyp i t)
  /-↑⋆ ρ₁ ρ₂ hyp i (t [ b ])    =
    cong₂ _[_]     (/-↑⋆ ρ₁ ρ₂ hyp i t)     (T./-↑⋆ ρ₁ ρ₂ hyp i b)
  /-↑⋆ ρ₁ ρ₂ hyp i (s · t)      =
    cong₂ _·_      (/-↑⋆ ρ₁ ρ₂ hyp i s)       (/-↑⋆ ρ₁ ρ₂ hyp i t)
  /-↑⋆ ρ₁ ρ₂ hyp i (fold a t)   =
    cong₂ fold   (T./-↑⋆ ρ₁ ρ₂ hyp (1 + i) a) (/-↑⋆ ρ₁ ρ₂ hyp i t)
  /-↑⋆ ρ₁ ρ₂ hyp i (unfold a t) =
    cong₂ unfold (T./-↑⋆ ρ₁ ρ₂ hyp (1 + i) a) (/-↑⋆ ρ₁ ρ₂ hyp i t)
  /-wk : ∀ {m n} (t : Term m n) → t / TypeSubst.wk ≡ weaken t
  /-wk t = /-↑⋆ TypeSubst.wk VarSubst.wk (λ k x → begin
    tpVar x T./ T.wk T.↑⋆ k         ≡⟨ T.var-/-wk-↑⋆ k x ⟩
    tpVar (Data.Fin.lift k suc x)   ≡⟨ cong tpVar (sym (V.var-/-wk-↑⋆ k x)) ⟩
    tpVar (lookup (V.wk V.↑⋆ k) x)  ≡⟨ refl ⟩
    tpVar x T./Var V.wk V.↑⋆ k      ∎) 0 t
      where open Type using () renaming (var to tpVar)
-- Term substitutions in terms
module TermTermSubst where
  -- Substitutions of terms in terms
  --
  -- A TermSub T m n k is a substitution which, when applied to a term
  -- with at most m free term variables and n free type variables,
  -- yields a term with at most k free term variables and n free type
  -- variables.
  TermSub : (ℕ → ℕ → Set) → ℕ → ℕ → ℕ → Set
  TermSub T m n k = Sub (flip T n) m k
  record TermLift (T : ℕ → ℕ → Set) : Set where
    infix 10 _↑tm _↑tp
    field
      lift : ∀ {m n} → T m n → Term m n
      _↑tm : ∀ {m n k} → TermSub T m n k → TermSub T (suc m) n (suc k)
      _↑tp : ∀ {m n k} → TermSub T m n k → TermSub T m (suc n) k
  module TermTermApp {T} (l : TermLift T) where
    open TermLift l
    infixl 8 _/_
    -- Apply a term substitution to a term
    _/_ : ∀ {m n k} → Term m n → TermSub T m n k → Term k n
    var x      / ρ = lift (lookup ρ x)
    Λ t        / ρ = Λ (t / ρ ↑tp)
    λ' a t     / ρ = λ' a (t / ρ ↑tm)
    μ a t      / ρ = μ a (t / ρ ↑tm)
    t [ a ]    / ρ = (t / ρ) [ a ]
    s · t      / ρ = (s / ρ) · (t / ρ)
    fold a t   / ρ = fold a (t / ρ)
    unfold a t / ρ = unfold a (t / ρ)
  Fin′ : ℕ → ℕ → Set
  Fin′ m _ = Fin m
  varLift : TermLift Fin′
  varLift = record { lift = var; _↑tm = VarSubst._↑; _↑tp = Fun.id }
  infixl 8 _/Var_
  _/Var_ : ∀ {m n k} → Term m n → Sub Fin m k → Term k n
  _/Var_ = TermTermApp._/_ varLift
  Term′ : ℕ → ℕ → Set
  Term′ = flip Term
  private
    module ExpandSimple {n : ℕ} where
      simple : Simple (Term′ n)
      simple = record { var = var; weaken = λ t → t /Var VarSubst.wk }
      open Simple simple public
  open ExpandSimple  using (_↑; simple)
  open TermTypeSubst using () renaming (weaken to weakenTp)
  termLift : TermLift Term
  termLift = record
    { lift = Fun.id; _↑tm = _↑ ; _↑tp = λ ρ → map weakenTp ρ }
  private
    module ExpandSubst {n : ℕ} where
      app : Application (Term′ n) (Term′ n)
      app = record { _/_ = TermTermApp._/_ termLift {n = n} }
      subst : Subst (flip Term n)
      subst = record
        { simple      = simple
        ; application = app
        }
      open Subst subst public
  open ExpandSubst public hiding (var; simple)
  infix 8 _[/_]
  -- Shorthand for single-variable term substitutions in terms
  _[/_] : ∀ {m n} → Term (1 + m) n → Term m n → Term m n
  s [/ t ] = s / sub t
open TermTypeSubst renaming (weaken to weakenTmTp)
open TermTermSubst renaming (weaken to weakenTmTm) hiding (id)
open TypeSubst     renaming (weaken to weakenTp; weaken↑ to weakenTp↑)
                   hiding (id)
------------------------------------------------------------------------
-- Encoding of additional term operators
--
-- NOTE: These encoded operators require more type information than
-- their "classic" untyped counterparts.  The additional types are
-- required by the underlying (untyped) abstractions and type
-- applications.  Cf. TAPL sec. 24.3, pp. 377-379.
module TermOperators where
  open TypeOperators using (⊤; ⊥; _→ⁿ_)
  -- Polymorphic identity function
  id : {m n : ℕ} → Term m n
  id = Λ (λ' (var zero) (var zero))
  -- Bottom elimination/univeral property of the initial type
  ⊥-elim : ∀ {m n} → Type n → Term m n
  ⊥-elim a = λ' ⊥ ((var zero) [ a ])
  -- Unit value
  tt = id
  -- Top introduction/universal property of the terminal type
  ⊤-intro : ∀ {m n} → Type n → Term m n
  ⊤-intro a = λ' a id
  -- Packing existential types
  as-∃_pack_,_ : ∀ {m n} → Type (1 + n) → Type n → Term m n → Term m n
  as-∃ a pack b , t =
    Λ (λ' (∀' (weakenTp↑ a →' var (suc zero)))
          ((var zero [ weakenTp b ]) · weakenTmTm (weakenTmTp t)))
  -- Unpacking existential types
  unpack_in'_ : ∀ {m n} → Term m n → Term (1 + m) (1 + n) →
                {a : Type (1 + n)} {b : Type n} → Term m n
  unpack_in'_ s t {a} {b} = (s [ b ]) · (Λ (λ' a t))
  -- n-ary term abstraction
  λⁿ : ∀ {m n k} → Vec (Type n) k → Term (k + m) n → Term m n
  λⁿ []       t = t
  λⁿ (a ∷ as) t = λⁿ as (λ' a t)
  infixl 9 _·ⁿ_
  -- n-ary term application
  _·ⁿ_ : ∀ {m n k} → Term m n → Vec (Term m n) k → Term m n
  s ·ⁿ []       = s
  s ·ⁿ (t ∷ ts) = s ·ⁿ ts · t
  -- Record/tuple constructor
  new : ∀ {m n k} → Vec (Term m n) k → {as : Vec (Type n) k} → Term m n
  new []                = tt
  new (t ∷ ts) {a ∷ as} =
    Λ (λ' (map weakenTp (a ∷ as) →ⁿ var zero)
          (var zero ·ⁿ map weakenTmTm (map weakenTmTp (t ∷ ts))))
  -- Field access/projection
  π : ∀ {m n k} → Fin k → Term m n → {as : Vec (Type n) k} → Term m n
  π     () t {[]}
  π {m} x  t {a ∷ as} =
    (t [ lookup (a ∷ as) x ]) · (λⁿ (a ∷ as) (var (inject+ m x)))
 
 | 
	{
  "alphanum_fraction": 0.5240690282,
  "avg_line_length": 33.9349315068,
  "ext": "agda",
  "hexsha": "670a14fbde264a8c14e2ad13b2bf9876ddba95ff",
  "lang": "Agda",
  "max_forks_count": 8,
  "max_forks_repo_forks_event_max_datetime": "2021-07-06T23:12:48.000Z",
  "max_forks_repo_forks_event_min_datetime": "2015-05-29T12:24:46.000Z",
  "max_forks_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "sstucki/system-f-agda",
  "max_forks_repo_path": "src/SystemF/Term.agda",
  "max_issues_count": 2,
  "max_issues_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d",
  "max_issues_repo_issues_event_max_datetime": "2019-05-11T19:23:26.000Z",
  "max_issues_repo_issues_event_min_datetime": "2017-05-30T06:43:04.000Z",
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "sstucki/system-f-agda",
  "max_issues_repo_path": "src/SystemF/Term.agda",
  "max_line_length": 78,
  "max_stars_count": 68,
  "max_stars_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "sstucki/system-f-agda",
  "max_stars_repo_path": "src/SystemF/Term.agda",
  "max_stars_repo_stars_event_max_datetime": "2022-03-01T01:25:16.000Z",
  "max_stars_repo_stars_event_min_datetime": "2015-05-26T13:12:56.000Z",
  "num_tokens": 3720,
  "size": 9909
} 
 | 
					
	module Codata where
codata D : Set where
 
 | 
	{
  "alphanum_fraction": 0.7619047619,
  "avg_line_length": 10.5,
  "ext": "agda",
  "hexsha": "ca675ac4c132ccf2ebd1610e38736999c2e60ed2",
  "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": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
  "max_forks_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_forks_repo_name": "hborum/agda",
  "max_forks_repo_path": "test/Fail/Codata.agda",
  "max_issues_count": 1,
  "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
  "max_issues_repo_issues_event_max_datetime": "2020-01-26T18:22:08.000Z",
  "max_issues_repo_issues_event_min_datetime": "2020-01-26T18:22:08.000Z",
  "max_issues_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_issues_repo_name": "hborum/agda",
  "max_issues_repo_path": "test/Fail/Codata.agda",
  "max_line_length": 20,
  "max_stars_count": 3,
  "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
  "max_stars_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_stars_repo_name": "hborum/agda",
  "max_stars_repo_path": "test/Fail/Codata.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": 12,
  "size": 42
} 
 | 
					
	-- 2010-10-15
module DoNotEtaExpandMVarsWhenComparingAgainstRecord where
open import Common.Irrelevance
data _==_ {A : Set1}(a : A) : A -> Set where
  refl : a == a
record IR : Set1 where
  constructor mkIR
  field
    .fromIR : Set
open IR
reflIR2 : (r : IR) -> _ == mkIR (fromIR r)
reflIR2 r = refl {a = _}
-- this would fail if
-- ? = mkIR (fromIR r)
-- would be solved by
-- mkIR ?1 = mkIR (fromIR r)
-- because then no constraint is generated for ?1 due to triviality
 
 | 
	{
  "alphanum_fraction": 0.6617954071,
  "avg_line_length": 19.9583333333,
  "ext": "agda",
  "hexsha": "56c997513a433e0162afb97bcb438031bf9fb1d0",
  "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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
  "max_forks_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_forks_repo_name": "redfish64/autonomic-agda",
  "max_forks_repo_path": "test/Succeed/DoNotEtaExpandMVarsWhenComparingAgainstRecord.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "BSD-3-Clause"
  ],
  "max_issues_repo_name": "redfish64/autonomic-agda",
  "max_issues_repo_path": "test/Succeed/DoNotEtaExpandMVarsWhenComparingAgainstRecord.agda",
  "max_line_length": 67,
  "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/DoNotEtaExpandMVarsWhenComparingAgainstRecord.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": 165,
  "size": 479
} 
 | 
					
	-----------------------------------------------------------------------
-- This file defines Degenerate Dial₂(Sets) and shows that it is a   --
-- CCC.                                                              --
-----------------------------------------------------------------------
module DeDial2Sets where
open import prelude
data UnitType : Set₁ where  
  unit : UnitType
  mod : UnitType
  -- comp : UnitType → UnitType → UnitType
⟦_⟧ : UnitType → Set
⟦ unit ⟧ = ⊤
⟦ mod ⟧ = (⊤ *) × (⊤ *)
-- ⟦ comp t₁ t₂ ⟧ = ⟦ t₁ ⟧ × ⟦ t₂ ⟧
Obj⊤ : Set₁
Obj⊤ = Σ[ U ∈ Set ] (Σ[ X ∈ UnitType ](U → ⟦ X ⟧ → Set))
Hom⊤ : Obj⊤ → Obj⊤ → Set
Hom⊤ (U , X , α) (V , Y , β) =
  Σ[ f ∈ (U → V) ]
    (Σ[ F ∈  (⟦ Y ⟧ → ⟦ X ⟧) ] (∀{u : U}{y : ⟦ Y ⟧} → α u (F y) → β (f u) y))
comp⊤ : {A B C : Obj⊤} → Hom⊤ A B → Hom⊤ B C → Hom⊤ A C
comp⊤ {(U , X , α)} {(V , Y , β)} {(W , Z , γ)} (f , F , p₁) (g , G , p₂) =
  (g ∘ f , F ∘ G , (λ {u z} p-α → p₂ (p₁ p-α)))
infixl 5 _○⊤_
_○⊤_ = comp⊤
-- The contravariant hom-functor:
Hom⊤ₐ :  {A' A B B' : Obj⊤} → Hom⊤ A' A → Hom⊤ B B' → Hom⊤ A B → Hom⊤ A' B'
Hom⊤ₐ f h g = comp⊤ f (comp⊤ g h)
-- The identity function:
id⊤ : {A : Obj⊤} → Hom⊤ A A 
id⊤ {(U , X , α)} = (id-set , id-set , id-set)
-- In this formalization we will only worry about proving that the
-- data of morphisms are equivalent, and not worry about the morphism
-- conditions.  This will make proofs shorter and faster.
--
-- If we have parallel morphisms (f,F) and (g,G) in which we know that
-- f = g and F = G, then the condition for (f,F) will imply the
-- condition of (g,G) and vice versa.  Thus, we can safly ignore it.
infix 4 _≡h⊤_
_≡h⊤_ : {A B : Obj⊤} → (f g : Hom⊤ A B) → Set
_≡h⊤_ {(U , X , α)}{(V , Y , β)} (f , F , p₁) (g , G , p₂) = f ≡ g × F ≡ G
≡h⊤-refl : {A B : Obj⊤}{f : Hom⊤ A B} → f ≡h⊤ f
≡h⊤-refl {U , X , α}{V , Y , β}{f , F , _} = refl , refl
≡h⊤-trans : ∀{A B}{f g h : Hom⊤ A B} → f ≡h⊤ g → g ≡h⊤ h → f ≡h⊤ h
≡h⊤-trans {U , X , α}{V , Y , β}{f , F , _}{g , G , _}{h , H , _} (p₁ , p₂) (p₃ , p₄) rewrite p₁ | p₂ | p₃ | p₄ = refl , refl
≡h⊤-sym : ∀{A B}{f g : Hom⊤ A B} → f ≡h⊤ g → g ≡h⊤ f
≡h⊤-sym {U , X , α}{V , Y , β}{f , F , _}{g , G , _} (p₁ , p₂) rewrite p₁ | p₂ = refl , refl
≡h⊤-subst-○ : ∀{A B C : Obj⊤}{f₁ f₂ : Hom⊤ A B}{g₁ g₂ : Hom⊤ B C}{j : Hom⊤ A C}
  → f₁ ≡h⊤ f₂
  → g₁ ≡h⊤ g₂
  → f₂ ○⊤ g₂ ≡h⊤ j
  → f₁ ○⊤ g₁ ≡h⊤ j
≡h⊤-subst-○ {U , X , α}
         {V , Y , β}
         {W , Z , γ}
         {f₁ , F₁ , _}
         {f₂ , F₂ , _}
         {g₁ , G₁ , _}
         {g₂ , G₂ , _}
         {j , J , _}
         (p₅ , p₆) (p₇ , p₈) (p₉ , p₁₀) rewrite p₅ | p₆ | p₇ | p₈ | p₉ | p₁₀ = refl , refl
○⊤-assoc : ∀{A B C D}{f : Hom⊤ A B}{g : Hom⊤ B C}{h : Hom⊤ C D}
  → f ○⊤ (g ○⊤ h) ≡h⊤ (f ○⊤ g) ○⊤ h
○⊤-assoc {U , X , α}{V , Y , β}{W , Z , γ}{S , T , ι}
        {f , F , _}{g , G , _}{h , H , _} = refl , refl
○⊤-idl : ∀{A B}{f : Hom⊤ A B} → id⊤ ○⊤ f ≡h⊤ f
○⊤-idl {U , X , _}{V , Y , _}{f , F , _} = refl , refl
○⊤-idr : ∀{A B}{f : Hom⊤ A B} → f ○⊤ id⊤ ≡h⊤ f
○⊤-idr {U , X , _}{V , Y , _}{f , F , _} = refl , refl
_⊗ᵣ_ : ∀{U V : Set}{X Y : UnitType} → (α : U → ⟦ X ⟧ → Set) → (β : V → ⟦ Y ⟧ → Set) → Σ U (λ x → V) → Σ ⟦ X ⟧ (λ x → ⟦ Y ⟧) → Set
(α ⊗ᵣ β) (u , v) (l₁ , l₂) = (α u l₁) × (β v l₂)
_⊗ₒ_ : (A B : Obj⊤) → Obj⊤
(U , unit , α) ⊗ₒ (V , unit , β) = (U × V) , unit , (λ p t → (α (fst p) triv) × (β (snd p) triv))
(U , unit , α) ⊗ₒ (V , mod , β) = (U × V) , (mod , (λ p t → (α (fst p) triv) × (β (snd p) t)))
(U , mod , α) ⊗ₒ (V , unit , β) = (U × V) , (mod , (λ p t → (α (fst p) t) × (β (snd p) triv)))
(U , mod , α) ⊗ₒ (V , mod , β) = (U × V) , (mod , (λ p t → (α (fst p) t) × (β (snd p) t)))
-- F⊗ : ∀{S Z W T V X U Y : Set ℓ}{f : U → W}{F : Z → X}{g : V → S}{G : T → Y} → (S → Z) × (W → T) → (V → X) × (U → Y)
-- F⊗ {f = f}{F}{g}{G} (h₁ , h₂) = (λ v → F(h₁ (g v))) , (λ u → G(h₂ (f u)))
  
-- _⊗ₐ_ : {A B C D : Obj} → Hom A C → Hom B D → Hom (A ⊗ₒ B) (C ⊗ₒ D)
-- _⊗ₐ_ {(U , X , α)}{(V , Y , β)}{(W , Z , γ)}{(S , T , δ)} (f , F , p₁) (g , G , p₂) = ⟨ f , g ⟩ , F⊗ {f = f}{F}{g}{G} , (λ {u y} → cond {u}{y})
--  where
--   cond : {u : Σ U (λ x → V)} {y : Σ (S → Z) (λ x → W → T)} →
--       ((α ⊗ᵣ β) u (F⊗ {f = f}{F}{g}{G} y)) ≤L ((γ ⊗ᵣ δ) (⟨ f , g ⟩ u) y)
--   cond {u , v}{h , j} = l-mul-funct {p = mproset l-pf} (p₁ {u}{h (g v)}) (p₂ {v}{j (f u)})
  
-- □ᵣ : {U : Set}{X : UnitType} → (U → ⟦ X ⟧ → Set) → U → 𝕃 ⟦ X ⟧ → Set
-- □ᵣ α u [] = ⊤
-- □ᵣ {U}{X} α u (x :: l) = (α u x) × (□ᵣ {U}{X} α u l)
-- □ₒ : Obj⊤ → Obj⊤
-- □ₒ (U , X , α) = U , seq X , □ᵣ {U}{X} α
-- □ₐ : {A B : Obj⊤} → Hom⊤ A B → Hom⊤ (□ₒ A) (□ₒ B)
-- □ₐ {U , n₁ , α}{V , n₂ , β} (f , F , p) = f , map F , {!!}
  
π₁ : {A B : Obj⊤} → Hom⊤ (A ⊗ₒ B) A
π₁ {U , unit , α} {V , unit , β} = fst , id-set , (λ {u y} → aux {u}{y})
 where
   aux : {u : Σ U (λ x → V)} {y : ⊤} → Σ (α (fst u) triv) (λ x → β (snd u) triv) → α (fst u) y
   aux {u , v}{triv} = fst
   
π₁ {U , mod , α} {V , unit , β} = fst , id-set , (λ {u y} → aux {u}{y})
 where
  aux : {u : Σ U (λ x → V)} {y : Σ (𝕃 ⊤) (λ x → 𝕃 ⊤)} → Σ (α (fst u) y) (λ x → β (snd u) triv) → α (fst u) y
  aux {u , v}{l₁ , l₂} = fst
  
π₁ {U , unit , α} {V , mod , β} = fst , (λ x → [ x ] , [ x ]) , (λ {u y} → aux {u}{y})
 where
   aux : {u : Σ U (λ x → V)} {y : ⊤} → Σ (α (fst u) triv) (λ x → β (snd u) (y :: [] , y :: [])) → α (fst u) y
   aux {u , v}{triv} = fst
π₁ {U , mod , α} {V , mod , β} = fst , id-set , (λ {u y} → aux {u}{y})
 where
   aux : {u : Σ U (λ x → V)} {y : Σ (𝕃 ⊤) (λ x → 𝕃 ⊤)} → Σ (α (fst u) y) (λ x → β (snd u) y) → α (fst u) y
   aux {u , v}{l} = fst
π₂ : {A B : Obj⊤} → Hom⊤ (A ⊗ₒ B) B
π₂ {U , unit , α} {V , unit , β} = snd , {!!} , {!!}
π₂ {U , mod , α} {V , unit , β} = snd , {!!} , {!!}  
π₂ {U , unit , α} {V , mod , β} = snd , {!!} , {!!}
π₂ {U , mod , α} {V , mod , β} = snd , {!!} , {!!}
postulate rel-++ : ∀{W : Set}{w : W}{γ  : W → 𝕃 (⊤ {lzero}) → Set}{l₁ l₂ : 𝕃 ⊤} → γ w (l₁ ++ l₂) → ((γ w l₁) × (γ w l₂))
cart-ar : {A B C : Obj⊤}
  → (f : Hom⊤ C A)
  → (g : Hom⊤ C B)
  → Hom⊤ C (A ⊗ₒ B)
cart-ar {U , unit , α} {V , unit , β} {W , unit , γ} (f , F , p₁) (g , G , p₂) = trans-× f g , id-set , (λ {u y} → aux {u}{y})
 where
   aux : {u : W} {y : ⊤} → γ u y → Σ (α (f u) triv) (λ x → β (g u) triv)
   aux {w}{triv} p with p₁ {w}{triv} | p₂ {w}{triv}
   ... | p₃ | p₄ with F triv | G triv
   ... | triv | triv = p₃ p , p₄ p
cart-ar {U , unit , α} {V , unit , β} {W , mod , γ} (f , F , p₁) (g , G , p₂) = trans-× f g , (λ x → (fst (F x)) ++ (snd (F x)) , (fst (G x)) ++ (snd (G x))) , {!!}
cart-ar {U , unit , α} {V , mod , β} {W , unit , γ} (f , F , p₁) (g , G , p₂) = trans-× f g , {!!} , {!!}
cart-ar {U , unit , α} {V , mod , β} {W , mod , γ} (f , F , p₁) (g , G , p₂) = trans-× f g , {!!} , {!!}
cart-ar {U , mod , α} {V , unit , β} {W , unit , γ} (f , F , p₁) (g , G , p₂) = trans-× f g , {!!} , {!!}
cart-ar {U , mod , α} {V , unit , β} {W , mod , γ} (f , F , p₁) (g , G , p₂) = trans-× f g , {!!} , {!!}
   
cart-ar {U , mod , α} {V , mod , β} {W , unit , γ} (f , F , p₁) (g , G , p₂) = trans-× f g , {!!} , {!!}
  
cart-ar {U , mod , α} {V , mod , β} {W , mod , γ} (f , F , p₁) (g , G , p₂) = trans-× f g , {!!} , {!!}
   
cart-diag₁ : ∀{A B C : Obj⊤}
  → {f : Hom⊤ C A}
  → {g : Hom⊤ C B}
  → (cart-ar f g) ○⊤ π₁ ≡h⊤ f
cart-diag₁ {U , unit , α} {V , unit , β} {W , unit , γ} {f , F , p₁} {g , G , p₂} = refl , {!!}
cart-diag₁ {U , unit , α} {V , unit , β} {W , mod , γ} {f , F , p₁} {g , G , p₂} = refl , {!!}
cart-diag₁ {U , unit , α} {V , mod , β} {W , unit , γ} {f , F , p₁} {g , G , p₂} = {!!}
cart-diag₁ {U , unit , α} {V , mod , β} {W , mod , γ} {f , F , p₁} {g , G , p₂} = {!!}
cart-diag₁ {U , mod , α} {V , unit , β} {W , unit , γ} {f , F , p₁} {g , G , p₂} = {!!}
cart-diag₁ {U , mod , α} {V , unit , β} {W , mod , γ} {f , F , p₁} {g , G , p₂} = {!!}
cart-diag₁ {U , mod , α} {V , mod , β} {W , unit , γ} {f , F , p₁} {g , G , p₂} = {!!}
cart-diag₁ {U , mod , α} {V , mod , β} {W , mod , γ} {f , F , p₁} {g , G , p₂} = {!!}
-- cart-diag₂ : ∀{A B C : Obj⊤}
--   → {f : Hom (toObj C) (toObj A)}
--   → {g : Hom (toObj C) (toObj B)}
--   → (cart-ar f g) ○ π₂ ≡h g
-- cart-diag₂ {U , α}{V , β}{W , γ}{f , F , p₁}{g , G , p₂} = refl , ext-set ctr
--  where
--    ctr : {a : ⊤} → triv ≡ G a
--    ctr {triv} with G triv
--    ... | triv = refl
-- □ₒ-cond : ∀{U X : Set}
--   → (U → X → Set)
--   → U
--   → (X *)
--   → Set
-- □ₒ-cond {U} α u l = all-pred (α u) l 
-- fromObj : (A : Obj) → Σ[ B ∈ Obj⊤ ]( A ≡ toObj(B)) → Obj⊤
-- fromObj _ ((a , b) , b₁) = a , b 
-- □ₒ : Obj → Obj
-- □ₒ (U , X , α) = (U , X * , □ₒ-cond α)
-- □ₐ : {A B : Obj} → Hom A B → Hom (□ₒ A) (□ₒ B)
-- □ₐ {U , X , α}{V , Y , β} (f , F , p) = f , map F , cond
--  where
--   cond : {u : U} {y : 𝕃 Y} → all-pred (α u) (map F y) → all-pred (β (f u)) y
--   cond {y = []} x = triv
--   cond {y = x :: y} (a , b) = p a , cond b
-- □-ε : ∀{A : Obj} → Hom (□ₒ A) A
-- □-ε {U , X , α} = id-set , (λ x → [ x ] ) , aux
--  where
--   aux : {u : U} {y : X} → Σ (α u y) (λ x → ⊤) → α u y
--   aux (a , b) = a
-- □-δ : ∀{A : Obj} → Hom (□ₒ A) (□ₒ (□ₒ A))
-- □-δ {U , X , α} = id-set , (foldr _++_ []) , cond
--  where
--    cond : {u : U} {y : 𝕃 (𝕃 X)} → all-pred (α u) (foldr _++_ [] y) → all-pred (λ l → all-pred (α u) l) y
--    cond {y = []} p = triv
--    cond {u}{y = y :: y₁} p rewrite
--      (all-pred-append {X}{α u}{y}{foldr _++_ [] y₁} ∧-unit ∧-assoc)
--      with p
--    ... | p₁ , p₂ = p₁ , cond p₂
-- comonand-diag₁ : ∀{A : Obj}
--   → (□-δ {A}) ○ (□ₐ (□-δ {A})) ≡h (□-δ {A}) ○ (□-δ { □ₒ (A)})
-- comonand-diag₁ {U , X , α} = refl , ext-set (λ {a} → ctr {a})
--  where
--   ctr : {a : 𝕃 (𝕃 (𝕃 X))} → foldr _++_ [] (map (foldr _++_ []) a) ≡ foldr _++_ [] (foldr _++_ [] a)
--   ctr {[]} = refl
--   ctr {a :: a₁} rewrite sym (foldr-append {l₁ = a}{foldr _++_ [] a₁}) | ctr {a₁} = refl
-- comonand-diag₂ : ∀{A : Obj}
--   → (□-δ {A}) ○ (□-ε { □ₒ A}) ≡h (□-δ {A}) ○ (□ₐ (□-ε {A}))
-- comonand-diag₂ {U , X , α} = refl , ext-set (λ {a} → cond {a})
--  where
--    cond : {a : 𝕃 X} → a ++ [] ≡ foldr _++_ [] (map (λ x → x :: []) a)
--    cond {a} rewrite ++[] a = foldr-map
-- □-ctr : {U V : Set} → 𝕃 (Σ (V → ⊤) (λ x → U → ⊤)) → Σ (V → 𝕃 ⊤) (λ x → U → 𝕃 ⊤)
-- □-ctr [] = (λ x → [ triv ]) , (λ x → [ triv ])
-- □-ctr ((a , b) :: l) = (λ v → a v :: (fst (□-ctr l)) v) , (λ u → b u :: (snd (□-ctr l)) u)
  
-- □-m : {A B : Obj⊤} → Hom ((□ₒ (toObj A)) ⊗ₒ (□ₒ (toObj B))) (□ₒ ((toObj A) ⊗ₒ (toObj B)))
-- □-m {U , α}{V , β} = id-set , □-ctr , cond
--  where  
--   cond : {u : Σ U (λ x → V)} {y : 𝕃 (Σ (V → ⊤) (λ x → U → ⊤))} →
--       ((λ u₁ l → all-pred (α u₁) l) ⊗ᵣ (λ u₁ l → all-pred (β u₁) l)) u
--       (□-ctr y) → all-pred ((α ⊗ᵣ β) u) y
--   cond {a , b} {[]} x = triv
--   cond {a , b} {(a₁ , b₁) :: y} ((a₂ , b₂) , a₃ , b₃) with cond {a , b}{y}
--   ... | IH with □-ctr y
--   ... | c , d = (a₂ , a₃) , IH (b₂ , b₃)
-- □-m-nat : ∀{A A' B B' : Obj⊤}
--   → (f : Hom (toObj A) (toObj A'))
--   → (g : Hom (toObj B) (toObj B'))
--   → ((□ₐ f) ⊗ₐ (□ₐ g)) ○ □-m ≡h □-m ○ (□ₐ (f ⊗ₐ g))
-- □-m-nat {U , α}{U' , α'}{V , β}{V' , β'} (f , F , p₁) (g , G , p₂) = refl , ext-set (λ {a} → aux {a})
--   where
--     aux : {a : 𝕃 (Σ (V' → ⊤) (λ x → U' → ⊤))} → F⊗ {V'}{𝕃 ⊤}{U'}{𝕃 ⊤}{V}{𝕃 ⊤}{U}{𝕃 ⊤}{f}{map F}{g}{map G} (□-ctr a) ≡ □-ctr (map (F⊗ {V'} {⊤} {U'} {⊤} {V} {⊤} {U} {⊤} {f} {F} {g} {G}) a)
--     aux {[]} with G triv | F triv
--     ... | triv | triv = refl
--     aux {(a , b) :: a₁} = eq-× (ext-set aux₁) (ext-set aux₄)
--      where
--        aux₂ : ∀{v}{l : 𝕃 (Σ (V' → ⊤) (λ x → U' → ⊤))} → map F (fst (□-ctr l) (g v)) ≡ fst (□-ctr (map (F⊗ {V'} {⊤} {U'} {⊤} {V} {⊤} {U} {⊤} {f} {F} {g} {G}) l)) v
--        aux₂ {_}{[]} with F triv
--        ... | triv = refl
--        aux₂ {v}{(a₂ , b₁) :: l} rewrite aux₂ {v}{l} = refl
         
--        aux₁ : {a₂ : V} → F (a (g a₂)) :: map F (fst (□-ctr a₁) (g a₂)) ≡ F (a (g a₂)) :: fst (□-ctr (map (F⊗ {V'} {⊤} {U'} {⊤} {V} {⊤} {U} {⊤} {f} {F} {g} {G}) a₁)) a₂
--        aux₁ {v} with F (a (g v))
--        ... | triv rewrite aux₂ {v}{a₁} = refl
--        aux₃ : ∀{u l} → map G (snd (□-ctr l) (f u)) ≡ snd (□-ctr (map (F⊗ {V'} {⊤} {U'} {⊤} {V} {⊤} {U} {⊤} {f} {F} {g} {G}) l)) u
--        aux₃ {u}{[]} with G triv
--        ... | triv = refl
--        aux₃ {u}{(a₂ , b₁) :: l} rewrite aux₃ {u}{l} = refl
--        aux₄ : {a₂ : U} → G (b (f a₂)) :: map G (snd (□-ctr a₁) (f a₂)) ≡ G (b (f a₂)) :: snd (□-ctr (map (F⊗ {V'} {⊤} {U'} {⊤} {V} {⊤} {U} {⊤} {f} {F} {g} {G}) a₁)) a₂
--        aux₄ {u} rewrite aux₃ {u}{a₁} = refl
       
-- □-m-I : Hom I (□ₒ I)
-- □-m-I = id-set , (λ _ → triv) , cond
--  where
--   cond : {u : ⊤} {y : 𝕃 ⊤} → ι u triv → all-pred (ι u) y
--   cond {triv} {[]} x = triv
--   cond {triv} {triv :: y} triv = triv , cond triv
-- π-□-ctr : {U V : Set} → 𝕃 ⊤ → Σ (V → 𝕃 ⊤) (λ _ → U → 𝕃 ⊤)
-- π-□-ctr [] = (λ x → [ triv ]) , (λ x → [ triv ])
-- π-□-ctr {U}{V} (triv :: l) = (λ v → triv :: fst (π-□-ctr {U}{V} l) v) , ((λ v → triv :: snd (π-□-ctr {U}{V} l) v))
-- π₁-□ : ∀{U α V β} → Hom ((□ₒ (U , ⊤ , α)) ⊗ₒ (□ₒ (V , ⊤ , β))) (□ₒ (U , ⊤ , α))
-- π₁-□ {U}{α}{V}{β} = fst , π-□-ctr , cond
--  where
--    cond : {u : Σ U (λ x → V)} {y : 𝕃 ⊤} →
--       ((λ u₁ l → all-pred (α u₁) l) ⊗ᵣ (λ u₁ l → all-pred (β u₁) l)) u
--       (π-□-ctr y) →
--       all-pred (α (fst u)) y
--    cond {a , b} {[]} x = triv
--    cond {a , b} {triv :: y} ((a₁ , b₁) , a₂ , b₂) with cond {a , b} {y}
--    ... | IH with π-□-ctr {U}{V} y
--    ... | c , d = a₁ , IH (b₁ , b₂)
   
-- □-prod₁ : ∀{U α V β} → _≡h_ {((□ₒ (U , ⊤ , α)) ⊗ₒ (□ₒ (V , ⊤ , β)))}
--                             {(□ₒ (U , ⊤ , α))}
--                             (_○_ {(□ₒ (U , ⊤ , α)) ⊗ₒ (□ₒ (V , ⊤ , β))}{□ₒ ((U , ⊤ , α) ⊗ₒ (V , ⊤ , β))}{□ₒ (U , ⊤ , α)} (□-m {U , α}{V , β}) (□ₐ {(U , ⊤ , α) ⊗ₒ (V , ⊤ , β)}{U , ⊤ , α} (π₁ {U , α}{V , β})))
--                             (π₁-□ {U}{α}{V}{β})
-- □-prod₁ {U}{α}{V}{β} = refl , ext-set (λ {a} → aux {a})
--  where
--   aux : {a : 𝕃 ⊤} → □-ctr {U}{V} (map π-ctr a) ≡ π-□-ctr a
--   aux {[]} = refl
--   aux {triv :: a} rewrite aux {a} = refl
-- π₂-□ : ∀{U α V β} → Hom ((□ₒ (U , ⊤ , α)) ⊗ₒ (□ₒ (V , ⊤ , β))) (□ₒ (V , ⊤ , β))
-- π₂-□ {U}{α}{V}{β} = snd , π-□-ctr , cond
--  where
--    cond : {u : Σ U (λ x → V)} {y : 𝕃 ⊤} →
--       ((λ u₁ l → all-pred (α u₁) l) ⊗ᵣ (λ u₁ l → all-pred (β u₁) l)) u
--       (π-□-ctr y) →
--       all-pred (β (snd u)) y
--    cond {a , b} {[]} x = triv
--    cond {a , b} {triv :: y} ((a₁ , b₁) , a₂ , b₂) with cond {a , b}{y}
--    ... | IH with π-□-ctr {U}{V} y
--    ... | c , d = a₂ , (IH (b₁ , b₂))
-- □-prod₂ : ∀{U α V β} → _≡h_ {((□ₒ (U , ⊤ , α)) ⊗ₒ (□ₒ (V , ⊤ , β)))}
--                             {(□ₒ (V , ⊤ , β))}
--                             (_○_ {(□ₒ (U , ⊤ , α)) ⊗ₒ (□ₒ (V , ⊤ , β))}{□ₒ ((U , ⊤ , α) ⊗ₒ (V , ⊤ , β))}{□ₒ (V , ⊤ , β)} (□-m {U , α}{V , β}) (□ₐ {(U , ⊤ , α) ⊗ₒ (V , ⊤ , β)}{V , ⊤ , β} (π₂ {U , α}{V , β})))
--                             (π₂-□ {U}{α}{V}{β})
-- □-prod₂ {U}{α}{V}{β} = refl , (ext-set (λ {a} → aux {a}))
--  where
--   aux : {a : 𝕃 ⊤} → □-ctr {U}{V} (map π-ctr a) ≡ π-□-ctr a
--   aux {[]} = refl
--   aux {triv :: a} rewrite aux {a} = refl
-- cart-ar-□ : {A B C : Obj⊤}
--   → (f : Hom (□ₒ (toObj C)) (□ₒ (toObj A)))
--   → (g : Hom (□ₒ (toObj C)) (□ₒ (toObj B)))
--   → Hom (□ₒ (toObj C)) ((□ₒ (toObj A)) ⊗ₒ (□ₒ (toObj B)))
-- cart-ar-□ {U , α}{V , β}{W , γ} (f , F , p₁) (g , G , p₂) = trans-× f g ,  {!!} , {!!}
--  where
   
-- -}
 
 | 
	{
  "alphanum_fraction": 0.361194224,
  "avg_line_length": 43.0644257703,
  "ext": "agda",
  "hexsha": "143cb059bbc9916b7abdc0aa2f7f8cbdeaedd6a2",
  "lang": "Agda",
  "max_forks_count": null,
  "max_forks_repo_forks_event_max_datetime": null,
  "max_forks_repo_forks_event_min_datetime": null,
  "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
  "max_forks_repo_licenses": [
    "MIT"
  ],
  "max_forks_repo_name": "heades/AUGL",
  "max_forks_repo_path": "dialectica-cats/DeDial2Sets.agda",
  "max_issues_count": null,
  "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
  "max_issues_repo_issues_event_max_datetime": null,
  "max_issues_repo_issues_event_min_datetime": null,
  "max_issues_repo_licenses": [
    "MIT"
  ],
  "max_issues_repo_name": "heades/AUGL",
  "max_issues_repo_path": "dialectica-cats/DeDial2Sets.agda",
  "max_line_length": 210,
  "max_stars_count": null,
  "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
  "max_stars_repo_licenses": [
    "MIT"
  ],
  "max_stars_repo_name": "heades/AUGL",
  "max_stars_repo_path": "dialectica-cats/DeDial2Sets.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 8329,
  "size": 15374
} 
 | 
					
	{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Functor.Hom.Properties.Contra {o ℓ e} (C : Category o ℓ e) where
private
  module C = Category C
open import Level
open import Function.Equality renaming (id to idFun)
open import Categories.Category.Instance.Setoids
open import Categories.Diagram.Limit
open import Categories.Diagram.Limit.Properties
open import Categories.Diagram.Colimit
open import Categories.Diagram.Duality
open import Categories.Functor
open import Categories.Functor.Hom
open import Categories.Functor.Hom.Properties.Covariant C.op
open import Categories.NaturalTransformation
open import Categories.NaturalTransformation.NaturalIsomorphism
private
  variable
    o′ ℓ′ e′ : Level
    J : Category o′ ℓ′ e′
open C
open Hom C
-- contravariant hom functor sends colimit of F to its limit.
module _ (W : Obj) {F : Functor J C} (col : Colimit F) where
  private
    module F = Functor F
    module J = Category J
    open HomReasoning
    HomF : Functor J.op (Setoids ℓ e)
    HomF = Hom[-, W ] ∘F F.op
  hom-colimit⇒limit : Limit HomF
  hom-colimit⇒limit = ≃-resp-lim (Hom≃ ⓘʳ F.op) (hom-resp-limit W (Colimit⇒coLimit _ col))
    where Hom≃ : Hom[ op ][ W ,-] ≃ Hom[-, W ]
          Hom≃ = record
            { F⇒G = ntHelper record
              { η       = λ _ → idFun
              ; commute = λ _ eq → C.∘-resp-≈ˡ (C.∘-resp-≈ʳ eq) ○ C.assoc
              }
            ; F⇐G = ntHelper record
              { η       = λ _ → idFun
              ; commute = λ _ eq → C.sym-assoc ○ C.∘-resp-≈ˡ (C.∘-resp-≈ʳ eq)
              }
            ; iso = λ _ → record
              { isoˡ = λ eq → eq
              ; isoʳ = λ eq → eq
              }
            }
 
 | 
	{
  "alphanum_fraction": 0.6139130435,
  "avg_line_length": 29.2372881356,
  "ext": "agda",
  "hexsha": "6cc4b3bda5ee77d26c79bf2ddbec3ca643f69ebe",
  "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/Functor/Hom/Properties/Contra.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/Functor/Hom/Properties/Contra.agda",
  "max_line_length": 90,
  "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/Functor/Hom/Properties/Contra.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": 528,
  "size": 1725
} 
 | 
					
	open import Type
module Graph.Walk.Functions.Proofs {ℓ₁ ℓ₂} {V : Type{ℓ₁}} where
import      Data.Either as Either
open import Data.Either.Proofs
open import Logic.Propositional
import      Lvl
open import Graph{ℓ₁}{ℓ₂}(V)
open import Graph.Properties
open import Graph.Walk{ℓ₁}{ℓ₂}{V}
open import Graph.Walk.Properties{ℓ₁}{ℓ₂}{V}
open import Graph.Walk.Functions{ℓ₁}{ℓ₂}{V}
open import Numeral.Natural
open import Numeral.Natural.Oper
open import Numeral.Natural.Oper.Proofs
open import Relator.Equals
open import Relator.Equals.Proofs
open import Structure.Relator.Properties
open import Syntax.Function
open import Type.Dependent
open import Type.Dependent.Functions
module _ (_⟶_ : Graph) where
  at-path-length : ∀{a} → length{_⟶_}(at{x = a}) ≡ 0
  at-path-length = reflexivity(_≡_)
  edge-path-length : ∀{a b}{e : a ⟶ b} → length{_⟶_}(edge e) ≡ 1
  edge-path-length = reflexivity(_≡_)
  join-path-length : ∀{a b c}{e₁ : a ⟶ b}{e₂ : b ⟶ c} → length{_⟶_}(join e₁ e₂) ≡ 2
  join-path-length = reflexivity(_≡_)
  prepend-path-length : ∀{a b c}{e : a ⟶ b}{w : Walk(_⟶_) b c} → length(prepend e w) ≡ 𝐒(length w)
  prepend-path-length {w = at}          = reflexivity(_≡_)
  prepend-path-length {w = prepend e w} = [≡]-with(𝐒) (prepend-path-length{e = e}{w = w})
  [++]-identityᵣ : ∀{a b}{w : Walk(_⟶_) a b} → (w ++ at ≡ w)
  [++]-identityᵣ {w = at}          = reflexivity(_≡_)
  [++]-identityᵣ {w = prepend x w} = [≡]-with(prepend x) ([++]-identityᵣ {w = w})
  {-# REWRITE [++]-identityᵣ #-}
  [++]-path-length : ∀{a b c}{w₁ : Walk(_⟶_) a b}{w₂ : Walk(_⟶_) b c} → length(w₁ ++ w₂) ≡ length w₁ + length w₂
  [++]-path-length {a} {.a} {.a} {at}            {at}          = reflexivity(_≡_)
  [++]-path-length {a} {.a} {c}  {at}            {prepend e w} = prepend-path-length {e = e}{w = w}
  [++]-path-length {a} {b}  {c}  {prepend e₁ w₁} {w₂}          = [≡]-with(𝐒) ([++]-path-length {w₁ = w₁}{w₂ = w₂})
  {-# REWRITE [++]-path-length #-}
  at-visits : ∀{v} → Visits(_⟶_) v (at{x = v})
  at-visits = current
  edge-visits-left : ∀{a b}{e : a ⟶ b} → Visits(_⟶_) a (edge e)
  edge-visits-left = current
  edge-visits-right : ∀{a b}{e : a ⟶ b} → Visits(_⟶_) b (edge e)
  edge-visits-right = skip current
  join-visits-1 : ∀{a b c}{e₁ : a ⟶ b}{e₂ : b ⟶ c} → Visits(_⟶_) a (join e₁ e₂)
  join-visits-1 = current
  join-visits-2 : ∀{a b c}{e₁ : a ⟶ b}{e₂ : b ⟶ c} → Visits(_⟶_) b (join e₁ e₂)
  join-visits-2 = skip current
  join-visits-3 : ∀{a b c}{e₁ : a ⟶ b}{e₂ : b ⟶ c} → Visits(_⟶_) c (join e₁ e₂)
  join-visits-3 = skip (skip current)
  prepend-visitsᵣ-left : ∀{a b c}{e : a ⟶ b}{w : Walk(_⟶_) b c} → Visits(_⟶_) a (prepend e w)
  prepend-visitsᵣ-left = current
  prepend-visitsᵣ-right : ∀{v b c}{w : Walk(_⟶_) b c} → Visits(_⟶_) v w → ∀{a}{e : a ⟶ b} → Visits(_⟶_) v (prepend e w)
  prepend-visitsᵣ-right p = skip p
  prepend-visitsₗ : ∀{v a b c}{e : a ⟶ b}{w : Walk(_⟶_) b c} → Visits(_⟶_) v (prepend e w) → ((v ≡ a) ∨ Visits(_⟶_) v w)
  prepend-visitsₗ current  = [∨]-introₗ(reflexivity(_≡_))
  prepend-visitsₗ (skip p) = [∨]-introᵣ p
  [++]-visitsᵣ : ∀{v a b c}{w₁ : Walk(_⟶_) a b}{w₂ : Walk(_⟶_) b c} → (Visits(_⟶_) v w₁) ∨ (Visits(_⟶_) v w₂) → Visits(_⟶_) v (w₁ ++ w₂)
  [++]-visitsᵣ ([∨]-introₗ current) = current
  [++]-visitsᵣ {w₂ = w₂} ([∨]-introₗ (skip {rest = rest} p)) = skip ([++]-visitsᵣ {w₁ = rest}{w₂ = w₂} ([∨]-introₗ p))
  [++]-visitsᵣ {w₁ = at} ([∨]-introᵣ p) = p
  [++]-visitsᵣ {w₁ = prepend x w₁} {w₂ = w₂} ([∨]-introᵣ p) = skip ([++]-visitsᵣ {w₁ = w₁}{w₂ = w₂} ([∨]-introᵣ p))
  [++]-visitsₗ : ∀{v a b c}{w₁ : Walk(_⟶_) a b}{w₂ : Walk(_⟶_) b c} → (Visits(_⟶_) v w₁) ∨ (Visits(_⟶_) v w₂) ← Visits(_⟶_) v (w₁ ++ w₂)
  [++]-visitsₗ {v} {a} {.a} {.a} {at}           {at}            p = [∨]-introₗ p
  [++]-visitsₗ {v} {a} {.a} {c}  {at}           {prepend x w₂}  p = [∨]-introᵣ p
  [++]-visitsₗ {v} {a} {b}  {c}  {prepend e w₁} {w₂}            p with prepend-visitsₗ p
  [++]-visitsₗ {v} {a} {b}  {c}  {prepend e w₁} {w₂}            p | [∨]-introₗ eq = [∨]-introₗ ([≡]-substitutionₗ eq (Visits.current {path = prepend e w₁}))
  [++]-visitsₗ {v} {a} {b}  {c}  {prepend e w₁} {w₂}            _ | [∨]-introᵣ p  = Either.mapLeft skip ([++]-visitsₗ {w₁ = w₁} {w₂ = w₂} p)
 
 | 
	{
  "alphanum_fraction": 0.556745182,
  "avg_line_length": 47.2247191011,
  "ext": "agda",
  "hexsha": "6c866e8121e01fc2a88d2bf508ace59b87d6c83c",
  "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": "Graph/Walk/Functions/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": "Graph/Walk/Functions/Proofs.agda",
  "max_line_length": 156,
  "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": "Graph/Walk/Functions/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": 1843,
  "size": 4203
} 
 | 
					
	
module BadTermination where
data N : Set where
  zero : N
  suc  : N -> N
postulate inf : N
data D : N -> Set where
  d₁ : D (suc inf)
  d₂ : D inf
f : (n : N) -> D n -> N
f .inf       d₂ = zero
f .(suc inf) d₁ = f inf d₂
 
 | 
	{
  "alphanum_fraction": 0.5307017544,
  "avg_line_length": 12.6666666667,
  "ext": "agda",
  "hexsha": "9856292fb9fe30d0f77e9ee85b30dde5db5ad876",
  "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/fail/BadTermination.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/fail/BadTermination.agda",
  "max_line_length": 27,
  "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/fail/BadTermination.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 94,
  "size": 228
} 
 | 
					
	{-# OPTIONS --cumulativity #-}
postulate
  F : (X : Set) → X → Set
  X : Set₁
  a : X
  shouldfail : F _ a
 
 | 
	{
  "alphanum_fraction": 0.5277777778,
  "avg_line_length": 13.5,
  "ext": "agda",
  "hexsha": "32d62e9ff80b06ca7f2b8d865be0f8b328341a4a",
  "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/Cumulativity-bad-meta-solution.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/Cumulativity-bad-meta-solution.agda",
  "max_line_length": 30,
  "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/Cumulativity-bad-meta-solution.agda",
  "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
  "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
  "num_tokens": 42,
  "size": 108
} 
 | 
					
	{-# OPTIONS --without-K #-}
open import M-types.Base
module M-types.Coalg.Core (A : Ty ℓ) (B : A → Ty ℓ) where
    P : Ty ℓ → Ty ℓ
    P X = ∑[ a ∈ A ] (B a → X)
    P-Fun : {X Y : Ty ℓ} →
        (X → Y) → (P X → P Y)
    P-Fun f = λ (a , d) → (a , f ∘ d)
    P-SpanRel : {X : Ty ℓ} →
        SpanRel X → SpanRel (P X)
    P-SpanRel {X} ∼ = (P (ty ∼) , P-Fun (ρ₀ ∼) , P-Fun (ρ₁ ∼))
    P-SpanRelMor : {X : Ty ℓ} {∼ ≈ : SpanRel X} →
        SpanRelMor ∼ ≈ → SpanRelMor (P-SpanRel ∼) (P-SpanRel ≈)
    P-SpanRelMor {X} {∼} {≈} f =
        (
            P-Fun (fun f) ,
            ap P-Fun (com₀ f) ,
            ap P-Fun (com₁ f)
        )
    P-DepRel : {X : Ty ℓ} →
        DepRel X → DepRel (P X)
    P-DepRel {X} ∼ = λ (a₀ , d₀) → λ (a₁ , d₁) →
        ∑[ p ∈ a₀ ≡ a₁ ] ∏[ b₀ ∈ B a₀ ]
        d₀ b₀ [ ∼ ] d₁ (tra B p b₀)
    P-DepRelMor : {X : Ty ℓ} {∼ ≈ : DepRel X} →
        DepRelMor ∼ ≈ → DepRelMor (P-DepRel ∼) (P-DepRel ≈)
    P-DepRelMor {X} {∼} {≈} f = λ (a₀ , d₀) → λ (a₁ , d₁) → λ (p , e) → (
            p ,
            λ b₀ → f (d₀ b₀) (d₁ (tra B p b₀)) (e b₀)
        )
    Coalg : Ty (ℓ-suc ℓ)
    Coalg = ∑[ ty ∈ Ty ℓ ] (ty → P ty)
    obs = pr₁
    P-Coalg : Coalg → Coalg
    P-Coalg X = (P (ty X) , P-Fun (obs X))
    CoalgMor :  Coalg → Coalg → Ty ℓ
    CoalgMor X Y =
        ∑[ fun ∈ (ty X → ty Y) ]
        obs Y ∘ fun ≡ P-Fun fun ∘ obs X
    com = pr₁
    P-CoalgMor : {X Y : Coalg} →
        CoalgMor X Y → CoalgMor (P-Coalg X) (P-Coalg Y)
    P-CoalgMor {X} {Y} f =
        (
            P-Fun (fun f) ,
            ap P-Fun (com f)
        )
 
 | 
	{
  "alphanum_fraction": 0.4028912634,
  "avg_line_length": 23.7462686567,
  "ext": "agda",
  "hexsha": "810375da88d8af6923783f2f70b8bd13154f84d3",
  "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": "Coalg/Core.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": "Coalg/Core.agda",
  "max_line_length": 73,
  "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": "Coalg/Core.agda",
  "max_stars_repo_stars_event_max_datetime": null,
  "max_stars_repo_stars_event_min_datetime": null,
  "num_tokens": 715,
  "size": 1591
} 
 | 
					
			Subsets and Splits
				
	
				
			
				
No community queries yet
The top public SQL queries from the community will appear here once available.