hexsha
stringlengths
40
40
size
int64
3
1.05M
ext
stringclasses
163 values
lang
stringclasses
53 values
max_stars_repo_path
stringlengths
3
945
max_stars_repo_name
stringlengths
4
112
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
945
max_issues_repo_name
stringlengths
4
113
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
116k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
945
max_forks_repo_name
stringlengths
4
113
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
3
1.05M
avg_line_length
float64
1
966k
max_line_length
int64
1
977k
alphanum_fraction
float64
0
1
8b198d221fd572fb9b871df00d9010a02161d6ef
193
agda
Agda
Cubical/Data/Vec.agda
ryanorendorff/cubical
c67854d2e11aafa5677e25a09087e176fafd3e43
[ "MIT" ]
1
2020-03-23T23:52:11.000Z
2020-03-23T23:52:11.000Z
Cubical/Data/Vec.agda
ryanorendorff/cubical
c67854d2e11aafa5677e25a09087e176fafd3e43
[ "MIT" ]
null
null
null
Cubical/Data/Vec.agda
ryanorendorff/cubical
c67854d2e11aafa5677e25a09087e176fafd3e43
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Vec where open import Cubical.Data.Vec.Base public open import Cubical.Data.Vec.Properties public open import Cubical.Data.Vec.NAry public
27.571429
46
0.782383
8b2856ccb64254a925ec05178a01abc5d4e8045a
1,988
agda
Agda
test/Succeed/RecursiveInstanceSearchLevel.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/RecursiveInstanceSearchLevel.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/RecursiveInstanceSearchLevel.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --overlapping-instances #-} module Succeed.RecursiveInstanceSearchLevel where open import Common.Prelude open import Common.Product open import Common.Equality -- Definition of truncation levels. We wrap the definition into a datatype in -- order to be able to use instance search. data has-level (n : Nat) (A : Set) : Set has-level' : (n : Nat) (A : Set) → Set data has-level n A where c : has-level' n A → has-level n A has-level' zero A = Σ A (λ a → (b : A) → a ≡ b) has-level' (suc n) A = (a b : A) → has-level n (a ≡ b) -- This one should not be declared as eligible by instance search or else we -- will get unsolvable loops postulate higher-level : {n : Nat} {A : Set} {{_ : has-level n A}} → has-level (suc n) A postulate Trunc : Nat → Set → Set instance =-level : {n : Nat} {A : Set} {{_ : has-level (suc n) A}} {a b : A} → has-level n (a ≡ b) =-level {{c f}} = f _ _ postulate =-level-same : {n : Nat} {A : Set} {{_ : has-level n A}} {a b : A} → has-level n (a ≡ b) postulate Nat-level : has-level 2 Nat Π-level : {n : Nat} {A : Set} {B : A → Set} {{_ : {a : A} → has-level n (B a)}} → has-level n ((a : A) → B a) Πimp-level : {n : Nat} {A : Set} {B : A → Set} {{_ : {a : A} → has-level n (B a)}} → has-level n ({a : A} → B a) Σ-level : {n : Nat} {A : Set} {B : A → Set} {{_ : has-level n A}} {{_ : {a : A} → has-level n (B a)}} → has-level n (Σ A B) Trunc-level : {n : Nat} {A : Set} → has-level n (Trunc n A) -- Used to check, using instance search, if some type has a given level postulate check-level : (n : Nat) (A : Set) {{_ : has-level n A}} → Set test₁ : (A : Set) → Set test₁ A = check-level 1 ((a b : Trunc 2 A) → (a , (b , 3)) ≡ (b , (a , 4))) test₂ : (A : Set) → Set test₂ A = check-level 2 ((a b : Trunc 2 A) → (a , (b , 3)) ≡ (b , (a , 4))) -- -- To be fixed -- test₃ : {n : Nat} {A : Set} {B : A → Set} {_ : {a : A} → has-level n (B a)} → Nat → has-level n ((a : A) → B a) -- test₃ r = Π-level ⟨⟩
36.145455
127
0.55332
5e57ab1dfa0c39d8f88f8470b98336e7dfb68764
3,262
agda
Agda
RefactorAgdaEngine/ScopeParseTree.agda
omega12345/RefactorAgda
52d1034aed14c578c9e077fb60c3db1d0791416b
[ "BSD-3-Clause" ]
5
2019-01-31T14:10:18.000Z
2019-05-03T10:03:36.000Z
RefactorAgdaEngine/ScopeParseTree.agda
omega12345/RefactorAgda
52d1034aed14c578c9e077fb60c3db1d0791416b
[ "BSD-3-Clause" ]
3
2019-01-31T08:03:07.000Z
2019-02-05T12:53:36.000Z
RefactorAgdaEngine/ScopeParseTree.agda
omega12345/RefactorAgda
52d1034aed14c578c9e077fb60c3db1d0791416b
[ "BSD-3-Clause" ]
1
2019-01-31T08:40:41.000Z
2019-01-31T08:40:41.000Z
-- This module is responsible for adding the missing scope information to the parse tree. module ScopeParseTree where open import ParseTree open import Data.Empty open import ScopeState open import Data.List hiding (_++_) open import Data.Product hiding (map) open import Data.Fin open import Data.Nat open import Data.Sum open import Data.String open import Data.Bool open import AgdaHelperFunctions scopeSignature : TypeSignature -> ScopeType -> ScopeState TypeSignature scopeExpr : Expr -> ScopeState Expr scopeExpr (ident identifier₁) = do -- first try to find identifier among already declared (simplification for constructor), then assume new declaration (simplification for parameter or out-of-file declaration) inj₂ r <- try $ fillInIdentifier identifier₁ where _ -> do x <- addIdentifier identifier₁ return $ ident x return $ ident r scopeExpr (functionApp e e₁ {b} ) = do r1 <- scopeExpr e r2 <- scopeExpr e₁ return $ functionApp r1 r2 {b} scopeExpr (namedArgument arg {b} {bef} {aft}) = do x <- scopeSignature arg addVariableToType return $ namedArgument x {b}{bef}{aft} scopeExpr x = return x scopeSignature (typeSignature funcName funcType) scopeT = do newType <- saveAndReturnToScope $ scopeExpr funcType addScope scopeT newId <- addIdentifier funcName return $ typeSignature newId newType scopePragma : Pragma -> ScopeState Pragma scopePragma (builtin concept definition) = do x <- fillInIdentifier definition return $ builtin concept x scopePragma x = return x scopeParseTree : ParseTree -> ScopeState ParseTree scopeParseTree (signature signature₁ range₁) = do x <- scopeSignature signature₁ addFuncToModule return $ signature x range₁ scopeParseTree (functionDefinition definitionOf params body range₁) = do newId <- fillInIdentifier definitionOf x <- saveAndReturnToScope $ do addScope funcDef newParams <- mapState scopeExpr params newBody <- scopeExpr body return $ functionDefinition newId newParams newBody range₁ return x scopeParseTree (dataStructure dataName parameters indexInfo constructors range₁ {comments}) = do addScope $ moduleDef dataName newDataName <- addIdentifier dataName ( newParams , newIndex) , newCons <- saveAndReturnToScope $ do newParams <- mapState (λ x -> scopeSignature x addVariableToType) parameters newIndex <- scopeExpr indexInfo newCons <- mapState (λ x -> scopeSignature x addFuncToModule) constructors return ((newParams , newIndex) , newCons) r <- mapState addContentReferenceToModuleTop newCons return $ dataStructure newDataName newParams newIndex newCons range₁ {comments} scopeParseTree (moduleName moduleName₁ range₁) = do newMod <- addIdentifier moduleName₁ addScope $ moduleDef moduleName₁ return $ moduleName newMod range₁ scopeParseTree (pragma pragma₁ range₁) = do x <- scopePragma pragma₁ return $ pragma x range₁ scopeParseTree x = return x scopeParseTreeList : List ParseTree -> ScopeState (List ParseTree) scopeParseTreeList program = do --TODO: fix sloppy workaround put newEnv addIdentifier (identifier "Set" (λ _ -> before) 0 0 {true}{[]} {[]}) mapState scopeParseTree program
38.833333
176
0.746781
03167be9218af16266d35623bb626ad36ff5c0c1
3,137
agda
Agda
theorems/cohomology/InverseInSusp.agda
timjb/HoTT-Agda
66f800adef943afdf08c17b8ecfba67340fead5e
[ "MIT" ]
null
null
null
theorems/cohomology/InverseInSusp.agda
timjb/HoTT-Agda
66f800adef943afdf08c17b8ecfba67340fead5e
[ "MIT" ]
null
null
null
theorems/cohomology/InverseInSusp.agda
timjb/HoTT-Agda
66f800adef943afdf08c17b8ecfba67340fead5e
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import groups.ProductRepr open import cohomology.Theory open import homotopy.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.Wedge CT n private module Subtract = SuspRec {C = de⊙ (⊙Susp X ⊙∨ ⊙Susp X)} (winl south) (winr south) (λ x → ap winl (! (merid x)) ∙ wglue ∙ ap winr (merid x)) subtract = Subtract.f ⊙subtract : ⊙Susp X ⊙→ ⊙Susp X ⊙∨ ⊙Susp X ⊙subtract = (subtract , ! (ap winl (merid (pt X)))) projl-subtract : ∀ σ → projl (subtract σ) == Susp-flip σ projl-subtract = Susp-elim idp idp $ ↓-='-from-square ∘ vert-degen-square ∘ λ x → ap-∘ projl subtract (merid x) ∙ ap (ap projl) (Subtract.merid-β 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 _ ∙ ! (SuspFlip.merid-β x) projr-subtract : ∀ σ → projr (subtract σ) == σ projr-subtract = Susp-elim idp idp $ ↓-∘=idf-in' projr subtract ∘ λ x → ap (ap projr) (Subtract.merid-β 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 = Susp-elim idp idp $ ↓-app=cst-in ∘ ! ∘ λ x → ∙-unit-r _ ∙ ap-∘ fold subtract (merid x) ∙ ap (ap fold) (Subtract.merid-β 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) abstract cancel : ∀ x → GroupHom.f (×ᴳ-fanin (C-is-abelian n _) (C-fmap n (⊙Susp-flip X)) (idhom _)) (x , x) == Cident n (⊙Susp X) cancel x = ap2 (Group.comp (C n (⊙Susp X))) (! (CEl-fmap-base-indep n projl-subtract x)) (! (CEl-fmap-idf n x) ∙ ! (CEl-fmap-base-indep n projr-subtract x)) ∙ (C-Wedge-in-comm-sqr' (⊙Susp X) (⊙Susp X) ⊙subtract □$ᴳ (x , x)) ∙ ap (CEl-fmap n ⊙subtract) ( ap (GroupIso.g (C-Wedge (⊙Susp X) (⊙Susp X)) ∘ diag) (! (CEl-fmap-idf n x)) ∙ (C-Wedge-rec-comm-sqr' (⊙Susp X) (⊙Susp X) (⊙idf _) (⊙idf _) □$ᴳ x)) ∙ ∘-CEl-fmap n ⊙subtract ⊙fold x ∙ CEl-fmap-base-indep n (λ σ → fold-subtract σ ∙ ! (merid (pt X))) x ∙ CEl-fmap-cst n x abstract C-Susp-flip-is-inv : ∀ x → CEl-fmap n (⊙Susp-flip X) x == Group.inv (C n (⊙Susp X)) x C-Susp-flip-is-inv x = ! (Group.inv-unique-l (C n (⊙Susp X)) _ x (cancel x))
36.905882
92
0.541919
5e6a9bd40a1ce226c9bd9e75a4189df01b684f53
1,341
agda
Agda
examples/outdated-and-incorrect/AIM6/Cat/Category.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
examples/outdated-and-incorrect/AIM6/Cat/Category.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
examples/outdated-and-incorrect/AIM6/Cat/Category.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Category where open import Logic.Equivalence open import Logic.Relations open Equivalence using () renaming (_==_ to eq) record Cat : Set2 where field Obj : Set1 _─→_ : Obj -> Obj -> Set id : {A : Obj} -> A ─→ A _∘_ : {A B C : Obj} -> B ─→ C -> A ─→ B -> A ─→ C Eq : {A B : Obj} -> Equivalence (A ─→ B) cong : {A B C : Obj}{f₁ f₂ : B ─→ C}{g₁ g₂ : A ─→ B} -> eq Eq f₁ f₂ -> eq Eq g₁ g₂ -> eq Eq (f₁ ∘ g₁) (f₂ ∘ g₂) idLeft : {A B : Obj}{f : A ─→ B} -> eq Eq (id ∘ f) f idRight : {A B : Obj}{f : A ─→ B} -> eq Eq (f ∘ id) f assoc : {A B C D : Obj}{f : C ─→ D}{g : B ─→ C}{h : A ─→ B} -> eq Eq ((f ∘ g) ∘ h) (f ∘ (g ∘ h)) module Category (ℂ : Cat) where private module CC = Cat ℂ open CC public hiding (_─→_; _∘_) private module Eq {A B : Obj} = Equivalence (Eq {A}{B}) open Eq public hiding (_==_) infix 20 _==_ infixr 30 _─→_ infixr 90 _∘_ _─→_ = CC._─→_ _==_ : {A B : Obj} -> Rel (A ─→ B) _==_ = Eq._==_ _∘_ : {A B C : Obj} -> B ─→ C -> A ─→ B -> A ─→ C _∘_ = CC._∘_ congL : {A B C : Obj}{f₁ f₂ : B ─→ C}{g : A ─→ B} -> f₁ == f₂ -> f₁ ∘ g == f₂ ∘ g congL p = cong p refl congR : {A B C : Obj}{f : B ─→ C}{g₁ g₂ : A ─→ B} -> g₁ == g₂ -> f ∘ g₁ == f ∘ g₂ congR p = cong refl p
26.82
69
0.442953
d192851248f0d4bb7c3d73b5d4a4a810c6a66789
2,498
agda
Agda
Cubical/HITs/Rationals/QuoQ/Base.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
null
null
null
Cubical/HITs/Rationals/QuoQ/Base.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
null
null
null
Cubical/HITs/Rationals/QuoQ/Base.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
1
2021-11-22T02:02:01.000Z
2021-11-22T02:02:01.000Z
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Rationals.QuoQ.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Data.Nat as ℕ using (discreteℕ) open import Cubical.Data.NatPlusOne open import Cubical.Data.Sigma open import Cubical.HITs.Ints.QuoInt open import Cubical.HITs.SetQuotients as SetQuotient using ([_]; eq/; discreteSetQuotients) renaming (_/_ to _//_) public open import Cubical.Relation.Nullary open import Cubical.Relation.Binary.Base open BinaryRelation ℕ₊₁→ℤ : ℕ₊₁ → ℤ ℕ₊₁→ℤ n = pos (ℕ₊₁→ℕ n) private ℕ₊₁→ℤ-hom : ∀ m n → ℕ₊₁→ℤ (m *₊₁ n) ≡ ℕ₊₁→ℤ m * ℕ₊₁→ℤ n ℕ₊₁→ℤ-hom _ _ = refl -- ℚ as a set quotient of ℤ × ℕ₊₁ (as in the HoTT book) _∼_ : ℤ × ℕ₊₁ → ℤ × ℕ₊₁ → Type₀ (a , b) ∼ (c , d) = a * ℕ₊₁→ℤ d ≡ c * ℕ₊₁→ℤ b ℚ : Type₀ ℚ = (ℤ × ℕ₊₁) // _∼_ isSetℚ : isSet ℚ isSetℚ = SetQuotient.squash/ [_/_] : ℤ → ℕ₊₁ → ℚ [ a / b ] = [ a , b ] isEquivRel∼ : isEquivRel _∼_ isEquivRel.reflexive isEquivRel∼ (a , b) = refl isEquivRel.symmetric isEquivRel∼ (a , b) (c , d) = sym isEquivRel.transitive isEquivRel∼ (a , b) (c , d) (e , f) p q = *-injʳ _ _ _ r where r = (a * ℕ₊₁→ℤ f) * ℕ₊₁→ℤ d ≡[ i ]⟨ *-comm a (ℕ₊₁→ℤ f) i * ℕ₊₁→ℤ d ⟩ (ℕ₊₁→ℤ f * a) * ℕ₊₁→ℤ d ≡⟨ sym (*-assoc (ℕ₊₁→ℤ f) a (ℕ₊₁→ℤ d)) ⟩ ℕ₊₁→ℤ f * (a * ℕ₊₁→ℤ d) ≡[ i ]⟨ ℕ₊₁→ℤ f * p i ⟩ ℕ₊₁→ℤ f * (c * ℕ₊₁→ℤ b) ≡⟨ *-assoc (ℕ₊₁→ℤ f) c (ℕ₊₁→ℤ b) ⟩ (ℕ₊₁→ℤ f * c) * ℕ₊₁→ℤ b ≡[ i ]⟨ *-comm (ℕ₊₁→ℤ f) c i * ℕ₊₁→ℤ b ⟩ (c * ℕ₊₁→ℤ f) * ℕ₊₁→ℤ b ≡[ i ]⟨ q i * ℕ₊₁→ℤ b ⟩ (e * ℕ₊₁→ℤ d) * ℕ₊₁→ℤ b ≡⟨ sym (*-assoc e (ℕ₊₁→ℤ d) (ℕ₊₁→ℤ b)) ⟩ e * (ℕ₊₁→ℤ d * ℕ₊₁→ℤ b) ≡[ i ]⟨ e * *-comm (ℕ₊₁→ℤ d) (ℕ₊₁→ℤ b) i ⟩ e * (ℕ₊₁→ℤ b * ℕ₊₁→ℤ d) ≡⟨ *-assoc e (ℕ₊₁→ℤ b) (ℕ₊₁→ℤ d) ⟩ (e * ℕ₊₁→ℤ b) * ℕ₊₁→ℤ d ∎ eq/⁻¹ : ∀ x y → Path ℚ [ x ] [ y ] → x ∼ y eq/⁻¹ = SetQuotient.effective (λ _ _ → isSetℤ _ _) isEquivRel∼ discreteℚ : Discrete ℚ discreteℚ = discreteSetQuotients (discreteΣ discreteℤ (λ _ → subst Discrete 1+Path discreteℕ)) (λ _ _ → isSetℤ _ _) isEquivRel∼ (λ _ _ → discreteℤ _ _) -- 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 ] } instance fromNegℚ : HasFromNeg ℚ fromNegℚ = record { Constraint = λ _ → Unit ; fromNeg = λ n → [ neg n / 1 ] }
32.441558
94
0.556045
d0401870df08f3145c2eb030684910a104de0455
633
agda
Agda
test/Compiler/simple/VecReverseIrr.agda
pthariensflame/agda
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
[ "BSD-3-Clause" ]
4
2017-02-24T16:53:22.000Z
2019-12-23T04:56:23.000Z
test/Compiler/simple/VecReverseIrr.agda
Blaisorblade/Agda
802a28aa8374f15fe9d011ceb80317fdb1ec0949
[ "BSD-3-Clause" ]
6
2017-02-24T19:27:31.000Z
2017-02-24T19:38:17.000Z
test/Compiler/simple/VecReverseIrr.agda
Blaisorblade/Agda
802a28aa8374f15fe9d011ceb80317fdb1ec0949
[ "BSD-3-Clause" ]
1
2022-03-12T11:39:14.000Z
2022-03-12T11:39:14.000Z
module _ where open import Common.Prelude data Vec (A : Set) : Nat → Set where [] : Vec A 0 _∷_ : ∀ ..{n} → A → Vec A n → Vec A (suc n) sum : ∀ {n} → Vec Nat n → Nat sum (x ∷ xs) = x + sum xs sum [] = 0 foldl : ∀ {A} {B : Nat → Set} → (∀ ..{n} → B n → A → B (suc n)) → B 0 → ∀ ..{n} → Vec A n → B n foldl {B = B} f z (x ∷ xs) = foldl {B = λ n → B (suc n)} f (f z x) xs foldl f z [] = z reverse : ∀ {A} ..{n} → Vec A n → Vec A n reverse = foldl {B = Vec _} (λ xs x → x ∷ xs) [] downFrom : ∀ n → Vec Nat n downFrom zero = [] downFrom (suc n) = n ∷ downFrom n main : IO Unit main = printNat (sum (reverse (downFrom 100000)))
24.346154
95
0.503949
2e7461e02d1eeda7242ed10c4f36acf7656f25f4
19
agda
Agda
test/Fail/A/B/M.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/A/B/M.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/A/B/M.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module A.B.M where
9.5
18
0.736842
a0e7c5927d0124eaf8be15534e6d029c252daf6d
5,138
agda
Agda
Data/Bin/Addition.agda
Rotsor/BinDivMod
09cc5104421e88da82f9fead5a43f0028f77810d
[ "Unlicense" ]
1
2019-11-18T13:58:14.000Z
2019-11-18T13:58:14.000Z
Data/Bin/Addition.agda
Rotsor/BinDivMod
09cc5104421e88da82f9fead5a43f0028f77810d
[ "Unlicense" ]
null
null
null
Data/Bin/Addition.agda
Rotsor/BinDivMod
09cc5104421e88da82f9fead5a43f0028f77810d
[ "Unlicense" ]
null
null
null
module Data.Bin.Addition where open import Data.List using ([]; _∷_) open import Data.Bin using(addBits; addBitLists; addCarryToBitList) open import Relation.Binary.PropositionalEquality private module PropEq = Relation.Binary.PropositionalEquality open import Data.Fin using (zero; suc) renaming (toℕ to bitToℕ; _+_ to _+F_) open import Data.Fin.Properties using (_+′_) open import Data.Digit using (fromDigits) open import Data.Product import Data.Nat.Properties open import Data.Bin.Bijection using (fromℕ-bijection) module Solving where open Relation.Binary.PropositionalEquality open ≡-Reasoning open import Algebra -- open Algebra.Structures open CommutativeSemiring Data.Nat.Properties.commutativeSemiring hiding (sym; refl) open Data.Product open Data.Nat.Properties.SemiringSolver lem : ∀ {a b c as bs b' c' r} → c' * 2 + b' ≡ c + a + b → r ≡ c' + (as + bs) → b' + r * 2 ≡ c + (a + as * 2 + (b + bs * 2)) lem {a} {b} {c} {as} {bs} {b'} {c'} {r} eq1 eq2 = begin b' + r * 2 ≡⟨ cong (λ x → b' + x * 2) eq2 ⟩ b' + (c' + (as + bs)) * 2 ≡⟨ cong (λ x → b' + x) (proj₂ distrib 2 c' (as + bs)) ⟩ b' + (c' * 2 + (as + bs) * 2) ≡⟨ sym (+-assoc b' (c' * 2) ((as + bs) * 2)) ⟩ b' + c' * 2 + (as + bs) * 2 ≡⟨ +-cong (+-comm b' (c' * 2)) refl ⟩ c' * 2 + b' + (as + bs) * 2 ≡⟨ +-cong eq1 refl ⟩ c + a + b + (as + bs) * 2 ≡⟨ solve 5 (λ a b c as bs → c :+ a :+ b :+ (as :+ bs) :* con 2 := c :+ (a :+ as :* con 2 :+ (b :+ bs :* con 2)) ) refl a b c as bs ⟩ c + (a + as * 2 + (b + bs * 2)) ∎ open import Data.Nat using () renaming (_+_ to _+_; _*_ to _*_) open Data.Bin using (toℕ; toBits) addBits-is-addition : ∀ {c a b} → bitToℕ (proj₁ (addBits c a b)) * 2 + bitToℕ (proj₂ (addBits c a b)) ≡ bitToℕ c + bitToℕ a + bitToℕ b -- Brute force!!! (LOL) addBits-is-addition {zero} {zero} {zero} = refl addBits-is-addition {zero} {zero} {suc zero} = refl addBits-is-addition {zero} {suc zero} {zero} = refl addBits-is-addition {zero} {suc zero} {suc zero} = refl addBits-is-addition {suc zero} {zero} {zero} = refl addBits-is-addition {suc zero} {zero} {suc zero} = refl addBits-is-addition {suc zero} {suc zero} {zero} = refl addBits-is-addition {suc zero} {suc zero} {suc zero} = refl addBits-is-addition {suc (suc ())} addBits-is-addition {_} {suc (suc ())} addBits-is-addition {_} {_} {suc (suc ())} addCarryToBitLists-is-addition : ∀ c b → fromDigits (addCarryToBitList c b) ≡ bitToℕ c + fromDigits b addCarryToBitLists-is-addition zero _ = refl addCarryToBitLists-is-addition (suc zero) [] = refl addCarryToBitLists-is-addition (suc zero) (zero ∷ t) = refl addCarryToBitLists-is-addition (suc zero) (suc zero ∷ t) = cong (λ x → x * 2) (addCarryToBitLists-is-addition (suc zero) t) addCarryToBitLists-is-addition (suc (suc ())) _ addCarryToBitLists-is-addition _ ((suc (suc ())) ∷ _) open import Data.Nat.Properties using (isCommutativeSemiring) open import Algebra.Structures using (module IsCommutativeSemiring; module IsCommutativeMonoid) open IsCommutativeSemiring isCommutativeSemiring using (+-isCommutativeMonoid) open IsCommutativeMonoid +-isCommutativeMonoid using (identity; comm) renaming (∙-cong to +-cong) addBitLists-is-addition : ∀ c a b → fromDigits (addBitLists c a b) ≡ bitToℕ c + (fromDigits a + fromDigits b) addBitLists-is-addition c [] b = addCarryToBitLists-is-addition c b addBitLists-is-addition c (a ∷ as) [] = trans (addCarryToBitLists-is-addition c (a ∷ as)) (+-cong {bitToℕ c} refl (sym (proj₂ identity (fromDigits (a ∷ as))))) addBitLists-is-addition c (a ∷ as) (b ∷ bs) with addBits c a b | addBits-is-addition {c} {a} {b} ... | (c' , b') | abia with addBitLists c' as bs | addBitLists-is-addition c' as bs ... | r | ria = Solving.lem {bitToℕ a} {bitToℕ b} {bitToℕ c} {fromDigits as} {fromDigits bs} {bitToℕ b'} {bitToℕ c'} abia ria open import Function.Inverse using (Inverse) open import Function.Equality open import Data.Bin.BitListBijection using () renaming (toℕ⟶ to bits-to-ℕ) open import Data.Bin.Bijection using (Bits-inverse-Bin) simplify-fromBits-to-ℕ : ∀ a → toℕ (Data.Bin.fromBits a) ≡ bits-to-ℕ ⟨$⟩ a simplify-fromBits-to-ℕ a = Π.cong bits-to-ℕ (Inverse.left-inverse-of Bits-inverse-Bin a ) +-is-addition : ∀ a b → toℕ (Data.Bin._+_ a b) ≡ toℕ a + toℕ b +-is-addition a b = trans (simplify-fromBits-to-ℕ (addBitLists zero (toBits a) (toBits b))) (addBitLists-is-addition zero as bs) where as = toBits a bs = toBits b import Algebra.Lifting open import Data.Nat using (ℕ) open import Data.Bin using (Bin; 0#) open import Algebra.Structures using (IsCommutativeMonoid) private module Lifting = Algebra.Lifting _ _ fromℕ-bijection is-commutativeMonoid : IsCommutativeMonoid _≡_ Data.Bin._+_ 0# is-commutativeMonoid = lift-isCommutativeMonoid 0 +-isCommutativeMonoid where open Lifting.WithOp₂ _+_ Data.Bin._+_ +-is-addition
42.816667
161
0.63332
ad19a78ee4ad7ac71d0007a566c462fd7ea198c5
2,145
agda
Agda
lib/Haskell/Prim/Applicative.agda
flupe/agda2hs
4cb28f1b5032948b19b977b390fa260be292abf6
[ "MIT" ]
null
null
null
lib/Haskell/Prim/Applicative.agda
flupe/agda2hs
4cb28f1b5032948b19b977b390fa260be292abf6
[ "MIT" ]
null
null
null
lib/Haskell/Prim/Applicative.agda
flupe/agda2hs
4cb28f1b5032948b19b977b390fa260be292abf6
[ "MIT" ]
null
null
null
module Haskell.Prim.Applicative where open import Haskell.Prim open import Haskell.Prim.Either open import Haskell.Prim.Foldable open import Haskell.Prim.Functor open import Haskell.Prim.List open import Haskell.Prim.Maybe open import Haskell.Prim.Monoid open import Haskell.Prim.Tuple -------------------------------------------------- -- Applicative record Applicative (f : Set → Set) : Set₁ where infixl 4 _<*>_ field pure : a → f a _<*>_ : f (a → b) → f a → f b overlap ⦃ super ⦄ : Functor f _<*_ : f a → f b → f a x <* y = const <$> x <*> y _*>_ : f a → f b → f b x *> y = const id <$> x <*> y open Applicative ⦃ ... ⦄ public instance iApplicativeList : Applicative List iApplicativeList .pure x = x ∷ [] iApplicativeList ._<*>_ fs xs = concatMap (λ f → map f xs) fs iApplicativeMaybe : Applicative Maybe iApplicativeMaybe .pure = Just iApplicativeMaybe ._<*>_ (Just f) (Just x) = Just (f x) iApplicativeMaybe ._<*>_ _ _ = Nothing iApplicativeEither : Applicative (Either a) iApplicativeEither .pure = Right iApplicativeEither ._<*>_ (Right f) (Right x) = Right (f x) iApplicativeEither ._<*>_ (Left e) _ = Left e iApplicativeEither ._<*>_ _ (Left e) = Left e iApplicativeFun : Applicative (λ b → a → b) iApplicativeFun .pure = const iApplicativeFun ._<*>_ f g x = f x (g x) iApplicativeTuple₂ : ⦃ Monoid a ⦄ → Applicative (a ×_) iApplicativeTuple₂ .pure x = mempty , x iApplicativeTuple₂ ._<*>_ (a , f) (b , x) = a <> b , f x iApplicativeTuple₃ : ⦃ Monoid a ⦄ → ⦃ Monoid b ⦄ → Applicative (a × b ×_) iApplicativeTuple₃ .pure x = mempty , mempty , x iApplicativeTuple₃ ._<*>_ (a , b , f) (a₁ , b₁ , x) = a <> a₁ , b <> b₁ , f x iApplicativeTuple₄ : ⦃ Monoid a ⦄ → ⦃ Monoid b ⦄ → ⦃ Monoid c ⦄ → Applicative (λ d → Tuple (a ∷ b ∷ c ∷ d ∷ [])) iApplicativeTuple₄ .pure x = mempty ∷ mempty ∷ mempty ∷ x ∷ [] iApplicativeTuple₄ ._<*>_ (a ∷ b ∷ c ∷ f ∷ []) (a₁ ∷ b₁ ∷ c₁ ∷ x ∷ []) = a <> a₁ ∷ b <> b₁ ∷ c <> c₁ ∷ f x ∷ []
33
89
0.567366
196f91f523777791d6f9b80cd5795a5397cd6a91
10,744
agda
Agda
src/Up-to/Closure.agda
nad/up-to
b936ff85411baf3401ad85ce85d5ff2e9aa0ca14
[ "MIT" ]
null
null
null
src/Up-to/Closure.agda
nad/up-to
b936ff85411baf3401ad85ce85d5ff2e9aa0ca14
[ "MIT" ]
null
null
null
src/Up-to/Closure.agda
nad/up-to
b936ff85411baf3401ad85ce85d5ff2e9aa0ca14
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- Closure properties for Compatible and Size-preserving ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} module Up-to.Closure where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude as P open import Prelude.Size open import Bijection equality-with-J using (_↔_) open import Function-universe equality-with-J hiding (id; _∘_) import Bisimilarity open import Indexed-container hiding (Bisimilarity) open import Indexed-container.Combinators hiding (id; _∘_) open import Labelled-transition-system import Labelled-transition-system.CCS open import Relation import Similarity import Similarity.CCS as SC open import Up-to private module CCS {ℓ} (Name : Type ℓ) where open Labelled-transition-system.CCS Name public open module B = Bisimilarity CCS public open module S = Similarity CCS public using (Similarity) ------------------------------------------------------------------------ -- Closure properties for Compatible -- The results in this section are closely related to -- Proposition 6.3.21 in Pous and Sangiorgi's "Enhancements of the -- bisimulation proof method". -- The function flip Compatible F is closed under _⊗_, assuming that F -- is monotone. Compatible-⊗ : ∀ {ℓ} {I : Type ℓ} {C₁ C₂ : Container I I} {F : Trans ℓ I} → Monotone F → Compatible C₁ F → Compatible C₂ F → Compatible (C₁ ⊗ C₂) F Compatible-⊗ {C₁ = C₁} {C₂} {F} mono comp₁ comp₂ {R = R} = F (⟦ C₁ ⊗ C₂ ⟧ R) ⊆⟨ mono (⟦⊗⟧↔ _ C₁ C₂) ⟩ F (⟦ C₁ ⟧ R ∩ ⟦ C₂ ⟧ R) ⊆⟨ (λ x → mono proj₁ x , mono proj₂ x) ⟩ F (⟦ C₁ ⟧ R) ∩ F (⟦ C₂ ⟧ R) ⊆⟨ Σ-map comp₁ comp₂ ⟩ ⟦ C₁ ⟧ (F R) ∩ ⟦ C₂ ⟧ (F R) ⊆⟨ _⇔_.from (⟦⊗⟧↔ _ C₁ C₂) ⟩∎ ⟦ C₁ ⊗ C₂ ⟧ (F R) ∎ -- The function flip Compatible F is closed under reindex₁ f, assuming -- that F is monotone and f-symmetric. Compatible-reindex₁ : ∀ {ℓ} {I : Type ℓ} {C : Container I I} {F : Trans ℓ I} {f : I → I} → Monotone F → Symmetric f F → Compatible C F → Compatible (reindex₁ f C) F Compatible-reindex₁ {C = C} {F} {f} mono hyp comp {R = R} = F (⟦ reindex₁ f C ⟧ R) ⊆⟨ mono (⟦reindex₁⟧↔ _ C) ⟩ F (⟦ C ⟧ (R ∘ f)) ⊆⟨ comp ⟩ ⟦ C ⟧ (F (R ∘ f)) ⊆⟨ map C (hyp _) ⟩ ⟦ C ⟧ (F R ∘ f) ⊆⟨ _⇔_.from (⟦reindex₁⟧↔ _ C) ⟩∎ ⟦ reindex₁ f C ⟧ (F R) ∎ -- The function flip Compatible F is closed under reindex₂ f, assuming -- that F is f-symmetric. Compatible-reindex₂ : ∀ {ℓ} {I : Type ℓ} {C : Container I I} {F : Trans ℓ I} {f : I → I} → Symmetric f F → Compatible C F → Compatible (reindex₂ f C) F Compatible-reindex₂ {C = C} {F} {f} hyp comp {R = R} = F (⟦ reindex₂ f C ⟧ R) ⊆⟨⟩ F (⟦ C ⟧ R ∘ f) ⊆⟨ hyp _ ⟩ F (⟦ C ⟧ R) ∘ f ⊆⟨ comp ⟩ ⟦ C ⟧ (F R) ∘ f ⊆⟨ id ⟩∎ ⟦ reindex₂ f C ⟧ (F R) ∎ -- The function flip Compatible F is closed under reindex f, assuming -- that F is monotone and f-symmetric. Compatible-reindex : ∀ {ℓ} {I : Type ℓ} {C : Container I I} {F : Trans ℓ I} {f : I → I} → Monotone F → Symmetric f F → Compatible C F → Compatible (reindex f C) F Compatible-reindex {C = C} {F} {f} mono hyp = Compatible C F ↝⟨ Compatible-reindex₁ mono hyp ⟩ Compatible (reindex₁ f C) F ↝⟨ Compatible-reindex₂ hyp ⟩ Compatible (reindex₂ f (reindex₁ f C)) F ↔⟨⟩ Compatible (reindex f C) F □ -- The function flip Compatible F is closed under _⟷_, assuming that F -- is monotone and symmetric. Compatible-⟷ : ∀ {ℓ} {I : Type ℓ} {C₁ C₂ : Container (I × I) (I × I)} {F : Trans₂ ℓ I} → Monotone F → Symmetric swap F → Compatible C₁ F → Compatible C₂ F → Compatible (C₁ ⟷ C₂) F Compatible-⟷ {C₁ = C₁} {C₂} {F} mono sym = curry ( Compatible C₁ F × Compatible C₂ F ↝⟨ Σ-map id (Compatible-reindex mono sym) ⟩ Compatible C₁ F × Compatible (reindex swap C₂) F ↝⟨ uncurry (Compatible-⊗ mono) ⟩ Compatible (C₁ ⊗ reindex swap C₂) F ↔⟨⟩ Compatible (C₁ ⟷ C₂) F □) -- An instance of the result above: If F is monotone and symmetric, -- and compatible for strong similarity for some LTS, then F is -- compatible for strong bisimilarity for this LTS. compatible-for-similarity→compatible-for-bisimilarity : ∀ {ℓ} {lts : LTS ℓ} {F} → Monotone F → Symmetric swap F → Compatible (Similarity.StepC lts) F → Compatible (Bisimilarity.StepC lts) F compatible-for-similarity→compatible-for-bisimilarity mono sym comp = Compatible-⟷ mono sym comp comp ------------------------------------------------------------------------ -- Closure properties for Size-preserving -- The function flip Size-preserving F is closed under reindex, -- assuming that F is f-symmetric for an involutory function f. -- -- Note that the assumptions are different from the ones asked for in -- Compatible-reindex: monotonicity of F has been replaced by the -- assumption that f is an involution. Size-preserving-reindex : ∀ {ℓ} {I : Type ℓ} {C : Container I I} {F : Trans ℓ I} {f : I → I} → f ∘ f ≡ id → Symmetric f F → Size-preserving C F → Size-preserving (reindex f C) F Size-preserving-reindex {C = C} {F} {f} inv hyp pres {R = R} {i = i} R⊆ = F R ⊆⟨ (λ {x} → subst (λ g → F (R ∘ g) x) (sym inv)) ⟩ F (R ∘ f ∘ f) ⊆⟨ hyp _ ⟩ F (R ∘ f) ∘ f ⊆⟨ pres ( R ∘ f ⊆⟨ R⊆ ⟩ ν (reindex f C) i ∘ f ⊆⟨ _⇔_.to (ν-reindex⇔ inv) ⟩ ν C i ∘ f ∘ f ⊆⟨ (λ {x} → subst (λ g → ν C i (g x)) inv) ⟩∎ ν C i ∎) ⟩ ν C i ∘ f ⊆⟨ _⇔_.from (ν-reindex⇔ inv) ⟩∎ ν (reindex f C) i ∎ -- Some negative results: -- -- * For inhabited name types it is not in general the case that a -- monotone and symmetric function F that is size-preserving for -- similarity for CCS is also size-preserving for bisimilarity for -- CCS. -- -- * It is not in general the case that if F is monotone and -- symmetric, and size-preserving for strong similarity for some -- LTS, then F is size-preserving for strong bisimilarity for this -- LTS. -- -- * The function flip Size-preserving F is not closed under _⟷_ for -- all F, not even those that are monotone and symmetric. -- -- * Furthermore flip Size-preserving F is not closed under _⊗_ for -- all F, not even those that are monotone. ¬-Size-preserving-⟷/⊗ : ∀ {ℓ} → ({Name : Type ℓ} → let open CCS Name in Name → ¬ ({F : Trans₂ ℓ (Proc ∞)} → Monotone F → Symmetric swap F → Size-preserving S.StepC F → Size-preserving B.StepC F)) × ¬ (∀ {lts : LTS ℓ} {F} → Monotone F → Symmetric swap F → Size-preserving (Similarity.StepC lts) F → Size-preserving (Bisimilarity.StepC lts) F) × ¬ ({I : Type ℓ} {C₁ C₂ : Container (I × I) (I × I)} {F : Trans₂ ℓ I} → Monotone F → Symmetric swap F → Size-preserving C₁ F → Size-preserving C₂ F → Size-preserving (C₁ ⟷ C₂) F) × ¬ ({I : Type ℓ} {C₁ C₂ : Container I I} {F : Trans ℓ I} → Monotone F → Size-preserving C₁ F → Size-preserving C₂ F → Size-preserving (C₁ ⊗ C₂) F) ¬-Size-preserving-⟷/⊗ {ℓ} = Lemmas.contradiction₂ , Lemmas.contradiction₃ (lift tt) , Lemmas.contradiction₄ (lift tt) , Lemmas.contradiction₅ (lift tt) where module Lemmas {Name : Type ℓ} (a : Name) where open CCS Name public ≤≥≁ = SC.≤≥≁ a m₁ = proj₁ ≤≥≁ m₂ = proj₁ (proj₂ ≤≥≁) F : Trans₂ ℓ (Proc ∞) F R = R ∪ (_≡ (m₁ , m₂)) ∪ (_≡ (m₂ , m₁)) mono : Monotone F mono R⊆S = ⊎-map R⊆S id symm : Symmetric swap F symm R = F (R ⁻¹) ⊆⟨⟩ R ⁻¹ ∪ (_≡ (m₁ , m₂)) ∪ (_≡ (m₂ , m₁)) ⊆⟨ ⊎-map id P.[ inj₂ ∘ lemma , inj₁ ∘ lemma ] ⟩ R ⁻¹ ∪ (_≡ (m₁ , m₂)) ⁻¹ ∪ (_≡ (m₂ , m₁)) ⁻¹ ⊆⟨ id ⟩∎ F R ⁻¹ ∎ where lemma : {p₁ p₂ : Proc ∞ × Proc ∞} → p₁ ≡ swap p₂ → swap p₁ ≡ p₂ lemma refl = refl pres : Size-preserving S.StepC F pres {R = R} {i = i} R⊆ = F R ⊆⟨⟩ R ∪ (_≡ (m₁ , m₂)) ∪ (_≡ (m₂ , m₁)) ⊆⟨ [ R⊆ , helper ] ⟩∎ Similarity i ∎ where helper : ∀ {p} → p ≡ (m₁ , m₂) ⊎ p ≡ (m₂ , m₁) → Similarity i p helper (inj₁ refl) = proj₁ (proj₂ (proj₂ ≤≥≁)) helper (inj₂ refl) = proj₁ (proj₂ (proj₂ (proj₂ ≤≥≁))) contradiction = Size-preserving B.StepC F ↝⟨ (λ hyp → _⇔_.to (monotone→⇔ _ mono) hyp) ⟩ F (Bisimilarity ∞) ⊆ Bisimilarity ∞ ↝⟨ _$ inj₂ (inj₁ refl) ⟩ m₁ ∼ m₂ ↝⟨ proj₂ (proj₂ (proj₂ (proj₂ ≤≥≁))) ⟩□ ⊥ □ contradiction₂ = ({F : Trans₂ ℓ (Proc ∞)} → Monotone F → Symmetric swap F → Size-preserving S.StepC F → Size-preserving B.StepC F) ↝⟨ (λ closed → closed mono symm pres) ⟩ Size-preserving B.StepC F ↝⟨ contradiction ⟩□ ⊥ □ contradiction₃ = (∀ {lts : LTS ℓ} {F} → Monotone F → Symmetric swap F → Size-preserving (Similarity.StepC lts) F → Size-preserving (Bisimilarity.StepC lts) F) ↝⟨ (λ closed mono sym pres → closed mono sym pres) ⟩ ({F : Trans₂ ℓ (Proc ∞)} → Monotone F → Symmetric swap F → Size-preserving S.StepC F → Size-preserving B.StepC F) ↝⟨ contradiction₂ ⟩□ ⊥ □ contradiction₄ = ({I : Type ℓ} {C₁ C₂ : Container (I × I) (I × I)} {F : Trans₂ ℓ I} → Monotone F → Symmetric swap F → Size-preserving C₁ F → Size-preserving C₂ F → Size-preserving (C₁ ⟷ C₂) F) ↝⟨ (λ closed mono symm pres → closed mono symm pres pres) ⟩ (∀ {lts : LTS ℓ} {F} → Monotone F → Symmetric swap F → Size-preserving (Similarity.StepC lts) F → Size-preserving (Bisimilarity.StepC lts) F) ↝⟨ contradiction₃ ⟩□ ⊥ □ contradiction₅ = ({I : Type ℓ} {C₁ C₂ : Container I I} {F : Trans ℓ I} → Monotone F → Size-preserving C₁ F → Size-preserving C₂ F → Size-preserving (C₁ ⊗ C₂) F) ↝⟨ (λ closed → closed mono pres) ⟩ (Size-preserving (reindex swap S.StepC) F → Size-preserving B.StepC F) ↝⟨ _$ Size-preserving-reindex refl symm pres ⟩ Size-preserving B.StepC F ↝⟨ contradiction ⟩□ ⊥ □
37.176471
117
0.534066
d1424370aabde231ee9f6a5ed62dcf90eb17eff5
11,628
agda
Agda
agda-stdlib/src/Data/List/Membership/Setoid/Properties.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Data/List/Membership/Setoid/Properties.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Data/List/Membership/Setoid/Properties.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties related to setoid list membership ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Membership.Setoid.Properties where open import Algebra using (Op₂; Selective) open import Data.Bool.Base using (true; false) open import Data.Fin.Base using (Fin; zero; suc) open import Data.List.Base open import Data.List.Relation.Unary.Any as Any using (Any; here; there) open import Data.List.Relation.Unary.All as All using (All) import Data.List.Relation.Unary.Any.Properties as Any import Data.List.Membership.Setoid as Membership import Data.List.Relation.Binary.Equality.Setoid as Equality import Data.List.Relation.Unary.Unique.Setoid as Unique open import Data.Nat.Base using (suc; z≤n; s≤s; _≤_; _<_) open import Data.Nat.Properties using (≤-trans; n≤1+n) open import Data.Product as Prod using (∃; _×_; _,_ ; ∃₂; proj₁) open import Data.Sum.Base using (_⊎_; inj₁; inj₂) open import Function using (_$_; flip; _∘_; id) open import Relation.Binary as B hiding (Decidable) open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Relation.Unary as U using (Decidable; Pred) open import Relation.Nullary using (¬_; does; _because_; yes; no) open import Relation.Nullary.Reflects using (invert) open import Relation.Nullary.Negation using (¬?; contradiction) open Setoid using (Carrier) ------------------------------------------------------------------------ -- Equality properties module _ {c ℓ} (S : Setoid c ℓ) where open Setoid S open Equality S open Membership S -- _∈_ respects the underlying equality ∈-resp-≈ : ∀ {xs} → (_∈ xs) Respects _≈_ ∈-resp-≈ x≈y x∈xs = Any.map (trans (sym x≈y)) x∈xs ∉-resp-≈ : ∀ {xs} → (_∉ xs) Respects _≈_ ∉-resp-≈ v≈w v∉xs w∈xs = v∉xs (∈-resp-≈ (sym v≈w) w∈xs) ∈-resp-≋ : ∀ {x} → (x ∈_) Respects _≋_ ∈-resp-≋ = Any.lift-resp (flip trans) ∉-resp-≋ : ∀ {x} → (x ∉_) Respects _≋_ ∉-resp-≋ xs≋ys v∉xs v∈ys = v∉xs (∈-resp-≋ (≋-sym xs≋ys) v∈ys) ------------------------------------------------------------------------ -- Irrelevance module _ {c ℓ} (S : Setoid c ℓ) where open Setoid S open Unique S open Membership S private ∉×∈⇒≉ : ∀ {x y xs} → All (y ≉_) xs → x ∈ xs → x ≉ y ∉×∈⇒≉ = All.lookupWith λ y≉z x≈z x≈y → y≉z (trans (sym x≈y) x≈z) unique⇒irrelevant : B.Irrelevant _≈_ → ∀ {xs} → Unique xs → U.Irrelevant (_∈ xs) unique⇒irrelevant ≈-irr _ (here p) (here q) = P.cong here (≈-irr p q) unique⇒irrelevant ≈-irr (_ ∷ u) (there p) (there q) = P.cong there (unique⇒irrelevant ≈-irr u p q) unique⇒irrelevant ≈-irr (≉s ∷ _) (here p) (there q) = contradiction p (∉×∈⇒≉ ≉s q) unique⇒irrelevant ≈-irr (≉s ∷ _) (there p) (here q) = contradiction q (∉×∈⇒≉ ≉s p) ------------------------------------------------------------------------ -- mapWith∈ module _ {c₁ c₂ ℓ₁ ℓ₂} (S₁ : Setoid c₁ ℓ₁) (S₂ : Setoid c₂ ℓ₂) where open Setoid S₁ renaming (Carrier to A₁; _≈_ to _≈₁_; refl to refl₁) open Setoid S₂ renaming (Carrier to A₂; _≈_ to _≈₂_; refl to refl₂) open Equality S₁ using ([]; _∷_) renaming (_≋_ to _≋₁_) open Equality S₂ using () renaming (_≋_ to _≋₂_) open Membership S₁ mapWith∈-cong : ∀ {xs ys} → xs ≋₁ ys → (f : ∀ {x} → x ∈ xs → A₂) → (g : ∀ {y} → y ∈ ys → A₂) → (∀ {x y} → x ≈₁ y → (x∈xs : x ∈ xs) (y∈ys : y ∈ ys) → f x∈xs ≈₂ g y∈ys) → mapWith∈ xs f ≋₂ mapWith∈ ys g mapWith∈-cong [] f g cong = [] mapWith∈-cong (x≈y ∷ xs≋ys) f g cong = cong x≈y (here refl₁) (here refl₁) ∷ mapWith∈-cong xs≋ys (f ∘ there) (g ∘ there) (λ x≈y x∈xs y∈ys → cong x≈y (there x∈xs) (there y∈ys)) mapWith∈≗map : ∀ f xs → mapWith∈ xs (λ {x} _ → f x) ≋₂ map f xs mapWith∈≗map f [] = [] mapWith∈≗map f (x ∷ xs) = refl₂ ∷ mapWith∈≗map f xs module _ {c ℓ} (S : Setoid c ℓ) where open Setoid S open Membership S length-mapWith∈ : ∀ {a} {A : Set a} xs {f : ∀ {x} → x ∈ xs → A} → length (mapWith∈ xs f) ≡ length xs length-mapWith∈ [] = P.refl length-mapWith∈ (x ∷ xs) = P.cong suc (length-mapWith∈ xs) ------------------------------------------------------------------------ -- map module _ {c₁ c₂ ℓ₁ ℓ₂} (S₁ : Setoid c₁ ℓ₁) (S₂ : Setoid c₂ ℓ₂) where open Setoid S₁ renaming (Carrier to A₁; _≈_ to _≈₁_; refl to refl₁) open Setoid S₂ renaming (Carrier to A₂; _≈_ to _≈₂_) private module M₁ = Membership S₁; open M₁ using (find) renaming (_∈_ to _∈₁_) private module M₂ = Membership S₂; open M₂ using () renaming (_∈_ to _∈₂_) ∈-map⁺ : ∀ {f} → f Preserves _≈₁_ ⟶ _≈₂_ → ∀ {v xs} → v ∈₁ xs → f v ∈₂ map f xs ∈-map⁺ pres x∈xs = Any.map⁺ (Any.map pres x∈xs) ∈-map⁻ : ∀ {v xs f} → v ∈₂ map f xs → ∃ λ x → x ∈₁ xs × v ≈₂ f x ∈-map⁻ x∈map = find (Any.map⁻ x∈map) map-∷= : ∀ {f} (f≈ : f Preserves _≈₁_ ⟶ _≈₂_) {xs x v} → (x∈xs : x ∈₁ xs) → map f (x∈xs M₁.∷= v) ≡ ∈-map⁺ f≈ x∈xs M₂.∷= f v map-∷= f≈ (here x≈y) = P.refl map-∷= f≈ (there x∈xs) = P.cong (_ ∷_) (map-∷= f≈ x∈xs) ------------------------------------------------------------------------ -- _++_ module _ {c ℓ} (S : Setoid c ℓ) where open Membership S using (_∈_) open Setoid S open Equality S using (_≋_; _∷_; ≋-refl) ∈-++⁺ˡ : ∀ {v xs ys} → v ∈ xs → v ∈ xs ++ ys ∈-++⁺ˡ = Any.++⁺ˡ ∈-++⁺ʳ : ∀ {v} xs {ys} → v ∈ ys → v ∈ xs ++ ys ∈-++⁺ʳ = Any.++⁺ʳ ∈-++⁻ : ∀ {v} xs {ys} → v ∈ xs ++ ys → (v ∈ xs) ⊎ (v ∈ ys) ∈-++⁻ = Any.++⁻ ∈-insert : ∀ xs {ys v w} → v ≈ w → v ∈ xs ++ [ w ] ++ ys ∈-insert xs = Any.++-insert xs ∈-∃++ : ∀ {v xs} → v ∈ xs → ∃₂ λ ys zs → ∃ λ w → v ≈ w × xs ≋ ys ++ [ w ] ++ zs ∈-∃++ (here px) = [] , _ , _ , px , ≋-refl ∈-∃++ (there {d} v∈xs) with ∈-∃++ v∈xs ... | hs , _ , _ , v≈v′ , eq = d ∷ hs , _ , _ , v≈v′ , refl ∷ eq ------------------------------------------------------------------------ -- concat module _ {c ℓ} (S : Setoid c ℓ) where open Setoid S using (_≈_) open Membership S using (_∈_) open Equality S using (≋-setoid) open Membership ≋-setoid using (find) renaming (_∈_ to _∈ₗ_) ∈-concat⁺ : ∀ {v xss} → Any (v ∈_) xss → v ∈ concat xss ∈-concat⁺ = Any.concat⁺ ∈-concat⁻ : ∀ {v} xss → v ∈ concat xss → Any (v ∈_) xss ∈-concat⁻ = Any.concat⁻ ∈-concat⁺′ : ∀ {v vs xss} → v ∈ vs → vs ∈ₗ xss → v ∈ concat xss ∈-concat⁺′ v∈vs = ∈-concat⁺ ∘ Any.map (flip (∈-resp-≋ S) v∈vs) ∈-concat⁻′ : ∀ {v} xss → v ∈ concat xss → ∃ λ xs → v ∈ xs × xs ∈ₗ xss ∈-concat⁻′ xss v∈c[xss] with find (∈-concat⁻ xss v∈c[xss]) ... | xs , t , s = xs , s , t ------------------------------------------------------------------------ -- applyUpTo module _ {c ℓ} (S : Setoid c ℓ) where open Setoid S using (_≈_; refl) open Membership S using (_∈_) ∈-applyUpTo⁺ : ∀ f {i n} → i < n → f i ∈ applyUpTo f n ∈-applyUpTo⁺ f = Any.applyUpTo⁺ f refl ∈-applyUpTo⁻ : ∀ {v} f {n} → v ∈ applyUpTo f n → ∃ λ i → i < n × v ≈ f i ∈-applyUpTo⁻ = Any.applyUpTo⁻ ------------------------------------------------------------------------ -- tabulate module _ {c ℓ} (S : Setoid c ℓ) where open Setoid S using (_≈_; refl) renaming (Carrier to A) open Membership S using (_∈_) ∈-tabulate⁺ : ∀ {n} {f : Fin n → A} i → f i ∈ tabulate f ∈-tabulate⁺ i = Any.tabulate⁺ i refl ∈-tabulate⁻ : ∀ {n} {f : Fin n → A} {v} → v ∈ tabulate f → ∃ λ i → v ≈ f i ∈-tabulate⁻ = Any.tabulate⁻ ------------------------------------------------------------------------ -- filter module _ {c ℓ p} (S : Setoid c ℓ) {P : Pred (Carrier S) p} (P? : Decidable P) (resp : P Respects (Setoid._≈_ S)) where open Setoid S using (_≈_; sym) open Membership S using (_∈_) ∈-filter⁺ : ∀ {v xs} → v ∈ xs → P v → v ∈ filter P? xs ∈-filter⁺ {xs = x ∷ _} (here v≈x) Pv with P? x ... | true because _ = here v≈x ... | false because [¬Px] = contradiction (resp v≈x Pv) (invert [¬Px]) ∈-filter⁺ {xs = x ∷ _} (there v∈xs) Pv with does (P? x) ... | true = there (∈-filter⁺ v∈xs Pv) ... | false = ∈-filter⁺ v∈xs Pv ∈-filter⁻ : ∀ {v xs} → v ∈ filter P? xs → v ∈ xs × P v ∈-filter⁻ {xs = x ∷ xs} v∈f[x∷xs] with P? x ... | false because _ = Prod.map there id (∈-filter⁻ v∈f[x∷xs]) ... | true because [Px] with v∈f[x∷xs] ... | here v≈x = here v≈x , resp (sym v≈x) (invert [Px]) ... | there v∈fxs = Prod.map there id (∈-filter⁻ v∈fxs) ------------------------------------------------------------------------ -- derun and deduplicate module _ {c ℓ r} (S : Setoid c ℓ) {R : Rel (Carrier S) r} (R? : B.Decidable R) where open Setoid S using (_≈_) open Membership S using (_∈_) ∈-derun⁺ : _≈_ Respectsʳ R → ∀ {xs z} → z ∈ xs → z ∈ derun R? xs ∈-derun⁺ ≈-resp-R z∈xs = Any.derun⁺ R? ≈-resp-R z∈xs ∈-deduplicate⁺ : _≈_ Respectsʳ (flip R) → ∀ {xs z} → z ∈ xs → z ∈ deduplicate R? xs ∈-deduplicate⁺ ≈-resp-R z∈xs = Any.deduplicate⁺ R? ≈-resp-R z∈xs ∈-derun⁻ : ∀ xs {z} → z ∈ derun R? xs → z ∈ xs ∈-derun⁻ xs z∈derun[R,xs] = Any.derun⁻ R? z∈derun[R,xs] ∈-deduplicate⁻ : ∀ xs {z} → z ∈ deduplicate R? xs → z ∈ xs ∈-deduplicate⁻ xs z∈dedup[R,xs] = Any.deduplicate⁻ R? z∈dedup[R,xs] ------------------------------------------------------------------------ -- length module _ {c ℓ} (S : Setoid c ℓ) where open Membership S using (_∈_) ∈-length : ∀ {x xs} → x ∈ xs → 1 ≤ length xs ∈-length (here px) = s≤s z≤n ∈-length (there x∈xs) = ≤-trans (∈-length x∈xs) (n≤1+n _) ------------------------------------------------------------------------ -- lookup module _ {c ℓ} (S : Setoid c ℓ) where open Setoid S using (refl) open Membership S using (_∈_) ∈-lookup : ∀ xs i → lookup xs i ∈ xs ∈-lookup (x ∷ xs) zero = here refl ∈-lookup (x ∷ xs) (suc i) = there (∈-lookup xs i) ------------------------------------------------------------------------ -- foldr module _ {c ℓ} (S : Setoid c ℓ) {_•_ : Op₂ (Carrier S)} where open Setoid S using (_≈_; refl; sym; trans) open Membership S using (_∈_) foldr-selective : Selective _≈_ _•_ → ∀ e xs → (foldr _•_ e xs ≈ e) ⊎ (foldr _•_ e xs ∈ xs) foldr-selective •-sel i [] = inj₁ refl foldr-selective •-sel i (x ∷ xs) with •-sel x (foldr _•_ i xs) ... | inj₁ x•f≈x = inj₂ (here x•f≈x) ... | inj₂ x•f≈f with foldr-selective •-sel i xs ... | inj₁ f≈i = inj₁ (trans x•f≈f f≈i) ... | inj₂ f∈xs = inj₂ (∈-resp-≈ S (sym x•f≈f) (there f∈xs)) ------------------------------------------------------------------------ -- _∷=_ module _ {c ℓ} (S : Setoid c ℓ) where open Setoid S open Membership S ∈-∷=⁺-updated : ∀ {xs x v} (x∈xs : x ∈ xs) → v ∈ (x∈xs ∷= v) ∈-∷=⁺-updated (here px) = here refl ∈-∷=⁺-updated (there pxs) = there (∈-∷=⁺-updated pxs) ∈-∷=⁺-untouched : ∀ {xs x y v} (x∈xs : x ∈ xs) → (¬ x ≈ y) → y ∈ xs → y ∈ (x∈xs ∷= v) ∈-∷=⁺-untouched (here x≈z) x≉y (here y≈z) = contradiction (trans x≈z (sym y≈z)) x≉y ∈-∷=⁺-untouched (here x≈z) x≉y (there y∈xs) = there y∈xs ∈-∷=⁺-untouched (there x∈xs) x≉y (here y≈z) = here y≈z ∈-∷=⁺-untouched (there x∈xs) x≉y (there y∈xs) = there (∈-∷=⁺-untouched x∈xs x≉y y∈xs) ∈-∷=⁻ : ∀ {xs x y v} (x∈xs : x ∈ xs) → (¬ y ≈ v) → y ∈ (x∈xs ∷= v) → y ∈ xs ∈-∷=⁻ (here x≈z) y≉v (here y≈v) = contradiction y≈v y≉v ∈-∷=⁻ (here x≈z) y≉v (there y∈) = there y∈ ∈-∷=⁻ (there x∈xs) y≉v (here y≈z) = here y≈z ∈-∷=⁻ (there x∈xs) y≉v (there y∈) = there (∈-∷=⁻ x∈xs y≉v y∈)
35.236364
89
0.489594
4b675c23c89d77dca54d323e404401c1f6e33ff3
2,153
agda
Agda
agda/PLRTree/Complete/Properties.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
6
2015-05-21T12:50:35.000Z
2021-08-24T22:11:15.000Z
agda/PLRTree/Complete/Properties.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
agda/PLRTree/Complete/Properties.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
module PLRTree.Complete.Properties {A : Set} where open import Data.Empty open import Data.Sum renaming (_⊎_ to _∨_) open import PLRTree {A} open import PLRTree.Complete {A} open import PLRTree.Equality {A} open import PLRTree.Equality.Properties {A} lemma-⋗-≃ : {t t' t'' : PLRTree} → t ⋗ t' → t' ≃ t'' → t ⋗ t'' lemma-⋗-≃ (⋗lf x) ≃lf = ⋗lf x lemma-⋗-≃ (⋗nd x x' l≃r l'≃r' l⋗l') (≃nd .x' x'' _ l''≃r'' l'≃l'') = ⋗nd x x'' l≃r l''≃r'' (lemma-⋗-≃ l⋗l' l'≃l'') lemma-≃-⋗ : {t t' t'' : PLRTree} → t ≃ t' → t ⋗ t'' → t' ⋗ t'' lemma-≃-⋗ ≃lf t⋗t'' = t⋗t'' lemma-≃-⋗ (≃nd x x' ≃lf ≃lf ≃lf) (⋗lf .x) = ⋗lf x' lemma-≃-⋗ (≃nd x _ ≃lf (≃nd _ _ _ _ _) ()) (⋗lf .x) lemma-≃-⋗ (≃nd x x' l≃r l'≃r' l≃l') (⋗nd .x x'' _ l''≃r'' l⋗l'') = ⋗nd x' x'' l'≃r' l''≃r'' (lemma-≃-⋗ l≃l' l⋗l'') lemma-⋗* : {t t' t'' : PLRTree} → t ⋗ t' → t ⋗ t'' → t' ≃ t'' lemma-⋗* (⋗lf x) (⋗lf .x) = ≃lf lemma-⋗* (⋗lf x) (⋗nd .x _ _ _ ()) lemma-⋗* (⋗nd x _ _ _ ()) (⋗lf .x) lemma-⋗* (⋗nd x x' l≃r l'≃r' l⋗l') (⋗nd .x x'' _ l''≃r'' l'⋗l'') = ≃nd x' x'' l'≃r' l''≃r'' (lemma-⋗* l⋗l' l'⋗l'') lemma-*⋗ : {t t' t'' : PLRTree} → t ⋗ t' → t'' ⋗ t' → t ≃ t'' lemma-*⋗ (⋗lf x) (⋗lf y) = ≃nd x y ≃lf ≃lf ≃lf lemma-*⋗ (⋗nd x x' l≃r l'≃r' l⋗l') (⋗nd x'' .x' l''≃r'' _ l''⋗l') = ≃nd x x'' l≃r l''≃r'' (lemma-*⋗ l⋗l' l''⋗l') lemma-⋗refl-⊥ : {t : PLRTree} → t ⋗ t → ⊥ lemma-⋗refl-⊥ (⋗nd x .x _ _ t⋗t) with lemma-⋗refl-⊥ t⋗t ... | () lemma-⋙-⋗ : {t t' t'' : PLRTree} → t ⋙ t' → t ⋗ t'' → t' ⋘ t'' ∨ t' ≃ t'' lemma-⋙-⋗ (⋙p (⋗lf x)) (⋗lf .x) = inj₂ ≃lf lemma-⋙-⋗ (⋙p (⋗nd x _ _ _ ())) (⋗lf .x) lemma-⋙-⋗ (⋙p (⋗lf x)) (⋗nd .x _ _ _ ()) lemma-⋙-⋗ (⋙p (⋗nd x x' l≃r l'≃r' l⋗l')) (⋗nd .x x'' _ l''≃r'' l⋗l'') = inj₂ (≃nd x' x'' l'≃r' l''≃r'' (lemma-⋗* l⋗l' l⋗l'')) lemma-⋙-⋗ (⋙l x _ _ _ ()) (⋗lf .x) lemma-⋙-⋗ (⋙l x x' l≃r l'⋘r' l⋗r') (⋗nd .x x'' _ l''≃r'' l⋗l'') = inj₁ (l⋘ x' x'' l'⋘r' l''≃r'' (lemma-⋗* l⋗r' l⋗l'')) lemma-⋙-⋗ (⋙r x x' ≃lf (⋙p ()) ≃lf) (⋗lf .x) lemma-⋙-⋗ (⋙r x x' ≃lf (⋙l _ _ _ _ _) ()) (⋗lf .x) lemma-⋙-⋗ (⋙r x x' ≃lf (⋙r _ _ _ _ _) ()) (⋗lf .x) lemma-⋙-⋗ (⋙r x x' l≃r l'⋙r' l≃l') (⋗nd .x x'' _ l''≃r'' l⋗l'') = inj₁ (r⋘ x' x'' l'⋙r' l''≃r'' (lemma-≃-⋗ l≃l' l⋗l''))
42.215686
126
0.41477
9a8ffe895ae376fb2cdc98dabb02df73c2b8cb70
7,940
agda
Agda
complexity-drafts/Comp-lang.agda
benhuds/Agda
2404a6ef2688f879bda89860bb22f77664ad813e
[ "MIT" ]
2
2016-04-26T20:22:22.000Z
2019-08-08T12:27:18.000Z
complexity-drafts/Comp-lang.agda
benhuds/Agda
2404a6ef2688f879bda89860bb22f77664ad813e
[ "MIT" ]
1
2020-03-23T08:39:04.000Z
2020-05-12T00:32:45.000Z
complexity-drafts/Comp-lang.agda
benhuds/Agda
2404a6ef2688f879bda89860bb22f77664ad813e
[ "MIT" ]
null
null
null
{- Name: Bowornmet (Ben) Hudson -- define the complexity language from the paper -} open import Preliminaries open import Preorder-withmax module Comp-lang where -- define the complexity language from the paper -- we want to focus on arrow, cross, and nat types -- do I need unit types? data CTp : Set where unit : CTp nat : CTp _->c_ : CTp → CTp → CTp _×c_ : CTp → CTp → CTp C : CTp -- represent a context as a list of types Ctx = List CTp -- de Bruijn indices (for free variables) data _∈_ : CTp → Ctx → Set where i0 : ∀ {Γ τ} → τ ∈ (τ :: Γ) iS : ∀ {Γ τ τ1} → τ ∈ Γ → τ ∈ (τ1 :: Γ) data _|-_ : Ctx → CTp → Set where unit : ∀ {Γ} → Γ |- unit 0C : ∀ {Γ} → Γ |- C 1C : ∀ {Γ} → Γ |- C plusC : ∀ {Γ} → Γ |- C → Γ |- C → Γ |- C var : ∀ {Γ τ} → τ ∈ Γ → Γ |- τ z : ∀ {Γ} → Γ |- nat suc : ∀ {Γ} → (e : Γ |- nat) → Γ |- nat rec : ∀ {Γ τ} → Γ |- nat → Γ |- τ → (nat :: (τ :: Γ)) |- τ → Γ |- τ lam : ∀ {Γ τ ρ} → (ρ :: Γ) |- τ → Γ |- (ρ ->c τ) app : ∀ {Γ τ1 τ2} → Γ |- (τ2 ->c τ1) → Γ |- τ2 → Γ |- τ1 prod : ∀ {Γ τ1 τ2} → Γ |- τ1 → Γ |- τ2 → Γ |- (τ1 ×c τ2) l-proj : ∀ {Γ τ1 τ2} → Γ |- (τ1 ×c τ2) → Γ |- τ1 r-proj : ∀ {Γ τ1 τ2} → Γ |- (τ1 ×c τ2) → Γ |- τ2 _+C_ : ∀ {Γ τ} → Γ |- C → Γ |- (C ×c τ)→ Γ |- (C ×c τ) c +C e = prod (plusC c (l-proj e)) (r-proj e) ------weakening and substitution lemmas -- renaming function rctx : Ctx → Ctx → Set rctx Γ Γ' = ∀ {τ} → τ ∈ Γ' → τ ∈ Γ -- re: transferring variables in contexts lem1 : ∀ {Γ Γ' τ} → rctx Γ Γ' → rctx (τ :: Γ) (τ :: Γ') lem1 d i0 = i0 lem1 d (iS x) = iS (d x) -- renaming lemma ren : ∀ {Γ Γ' τ} → Γ' |- τ → rctx Γ Γ' → Γ |- τ ren unit d = unit ren 0C d = 0C ren 1C d = 1C ren (plusC e1 e2) d = plusC (ren e1 d) (ren e2 d) ren (var x) d = var (d x) ren z d = z ren (suc e) d = suc (ren e d) ren (rec e e0 e1) d = rec (ren e d) (ren e0 d) (ren e1 (lem1 (lem1 d))) ren (lam e) d = lam (ren e (lem1 d)) ren (app e1 e2) d = app (ren e1 d) (ren e2 d) ren (prod e1 e2) d = prod (ren e1 d) (ren e2 d) ren (l-proj e) d = l-proj (ren e d) ren (r-proj e) d = r-proj (ren e d) -- substitution sctx : Ctx → Ctx → Set sctx Γ Γ' = ∀ {τ} → τ ∈ Γ' → Γ |- τ -- weakening a context wkn : ∀ {Γ τ1 τ2} → Γ |- τ2 → (τ1 :: Γ) |- τ2 wkn e = ren e iS -- weakening also works with substitution wkn-s : ∀ {Γ τ1 Γ'} → sctx Γ Γ' → sctx (τ1 :: Γ) Γ' wkn-s d = λ f → wkn (d f) wkn-r : ∀ {Γ τ1 Γ'} → rctx Γ Γ' → rctx (τ1 :: Γ) Γ' wkn-r d = λ x → iS (d x) -- lem2 (need a lemma for subst like we did for renaming) lem2 : ∀ {Γ Γ' τ} → sctx Γ Γ' → sctx (τ :: Γ) (τ :: Γ') lem2 d i0 = var i0 lem2 d (iS i) = wkn (d i) -- another substitution lemma lem3 : ∀ {Γ τ} → Γ |- τ → sctx Γ (τ :: Γ) lem3 e i0 = e lem3 e (iS i) = var i lem3' : ∀ {Γ Γ' τ} → sctx Γ Γ' → Γ |- τ → sctx Γ (τ :: Γ') lem3' Θ e i0 = e lem3' Θ e (iS i) = Θ i -- one final lemma needed for the last stepping rule. Thank you Professor Licata! lem4 : ∀ {Γ τ1 τ2} → Γ |- τ1 → Γ |- τ2 → sctx Γ (τ1 :: (τ2 :: Γ)) lem4 e1 e2 i0 = e1 lem4 e1 e2 (iS i0) = e2 lem4 e1 e2 (iS (iS i)) = var i lem4' : ∀ {Γ Γ' τ1 τ2} → sctx Γ Γ' → Γ |- τ1 → Γ |- τ2 → sctx Γ (τ1 :: (τ2 :: Γ')) lem4' Θ a b i0 = a lem4' Θ a b (iS i0) = b lem4' Θ a b (iS (iS i)) = Θ i -- the 'real' substitution lemma (if (x : τ') :: Γ |- (e : τ) and Γ |- (e : τ') , then Γ |- e[x -> e'] : τ) subst : ∀ {Γ Γ' τ} → sctx Γ Γ' → Γ' |- τ → Γ |- τ subst d unit = unit subst d 0C = 0C subst d 1C = 1C subst d (plusC e1 e2) = plusC (subst d e1) (subst d e2) subst d (var x) = d x subst d z = z subst d (suc x) = suc (subst d x) subst d (rec e e0 e1) = rec (subst d e) (subst d e0) (subst (lem2 (lem2 d)) e1) subst d (lam e) = lam (subst (lem2 d) e) subst d (app e1 e2) = app (subst d e1) (subst d e2) subst d (prod e1 e2) = prod (subst d e1) (subst d e2) subst d (l-proj e) = l-proj (subst d e) subst d (r-proj e) = r-proj (subst d e) postulate subst-compose : ∀ {Γ Γ' τ τ1} (Θ : sctx Γ Γ') (v : Γ |- τ) (e : (τ :: Γ' |- τ1) ) → subst (lem3 v) (subst (lem2 Θ) e) == subst (lem3' Θ v) e postulate subst-compose2 : ∀ {Γ Γ' τ} (Θ : sctx Γ Γ') (n : Γ |- nat) (e1 : Γ' |- τ) (e2 : (nat :: (τ :: Γ')) |- τ) → subst (lem4 n (rec n (subst Θ e1) (subst (lem2 (lem2 Θ)) e2))) (subst (lem2 (lem2 Θ)) e2) == subst (lem4' Θ n (rec n (subst Θ e1) (subst (lem2 (lem2 Θ)) e2))) e2 postulate subst-compose3 : ∀ {Γ Γ' τ τ1 τ2} (Θ : sctx Γ Γ') (e1 : (τ1 :: (τ2 :: Γ')) |- τ) (v1 : Γ' |- τ1) (v2 : Γ' |- τ2) → subst Θ (subst (lem4 v1 v2) e1) == subst (lem4' Θ (subst Θ v1) (subst Θ v2)) e1 postulate subst-compose4 : ∀ {Γ Γ' τ} (Θ : sctx Γ Γ') (v' : Γ |- nat) (r : Γ |- τ) (e2 : (nat :: (τ :: Γ')) |- τ) → subst (lem4 v' r) (subst (lem2 (lem2 Θ)) e2) == subst (lem4' Θ v' r) e2 ------- -- define 'stepping' as a datatype (fig. 1 of proof) data _≤s_ : ∀ {Γ T} → Γ |- T → Γ |- T → Set where refl-s : ∀ {Γ T} → {e : Γ |- T} → e ≤s e trans-s : ∀ {Γ T} → {e e' e'' : Γ |- T} → e ≤s e' → e' ≤s e'' → e ≤s e'' plus-s : ∀ {Γ} → {e1 e2 n1 n2 : Γ |- C} → e1 ≤s n1 → e2 ≤s n2 → (plusC e1 e2) ≤s (plusC n1 n2) cong-refl : ∀ {Γ τ} {e e' : Γ |- τ} → e == e' → e ≤s e' +-unit-l : ∀ {Γ} {e : Γ |- C} → (plusC 0C e) ≤s e +-unit-l' : ∀ {Γ} {e : Γ |- C} → e ≤s (plusC 0C e) +-unit-r : ∀ {Γ} {e : Γ |- C} → (plusC e 0C) ≤s e +-unit-r' : ∀ {Γ} {e : Γ |- C} → e ≤s (plusC e 0C) +-assoc : ∀ {Γ} {e1 e2 e3 : Γ |- C} → (plusC e1 (plusC e2 e3)) ≤s (plusC (plusC e1 e2) e3) +-assoc' : ∀ {Γ} {e1 e2 e3 : Γ |- C} → (plusC e1 (plusC e2 e3)) ≤s (plusC (plusC e1 e2) e3) refl-+ : ∀ {Γ} {e0 e1 : Γ |- C} → (plusC e0 e1) ≤s (plusC e1 e0) cong-+ : ∀ {Γ} {e0 e1 e0' e1' : Γ |- C} → e0 ≤s e0' → e1 ≤s e1' → (plusC e0 e1) ≤s (plusC e0' e1') cong-lproj : ∀ {Γ τ τ'} {e e' : Γ |- (τ ×c τ')} → e ≤s e' → (l-proj e) ≤s (l-proj e') cong-rproj : ∀ {Γ τ τ'} {e e' : Γ |- (τ ×c τ')} → e ≤s e' → (r-proj e) ≤s (r-proj e') cong-app : ∀ {Γ τ τ'} {e e' : Γ |- (τ ->c τ')} {e1 : Γ |- τ} → e ≤s e' → (app e e1) ≤s (app e' e1) cong-rec : ∀ {Γ τ} {e e' : Γ |- nat} {e0 : Γ |- τ} {e1 : (nat :: (τ :: Γ)) |- τ} → e ≤s e' → rec e e0 e1 ≤s rec e' e0 e1 lam-s : ∀ {Γ T T'} → {e : (T :: Γ) |- T'} → {e2 : Γ |- T} → subst (lem3 e2) e ≤s app (lam e) e2 l-proj-s : ∀ {Γ T1 T2} → {e1 : Γ |- T1} {e2 : Γ |- T2} → e1 ≤s (l-proj (prod e1 e2)) r-proj-s : ∀ {Γ T1 T2} → {e1 : Γ |- T1} → {e2 : Γ |- T2} → e2 ≤s (r-proj (prod e1 e2)) rec-steps-s : ∀ {Γ T} → {e : Γ |- nat} → {e0 : Γ |- T} → {e1 : (nat :: (T :: Γ)) |- T} → subst (lem4 e (rec e e0 e1)) e1 ≤s (rec (suc e) e0 e1) rec-steps-z : ∀ {Γ T} → {e0 : Γ |- T} → {e1 : (nat :: (T :: Γ)) |- T} → e0 ≤s (rec z e0 e1) _trans_ : ∀ {Γ T} → {e e' e'' : Γ |- T} → e ≤s e' → e' ≤s e'' → e ≤s e'' _trans_ = trans-s infixr 10 _trans_ ------- -- interpret complexity types as preorders [_]t : CTp → PREORDER [ unit ]t = unit-p [ nat ]t = Nat , nat-p [ A ->c B ]t = [ A ]t ->p [ B ]t [ A ×c B ]t = [ A ]t ×p [ B ]t [ C ]t = Nat , nat-p -- interpret contexts as preorders [_]c : Ctx → PREORDER [ [] ]c = unit-p [ τ :: Γ ]c = [ τ ]t ×p [ Γ ]c
31.88755
116
0.420025
3d4b60fe14d2b6ae34d48fcacfd255392e8fa665
4,749
agda
Agda
Cubical/HITs/S2/Properties.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
1
2021-10-31T17:32:49.000Z
2021-10-31T17:32:49.000Z
Cubical/HITs/S2/Properties.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
Cubical/HITs/S2/Properties.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.HITs.S2.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Pointed open import Cubical.Foundations.Function open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Path open import Cubical.HITs.S1.Base open import Cubical.HITs.S2.Base open import Cubical.HITs.Susp open import Cubical.Homotopy.Loopspace S²ToSetElim : ∀ {ℓ} {A : S² → Type ℓ} → ((x : S²) → isSet (A x)) → A base → (x : S²) → A x S²ToSetElim set b base = b S²ToSetElim set b (surf i j) = isOfHLevel→isOfHLevelDep 2 set b b {a0 = refl} {a1 = refl} refl refl surf i j -- Wedge connectivity lemmas for S² (binary maps 2-groupoids) wedgeconFunS² : ∀ {ℓ} {P : S² → S² → Type ℓ} → ((x y : _) → isOfHLevel 4 (P x y)) → (l : ((x : S²) → P x base)) → (r : (x : S²) → P base x) → l base ≡ r base → (x y : _) → P x y wedgeconFunS² {P = P} hlev l r p base y = r y wedgeconFunS² {P = P} hlev l r p (surf i i₁) y = help y i i₁ where help : (y : S²) → SquareP (λ i j → P (surf i j) y) (λ _ → r y) (λ _ → r y) (λ _ → r y) λ _ → r y help = S²ToSetElim (λ _ → isOfHLevelPathP' 2 (isOfHLevelPathP' 3 (hlev _ _) _ _) _ _) λ w j → hcomp (λ k → λ { (j = i0) → p k ; (j = i1) → p k ; (w = i0) → p k ; (w = i1) → p k}) (l (surf w j)) wedgeconFunS²Id : ∀ {ℓ} {P : S² → S² → Type ℓ} → (h : ((x y : _) → isOfHLevel 4 (P x y))) → (l : ((x : S²) → P x base)) → (r : (x : S²) → P base x) → (p : l base ≡ r base) → (x : S²) → wedgeconFunS² h l r p x base ≡ l x wedgeconFunS²Id h l r p base = sym p wedgeconFunS²Id h l r p (surf i j) k = hcomp (λ w → λ {(i = i0) → p (~ k ∧ w) ; (i = i1) → p (~ k ∧ w) ; (j = i0) → p (~ k ∧ w) ; (j = i1) → p (~ k ∧ w) ; (k = i1) → l (surf i j)}) (l (surf i j)) S¹×S¹→S² : S¹ → S¹ → S² S¹×S¹→S² base y = base S¹×S¹→S² (loop i) base = base S¹×S¹→S² (loop i) (loop j) = surf i j invS² : S² → S² invS² base = base invS² (surf i j) = surf j i S¹×S¹→S²-anticomm : (x y : S¹) → invS² (S¹×S¹→S² x y) ≡ S¹×S¹→S² y x S¹×S¹→S²-anticomm base base = refl S¹×S¹→S²-anticomm base (loop i) = refl S¹×S¹→S²-anticomm (loop i) base = refl S¹×S¹→S²-anticomm (loop i) (loop i₁) = refl toSuspPresInvS² : (x : S²) → toSusp S²∙ (invS² x) ≡ sym (toSusp S²∙ x) toSuspPresInvS² base = rCancel (merid base) ∙∙ refl ∙∙ cong sym (sym (rCancel (merid base))) toSuspPresInvS² (surf i j) k r = hcomp (λ l → λ {(i = i0) → cc l k r ; (i = i1) → cc l k r ; (j = i0) → cc l k r ; (j = i1) → cc l k r ; (k = i0) → l1-fill j i r (~ l) ; (k = i1) → l1-fill i j (~ r) (~ l) ; (r = i0) → north ; (r = i1) → north}) (l1≡l2 k j i r) where cc : Cube {A = Susp S²} _ _ _ _ _ _ cc = doubleCompPath-filler (rCancel (merid base)) refl (cong sym (sym (rCancel (merid base)))) l1-fill : (i j k r : I) → Susp S² l1-fill i j k r = hfill (λ r → λ {(i = i0) → rCancel (merid base) r k ; (i = i1) → rCancel (merid base) r k ; (j = i0) → rCancel (merid base) r k ; (j = i1) → rCancel (merid base) r k ; (k = i0) → north ; (k = i1) → north}) (inS (toSusp S²∙ (surf i j) k)) r l1 : (Ω^ 3) (Susp∙ S²) .fst l1 i j k = l1-fill i j k i1 l2 : (Ω^ 3) (Susp∙ S²) .fst l2 i j k = l1 j i (~ k) sym≡cong-sym-refl : ∀ {ℓ} {A : Type ℓ} {x : A} → sym≡cong-sym (λ _ _ → x) ≡ refl sym≡cong-sym-refl {x = x} = transportRefl (λ _ _ _ → x) l1≡l2 : l1 ≡ l2 l1≡l2 = sym (sym≡flipSquare (λ i j → l1 j i)) ∙ ((λ _ i j k → l1 j (~ i) k) ∙ λ r i j k → hcomp (λ l → λ {(i = i0) → north ; (i = i1) → north ; (j = i0) → sym≡cong-sym-refl {x = north} r (~ l) i k ; (j = i1) → sym≡cong-sym-refl {x = north} r (~ l) i k ; (k = i0) → north ; (k = i1) → north ; (r = i0) → sym≡cong-sym (λ i k → l1 j i k) (~ l) i k ; (r = i1) → l2 i j k}) (l2 i j k)) S¹×S¹→S²-sym : (x y : S¹) → toSusp S²∙ (S¹×S¹→S² x y) ≡ sym (toSusp S²∙ (S¹×S¹→S² y x)) S¹×S¹→S²-sym x y = cong sym (sym (toSuspPresInvS² (S¹×S¹→S² x y))) ∙ cong (sym ∘ toSusp S²∙) (S¹×S¹→S²-anticomm x y)
35.440299
87
0.463255
0303c001aacb4ebc364a8616859103f8d9421f4e
342
agda
Agda
Cubical/Data/DiffInt/Base.agda
ryanorendorff/cubical
c67854d2e11aafa5677e25a09087e176fafd3e43
[ "MIT" ]
1
2020-03-23T23:52:11.000Z
2020-03-23T23:52:11.000Z
Cubical/Data/DiffInt/Base.agda
ryanorendorff/cubical
c67854d2e11aafa5677e25a09087e176fafd3e43
[ "MIT" ]
null
null
null
Cubical/Data/DiffInt/Base.agda
ryanorendorff/cubical
c67854d2e11aafa5677e25a09087e176fafd3e43
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.Data.DiffInt.Base where open import Cubical.Foundations.Prelude open import Cubical.HITs.SetQuotients.Base open import Cubical.Data.Sigma open import Cubical.Data.Nat rel : (ℕ × ℕ) → (ℕ × ℕ) → Type₀ rel (a₀ , b₀) (a₁ , b₁) = x ≡ y where x = a₀ + b₁ y = a₁ + b₀ ℤ = (ℕ × ℕ) / rel
19
42
0.640351
d11c1be61f1663ab5c0c9ea69cee3689bec29fed
424
agda
Agda
test/Succeed/Issue5545.agda
cagix/agda
cc026a6a97a3e517bb94bafa9d49233b067c7559
[ "BSD-2-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue5545.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue5545.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2021-09-06, issue #5545, -- regression introduced by #5522 (fix for #5291). -- -- Note: this test requires that there is no newline at the end of file. -- So, it violates the whitespace requirement of fix-whitespace, -- and needs to be an exception in the configuration of fix-whitespace. {-# OPTIONS --allow-unsolved-metas #-} -- No newline at end of file triggered "Unterminated {!" error. _ : Set _ = {! !}
32.615385
72
0.700472
5e604565ef449a0e64f91ff94f01063170b0634c
2,886
agda
Agda
PiQ/AuxLemmas.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
PiQ/AuxLemmas.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
PiQ/AuxLemmas.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
module PiQ.AuxLemmas where open import Data.Empty open import Data.Unit hiding (_≟_) open import Data.Sum open import Data.Product open import Data.Maybe open import Relation.Binary.Core open import Relation.Binary open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import PiQ.Syntax open import PiQ.Opsem Lemma₁ : ∀ {A B C D v v' κ κ'} {c : A ↔ B} {c' : C ↔ D} → [ c ∣ v ∣ κ ]◁ ↦ ⟨ c' ∣ v' ∣ κ' ⟩◁ → A ≡ C × B ≡ D Lemma₁ ↦⃖₁ = refl , refl Lemma₁ ↦⃖₂ = refl , refl Lemma₁ ↦⃖ηₓ₁ = refl , refl Lemma₁ ↦⃖εₓ = refl , refl Lemma₂ : ∀ {A B v v' κ κ'} {c c' : A ↔ B} → [ c ∣ v ∣ κ ]◁ ↦ ⟨ c' ∣ v' ∣ κ' ⟩◁ → c ≡ c' × κ ≡ κ' Lemma₂ ↦⃖₁ = refl , refl Lemma₂ ↦⃖₂ = refl , refl Lemma₂ ↦⃖ηₓ₁ = refl , refl Lemma₂ ↦⃖εₓ = refl , refl Lemma₃ : ∀ {A B v v' κ} {c : A ↔ B} → [ c ∣ v ∣ κ ]◁ ↦ ⟨ c ∣ v' ∣ κ ⟩◁ → base c ⊎ dual c ⊎ A ≡ B Lemma₃ (↦⃖₁ {b = b}) = inj₁ b Lemma₃ ↦⃖₂ = inj₂ (inj₂ refl) Lemma₃ ↦⃖ηₓ₁ = inj₂ (inj₁ tt) Lemma₃ ↦⃖εₓ = inj₂ (inj₁ tt) Lemma₄ : ∀ {A v v' κ} {c : A ↔ A} → [ c ∣ v ∣ κ ]◁ ↦ ⟨ c ∣ v' ∣ κ ⟩◁ → base c ⊎ c ≡ id↔ Lemma₄ (↦⃖₁ {b = b}) = inj₁ b Lemma₄ ↦⃖₂ = inj₂ refl Lemma₅ : ∀ {A B C D v v' κ κ'} {c : A ↔ B} {c' : C ↔ D} → [ c ∣ v ∣ κ ]◁ ↦ [ c' ∣ v' ∣ κ' ]▷ → A ≡ C × B ≡ D Lemma₅ ↦η₊₁ = refl , refl Lemma₅ ↦η₊₂ = refl , refl Lemma₆ : ∀ {A B v v' κ κ'} {c c' : A ↔ B} → [ c ∣ v ∣ κ ]◁ ↦ [ c' ∣ v' ∣ κ' ]▷ → c ≡ c' × κ ≡ κ' Lemma₆ ↦η₊₁ = refl , refl Lemma₆ ↦η₊₂ = refl , refl Lemma₇ : ∀ {A B v v' κ} {c : A ↔ B} → [ c ∣ v ∣ κ ]◁ ↦ [ c ∣ v' ∣ κ ]▷ → A ≡ 𝟘 Lemma₇ ↦η₊₁ = refl Lemma₇ ↦η₊₂ = refl Lemma₈ : ∀ {A B v κ} {c : A ↔ B} → [ c ∣ v ∣ κ ]◁ ↦ ⊠ → ¬ (base c) Lemma₈ ↦⃖ηₓ₂ () Lemma₉ : ∀ {A B} {κ : Context} {v : ⟦ B ⟧} {v' : ⟦ A ⟧} {c : A ↔ B} → [ c ∣ v ∣ κ ]◁ ↦ ⟨ c ∣ v' ∣ κ ⟩◁ → [ c ∣ v ∣ κ ]◁ ↦ ⊠ → ⊥ Lemma₉ r' r with Lemma₈ r Lemma₉ (↦⃖₁ {b = b}) r | nb = nb b Lemma₉ (↦⃖ηₓ₁ {eq = eq}) (↦⃖ηₓ₂ {neq = neq}) | _ = ⊥-elim (neq eq) Lemma₁₀ : ∀ {A B C D v v' κ κ'} {c : A ↔ B} {c' : C ↔ D} → ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c' ∣ v' ∣ κ' ]▷ → (A ≡ C × B ≡ D) Lemma₁₀ ↦⃗₁ = refl , refl Lemma₁₀ ↦⃗₂ = refl , refl Lemma₁₀ ↦⃗ηₓ = refl , refl Lemma₁₀ ↦⃗εₓ₁ = refl , refl Lemma₁₁ : ∀ {A B v v' κ κ'} {c c' : A ↔ B} → ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c' ∣ v' ∣ κ' ]▷ → c ≡ c' × κ ≡ κ' Lemma₁₁ ↦⃗₁ = refl , refl Lemma₁₁ ↦⃗₂ = refl , refl Lemma₁₁ ↦⃗ηₓ = refl , refl Lemma₁₁ ↦⃗εₓ₁ = refl , refl Lemma₁₂ : ∀ {A B v v' κ} {c : A ↔ B} → (r : ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c ∣ v' ∣ κ ]▷) → base c ⊎ dual c ⊎ A ≡ B Lemma₁₂ (↦⃗₁ {b = b}) = inj₁ b Lemma₁₂ ↦⃗₂ = inj₂ (inj₂ refl) Lemma₁₂ ↦⃗ηₓ = inj₂ (inj₁ tt) Lemma₁₂ ↦⃗εₓ₁ = inj₂ (inj₁ tt) Lemma₁₃ : ∀ {A v v' κ} {c : A ↔ A} → (r : ⟨ c ∣ v ∣ κ ⟩▷ ↦ [ c ∣ v' ∣ κ ]▷) → base c ⊎ c ≡ id↔ Lemma₁₃ (↦⃗₁ {b = b}) = inj₁ b Lemma₁₃ ↦⃗₂ = inj₂ refl
27.75
67
0.442827
adfe6d5f21762f6d5f167f86afc7fbcc08f6f754
747
agda
Agda
agda/BSTree.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
6
2015-05-21T12:50:35.000Z
2021-08-24T22:11:15.000Z
agda/BSTree.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
agda/BSTree.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
module BSTree {A : Set}(_≤_ : A → A → Set) where open import BTree {A} data _⊴*_ : A → BTree → Set where gelf : {x : A} → x ⊴* leaf gend : {x y : A}{l r : BTree} → x ≤ y → x ⊴* l → x ⊴* (node y l r) data _*⊴_ : BTree → A → Set where lelf : {x : A} → leaf *⊴ x lend : {x y : A}{l r : BTree} → y ≤ x → r *⊴ x → (node y l r) *⊴ x data BSTree : BTree → Set where slf : BSTree leaf snd : {x : A}{l r : BTree} → BSTree l → BSTree r → l *⊴ x → x ⊴* r → BSTree (node x l r)
23.34375
49
0.317269
19d964a3e3e98438856158bc2cbe7d1ea0f22278
1,506
agda
Agda
theorems/cw/cohomology/AxiomaticIsoCellular.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
theorems/cw/cohomology/AxiomaticIsoCellular.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
theorems/cw/cohomology/AxiomaticIsoCellular.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
50
2015-01-10T01:48:08.000Z
2022-02-14T03:03:25.000Z
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cw.CW open import cw.FinCW open import cw.FinBoundary open import cohomology.ChainComplex open import cohomology.Theory module cw.cohomology.AxiomaticIsoCellular (OT : OrdinaryTheory lzero) where open OrdinaryTheory OT open import cw.cohomology.cellular.ChainComplex import cw.cohomology.reconstructed.cochain.Complex OT as RCC open import cw.cohomology.ReconstructedCohomologyGroups OT open import cw.cohomology.ReconstructedCochainsEquivCellularCochains OT axiomatic-iso-cellular : ∀ m {n} (⊙fin-skel : ⊙FinSkeleton n) → C m ⊙⟦ ⊙⦉ ⊙fin-skel ⦊ ⟧ ≃ᴳ cohomology-group (cochain-complex ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ (FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel)) (FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel)) (C2-abgroup 0)) m axiomatic-iso-cellular m ⊙fin-skel = C m ⊙⟦ ⊙⦉ ⊙fin-skel ⦊ ⟧ ≃ᴳ⟨ reconstructed-cohomology-group m ⊙⦉ ⊙fin-skel ⦊ (⊙FinSkeleton-has-cells-with-choice 0 ⊙fin-skel lzero) ⟩ cohomology-group (RCC.cochain-complex ⊙⦉ ⊙fin-skel ⦊) m ≃ᴳ⟨ frc-iso-fcc ⊙fin-skel m ⟩ cohomology-group (cochain-complex ⦉ ⊙FinSkeleton.skel ⊙fin-skel ⦊ (FinSkeleton-has-cells-with-dec-eq (⊙FinSkeleton.skel ⊙fin-skel)) (FinSkeleton-has-degrees-with-finite-support (⊙FinSkeleton.skel ⊙fin-skel)) (C2-abgroup 0)) m ≃ᴳ∎
38.615385
85
0.675299
22d694b9633a3da5a503439f497916890553fbb2
475
agda
Agda
Function/Reasoning.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
6
2020-09-11T17:45:41.000Z
2021-11-16T08:11:34.000Z
Function/Reasoning.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
null
null
null
Function/Reasoning.agda
oisdk/agda-playground
97a3aab1282b2337c5f43e2cfa3fa969a94c11b7
[ "MIT" ]
1
2021-11-11T12:30:21.000Z
2021-11-11T12:30:21.000Z
{-# OPTIONS --without-K --safe #-} module Function.Reasoning where open import Level infixr 2 _⟨⟩⇒_ ⟨∙⟩⇒-syntax ⟨∙⟩⇒-syntax : ∀ (A : Type a) → (B → C) → (A → B) → A → C ⟨∙⟩⇒-syntax _ f g x = f (g x) syntax ⟨∙⟩⇒-syntax A f g = A ⟨ g ⟩⇒ f _⟨⟩⇒_ : ∀ (A : Type a) → (A → B) → A → B _ ⟨⟩⇒ f = f infix 2.5 _⇒∎ _⇒∎ : (A : Type a) → A → A _⇒∎ _ x = x infixr 1.5 [_]⇒_ [_]⇒_ : A → (A → B) → B [ x ]⇒ f = f x -- infix 2.5 _⇒[_] -- _⇒[_] : (A : Type a) → A → A -- _ ⇒[ x ] = x
16.964286
56
0.429474
9a73a6dbfb367b517e825b9ac607ebe43478c431
1,049
agda
Agda
Cubical/Algebra/CommMonoid/CommMonoidProd.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
Cubical/Algebra/CommMonoid/CommMonoidProd.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
Cubical/Algebra/CommMonoid/CommMonoidProd.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.Algebra.CommMonoid.CommMonoidProd where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Algebra.CommMonoid.Base open CommMonoidStr private variable ℓ ℓ' : Level CommMonoidProd : CommMonoid ℓ → CommMonoid ℓ' → CommMonoid (ℓ-max ℓ ℓ') CommMonoidProd M N = makeCommMonoid ε× _·×_ is-set× assoc× ·IdR× comm× where ε× : (fst M) × (fst N) ε× = (ε (snd M)) , (ε (snd N)) _·×_ : (fst M) × (fst N) → (fst M) × (fst N) → (fst M) × (fst N) (x₁ , x₂) ·× (y₁ , y₂) = (_·_ (snd M) x₁ y₁) , (_·_ (snd N) x₂ y₂) is-set× : isSet ((fst M) × (fst N)) is-set× = isSet× (is-set (snd M)) (is-set (snd N)) assoc× : ∀ x y z → x ·× (y ·× z) ≡ (x ·× y) ·× z assoc× _ _ _ = cong₂ (_,_) (·Assoc (snd M) _ _ _) (·Assoc (snd N) _ _ _) ·IdR× : ∀ x → x ·× ε× ≡ x ·IdR× _ = cong₂ (_,_) (·IdR (snd M) _) (·IdR (snd N) _) comm× : ∀ x y → x ·× y ≡ y ·× x comm× _ _ = cong₂ (_,_) (·Comm (snd M) _ _) (·Comm (snd N) _ _)
27.605263
74
0.56244
1944b479cb72eb23fb4f52a312b4cd5b0cf0e9c5
2,160
agda
Agda
Cubical/Categories/Instances/CommRings.agda
antoinevanmuylder/cubical
5b40df813434aa11631ac240409ca2c4d849453c
[ "MIT" ]
null
null
null
Cubical/Categories/Instances/CommRings.agda
antoinevanmuylder/cubical
5b40df813434aa11631ac240409ca2c4d849453c
[ "MIT" ]
null
null
null
Cubical/Categories/Instances/CommRings.agda
antoinevanmuylder/cubical
5b40df813434aa11631ac240409ca2c4d849453c
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.Categories.Instances.CommRings where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Structure open import Cubical.Data.Unit open import Cubical.Data.Sigma open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.FiberedProduct open import Cubical.Algebra.CommRing.Instances.Unit open import Cubical.Categories.Category open import Cubical.Categories.Limits.Terminal open import Cubical.Categories.Limits.Pullback open Category hiding (_∘_) open CommRingHoms private variable ℓ : Level CommRingsCategory : Category (ℓ-suc ℓ) ℓ ob CommRingsCategory = CommRing _ Hom[_,_] CommRingsCategory = CommRingHom id CommRingsCategory {R} = idCommRingHom R _⋆_ CommRingsCategory {R} {S} {T} = compCommRingHom R S T ⋆IdL CommRingsCategory {R} {S} = compIdCommRingHom {R = R} {S} ⋆IdR CommRingsCategory {R} {S} = idCompCommRingHom {R = R} {S} ⋆Assoc CommRingsCategory {R} {S} {T} {U} = compAssocCommRingHom {R = R} {S} {T} {U} isSetHom CommRingsCategory = isSetRingHom _ _ TerminalCommRing : Terminal {ℓ-suc ℓ-zero} CommRingsCategory fst TerminalCommRing = UnitCommRing fst (fst (snd TerminalCommRing y)) _ = tt snd (fst (snd TerminalCommRing y)) = makeIsRingHom refl (λ _ _ → refl) (λ _ _ → refl) snd (snd TerminalCommRing y) f = RingHom≡ (funExt (λ _ → refl)) open Pullback {- A x_C B -----> A | | | | α | | V V B --------> C β -} PullbackCommRing : Pullbacks {ℓ-suc ℓ} CommRingsCategory pbOb (PullbackCommRing (cospan A C B α β)) = fiberedProduct A B C α β pbPr₁ (PullbackCommRing (cospan A C B α β)) = fiberedProductPr₁ A B C α β pbPr₂ (PullbackCommRing (cospan A C B α β)) = fiberedProductPr₂ A B C α β pbCommutes (PullbackCommRing (cospan A C B α β)) = fiberedProductPr₁₂Commutes A B C α β univProp (PullbackCommRing (cospan A C B α β)) {d = D} = fiberedProductUnivProp A B C α β D
34.83871
91
0.688889
5e84ac9ba593a8bca5669d4fb14fe4113ff8c958
180
agda
Agda
Cubical/HITs/Localization.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
1
2020-03-23T23:52:11.000Z
2020-03-23T23:52:11.000Z
Cubical/HITs/Localization.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/HITs/Localization.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Localization where open import Cubical.HITs.Localization.Base public open import Cubical.HITs.Localization.Properties public
25.714286
55
0.8
3001b51e6643bad7ff71d0c9a4c0b8e749fa4cc5
1,190
agda
Agda
Basic/Axiomatic/TotalImpliesPartial.agda
AndrasKovacs/SemanticsWithApplications
05200d60b4a4b2c6fa37806ced9247055d24db94
[ "MIT" ]
8
2016-09-12T04:25:39.000Z
2020-02-02T10:01:52.000Z
Basic/Axiomatic/TotalImpliesPartial.agda
AndrasKovacs/SemanticsWithApplications
05200d60b4a4b2c6fa37806ced9247055d24db94
[ "MIT" ]
null
null
null
Basic/Axiomatic/TotalImpliesPartial.agda
AndrasKovacs/SemanticsWithApplications
05200d60b4a4b2c6fa37806ced9247055d24db94
[ "MIT" ]
null
null
null
module Basic.Axiomatic.TotalImpliesPartial where open import Basic.AST open import Basic.BigStep open import Basic.Axiomatic.Total as T renaming (〈_〉_〈_〉 to total〈_〉_〈_〉) open import Basic.Axiomatic.Partial as P renaming (〈_〉_〈_〉 to partial〈_〉_〈_〉) hiding (_==>_; _∧_) open import Function open import Data.Product {- The proof that total correctness implies partial correctness (exercise 6.33) is fortunately really simple. We already proved soundness and completeness for both systems, so instead of trying to construct the partial proof directly from the total proof, we can just take a detour and prove the analoguous implication about the *validity* of triples. -} {- The total validity of Hoare triples implies partial validity, if the language semantics is deterministic. -} P==>wp→P==>wlp : ∀{n S}{P Q : State n → Set} → (P ==> wp S Q) → (P ==> wlp S Q) P==>wp→P==>wlp pwp ps runS with pwp ps ... | _ , runS' , qs' rewrite deterministic runS runS' = qs' {- And now we just do an excursion to semantics-land and then back -} total→partial : ∀ {n S}{P Q : State n → Set} → total〈 P 〉 S 〈 Q 〉 → partial〈 P 〉 S 〈 Q 〉 total→partial = P.complete _ ∘ P==>wp→P==>wlp ∘ T.sound
34
90
0.706723
22aebabb4f316386ce387d994db4108d379bf107
14,709
agda
Agda
theorems/homotopy/PtdAdjoint.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
theorems/homotopy/PtdAdjoint.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
theorems/homotopy/PtdAdjoint.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
50
2015-01-10T01:48:08.000Z
2022-02-14T03:03:25.000Z
{-# OPTIONS --without-K --rewriting #-} open import HoTT {- The pseudo-adjoint functors F,G : Ptd → Ptd - It stops at composition and ignores - all the higher associahedrons. -} module homotopy.PtdAdjoint where record PtdFunctor i j : Type (lsucc (lmax i j)) where field obj : Ptd i → Ptd j arr : {X Y : Ptd i} → X ⊙→ Y → obj X ⊙→ obj Y id : (X : Ptd i) → arr (⊙idf X) == ⊙idf (obj X) comp : {X Y Z : Ptd i} (g : Y ⊙→ Z) (f : X ⊙→ Y) → arr (g ⊙∘ f) == arr g ⊙∘ arr f {- counit-unit description of F ⊣ G -} record CounitUnitAdjoint {i j} (F : PtdFunctor i j) (G : PtdFunctor j i) : Type (lsucc (lmax i j)) where private module F = PtdFunctor F module G = PtdFunctor G field η : (X : Ptd i) → (X ⊙→ G.obj (F.obj X)) ε : (U : Ptd j) → (F.obj (G.obj U) ⊙→ U) η-natural : {X Y : Ptd i} (h : X ⊙→ Y) → η Y ⊙∘ h == G.arr (F.arr h) ⊙∘ η X ε-natural : {U V : Ptd j} (k : U ⊙→ V) → ε V ⊙∘ F.arr (G.arr k) == k ⊙∘ ε U εF-Fη : (X : Ptd i) → ε (F.obj X) ⊙∘ F.arr (η X) == ⊙idf (F.obj X) Gε-ηG : (U : Ptd j) → G.arr (ε U) ⊙∘ η (G.obj U) == ⊙idf (G.obj U) {- hom-set isomorphism description of F ⊣ G -} record HomAdjoint {i j} (F : PtdFunctor i j) (G : PtdFunctor j i) : Type (lsucc (lmax i j)) where private module F = PtdFunctor F module G = PtdFunctor G field eq : (X : Ptd i) (U : Ptd j) → (F.obj X ⊙→ U) ≃ (X ⊙→ G.obj U) nat-dom : {X Y : Ptd i} (h : X ⊙→ Y) (U : Ptd j) (r : F.obj Y ⊙→ U) → –> (eq Y U) r ⊙∘ h == –> (eq X U) (r ⊙∘ F.arr h) nat-cod : (X : Ptd i) {U V : Ptd j} (k : U ⊙→ V) (r : F.obj X ⊙→ U) → G.arr k ⊙∘ –> (eq X U) r == –> (eq X V) (k ⊙∘ r) nat!-dom : {X Y : Ptd i} (h : X ⊙→ Y) (U : Ptd j) (s : Y ⊙→ G.obj U) → <– (eq Y U) s ⊙∘ F.arr h == <– (eq X U) (s ⊙∘ h) nat!-dom {X} {Y} h U s = ! (<–-inv-l (eq X U) (<– (eq Y U) s ⊙∘ F.arr h)) ∙ ap (<– (eq X U)) (! (nat-dom h U (<– (eq Y U) s))) ∙ ap (λ w → <– (eq X U) (w ⊙∘ h)) (<–-inv-r (eq Y U) s) nat!-cod : (X : Ptd i) {U V : Ptd j} (k : U ⊙→ V) (s : X ⊙→ G.obj U) → k ⊙∘ <– (eq X U) s == <– (eq X V) (G.arr k ⊙∘ s) nat!-cod X {U} {V} k s = ! (<–-inv-l (eq X V) (k ⊙∘ <– (eq X U) s)) ∙ ap (<– (eq X V)) (! (nat-cod X k (<– (eq X U) s))) ∙ ap (λ w → <– (eq X V) (G.arr k ⊙∘ w)) (<–-inv-r (eq X U) s) counit-unit-to-hom : ∀ {i j} {F : PtdFunctor i j} {G : PtdFunctor j i} → CounitUnitAdjoint F G → HomAdjoint F G counit-unit-to-hom {i} {j} {F} {G} adj = record { eq = eq; nat-dom = nat-dom; nat-cod = nat-cod} where module F = PtdFunctor F module G = PtdFunctor G open CounitUnitAdjoint adj module _ (X : Ptd i) (U : Ptd j) where into : F.obj X ⊙→ U → X ⊙→ G.obj U into r = G.arr r ⊙∘ η X out : X ⊙→ G.obj U → F.obj X ⊙→ U out s = ε U ⊙∘ F.arr s into-out : (s : X ⊙→ G.obj U) → into (out s) == s into-out s = G.arr (ε U ⊙∘ F.arr s) ⊙∘ η X =⟨ G.comp (ε U) (F.arr s) |in-ctx (λ w → w ⊙∘ η X) ⟩ (G.arr (ε U) ⊙∘ G.arr (F.arr s)) ⊙∘ η X =⟨ ⊙λ= $ ⊙∘-assoc (G.arr (ε U)) (G.arr (F.arr s)) (η X) ⟩ G.arr (ε U) ⊙∘ G.arr (F.arr s) ⊙∘ η X =⟨ ! (η-natural s) |in-ctx (λ w → G.arr (ε U) ⊙∘ w) ⟩ G.arr (ε U) ⊙∘ η (G.obj U) ⊙∘ s =⟨ ! $ ⊙λ= (⊙∘-assoc (G.arr (ε U)) (η (G.obj U)) s) ⟩ (G.arr (ε U) ⊙∘ η (G.obj U)) ⊙∘ s =⟨ Gε-ηG U |in-ctx (λ w → w ⊙∘ s) ⟩ ⊙idf (G.obj U) ⊙∘ s =⟨ ⊙λ= $ ⊙∘-unit-l s ⟩ s ∎ out-into : (r : F.obj X ⊙→ U) → out (into r) == r out-into r = ε U ⊙∘ F.arr (G.arr r ⊙∘ η X) =⟨ F.comp (G.arr r) (η X) |in-ctx (λ w → ε U ⊙∘ w) ⟩ ε U ⊙∘ F.arr (G.arr r) ⊙∘ F.arr (η X) =⟨ ! $ ⊙λ= (⊙∘-assoc (ε U) (F.arr (G.arr r)) (F.arr (η X))) ⟩ (ε U ⊙∘ F.arr (G.arr r)) ⊙∘ F.arr (η X) =⟨ ε-natural r |in-ctx (λ w → w ⊙∘ F.arr (η X)) ⟩ (r ⊙∘ ε (F.obj X)) ⊙∘ F.arr (η X) =⟨ ⊙λ= $ ⊙∘-assoc r (ε (F.obj X)) (F.arr (η X)) ⟩ r ⊙∘ ε (F.obj X) ⊙∘ F.arr (η X) =⟨ εF-Fη X |in-ctx (λ w → r ⊙∘ w) ⟩ r ∎ eq : (F.obj X ⊙→ U) ≃ (X ⊙→ G.obj U) eq = equiv into out into-out out-into nat-dom : {X Y : Ptd i} (h : X ⊙→ Y) (U : Ptd j) (r : F.obj Y ⊙→ U) → –> (eq Y U) r ⊙∘ h == –> (eq X U) (r ⊙∘ F.arr h) nat-dom {X} {Y} h U r = (G.arr r ⊙∘ η Y) ⊙∘ h =⟨ ⊙λ= $ ⊙∘-assoc (G.arr r) (η Y) h ⟩ G.arr r ⊙∘ η Y ⊙∘ h =⟨ η-natural h |in-ctx (λ w → G.arr r ⊙∘ w) ⟩ G.arr r ⊙∘ G.arr (F.arr h) ⊙∘ η X =⟨ ! $ ⊙λ= (⊙∘-assoc (G.arr r) (G.arr (F.arr h)) (η X)) ⟩ (G.arr r ⊙∘ G.arr (F.arr h)) ⊙∘ η X =⟨ ! (G.comp r (F.arr h)) |in-ctx (λ w → w ⊙∘ η X) ⟩ G.arr (r ⊙∘ F.arr h) ⊙∘ η X ∎ nat-cod : (X : Ptd i) {U V : Ptd j} (k : U ⊙→ V) (r : F.obj X ⊙→ U) → G.arr k ⊙∘ –> (eq X U) r == –> (eq X V) (k ⊙∘ r) nat-cod X k r = G.arr k ⊙∘ (G.arr r ⊙∘ η X) =⟨ ! $ ⊙λ= (⊙∘-assoc (G.arr k) (G.arr r) (η X)) ⟩ (G.arr k ⊙∘ G.arr r) ⊙∘ η X =⟨ ! (G.comp k r) |in-ctx (λ w → w ⊙∘ η X) ⟩ G.arr (k ⊙∘ r) ⊙∘ η X ∎ {- a right adjoint preserves products -} module RightAdjoint× {i j} {F : PtdFunctor i j} {G : PtdFunctor j i} (adj : HomAdjoint F G) (U V : Ptd j) where private module F = PtdFunctor F module G = PtdFunctor G module A = HomAdjoint adj ⊙into : G.obj (U ⊙× V) ⊙→ G.obj U ⊙× G.obj V ⊙into = ⊙fanout (G.arr ⊙fst) (G.arr ⊙snd) ⊙out : G.obj U ⊙× G.obj V ⊙→ G.obj (U ⊙× V) ⊙out = –> (A.eq (G.obj U ⊙× G.obj V) (U ⊙× V)) (⊙fanout (<– (A.eq (G.obj U ⊙× G.obj V) U) ⊙fst) (<– (A.eq (G.obj U ⊙× G.obj V) V) ⊙snd)) ⊙into-out : ⊙into ⊙∘ ⊙out == ⊙idf (G.obj U ⊙× G.obj V) ⊙into-out = ⊙fanout (G.arr ⊙fst) (G.arr ⊙snd) ⊙∘ ⊙out =⟨ ⊙fanout-pre∘ (G.arr ⊙fst) (G.arr ⊙snd) ⊙out ⟩ ⊙fanout (G.arr ⊙fst ⊙∘ ⊙out) (G.arr ⊙snd ⊙∘ ⊙out) =⟨ ap2 ⊙fanout (A.nat-cod _ ⊙fst (⊙fanout (<– (A.eq (G.obj U ⊙× G.obj V) U) ⊙fst) (<– (A.eq (G.obj U ⊙× G.obj V) V) ⊙snd)) ∙ ap (–> (A.eq (G.obj U ⊙× G.obj V) U)) (⊙fst-fanout (<– (A.eq (G.obj U ⊙× G.obj V) U) ⊙fst) (<– (A.eq (G.obj U ⊙× G.obj V) V) ⊙snd)) ∙ <–-inv-r (A.eq (G.obj U ⊙× G.obj V) U) ⊙fst) (A.nat-cod _ ⊙snd (⊙fanout (<– (A.eq (G.obj U ⊙× G.obj V) U) ⊙fst) (<– (A.eq (G.obj U ⊙× G.obj V) V) ⊙snd)) ∙ ap (–> (A.eq (G.obj U ⊙× G.obj V) V)) (⊙snd-fanout (<– (A.eq (G.obj U ⊙× G.obj V) U) ⊙fst) (<– (A.eq (G.obj U ⊙× G.obj V) V) ⊙snd)) ∙ <–-inv-r (A.eq (G.obj U ⊙× G.obj V) V) ⊙snd) ⟩ ⊙fanout ⊙fst ⊙snd ∎ ⊙out-into : ⊙out ⊙∘ ⊙into == ⊙idf _ ⊙out-into = –> (A.eq (G.obj U ⊙× G.obj V) (U ⊙× V)) (⊙fanout (<– (A.eq (G.obj U ⊙× G.obj V) U) ⊙fst) (<– (A.eq (G.obj U ⊙× G.obj V) V) ⊙snd)) ⊙∘ ⊙fanout (G.arr ⊙fst) (G.arr ⊙snd) =⟨ A.nat-dom (⊙fanout (G.arr ⊙fst) (G.arr ⊙snd)) _ (⊙fanout (<– (A.eq (G.obj U ⊙× G.obj V) U) ⊙fst) (<– (A.eq (G.obj U ⊙× G.obj V) V) ⊙snd)) ⟩ –> (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (⊙fanout (<– (A.eq (G.obj U ⊙× G.obj V) U) ⊙fst) (<– (A.eq (G.obj U ⊙× G.obj V) V) ⊙snd) ⊙∘ F.arr (⊙fanout (G.arr ⊙fst) (G.arr ⊙snd))) =⟨ ⊙fanout-pre∘ (<– (A.eq (G.obj U ⊙× G.obj V) U) ⊙fst) (<– (A.eq (G.obj U ⊙× G.obj V) V) ⊙snd) (F.arr (⊙fanout (G.arr ⊙fst) (G.arr ⊙snd))) |in-ctx –> (A.eq _ _) ⟩ –> (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (⊙fanout (<– (A.eq (G.obj U ⊙× G.obj V) U) ⊙fst ⊙∘ F.arr (⊙fanout (G.arr ⊙fst) (G.arr ⊙snd))) (<– (A.eq (G.obj U ⊙× G.obj V) V) ⊙snd ⊙∘ F.arr (⊙fanout (G.arr ⊙fst) (G.arr ⊙snd)))) =⟨ ap2 (λ f g → –> (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (⊙fanout f g)) (A.nat!-dom (⊙fanout (G.arr ⊙fst) (G.arr ⊙snd)) _ ⊙fst ∙ ap (<– (A.eq (G.obj (U ⊙× V)) U)) (⊙fst-fanout (G.arr ⊙fst) (G.arr ⊙snd)) ∙ ! (A.nat!-cod _ ⊙fst (⊙idf _))) (A.nat!-dom (⊙fanout (G.arr ⊙fst) (G.arr ⊙snd)) _ ⊙snd ∙ ap (<– (A.eq (G.obj (U ⊙× V)) V)) (⊙snd-fanout (G.arr ⊙fst) (G.arr ⊙snd)) ∙ ! (A.nat!-cod _ ⊙snd (⊙idf _))) ⟩ –> (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (⊙fanout (⊙fst ⊙∘ <– (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (⊙idf _)) (⊙snd ⊙∘ <– (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (⊙idf _))) =⟨ ap (–> (A.eq (G.obj (U ⊙× V)) (U ⊙× V))) (! (⊙fanout-pre∘ ⊙fst ⊙snd (<– (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (⊙idf _)))) ⟩ –> (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (⊙fanout ⊙fst ⊙snd ⊙∘ <– (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (⊙idf _)) =⟨ ⊙λ= (⊙∘-unit-l _) |in-ctx –> (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) ⟩ –> (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (<– (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (⊙idf _)) =⟨ <–-inv-r (A.eq (G.obj (U ⊙× V)) (U ⊙× V)) (⊙idf _) ⟩ ⊙idf _ ∎ ⊙eq : G.obj (U ⊙× V) ⊙≃ G.obj U ⊙× G.obj V ⊙eq = ≃-to-⊙≃ (equiv (fst ⊙into) (fst ⊙out) (app= (ap fst ⊙into-out)) (app= (ap fst ⊙out-into))) (snd ⊙into) ⊙path = ⊙ua ⊙eq {- Using the equivalence in RightAdjoint× we get a binary - "G.arr2" : (X × Y → Z) → (G X × G Y → G Z) - and there is some kind of naturality wrt the (FX→Y)≃(X→GY) equivalence - (use case: from ⊙ap we get ⊙ap2) -} module RightAdjointBinary {i j} {F : PtdFunctor i j} {G : PtdFunctor j i} (adj : HomAdjoint F G) where private module F = PtdFunctor F module G = PtdFunctor G module A = HomAdjoint adj module A× = RightAdjoint× adj arr2 : {X Y Z : Ptd j} → X ⊙× Y ⊙→ Z → G.obj X ⊙× G.obj Y ⊙→ G.obj Z arr2 {X} {Y} {Z} f = G.arr f ⊙∘ A×.⊙out X Y nat-cod : {X : Ptd i} {Y Z W : Ptd j} (r₁ : F.obj X ⊙→ Y) (r₂ : F.obj X ⊙→ Z) (o : Y ⊙× Z ⊙→ W) → –> (A.eq X W) (o ⊙∘ ⊙fanout r₁ r₂) == arr2 o ⊙∘ ⊙fanout (–> (A.eq X Y) r₁) (–> (A.eq X Z) r₂) nat-cod {X} {Y} {Z} {W} r₁ r₂ o = –> (A.eq X W) (o ⊙∘ ⊙fanout r₁ r₂) =⟨ ! (A.nat-cod X o (⊙fanout r₁ r₂)) ⟩ G.arr o ⊙∘ –> (A.eq X (Y ⊙× Z)) (⊙fanout r₁ r₂) =⟨ ! (A×.⊙out-into Y Z) |in-ctx (λ w → (G.arr o ⊙∘ w) ⊙∘ –> (A.eq X (Y ⊙× Z)) (⊙fanout r₁ r₂)) ⟩ (G.arr o ⊙∘ (A×.⊙out Y Z ⊙∘ A×.⊙into Y Z)) ⊙∘ –> (A.eq X (Y ⊙× Z)) (⊙fanout r₁ r₂) =⟨ ⊙∘-assoc-lemma (G.arr o) (A×.⊙out Y Z) (A×.⊙into Y Z) (–> (A.eq X (Y ⊙× Z)) (⊙fanout r₁ r₂)) ⟩ arr2 o ⊙∘ A×.⊙into Y Z ⊙∘ –> (A.eq X (Y ⊙× Z)) (⊙fanout r₁ r₂) =⟨ ⊙fanout-pre∘ (G.arr ⊙fst) (G.arr ⊙snd) (–> (A.eq X (Y ⊙× Z)) (⊙fanout r₁ r₂)) |in-ctx (λ w → arr2 o ⊙∘ w) ⟩ arr2 o ⊙∘ ⊙fanout (G.arr ⊙fst ⊙∘ –> (A.eq X (Y ⊙× Z)) (⊙fanout r₁ r₂)) (G.arr ⊙snd ⊙∘ –> (A.eq X (Y ⊙× Z)) (⊙fanout r₁ r₂)) =⟨ ap2 (λ w₁ w₂ → arr2 o ⊙∘ ⊙fanout w₁ w₂) (A.nat-cod X ⊙fst (⊙fanout r₁ r₂) ∙ ap (–> (A.eq X Y)) (⊙fst-fanout r₁ r₂)) (A.nat-cod X ⊙snd (⊙fanout r₁ r₂) ∙ ap (–> (A.eq X Z)) (⊙snd-fanout r₁ r₂)) ⟩ arr2 o ⊙∘ ⊙fanout (–> (A.eq X Y) r₁) (–> (A.eq X Z) r₂) ∎ where ⊙∘-assoc-lemma : ∀ {i j k l m} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {U : Ptd l} {V : Ptd m} (k : U ⊙→ V) (h : Z ⊙→ U) (g : Y ⊙→ Z) (f : X ⊙→ Y) → (k ⊙∘ (h ⊙∘ g)) ⊙∘ f == (k ⊙∘ h) ⊙∘ g ⊙∘ f ⊙∘-assoc-lemma (k , idp) (h , idp) (g , idp) (f , idp) = idp {- a left adjoint preserves wedges -} module LeftAdjoint∨ {i j} {F : PtdFunctor i j} {G : PtdFunctor j i} (adj : HomAdjoint F G) (U V : Ptd i) where private module F = PtdFunctor F module G = PtdFunctor G module A = HomAdjoint adj module Into = ⊙WedgeRec (F.arr ⊙winl) (F.arr ⊙winr) ⊙into : F.obj U ⊙∨ F.obj V ⊙→ F.obj (U ⊙∨ V) ⊙into = Into.⊙f module OutHelp = ⊙WedgeRec (–> (A.eq U (F.obj U ⊙∨ F.obj V)) ⊙winl) (–> (A.eq V (F.obj U ⊙∨ F.obj V)) ⊙winr) ⊙out : F.obj (U ⊙∨ V) ⊙→ F.obj U ⊙∨ F.obj V ⊙out = <– (A.eq (U ⊙∨ V) (F.obj U ⊙∨ F.obj V)) OutHelp.⊙f ⊙into-out : ⊙into ⊙∘ ⊙out == ⊙idf (F.obj (U ⊙∨ V)) ⊙into-out = ⊙into ⊙∘ ⊙out =⟨ A.nat!-cod _ ⊙into (⊙Wedge-rec (–> (A.eq U (F.obj U ⊙∨ F.obj V)) ⊙winl) (–> (A.eq V (F.obj U ⊙∨ F.obj V)) ⊙winr)) ⟩ <– (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (G.arr ⊙into ⊙∘ ⊙Wedge-rec (–> (A.eq U (F.obj U ⊙∨ F.obj V)) ⊙winl) (–> (A.eq V (F.obj U ⊙∨ F.obj V)) ⊙winr)) =⟨ ap (<– (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V)))) $ ⊙λ= $ ⊙Wedge-rec-post∘ (G.arr ⊙into) (–> (A.eq U (F.obj U ⊙∨ F.obj V)) ⊙winl) (–> (A.eq V (F.obj U ⊙∨ F.obj V)) ⊙winr) ⟩ <– (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (⊙Wedge-rec (G.arr ⊙into ⊙∘ –> (A.eq U (F.obj U ⊙∨ F.obj V)) ⊙winl) (G.arr ⊙into ⊙∘ –> (A.eq V (F.obj U ⊙∨ F.obj V)) ⊙winr)) =⟨ ap2 (λ w₁ w₂ → <– (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (⊙Wedge-rec w₁ w₂)) (A.nat-cod _ ⊙into ⊙winl ∙ ap (–> (A.eq U (F.obj (U ⊙∨ V)))) (Into.⊙winl-β ∙ ! (⊙λ= $ ⊙∘-unit-l _)) ∙ ! (A.nat-dom ⊙winl _ (⊙idf _))) (A.nat-cod _ ⊙into ⊙winr ∙ ap (–> (A.eq V (F.obj (U ⊙∨ V)))) (Into.⊙winr-β ∙ ! (⊙λ= $ ⊙∘-unit-l _)) ∙ ! (A.nat-dom ⊙winr _ (⊙idf _))) ⟩ <– (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (⊙Wedge-rec (–> (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (⊙idf _) ⊙∘ ⊙winl) (–> (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (⊙idf _) ⊙∘ ⊙winr)) =⟨ ap (<– (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V)))) $ ! $ ⊙λ= $ ⊙Wedge-rec-post∘ (–> (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (⊙idf _)) ⊙winl ⊙winr ⟩ <– (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (–> (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (⊙idf _) ⊙∘ ⊙Wedge-rec ⊙winl ⊙winr) =⟨ ap (λ w → <– (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (–> (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (⊙idf _) ⊙∘ w)) ⊙Wedge-rec-η ⟩ <– (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (–> (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (⊙idf _)) =⟨ <–-inv-l (A.eq (U ⊙∨ V) (F.obj (U ⊙∨ V))) (⊙idf _) ⟩ ⊙idf _ ∎ ⊙out-into : ⊙out ⊙∘ ⊙into == ⊙idf _ ⊙out-into = ⊙out ⊙∘ ⊙Wedge-rec (F.arr ⊙winl) (F.arr ⊙winr) =⟨ ⊙λ= $ ⊙Wedge-rec-post∘ ⊙out (F.arr ⊙winl) (F.arr ⊙winr) ⟩ ⊙Wedge-rec (⊙out ⊙∘ F.arr ⊙winl) (⊙out ⊙∘ F.arr ⊙winr) =⟨ ap2 ⊙Wedge-rec (A.nat!-dom ⊙winl _ (⊙Wedge-rec _ _) ∙ ap (<– (A.eq U (F.obj U ⊙∨ F.obj V))) OutHelp.⊙winl-β ∙ <–-inv-l (A.eq U (F.obj U ⊙∨ F.obj V)) ⊙winl) (A.nat!-dom ⊙winr _ (⊙Wedge-rec _ _) ∙ ap (<– (A.eq V (F.obj U ⊙∨ F.obj V))) OutHelp.⊙winr-β ∙ <–-inv-l (A.eq V (F.obj U ⊙∨ F.obj V)) ⊙winr) ⟩ ⊙Wedge-rec ⊙winl ⊙winr =⟨ ⊙Wedge-rec-η ⟩ ⊙idf _ ∎ ⊙eq : F.obj U ⊙∨ F.obj V ⊙≃ F.obj (U ⊙∨ V) ⊙eq = ≃-to-⊙≃ (equiv (fst ⊙into) (fst ⊙out) (app= (ap fst ⊙into-out)) (app= (ap fst ⊙out-into))) (snd ⊙into) ⊙path = ⊙ua ⊙eq
42.511561
133
0.410429
22ffa3761b6bc980348448074087462e5e8cb6ba
3,212
agda
Agda
src/Categories/Category/Construction/Properties/EilenbergMoore.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Category/Construction/Properties/EilenbergMoore.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Category/Construction/Properties/EilenbergMoore.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} module Categories.Category.Construction.Properties.EilenbergMoore where open import Level import Relation.Binary.PropositionalEquality.Core as ≡ open import Categories.Adjoint open import Categories.Adjoint.Properties open import Categories.Category open import Categories.Functor using (Functor; _∘F_) open import Categories.Functor.Equivalence open import Categories.Monad open import Categories.NaturalTransformation.Core renaming (id to idN) open import Categories.Morphism.HeterogeneousIdentity open import Categories.Adjoint.Construction.EilenbergMoore open import Categories.Category.Construction.EilenbergMoore private variable o ℓ e : Level 𝒞 𝒟 : Category o ℓ e module _ {F : Functor 𝒞 𝒟} {G : Functor 𝒟 𝒞} (F⊣G : Adjoint F G) where private T : Monad 𝒞 T = adjoint⇒monad F⊣G 𝒞ᵀ : Category _ _ _ 𝒞ᵀ = EilenbergMoore T module 𝒞 = Category 𝒞 module 𝒟 = Category 𝒟 module 𝒞ᵀ = Category 𝒞ᵀ open 𝒞.HomReasoning module T = Monad T module F = Functor F module G = Functor G open Adjoint F⊣G open NaturalTransformation -- Maclane's Comparison Functor ComparisonF : Functor 𝒟 𝒞ᵀ ComparisonF = record { F₀ = λ X → record { A = G.F₀ X ; action = G.F₁ (counit.η X) ; commute = commute (G ∘ˡ counit) (counit.η X) ; identity = zag } ; F₁ = λ {A} {B} f → record { arr = G.F₁ f ; commute = begin 𝒞 [ G.F₁ f ∘ G.F₁ (counit.η A) ] ≈˘⟨ G.homomorphism ⟩ G.F₁ (𝒟 [ f ∘ (counit.η A) ]) ≈˘⟨ G.F-resp-≈ (counit.commute f) ⟩ G.F₁ (𝒟 [ counit.η B ∘ F.F₁ (G.F₁ f) ]) ≈⟨ G.homomorphism ⟩ 𝒞 [ G.F₁ (counit.η B) ∘ G.F₁ (F.F₁ (G.F₁ f)) ] ∎ } ; identity = G.identity ; homomorphism = G.homomorphism ; F-resp-≈ = G.F-resp-≈ } private K = ComparisonF module K = Functor K module Gᵀ = Functor (Forgetful T) module Fᵀ = Functor (Free T) Comparison∘F≡Free : (ComparisonF ∘F F) ≡F Free T Comparison∘F≡Free = record { eq₀ = λ X → ≡.refl ; eq₁ = λ {A} {B} f → begin Module⇒.arr (𝒞ᵀ [ (hid 𝒞ᵀ ≡.refl) ∘ K.F₁ (F.F₁ f) ]) ≈⟨ hid-refl 𝒞ᵀ {A = K.F₀ (F.F₀ B)} ⟩∘⟨refl ⟩ Module⇒.arr (𝒞ᵀ [ 𝒞ᵀ.id ∘ K.F₁ (F.F₁ f) ]) ≈⟨ 𝒞.identityˡ {f = Module⇒.arr (K.F₁ (F.F₁ f))} ⟩ Module⇒.arr (K.F₁ (F.F₁ f)) ≈⟨ 𝒞.Equiv.refl ⟩ Module⇒.arr (Fᵀ.F₁ f) ≈˘⟨ 𝒞ᵀ.identityʳ {f = Fᵀ.F₁ f} ⟩ Module⇒.arr (𝒞ᵀ [ Fᵀ.F₁ f ∘ 𝒞ᵀ.id ]) ≈˘⟨ refl⟩∘⟨ hid-refl 𝒞ᵀ {A = Fᵀ.F₀ A} ⟩ Module⇒.arr (𝒞ᵀ [ Fᵀ.F₁ f ∘ (hid 𝒞ᵀ ≡.refl) ]) ∎ } Forgetful∘ComparisonF≡G : (Forgetful T ∘F ComparisonF) ≡F G Forgetful∘ComparisonF≡G = record { eq₀ = λ X → ≡.refl ; eq₁ = λ f → begin 𝒞 [ (hid 𝒞 ≡.refl) ∘ (Gᵀ.F₁ (K.F₁ f)) ] ≈⟨ hid-refl 𝒞 ⟩∘⟨refl ⟩ 𝒞 [ 𝒞.id ∘ (Gᵀ.F₁ (K.F₁ f)) ] ≈⟨ 𝒞.identityˡ ⟩ (Gᵀ.F₁ (K.F₁ f)) ≈⟨ 𝒞.Equiv.refl ⟩ G.F₁ f ≈˘⟨ 𝒞.identityʳ ⟩ 𝒞 [ G.F₁ f ∘ 𝒞.id ] ≈˘⟨ refl⟩∘⟨ hid-refl 𝒞 ⟩ 𝒞 [ G.F₁ f ∘ (hid 𝒞 ≡.refl) ] ∎ }
33.113402
109
0.548257
c77c0dcbe4670b9346625325a91776d68e98b90a
196
agda
Agda
Cubical/Data/InfNat.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
null
null
null
Cubical/Data/InfNat.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
1
2022-01-27T02:07:48.000Z
2022-01-27T02:07:48.000Z
Cubical/Data/InfNat.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
1
2021-11-22T02:02:01.000Z
2021-11-22T02:02:01.000Z
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Data.InfNat where open import Cubical.Data.InfNat.Base public open import Cubical.Data.InfNat.Properties public
32.666667
67
0.770408
57e185e103a1e426d5bb3770498cbbfe19940863
469
agda
Agda
test/succeed/InstanceArgumentsConstraints.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
null
null
null
test/succeed/InstanceArgumentsConstraints.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
null
null
null
test/succeed/InstanceArgumentsConstraints.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
null
null
null
{-# OPTIONS --verbose tc.constr.findInScope:20 #-} module InstanceArgumentsConstraints where data Bool : Set where true false : Bool postulate A1 A2 B C : Set a1 : A1 a2 : A2 someF : A1 → C record Class (R : Bool → Set) : Set where field f : (t : Bool) → R t open Class {{...}} class1 : Class (λ _ → A1) class1 = record { f = λ _ → a1 } class2 : Class (λ _ → A2) class2 = record { f = λ _ → a2 } test : C test = someF (f true)
18.038462
50
0.573561
d1312dcecbb841265e486013ddd0f09af08453b1
6,381
agda
Agda
src/Categories/Adjoint/TwoSided.agda
turion/agda-categories
ad0f94b6cf18d8a448b844b021aeda58e833d152
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Adjoint/TwoSided.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Adjoint/TwoSided.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} module Categories.Adjoint.TwoSided where -- A "two sided" adjoint is an adjoint of two functors L and R where the -- unit and counit are natural isomorphisms. -- A two sided adjoint is the underlying data to an Adjoint Equivalence open import Level open import Categories.Adjoint open import Categories.Category.Core using (Category) open import Categories.Functor renaming (id to idF) open import Categories.Functor.Properties open import Categories.NaturalTransformation using (ntHelper) open import Categories.NaturalTransformation.NaturalIsomorphism as ≃ using (_≃_; NaturalIsomorphism) open import Categories.NaturalTransformation.NaturalIsomorphism.Properties import Categories.Morphism.Reasoning as MR private variable o ℓ e : Level o′ ℓ′ e′ : Level C D : Category o ℓ e infix 5 _⊣⊢_ record _⊣⊢_ (L : Functor C D) (R : Functor D C) : Set (levelOfTerm L ⊔ levelOfTerm R) where field unit : idF ≃ (R ∘F L) counit : (L ∘F R) ≃ idF module unit = NaturalIsomorphism unit module counit = NaturalIsomorphism counit private module C = Category C using (Obj; id; _∘_; _≈_; module HomReasoning) module D = Category D using (Obj; id; _∘_; _≈_; module HomReasoning) module L = Functor L using (₀; ₁; op; identity) module R = Functor R using (₀; ₁; op; identity) field zig : ∀ {A : C.Obj} → counit.⇒.η (L.₀ A) D.∘ L.₁ (unit.⇒.η A) D.≈ D.id zag : ∀ {B : D.Obj} → R.₁ (counit.⇒.η B) C.∘ unit.⇒.η (R.₀ B) C.≈ C.id op₁ : R.op ⊣⊢ L.op op₁ = record { unit = counit.op ; counit = unit.op ; zig = zag ; zag = zig } zag⁻¹ : {B : D.Obj} → unit.⇐.η (R.₀ B) C.∘ R.₁ (counit.⇐.η B) C.≈ C.id zag⁻¹ {B} = begin unit.⇐.η (R.₀ B) C.∘ R.₁ (counit.⇐.η B) ≈˘⟨ flip-fromʳ unit.FX≅GX zag ⟩∘⟨refl ⟩ R.₁ (counit.⇒.η B) C.∘ R.₁ (counit.⇐.η B) ≈⟨ [ R ]-resp-∘ (counit.iso.isoʳ B) ⟩ R.₁ D.id ≈⟨ R.identity ⟩ C.id ∎ where open C.HomReasoning open MR C zig⁻¹ : {A : C.Obj} → L.₁ (unit.⇐.η A) D.∘ counit.⇐.η (L.₀ A) D.≈ D.id zig⁻¹ {A} = begin L.₁ (unit.⇐.η A) D.∘ counit.⇐.η (L.₀ A) ≈˘⟨ refl⟩∘⟨ flip-fromˡ counit.FX≅GX zig ⟩ L.₁ (unit.⇐.η A) D.∘ L.₁ (unit.⇒.η A) ≈⟨ [ L ]-resp-∘ (unit.iso.isoˡ A) ⟩ L.₁ C.id ≈⟨ L.identity ⟩ D.id ∎ where open D.HomReasoning open MR D op₂ : R ⊣⊢ L op₂ = record { unit = ≃.sym counit ; counit = ≃.sym unit ; zig = zag⁻¹ ; zag = zig⁻¹ } L⊣R : L ⊣ R L⊣R = record { unit = unit.F⇒G ; counit = counit.F⇒G ; zig = zig ; zag = zag } module L⊣R = Adjoint L⊣R open L⊣R hiding (unit; counit; zig; zag; op) public R⊣L : R ⊣ L R⊣L = record { unit = counit.F⇐G ; counit = unit.F⇐G ; zig = zag⁻¹ ; zag = zig⁻¹ } module R⊣L = Adjoint R⊣L private record WithZig (L : Functor C D) (R : Functor D C) : Set (levelOfTerm L ⊔ levelOfTerm R) where field unit : idF ≃ (R ∘F L) counit : (L ∘F R) ≃ idF private module unit = NaturalIsomorphism unit module counit = NaturalIsomorphism counit module C = Category C using (Obj; id; _∘_; _≈_; module HomReasoning) module D = Category D using (Obj; id; _∘_; _≈_; module HomReasoning) module L = Functor L using (₀; ₁; op; identity) module R = Functor R using (₀; ₁; op; identity; F-resp-≈) field zig : ∀ {A : C.Obj} → counit.⇒.η (L.₀ A) D.∘ L.₁ (unit.⇒.η A) D.≈ D.id zag : ∀ {B : D.Obj} → R.₁ (counit.⇒.η B) C.∘ unit.⇒.η (R.₀ B) C.≈ C.id zag {B} = F≃id⇒id (≃.sym unit) helper where open C open HomReasoning helper : R.₁ (L.₁ (R.₁ (counit.⇒.η B) ∘ unit.⇒.η (R.₀ B))) ≈ id helper = begin R.₁ (L.₁ (R.₁ (counit.⇒.η B) ∘ unit.⇒.η (R.₀ B))) ≈⟨ Functor.homomorphism (R ∘F L) ⟩ R.₁ (L.₁ (R.₁ (counit.⇒.η B))) ∘ R.₁ (L.₁ (unit.⇒.η (R.₀ B))) ≈˘⟨ R.F-resp-≈ (F≃id-comm₁ counit) ⟩∘⟨refl ⟩ R.₁ (counit.⇒.η (L.₀ (R.₀ B))) ∘ R.₁ (L.₁ (unit.⇒.η (R.₀ B))) ≈⟨ [ R ]-resp-∘ zig ⟩ R.₁ D.id ≈⟨ R.identity ⟩ id ∎ record WithZag (L : Functor C D) (R : Functor D C) : Set (levelOfTerm L ⊔ levelOfTerm R) where field unit : idF ≃ (R ∘F L) counit : (L ∘F R) ≃ idF private module unit = NaturalIsomorphism unit module counit = NaturalIsomorphism counit module C = Category C using (Obj; id; _∘_; _≈_; module HomReasoning) module D = Category D using (Obj; id; _∘_; _≈_; module HomReasoning) module L = Functor L using (₀; ₁; op; identity; F-resp-≈) module R = Functor R using (₀; ₁; op; identity) field zag : ∀ {B : D.Obj} → R.₁ (counit.⇒.η B) C.∘ unit.⇒.η (R.₀ B) C.≈ C.id zig : ∀ {A : C.Obj} → counit.⇒.η (L.₀ A) D.∘ L.₁ (unit.⇒.η A) D.≈ D.id zig {A} = F≃id⇒id counit helper where open D open HomReasoning helper : L.₁ (R.₁ (counit.⇒.η (L.₀ A) ∘ L.₁ (unit.⇒.η A))) ≈ id helper = begin L.₁ (R.₁ (counit.⇒.η (L.₀ A) ∘ L.₁ (unit.⇒.η A))) ≈⟨ Functor.homomorphism (L ∘F R) ⟩ (L.₁ (R.₁ (counit.⇒.η (L.₀ A))) ∘ L.₁ (R.₁ (L.₁ (unit.⇒.η A)))) ≈˘⟨ refl⟩∘⟨ L.F-resp-≈ (F≃id-comm₂ (≃.sym unit)) ⟩ L.₁ (R.₁ (counit.⇒.η (L.₀ A))) ∘ L.₁ (unit.⇒.η (R.₀ (L.₀ A))) ≈⟨ [ L ]-resp-∘ zag ⟩ L.₁ C.id ≈⟨ L.identity ⟩ id ∎ module _ {L : Functor C D} {R : Functor D C} where withZig : WithZig L R → L ⊣⊢ R withZig LR = record { unit = unit ; counit = counit ; zig = zig ; zag = zag } where open WithZig LR withZag : WithZag L R → L ⊣⊢ R withZag LR = record { unit = unit ; counit = counit ; zig = zig ; zag = zag } where open WithZag LR id⊣⊢id : idF {C = C} ⊣⊢ idF id⊣⊢id {C = C} = record { unit = ≃.sym ≃.unitor² ; counit = ≃.unitor² ; zig = identity² ; zag = identity² } where open Category C
34.122995
128
0.506034
1a22659c24196e266f3d4e01ee2fe52740ea1beb
652
agda
Agda
snoc.agda
heades/AUGL
b33c6a59d664aed46cac8ef77d34313e148fecc2
[ "MIT" ]
null
null
null
snoc.agda
heades/AUGL
b33c6a59d664aed46cac8ef77d34313e148fecc2
[ "MIT" ]
null
null
null
snoc.agda
heades/AUGL
b33c6a59d664aed46cac8ef77d34313e148fecc2
[ "MIT" ]
null
null
null
module snoc where open import unit open import empty open import bool open import product data Snoc (A : Set) : Set where [] : Snoc A _::_ : Snoc A → A → Snoc A infixl 6 _::_ _++_ [_] : {A : Set} → A → Snoc A [ x ] = [] :: x _++_ : {A : Set} → Snoc A → Snoc A → Snoc A [] ++ l₂ = l₂ (l₁ :: x) ++ l₂ = (l₁ ++ l₂) :: x member : {A : Set} → (A → A → 𝔹) → A → Snoc A → 𝔹 member _=A_ x (l :: y) with x =A y ... | tt = tt ... | ff = ff member _=A_ x _ = ff inPairSnocFst : {A B : Set} → (A → A → 𝔹) → A → Snoc (A × B) → Set inPairSnocFst _=A_ x [] = ⊥ inPairSnocFst _=A_ x (l :: (a , _)) with x =A a ... | tt = ⊤ ... | ff = inPairSnocFst _=A_ x l
20.375
66
0.504601
22480955c2d9f5ccae7a4f946d66ef6b13a776c7
339
agda
Agda
Cats/Util/SetoidReasoning.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
24
2017-11-03T15:18:57.000Z
2021-08-06T05:00:46.000Z
Cats/Util/SetoidReasoning.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
null
null
null
Cats/Util/SetoidReasoning.agda
JLimperg/cats
1ad7b243acb622d46731e9ae7029408db6e561f1
[ "MIT" ]
1
2019-03-18T15:35:07.000Z
2019-03-18T15:35:07.000Z
{-# OPTIONS --without-K --safe #-} module Cats.Util.SetoidReasoning where open import Relation.Binary.Reasoning.MultiSetoid public open import Relation.Binary using (Setoid) module _ {c ℓ} (S : Setoid c ℓ) where open Setoid S triangle : ∀ m {x y} → x ≈ m → y ≈ m → x ≈ y triangle m x≈m y≈m = trans x≈m (sym y≈m)
18.833333
56
0.631268
4bd982345eb69efd96087a6fb29b80172284b584
16,174
agda
Agda
agda/book/Programming_Language_Foundations_in_Agda/x01naturals.agda
haroldcarr/learn-haskell-coq-ml-etc
3dc7abca7ad868316bb08f31c77fbba0d3910225
[ "Unlicense" ]
36
2015-01-29T14:37:15.000Z
2021-07-30T06:55:03.000Z
agda/book/Programming_Language_Foundations_in_Agda/x01naturals.agda
haroldcarr/learn-haskell-coq-ml-etc
3dc7abca7ad868316bb08f31c77fbba0d3910225
[ "Unlicense" ]
null
null
null
agda/book/Programming_Language_Foundations_in_Agda/x01naturals.agda
haroldcarr/learn-haskell-coq-ml-etc
3dc7abca7ad868316bb08f31c77fbba0d3910225
[ "Unlicense" ]
8
2015-04-13T21:40:15.000Z
2021-09-21T15:58:10.000Z
module x01naturals where {- ------------------------------------------------------------------------------ naturals : inductive datatype definition as a pair of inference rules: -- no assumptions --------- zero : ℕ -- base case m : ℕ -- assuming m is Natural --------- suc m : ℕ -- inductive case : then suc m is also a Natural in Agda: -} data ℕ : Set where zero : ℕ -- base case suc : ℕ → ℕ -- inductive case -- #### Exercise Write out `7` in longhand. seven : ℕ seven = suc (suc (suc (suc (suc (suc (suc zero)))))) {- inference rules consists of - zero or more _judgments_ written above a horizontal line, called the _hypotheses_ - single judgment written below, called the _conclusion_ `Set` : the way in Agda of saying that it is a type Inductive case defines natural numbers in terms of natural numbers. Base case jump starts the process of induction. ## Philosophy and history inductive def of nats is relatively recent - 1888 Richard Dedekind's paper "_Was sind und was sollen die Zahlen?_" (What are and what should be the numbers?) - 1889 Giuseppe Peano's book "_Arithmetices principia, nova methodo exposita_" (The principles of arithmetic presented by a new method) ------------------------------------------------------------------------------ ## PRAGMA the line -} {-# BUILTIN NATURAL ℕ #-} {- tells Agda that `ℕ` corresponds to the natural numbers - pragma must be given a previously declared type (in this case `ℕ`) - enables 0, 1, 2, ... shorthand - enables efficient internal Haskell representation ## IMPORTS To write equations that hold between terms involving natural numbers import the definition of equality and notations for reasoning about equality from the Agda standard library: -} import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) {- 1st line : brings equality module into scope and gives it the name `Eq`. 2nd line : opens that module and adds names in `using` clause into scope. 3rd line : opens module that specifies operators to support reasoning about equivalence and adds names in `using` clause into scope. later will see their definitions in Chapter Equality underbars indicate where terms appear - `_≡_` and `_≡⟨⟩_` : terms on each side - `begin_` is prefix : terms after - : `_∎` : terms before ------------------------------------------------------------------------------ ## operations on naturals are recursive functions -} -- ADDITION _+_ : ℕ → ℕ → ℕ zero + n = n -- base case : 0 + n ≡ n (suc m) + n = suc (m + n) -- inductive case : (1 + m) + n ≡ 1 + (m + n) : associativity {- Inductive definition works because addition of larger numbers is defined in terms of addition of smaller numbers : WELL FOUNDED -} _ : 2 + 3 ≡ 5 _ = begin 2 + 3 ≡⟨⟩ -- is shorthand for (suc (suc zero)) + (suc (suc (suc zero))) ≡⟨⟩ -- inductive case suc ((suc zero) + (suc (suc (suc zero)))) ≡⟨⟩ -- inductive case suc (suc (zero + (suc (suc (suc zero))))) ≡⟨⟩ -- base case suc (suc (suc (suc (suc zero)))) ≡⟨⟩ -- is longhand for 5 ∎ -- ∎ is QED -- equivalent _ : 2 + 3 ≡ 5 _ = begin 2 + 3 ≡⟨⟩ suc (1 + 3) ≡⟨⟩ suc (suc (0 + 3)) ≡⟨⟩ suc (suc 3) ≡⟨⟩ 5 ∎ -- A binary relation is said to be REFLEXIVE if every value relates to itself. -- Evidence that a value is equal to itself is written `refl` _ : 2 + 3 ≡ 5 _ = refl {- above derivations consist of - a signature (written with a colon, `:`), giving a type - a binding (written with an equal sign, `=`), giving a term of the given type. the dummy name `_` can be reused consists of a series of terms separated by `≡⟨⟩`. duality of interpretation - type as a proposition - term as evidence (aka proof) #### Exercise `+-example` Compute `3 + 4` -} _ : 3 + 4 ≡ 7 _ = begin 3 + 4 ≡⟨⟩ suc (2 + 4) ≡⟨⟩ suc (suc (1 + 4)) ≡⟨⟩ suc (suc (suc (0 + 4))) ≡⟨⟩ suc (suc (suc 4)) ≡⟨⟩ 7 ∎ _ : 3 + 4 ≡ 7 _ = refl {- ------------------------------------------------------------------------------ ## MULTIPLICATION -} _*_ : ℕ → ℕ → ℕ zero * n = zero -- 0 * n ≡ 0 (suc m) * n = n + (m * n) -- (1 + m) * n ≡ n + (m * n) {- computing `m * n` returns the sum of `m` copies of `n`. 2nd line because multiplication distributes over addition: (m + n) * p ≡ (m * p) + (n * p) We get the second equation from the third by - taking `m` to be `1` - `n` to be `m` - `p` to be `n` - then use fact that one is identity for multiplication, so - `1 * n ≡ n` WELL FOUNDED : _*_ of larger numbers is defined in terms of _*_ of smaller numbers -} _ : 2 * 3 ≡ 6 _ = begin 2 * 3 ≡⟨⟩ -- inductive case 3 + (1 * 3) ≡⟨⟩ -- inductive case 3 + (3 + (0 * 3)) ≡⟨⟩ -- base case 3 + (3 + 0) ≡⟨⟩ -- simplify 6 ∎ {- #### Exercise `*-example` Compute `3 * 4` -} _ : 3 * 4 ≡ 12 _ = begin 3 * 4 ≡⟨⟩ 4 + (2 * 4) ≡⟨⟩ 4 + (4 + (1 * 4)) ≡⟨⟩ 4 + (4 + (4 + (0 * 4))) ≡⟨⟩ -- base case 4 + (4 + (4 + 0)) ≡⟨⟩ -- addition 12 ∎ -- HC _*hc_ : ℕ → ℕ → ℕ n *hc zero = zero n *hc (suc m) = (n *hc m) + n _ : 2 *hc 3 ≡ 6 _ = begin 2 *hc 3 ≡⟨⟩ (2 *hc 2) + 2 ≡⟨⟩ ((2 *hc 1) + 2) + 2 ≡⟨⟩ (((2 *hc 0) + 2) + 2) + 2 ≡⟨⟩ (( 0 + 2) + 2) + 2 ≡⟨⟩ ( 2 + 2) + 2 ≡⟨⟩ 6 ∎ {- ------------------------------------------------------------------------------ #### Exercise (recommended) Define EXPONENTIATION -} _^_ : ℕ → ℕ → ℕ m ^ 0 = 1 -- m ^ 0 = 1 m ^ (suc n) = m * (m ^ n) -- m ^ (1 + n) = m * (m ^ n) -- Check that `3 ^ 4` is `81`. _ : 3 ^ 4 ≡ 81 _ = refl _ : 2 ^ 3 ≡ 8 _ = refl {- ------------------------------------------------------------------------------ ## MONUS SUBTRACTION uses pattern matching against both arguments: -} _∸_ : ℕ → ℕ → ℕ m ∸ zero = m zero ∸ suc n = zero suc m ∸ suc n = m ∸ n -- WELL FOUNDED : monus on bigger numbers is defined in terms of monus on smaller numbers. _ = begin 3 ∸ 2 ≡⟨⟩ 2 ∸ 1 ≡⟨⟩ 1 ∸ 0 ≡⟨⟩ 1 ∎ _ = begin 2 ∸ 3 ≡⟨⟩ 1 ∸ 2 ≡⟨⟩ 0 ∸ 1 ≡⟨⟩ 0 ∎ {- #### Exercise Compute `5 ∸ 3` and `3 ∸ 5`, reasoning as a chain of equations. -} _ = begin 5 ∸ 3 ≡⟨⟩ 4 ∸ 2 ≡⟨⟩ 3 ∸ 1 ≡⟨⟩ 2 ∸ 0 ≡⟨⟩ 2 ∎ _ = begin 3 ∸ 5 ≡⟨⟩ 2 ∸ 4 ≡⟨⟩ 1 ∸ 3 ≡⟨⟩ 0 ∸ 2 ≡⟨⟩ 0 ∎ {- ------------------------------------------------------------------------------ ## PRECEDENCE Application higher than operators : `suc m + n` means `(suc m) + n` multiplication higher than addition : `n + m * n` means `n + (m * n)` addition _associates to the left_ : `m + n + p` means `(m + n) + p` declare precedence and associativity of infix operators -} infixl 6 _+_ _∸_ infixl 7 _*_ {- `infixl` : associate to the left `infixr` : associate to the right `infix` : indicates that parentheses are required to disambiguate ------------------------------------------------------------------------------ ## CURRYING a function of two arguments in terms of - a function of the first argument - that returns a function of the second argument Function arrows associate to the right : `ℕ → ℕ → ℕ` stands for `ℕ → (ℕ → ℕ)` Application associates to the left : `_+_ 2 3` stands for `(_+_ 2) 3` Named for Haskell Curry. The idea actually appears in the _Begriffsschrift_ of Gottlob Frege, published in 1879. ------------------------------------------------------------------------------ ## The story of creation, revisited inductive definition defines naturals in terms of naturals recursive definition defines addition in terms of addition n : ℕ -------------- zero + n = n m + n = p --------------------- (suc m) + n = suc p ------------------------------------------------------------------------------ ## The story of creation, finitely {name=finite-creation} SKIPPED ------------------------------------------------------------------------------ ## Writing definitions interactively _+_ : ℕ → ℕ → ℕ m + n = ? ? : ask Agda to fill in `C-c C-l` ? replaced: _+_ : ℕ → ℕ → ℕ m + n = { }0 empty braces : a "numbered" *hole* Emacs will also create a window displaying the text ?0 : ℕ to indicate that hole 0 is to be filled in with a term of type `ℕ`. `C-c C-f` (for **f**orward) will move you into the next hole. To define addition by recursion on the first argument: cursor in hole : `C-c C-c` (for **c**ase). prompt: pattern variables to case (empty for split on result): Type `m` : case split on `m`: _+_ : ℕ → ℕ → ℕ zero + n = { }0 suc m + n = { }1 window at the bottom type of each: ?0 : ℕ ?1 : ℕ in hole 0 : `C-c C-,` displays info on required type of hole, and what free variables are available: Goal: ℕ ———————————————————————————————————————————————————————————— n : ℕ suggests filling the hole with `n` after hole filled in : `C-c C-space` : removes hole: _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = { }1 in hole 1 : `C-c C-,` displays info Goal: ℕ ———————————————————————————————————————————————————————————— n : ℕ m : ℕ in hole : `C-c C-r` (for **r**efine) will fill in with a constructor (if there is a unique choice) or tell you what constructors you might use, if there is a choice Don't know which constructor to introduce of zero or suc fill in hole with `suc ?` : `C-c C-space` _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc { }1 in new hole : `C-c C-,` Goal: ℕ ———————————————————————————————————————————————————————————— n : ℕ m : ℕ fill hole with `m + n` : `C-c C-space` complete the program: _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc (m + n) ------------------------------------------------------------------------------ ## More pragmas -} {-# BUILTIN NATPLUS _+_ #-} {-# BUILTIN NATTIMES _*_ #-} {-# BUILTIN NATMINUS _∸_ #-} {- tells Agda correspondance between operators correspond and the usual ones. Enables using corresponding Haskell operators on arbitrary-precision integer type. ------------------------------------------------------------------------------ #### Exercise `Bin` (stretch) {name=Bin} represent nat as bitstring -} data Bin : Set where ⟨⟩ : Bin _O : Bin → Bin _I : Bin → Bin {- bitstring 1011 (eleven) encoded as ⟨⟩ I O I I or, with leading zeros, ⟨⟩ O O I O I I define inc : Bin → Bin converts bitstring to bitstring for next higher number -} -- this definition has TWO forms of ZERO: '⟨⟩' and '⟨⟩ O' -- will probably cause problems later on inc : Bin → Bin inc ⟨⟩ = ⟨⟩ I inc (⟨⟩ O) = ⟨⟩ I inc (⟨⟩ I) = ⟨⟩ I O inc (b O) = b I inc (b I) = (inc b) O -- `IOII` eleven to `1100` twelve _ : inc (⟨⟩ I O I I) ≡ ⟨⟩ I I O O _ = refl -- Confirm correct answer for the bitstrings encoding zero through four. _ : inc (⟨⟩ O) ≡ ⟨⟩ I _ = refl _ : inc (⟨⟩ I) ≡ ⟨⟩ I O _ = refl _ : inc (⟨⟩ I O) ≡ ⟨⟩ I I _ = refl _ : inc (⟨⟩ I I) ≡ ⟨⟩ I O O _ = refl _ : inc (⟨⟩ I O O) ≡ ⟨⟩ I O I _ = refl {- using above, define to : ℕ → Bin from : Bin → ℕ `to` should not have leading zeros, except represent zero as `⟨⟩ O` confirm for zero through four -} to : ℕ → Bin to zero = ⟨⟩ O to (suc m) = inc (to m) from : Bin → ℕ from ⟨⟩ = 0 from (b O) = 2 * from b from (b I) = 2 * from b + 1 _ : from (⟨⟩ O) ≡ 0 _ = refl _ : from (⟨⟩ I) ≡ 1 _ = refl _ : from (⟨⟩ I O) ≡ 2 _ = refl _ : from (⟨⟩ I I) ≡ 3 _ = refl _ : from (⟨⟩ I O O) ≡ 4 _ = refl _ : from (⟨⟩ I I O) ≡ 6 _ = refl _ : to 0 ≡ (⟨⟩ O) _ = refl _ : to 1 ≡ (⟨⟩ I) _ = refl _ : to 2 ≡ (⟨⟩ I O) _ = refl _ : to 3 ≡ (⟨⟩ I I) _ = refl _ : to 4 ≡ (⟨⟩ I O O) _ = refl _ : to 6 ≡ (⟨⟩ I I O) _ = refl _ : from (to 12) ≡ 12 _ = refl _ : to (from (⟨⟩ I I O O)) ≡ ⟨⟩ I I O O _ = refl -- 842 exercise : bin-+ _bin-+_ : Bin → Bin → Bin ⟨⟩ bin-+ ⟨⟩ = ⟨⟩ ⟨⟩ bin-+ b = b b bin-+ ⟨⟩ = b (bl O) bin-+ (br O) = let r = bl bin-+ br in r O (bl O) bin-+ (br I) = let r = bl bin-+ br in r I (bl I) bin-+ (br O) = let r = bl bin-+ br in r I (bl I) bin-+ (br I) = let r = bl bin-+ br in (inc r) O _ : (⟨⟩) bin-+ (⟨⟩) ≡ (⟨⟩) _ = refl _ : (⟨⟩) bin-+ (⟨⟩ O) ≡ (⟨⟩ O) _ = refl _ : (⟨⟩ O) bin-+ (⟨⟩) ≡ (⟨⟩ O) _ = refl _ : (⟨⟩ O) bin-+ (⟨⟩ O) ≡ (⟨⟩ O) _ = refl _ : (⟨⟩ O) bin-+ (⟨⟩ I) ≡ (⟨⟩ I) _ = refl _ : (⟨⟩ I) bin-+ (⟨⟩ I) ≡ (⟨⟩ I O) _ = refl _ : (⟨⟩ I O) bin-+ (⟨⟩ I O) ≡ (⟨⟩ I O O) _ = refl _ : (⟨⟩ I I) bin-+ (⟨⟩ I I) ≡ (⟨⟩ I I O) _ = refl _ : (⟨⟩ I O I) bin-+ (⟨⟩ I) ≡ (⟨⟩ I I O) _ = refl _ : (⟨⟩ I I I) bin-+ (⟨⟩ I) ≡ (⟨⟩ I O O O) _ = refl ------------------------------------------------------------------------------ -- hc exercise : explore two representation of ZERO z1-bin-+ : ∀ (b1 b2 : Bin) → b1 ≡ ⟨⟩ → b1 bin-+ b2 ≡ b2 z1-bin-+ b1 ⟨⟩ p -- (b1 bin-+ ⟨⟩) ≡ ⟨⟩ rewrite p -- (⟨⟩ bin-+ ⟨⟩) ≡ ⟨⟩ -- ⟨⟩ ≡ ⟨⟩ = refl z1-bin-+ b1 (⟨⟩ O) p -- (b1 bin-+ (⟨⟩ O)) ≡ (⟨⟩ O) rewrite p -- (⟨⟩ bin-+ (⟨⟩ O)) ≡ (⟨⟩ O) -- (⟨⟩ O) ≡ (⟨⟩ O) = refl z1-bin-+ b1 (b O) p -- (b1 bin-+ (b O)) ≡ (b O) rewrite p -- (⟨⟩ bin-+ (b O)) ≡ (b O) -- (b O) ≡ (b O) = refl z1-bin-+ b1 (b I) p -- (b1 bin-+ (b I)) ≡ (b I) rewrite p -- (⟨⟩ bin-+ (b I)) ≡ (b I) -- (b I) ≡ (b I) = refl z-bin-+ : ∀ (b1 b2 : Bin) → b1 ≡ (⟨⟩ O) → b1 bin-+ b2 ≡ b2 z-bin-+ b1 ⟨⟩ p -- (b1 bin-+ ⟨⟩) ≡ ⟨⟩ rewrite p -- ((⟨⟩ O) bin-+ ⟨⟩) ≡ ⟨⟩ -- (⟨⟩ O) ≡ ⟨⟩ = {!!} z-bin-+ b1 (⟨⟩ O) p -- (b1 bin-+ (⟨⟩ O)) ≡ (⟨⟩ O) rewrite p -- ((⟨⟩ O) bin-+ (⟨⟩ O)) ≡ (⟨⟩ O) -- (⟨⟩ O) ≡ (⟨⟩ O) = refl z-bin-+ b1 (b O) p -- (b1 bin-+ (b O)) ≡ (b O) rewrite p -- ((⟨⟩ O) bin-+ (b O)) ≡ (b O) -- ((⟨⟩ bin-+ b) O) ≡ (b O) = {!!} z-bin-+ b1 (b I) p -- (b1 bin-+ (b I)) ≡ (b I) rewrite p -- ((⟨⟩ O) bin-+ (b I)) ≡ (b I) -- ((⟨⟩ bin-+ b) I) ≡ (b I) = {!!} hc : ∀ (m n : ℕ) → from (to m bin-+ to n) ≡ m + n hc zero n -- from (to zero bin-+ to n) ≡ zero + n = {!!} -- from ( (⟨⟩ O) bin-+ to n) ≡ n hc (suc m) n = {!!} {- ------------------------------------------------------------------------------ ## Standard library where to find relevant definitions in the standard library Naturals, constructors, operators : import Data.Nat using (ℕ; zero; suc; _+_; _*_; _^_; _∸_) https://agda.readthedocs.io/en/v2.6.1/language/pragmas.html ------------------------------------------------------------------------------ ## Unicode This chapter uses the following unicode: char code name emacs ------------------------------------------------------ ℕ U+2115 DOUBLE-STRUCK CAPITAL N (\bN) → U+2192 RIGHTWARDS ARROW (\to, \r, \->) ∸ U+2238 DOT MINUS (\.-) ≡ U+2261 IDENTICAL TO (\==) ⟨ U+27E8 MATHEMATICAL LEFT ANGLE BRACKET (\<) ⟩ U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET (\>) ∎ U+220E END OF PROOF (\qed) `\r` : variety of right arrows `\l` : variety of left arrows All the characters supported by `agda-mode`: M-x agda-input-show-translations To see how to input an existing specific Unicode character in an agda file, move cursor to character M-x quail-show-key -}
23.961481
90
0.455917
193d04150ed4cffcaa58844c841b10f1cacdbcdb
5,267
agda
Agda
src/IntuitionisticLogic.agda
wenkokke/msla2014
b880cf25ed8e81b9a965ea9aad18377008d68a9f
[ "MIT" ]
5
2018-11-17T23:04:39.000Z
2020-10-29T09:07:45.000Z
src/IntuitionisticLogic.agda
wenkokke/msla2014
b880cf25ed8e81b9a965ea9aad18377008d68a9f
[ "MIT" ]
null
null
null
src/IntuitionisticLogic.agda
wenkokke/msla2014
b880cf25ed8e81b9a965ea9aad18377008d68a9f
[ "MIT" ]
null
null
null
open import Level using (Level; _⊔_) open import Function using (id; case_of_) open import Data.Nat using (ℕ; suc) open import Data.Fin using (Fin; suc; zero) open import Data.Vec as Vec using (Vec) renaming (_∷_ to _,_; [] to ∅) open import Data.List using (_∷_; []) open import Data.List as List using (List; _++_) renaming (_∷_ to _,_; [] to ∅) open import Data.Product as Product using (∃; _×_; _,_) open import Relation.Binary.PropositionalEquality as P using (_≡_; refl; sym; cong) module IntuitionisticLogic (U : Set) (⟦_⟧ᵁ : U → Set) where infix 30 _⊗_ infixr 20 _⇒_ data Type : Set where el : (A : U) → Type _⊗_ : Type → Type → Type _⇒_ : Type → Type → Type module Implicit where infix 4 _⊢_ data _⊢_ : ∀ {k} (Γ : Vec Type k) (A : Type) → Set where var : ∀ {k} {Γ : Vec Type k} (x : Fin k) → Γ ⊢ Vec.lookup x Γ abs : ∀ {A B} {k} {Γ : Vec Type k} → A , Γ ⊢ B → Γ ⊢ A ⇒ B app : ∀ {A B} {k} {Γ : Vec Type k} → Γ ⊢ A ⇒ B → Γ ⊢ A → Γ ⊢ B pair : ∀ {A B} {k} {Γ : Vec Type k} → Γ ⊢ A → Γ ⊢ B → Γ ⊢ A ⊗ B case : ∀ {A B C} {k} {Γ : Vec Type k} → Γ ⊢ A ⊗ B → A , B , Γ ⊢ C → Γ ⊢ C swap : ∀ {A B} {k} {Γ : Vec Type k} → Γ ⊢ A ⊗ B ⇒ B ⊗ A swap = abs (case (var zero) (pair (var (suc zero)) (var zero))) Vec-exch : ∀ {k} (i : Fin k) → Vec Type (suc k) → Vec Type (suc k) Vec-exch zero (A , B , Γ) = B , A , Γ Vec-exch (suc i) (A , Γ) = A , (Vec-exch i Γ) lemma-var : ∀ {k} {Γ : Vec Type (suc k)} → ∀ i x → ∃ λ y → Vec.lookup x Γ ≡ Vec.lookup y (Vec-exch i Γ) lemma-var {Γ = A , B , Γ} zero zero = suc zero , refl lemma-var {Γ = A , B , Γ} zero (suc zero) = zero , refl lemma-var {Γ = A , B , Γ} zero (suc (suc x)) = suc (suc x) , refl lemma-var {Γ = A , Γ} (suc i) zero = zero , refl lemma-var {Γ = A , Γ} (suc i) (suc x) = Product.map suc id (lemma-var {Γ = Γ} i x) exch : ∀ {k} {Γ : Vec Type (suc k)} {A} → ∀ i → Γ ⊢ A → Vec-exch i Γ ⊢ A exch {Γ = Γ} i (var x) with lemma-var {Γ = Γ} i x exch {Γ = Γ} i (var x) | y , p rewrite p = var y exch i (abs t) = abs (exch (suc i) t) exch i (app s t) = app (exch i s) (exch i t) exch i (pair s t) = pair (exch i s) (exch i t) exch i (case s t) = case (exch i s) (exch (suc (suc i)) t) module Explicit where infix 4 _⊢_ data _⊢_ : ∀ (X : List Type) (A : Type) → Set where var : ∀ {A} → A , ∅ ⊢ A abs : ∀ {X A B} → A , X ⊢ B → X ⊢ A ⇒ B app : ∀ {X Y A B} → X ⊢ A ⇒ B → Y ⊢ A → X ++ Y ⊢ B pair : ∀ {X Y A B} → X ⊢ A → Y ⊢ B → X ++ Y ⊢ A ⊗ B case : ∀ {X Y A B C} → X ⊢ A ⊗ B → A , B , Y ⊢ C → X ++ Y ⊢ C weak : ∀ {X Y A} → X ⊢ A → X ++ Y ⊢ A cont : ∀ {X A B} → A , A , X ⊢ B → A , X ⊢ B exch : ∀ {X Y Z W A} → (X ++ Z) ++ (Y ++ W) ⊢ A → (X ++ Y) ++ (Z ++ W) ⊢ A exch₀ : ∀ {X A B C} → B , A , X ⊢ C → A , B , X ⊢ C exch₀ {X} {A} {B} = exch {∅} {A , ∅} {B , ∅} {X} swap : ∀ {X A B} → X ⊢ A ⊗ B ⇒ B ⊗ A swap {X} {A} {B} = abs (case var (exch₀ (pair var (weak {A , ∅} {X} var)))) record Reify {a b : Level} (A : Set a) (B : Set b) : Set (a ⊔ b) where field ⟦_⟧ : A → B instance ReifyType : Reify Type Set ReifyType = record { ⟦_⟧ = ⟦_⟧ } where ⟦_⟧ : Type → Set ⟦ el A ⟧ = ⟦ A ⟧ᵁ ⟦ A ⊗ B ⟧ = ⟦ A ⟧ × ⟦ B ⟧ ⟦ A ⇒ B ⟧ = ⟦ A ⟧ → ⟦ B ⟧ data Ctxt : ∀ (X : List Set) → Set₁ where ∅ : Ctxt ∅ _,_ : ∀ {A X} → A → Ctxt X → Ctxt (A , X) open Reify {{...}} using (⟦_⟧) instance ReifyCtxt : Reify (List Type) (List Set) ReifyCtxt = record { ⟦_⟧ = List.map ⟦_⟧ } Ctxt-insert : {A : Type} {X Y : List Type} → ⟦ A ⟧ → Ctxt ⟦ X ++ Y ⟧ → Ctxt ⟦ X ++ (A , Y) ⟧ Ctxt-insert {A} {∅} {Y} A′ E = A′ , E Ctxt-insert {A} {B , X} {Y} A′ (B′ , E) = B′ , Ctxt-insert {A} {X} {Y} A′ E Ctxt-exch : {X Y Z W : List Type} → Ctxt ⟦ (X ++ Y) ++ (Z ++ W) ⟧ → Ctxt ⟦ (X ++ Z) ++ (Y ++ W) ⟧ Ctxt-exch {X = ∅} {Y = ∅} {Z} {W} E = E Ctxt-exch {X = ∅} {Y = A , Y} {Z} {W} (A′ , E) = Ctxt-insert {A} {Z} {Y ++ W} A′ (Ctxt-exch {∅} {Y} {Z} {W} E) Ctxt-exch {X = A , X} {Y} {Z} {W} (A′ , E) = A′ , Ctxt-exch {X} {Y} {Z} {W} E Ctxt-split : {X Y : List Type} → Ctxt ⟦ X ++ Y ⟧ → Ctxt ⟦ X ⟧ × Ctxt ⟦ Y ⟧ Ctxt-split {∅} {Y} E = ∅ , E Ctxt-split {A , X} {Y} (A′ , E) with Ctxt-split {X} {Y} E ... | Eˣ , Eʸ = ((A′ , Eˣ) , Eʸ) reify : {A : Type} {X : List Type} → X ⊢ A → (Ctxt ⟦ X ⟧ → ⟦ A ⟧) reify var (x , ∅) = x reify (abs t) E = λ x → reify t (x , E) reify (app s t) E with Ctxt-split E ... | Eˢ , Eᵗ = (reify s Eˢ) (reify t Eᵗ) reify (pair s t) E with Ctxt-split E ... | Eˢ , Eᵗ = (reify s Eˢ , reify t Eᵗ) reify (case s t) E with Ctxt-split E ... | Eˢ , Eᵗ = case reify s Eˢ of λ{ (x , y) → reify t (x , y , Eᵗ)} reify (weak {X} s) E with Ctxt-split {X} E ... | Eˢ , Eᵗ = reify s Eˢ reify (cont t) (x , E) = reify t (x , x , E) reify (exch {X} {Y} {Z} {W} t) E = reify t (Ctxt-exch {X} {Y} {Z} {W} E) [_] : {A : Type} {X : List Type} → X ⊢ A → (Ctxt ⟦ X ⟧ → ⟦ A ⟧) [_] = reify swap′ : ∀ {A B} → ⟦ A ⟧ × ⟦ B ⟧ → ⟦ B ⟧ × ⟦ A ⟧ swap′ {A} {B} = [ swap {∅} {A} {B} ] ∅
39.601504
112
0.440099
2937de776ba7cdf865469251288105d1a90d5252
678
agda
Agda
test/Fail/Issue2348-visible-instance.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue2348-visible-instance.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue2348-visible-instance.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2016-12-20, issue #2348, testing nameFirstIfHidden -- {-# OPTIONS -v tc.proj.like:100 #-} {-# OPTIONS --show-implicit #-} -- NEEDED -- something projection-like record Wrap (A : Set) : Set where field out : A proj-like : (A : Set) {{r : Wrap A}} → A proj-like A {{r}} = Wrap.out r -- display term with projection-like thing postulate B : Set b : B P : B → Set p : P b instance w : Wrap B ok = P (proj-like _ {{w}}) -- instance argument does not have to be named test : P (proj-like B) test = p -- triggers error message -- Expected error: -- b != Wrap.out w of type B -- when checking that the expression p has type P (proj-like _ {{w}})
20.545455
74
0.620944
ad25f3219509764ef99f57ef4887910b33c50028
19,514
agda
Agda
src/AssocFree/STLambdaC/Exp.agda
agda/agda-assoc-free
08337fdb8375137a52cc9b3ade766305191b2394
[ "MIT" ]
3
2016-11-22T11:48:31.000Z
2020-08-27T20:56:20.000Z
src/AssocFree/STLambdaC/Exp.agda
agda/agda-assoc-free
08337fdb8375137a52cc9b3ade766305191b2394
[ "MIT" ]
null
null
null
src/AssocFree/STLambdaC/Exp.agda
agda/agda-assoc-free
08337fdb8375137a52cc9b3ade766305191b2394
[ "MIT" ]
2
2018-03-03T04:39:31.000Z
2022-03-12T11:38:44.000Z
open import Function using () renaming ( _∘′_ to _∘_ ) open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym ; cong ; cong₂ ; subst ) open import AssocFree.Util using ( subst-natural ) import AssocFree.STLambdaC.Typ open Relation.Binary.PropositionalEquality.≡-Reasoning using ( begin_ ; _≡⟨_⟩_ ; _∎ ) module AssocFree.STLambdaC.Exp (TConst : Set) (Const : AssocFree.STLambdaC.Typ.Typ TConst → Set) where open module Typ = AssocFree.STLambdaC.Typ TConst using ( Typ ; Var ; Ctxt ; const ; _⇝_ ; [] ; [_] ; _++_ ; _∷_ ; _∈_ ; _≪_ ; _≫_ ; _⋙_ ; uniq ; singleton ; Case ; case ; inj₁ ; inj₂ ; inj₃ ; case-≪ ; case-≫ ; case-⋙ ; Case₃ ; case₃ ; caseˡ ; caseʳ ; caseˡ₃ ; caseʳ₃ ; case⁻¹ ; case-iso ) -- Syntax data Exp (Γ : Ctxt) : Typ → Set where const : ∀ {T} → Const T → Exp Γ T abs : ∀ T {U} → Exp (T ∷ Γ) U → Exp Γ (T ⇝ U) app : ∀ {T U} → Exp Γ (T ⇝ U) → Exp Γ T → Exp Γ U var : ∀ {T} → (T ∈ Γ) → Exp Γ T -- Shorthand var₀ : ∀ {Γ T} → Exp (T ∷ Γ) T var₀ {Γ} {T} = var (singleton T ≪ Γ) var₁ : ∀ {Γ T U} → Exp (U ∷ (T ∷ Γ)) T var₁ {Γ} {T} {U} = var ([ U ] ≫ singleton T ≪ Γ) var₂ : ∀ {Γ T U V} → Exp (V ∷ (U ∷ (T ∷ Γ))) T var₂ {Γ} {T} {U} {V} = var ([ V ] ≫ [ U ] ≫ singleton T ≪ Γ) -- Andreas Abel suggested defining substitution and renaming together, citing: -- -- Conor McBride -- Type Preserving Renaming and Substitution -- -- Thorsten Altenkirch and Bernhard Reus -- Monadic Presentations of Lambda Terms Using Generalized Inductive Types -- -- http://www2.tcs.ifi.lmu.de/~abel/ParallelSubstitution.agda -- The idea is to define two kinds, for expressions and variables, -- such that the kind of variables is contained in the kind of -- expressions (so admits recursion). mutual data Kind : Set where var : Kind exp : ∀ {k} → IsVar k → Kind data IsVar : Kind → Set where var : IsVar var Thing : Kind → Ctxt → Typ → Set Thing var Γ T = (T ∈ Γ) Thing (exp var) Γ T = Exp Γ T Substn : Kind → Ctxt → Ctxt → Set Substn k Γ Δ = ∀ {T} → (T ∈ Δ) → Thing k Γ T -- Convert between variables, things and expressions thing : ∀ {k Γ T} → (T ∈ Γ) → Thing k Γ T thing {var} x = x thing {exp var} x = var x expr : ∀ {k Γ T} → Thing k Γ T → Exp Γ T expr {var} x = var x expr {exp var} M = M -- Extensional equivalence on substitutions (note: not assuming extensionality) _≈_ : ∀ {k Γ Δ} → Substn k Γ Δ → Substn k Γ Δ → Set ρ ≈ σ = ∀ {T} x → ρ {T} x ≡ σ {T} x -- Identity substitution id : ∀ {k} Γ → Substn k Γ Γ id {var} Γ x = x id {exp var} Γ x = var x -- Product structure of substitutions fst : ∀ Γ Δ → Substn var (Γ ++ Δ) Γ fst Γ Δ x = x ≪ Δ snd : ∀ Γ Δ → Substn var (Γ ++ Δ) Δ snd Γ Δ x = Γ ≫ x choose : ∀ {k Γ Δ E T} → Substn k Γ Δ → Substn k Γ E → (Case T Δ E) → Thing k Γ T choose ρ σ (inj₁ x) = ρ x choose ρ σ (inj₂ x) = σ x _&&&_ : ∀ {k Γ Δ E} → Substn k Γ Δ → Substn k Γ E → Substn k Γ (Δ ++ E) (ρ &&& σ) = choose ρ σ ∘ case _ _ -- Singleton substitution ⟨_⟩ : ∀ {k Γ T} → Thing k Γ T → Substn k Γ [ T ] ⟨ M ⟩ x = subst (Thing _ _) (uniq x) M -- Cons on substitutions _◁_ : ∀ {k Γ Δ T} → Thing k Γ T → Substn k Γ Δ → Substn k Γ (T ∷ Δ) M ◁ σ = ⟨ M ⟩ &&& σ -- Applying a substitution mutual substn+ : ∀ {k} B Γ Δ → Substn k Γ Δ → ∀ {T} → Exp (B ++ Δ) T → Exp (B ++ Γ) T substn+ B Γ Δ σ (const c) = const c substn+ B Γ Δ σ (abs T M) = abs T (substn+ (T ∷ B) Γ Δ σ M) substn+ B Γ Δ σ (app M N) = app (substn+ B Γ Δ σ M) (substn+ B Γ Δ σ N) substn+ B Γ Δ σ (var x) = expr (xsubstn+ B Γ Δ σ (case B Δ x)) xsubstn+ : ∀ {k} B Γ Δ → Substn k Γ Δ → ∀ {T} → (Case T B Δ) → Thing k (B ++ Γ) T xsubstn+ B Γ Δ σ (inj₁ x) = thing (x ≪ Γ) xsubstn+ {var} B Γ Δ σ (inj₂ x) = B ≫ σ x xsubstn+ {exp var} B Γ Δ σ (inj₂ x) = substn+ [] (B ++ Γ) Γ (snd B Γ) (σ x) -- weaken* B (σ x) -- Shorthands substn* : ∀ {k Γ Δ} → Substn k Γ Δ → ∀ {T} → Exp Δ T → Exp Γ T substn* {k} {Γ} {Δ} = substn+ [] Γ Δ substn : ∀ {Γ T U} → Exp Γ T → Exp (T ∷ Γ) U → Exp Γ U substn {Γ} M = substn* (M ◁ id Γ) xweaken+ : ∀ B Γ Δ {T} → (T ∈ (B ++ Δ)) → (T ∈ (B ++ Γ ++ Δ)) xweaken+ B Γ Δ x = xsubstn+ B (Γ ++ Δ) Δ (snd Γ Δ) (case B Δ x) weaken+ : ∀ B Γ Δ {T} → Exp (B ++ Δ) T → Exp (B ++ Γ ++ Δ) T weaken+ B Γ Δ = substn+ B (Γ ++ Δ) Δ (snd Γ Δ) weaken* : ∀ Γ {Δ T} → Exp Δ T → Exp (Γ ++ Δ) T weaken* Γ {Δ} = weaken+ [] Γ Δ weakens* : ∀ {Γ Δ} E → Substn (exp var) Γ Δ → Substn (exp var) (E ++ Γ) Δ weakens* E σ x = weaken* E (σ x) weaken*ʳ : ∀ {Γ} Δ {T} → Exp Γ T → Exp (Γ ++ Δ) T weaken*ʳ {Γ} Δ = weaken+ Γ Δ [] weaken : ∀ {Γ} T {U} → Exp Γ U → Exp (T ∷ Γ) U weaken T = weaken* [ T ] -- Composition of substitutions _⊔_ : Kind → Kind → Kind k ⊔ var = k k ⊔ exp var = exp var _∙_ : ∀ {k l Γ Δ E} → Substn k Γ Δ → Substn l Δ E → Substn (k ⊔ l) Γ E _∙_ {k} {var} ρ σ = ρ ∘ σ _∙_ {k} {exp var} ρ σ = substn* ρ ∘ σ -- Functorial action of ++ on substitutions par : ∀ {k Γ Δ Φ Ψ T} → Substn k Γ Φ → Substn k Δ Ψ → (Case T Φ Ψ) → Thing k (Γ ++ Δ) T par {var} {Γ} {Δ} ρ σ (inj₁ x) = ρ x ≪ Δ par {var} {Γ} {Δ} ρ σ (inj₂ x) = Γ ≫ σ x par {exp var} {Γ} {Δ} ρ σ (inj₁ x) = weaken*ʳ Δ (ρ x) par {exp var} {Γ} {Δ} ρ σ (inj₂ x) = weaken* Γ (σ x) _+++_ : ∀ {k Γ Δ Φ Ψ} → Substn k Γ Δ → Substn k Φ Ψ → Substn k (Γ ++ Φ) (Δ ++ Ψ) (ρ +++ σ) = par ρ σ ∘ case _ _ -- Weakening a variable is a variable weaken*-var : ∀ Γ {Δ T} (x : T ∈ Δ) → weaken* Γ (var x) ≡ var (Γ ≫ x) weaken*-var Γ {Δ} x = cong (expr ∘ xsubstn+ [] (Γ ++ Δ) Δ (snd Γ Δ)) (case-≫ [] x) weaken*ʳ-var : ∀ {Γ} Δ {T} (x : T ∈ Γ) → weaken*ʳ Δ (var x) ≡ var (x ≪ Δ) weaken*ʳ-var {Γ} Δ x = cong (expr ∘ xsubstn+ Γ Δ [] (snd Δ [])) (case-≪ x []) weaken+-var₀ : ∀ B Γ Δ {T} → weaken+ (T ∷ B) Γ Δ (var₀ {B ++ Δ}) ≡ var₀ {B ++ Γ ++ Δ} weaken+-var₀ B Γ Δ {T} = cong (var ∘ xsubstn+ (T ∷ B) (Γ ++ Δ) Δ (snd Γ Δ)) (case-≪ (singleton T ≪ B) Δ) -- Substitution respects extensional equality substn+-cong : ∀ {k} B Γ Δ {σ : Substn k Γ Δ} {ρ : Substn k Γ Δ} → (σ ≈ ρ) → ∀ {T} M → substn+ B Γ Δ σ {T} M ≡ substn+ B Γ Δ ρ M substn+-cong B Γ Δ σ≈ρ (const c) = refl substn+-cong B Γ Δ σ≈ρ (abs T M) = cong (abs {B ++ Γ} T) (substn+-cong (T ∷ B) Γ Δ σ≈ρ M) substn+-cong B Γ Δ σ≈ρ (app M N) = cong₂ app (substn+-cong B Γ Δ σ≈ρ M) (substn+-cong B Γ Δ σ≈ρ N) substn+-cong B Γ Δ σ≈ρ (var x) = cong expr (xsubstn+-cong B Γ Δ σ≈ρ (case B Δ x)) where xsubstn+-cong : ∀ {k} B Γ Δ {σ : Substn k Γ Δ} {ρ : Substn k Γ Δ} → (σ ≈ ρ) → ∀ {T} x → xsubstn+ B Γ Δ σ {T} x ≡ xsubstn+ B Γ Δ ρ x xsubstn+-cong {var} B Γ Δ σ≈ρ (inj₁ x) = refl xsubstn+-cong {exp var} B Γ Δ σ≈ρ (inj₁ x) = refl xsubstn+-cong {var} B Γ Δ σ≈ρ (inj₂ x) = cong (_≫_ B) (σ≈ρ x) xsubstn+-cong {exp var} B Γ Δ σ≈ρ (inj₂ x) = cong (substn+ [] (B ++ Γ) Γ (snd B Γ)) (σ≈ρ x) substn*-cong : ∀ {k Γ Δ} {σ : Substn k Γ Δ} {ρ : Substn k Γ Δ} → (σ ≈ ρ) → ∀ {T} M → substn* σ {T} M ≡ substn* ρ M substn*-cong {k} {Γ} {Δ} = substn+-cong [] Γ Δ -- Identity of substitutions xsubstn+-id : ∀ {k} B Γ {T} (x : Case T B Γ) → expr (xsubstn+ B Γ Γ (id {k} Γ) x) ≡ var (case⁻¹ x) xsubstn+-id {var} B Γ (inj₁ x) = refl xsubstn+-id {exp var} B Γ (inj₁ x) = refl xsubstn+-id {var} B Γ (inj₂ x) = refl xsubstn+-id {exp var} B Γ (inj₂ x) = weaken*-var B x substn+-id : ∀ {k} B Γ {T} (M : Exp (B ++ Γ) T) → substn+ B Γ Γ (id {k} Γ) M ≡ M substn+-id B Γ (const c) = refl substn+-id B Γ (abs T M) = cong (abs {B ++ Γ} T) (substn+-id (T ∷ B) Γ M) substn+-id B Γ (app M N) = cong₂ app (substn+-id B Γ M) (substn+-id B Γ N) substn+-id {k} B Γ (var x) = begin substn+ B Γ Γ (id {k} Γ) (var x) ≡⟨ xsubstn+-id {k} B Γ (case B Γ x) ⟩ var (case⁻¹ (case B Γ x)) ≡⟨ cong var (case-iso B Γ x) ⟩ var x ∎ substn*-id : ∀ {k Γ T} (M : Exp Γ T) → substn* (id {k} Γ) M ≡ M substn*-id {k} {Γ} = substn+-id [] Γ weaken*-[] : ∀ {Γ T} (M : Exp Γ T) → weaken* [] M ≡ M weaken*-[] M = substn*-id M mutual -- Composition of substitutions substn+-∙ : ∀ {k l} B Γ Δ E (σ : Substn k Γ Δ) (ρ : Substn l Δ E) {T} (M : Exp (B ++ E) T) → (substn+ B Γ Δ σ (substn+ B Δ E ρ M) ≡ substn+ B Γ E (σ ∙ ρ) M) substn+-∙ B Γ Δ E ρ σ (const c) = refl substn+-∙ B Γ Δ E ρ σ (abs T M) = cong (abs {B ++ Γ} T) (substn+-∙ (T ∷ B) Γ Δ E ρ σ M) substn+-∙ B Γ Δ E ρ σ (app M N) = cong₂ app (substn+-∙ B Γ Δ E ρ σ M) (substn+-∙ B Γ Δ E ρ σ N) substn+-∙ B Γ Δ E ρ σ (var x) = xsubstn+-∙ B Γ Δ E ρ σ (case B E x) where xsubstn+-∙ : ∀ {k l} B Γ Δ E (σ : Substn k Γ Δ) (ρ : Substn l Δ E) {T} (x : Case T B E) → (substn+ B Γ Δ σ (expr (xsubstn+ B Δ E ρ x)) ≡ expr (xsubstn+ B Γ E (σ ∙ ρ) x)) xsubstn+-∙ {k} {var} B Γ Δ E σ ρ (inj₁ x) = cong (expr ∘ xsubstn+ B Γ Δ σ) (case-≪ x Δ) xsubstn+-∙ {var} {exp var} B Γ Δ E σ ρ (inj₁ x) = cong (expr ∘ xsubstn+ B Γ Δ σ) (case-≪ x Δ) xsubstn+-∙ {exp var} {exp var} B Γ Δ E σ ρ (inj₁ x) = cong (expr ∘ xsubstn+ B Γ Δ σ) (case-≪ x Δ) xsubstn+-∙ {var} {var} B Γ Δ E σ ρ (inj₂ x) = cong (expr ∘ xsubstn+ B Γ Δ σ) (case-≫ B (ρ x)) xsubstn+-∙ {exp var} {var} B Γ Δ E σ ρ (inj₂ x) = cong (expr ∘ xsubstn+ B Γ Δ σ) (case-≫ B (ρ x)) xsubstn+-∙ {var} {exp var} B Γ Δ E σ ρ (inj₂ x) = begin substn+ B Γ Δ σ (weaken* B (ρ x)) ≡⟨ substn+* B Γ Δ σ (weaken* B (ρ x)) ⟩ substn* (id B +++ σ) (weaken* B (ρ x)) ≡⟨ substn+-∙ [] (B ++ Γ) (B ++ Δ) Δ (id B +++ σ) (snd B Δ) (ρ x) ⟩ substn* ((id B +++ σ) ∙ snd B Δ) (ρ x) ≡⟨ substn*-cong (λ y → cong (par (id B) σ) (case-≫ B y)) (ρ x) ⟩ substn* (snd B Γ ∙ σ) (ρ x) ≡⟨ sym (substn+-∙ [] (B ++ Γ) Γ Δ (snd B Γ) σ (ρ x)) ⟩ weaken* B (substn* σ (ρ x)) ∎ xsubstn+-∙ {exp var} {exp var} B Γ Δ E σ ρ (inj₂ x) = begin substn+ B Γ Δ σ (weaken* B (ρ x)) ≡⟨ substn+* B Γ Δ σ (weaken* B (ρ x)) ⟩ substn* (id B +++ σ) (weaken* B (ρ x)) ≡⟨ substn+-∙ [] (B ++ Γ) (B ++ Δ) Δ (id B +++ σ) (snd B Δ) (ρ x) ⟩ substn* ((id B +++ σ) ∙ snd B Δ) (ρ x) ≡⟨ substn*-cong (λ y → cong (par (id B) σ) (case-≫ B y))(ρ x) ⟩ substn* (snd B Γ ∙ σ) (ρ x) ≡⟨ sym (substn+-∙ [] (B ++ Γ) Γ Δ (snd B Γ) σ (ρ x)) ⟩ weaken* B (substn* σ (ρ x)) ∎ substn*-∙ : ∀ {k l Γ Δ E} (σ : Substn k Γ Δ) (ρ : Substn l Δ E) {T} (M : Exp E T) → (substn* σ (substn* ρ M) ≡ substn* (σ ∙ ρ) M) substn*-∙ {k} {l} {Γ} {Δ} {E} = substn+-∙ [] Γ Δ E -- Proof uses the fact that substn+ is an instance of substn* substn++ : ∀ {k} A B Γ Δ (σ : Substn k Γ Δ) {T} (M : Exp (A ++ B ++ Δ) T) → substn+ (A ++ B) Γ Δ σ M ≡ substn+ A (B ++ Γ) (B ++ Δ) (id B +++ σ) M substn++ A B Γ Δ σ (const c) = refl substn++ A B Γ Δ σ (abs T M) = cong (abs {A ++ B ++ Γ} T) (substn++ (T ∷ A) B Γ Δ σ M) substn++ A B Γ Δ σ (app M N) = cong₂ app (substn++ A B Γ Δ σ M) (substn++ A B Γ Δ σ N) substn++ A B Γ Δ σ (var x) = cong expr (begin xsubstn+ (A ++ B) Γ Δ σ (case (A ++ B) Δ x) ≡⟨ cong (xsubstn+ (A ++ B) Γ Δ σ) (sym (caseˡ₃ A B Δ x)) ⟩ xsubstn+ (A ++ B) Γ Δ σ (caseˡ (case₃ A B Δ x)) ≡⟨ xsubstn++ A B Γ Δ σ (case₃ A B Δ x) ⟩ xsubstn+ A (B ++ Γ) (B ++ Δ) (id B +++ σ) (caseʳ (case₃ A B Δ x)) ≡⟨ cong (xsubstn+ A (B ++ Γ) (B ++ Δ) (id B +++ σ)) (caseʳ₃ A B Δ x) ⟩ xsubstn+ A (B ++ Γ) (B ++ Δ) (id B +++ σ) (case A (B ++ Δ) x) ∎) where xsubstn++ : ∀ {k} A B Γ Δ (σ : Substn k Γ Δ) {T} (x : Case₃ T A B Δ) → xsubstn+ (A ++ B) Γ Δ σ (caseˡ x) ≡ xsubstn+ A (B ++ Γ) (B ++ Δ) (id B +++ σ) (caseʳ x) xsubstn++ A B Γ Δ σ (inj₁ x) = refl xsubstn++ {var} A B Γ Δ σ (inj₂ x) = cong (λ X → A ≫ par (id B) σ X) (sym (case-≪ x Δ)) xsubstn++ {exp var} A B Γ Δ σ (inj₂ x) = begin var (A ≫ x ≪ Γ) ≡⟨ sym (weaken*-var A (x ≪ Γ)) ⟩ weaken* A (var (x ≪ Γ)) ≡⟨ cong (weaken* A) (sym (weaken*ʳ-var Γ x)) ⟩ weaken* A (weaken*ʳ Γ (var x)) ≡⟨ cong (weaken* A ∘ par (id B) σ) (sym (case-≪ x Δ)) ⟩ weaken* A ((id B +++ σ) (x ≪ Δ)) ∎ xsubstn++ {var} A B Γ Δ σ (inj₃ x) = cong (λ X → A ≫ par (id B) σ X) (sym (case-≫ B x)) xsubstn++ {exp var} A B Γ Δ σ (inj₃ x) = begin weaken* (A ++ B) (σ x) ≡⟨ sym (substn*-∙ (snd A (B ++ Γ)) (snd B Γ) (σ x)) ⟩ weaken* A (weaken* B (σ x)) ≡⟨ cong (weaken* A ∘ par (id B) σ) (sym (case-≫ B x)) ⟩ weaken* A ((id B +++ σ) (B ≫ x)) ∎ substn+* : ∀ {k} B Γ Δ (σ : Substn k Γ Δ) {T} (M : Exp (B ++ Δ) T) → substn+ B Γ Δ σ M ≡ substn* (id B +++ σ) M substn+* = substn++ [] -- Weakening of weakening is weakening weaken*-++ : ∀ A B Γ {T} (M : Exp Γ T) → weaken* A (weaken* B M) ≡ weaken* (A ++ B) M weaken*-++ A B Γ = substn*-∙ (snd A (B ++ Γ)) (snd B Γ) -- Weakening commutes with weakening weaken*-comm : ∀ A B Γ Δ {U} (M : Exp (B ++ Δ) U) → weaken* A (weaken+ B Γ Δ M) ≡ weaken+ (A ++ B) Γ Δ (weaken* A M) weaken*-comm A B Γ Δ M = begin weaken* A (weaken+ B Γ Δ M) ≡⟨ cong (substn* (snd A (B ++ Γ ++ Δ))) (substn+* B (Γ ++ Δ) Δ (snd Γ Δ) M) ⟩ substn* (snd A (B ++ Γ ++ Δ)) (substn* (id B +++ snd Γ Δ) M) ≡⟨ substn*-∙ (snd A (B ++ Γ ++ Δ)) (id B +++ snd Γ Δ) M ⟩ substn* (snd A (B ++ Γ ++ Δ) ∙ (id B +++ snd Γ Δ)) M ≡⟨ substn*-cong lemma₂ M ⟩ substn* ((id (A ++ B) +++ snd Γ Δ) ∙ snd A (B ++ Δ)) M ≡⟨ sym (substn*-∙ (id (A ++ B) +++ snd Γ Δ) (snd A (B ++ Δ)) M) ⟩ substn* (id (A ++ B) +++ snd Γ Δ) (substn* (snd A (B ++ Δ)) M) ≡⟨ sym (substn+* (A ++ B) (Γ ++ Δ) Δ (snd Γ Δ) (substn* (snd A (B ++ Δ)) M)) ⟩ weaken+ (A ++ B) Γ Δ (weaken* A M) ∎ where lemma₁ : ∀ {T} (x : Case T B Δ) → snd A (B ++ Γ ++ Δ) (par (id B) (snd Γ Δ) x) ≡ (par (id (A ++ B)) (snd Γ Δ) (A ⋙ x)) lemma₁ (inj₁ x) = refl lemma₁ (inj₂ x) = refl lemma₂ : (snd A (B ++ Γ ++ Δ) ∙ (id B +++ snd Γ Δ)) ≈ ((id (A ++ B) +++ snd Γ Δ) ∙ snd A (B ++ Δ)) lemma₂ {T} x = begin snd A (B ++ Γ ++ Δ) (par (id B) (snd Γ Δ) (case B Δ x)) ≡⟨ lemma₁ (case B Δ x) ⟩ par (id (A ++ B)) (snd Γ Δ) (A ⋙ (case B Δ x)) ≡⟨ cong (par (id (A ++ B)) (snd Γ Δ)) (case-⋙ A B Δ x) ⟩ par (id (A ++ B)) (snd Γ Δ) (case (A ++ B) Δ (A ≫ x)) ∎ weaken-comm : ∀ T B Γ Δ {U} (M : Exp (B ++ Δ) U) → weaken T (weaken+ B Γ Δ M) ≡ weaken+ (T ∷ B) Γ Δ (weaken T M) weaken-comm T = weaken*-comm [ T ] -- Weakening distributes through susbtn weaken-substn : ∀ B Γ Δ {T U} (M : Exp (B ++ Δ) T) (N : Exp (T ∷ B ++ Δ) U) → substn (weaken+ B Γ Δ M) (weaken+ (T ∷ B) Γ Δ N) ≡ weaken+ B Γ Δ (substn M N) weaken-substn B Γ Δ {T} M N = begin substn (weaken+ B Γ Δ M) (weaken+ (T ∷ B) Γ Δ N) ≡⟨ cong₂ substn (substn+* B (Γ ++ Δ) Δ (snd Γ Δ) M) (substn+* (T ∷ B) (Γ ++ Δ) Δ (snd Γ Δ) N) ⟩ substn (substn* (id B +++ snd Γ Δ) M) (substn* (id (T ∷ B) +++ snd Γ Δ) N) ≡⟨ substn*-∙ (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) (id (T ∷ B) +++ snd Γ Δ) N ⟩ substn* ((substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) ∙ (id (T ∷ B) +++ snd Γ Δ)) N ≡⟨ substn*-cong lemma₂ N ⟩ substn* ((id B +++ snd Γ Δ) ∙ (M ◁ id (B ++ Δ))) N ≡⟨ sym (substn*-∙ (id B +++ snd Γ Δ) (M ◁ id (B ++ Δ)) N) ⟩ substn* (id B +++ snd Γ Δ) (substn M N) ≡⟨ sym (substn+* B (Γ ++ Δ) Δ (snd Γ Δ) (substn M N)) ⟩ weaken+ B Γ Δ (substn M N) ∎ where lemma₁ : ∀ {S} (x : Case₃ S [ T ] B Δ) → (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) (par (id (T ∷ B)) (snd Γ Δ) (caseˡ x)) ≡ substn* (id B +++ snd Γ Δ) (choose ⟨ M ⟩ (id (B ++ Δ)) (caseʳ x)) lemma₁ (inj₁ x) = begin (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) (x ≪ B ≪ Γ ≪ Δ) ≡⟨ cong (choose ⟨ substn* (id B +++ snd Γ Δ) M ⟩ (id (B ++ Γ ++ Δ))) (case-≪ x (B ++ Γ ++ Δ)) ⟩ ⟨ substn* (id B +++ snd Γ Δ) M ⟩ x ≡⟨ subst-natural (uniq x) (substn* (id B +++ snd Γ Δ)) M ⟩ substn* (id B +++ snd Γ Δ) (⟨ M ⟩ x) ∎ lemma₁ (inj₂ x) = begin (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) ([ T ] ≫ x ≪ Γ ≪ Δ) ≡⟨ cong (choose ⟨ substn* (id B +++ snd Γ Δ) M ⟩ (id (B ++ Γ ++ Δ))) (case-≫ [ T ] (x ≪ Γ ≪ Δ)) ⟩ var (x ≪ Γ ≪ Δ) ≡⟨ cong (var ∘ par (id B) (snd Γ Δ)) (sym (case-≪ x Δ)) ⟩ var ((id B +++ snd Γ Δ) (x ≪ Δ)) ≡⟨ cong (var ∘ xsubstn+ [] (B ++ Γ ++ Δ) (B ++ Δ) (id B +++ snd Γ Δ)) (sym (case-≫ [] (x ≪ Δ))) ⟩ substn* (id B +++ snd Γ Δ) (var (x ≪ Δ)) ∎ lemma₁ (inj₃ x) = begin (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) ([ T ] ≫ B ≫ Γ ≫ x) ≡⟨ cong (choose ⟨ substn* (id B +++ snd Γ Δ) M ⟩ (id (B ++ Γ ++ Δ))) (case-≫ [ T ] (B ≫ Γ ≫ x)) ⟩ var (B ≫ Γ ≫ x) ≡⟨ cong (var ∘ par (id B) (snd Γ Δ)) (sym (case-≫ B x)) ⟩ var ((id B +++ snd Γ Δ) (B ≫ x)) ≡⟨ cong (var ∘ xsubstn+ [] (B ++ Γ ++ Δ) (B ++ Δ) (id B +++ snd Γ Δ)) (sym (case-≫ [] (B ≫ x))) ⟩ substn* (id B +++ snd Γ Δ) (var (B ≫ x)) ∎ lemma₂ : ((substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) ∙ (id (T ∷ B) +++ snd Γ Δ)) ≈ ((id B +++ snd Γ Δ) ∙ (M ◁ id (B ++ Δ))) lemma₂ {S} x = begin ((substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) ∙ (id (T ∷ B) +++ snd Γ Δ)) x ≡⟨ cong (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ) ∘ par (id (T ∷ B)) (snd Γ Δ)) (sym (caseˡ₃ [ T ] B Δ x)) ⟩ (substn* (id B +++ snd Γ Δ) M ◁ id (B ++ Γ ++ Δ)) (par (id (T ∷ B)) (snd Γ Δ) (caseˡ (case₃ [ T ] B Δ x))) ≡⟨ lemma₁ (case₃ [ T ] B Δ x) ⟩ substn* (id B +++ snd Γ Δ) (choose ⟨ M ⟩ (id (B ++ Δ)) (caseʳ (case₃ [ T ] B Δ x))) ≡⟨ cong (substn* (id B +++ snd Γ Δ) ∘ choose ⟨ M ⟩ (id (B ++ Δ))) (caseʳ₃ [ T ] B Δ x) ⟩ ((id B +++ snd Γ Δ) ∙ (M ◁ id (B ++ Δ))) x ∎ -- Substitution into weakening discards the substitution substn-weaken : ∀ {Γ T U} (M : Exp Γ U) (N : Exp Γ T) → substn N (weaken T M) ≡ M substn-weaken {Γ} {T} M N = begin substn N (weaken T M) ≡⟨ substn*-∙ (N ◁ id Γ) (snd [ T ] Γ) M ⟩ substn* ((N ◁ id Γ) ∙ snd [ T ] Γ) M ≡⟨ substn*-cong (λ x → cong (choose ⟨ N ⟩ (id Γ)) (case-≫ [ T ] x)) M ⟩ substn* (id Γ) M ≡⟨ substn*-id M ⟩ M ∎ -- Substitution + weakening respects ◁ substn*-◁ : ∀ Γ Δ E {T U} (M : Exp (T ∷ Γ) U) (N : Exp (E ++ Δ) T) (σ : Substn (exp var) Δ Γ) → substn* (N ◁ weakens* E σ) M ≡ substn N (weaken+ [ T ] E Δ (substn+ [ T ] Δ Γ σ M)) substn*-◁ Γ Δ E {T} M N σ = begin substn* (N ◁ weakens* E σ) M ≡⟨ substn*-cong (λ x → lemma (case [ T ] Γ x)) M ⟩ substn* ((N ◁ id (E ++ Δ)) ∙ (id [ T ] +++ (snd E Δ ∙ σ))) M ≡⟨ sym (substn*-∙ (N ◁ id (E ++ Δ)) (id [ T ] +++ (snd E Δ ∙ σ)) M) ⟩ substn N (substn* (id [ T ] +++ (snd E Δ ∙ σ)) M) ≡⟨ cong (substn N) (sym (substn+* [ T ] (E ++ Δ) Γ (snd E Δ ∙ σ) M)) ⟩ substn N (substn+ [ T ] (E ++ Δ) Γ (snd E Δ ∙ σ) M) ≡⟨ cong (substn N) (sym (substn+-∙ [ T ] (E ++ Δ) Δ Γ (snd E Δ) σ M)) ⟩ substn N (weaken+ [ T ] E Δ (substn+ [ T ] Δ Γ σ M)) ∎ where lemma : ∀ {U} (x : Case U [ T ] Γ) → choose ⟨ N ⟩ (weakens* E σ) x ≡ substn N (par (id [ T ]) (snd E Δ ∙ σ) x) lemma (inj₁ x) = begin subst (Exp (E ++ Δ)) (uniq x) N ≡⟨ cong (choose ⟨ N ⟩ (id (E ++ Δ))) (sym (case-≪ x (E ++ Δ))) ⟩ (N ◁ id (E ++ Δ)) (x ≪ E ≪ Δ) ≡⟨ sym (weaken*-[] ((N ◁ id (E ++ Δ)) (x ≪ E ≪ Δ))) ⟩ weaken* [] ((N ◁ id (E ++ Δ)) (x ≪ E ≪ Δ)) ≡⟨ cong (xsubstn+ [] (E ++ Δ) ([ T ] ++ E ++ Δ) (N ◁ id (E ++ Δ))) (sym (case-≫ [] (x ≪ E ≪ Δ))) ⟩ substn N (var (x ≪ E ≪ Δ)) ≡⟨ cong (substn N) (sym (weaken*ʳ-var (E ++ Δ) x)) ⟩ substn N (weaken*ʳ (E ++ Δ) (var x)) ∎ lemma (inj₂ x) = sym (substn-weaken (weaken* E (σ x)) N)
39.028
101
0.470688
1ed220e40c6aba94f6ec36d2ef48eb0dabf5862d
23,621
agda
Agda
src/meta-vars.agda
CarlOlson/cedille
f5ce42258b7d9bc66f75cd679c785d6133b82b58
[ "MIT" ]
null
null
null
src/meta-vars.agda
CarlOlson/cedille
f5ce42258b7d9bc66f75cd679c785d6133b82b58
[ "MIT" ]
null
null
null
src/meta-vars.agda
CarlOlson/cedille
f5ce42258b7d9bc66f75cd679c785d6133b82b58
[ "MIT" ]
null
null
null
import cedille-options open import general-util module meta-vars (options : cedille-options.options) {mF : Set → Set} {{_ : monad mF}} where open import lib open import functions open import cedille-types open import constants open import conversion open import ctxt open import is-free open import rename open import spans options {mF} open import subst open import syntax-util open import to-string options -- TODO propose adding these to the standard lib module helpers where -- src/spans.agda _≫=spane_ : ∀ {A B : Set} → spanM (error-t A) → (A → spanM (error-t B)) → spanM (error-t B) (s₁ ≫=spane f) = s₁ ≫=span λ { (no-error x) → f x ; (yes-error x) → spanMr (yes-error x)} -- sum.agda is-inj₁ : ∀ {a b} {A : Set a} {B : Set b} → A ∨ B → 𝔹 is-inj₁ (inj₁ x) = tt is-inj₁ (inj₂ y) = ff open helpers -- misc ---------------------------------------------------------------------- -- Meta-variables, prototypes, decorated types -- ================================================== record meta-var-sol (A : Set) : Set where constructor mk-meta-var-sol field sol : A src : checking-mode data meta-var-sort : Set where meta-var-tp : (k : kind) → (mtp : maybe $ meta-var-sol type) → meta-var-sort meta-var-tm : (tp : type) → (mtm : maybe $ meta-var-sol term) → meta-var-sort record meta-var : Set where constructor meta-var-mk field name : string sort : meta-var-sort loc : span-location open meta-var pattern meta-var-mk-tp x k mtp l = meta-var-mk x (meta-var-tp k mtp) l record meta-vars : Set where constructor meta-vars-mk field order : 𝕃 var varset : trie meta-var open meta-vars data prototype : Set where proto-maybe : maybe type → prototype proto-arrow : maybeErased → prototype → prototype data decortype : Set where decor-type : type → decortype decor-arrow : maybeErased → type → decortype → decortype decor-decor : maybeErased → posinfo → bvar → meta-var-sort → decortype → decortype decor-stuck : type → prototype → decortype decor-error : type → prototype → decortype -- Simple definitions and accessors -- -------------------------------------------------- meta-var-name : meta-var → var meta-var-name X = meta-var.name X meta-vars-get-varlist : meta-vars → 𝕃 var meta-vars-get-varlist Xs = map (name ∘ snd) (trie-mappings (varset Xs)) meta-var-solved? : meta-var → 𝔹 meta-var-solved? (meta-var-mk n (meta-var-tp k nothing) _) = ff meta-var-solved? (meta-var-mk n (meta-var-tp k (just _)) _) = tt meta-var-solved? (meta-var-mk n (meta-var-tm tp nothing) _) = ff meta-var-solved? (meta-var-mk n (meta-var-tm tp (just _)) _) = tt meta-vars-empty : meta-vars meta-vars-empty = meta-vars-mk [] empty-trie meta-vars-empty? : meta-vars → 𝔹 meta-vars-empty? Xs = ~ (trie-nonempty (varset Xs )) meta-vars-solved? : meta-vars → 𝔹 meta-vars-solved? Xs = trie-all meta-var-solved? (varset Xs) meta-vars-filter : (meta-var → 𝔹) → meta-vars → meta-vars meta-vars-filter f Xs = meta-vars-mk or vs where vs = trie-filter f (varset Xs) or = filter (trie-contains vs) (order Xs) meta-var-sort-eq? : ctxt → (=S =T : meta-var-sort) → 𝔹 meta-var-sort-eq? Γ (meta-var-tp k₁ mtp₁) (meta-var-tp k₂ mtp₂) with conv-kind Γ k₁ k₂ ... | ff = ff ... | tt = maybe-equal? sol-eq mtp₁ mtp₂ where sol-eq : (sol₁ sol₂ : meta-var-sol type) → 𝔹 sol-eq (mk-meta-var-sol sol₁ src) (mk-meta-var-sol sol₂ src₁) = conv-type Γ sol₁ sol₂ meta-var-sort-eq? _ _ _ = ff -- TODO terms not supported -- meta-var-sol-eq? (meta-var-tm tp mtm) (meta-var-tm tp₁ mtm₁) = {!!} meta-var-equal? : ctxt → (X Y : meta-var) → 𝔹 meta-var-equal? Γ (meta-var-mk name₁ sol₁ _) (meta-var-mk name₂ sol₂ _) = name₁ =string name₂ && meta-var-sort-eq? Γ sol₁ sol₂ meta-vars-equal? : ctxt → (Xs Ys : meta-vars) → 𝔹 meta-vars-equal? Γ Xs Ys = trie-equal? (meta-var-equal? Γ) (meta-vars.varset Xs) (meta-vars.varset Ys) meta-vars-lookup : meta-vars → var → maybe meta-var meta-vars-lookup Xs x = trie-lookup (varset Xs) x meta-vars-lookup-with-kind : meta-vars → var → maybe (meta-var × kind) meta-vars-lookup-with-kind Xs x with meta-vars-lookup Xs x ... | nothing = nothing ... | (just X@(meta-var-mk-tp _ k _ _)) = just $ X , k ... | (just X) = nothing meta-var-set-src : meta-var → checking-mode → meta-var meta-var-set-src (meta-var-mk-tp name₁ k (just sol) loc₁) m = meta-var-mk-tp name₁ k (just (record sol { src = m })) loc₁ meta-var-set-src (meta-var-mk-tp name₁ k nothing loc₁) m = meta-var-mk-tp name₁ k nothing loc₁ meta-var-set-src (meta-var-mk name₁ (meta-var-tm tp (just sol)) loc₁) m = meta-var-mk name₁ (meta-var-tm tp (just (record sol { src = m }))) loc₁ meta-var-set-src (meta-var-mk name₁ (meta-var-tm tp nothing) loc₁) m = meta-var-mk name₁ (meta-var-tm tp nothing) loc₁ meta-vars-lookup-kind : meta-vars → var → maybe kind meta-vars-lookup-kind Xs x with meta-vars-lookup Xs x ... | nothing = nothing ... | (just (meta-var-mk-tp _ k _ _)) = just k ... | (just X) = nothing -- conversion to types, terms, tks -- -------------------------------------------------- meta-var-sort-to-tk : meta-var-sort → tk meta-var-sort-to-tk (meta-var-tp k mtp) = Tkk k meta-var-sort-to-tk (meta-var-tm tp mtm) = Tkt tp meta-var-to-type : meta-var → maybe type meta-var-to-type (meta-var-mk-tp x k (just tp) _) = just (meta-var-sol.sol tp) meta-var-to-type (meta-var-mk-tp x k nothing _) = just (TpVar posinfo-gen x) meta-var-to-type (meta-var-mk x (meta-var-tm tp mtm) _) = nothing meta-var-to-term : meta-var → maybe term meta-var-to-term (meta-var-mk-tp x k mtp _) = nothing meta-var-to-term (meta-var-mk x (meta-var-tm tp (just tm)) _) = just (meta-var-sol.sol tm) meta-var-to-term (meta-var-mk x (meta-var-tm tp nothing) _) = just (Var posinfo-gen x) meta-var-to-type-unsafe : meta-var → type meta-var-to-type-unsafe X with meta-var-to-type X ... | just tp = tp ... | nothing = TpVar posinfo-gen (meta-var-name X) meta-var-to-term-unsafe : meta-var → term meta-var-to-term-unsafe X with meta-var-to-term X ... | just tm = tm ... | nothing = Var posinfo-gen (meta-var-name X) prototype-to-maybe : prototype → maybe type prototype-to-maybe (proto-maybe mtp) = mtp prototype-to-maybe (proto-arrow _ _) = nothing prototype-to-checking : prototype → checking-mode prototype-to-checking = maybe-to-checking ∘ prototype-to-maybe decortype-to-type : decortype → type decortype-to-type (decor-type tp) = tp decortype-to-type (decor-arrow at tp dt) = TpArrow tp at (decortype-to-type dt) decortype-to-type (decor-decor b pi x sol dt) = Abs pi b posinfo-gen x (meta-var-sort-to-tk sol) (decortype-to-type dt) decortype-to-type (decor-stuck tp pt) = tp decortype-to-type (decor-error tp pt) = tp -- hnf for decortype -- -------------------------------------------------- hnf-decortype : ctxt → unfolding → decortype → (is-head : 𝔹) → decortype hnf-decortype Γ uf (decor-type tp) ish = decor-type (hnf Γ uf tp ish) hnf-decortype Γ uf (decor-arrow e? tp dt) ish = decor-arrow e? (hnf Γ uf tp ff) (hnf-decortype Γ uf dt ff) hnf-decortype Γ uf (decor-decor e? pi x sol dt) ish = decor-decor e? pi x sol (hnf-decortype Γ uf dt ff) hnf-decortype Γ uf dt@(decor-stuck _ _) ish = dt hnf-decortype Γ uf (decor-error tp pt) ish = decor-error (hnf Γ uf tp ff) pt -- substitutions -- -------------------------------------------------- substh-meta-var-sort : substh-ret-t meta-var-sort substh-meta-var-sort Γ ρ σ (meta-var-tp k mtp) = meta-var-tp (substh Γ ρ σ k) ((flip maybe-map) mtp λ sol → record sol { sol = substh Γ ρ σ (meta-var-sol.sol sol) }) substh-meta-var-sort Γ ρ σ (meta-var-tm tp mtm) = meta-var-tm (substh Γ ρ σ tp) (flip maybe-map mtm λ sol → record sol { sol = substh Γ ρ σ (meta-var-sol.sol sol) }) subst-meta-var-sort : subst-ret-t meta-var-sort subst-meta-var-sort Γ t x (meta-var-tp k mtp) = meta-var-tp (subst Γ t x k) $ (flip maybe-map) mtp λ sol → record sol { sol = subst Γ t x $ meta-var-sol.sol sol } subst-meta-var-sort Γ t x (meta-var-tm tp mtm) = meta-var-tm (subst Γ t x tp) $ (flip maybe-map) mtm λ where (mk-meta-var-sol sol src) → mk-meta-var-sol (subst Γ t x sol) src meta-vars-get-sub : meta-vars → trie type meta-vars-get-sub Xs = trie-catMaybe (trie-map meta-var-to-type (varset Xs)) meta-vars-subst-type' : (unfold : 𝔹) → ctxt → meta-vars → type → type meta-vars-subst-type' u Γ Xs tp = let tp' = substh Γ empty-renamectxt (meta-vars-get-sub Xs) tp in if u then hnf Γ (unfolding-elab unfold-head) tp' tt else tp' meta-vars-subst-type : ctxt → meta-vars → type → type meta-vars-subst-type = meta-vars-subst-type' tt meta-vars-subst-kind : ctxt → meta-vars → kind → kind meta-vars-subst-kind Γ Xs k = hnf Γ (unfolding-elab unfold-head) (substh Γ empty-renamectxt (meta-vars-get-sub Xs) k) tt -- string and span helpers -- -------------------------------------------------- meta-var-to-string : meta-var → strM meta-var-to-string (meta-var-mk-tp name k nothing sl) = strMetaVar name sl ≫str strAdd " : " ≫str to-stringh k meta-var-to-string (meta-var-mk-tp name k (just tp) sl) = strMetaVar name sl ≫str strAdd " : " ≫str to-stringh k ≫str strAdd " = " ≫str to-stringh (meta-var-sol.sol tp) -- tp meta-var-to-string (meta-var-mk name (meta-var-tm tp nothing) sl) = strMetaVar name sl ≫str strAdd " : " ≫str to-stringh tp meta-var-to-string (meta-var-mk name (meta-var-tm tp (just tm)) sl) = strMetaVar name sl ≫str strAdd " : " ≫str to-stringh tp ≫str strAdd " = " ≫str to-stringh (meta-var-sol.sol tm) -- tm meta-vars-to-stringh : 𝕃 meta-var → strM meta-vars-to-stringh [] = strEmpty meta-vars-to-stringh (v :: []) = meta-var-to-string v meta-vars-to-stringh (v :: vs) = meta-var-to-string v ≫str strAdd ", " ≫str meta-vars-to-stringh vs meta-vars-to-string : meta-vars → strM meta-vars-to-string Xs = meta-vars-to-stringh ((flip map) (order Xs) λ x → case trie-lookup (varset Xs) x of λ where nothing → meta-var-mk (x ^ "-missing!") (meta-var-tp (Star posinfo-gen) nothing) missing-span-location (just X) → X) prototype-to-string : prototype → strM prototype-to-string (proto-maybe nothing) = strAdd "⁇" prototype-to-string (proto-maybe (just tp)) = to-stringh tp prototype-to-string (proto-arrow e? pt) = strAdd "⁇" ≫str strAdd (arrowtype-to-string e?) ≫str prototype-to-string pt decortype-to-string : decortype → strM decortype-to-string (decor-type tp) = strAdd "[" ≫str to-stringh tp ≫str strAdd "]" decortype-to-string (decor-arrow e? tp dt) = to-stringh tp ≫str strAdd (arrowtype-to-string e?) ≫str decortype-to-string dt decortype-to-string (decor-decor e? pi x sol dt) = strAdd (binder e? sol) ≫str meta-var-to-string (meta-var-mk x sol missing-span-location) ≫str strAdd " . " ≫str decortype-to-string dt where binder : maybeErased → meta-var-sort → string binder Erased sol = "∀ " binder Pi (meta-var-tm tp mtm) = "Π " -- vv clause below "shouldn't" happen binder Pi (meta-var-tp k mtp) = "∀ " decortype-to-string (decor-stuck tp pt) = strAdd "(" ≫str to-stringh tp ≫str strAdd " , " ≫str prototype-to-string pt ≫str strAdd ")" decortype-to-string (decor-error tp pt) = strAdd "([" ≫str (to-stringh tp) ≫str strAdd "] ‼ " ≫str prototype-to-string pt ≫str strAdd ")" meta-vars-data-h : ctxt → string → kind ∨ (meta-var-sol type) → tagged-val meta-vars-data-h Γ X (inj₁ k) = strRunTag "meta-vars-intro" Γ (strAdd (unqual-local X ^ " ") ≫str to-stringh k) meta-vars-data-h Γ X (inj₂ sol) = strRunTag "meta-vars-sol" Γ $ strAdd (unqual-local X ^ " ") ≫str strAdd (checking-to-string (meta-var-sol.src sol) ^ " ") ≫str (to-stringh ∘ meta-var-sol.sol $ sol) meta-vars-data-all : ctxt → meta-vars → 𝕃 tagged-val meta-vars-data-all Γ = foldr (uncurry λ where _ (meta-var-mk X (meta-var-tp kd nothing) loc) xs → meta-vars-data-h Γ X (inj₁ kd) :: xs _ (meta-var-mk X (meta-var-tp kd (just tp)) loc) xs → meta-vars-data-h Γ X (inj₁ kd) :: meta-vars-data-h Γ X (inj₂ tp) :: xs _ _ xs → xs) [] ∘ (trie-mappings ∘ meta-vars.varset) meta-vars-intro-data : ctxt → meta-vars → 𝕃 tagged-val meta-vars-intro-data Γ = map (h ∘ snd) ∘ (trie-mappings ∘ meta-vars.varset) where h : meta-var → tagged-val h (meta-var-mk X (meta-var-tp kd mtp) loc) = meta-vars-data-h Γ X (inj₁ kd) h (meta-var-mk X (meta-var-tm tp mtm) loc) = meta-vars-data-h Γ X (inj₂ (mk-meta-var-sol (TpVar posinfo-gen "unimplemented") untyped)) meta-vars-sol-data : ctxt → meta-vars → meta-vars → 𝕃 tagged-val meta-vars-sol-data Γ Xsₒ Xsₙ = foldr (λ X xs → maybe-else xs (_:: xs) (h (snd X))) [] (trie-mappings (meta-vars.varset Xsₙ)) where h : meta-var → maybe tagged-val h (meta-var-mk X (meta-var-tp kd (just tp)) loc) with trie-lookup (meta-vars.varset Xsₒ) X ...| just (meta-var-mk _ (meta-var-tp _ (just _)) _) = nothing ...| _ = just (meta-vars-data-h Γ X (inj₂ tp) ) h (meta-var-mk X (meta-var-tp kd nothing) loc) = nothing h (meta-var-mk X (meta-var-tm tp mtm) loc) = just (meta-vars-data-h Γ X (inj₂ (mk-meta-var-sol (TpVar posinfo-gen "unimplemented") untyped))) meta-vars-check-type-mismatch : ctxt → string → type → meta-vars → type → 𝕃 tagged-val × err-m meta-vars-check-type-mismatch Γ s tp Xs tp' = (expected-type Γ tp :: [ type-data Γ tp'' ]) , (if conv-type Γ tp tp'' then nothing else just ("The expected type does not match the " ^ s ^ " type.")) where tp'' = meta-vars-subst-type' ff Γ Xs tp' meta-vars-check-type-mismatch-if : maybe type → ctxt → string → meta-vars → type → 𝕃 tagged-val × err-m meta-vars-check-type-mismatch-if (just tp) Γ s Xs tp' = meta-vars-check-type-mismatch Γ s tp Xs tp' meta-vars-check-type-mismatch-if nothing Γ s Xs tp' = [ type-data Γ tp″ ] , nothing where tp″ = meta-vars-subst-type' ff Γ Xs tp' decortype-data : ctxt → decortype → tagged-val decortype-data Γ dt = strRunTag "head decoration" Γ (decortype-to-string dt) prototype-data : ctxt → prototype → tagged-val prototype-data Γ pt = strRunTag "head prototype" Γ (prototype-to-string pt) -- collecting, merging, matching -- -------------------------------------------------- meta-var-fresh-t : (S : Set) → Set meta-var-fresh-t S = meta-vars → var → span-location → S → meta-var meta-var-fresh : meta-var-fresh-t meta-var-sort meta-var-fresh Xs x sl sol with rename-away-from (meta-var-pfx-str ^ x) (trie-contains (varset Xs)) empty-renamectxt ... | x' = meta-var-mk x' sol sl meta-var-fresh-tp : meta-var-fresh-t (kind × maybe (meta-var-sol type)) meta-var-fresh-tp Xs x sl (k , msol) = meta-var-fresh Xs x sl (meta-var-tp k msol) meta-var-fresh-tm : meta-var-fresh-t (type × maybe (meta-var-sol term)) meta-var-fresh-tm Xs x sl (tp , mtm) = meta-var-fresh Xs x sl (meta-var-tm tp mtm) private meta-vars-set : meta-vars → meta-var → meta-vars meta-vars-set Xs X = record Xs { varset = trie-insert (varset Xs) (name X) X } -- add a meta-var meta-vars-add : meta-vars → meta-var → meta-vars meta-vars-add Xs X = record (meta-vars-set Xs X) { order = (order Xs) ++ [ name X ] } meta-vars-add* : meta-vars → 𝕃 meta-var → meta-vars meta-vars-add* Xs [] = Xs meta-vars-add* Xs (Y :: Ys) = meta-vars-add* (meta-vars-add Xs Y) Ys meta-vars-from-list : 𝕃 meta-var → meta-vars meta-vars-from-list Xs = meta-vars-add* meta-vars-empty Xs meta-vars-remove : meta-vars → meta-var → meta-vars meta-vars-remove (meta-vars-mk or vs) X = let x = meta-var-name X in meta-vars-mk (remove _=string_ x or) (trie-remove vs x) meta-vars-in-type : meta-vars → type → meta-vars meta-vars-in-type Xs tp = (flip meta-vars-filter) Xs λ X → are-free-in-type check-erased (trie-single (name X) triv) tp meta-vars-unsolved : meta-vars → meta-vars meta-vars-unsolved = meta-vars-filter λ where (meta-var-mk x (meta-var-tp k mtp) _) → ~ isJust mtp (meta-var-mk x (meta-var-tm tp mtm) _) → ~ isJust mtm meta-vars-are-free-in-type : meta-vars → type → 𝔹 meta-vars-are-free-in-type Xs tp = are-free-in-type check-erased (varset Xs) tp -- Unfolding a type with meta-vars -- ================================================== -- ... in order to reveal a term or type application -- "View" data structures -- -------------------------------------------------- -- The decorated type is really an arrow record is-tmabsd : Set where constructor mk-tmabsd field is-tmabsd-dt : decortype is-tmabsd-e? : maybeErased is-tmabsd-var : var is-tmabsd-dom : type is-tmabsd-var-in-body : 𝔹 is-tmabsd-cod : decortype open is-tmabsd public is-tmabsd? = decortype ∨ is-tmabsd pattern yes-tmabsd dt e? x dom occ cod = inj₂ (mk-tmabsd dt e? x dom occ cod) pattern not-tmabsd tp = inj₁ tp record is-tpabsd : Set where constructor mk-tpabsd field is-tpabsd-dt : decortype is-tpabsd-e? : maybeErased is-tpabsd-var : var is-tpabsd-kind : kind is-tpabsd-sol : maybe type is-tpabsd-body : decortype open is-tpabsd public is-tpabsd? = decortype ∨ is-tpabsd pattern yes-tpabsd dt e? x k mtp dt' = inj₂ (mk-tpabsd dt e? x k mtp dt') pattern not-tpabsd dt = inj₁ dt {-# TERMINATING #-} num-arrows-in-type : ctxt → type → ℕ num-arrows-in-type Γ tp = nait Γ (hnf' Γ tp) 0 tt where hnf' : ctxt → type → type hnf' Γ tp = hnf Γ (unfolding-elab unfold-head) tp tt nait : ctxt → type → (acc : ℕ) → 𝔹 → ℕ -- definitely another arrow nait Γ (Abs _ _ _ _ (Tkk _) tp) acc uf = nait Γ tp acc ff nait Γ (Abs _ _ _ _ (Tkt _) tp) acc uf = nait Γ tp (1 + acc) ff nait Γ (TpArrow _ _ tp) acc uf = nait Γ tp (1 + acc) ff -- definitely not another arrow nait Γ (Iota _ _ _ _ _) acc uf = acc nait Γ (Lft _ _ _ _ _) acc uf = acc nait Γ (TpEq _ _ _ _) acc uf = acc nait Γ (TpHole _) acc uf = acc nait Γ (TpLambda _ _ _ _ _) acc uf = acc nait Γ (TpVar x₁ x₂) acc tt = acc nait Γ (TpApp tp₁ tp₂) acc tt = acc nait Γ (TpAppt tp₁ x₁) acc tt = acc -- not sure nait Γ (NoSpans tp _) acc uf = nait Γ tp acc uf nait Γ (TpLet _ (DefTerm _ x _ tm) tp) acc uf = nait Γ (subst Γ tm x tp) acc uf nait Γ (TpLet _ (DefType _ x _ tp-let) tp-in) acc uf = nait Γ (subst Γ tp-let x tp-in) acc uf nait Γ (TpParens _ tp _) acc uf = nait Γ tp acc uf nait Γ tp acc ff = nait Γ (hnf' Γ tp) acc tt -- Utilities for match-types in classify.agda -- ================================================== -- -- Match a type with meta-variables in it to one without -- errors -- -------------------------------------------------- match-error-data = string × 𝕃 tagged-val match-error-t : ∀ {a} → Set a → Set a match-error-t A = match-error-data ∨ A pattern match-error e = inj₁ e pattern match-ok a = inj₂ a module meta-vars-match-errors where -- boilerplate match-error-msg = "Matching failed" -- tagged values for error messages match-lhs : {ed : exprd} → ctxt → ⟦ ed ⟧ → tagged-val match-lhs = to-string-tag "expected lhs" match-rhs : {ed : exprd} → ctxt → ⟦ ed ⟧ → tagged-val match-rhs = to-string-tag "computed rhs" the-meta-var : var → tagged-val the-meta-var = strRunTag "the meta-var" empty-ctxt ∘ strAdd the-solution : ctxt → type → tagged-val the-solution = to-string-tag "the solution" fst-snd-sol : {ed : exprd} → ctxt → (t₁ t₂ : ⟦ ed ⟧) → 𝕃 tagged-val fst-snd-sol Γ t₁ t₂ = to-string-tag "first solution" Γ t₁ :: [ to-string-tag "second solution" Γ t₂ ] lhs-rhs : {ed : exprd} → ctxt → (t₁ t₂ : ⟦ ed ⟧) → 𝕃 tagged-val lhs-rhs Γ t₁ t₂ = match-lhs Γ t₁ :: [ match-rhs Γ t₂ ] -- error-data e-solution-ineq : ctxt → (tp₁ tp₂ : type) → var → match-error-data e-solution-ineq Γ tp₁ tp₂ X = match-error-msg ^ " because it produced two incovertible solutions for a meta-variable" , the-meta-var X :: fst-snd-sol Γ tp₁ tp₂ e-match-failure : match-error-data e-match-failure = "The expected argument type is not a (first-order) match of the computed type" , [] e-matchk-failure : match-error-data e-matchk-failure = "The expected argument kind is not a (first-order) match of the computed kind" , [] e-meta-scope : ctxt → (X tp : type) → match-error-data -- e-meta-scope : ctxt → (x : var) → (tp₁ tp₂ : type) → match-error-data e-meta-scope Γ X tp = match-error-msg ^ " because the solution contains a bound variable of the computed argument type" , to-string-tag "the meta var" Γ X :: [ to-string-tag "the solution" Γ tp ] e-bad-sol-kind : ctxt → (X : var) → (sol : type) → match-error-data e-bad-sol-kind Γ X sol = "The meta-variable was matched to a type whose kind does not match its own" , the-meta-var X :: [ the-solution Γ sol ] open meta-vars-match-errors -- meta-vars-match auxiliaries -- -------------------------------------------------- local-vars = stringset meta-vars-solve-tp : ctxt → meta-vars → var → type → checking-mode → match-error-t meta-vars meta-vars-solve-tp Γ Xs x tp m with trie-lookup (varset Xs) x ... | nothing = match-error $ x ^ " is not a meta-var!" , [] ... | just (meta-var-mk _ (meta-var-tm tp' mtm) _) = match-error $ x ^ " is a term meta-var!" , [] ... | just (meta-var-mk-tp _ k nothing sl) = match-ok (meta-vars-set Xs (meta-var-mk-tp x k (just (mk-meta-var-sol tp m)) sl)) ... | just (meta-var-mk-tp _ k (just sol) _) = let mk-meta-var-sol tp' src = sol in err⊎-guard (~ conv-type Γ tp tp') (e-solution-ineq Γ tp tp x) ≫⊎ match-ok Xs -- update the kinds of HO meta-vars with -- solutions meta-vars-update-kinds : ctxt → (Xs Xsₖ : meta-vars) → meta-vars meta-vars-update-kinds Γ Xs Xsₖ = record Xs { varset = (flip trie-map) (varset Xs) λ where (meta-var-mk-tp x k mtp sl) → meta-var-mk-tp x (meta-vars-subst-kind Γ Xsₖ k) mtp sl sol → sol } hnf-elab-if : {ed : exprd} → 𝔹 → ctxt → ⟦ ed ⟧ → 𝔹 → ⟦ ed ⟧ hnf-elab-if b Γ t b' = if b then hnf Γ (unfolding-elab unfold-head) t b' else t -- Legacy for elaboration.agda -- ================================================== -- TODO: remove dependency and delete code meta-vars-add-from-tpabs : ctxt → span-location → meta-vars → is-tpabs → meta-var × meta-vars meta-vars-add-from-tpabs Γ sl Xs (mk-tpabs e? x k tp) = let Y = meta-var-fresh-tp Xs x sl (k , nothing) Xs' = meta-vars-add Xs Y tp' = subst Γ (meta-var-to-type-unsafe Y) x tp in Y , Xs' {-# TERMINATING #-} -- subst of a meta-var does not increase distance to arrow meta-vars-peel : ctxt → span-location → meta-vars → type → (𝕃 meta-var) × type meta-vars-peel Γ sl Xs (Abs pi e? pi' x tk@(Tkk k) tp) with meta-vars-add-from-tpabs Γ sl Xs (mk-tpabs e? x k tp) ... | (Y , Xs') with subst Γ (meta-var-to-type-unsafe Y) x tp ... | tp' = let ret = meta-vars-peel Γ sl Xs' tp' ; Ys = fst ret ; rtp = snd ret in (Y :: Ys , rtp) meta-vars-peel Γ sl Xs (NoSpans tp _) = meta-vars-peel Γ sl Xs tp meta-vars-peel Γ sl Xs (TpParens _ tp _) = meta-vars-peel Γ sl Xs tp meta-vars-peel Γ sl Xs tp = [] , tp meta-vars-unfold-tpapp : ctxt → meta-vars → type → is-tpabs? meta-vars-unfold-tpapp Γ Xs tp with meta-vars-subst-type Γ Xs tp ... | Abs _ b _ x (Tkk k) tp' = yes-tpabs b x k tp' ... | tp' = not-tpabs tp' meta-vars-unfold-tmapp : ctxt → span-location → meta-vars → type → 𝕃 meta-var × is-tmabs? meta-vars-unfold-tmapp Γ sl Xs tp with meta-vars-peel Γ sl Xs (meta-vars-subst-type Γ Xs tp) ... | Ys , Abs _ b _ x (Tkt dom) cod = Ys , yes-tmabs b x dom (is-free-in check-erased x cod) cod ... | Ys , TpArrow dom e? cod = Ys , yes-tmabs e? "_" dom ff cod ... | Ys , tp' = Ys , not-tmabs tp'
35.73525
101
0.630202
d133120730a5fd5d64dc7f5641da412c6b88a673
12,043
agda
Agda
setoid-cats/Category/Preorder.agda
heades/AUGL
b33c6a59d664aed46cac8ef77d34313e148fecc2
[ "MIT" ]
null
null
null
setoid-cats/Category/Preorder.agda
heades/AUGL
b33c6a59d664aed46cac8ef77d34313e148fecc2
[ "MIT" ]
null
null
null
setoid-cats/Category/Preorder.agda
heades/AUGL
b33c6a59d664aed46cac8ef77d34313e148fecc2
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- This file contains the definition of a preorder as a category with -- -- additional properties. -- ------------------------------------------------------------------------ module Category.Preorder where open import Level renaming (suc to lsuc) open import Data.Empty open import Setoid.Total open import Category.Category open import Equality.Eq record PO {l : Level} : Set (lsuc l) where field -- The underlying category. ℙ : Cat {l} -- The preorder axiom. POax : ∀{A B}{f g : el (Hom ℙ A B)} → ⟨ Hom ℙ A B ⟩[ f ≡ g ] open PO public renaming (ℙ to po-cat) -- A PO with 4 objects. module 4PO where -- The objects. data 4Obj {l : Level} : Set l where i₁ : 4Obj i₂ : 4Obj i₃ : 4Obj i₄ : 4Obj -- The PreHom. data 4PHom {l : Level} : 4Obj {l} → 4Obj {l} → Set l where id₁ : 4PHom i₁ i₁ f₁ : 4PHom i₁ i₂ f₂ : 4PHom i₁ i₃ id₂ : 4PHom i₂ i₂ f₃ : 4PHom i₂ i₄ id₃ : 4PHom i₃ i₃ f₄ : 4PHom i₃ i₄ f₅ : 4PHom i₁ i₄ id₄ : 4PHom i₄ i₄ -- The Hom. 4Hom : {l : Level} → 4Obj {l} → 4Obj {l} → Setoid {l} 4Hom i₁ i₁ = record { el = 4PHom i₁ i₁; eq = λ a b → a ≅ b; eqRpf = isEqRel } 4Hom i₁ i₂ = record { el = 4PHom i₁ i₂; eq = λ a b → a ≅ b; eqRpf = isEqRel } 4Hom i₁ i₃ = record { el = 4PHom i₁ i₃; eq = λ a b → a ≅ b; eqRpf = isEqRel } 4Hom i₁ i₄ = record { el = 4PHom i₁ i₄; eq = λ a b → a ≅ b; eqRpf = isEqRel } 4Hom i₂ i₂ = record { el = 4PHom i₂ i₂; eq = λ a b → a ≅ b; eqRpf = isEqRel } 4Hom i₂ i₄ = record { el = 4PHom i₂ i₄; eq = λ a b → a ≅ b; eqRpf = isEqRel } 4Hom i₃ i₃ = record { el = 4PHom i₃ i₃; eq = λ a b → a ≅ b; eqRpf = isEqRel } 4Hom i₃ i₄ = record { el = 4PHom i₃ i₄; eq = λ a b → a ≅ b; eqRpf = isEqRel } 4Hom i₄ i₄ = record { el = 4PHom i₄ i₄; eq = λ a b → a ≅ b; eqRpf = isEqRel } 4Hom _ _ = EmptySetoid 4Comp : {l : Level}{a b c : 4Obj {l}} → BinSetoidFun (4Hom a b) (4Hom b c) (4Hom a c) 4Comp {_} {i₁} {i₂} {i₁} = record { appT = λ x → record { appT = λ x₁ → id₁; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₂} {i₁} {i₁} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₂} {i₁} {i₂} = record { appT = λ x → record { appT = λ x₁ → id₂; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₂} {i₁} {i₃} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₂} {i₁} {i₄} = record { appT = λ x → record { appT = λ x₁ → f₃; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₃} {i₁} {i₁} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₃} {i₂} {i₁} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₃} {i₁} {i₂} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₃} {i₁} {i₃} = record { appT = λ x → record { appT = λ x₁ → id₃; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₃} {i₁} {i₄} = record { appT = λ x → record { appT = λ x₁ → f₄; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₄} {i₁} {i₁} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₄} {i₂} {i₁} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₄} {i₁} {i₂} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₄} {i₁} {i₃} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₄} {i₃} {i₃} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₄} {i₁} {i₄} = record { appT = λ x → record { appT = λ x₁ → ⊥-poly-elim x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₄} {i₄} {i₃} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₄} {i₄} {i₂} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₄} {i₄} {i₁} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₄} {i₃} {i₄} = record { appT = λ x → record { appT = λ x₁ → id₄; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₄} {i₃} {i₂} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₄} {i₃} {i₁} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₄} {i₂} {i₄} = record { appT = λ x → record { appT = λ x₁ → id₄; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₄} {i₂} {i₃} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₄} {i₂} {i₂} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₃} {i₄} {i₃} = record { appT = λ x → record { appT = λ x₁ → id₃; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₃} {i₄} {i₂} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₃} {i₄} {i₁} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₃} {i₃} {i₄} = record { appT = λ x → record { appT = λ x₁ → f₄; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₃} {i₃} {i₂} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₃} {i₃} {i₁} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₃} {i₂} {i₄} = record { appT = λ x → record { appT = λ x₁ → f₄; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₃} {i₂} {i₃} = record { appT = λ x → record { appT = λ x₁ → id₃; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₃} {i₂} {i₂} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₃} {i₄} {i₄} = record { appT = λ x → record { appT = λ x₁ → f₄; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₂} {i₄} {i₃} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₂} {i₄} {i₂} = record { appT = λ x → record { appT = λ x₁ → id₂; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₂} {i₄} {i₁} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₂} {i₃} {i₄} = record { appT = λ x → record { appT = λ x₁ → f₃; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₂} {i₃} {i₂} = record { appT = λ x → record { appT = λ x₁ → id₂; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₂} {i₃} {i₁} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₂} {i₂} {i₄} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₂} {i₂} {i₃} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₂} {i₂} {i₂} = record { appT = λ x → record { appT = λ x₁ → id₂; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₂} {i₃} {i₃} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₂} {i₄} {i₄} = record { appT = λ x → record { appT = λ x₁ → x; extT = λ x₂ → refl }; extT = λ x₁ x₂ → x₁ } 4Comp {_} {i₁} {i₄} {i₃} = record { appT = λ x → record { appT = λ x₁ → f₂; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₁} {i₄} {i₂} = record { appT = λ x → record { appT = λ x₁ → f₁; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₁} {i₄} {i₁} = record { appT = λ x → record { appT = λ x₁ → id₁; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₁} {i₃} {i₄} = record { appT = λ x → record { appT = λ x₁ → f₅; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₁} {i₃} {i₂} = record { appT = λ x → record { appT = λ x₁ → f₁; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₁} {i₃} {i₁} = record { appT = λ x → record { appT = λ x₁ → id₁; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₁} {i₂} {i₄} = record { appT = λ x → record { appT = λ x₁ → f₅; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₁} {i₂} {i₃} = record { appT = λ x → record { appT = λ x₁ → f₂; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₁} {i₂} {i₂} = record { appT = λ x → record { appT = λ x₁ → f₁; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₁} {i₃} {i₃} = record { appT = λ x → record { appT = λ x₁ → f₂; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {_} {i₁} {i₄} {i₄} = record { appT = λ x → record { appT = λ x₁ → f₅; extT = λ x₂ → refl }; extT = λ x₁ x₂ → refl } 4Comp {l} {i₁} {i₁} {c} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refPf (eqRpf (4Hom i₁ c)) {x₂} } 4Comp {l} {i₂} {i₂} {c} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refPf (eqRpf (4Hom i₂ c)) {x₂} } 4Comp {l} {i₃} {i₃} {c} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refPf (eqRpf (4Hom i₃ c)) {x₂} } 4Comp {l} {i₄} {i₄} {c} = record { appT = λ x → record { appT = λ x₁ → x₁; extT = λ x₂ → x₂ }; extT = λ x₁ x₂ → refPf (eqRpf (4Hom i₄ c)) {x₂} } 4Id : {l : Level}{A : 4Obj {l}} → el (4Hom A A) 4Id {_}{i₁} = id₁ 4Id {_}{i₂} = id₂ 4Id {_}{i₃} = id₃ 4Id {_}{i₄} = id₄ 4PO-ax : ∀{l}{A B : 4Obj {l}}{f g : el (4Hom A B)} → eq (4Hom A B) f g 4PO-ax {A = i₁} {i₁} {id₁} {id₁} = refl 4PO-ax {A = i₁} {i₂} {f₁} {f₁} = refl 4PO-ax {A = i₁} {i₃} {f₂} {f₂} = refl 4PO-ax {A = i₁} {i₄} {f₅} {f₅} = refl 4PO-ax {A = i₂} {i₂} {id₂} {id₂} = refl 4PO-ax {A = i₂} {i₄} {f₃} {f₃} = refl 4PO-ax {A = i₃} {i₃} {id₃} {id₃} = refl 4PO-ax {A = i₃} {i₄} {f₄} {f₄} = refl 4PO-ax {A = i₄} {i₄} {id₄} {id₄} = refl 4PO-ax {A = i₂} {i₁} {f} = ⊥-poly-elim f 4PO-ax {A = i₃} {i₁} {f} = ⊥-poly-elim f 4PO-ax {A = i₄} {i₁} {f} = ⊥-poly-elim f 4PO-ax {A = i₃} {i₂} {f} = ⊥-poly-elim f 4PO-ax {A = i₄} {i₂} {f} = ⊥-poly-elim f 4PO-ax {A = i₂} {i₃} {f} = ⊥-poly-elim f 4PO-ax {A = i₄} {i₃} {f} = ⊥-poly-elim f 4AssocPf : ∀{l}{A B C D : 4Obj {l}} {f : el (4Hom A B)} {g : el (4Hom B C)}{h : el (4Hom C D)} → ⟨ 4Hom A D ⟩[ f ○[ 4Comp {l} {A}{B}{D} ] (g ○[ 4Comp {l}{B}{C}{D} ] h) ≡ (f ○[ 4Comp {l} {A}{B}{C} ] g) ○[ 4Comp {l}{A}{C}{D} ] h ] 4AssocPf {l}{A}{B}{C}{D} {f}{g} = 4PO-ax {l} {A} {D} 4IdPF : {l : Level}{A B : 4Obj {l}} {f : el (4Hom A B)} → ⟨ 4Hom A B ⟩[ (4Id {l}{A}) ○[ 4Comp {l}{A}{A}{B} ] f ≡ f ○[ 4Comp {l}{A}{B}{B} ] (4Id {l}{B}) ] 4IdPF {l}{A}{B}{f} = 4PO-ax {l} {A} {B} -- We have a category. 4cat : {l : Level} → Cat {l} 4cat {l} = record { Obj = 4Obj {l}; Hom = 4Hom; comp = λ {A} {B} {C} → 4Comp {l} {A}{B}{C}; id = λ {A} → 4Id {l}{A}; assocPf = λ {A} {B} {C} {D} {f} {g} {h} → 4AssocPf {l}{A}{B}{C}{D}{f}{g}{h}; idPfCom = λ {A} {B} {f} → 4IdPF {l}{A}{B}{f}; idPf = λ {A} {B} {f} → 4PO-ax {l} {A} {B}} -- We have a preorder. 4po : {l : Level} → PO {l} 4po {l} = record { ℙ = 4cat; POax = λ {A} {B} {f} {g} → 4PO-ax {l} {A} {B} {f} {g} }
72.113772
150
0.47455
5ea33d09d727cb53460e9178794fe92df7e84cce
3,037
agda
Agda
core/lib/groups/CommutingSquare.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
core/lib/groups/CommutingSquare.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
core/lib/groups/CommutingSquare.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
50
2015-01-10T01:48:08.000Z
2022-02-14T03:03:25.000Z
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Sigma open import lib.types.Group open import lib.types.CommutingSquare open import lib.groups.Homomorphism open import lib.groups.Isomorphism module lib.groups.CommutingSquare where -- A new type to keep the parameters. record CommSquareᴳ {i₀ i₁ j₀ j₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} (φ₀ : G₀ →ᴳ H₀) (φ₁ : G₁ →ᴳ H₁) (ξG : G₀ →ᴳ G₁) (ξH : H₀ →ᴳ H₁) : Type (lmax (lmax i₀ i₁) (lmax j₀ j₁)) where constructor comm-sqrᴳ field commutesᴳ : ∀ g₀ → GroupHom.f (ξH ∘ᴳ φ₀) g₀ == GroupHom.f (φ₁ ∘ᴳ ξG) g₀ infixr 0 _□$ᴳ_ _□$ᴳ_ = CommSquareᴳ.commutesᴳ is-csᴳ-equiv : ∀ {i₀ i₁ j₀ j₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} {φ₀ : G₀ →ᴳ H₀} {φ₁ : G₁ →ᴳ H₁} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} → CommSquareᴳ φ₀ φ₁ ξG ξH → Type (lmax (lmax i₀ i₁) (lmax j₀ j₁)) is-csᴳ-equiv {ξG = ξG} {ξH} _ = is-equiv (GroupHom.f ξG) × is-equiv (GroupHom.f ξH) CommSquareEquivᴳ : ∀ {i₀ i₁ j₀ j₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} (φ₀ : G₀ →ᴳ H₀) (φ₁ : G₁ →ᴳ H₁) (ξG : G₀ →ᴳ G₁) (ξH : H₀ →ᴳ H₁) → Type (lmax (lmax i₀ i₁) (lmax j₀ j₁)) CommSquareEquivᴳ φ₀ φ₁ ξG ξH = Σ (CommSquareᴳ φ₀ φ₁ ξG ξH) is-csᴳ-equiv abstract CommSquareᴳ-∘v : ∀ {i₀ i₁ i₂ j₀ j₁ j₂} {G₀ : Group i₀} {G₁ : Group i₁} {G₂ : Group i₂} {H₀ : Group j₀} {H₁ : Group j₁} {H₂ : Group j₂} {φ : G₀ →ᴳ H₀} {ψ : G₁ →ᴳ H₁} {χ : G₂ →ᴳ H₂} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} {μA : G₁ →ᴳ G₂} {μB : H₁ →ᴳ H₂} → CommSquareᴳ ψ χ μA μB → CommSquareᴳ φ ψ ξG ξH → CommSquareᴳ φ χ (μA ∘ᴳ ξG) (μB ∘ᴳ ξH) CommSquareᴳ-∘v {ξG = ξG} {μB = μB} (comm-sqrᴳ □₁₂) (comm-sqrᴳ □₀₁) = comm-sqrᴳ λ g₀ → ap (GroupHom.f μB) (□₀₁ g₀) ∙ □₁₂ (GroupHom.f ξG g₀) CommSquareEquivᴳ-inverse-v : ∀ {i₀ i₁ j₀ j₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} {φ₀ : G₀ →ᴳ H₀} {φ₁ : G₁ →ᴳ H₁} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} → (cse : CommSquareEquivᴳ φ₀ φ₁ ξG ξH) → CommSquareEquivᴳ φ₁ φ₀ (GroupIso.g-hom (ξG , fst (snd cse))) (GroupIso.g-hom (ξH , snd (snd cse))) CommSquareEquivᴳ-inverse-v (comm-sqrᴳ cs , ise) with CommSquareEquiv-inverse-v (comm-sqr cs , ise) ... | (comm-sqr cs' , ise') = cs'' , ise' where abstract cs'' = comm-sqrᴳ cs' CommSquareᴳ-inverse-v : ∀ {i₀ i₁ j₀ j₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} {φ₀ : G₀ →ᴳ H₀} {φ₁ : G₁ →ᴳ H₁} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} → CommSquareᴳ φ₀ φ₁ ξG ξH → (ξG-ise : is-equiv (GroupHom.f ξG)) (ξH-ise : is-equiv (GroupHom.f ξH)) → CommSquareᴳ φ₁ φ₀ (GroupIso.g-hom (ξG , ξG-ise)) (GroupIso.g-hom (ξH , ξH-ise)) CommSquareᴳ-inverse-v cs ξG-ise ξH-ise = fst (CommSquareEquivᴳ-inverse-v (cs , ξG-ise , ξH-ise)) -- basic facts nicely represented in commuting squares inv-hom-natural-comm-sqr : ∀ {i j} (G : AbGroup i) (H : AbGroup j) (φ : AbGroup.grp G →ᴳ AbGroup.grp H) → CommSquareᴳ φ φ (inv-hom G) (inv-hom H) inv-hom-natural-comm-sqr _ _ φ = comm-sqrᴳ λ g → ! (GroupHom.pres-inv φ g)
42.180556
102
0.609483
3dafd58f2f44ac463cf9631e5698efa0ffcc2e99
18,898
agda
Agda
Cubical/Foundations/GroupoidLaws.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
1
2022-03-05T00:28:39.000Z
2022-03-05T00:28:39.000Z
Cubical/Foundations/GroupoidLaws.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
null
null
null
Cubical/Foundations/GroupoidLaws.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
null
null
null
{- This file proves the higher groupoid structure of types for homogeneous and heterogeneous paths -} {-# OPTIONS --safe #-} module Cubical.Foundations.GroupoidLaws where open import Cubical.Foundations.Prelude private variable ℓ : Level A : Type ℓ x y z w v : A _⁻¹ : (x ≡ y) → (y ≡ x) x≡y ⁻¹ = sym x≡y infix 40 _⁻¹ -- homogeneous groupoid laws symInvo : (p : x ≡ y) → p ≡ p ⁻¹ ⁻¹ symInvo p = refl rUnit : (p : x ≡ y) → p ≡ p ∙ refl rUnit p j i = compPath-filler p refl j i -- The filler of left unit: lUnit-filler p = -- PathP (λ i → PathP (λ j → PathP (λ k → A) x (p (~ j ∨ i))) -- (refl i) (λ j → compPath-filler refl p i j)) (λ k i → (p (~ k ∧ i ))) (lUnit p) lUnit-filler : {x y : A} (p : x ≡ y) → I → I → I → A lUnit-filler {x = x} p j k i = hfill (λ j → λ { (i = i0) → x ; (i = i1) → p (~ k ∨ j ) ; (k = i0) → p i -- ; (k = i1) → compPath-filler refl p j i }) (inS (p (~ k ∧ i ))) j lUnit : (p : x ≡ y) → p ≡ refl ∙ p lUnit p j i = lUnit-filler p i1 j i symRefl : refl {x = x} ≡ refl ⁻¹ symRefl i = refl compPathRefl : refl {x = x} ≡ refl ∙ refl compPathRefl = rUnit refl -- The filler of right cancellation: rCancel-filler p = -- PathP (λ i → PathP (λ j → PathP (λ k → A) x (p (~ j ∧ ~ i))) -- (λ j → compPath-filler p (p ⁻¹) i j) (refl i)) (λ j i → (p (i ∧ ~ j))) (rCancel p) rCancel-filler : ∀ {x y : A} (p : x ≡ y) → (k j i : I) → A rCancel-filler {x = x} p k j i = hfill (λ k → λ { (i = i0) → x ; (i = i1) → p (~ k ∧ ~ j) -- ; (j = i0) → compPath-filler p (p ⁻¹) k i ; (j = i1) → x }) (inS (p (i ∧ ~ j))) k rCancel : (p : x ≡ y) → p ∙ p ⁻¹ ≡ refl rCancel {x = x} p j i = rCancel-filler p i1 j i rCancel-filler' : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y) → (i j k : I) → A rCancel-filler' {x = x} {y} p i j k = hfill (λ i → λ { (j = i1) → p (~ i ∧ k) ; (k = i0) → x ; (k = i1) → p (~ i) }) (inS (p k)) (~ i) rCancel' : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y) → p ∙ p ⁻¹ ≡ refl rCancel' p j k = rCancel-filler' p i0 j k lCancel : (p : x ≡ y) → p ⁻¹ ∙ p ≡ refl lCancel p = rCancel (p ⁻¹) assoc : (p : x ≡ y) (q : y ≡ z) (r : z ≡ w) → p ∙ q ∙ r ≡ (p ∙ q) ∙ r assoc p q r k = (compPath-filler p q k) ∙ compPath-filler' q r (~ k) -- heterogeneous groupoid laws symInvoP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) → PathP (λ j → PathP (λ i → symInvo (λ i → A i) j i) x y) p (symP (symP p)) symInvoP p = refl rUnitP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) → PathP (λ j → PathP (λ i → rUnit (λ i → A i) j i) x y) p (compPathP p refl) rUnitP p j i = compPathP-filler p refl j i lUnitP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) → PathP (λ j → PathP (λ i → lUnit (λ i → A i) j i) x y) p (compPathP refl p) lUnitP {A = A} {x = x} p k i = comp (λ j → lUnit-filler (λ i → A i) j k i) (λ j → λ { (i = i0) → x ; (i = i1) → p (~ k ∨ j ) ; (k = i0) → p i }) (p (~ k ∧ i )) rCancelP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) → PathP (λ j → PathP (λ i → rCancel (λ i → A i) j i) x x) (compPathP p (symP p)) refl rCancelP {A = A} {x = x} p j i = comp (λ k → rCancel-filler (λ i → A i) k j i) (λ k → λ { (i = i0) → x ; (i = i1) → p (~ k ∧ ~ j) ; (j = i1) → x }) (p (i ∧ ~ j)) lCancelP : {A : I → Type ℓ} → {x : A i0} → {y : A i1} → (p : PathP A x y) → PathP (λ j → PathP (λ i → lCancel (λ i → A i) j i) y y) (compPathP (symP p) p) refl lCancelP p = rCancelP (symP p) assocP : {A : I → Type ℓ} {x : A i0} {y : A i1} {B_i1 : Type ℓ} {B : (A i1) ≡ B_i1} {z : B i1} {C_i1 : Type ℓ} {C : (B i1) ≡ C_i1} {w : C i1} (p : PathP A x y) (q : PathP (λ i → B i) y z) (r : PathP (λ i → C i) z w) → PathP (λ j → PathP (λ i → assoc (λ i → A i) B C j i) x w) (compPathP p (compPathP q r)) (compPathP (compPathP p q) r) assocP {A = A} {B = B} {C = C} p q r k i = comp (\ j' → hfill (λ j → λ { (i = i0) → A i0 ; (i = i1) → compPath-filler' (λ i₁ → B i₁) (λ i₁ → C i₁) (~ k) j }) (inS (compPath-filler (λ i₁ → A i₁) (λ i₁ → B i₁) k i)) j') (λ j → λ { (i = i0) → p i0 ; (i = i1) → comp (\ j' → hfill ((λ l → λ { (j = i0) → B k ; (j = i1) → C l ; (k = i1) → C (j ∧ l) })) (inS (B ( j ∨ k)) ) j') (λ l → λ { (j = i0) → q k ; (j = i1) → r l ; (k = i1) → r (j ∧ l) }) (q (j ∨ k)) }) (compPathP-filler p q k i) -- Loic's code below -- some exchange law for doubleCompPath and refl invSides-filler : {x y z : A} (p : x ≡ y) (q : x ≡ z) → Square p (sym q) q (sym p) invSides-filler {x = x} p q i j = hcomp (λ k → λ { (i = i0) → p (k ∧ j) ; (i = i1) → q (~ j ∧ k) ; (j = i0) → q (i ∧ k) ; (j = i1) → p (~ i ∧ k)}) x leftright : {ℓ : Level} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) → (refl ∙∙ p ∙∙ q) ≡ (p ∙∙ q ∙∙ refl) leftright p q i j = hcomp (λ t → λ { (j = i0) → p (i ∧ (~ t)) ; (j = i1) → q (t ∨ i) }) (invSides-filler q (sym p) (~ i) j) -- equating doubleCompPath and a succession of two compPath split-leftright : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) → (p ∙∙ q ∙∙ r) ≡ (refl ∙∙ (p ∙∙ q ∙∙ refl) ∙∙ r) split-leftright p q r j i = hcomp (λ t → λ { (i = i0) → p (~ j ∧ ~ t) ; (i = i1) → r t }) (doubleCompPath-filler p q refl j i) split-leftright' : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) → (p ∙∙ q ∙∙ r) ≡ (p ∙∙ (refl ∙∙ q ∙∙ r) ∙∙ refl) split-leftright' p q r j i = hcomp (λ t → λ { (i = i0) → p (~ t) ; (i = i1) → r (j ∨ t) }) (doubleCompPath-filler refl q r j i) doubleCompPath-elim : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) → (p ∙∙ q ∙∙ r) ≡ (p ∙ q) ∙ r doubleCompPath-elim p q r = (split-leftright p q r) ∙ (λ i → (leftright p q (~ i)) ∙ r) doubleCompPath-elim' : {ℓ : Level} {A : Type ℓ} {w x y z : A} (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) → (p ∙∙ q ∙∙ r) ≡ p ∙ (q ∙ r) doubleCompPath-elim' p q r = (split-leftright' p q r) ∙ (sym (leftright p (q ∙ r))) cong-∙∙-filler : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {x y z w : A} (f : A → B) (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) → I → I → I → B cong-∙∙-filler {A = A} f p q r k j i = hfill ((λ k → λ { (j = i1) → doubleCompPath-filler (cong f p) (cong f q) (cong f r) k i ; (j = i0) → f (doubleCompPath-filler p q r k i) ; (i = i0) → f (p (~ k)) ; (i = i1) → f (r k) })) (inS (f (q i))) k cong-∙∙ : ∀ {B : Type ℓ} (f : A → B) (p : w ≡ x) (q : x ≡ y) (r : y ≡ z) → cong f (p ∙∙ q ∙∙ r) ≡ (cong f p) ∙∙ (cong f q) ∙∙ (cong f r) cong-∙∙ f p q r j i = cong-∙∙-filler f p q r i1 j i cong-∙ : ∀ {B : Type ℓ} (f : A → B) (p : x ≡ y) (q : y ≡ z) → cong f (p ∙ q) ≡ (cong f p) ∙ (cong f q) cong-∙ f p q = cong-∙∙ f refl p q hcomp-unique : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) → (h2 : ∀ i → A [ (φ ∨ ~ i) ↦ (\ { (φ = i1) → u i 1=1; (i = i0) → outS u0}) ]) → (hcomp u (outS u0) ≡ outS (h2 i1)) [ φ ↦ (\ { (φ = i1) → (\ i → u i1 1=1)}) ] hcomp-unique {φ = φ} u u0 h2 = inS (\ i → hcomp (\ k → \ { (φ = i1) → u k 1=1 ; (i = i1) → outS (h2 k) }) (outS u0)) lid-unique : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) → (h1 h2 : ∀ i → A [ (φ ∨ ~ i) ↦ (\ { (φ = i1) → u i 1=1; (i = i0) → outS u0}) ]) → (outS (h1 i1) ≡ outS (h2 i1)) [ φ ↦ (\ { (φ = i1) → (\ i → u i1 1=1)}) ] lid-unique {φ = φ} u u0 h1 h2 = inS (\ i → hcomp (\ k → \ { (φ = i1) → u k 1=1 ; (i = i0) → outS (h1 k) ; (i = i1) → outS (h2 k) }) (outS u0)) transp-hcomp : ∀ {ℓ} (φ : I) {A' : Type ℓ} (A : (i : I) → Type ℓ [ φ ↦ (λ _ → A') ]) (let B = \ (i : I) → outS (A i)) → ∀ {ψ} (u : I → Partial ψ (B i0)) → (u0 : B i0 [ ψ ↦ u i0 ]) → (transp (\ i → B i) φ (hcomp u (outS u0)) ≡ hcomp (\ i o → transp (\ i → B i) φ (u i o)) (transp (\ i → B i) φ (outS u0))) [ ψ ↦ (\ { (ψ = i1) → (\ i → transp (\ i → B i) φ (u i1 1=1))}) ] transp-hcomp φ A u u0 = inS (sym (outS (hcomp-unique ((\ i o → transp (\ i → B i) φ (u i o))) (inS (transp (\ i → B i) φ (outS u0))) \ i → inS (transp (\ i → B i) φ (hfill u u0 i))))) where B = \ (i : I) → outS (A i) hcomp-cong : ∀ {ℓ} {A : Type ℓ} {φ} → (u : I → Partial φ A) → (u0 : A [ φ ↦ u i0 ]) → (u' : I → Partial φ A) → (u0' : A [ φ ↦ u' i0 ]) → (ueq : ∀ i → PartialP φ (\ o → u i o ≡ u' i o)) → (outS u0 ≡ outS u0') [ φ ↦ (\ { (φ = i1) → ueq i0 1=1}) ] → (hcomp u (outS u0) ≡ hcomp u' (outS u0')) [ φ ↦ (\ { (φ = i1) → ueq i1 1=1 }) ] hcomp-cong u u0 u' u0' ueq 0eq = inS (\ j → hcomp (\ i o → ueq i o j) (outS 0eq j)) congFunct-filler : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {x y z : A} (f : A → B) (p : x ≡ y) (q : y ≡ z) → I → I → I → B congFunct-filler {x = x} f p q i j z = hfill (λ k → λ { (i = i0) → f x ; (i = i1) → f (q k) ; (j = i0) → f (compPath-filler p q k i)}) (inS (f (p i))) z congFunct : ∀ {ℓ} {B : Type ℓ} (f : A → B) (p : x ≡ y) (q : y ≡ z) → cong f (p ∙ q) ≡ cong f p ∙ cong f q congFunct f p q j i = congFunct-filler f p q i j i1 -- congFunct for dependent types congFunct-dep : ∀ {ℓ ℓ'} {A : Type ℓ} {B : A → Type ℓ'} {x y z : A} (f : (a : A) → B a) (p : x ≡ y) (q : y ≡ z) → PathP (λ i → PathP (λ j → B (compPath-filler p q i j)) (f x) (f (q i))) (cong f p) (cong f (p ∙ q)) congFunct-dep {B = B} {x = x} f p q i j = f (compPath-filler p q i j) cong₂Funct : ∀ {ℓ ℓ'} {A : Type ℓ} {x y : A} {B : Type ℓ'} (f : A → A → B) → (p : x ≡ y) → {u v : A} (q : u ≡ v) → cong₂ f p q ≡ cong (λ x → f x u) p ∙ cong (f y) q cong₂Funct {x = x} {y = y} f p {u = u} {v = v} q j i = hcomp (λ k → λ { (i = i0) → f x u ; (i = i1) → f y (q k) ; (j = i0) → f (p i) (q (i ∧ k))}) (f (p i) u) symDistr-filler : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) → I → I → I → A symDistr-filler {A = A} {z = z} p q i j k = hfill (λ k → λ { (i = i0) → q (k ∨ j) ; (i = i1) → p (~ k ∧ j) }) (inS (invSides-filler q (sym p) i j)) k symDistr : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : y ≡ z) → sym (p ∙ q) ≡ sym q ∙ sym p symDistr p q i j = symDistr-filler p q j i i1 -- we can not write hcomp-isEquiv : {ϕ : I} → (p : I → Partial ϕ A) → isEquiv (λ (a : A [ ϕ ↦ p i0 ]) → hcomp p a) -- due to size issues. But what we can write (compare to hfill) is: hcomp-equivFillerSub : {ϕ : I} → (p : I → Partial ϕ A) → (a : A [ ϕ ↦ p i0 ]) → (i : I) → A [ ϕ ∨ i ∨ ~ i ↦ (λ { (i = i0) → outS a ; (i = i1) → hcomp (λ i → p (~ i)) (hcomp p (outS a)) ; (ϕ = i1) → p i0 1=1 }) ] hcomp-equivFillerSub {ϕ = ϕ} p a i = inS (hcomp (λ k → λ { (i = i1) → hfill (λ j → p (~ j)) (inS (hcomp p (outS a))) k ; (i = i0) → outS a ; (ϕ = i1) → p (~ k ∧ i) 1=1 }) (hfill p a i)) hcomp-equivFiller : {ϕ : I} → (p : I → Partial ϕ A) → (a : A [ ϕ ↦ p i0 ]) → (i : I) → A hcomp-equivFiller p a i = outS (hcomp-equivFillerSub p a i) pentagonIdentity : (p : x ≡ y) → (q : y ≡ z) → (r : z ≡ w) → (s : w ≡ v) → (assoc p q (r ∙ s) ∙ assoc (p ∙ q) r s) ≡ cong (p ∙_) (assoc q r s) ∙∙ assoc p (q ∙ r) s ∙∙ cong (_∙ s) (assoc p q r) pentagonIdentity {x = x} {y} p q r s = (λ i → (λ j → cong (p ∙_) (assoc q r s) (i ∧ j)) ∙∙ (λ j → lemma₀₀ i j ∙ lemma₀₁ i j) ∙∙ (λ j → lemma₁₀ i j ∙ lemma₁₁ i j) ) where lemma₀₀ : ( i j : I) → _ ≡ _ lemma₀₀ i j i₁ = hcomp (λ k → λ { (j = i0) → p i₁ ; (i₁ = i0) → x ; (i₁ = i1) → hcomp (λ k₁ → λ { (i = i0) → (q (j ∧ k)) ; (k = i0) → y ; (j = i0) → y ; (j = i1)(k = i1) → r (k₁ ∧ i)}) (q (j ∧ k)) }) (p i₁) lemma₀₁ : ( i j : I) → hcomp (λ k → λ {(i = i0) → q j ; (j = i0) → y ; (j = i1) → r (k ∧ i) }) (q j) ≡ _ lemma₀₁ i j i₁ = (hcomp (λ k → λ { (j = i1) → hcomp (λ k₁ → λ { (i₁ = i0) → r i ; (k = i0) → r i ; (i = i1) → s (k₁ ∧ k ∧ i₁) ; (i₁ = i1)(k = i1) → s k₁ }) (r ((i₁ ∧ k) ∨ i)) ; (i₁ = i0) → compPath-filler q r i j ; (i₁ = i1) → hcomp (λ k₁ → λ { (k = i0) → r i ; (k = i1) → s k₁ ; (i = i1) → s (k ∧ k₁)}) (r (i ∨ k))}) (hfill (λ k → λ { (j = i1) → r k ; (i₁ = i1) → r k ; (i₁ = i0)(j = i0) → y }) (inS (q (i₁ ∨ j))) i)) lemma₁₁ : ( i j : I) → (r (i ∨ j)) ≡ _ lemma₁₁ i j i₁ = hcomp (λ k → λ { (i = i1) → s (i₁ ∧ k) ; (j = i1) → s (i₁ ∧ k) ; (i₁ = i0) → r (i ∨ j) ; (i₁ = i1) → s k }) (r (i ∨ j ∨ i₁)) lemma₁₀-back : I → I → I → _ lemma₁₀-back i j i₁ = hcomp (λ k → λ { (i₁ = i0) → x ; (i₁ = i1) → hcomp (λ k₁ → λ { (k = i0) → q (j ∨ ~ i) ; (k = i1) → r (k₁ ∧ j) ; (j = i0) → q (k ∨ ~ i) ; (j = i1) → r (k₁ ∧ k) ; (i = i0) → r (k ∧ j ∧ k₁) }) (q (k ∨ j ∨ ~ i)) ; (i = i0)(j = i0) → (p ∙ q) i₁ }) (hcomp (λ k → λ { (i₁ = i0) → x ; (i₁ = i1) → q ((j ∨ ~ i ) ∧ k) ; (j = i0)(i = i1) → p i₁ }) (p i₁)) lemma₁₀-front : I → I → I → _ lemma₁₀-front i j i₁ = (((λ _ → x) ∙∙ compPath-filler p q j ∙∙ (λ i₁ → hcomp (λ k → λ { (i₁ = i0) → q j ; (i₁ = i1) → r (k ∧ (j ∨ i)) ; (j = i0)(i = i0) → q i₁ ; (j = i1) → r (i₁ ∧ k) }) (q (j ∨ i₁)) )) i₁) compPath-filler-in-filler : (p : _ ≡ y) → (q : _ ≡ _ ) → _≡_ {A = Square (p ∙ q) (p ∙ q) (λ _ → x) (λ _ → z)} (λ i j → hcomp (λ i₂ → λ { (j = i0) → x ; (j = i1) → q (i₂ ∨ ~ i) ; (i = i0) → (p ∙ q) j }) (compPath-filler p q (~ i) j)) (λ _ → p ∙ q) compPath-filler-in-filler p q z i j = hcomp (λ k → λ { (j = i0) → p i0 ; (j = i1) → q (k ∨ ~ i ∧ ~ z) ; (i = i0) → hcomp (λ i₂ → λ { (j = i0) → p i0 ;(j = i1) → q ((k ∨ ~ z) ∧ i₂) ;(z = i1) (k = i0) → p j }) (p j) ; (i = i1) → compPath-filler p (λ i₁ → q (k ∧ i₁)) k j ; (z = i0) → hfill ((λ i₂ → λ { (j = i0) → p i0 ; (j = i1) → q (i₂ ∨ ~ i) ; (i = i0) → (p ∙ q) j })) (inS ((compPath-filler p q (~ i) j))) k ; (z = i1) → compPath-filler p q k j }) (compPath-filler p q (~ i ∧ ~ z) j) cube-comp₋₀₋ : (c : I → I → I → A) → {a' : Square _ _ _ _} → (λ i i₁ → c i i0 i₁) ≡ a' → (I → I → I → A) cube-comp₋₀₋ c p i j k = hcomp (λ l → λ { (i = i0) → c i0 j k ;(i = i1) → c i1 j k ;(j = i0) → p l i k ;(j = i1) → c i i1 k ;(k = i0) → c i j i0 ;(k = i1) → c i j i1 }) (c i j k) cube-comp₀₋₋ : (c : I → I → I → A) → {a' : Square _ _ _ _} → (λ i i₁ → c i0 i i₁) ≡ a' → (I → I → I → A) cube-comp₀₋₋ c p i j k = hcomp (λ l → λ { (i = i0) → p l j k ;(i = i1) → c i1 j k ;(j = i0) → c i i0 k ;(j = i1) → c i i1 k ;(k = i0) → c i j i0 ;(k = i1) → c i j i1 }) (c i j k) lemma₁₀-back' : _ lemma₁₀-back' k j i₁ = (cube-comp₋₀₋ (lemma₁₀-back) (compPath-filler-in-filler p q)) k j i₁ lemma₁₀ : ( i j : I) → _ ≡ _ lemma₁₀ i j i₁ = (cube-comp₀₋₋ lemma₁₀-front (sym lemma₁₀-back')) i j i₁ -- misc. ∙∙lCancel-fill : ∀ {ℓ} {A : Type ℓ} {x y : A} → (p : x ≡ y) → I → I → I → A ∙∙lCancel-fill p i j k = hfill (λ k → λ { (i = i1) → p k ; (j = i0) → p k ; (j = i1) → p k}) (inS (p i0)) k ∙∙lCancel : ∀ {ℓ} {A : Type ℓ} {x y : A} → (p : x ≡ y) → sym p ∙∙ refl ∙∙ p ≡ refl ∙∙lCancel p i j = ∙∙lCancel-fill p i j i1
37.947791
139
0.336173
ada608a85b5fe4e6ab027665dedb75fab42f9b32
2,728
agda
Agda
Cubical/Categories/NaturalTransformation.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/Categories/NaturalTransformation.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/Categories/NaturalTransformation.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical #-} module Cubical.Categories.NaturalTransformation where open import Cubical.Foundations.Prelude open import Cubical.Categories.Category open import Cubical.Categories.Functor private variable ℓ𝒞 ℓ𝒞' ℓ𝒟 ℓ𝒟' : Level module _ {𝒞 : Precategory ℓ𝒞 ℓ𝒞'} {𝒟 : Precategory ℓ𝒟 ℓ𝒟'} where record NatTrans (F G : Functor 𝒞 𝒟) : Type (ℓ-max (ℓ-max ℓ𝒞 ℓ𝒞') (ℓ-max ℓ𝒟 ℓ𝒟')) where open Precategory open Functor field N-ob : (x : 𝒞 .ob) → 𝒟 .hom (F .F-ob x) (G .F-ob x) N-hom : {x y : 𝒞 .ob} (f : 𝒞 .hom x y) → 𝒟 .seq (F .F-hom f) (N-ob y) ≡ 𝒟 .seq (N-ob x) (G .F-hom f) open Precategory open Functor open NatTrans id-trans : (F : Functor 𝒞 𝒟) → NatTrans F F id-trans F .N-ob x = 𝒟 .idn (F .F-ob x) id-trans F .N-hom f = 𝒟 .seq (F .F-hom f) (id-trans F .N-ob _) ≡⟨ 𝒟 .seq-ρ _ ⟩ F .F-hom f ≡⟨ sym (𝒟 .seq-λ _) ⟩ 𝒟 .seq (𝒟 .idn (F .F-ob _)) (F .F-hom f) ∎ seq-trans : {F G H : Functor 𝒞 𝒟} (α : NatTrans F G) (β : NatTrans G H) → NatTrans F H seq-trans α β .N-ob x = 𝒟 .seq (α .N-ob x) (β .N-ob x) seq-trans {F} {G} {H} α β .N-hom f = 𝒟 .seq (F .F-hom f) (𝒟 .seq (α .N-ob _) (β .N-ob _)) ≡⟨ sym (𝒟 .seq-α _ _ _) ⟩ 𝒟 .seq (𝒟 .seq (F .F-hom f) (α .N-ob _)) (β .N-ob _) ≡[ i ]⟨ 𝒟 .seq (α .N-hom f i) (β .N-ob _) ⟩ 𝒟 .seq (𝒟 .seq (α .N-ob _) (G .F-hom f)) (β .N-ob _) ≡⟨ 𝒟 .seq-α _ _ _ ⟩ 𝒟 .seq (α .N-ob _) (𝒟 .seq (G .F-hom f) (β .N-ob _)) ≡[ i ]⟨ 𝒟 .seq (α .N-ob _) (β .N-hom f i) ⟩ 𝒟 .seq (α .N-ob _) (𝒟 .seq (β .N-ob _) (H .F-hom f)) ≡⟨ sym (𝒟 .seq-α _ _ _) ⟩ 𝒟 .seq (𝒟 .seq (α .N-ob _) (β .N-ob _)) (H .F-hom f) ∎ module _ ⦃ 𝒟-category : isCategory 𝒟 ⦄ {F G : Functor 𝒞 𝒟} {α β : NatTrans F G} where open Precategory open Functor open NatTrans make-nat-trans-path : α .N-ob ≡ β .N-ob → α ≡ β make-nat-trans-path p i .N-ob = p i make-nat-trans-path p i .N-hom f = rem i where rem : PathP (λ i → 𝒟 .seq (F .F-hom f) (p i _) ≡ 𝒟 .seq (p i _) (G .F-hom f)) (α .N-hom f) (β .N-hom f) rem = toPathP (𝒟-category .homIsSet _ _ _ _) module _ (𝒞 : Precategory ℓ𝒞 ℓ𝒞') (𝒟 : Precategory ℓ𝒟 ℓ𝒟') ⦃ _ : isCategory 𝒟 ⦄ where open Precategory open NatTrans open Functor FUNCTOR : Precategory (ℓ-max (ℓ-max ℓ𝒞 ℓ𝒞') (ℓ-max ℓ𝒟 ℓ𝒟')) (ℓ-max (ℓ-max ℓ𝒞 ℓ𝒞') (ℓ-max ℓ𝒟 ℓ𝒟')) FUNCTOR .ob = Functor 𝒞 𝒟 FUNCTOR .hom = NatTrans FUNCTOR .idn = id-trans FUNCTOR .seq = seq-trans FUNCTOR .seq-λ α = make-nat-trans-path λ i x → 𝒟 .seq-λ (α .N-ob x) i FUNCTOR .seq-ρ α = make-nat-trans-path λ i x → 𝒟 .seq-ρ (α .N-ob x) i FUNCTOR .seq-α α β γ = make-nat-trans-path λ i x → 𝒟 .seq-α (α .N-ob x) (β .N-ob x) (γ .N-ob x) i
34.1
111
0.538856
191cc1062204a983c1b2ab00868919a1a6b50168
435
agda
Agda
Categories/Diagram/Finite.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
Categories/Diagram/Finite.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
Categories/Diagram/Finite.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} module Categories.Diagram.Finite where open import Level open import Categories.Category open import Categories.Category.Finite renaming (Finite to FiniteC) open import Categories.Functor private variable o ℓ e : Level J C : Category o ℓ e record Finite (F : Functor J C) : Set (levelOfTerm F) where field finite : FiniteC J open Functor F public open FiniteC finite public
19.772727
67
0.731034
a0d6e821a5555e72da6c5df8bc93320528a3fcc0
117
agda
Agda
Cubical/Algebra/DistLattice.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
301
2018-10-17T18:00:24.000Z
2022-03-24T02:10:47.000Z
Cubical/Algebra/DistLattice.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
584
2018-10-15T09:49:02.000Z
2022-03-30T12:09:17.000Z
Cubical/Algebra/DistLattice.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
134
2018-11-16T06:11:03.000Z
2022-03-23T16:22:13.000Z
{-# OPTIONS --safe #-} module Cubical.Algebra.DistLattice where open import Cubical.Algebra.DistLattice.Base public
23.4
51
0.786325
31a7e60031835e6d792a7ac3c0cf569978813ee0
2,607
agda
Agda
test/Succeed/AbstractCoinduction.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/AbstractCoinduction.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/AbstractCoinduction.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2016-10-03, re issue #2231 -- Testing whether the musical coinduction works fine in abstract blocks {-# OPTIONS --guardedness #-} module AbstractCoinduction where 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 ♭ #-} infixr 5 _≺_ abstract ------------------------------------------------------------------------ -- Streams data Stream (A : Set) : Set where _≺_ : (x : A) (xs : ∞ (Stream A)) -> Stream A head : ∀ {A} -> Stream A -> A head (x ≺ xs) = x tail : ∀ {A} -> Stream A -> Stream A tail (x ≺ xs) = ♭ xs ------------------------------------------------------------------------ -- Stream programs infix 8 _∞ infixr 5 _⋎_ infix 4 ↓_ mutual data Stream′ (A : Set) : Set1 where _≺_ : (x : A) (xs : ∞ (StreamProg A)) -> Stream′ A data StreamProg (A : Set) : Set1 where ↓_ : (xs : Stream′ A) -> StreamProg A _∞' : (x : A) -> StreamProg A _⋎'_ : (xs ys : StreamProg A) -> StreamProg A _∞ : ∀ {A : Set} (x : A) -> StreamProg A _∞ = _∞' _⋎_ : ∀ {A : Set} (xs ys : StreamProg A) -> StreamProg A _⋎_ = _⋎'_ head′ : ∀ {A} → Stream′ A → A head′ (x ≺ xs) = x tail′ : ∀ {A} → Stream′ A → StreamProg A tail′ (x ≺ xs) = ♭ xs P⇒′ : ∀ {A} -> StreamProg A -> Stream′ A P⇒′ (↓ xs) = xs P⇒′ (x ∞') = x ≺ ♯ (x ∞) P⇒′ (xs ⋎' ys) with P⇒′ xs P⇒′ (xs ⋎' ys) | xs′ = head′ xs′ ≺ ♯ (ys ⋎ tail′ xs′) mutual ′⇒ : ∀ {A} -> Stream′ A -> Stream A ′⇒ (x ≺ xs) = x ≺ ♯ P⇒ (♭ xs) P⇒ : ∀ {A} -> StreamProg A -> Stream A P⇒ xs = ′⇒ (P⇒′ xs) ------------------------------------------------------------------------ -- Stream equality infix 4 _≡_ _≈_ _≊_ data _≡_ {a : Set} (x : a) : a -> Set where ≡-refl : x ≡ x data _≈_ {A} (xs ys : Stream A) : Set where _≺_ : (x≡ : head xs ≡ head ys) (xs≈ : ∞ (tail xs ≈ tail ys)) -> xs ≈ ys _≊_ : ∀ {A} (xs ys : StreamProg A) -> Set xs ≊ ys = P⇒ xs ≈ P⇒ ys foo : ∀ {A : Set} (x : A) -> x ∞ ⋎ x ∞ ≊ x ∞ foo x = ≡-refl ≺ ♯ foo x -- The first goal has goal type -- head (′⇒ (x ≺ x ∞ ⋎ x ∞)) ≡ head (′⇒ (x ≺ x ∞)). -- The normal form of the left-hand side is x, and the normal form of -- the right-hand side is x (both according to Agda), but ≡-refl is -- not accepted by the type checker: -- x != head (′⇒ (P⇒′ (x ∞))) of type .A -- when checking that the expression ≡-refl has type -- (head (P⇒ (x ∞ ⋎ x ∞)) ≡ head (P⇒ (x ∞)))
24.828571
74
0.43575
a0aa219969b56b6e4b859b88342728640791c303
233
agda
Agda
stdlib-exts/Data/Empty/Instance.agda
WhatisRT/meta-cedille
62fa6f36e4555360d94041113749bbb6d291691c
[ "MIT" ]
35
2019-06-13T07:44:50.000Z
2021-10-12T22:59:10.000Z
stdlib-exts/Data/Empty/Instance.agda
WhatisRT/meta-cedille
62fa6f36e4555360d94041113749bbb6d291691c
[ "MIT" ]
10
2019-06-13T17:44:43.000Z
2020-04-25T15:29:17.000Z
stdlib-exts/Data/Empty/Instance.agda
WhatisRT/meta-cedille
62fa6f36e4555360d94041113749bbb6d291691c
[ "MIT" ]
2
2019-06-27T23:12:48.000Z
2021-10-20T10:46:20.000Z
module Data.Empty.Instance where open import Class.Equality open import Class.Show open import Data.Empty instance Empty-Eq : Eq ⊥ Empty-Eq = record { _≟_ = λ x () } Empty-Show : Show ⊥ Empty-Show = record { show = λ () }
17.923077
37
0.669528
9abd0688f5a3250bec93cbd3461b5d7d74e69372
688
agda
Agda
Formalization/LambdaCalculus/Semantics/CallByValue.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
Formalization/LambdaCalculus/Semantics/CallByValue.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
Formalization/LambdaCalculus/Semantics/CallByValue.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
module Formalization.LambdaCalculus.Semantics.CallByValue where import Lvl open import Data open import Formalization.LambdaCalculus open import Formalization.LambdaCalculus.Semantics open import Formalization.LambdaCalculus.SyntaxTransformation open import Logic.Predicate open import Numeral.Natural open import Syntax.Number open import Type private variable d db : ℕ private variable f t x : Term(d) private variable body : Term(db) private variable v vx : ∃(Value) data _⇓_ : Term(d) → ∃(Value) → Type{0} where value : ⦃ val : Value(t) ⦄ → (t ⇓ [∃]-intro t) apply : (f ⇓ [∃]-intro(Abstract body)) → (x ⇓ vx) → (substituteVar0 ([∃]-witness vx) body ⇓ v) → (Apply f x ⇓ v)
32.761905
114
0.732558
41176879bb4b10b5327567b1c07effdff9df1c80
22,304
agda
Agda
agda/Text/Greek/SBLGNT/Jude.agda
scott-fleischman/GreekGrammar
915c46c27c7f8aad5907474d8484f2685a4cd6a7
[ "MIT" ]
44
2015-05-29T14:48:51.000Z
2022-03-06T15:41:57.000Z
agda/Text/Greek/SBLGNT/Jude.agda
scott-fleischman/GreekGrammar
915c46c27c7f8aad5907474d8484f2685a4cd6a7
[ "MIT" ]
13
2015-05-28T20:04:08.000Z
2020-09-07T11:58:38.000Z
agda/Text/Greek/SBLGNT/Jude.agda
scott-fleischman/GreekGrammar
915c46c27c7f8aad5907474d8484f2685a4cd6a7
[ "MIT" ]
5
2015-02-27T22:34:13.000Z
2017-06-11T11:25:09.000Z
module Text.Greek.SBLGNT.Jude where open import Data.List open import Text.Greek.Bible open import Text.Greek.Script open import Text.Greek.Script.Unicode ΙΟΥΔΑ : List (Word) ΙΟΥΔΑ = word (Ἰ ∷ ο ∷ ύ ∷ δ ∷ α ∷ ς ∷ []) "Jude.1.1" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Jude.1.1" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.1" ∷ word (δ ∷ ο ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "Jude.1.1" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ὸ ∷ ς ∷ []) "Jude.1.1" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.1" ∷ word (Ἰ ∷ α ∷ κ ∷ ώ ∷ β ∷ ο ∷ υ ∷ []) "Jude.1.1" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Jude.1.1" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.1" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "Jude.1.1" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὶ ∷ []) "Jude.1.1" ∷ word (ἠ ∷ γ ∷ α ∷ π ∷ η ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.1" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Jude.1.1" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Jude.1.1" ∷ word (τ ∷ ε ∷ τ ∷ η ∷ ρ ∷ η ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.1" ∷ word (κ ∷ ∙λ ∷ η ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Jude.1.1" ∷ word (ἔ ∷ ∙λ ∷ ε ∷ ο ∷ ς ∷ []) "Jude.1.2" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Jude.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.2" ∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "Jude.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.2" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ []) "Jude.1.2" ∷ word (π ∷ ∙λ ∷ η ∷ θ ∷ υ ∷ ν ∷ θ ∷ ε ∷ ί ∷ η ∷ []) "Jude.1.2" ∷ word (Ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.3" ∷ word (π ∷ ᾶ ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.3" ∷ word (σ ∷ π ∷ ο ∷ υ ∷ δ ∷ ὴ ∷ ν ∷ []) "Jude.1.3" ∷ word (π ∷ ο ∷ ι ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Jude.1.3" ∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ε ∷ ι ∷ ν ∷ []) "Jude.1.3" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Jude.1.3" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Jude.1.3" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Jude.1.3" ∷ word (κ ∷ ο ∷ ι ∷ ν ∷ ῆ ∷ ς ∷ []) "Jude.1.3" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.3" ∷ word (σ ∷ ω ∷ τ ∷ η ∷ ρ ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.3" ∷ word (ἀ ∷ ν ∷ ά ∷ γ ∷ κ ∷ η ∷ ν ∷ []) "Jude.1.3" ∷ word (ἔ ∷ σ ∷ χ ∷ ο ∷ ν ∷ []) "Jude.1.3" ∷ word (γ ∷ ρ ∷ ά ∷ ψ ∷ α ∷ ι ∷ []) "Jude.1.3" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Jude.1.3" ∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ῶ ∷ ν ∷ []) "Jude.1.3" ∷ word (ἐ ∷ π ∷ α ∷ γ ∷ ω ∷ ν ∷ ί ∷ ζ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Jude.1.3" ∷ word (τ ∷ ῇ ∷ []) "Jude.1.3" ∷ word (ἅ ∷ π ∷ α ∷ ξ ∷ []) "Jude.1.3" ∷ word (π ∷ α ∷ ρ ∷ α ∷ δ ∷ ο ∷ θ ∷ ε ∷ ί ∷ σ ∷ ῃ ∷ []) "Jude.1.3" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Jude.1.3" ∷ word (ἁ ∷ γ ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.3" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "Jude.1.3" ∷ word (π ∷ α ∷ ρ ∷ ε ∷ ι ∷ σ ∷ έ ∷ δ ∷ υ ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.4" ∷ word (γ ∷ ά ∷ ρ ∷ []) "Jude.1.4" ∷ word (τ ∷ ι ∷ ν ∷ ε ∷ ς ∷ []) "Jude.1.4" ∷ word (ἄ ∷ ν ∷ θ ∷ ρ ∷ ω ∷ π ∷ ο ∷ ι ∷ []) "Jude.1.4" ∷ word (ο ∷ ἱ ∷ []) "Jude.1.4" ∷ word (π ∷ ά ∷ ∙λ ∷ α ∷ ι ∷ []) "Jude.1.4" ∷ word (π ∷ ρ ∷ ο ∷ γ ∷ ε ∷ γ ∷ ρ ∷ α ∷ μ ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.4" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.4" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Jude.1.4" ∷ word (τ ∷ ὸ ∷ []) "Jude.1.4" ∷ word (κ ∷ ρ ∷ ί ∷ μ ∷ α ∷ []) "Jude.1.4" ∷ word (ἀ ∷ σ ∷ ε ∷ β ∷ ε ∷ ῖ ∷ ς ∷ []) "Jude.1.4" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Jude.1.4" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.4" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Jude.1.4" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.4" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ τ ∷ α ∷ []) "Jude.1.4" ∷ word (μ ∷ ε ∷ τ ∷ α ∷ τ ∷ ι ∷ θ ∷ έ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.4" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.4" ∷ word (ἀ ∷ σ ∷ έ ∷ ∙λ ∷ γ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "Jude.1.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.4" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Jude.1.4" ∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "Jude.1.4" ∷ word (δ ∷ ε ∷ σ ∷ π ∷ ό ∷ τ ∷ η ∷ ν ∷ []) "Jude.1.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.4" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.4" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.4" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ν ∷ []) "Jude.1.4" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ν ∷ []) "Jude.1.4" ∷ word (ἀ ∷ ρ ∷ ν ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.4" ∷ word (Ὑ ∷ π ∷ ο ∷ μ ∷ ν ∷ ῆ ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.5" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.5" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Jude.1.5" ∷ word (β ∷ ο ∷ ύ ∷ ∙λ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Jude.1.5" ∷ word (ε ∷ ἰ ∷ δ ∷ ό ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.5" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Jude.1.5" ∷ word (ἅ ∷ π ∷ α ∷ ξ ∷ []) "Jude.1.5" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Jude.1.5" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Jude.1.5" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ς ∷ []) "Jude.1.5" ∷ word (∙λ ∷ α ∷ ὸ ∷ ν ∷ []) "Jude.1.5" ∷ word (ἐ ∷ κ ∷ []) "Jude.1.5" ∷ word (γ ∷ ῆ ∷ ς ∷ []) "Jude.1.5" ∷ word (Α ∷ ἰ ∷ γ ∷ ύ ∷ π ∷ τ ∷ ο ∷ υ ∷ []) "Jude.1.5" ∷ word (σ ∷ ώ ∷ σ ∷ α ∷ ς ∷ []) "Jude.1.5" ∷ word (τ ∷ ὸ ∷ []) "Jude.1.5" ∷ word (δ ∷ ε ∷ ύ ∷ τ ∷ ε ∷ ρ ∷ ο ∷ ν ∷ []) "Jude.1.5" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.5" ∷ word (μ ∷ ὴ ∷ []) "Jude.1.5" ∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ σ ∷ α ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.5" ∷ word (ἀ ∷ π ∷ ώ ∷ ∙λ ∷ ε ∷ σ ∷ ε ∷ ν ∷ []) "Jude.1.5" ∷ word (ἀ ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "Jude.1.6" ∷ word (τ ∷ ε ∷ []) "Jude.1.6" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.6" ∷ word (μ ∷ ὴ ∷ []) "Jude.1.6" ∷ word (τ ∷ η ∷ ρ ∷ ή ∷ σ ∷ α ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.6" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Jude.1.6" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.6" ∷ word (ἀ ∷ ρ ∷ χ ∷ ὴ ∷ ν ∷ []) "Jude.1.6" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Jude.1.6" ∷ word (ἀ ∷ π ∷ ο ∷ ∙λ ∷ ι ∷ π ∷ ό ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.6" ∷ word (τ ∷ ὸ ∷ []) "Jude.1.6" ∷ word (ἴ ∷ δ ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.6" ∷ word (ο ∷ ἰ ∷ κ ∷ η ∷ τ ∷ ή ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.6" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.6" ∷ word (κ ∷ ρ ∷ ί ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.6" ∷ word (μ ∷ ε ∷ γ ∷ ά ∷ ∙λ ∷ η ∷ ς ∷ []) "Jude.1.6" ∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "Jude.1.6" ∷ word (δ ∷ ε ∷ σ ∷ μ ∷ ο ∷ ῖ ∷ ς ∷ []) "Jude.1.6" ∷ word (ἀ ∷ ϊ ∷ δ ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.6" ∷ word (ὑ ∷ π ∷ ὸ ∷ []) "Jude.1.6" ∷ word (ζ ∷ ό ∷ φ ∷ ο ∷ ν ∷ []) "Jude.1.6" ∷ word (τ ∷ ε ∷ τ ∷ ή ∷ ρ ∷ η ∷ κ ∷ ε ∷ ν ∷ []) "Jude.1.6" ∷ word (ὡ ∷ ς ∷ []) "Jude.1.7" ∷ word (Σ ∷ ό ∷ δ ∷ ο ∷ μ ∷ α ∷ []) "Jude.1.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.7" ∷ word (Γ ∷ ό ∷ μ ∷ ο ∷ ρ ∷ ρ ∷ α ∷ []) "Jude.1.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.7" ∷ word (α ∷ ἱ ∷ []) "Jude.1.7" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Jude.1.7" ∷ word (α ∷ ὐ ∷ τ ∷ ὰ ∷ ς ∷ []) "Jude.1.7" ∷ word (π ∷ ό ∷ ∙λ ∷ ε ∷ ι ∷ ς ∷ []) "Jude.1.7" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Jude.1.7" ∷ word (ὅ ∷ μ ∷ ο ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.7" ∷ word (τ ∷ ρ ∷ ό ∷ π ∷ ο ∷ ν ∷ []) "Jude.1.7" ∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.7" ∷ word (ἐ ∷ κ ∷ π ∷ ο ∷ ρ ∷ ν ∷ ε ∷ ύ ∷ σ ∷ α ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.7" ∷ word (ἀ ∷ π ∷ ε ∷ ∙λ ∷ θ ∷ ο ∷ ῦ ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.7" ∷ word (ὀ ∷ π ∷ ί ∷ σ ∷ ω ∷ []) "Jude.1.7" ∷ word (σ ∷ α ∷ ρ ∷ κ ∷ ὸ ∷ ς ∷ []) "Jude.1.7" ∷ word (ἑ ∷ τ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "Jude.1.7" ∷ word (π ∷ ρ ∷ ό ∷ κ ∷ ε ∷ ι ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.7" ∷ word (δ ∷ ε ∷ ῖ ∷ γ ∷ μ ∷ α ∷ []) "Jude.1.7" ∷ word (π ∷ υ ∷ ρ ∷ ὸ ∷ ς ∷ []) "Jude.1.7" ∷ word (α ∷ ἰ ∷ ω ∷ ν ∷ ί ∷ ο ∷ υ ∷ []) "Jude.1.7" ∷ word (δ ∷ ί ∷ κ ∷ η ∷ ν ∷ []) "Jude.1.7" ∷ word (ὑ ∷ π ∷ έ ∷ χ ∷ ο ∷ υ ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.7" ∷ word (Ὁ ∷ μ ∷ ο ∷ ί ∷ ω ∷ ς ∷ []) "Jude.1.8" ∷ word (μ ∷ έ ∷ ν ∷ τ ∷ ο ∷ ι ∷ []) "Jude.1.8" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.8" ∷ word (ο ∷ ὗ ∷ τ ∷ ο ∷ ι ∷ []) "Jude.1.8" ∷ word (ἐ ∷ ν ∷ υ ∷ π ∷ ν ∷ ι ∷ α ∷ ζ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.8" ∷ word (σ ∷ ά ∷ ρ ∷ κ ∷ α ∷ []) "Jude.1.8" ∷ word (μ ∷ ὲ ∷ ν ∷ []) "Jude.1.8" ∷ word (μ ∷ ι ∷ α ∷ ί ∷ ν ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.8" ∷ word (κ ∷ υ ∷ ρ ∷ ι ∷ ό ∷ τ ∷ η ∷ τ ∷ α ∷ []) "Jude.1.8" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.8" ∷ word (ἀ ∷ θ ∷ ε ∷ τ ∷ ο ∷ ῦ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.8" ∷ word (δ ∷ ό ∷ ξ ∷ α ∷ ς ∷ []) "Jude.1.8" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.8" ∷ word (β ∷ ∙λ ∷ α ∷ σ ∷ φ ∷ η ∷ μ ∷ ο ∷ ῦ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.8" ∷ word (ὁ ∷ []) "Jude.1.9" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.9" ∷ word (Μ ∷ ι ∷ χ ∷ α ∷ ὴ ∷ ∙λ ∷ []) "Jude.1.9" ∷ word (ὁ ∷ []) "Jude.1.9" ∷ word (ἀ ∷ ρ ∷ χ ∷ ά ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ο ∷ ς ∷ []) "Jude.1.9" ∷ word (ὅ ∷ τ ∷ ε ∷ []) "Jude.1.9" ∷ word (τ ∷ ῷ ∷ []) "Jude.1.9" ∷ word (δ ∷ ι ∷ α ∷ β ∷ ό ∷ ∙λ ∷ ῳ ∷ []) "Jude.1.9" ∷ word (δ ∷ ι ∷ α ∷ κ ∷ ρ ∷ ι ∷ ν ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Jude.1.9" ∷ word (δ ∷ ι ∷ ε ∷ ∙λ ∷ έ ∷ γ ∷ ε ∷ τ ∷ ο ∷ []) "Jude.1.9" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Jude.1.9" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.9" ∷ word (Μ ∷ ω ∷ ϋ ∷ σ ∷ έ ∷ ω ∷ ς ∷ []) "Jude.1.9" ∷ word (σ ∷ ώ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "Jude.1.9" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "Jude.1.9" ∷ word (ἐ ∷ τ ∷ ό ∷ ∙λ ∷ μ ∷ η ∷ σ ∷ ε ∷ ν ∷ []) "Jude.1.9" ∷ word (κ ∷ ρ ∷ ί ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.9" ∷ word (ἐ ∷ π ∷ ε ∷ ν ∷ ε ∷ γ ∷ κ ∷ ε ∷ ῖ ∷ ν ∷ []) "Jude.1.9" ∷ word (β ∷ ∙λ ∷ α ∷ σ ∷ φ ∷ η ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.9" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Jude.1.9" ∷ word (ε ∷ ἶ ∷ π ∷ ε ∷ ν ∷ []) "Jude.1.9" ∷ word (Ἐ ∷ π ∷ ι ∷ τ ∷ ι ∷ μ ∷ ή ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.9" ∷ word (σ ∷ ο ∷ ι ∷ []) "Jude.1.9" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "Jude.1.9" ∷ word (ο ∷ ὗ ∷ τ ∷ ο ∷ ι ∷ []) "Jude.1.10" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.10" ∷ word (ὅ ∷ σ ∷ α ∷ []) "Jude.1.10" ∷ word (μ ∷ ὲ ∷ ν ∷ []) "Jude.1.10" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "Jude.1.10" ∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.10" ∷ word (β ∷ ∙λ ∷ α ∷ σ ∷ φ ∷ η ∷ μ ∷ ο ∷ ῦ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.10" ∷ word (ὅ ∷ σ ∷ α ∷ []) "Jude.1.10" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.10" ∷ word (φ ∷ υ ∷ σ ∷ ι ∷ κ ∷ ῶ ∷ ς ∷ []) "Jude.1.10" ∷ word (ὡ ∷ ς ∷ []) "Jude.1.10" ∷ word (τ ∷ ὰ ∷ []) "Jude.1.10" ∷ word (ἄ ∷ ∙λ ∷ ο ∷ γ ∷ α ∷ []) "Jude.1.10" ∷ word (ζ ∷ ῷ ∷ α ∷ []) "Jude.1.10" ∷ word (ἐ ∷ π ∷ ί ∷ σ ∷ τ ∷ α ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.10" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.10" ∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.10" ∷ word (φ ∷ θ ∷ ε ∷ ί ∷ ρ ∷ ο ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.10" ∷ word (ο ∷ ὐ ∷ α ∷ ὶ ∷ []) "Jude.1.11" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Jude.1.11" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Jude.1.11" ∷ word (τ ∷ ῇ ∷ []) "Jude.1.11" ∷ word (ὁ ∷ δ ∷ ῷ ∷ []) "Jude.1.11" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.11" ∷ word (Κ ∷ ά ∷ ϊ ∷ ν ∷ []) "Jude.1.11" ∷ word (ἐ ∷ π ∷ ο ∷ ρ ∷ ε ∷ ύ ∷ θ ∷ η ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.11" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.11" ∷ word (τ ∷ ῇ ∷ []) "Jude.1.11" ∷ word (π ∷ ∙λ ∷ ά ∷ ν ∷ ῃ ∷ []) "Jude.1.11" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.11" ∷ word (Β ∷ α ∷ ∙λ ∷ α ∷ ὰ ∷ μ ∷ []) "Jude.1.11" ∷ word (μ ∷ ι ∷ σ ∷ θ ∷ ο ∷ ῦ ∷ []) "Jude.1.11" ∷ word (ἐ ∷ ξ ∷ ε ∷ χ ∷ ύ ∷ θ ∷ η ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.11" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.11" ∷ word (τ ∷ ῇ ∷ []) "Jude.1.11" ∷ word (ἀ ∷ ν ∷ τ ∷ ι ∷ ∙λ ∷ ο ∷ γ ∷ ί ∷ ᾳ ∷ []) "Jude.1.11" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.11" ∷ word (Κ ∷ ό ∷ ρ ∷ ε ∷ []) "Jude.1.11" ∷ word (ἀ ∷ π ∷ ώ ∷ ∙λ ∷ ο ∷ ν ∷ τ ∷ ο ∷ []) "Jude.1.11" ∷ word (ο ∷ ὗ ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.12" ∷ word (ε ∷ ἰ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.12" ∷ word (ο ∷ ἱ ∷ []) "Jude.1.12" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.12" ∷ word (τ ∷ α ∷ ῖ ∷ ς ∷ []) "Jude.1.12" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ α ∷ ι ∷ ς ∷ []) "Jude.1.12" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.12" ∷ word (σ ∷ π ∷ ι ∷ ∙λ ∷ ά ∷ δ ∷ ε ∷ ς ∷ []) "Jude.1.12" ∷ word (σ ∷ υ ∷ ν ∷ ε ∷ υ ∷ ω ∷ χ ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.12" ∷ word (ἀ ∷ φ ∷ ό ∷ β ∷ ω ∷ ς ∷ []) "Jude.1.12" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.12" ∷ word (π ∷ ο ∷ ι ∷ μ ∷ α ∷ ί ∷ ν ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.12" ∷ word (ν ∷ ε ∷ φ ∷ έ ∷ ∙λ ∷ α ∷ ι ∷ []) "Jude.1.12" ∷ word (ἄ ∷ ν ∷ υ ∷ δ ∷ ρ ∷ ο ∷ ι ∷ []) "Jude.1.12" ∷ word (ὑ ∷ π ∷ ὸ ∷ []) "Jude.1.12" ∷ word (ἀ ∷ ν ∷ έ ∷ μ ∷ ω ∷ ν ∷ []) "Jude.1.12" ∷ word (π ∷ α ∷ ρ ∷ α ∷ φ ∷ ε ∷ ρ ∷ ό ∷ μ ∷ ε ∷ ν ∷ α ∷ ι ∷ []) "Jude.1.12" ∷ word (δ ∷ έ ∷ ν ∷ δ ∷ ρ ∷ α ∷ []) "Jude.1.12" ∷ word (φ ∷ θ ∷ ι ∷ ν ∷ ο ∷ π ∷ ω ∷ ρ ∷ ι ∷ ν ∷ ὰ ∷ []) "Jude.1.12" ∷ word (ἄ ∷ κ ∷ α ∷ ρ ∷ π ∷ α ∷ []) "Jude.1.12" ∷ word (δ ∷ ὶ ∷ ς ∷ []) "Jude.1.12" ∷ word (ἀ ∷ π ∷ ο ∷ θ ∷ α ∷ ν ∷ ό ∷ ν ∷ τ ∷ α ∷ []) "Jude.1.12" ∷ word (ἐ ∷ κ ∷ ρ ∷ ι ∷ ζ ∷ ω ∷ θ ∷ έ ∷ ν ∷ τ ∷ α ∷ []) "Jude.1.12" ∷ word (κ ∷ ύ ∷ μ ∷ α ∷ τ ∷ α ∷ []) "Jude.1.13" ∷ word (ἄ ∷ γ ∷ ρ ∷ ι ∷ α ∷ []) "Jude.1.13" ∷ word (θ ∷ α ∷ ∙λ ∷ ά ∷ σ ∷ σ ∷ η ∷ ς ∷ []) "Jude.1.13" ∷ word (ἐ ∷ π ∷ α ∷ φ ∷ ρ ∷ ί ∷ ζ ∷ ο ∷ ν ∷ τ ∷ α ∷ []) "Jude.1.13" ∷ word (τ ∷ ὰ ∷ ς ∷ []) "Jude.1.13" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.13" ∷ word (α ∷ ἰ ∷ σ ∷ χ ∷ ύ ∷ ν ∷ α ∷ ς ∷ []) "Jude.1.13" ∷ word (ἀ ∷ σ ∷ τ ∷ έ ∷ ρ ∷ ε ∷ ς ∷ []) "Jude.1.13" ∷ word (π ∷ ∙λ ∷ α ∷ ν ∷ ῆ ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.13" ∷ word (ο ∷ ἷ ∷ ς ∷ []) "Jude.1.13" ∷ word (ὁ ∷ []) "Jude.1.13" ∷ word (ζ ∷ ό ∷ φ ∷ ο ∷ ς ∷ []) "Jude.1.13" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.13" ∷ word (σ ∷ κ ∷ ό ∷ τ ∷ ο ∷ υ ∷ ς ∷ []) "Jude.1.13" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.13" ∷ word (α ∷ ἰ ∷ ῶ ∷ ν ∷ α ∷ []) "Jude.1.13" ∷ word (τ ∷ ε ∷ τ ∷ ή ∷ ρ ∷ η ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.13" ∷ word (Π ∷ ρ ∷ ο ∷ ε ∷ φ ∷ ή ∷ τ ∷ ε ∷ υ ∷ σ ∷ ε ∷ ν ∷ []) "Jude.1.14" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.14" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.14" ∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.14" ∷ word (ἕ ∷ β ∷ δ ∷ ο ∷ μ ∷ ο ∷ ς ∷ []) "Jude.1.14" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "Jude.1.14" ∷ word (Ἀ ∷ δ ∷ ὰ ∷ μ ∷ []) "Jude.1.14" ∷ word (Ἑ ∷ ν ∷ ὼ ∷ χ ∷ []) "Jude.1.14" ∷ word (∙λ ∷ έ ∷ γ ∷ ω ∷ ν ∷ []) "Jude.1.14" ∷ word (Ἰ ∷ δ ∷ ο ∷ ὺ ∷ []) "Jude.1.14" ∷ word (ἦ ∷ ∙λ ∷ θ ∷ ε ∷ ν ∷ []) "Jude.1.14" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "Jude.1.14" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.14" ∷ word (ἁ ∷ γ ∷ ί ∷ α ∷ ι ∷ ς ∷ []) "Jude.1.14" ∷ word (μ ∷ υ ∷ ρ ∷ ι ∷ ά ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.14" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.14" ∷ word (π ∷ ο ∷ ι ∷ ῆ ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.15" ∷ word (κ ∷ ρ ∷ ί ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.15" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Jude.1.15" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "Jude.1.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.15" ∷ word (ἐ ∷ ∙λ ∷ έ ∷ γ ∷ ξ ∷ α ∷ ι ∷ []) "Jude.1.15" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.15" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.15" ∷ word (ἀ ∷ σ ∷ ε ∷ β ∷ ε ∷ ῖ ∷ ς ∷ []) "Jude.1.15" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Jude.1.15" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "Jude.1.15" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.15" ∷ word (ἔ ∷ ρ ∷ γ ∷ ω ∷ ν ∷ []) "Jude.1.15" ∷ word (ἀ ∷ σ ∷ ε ∷ β ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.15" ∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.15" ∷ word (ὧ ∷ ν ∷ []) "Jude.1.15" ∷ word (ἠ ∷ σ ∷ έ ∷ β ∷ η ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.15" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Jude.1.15" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "Jude.1.15" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.15" ∷ word (σ ∷ κ ∷ ∙λ ∷ η ∷ ρ ∷ ῶ ∷ ν ∷ []) "Jude.1.15" ∷ word (ὧ ∷ ν ∷ []) "Jude.1.15" ∷ word (ἐ ∷ ∙λ ∷ ά ∷ ∙λ ∷ η ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.15" ∷ word (κ ∷ α ∷ τ ∷ []) "Jude.1.15" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.15" ∷ word (ἁ ∷ μ ∷ α ∷ ρ ∷ τ ∷ ω ∷ ∙λ ∷ ο ∷ ὶ ∷ []) "Jude.1.15" ∷ word (ἀ ∷ σ ∷ ε ∷ β ∷ ε ∷ ῖ ∷ ς ∷ []) "Jude.1.15" ∷ word (ο ∷ ὗ ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.16" ∷ word (ε ∷ ἰ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.16" ∷ word (γ ∷ ο ∷ γ ∷ γ ∷ υ ∷ σ ∷ τ ∷ α ∷ ί ∷ []) "Jude.1.16" ∷ word (μ ∷ ε ∷ μ ∷ ψ ∷ ί ∷ μ ∷ ο ∷ ι ∷ ρ ∷ ο ∷ ι ∷ []) "Jude.1.16" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Jude.1.16" ∷ word (τ ∷ ὰ ∷ ς ∷ []) "Jude.1.16" ∷ word (ἐ ∷ π ∷ ι ∷ θ ∷ υ ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.16" ∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.16" ∷ word (π ∷ ο ∷ ρ ∷ ε ∷ υ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.16" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.16" ∷ word (τ ∷ ὸ ∷ []) "Jude.1.16" ∷ word (σ ∷ τ ∷ ό ∷ μ ∷ α ∷ []) "Jude.1.16" ∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.16" ∷ word (∙λ ∷ α ∷ ∙λ ∷ ε ∷ ῖ ∷ []) "Jude.1.16" ∷ word (ὑ ∷ π ∷ έ ∷ ρ ∷ ο ∷ γ ∷ κ ∷ α ∷ []) "Jude.1.16" ∷ word (θ ∷ α ∷ υ ∷ μ ∷ ά ∷ ζ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.16" ∷ word (π ∷ ρ ∷ ό ∷ σ ∷ ω ∷ π ∷ α ∷ []) "Jude.1.16" ∷ word (ὠ ∷ φ ∷ ε ∷ ∙λ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.16" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ν ∷ []) "Jude.1.16" ∷ word (Ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "Jude.1.17" ∷ word (δ ∷ έ ∷ []) "Jude.1.17" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.17" ∷ word (μ ∷ ν ∷ ή ∷ σ ∷ θ ∷ η ∷ τ ∷ ε ∷ []) "Jude.1.17" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.17" ∷ word (ῥ ∷ η ∷ μ ∷ ά ∷ τ ∷ ω ∷ ν ∷ []) "Jude.1.17" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.17" ∷ word (π ∷ ρ ∷ ο ∷ ε ∷ ι ∷ ρ ∷ η ∷ μ ∷ έ ∷ ν ∷ ω ∷ ν ∷ []) "Jude.1.17" ∷ word (ὑ ∷ π ∷ ὸ ∷ []) "Jude.1.17" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.17" ∷ word (ἀ ∷ π ∷ ο ∷ σ ∷ τ ∷ ό ∷ ∙λ ∷ ω ∷ ν ∷ []) "Jude.1.17" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.17" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "Jude.1.17" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.17" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Jude.1.17" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.17" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Jude.1.18" ∷ word (ἔ ∷ ∙λ ∷ ε ∷ γ ∷ ο ∷ ν ∷ []) "Jude.1.18" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Jude.1.18" ∷ word (Ἐ ∷ π ∷ []) "Jude.1.18" ∷ word (ἐ ∷ σ ∷ χ ∷ ά ∷ τ ∷ ο ∷ υ ∷ []) "Jude.1.18" ∷ word (χ ∷ ρ ∷ ό ∷ ν ∷ ο ∷ υ ∷ []) "Jude.1.18" ∷ word (ἔ ∷ σ ∷ ο ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.18" ∷ word (ἐ ∷ μ ∷ π ∷ α ∷ ῖ ∷ κ ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.18" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Jude.1.18" ∷ word (τ ∷ ὰ ∷ ς ∷ []) "Jude.1.18" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.18" ∷ word (ἐ ∷ π ∷ ι ∷ θ ∷ υ ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.18" ∷ word (π ∷ ο ∷ ρ ∷ ε ∷ υ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.18" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.18" ∷ word (ἀ ∷ σ ∷ ε ∷ β ∷ ε ∷ ι ∷ ῶ ∷ ν ∷ []) "Jude.1.18" ∷ word (ο ∷ ὗ ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.19" ∷ word (ε ∷ ἰ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.19" ∷ word (ο ∷ ἱ ∷ []) "Jude.1.19" ∷ word (ἀ ∷ π ∷ ο ∷ δ ∷ ι ∷ ο ∷ ρ ∷ ί ∷ ζ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.19" ∷ word (ψ ∷ υ ∷ χ ∷ ι ∷ κ ∷ ο ∷ ί ∷ []) "Jude.1.19" ∷ word (π ∷ ν ∷ ε ∷ ῦ ∷ μ ∷ α ∷ []) "Jude.1.19" ∷ word (μ ∷ ὴ ∷ []) "Jude.1.19" ∷ word (ἔ ∷ χ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.19" ∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "Jude.1.20" ∷ word (δ ∷ έ ∷ []) "Jude.1.20" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.20" ∷ word (ἐ ∷ π ∷ ο ∷ ι ∷ κ ∷ ο ∷ δ ∷ ο ∷ μ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.20" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.20" ∷ word (τ ∷ ῇ ∷ []) "Jude.1.20" ∷ word (ἁ ∷ γ ∷ ι ∷ ω ∷ τ ∷ ά ∷ τ ∷ ῃ ∷ []) "Jude.1.20" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.20" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "Jude.1.20" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.20" ∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "Jude.1.20" ∷ word (ἁ ∷ γ ∷ ί ∷ ῳ ∷ []) "Jude.1.20" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ υ ∷ χ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.20" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.21" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.21" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ ῃ ∷ []) "Jude.1.21" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Jude.1.21" ∷ word (τ ∷ η ∷ ρ ∷ ή ∷ σ ∷ α ∷ τ ∷ ε ∷ []) "Jude.1.21" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ δ ∷ ε ∷ χ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.21" ∷ word (τ ∷ ὸ ∷ []) "Jude.1.21" ∷ word (ἔ ∷ ∙λ ∷ ε ∷ ο ∷ ς ∷ []) "Jude.1.21" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.21" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "Jude.1.21" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.21" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Jude.1.21" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.21" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.21" ∷ word (ζ ∷ ω ∷ ὴ ∷ ν ∷ []) "Jude.1.21" ∷ word (α ∷ ἰ ∷ ώ ∷ ν ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.21" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.22" ∷ word (ο ∷ ὓ ∷ ς ∷ []) "Jude.1.22" ∷ word (μ ∷ ὲ ∷ ν ∷ []) "Jude.1.22" ∷ word (ἐ ∷ ∙λ ∷ ε ∷ ᾶ ∷ τ ∷ ε ∷ []) "Jude.1.22" ∷ word (δ ∷ ι ∷ α ∷ κ ∷ ρ ∷ ι ∷ ν ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "Jude.1.22" ∷ word (ο ∷ ὓ ∷ ς ∷ []) "Jude.1.23" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.23" ∷ word (σ ∷ ῴ ∷ ζ ∷ ε ∷ τ ∷ ε ∷ []) "Jude.1.23" ∷ word (ἐ ∷ κ ∷ []) "Jude.1.23" ∷ word (π ∷ υ ∷ ρ ∷ ὸ ∷ ς ∷ []) "Jude.1.23" ∷ word (ἁ ∷ ρ ∷ π ∷ ά ∷ ζ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.23" ∷ word (ο ∷ ὓ ∷ ς ∷ []) "Jude.1.23" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.23" ∷ word (ἐ ∷ ∙λ ∷ ε ∷ ᾶ ∷ τ ∷ ε ∷ []) "Jude.1.23" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.23" ∷ word (φ ∷ ό ∷ β ∷ ῳ ∷ []) "Jude.1.23" ∷ word (μ ∷ ι ∷ σ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.23" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.23" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Jude.1.23" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "Jude.1.23" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Jude.1.23" ∷ word (σ ∷ α ∷ ρ ∷ κ ∷ ὸ ∷ ς ∷ []) "Jude.1.23" ∷ word (ἐ ∷ σ ∷ π ∷ ι ∷ ∙λ ∷ ω ∷ μ ∷ έ ∷ ν ∷ ο ∷ ν ∷ []) "Jude.1.23" ∷ word (χ ∷ ι ∷ τ ∷ ῶ ∷ ν ∷ α ∷ []) "Jude.1.23" ∷ word (Τ ∷ ῷ ∷ []) "Jude.1.24" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.24" ∷ word (δ ∷ υ ∷ ν ∷ α ∷ μ ∷ έ ∷ ν ∷ ῳ ∷ []) "Jude.1.24" ∷ word (φ ∷ υ ∷ ∙λ ∷ ά ∷ ξ ∷ α ∷ ι ∷ []) "Jude.1.24" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Jude.1.24" ∷ word (ἀ ∷ π ∷ τ ∷ α ∷ ί ∷ σ ∷ τ ∷ ο ∷ υ ∷ ς ∷ []) "Jude.1.24" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.24" ∷ word (σ ∷ τ ∷ ῆ ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.24" ∷ word (κ ∷ α ∷ τ ∷ ε ∷ ν ∷ ώ ∷ π ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.24" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Jude.1.24" ∷ word (δ ∷ ό ∷ ξ ∷ η ∷ ς ∷ []) "Jude.1.24" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.24" ∷ word (ἀ ∷ μ ∷ ώ ∷ μ ∷ ο ∷ υ ∷ ς ∷ []) "Jude.1.24" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.24" ∷ word (ἀ ∷ γ ∷ α ∷ ∙λ ∷ ∙λ ∷ ι ∷ ά ∷ σ ∷ ε ∷ ι ∷ []) "Jude.1.24" ∷ word (μ ∷ ό ∷ ν ∷ ῳ ∷ []) "Jude.1.25" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "Jude.1.25" ∷ word (σ ∷ ω ∷ τ ∷ ῆ ∷ ρ ∷ ι ∷ []) "Jude.1.25" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.25" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Jude.1.25" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Jude.1.25" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.25" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.25" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "Jude.1.25" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.25" ∷ word (δ ∷ ό ∷ ξ ∷ α ∷ []) "Jude.1.25" ∷ word (μ ∷ ε ∷ γ ∷ α ∷ ∙λ ∷ ω ∷ σ ∷ ύ ∷ ν ∷ η ∷ []) "Jude.1.25" ∷ word (κ ∷ ρ ∷ ά ∷ τ ∷ ο ∷ ς ∷ []) "Jude.1.25" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.25" ∷ word (ἐ ∷ ξ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ []) "Jude.1.25" ∷ word (π ∷ ρ ∷ ὸ ∷ []) "Jude.1.25" ∷ word (π ∷ α ∷ ν ∷ τ ∷ ὸ ∷ ς ∷ []) "Jude.1.25" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.25" ∷ word (α ∷ ἰ ∷ ῶ ∷ ν ∷ ο ∷ ς ∷ []) "Jude.1.25" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.25" ∷ word (ν ∷ ῦ ∷ ν ∷ []) "Jude.1.25" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.25" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.25" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.25" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.25" ∷ word (α ∷ ἰ ∷ ῶ ∷ ν ∷ α ∷ ς ∷ []) "Jude.1.25" ∷ word (ἀ ∷ μ ∷ ή ∷ ν ∷ []) "Jude.1.25" ∷ []
47.455319
85
0.340253
38fb6dd3934f39c9129f29a8cbea7b2b55abbdf7
6,608
agda
Agda
src/Categories/Category/Cocartesian.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
1
2021-04-18T18:21:47.000Z
2021-04-18T18:21:47.000Z
src/Categories/Category/Cocartesian.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
null
null
null
src/Categories/Category/Cocartesian.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} open import Categories.Category -- BinaryCoproducts -- a category with all binary coproducts -- Cocartesian -- a category with all coproducts -- since most of the work is dual to Categories.Category.Cartesian, so the idea -- in this module is to make use of duality module Categories.Category.Cocartesian {o ℓ e} (𝒞 : Category o ℓ e) where open import Level private module 𝒞 = Category 𝒞 open Category 𝒞 open HomReasoning variable A B C D : Obj f g h i : A ⇒ B open import Categories.Object.Initial 𝒞 open import Categories.Object.Coproduct 𝒞 open import Categories.Object.Duality 𝒞 open import Categories.Category.Monoidal open import Categories.Category.Monoidal.Symmetric open import Categories.Category.Cartesian 𝒞.op open import Categories.Morphism 𝒞 open import Categories.Morphism.Properties 𝒞 open import Categories.Morphism.Duality 𝒞 open import Categories.Morphism.Reasoning 𝒞 open import Categories.Functor renaming (id to idF) open import Categories.Functor.Properties open import Categories.Functor.Bifunctor record BinaryCoproducts : Set (levelOfTerm 𝒞) where infixr 6 _+_ infixr 7 _+₁_ field coproduct : ∀ {A B} → Coproduct A B module coproduct {A} {B} = Coproduct (coproduct {A} {B}) _+_ : Obj → Obj → Obj A + B = coproduct.A+B {A} {B} open coproduct using (i₁; i₂; [_,_]; inject₁; inject₂; []-cong₂; ∘-distribˡ-[]) renaming (unique to +-unique; η to +-η; g-η to +-g-η) public module Dual where op-binaryProducts : BinaryProducts op-binaryProducts = record { product = Coproduct⇒coProduct coproduct } module op-binaryProducts = BinaryProducts op-binaryProducts open Dual +-comm : A + B ≅ B + A +-comm = op-≅⇒≅ (op-binaryProducts.×-comm) +-assoc : A + B + C ≅ (A + B) + C +-assoc = op-≅⇒≅ (op-binaryProducts.×-assoc) _+₁_ : A ⇒ B → C ⇒ D → A + C ⇒ B + D _+₁_ = op-binaryProducts._⁂_ open op-binaryProducts using () renaming ( ⟨⟩-congʳ to []-congʳ ; ⟨⟩-congˡ to []-congˡ ; assocˡ to +-assocʳ ; assocʳ to +-assocˡ ; swap to +-swap ; first to +-first ; second to +-second ; π₁∘⁂ to +₁∘i₁ ; π₂∘⁂ to +₁∘i₂ ; ⁂-cong₂ to +₁-cong₂ ; ⁂∘⟨⟩ to []∘+₁ ; ⁂∘⁂ to +₁∘+₁ ; ⟨⟩∘ to ∘[] ; first↔second to +-second↔first ; swap∘⁂ to +₁∘+-swap ; swap∘swap to +-swap∘swap ) public -- since op-×- has type Bifunctor 𝒞.op 𝒞.op 𝒞.op, -- need to rewrap in order to type check -+- : Bifunctor 𝒞 𝒞 𝒞 -+- = record { F₀ = op-×-.F₀ ; F₁ = op-×-.F₁ ; identity = op-×-.identity ; homomorphism = op-×-.homomorphism ; F-resp-≈ = op-×-.F-resp-≈ } where op-×- = op-binaryProducts.-×- module op-×- = Functor op-×- -+_ : Obj → Functor 𝒞 𝒞 -+_ = appʳ -+- _+- : Obj → Functor 𝒞 𝒞 _+- = appˡ -+- record Cocartesian : Set (levelOfTerm 𝒞) where field initial : Initial coproducts : BinaryCoproducts module initial = Initial initial module coproducts = BinaryCoproducts coproducts open initial renaming (! to ¡; !-unique to ¡-unique; !-unique₂ to ¡-unique₂) public open coproducts hiding (module Dual) public module Dual where open coproducts.Dual public op-cartesian : Cartesian op-cartesian = record { terminal = ⊥⇒op⊤ initial ; products = op-binaryProducts } module op-cartesian = Cartesian op-cartesian -- The op-cartesian structure induces a monoidal one. module CocartesianMonoidal (cocartesian : Cocartesian) where open Cocartesian cocartesian private module op-cartesianMonoidal = CartesianMonoidal Dual.op-cartesian ⊥+A≅A : ⊥ + A ≅ A ⊥+A≅A = op-≅⇒≅ (op-cartesianMonoidal.⊤×A≅A) A+⊥≅A : A + ⊥ ≅ A A+⊥≅A = op-≅⇒≅ (op-cartesianMonoidal.A×⊤≅A) open op-cartesianMonoidal using () -- both are natural isomorphism renaming (⊤×--id to ⊥+--id; -×⊤-id to -+⊥-id) public +-monoidal : Monoidal 𝒞 +-monoidal = record { ⊗ = -+- ; unit = unit ; unitorˡ = ⊥+A≅A ; unitorʳ = A+⊥≅A ; associator = ≅.sym +-assoc ; unitorˡ-commute-from = ⟺ unitorˡ-commute-to ; unitorˡ-commute-to = ⟺ unitorˡ-commute-from ; unitorʳ-commute-from = ⟺ unitorʳ-commute-to ; unitorʳ-commute-to = ⟺ unitorʳ-commute-from ; assoc-commute-from = ⟺ assoc-commute-to ; assoc-commute-to = ⟺ assoc-commute-from -- the proof idea of triangle is that the opposite triangle is obtained for free, -- but notice that triangle and the opposite triangle form isomorphism. ; triangle = λ {X Y} → Iso-≈ triangle (Iso-∘ ([ X +- ]-resp-Iso (Iso-swap (iso ⊥+A≅A))) (iso +-assoc)) ([ -+ Y ]-resp-Iso (Iso-swap (iso A+⊥≅A))) ; pentagon = λ {X Y Z W} → Iso-≈ pentagon (Iso-∘ ([ X +- ]-resp-Iso (iso +-assoc)) (Iso-∘ (iso +-assoc) ([ -+ W ]-resp-Iso (iso +-assoc)))) (Iso-∘ (iso +-assoc) (iso +-assoc)) } where open op-cartesianMonoidal open _≅_ open Monoidal +-monoidal public module CocartesianSymmetricMonoidal (cocartesian : Cocartesian) where open Cocartesian cocartesian open CocartesianMonoidal cocartesian private module op-cartesianSymmetricMonoidal = CartesianSymmetricMonoidal Dual.op-cartesian +-symmetric : Symmetric +-monoidal +-symmetric = record { braided = record { braiding = record { F⇒G = record { η = λ _ → +-swap ; commute = λ _ → ⟺ +₁∘+-swap ; sym-commute = λ _ → +₁∘+-swap } ; F⇐G = record { η = λ _ → +-swap ; commute = λ _ → ⟺ +₁∘+-swap ; sym-commute = λ _ → +₁∘+-swap } ; iso = λ _ → iso +-comm } ; hexagon₁ = braided.hexagon₂ ; hexagon₂ = braided.hexagon₁ } ; commutative = commutative } where open op-cartesianSymmetricMonoidal open _≅_ open Symmetric +-symmetric public
30.173516
86
0.551604
5ed910c456e0eeb1140f0c13750b3ea31d5143b0
59,404
agda
Agda
Definition/LogicalRelation/Substitution/Introductions/Pi.agda
CoqHott/logrel-mltt
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
[ "MIT" ]
2
2018-06-21T08:39:01.000Z
2022-01-17T16:13:53.000Z
Definition/LogicalRelation/Substitution/Introductions/Pi.agda
CoqHott/logrel-mltt
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
[ "MIT" ]
null
null
null
Definition/LogicalRelation/Substitution/Introductions/Pi.agda
CoqHott/logrel-mltt
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
[ "MIT" ]
2
2022-01-26T14:55:51.000Z
2022-02-15T19:42:19.000Z
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Pi {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped as U hiding (wk) open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Weakening using (_∷_⊆_ ; _•ₜ_) open import Definition.Typed.Properties open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Weakening open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Weakening open import Definition.LogicalRelation.Substitution.Properties open import Definition.LogicalRelation.Substitution.MaybeEmbed import Definition.LogicalRelation.Substitution.Irrelevance as S open import Definition.LogicalRelation.Substitution.Introductions.Universe open import Tools.Nat open import Tools.Product import Tools.PropositionalEquality as PE open import Tools.Empty using (⊥; ⊥-elim) GappGen : ∀ {F G Γ rF lF lG rΠ l Δ σ ρ Δ₁} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ]) → Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ G ^ [ rΠ , ι lG ] / [Γ] ∙ [F] → ∀ ⊢Δ [σ] a ([ρ] : ρ ∷ Δ₁ ⊆ Δ) (⊢Δ₁ : ⊢ Δ₁) ([a] : Δ₁ ⊩⟨ l ⟩ a ∷ subst (ρ •ₛ σ) F ^ [ rF , ι lF ] / proj₁ ([F] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]))) → Σ (Δ₁ ⊩⟨ l ⟩ subst (consSubst (ρ •ₛ σ) a) G ^ [ rΠ , ι lG ]) (λ [Aσ] → {σ′ : Nat → Term} → (Σ (Δ₁ ⊩ˢ tail σ′ ∷ Γ / [Γ] / ⊢Δ₁) (λ [tailσ] → Δ₁ ⊩⟨ l ⟩ head σ′ ∷ subst (tail σ′) F ^ [ rF , ι lF ] / proj₁ ([F] ⊢Δ₁ [tailσ]))) → Δ₁ ⊩ˢ consSubst (ρ •ₛ σ) a ≡ σ′ ∷ Γ ∙ F ^ [ rF , ι lF ] / [Γ] ∙ [F] / ⊢Δ₁ / consSubstS {t = a} {A = F} [Γ] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]) [F] [a] → Δ₁ ⊩⟨ l ⟩ subst (consSubst (ρ •ₛ σ) a) G ≡ subst σ′ G ^ [ rΠ , ι lG ] / [Aσ]) GappGen {F} {G} {Γ} {rF} {lF} {lG} {rΠ} {l} {Δ} {σ} {ρ} {Δ₁} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a] = [G] {σ = consSubst (ρ •ₛ σ) a} ⊢Δ₁ (consSubstS {t = a} {A = F} [Γ] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]) [F] [a]) Gapp : ∀ {F G Γ rF lF lG rΠ l Δ σ ρ Δ₁} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ]) → Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ G ^ [ rΠ , ι lG ] / [Γ] ∙ [F] → ∀ ⊢Δ [σ] a ([ρ] : ρ ∷ Δ₁ ⊆ Δ) (⊢Δ₁ : ⊢ Δ₁) ([a] : Δ₁ ⊩⟨ l ⟩ a ∷ subst (ρ •ₛ σ) F ^ [ rF , ι lF ] / proj₁ ([F] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]))) → Δ₁ ⊩⟨ l ⟩ U.wk (lift ρ) (subst (liftSubst σ) G) [ a ] ^ [ rΠ , ι lG ] Gapp {F} {G} {Γ} {rF} {lF} {lG} {rΠ} {l} {Δ} {σ} {ρ} {Δ₁} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a] = irrelevance′ (PE.sym (singleSubstWkComp a σ G)) (proj₁ (GappGen {F} {G} {Γ} {rF} {lF} {lG} {rΠ} {l} {Δ} {σ} {ρ} {Δ₁} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a])) -- Validity of Π. Πᵛ : ∀ {F G Γ rF lF lG rΠ lΠ l} (lF≤ : lF ≤ lΠ) (lG≤ : lG ≤ lΠ) ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ]) → Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ G ^ [ rΠ , ι lG ] / [Γ] ∙ [F] → Γ ⊩ᵛ⟨ l ⟩ Π F ^ rF ° lF ▹ G ° lG ° lΠ ^ [ rΠ , ι lΠ ] / [Γ] Πᵛ {F} {G} {Γ} {rF} {lF} {lG} {rΠ} {lΠ} {l} lF≤ lG≤ [Γ] [F] [G] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let [F]σ {σ′} [σ′] = [F] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([F]σ [σ]) ⊢F {σ′} [σ′] = escape (proj₁ ([F]σ {σ′} [σ′])) ⊢F≡F = escapeEq [σF] (reflEq [σF]) [G]σ {σ′} [σ′] = [G] {σ = liftSubst σ′} (⊢Δ ∙ ⊢F [σ′]) (liftSubstS {F = F} [Γ] ⊢Δ [F] [σ′]) ⊢G {σ′} [σ′] = escape (proj₁ ([G]σ {σ′} [σ′])) ⊢G≡G = escapeEq (proj₁ ([G]σ [σ])) (reflEq (proj₁ ([G]σ [σ]))) ⊢ΠF▹G = Πⱼ lF≤ ▹ lG≤ ▹ un-univ (⊢F [σ]) ▹ un-univ (⊢G [σ]) in Πᵣ′ rF lF lG lF≤ lG≤ (subst σ F) (subst (liftSubst σ) G) (idRed:*: (univ ⊢ΠF▹G)) (⊢F [σ]) (⊢G [σ]) (≅-univ (≅ₜ-Π-cong lF≤ lG≤ (⊢F [σ]) (≅-un-univ ⊢F≡F) (≅-un-univ ⊢G≡G))) (λ ρ ⊢Δ₁ → wk ρ ⊢Δ₁ [σF]) (λ {ρ} {Δ₁} {a} [ρ] ⊢Δ₁ [a] → let [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ] ⊢Δ₁ [σF]) (proj₁ ([F] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]))) [a] in Gapp {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′) (λ {ρ} {Δ₁} {a} {b} [ρ] ⊢Δ₁ [a] [b] [a≡b] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ] ⊢Δ₁ [σF]) (proj₁ ([F] ⊢Δ₁ [ρσ])) [a] [b]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ] ⊢Δ₁ [σF]) (proj₁ ([F] ⊢Δ₁ [ρσ])) [b] [a≡b]′ = irrelevanceEqTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ] ⊢Δ₁ [σF]) (proj₁ ([F] ⊢Δ₁ [ρσ])) [a≡b] in irrelevanceEq″ (PE.sym (singleSubstWkComp a σ G)) (PE.sym (singleSubstWkComp b σ G)) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′)) (Gapp {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′) (proj₂ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′) ([ρσ] , [b]′) (reflSubst [Γ] ⊢Δ₁ [ρσ] , [a≡b]′))) , (λ {σ′} [σ′] [σ≡σ′] → let var0 = var (⊢Δ ∙ ⊢F [σ]) (PE.subst (λ x → 0 ∷ x ^ [ rF , ι lF ] ∈ (Δ ∙ subst σ F ^ [ rF , ι lF ])) (wk-subst F) here) [wk1σ] = wk1SubstS [Γ] ⊢Δ (⊢F [σ]) [σ] [wk1σ′] = wk1SubstS [Γ] ⊢Δ (⊢F [σ]) [σ′] [wk1σ≡wk1σ′] = wk1SubstSEq [Γ] ⊢Δ (⊢F [σ]) [σ] [σ≡σ′] [F][wk1σ] = proj₁ ([F] (⊢Δ ∙ ⊢F [σ]) [wk1σ]) [F][wk1σ′] = proj₁ ([F] (⊢Δ ∙ ⊢F [σ]) [wk1σ′]) var0′ = conv var0 (≅-eq (escapeEq [F][wk1σ] (proj₂ ([F] (⊢Δ ∙ ⊢F [σ]) [wk1σ]) [wk1σ′] [wk1σ≡wk1σ′]))) in Π₌ _ _ (id (univ (Πⱼ lF≤ ▹ lG≤ ▹ un-univ (⊢F [σ′]) ▹ un-univ (⊢G [σ′])))) (≅-univ (≅ₜ-Π-cong lF≤ lG≤ (⊢F [σ]) (≅-un-univ (escapeEq (proj₁ ([F] ⊢Δ [σ])) (proj₂ ([F] ⊢Δ [σ]) [σ′] [σ≡σ′]))) (≅-un-univ (escapeEq (proj₁ ([G]σ [σ])) (proj₂ ([G]σ [σ]) ([wk1σ′] , neuTerm [F][wk1σ′] (var 0) var0′ (~-var var0′)) ([wk1σ≡wk1σ′] , neuEqTerm [F][wk1σ] (var 0) (var 0) var0 var0 (~-var var0))))))) (λ ρ ⊢Δ₁ → wkEq ρ ⊢Δ₁ [σF] (proj₂ ([F] ⊢Δ [σ]) [σ′] [σ≡σ′])) (λ {ρ} {Δ₁} {a} [ρ] ⊢Δ₁ [a] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [ρσ′] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ′] [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ] ⊢Δ₁ [σF]) (proj₁ ([F] ⊢Δ₁ [ρσ])) [a] [a]″ = convTerm₁ (proj₁ ([F] ⊢Δ₁ [ρσ])) (proj₁ ([F] ⊢Δ₁ [ρσ′])) (proj₂ ([F] ⊢Δ₁ [ρσ]) [ρσ′] (wkSubstSEq [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σ≡σ′])) [a]′ [ρσa≡ρσ′a] = consSubstSEq {t = a} {A = F} [Γ] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]) (wkSubstSEq [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σ≡σ′]) [F] [a]′ in irrelevanceEq″ (PE.sym (singleSubstWkComp a σ G)) (PE.sym (singleSubstWkComp a σ′ G)) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′)) (Gapp {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′) (proj₂ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F] [G] ⊢Δ [σ] a [ρ] ⊢Δ₁ [a]′) (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ′] , [a]″) [ρσa≡ρσ′a]))) -- Validity of Π-congurence. Π-congᵛ : ∀ {F G H E Γ rF lF lG rΠ lΠ l} (lF≤ : lF ≤ lΠ) (lG≤ : lG ≤ lΠ) ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ]) ([G] : Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ G ^ [ rΠ , ι lG ] / [Γ] ∙ [F]) ([H] : Γ ⊩ᵛ⟨ l ⟩ H ^ [ rF , ι lF ] / [Γ]) ([E] : Γ ∙ H ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ E ^ [ rΠ , ι lG ] / [Γ] ∙ [H]) ([F≡H] : Γ ⊩ᵛ⟨ l ⟩ F ≡ H ^ [ rF , ι lF ] / [Γ] / [F]) ([G≡E] : Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ G ≡ E ^ [ rΠ , ι lG ] / [Γ] ∙ [F] / [G]) → Γ ⊩ᵛ⟨ l ⟩ Π F ^ rF ° lF ▹ G ° lG ° lΠ ≡ Π H ^ rF ° lF ▹ E ° lG ° lΠ ^ [ rΠ , ι lΠ ] / [Γ] / Πᵛ {F} {G} lF≤ lG≤ [Γ] [F] [G] Π-congᵛ {F} {G} {H} {E} lF≤ lG≤ [Γ] [F] [G] [H] [E] [F≡H] [G≡E] {σ = σ} ⊢Δ [σ] = let [ΠFG] = Πᵛ {F} {G} lF≤ lG≤ [Γ] [F] [G] [σΠFG] = proj₁ ([ΠFG] ⊢Δ [σ]) _ , Πᵣ rF′ lF' lG' lF≤ lG≤ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (Π-elim [σΠFG]) [σF] = proj₁ ([F] ⊢Δ [σ]) ⊢σF = escape [σF] [σG] = proj₁ ([G] (⊢Δ ∙ ⊢σF) (liftSubstS {F = F} [Γ] ⊢Δ [F] [σ])) ⊢σH = escape (proj₁ ([H] ⊢Δ [σ])) ⊢σE = escape (proj₁ ([E] (⊢Δ ∙ ⊢σH) (liftSubstS {F = H} [Γ] ⊢Δ [H] [σ]))) ⊢σF≡σH = escapeEq [σF] ([F≡H] ⊢Δ [σ]) ⊢σG≡σE = escapeEq [σG] ([G≡E] (⊢Δ ∙ ⊢σF) (liftSubstS {F = F} [Γ] ⊢Δ [F] [σ])) in Π₌ (subst σ H) (subst (liftSubst σ) E) (id (univ (Πⱼ lF≤ ▹ lG≤ ▹ (un-univ ⊢σH) ▹ (un-univ ⊢σE)))) (≅-univ (≅ₜ-Π-cong lF≤ lG≤ ⊢σF (≅-un-univ ⊢σF≡σH) (≅-un-univ ⊢σG≡σE))) (λ ρ ⊢Δ₁ → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ ρ [σ] in irrelevanceEq″ (PE.sym (wk-subst F)) (PE.sym (wk-subst H)) PE.refl PE.refl (proj₁ ([F] ⊢Δ₁ [ρσ])) ([F]′ ρ ⊢Δ₁) ([F≡H] ⊢Δ₁ [ρσ])) (λ {ρ} {Δ} {a} [ρ] ⊢Δ₁ [a] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl ([F]′ [ρ] ⊢Δ₁) (proj₁ ([F] ⊢Δ₁ [ρσ])) [a] [aρσ] = consSubstS {t = a} {A = F} [Γ] ⊢Δ₁ [ρσ] [F] [a]′ in irrelevanceEq″ (PE.sym (singleSubstWkComp a σ G)) (PE.sym (singleSubstWkComp a σ E)) PE.refl PE.refl (proj₁ ([G] ⊢Δ₁ [aρσ])) ([G]′ [ρ] ⊢Δ₁ [a]) ([G≡E] ⊢Δ₁ [aρσ]) ) -- Validity of Π as a term. Πᵗᵛ₁ : ∀ {F G rF lF lG rΠ lΠ Γ} (lF≤ : lF ≤ lΠ) (lG≤ : lG ≤ lΠ) ([Γ] : ⊩ᵛ Γ)→ let l = ∞ [UF] = maybeEmbᵛ {A = Univ rF _} [Γ] (Uᵛ (proj₂ (levelBounded lF)) [Γ]) [UΠ] = maybeEmbᵛ {A = Univ rΠ _} [Γ] (Uᵛ (proj₂ (levelBounded lΠ)) [Γ]) in ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ]) ([UG] : Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ Univ rΠ lG ^ [ ! , next lG ] / [Γ] ∙ [F]) → Γ ⊩ᵛ⟨ l ⟩ F ∷ Univ rF lF ^ [ ! , next lF ] / [Γ] / [UF] → Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ G ∷ Univ rΠ lG ^ [ ! , next lG ] / [Γ] ∙ [F] / (λ {Δ} {σ} → [UG] {Δ} {σ}) → ∀ {Δ σ} (⊢Δ : ⊢ Δ) ([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ) → Δ ⊩⟨ l ⟩ subst σ (Π F ^ rF ° lF ▹ G ° lG ° lΠ) ∷ subst σ (Univ rΠ lΠ) ^ [ ! , next lΠ ] / proj₁ ([UΠ] ⊢Δ [σ]) Πᵗᵛ₁ {F} {G} {rF} {lF} {lG} {rΠ} {lΠ = ¹} {Γ} lF≤ lG≤ [Γ] [F] [UG] [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let l = ∞ lΠ = ¹ [UF] = maybeEmbᵛ {A = Univ rF _} [Γ] (Uᵛ (proj₂ (levelBounded lF)) [Γ]) [UΠ] = maybeEmbᵛ {A = Univ rΠ _} [Γ] (Uᵛ (proj₂ (levelBounded lΠ)) [Γ]) ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ = escapeTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) ⊢F≡Fₜ = escapeTermEq univΔ (reflEqTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ]))) [UG]σ = proj₁ ([UG] {σ = liftSubst σ} (⊢Δ ∙ ⊢F) [liftσ]) [Gₜ]σ = proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ]) ⊢Gₜ = escapeTerm [UG]σ [Gₜ]σ ⊢G≡Gₜ = escapeTermEq [UG]σ (reflEqTerm [UG]σ [Gₜ]σ) [F]₀ = univᵛ {F} [Γ] lF≤ [UF] [Fₜ] [UG]′ = S.irrelevance {A = Univ rΠ lG} {r = [ ! , next lG ]} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) [Gₜ]′ = S.irrelevanceTerm {l′ = ∞} {A = Univ rΠ lG} {t = G} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ] [G]₀ = univᵛ {G} (_∙_ {A = F} [Γ] [F]₀) lG≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) (λ {Δ} {σ} → [Gₜ]′ {Δ} {σ}) [Guniv] = univᵛ {A = G} (_∙_ {A = F} [Γ] [F]₀) lG≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ]′ in Uₜ (Π subst σ F ^ rF ° lF ▹ subst (liftSubst σ) G ° lG ° lΠ) (idRedTerm:*: (Πⱼ lF≤ ▹ lG≤ ▹ ⊢Fₜ ▹ ⊢Gₜ)) Πₙ (≅ₜ-Π-cong lF≤ lG≤ ⊢F ⊢F≡Fₜ ⊢G≡Gₜ) (λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let ⊢Fₜ' = Definition.Typed.Weakening.wkTerm [ρ] ⊢Δ₁ ⊢Fₜ ⊢Gₜ' = Definition.Typed.Weakening.wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') ⊢Gₜ [wkFₜ] = wkTerm [ρ] ⊢Δ₁ univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) [wkGₜ] = wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] {σ = liftSubst σ} (⊢Δ ∙ ⊢F) [liftσ])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ])) [⊢weakF≡Fₜ] = escapeTermEq (wk [ρ] ⊢Δ₁ univΔ) (reflEqTerm (wk [ρ] ⊢Δ₁ univΔ) [wkFₜ]) [⊢weakG≡Gₜ] = escapeTermEq (wk (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ]))) (reflEqTerm (wk (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ]))) (wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ])))) [wkFₜ]Type : ∀ {ρ₁ Δ₂} [ρ₁] ⊢Δ₂ → Δ₂ ⊩⟨ ι ¹ ⟩ U.wk ρ₁ (U.wk ρ (subst σ F)) ^ [ rF , ι lF ] [wkFₜ]Type = λ {ρ₁} {Δ₂} [ρ₁] ⊢Δ₂ → let [wkFₜ]Type = univEq (wk [ρ₁] ⊢Δ₂ (wk [ρ] ⊢Δ₁ univΔ)) (wkTerm [ρ₁] ⊢Δ₂ (wk [ρ] ⊢Δ₁ univΔ) [wkFₜ]) in maybeEmb′ lF≤ [wkFₜ]Type in Πᵣ′ rF lF lG lF≤ lG≤ (U.wk ρ (subst σ F)) (U.wk (lift ρ) (subst (liftSubst σ) G)) (idRed:*: (univ (Πⱼ lF≤ ▹ lG≤ ▹ ⊢Fₜ' ▹ ⊢Gₜ'))) (univ ⊢Fₜ') (univ ⊢Gₜ') (≅-univ (≅ₜ-Π-cong lF≤ lG≤ (univ ⊢Fₜ') [⊢weakF≡Fₜ] [⊢weakG≡Gₜ])) [wkFₜ]Type (λ {ρ₁} {Δ₂} {a} [ρ₁] ⊢Δ₂ [a] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₂ ([ρ₁] •ₜ [ρ]) [σ] [a]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a] [Gapp] = Gapp {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ in PE.subst (λ X → _ ⊩⟨ ι ¹ ⟩ X ^ _) (wk-comp-subst _ _ (subst (liftSubst σ) G)) [Gapp]) (λ {ρ₁} {Δ₂} {a} {b} [ρ₁] ⊢Δ₂ [a] [b] [a≡b] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₂ ([ρ₁] •ₜ [ρ]) [σ] [a]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a] [b]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [b] [a≡b]′ = irrelevanceEqTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a≡b] [Gapp] = Gapp {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ in irrelevanceEq″ (PE.trans (PE.sym (singleSubstWkComp a σ G)) (wk-comp-subst {a} ρ₁ ρ (subst (liftSubst σ) G))) (PE.trans (PE.sym (singleSubstWkComp b σ G)) (wk-comp-subst {b} ρ₁ ρ (subst (liftSubst σ) G))) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ )) (PE.subst (λ X → _ ⊩⟨ ι ¹ ⟩ X ^ _) (wk-comp-subst _ _ (subst (liftSubst σ) G)) [Gapp]) (proj₂ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ ) ([ρσ] , [b]′) (reflSubst [Γ] ⊢Δ₂ [ρσ] , [a≡b]′)))) Πᵗᵛ₁ {F} {G} {rF} {lF} {lG} {rΠ} {lΠ = ⁰} {Γ} lF≤ lG≤ [Γ] [F] [UG] [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let l = ∞ lΠ = ⁰ [UF] = maybeEmbᵛ {A = Univ rF _} [Γ] (Uᵛ (proj₂ (levelBounded lF)) [Γ]) [UΠ] = maybeEmbᵛ {A = Univ rΠ _} [Γ] (Uᵛ (proj₂ (levelBounded lΠ)) [Γ]) ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ = escapeTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) ⊢F≡Fₜ = escapeTermEq univΔ (reflEqTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ]))) [UG]σ = proj₁ ([UG] {σ = liftSubst σ} (⊢Δ ∙ ⊢F) [liftσ]) [Gₜ]σ = proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ]) ⊢Gₜ = escapeTerm [UG]σ [Gₜ]σ ⊢G≡Gₜ = escapeTermEq [UG]σ (reflEqTerm [UG]σ [Gₜ]σ) [F]₀ = univᵛ {F} [Γ] lF≤ [UF] [Fₜ] [UG]′ = S.irrelevance {A = Univ rΠ lG} {r = [ ! , next lG ]} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) [Gₜ]′ = S.irrelevanceTerm {l′ = ∞} {A = Univ rΠ lG} {t = G} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ] [G]₀ = univᵛ {G} (_∙_ {A = F} [Γ] [F]₀) lG≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) (λ {Δ} {σ} → [Gₜ]′ {Δ} {σ}) [Guniv] = univᵛ {A = G} (_∙_ {A = F} [Γ] [F]₀) lG≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ]′ in Uₜ (Π subst σ F ^ rF ° lF ▹ subst (liftSubst σ) G ° lG ° lΠ) (idRedTerm:*: (Πⱼ lF≤ ▹ lG≤ ▹ ⊢Fₜ ▹ ⊢Gₜ)) Πₙ (≅ₜ-Π-cong lF≤ lG≤ ⊢F ⊢F≡Fₜ ⊢G≡Gₜ) (λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let ⊢Fₜ' = Definition.Typed.Weakening.wkTerm [ρ] ⊢Δ₁ ⊢Fₜ ⊢Gₜ' = Definition.Typed.Weakening.wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') ⊢Gₜ [wkFₜ] = wkTerm [ρ] ⊢Δ₁ univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) [wkGₜ] = wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] {σ = liftSubst σ} (⊢Δ ∙ ⊢F) [liftσ])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ])) [⊢weakF≡Fₜ] = escapeTermEq (wk [ρ] ⊢Δ₁ univΔ) (reflEqTerm (wk [ρ] ⊢Δ₁ univΔ) [wkFₜ]) [⊢weakG≡Gₜ] = escapeTermEq (wk (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ]))) (reflEqTerm (wk (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ]))) (wkTerm (Definition.Typed.Weakening.lift [ρ]) (⊢Δ₁ ∙ univ ⊢Fₜ') (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ])))) [wkFₜ]Type : ∀ {ρ₁ Δ₂} [ρ₁] ⊢Δ₂ → Δ₂ ⊩⟨ ι ⁰ ⟩ U.wk ρ₁ (U.wk ρ (subst σ F)) ^ [ rF , ι lF ] [wkFₜ]Type = λ {ρ₁} {Δ₂} [ρ₁] ⊢Δ₂ → let [wkFₜ]Type = univEq (wk [ρ₁] ⊢Δ₂ (wk [ρ] ⊢Δ₁ univΔ)) (wkTerm [ρ₁] ⊢Δ₂ (wk [ρ] ⊢Δ₁ univΔ) [wkFₜ]) in maybeEmb′ lF≤ [wkFₜ]Type in Πᵣ′ rF lF lG lF≤ lG≤ (U.wk ρ (subst σ F)) (U.wk (lift ρ) (subst (liftSubst σ) G)) (idRed:*: (univ (Πⱼ lF≤ ▹ lG≤ ▹ ⊢Fₜ' ▹ ⊢Gₜ'))) (univ ⊢Fₜ') (univ ⊢Gₜ') (≅-univ (≅ₜ-Π-cong lF≤ lG≤ (univ ⊢Fₜ') [⊢weakF≡Fₜ] [⊢weakG≡Gₜ])) [wkFₜ]Type (λ {ρ₁} {Δ₂} {a} [ρ₁] ⊢Δ₂ [a] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₂ ([ρ₁] •ₜ [ρ]) [σ] [a]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a] [Gapp] = Gapp {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ in PE.subst (λ X → _ ⊩⟨ ι ⁰ ⟩ X ^ _) (wk-comp-subst _ _ (subst (liftSubst σ) G)) [Gapp]) (λ {ρ₁} {Δ₂} {a} {b} [ρ₁] ⊢Δ₂ [a] [b] [a≡b] → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₂ ([ρ₁] •ₜ [ρ]) [σ] [a]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a] [b]′ = irrelevanceTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [b] [a≡b]′ = irrelevanceEqTerm′ (wk-subst2 {ρ} {ρ₁} {σ} F) PE.refl PE.refl ([wkFₜ]Type [ρ₁] ⊢Δ₂) (proj₁ ([F]₀ ⊢Δ₂ [ρσ])) [a≡b] [Gapp] = Gapp {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ in irrelevanceEq″ (PE.trans (PE.sym (singleSubstWkComp a σ G)) (wk-comp-subst {a} ρ₁ ρ (subst (liftSubst σ) G))) (PE.trans (PE.sym (singleSubstWkComp b σ G)) (wk-comp-subst {b} ρ₁ ρ (subst (liftSubst σ) G))) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ )) (PE.subst (λ X → _ ⊩⟨ ι ⁰ ⟩ X ^ _) (wk-comp-subst _ _ (subst (liftSubst σ) G)) [Gapp]) (proj₂ (GappGen {F = F} {G = G} {σ = σ} [Γ] [F]₀ [Guniv] ⊢Δ [σ] a ([ρ₁] •ₜ [ρ]) ⊢Δ₂ [a]′ ) ([ρσ] , [b]′) (reflSubst [Γ] ⊢Δ₂ [ρσ] , [a≡b]′)))) Πᵗᵛ : ∀ {F G rF lF lG rΠ lΠ Γ} (lF≤ : lF ≤ lΠ) (lG≤ : lG ≤ lΠ) ([Γ] : ⊩ᵛ Γ)→ let l = ∞ [UF] = maybeEmbᵛ {A = Univ rF _} [Γ] (Uᵛ (proj₂ (levelBounded lF)) [Γ]) [UΠ] = maybeEmbᵛ {A = Univ rΠ _} [Γ] (Uᵛ (proj₂ (levelBounded lΠ)) [Γ]) in ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ]) ([UG] : Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ Univ rΠ lG ^ [ ! , next lG ] / [Γ] ∙ [F]) → Γ ⊩ᵛ⟨ l ⟩ F ∷ Univ rF lF ^ [ ! , next lF ] / [Γ] / [UF] → Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ G ∷ Univ rΠ lG ^ [ ! , next lG ] / [Γ] ∙ [F] / (λ {Δ} {σ} → [UG] {Δ} {σ}) → Γ ⊩ᵛ⟨ l ⟩ Π F ^ rF ° lF ▹ G ° lG ° lΠ ∷ Univ rΠ lΠ ^ [ ! , next lΠ ] / [Γ] / [UΠ] Πᵗᵛ {F} {G} {rF} {lF} {lG} {rΠ} {lΠ = ¹} {Γ} lF≤ lG≤ [Γ] [F] [UG] [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let l = ∞ [UF] = maybeEmbᵛ {A = Univ rF _} [Γ] (Uᵛ (proj₂ (levelBounded lF)) [Γ]) in Πᵗᵛ₁ {F} {G} {rF} {lF} {lG} {rΠ} {¹} {Γ} lF≤ lG≤ [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] , (λ {σ′} [σ′] [σ≡σ′] → let ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ = escapeTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) ⊢F≡Fₜ = escapeTermEq univΔ (reflEqTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ]))) [liftσ′] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ′] [wk1σ] = wk1SubstS [Γ] ⊢Δ ⊢F [σ] [wk1σ′] = wk1SubstS [Γ] ⊢Δ ⊢F [σ′] var0 = conv (var (⊢Δ ∙ ⊢F) (PE.subst (λ x → 0 ∷ x ^ [ rF , ι lF ] ∈ (Δ ∙ subst σ F ^ [ rF , ι lF ])) (wk-subst F) here)) (≅-eq (escapeEq (proj₁ ([F] (⊢Δ ∙ ⊢F) [wk1σ])) (proj₂ ([F] (⊢Δ ∙ ⊢F) [wk1σ]) [wk1σ′] (wk1SubstSEq [Γ] ⊢Δ ⊢F [σ] [σ≡σ′])))) [liftσ′]′ = [wk1σ′] , neuTerm (proj₁ ([F] (⊢Δ ∙ ⊢F) [wk1σ′])) (var 0) var0 (~-var var0) ⊢F′ = escape (proj₁ ([F] ⊢Δ [σ′])) univΔ = proj₁ ([UF] ⊢Δ [σ]) univΔ′ = proj₁ ([UF] ⊢Δ [σ′]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ′ = escapeTerm univΔ′ (proj₁ ([Fₜ] ⊢Δ [σ′])) ⊢Gₜ′ = escapeTerm (proj₁ ([UG] {σ = liftSubst σ′} (⊢Δ ∙ ⊢F′) [liftσ′])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F′) [liftσ′])) ⊢F≡F′ = escapeTermEq univΔ (proj₂ ([Fₜ] ⊢Δ [σ]) [σ′] [σ≡σ′]) ⊢G≡G′ = escapeTermEq (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) (proj₂ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ]) [liftσ′]′ (liftSubstSEq {F = F} [Γ] ⊢Δ [F] [σ] [σ≡σ′])) [F]₀ = univᵛ {F} [Γ] lF≤ [UF] [Fₜ] [UG]′ = S.irrelevance {A = Univ rΠ lG} {r = [ ! , next lG ]} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) [Gₜ]′ = S.irrelevanceTerm {l′ = ∞} {A = Univ rΠ lG} {t = G} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ] [G]₀ = univᵛ {G} (_∙_ {A = F} [Γ] [F]₀) lG≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) (λ {Δ} {σ} → [Gₜ]′ {Δ} {σ}) [ΠFG-cong] = Π-congᵛ {F} {G} {F} {G} lF≤ lG≤ [Γ] [F]₀ [G]₀ [F]₀ [G]₀ (λ ⊢Δ₁ [σ]₁ → proj₂ ([F]₀ ⊢Δ₁ [σ]₁) [σ]₁ (reflSubst [Γ] ⊢Δ₁ [σ]₁)) (λ {Δ₁} {σ₁} ⊢Δ₁ [σ]₁ → proj₂ ([G]₀ ⊢Δ₁ [σ]₁) [σ]₁ (reflSubst {σ₁} ((_∙_ {A = F} [Γ] [F]₀)) ⊢Δ₁ [σ]₁)) [ΠFG]ᵗ = Πᵗᵛ₁ {F} {G} {rF} {lF} {lG} {rΠ} {lΠ = ¹} {Γ} lF≤ lG≤ [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] [ΠFG]ᵗ′ = Πᵗᵛ₁ {F} {G} {rF} {lF} {lG} {rΠ} {lΠ = ¹} {Γ} lF≤ lG≤ [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ′} ⊢Δ [σ′] [ΠFG] = Πᵛ {F} {G} {Γ} {rF} {lF} {lG} {rΠ} {lΠ = ¹} lF≤ lG≤ [Γ] [F]₀ [G]₀ in Uₜ₌ [ΠFG]ᵗ [ΠFG]ᵗ′ (≅ₜ-Π-cong lF≤ lG≤ ⊢F ⊢F≡F′ ⊢G≡G′) (λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let [ΠFG-cong]′ = [ΠFG-cong] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]) X = irrelevanceEq″ (PE.sym (wk-subst (Π F ^ rF ° lF ▹ G ° lG ° ¹))) (PE.sym (wk-subst (Π F ^ rF ° lF ▹ G ° lG ° ¹))) PE.refl PE.refl (proj₁ ([ΠFG] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]))) (LogRel._⊩¹U_∷_^_/_.[t] [ΠFG]ᵗ [ρ] ⊢Δ₁) [ΠFG-cong]′ [σΠFG] = proj₁ ([ΠFG] ⊢Δ [σ]) _ , Πᵣ rF′ lF' lG' lF≤' lG≤' F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (Π-elim [σΠFG]) [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σF]₀ = proj₁ ([F]₀ ⊢Δ₁ [ρσ]) ⊢σF₀ = escape [σF]₀ [σG]₀ = proj₁ ([G]₀ (⊢Δ₁ ∙ ⊢σF₀) (liftSubstS {F = F} [Γ] ⊢Δ₁ [F]₀ [ρσ])) [ρσ′] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ′] [σF′]₀ = proj₁ ([F]₀ ⊢Δ₁ [ρσ′]) ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₁ [ρσ′])) ⊢σE = escape (proj₁ ([G]₀ (⊢Δ₁ ∙ ⊢σH) (liftSubstS {F = F} [Γ] ⊢Δ₁ [F]₀ [ρσ′]))) univΔ₁ = proj₁ ([UF] ⊢Δ₁ [ρσ]) [ρσ≡ρσ′] = wkSubstSEq [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σ≡σ′] [σF≡σH] = univEqEq univΔ₁ [σF]₀ (proj₂ ([Fₜ] ⊢Δ₁ [ρσ]) [ρσ′] [ρσ≡ρσ′]) ⊢σF≡σH = escapeEq [σF]₀ [σF≡σH] [σF] = proj₁ ([F] ⊢Δ₁ [ρσ]) ⊢σF = escape [σF] liftσ = liftSubstS {F = F} [Γ] ⊢Δ₁ [F] [ρσ] [wk1σ] = wk1SubstS [Γ] ⊢Δ₁ ⊢σF [ρσ] [wk1σ′] = wk1SubstS [Γ] ⊢Δ₁ ⊢σF [ρσ′] var0 = conv (var (⊢Δ₁ ∙ ⊢σF) (PE.subst (λ x → 0 ∷ x ^ [ rF , ι lF ] ∈ (Δ₁ ∙ subst (ρ •ₛ σ) F ^ [ rF , ι lF ])) (wk-subst F) here)) (≅-eq (escapeEq (proj₁ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ])) (proj₂ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ]) [wk1σ′] (wk1SubstSEq [Γ] ⊢Δ₁ ⊢σF [ρσ] [ρσ≡ρσ′])))) [liftσ′]′ : (Δ₁ ∙ subst (ρ •ₛ σ) F ^ [ rF , ι lF ]) ⊩ˢ liftSubst (ρ •ₛ σ′) ∷ Γ ∙ F ^ [ rF , ι lF ] / [Γ] ∙ [F] / (⊢Δ₁ ∙ escape (proj₁ ([F] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ])))) [liftσ′]′ = [wk1σ′] , neuTerm (proj₁ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ′])) (var 0) var0 (~-var var0) liftσ′ = liftSubstS {F = F} [Γ] ⊢Δ₁ [F] [ρσ′] univΔ₁G = proj₁ ([UG] (⊢Δ₁ ∙ ⊢σF) liftσ) [σG≡σE] = univEqEq univΔ₁G [σG]₀ (proj₂ ([Gₜ] {σ = liftSubst (ρ •ₛ σ)} (⊢Δ₁ ∙ ⊢σF) liftσ) [liftσ′]′ (liftSubstSEq {F = F} [Γ] ⊢Δ₁ [F] [ρσ] [ρσ≡ρσ′])) ⊢σG≡σE = escapeEq [σG]₀ [σG≡σE] X = Π₌ (subst (ρ •ₛ σ′) F) (subst (liftSubst (ρ •ₛ σ′)) G) (id (univ (Πⱼ lF≤ ▹ lG≤ ▹ (un-univ ⊢σH) ▹ (un-univ ⊢σE)))) ((≅-univ (≅ₜ-Π-cong lF≤ lG≤ ⊢σF (≅-un-univ ⊢σF≡σH) (≅-un-univ ⊢σG≡σE)))) (λ {ρ₂} {Δ₂} [ρ₂] ⊢Δ₂ → let [ρσ₂] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ₂F]₀ = proj₁ ([F]₀ ⊢Δ₂ [ρσ₂]) [σΠFG] = proj₁ ([ΠFG] ⊢Δ₁ [ρσ]) _ , Πᵣ rF′ lF' lG' lF≤' lG≤' F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (Π-elim [σΠFG]) ⊢ρσ₂F = escape [ρσ₂F]₀ [ρσ₂′] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ′] ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) univΔ₂ = proj₁ ([UF] ⊢Δ₂ [ρσ₂]) [σF≡σH] = univEqEq univΔ₂ [ρσ₂F]₀ (proj₂ ([Fₜ] ⊢Δ₂ [ρσ₂]) [ρσ₂′] (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′])) in irrelevanceEq″ (PE.sym (wk-subst F)) (PE.sym (wk-subst F)) PE.refl PE.refl [ρσ₂F]₀ ([F]′ [ρ₂] ⊢Δ₂) [σF≡σH]) (λ {ρ₂} {Δ₂} {a} [ρ₂] ⊢Δ₂ [a] → let [ρσ₂] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ₂F]₀ = proj₁ ([F]₀ ⊢Δ₂ [ρσ₂]) [σΠFG] = proj₁ ([ΠFG] ⊢Δ₁ [ρσ]) _ , Πᵣ rF′ lF' lG' lF≤' lG≤' F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (Π-elim [σΠFG]) ⊢ρσ₂F = escape [ρσ₂F]₀ [ρσ₂′] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ′] ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) univΔ₂ = proj₁ ([UF] ⊢Δ₂ [ρσ₂]) [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ₂] ⊢Δ₂ [σF]₀) (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂])) [a] [a]″ = convTerm₁ (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂])) (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) (proj₂ ([F]₀ ⊢Δ₂ [ρσ₂]) [ρσ₂′] (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′])) [a]′ [ρσa≡ρσ′a] = consSubstSEq {t = a} {A = F} [Γ] ⊢Δ₂ (wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ]) (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′]) [F]₀ [a]′ in irrelevanceEq″ (PE.sym (singleSubstWkComp a (ρ •ₛ σ) G)) (PE.sym (singleSubstWkComp a (ρ •ₛ σ′) G)) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′)) (Gapp {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′) (proj₂ (GappGen {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′) ([ρσ₂′] , [a]″) [ρσa≡ρσ′a] )) in irrelevanceEq″ (PE.sym (wk-subst (Π F ^ rF ° lF ▹ G ° lG ° ¹))) (PE.sym (wk-subst (Π F ^ rF ° lF ▹ G ° lG ° ¹))) PE.refl PE.refl (proj₁ ([ΠFG] ⊢Δ₁ [ρσ])) (LogRel._⊩¹U_∷_^_/_.[t] [ΠFG]ᵗ [ρ] ⊢Δ₁) X)) Πᵗᵛ {F} {G} {rF} {lF} {lG} {rΠ} {lΠ = ⁰} {Γ} lFΠ< lG≤ [Γ] [F] [UG] [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let l = ∞ [UF] = maybeEmbᵛ {A = Univ rF _} [Γ] (Uᵛ (proj₂ (levelBounded lF)) [Γ]) in Πᵗᵛ₁ {F} {G} {rF} {lF} {lG} {rΠ} {⁰} {Γ} lFΠ< lG≤ [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] , (λ {σ′} [σ′] [σ≡σ′] → let ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ = escapeTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ])) ⊢F≡Fₜ = escapeTermEq univΔ (reflEqTerm univΔ (proj₁ ([Fₜ] ⊢Δ [σ]))) [liftσ′] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ′] [wk1σ] = wk1SubstS [Γ] ⊢Δ ⊢F [σ] [wk1σ′] = wk1SubstS [Γ] ⊢Δ ⊢F [σ′] var0 = conv (var (⊢Δ ∙ ⊢F) (PE.subst (λ x → 0 ∷ x ^ [ rF , ι lF ] ∈ (Δ ∙ subst σ F ^ [ rF , ι lF ])) (wk-subst F) here)) (≅-eq (escapeEq (proj₁ ([F] (⊢Δ ∙ ⊢F) [wk1σ])) (proj₂ ([F] (⊢Δ ∙ ⊢F) [wk1σ]) [wk1σ′] (wk1SubstSEq [Γ] ⊢Δ ⊢F [σ] [σ≡σ′])))) [liftσ′]′ = [wk1σ′] , neuTerm (proj₁ ([F] (⊢Δ ∙ ⊢F) [wk1σ′])) (var 0) var0 (~-var var0) ⊢F′ = escape (proj₁ ([F] ⊢Δ [σ′])) univΔ = proj₁ ([UF] ⊢Δ [σ]) univΔ′ = proj₁ ([UF] ⊢Δ [σ′]) [Fₜ]σ {σ′} [σ′] = [Fₜ] {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) ⊢Fₜ′ = escapeTerm univΔ′ (proj₁ ([Fₜ] ⊢Δ [σ′])) ⊢Gₜ′ = escapeTerm (proj₁ ([UG] {σ = liftSubst σ′} (⊢Δ ∙ ⊢F′) [liftσ′])) (proj₁ ([Gₜ] (⊢Δ ∙ ⊢F′) [liftσ′])) ⊢F≡F′ = escapeTermEq univΔ (proj₂ ([Fₜ] ⊢Δ [σ]) [σ′] [σ≡σ′]) ⊢G≡G′ = escapeTermEq (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) (proj₂ ([Gₜ] (⊢Δ ∙ ⊢F) [liftσ]) [liftσ′]′ (liftSubstSEq {F = F} [Γ] ⊢Δ [F] [σ] [σ≡σ′])) [F]₀ = univᵛ {F} [Γ] lFΠ< [UF] [Fₜ] [UG]′ = S.irrelevance {A = Univ rΠ lG} {r = [ ! , next lG ]} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) [Gₜ]′ = S.irrelevanceTerm {l′ = ∞} {A = Univ rΠ lG} {t = G} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]₀) (λ {Δ} {σ} → [UG] {Δ} {σ}) (λ {Δ} {σ} → [UG]′ {Δ} {σ}) [Gₜ] [G]₀ = univᵛ {G} (_∙_ {A = F} [Γ] [F]₀) lG≤ (λ {Δ} {σ} → [UG]′ {Δ} {σ}) (λ {Δ} {σ} → [Gₜ]′ {Δ} {σ}) [ΠFG-cong] = Π-congᵛ {F} {G} {F} {G} lFΠ< lG≤ [Γ] [F]₀ [G]₀ [F]₀ [G]₀ (λ ⊢Δ₁ [σ]₁ → proj₂ ([F]₀ ⊢Δ₁ [σ]₁) [σ]₁ (reflSubst [Γ] ⊢Δ₁ [σ]₁)) (λ {Δ₁} {σ₁} ⊢Δ₁ [σ]₁ → proj₂ ([G]₀ ⊢Δ₁ [σ]₁) [σ]₁ (reflSubst {σ₁} ((_∙_ {A = F} [Γ] [F]₀)) ⊢Δ₁ [σ]₁)) [ΠFG]ᵗ = Πᵗᵛ₁ {F} {G} {rF} {lF} {lG} {rΠ} {lΠ = ⁰} {Γ} lFΠ< lG≤ [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ} ⊢Δ [σ] [ΠFG]ᵗ′ = Πᵗᵛ₁ {F} {G} {rF} {lF} {lG} {rΠ} {lΠ = ⁰} {Γ} lFΠ< lG≤ [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] {Δ = Δ} {σ = σ′} ⊢Δ [σ′] [ΠFG] = Πᵛ {F} {G} {Γ} {rF} {lF} {lG} {rΠ} {lΠ = ⁰} lFΠ< lG≤ [Γ] [F]₀ [G]₀ in Uₜ₌ [ΠFG]ᵗ [ΠFG]ᵗ′ (≅ₜ-Π-cong lFΠ< lG≤ ⊢F ⊢F≡F′ ⊢G≡G′) (λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let [ΠFG-cong]′ = [ΠFG-cong] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]) X = irrelevanceEq″ (PE.sym (wk-subst (Π F ^ rF ° lF ▹ G ° lG ° ⁰))) (PE.sym (wk-subst (Π F ^ rF ° lF ▹ G ° lG ° ⁰))) PE.refl PE.refl (proj₁ ([ΠFG] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ]))) (LogRel._⊩¹U_∷_^_/_.[t] [ΠFG]ᵗ [ρ] ⊢Δ₁) [ΠFG-cong]′ [σΠFG] = proj₁ ([ΠFG] ⊢Δ [σ]) _ , Πᵣ rF′ lF' lG' lF≤' lG≤' F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (Π-elim [σΠFG]) [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σF]₀ = proj₁ ([F]₀ ⊢Δ₁ [ρσ]) ⊢σF₀ = escape [σF]₀ [σG]₀ = proj₁ ([G]₀ (⊢Δ₁ ∙ ⊢σF₀) (liftSubstS {F = F} [Γ] ⊢Δ₁ [F]₀ [ρσ])) [ρσ′] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ′] [σF′]₀ = proj₁ ([F]₀ ⊢Δ₁ [ρσ′]) ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₁ [ρσ′])) ⊢σE = escape (proj₁ ([G]₀ (⊢Δ₁ ∙ ⊢σH) (liftSubstS {F = F} [Γ] ⊢Δ₁ [F]₀ [ρσ′]))) univΔ₁ = proj₁ ([UF] ⊢Δ₁ [ρσ]) [ρσ≡ρσ′] = wkSubstSEq [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] [σ≡σ′] [σF≡σH] = univEqEq univΔ₁ [σF]₀ (proj₂ ([Fₜ] ⊢Δ₁ [ρσ]) [ρσ′] [ρσ≡ρσ′]) ⊢σF≡σH = escapeEq [σF]₀ [σF≡σH] [σF] = proj₁ ([F] ⊢Δ₁ [ρσ]) ⊢σF = escape [σF] liftσ = liftSubstS {F = F} [Γ] ⊢Δ₁ [F] [ρσ] [wk1σ] = wk1SubstS [Γ] ⊢Δ₁ ⊢σF [ρσ] [wk1σ′] = wk1SubstS [Γ] ⊢Δ₁ ⊢σF [ρσ′] var0 = conv (var (⊢Δ₁ ∙ ⊢σF) (PE.subst (λ x → 0 ∷ x ^ [ rF , ι lF ] ∈ (Δ₁ ∙ subst (ρ •ₛ σ) F ^ [ rF , ι lF ])) (wk-subst F) here)) (≅-eq (escapeEq (proj₁ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ])) (proj₂ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ]) [wk1σ′] (wk1SubstSEq [Γ] ⊢Δ₁ ⊢σF [ρσ] [ρσ≡ρσ′])))) [liftσ′]′ : (Δ₁ ∙ subst (ρ •ₛ σ) F ^ [ rF , ι lF ]) ⊩ˢ liftSubst (ρ •ₛ σ′) ∷ Γ ∙ F ^ [ rF , ι lF ] / [Γ] ∙ [F] / (⊢Δ₁ ∙ escape (proj₁ ([F] ⊢Δ₁ (wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ])))) [liftσ′]′ = [wk1σ′] , neuTerm (proj₁ ([F] (⊢Δ₁ ∙ ⊢σF) [wk1σ′])) (var 0) var0 (~-var var0) liftσ′ = liftSubstS {F = F} [Γ] ⊢Δ₁ [F] [ρσ′] univΔ₁G = proj₁ ([UG] (⊢Δ₁ ∙ ⊢σF) liftσ) [σG≡σE] = univEqEq univΔ₁G [σG]₀ (proj₂ ([Gₜ] {σ = liftSubst (ρ •ₛ σ)} (⊢Δ₁ ∙ ⊢σF) liftσ) [liftσ′]′ (liftSubstSEq {F = F} [Γ] ⊢Δ₁ [F] [ρσ] [ρσ≡ρσ′])) ⊢σG≡σE = escapeEq [σG]₀ [σG≡σE] X = Π₌ (subst (ρ •ₛ σ′) F) (subst (liftSubst (ρ •ₛ σ′)) G) (id (univ (Πⱼ lFΠ< ▹ lG≤ ▹ (un-univ ⊢σH) ▹ (un-univ ⊢σE)))) ((≅-univ (≅ₜ-Π-cong lFΠ< lG≤ ⊢σF (≅-un-univ ⊢σF≡σH) (≅-un-univ ⊢σG≡σE)))) (λ {ρ₂} {Δ₂} [ρ₂] ⊢Δ₂ → let [ρσ₂] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ₂F]₀ = proj₁ ([F]₀ ⊢Δ₂ [ρσ₂]) [σΠFG] = proj₁ ([ΠFG] ⊢Δ₁ [ρσ]) _ , Πᵣ rF′ lF' lG' lF≤' lG≤' F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (Π-elim [σΠFG]) ⊢ρσ₂F = escape [ρσ₂F]₀ [ρσ₂′] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ′] ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) univΔ₂ = proj₁ ([UF] ⊢Δ₂ [ρσ₂]) [σF≡σH] = univEqEq univΔ₂ [ρσ₂F]₀ (proj₂ ([Fₜ] ⊢Δ₂ [ρσ₂]) [ρσ₂′] (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′])) in irrelevanceEq″ (PE.sym (wk-subst F)) (PE.sym (wk-subst F)) PE.refl PE.refl [ρσ₂F]₀ ([F]′ [ρ₂] ⊢Δ₂) [σF≡σH]) (λ {ρ₂} {Δ₂} {a} [ρ₂] ⊢Δ₂ [a] → let [ρσ₂] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ₂F]₀ = proj₁ ([F]₀ ⊢Δ₂ [ρσ₂]) [σΠFG] = proj₁ ([ΠFG] ⊢Δ₁ [ρσ]) _ , Πᵣ rF′ lF' lG' lF≤' lG≤' F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′ = extractMaybeEmb (Π-elim [σΠFG]) ⊢ρσ₂F = escape [ρσ₂F]₀ [ρσ₂′] = wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ′] ⊢σH = escape (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) univΔ₂ = proj₁ ([UF] ⊢Δ₂ [ρσ₂]) [a]′ = irrelevanceTerm′ (wk-subst F) PE.refl PE.refl (wk [ρ₂] ⊢Δ₂ [σF]₀) (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂])) [a] [a]″ = convTerm₁ (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂])) (proj₁ ([F]₀ ⊢Δ₂ [ρσ₂′])) (proj₂ ([F]₀ ⊢Δ₂ [ρσ₂]) [ρσ₂′] (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′])) [a]′ [ρσa≡ρσ′a] = consSubstSEq {t = a} {A = F} [Γ] ⊢Δ₂ (wkSubstS [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ]) (wkSubstSEq [Γ] ⊢Δ₁ ⊢Δ₂ [ρ₂] [ρσ] [ρσ≡ρσ′]) [F]₀ [a]′ in irrelevanceEq″ (PE.sym (singleSubstWkComp a (ρ •ₛ σ) G)) (PE.sym (singleSubstWkComp a (ρ •ₛ σ′) G)) PE.refl PE.refl (proj₁ (GappGen {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′)) (Gapp {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′) (proj₂ (GappGen {F = F} {G = G} {σ = _} [Γ] [F]₀ [G]₀ ⊢Δ₁ [ρσ] a [ρ₂] ⊢Δ₂ [a]′) ([ρσ₂′] , [a]″) [ρσa≡ρσ′a] )) in irrelevanceEq″ (PE.sym (wk-subst (Π F ^ rF ° lF ▹ G ° lG ° ⁰))) (PE.sym (wk-subst (Π F ^ rF ° lF ▹ G ° lG ° ⁰))) PE.refl PE.refl (proj₁ ([ΠFG] ⊢Δ₁ [ρσ])) (LogRel._⊩¹U_∷_^_/_.[t] [ΠFG]ᵗ [ρ] ⊢Δ₁) X)) -- Validity of Π-congurence as a term equality. Π-congᵗᵛ : ∀ {F G H E rF lF lG rΠ lΠ Γ} (lF≤ : lF ≤ lΠ) (lG≤ : lG ≤ lΠ) ([Γ] : ⊩ᵛ Γ) → let l = ∞ [UF] = maybeEmbᵛ {A = Univ rF _} [Γ] (Uᵛ (proj₂ (levelBounded lF)) [Γ]) [UΠ] = maybeEmbᵛ {A = Univ rΠ _} [Γ] (Uᵛ (proj₂ (levelBounded lΠ)) [Γ]) in ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ]) ([H] : Γ ⊩ᵛ⟨ l ⟩ H ^ [ rF , ι lF ] / [Γ]) ([UG] : Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ Univ rΠ lG ^ [ ! , next lG ] / [Γ] ∙ [F]) ([UE] : Γ ∙ H ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ Univ rΠ lG ^ [ ! , next lG ] / [Γ] ∙ [H]) ([F]ₜ : Γ ⊩ᵛ⟨ l ⟩ F ∷ Univ rF lF ^ [ ! , next lF ] / [Γ] / [UF]) ([G]ₜ : Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ G ∷ Univ rΠ lG ^ [ ! , next lG ] / [Γ] ∙ [F] / (λ {Δ} {σ} → [UG] {Δ} {σ})) ([H]ₜ : Γ ⊩ᵛ⟨ l ⟩ H ∷ Univ rF lF ^ [ ! , next lF ] / [Γ] / [UF]) ([E]ₜ : Γ ∙ H ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ E ∷ Univ rΠ lG ^ [ ! , next lG ] / [Γ] ∙ [H] / (λ {Δ} {σ} → [UE] {Δ} {σ})) ([F≡H]ₜ : Γ ⊩ᵛ⟨ l ⟩ F ≡ H ∷ Univ rF lF ^ [ ! , next lF ] / [Γ] / [UF]) ([G≡E]ₜ : Γ ∙ F ^ [ rF , ι lF ] ⊩ᵛ⟨ l ⟩ G ≡ E ∷ Univ rΠ lG ^ [ ! , next lG ] / [Γ] ∙ [F] / (λ {Δ} {σ} → [UG] {Δ} {σ})) → Γ ⊩ᵛ⟨ l ⟩ Π F ^ rF ° lF ▹ G ° lG ° lΠ ≡ Π H ^ rF ° lF ▹ E ° lG ° lΠ ∷ Univ rΠ lΠ ^ [ ! , next lΠ ] / [Γ] / [UΠ] Π-congᵗᵛ {F} {G} {H} {E} {rF} {lF} {lG} {rΠ} {lΠ = ¹} {Γ} lF≤ lG≤ [Γ] [F] [H] [UG] [UE] [F]ₜ [G]ₜ [H]ₜ [E]ₜ [F≡H]ₜ [G≡E]ₜ {Δ} {σ} ⊢Δ [σ] = let l = ∞ [UF] = maybeEmbᵛ {A = Univ rF _} [Γ] (Uᵛ (proj₂ (levelBounded lF)) [Γ]) [ΠFG]ᵗ = Πᵗᵛ₁ {F} {G} {rF} {lF} {lG} {rΠ} {lΠ = ¹} {Γ} lF≤ lG≤ [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [F]ₜ [G]ₜ {Δ = Δ} {σ = σ} ⊢Δ [σ] [ΠHE]ᵗ = Πᵗᵛ₁ {H} {E} {rF} {lF} {lG} {rΠ} {lΠ = ¹} {Γ} lF≤ lG≤ [Γ] [H] (λ {Δ} {σ} → [UE] {Δ} {σ}) [H]ₜ [E]ₜ {Δ = Δ} {σ = σ} ⊢Δ [σ] ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [G] = maybeEmbᵛ {A = G} (_∙_ {A = F} [Γ] [F]) (univᵛ {G} (_∙_ {A = F} [Γ] [F]) lG≤ (λ {Δ} {σ} → [UG] {Δ} {σ}) [G]ₜ) [E] = maybeEmbᵛ {A = E} (_∙_ {A = H} [Γ] [H]) (univᵛ {E} (_∙_ {A = H} [Γ] [H]) lG≤ (λ {Δ} {σ} → [UE] {Δ} {σ}) [E]ₜ) [F≡H] = univEqᵛ {F} {H} [Γ] [UF] [F] [F≡H]ₜ [G≡E] = univEqᵛ {G} {E} (_∙_ {A = F} [Γ] [F]) (λ {Δ} {σ} → [UG] {Δ} {σ}) [G] [G≡E]ₜ in Uₜ₌ [ΠFG]ᵗ [ΠHE]ᵗ (≅ₜ-Π-cong lF≤ lG≤ ⊢F (escapeTermEq univΔ ([F≡H]ₜ ⊢Δ [σ])) (escapeTermEq (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) ([G≡E]ₜ (⊢Δ ∙ ⊢F) [liftσ]))) λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] X = Π-congᵛ {F} {G} {H} {E} {Γ} {rF} {lF} {lG} {rΠ} {¹} lF≤ lG≤ [Γ] [F] [G] [H] [E] [F≡H] [G≡E] ⊢Δ₁ [ρσ] in irrelevanceEq″ (PE.sym (wk-subst (Π F ^ rF ° lF ▹ G ° lG ° ¹))) (PE.sym (wk-subst (Π H ^ rF ° lF ▹ E ° lG ° ¹))) PE.refl PE.refl (proj₁ (Πᵛ {F} {G} lF≤ lG≤ [Γ] [F] [G] ⊢Δ₁ [ρσ])) (LogRel._⊩¹U_∷_^_/_.[t] [ΠFG]ᵗ [ρ] ⊢Δ₁) X Π-congᵗᵛ {F} {G} {H} {E} {rF} {lF} {lG} {rΠ} {lΠ = ⁰} {Γ} lF≤ lG≤ [Γ] [F] [H] [UG] [UE] [F]ₜ [G]ₜ [H]ₜ [E]ₜ [F≡H]ₜ [G≡E]ₜ {Δ} {σ} ⊢Δ [σ] = let l = ∞ [UF] = maybeEmbᵛ {A = Univ rF _} [Γ] (Uᵛ (proj₂ (levelBounded lF)) [Γ]) [ΠFG]ᵗ = Πᵗᵛ₁ {F} {G} {rF} {lF} {lG} {rΠ} {lΠ = ⁰} {Γ} lF≤ lG≤ [Γ] [F] (λ {Δ} {σ} → [UG] {Δ} {σ}) [F]ₜ [G]ₜ {Δ = Δ} {σ = σ} ⊢Δ [σ] [ΠHE]ᵗ = Πᵗᵛ₁ {H} {E} {rF} {lF} {lG} {rΠ} {lΠ = ⁰} {Γ} lF≤ lG≤ [Γ] [H] (λ {Δ} {σ} → [UE] {Δ} {σ}) [H]ₜ [E]ₜ {Δ = Δ} {σ = σ} ⊢Δ [σ] ⊢F = escape (proj₁ ([F] ⊢Δ [σ])) [liftσ] = liftSubstS {F = F} [Γ] ⊢Δ [F] [σ] univΔ = proj₁ ([UF] ⊢Δ [σ]) [Fₜ]σ {σ′} [σ′] = [F]ₜ {σ = σ′} ⊢Δ [σ′] [σF] = proj₁ ([Fₜ]σ [σ]) [G] = maybeEmbᵛ {A = G} (_∙_ {A = F} [Γ] [F]) (univᵛ {G} (_∙_ {A = F} [Γ] [F]) lG≤ (λ {Δ} {σ} → [UG] {Δ} {σ}) [G]ₜ) [E] = maybeEmbᵛ {A = E} (_∙_ {A = H} [Γ] [H]) (univᵛ {E} (_∙_ {A = H} [Γ] [H]) lG≤ (λ {Δ} {σ} → [UE] {Δ} {σ}) [E]ₜ) [F≡H] = univEqᵛ {F} {H} [Γ] [UF] [F] [F≡H]ₜ [G≡E] = univEqᵛ {G} {E} (_∙_ {A = F} [Γ] [F]) (λ {Δ} {σ} → [UG] {Δ} {σ}) [G] [G≡E]ₜ in Uₜ₌ [ΠFG]ᵗ [ΠHE]ᵗ (≅ₜ-Π-cong lF≤ lG≤ ⊢F (escapeTermEq univΔ ([F≡H]ₜ ⊢Δ [σ])) (escapeTermEq (proj₁ ([UG] (⊢Δ ∙ ⊢F) [liftσ])) ([G≡E]ₜ (⊢Δ ∙ ⊢F) [liftσ]))) λ {ρ} {Δ₁} [ρ] ⊢Δ₁ → let [ρσ] = wkSubstS [Γ] ⊢Δ ⊢Δ₁ [ρ] [σ] X = Π-congᵛ {F} {G} {H} {E} {Γ} {rF} {lF} {lG} {rΠ} {⁰} lF≤ lG≤ [Γ] [F] [G] [H] [E] [F≡H] [G≡E] ⊢Δ₁ [ρσ] in irrelevanceEq″ (PE.sym (wk-subst (Π F ^ rF ° lF ▹ G ° lG ° ⁰))) (PE.sym (wk-subst (Π H ^ rF ° lF ▹ E ° lG ° ⁰))) PE.refl PE.refl (proj₁ (Πᵛ {F} {G} lF≤ lG≤ [Γ] [F] [G] ⊢Δ₁ [ρσ])) (LogRel._⊩¹U_∷_^_/_.[t] [ΠFG]ᵗ [ρ] ⊢Δ₁) X -- Validity of non-dependent function types. ▹▹ᵛ : ∀ {F G rF lF lG rΠ lΠ Γ l} (lF< : lF ≤ lΠ) (lG< : lG ≤ lΠ) ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ]) → Γ ⊩ᵛ⟨ l ⟩ G ^ [ rΠ , ι lG ] / [Γ] → Γ ⊩ᵛ⟨ l ⟩ F ^ rF ° lF ▹▹ G ° lG ° lΠ ^ [ rΠ , ι lΠ ] / [Γ] ▹▹ᵛ {F} {G} lF< lG< [Γ] [F] [G] = Πᵛ {F} {wk1 G} lF< lG< [Γ] [F] (wk1ᵛ {G} {F} [Γ] [F] [G]) -- Validity of non-dependent function type congurence. ▹▹-congᵛ : ∀ {F F′ G G′ rF lF lG rΠ lΠ Γ l} (lF≤ : lF ≤ lΠ) (lG≤ : lG ≤ lΠ) ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ]) ([F′] : Γ ⊩ᵛ⟨ l ⟩ F′ ^ [ rF , ι lF ] / [Γ]) ([F≡F′] : Γ ⊩ᵛ⟨ l ⟩ F ≡ F′ ^ [ rF , ι lF ] / [Γ] / [F]) ([G] : Γ ⊩ᵛ⟨ l ⟩ G ^ [ rΠ , ι lG ] / [Γ]) ([G′] : Γ ⊩ᵛ⟨ l ⟩ G′ ^ [ rΠ , ι lG ] / [Γ]) ([G≡G′] : Γ ⊩ᵛ⟨ l ⟩ G ≡ G′ ^ [ rΠ , ι lG ] / [Γ] / [G]) → Γ ⊩ᵛ⟨ l ⟩ F ^ rF ° lF ▹▹ G ° lG ° lΠ ≡ F′ ^ rF ° lF ▹▹ G′ ° lG ° lΠ ^ [ rΠ , ι lΠ ] / [Γ] / ▹▹ᵛ {F} {G} lF≤ lG≤ [Γ] [F] [G] ▹▹-congᵛ {F} {F′} {G} {G′} lF< lG< [Γ] [F] [F′] [F≡F′] [G] [G′] [G≡G′] = Π-congᵛ {F} {wk1 G} {F′} {wk1 G′} lF< lG< [Γ] [F] (wk1ᵛ {G} {F} [Γ] [F] [G]) [F′] (wk1ᵛ {G′} {F′} [Γ] [F′] [G′]) [F≡F′] (wk1Eqᵛ {G} {G′} {F} [Γ] [F] [G] [G≡G′]) ▹▹ᵗᵛ : ∀ {F G rF lF lG rΠ lΠ Γ} (lF≤ : lF ≤ lΠ) (lG≤ : lG ≤ lΠ) ([Γ] : ⊩ᵛ Γ)→ let l = ∞ [UF] = maybeEmbᵛ {A = Univ rF _} [Γ] (Uᵛ (proj₂ (levelBounded lF)) [Γ]) [UΠ] = maybeEmbᵛ {A = Univ rΠ _} [Γ] (Uᵛ (proj₂ (levelBounded lΠ)) [Γ]) in ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ]) ([UG] : Γ ⊩ᵛ⟨ l ⟩ Univ rΠ lG ^ [ ! , next lG ] / [Γ]) → Γ ⊩ᵛ⟨ l ⟩ F ∷ Univ rF lF ^ [ ! , next lF ] / [Γ] / [UF] → Γ ⊩ᵛ⟨ l ⟩ G ∷ Univ rΠ lG ^ [ ! , next lG ] / [Γ] / (λ {Δ} {σ} → [UG] {Δ} {σ}) → Γ ⊩ᵛ⟨ l ⟩ F ^ rF ° lF ▹▹ G ° lG ° lΠ ∷ Univ rΠ lΠ ^ [ ! , next lΠ ] / [Γ] / [UΠ] ▹▹ᵗᵛ {F} {G} {rF} {lF} {lG} {rΠ} {lΠ} lF< lG< [Γ] [F] [UG] [Fₜ] [Gₜ] = let [UG]′ = maybeEmbᵛ {A = Univ rΠ _} [Γ] (Uᵛ (proj₂ (levelBounded lG)) [Γ]) [Gₜ]′ = wk1ᵗᵛ {F} {G} {[ rF , ι lF ]} {rΠ} {lG} [Γ] [F] (S.irrelevanceTerm {A = Univ _ _} {t = G} [Γ] [Γ] [UG] [UG]′ [Gₜ]) [wUG] = maybeEmbᵛ {A = Univ rΠ _} (_∙_ {A = F} [Γ] [F]) (λ {Δ} {σ} → Uᵛ (proj₂ (levelBounded lG)) (_∙_ {A = F} [Γ] [F]) {Δ} {σ}) [wUG]′ = wk1ᵛ {Univ _ _ } {F} [Γ] [F] [UG] in Πᵗᵛ {F} {wk1 G} lF< lG< [Γ] [F] (λ {Δ} {σ} → [wUG]′ {Δ} {σ}) [Fₜ] (S.irrelevanceTerm {A = Univ _ _} {t = wk1 G} (_∙_ {A = F} [Γ] [F]) (_∙_ {A = F} [Γ] [F]) (λ {Δ} {σ} → [wUG] {Δ} {σ}) (λ {Δ} {σ} → [wUG]′ {Δ} {σ}) [Gₜ]′)
75.194937
186
0.300653
1ee1475dc2e3885f09093d4ca7b6189f3bbf5140
462
agda
Agda
core/lib/types/Smash.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
core/lib/types/Smash.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
core/lib/types/Smash.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
1
2018-12-26T21:31:57.000Z
2018-12-26T21:31:57.000Z
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Cofiber open import lib.types.Sigma open import lib.types.Wedge module lib.types.Smash {i j} (X : Ptd i) (Y : Ptd j) where module ∨In× = WedgeRec {X = X} {Y = Y} (λ x → (x , pt Y)) (λ y → (pt X , y)) idp ∨-in-× = ∨In×.f ∨-⊙in-× : X ⊙∨ Y ⊙→ X ⊙× Y ∨-⊙in-× = (∨In×.f , idp) ⊙Smash : Ptd (lmax i j) ⊙Smash = ⊙Cofiber ∨-⊙in-× Smash = de⊙ ⊙Smash _∧_ = Smash _⊙∧_ = ⊙Smash
18.48
58
0.558442
9a0fd484e6058e3f6213c55224f5111028ee577b
212
agda
Agda
test/interaction/GiveSize.agda
larrytheliquid/agda
477c8c37f948e6038b773409358fd8f38395f827
[ "MIT" ]
1
2018-10-10T17:08:44.000Z
2018-10-10T17:08:44.000Z
test/interaction/GiveSize.agda
masondesu/agda
70c8a575c46f6a568c7518150a1a64fcd03aa437
[ "MIT" ]
null
null
null
test/interaction/GiveSize.agda
masondesu/agda
70c8a575c46f6a568c7518150a1a64fcd03aa437
[ "MIT" ]
1
2022-03-12T11:35:18.000Z
2022-03-12T11:35:18.000Z
-- {-# OPTIONS -v tc.meta:30 #-} {-# OPTIONS --sized-types #-} module GiveSize where postulate Size : Set postulate ∞ : Size {-# BUILTIN SIZE Size #-} -- {-# BUILTIN SIZEINF ∞ #-} id : Size → Size id i = {!i!}
17.666667
32
0.584906
06ddf6321e479a88c2e78f073d0cd886bee1e977
3,996
agda
Agda
agda-stdlib/src/Data/Nat/Base.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Data/Nat/Base.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Data/Nat/Base.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- Natural numbers, basic types and operations ------------------------------------------------------------------------ -- See README.Data.Nat for examples of how to use and reason about -- naturals. {-# OPTIONS --without-K --safe #-} module Data.Nat.Base where open import Level using (0ℓ) open import Relation.Binary open import Relation.Binary.Core open import Agda.Builtin.Equality open import Relation.Nullary using (¬_) ------------------------------------------------------------------------ -- The types open import Agda.Builtin.Nat public using (zero; suc) renaming (Nat to ℕ) ------------------------------------------------------------------------ -- Standard ordering relations open import Agda.Builtin.Nat public using () renaming (_==_ to _≡ᵇ_; _<_ to _<ᵇ_) infix 4 _≤_ _<_ _≥_ _>_ _≰_ _≮_ _≱_ _≯_ data _≤_ : Rel ℕ 0ℓ where z≤n : ∀ {n} → zero ≤ n s≤s : ∀ {m n} (m≤n : m ≤ n) → suc m ≤ suc n _<_ : Rel ℕ 0ℓ m < n = suc m ≤ n _≥_ : Rel ℕ 0ℓ m ≥ n = n ≤ m _>_ : Rel ℕ 0ℓ m > n = n < m _≰_ : Rel ℕ 0ℓ a ≰ b = ¬ a ≤ b _≮_ : Rel ℕ 0ℓ a ≮ b = ¬ a < b _≱_ : Rel ℕ 0ℓ a ≱ b = ¬ a ≥ b _≯_ : Rel ℕ 0ℓ a ≯ b = ¬ a > b ------------------------------------------------------------------------ -- Arithmetic open import Agda.Builtin.Nat public using (_+_; _*_) renaming (_-_ to _∸_) pred : ℕ → ℕ pred zero = zero pred (suc n) = n infixl 7 _⊓_ infixl 6 _+⋎_ _⊔_ -- Argument-swapping addition. Used by Data.Vec._⋎_. _+⋎_ : ℕ → ℕ → ℕ zero +⋎ n = n suc m +⋎ n = suc (n +⋎ m) -- Max. _⊔_ : ℕ → ℕ → ℕ zero ⊔ n = n suc m ⊔ zero = suc m suc m ⊔ suc n = suc (m ⊔ n) -- Min. _⊓_ : ℕ → ℕ → ℕ zero ⊓ n = zero suc m ⊓ zero = zero suc m ⊓ suc n = suc (m ⊓ n) -- Division by 2, rounded downwards. ⌊_/2⌋ : ℕ → ℕ ⌊ 0 /2⌋ = 0 ⌊ 1 /2⌋ = 0 ⌊ suc (suc n) /2⌋ = suc ⌊ n /2⌋ -- Division by 2, rounded upwards. ⌈_/2⌉ : ℕ → ℕ ⌈ n /2⌉ = ⌊ suc n /2⌋ -- Naïve exponentiation _^_ : ℕ → ℕ → ℕ x ^ zero = 1 x ^ suc n = x * x ^ n -- Distance ∣_-_∣ : ℕ → ℕ → ℕ ∣ zero - y ∣ = y ∣ x - zero ∣ = x ∣ suc x - suc y ∣ = ∣ x - y ∣ ------------------------------------------------------------------------ -- The following, alternative definition of _≤_ is more suitable for -- well-founded induction (see Induction.Nat). infix 4 _≤′_ _<′_ _≥′_ _>′_ data _≤′_ (m : ℕ) : ℕ → Set where ≤′-refl : m ≤′ m ≤′-step : ∀ {n} (m≤′n : m ≤′ n) → m ≤′ suc n _<′_ : Rel ℕ 0ℓ m <′ n = suc m ≤′ n _≥′_ : Rel ℕ 0ℓ m ≥′ n = n ≤′ m _>′_ : Rel ℕ 0ℓ m >′ n = n <′ m ------------------------------------------------------------------------ -- Another alternative definition of _≤_. record _≤″_ (m n : ℕ) : Set where constructor less-than-or-equal field {k} : ℕ proof : m + k ≡ n infix 4 _≤″_ _<″_ _≥″_ _>″_ _<″_ : Rel ℕ 0ℓ m <″ n = suc m ≤″ n _≥″_ : Rel ℕ 0ℓ m ≥″ n = n ≤″ m _>″_ : Rel ℕ 0ℓ m >″ n = n <″ m ------------------------------------------------------------------------ -- Useful for induction when you have an upper bound. data _≤‴_ : ℕ → ℕ → Set where ≤‴-refl : ∀{m} → m ≤‴ m ≤‴-step : ∀{m n} → suc m ≤‴ n → m ≤‴ n infix 4 _≤‴_ _<‴_ _≥‴_ _>‴_ _<‴_ : Rel ℕ 0ℓ m <‴ n = suc m ≤‴ n _≥‴_ : Rel ℕ 0ℓ m ≥‴ n = n ≤‴ m _>‴_ : Rel ℕ 0ℓ m >‴ n = n <‴ m ------------------------------------------------------------------------ -- A comparison view. Taken from "View from the left" -- (McBride/McKinna); details may differ. data Ordering : Rel ℕ 0ℓ where less : ∀ m k → Ordering m (suc (m + k)) equal : ∀ m → Ordering m m greater : ∀ m k → Ordering (suc (m + k)) m compare : ∀ m n → Ordering m n compare zero zero = equal zero compare (suc m) zero = greater zero m compare zero (suc n) = less zero n compare (suc m) (suc n) with compare m n ... | less m k = less (suc m) k ... | equal m = equal (suc m) ... | greater n k = greater (suc n) k
20.921466
72
0.444695
03f778c25227b2704c20d7240576f207fc049d22
182
agda
Agda
test/Succeed/Issue1614a.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue1614a.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue1614a.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- New NO_POSITIVITY_CHECK pragma for data definitions and mutual -- blocks -- Skipping a single data definition. {-# NO_POSITIVITY_CHECK #-} data D : Set where lam : (D → D) → D
22.75
65
0.703297
1ec8f02d230f320306ad828c4785110dfc2c0f9b
331
agda
Agda
Cats/Category/Constructions/Epi.agda
alessio-b-zak/cats
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
[ "MIT" ]
null
null
null
Cats/Category/Constructions/Epi.agda
alessio-b-zak/cats
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
[ "MIT" ]
null
null
null
Cats/Category/Constructions/Epi.agda
alessio-b-zak/cats
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
[ "MIT" ]
null
null
null
module Cats.Category.Constructions.Epi where open import Level open import Cats.Category.Base module Build {lo la l≈} (Cat : Category lo la l≈) where private open module Cat = Category Cat open Cat.≈-Reasoning IsEpi : ∀ {A B} → A ⇒ B → Set (lo ⊔ la ⊔ l≈) IsEpi {A} {B} f = ∀ {C} {g h : B ⇒ C} → g ∘ f ≈ h ∘ f → g ≈ h
22.066667
63
0.60423
5e724e710a4b9e274a425f4d8b2dba8bae3bba01
12,149
agda
Agda
agda-stdlib/src/Reflection/Term.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Reflection/Term.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Reflection/Term.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- Terms used in the reflection machinery ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Reflection.Term where open import Data.List.Base hiding (_++_) import Data.List.Properties as Lₚ open import Data.Nat as ℕ using (ℕ; zero; suc) open import Data.Product open import Data.Maybe.Base using (Maybe; just; nothing) open import Reflection.Abstraction open import Reflection.Argument open import Reflection.Argument.Information using (visibility) import Reflection.Argument.Visibility as Visibility; open Visibility.Visibility import Reflection.Literal as Literal import Reflection.Meta as Meta open import Reflection.Name as Name using (Name) import Reflection.Pattern as Pattern open import Relation.Nullary open import Relation.Nullary.Product using (_×-dec_) open import Relation.Nullary.Decidable as Dec open import Relation.Binary open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------ -- Re-exporting the builtin type and constructors open import Agda.Builtin.Reflection as Builtin public using (Sort; Type; Term; Clause) open Sort public open Term public renaming (agda-sort to sort) open Clause public ------------------------------------------------------------------------ -- Handy synonyms Clauses : Set Clauses = List Clause -- Pattern synonyms for more compact presentation pattern vLam s t = lam visible (abs s t) pattern hLam s t = lam hidden (abs s t) pattern iLam s t = lam instance′ (abs s t) pattern Π[_∶_]_ s a ty = pi a (abs s ty) pattern vΠ[_∶_]_ s a ty = Π[ s ∶ (vArg a) ] ty pattern hΠ[_∶_]_ s a ty = Π[ s ∶ (hArg a) ] ty pattern iΠ[_∶_]_ s a ty = Π[ s ∶ (iArg a) ] ty ---------------------------------------------------------------------- -- Utility functions getName : Term → Maybe Name getName (con c args) = just c getName (def f args) = just f getName _ = nothing -- "n ⋯⟅∷⟆ xs" prepends "n" visible unknown arguments to the list of -- arguments. Useful when constructing the list of arguments for a -- function with initial inferable arguments. infixr 5 _⋯⟨∷⟩_ _⋯⟨∷⟩_ : ℕ → Args Term → Args Term zero ⋯⟨∷⟩ xs = xs suc i ⋯⟨∷⟩ xs = unknown ⟨∷⟩ (i ⋯⟨∷⟩ xs) {-# INLINE _⋯⟨∷⟩_ #-} -- "n ⋯⟅∷⟆ xs" prepends "n" hidden unknown arguments to the list of -- arguments. Useful when constructing the list of arguments for a -- function with initial implicit arguments. infixr 5 _⋯⟅∷⟆_ _⋯⟅∷⟆_ : ℕ → Args Term → Args Term zero ⋯⟅∷⟆ xs = xs suc i ⋯⟅∷⟆ xs = unknown ⟅∷⟆ (i ⋯⟅∷⟆ xs) {-# INLINE _⋯⟅∷⟆_ #-} ------------------------------------------------------------------------ -- Decidable equality clause-injective₁ : ∀ {ps ps′ b b′} → clause ps b ≡ clause ps′ b′ → ps ≡ ps′ clause-injective₁ refl = refl clause-injective₂ : ∀ {ps ps′ b b′} → clause ps b ≡ clause ps′ b′ → b ≡ b′ clause-injective₂ refl = refl clause-injective : ∀ {ps ps′ b b′} → clause ps b ≡ clause ps′ b′ → ps ≡ ps′ × b ≡ b′ clause-injective = < clause-injective₁ , clause-injective₂ > absurd-clause-injective : ∀ {ps ps′} → absurd-clause ps ≡ absurd-clause ps′ → ps ≡ ps′ absurd-clause-injective refl = refl infix 4 _≟-AbsTerm_ _≟-AbsType_ _≟-ArgTerm_ _≟-ArgType_ _≟-Args_ _≟-Clause_ _≟-Clauses_ _≟_ _≟-Sort_ _≟-AbsTerm_ : DecidableEquality (Abs Term) _≟-AbsType_ : DecidableEquality (Abs Type) _≟-ArgTerm_ : DecidableEquality (Arg Term) _≟-ArgType_ : DecidableEquality (Arg Type) _≟-Args_ : DecidableEquality (Args Term) _≟-Clause_ : DecidableEquality Clause _≟-Clauses_ : DecidableEquality Clauses _≟_ : DecidableEquality Term _≟-Sort_ : DecidableEquality Sort -- Decidable equality 'transformers' -- We need to inline these because the terms are not sized so termination -- would not obvious if we were to use higher-order functions such as -- Data.List.Properties' ≡-dec abs s a ≟-AbsTerm abs s′ a′ = unAbs-dec (a ≟ a′) abs s a ≟-AbsType abs s′ a′ = unAbs-dec (a ≟ a′) arg i a ≟-ArgTerm arg i′ a′ = unArg-dec (a ≟ a′) arg i a ≟-ArgType arg i′ a′ = unArg-dec (a ≟ a′) [] ≟-Args [] = yes refl (x ∷ xs) ≟-Args (y ∷ ys) = Lₚ.∷-dec (x ≟-ArgTerm y) (xs ≟-Args ys) [] ≟-Args (_ ∷ _) = no λ() (_ ∷ _) ≟-Args [] = no λ() [] ≟-Clauses [] = yes refl (x ∷ xs) ≟-Clauses (y ∷ ys) = Lₚ.∷-dec (x ≟-Clause y) (xs ≟-Clauses ys) [] ≟-Clauses (_ ∷ _) = no λ() (_ ∷ _) ≟-Clauses [] = no λ() clause ps b ≟-Clause clause ps′ b′ = Dec.map′ (uncurry (cong₂ clause)) clause-injective (ps Pattern.≟s ps′ ×-dec b ≟ b′) absurd-clause ps ≟-Clause absurd-clause ps′ = Dec.map′ (cong absurd-clause) absurd-clause-injective (ps Pattern.≟s ps′) clause _ _ ≟-Clause absurd-clause _ = no λ() absurd-clause _ ≟-Clause clause _ _ = no λ() var-injective₁ : ∀ {x x′ args args′} → var x args ≡ var x′ args′ → x ≡ x′ var-injective₁ refl = refl var-injective₂ : ∀ {x x′ args args′} → var x args ≡ var x′ args′ → args ≡ args′ var-injective₂ refl = refl var-injective : ∀ {x x′ args args′} → var x args ≡ var x′ args′ → x ≡ x′ × args ≡ args′ var-injective = < var-injective₁ , var-injective₂ > con-injective₁ : ∀ {c c′ args args′} → con c args ≡ con c′ args′ → c ≡ c′ con-injective₁ refl = refl con-injective₂ : ∀ {c c′ args args′} → con c args ≡ con c′ args′ → args ≡ args′ con-injective₂ refl = refl con-injective : ∀ {c c′ args args′} → con c args ≡ con c′ args′ → c ≡ c′ × args ≡ args′ con-injective = < con-injective₁ , con-injective₂ > def-injective₁ : ∀ {f f′ args args′} → def f args ≡ def f′ args′ → f ≡ f′ def-injective₁ refl = refl def-injective₂ : ∀ {f f′ args args′} → def f args ≡ def f′ args′ → args ≡ args′ def-injective₂ refl = refl def-injective : ∀ {f f′ args args′} → def f args ≡ def f′ args′ → f ≡ f′ × args ≡ args′ def-injective = < def-injective₁ , def-injective₂ > meta-injective₁ : ∀ {x x′ args args′} → meta x args ≡ meta x′ args′ → x ≡ x′ meta-injective₁ refl = refl meta-injective₂ : ∀ {x x′ args args′} → meta x args ≡ meta x′ args′ → args ≡ args′ meta-injective₂ refl = refl meta-injective : ∀ {x x′ args args′} → meta x args ≡ meta x′ args′ → x ≡ x′ × args ≡ args′ meta-injective = < meta-injective₁ , meta-injective₂ > lam-injective₁ : ∀ {v v′ t t′} → lam v t ≡ lam v′ t′ → v ≡ v′ lam-injective₁ refl = refl lam-injective₂ : ∀ {v v′ t t′} → lam v t ≡ lam v′ t′ → t ≡ t′ lam-injective₂ refl = refl lam-injective : ∀ {v v′ t t′} → lam v t ≡ lam v′ t′ → v ≡ v′ × t ≡ t′ lam-injective = < lam-injective₁ , lam-injective₂ > pat-lam-injective₁ : ∀ {cs cs′ args args′} → pat-lam cs args ≡ pat-lam cs′ args′ → cs ≡ cs′ pat-lam-injective₁ refl = refl pat-lam-injective₂ : ∀ {cs cs′ args args′} → pat-lam cs args ≡ pat-lam cs′ args′ → args ≡ args′ pat-lam-injective₂ refl = refl pat-lam-injective : ∀ {cs cs′ args args′} → pat-lam cs args ≡ pat-lam cs′ args′ → cs ≡ cs′ × args ≡ args′ pat-lam-injective = < pat-lam-injective₁ , pat-lam-injective₂ > pi-injective₁ : ∀ {t₁ t₁′ t₂ t₂′} → pi t₁ t₂ ≡ pi t₁′ t₂′ → t₁ ≡ t₁′ pi-injective₁ refl = refl pi-injective₂ : ∀ {t₁ t₁′ t₂ t₂′} → pi t₁ t₂ ≡ pi t₁′ t₂′ → t₂ ≡ t₂′ pi-injective₂ refl = refl pi-injective : ∀ {t₁ t₁′ t₂ t₂′} → pi t₁ t₂ ≡ pi t₁′ t₂′ → t₁ ≡ t₁′ × t₂ ≡ t₂′ pi-injective = < pi-injective₁ , pi-injective₂ > sort-injective : ∀ {x y} → sort x ≡ sort y → x ≡ y sort-injective refl = refl lit-injective : ∀ {x y} → lit x ≡ lit y → x ≡ y lit-injective refl = refl set-injective : ∀ {x y} → set x ≡ set y → x ≡ y set-injective refl = refl slit-injective : ∀ {x y} → Sort.lit x ≡ lit y → x ≡ y slit-injective refl = refl var x args ≟ var x′ args′ = Dec.map′ (uncurry (cong₂ var)) var-injective (x ℕ.≟ x′ ×-dec args ≟-Args args′) con c args ≟ con c′ args′ = Dec.map′ (uncurry (cong₂ con)) con-injective (c Name.≟ c′ ×-dec args ≟-Args args′) def f args ≟ def f′ args′ = Dec.map′ (uncurry (cong₂ def)) def-injective (f Name.≟ f′ ×-dec args ≟-Args args′) meta x args ≟ meta x′ args′ = Dec.map′ (uncurry (cong₂ meta)) meta-injective (x Meta.≟ x′ ×-dec args ≟-Args args′) lam v t ≟ lam v′ t′ = Dec.map′ (uncurry (cong₂ lam)) lam-injective (v Visibility.≟ v′ ×-dec t ≟-AbsTerm t′) pat-lam cs args ≟ pat-lam cs′ args′ = Dec.map′ (uncurry (cong₂ pat-lam)) pat-lam-injective (cs ≟-Clauses cs′ ×-dec args ≟-Args args′) pi t₁ t₂ ≟ pi t₁′ t₂′ = Dec.map′ (uncurry (cong₂ pi)) pi-injective (t₁ ≟-ArgType t₁′ ×-dec t₂ ≟-AbsType t₂′) sort s ≟ sort s′ = Dec.map′ (cong sort) sort-injective (s ≟-Sort s′) lit l ≟ lit l′ = Dec.map′ (cong lit) lit-injective (l Literal.≟ l′) unknown ≟ unknown = yes refl var x args ≟ con c args′ = no λ() var x args ≟ def f args′ = no λ() var x args ≟ lam v t = no λ() var x args ≟ pi t₁ t₂ = no λ() var x args ≟ sort _ = no λ() var x args ≟ lit _ = no λ() var x args ≟ meta _ _ = no λ() var x args ≟ unknown = no λ() con c args ≟ var x args′ = no λ() con c args ≟ def f args′ = no λ() con c args ≟ lam v t = no λ() con c args ≟ pi t₁ t₂ = no λ() con c args ≟ sort _ = no λ() con c args ≟ lit _ = no λ() con c args ≟ meta _ _ = no λ() con c args ≟ unknown = no λ() def f args ≟ var x args′ = no λ() def f args ≟ con c args′ = no λ() def f args ≟ lam v t = no λ() def f args ≟ pi t₁ t₂ = no λ() def f args ≟ sort _ = no λ() def f args ≟ lit _ = no λ() def f args ≟ meta _ _ = no λ() def f args ≟ unknown = no λ() lam v t ≟ var x args = no λ() lam v t ≟ con c args = no λ() lam v t ≟ def f args = no λ() lam v t ≟ pi t₁ t₂ = no λ() lam v t ≟ sort _ = no λ() lam v t ≟ lit _ = no λ() lam v t ≟ meta _ _ = no λ() lam v t ≟ unknown = no λ() pi t₁ t₂ ≟ var x args = no λ() pi t₁ t₂ ≟ con c args = no λ() pi t₁ t₂ ≟ def f args = no λ() pi t₁ t₂ ≟ lam v t = no λ() pi t₁ t₂ ≟ sort _ = no λ() pi t₁ t₂ ≟ lit _ = no λ() pi t₁ t₂ ≟ meta _ _ = no λ() pi t₁ t₂ ≟ unknown = no λ() sort _ ≟ var x args = no λ() sort _ ≟ con c args = no λ() sort _ ≟ def f args = no λ() sort _ ≟ lam v t = no λ() sort _ ≟ pi t₁ t₂ = no λ() sort _ ≟ lit _ = no λ() sort _ ≟ meta _ _ = no λ() sort _ ≟ unknown = no λ() lit _ ≟ var x args = no λ() lit _ ≟ con c args = no λ() lit _ ≟ def f args = no λ() lit _ ≟ lam v t = no λ() lit _ ≟ pi t₁ t₂ = no λ() lit _ ≟ sort _ = no λ() lit _ ≟ meta _ _ = no λ() lit _ ≟ unknown = no λ() meta _ _ ≟ var x args = no λ() meta _ _ ≟ con c args = no λ() meta _ _ ≟ def f args = no λ() meta _ _ ≟ lam v t = no λ() meta _ _ ≟ pi t₁ t₂ = no λ() meta _ _ ≟ sort _ = no λ() meta _ _ ≟ lit _ = no λ() meta _ _ ≟ unknown = no λ() unknown ≟ var x args = no λ() unknown ≟ con c args = no λ() unknown ≟ def f args = no λ() unknown ≟ lam v t = no λ() unknown ≟ pi t₁ t₂ = no λ() unknown ≟ sort _ = no λ() unknown ≟ lit _ = no λ() unknown ≟ meta _ _ = no λ() pat-lam _ _ ≟ var x args = no λ() pat-lam _ _ ≟ con c args = no λ() pat-lam _ _ ≟ def f args = no λ() pat-lam _ _ ≟ lam v t = no λ() pat-lam _ _ ≟ pi t₁ t₂ = no λ() pat-lam _ _ ≟ sort _ = no λ() pat-lam _ _ ≟ lit _ = no λ() pat-lam _ _ ≟ meta _ _ = no λ() pat-lam _ _ ≟ unknown = no λ() var x args ≟ pat-lam _ _ = no λ() con c args ≟ pat-lam _ _ = no λ() def f args ≟ pat-lam _ _ = no λ() lam v t ≟ pat-lam _ _ = no λ() pi t₁ t₂ ≟ pat-lam _ _ = no λ() sort _ ≟ pat-lam _ _ = no λ() lit _ ≟ pat-lam _ _ = no λ() meta _ _ ≟ pat-lam _ _ = no λ() unknown ≟ pat-lam _ _ = no λ() set t ≟-Sort set t′ = Dec.map′ (cong set) set-injective (t ≟ t′) lit n ≟-Sort lit n′ = Dec.map′ (cong lit) slit-injective (n ℕ.≟ n′) unknown ≟-Sort unknown = yes refl set _ ≟-Sort lit _ = no λ() set _ ≟-Sort unknown = no λ() lit _ ≟-Sort set _ = no λ() lit _ ≟-Sort unknown = no λ() unknown ≟-Sort set _ = no λ() unknown ≟-Sort lit _ = no λ()
36.593373
105
0.570088
1c3260ba57cb4256532dcd6fbd8b2d5d24d55e2b
229
agda
Agda
test/Succeed/RelevanceSubtyping.agda
vlopezj/agda
ff4d89e75970cf27599fb9f572bd43c9455cbb56
[ "BSD-3-Clause" ]
3
2015-03-28T14:51:03.000Z
2015-12-07T20:14:00.000Z
test/Succeed/RelevanceSubtyping.agda
vikfret/agda
49ad0b3f0d39c01bc35123478b857e702b29fb9d
[ "BSD-3-Clause" ]
3
2018-11-14T15:31:44.000Z
2019-04-01T19:39:26.000Z
test/Succeed/RelevanceSubtyping.agda
vikfret/agda
49ad0b3f0d39c01bc35123478b857e702b29fb9d
[ "BSD-3-Clause" ]
1
2019-03-05T20:02:38.000Z
2019-03-05T20:02:38.000Z
-- Andreas, 2012-09-13 module RelevanceSubtyping where -- this naturally type-checks: one : {A B : Set} → (.A → B) → A → B one f x = f x -- this type-checks because of subtyping one' : {A B : Set} → (.A → B) → A → B one' f = f
20.818182
40
0.58952
1e1d3ac31ffed8cfe39f198c7bfbb81363dc8ba2
2,678
agda
Agda
agda/MorePropAlgebra/Properties/Group.agda
mchristianl/synthetic-reals
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
[ "MIT" ]
3
2020-07-31T18:15:26.000Z
2022-02-19T12:15:21.000Z
agda/MorePropAlgebra/Properties/Group.agda
mchristianl/synthetic-reals
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
[ "MIT" ]
null
null
null
agda/MorePropAlgebra/Properties/Group.agda
mchristianl/synthetic-reals
10206b5c3eaef99ece5d18bf703c9e8b2371bde4
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --no-import-sorts #-} open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Function.Base using (_∋_) import Cubical.Algebra.Group as Std -- import Cubical.Structures.Group.Properties open import MorePropAlgebra.Bundles module MorePropAlgebra.Properties.Group {ℓ} (assumptions : Group {ℓ}) where open Group assumptions renaming (Carrier to G) import MorePropAlgebra.Properties.Monoid module Monoid'Properties = MorePropAlgebra.Properties.Monoid (record { Group assumptions }) -- how does this even work without renaming? module Monoid' = Monoid (record { Group assumptions }) ( Monoid') = Monoid ∋ (record { Group assumptions }) stdIsGroup : Std.IsGroup 0g _+_ (-_) stdIsGroup .Std.IsGroup.isMonoid = Monoid'Properties.stdIsMonoid stdIsGroup .Std.IsGroup.inverse = is-inverse stdGroup : Std.Group {ℓ} stdGroup = record { Group assumptions ; isGroup = stdIsGroup } module GroupLemmas' = Std.GroupLemmas stdGroup -- module GroupLemmas (G : Group {ℓ}) where -- open Group G public -- abstract -- simplL : (a : Carrier) {b c : Carrier} → a + b ≡ a + c → b ≡ c -- simplR : {a b : Carrier} (c : Carrier) → a + c ≡ b + c → a ≡ b -- invInvo : (a : Carrier) → - (- a) ≡ a -- invId : - 0g ≡ 0g -- idUniqueL : {e : Carrier} (x : Carrier) → e + x ≡ x → e ≡ 0g -- idUniqueR : (x : Carrier) {e : Carrier} → x + e ≡ x → e ≡ 0g -- invUniqueL : {g h : Carrier} → g + h ≡ 0g → g ≡ - h -- invUniqueR : {g h : Carrier} → g + h ≡ 0g → h ≡ - g -- invDistr : (a b : Carrier) → - (a + b) ≡ - b - a -- private -- simplR = GroupLemmas.simplR G abstract invUniqueL : {g h : G} → g + h ≡ 0g → g ≡ - h invUniqueL {g} {h} p = GroupLemmas'.simplR h (p ∙ sym (is-invl h)) -- ported from `Algebra.Properties.Group` private right-helper : ∀ x y → y ≡ - x + (x + y) right-helper x y = ( y ≡⟨ sym (snd (is-identity y)) ⟩ 0g + y ≡⟨ cong₂ _+_ (sym (snd (is-inverse x))) refl ⟩ ((- x) + x) + y ≡⟨ sym (is-assoc (- x) x y) ⟩ (- x) + (x + y) ∎) -- alternative: -- follows from uniqueness of - -- (a + -a) ≡ 0 -- ∃! b . a + b = 0 -- show that a is an additive inverse of - a then it must be THE additive inverse of - a and has to be called - - a which is a by uniqueness -involutive : ∀ x → - - x ≡ x -involutive x = ( (- (- x)) ≡⟨ sym (fst (is-identity _)) ⟩ (- (- x)) + 0g ≡⟨ cong₂ _+_ refl (sym (snd (is-inverse _))) ⟩ (- (- x)) + (- x + x) ≡⟨ sym (right-helper (- x) x) ⟩ x ∎)
39.970149
144
0.558999
9a2b124bed86aa312bef0696f2fd8ec2629d76fc
380
agda
Agda
test/Succeed/Issue2858-EvenOdd.agda
AntoineAllioux/agda
68ec2312961776e415c99d2839e41a92ffe464db
[ "BSD-3-Clause" ]
null
null
null
test/Succeed/Issue2858-EvenOdd.agda
AntoineAllioux/agda
68ec2312961776e415c99d2839e41a92ffe464db
[ "BSD-3-Clause" ]
null
null
null
test/Succeed/Issue2858-EvenOdd.agda
AntoineAllioux/agda
68ec2312961776e415c99d2839e41a92ffe464db
[ "BSD-3-Clause" ]
null
null
null
data Nat : Set where zero : Nat suc : Nat → Nat interleaved mutual data Even : Nat → Set data Odd : Nat → Set -- base cases: 0 is Even, 1 is Odd constructor even-zero : Even zero odd-one : Odd (suc zero) -- step case: suc switches the even/odd-ness constructor even-suc : ∀ {n} → Odd n → Even (suc n) odd-suc : ∀ {n} → Even n → Odd (suc n)
20
46
0.586842
2fd98ceb26bf6e6b2dfda1d170f82e441792b2a7
537
agda
Agda
test/fail/SizedTypesScopeExtrusion.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
1
2019-11-27T07:26:06.000Z
2019-11-27T07:26:06.000Z
test/fail/SizedTypesScopeExtrusion.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
test/fail/SizedTypesScopeExtrusion.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
1
2022-03-12T11:35:18.000Z
2022-03-12T11:35:18.000Z
{-# OPTIONS --sized-types #-} module SizedTypesScopeExtrusion where postulate Size : Set _^ : Size -> Size ∞ : Size {-# BUILTIN SIZE Size #-} {-# BUILTIN SIZESUC _^ #-} {-# BUILTIN SIZEINF ∞ #-} data Nat : {size : Size} -> Set where zero : {size : Size} -> Nat {size ^} suc : {size : Size} -> Nat {size} -> Nat {size ^} data Empty : Set where data Unit : Set where unit : Unit Zero : (i : Size) -> Nat {i} -> Set Zero ._ zero = Unit Zero ._ (suc _) = Empty bla : Set bla = (x : Nat) -> (i : Size) -> Zero i x
18.517241
52
0.558659
a054bd4333c22e7d1f46c0eec9eadcbe4373bad5
4,503
agda
Agda
src/cpnd1/nodcap/NF/Expand.agda
wenkokke/nodcap
fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2
[ "MIT" ]
4
2018-09-05T08:58:11.000Z
2019-09-24T20:16:35.000Z
src/cpnd1/nodcap/NF/Expand.agda
pepijnkokke/nodcap
fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2
[ "MIT" ]
null
null
null
src/cpnd1/nodcap/NF/Expand.agda
pepijnkokke/nodcap
fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2
[ "MIT" ]
1
2018-09-05T08:58:13.000Z
2018-09-05T08:58:13.000Z
open import Algebra open import Data.Nat as ℕ using (ℕ; suc; zero) open import Data.Pos as ℕ⁺ open import Data.List as L using (List; []; _∷_; _++_) open import Data.List.Any as LA using (Any; here; there) open import Data.List.Any.BagAndSetEquality as B open import Data.Product as PR using (∃; _×_; _,_; proj₁; proj₂) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Function using (_$_; flip) open import Function.Equality using (_⟨$⟩_) open import Function.Inverse as I using () open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_) open import Data.Environment open import nodcap.Base open import nodcap.NF.Typing module nodcap.NF.Expand where open I.Inverse using (to; from) private module ++ {a} {A : Set a} = Monoid (L.monoid A) {-# TERMINATING #-} -- Lemma: -- We can expand an instance of ?[ n ] A into n repetitions of A, -- by induction on n. -- -- Problematic calls: -- * in the recursive call under cont, the index n is split as -- n₁ + n₂, for which we have n₁, n₂ < n, but not definitionally. mutual expand : {Γ : Environment} {A : Type} {n : ℕ⁺} → ⊢ⁿᶠ ?[ n ] A ∷ Γ → -------------------- ⊢ⁿᶠ replicate⁺ n A ++ Γ expand (mk?₁ x) = x expand (cont {Γ} {A} {m} {n} x) = P.subst (λ Δ → ⊢ⁿᶠ Δ ++ Γ) (replicate⁺-++-commute m n) $ P.subst ⊢ⁿᶠ_ (P.sym (++.assoc (replicate⁺ m A) (replicate⁺ n A) Γ)) $ exch (swp [] (replicate⁺ m A) (replicate⁺ n A)) $ expand {n = n} $ exch (fwd [] (replicate⁺ m A)) $ expand {n = m} x expand {Γ} {A} {n} (exch b x) = exch (B.++-cong {xs₁ = replicate⁺ n A} I.id (del-from b (here P.refl))) $ expandIn (from b ⟨$⟩ here P.refl) x expandIn : {Γ : Environment} {A : Type} {n : ℕ⁺} (i : ?[ n ] A ∈ Γ) → ⊢ⁿᶠ Γ → ---------------------------- ⊢ⁿᶠ replicate⁺ n A ++ Γ - i expandIn (here P.refl) x = expand x expandIn {_} {A} {n} (there i) (send {Γ} {Δ} x h) with split Γ i ... | inj₁ (j , p) rewrite p = exch (swp [] (replicate⁺ n A) (_ ∷ [])) $ P.subst ⊢ⁿᶠ_ (++.assoc (_ ∷ replicate⁺ n A) (Γ - j) Δ) $ flip send h $ exch (swp [] (_ ∷ []) (replicate⁺ n A)) $ expandIn (there j) x ... | inj₂ (j , p) rewrite p = exch (swp [] (replicate⁺ n A) (_ ∷ Γ)) $ send x $ exch (swp [] (_ ∷ []) (replicate⁺ n A)) $ expandIn (there j) h expandIn {Γ} {A} {n} (there i) (recv x) = exch (swp [] (replicate⁺ n A) (_ ∷ [])) $ recv $ exch (swp [] (_ ∷ _ ∷ []) (replicate⁺ n A)) $ expandIn (there (there i)) x expandIn {Γ} {A} {n} (there i) (sel₁ x) = exch (swp [] (replicate⁺ n A) (_ ∷ [])) $ sel₁ $ exch (swp [] (_ ∷ []) (replicate⁺ n A)) $ expandIn (there i) x expandIn {Γ} {A} {n} (there i) (sel₂ x) = exch (swp [] (replicate⁺ n A) (_ ∷ [])) $ sel₂ $ exch (swp [] (_ ∷ []) (replicate⁺ n A)) $ expandIn (there i) x expandIn {Γ} {A} {n} (there i) (case x h) = exch (swp [] (replicate⁺ n A) (_ ∷ [])) $ case ( exch (swp [] (_ ∷ []) (replicate⁺ n A)) $ expandIn (there i) x ) ( exch (swp [] (_ ∷ []) (replicate⁺ n A)) $ expandIn (there i) h ) expandIn (there ()) halt expandIn {Γ} {A} {n} (there i) (wait x) = exch (swp [] (replicate⁺ n A) (_ ∷ [])) $ wait $ expandIn i x expandIn {Γ} {A} {n} (there i) loop = exch (swp [] (replicate⁺ n A) (_ ∷ [])) $ loop expandIn {Γ} {A} {n} (there i) (mk?₁ x) = exch (swp [] (replicate⁺ n A) (_ ∷ [])) $ mk?₁ $ exch (swp [] (_ ∷ []) (replicate⁺ n A)) $ expandIn (there i) x expandIn {Γ} {A} {n} (there i) (mk!₁ x) = exch (swp [] (replicate⁺ n A) (_ ∷ [])) $ mk!₁ $ exch (swp [] (_ ∷ []) (replicate⁺ n A)) $ expandIn (there i) x expandIn {Γ} {A} {n} (there i) (cont x) = exch (swp [] (replicate⁺ n A) (_ ∷ [])) $ cont $ exch (swp [] (_ ∷ _ ∷ []) (replicate⁺ n A)) $ expandIn (there (there i)) x expandIn {_} {A} {n} (there i) (pool {Γ} {Δ} x y) with split Γ i ... | inj₁ (j , p) rewrite p = exch (swp [] (replicate⁺ n A) (_ ∷ [])) $ P.subst ⊢ⁿᶠ_ (++.assoc (_ ∷ replicate⁺ n A) (Γ - j) Δ) $ flip pool y $ exch (swp [] (_ ∷ []) (replicate⁺ n A)) $ expandIn (there j) x ... | inj₂ (j , p) rewrite p = exch (swp [] (replicate⁺ n A) (_ ∷ Γ)) $ pool x $ exch (swp [] (_ ∷ []) (replicate⁺ n A)) $ expandIn (there j) y expandIn {Γ} {A} {n} i (exch b x) = exch (B.++-cong {xs₁ = replicate⁺ n A} I.id (del-from b i)) $ expandIn (from b ⟨$⟩ i) x
34.374046
77
0.514546
5edc0a66c5ba822281f697fd6402be082df1b71f
30
agda
Agda
Categories/Coend.agda
copumpkin/categories
36f4181d751e2ecb54db219911d8c69afe8ba892
[ "BSD-3-Clause" ]
98
2015-04-15T14:57:33.000Z
2022-03-08T05:20:36.000Z
Categories/Coend.agda
p-pavel/categories
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
[ "BSD-3-Clause" ]
19
2015-05-23T06:47:10.000Z
2019-08-09T16:31:40.000Z
Categories/Coend.agda
p-pavel/categories
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
[ "BSD-3-Clause" ]
23
2015-02-05T13:03:09.000Z
2021-11-11T13:50:56.000Z
module Categories.Coend where
15
29
0.866667
30418ea41bee20539c7224c7a02fd09af25adfb9
686
agda
Agda
test/succeed/TestQuote.agda
larrytheliquid/agda
477c8c37f948e6038b773409358fd8f38395f827
[ "MIT" ]
1
2018-10-10T17:08:44.000Z
2018-10-10T17:08:44.000Z
test/succeed/TestQuote.agda
masondesu/agda
70c8a575c46f6a568c7518150a1a64fcd03aa437
[ "MIT" ]
null
null
null
test/succeed/TestQuote.agda
masondesu/agda
70c8a575c46f6a568c7518150a1a64fcd03aa437
[ "MIT" ]
1
2022-03-12T11:35:18.000Z
2022-03-12T11:35:18.000Z
module TestQuote where {- test of reflection, implementing a trivial prover. -} open import Common.Reflect open import Common.Prelude open import Common.Level _==_ : Term → Term → Bool def x [] == def y [] = primQNameEquality x y _ == _ = false data Thm : Set where triv : Thm `Thm = def (quote Thm) [] ⟦_⟧ : Term → Set ⟦ goal ⟧ with goal == `Thm ... | true = Thm ... | false = ⊥ Hyp : Term → Set → Set Hyp goal A with goal == `Thm ... | true = ⊤ ... | false = A solve : (goal : Term) → Hyp goal ⟦ goal ⟧ → ⟦ goal ⟧ solve goal h with goal == `Thm ... | true = triv ... | false = h test₁ : Thm test₁ = quoteGoal t in solve t _
19.6
56
0.561224
586c4247a18256a57e9997f155cde8d104165842
547
agda
Agda
src/decidable.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
20
2015-06-12T12:20:17.000Z
2022-02-01T11:25:54.000Z
src/decidable.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T14:32:16.000Z
2016-10-26T11:57:26.000Z
src/decidable.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T12:17:00.000Z
2019-05-04T19:31:00.000Z
{-# OPTIONS --without-K #-} module decidable where open import level open import sets.empty using (⊥; ¬_) open import sets.unit using (⊤; tt) -- Decidable relations. data Dec {i} (P : Set i) : Set i where yes : ( p : P) → Dec P no : (¬p : ¬ P) → Dec P True : ∀ {i}{P : Set i} → Dec P → Set lzero True (yes _) = ⊤ True (no _) = ⊥ witness : ∀ {i}{P : Set i}{d : Dec P} → True d → P witness {d = yes x} _ = x witness {d = no _} () decide : ∀ {i} {P : Set i} {d : Dec P} → P → True d decide {d = yes p} = λ _ → tt decide {d = no f} = f
21.038462
51
0.533821
5e420a29792ec0331859067a10e9a087f5ff6055
8,466
agda
Agda
archive/agda-2/Oscar/Data/Term/internal/SubstituteAndSubstitution1.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
archive/agda-2/Oscar/Data/Term/internal/SubstituteAndSubstitution1.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
1
2019-04-29T00:35:04.000Z
2019-05-11T23:33:04.000Z
archive/agda-2/Oscar/Data/Term/internal/SubstituteAndSubstitution1.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
module Oscar.Data.Term.internal.SubstituteAndSubstitution1 {𝔣} (FunctionName : Set 𝔣) where open import Oscar.Data.Equality open import Oscar.Data.Equality.properties open import Oscar.Data.Fin open import Oscar.Data.Nat open import Oscar.Data.Term FunctionName open import Oscar.Data.Vec open import Oscar.Function infix 19 _◃_ _◃s_ mutual _◃_ : ∀ {m n} → (f : m ⊸ n) → Term m → Term n σ̇ ◃ i 𝑥 = σ̇ 𝑥 _ ◃ leaf = leaf σ̇ ◃ (τl fork τr) = (σ̇ ◃ τl) fork (σ̇ ◃ τr) σ̇ ◃ (function fn τs) = function fn (σ̇ ◃s τs) where _◃s_ : ∀ {m n} → m ⊸ n → ∀ {N} → Vec (Term m) N → Vec (Term n) N f ◃s [] = [] f ◃s (t ∷ ts) = f ◃ t ∷ f ◃s ts _◇_ : ∀ {m n} → m ⊸ n → ∀ {l} → l ⊸ m → l ⊸ n _◇_ f g = (f ◃_) ∘ g mutual ◃-extensionality : ∀ {m n} {f g : m ⊸ n} → f ≡̇ g → f ◃_ ≡̇ g ◃_ ◃-extensionality p (i x) = p x ◃-extensionality p leaf = refl ◃-extensionality p (s fork t) = cong₂ _fork_ (◃-extensionality p s) (◃-extensionality p t) ◃-extensionality p (function fn ts) = cong (function fn) (◃s-extensionality p ts) ◃s-extensionality : ∀ {m n} {f g : m ⊸ n} → f ≡̇ g → ∀ {N} → _◃s_ f {N} ≡̇ _◃s_ g ◃s-extensionality p [] = refl ◃s-extensionality p (t ∷ ts) = cong₂ _∷_ (◃-extensionality p t) (◃s-extensionality p ts) mutual ◃-associativity : ∀ {l m} (f : l ⊸ m) {n} (g : m ⊸ n) → (g ◇ f) ◃_ ≡̇ (g ◃_) ∘ (f ◃_) ◃-associativity _ _ (i _) = refl ◃-associativity _ _ leaf = refl ◃-associativity _ _ (τ₁ fork τ₂) = cong₂ _fork_ (◃-associativity _ _ τ₁) (◃-associativity _ _ τ₂) ◃-associativity f g (function fn ts) = cong (function fn) (◃s-associativity f g ts) ◃s-associativity : ∀ {l m n} (f : l ⊸ m) (g : m ⊸ n) → ∀ {N} → (_◃s_ (g ◇ f) {N}) ≡̇ (g ◃s_) ∘ (f ◃s_) ◃s-associativity _ _ [] = refl ◃s-associativity _ _ (τ ∷ τs) = cong₂ _∷_ (◃-associativity _ _ τ) (◃s-associativity _ _ τs) ◇-associativity : ∀ {k l} (f : k ⊸ l) {m} (g : l ⊸ m) {n} (h : m ⊸ n) → (h ◇ g) ◇ f ≡̇ h ◇ (g ◇ f) ◇-associativity f g h x rewrite ◃-associativity g h (f x) = refl ◇-extensionality : ∀ {l m} {f₁ f₂ : l ⊸ m} → f₁ ≡̇ f₂ → ∀ {n} {g₁ g₂ : m ⊸ n} → g₁ ≡̇ g₂ → g₁ ◇ f₁ ≡̇ g₂ ◇ f₂ ◇-extensionality {f₂ = f₂} f₁≡̇f₂ g₁≡̇g₂ x rewrite f₁≡̇f₂ x = ◃-extensionality g₁≡̇g₂ (f₂ x) open import Oscar.Category.Semigroupoid SemigroupoidSubstitution : Semigroupoid _ _ _ Semigroupoid.⋆ SemigroupoidSubstitution = _ Semigroupoid._⇒_ SemigroupoidSubstitution m n = Fin m ⇒ Term n Semigroupoid._∙_ SemigroupoidSubstitution = _◇_ Semigroupoid.associativity SemigroupoidSubstitution = ◇-associativity Semigroupoid.extensionality SemigroupoidSubstitution = ◇-extensionality open import Oscar.Category.Semifunctor SemifunctorSubstitution : Semifunctor _ _ _ _ _ _ Semifunctor.semigroupoid₁ SemifunctorSubstitution = SemigroupoidSubstitution Semifunctor.semigroupoid₂ SemifunctorSubstitution = SemigroupoidFunction Term Semifunctor.μ SemifunctorSubstitution = id Semifunctor.𝔣 SemifunctorSubstitution = _◃_ Semifunctor.extensionality SemifunctorSubstitution = ◃-extensionality Semifunctor.preservativity SemifunctorSubstitution = ◃-associativity ε : ∀ {m} → m ⊸ m ε = i mutual ◃-identity : ∀ {m} (t : Term m) → ε ◃ t ≡ t ◃-identity (i x) = refl ◃-identity leaf = refl ◃-identity (s fork t) = cong₂ _fork_ (◃-identity s) (◃-identity t) ◃-identity (function fn ts) = cong (function fn) (◃s-identity ts) ◃s-identity : ∀ {N m} (t : Vec (Term m) N) → ε ◃s t ≡ t ◃s-identity [] = refl ◃s-identity (t ∷ ts) = cong₂ _∷_ (◃-identity t) (◃s-identity ts) ◇-left-identity : ∀ {m n} (f : m ⊸ n) → ε ◇ f ≡̇ f ◇-left-identity f = ◃-identity ∘ f ◇-right-identity : ∀ {m n} (f : m ⊸ n) → f ◇ ε ≡̇ f ◇-right-identity _ _ = refl open import Oscar.Category.Category CategorySubstitution : Category _ _ _ Category.semigroupoid CategorySubstitution = SemigroupoidSubstitution Category.ε CategorySubstitution = ε Category.left-identity CategorySubstitution = {!!} Category.right-identity CategorySubstitution {x} {y} {f} x₁ = ◇-right-identity f x₁ test-right-id = {!Category.right-identity CategorySubstitution!} -- open import Oscar.Property.Associativity -- open import Oscar.Property.Equivalence -- open import Oscar.Property.Extensionality₂ -- instance -- AssociativitySubstitutionComposition : Associativity _◇_ _≡̇_ -- Associativity.associativity AssociativitySubstitutionComposition = ◇-associativity -- ExtensionalityS◇ : ExtensionalitySemigroupoid _◇_ _≡̇_ -- ExtensionalitySemigroupoid.extensionalitySemigroupoid ExtensionalityS◇ g₁≡̇g₂ {_} {_} {f₂} f₁≡̇f₂ x rewrite f₁≡̇f₂ x = ◃-extensionality g₁≡̇g₂ (f₂ x) -- -- instance -- -- Extensionality₂≡̇◇⋆ : ∀ {x y z} → Extensionality₂⋆ _≡̇_ _≡̇_ (λ ‵ → _≡̇_ ‵) ((y ⊸ z → x ⊸ y → x ⊸ z) ∋ λ ` → _◇_ `) (λ ` → _◇_ `) -- -- Extensionality₂⋆.extensionality* Extensionality₂≡̇◇⋆ g₁≡̇g₂ {_} {f₂} f₁≡̇f₂ x rewrite f₁≡̇f₂ x = ◃-extensionality g₁≡̇g₂ (f₂ x) -- -- -- Extensionality₂≡̇◇ : ∀ {x y z} → Extensionality₂ _≡̇_ _≡̇_ (λ ‵ → _≡̇_ ‵) (λ {yz} → _◇_ {y} {z} yz {x}) (λ {_} {yz} → yz ◇_) -- -- -- Extensionality₂.extensionality₂ Extensionality₂≡̇◇ {g₁} {g₂} g₁≡̇g₂ {f₁} {f₂} f₁≡̇f₂ x rewrite f₁≡̇f₂ x = ◃-extensionality g₁≡̇g₂ (f₂ x) -- instance -- SemigroupoidSubstitution : Semigroupoid _ _ _ -- Semigroupoid.⋆ SemigroupoidSubstitution = _ -- Semigroupoid._⇒_ SemigroupoidSubstitution = _⊸_ -- Semigroupoid._≋_ SemigroupoidSubstitution = _≡̇_ -- Semigroupoid._∙_ SemigroupoidSubstitution = _◇_ -- instance -- Associativity-∘ : ∀ {𝔬} {⋆ : Set 𝔬} {f} {F : ⋆ → Set f} → -- Associativity (λ {y} {z} g {x} f₁ x₁ → g (f₁ x₁)) -- (λ {x} {y} f₁ g → (x₁ : F x) → f₁ x₁ ≡ g x₁) -- Associativity.associativity Associativity-∘ _ _ _ _ = refl -- ExtensionalityS∘ : ∀ {𝔬} {⋆ : Set 𝔬} {f} {F : ⋆ → Set f} → ExtensionalitySemigroupoid (λ g f → {!(λ {_} → g) ∘ f!}) (_≡̇_ {B = F}) -- ExtensionalityS∘ = {!!} -- -- Extensionality₂-≡̇ : ∀ {𝔬} {⋆ : Set 𝔬} {f} {F : ⋆ → Set f} {x y z : ⋆} → -- -- Extensionality₂ {_} {F _ → _} {_} {λ _ → F _ → _} -- -- (λ f₁ g → (x₁ : F y) → _≡_ (f₁ x₁) (g x₁)) {_} -- -- {λ {w} _ → F _ → _} {_} {λ {w} {x₁} _ → F x → F y} {f} -- -- (λ {w} {x₁} f₁ g → (x₂ : F x) → _≡_ {f} {F y} (f₁ x₂) (g x₂)) {f} -- -- {λ {w} {y₁} _ → F x → F z} {f} {λ {w} {x₁} {y₁} _ → F x → F z} {f} -- -- (λ {w} {x₁} {y₁} ′ {z₁} g → -- -- (x₂ : F x) → _≡_ (′ x₂) (g x₂)) -- -- (λ {yz} f₁ x₂ → yz (f₁ x₂)) -- -- (λ {_} {yz} f₁ x₁ → yz (f₁ x₁)) -- -- Extensionality₂.extensionality₂ Extensionality₂-≡̇ w≡̇x y≡̇z f rewrite y≡̇z f = w≡̇x _ -- SemigroupoidIndexedFunction : ∀ {𝔬} {⋆ : Set 𝔬} {f} (F : ⋆ → Set f) → Semigroupoid _ _ _ -- Semigroupoid.⋆ (SemigroupoidIndexedFunction F) = _ -- Semigroupoid._⇒_ (SemigroupoidIndexedFunction F) m n = F m → F n -- Semigroupoid._≋_ (SemigroupoidIndexedFunction F) = _≡̇_ -- Semigroupoid._∙_ (SemigroupoidIndexedFunction F) g f = g ∘ f -- Semigroupoid.′associativity (SemigroupoidIndexedFunction F) = it -- Semigroupoid.′extensionality₂ (SemigroupoidIndexedFunction F) = {!!} -- Extensionality₂-≡̇ {F = F} -- open import Oscar.Property.Extensionality -- instance -- ex : ∀ {x y} → -- Extensionality (λ f g → -- (x₁ : Fin x) → -- _≡_ (f x₁) (g x₁)) -- (λ {x₁} ‵ {y₁} g → -- (x₂ : Term x) → -- _≡_ {𝔣} {Term y} (‵ x₂) (g x₂)) -- _◃_ _◃_ -- Extensionality.extensionality ex = ◃-extensionality -- open import Oscar.Property.Preservativity -- instance -- pres : ∀ {x y z} → -- Preservativity {𝔣} -- {Fin y → Term z} {𝔣} -- {λ _ → Fin x → Term y} {𝔣} -- {λ x₁ _ → Fin x → Term z} -- (λ ‵ g x₁ → _◃_ {y} {z} ‵ (g x₁)) {𝔣} -- {Term y → -- Term z} -- {𝔣} -- {λ _ → -- Term x → -- Term y} -- {𝔣} -- {λ x₁ _ → -- Term x → -- Term z} -- (λ ‵ f x₁ → ‵ (f x₁)) {𝔣} -- (λ {x₁} {y₁} f g → -- (x₂ : Term x) → -- _≡_ {𝔣} {Term z} (f x₂) (g x₂)) -- (_◃_ {y} {z}) (λ {x₁} → _◃_ {x} {y}) (λ {x₁} {y₁} → _◃_ {x} {z}) -- Preservativity.preservativity pres ρ₂ ρ₁ t = ◃-associativity' t ρ₁ ρ₂ -- semifunctor : Semifunctor _ _ _ _ _ _ -- Semifunctor.semigroupoid₁ semifunctor = SemigroupoidSubstitution -- Semifunctor.semigroupoid₂ semifunctor = SemigroupoidIndexedFunction Term -- Semifunctor.μ semifunctor = id -- Semifunctor.𝔣 semifunctor = _◃_
39.560748
154
0.581384
c7821d378f1a71faf459edc174b7a8a921838d12
1,667
agda
Agda
src/System/IO/Transducers/IO.agda
ilya-fiveisky/agda-system-io
d06c219c7b7afc85aae3b1d4d66951b889aa7371
[ "MIT" ]
10
2015-01-04T13:45:16.000Z
2021-09-15T04:35:41.000Z
src/System/IO/Transducers/IO.agda
ilya-fiveisky/agda-system-io
d06c219c7b7afc85aae3b1d4d66951b889aa7371
[ "MIT" ]
null
null
null
src/System/IO/Transducers/IO.agda
ilya-fiveisky/agda-system-io
d06c219c7b7afc85aae3b1d4d66951b889aa7371
[ "MIT" ]
2
2017-08-10T06:12:54.000Z
2022-03-12T11:40:23.000Z
{-# OPTIONS --no-termination-check #-} -- TODO: switch the termination checker back on. open import Coinduction using ( ∞ ; ♭ ; ♯_ ) open import Data.Bool using ( Bool ; true ; false ) open import Data.Maybe using ( Maybe ; just ; nothing ) open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ ) open import Data.Product using ( ∃ ; _,_ ) open import Data.ByteString using ( ByteString ; strict ; null ) open import System.IO using ( IO ; Command ; return ; _>>_ ; _>>=_ ; skip ; getBytes ; putBytes ; commit ) open import System.IO.Transducers.Lazy using ( _⇒_ ; _⤇_ ; inp ; out ; done ; ι⁻¹ ) open import System.IO.Transducers.Session using ( I ; Σ ; Bytes ) open import System.IO.Transducers.Strict using ( _⇛_ ) module System.IO.Transducers.IO where infixl 5 _$_ postulate IOError : Set _catch_ : ∀ {A} → (IO A) → (IOError → (IO A)) → (IO A) {-# COMPILED_TYPE IOError IOError #-} {-# COMPILED _catch_ (\ _ -> catch) #-} _$_ : ∀ {A V F T} → (Σ {A} V F ⤇ T) → (a : A) → (♭ F a ⤇ T) inp P $ a = ♭ P a out b P $ a = out b (P $ a) getBytes? : IO (Maybe (ByteString strict)) getBytes? = (getBytes >>= λ x → return (just x)) catch (λ e → return nothing) runI : (I ⤇ Bytes) → Command runI (out true (out x P)) = putBytes x >> commit >> runI P runI (out false P) = skip mutual run? : (Bytes ⤇ Bytes) → (Maybe (ByteString strict)) → Command run? P (just b) = run' (P $ true $ b) run? P nothing = runI (P $ false) run' : (Bytes ⤇ Bytes) → Command run' (out true (out b P)) = putBytes b >> commit >> run' P run' (out false P) = skip run' P = getBytes? >>= run? P run : (Bytes ⇒ Bytes) → Command run P = run' (ι⁻¹ P)
34.020408
106
0.602879
19c29a94e773c659e0e3550e921ddea456233e05
2,581
agda
Agda
src/Model/Stream.agda
JLimperg/msc-thesis-code
104cddc6b65386c7e121c13db417aebfd4b7a863
[ "MIT" ]
5
2021-04-13T21:31:17.000Z
2021-06-26T06:37:31.000Z
src/Model/Stream.agda
JLimperg/msc-thesis-code
104cddc6b65386c7e121c13db417aebfd4b7a863
[ "MIT" ]
null
null
null
src/Model/Stream.agda
JLimperg/msc-thesis-code
104cddc6b65386c7e121c13db417aebfd4b7a863
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K #-} module Model.Stream where open import Model.Size as MS using ( Size ; Sizes ; _≤_ ; _<_ ; ≤-IsProp ; ≤-trans ; nat ) open import Model.Type.Core open import Util.HoTT.FunctionalExtensionality open import Util.HoTT.HLevel open import Util.Prelude import Data.Nat.Properties as ℕ open Size Colist : Size → Set Colist n = ∀ m → nat m ≤ n → ℕ abstract Colist-≡⁺ : ∀ {n} {xs ys : Colist n} → (∀ m m≤n → xs m m≤n ≡ ys m m≤n) → xs ≡ ys Colist-≡⁺ eq = funext λ m → funext λ m≤n → eq m m≤n Colist-≡⁻ : ∀ {n} {xs ys : Colist n} → xs ≡ ys → ∀ m m≤n₀ m≤n₁ → xs m m≤n₀ ≡ ys m m≤n₁ Colist-≡⁻ {xs = xs} refl m m≤n₀ m≤n₁ = cong (xs m) (≤-IsProp _ _) Colist-IsSet : ∀ {n} → IsSet (Colist n) Colist-IsSet = ∀-IsSet λ m → ∀-IsSet λ m≤n → ℕ.≡-irrelevant castColist : ∀ {n m} → n ≤ m → Colist m → Colist n castColist n≤m xs k k≤n = xs k go where abstract go = ≤-trans k≤n n≤m Stream : ⟦Type⟧ Sizes Stream = record { ObjHSet = λ n → HLevel⁺ (Colist n) Colist-IsSet ; eqHProp = λ {n} {n′} _ xs ys → ∀-HProp ℕ λ m → ∀-HProp (nat m ≤ n) λ m≤n → ∀-HProp (nat m ≤ n′) λ m≤n′ → HLevel⁺ (xs m m≤n ≡ ys m m≤n′) ℕ.≡-irrelevant ; eq-refl = λ x m m≤n m≤n′ → cong (x m) (≤-IsProp _ _) } cons : ∀ {n} → ℕ → (∀ m → m < n → Colist m) → Colist n cons x xs zero _ = x cons x xs (suc k) Sk≤n = xs (nat k) go k MS.≤-refl where abstract go = MS.Sn≤m→n<m Sk≤n head : ∀ {n} → Colist n → ℕ head xs = xs 0 MS.0≤n tail : ∀ {n} → Colist n → ∀ m → m < n → Colist m tail xs m m<n k k≤m = xs (suc k) go where abstract go = MS.n<m→Sn≤m (MS.≤→<→< k≤m m<n) abstract cons-≡⁺ : ∀ {n n′ i i′ is is′} → i ≡ i′ → (∀ m (m<n : m < n) (m<n′ : m < n′) k k≤m → is m m<n k k≤m ≡ is′ m m<n′ k k≤m) → ∀ m m<n m<n′ → cons i is m m<n ≡ cons i′ is′ m m<n′ cons-≡⁺ i≡i′ is≡is′ zero m<n₀ m<n₁ = i≡i′ cons-≡⁺ {is′ = is′} i≡i′ is≡is′ (suc m) m<n m<n′ = trans (is≡is′ (nat m) (MS.Sn≤m→n<m m<n) (MS.Sn≤m→n<m m<n′) m MS.≤-refl) (cong (λ p → is′ _ p _ _) (MS.<-IsProp _ _)) head-≡⁺ : ∀ {n n′ is is′} → (∀ m (m≤n : nat m ≤ n) (m≤n′ : nat m ≤ n′) → is m m≤n ≡ is′ m m≤n′) → head is ≡ head is′ head-≡⁺ is≡is′ = is≡is′ 0 MS.0≤n MS.0≤n tail-≡⁺ : ∀ {n n′ is is′} → (∀ m (m≤n : nat m ≤ n) (m≤n′ : nat m ≤ n′) → is m m≤n ≡ is′ m m≤n′) → ∀ m m′ m<n m′<n′ k k≤m k≤m′ → tail is m m<n k k≤m ≡ tail is′ m′ m′<n′ k k≤m′ tail-≡⁺ {is′ = is′} is≡is′ m m′ m<n m′<n′ k k≤m k≤m′ = trans (is≡is′ (suc k) _ (MS.n<m→Sn≤m (MS.≤→<→< k≤m′ m′<n′))) (cong (is′ (suc k)) (≤-IsProp _ _))
27.457447
79
0.496707
03d5881b8b1194f2b27a29fe135248dfdde7e6ab
3,870
agda
Agda
OutsideIn/TypeSchema.agda
liamoc/outside-in
fc1fc1bba2af95806d9075296f9ed1074afa4c24
[ "BSD-3-Clause" ]
2
2015-09-14T05:22:15.000Z
2020-11-19T14:30:07.000Z
OutsideIn/TypeSchema.agda
liamoc/outside-in
fc1fc1bba2af95806d9075296f9ed1074afa4c24
[ "BSD-3-Clause" ]
null
null
null
OutsideIn/TypeSchema.agda
liamoc/outside-in
fc1fc1bba2af95806d9075296f9ed1074afa4c24
[ "BSD-3-Clause" ]
null
null
null
open import OutsideIn.Prelude open import OutsideIn.X module OutsideIn.TypeSchema(x : X) where open X(x) open import Data.Vec hiding (_>>=_) data NameType : Set where Regular : NameType Datacon : ℕ → NameType data TypeSchema ( n : Set) : NameType → Set where ∀′_·_⇒_ : (v : ℕ) → QConstraint (n ⨁ v) → Type (n ⨁ v) → TypeSchema n Regular DC∀′_,_·_⇒_⟶_ : (a b : ℕ){l : ℕ} → QConstraint ((n ⨁ a) ⨁ b) → Vec (Type ((n ⨁ a) ⨁ b)) l → n → TypeSchema n (Datacon l) DC∀_·_⟶_ : (a : ℕ){l : ℕ} → Vec (Type (n ⨁ a)) l → n → TypeSchema n (Datacon l) private module PlusN-f n = Functor (Monad.is-functor (PlusN-is-monad {n})) module Vec-f {n} = Functor (vec-is-functor {n}) module Type-f = Functor (type-is-functor) module QC-f = Functor (qconstraint-is-functor) private fmap-schema : {A B : Set}{x : NameType} → (A → B) → TypeSchema A x → TypeSchema B x fmap-schema f (∀′ n · Q ⇒ τ) = ∀′ n · QC-f.map (pn.map f) Q ⇒ Type-f.map (pn.map f) τ where module pn = PlusN-f n fmap-schema f (DC∀′ a , b · Q ⇒ τs ⟶ K) = DC∀′ a , b · QC-f.map (pb.map (pa.map f)) Q ⇒ map (Type-f.map (pb.map (pa.map f))) τs ⟶ f K where module pa = PlusN-f a module pb = PlusN-f b fmap-schema f (DC∀ a · τs ⟶ K) = DC∀ a · map (Type-f.map (pa.map f)) τs ⟶ f K where module pa = PlusN-f a fmap-schema-id : {A : Set}{x : NameType} {f : A → A} → isIdentity f → isIdentity (fmap-schema {A}{A}{x} f) fmap-schema-id isid {∀′ n · Q ⇒ τ} = cong₂ (∀′_·_⇒_ n) (QC-f.identity (pn.identity isid)) (Type-f.identity (pn.identity isid)) where module pn = PlusN-f n fmap-schema-id isid {DC∀′ a , b · Q ⇒ τs ⟶ K} = cong₃ (DC∀′_,_·_⇒_⟶_ a b) (QC-f.identity (pb.identity (pa.identity isid))) (Vec-f.identity (Type-f.identity (pb.identity (pa.identity isid)))) isid where module pa = PlusN-f a module pb = PlusN-f b fmap-schema-id isid {DC∀ a · τs ⟶ K} = cong₂ (DC∀_·_⟶_ a) (Vec-f.identity (Type-f.identity (pa.identity isid))) isid where module pa = PlusN-f a fmap-schema-comp : {A B C : Set}{s : NameType} {f : A → B} {g : B → C} {x : TypeSchema A s} → fmap-schema (g ∘ f) x ≡ fmap-schema g (fmap-schema f x) fmap-schema-comp {x = ∀′ n · Q ⇒ τ} = cong₂ (∀′_·_⇒_ n) (Functor.composite (qconstraint-is-functor ∘f pnf)) (Functor.composite (type-is-functor ∘f pnf)) where pnf = Monad.is-functor (PlusN-is-monad {n}) fmap-schema-comp {x = DC∀′ a , b · Q ⇒ τs ⟶ K} = cong₃ (DC∀′_,_·_⇒_⟶_ a b) (Functor.composite (qconstraint-is-functor ∘f pbf ∘f paf )) (Functor.composite (vec-is-functor ∘f type-is-functor ∘f pbf ∘f paf)) refl where module pa = PlusN-f a module pb = PlusN-f b paf = Monad.is-functor (PlusN-is-monad {a}) pbf = Monad.is-functor (PlusN-is-monad {b}) fmap-schema-comp {x = DC∀ a · τs ⟶ K} = cong₂ (DC∀_·_⟶_ a) (Functor.composite (vec-is-functor ∘f type-is-functor ∘f paf)) refl where module pa = PlusN-f a paf = Monad.is-functor (PlusN-is-monad {a}) type-schema-is-functor : ∀{s} → Functor (λ x → TypeSchema x s) type-schema-is-functor = record { map = fmap-schema ; identity = fmap-schema-id ; composite = fmap-schema-comp }
46.071429
100
0.488372
4316c120e0d249ae12910919aff69c37a3304d08
1,796
agda
Agda
test/Succeed/Issue1271a.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue1271a.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue1271a.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Empty, unit and equality. ⊥ = (X : Set) → X ⊤ = (X : Set) → X → X data _≡_ {l}{A : Set l}(x : A) : A → Set l where <> : x ≡ x -- The fixpoint of the identity functor as a data definition. module Data where data μId : Set where In : μId → μId -- μId can be proved empty. Here are both a direct proof and one that -- relies on the eliminator for μId. ¬μId : μId → ⊥ ¬μId (In x) = ¬μId x μId-elim : ∀ {l}(P : μId → Set l) → (∀ x → P x → P (In x)) → ∀ x → P x μId-elim P m (In x) = m x (μId-elim P m x) ¬Id' : μId → ⊥ ¬Id' = μId-elim (λ _ → ⊥) (λ _ p → p) -- To prove ∀ x → ¬ (x ≡ In x) it is enough to call ¬μId (or ¬μId'): the -- equality proof is not inspected. ¬id≡In-empty : ∀ {x} → x ≡ In x → ⊥ ¬id≡In-empty {x} _ = ¬μId x -- or ¬Id' x -- Alternatively, one could use an absurd pattern which relies on the -- presence of a cycle. ¬id≡In-pm : ∀ {x} → x ≡ In x → ⊥ ¬id≡In-pm () -- The case of inductive records is a bit different. Here is the fixpoint -- of the identity functor as an inductive record definition. module Record where record μId : Set where inductive; pattern constructor In field Out : μId open μId -- It does not seem possible to prove Record.μId empty, as Agda does not -- consider the following definitions as terminating. -- EDIT: it does now. ¬μId : μId → ⊥ ¬μId (In x) = ¬μId x μId-elim : ∀ {l}(P : μId → Set l) → (∀ x → P x → P (In x)) → ∀ x → P x μId-elim P m (In x) = m x (μId-elim P m x) ¬Id' : μId → ⊥ ¬Id' = μId-elim (λ _ → ⊥) (λ _ p → p) ¬id≡In-empty : ∀ {x} → x ≡ In x → ⊥ ¬id≡In-empty {x} _ = ¬μId x -- or ¬Id' x -- However, we can still use an absurd pattern as in Data.¬id≡In-pm. ¬id≡In-pm : ∀ {x} → x ≡ In x → ⊥ ¬id≡In-pm () -- This should not be possible.
24.27027
74
0.55902
5effdaab03d73e764cfa7d863eabc0577bf62731
2,949
agda
Agda
Cubical/Categories/Category/Base.agda
hyleIndex/cubical
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
[ "MIT" ]
301
2018-10-17T18:00:24.000Z
2022-03-24T02:10:47.000Z
Cubical/Categories/Category/Base.agda
hyleIndex/cubical
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
[ "MIT" ]
584
2018-10-15T09:49:02.000Z
2022-03-30T12:09:17.000Z
Cubical/Categories/Category/Base.agda
hyleIndex/cubical
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
[ "MIT" ]
134
2018-11-16T06:11:03.000Z
2022-03-23T16:22:13.000Z
{-# OPTIONS --safe #-} module Cubical.Categories.Category.Base where open import Cubical.Core.Glue open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Equiv private variable ℓ ℓ' : Level -- Precategories record Precategory ℓ ℓ' : Type (ℓ-suc (ℓ-max ℓ ℓ')) where -- no-eta-equality ; NOTE: need eta equality for `opop` field ob : Type ℓ Hom[_,_] : ob → ob → Type ℓ' id : ∀ x → Hom[ x , x ] _⋆_ : ∀ {x y z} (f : Hom[ x , y ]) (g : Hom[ y , z ]) → Hom[ x , z ] -- TODO: change these to implicit argument ⋆IdL : ∀ {x y : ob} (f : Hom[ x , y ]) → (id x) ⋆ f ≡ f ⋆IdR : ∀ {x y} (f : Hom[ x , y ]) → f ⋆ (id y) ≡ f ⋆Assoc : ∀ {u v w x} (f : Hom[ u , v ]) (g : Hom[ v , w ]) (h : Hom[ w , x ]) → (f ⋆ g) ⋆ h ≡ f ⋆ (g ⋆ h) -- composition: alternative to diagramatic order _∘_ : ∀ {x y z} (g : Hom[ y , z ]) (f : Hom[ x , y ]) → Hom[ x , z ] g ∘ f = f ⋆ g open Precategory -- Helpful syntax/notation _[_,_] : (C : Precategory ℓ ℓ') → (x y : C .ob) → Type ℓ' _[_,_] = Hom[_,_] -- needed to define this in order to be able to make the subsequence syntax declaration seq' : ∀ (C : Precategory ℓ ℓ') {x y z} (f : C [ x , y ]) (g : C [ y , z ]) → C [ x , z ] seq' = _⋆_ infixl 15 seq' syntax seq' C f g = f ⋆⟨ C ⟩ g -- composition comp' : ∀ (C : Precategory ℓ ℓ') {x y z} (g : C [ y , z ]) (f : C [ x , y ]) → C [ x , z ] comp' = _∘_ infixr 16 comp' syntax comp' C g f = g ∘⟨ C ⟩ f -- Categories record isCategory (C : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where field isSetHom : ∀ {x y} → isSet (C [ x , y ]) -- Isomorphisms and paths in precategories record CatIso {C : Precategory ℓ ℓ'} (x y : C .Precategory.ob) : Type ℓ' where constructor catiso field mor : C [ x , y ] inv : C [ y , x ] sec : inv ⋆⟨ C ⟩ mor ≡ C .id y ret : mor ⋆⟨ C ⟩ inv ≡ C .id x pathToIso : {C : Precategory ℓ ℓ'} (x y : C .ob) (p : x ≡ y) → CatIso {C = C} x y pathToIso {C = C} x y p = J (λ z _ → CatIso x z) (catiso (C .id x) idx (C .⋆IdL idx) (C .⋆IdL idx)) p where idx = C .id x -- Univalent Categories record isUnivalent (C : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where field univ : (x y : C .ob) → isEquiv (pathToIso {C = C} x y) -- package up the univalence equivalence univEquiv : ∀ (x y : C .ob) → (x ≡ y) ≃ (CatIso x y) univEquiv x y = (pathToIso {C = C} x y) , (univ x y) -- The function extracting paths from category-theoretic isomorphisms. CatIsoToPath : {x y : C .ob} (p : CatIso x y) → x ≡ y CatIsoToPath {x = x} {y = y} p = equivFun (invEquiv (univEquiv x y)) p open isUnivalent public -- Opposite Categories _^op : Precategory ℓ ℓ' → Precategory ℓ ℓ' (C ^op) .ob = C .ob (C ^op) .Hom[_,_] x y = C .Hom[_,_] y x (C ^op) .id = C .id (C ^op) ._⋆_ f g = C ._⋆_ g f (C ^op) .⋆IdL = C .⋆IdR (C ^op) .⋆IdR = C .⋆IdL (C ^op) .⋆Assoc f g h = sym (C .⋆Assoc _ _ _) open isCategory public
27.560748
109
0.550017
8bbce78e661551632322dd60b8ce4d64173fbe76
6,581
agda
Agda
src/Categories/NaturalTransformation/NaturalIsomorphism.agda
glittershark/agda-categories
2128fab9e8d341364cbf784bb17c547bf73891de
[ "MIT" ]
null
null
null
src/Categories/NaturalTransformation/NaturalIsomorphism.agda
glittershark/agda-categories
2128fab9e8d341364cbf784bb17c547bf73891de
[ "MIT" ]
null
null
null
src/Categories/NaturalTransformation/NaturalIsomorphism.agda
glittershark/agda-categories
2128fab9e8d341364cbf784bb17c547bf73891de
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} module Categories.NaturalTransformation.NaturalIsomorphism where open import Level open import Data.Product using (_×_; _,_; map; zip) open import Function using (flip) open import Categories.Category open import Categories.Functor as ℱ renaming (id to idF) import Categories.NaturalTransformation as NT open NT hiding (id) import Categories.Morphism as Morphism import Categories.Morphism.Properties as Morphismₚ import Categories.Morphism.Reasoning as MR open import Categories.Functor.Properties open import Relation.Binary private variable o ℓ e o′ ℓ′ e′ : Level B C D E : Category o ℓ e record NaturalIsomorphism {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F G : Functor C D) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where private module F = Functor F module G = Functor G field F⇒G : NaturalTransformation F G F⇐G : NaturalTransformation G F module ⇒ = NaturalTransformation F⇒G module ⇐ = NaturalTransformation F⇐G field iso : ∀ X → Morphism.Iso D (⇒.η X) (⇐.η X) module iso X = Morphism.Iso (iso X) open Morphism D FX≅GX : ∀ {X} → F.F₀ X ≅ G.F₀ X FX≅GX {X} = record { from = _ ; to = _ ; iso = iso X } op : NaturalIsomorphism G.op F.op op = record { F⇒G = ⇒.op ; F⇐G = ⇐.op ; iso = λ X → record { isoˡ = iso.isoʳ X ; isoʳ = iso.isoˡ X } } op′ : NaturalIsomorphism F.op G.op op′ = record { F⇒G = ⇐.op ; F⇐G = ⇒.op ; iso = λ X → record { isoˡ = iso.isoˡ X ; isoʳ = iso.isoʳ X } } -- This helper definition lets us specify only one of the commuting -- squares and have the other one derived. record NIHelper {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F G : Functor C D) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where open Functor F using (F₀; F₁) open Functor G using () renaming (F₀ to G₀; F₁ to G₁) open Category D field η : ∀ X → D [ F₀ X , G₀ X ] η⁻¹ : ∀ X → D [ G₀ X , F₀ X ] commute : ∀ {X Y} (f : C [ X , Y ]) → η Y ∘ F₁ f ≈ G₁ f ∘ η X iso : ∀ X → Morphism.Iso D (η X) (η⁻¹ X) niHelper : ∀ {F G : Functor C D} → NIHelper F G → NaturalIsomorphism F G niHelper {D = D} {F = F} {G = G} α = record { F⇒G = ntHelper record { η = η ; commute = commute } ; F⇐G = ntHelper record { η = η⁻¹ ; commute = λ {X Y} f → begin η⁻¹ Y ∘ F₁ G f ≈˘⟨ cancelʳ (isoʳ (iso X)) ⟩ ((η⁻¹ Y ∘ F₁ G f) ∘ η X) ∘ η⁻¹ X ≈˘⟨ pushʳ (commute f) ⟩∘⟨refl ⟩ (η⁻¹ Y ∘ (η Y ∘ F₁ F f)) ∘ η⁻¹ X ≈⟨ cancelˡ (isoˡ (iso Y)) ⟩∘⟨refl ⟩ F₁ F f ∘ η⁻¹ X ∎ } ; iso = iso } where open Morphism.Iso open NIHelper α open Functor open Category D open HomReasoning open MR D open NaturalIsomorphism infixr 9 _ⓘᵥ_ _ⓘₕ_ _ⓘˡ_ _ⓘʳ_ infix 4 _≃_ -- commonly used short-hand in CT for NaturalIsomorphism _≃_ : (F G : Functor C D) → Set _ _≃_ = NaturalIsomorphism _ⓘᵥ_ : {F G H : Functor C D} → G ≃ H → F ≃ G → F ≃ H _ⓘᵥ_ {D = D} α β = record { F⇒G = F⇒G α ∘ᵥ F⇒G β ; F⇐G = F⇐G β ∘ᵥ F⇐G α ; iso = λ X → Iso-∘ (iso β X) (iso α X) } where open NaturalIsomorphism open Morphismₚ D _ⓘₕ_ : {H I : Functor D E} {F G : Functor C D} → H ≃ I → F ≃ G → (H ∘F F) ≃ (I ∘F G) _ⓘₕ_ {E = E} {I = I} α β = record { F⇒G = F⇒G α ∘ₕ F⇒G β ; F⇐G = F⇐G α ∘ₕ F⇐G β ; iso = λ X → Iso-resp-≈ (Iso-∘ (iso α _) ([ I ]-resp-Iso (iso β X))) E.Equiv.refl (commute (F⇐G α) (η (F⇐G β) X)) } where open NaturalIsomorphism open NaturalTransformation module E = Category E open E.Equiv open Morphismₚ E _ⓘˡ_ : {F G : Functor C D} → (H : Functor D E) → (η : F ≃ G) → H ∘F F ≃ H ∘F G H ⓘˡ η = record { F⇒G = H ∘ˡ F⇒G η ; F⇐G = H ∘ˡ F⇐G η ; iso = λ X → [ H ]-resp-Iso (iso η X) } where open Functor H _ⓘʳ_ : {F G : Functor C D} → (η : F ≃ G) → (K : Functor E C) → F ∘F K ≃ G ∘F K η ⓘʳ K = record { F⇒G = F⇒G η ∘ʳ K ; F⇐G = F⇐G η ∘ʳ K ; iso = λ X → iso η (F₀ X) } where open Functor K refl : Reflexive (NaturalIsomorphism {C = C} {D = D}) refl {D = D} = record { F⇒G = NT.id ; F⇐G = NT.id ; iso = λ _ → record { isoˡ = Category.identityˡ D ; isoʳ = Category.identityʳ D } } sym : Symmetric (NaturalIsomorphism {C = C} {D = D}) sym {D = D} F≃G = record { F⇒G = F⇐G F≃G ; F⇐G = F⇒G F≃G ; iso = λ X → let open Iso (iso F≃G X) in record { isoˡ = isoʳ ; isoʳ = isoˡ } } where open Morphism D trans : Transitive (NaturalIsomorphism {C = C} {D = D}) trans = flip _ⓘᵥ_ isEquivalence : {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → IsEquivalence (NaturalIsomorphism {C = C} {D = D}) isEquivalence = record { refl = refl ; sym = sym ; trans = trans } module ≃ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} = IsEquivalence (isEquivalence {C = C} {D = D}) Functor-NI-setoid : (C : Category o ℓ e) (D : Category o′ ℓ′ e′) → Setoid _ _ Functor-NI-setoid C D = record { Carrier = Functor C D ; _≈_ = NaturalIsomorphism ; isEquivalence = isEquivalence } module LeftRightId (F : Functor C D) where module D = Category D iso-id-id : (X : Category.Obj C) → Morphism.Iso D {A = Functor.F₀ F X} D.id D.id iso-id-id X = record { isoˡ = D.identityˡ ; isoʳ = D.identityʳ } -- Left and Right and 'Central' Unitors, Natural Isomorphisms. module _ {F : Functor C D} where open Category.HomReasoning D open Functor F open LeftRightId F open Category D unitorˡ : ℱ.id ∘F F ≃ F unitorˡ = record { F⇒G = id∘F⇒F ; F⇐G = F⇒id∘F ; iso = iso-id-id } unitorʳ : F ∘F ℱ.id ≃ F unitorʳ = record { F⇒G = F∘id⇒F ; F⇐G = F⇒F∘id ; iso = iso-id-id } unitor² : {C : Category o ℓ e} → ℱ.id ∘F ℱ.id ≃ ℱ.id {C = C} unitor² = record { F⇒G = id∘id⇒id ; F⇐G = id⇒id∘id ; iso = LeftRightId.iso-id-id ℱ.id } -- associator module _ (F : Functor B C) (G : Functor C D) (H : Functor D E) where open Category.HomReasoning E open Category E open Functor open LeftRightId (H ∘F (G ∘F F)) private -- components of α assocʳ : NaturalTransformation ((H ∘F G) ∘F F) (H ∘F (G ∘F F)) assocʳ = ntHelper record { η = λ _ → id ; commute = λ _ → MR.id-comm-sym E } assocˡ : NaturalTransformation (H ∘F (G ∘F F)) ((H ∘F G) ∘F F) assocˡ = ntHelper record { η = λ _ → id ; commute = λ _ → MR.id-comm-sym E } associator : (H ∘F G) ∘F F ≃ H ∘F (G ∘F F) associator = record { F⇒G = assocʳ ; F⇐G = assocˡ ; iso = iso-id-id }
27.767932
118
0.553107
d1d7b5a554c84bf3c79e6f36fd657c48a67c1817
2,198
agda
Agda
experimental/GlobularTypes.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
1
2021-06-30T00:17:55.000Z
2021-06-30T00:17:55.000Z
experimental/GlobularTypes.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
null
null
null
experimental/GlobularTypes.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --copatterns #-} open import HoTT module experimental.GlobularTypes where {- Globular types as a coinductive record -} record Glob (i : ULevel) : Type (suc i) where coinductive constructor glob field Ob : Type i Hom : (a b : Ob) → Glob i open Glob public {- The terminal globular type -} Unit-glob : Glob zero Ob Unit-glob = Unit Hom Unit-glob _ _ = Unit-glob {- The tower of identity types -} Id-glob : ∀ {i} (A : Type i) → Glob zero Ob (Id-glob A) = A Hom (Id-glob A) a b = Id-glob (a == b) {- Bisimulation between globular types -} record _~_ {i} (G H : Glob i) : Type (suc i) where coinductive constructor glob~ field Ob= : Ob G == Ob H Hom= : {a : Ob G} {a' : Ob H} (p : a == a' [ (λ x → x) ↓ Ob= ]) {b : Ob G} {b' : Ob H} (q : b == b' [ (λ x → x) ↓ Ob= ]) → Hom G a b ~ Hom H a' b' open _~_ public =-to-~ : ∀ {i} {G H : Glob i} → G == H → G ~ H Ob= (=-to-~ p) = ap Ob p Hom= (=-to-~ p) q r = =-to-~ (↓-app→cst-out (↓-→-out (apd Hom p) (↓-ap-out _ Ob p q)) (↓-ap-out _ Ob p r)) -- The definition of [Hom= (=-to-~ p) q r] would/should just be -- [=-to-~ (apd Hom p q r)] in infinite-dimensional type theory, but here we -- need to add a lot of non-sense to make it type-check. {- We postulate that bisimilarity is equality, because this should be true. -} postulate bisim-is-equiv : ∀ {i} {G H : Glob i} → is-equiv (=-to-~ :> (G == H → G ~ H)) bisim-equiv : ∀ {i} {G H : Glob i} → (G == H) ≃ (G ~ H) bisim-equiv = (=-to-~ , bisim-is-equiv) bisim : ∀ {i} {G H : Glob i} → (G ~ H) → G == H bisim e = <– bisim-equiv e {- The type of globular types is the terminal coalgebra of the appropriate thing. This is proved in the following two lemmas. -} Glob-corec : ∀ {i} {A : Type (suc i)} (Ob* : A → Type i) (Hom* : (x : A) (a b : Ob* x) → A) → (A → Glob i) Ob (Glob-corec Ob* Hom* x) = Ob* x Hom (Glob-corec Ob* Hom* x) a b = Glob-corec Ob* Hom* (Hom* x a b) eta : ∀ {i} {A : Type (suc i)} (Ob* : A → Type i) (Hom* : (x : A) (a b : Ob* x) → A) (f g : A → Glob i) (s : (x : A) → f x ~ g x) → f == g eta Ob* Hom* f g s = funext (λ x → bisim (s x))
30.109589
79
0.534122
31995b9f2ea95922a7928e9120a732bca7b17a8e
9,303
agda
Agda
data/github.com/Saizan/miller/17637ec5267fac2f2072f8c5d5e2a82d11505a46/Injections.agda
ajnavarro/language-dataset
34e2980af98ff2ded500619edce3e0907a6e9050
[ "MIT" ]
9
2018-08-07T11:54:33.000Z
2022-03-11T09:48:45.000Z
data/github.com/Saizan/miller/17637ec5267fac2f2072f8c5d5e2a82d11505a46/Injections.agda
ajnavarro/language-dataset
34e2980af98ff2ded500619edce3e0907a6e9050
[ "MIT" ]
91
2019-11-11T15:41:26.000Z
2022-03-21T04:17:18.000Z
data/github.com/Saizan/miller/17637ec5267fac2f2072f8c5d5e2a82d11505a46/Injections.agda
ajnavarro/language-dataset
34e2980af98ff2ded500619edce3e0907a6e9050
[ "MIT" ]
3
2019-11-13T12:44:41.000Z
2022-01-06T19:34:26.000Z
module Injections where open import Data.Product open import Relation.Nullary open import Data.Empty open import Data.Sum open import Support.Equality open ≡-Reasoning open import Vars public open import Injections.Type public invert : ∀ {A : Set} {xs ys : List A} (i : Inj xs ys) → ∀ {t} (y : ys ∋ t) → Dec (∃ \ x → i $ x ≡ y) invert [] y = no (λ { (() , _)}) invert ( z ∷ i [ pf ]) y with z ≅∋? y invert (.y ∷ i [ pf ]) y | yes refl` = yes (zero , refl) invert ( z ∷ i [ pf ]) y | no z≢y with invert i y invert ( z ∷ i [ pf ]) y | no z≢y | yes (x , i$x≡y) = yes (suc x , i$x≡y) invert ( z ∷ i [ pf ]) y | no z≢y | no ¬[i⁻¹y] = no (neither z≢y ¬[i⁻¹y]) where neither : ∀ {t} {y : _ ∋ t} → ¬ z ≅∋ y → ¬ (∃ \ x → i $ x ≡ y) → ¬ Σ (_ ∷ _ ∋ _) (λ x → (z ∷ i [ pf ]) $ x ≡ y) neither ¬1 ¬2 (zero , p) = ¬1 (refl , ≡-to-≅ p) neither ¬1 ¬2 (suc x , p) = ¬2 (x , p) abstract _∘i_ : ∀ {A : Set}{xs ys zs : List A} → Inj ys zs → Inj xs ys → Inj xs zs f ∘i g = quo (λ x x₁ → f $ (g $ x₁)) {λ x x₁ → injective g _ _ (injective f _ _ x₁)} mutual id-i : ∀ {A : Set}{xs : List A} → Inj xs xs id-i = quo (\ _ x → x) {\ _ e → e} Inj-thin : ∀ {A : Set}{x : A}{xs ys} → (v : ys ∋ x) -> Inj xs (ys - v) → Inj xs ys Inj-thin v f = quo (λ x x₁ → thin v x (f $ x₁)) {λ x x₁ → injective f _ _ (thin-inj v x₁)} abstract id-i$ : ∀ {A : Set}{xs : List A} -> ∀ {x}(v : xs ∋ x) -> id-i $ v ≡ v id-i$ v = iso2 _ _ v right-id : ∀ {A : Set}{xs ys : List A} → (i : Inj xs ys) → i ∘i id-i ≡ i right-id i = begin quo (λ x z → i $ (id-i $ z)) ≡⟨ quo-ext (λ x v → cong (_$_ i) (iso2 _ _ v)) ⟩ quo (λ x → _$_ i) ≡⟨ iso1 i (λ x eq → injective i _ _ eq) ⟩ i ∎ left-id : ∀ {A : Set}{xs ys : List A} → (i : Inj xs ys) → id-i ∘i i ≡ i left-id i = begin quo (λ x z → id-i $ (i $ z)) ≡⟨ quo-ext (λ x v → (iso2 _ _ (i $ v))) ⟩ quo (λ x → _$_ i) ≡⟨ iso1 i (λ x eq → injective i _ _ eq) ⟩ i ∎ apply-∘ : ∀ {A : Set}{xs ys zs : List A} → (j : Inj ys zs) → (i : Inj xs ys) → ∀ {x} {v : x ∈ xs} → (j ∘i i) $ v ≡ j $ (i $ v) apply-∘ j i {x}{v} = iso2 _ _ v assoc-∘i : ∀ {A : Set}{xs ys ws zs : List A} {f : Inj ws zs}{g : Inj _ ws}{h : Inj xs ys} → f ∘i (g ∘i h) ≡ (f ∘i g) ∘i h assoc-∘i {f = f}{g = g}{h = h} = quo-ext λ x v → begin f $ (quo (λ x₁ x₂ → g $ (h $ x₂)) $ v) ≡⟨ cong (_$_ f) (iso2 _ _ v) ⟩ f $ (g $ (h $ v)) ≡⟨ sym (iso2 _ _ (h $ v)) ⟩ quo (λ x₁ x₂ → f $ (g $ x₂)) $ (h $ v) ∎ cong-$ : ∀ {A : Set}{xs ys : List A} {f g : _} {inj1 inj2} → quo {_} {xs} {ys} f {inj1} ≡ quo g {inj2} → ∀ {s} (x : xs ∋ s) → f s x ≡ g s x cong-$ {A} {xs} {ys} {f} {g} eq x = begin f _ x ≡⟨ sym (iso2 f _ x) ⟩ quo f $ x ≡⟨ cong (λ f₁ → f₁ $ x) eq ⟩ quo g $ x ≡⟨ iso2 g _ x ⟩ g _ x ∎ ∘i-inj : ∀ {A : Set}{xs ys zs : List A} → (i : Inj ys zs) (j1 j2 : Inj xs ys) → (i ∘i j1) ≡ (i ∘i j2) → j1 ≡ j2 ∘i-inj i j1 j2 eq = begin j1 ≡⟨ sym (iso1 j1 (λ x x₁ → injective j1 _ _ x₁)) ⟩ quo (λ x → _$_ j1) ≡⟨ quo-ext (λ x v → injective i _ _ (cong-$ eq v)) ⟩ quo (λ x → _$_ j2) ≡⟨ iso1 j2 (λ x x₁ → injective j2 _ _ x₁) ⟩ j2 ∎ Inj-thin-$ : ∀ {A : Set}{x : A}{xs ys} → (v : ys ∋ x) -> (f : Inj xs (ys - v)) -> ∀ {y}(u : xs ∋ y) -> Inj-thin v f $ u ≡ thin v _ (f $ u) Inj-thin-$ v f u = iso2 _ _ u Inj-thin-inj : ∀ {A : Set}{x : A}{xs ys} → (v : ys ∋ x) -> (f g : Inj xs (ys - v)) -> Inj-thin v f ≡ Inj-thin v g -> f ≡ g Inj-thin-inj v f g eq = ext-$ f g (λ x v₁ → thin-inj v (cong-$ {inj1 = λ x₁ x₂ → injective f _ _ (thin-inj v x₂)} {inj2 = λ x₁ x₂ → injective g _ _ (thin-inj v x₂)} eq v₁)) -- XXX regression Inj-thin-∘i : ∀ {A : Set}{x : A}{zs xs ys} → (v : ys ∋ x) -> (f : Inj xs (ys - v)) (m : Inj zs xs) -> Inj-thin v f ∘i m ≡ Inj-thin v (f ∘i m) Inj-thin-∘i v f m = quo-ext (λ x v₁ → trans (iso2 _ _ (m $ v₁)) (cong (thin v x) (sym (iso2 _ _ v₁)))) v∉Inj-thinv : ∀ {A : Set}{x : A}{xs ys} → (v : ys ∋ x) -> (f : Inj xs (ys - v)) -> v ∉ Inj-thin v f v∉Inj-thinv v f = ∉Im$-∉ (λ x x₁ → thin v _ (f $ x₁)) v (λ b → x∉thinx v (f $ b)) test : ∀ {A : Set} {xs ys} → (f : ∀ (x : A) → x ∈ xs → x ∈ ys){inj1 inj2 : ∀ x → {i j : x ∈ xs} → f x i ≡ f x j → i ≡ j} → quo f {inj1} ≡ quo f {inj2} test f = refl weak : ∀ {A : Set}{x : A}{xs ys} → Inj xs ys → Inj xs (x ∷ ys) weak f = Inj-thin zero f apply-weakid : ∀ {A : Set}{xs : List A}{x y}(i : xs ∋ x) -> weak {x = y} id-i $ i ≡ suc i apply-weakid i = begin quo (λ x v → thin zero x (id-i $ v)) $ i ≡⟨ iso2 _ _ i ⟩ suc (id-i $ i) ≡⟨ cong suc (id-i$ i) ⟩ suc i ∎ _∷[]_ : ∀ {A : Set}{x : A}{xs ys} → (v : ys ∋ x) -> Inj xs (ys - v) → Inj (x ∷ xs) ys v ∷[] f = v ∷ Inj-thin v f [ v∉Inj-thinv v f ] cons : ∀ {A : Set}{x : A}{xs ys} → Inj xs ys → Inj (x ∷ xs) (x ∷ ys) cons z = zero ∷[] z abstract cons-id : ∀ {A : Set}{x : A}{xs} -> cons id-i ≡ id-i {_} {x ∷ xs} cons-id = cong-∷[] refl (quo-ext (λ x v → cong suc (id-i$ v))) cons-∘i : ∀ {A : Set}{xs ys zs : List A}{x} → (j : Inj ys zs) → (i : Inj xs ys) → cons {A} {x} (j ∘i i) ≡ cons j ∘i cons i cons-∘i j i = cong-∷[] refl (begin quo (λ x z → suc (proj₁ (quo' (λ v v₁ → j $ (i $ v₁))) $ z)) ≡⟨ quo-ext {injg = λ x x₁ → injective i _ _ (injective (weak j) _ _ x₁)} (λ x v → begin suc (proj₁ (quo' (λ v₁ v₂ → j $ (i $ v₂))) $ v) ≡⟨ cong suc (iso2 _ _ v) ⟩ suc (j $ (i $ v)) ≡⟨ sym (iso2 _ _ (i $ v)) ⟩ quo (λ x₁ x₂ → suc (j $ x₂)) $ (i $ v) ∎) ⟩ quo (λ x v → cons j $ suc (i $ v)) ≡⟨ sym (quo-ext (λ x₁ v → cong (_$_ (cons j)) (iso2 (λ _ x → suc (i $ x)) _ v))) ⟩ quo (λ x v → cons j $ (quo (λ z x₁ → suc (i $ x₁)) $ v)) ∎) ∘-ext : ∀ {A : Set}{xs ys zs ws : List A} {f : Inj ys zs}{g : Inj xs ys}{f1 : Inj ws zs}{g1 : Inj xs ws} -> f ∘i g ≡ f1 ∘i g1 -> (∀ x (v : xs ∋ x) -> f $ (g $ v) ≡ f1 $ (g1 $ v)) ∘-ext eq = (\ x v -> trans (sym (apply-∘ _ _)) (trans (cong (\ f -> f $ v) eq) ((apply-∘ _ _)))) ext-∘ : ∀ {A : Set}{xs ys zs ws : List A} {f : Inj ys zs}{g : Inj xs ys}{f1 : Inj ws zs}{g1 : Inj xs ws} -> (∀ x (v : xs ∋ x) -> f $ (g $ v) ≡ f1 $ (g1 $ v)) -> f ∘i g ≡ f1 ∘i g1 ext-∘ eq = ext-$ _ _ (\ x v -> trans (apply-∘ _ _) (trans (eq x v) (sym (apply-∘ _ _)))) -- Transforming pointwise representations of universal morphisms into Inj ones. Equ-universal-quote : ∀ {A : Set} {xs ys : List A} → (i j : Inj xs ys) → ∀ {E} → (e : Inj E xs) -> (∀ a (y : xs ∋ a) -> i $ y ≡ j $ y -> ∃ \ z -> y ≡ e $ z) -> {as : List A} (h : Inj as xs) → i ∘i h ≡ j ∘i h → Σ (Inj as E) (λ z → e ∘i z ≡ h ) Equ-universal-quote {A} {xs} {ys} i j {E} e c {as} h eq = quo u {λ x {v} {w} eq1 → injective h v w (begin h $ v ≡⟨ proj₂ (f x v) ⟩ e $ u x v ≡⟨ cong (_$_ e) eq1 ⟩ e $ u x w ≡⟨ sym (proj₂ (f x w)) ⟩ h $ w ∎)} , ext-$ (e ∘i quo u) h (λ x v → begin (e ∘i quo u) $ v ≡⟨ apply-∘ _ _ ⟩ e $ (quo u $ v) ≡⟨ cong (_$_ e) (iso2 _ _ v) ⟩ e $ u x v ≡⟨ sym (proj₂ (f x v)) ⟩ h $ v ∎) where f : ∀ a (y : as ∋ a) -> ∃ \ z -> h $ y ≡ e $ z f a y = c a (h $ y) (∘-ext eq a y) u = (λ x v → proj₁ (f x v)) Pull-universal-quote : ∀ {A : Set} {X Y Z : List A} → (i : Inj X Z)(j : Inj Y Z) -> ∀ {P} -> (p₁ : Inj P X) (p₂ : Inj P Y) -> (∀ (a : A) (y : Y ∋ a)(x : X ∋ a) -> i $ x ≡ j $ y -> (∃ \ z -> p₁ $ z ≡ x × p₂ $ z ≡ y)) -> ∀ {Q} -> (q₁ : Inj Q X) (q₂ : Inj Q Y) -> i ∘i q₁ ≡ j ∘i q₂ -> ∃ \ u -> q₁ ≡ p₁ ∘i u × q₂ ≡ p₂ ∘i u Pull-universal-quote i j p₁ p₂ uni {Q} q₁ q₂ commutes = quo u {λ x {v} {w} eq → injective q₁ v w (begin q₁ $ v ≡⟨ sym (proj₁ (proj₂ (f x v))) ⟩ p₁ $ u x v ≡⟨ cong (_$_ p₁) eq ⟩ p₁ $ u x w ≡⟨ proj₁ (proj₂ (f x w)) ⟩ q₁ $ w ∎)} , ext-$ q₁ (p₁ ∘i quo u) (λ x v → begin q₁ $ v ≡⟨ sym (proj₁ (proj₂ (f x v))) ⟩ p₁ $ u x v ≡⟨ cong (_$_ p₁) (sym (iso2 _ _ v)) ⟩ p₁ $ (quo u $ v) ≡⟨ sym (apply-∘ _ _) ⟩ (p₁ ∘i quo u) $ v ∎) , ext-$ q₂ (p₂ ∘i quo u) (λ x v → begin q₂ $ v ≡⟨ sym (proj₂ (proj₂ (f x v))) ⟩ p₂ $ u x v ≡⟨ cong (_$_ p₂) (sym (iso2 _ _ v)) ⟩ p₂ $ (quo u $ v) ≡⟨ sym (apply-∘ _ _) ⟩ (p₂ ∘i quo u) $ v ∎) where f : ∀ a (v : Q ∋ a) -> (∃ \ z -> p₁ $ z ≡ q₁ $ v × p₂ $ z ≡ q₂ $ v) f a v = uni a (q₂ $ v) (q₁ $ v) (∘-ext commutes a v) u : ∀ a (v : Q ∋ a) -> _ u a v = proj₁ (f a v)
54.723529
192
0.391272
38fc1ee9a3187199e4d3d15837a1fcdf7c8bef30
812
agda
Agda
vector-sort.agda
rfindler/ial
f3f0261904577e930bd7646934f756679a6cbba6
[ "MIT" ]
29
2019-02-06T13:09:31.000Z
2022-03-04T15:05:12.000Z
vector-sort.agda
rfindler/ial
f3f0261904577e930bd7646934f756679a6cbba6
[ "MIT" ]
8
2018-07-09T22:53:38.000Z
2022-03-22T03:43:34.000Z
vector-sort.agda
rfindler/ial
f3f0261904577e930bd7646934f756679a6cbba6
[ "MIT" ]
17
2018-12-03T22:38:15.000Z
2021-11-28T20:13:21.000Z
module vector-sort where open import level open import bool open import nat open import product open import vector insert𝕍 : ∀{ℓ}{A : Set ℓ}{n : ℕ} → (_<_ : A → A → 𝔹) → (_≅_ : A → A → 𝔹) → A → 𝕍 A n → Σi ℕ (λ m → 𝕍 A (suc m)) insert𝕍 _<_ _≅_ x [] = , [ x ]𝕍 insert𝕍 _<_ _≅_ x (y :: ys) with x < y ... | tt = , x :: y :: ys ... | ff with x ≅ y ... | tt = , y :: ys ... | ff with (insert𝕍 _<_ _≅_ x ys) ... | , r = , y :: r insertion-sort𝕍 : ∀{ℓ}{A : Set ℓ}{n : ℕ} → (_<_ : A → A → 𝔹) → (_≅_ : A → A → 𝔹) → 𝕍 A (suc n) → Σi ℕ (λ m → 𝕍 A (suc m)) insertion-sort𝕍 _ _ (x :: []) = , [ x ]𝕍 insertion-sort𝕍 _<_ _≅_ (x :: (y :: ys)) with insertion-sort𝕍 _<_ _≅_ (y :: ys) ... | , (z :: zs) = insert𝕍 _<_ _≅_ x (z :: zs) test-insertion-sort𝕍 = insertion-sort𝕍 _<_ _=ℕ_ (3 :: 5 :: 2 :: 7 :: 1 :: 2 :: 3 :: 9 :: [])
33.833333
121
0.481527
38f4bb131355452d58f52377636ff87e9e407359
602
agda
Agda
test/Fail/TerminationAndUnivalence.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/TerminationAndUnivalence.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/TerminationAndUnivalence.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{- Jesper Cockx, 26-05-2014 Issue 1023 -} {-# OPTIONS --without-K #-} module TerminationAndUnivalence where data _≡_ {a} {A : Set a} (x : A) : A → Set a where refl : x ≡ x J : ∀ {a b} {A : Set a} {x : A} (P : (y : A) → x ≡ y → Set b) → (p : P x refl) {y : A} (e : x ≡ y) → P y e J P p refl = p data ⊥ : Set where data WOne : Set where wrap : (⊥ → WOne) → WOne FOne = ⊥ → WOne f : WOne → FOne f x () g : FOne → WOne g x = wrap (λ ()) postulate iso : WOne ≡ FOne noo : (X : Set) → (WOne ≡ X) → X → ⊥ noo .WOne refl (wrap x) = noo FOne iso x absurd : ⊥ absurd = noo FOne iso (λ ())
16.722222
63
0.511628
5e4b9a49121371049ddb18f582ba4a75f868adc4
66
agda
Agda
test/Fail/MisformedTypeSignature.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/MisformedTypeSignature.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/MisformedTypeSignature.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module MisformedTypeSignature where postulate A : Set (f g) : A
11
35
0.742424
5e5a1b526cc2f95965bb3188f1cba506ec7d8c2f
690
agda
Agda
test/Succeed/Issue2553.agda
vlopezj/agda
ff4d89e75970cf27599fb9f572bd43c9455cbb56
[ "BSD-3-Clause" ]
2
2019-10-29T09:40:30.000Z
2020-09-20T00:28:57.000Z
test/Succeed/Issue2553.agda
vikfret/agda
49ad0b3f0d39c01bc35123478b857e702b29fb9d
[ "BSD-3-Clause" ]
3
2018-11-14T15:31:44.000Z
2019-04-01T19:39:26.000Z
test/Succeed/Issue2553.agda
vikfret/agda
49ad0b3f0d39c01bc35123478b857e702b29fb9d
[ "BSD-3-Clause" ]
1
2019-03-05T20:02:38.000Z
2019-03-05T20:02:38.000Z
module _ where id : (A B : Set₁) → (A → B) → A → B id _ _ f = f postulate P : (A : Set₁) → A → Set₁ cong : (A B : Set₁) (f : A → B) (x : A) → P A x → P B (f x) A : Set record R₀ (B : Set) : Set₁ where constructor mkR₀ no-eta-equality field proj₁ : Set proj₂ : B record R₁ (_ : Set) : Set₁ where constructor mkR₁ eta-equality field p : R₀ A X : Set X = R₀.proj₁ p record R₂ (r : R₁ A) : Set₁ where constructor mkR₂ eta-equality field g : R₀ (R₁.X r) should-succeed : (r₁ : R₁ A) (r₂ : R₂ r₁) → P (R₂ r₁) r₂ → P (R₀ (R₁.X r₁)) (R₂.g r₂) should-succeed r₁ r₂ = id (P _ _) (P (R₀ (R₁.X r₁)) (R₂.g r₂)) (cong _ _ R₂.g _)
16.829268
61
0.523188
5e7516e0ac1cea734740ded9386701173ad014bb
1,262
agda
Agda
test/asset/agda-stdlib-1.0/Data/AVL/Height.agda
omega12345/agda-mode
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
[ "MIT" ]
null
null
null
test/asset/agda-stdlib-1.0/Data/AVL/Height.agda
omega12345/agda-mode
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
[ "MIT" ]
null
null
null
test/asset/agda-stdlib-1.0/Data/AVL/Height.agda
omega12345/agda-mode
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- The Agda standard library -- -- Types and functions which are used to keep track of height -- invariants in AVL Trees ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.AVL.Height where open import Data.Nat.Base open import Data.Fin using (Fin; zero; suc) ℕ₂ = Fin 2 pattern 0# = zero pattern 1# = suc zero pattern ## = suc (suc ()) -- Addition. infixl 6 _⊕_ _⊕_ : ℕ₂ → ℕ → ℕ 0# ⊕ n = n 1# ⊕ n = 1 + n ## ⊕ n -- pred[ i ⊕ n ] = pred (i ⊕ n). pred[_⊕_] : ℕ₂ → ℕ → ℕ pred[ i ⊕ zero ] = 0 pred[ i ⊕ suc n ] = i ⊕ n infix 4 _∼_⊔_ -- If i ∼ j ⊔ m, then the difference between i and j is at most 1, -- and the maximum of i and j is m. _∼_⊔_ is used to record the -- balance factor of the AVL trees, and also to ensure that the -- absolute value of the balance factor is never more than 1. data _∼_⊔_ : ℕ → ℕ → ℕ → Set where ∼+ : ∀ {n} → n ∼ 1 + n ⊔ 1 + n ∼0 : ∀ {n} → n ∼ n ⊔ n ∼- : ∀ {n} → 1 + n ∼ n ⊔ 1 + n -- Some lemmas. max∼ : ∀ {i j m} → i ∼ j ⊔ m → m ∼ i ⊔ m max∼ ∼+ = ∼- max∼ ∼0 = ∼0 max∼ ∼- = ∼0 ∼max : ∀ {i j m} → i ∼ j ⊔ m → j ∼ m ⊔ m ∼max ∼+ = ∼0 ∼max ∼0 = ∼0 ∼max ∼- = ∼+
21.758621
72
0.466719
1e9f2edf8c32d0e0842f4fd9c5d07115380e78c9
3,155
agda
Agda
agda/Mergesort/Impl2/Correctness/Permutation.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
6
2015-05-21T12:50:35.000Z
2021-08-24T22:11:15.000Z
agda/Mergesort/Impl2/Correctness/Permutation.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
agda/Mergesort/Impl2/Correctness/Permutation.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
open import Relation.Binary.Core module Mergesort.Impl2.Correctness.Permutation {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 List.Permutation.Base A open import List.Permutation.Base.Concatenation A open import List.Permutation.Base.Equivalence A open import List.Properties A open import LRTree {A} open import Mergesort.Impl2 _≤_ tot≤ open import OList _≤_ lemma-merge'-empty : {b : Bound}(xs : OList b) → merge' xs (onil {b}) ≡ xs lemma-merge'-empty onil = refl lemma-merge'-empty (:< b≤x xs) = refl mutual lemma-merge' : {b : Bound}(xs ys : OList b) → (forget xs ++ forget ys) ∼ forget (merge' xs ys) lemma-merge' onil ys = refl∼ lemma-merge' xs onil rewrite ++id (forget xs) | lemma-merge'-empty xs = refl∼ lemma-merge' (:< {x = x} b≤x xs) (:< {x = y} b≤y ys) with tot≤ x y ... | inj₁ x≤y = ∼x /head /head (lemma-merge' xs (:< (lexy x≤y) ys)) ... | inj₂ y≤x = let f'xxsyf'ys∼yf'xxsf'ys = ∼x (lemma++/ {y} {forget (:< b≤x xs)}) /head refl∼ ; yf'xxsf'ys∼yf'm'xxsys = ∼x /head /head (lemma-merge'xs (lexy y≤x) xs ys) in trans∼ f'xxsyf'ys∼yf'xxsf'ys yf'xxsf'ys∼yf'm'xxsys lemma-merge'xs : {b : Bound}{x : A} → (b≤x : LeB b (val x))(xs : OList (val x))(ys : OList b) → (forget (:< b≤x xs) ++ forget ys) ∼ forget (merge'xs b≤x xs ys) lemma-merge'xs b≤x xs onil rewrite ++id (forget xs) | lemma-merge'-empty xs = refl∼ lemma-merge'xs {x = x} b≤x xs (:< {x = y} b≤y ys) with tot≤ x y ... | inj₁ x≤y = ∼x /head /head (lemma-merge' xs (:< (lexy x≤y) ys)) ... | inj₂ y≤x = let f'xxsyf'ys∼yf'xxsf'ys = ∼x (lemma++/ {y} {forget (:< b≤x xs)}) /head refl∼ ; yf'xxsf'ys∼yf'm'xxsys = ∼x /head /head (lemma-merge'xs (lexy y≤x) xs ys) in trans∼ f'xxsyf'ys∼yf'xxsf'ys yf'xxsf'ys∼yf'm'xxsys lemma-insert : (x : A)(t : LRTree) → (x ∷ flatten t) ∼ flatten (insert x t) lemma-insert x empty = ∼x /head /head ∼[] lemma-insert x (leaf y) = ∼x (/tail /head) /head (∼x /head /head ∼[]) lemma-insert x (node left l r) = lemma++∼r (lemma-insert x l) lemma-insert x (node right l r) = let xlr∼lxr = ∼x /head (lemma++/ {x} {flatten l}) refl∼ ; lxr∼lrᵢ = lemma++∼l {flatten l} (lemma-insert x r) in trans∼ xlr∼lxr lxr∼lrᵢ lemma-deal : (xs : List A) → xs ∼ flatten (deal xs) lemma-deal [] = ∼[] lemma-deal (x ∷ xs) = trans∼ (∼x /head /head (lemma-deal xs)) (lemma-insert x (deal xs)) lemma-merge : (t : LRTree) → flatten t ∼ forget (merge t) lemma-merge empty = ∼[] lemma-merge (leaf x) = ∼x /head /head ∼[] lemma-merge (node t l r) = let flfr∼f'm'lf'm'r = lemma++∼ (lemma-merge l) (lemma-merge r) ; f'm'lf'm'r∼m''m''lm''r = lemma-merge' (merge l) (merge r) in trans∼ flfr∼f'm'lf'm'r f'm'lf'm'r∼m''m''lm''r theorem-mergesort-∼ : (xs : List A) → xs ∼ (forget (mergesort xs)) theorem-mergesort-∼ xs = trans∼ (lemma-deal xs) (lemma-merge (deal xs))
46.397059
161
0.568938
9a900088f7028c65764f8b7c385af5d573969d4d
2,578
agda
Agda
misc/RecursiveDescent/InductiveWithFix.agda
yurrriq/parser-combinators
b396d35cc2cb7e8aea50b982429ee385f001aa88
[ "MIT" ]
7
2016-12-13T05:23:14.000Z
2021-06-22T05:35:31.000Z
misc/RecursiveDescent/InductiveWithFix.agda
nad/parser-combinators
76774f54f466cfe943debf2da731074fe0c33644
[ "MIT" ]
1
2018-01-22T22:21:41.000Z
2018-01-24T16:39:37.000Z
misc/RecursiveDescent/InductiveWithFix.agda
nad/parser-combinators
76774f54f466cfe943debf2da731074fe0c33644
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- Terminating parser "combinator" interface ------------------------------------------------------------------------ module RecursiveDescent.InductiveWithFix where open import RecursiveDescent.Index import RecursiveDescent.InductiveWithFix.Internal as P open P public using (Parser; Grammar; Lift; fresh; lift) open import Data.List open import Data.Bool open import Data.Maybe open import Data.Product.Record hiding (map) import Data.Product as Prod open import Data.Function import Data.BoundedVec.Inefficient as BVec ------------------------------------------------------------------------ -- Run function for the parsers parse : forall {tok nt i r} -> Parser tok nt i r -> Grammar tok nt -> List tok -> List (Prod._×_ r (List tok)) parse p g s = map (Prod.map id BVec.toList) (P.parse g _ p (BVec.fromList s)) -- A variant which only returns parses which leave no remaining input. parse-complete : forall {tok nt i r} -> Parser tok nt i r -> Grammar tok nt -> List tok -> List r parse-complete p g s = map Prod.proj₁ (filter (null ∘ Prod.proj₂) (parse p g s)) ------------------------------------------------------------------------ -- Exported combinators infix 60 !_ infixl 40 _∣_ infixl 10 _>>=_ _!>>=_ !_ : forall {tok nt e c r} -> nt (e , c) r -> Parser tok nt (e , step c) r !_ = P.!_ fix : forall {tok nt e c r} -> Parser tok (Lift (e , step c) r nt) (e , c) r -> Parser tok nt (e , step c) r fix = P.fix symbol : forall {tok nt} -> Parser tok nt 0I tok symbol = P.symbol return : forall {tok nt r} -> r -> Parser tok nt 1I r return = P.ret fail : forall {tok nt r} -> Parser tok nt 0I r fail = P.fail _>>=_ : forall {tok nt e₁ c₁ i₂ r₁ r₂} -> let i₁ = (e₁ , c₁) in Parser tok nt i₁ r₁ -> (r₁ -> Parser tok nt i₂ r₂) -> Parser tok nt (i₁ ·I i₂) r₂ _>>=_ {e₁ = true } = P.bind₀ _>>=_ {e₁ = false} = P.bind₁ -- If the first parser is guaranteed to consume something, then the -- second parser's index can depend on the result of the first parser. _!>>=_ : forall {tok nt c₁ r₁ r₂} {i₂ : r₁ -> Index} -> let i₁ = (false , c₁) in Parser tok nt i₁ r₁ -> ((x : r₁) -> Parser tok nt (i₂ x) r₂) -> Parser tok nt (i₁ ·I 1I) r₂ _!>>=_ = P.bind₁ _∣_ : forall {tok nt e₁ c₁ i₂ r} -> let i₁ = (e₁ , c₁) in Parser tok nt i₁ r -> Parser tok nt i₂ r -> Parser tok nt (i₁ ∣I i₂) r _∣_ {e₁ = true } = P.alt₀ _∣_ {e₁ = false} = P.alt₁ _
30.690476
72
0.54422
9a38acf5c9046902da96294c6b61c626f73e258f
365
agda
Agda
test/Succeed/Issue4769.agda
zliu41/agda
73405f70bced057d24dd4bf122d53f9548544aba
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue4769.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue4769.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2020-06-21, issue #4769 -- Name and hiding ignored in subsequent face constraint patterns. -- Instead, we should throw a warning. open import Agda.Primitive.Cubical data S : Set where base : S foo : ∀ i j → Partial _ S foo i j (i = i0) {{agdaDoesNotSeeThisName = (j = i1)}} = base -- Expect: warning about name and "instance" flavor and argument.
26.071429
66
0.69863
4bbfc2140d501f07a783382670872d0d1784fbd2
2,372
agda
Agda
Cubical/Algebra/Group/Morphism.agda
Schippmunk/cubical
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
[ "MIT" ]
null
null
null
Cubical/Algebra/Group/Morphism.agda
Schippmunk/cubical
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
[ "MIT" ]
null
null
null
Cubical/Algebra/Group/Morphism.agda
Schippmunk/cubical
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Group.Morphism where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Structure open import Cubical.Algebra.Group.Base open import Cubical.Data.Sigma private variable ℓ ℓ' ℓ'' ℓ''' : Level -- The following definition of GroupHom and GroupEquiv are level-wise heterogeneous. -- This allows for example to deduce that G ≡ F from a chain of isomorphisms -- G ≃ H ≃ F, even if H does not lie in the same level as G and F. isGroupHom : (G : Group {ℓ}) (H : Group {ℓ'}) (f : ⟨ G ⟩ → ⟨ H ⟩) → Type _ isGroupHom G H f = (x y : ⟨ G ⟩) → f (x G.+ y) ≡ (f x H.+ f y) where module G = GroupStr (snd G) module H = GroupStr (snd H) record GroupHom (G : Group {ℓ}) (H : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where constructor grouphom field fun : ⟨ G ⟩ → ⟨ H ⟩ isHom : isGroupHom G H fun record GroupEquiv (G : Group {ℓ}) (H : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where constructor groupequiv field eq : ⟨ G ⟩ ≃ ⟨ H ⟩ isHom : isGroupHom G H (equivFun eq) hom : GroupHom G H hom = grouphom (equivFun eq) isHom open GroupHom open GroupStr η-hom : {G : Group {ℓ}} {H : Group {ℓ'}} → (a : GroupHom G H) → grouphom (fun a) (isHom a) ≡ a fun (η-hom a i) = fun a isHom (η-hom a i) = isHom a η-equiv : {G : Group {ℓ}} {H : Group {ℓ'}} → (a : GroupEquiv G H) → groupequiv (GroupEquiv.eq a) (GroupEquiv.isHom a) ≡ a GroupEquiv.eq (η-equiv a i) = GroupEquiv.eq a GroupEquiv.isHom (η-equiv a i) = GroupEquiv.isHom a ×hom : {A : Group {ℓ}} {B : Group {ℓ'}} {C : Group {ℓ''}} {D : Group {ℓ'''}} → GroupHom A C → GroupHom B D → GroupHom (dirProd A B) (dirProd C D) fun (×hom mf1 mf2) = map-× (fun mf1) (fun mf2) isHom (×hom mf1 mf2) a b = ≡-× (isHom mf1 _ _) (isHom mf2 _ _) isInIm : (G : Group {ℓ}) (H : Group {ℓ'}) → GroupHom G H → ⟨ H ⟩ → Type (ℓ-max ℓ ℓ') isInIm G H ϕ h = ∃[ g ∈ ⟨ G ⟩ ] ϕ .fun g ≡ h isInKer : (G : Group {ℓ}) (H : Group {ℓ'}) → GroupHom G H → ⟨ G ⟩ → Type ℓ' isInKer G H ϕ g = ϕ .fun g ≡ 0g (snd H) isSurjective : (G : Group {ℓ}) (H : Group {ℓ'}) → GroupHom G H → Type (ℓ-max ℓ ℓ') isSurjective G H ϕ = (x : ⟨ H ⟩) → isInIm G H ϕ x isInjective : (G : Group {ℓ}) (H : Group {ℓ'}) → GroupHom G H → Type (ℓ-max ℓ ℓ') isInjective G H ϕ = (x : ⟨ G ⟩) → isInKer G H ϕ x → x ≡ 0g (snd G)
33.885714
84
0.596965
38e65ddf8b5cfa869a5dc916239b944440ec16ac
763
agda
Agda
030-semigroup.agda
mcmtroffaes/agda-proofs
76fe404b25210258810641cc6807feecf0ff8d6c
[ "MIT" ]
2
2015-08-09T22:51:55.000Z
2016-08-17T16:15:42.000Z
030-semigroup.agda
mcmtroffaes/agda-proofs
76fe404b25210258810641cc6807feecf0ff8d6c
[ "MIT" ]
null
null
null
030-semigroup.agda
mcmtroffaes/agda-proofs
76fe404b25210258810641cc6807feecf0ff8d6c
[ "MIT" ]
null
null
null
module 030-semigroup where -- We need equivalence. open import 020-equivalence -- Semigroups are basically a set with equality and some binary -- operator which is associative and respects equality. record SemiGroup {M : Set} (_==_ : M -> M -> Set) (_*_ : M -> M -> M) : Set1 where field equiv : Equivalence _==_ assoc : ∀ {r s t} -> ((r * s) * t) == (r * (s * t)) cong : ∀ {r s u v} -> (r == s) -> (u == v) -> (r * u) == (s * v) -- The next line brings all fields and declarations of Equivalence -- into this record's namespace so we can refer to them in an -- unqualified way in proofs (for example, we can write "refl" for -- "Equivalence.symm equiv" and so on). open Equivalence equiv public -- No theorems here yet.
26.310345
68
0.618611
8b7def68136f17fd31fe3f5045f376c3d4e44cf3
4,396
agda
Agda
theorems/cohomology/Torus.agda
timjb/HoTT-Agda
66f800adef943afdf08c17b8ecfba67340fead5e
[ "MIT" ]
null
null
null
theorems/cohomology/Torus.agda
timjb/HoTT-Agda
66f800adef943afdf08c17b8ecfba67340fead5e
[ "MIT" ]
null
null
null
theorems/cohomology/Torus.agda
timjb/HoTT-Agda
66f800adef943afdf08c17b8ecfba67340fead5e
[ "MIT" ]
1
2018-12-26T21:31:57.000Z
2018-12-26T21:31:57.000Z
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cohomology.Theory {- Ordinary cohomology groups of the n-torus Tⁿ = (S¹)ⁿ. - We have Cᵏ(Tⁿ) == C⁰(S⁰)^(n choose' k) where _choose'_ defined as below. - This argument could give Cᵏ((Sᵐ)ⁿ) with a little more work. -} module cohomology.Torus {i} (OT : OrdinaryTheory i) where open OrdinaryTheory OT open import cohomology.Sphere OT open import cohomology.SphereProduct cohomology-theory {- Almost n choose k, but with n choose' O = 0 for any n. -} _choose'_ : ℕ → ℤ → ℕ n choose' negsucc _ = 0 n choose' pos O = 0 n choose' pos (S O) = n O choose' pos (S (S k)) = 0 S n choose' pos (S (S k)) = (n choose' (pos (S (S k)))) + (n choose' (pos (S k))) _-⊙Torus : ℕ → Ptd₀ O -⊙Torus = ⊙Unit (S n) -⊙Torus = ⊙S¹ ⊙× (n -⊙Torus) C-nTorus : (k : ℤ) (n : ℕ) → C k (⊙Lift (n -⊙Torus)) ≃ᴳ C 0 (⊙Lift ⊙S⁰) ^ᴳ (n choose' k) C-nTorus (negsucc k) O = lift-iso ∘eᴳ trivial-iso-0ᴳ (C-Unit (negsucc k)) C-nTorus (negsucc k) (S n) = C (negsucc k) (⊙Lift (S n -⊙Torus)) ≃ᴳ⟨ C-emap (negsucc k) (⊙lift-equiv ⊙∘e ⊙×-emap (⊙ide _) ⊙lower-equiv) ⟩ C (negsucc k) (⊙S¹ ⊙× ⊙Lift (n -⊙Torus)) ≃ᴳ⟨ C-Sphere× (negsucc k) 1 (⊙Lift (n -⊙Torus)) ⟩ C (negsucc k) (⊙Lift ⊙S¹) ×ᴳ (C (negsucc k) (⊙Lift (n -⊙Torus)) ×ᴳ C (negsucc k) (⊙Susp (⊙Lift (n -⊙Torus)))) ≃ᴳ⟨ ×ᴳ-emap (trivial-iso-0ᴳ (C-Sphere-≠-is-trivial (negsucc k) 1 (ℤ-negsucc≠pos _ _))) (idiso _) ⟩ 0ᴳ ×ᴳ (C (negsucc k) (⊙Lift (n -⊙Torus)) ×ᴳ C (negsucc k) (⊙Susp (⊙Lift (n -⊙Torus)))) ≃ᴳ⟨ ×ᴳ-unit-l _ ⟩ C (negsucc k) (⊙Lift (n -⊙Torus)) ×ᴳ C (negsucc k) (⊙Susp (⊙Lift (n -⊙Torus))) ≃ᴳ⟨ ×ᴳ-emap (lower-iso ∘eᴳ C-nTorus (negsucc k) n) (C-nTorus (negsucc (S k)) n ∘eᴳ C-Susp (negsucc (S k)) (⊙Lift (n -⊙Torus))) ⟩ 0ᴳ ×ᴳ Lift-group 0ᴳ ≃ᴳ⟨ ×ᴳ-unit-l (Lift-group 0ᴳ) ⟩ Lift-group 0ᴳ ≃ᴳ∎ C-nTorus (pos O) O = lift-iso ∘eᴳ trivial-iso-0ᴳ (C-Unit 0) C-nTorus (pos O) (S n) = C 0 (⊙Lift (S n -⊙Torus)) ≃ᴳ⟨ C-emap 0 (⊙lift-equiv ⊙∘e ⊙×-emap (⊙ide _) ⊙lower-equiv) ⟩ C 0 (⊙S¹ ⊙× ⊙Lift (n -⊙Torus)) ≃ᴳ⟨ C-Sphere× 0 1 (⊙Lift (n -⊙Torus)) ⟩ C 0 (⊙Lift ⊙S¹) ×ᴳ (C 0 (⊙Lift (n -⊙Torus)) ×ᴳ C 0 (⊙Susp (⊙Lift (n -⊙Torus)))) ≃ᴳ⟨ ×ᴳ-emap (trivial-iso-0ᴳ (C-Sphere-≠-is-trivial 0 1 (pos-≠ (ℕ-O≠S _)))) (idiso _) ⟩ 0ᴳ ×ᴳ (C 0 (⊙Lift (n -⊙Torus)) ×ᴳ C 0 (⊙Susp (⊙Lift (n -⊙Torus)))) ≃ᴳ⟨ ×ᴳ-unit-l _ ⟩ C 0 (⊙Lift (n -⊙Torus)) ×ᴳ C 0 (⊙Susp (⊙Lift (n -⊙Torus))) ≃ᴳ⟨ ×ᴳ-emap (lower-iso ∘eᴳ C-nTorus 0 n) (C-nTorus -1 n ∘eᴳ C-Susp -1 (⊙Lift (n -⊙Torus))) ⟩ 0ᴳ ×ᴳ Lift-group 0ᴳ ≃ᴳ⟨ ×ᴳ-unit-l _ ⟩ Lift-group 0ᴳ ≃ᴳ∎ C-nTorus (pos (S O)) O = lift-iso ∘eᴳ trivial-iso-0ᴳ (C-Unit 1) C-nTorus (pos (S O)) (S n) = C 1 (⊙Lift (S n -⊙Torus)) ≃ᴳ⟨ C-emap 1 (⊙lift-equiv ⊙∘e ⊙×-emap (⊙ide _) ⊙lower-equiv) ⟩ C 1 (⊙S¹ ⊙× ⊙Lift (n -⊙Torus)) ≃ᴳ⟨ C-Sphere× 1 1 (⊙Lift (n -⊙Torus)) ⟩ C 1 (⊙Lift ⊙S¹) ×ᴳ (C 1 (⊙Lift (n -⊙Torus)) ×ᴳ C 1 (⊙Susp (⊙Lift (n -⊙Torus)))) ≃ᴳ⟨ ×ᴳ-emap (C-Sphere-diag 1) ( ×ᴳ-unit-r _ ∘eᴳ ×ᴳ-emap (C-nTorus 1 n) (lower-iso ∘eᴳ C-nTorus 0 n ∘eᴳ C-Susp 0 (⊙Lift (n -⊙Torus)))) ⟩ C 0 (⊙Lift ⊙S⁰) ×ᴳ (C 0 (⊙Lift ⊙S⁰) ^ᴳ n) ≃ᴳ∎ C-nTorus (pos (S (S k))) O = lift-iso ∘eᴳ trivial-iso-0ᴳ (C-Unit (pos (S (S k)))) C-nTorus (pos (S (S k))) (S n) = C (pos (S (S k))) (⊙Lift (S n -⊙Torus)) ≃ᴳ⟨ C-emap (pos (S (S k))) (⊙lift-equiv ⊙∘e ⊙×-emap (⊙ide _) ⊙lower-equiv) ⟩ C (pos (S (S k))) (⊙S¹ ⊙× ⊙Lift (n -⊙Torus)) ≃ᴳ⟨ C-Sphere× (pos (S (S k))) 1 (⊙Lift (n -⊙Torus)) ⟩ C (pos (S (S k))) (⊙Lift ⊙S¹) ×ᴳ (C (pos (S (S k))) (⊙Lift (n -⊙Torus)) ×ᴳ C (pos (S (S k))) (⊙Susp (⊙Lift (n -⊙Torus)))) ≃ᴳ⟨ ×ᴳ-emap (trivial-iso-0ᴳ (C-Sphere-≠-is-trivial (pos (S (S k))) 1 (pos-≠ (ℕ-S-≠ (ℕ-S≠O k))))) (idiso _) ⟩ 0ᴳ ×ᴳ (C (pos (S (S k))) (⊙Lift (n -⊙Torus)) ×ᴳ C (pos (S (S k))) (⊙Susp (⊙Lift (n -⊙Torus)))) ≃ᴳ⟨ ×ᴳ-unit-l _ ⟩ C (pos (S (S k))) (⊙Lift (n -⊙Torus)) ×ᴳ C (pos (S (S k))) (⊙Susp (⊙Lift (n -⊙Torus))) ≃ᴳ⟨ ×ᴳ-emap (C-nTorus (pos (S (S k))) n) (C-nTorus (pos (S k)) n ∘eᴳ C-Susp (pos (S k)) (⊙Lift (n -⊙Torus))) ⟩ (C 0 (⊙Lift ⊙S⁰) ^ᴳ (n choose' pos (S (S k)))) ×ᴳ (C 0 (⊙Lift ⊙S⁰) ^ᴳ (n choose' pos (S k))) ≃ᴳ⟨ ^ᴳ-+ (C 0 (⊙Lift ⊙S⁰)) (n choose' pos (S (S k))) (n choose' pos (S k)) ⁻¹ᴳ ⟩ C 0 (⊙Lift ⊙S⁰) ^ᴳ (S n choose' pos (S (S k))) ≃ᴳ∎
39.25
123
0.509782
0392137b5eb168a369cd5af4a14c501a074d5447
514
agda
Agda
test/Succeed/Issue3089.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue3089.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue3089.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
open import Agda.Builtin.Nat open import Agda.Builtin.Equality open import Agda.Builtin.Sigma works : Nat → Nat works 0 = 0 works x@(suc _) = x forced-implicit : ∀ x {y} → x ≡ y → Nat forced-implicit x .{x} refl = x forced-instance : ∀ x {{y}} → x ≡ y → Nat forced-instance x .{{x}} refl = x fails : ∀ {x : Nat} → Nat fails {0} = 0 fails x@{suc _} = x forced-implicit' : ∀ x {y} → x ≡ y → Nat forced-implicit' x x@.{_} refl = x forced-instance' : ∀ x {{y}} → x ≡ y → Nat forced-instance' x x@.{{_}} refl = x
21.416667
42
0.599222
192fbbd2aad22b623b06e3d848908e48559c5bef
1,456
agda
Agda
src/Fragment/Algebra/Free/Atoms.agda
yallop/agda-fragment
f2a6b1cf4bc95214bd075a155012f84c593b9496
[ "MIT" ]
18
2021-06-15T15:45:39.000Z
2022-01-17T17:26:09.000Z
src/Fragment/Algebra/Free/Atoms.agda
yallop/agda-fragment
f2a6b1cf4bc95214bd075a155012f84c593b9496
[ "MIT" ]
1
2021-06-16T09:44:31.000Z
2021-06-16T10:24:15.000Z
src/Fragment/Algebra/Free/Atoms.agda
yallop/agda-fragment
f2a6b1cf4bc95214bd075a155012f84c593b9496
[ "MIT" ]
3
2021-06-15T15:34:50.000Z
2021-06-16T08:04:31.000Z
{-# OPTIONS --without-K --exact-split --safe #-} module Fragment.Algebra.Free.Atoms where open import Level using (Level; _⊔_) open import Data.Nat using (ℕ) open import Data.Fin using (Fin) open import Relation.Binary using (Setoid; IsEquivalence) open import Relation.Binary.PropositionalEquality as PE using (_≡_) private variable a ℓ : Level module _ (A : Set a) where data BT (n : ℕ) : Set a where sta : A → BT n dyn : Fin n → BT n module _ (S : Setoid a ℓ) (n : ℕ) where open Setoid S renaming (Carrier to A) data _≍_ : BT A n → BT A n → Set (a ⊔ ℓ) where sta : ∀ {x y} → x ≈ y → sta x ≍ sta y dyn : ∀ {x y} → x ≡ y → dyn x ≍ dyn y private ≍-refl : ∀ {x} → x ≍ x ≍-refl {sta _} = sta refl ≍-refl {dyn _} = dyn PE.refl ≍-sym : ∀ {x y} → x ≍ y → y ≍ x ≍-sym (sta x≈y) = sta (sym x≈y) ≍-sym (dyn x≡y) = dyn (PE.sym x≡y) ≍-trans : ∀ {x y z} → x ≍ y → y ≍ z → x ≍ z ≍-trans (sta x≈y) (sta y≈z) = sta (trans x≈y y≈z) ≍-trans (dyn x≡y) (dyn y≡z) = dyn (PE.trans x≡y y≡z) ≍-isEquivalence : IsEquivalence _≍_ ≍-isEquivalence = record { refl = ≍-refl ; sym = ≍-sym ; trans = ≍-trans } Atoms : Setoid a (a ⊔ ℓ) Atoms = record { Carrier = BT (Setoid.Carrier S) n ; _≈_ = _≍_ ; isEquivalence = ≍-isEquivalence }
26
67
0.50206
5e722121e2272374451f9aa4a4fb5a0076e9213c
265
agda
Agda
src/agda/FRP/JS/Main.agda
agda/agda-frp-js
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
[ "MIT", "BSD-3-Clause" ]
63
2015-04-20T21:47:00.000Z
2022-02-28T09:46:14.000Z
src/agda/FRP/JS/Main.agda
agda/agda-frp-js
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
[ "MIT", "BSD-3-Clause" ]
null
null
null
src/agda/FRP/JS/Main.agda
agda/agda-frp-js
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
[ "MIT", "BSD-3-Clause" ]
7
2016-11-07T21:50:58.000Z
2022-03-12T11:39:38.000Z
open import FRP.JS.RSet using ( ⟦_⟧ ) open import FRP.JS.Behaviour using ( Beh ) open import FRP.JS.DOM using ( DOM ) module FRP.JS.Main where postulate Main : Set reactimate : ⟦ Beh DOM ⟧ → Main {-# COMPILED_JS reactimate require("agda.frp").reactimate #-}
22.083333
61
0.69434
434e5fc51e963e882b363666bd5f5f99597abd23
185
agda
Agda
test/Fail/Prop-NoDisjointConstructors.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Prop-NoDisjointConstructors.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Prop-NoDisjointConstructors.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --prop #-} data TestProp : Prop where p₁ p₂ : TestProp data _≡Prop_ {A : Prop} (x : A) : A → Set where refl : x ≡Prop x p₁≢p₂ : {P : Prop} → p₁ ≡Prop p₂ → P p₁≢p₂ ()
16.818182
47
0.551351
ad751f8c8ea77f14aff5767303cf215b2d30a6b8
1,305
agda
Agda
test/js/TestList.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
1
2019-11-27T07:26:06.000Z
2019-11-27T07:26:06.000Z
test/js/TestList.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
test/js/TestList.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
open import Common.Prelude open import TestHarness open import TestBool using ( not; _∧_ ; _↔_ ) module TestList where _++_ : ∀ {X} → List X → List X → List X [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) revApp : ∀ {X} → List X → List X → List X revApp [] ys = ys revApp (x ∷ xs) ys = revApp xs (x ∷ ys) reverse : ∀ {X} → List X → List X reverse xs = revApp xs [] _≟_ : List Bool → List Bool → Bool [] ≟ [] = true (x ∷ xs) ≟ (y ∷ ys) = (x ↔ y) ∧ (xs ≟ ys) _ ≟ - = false [tt] = true ∷ [] [ff] = false ∷ [] [tt,ff] = true ∷ [ff] [ff,tt] = false ∷ [tt] [ff,tt,ff] = false ∷ [tt,ff] tests : Tests tests _ = ( assert ([] ≟ []) "[]=[]" , assert (not ([tt] ≟ [ff])) "[tt]≠[ff]" , assert (([] ++ [tt]) ≟ [tt]) "[]++[tt]=[tt]" , assert (([tt] ++ []) ≟ [tt]) "[tt]++[]=[tt]" , assert (([tt] ++ [ff]) ≟ [tt,ff]) "[tt]++[ff]=[tt,ff]" , assert (([ff,tt] ++ [ff]) ≟ [ff,tt,ff]) "[ff,tt]++[ff]=[ff,tt,ff]" , assert (not (([ff] ++ [tt]) ≟ [tt,ff])) "[ff]++[tt]≠[tt,ff]" , assert (not (([tt] ++ [tt]) ≟ [tt,ff])) "[tt]++[tt]≠[tt,ff]" , assert (reverse [tt,ff] ≟ [ff,tt]) "rev[tt,ff]=[ff,tt]" , assert (reverse (reverse [tt,ff]) ≟ [tt,ff]) "rev(rev[tt,ff])=[tt,ff]" , assert (not (reverse [tt,ff] ≟ [tt,ff])) "rev[tt,ff]≠[tt,ff]" )
31.071429
76
0.448276
a00b9d0dc9ccc2677ea193dd709efa1293f20952
6,938
agda
Agda
src/Implicits/Resolution/Infinite/Algorithm/Soundness.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
4
2019-04-05T17:57:11.000Z
2021-05-07T04:08:41.000Z
src/Implicits/Resolution/Infinite/Algorithm/Soundness.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
src/Implicits/Resolution/Infinite/Algorithm/Soundness.agda
metaborg/ts.agda
7fe638b87de26df47b6437f5ab0a8b955384958d
[ "MIT" ]
null
null
null
open import Prelude module Implicits.Resolution.Infinite.Algorithm.Soundness where open import Data.Vec hiding (_∈_) open import Data.List hiding (map) open import Data.List.Any hiding (tail) open Membership-≡ open import Data.Bool open import Data.Unit.Base open import Data.Maybe as Maybe hiding (All) open import Coinduction open import Data.Fin.Substitution open import Implicits.Syntax open import Implicits.Substitutions open import Implicits.Substitutions.MetaType open import Implicits.Substitutions.Lemmas open import Implicits.Syntax.Type.Unification open import Implicits.Syntax.Type.Unification.Lemmas renaming (sound to mgu-sound) open import Implicits.Resolution.Infinite.Resolution open import Implicits.Resolution.Infinite.Algorithm open import Implicits.Resolution.Termination open Inductive open import Induction.WellFounded open import Category.Functor open import Category.Monad.Partiality as P open import Category.Monad.Partiality.All using (All; module Alternative) open Alternative renaming (sound to AllP-sound) private module MaybeFunctor {f} = RawFunctor (functor {f}) open import Extensions.Bool as B hiding (All) open import Relation.Binary.PropositionalEquality as PEq using (_≡_) module PR = P.Reasoning (PEq.isEquivalence {A = Bool}) private module M = MetaTypeMetaSubst postulate lem₄ : ∀ {m ν} (a : MetaType m (suc ν)) u us → from-meta (((M.open-meta a) M./ (us M.↑)) M./ (M.sub u)) ≡ (from-meta (a M./ (us M.↑tp))) tp[/tp from-meta u ] open-↓-∀ : ∀ {ν m} {Δ : ICtx ν} (a : MetaType m (suc ν)) τ u us → Δ ⊢ (from-meta ((open-meta a) M./ (u ∷ us))) ↓ τ → Δ ⊢ (from-meta (∀' a M./ us)) ↓ τ open-↓-∀ {Δ = Δ} a τ u us p = (i-tabs (from-meta u) (subst (λ v → Δ ⊢ v ↓ τ) (begin from-meta (M._/_ (open-meta a) (u ∷ us)) ≡⟨ cong (λ v → from-meta (M._/_ (open-meta a) v)) (sym $ us↑-⊙-sub-u≡u∷us u us) ⟩ from-meta ((open-meta a) M./ (us M.↑ M.⊙ (M.sub u))) ≡⟨ cong from-meta (/-⊙ (open-meta a)) ⟩ from-meta ((open-meta a) M./ us M.↑ M./ (M.sub u)) ≡⟨ lem₄ a u us ⟩ from-meta (M._/_ a (us M.↑tp)) tp[/tp from-meta u ] ∎) p)) where open MetaTypeMetaLemmas hiding (subst) mutual delayed-resolve-sound : ∀ {ν} (Δ : ICtx ν) (a : Type ν) → AllP (B.All (Δ ⊢ᵣ a)) (delayed-resolve Δ a) delayed-resolve-sound Δ a = later (♯ (resolve'-sound Δ a)) resolve-context-sound : ∀ {ν m} (Δ : ICtx ν) (a : MetaType m ν) b {τ v} → Maybe.All (λ u → Δ ⊢ from-meta (b M./ u) ↓ τ) v → AllP (Maybe.All (λ u → (Δ ⊢ from-meta (a M./ u) ⇒ from-meta (b M./ u) ↓ τ)) ) (resolve-context Δ a v) resolve-context-sound Δ a b {τ = τ} (just {x = u} px) = _ ≅⟨ resolve-context-comp Δ a u ⟩P delayed-resolve-sound Δ (from-meta (M._/_ a u)) >>=-congP lem where lem : ∀ {v} → B.All (Δ ⊢ᵣ from-meta (a M./ u)) v → AllP (Maybe.All (λ u → Δ ⊢ from-meta (a M./ u) ⇒ from-meta (b M./ u) ↓ τ)) (map-bool u v) lem (true x) = now (just (i-iabs x px)) lem (false) = now nothing resolve-context-sound Δ a b nothing = now nothing match-u-sound : ∀ {ν m} (Δ : ICtx ν) τ (r : MetaType m ν) → (r-acc : m<-Acc r) → AllP (Maybe.All (λ u → (Δ ⊢ from-meta (r M./ u) ↓ τ))) (match-u Δ τ r r-acc) match-u-sound Δ τ (a ⇒ b) (acc rs) = _ ≅⟨ match-u-iabs-comp Δ τ a b rs ⟩P match-u-sound Δ τ b (rs _ (b-m<-a⇒b a b)) >>=-congP resolve-context-sound Δ a b match-u-sound Δ τ (∀' r) (acc rs) = _ ≅⟨ match-u-tabs-comp Δ τ r rs ⟩P match-u-sound Δ τ (open-meta r) _ >>=-congP lem where lem : ∀ {v} → Maybe.All (λ u → Δ ⊢ from-meta (open-meta r M./ u) ↓ τ) v → AllP (Maybe.All (λ u → Δ ⊢ ∀' (from-meta (r M./ u M.↑tp)) ↓ τ )) ((now ∘ (MaybeFunctor._<$>_ tail)) v) lem (just {x = u ∷ us} px) = now (just (open-↓-∀ r τ u us px)) lem nothing = now nothing match-u-sound Δ τ (simpl x) (acc rs) with mgu (simpl x) τ | mgu-sound (simpl x) τ match-u-sound Δ τ (simpl x) (acc rs) | just us | just x/us≡τ = now (just (subst (λ z → Δ ⊢ z ↓ τ) (sym x/us≡τ) (i-simp τ))) match-u-sound Δ τ (simpl x) (acc rs) | nothing | nothing = now nothing match-sound : ∀ {ν} (Δ : ICtx ν) τ r → AllP (B.All (Δ ⊢ r ↓ τ)) (match Δ τ r) match-sound Δ τ r = _ ≅⟨ match-comp Δ τ r ⟩P match-u-sound Δ τ (to-meta {zero} r) (m<-well-founded _) >>=-congP lem where eq : ∀ {ν} {a : Type ν} {s} → from-meta (to-meta {zero} a M./ s) ≡ a eq {a = a} {s = []} = begin from-meta (M._/_ (to-meta {zero} a) []) ≡⟨ cong (λ q → from-meta q) (MetaTypeMetaLemmas.id-vanishes (to-meta {zero} a)) ⟩ from-meta (to-meta {zero} a) ≡⟨ to-meta-zero-vanishes ⟩ a ∎ lem : ∀ {v} → Maybe.All (λ u → (Δ ⊢ from-meta ((to-meta {zero} r) M./ u) ↓ τ)) v → AllP (B.All (Δ ⊢ r ↓ τ)) ((now ∘ is-just) v) lem (just px) = now (true (subst (λ z → Δ ⊢ z ↓ τ) eq px)) lem nothing = now false match1st-recover-sound : ∀ {ν b} x (Δ ρs : ICtx ν) τ → B.All (Δ ⊢ x ↓ τ) b → AllP (B.All (∃₂ λ r (r∈Δ : r ∈ (x ∷ ρs)) → Δ ⊢ r ↓ τ)) (match1st-recover Δ ρs τ b) match1st-recover-sound x Δ ρs τ (true p) = now (true (x , (here refl) , p)) match1st-recover-sound x Δ ρs τ false = _ ≅⟨ PR.sym (right-identity refl (match1st Δ ρs τ)) ⟩P match1st'-sound Δ ρs τ >>=-congP lem where lem : ∀ {v} → B.All (∃₂ λ r (r∈Δ : r ∈ ρs)→ Δ ⊢ r ↓ τ) v → AllP (B.All (∃₂ λ r (r∈Δ : r ∈ x ∷ ρs) → Δ ⊢ r ↓ τ)) (now v) lem (true (r , r∈ρs , p)) = now (true (r , (there r∈ρs) , p)) lem false = now false -- {!match1st'-sound Δ ρs τ!} match1st'-sound : ∀ {ν} (Δ ρs : ICtx ν) τ → AllP (B.All (∃₂ λ r (r∈Δ : r ∈ ρs) → Δ ⊢ r ↓ τ)) (match1st Δ ρs τ) match1st'-sound Δ [] τ = now false match1st'-sound Δ (x ∷ ρs) τ = _ ≅⟨ match1st-comp Δ x ρs τ ⟩P match-sound Δ τ x >>=-congP match1st-recover-sound x Δ ρs τ resolve'-sound : ∀ {ν} (Δ : ICtx ν) r → AllP (B.All (Δ ⊢ᵣ r)) (resolve Δ r) resolve'-sound Δ (simpl x) = _ ≅⟨ PR.sym (right-identity refl (match1st Δ Δ x)) ⟩P match1st'-sound Δ Δ x >>=-congP (λ x → now (B.all-map x (λ{ (r , r∈Δ , p) → r-simp r∈Δ p }))) resolve'-sound Δ (a ⇒ b) = _ ≅⟨ PR.sym (right-identity refl (resolve (a ∷ Δ) b)) ⟩P resolve'-sound (a ∷ Δ) b >>=-congP (λ x → now (B.all-map x r-iabs)) resolve'-sound Δ (∀' r) = _ ≅⟨ PR.sym (right-identity refl (resolve (ictx-weaken Δ) r)) ⟩P resolve'-sound (ictx-weaken Δ) r >>=-congP (λ x → now (B.all-map x r-tabs)) -- Soundness means: -- for all terminating runs of the algorithm we have a finite resolution proof. sound : ∀ {ν} (Δ : ICtx ν) r → All (B.All (Δ ⊢ᵣ r)) (resolve Δ r) sound Δ r = AllP-sound (resolve'-sound Δ r)
45.94702
101
0.556645
9aeb34eb5e2979f19e7a9dd3ce442d4c27b070f6
421
agda
Agda
test/Succeed/Issue796.agda
cagix/agda
cc026a6a97a3e517bb94bafa9d49233b067c7559
[ "BSD-2-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue796.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue796.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- 2013-02-21 Andreas -- ensure that constructor-headedness works also for abstract things module Issue796 where data U : Set where a b : U data A : Set where data B : Set where abstract A' B' : Set A' = A B' = B -- fails if changed to A. [_] : U → Set [_] a = A' [_] b = B' f : ∀ u → [ u ] → U f u _ = u postulate x : A' zzz : U zzz = f _ x -- succeeds since [_] is constructor headed
14.517241
68
0.570071
9adfb361a2d0f41b8159365b6c35bdeabac1f5f0
381
agda
Agda
test/Fail/Issue4120-loop.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue4120-loop.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue4120-loop.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --prop --show-irrelevant #-} open import Agda.Builtin.Equality postulate A : Set P : Prop f : P → A g : A → P {-# TERMINATING #-} loop : A → A loop y = loop y mutual X : A X = _ test : ∀ y → X ≡ f (g (loop y)) test y = refl -- The occurs check should not try to normalize the argument `loop y` -- because it only appears in an irrelevant context.
15.875
69
0.606299
c7a637e152c27367377c135306675a14bf5cae9d
1,205
agda
Agda
test/succeed/ProjectionsPreserveGuardednessTrivialExample.agda
asr/agda-kanso
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
[ "MIT" ]
1
2019-11-27T04:41:05.000Z
2019-11-27T04:41:05.000Z
test/succeed/ProjectionsPreserveGuardednessTrivialExample.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
test/succeed/ProjectionsPreserveGuardednessTrivialExample.agda
np/agda-git-experiment
20596e9dd9867166a64470dd24ea68925ff380ce
[ "MIT" ]
null
null
null
-- 2010-10-14 {-# OPTIONS --universe-polymorphism #-} module ProjectionsPreserveGuardednessTrivialExample where -- Coinduction is only available with universe polymorphism postulate Level : Set zero : Level suc : (i : Level) → Level _⊔_ : Level → Level → Level {-# BUILTIN LEVEL Level #-} {-# BUILTIN LEVELZERO zero #-} {-# BUILTIN LEVELSUC suc #-} {-# BUILTIN LEVELMAX _⊔_ #-} infixl 6 _⊔_ -- Coinduction 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 ♭ #-} -- Products infixr 4 _,_ infixr 2 _×_ record Σ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ public syntax Σ A (λ x → B) = Σ[ x ∶ A ] B _×_ : ∀ {a b} (A : Set a) (B : Set b) → Set (a ⊔ b) A × B = Σ[ x ∶ A ] B -- Streams infixr 5 _∷_ data Stream (A : Set) : Set where _∷_ : (x : A) (xs : ∞ (Stream A)) → Stream A mutual repeat : {A : Set}(a : A) → Stream A repeat a = a ∷ proj₂ (repeat' a) repeat' : {A : Set}(a : A) → A × ∞ (Stream A) repeat' a = a , ♯ repeat a
17.985075
62
0.542739
5e45ae12b939d0d04313f8a61154fe0098f26620
161
agda
Agda
test/Fail/Issue2583.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue2583.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue2583.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
data ⊥ : Set where data Maybe : Set where just : ⊥ → Maybe nothing : Maybe test : Set → Set test x with nothing test x | just () test x | nothing = test x
14.636364
25
0.63354
43586808667d944587f6dfaf416fa45b3434cc3a
5,356
agda
Agda
Cubical/Modalities/Modality.agda
Rotsor/cubical
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
[ "MIT" ]
null
null
null
Cubical/Modalities/Modality.agda
Rotsor/cubical
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
[ "MIT" ]
null
null
null
Cubical/Modalities/Modality.agda
Rotsor/cubical
d55cd4834ca1f171f58b4a0c46b804ea6d18191f
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.Modalities.Modality where {- translated from https://github.com/HoTT/HoTT-Agda/blob/master/core/lib/types/Modality.agda -} open import Cubical.Core.Everything open import Cubical.Foundations.Everything record Modality ℓ : Type (ℓ-suc ℓ) where field isModal : Type ℓ → Type ℓ isModalIsProp : {A : Type ℓ} → isProp (isModal A) ◯ : Type ℓ → Type ℓ -- \ciO ◯-isModal : {A : Type ℓ} → isModal (◯ A) η : {A : Type ℓ} → A → ◯ A ◯-elim : {A : Type ℓ} {B : ◯ A → Type ℓ} (B-modal : (x : ◯ A) → isModal (B x)) → ((x : A) → (B (η x))) → ((x : ◯ A) → B x) ◯-elim-β : {A : Type ℓ} {B : ◯ A → Type ℓ} (B-modal : (x : ◯ A) → isModal (B x)) (f : (x : A) → (B (η x))) → (a : A) → ◯-elim B-modal f (η a) ≡ f a ◯-=-isModal : {A : Type ℓ} (x y : ◯ A) → isModal (x ≡ y) ◯-Types : Type (ℓ-suc ℓ) ◯-Types = Σ[ A ∈ Type ℓ ] isModal A {- elimination rules -} module ◯Elim {A : Type ℓ} {B : ◯ A → Type ℓ} (B-modal : (x : ◯ A) → isModal (B x)) (η* : (x : A) → (B (η x))) where f : (x : ◯ A) → B x f = ◯-elim B-modal η* η-β : (a : A) → ◯-elim B-modal η* (η a) ≡ η* a η-β = ◯-elim-β B-modal η* module ◯Rec {A : Type ℓ} {B : Type ℓ} (B-modal : isModal B) (η* : A → B) = ◯Elim (λ _ → B-modal) η* ◯-rec = ◯Rec.f ◯-rec-β = ◯Rec.η-β {- functoriality -} module ◯Fmap {A B : Type ℓ} (f : A → B) = ◯Rec ◯-isModal (η ∘ f) ◯-map = ◯Fmap.f ◯-map-β = ◯Fmap.η-β ◯-preservesEquiv : {A B : Type ℓ} (f : A → B) → isEquiv f → isEquiv (◯-map f) ◯-preservesEquiv f f-ise = isoToIsEquiv (iso _ (◯-map inv) to-from from-to) where open Iso (equivToIso (f , f-ise)) abstract to-from : ∀ ◯b → ◯-map f (◯-map inv ◯b) ≡ ◯b to-from = ◯-elim (λ ◯b → ◯-=-isModal (◯-map f (◯-map inv ◯b)) ◯b) (λ b → cong (◯-map f) (◯-map-β inv b) ∙ ◯-map-β f (inv b) ∙ cong η (rightInv b)) from-to : ∀ ◯a → ◯-map inv (◯-map f ◯a) ≡ ◯a from-to = ◯-elim (λ ◯a → ◯-=-isModal (◯-map inv (◯-map f ◯a)) ◯a) (λ a → cong (◯-map inv) (◯-map-β f a) ∙ ◯-map-β inv (f a) ∙ cong η (leftInv a)) ◯-equiv : {A B : Type ℓ} → A ≃ B → ◯ A ≃ ◯ B ◯-equiv (f , f-ise) = ◯-map f , ◯-preservesEquiv f f-ise {- equivalences preserve being modal -} equivPreservesIsModal : {A B : Type ℓ} → A ≃ B → isModal A → isModal B equivPreservesIsModal eq = fst (pathToEquiv (cong isModal (ua eq))) {- modal types and [η] being an equivalence -} isModalToIsEquiv : {A : Type ℓ} → isModal A → isEquiv (η {A}) isModalToIsEquiv {A} w = isoToIsEquiv (iso (η {A}) η-inv inv-l inv-r) where η-inv : ◯ A → A η-inv = ◯-rec w (idfun A) abstract inv-r : (a : A) → η-inv (η a) ≡ a inv-r = ◯-rec-β w (idfun A) inv-l : (a : ◯ A) → η (η-inv a) ≡ a inv-l = ◯-elim (λ a₀ → ◯-=-isModal _ _) (λ a₀ → cong η (inv-r a₀)) abstract isEquivToIsModal : {A : Type ℓ} → isEquiv (η {A}) → isModal A isEquivToIsModal {A} eq = equivPreservesIsModal (invEquiv (η , eq)) ◯-isModal retractIsModal : {A B : Type ℓ} (w : isModal A) (f : A → B) (g : B → A) (r : (b : B) → f (g b) ≡ b) → isModal B retractIsModal {A} {B} w f g r = isEquivToIsModal (isoToIsEquiv (iso η η-inv inv-l inv-r)) where η-inv : ◯ B → B η-inv = f ∘ (◯-rec w g) inv-r : (b : B) → η-inv (η b) ≡ b inv-r b = cong f (◯-rec-β w g b) ∙ r b inv-l : (b : ◯ B) → η (η-inv b) ≡ b inv-l = ◯-elim (λ b → ◯-=-isModal _ _) (λ b → cong η (inv-r b)) {- function types with modal codomain are modal -} abstract Π-isModal : {A : Type ℓ} {B : A → Type ℓ} (w : (a : A) → isModal (B a)) → isModal ((x : A) → B x) Π-isModal {A} {B} w = retractIsModal {◯ _} {(x : A) → B x} ◯-isModal η-inv η r where η-inv : ◯ ((x : A) → B x) → (x : A) → B x η-inv φ' a = ◯-rec (w a) (λ φ → φ a) φ' r : (φ : (x : A) → B x) → η-inv (η φ) ≡ φ r φ = funExt (λ a → ◯-rec-β (w a) (λ φ₀ → φ₀ a) φ) →-isModal : {A B : Type ℓ} → isModal B → isModal (A → B) →-isModal w = Π-isModal (λ _ → w) {- sigma types of a modal dependent type with modal base are modal -} abstract Σ-isModal : {A : Type ℓ} (B : A → Type ℓ) → isModal A → ((a : A) → isModal (B a)) → isModal (Σ A B) Σ-isModal {A} B A-modal B-modal = retractIsModal {◯ (Σ A B)} {Σ A B} ◯-isModal η-inv η r where h : ◯ (Σ A B) → A h = ◯-rec A-modal fst h-β : (x : Σ A B) → h (η x) ≡ fst x h-β = ◯-rec-β A-modal fst f : (j : I) → (x : Σ A B) → B (h-β x j) f j x = transp (λ i → B (h-β x ((~ i) ∨ j))) j (snd x) k : (y : ◯ (Σ A B)) → B (h y) k = ◯-elim (B-modal ∘ h) (f i0) η-inv : ◯ (Σ A B) → Σ A B η-inv y = h y , k y p : (x : Σ A B) → k (η x) ≡ f i0 x p = ◯-elim-β (B-modal ∘ h) (f i0) almost : (x : Σ A B) → (h (η x) , f i0 x) ≡ x almost x i = h-β x i , f i x r : (x : Σ A B) → η-inv (η x) ≡ x r x = (λ i → h (η x) , p x i) ∙ (almost x)
32.26506
89
0.447535
5ed0c3335476cde35966ce46f6535bc2419b636f
461
agda
Agda
bool.agda
mrLSD/agda-emacs
2c92eb9520dc83f0258e43b4227ce281dfadaffe
[ "MIT" ]
null
null
null
bool.agda
mrLSD/agda-emacs
2c92eb9520dc83f0258e43b4227ce281dfadaffe
[ "MIT" ]
null
null
null
bool.agda
mrLSD/agda-emacs
2c92eb9520dc83f0258e43b4227ce281dfadaffe
[ "MIT" ]
null
null
null
module bool where ------------------------ -- Datatypes ------------------------ data 𝔹 : Set where true : 𝔹 false : 𝔹 ---------------------- -- AND ---------------------- infixr 6 _∧_ _∧_ : 𝔹 → 𝔹 → 𝔹 true ∧ b = b false ∧ b = false --------------------- -- OR --------------------- infixr 5 _∨_ _∨_ : 𝔹 → 𝔹 → 𝔹 true ∨ b = true false ∨ b = b -------------------- -- NEFATION -------------------- infixr 7 ¬_ ¬_ : 𝔹 → 𝔹 ¬ true = false ¬ false = true
13.969697
24
0.327549
5e31433dab42d82a85b04acd0c8ef470999868fd
884
agda
Agda
vendor/stdlib/src/Foreign/Haskell.agda
isabella232/Lemmachine
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
[ "MIT" ]
56
2015-01-20T02:11:42.000Z
2021-12-21T17:02:19.000Z
vendor/stdlib/src/Foreign/Haskell.agda
larrytheliquid/Lemmachine
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
[ "MIT" ]
1
2022-03-12T12:17:51.000Z
2022-03-12T12:17:51.000Z
vendor/stdlib/src/Foreign/Haskell.agda
isabella232/Lemmachine
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
[ "MIT" ]
3
2015-07-21T16:37:58.000Z
2022-03-12T11:54:10.000Z
------------------------------------------------------------------------ -- Types used (only) when calling out to Haskell via the FFI ------------------------------------------------------------------------ module Foreign.Haskell where open import Coinduction open import Data.Colist as C using ([]; _∷_) ------------------------------------------------------------------------ -- Simple types -- A unit type. data Unit : Set where unit : Unit {-# COMPILED_DATA Unit () () #-} -- Potentially infinite lists. infixr 5 _∷_ codata Colist (A : Set) : Set where [] : Colist A _∷_ : (x : A) (xs : Colist A) → Colist A {-# COMPILED_DATA Colist [] [] (:) #-} fromColist : ∀ {A} → C.Colist A → Colist A fromColist [] = [] fromColist (x ∷ xs) = x ∷ fromColist (♭ xs) toColist : ∀ {A} → Colist A → C.Colist A toColist [] = [] toColist (x ∷ xs) = x ∷ ♯ toColist xs
23.891892
72
0.45362
0485f8716af69901ed9a257f3b996e0f40ca51a8
1,143
agda
Agda
nat-log.agda
heades/AUGL
b33c6a59d664aed46cac8ef77d34313e148fecc2
[ "MIT" ]
null
null
null
nat-log.agda
heades/AUGL
b33c6a59d664aed46cac8ef77d34313e148fecc2
[ "MIT" ]
null
null
null
nat-log.agda
heades/AUGL
b33c6a59d664aed46cac8ef77d34313e148fecc2
[ "MIT" ]
null
null
null
module nat-log where open import bool open import eq open import nat open import nat-thms open import nat-division open import product data log-result (x : ℕ)(b : ℕ) : Set where pos-power : (e : ℕ) → (s : ℕ) → b pow e + s ≡ x → log-result x b no-power : x < b ≡ tt → log-result x b -- as a first version, we do not try to prove termination of this function {-# NON_TERMINATING #-} log : (x : ℕ) → (b : ℕ) → x =ℕ 0 ≡ ff → b =ℕ 0 ≡ ff → log-result x b log x b p1 p2 with x ÷ b ! p2 log x b p1 p2 | 0 , r , u1 , u2 rewrite u1 = no-power u2 log x b p1 p2 | (suc q) , r , u1 , u2 with log (suc q) b refl p2 log x b p1 p2 | (suc q) , r , u1 , u2 | no-power u rewrite sym u1 = pos-power 1 (b * q + r) lem where lem : b * 1 + (b * q + r) ≡ b + q * b + r lem rewrite *1{b} | *comm b q = +assoc b (q * b) r log x b p1 p2 | (suc q) , r , u1 , u2 | pos-power e s u rewrite sym u1 = pos-power (suc e) (b * s + r) lem where lem : b * b pow e + (b * s + r) ≡ b + q * b + r lem rewrite +assoc (b * b pow e) (b * s) r | sym (*distribl b (b pow e) s) | *comm b (b pow e + s) = sym (cong (λ i → i * b + r) (sym u))
38.1
109
0.542432
31ae06f50dcc946b15b2fb26c2a3b410e52c30d7
1,175
agda
Agda
old/Homotopy/PointConnected.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
old/Homotopy/PointConnected.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
old/Homotopy/PointConnected.agda
danbornside/HoTT-Agda
1695a7f3dc60177457855ae846bbd86fcd96983e
[ "MIT" ]
50
2015-01-10T01:48:08.000Z
2022-02-14T03:03:25.000Z
{-# OPTIONS --without-K #-} open import Base {- This file contains the lemma that a point (1 -> A) has n-connected fibers if A is (S n)-connected. The other direction will be added whenever it is needed. -} module Homotopy.PointConnected {i} (A : Set i) (a : A) where open import Homotopy.Connected open import Homotopy.Truncation open import Homotopy.PathTruncation point : unit {i} → A point _ = a abstract point-has-connected-fibers : ∀ {n} → is-connected (S n) A → has-connected-fibers n point point-has-connected-fibers {n} A-is-conn a₂ = center [a≡a₂]n , path where [a≡a₂]n : τ n (a ≡ a₂) [a≡a₂]n = connected-has-all-τ-paths A-is-conn a a₂ center : τ n (a ≡ a₂) → τ n (hfiber point a₂) center = τ-extend-nondep ⦃ τ-is-truncated n _ ⦄ (λ shift → proj $ tt , shift) path′ : ∀ f → proj f ≡ center [a≡a₂]n path′ (tt , a≡a₂) = ap center $ contr-has-all-paths (connected-has-connected-paths A-is-conn a a₂) (proj a≡a₂) [a≡a₂]n path : ∀ f → f ≡ center [a≡a₂]n path = τ-extend ⦃ λ _ → ≡-is-truncated n $ τ-is-truncated n _ ⦄ path′
28.658537
77
0.589787
8b595a714e96453efcf686669aa21f9dd0569ab9
7,128
agda
Agda
internal/well-typed-syntax-pre-interpreter.agda
JasonGross/lob
716129208eaf4fe3b5f629f95dde4254805942b3
[ "MIT" ]
19
2015-07-17T17:53:30.000Z
2021-03-17T14:04:53.000Z
internal/well-typed-syntax-pre-interpreter.agda
JasonGross/lob
716129208eaf4fe3b5f629f95dde4254805942b3
[ "MIT" ]
1
2015-07-17T20:20:43.000Z
2015-07-17T20:20:43.000Z
internal/well-typed-syntax-pre-interpreter.agda
JasonGross/lob
716129208eaf4fe3b5f629f95dde4254805942b3
[ "MIT" ]
1
2015-07-17T18:53:37.000Z
2015-07-17T18:53:37.000Z
{-# OPTIONS --without-K #-} module well-typed-syntax-pre-interpreter where open import common public open import well-typed-syntax open import well-typed-syntax-helpers max-level : Level max-level = lsuc lzero module inner (context-pick-if' : ∀ ℓ (P : Context → Set ℓ) (Γ : Context) (dummy : P (ε ▻ ‘Σ’ ‘Context’ ‘Typ’)) (val : P Γ) → P (ε ▻ ‘Σ’ ‘Context’ ‘Typ’)) (context-pick-if-refl' : ∀ ℓ P dummy val → context-pick-if' ℓ P (ε ▻ ‘Σ’ ‘Context’ ‘Typ’) dummy val ≡ val) where context-pick-if : ∀ {ℓ} {P : Context → Set ℓ} {Γ : Context} (dummy : P (ε ▻ ‘Σ’ ‘Context’ ‘Typ’)) (val : P Γ) → P (ε ▻ ‘Σ’ ‘Context’ ‘Typ’) context-pick-if {P = P} dummy val = context-pick-if' _ P _ dummy val context-pick-if-refl : ∀ {ℓ P dummy val} → context-pick-if {ℓ} {P} {ε ▻ ‘Σ’ ‘Context’ ‘Typ’} dummy val ≡ val context-pick-if-refl {P = P} = context-pick-if-refl' _ P _ _ private dummy : Typ ε dummy = ‘Context’ cast-helper : ∀ {X T A} {x : Term X} → A ≡ T → Term {ε} (T ‘’ x ‘→'’ A ‘’ x) cast-helper refl = ‘λ∙’ ‘VAR₀’ cast'-proof : ∀ {T} → Term {ε} (context-pick-if {P = Typ} (W dummy) T ‘’ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T ‘→'’ T ‘’ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T) cast'-proof {T} = cast-helper {‘Σ’ ‘Context’ ‘Typ’} {context-pick-if {P = Typ} {ε ▻ ‘Σ’ ‘Context’ ‘Typ’} (W dummy) T} {T} (sym (context-pick-if-refl {P = Typ} {dummy = W dummy})) cast-proof : ∀ {T} → Term {ε} (T ‘’ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T ‘→'’ context-pick-if {P = Typ} (W dummy) T ‘’ ‘existT’ ⌜ ε ▻ ‘Σ’ ‘Context’ ‘Typ’ ⌝c ⌜ T ⌝T) cast-proof {T} = cast-helper {‘Σ’ ‘Context’ ‘Typ’} {T} {context-pick-if {P = Typ} {ε ▻ ‘Σ’ ‘Context’ ‘Typ’} (W dummy) T} (context-pick-if-refl {P = Typ} {dummy = W dummy}) ‘idfun’ : ∀ {T} → Term {ε} (T ‘→'’ T) ‘idfun’ = ‘λ∙’ ‘VAR₀’ mutual Context⇓ : (Γ : Context) → Set (lsuc max-level) Typ⇓ : {Γ : Context} → Typ Γ → Context⇓ Γ → Set max-level Context⇓ ε = ⊤ Context⇓ (Γ ▻ T) = Σ (Context⇓ Γ) (λ Γ' → Typ⇓ T Γ') Typ⇓ (T₁ ‘’ x) Γ⇓ = Typ⇓ T₁ (Γ⇓ , Term⇓ x Γ⇓) Typ⇓ (T₂ ‘’₁ a) (Γ⇓ , A⇓) = Typ⇓ T₂ ((Γ⇓ , Term⇓ a Γ⇓) , A⇓) Typ⇓ (T₃ ‘’₂ a) ((Γ⇓ , A⇓) , B⇓) = Typ⇓ T₃ (((Γ⇓ , Term⇓ a Γ⇓) , A⇓) , B⇓) Typ⇓ (T₃ ‘’₃ a) (((Γ⇓ , A⇓) , B⇓) , C⇓) = Typ⇓ T₃ ((((Γ⇓ , Term⇓ a Γ⇓) , A⇓) , B⇓) , C⇓) Typ⇓ (W T₁) (Γ⇓ , _) = Typ⇓ T₁ Γ⇓ Typ⇓ (W1 T₂) ((Γ⇓ , A⇓) , B⇓) = Typ⇓ T₂ (Γ⇓ , B⇓) Typ⇓ (W2 T₃) (((Γ⇓ , A⇓) , B⇓) , C⇓) = Typ⇓ T₃ ((Γ⇓ , B⇓) , C⇓) Typ⇓ (T ‘→’ T₁) Γ⇓ = (T⇓ : Typ⇓ T Γ⇓) → Typ⇓ T₁ (Γ⇓ , T⇓) Typ⇓ ‘Context’ Γ⇓ = Lifted Context Typ⇓ ‘Typ’ (Γ⇓ , T⇓) = Lifted (Typ (lower T⇓)) Typ⇓ ‘Term’ (Γ⇓ , T⇓ , t⇓) = Lifted (Term (lower t⇓)) Typ⇓ (‘Σ’ T T₁) Γ⇓ = Σ (Typ⇓ T Γ⇓) (λ T⇓ → Typ⇓ T₁ (Γ⇓ , T⇓)) Term⇓ : ∀ {Γ : Context} {T : Typ Γ} → Term T → (Γ⇓ : Context⇓ Γ) → Typ⇓ T Γ⇓ Term⇓ (w t) (Γ⇓ , A⇓) = Term⇓ t Γ⇓ Term⇓ (‘λ∙’ t) Γ⇓ T⇓ = Term⇓ t (Γ⇓ , T⇓) Term⇓ (t ‘’ₐ t₁) Γ⇓ = Term⇓ t Γ⇓ (Term⇓ t₁ Γ⇓) Term⇓ ‘VAR₀’ (Γ⇓ , A⇓) = A⇓ Term⇓ (⌜ Γ ⌝c) Γ⇓ = lift Γ Term⇓ (⌜ T ⌝T) Γ⇓ = lift T Term⇓ (⌜ t ⌝t) Γ⇓ = lift t Term⇓ ‘quote-term’ Γ⇓ (lift T⇓) = lift ⌜ T⇓ ⌝t Term⇓ (‘quote-sigma’ {Γ₀} {Γ₁}) Γ⇓ (lift Γ , lift T) = lift (‘existT’ {Γ₁} ⌜ Γ ⌝c ⌜ T ⌝T) Term⇓ ‘cast’ Γ⇓ T⇓ = lift (context-pick-if {P = Typ} {lower (Σ.proj₁ T⇓)} (W dummy) (lower (Σ.proj₂ T⇓))) Term⇓ (SW t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (substTyp-weakenTyp1-VAR₀ t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (weakenTyp-tProd-inv t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (weakenTyp-weakenTyp-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (substTyp1-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (weakenTyp1-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (substTyp2-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (substTyp1-substTyp-weakenTyp-inv t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp1-substTyp-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-weakenTyp-substTyp1-substTyp-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp2-substTyp1-substTyp-weakenTyp-inv t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp2-substTyp1-substTyp-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp2-substTyp1-substTyp-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (weakenTyp2-weakenTyp1 t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp1-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp1-weakenTyp-inv t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp1-weakenTyp1-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp1-weakenTyp1 t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp1-substTyp-weakenTyp1-inv t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp1-substTyp-weakenTyp1 t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp-substTyp-weakenTyp1 t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp-substTyp-weakenTyp1-inv t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp-weakenTyp1-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp3-substTyp2-substTyp1-substTyp-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-substTyp2-substTyp1-substTyp-weakenTyp1 t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp1-substTyp-tProd t) Γ⇓ T⇓ = Term⇓ t Γ⇓ T⇓ Term⇓ (substTyp2-substTyp-substTyp-weakenTyp1-weakenTyp-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (substTyp1-substTyp-weakenTyp2-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (weakenTyp-weakenTyp1-weakenTyp t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ (beta-under-subst t) Γ⇓ = Term⇓ t Γ⇓ Term⇓ ‘proj₁'’ Γ⇓ (x , p) = x Term⇓ ‘proj₂'’ (Γ⇓ , (x , p)) = p Term⇓ (‘existT’ x p) Γ⇓ = Term⇓ x Γ⇓ , Term⇓ p Γ⇓ Term⇓ (f ‘‘’’ x) Γ⇓ = lift (lower (Term⇓ f Γ⇓) ‘’ lower (Term⇓ x Γ⇓)) Term⇓ (f w‘‘’’ x) Γ⇓ = lift (lower (Term⇓ f Γ⇓) ‘’ lower (Term⇓ x Γ⇓)) Term⇓ (f ‘‘→'’’ x) Γ⇓ = lift (lower (Term⇓ f Γ⇓) ‘→'’ lower (Term⇓ x Γ⇓)) Term⇓ (f w‘‘→'’’ x) Γ⇓ = lift (lower (Term⇓ f Γ⇓) ‘→'’ lower (Term⇓ x Γ⇓)) Term⇓ (w→ x) Γ⇓ A⇓ = Term⇓ x (Σ.proj₁ Γ⇓) A⇓ Term⇓ w‘‘→'’’→‘‘→'’’ Γ⇓ T⇓ = T⇓ Term⇓ ‘‘→'’’→w‘‘→'’’ Γ⇓ T⇓ = T⇓ Term⇓ ‘tApp-nd’ Γ⇓ f⇓ x⇓ = lift (SW (lower f⇓ ‘’ₐ lower x⇓)) Term⇓ ⌜←'⌝ Γ⇓ T⇓ = T⇓ Term⇓ ⌜→'⌝ Γ⇓ T⇓ = T⇓ Term⇓ (‘‘fcomp-nd’’ {A} {B} {C}) Γ⇓ g⇓ f⇓ = lift (_‘∘’_ {ε} (lower g⇓) (lower f⇓)) Term⇓ (⌜‘’⌝ {B} {A} {b}) Γ⇓ = lift (‘λ∙’ {ε} (‘VAR₀’ {ε} {_‘’_ {ε} A b})) Term⇓ (⌜‘’⌝' {B} {A} {b}) Γ⇓ = lift (‘λ∙’ {ε} (‘VAR₀’ {ε} {_‘’_ {ε} A b})) Term⇓ (‘cast-refl’ {T}) Γ⇓ = lift (cast-proof {T}) Term⇓ (‘cast-refl'’ {T}) Γ⇓ = lift (cast'-proof {T}) Term⇓ (‘s→→’ {T} {B} {b} {c} {v}) Γ⇓ = lift (‘idfun’ {_‘’_ {ε} (lower (Term⇓ b tt (Term⇓ v Γ⇓))) (lower (Term⇓ c tt (Term⇓ v Γ⇓)))}) Term⇓ (‘s←←’ {T} {B} {b} {c} {v}) Γ⇓ = lift (‘idfun’ {_‘’_ {ε} (lower (Term⇓ b tt (Term⇓ v Γ⇓))) (lower (Term⇓ c tt (Term⇓ v Γ⇓)))})
51.280576
136
0.481341
a035eb088cef358b6d44920aa97c6435105e4fd6
1,060
agda
Agda
Cubical/HITs/Nullification/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/HITs/Nullification/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
Cubical/HITs/Nullification/Base.agda
borsiemir/cubical
cefeb3669ffdaea7b88ae0e9dd258378418819ca
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Nullification.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.PathSplitEquiv open isPathSplitEquiv isNull : ∀ {ℓ ℓ'} (S : Type ℓ) (A : Type ℓ') → Type (ℓ-max ℓ ℓ') isNull S A = isPathSplitEquiv (const {A = A} {B = S}) data Null {ℓ ℓ'} (S : Type ℓ) (A : Type ℓ') : Type (ℓ-max ℓ ℓ') where ∣_∣ : A → Null S A -- the image of every map (S → Null S A) is contractible in Null S A hub : (f : S → Null S A) → Null S A spoke : (f : S → Null S A) (s : S) → hub f ≡ f s -- the image of every map (S → x ≡ y) for x y : A is contractible in x ≡ y ≡hub : ∀ {x y} (p : S → x ≡ y) → x ≡ y ≡spoke : ∀ {x y} (p : S → x ≡ y) (s : S) → ≡hub p ≡ p s isNull-Null : ∀ {ℓ ℓ'} {S : Type ℓ} {A : Type ℓ'} → isNull S (Null S A) fst (sec isNull-Null) f = hub f snd (sec isNull-Null) f i s = spoke f s i fst (secCong isNull-Null x y) p i = ≡hub (funExt⁻ p) i snd (secCong isNull-Null x y) p i j s = ≡spoke (funExt⁻ p) s i j
40.769231
76
0.583962