Search is not available for this dataset
text
string
meta
dict
------------------------------------------------------------------------ -- The Agda standard library -- -- Vectors ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec where open import Data.Nat open import Data.Fin using (Fin; zero; suc) open import Data.List.Base as List using (List) open import Data.Product as Prod using (∃; ∃₂; _×_; _,_) open import Data.These as These using (These; this; that; these) open import Function open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Relation.Nullary using (yes; no) open import Relation.Unary using (Pred; Decidable) ------------------------------------------------------------------------ -- Types infixr 5 _∷_ data Vec {a} (A : Set a) : ℕ → Set a where [] : Vec A zero _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n) infix 4 _[_]=_ data _[_]=_ {a} {A : Set a} : {n : ℕ} → Vec A n → Fin n → A → Set a where here : ∀ {n} {x} {xs : Vec A n} → x ∷ xs [ zero ]= x there : ∀ {n} {i} {x y} {xs : Vec A n} (xs[i]=x : xs [ i ]= x) → y ∷ xs [ suc i ]= x ------------------------------------------------------------------------ -- Basic operations module _ {a} {A : Set a} where head : ∀ {n} → Vec A (1 + n) → A head (x ∷ xs) = x tail : ∀ {n} → Vec A (1 + n) → Vec A n tail (x ∷ xs) = xs lookup : ∀ {n} → Vec A n → Fin n → A lookup (x ∷ xs) zero = x lookup (x ∷ xs) (suc i) = lookup xs i insert : ∀ {n} → Vec A n → Fin (suc n) → A → Vec A (suc n) insert xs zero v = v ∷ xs insert [] (suc ()) v insert (x ∷ xs) (suc i) v = x ∷ insert xs i v remove : ∀ {n} → Vec A (suc n) → Fin (suc n) → Vec A n remove (_ ∷ xs) zero = xs remove (x ∷ []) (suc ()) remove (x ∷ y ∷ xs) (suc i) = x ∷ remove (y ∷ xs) i updateAt : ∀ {n} → Fin n → (A → A) → Vec A n → Vec A n updateAt zero f (x ∷ xs) = f x ∷ xs updateAt (suc i) f (x ∷ xs) = x ∷ updateAt i f xs -- xs [ i ]%= f modifies the i-th element of xs according to f infixl 6 _[_]%=_ _[_]%=_ : ∀ {n} → Vec A n → Fin n → (A → A) → Vec A n xs [ i ]%= f = updateAt i f xs -- xs [ i ]≔ y overwrites the i-th element of xs with y infixl 6 _[_]≔_ _[_]≔_ : ∀ {n} → Vec A n → Fin n → A → Vec A n xs [ i ]≔ y = xs [ i ]%= const y ------------------------------------------------------------------------ -- Operations for transforming vectors map : ∀ {a b n} {A : Set a} {B : Set b} → (A → B) → Vec A n → Vec B n map f [] = [] map f (x ∷ xs) = f x ∷ map f xs -- Concatenation. infixr 5 _++_ _++_ : ∀ {a m n} {A : Set a} → Vec A m → Vec A n → Vec A (m + n) [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) concat : ∀ {a m n} {A : Set a} → Vec (Vec A m) n → Vec A (n * m) concat [] = [] concat (xs ∷ xss) = xs ++ concat xss -- Align and Zip. module _ {a b c} {A : Set a} {B : Set b} {C : Set c} where alignWith : ∀ {m n} → (These A B → C) → Vec A m → Vec B n → Vec C (m ⊔ n) alignWith f [] bs = map (f ∘′ that) bs alignWith f as@(_ ∷ _) [] = map (f ∘′ this) as alignWith f (a ∷ as) (b ∷ bs) = f (these a b) ∷ alignWith f as bs zipWith : ∀ {n} → (A → B → C) → Vec A n → Vec B n → Vec C n zipWith f [] [] = [] zipWith f (x ∷ xs) (y ∷ ys) = f x y ∷ zipWith f xs ys unzipWith : ∀ {n} → (A → B × C) → Vec A n → Vec B n × Vec C n unzipWith f [] = [] , [] unzipWith f (a ∷ as) = Prod.zip _∷_ _∷_ (f a) (unzipWith f as) module _ {a b} {A : Set a} {B : Set b} where align : ∀ {m n} → Vec A m → Vec B n → Vec (These A B) (m ⊔ n) align = alignWith id zip : ∀ {n} → Vec A n → Vec B n → Vec (A × B) n zip = zipWith _,_ unzip : ∀ {n} → Vec (A × B) n → Vec A n × Vec B n unzip = unzipWith id -- Interleaving. infixr 5 _⋎_ _⋎_ : ∀ {a m n} {A : Set a} → Vec A m → Vec A n → Vec A (m +⋎ n) [] ⋎ ys = ys (x ∷ xs) ⋎ ys = x ∷ (ys ⋎ xs) -- Pointwise application infixl 4 _⊛_ _⊛_ : ∀ {a b n} {A : Set a} {B : Set b} → Vec (A → B) n → Vec A n → Vec B n [] ⊛ _ = [] (f ∷ fs) ⊛ (x ∷ xs) = f x ∷ (fs ⊛ xs) -- Multiplication infixl 1 _>>=_ _>>=_ : ∀ {a b m n} {A : Set a} {B : Set b} → Vec A m → (A → Vec B n) → Vec B (m * n) xs >>= f = concat (map f xs) infixl 4 _⊛*_ _⊛*_ : ∀ {a b m n} {A : Set a} {B : Set b} → Vec (A → B) m → Vec A n → Vec B (m * n) fs ⊛* xs = fs >>= λ f → map f xs allPairs : ∀ {a b m n} {A : Set a} {B : Set b} → Vec A m → Vec B n → Vec (A × B) (m * n) allPairs xs ys = map _,_ xs ⊛* ys ------------------------------------------------------------------------ -- Operations for reducing vectors foldr : ∀ {a b} {A : Set a} (B : ℕ → Set b) {m} → (∀ {n} → A → B n → B (suc n)) → B zero → Vec A m → B m foldr b _⊕_ n [] = n foldr b _⊕_ n (x ∷ xs) = x ⊕ foldr b _⊕_ n xs foldr₁ : ∀ {a} {A : Set a} {m} → (A → A → A) → Vec A (suc m) → A foldr₁ _⊕_ (x ∷ []) = x foldr₁ _⊕_ (x ∷ y ∷ ys) = x ⊕ foldr₁ _⊕_ (y ∷ ys) foldl : ∀ {a b} {A : Set a} (B : ℕ → Set b) {m} → (∀ {n} → B n → A → B (suc n)) → B zero → Vec A m → B m foldl b _⊕_ n [] = n foldl b _⊕_ n (x ∷ xs) = foldl (λ n → b (suc n)) _⊕_ (n ⊕ x) xs foldl₁ : ∀ {a} {A : Set a} {m} → (A → A → A) → Vec A (suc m) → A foldl₁ _⊕_ (x ∷ xs) = foldl _ _⊕_ x xs -- Special folds sum : ∀ {n} → Vec ℕ n → ℕ sum = foldr _ _+_ 0 count : ∀ {a p} {A : Set a} {P : Pred A p} → Decidable P → ∀ {n} → Vec A n → ℕ count P? [] = zero count P? (x ∷ xs) with P? x ... | yes _ = suc (count P? xs) ... | no _ = count P? xs ------------------------------------------------------------------------ -- Operations for building vectors [_] : ∀ {a} {A : Set a} → A → Vec A 1 [ x ] = x ∷ [] replicate : ∀ {a n} {A : Set a} → A → Vec A n replicate {n = zero} x = [] replicate {n = suc n} x = x ∷ replicate x tabulate : ∀ {n a} {A : Set a} → (Fin n → A) → Vec A n tabulate {zero} f = [] tabulate {suc n} f = f zero ∷ tabulate (f ∘ suc) allFin : ∀ n → Vec (Fin n) n allFin _ = tabulate id ------------------------------------------------------------------------ -- Operations for dividing vectors splitAt : ∀ {a} {A : Set a} m {n} (xs : Vec A (m + n)) → ∃₂ λ (ys : Vec A m) (zs : Vec A n) → xs ≡ ys ++ zs splitAt zero xs = ([] , xs , refl) splitAt (suc m) (x ∷ xs) with splitAt m xs splitAt (suc m) (x ∷ .(ys ++ zs)) | (ys , zs , refl) = ((x ∷ ys) , zs , refl) take : ∀ {a} {A : Set a} m {n} → Vec A (m + n) → Vec A m take m xs with splitAt m xs take m .(ys ++ zs) | (ys , zs , refl) = ys drop : ∀ {a} {A : Set a} m {n} → Vec A (m + n) → Vec A n drop m xs with splitAt m xs drop m .(ys ++ zs) | (ys , zs , refl) = zs group : ∀ {a} {A : Set a} n k (xs : Vec A (n * k)) → ∃ λ (xss : Vec (Vec A k) n) → xs ≡ concat xss group zero k [] = ([] , refl) group (suc n) k xs with splitAt k xs group (suc n) k .(ys ++ zs) | (ys , zs , refl) with group n k zs group (suc n) k .(ys ++ concat zss) | (ys , ._ , refl) | (zss , refl) = ((ys ∷ zss) , refl) split : ∀ {a n} {A : Set a} → Vec A n → Vec A ⌈ n /2⌉ × Vec A ⌊ n /2⌋ split [] = ([] , []) split (x ∷ []) = (x ∷ [] , []) split (x ∷ y ∷ xs) = Prod.map (x ∷_) (y ∷_) (split xs) ------------------------------------------------------------------------ -- Operations for converting between lists toList : ∀ {a n} {A : Set a} → Vec A n → List A toList [] = List.[] toList (x ∷ xs) = List._∷_ x (toList xs) fromList : ∀ {a} {A : Set a} → (xs : List A) → Vec A (List.length xs) fromList List.[] = [] fromList (List._∷_ x xs) = x ∷ fromList xs ------------------------------------------------------------------------ -- Operations for reversing vectors reverse : ∀ {a n} {A : Set a} → Vec A n → Vec A n reverse {A = A} = foldl (Vec A) (λ rev x → x ∷ rev) [] infixl 5 _∷ʳ_ _∷ʳ_ : ∀ {a n} {A : Set a} → Vec A n → A → Vec A (1 + n) [] ∷ʳ y = [ y ] (x ∷ xs) ∷ʳ y = x ∷ (xs ∷ʳ y) initLast : ∀ {a n} {A : Set a} (xs : Vec A (1 + n)) → ∃₂ λ (ys : Vec A n) (y : A) → xs ≡ ys ∷ʳ y initLast {n = zero} (x ∷ []) = ([] , x , refl) initLast {n = suc n} (x ∷ xs) with initLast xs initLast {n = suc n} (x ∷ .(ys ∷ʳ y)) | (ys , y , refl) = ((x ∷ ys) , y , refl) init : ∀ {a n} {A : Set a} → Vec A (1 + n) → Vec A n init xs with initLast xs init .(ys ∷ʳ y) | (ys , y , refl) = ys last : ∀ {a n} {A : Set a} → Vec A (1 + n) → A last xs with initLast xs last .(ys ∷ʳ y) | (ys , y , refl) = y
{ "alphanum_fraction": 0.4265386395, "avg_line_length": 29.9100346021, "ext": "agda", "hexsha": "373f8dbedec17fe9c103bde8f60f86b64f8495a0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3414, "size": 8644 }
open import Prelude hiding (abs) open import Container.List open import Container.Traversable open import Tactic.Reflection hiding (substArgs) renaming (unify to unifyTC) open import Tactic.Reflection.Equality open import Tactic.Deriving module Tactic.Deriving.Eq where _∋_ : ∀ {a} (A : Set a) → A → A A ∋ x = x private -- Pattern synonyms -- infix 5 _`≡_ pattern _`≡_ x y = def₂ (quote _≡_) x y pattern `subst x y z = def₃ (quote transport) x y z pattern `refl = con (quote refl) [] pattern `Eq a = def (quote Eq) (vArg a ∷ []) pattern vLam s t = lam visible (abs s t) -- Helper functions -- nLam : ∀ {A} → List (Arg A) → Term → Term nLam [] t = t nLam (arg (arg-info v _) s ∷ tel) t = lam v (abs "x" (nLam tel t)) nPi : ∀ {A} → List (Arg A) → Term → Term nPi [] t = t nPi (arg i _ ∷ tel) t = pi (arg i unknown) (abs "x" (nPi tel t)) newArgs : ∀ {A} → List (Arg A) → List (Arg Term) newArgs {A} tel = newArgsFrom (length tel) tel where newArgsFrom : Nat → List (Arg A) → List (Arg Term) newArgsFrom (suc n) (arg i _ ∷ tel) = arg i (var n []) ∷ newArgsFrom n tel newArgsFrom _ _ = [] hideTel : ∀ {A} → List (Arg A) → List (Arg A) hideTel [] = [] hideTel (arg (arg-info _ r) t ∷ tel) = arg (arg-info hidden r) t ∷ hideTel tel weakenTelFrom : (from n : Nat) → Telescope → Telescope weakenTelFrom from n [] = [] weakenTelFrom from n (t ∷ tel) = weakenFrom from n t ∷ weakenTelFrom (suc from) n tel weakenTel : (n : Nat) → Telescope → Telescope weakenTel 0 = id weakenTel n = weakenTelFrom 0 n #pars : (d : Name) → TC Nat #pars = getParameters argsTel : (c : Name) → TC Telescope argsTel c = caseM telView <$> getType c of λ { (tel , def d ixs) → flip drop tel <$> #pars d ; (tel , _ ) → pure tel } #args : (c : Name) → TC Nat #args c = length <$> argsTel c params : (c : Name) → TC (List (Arg Type)) params c = telView <$> getType c >>= λ { (tel , def d ixs) → flip take tel <$> #pars d ; _ → pure [] } -- Parallel substitution -- Substitution : Set Substitution = List (Nat × Term) underLambda : Substitution → Substitution underLambda = map (λ { (i , t) → suc i , weaken 1 t }) {-# TERMINATING #-} subst : Substitution → Term → Term apply : Term → List (Arg Term) → Term substArgs : Substitution → List (Arg Term) → List (Arg Term) subst sub (var x args) = case (lookup sub x) of λ { (just s) → apply s (substArgs sub args) ; nothing → var x (substArgs sub args) } subst sub (con c args) = con c (substArgs sub args) subst sub (def f args) = def f (substArgs sub args) subst sub (lam v t) = lam v (fmap (subst (underLambda sub)) t) subst sub (lit l) = lit l subst sub _ = unknown -- TODO apply f [] = f apply (var x args) xs = var x (args ++ xs) apply (con c args) xs = con c (args ++ xs) apply (def f args) xs = def f (args ++ xs) apply (lam _ (abs _ t)) (arg _ x ∷ xs) = case (strengthen 1 (subst ((0 , weaken 1 x) ∷ []) t)) of λ { (just f) → apply f xs ; nothing → unknown } apply _ _ = unknown -- TODO substArgs sub = map (fmap (subst sub)) -- Unification of datatype indices -- data Unify : Set where positive : List (Nat × Term) → Unify negative : Unify failure : ∀ {a} {A : Set a} → String → TC A failure s = typeErrorS ("Unification error when deriving Eq: " & s) _&U_ : Unify → Unify → Unify (positive xs) &U (positive ys) = positive (xs ++ ys) (positive _) &U negative = negative negative &U (positive _) = negative negative &U negative = negative {-# TERMINATING #-} unify : Term → Term → TC Unify unifyArgs : List (Arg Term) → List (Arg Term) → TC Unify unify s t with s == t unify s t | yes _ = pure (positive []) unify (var x []) (var y []) | no _ = if (x <? y) -- In var-var case, instantiate the one that is bound the closest to us. then pure (positive ((x , var y []) ∷ [])) else pure (positive ((y , var x []) ∷ [])) unify (var x []) t | no _ = if (elem x (freeVars t)) then failure "cyclic occurrence" -- We don't currently know if the occurrence is rigid or not else pure (positive ((x , t) ∷ [])) unify t (var x []) | no _ = if (elem x (freeVars t)) then failure "cyclic occurrence" else pure (positive ((x , t) ∷ [])) unify (con c₁ xs₁) (con c₂ xs₂) | no _ = if (isYes (c₁ == c₂)) then unifyArgs xs₁ xs₂ else pure negative unify _ _ | no _ = failure "not a constructor or a variable" unifyArgs [] [] = pure (positive []) unifyArgs [] (_ ∷ _) = failure "panic: different number of arguments" unifyArgs (_ ∷ _) [] = failure "panic: different number of arguments" unifyArgs (arg v₁ x ∷ xs) (arg v₂ y ∷ ys) = if isYes (_==_ {{EqArgInfo}} v₁ v₂) then (unify x y >>= λ { (positive sub) → (positive sub &U_) <$> unifyArgs (substArgs sub xs) (substArgs sub ys) ; negative → pure negative }) else failure "panic: hiding mismatch" unifyIndices : (c₁ c₂ : Name) → TC Unify unifyIndices c₁ c₂ = do let panic = failure "panic: constructor type doesn't end in a def" tel₁ , def d₁ xs₁ ← telView <$> getType c₁ where _ → panic tel₂ , def d₂ xs₂ ← telView <$> getType c₂ where _ → panic n₁ ← #pars d₁ n₂ ← #pars d₂ let ixs₁ = drop n₁ xs₁ ixs₂ = drop n₂ xs₂ unifyArgs (weaken (length tel₂ - n₂) ixs₁) -- weaken all variables of first constructor by number of arguments of second constructor (weakenFrom (length tel₂ - n₂) (length tel₁ - n₁) ixs₂) -- weaken parameters of second constructor by number of arguments of first constructor -- Analysing constructor types -- forcedArgs : (c : Name) → TC (List Nat) forcedArgs c = caseM (unifyIndices c c) of λ { (positive xs) → pure (map fst xs) ; _ → pure [] } data Forced : Set where forced free : Forced instance DeBruijnForced : DeBruijn Forced strengthenFrom {{DeBruijnForced}} _ _ = just weakenFrom {{DeBruijnForced}} _ _ = id DeBruijnProd : {A B : Set} {{_ : DeBruijn A}} {{_ : DeBruijn B}} → DeBruijn (A × B) strengthenFrom {{DeBruijnProd}} m n (x , y) = ⦇ strengthenFrom m n x , strengthenFrom m n y ⦈ weakenFrom {{DeBruijnProd}} m n (x , y) = weakenFrom m n x , weakenFrom m n y RemainingArgs : Nat → Set RemainingArgs = Vec (Arg (Forced × Term × Term)) leftArgs : ∀ {n} → RemainingArgs n → List (Arg Term) leftArgs = map (fmap (fst ∘ snd)) ∘ vecToList rightArgs : ∀ {n} → RemainingArgs n → List (Arg Term) rightArgs = map (fmap (snd ∘ snd)) ∘ vecToList classifyArgs : (c : Name) → TC (Σ Nat RemainingArgs) classifyArgs c = do #argsc ← #args c forcedc ← forcedArgs c let #freec = #argsc - length forcedc _,_ _ ∘ classify #freec forcedc (#argsc - 1) (#freec - 1) <$> argsTel c -- The final argument should be (weakenTel (#argsc + #freec) (argsTel c)), -- but we don't really care about the types of the arguments anyway. where classify : Nat → List Nat → (m n : Nat) (tel : List (Arg Type)) → RemainingArgs (length tel) classify _ _ m n [] = [] classify #freec forcedc m n (arg i ty ∷ tel) = if (elem m forcedc) then arg i (forced , var (#freec + m) [] , var (#freec + m) []) ∷ classify #freec forcedc (m - 1) n tel else arg i (free , var (#freec + m) [] , var n []) ∷ classify #freec forcedc (m - 1) (n - 1) tel rightArgsFree : ∀ {n} → RemainingArgs n → List (Arg Term) rightArgsFree [] = [] rightArgsFree (arg _ (forced , _ , _) ∷ xs) = rightArgsFree xs rightArgsFree (arg i (free , _ , x) ∷ xs) = arg i x ∷ rightArgsFree xs countFree : ∀ {n} → RemainingArgs n → Nat countFree xs = length (rightArgsFree xs) refreshArgs : ∀ {n} → RemainingArgs n → RemainingArgs n refreshArgs xs = refresh (nfree - 1) xs where nfree = countFree xs refresh : ∀ {n} → Nat → RemainingArgs n → RemainingArgs n refresh n [] = [] refresh n (arg i (forced , x , y) ∷ xs) = arg i (forced , x , y) ∷ refresh n xs refresh n (arg i (free , x , y) ∷ xs) = arg i (free , x , var n []) ∷ refresh (n - 1) xs -- Matching constructor case -- caseDec : ∀ {a b} {A : Set a} {B : Set b} → Dec A → (A → B) → (¬ A → B) → B caseDec (yes x) y n = y x caseDec (no x) y n = n x checkEqArgs : ∀ {n} (c : Name) (xs : List (Arg Term)) (ys : RemainingArgs n) → Term checkEqArgs c xs (arg i (forced , y , z) ∷ args) = checkEqArgs c (xs ++ [ arg i y ]) args checkEqArgs {suc remainingArgs} c xs (arg i (free , y , z) ∷ args) = def₃ (quote caseDec) (def₂ (quote _==_) y z) (vLam "x≡y" checkEqArgsYes) (vLam "x≢y" checkEqArgsNo) where remainingFree = countFree args wk : {A : Set} {{_ : DeBruijn A}} → Nat → A → A wk k = weaken (k + remainingFree) checkEqArgsYes : Term checkEqArgsYes = def (quote transport) ( (vArg (vLam "x" (nPi (rightArgsFree args) (def₁ (quote Dec) (wk 2 (con c (xs ++ arg i y ∷ (leftArgs args))) `≡ con c (wk 2 xs ++ arg i (var remainingFree []) ∷ rightArgs (refreshArgs (wk 2 args)))))))) ∷ (vArg (var 0 [])) ∷ (vArg (nLam (rightArgsFree args) (checkEqArgs c (wk 1 (xs ++ [ arg i y ])) (refreshArgs (wk 1 args))))) ∷ weaken 1 (rightArgsFree args)) checkEqArgsNo : Term checkEqArgsNo = con₁ (quote no) (vLam "eq" (var 1 (vArg (def₃ (quote _∋_) (nPi (hideTel (arg i z ∷ rightArgsFree args)) (weaken (3 + remainingFree) (con c (xs ++ arg i y ∷ leftArgs args)) `≡ con c (wk 3 xs ++ arg i (var remainingFree []) ∷ rightArgs (refreshArgs (wk 3 args))) `→ wk 4 y `≡ var (1 + remainingFree) [])) (pat-lam (clause (replicate (1 + remainingFree) (hArg dot) ++ vArg `refl ∷ []) `refl ∷ []) []) (var 0 [])) ∷ []))) checkEqArgs _ _ _ = con₁ (quote yes) (con₀ (quote refl)) matchingClause : (c : Name) → TC Clause matchingClause c = do _ , args ← classifyArgs c paramPats ← map (fmap λ _ → var "A") ∘ hideTel <$> params c params ← makeParams args pure (clause (paramPats ++ vArg (con c (makeLeftPattern args)) ∷ vArg (con c (makeRightPattern args)) ∷ []) (checkEqArgs c params args)) where args = classifyArgs c makeParamsPats : TC (List (Arg Pattern)) makeParamsPats = map (fmap λ _ → var "A") ∘ hideTel <$> params c makeParams : ∀ {n} → RemainingArgs n → TC (List (Arg Term)) makeParams args = do ps ← params c pure (weaken (length (vecToList args) + countFree args) (newArgs ps)) makeLeftPattern : ∀ {n} → RemainingArgs n → List (Arg Pattern) makeLeftPattern [] = [] makeLeftPattern (arg i _ ∷ xs) = arg i (var "x") ∷ makeLeftPattern xs makeRightPattern : ∀ {n} → RemainingArgs n → List (Arg Pattern) makeRightPattern [] = [] makeRightPattern (arg i (forced , _ , _) ∷ xs) = arg i dot ∷ makeRightPattern xs makeRightPattern (arg i (free , _ , _) ∷ xs) = arg i (var "y") ∷ makeRightPattern xs -- Mismatching constructor case -- mismatchingClause : (c₁ c₂ : Name) (fs : List Nat) → TC Clause mismatchingClause c₁ c₂ fs = do args₁ ← argsTel c₁ args₂ ← argsTel c₂ let #args₁ = length args₁ #args₂ = length args₂ pure (clause (vArg (con c₁ (makePattern (#args₁ + #args₂ - 1) args₁)) ∷ vArg (con c₂ (makePattern (#args₂ - 1) args₂)) ∷ []) (con (quote no) ([ vArg (pat-lam ([ absurd-clause ([ vArg absurd ]) ]) []) ]))) where makePattern : (k : Nat) (args : List (Arg Type)) → List (Arg Pattern) makePattern k [] = [] makePattern k (arg i _ ∷ args) = (if (elem k fs) then (arg i dot) else arg i (var "x")) ∷ makePattern (k - 1) args -- Clauses -- makeClause : (c₁ c₂ : Name) → TC (List Clause) makeClause c₁ c₂ = case (c₁ == c₂) of λ { (yes _) → _∷ [] <$> matchingClause c₁ ; (no _) → caseM (unifyIndices c₁ c₂) of λ { (positive fs) → _∷ [] <$> mismatchingClause c₁ c₂ (map fst fs) ; _ → pure [] } } constructorPairs : (d : Name) → TC (List (Name × Name)) constructorPairs d = caseM getDefinition d of λ { (data-type _ cs) → pure $ concat (map (λ c₁ → map (_,_ c₁) cs) cs) ; _ → pure [] } eqDefinition : (d : Name) → TC (List Clause) eqDefinition d = concat <$> (mapM (uncurry makeClause) =<< constructorPairs d) makeArgs : Nat → List (Arg Nat) → List (Arg Term) makeArgs n xs = reverse $ map (fmap (λ i → var (n - i - 1) [])) xs computeInstanceType : Nat → List (Arg Nat) → Type → Maybe Term computeInstanceType n xs (agda-sort _) = just (`Eq (var n (makeArgs n xs))) computeInstanceType n xs (pi a (abs s b)) = pi (hArg (unArg a)) ∘ abs s <$> computeInstanceType (suc n) ((n <$ a) ∷ xs) b computeInstanceType _ _ _ = nothing computeType : Name → Nat → List (Arg Nat) → Telescope → Telescope → Term computeType d n xs is [] = telPi (reverse is) $ def d (makeArgs (n + k) xs) `→ def d (makeArgs (n + k + 1) xs) `→ def₁ (quote Dec) (var 1 [] `≡ var 0 []) where k = length is computeType d n xs is (a ∷ tel) = unArg a `→ʰ (case computeInstanceType 0 [] (weaken 1 $ unArg a) of λ { (just i) → computeType d (1 + n) ((n <$ a) ∷ xs) (iArg (weaken (length is) i) ∷ weaken 1 is) tel ; nothing → computeType d (1 + n) ((n <$ a) ∷ xs) (weaken 1 is) tel }) eqType : Name → TC Type eqType d = computeType d 0 [] [] ∘ fst ∘ telView <$> getType d macro deriveEqType : Name → Tactic deriveEqType d hole = unifyTC hole =<< (computeType d 0 [] [] ∘ fst ∘ telView <$> getType d) deriveEqDef : Name → Name → TC ⊤ deriveEqDef i d = defineFun i =<< eqDefinition d declareEqInstance : Name → Name → TC ⊤ declareEqInstance iname d = declareDef (iArg iname) =<< instanceType d (quote Eq) defineEqInstance : Name → Name → TC ⊤ defineEqInstance iname d = do fname ← freshName ("_==[" & show d & "]_") declareDef (vArg fname) =<< eqType d dictCon ← recordConstructor (quote Eq) defineFun iname (clause [] (con₁ dictCon (def₀ fname)) ∷ []) defineFun fname =<< eqDefinition d return _ deriveEq : Name → Name → TC ⊤ deriveEq iname d = declareEqInstance iname d >> defineEqInstance iname d
{ "alphanum_fraction": 0.5672663802, "avg_line_length": 36.7802469136, "ext": "agda", "hexsha": "a20827fcbbac35ec65b290533c441469449980ed", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Tactic/Deriving/Eq.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Tactic/Deriving/Eq.agda", "max_line_length": 105, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Tactic/Deriving/Eq.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4846, "size": 14896 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types open import LibraBFT.Impl.OBM.Rust.RustTypes open import Optics.All open import Util.Encode open import Util.KVMap as KVMap open import Util.PKCS open import Util.Prelude ------------------------------------------------------------------------------ open import Data.String using (String) -- This module defines types for an out-of-date implementation, based -- on a previous version of LibraBFT. It will be updated to model a -- more recent version in future. -- -- One important trick here is that the RoundManager type separayes -- types that /define/ the EpochConfig and types that /use/ the -- /EpochConfig/. The advantage of doing this separation can be seen -- in Util.Util.liftEC, where we define a lifting of a function that -- does not change the bits that define the EpochConfig into the whole -- state. This enables a more elegant approach for reasoning about -- functions that do not change parts of the state responsible for -- defining the epoch config. However, the separation is not perfect, -- so sometimes fields may be modified in EpochIndep even though there -- is no epoch change. module LibraBFT.ImplShared.Consensus.Types where open import LibraBFT.ImplShared.NetworkMsg public open import LibraBFT.ImplShared.Base.Types public open import LibraBFT.ImplShared.Consensus.Types.EpochIndep public open import LibraBFT.ImplShared.Util.Crypto public record ExponentialTimeInterval : Set where constructor mkExponentialTimeInterval field _etiBaseMs : U64 _etiExponentBase : F64 _etiMaxExponent : Usize unquoteDecl etiBaseMs etiExponentBase etiMaxExponent = mkLens (quote ExponentialTimeInterval) (etiBaseMs ∷ etiExponentBase ∷ etiMaxExponent ∷ []) RoundStateTimeInterval = ExponentialTimeInterval record RoundState : Set where constructor mkRoundState field _rsTimeInterval : RoundStateTimeInterval _rsHighestCommittedRound : Round _rsCurrentRound : Round _rsCurrentRoundDeadline : Instant _rsPendingVotes : PendingVotes _rsVoteSent : Maybe Vote open RoundState public unquoteDecl rsTimeInterval rsHighestCommittedRound rsCurrentRound rsCurrentRoundDeadline rsPendingVotes rsVoteSent = mkLens (quote RoundState) (rsTimeInterval ∷ rsHighestCommittedRound ∷ rsCurrentRound ∷ rsCurrentRoundDeadline ∷ rsPendingVotes ∷ rsVoteSent ∷ []) record ObmNeedFetch : Set where constructor ObmNeedFetch∙new -- The parts of the state of a peer that are used to -- define the EpochConfig are the SafetyRules and ValidatorVerifier: record RoundManager : Set where constructor RoundManager∙new field _rmObmNeedFetch : ObmNeedFetch ------------------------- _rmEpochState : EpochState _rmBlockStore : BlockStore _rmRoundState : RoundState _rmProposerElection : ProposerElection _rmProposalGenerator : ProposalGenerator _rmSafetyRules : SafetyRules _rmSyncOnly : Bool open RoundManager public unquoteDecl rmObmNeedFetch rmEpochState rmBlockStore rmRoundState rmProposerElection rmProposalGenerator rmSafetyRules rmSyncOnly = mkLens (quote RoundManager) (rmObmNeedFetch ∷ rmEpochState ∷ rmBlockStore ∷ rmRoundState ∷ rmProposerElection ∷ rmProposalGenerator ∷ rmSafetyRules ∷ rmSyncOnly ∷ []) -- IMPL-DIFF: this is RoundManager field/lens in Haskell; and it is implemented completely different rmObmAllAuthors : Lens RoundManager (List Author) rmObmAllAuthors = mkLens' (λ rm → List-map proj₁ (kvm-toList (rm ^∙ rmEpochState ∙ esVerifier ∙ vvAddressToValidatorInfo))) (λ rm _ → rm) -- TODO-1 cannot be written -- IMPL-DIFF : In places that do "set" -- e.g., RoundState.processCertificates -- the Haskell code is : rsVoteSent .= Nothing -- the Agda code is : lRoundState ∙ rsVoteSent ∙= nothing -- -- The Haskell code leverages the "RW" constraints (e.g., RWRoundState) -- to enable not specifying where something is contained (i.e., in the round manager). -- The Agda code does not model that, therefore it needs `lRoundState`. lRoundManager : Lens RoundManager RoundManager lRoundManager = lens (λ _ _ f rm → f rm) lBlockStore : Lens RoundManager BlockStore lBlockStore = rmBlockStore lBlockTree : Lens RoundManager BlockTree lBlockTree = lBlockStore ∙ bsInner lPendingVotes : Lens RoundManager PendingVotes lPendingVotes = rmRoundState ∙ rsPendingVotes lRoundState : Lens RoundManager RoundState lRoundState = rmRoundState lProposerElection : Lens RoundManager ProposerElection lProposerElection = rmProposerElection lProposalGenerator : Lens RoundManager ProposalGenerator lProposalGenerator = rmProposalGenerator lSafetyRules : Lens RoundManager SafetyRules lSafetyRules = rmSafetyRules lPersistentSafetyStorage : Lens RoundManager PersistentSafetyStorage lPersistentSafetyStorage = lSafetyRules ∙ srPersistentStorage lObmNeedFetch : Lens RoundManager ObmNeedFetch lObmNeedFetch = rmObmNeedFetch -- getter only in Haskell pgAuthor : Lens RoundManager (Maybe Author) pgAuthor = mkLens' g s where g : RoundManager → Maybe Author g rm = maybeS (rm ^∙ rmSafetyRules ∙ srValidatorSigner) nothing (just ∘ (_^∙ vsAuthor)) s : RoundManager → Maybe Author → RoundManager s rm _ma = rm -- TODO-1 cannot be written -- getter only in Haskell srValidatorVerifier : Lens RoundManager ValidatorVerifier srValidatorVerifier = rmEpochState ∙ esVerifier -- getter only in Haskell -- IMPL-DIFF : this returns Author OR does an errorExit rmObmMe : Lens RoundManager (Maybe Author) rmObmMe = mkLens' g s where g : RoundManager → Maybe Author g rm = case rm ^∙ rmSafetyRules ∙ srValidatorSigner of λ where (just vs) → just (vs ^∙ vsAuthor) nothing → nothing s : RoundManager → Maybe Author → RoundManager s s _ = s -- getter only in Haskell rmEpoch : Lens RoundManager Epoch rmEpoch = rmEpochState ∙ esEpoch -- not defined in Haskell, only used for proofs rmValidatorVerifer : Lens RoundManager ValidatorVerifier rmValidatorVerifer = rmEpochState ∙ esVerifier -- getter only in Haskell rmRound : Lens RoundManager Round rmRound = rmRoundState ∙ rsCurrentRound -- not defined in Haskell rmLastVotedRound : Lens RoundManager Round rmLastVotedRound = rmSafetyRules ∙ srPersistentStorage ∙ pssSafetyData ∙ sdLastVotedRound -- BEGIN : lens mimicking Haskell/LBFT RW* setters. -- IN THE MODEL OF THE HASKELL CODE, THESE SHOULD ONLY BE USED FOR SETTING. -- THEY CAN BE USED AS GETTERS IN PROPERTIES/PROOFS. rsVoteSent-rm : Lens RoundManager (Maybe Vote) rsVoteSent-rm = lRoundState ∙ rsVoteSent pssSafetyData-rm : Lens RoundManager SafetyData pssSafetyData-rm = lPersistentSafetyStorage ∙ pssSafetyData -- END : lens mimicking Haskell/LBFT RW* setters. record BootstrapInfo : Set where constructor mkBootstrapInfo field _bsiNumFaults : ℕ _bsiLIWS : LedgerInfoWithSignatures _bsiVSS : List ValidatorSigner _bsiVV : ValidatorVerifier _bsiPE : ProposerElection open BootstrapInfo public unquoteDecl bsiNumFaults bsiLIWS bsiVSS bsiVV bsiPE = mkLens (quote BootstrapInfo) (bsiNumFaults ∷ bsiLIWS ∷ bsiVSS ∷ bsiVV ∷ bsiPE ∷ []) postulate -- valid assumption -- We postulate the existence of BootstrapInfo known to all -- TODO: construct one or write a function that generates one from some parameters. fakeBootstrapInfo : BootstrapInfo data ∈BootstrapInfo-impl (bi : BootstrapInfo) : Signature → Set where inBootstrapQC : ∀ {sig} → sig ∈ (KVMap.elems (bi ^∙ bsiLIWS ∙ liwsSignatures)) → ∈BootstrapInfo-impl bi sig postulate -- TODO-1 : prove ∈BootstrapInfo?-impl : (bi : BootstrapInfo) (sig : Signature) → Dec (∈BootstrapInfo-impl bi sig) postulate -- TODO-1: prove after defining bootstrapInfo bootstrapVotesRound≡0 : ∀ {pk v} → (wvs : WithVerSig pk v) → ∈BootstrapInfo-impl fakeBootstrapInfo (ver-signature wvs) → v ^∙ vRound ≡ 0 bootstrapVotesConsistent : (v1 v2 : Vote) → ∈BootstrapInfo-impl fakeBootstrapInfo (_vSignature v1) → ∈BootstrapInfo-impl fakeBootstrapInfo (_vSignature v2) → v1 ^∙ vProposedId ≡ v2 ^∙ vProposedId -- To enable modeling of logging info that has not been added yet, -- InfoLog and an inhabitant is postulated. postulate -- Valid assumption: InfoLog type InfoLog : Set fakeInfo : InfoLog -- The Haskell implementation has many more constructors. -- Constructors are being added incrementally as needed for the verification effort. data ErrLog : Set where -- full name of following field : Consensus_BlockNotFound ErrCBlockNotFound : HashValue → ErrLog -- full name of following field : ExecutionCorrectnessClient_BlockNotFound ErrECCBlockNotFound : HashValue → ErrLog ErrInfo : InfoLog → ErrLog -- to exit early, but not an error ErrVerify : VerifyError → ErrLog -- To enable modeling of logging errors that have not been added yet, -- an inhabitant of ErrLog is postulated. postulate -- Valid assumption: ErrLog type fakeErr : ErrLog record TxTypeDependentStuffForNetwork : Set where constructor TxTypeDependentStuffForNetwork∙new field _ttdsnProposalGenerator : ProposalGenerator _ttdsnStateComputer : StateComputer open TxTypeDependentStuffForNetwork public unquoteDecl ttdsnProposalGenerator ttdsnStateComputer = mkLens (quote TxTypeDependentStuffForNetwork) (ttdsnProposalGenerator ∷ ttdsnStateComputer ∷ [])
{ "alphanum_fraction": 0.7089074326, "avg_line_length": 40.8968253968, "ext": "agda", "hexsha": "a2e8aaf9911c4bea0261e6952a868da6f7a0b430", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/ImplShared/Consensus/Types.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/ImplShared/Consensus/Types.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/ImplShared/Consensus/Types.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2685, "size": 10306 }
------------------------------------------------------------------------ -- An implementation of "A Unifying Approach to Recursive and -- Co-recursive Definitions" by Pietro Di Gianantonio and Marino -- Miculan ------------------------------------------------------------------------ -- See the paper for more explanations. module Contractive where open import Relation.Unary open import Relation.Binary import Relation.Binary.Reasoning.Setoid as EqR open import Induction.WellFounded open import Function open import Level hiding (lift) -- Well-founded orders. record IsWellFoundedOrder {A} (_<_ : Rel A zero) : Set where field trans : Transitive _<_ isWellFounded : WellFounded _<_ -- Ordered families of equivalences. record OFE : Set1 where field Carrier : Set Domain : Set _<_ : Rel Carrier zero isWellFoundedOrder : IsWellFoundedOrder _<_ Eq : Carrier → Rel Domain zero isEquivalence : ∀ a → IsEquivalence (Eq a) open IsWellFoundedOrder isWellFoundedOrder public open All isWellFounded public setoid : Carrier → Setoid _ _ setoid a = record { Carrier = Domain ; _≈_ = Eq a ; isEquivalence = isEquivalence a } module EqReasoning {a : Carrier} where open EqR (setoid a) public open Setoid (setoid a) public using (refl; sym) -- The set of predecessors of a. ↓ : Carrier → Carrier → Set ↓ a = λ a' → a' < a -- The intersection of all the equivalences. _≅_ : Rel Domain zero x ≅ y = ∀ a → Eq a x y Family : (Carrier → Set) → Set Family I = ∀ x → x ∈ I → Domain lift : ∀ {I} → (Carrier → Domain) → Family I lift P = λ x _ → P x IsCoherent : ∀ {I} → Family I → Set IsCoherent {I} fam = ∀ {a' a} (a'∈I : a' ∈ I) (a∈I : a ∈ I) → a' < a → Eq a' (fam a' a'∈I) (fam a a∈I) IsLimit : ∀ {I} → Family I → Domain → Set IsLimit {I} fam y = ∀ {a'} (a'∈I : a' ∈ I) → Eq a' (fam a' a'∈I) y IsContractive : (Domain → Domain) → Set IsContractive F = ∀ {x y a} → (∀ {a'} → a' < a → Eq a' x y) → Eq a (F x) (F y) -- Complete ordered families of equivalences. record COFE : Set1 where field ofe : OFE open OFE ofe field limU : (Carrier → Domain) → Domain isLimitU : ∀ {fam} → IsCoherent {U} (lift fam) → IsLimit {U} (lift fam) (limU fam) lim↓ : ∀ a → Family (↓ a) → Domain isLimit↓ : ∀ a {fam : Family (↓ a)} → IsCoherent fam → IsLimit fam (lim↓ a fam) open OFE ofe public -- Contractive functions over complete ordered families have -- fixpoints. record ContractiveFun (cofe : COFE) : Set where open COFE cofe field F : Domain → Domain isContractive : IsContractive F open EqReasoning -- The fixpoint is the limit of the following family. fam : Carrier → Domain fam = wfRec _ (const Domain) (λ a rec → F (lim↓ a rec)) fixpoint : Domain fixpoint = limU fam -- I am not sure if this lemma can be proved without assuming some -- kind of proof irrelevance and/or extensionality. It is not -- central to the ideas developed here, though, so I leave it as a -- postulate. postulate unfold : ∀ a → fam a ≅ F (lim↓ a (lift fam)) -- The family is coherent in several ways. fam-isCoherent-↓ : ∀ a → IsCoherent {↓ a} (lift fam) fam-isCoherent-↓ = wfRec _ P step where P : Carrier → Set P a = IsCoherent {↓ a} (lift fam) step : ∀ a → WfRec _<_ P a → P a step a rec {c} {b} c<a b<a c<b = begin fam c ≈⟨ unfold c c ⟩ F (lim↓ c (lift fam)) ≈⟨ isContractive (λ {d} d<c → begin lim↓ c (lift fam) ≈⟨ sym $ isLimit↓ c (rec c c<a) d<c ⟩ lift {↓ a} fam d (trans d<c c<a) ≈⟨ isLimit↓ b (rec b b<a) (trans d<c c<b) ⟩ lim↓ b (lift fam) ∎) ⟩ F (lim↓ b (lift fam)) ≈⟨ sym $ unfold b c ⟩ fam b ∎ fam-isCoherent-U : IsCoherent {U} (lift fam) fam-isCoherent-U {a'} {a} _ _ = wfRec _ P step a a' where P : Carrier → Set P a = ∀ a' → a' < a → Eq a' (fam a') (fam a) step : ∀ a → WfRec _<_ P a → P a step a rec a' a'<a = begin fam a' ≈⟨ unfold a' a' ⟩ F (lim↓ a' (lift fam)) ≈⟨ isContractive (λ {b} b<a' → begin lim↓ a' (lift fam) ≈⟨ sym $ isLimit↓ a' (fam-isCoherent-↓ a') b<a' ⟩ fam b ≈⟨ isLimit↓ a (fam-isCoherent-↓ a) (trans b<a' a'<a) ⟩ lim↓ a (lift fam) ∎) ⟩ F (lim↓ a (lift fam)) ≈⟨ sym $ unfold a a' ⟩ fam a ∎ -- The fixpoint is a fixpoint. isFixpoint : fixpoint ≅ F fixpoint isFixpoint a = begin fixpoint ≈⟨ sym $ isLimitU fam-isCoherent-U _ ⟩ fam a ≈⟨ unfold a a ⟩ F (lim↓ a (lift fam)) ≈⟨ isContractive (λ {a'} a'<a → begin lim↓ a (lift fam) ≈⟨ sym $ isLimit↓ a (fam-isCoherent-↓ a) a'<a ⟩ fam a' ≈⟨ isLimitU fam-isCoherent-U _ ⟩ limU fam ∎) ⟩ F (limU fam) ≈⟨ refl ⟩ F fixpoint ∎ -- And it is unique. unique : ∀ x → x ≅ F x → x ≅ fixpoint unique x isFix = wfRec _ P step where P = λ a → Eq a x fixpoint step : ∀ a → WfRec _<_ P a → P a step a rec = begin x ≈⟨ isFix a ⟩ F x ≈⟨ isContractive (λ {a'} a'<a → rec a' a'<a) ⟩ F fixpoint ≈⟨ sym $ isFixpoint a ⟩ fixpoint ∎
{ "alphanum_fraction": 0.5251265365, "avg_line_length": 29.9027027027, "ext": "agda", "hexsha": "46ca5cf641e878c00730da6602cb70cc075daeab", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "Contractive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/codata", "max_issues_repo_path": "Contractive.agda", "max_line_length": 87, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "Contractive.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 1848, "size": 5532 }
-- Problem 2: Multiplication for matrices (from the matrix algebra DSL). module P2 where -- 2a: Type the variables in the text. -- (This answer uses Agda syntax, but that is not required.) postulate Nat : Set postulate V : Nat -> Set -> Set postulate Fin : Nat -> Set Op : Set -> Set Op a = a -> a -> a postulate sum : {n : Nat} {a : Set} -> Op a -> V n a -> a postulate zipWith : {n : Nat} {a : Set} -> Op a -> V n a -> V n a -> V n a data M (m n : Nat) (a : Set) : Set where matrix : (Fin m -> Fin n -> a) -> M m n a record Dummy (a : Set) : Set where field m : Nat n : Nat A : M m n a p : Nat B : M n p a i : Fin m j : Fin p -- 2b: Type |mul| and |proj| postulate proj : {m n : Nat} {a : Set} -> Fin m -> Fin n -> M m n a -> a mul : {m n p : Nat} {a : Set} -> Op a -> Op a -> M m n a -> M n p a -> M m p a -- 2c: Implement |mul|. postulate row : {m n : Nat} {a : Set} -> Fin m -> M m n a -> V n a col : {m n : Nat} {a : Set} -> Fin n -> M m n a -> V m a mul addE mulE A B = matrix (\i j -> sum addE (zipWith mulE (row i A) (col j B)))
{ "alphanum_fraction": 0.509383378, "avg_line_length": 23.8085106383, "ext": "agda", "hexsha": "a395c6965783bd8562f725b13bf96a9d3ca1c82d", "lang": "Agda", "max_forks_count": 47, "max_forks_repo_forks_event_max_datetime": "2022-03-03T23:57:42.000Z", "max_forks_repo_forks_event_min_datetime": "2015-11-16T08:41:04.000Z", "max_forks_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "nicolabotta/DSLsofMath", "max_forks_repo_path": "Exam/2017-08/P2.agda", "max_issues_count": 51, "max_issues_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_issues_repo_issues_event_max_datetime": "2022-03-03T20:06:39.000Z", "max_issues_repo_issues_event_min_datetime": "2016-01-30T15:59:39.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "nicolabotta/DSLsofMath", "max_issues_repo_path": "Exam/2017-08/P2.agda", "max_line_length": 74, "max_stars_count": 248, "max_stars_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "nicolabotta/DSLsofMath", "max_stars_repo_path": "Exam/2017-08/P2.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-29T11:12:24.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-27T21:04:02.000Z", "num_tokens": 415, "size": 1119 }
{-# OPTIONS --without-K --safe #-} module C where open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Relation.Binary.PropositionalEquality open import Singleton infixr 70 _×ᵤ_ infixr 60 _+ᵤₗ_ infixr 60 _+ᵤᵣ_ infixr 50 _⊚_ ------------------------------------------------------------------------------ -- Pi data 𝕌 : Set ⟦_⟧ : 𝕌 → Σ[ A ∈ Set ] A data _⟷_ : 𝕌 → 𝕌 → Set data 𝕌 where 𝟙 : 𝕌 _+ᵤₗ_ : 𝕌 → 𝕌 → 𝕌 _+ᵤᵣ_ : 𝕌 → 𝕌 → 𝕌 _×ᵤ_ : 𝕌 → 𝕌 → 𝕌 Singᵤ : 𝕌 → 𝕌 Recipᵤ : 𝕌 → 𝕌 ⟦ 𝟙 ⟧ = ⊤ , tt ⟦ T₁ ×ᵤ T₂ ⟧ = zip _×_ _,_ ⟦ T₁ ⟧ ⟦ T₂ ⟧ ⟦ T₁ +ᵤₗ T₂ ⟧ = zip _⊎_ (λ x _ → inj₁ x) ⟦ T₁ ⟧ ⟦ T₂ ⟧ ⟦ T₁ +ᵤᵣ T₂ ⟧ = zip _⊎_ (λ _ y → inj₂ y) ⟦ T₁ ⟧ ⟦ T₂ ⟧ ⟦ Singᵤ T ⟧ = < uncurry Singleton , (λ y → proj₂ y , refl) > ⟦ T ⟧ ⟦ Recipᵤ T ⟧ = < uncurry Recip , (λ _ _ → tt) > ⟦ T ⟧ data _⟷_ where swap₊₁ : {t₁ t₂ : 𝕌} → t₁ +ᵤₗ t₂ ⟷ t₂ +ᵤᵣ t₁ swap₊₂ : {t₁ t₂ : 𝕌} → t₁ +ᵤᵣ t₂ ⟷ t₂ +ᵤₗ t₁ assocl₊₁ : {t₁ t₂ t₃ : 𝕌} → t₁ +ᵤₗ (t₂ +ᵤₗ t₃) ⟷ (t₁ +ᵤₗ t₂) +ᵤₗ t₃ assocl₊₂ : {t₁ t₂ t₃ : 𝕌} → t₁ +ᵤₗ (t₂ +ᵤᵣ t₃) ⟷ (t₁ +ᵤₗ t₂) +ᵤₗ t₃ assocl₊₃ : {t₁ t₂ t₃ : 𝕌} → t₁ +ᵤᵣ (t₂ +ᵤₗ t₃) ⟷ (t₁ +ᵤᵣ t₂) +ᵤₗ t₃ assocl₊₄ : {t₁ t₂ t₃ : 𝕌} → t₁ +ᵤᵣ (t₂ +ᵤᵣ t₃) ⟷ (t₁ +ᵤₗ t₂) +ᵤᵣ t₃ assocl₊₅ : {t₁ t₂ t₃ : 𝕌} → t₁ +ᵤᵣ (t₂ +ᵤᵣ t₃) ⟷ (t₁ +ᵤᵣ t₂) +ᵤᵣ t₃ assocr₊₁ : {t₁ t₂ t₃ : 𝕌} → (t₁ +ᵤₗ t₂) +ᵤₗ t₃ ⟷ t₁ +ᵤₗ (t₂ +ᵤᵣ t₃) assocr₊₂ : {t₁ t₂ t₃ : 𝕌} → (t₁ +ᵤₗ t₂) +ᵤₗ t₃ ⟷ t₁ +ᵤₗ (t₂ +ᵤₗ t₃) assocr₊₃ : {t₁ t₂ t₃ : 𝕌} → (t₁ +ᵤᵣ t₂) +ᵤₗ t₃ ⟷ t₁ +ᵤᵣ (t₂ +ᵤₗ t₃) assocr₊₄ : {t₁ t₂ t₃ : 𝕌} → (t₁ +ᵤₗ t₂) +ᵤᵣ t₃ ⟷ t₁ +ᵤᵣ (t₂ +ᵤᵣ t₃) assocr₊₅ : {t₁ t₂ t₃ : 𝕌} → (t₁ +ᵤᵣ t₂) +ᵤᵣ t₃ ⟷ t₁ +ᵤᵣ (t₂ +ᵤᵣ t₃) unite⋆l : {t : 𝕌} → 𝟙 ×ᵤ t ⟷ t uniti⋆l : {t : 𝕌} → t ⟷ 𝟙 ×ᵤ t unite⋆r : {t : 𝕌} → t ×ᵤ 𝟙 ⟷ t uniti⋆r : {t : 𝕌} → t ⟷ t ×ᵤ 𝟙 swap⋆ : {t₁ t₂ : 𝕌} → t₁ ×ᵤ t₂ ⟷ t₂ ×ᵤ t₁ assocl⋆ : {t₁ t₂ t₃ : 𝕌} → t₁ ×ᵤ (t₂ ×ᵤ t₃) ⟷ (t₁ ×ᵤ t₂) ×ᵤ t₃ assocr⋆ : {t₁ t₂ t₃ : 𝕌} → (t₁ ×ᵤ t₂) ×ᵤ t₃ ⟷ t₁ ×ᵤ (t₂ ×ᵤ t₃) dist₁ : {t₁ t₂ t₃ : 𝕌} → (t₁ +ᵤₗ t₂) ×ᵤ t₃ ⟷ (t₁ ×ᵤ t₃) +ᵤₗ (t₂ ×ᵤ t₃) dist₂ : {t₁ t₂ t₃ : 𝕌} → (t₁ +ᵤᵣ t₂) ×ᵤ t₃ ⟷ (t₁ ×ᵤ t₃) +ᵤᵣ (t₂ ×ᵤ t₃) factor₁ : {t₁ t₂ t₃ : 𝕌} → (t₁ ×ᵤ t₃) +ᵤₗ (t₂ ×ᵤ t₃) ⟷ (t₁ +ᵤₗ t₂) ×ᵤ t₃ factor₂ : {t₁ t₂ t₃ : 𝕌} → (t₁ ×ᵤ t₃) +ᵤᵣ (t₂ ×ᵤ t₃) ⟷ (t₁ +ᵤᵣ t₂) ×ᵤ t₃ distl₁ : {t₁ t₂ t₃ : 𝕌} → t₁ ×ᵤ (t₂ +ᵤₗ t₃) ⟷ (t₁ ×ᵤ t₂) +ᵤₗ (t₁ ×ᵤ t₃) distl₂ : {t₁ t₂ t₃ : 𝕌} → t₁ ×ᵤ (t₂ +ᵤᵣ t₃) ⟷ (t₁ ×ᵤ t₂) +ᵤᵣ (t₁ ×ᵤ t₃) factorl₁ : {t₁ t₂ t₃ : 𝕌 } → (t₁ ×ᵤ t₂) +ᵤₗ (t₁ ×ᵤ t₃) ⟷ t₁ ×ᵤ (t₂ +ᵤₗ t₃) factorl₂ : {t₁ t₂ t₃ : 𝕌 } → (t₁ ×ᵤ t₂) +ᵤᵣ (t₁ ×ᵤ t₃) ⟷ t₁ ×ᵤ (t₂ +ᵤᵣ t₃) id⟷ : {t : 𝕌} → t ⟷ t _⊚_ : {t₁ t₂ t₃ : 𝕌} → (t₁ ⟷ t₂) → (t₂ ⟷ t₃) → (t₁ ⟷ t₃) _⊕₁_ : {t₁ t₂ t₃ t₄ : 𝕌} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (t₁ +ᵤₗ t₂ ⟷ t₃ +ᵤₗ t₄) _⊕₂_ : {t₁ t₂ t₃ t₄ : 𝕌} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (t₁ +ᵤᵣ t₂ ⟷ t₃ +ᵤᵣ t₄) _⊗_ : {t₁ t₂ t₃ t₄ : 𝕌} → (t₁ ⟷ t₃) → (t₂ ⟷ t₄) → (t₁ ×ᵤ t₂ ⟷ t₃ ×ᵤ t₄) -- monad return : (T : 𝕌) → T ⟷ Singᵤ T join : (T : 𝕌) → Singᵤ (Singᵤ T) ⟷ Singᵤ T unjoin : (T : 𝕌) → Singᵤ T ⟷ Singᵤ (Singᵤ T) tensorl : (T₁ T₂ : 𝕌) → (Singᵤ T₁ ×ᵤ T₂) ⟷ Singᵤ (T₁ ×ᵤ T₂) tensorr : (T₁ T₂ : 𝕌) → (T₁ ×ᵤ Singᵤ T₂) ⟷ Singᵤ (T₁ ×ᵤ T₂) tensor : (T₁ T₂ : 𝕌) → (Singᵤ T₁ ×ᵤ Singᵤ T₂) ⟷ Singᵤ (T₁ ×ᵤ T₂) untensor : (T₁ T₂ : 𝕌) → Singᵤ (T₁ ×ᵤ T₂) ⟷ (Singᵤ T₁ ×ᵤ Singᵤ T₂) plusl : (T₁ T₂ : 𝕌) → (Singᵤ T₁ +ᵤₗ T₂) ⟷ Singᵤ (T₁ +ᵤₗ T₂) plusr : (T₁ T₂ : 𝕌) → (T₁ +ᵤᵣ Singᵤ T₂) ⟷ Singᵤ (T₁ +ᵤᵣ T₂) -- comonad extract : (T : 𝕌) → Singᵤ T ⟷ T cojoin : (T : 𝕌) → Singᵤ T ⟷ Singᵤ (Singᵤ T) counjoin : (T : 𝕌) → Singᵤ (Singᵤ T) ⟷ Singᵤ T cotensorl : (T₁ T₂ : 𝕌) → Singᵤ (T₁ ×ᵤ T₂) ⟷ (Singᵤ T₁ ×ᵤ T₂) cotensorr : (T₁ T₂ : 𝕌) → Singᵤ (T₁ ×ᵤ T₂) ⟷ (T₁ ×ᵤ Singᵤ T₂) coplusl : (T₁ T₂ : 𝕌) → Singᵤ (T₁ +ᵤₗ T₂) ⟷ (Singᵤ T₁ +ᵤₗ T₂) coplusr : (T₁ T₂ : 𝕌) → Singᵤ (T₁ +ᵤᵣ T₂) ⟷ (T₁ +ᵤᵣ Singᵤ T₂) -- both? Singᵤ : (T₁ T₂ : 𝕌) → (T₁ ⟷ T₂) → (Singᵤ T₁ ⟷ Singᵤ T₂) -- eta/epsilon η : (T : 𝕌) → 𝟙 ⟷ (Singᵤ T ×ᵤ Recipᵤ T) ε : (T : 𝕌) → (Singᵤ T ×ᵤ Recipᵤ T) ⟷ 𝟙 !_ : {t₁ t₂ : 𝕌} → t₁ ⟷ t₂ → t₂ ⟷ t₁ ! swap₊₁ = swap₊₂ ! swap₊₂ = swap₊₁ ! assocl₊₁ = assocr₊₂ ! assocl₊₂ = assocr₊₁ ! assocl₊₃ = assocr₊₃ ! assocl₊₄ = assocr₊₄ ! assocl₊₅ = assocr₊₅ ! assocr₊₁ = assocl₊₂ ! assocr₊₂ = assocl₊₁ ! assocr₊₃ = assocl₊₃ ! assocr₊₄ = assocl₊₄ ! assocr₊₅ = assocl₊₅ ! unite⋆l = uniti⋆l ! uniti⋆l = unite⋆l ! unite⋆r = uniti⋆r ! uniti⋆r = unite⋆r ! swap⋆ = swap⋆ ! assocl⋆ = assocr⋆ ! assocr⋆ = assocl⋆ ! dist₁ = factor₁ ! dist₂ = factor₂ ! factor₁ = dist₁ ! factor₂ = dist₂ ! distl₁ = factorl₁ ! distl₂ = factorl₂ ! factorl₁ = distl₁ ! factorl₂ = distl₂ ! id⟷ = id⟷ ! (c ⊚ c₁) = (! c₁) ⊚ (! c) ! (c ⊕₁ c₁) = (! c) ⊕₁ (! c₁) ! (c ⊕₂ c₁) = (! c) ⊕₂ (! c₁) ! (c ⊗ c₁) = (! c) ⊗ (! c₁) ! return T = extract T ! join T = return (Singᵤ T) ! unjoin T = join T ! tensorl T₁ T₂ = cotensorl T₁ T₂ ! tensorr T₁ T₂ = cotensorr T₁ T₂ ! tensor T₁ T₂ = untensor T₁ T₂ ! untensor T₁ T₂ = tensor T₁ T₂ ! plusl T₁ T₂ = coplusl T₁ T₂ ! plusr T₁ T₂ = coplusr T₁ T₂ ! extract T = return T ! cojoin T = join T ! counjoin T = return (Singᵤ T) ! cotensorl T₁ T₂ = tensorl T₁ T₂ ! cotensorr T₁ T₂ = tensorr T₁ T₂ ! coplusl T₁ T₂ = plusl T₁ T₂ ! coplusr T₁ T₂ = plusr T₁ T₂ ! Singᵤ T₁ T₂ c = Singᵤ T₂ T₁ (! c) ! η T = ε T ! ε T = η T
{ "alphanum_fraction": 0.5010514242, "avg_line_length": 35.1073825503, "ext": "agda", "hexsha": "edeb91b42d3bbf5160189ce0e7e5c9f529990b8e", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "fracGC/C.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "fracGC/C.agda", "max_line_length": 80, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "fracGC/C.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 3711, "size": 5231 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Product where open import Level open import Function using () renaming (_∘_ to _∙_) open import Data.Product using (_×_; Σ; _,_; proj₁; proj₂; zip; map; <_,_>; swap) open import Categories.Category private map⁎ : ∀ {a b p q} {A : Set a} {B : A → Set b} {P : A → Set p} {Q : {x : A} → P x → B x → Set q} → (f : (x : A) → B x) → (∀ {x} → (y : P x) → Q y (f x)) → (v : Σ A P) → Σ (B (proj₁ v)) (Q (proj₂ v)) map⁎ f g (x , y) = (f x , g y) map⁎′ : ∀ {a b p q} {A : Set a} {B : A → Set b} {P : Set p} {Q : P → Set q} → (f : (x : A) → B x) → ((x : P) → Q x) → (v : A × P) → B (proj₁ v) × Q (proj₂ v) map⁎′ f g (x , y) = (f x , g y) zipWith : ∀ {a b c p q r s} {A : Set a} {B : Set b} {C : Set c} {P : A → Set p} {Q : B → Set q} {R : C → Set r} {S : (x : C) → R x → Set s} (_∙_ : A → B → C) → (_∘_ : ∀ {x y} → P x → Q y → R (x ∙ y)) → (_*_ : (x : C) → (y : R x) → S x y) → (x : Σ A P) → (y : Σ B Q) → S (proj₁ x ∙ proj₁ y) (proj₂ x ∘ proj₂ y) zipWith _∙_ _∘_ _*_ (a , p) (b , q) = (a ∙ b) * (p ∘ q) syntax zipWith f g h = f -< h >- g Product : ∀ {o ℓ e o′ ℓ′ e′} (C : Category o ℓ e) (D : Category o′ ℓ′ e′) → Category (o ⊔ o′) (ℓ ⊔ ℓ′) (e ⊔ e′) Product C D = record { Obj = C.Obj × D.Obj ; _⇒_ = C._⇒_ -< _×_ >- D._⇒_ ; _≡_ = C._≡_ -< _×_ >- D._≡_ ; _∘_ = zip C._∘_ D._∘_ ; id = C.id , D.id ; assoc = C.assoc , D.assoc ; identityˡ = C.identityˡ , D.identityˡ ; identityʳ = C.identityʳ , D.identityʳ ; equiv = record { refl = C.Equiv.refl , D.Equiv.refl ; sym = map C.Equiv.sym D.Equiv.sym ; trans = zip C.Equiv.trans D.Equiv.trans } ; ∘-resp-≡ = zip C.∘-resp-≡ D.∘-resp-≡ } where module C = Category C module D = Category D open import Categories.Functor using (Functor; module Functor) infixr 2 _※_ _※_ : ∀ {o ℓ e o′₁ ℓ′₁ e′₁ o′₂ ℓ′₂ e′₂} {C : Category o ℓ e} {D₁ : Category o′₁ ℓ′₁ e′₁} {D₂ : Category o′₂ ℓ′₂ e′₂} → (F : Functor C D₁) → (G : Functor C D₂) → Functor C (Product D₁ D₂) F ※ G = record { F₀ = < F.F₀ , G.F₀ > ; F₁ = < F.F₁ , G.F₁ > ; identity = F.identity , G.identity ; homomorphism = F.homomorphism , G.homomorphism ; F-resp-≡ = < F.F-resp-≡ , G.F-resp-≡ > } where module F = Functor F module G = Functor G infixr 2 _⁂_ _⁂_ : ∀ {o₁ ℓ₁ e₁ o′₁ ℓ′₁ e′₁ o₂ ℓ₂ e₂ o′₂ ℓ′₂ e′₂} {C₁ : Category o₁ ℓ₁ e₁} {D₁ : Category o′₁ ℓ′₁ e′₁} → {C₂ : Category o₂ ℓ₂ e₂} {D₂ : Category o′₂ ℓ′₂ e′₂} → (F₁ : Functor C₁ D₁) → (F₂ : Functor C₂ D₂) → Functor (Product C₁ C₂) (Product D₁ D₂) F ⁂ G = record { F₀ = map F.F₀ G.F₀ ; F₁ = map F.F₁ G.F₁ ; identity = F.identity , G.identity ; homomorphism = F.homomorphism , G.homomorphism ; F-resp-≡ = map F.F-resp-≡ G.F-resp-≡ } where module F = Functor F module G = Functor G open import Categories.NaturalTransformation using (NaturalTransformation; module NaturalTransformation) infixr 2 _⁂ⁿ_ _⁂ⁿ_ : ∀ {o₁ ℓ₁ e₁ o′₁ ℓ′₁ e′₁ o₂ ℓ₂ e₂ o′₂ ℓ′₂ e′₂} {C₁ : Category o₁ ℓ₁ e₁} {D₁ : Category o′₁ ℓ′₁ e′₁} → {C₂ : Category o₂ ℓ₂ e₂} {D₂ : Category o′₂ ℓ′₂ e′₂} → {F₁ G₁ : Functor C₁ D₁} {F₂ G₂ : Functor C₂ D₂} → (α : NaturalTransformation F₁ G₁) → (β : NaturalTransformation F₂ G₂) → NaturalTransformation (F₁ ⁂ F₂) (G₁ ⁂ G₂) α ⁂ⁿ β = record { η = map⁎′ α.η β.η; commute = map⁎′ α.commute β.commute } where module α = NaturalTransformation α module β = NaturalTransformation β infixr 2 _※ⁿ_ _※ⁿ_ : ∀ {o ℓ e o′₁ ℓ′₁ e′₁} {C : Category o ℓ e} {D₁ : Category o′₁ ℓ′₁ e′₁} {F₁ G₁ : Functor C D₁} (α : NaturalTransformation F₁ G₁) → ∀ {o′₂ ℓ′₂ e′₂} {D₂ : Category o′₂ ℓ′₂ e′₂} {F₂ G₂ : Functor C D₂} (β : NaturalTransformation F₂ G₂) → NaturalTransformation (F₁ ※ F₂) (G₁ ※ G₂) α ※ⁿ β = record { η = < α.η , β.η >; commute = < α.commute , β.commute > } where module α = NaturalTransformation α module β = NaturalTransformation β assocˡ : ∀ {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ o₃ ℓ₃ e₃} → (C₁ : Category o₁ ℓ₁ e₁) (C₂ : Category o₂ ℓ₂ e₂) (C₃ : Category o₃ ℓ₃ e₃) → Functor (Product (Product C₁ C₂) C₃) (Product C₁ (Product C₂ C₃)) assocˡ C₁ C₂ C₃ = record { F₀ = < proj₁ ∙ proj₁ , < proj₂ ∙ proj₁ , proj₂ > > ; F₁ = < proj₁ ∙ proj₁ , < proj₂ ∙ proj₁ , proj₂ > > ; identity = C₁.Equiv.refl , C₂.Equiv.refl , C₃.Equiv.refl ; homomorphism = C₁.Equiv.refl , C₂.Equiv.refl , C₃.Equiv.refl ; F-resp-≡ = < proj₁ ∙ proj₁ , < proj₂ ∙ proj₁ , proj₂ > > } where module C₁ = Category C₁ module C₂ = Category C₂ module C₃ = Category C₃ assocʳ : ∀ {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ o₃ ℓ₃ e₃} → (C₁ : Category o₁ ℓ₁ e₁) (C₂ : Category o₂ ℓ₂ e₂) (C₃ : Category o₃ ℓ₃ e₃) → Functor (Product C₁ (Product C₂ C₃)) (Product (Product C₁ C₂) C₃) assocʳ C₁ C₂ C₃ = record { F₀ = < < proj₁ , proj₁ ∙ proj₂ > , proj₂ ∙ proj₂ > ; F₁ = < < proj₁ , proj₁ ∙ proj₂ > , proj₂ ∙ proj₂ > ; identity = (C₁.Equiv.refl , C₂.Equiv.refl) , C₃.Equiv.refl ; homomorphism = (C₁.Equiv.refl , C₂.Equiv.refl) , C₃.Equiv.refl ; F-resp-≡ = < < proj₁ , proj₁ ∙ proj₂ > , proj₂ ∙ proj₂ > } where module C₁ = Category C₁ module C₂ = Category C₂ module C₃ = Category C₃ πˡ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Functor (Product C D) C πˡ {C = C} = record { F₀ = proj₁; F₁ = proj₁; identity = refl ; homomorphism = refl; F-resp-≡ = proj₁ } where open Category.Equiv C using (refl) πʳ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Functor (Product C D) D πʳ {D = D} = record { F₀ = proj₂; F₁ = proj₂; identity = refl ; homomorphism = refl; F-resp-≡ = proj₂ } where open Category.Equiv D using (refl) Swap : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} → Functor (Product D C) (Product C D) Swap {C = C} {D = D} = (record { F₀ = swap ; F₁ = swap ; identity = C.Equiv.refl , D.Equiv.refl ; homomorphism = C.Equiv.refl , D.Equiv.refl ; F-resp-≡ = swap }) where module C = Category C module D = Category D
{ "alphanum_fraction": 0.5504042237, "avg_line_length": 45.5714285714, "ext": "agda", "hexsha": "65d6c1b3b336078d3520f67522355e729c93739b", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Product.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Product.agda", "max_line_length": 326, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Product.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 2676, "size": 6061 }
open import Nat open import Prelude open import List open import core open import judgemental-erase open import sensibility open import moveerase module checks where -- these three judmgements lift the action semantics judgements to relate -- an expression and a list of pair-wise composable actions to the -- expression that's produced by tracing through the action semantics for -- each element in that list. -- -- we do this just by appealing to the original judgement with -- constraints on the terms to enforce composability. -- -- in all three cases, we assert that the empty list of actions -- constitutes a reflexivity step, so when you run out of actions to -- preform you have to be where you wanted to be. -- -- note that the only difference between the types for each judgement and -- the original action semantics is that the action is now a list of -- actions. data runtype : (t : τ̂) (Lα : List action) (t' : τ̂) → Set where DoRefl : {t : τ̂} → runtype t [] t DoType : {t : τ̂} {α : action} {t' t'' : τ̂} {L : List action} → t + α +> t' → runtype t' L t'' → runtype t (α :: L) t'' data runsynth : (Γ : ·ctx) (e : ê) (t1 : τ̇) (Lα : List action) (e' : ê) (t2 : τ̇) → Set where DoRefl : {Γ : ·ctx} {e : ê} {t : τ̇} → runsynth Γ e t [] e t DoSynth : {Γ : ·ctx} {e : ê} {t : τ̇} {α : action} {e' e'' : ê} {t' t'' : τ̇} {L : List action} → Γ ⊢ e => t ~ α ~> e' => t' → runsynth Γ e' t' L e'' t'' → runsynth Γ e t (α :: L) e'' t'' data runana : (Γ : ·ctx) (e : ê) (Lα : List action) (e' : ê) (t : τ̇) → Set where DoRefl : {Γ : ·ctx} {e : ê} {t : τ̇} → runana Γ e [] e t DoAna : {Γ : ·ctx} {e : ê} {α : action} {e' e'' : ê} {t : τ̇} {L : List action} → Γ ⊢ e ~ α ~> e' ⇐ t → runana Γ e' L e'' t → runana Γ e (α :: L) e'' t -- all three run judgements lift to the list monoid as expected. these -- theorems are simple because the structure of lists is simple, but they -- amount a reasoning principle about the composition of action sequences -- by letting you split lists in (nearly) arbitrary places and argue -- about the consequences of the splits before composing them together. runtype++ : ∀{t t' t'' L1 L2 } → runtype t L1 t' → runtype t' L2 t'' → runtype t (L1 ++ L2) t'' runtype++ DoRefl d2 = d2 runtype++ (DoType x d1) d2 = DoType x (runtype++ d1 d2) runsynth++ : ∀{Γ e t L1 e' t' L2 e'' t''} → runsynth Γ e t L1 e' t' → runsynth Γ e' t' L2 e'' t'' → runsynth Γ e t (L1 ++ L2) e'' t'' runsynth++ DoRefl d2 = d2 runsynth++ (DoSynth x d1) d2 = DoSynth x (runsynth++ d1 d2) runana++ : ∀{Γ e t L1 e' L2 e''} → runana Γ e L1 e' t → runana Γ e' L2 e'' t → runana Γ e (L1 ++ L2) e'' t runana++ DoRefl d2 = d2 runana++ (DoAna x d1) d2 = DoAna x (runana++ d1 d2) -- the following collection of lemmas asserts that the various runs -- interoperate nicely. in many cases, these amount to observing -- something like congruence: if a subterm is related to something by one -- of the judgements, it can be replaced by the thing to which it is -- related in a larger context without disrupting that larger -- context. -- -- taken together, this is a little messier than a proper congruence, -- because the action semantics demand well-typedness at each step, and -- therefore there are enough premises to each lemma to supply to the -- action semantics rules. -- -- therefore, these amount to a checksum on the zipper actions under the -- lifing of the action semantics to the list monoid. -- -- they only check the zipper actions they happen to be include, however, -- which is driven by the particular lists we use in the proofs of -- contructability and reachability, which may or may not be all of -- them. additionally, the lemmas given here are what is needed for these -- proofs, not anything that's more general. -- type zippers ziplem-tmarr1 : ∀ {t1 t1' t2 L } → runtype t1' L t1 → runtype (t1' ==>₁ t2) L (t1 ==>₁ t2) ziplem-tmarr1 DoRefl = DoRefl ziplem-tmarr1 (DoType x L') = DoType (TMArrZip1 x) (ziplem-tmarr1 L') ziplem-tmarr2 : ∀ {t1 t2 t2' L } → runtype t2' L t2 → runtype (t1 ==>₂ t2') L (t1 ==>₂ t2) ziplem-tmarr2 DoRefl = DoRefl ziplem-tmarr2 (DoType x L') = DoType (TMArrZip2 x) (ziplem-tmarr2 L') -- expression zippers ziplem-asc1 : ∀{Γ t L e e'} → runana Γ e L e' t → runsynth Γ (e ·:₁ t) t L (e' ·:₁ t) t ziplem-asc1 DoRefl = DoRefl ziplem-asc1 (DoAna a r) = DoSynth (SAZipAsc1 a) (ziplem-asc1 r) ziplem-asc2 : ∀{Γ t L t' t◆ t'◆} → erase-t t t◆ → erase-t t' t'◆ → runtype t L t' → runsynth Γ (⦇-⦈ ·:₂ t) t◆ L (⦇-⦈ ·:₂ t') t'◆ ziplem-asc2 {Γ} er er' rt with erase-t◆ er | erase-t◆ er' ... | refl | refl = ziplem-asc2' {Γ = Γ} rt where ziplem-asc2' : ∀{t L t' Γ } → runtype t L t' → runsynth Γ (⦇-⦈ ·:₂ t) (t ◆t) L (⦇-⦈ ·:₂ t') (t' ◆t) ziplem-asc2' DoRefl = DoRefl ziplem-asc2' (DoType x rt) = DoSynth (SAZipAsc2 x (◆erase-t _ _ refl) (◆erase-t _ _ refl) (ASubsume SEHole TCHole1)) (ziplem-asc2' rt) ziplem-lam : ∀ {Γ x e t t1 t2 L e'} → x # Γ → t ▸arr (t1 ==> t2) → runana (Γ ,, (x , t1)) e L e' t2 → runana Γ (·λ x e) L (·λ x e') t ziplem-lam a m DoRefl = DoRefl ziplem-lam a m (DoAna x₁ d) = DoAna (AAZipLam a m x₁) (ziplem-lam a m d) ziplem-plus1 : ∀{ Γ e L e' f} → runana Γ e L e' num → runsynth Γ (e ·+₁ f) num L (e' ·+₁ f) num ziplem-plus1 DoRefl = DoRefl ziplem-plus1 (DoAna x d) = DoSynth (SAZipPlus1 x) (ziplem-plus1 d) ziplem-plus2 : ∀{ Γ e L e' f} → runana Γ e L e' num → runsynth Γ (f ·+₂ e) num L (f ·+₂ e') num ziplem-plus2 DoRefl = DoRefl ziplem-plus2 (DoAna x d) = DoSynth (SAZipPlus2 x) (ziplem-plus2 d) ziplem-ap2 : ∀{ Γ e L e' t t' f tf} → Γ ⊢ f => t' → t' ▸arr (t ==> tf) → runana Γ e L e' t → runsynth Γ (f ∘₂ e) tf L (f ∘₂ e') tf ziplem-ap2 wt m DoRefl = DoRefl ziplem-ap2 wt m (DoAna x d) = DoSynth (SAZipApAna m wt x) (ziplem-ap2 wt m d) ziplem-nehole-a : ∀{Γ e e' L t t'} → (Γ ⊢ e ◆e => t) → runsynth Γ e t L e' t' → runsynth Γ ⦇⌜ e ⌟⦈ ⦇-⦈ L ⦇⌜ e' ⌟⦈ ⦇-⦈ ziplem-nehole-a wt DoRefl = DoRefl ziplem-nehole-a wt (DoSynth {e = e} x d) = DoSynth (SAZipHole (rel◆ e) wt x) (ziplem-nehole-a (actsense-synth (rel◆ e) (rel◆ _) x wt) d) ziplem-nehole-b : ∀{Γ e e' L t t' t''} → (Γ ⊢ e ◆e => t) → (t'' ~ t') → runsynth Γ e t L e' t' → runana Γ ⦇⌜ e ⌟⦈ L ⦇⌜ e' ⌟⦈ t'' ziplem-nehole-b wt c DoRefl = DoRefl ziplem-nehole-b wt c (DoSynth x rs) = DoAna (AASubsume (erase-in-hole (rel◆ _)) (SNEHole wt) (SAZipHole (rel◆ _) wt x) TCHole1) (ziplem-nehole-b (actsense-synth (rel◆ _) (rel◆ _) x wt) c rs) -- because the point of the reachability theorems is to show that we -- didn't forget to define any of the action semantic cases, it's -- important that theorems include the fact that the witness only uses -- move -- otherwise, you could cheat by just prepending [ del ] to the -- list produced by constructability. constructability does also use -- some, but not all, of the possible movements, so this would no longer -- demonstrate the property we really want. to that end, we define a -- predicate on lists that they contain only (move _) and that the -- various things above that produce the lists we use have this property. -- predicate data movements : List action → Set where AM:: : {L : List action} {δ : direction} → movements L → movements ((move δ) :: L) AM[] : movements [] -- movements breaks over the list monoid, as expected movements++ : {l1 l2 : List action} → movements l1 → movements l2 → movements (l1 ++ l2) movements++ (AM:: m1) m2 = AM:: (movements++ m1 m2) movements++ AM[] m2 = m2 -- these are zipper lemmas that are specific to list of movement -- actions. they are not true for general actions, but because -- reachability is restricted to movements, we get some milage out of -- them anyway. endpoints : ∀{ Γ e t L e' t'} → Γ ⊢ (e ◆e) => t → runsynth Γ e t L e' t' → movements L → t == t' endpoints _ DoRefl AM[] = refl endpoints wt (DoSynth x rs) (AM:: mv) with endpoints (actsense-synth (rel◆ _) (rel◆ _) x wt) rs mv ... | refl = π2 (moveerase-synth (rel◆ _) wt x) ziplem-moves-asc2 : ∀{ Γ l t t' e t◆ } → movements l → erase-t t t◆ → Γ ⊢ e <= t◆ → runtype t l t' → runsynth Γ (e ·:₂ t) t◆ l (e ·:₂ t') t◆ ziplem-moves-asc2 _ _ _ DoRefl = DoRefl ziplem-moves-asc2 (AM:: m) er wt (DoType x rt) with moveeraset' er x ... | er' = DoSynth (SAZipAsc2 x er' er wt) (ziplem-moves-asc2 m er' wt rt) synthana-moves : ∀{t t' l e e' Γ} → Γ ⊢ e ◆e => t' → movements l → t ~ t' → runsynth Γ e t' l e' t' → runana Γ e l e' t synthana-moves _ _ _ DoRefl = DoRefl synthana-moves wt (AM:: m) c (DoSynth x rs) with π2 (moveerase-synth (rel◆ _) wt x) ... | refl = DoAna (AASubsume (rel◆ _) wt x c) (synthana-moves (actsense-synth (rel◆ _) (rel◆ _) x wt) m c rs) ziplem-moves-ap1 : ∀{Γ l e1 e1' e2 t t' tx} → Γ ⊢ e1 ◆e => t → t ▸arr (tx ==> t') → Γ ⊢ e2 <= tx → movements l → runsynth Γ e1 t l e1' t → runsynth Γ (e1 ∘₁ e2) t' l (e1' ∘₁ e2) t' ziplem-moves-ap1 _ _ _ _ DoRefl = DoRefl ziplem-moves-ap1 wt1 mch wt2 (AM:: m) (DoSynth x rs) with π2 (moveerase-synth (rel◆ _) wt1 x) ... | refl = DoSynth (SAZipApArr mch (rel◆ _) wt1 x wt2) (ziplem-moves-ap1 (actsense-synth (rel◆ _) (rel◆ _) x wt1) mch wt2 m rs)
{ "alphanum_fraction": 0.5325915624, "avg_line_length": 42.7976190476, "ext": "agda", "hexsha": "9f671da7c1ce7fc505c903116ebd33f6de23960d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-07-03T03:45:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-07-03T03:45:07.000Z", "max_forks_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/agda-popl17", "max_forks_repo_path": "checks.agda", "max_issues_count": 37, "max_issues_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_issues_repo_issues_event_max_datetime": "2016-11-09T18:13:55.000Z", "max_issues_repo_issues_event_min_datetime": "2016-07-07T16:23:11.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/agda-popl17", "max_issues_repo_path": "checks.agda", "max_line_length": 110, "max_stars_count": 14, "max_stars_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/agda-popl17", "max_stars_repo_path": "checks.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-11T12:30:50.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-01T22:44:11.000Z", "num_tokens": 3770, "size": 10785 }
{-# OPTIONS --no-import-sorts #-} open import Agda.Primitive renaming (Set to _X_X_) test : _X_X₁_ test = _X_X_
{ "alphanum_fraction": 0.701754386, "avg_line_length": 16.2857142857, "ext": "agda", "hexsha": "969f4e6626d3c936cc4caff5c78f1d0a4a2a9514", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Succeed/RenameSetToMixfix.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/RenameSetToMixfix.agda", "max_line_length": 50, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/RenameSetToMixfix.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 36, "size": 114 }
{-# OPTIONS --without-K #-} open import Agda.Primitive using (Level; lsuc) open import Relation.Binary.PropositionalEquality.Core using (_≡_; cong) open import Data.Empty using (⊥; ⊥-elim) open import Data.Product using (proj₁; proj₂; Σ-syntax; _,_) open import Function.Base using (_∘_) variable ℓ ℓ′ : Level A C : Set ℓ B : A → Set ℓ {- Sizes Defining sizes as a generalized form of Brouwer ordinals, with an order (see https://arxiv.org/abs/2104.02549) -} infix 30 ↑_ infix 30 ⊔_ data Size {ℓ} : Set (lsuc ℓ) where ↑_ : Size {ℓ} → Size ⊔_ : {A : Set ℓ} → (A → Size {ℓ}) → Size data _≤_ {ℓ} : Size {ℓ} → Size {ℓ} → Set (lsuc ℓ) where ↑s≤↑s : ∀ {r s} → r ≤ s → ↑ r ≤ ↑ s s≤⊔f : ∀ {s} f (a : A) → s ≤ f a → s ≤ ⊔ f ⊔f≤s : ∀ {s} f → (∀ (a : A) → f a ≤ s) → ⊔ f ≤ s -- A possible definition of the smallest size ◯ : Size ◯ = ⊔ ⊥-elim ◯≤s : ∀ {s} → ◯ ≤ s ◯≤s = ⊔f≤s ⊥-elim λ () -- Reflexivity of ≤ s≤s : ∀ {s : Size {ℓ}} → s ≤ s s≤s {s = ↑ s} = ↑s≤↑s s≤s s≤s {s = ⊔ f} = ⊔f≤s f (λ a → s≤⊔f f a s≤s) -- Transitivity of ≤ s≤s≤s : ∀ {r s t : Size {ℓ}} → r ≤ s → s ≤ t → r ≤ t s≤s≤s (↑s≤↑s r≤s) (↑s≤↑s s≤t) = ↑s≤↑s (s≤s≤s r≤s s≤t) s≤s≤s r≤s (s≤⊔f f a s≤fa) = s≤⊔f f a (s≤s≤s r≤s s≤fa) s≤s≤s (⊔f≤s f fa≤s) s≤t = ⊔f≤s f (λ a → s≤s≤s (fa≤s a) s≤t) s≤s≤s (s≤⊔f f a s≤fa) (⊔f≤s f fa≤t) = s≤s≤s s≤fa (fa≤t a) -- Successor behaves as expected wrt ≤ s≤↑s : ∀ {s : Size {ℓ}} → s ≤ ↑ s s≤↑s {s = ↑ s} = ↑s≤↑s s≤↑s s≤↑s {s = ⊔ f} = ⊔f≤s f (λ a → s≤s≤s s≤↑s (↑s≤↑s (s≤⊔f f a s≤s))) -- Strict order _<_ : Size {ℓ} → Size {ℓ} → Set (lsuc ℓ) r < s = ↑ r ≤ s {- Well-founded induction for Sizes via an accessibility predicate based on strict order -} record Acc (s : Size {ℓ}) : Set (lsuc ℓ) where inductive pattern constructor acc field acc< : (∀ r → r < s → Acc r) open Acc -- The accessibility predicate is a mere proposition accIsProp : ∀ {s : Size {ℓ}} → (acc1 acc2 : Acc s) → acc1 ≡ acc2 accIsProp (acc p) (acc q) = cong acc (funext p q (λ r → funext (p r) (q r) (λ r<s → accIsProp (p r r<s) (q r r<s)))) where postulate funext : ∀ (p q : ∀ x → B x) → (∀ x → p x ≡ q x) → p ≡ q -- A size smaller or equal to an accessible size is still accessible acc≤ : ∀ {r s : Size {ℓ}} → r ≤ s → Acc s → Acc r acc≤ r≤s (acc p) = acc (λ t t<r → p t (s≤s≤s t<r r≤s)) -- All sizes are accessible wf : ∀ (s : Size {ℓ}) → Acc s wf (↑ s) = acc (λ { _ (↑s≤↑s r≤s) → acc≤ r≤s (wf s) }) wf (⊔ f) = acc (λ { r (s≤⊔f f a r<fa) → (wf (f a)).acc< r r<fa }) -- Well-founded induction: -- If P holds on every smaller size, then P holds on this size -- Recursion occurs structurally on the accessbility of sizes wfInd : ∀ (P : Size {ℓ} → Set ℓ′) → (∀ s → (∀ r → r < s → P r) → P s) → ∀ s → P s wfInd P f s = wfAcc s (wf s) where wfAcc : ∀ s → Acc s → P s wfAcc s (acc p) = f s (λ r r<s → wfAcc r (p r r<s)) {- W types W∞ is the full or "infinite" form, where there are no sizes; W is the bounded-sized form, parameterized by some Size, where constructors take a proof of smaller-sizedness -} data W∞ (A : Set ℓ) (B : A → Set ℓ) : Set ℓ where sup∞ : ∀ a → (B a → W∞ A B) → W∞ A B data W (A : Set ℓ) (B : A → Set ℓ) (s : Size {ℓ}) : Set (lsuc ℓ) where sup : ∀ r → r < s → (a : A) → (B a → W A B r) → W A B s -- Eliminator for the W type based on wellfoundedness of sizes elimW : (P : ∀ s → W A B s → Set ℓ′) → (p : ∀ s → (∀ r → r < s → (w : W A B r) → P r w) → (w : W A B s) → P s w) → ∀ s → (w : W A B s) → P s w elimW P = wfInd (λ s → (w : W _ _ s) → P s w) -- A full W∞ to a size-paired bounded-sized W form findW : W∞ {ℓ} A B → Σ[ s ∈ Size ] W A B s findW (sup∞ a f) = let s = ⊔ (proj₁ ∘ findW ∘ f) in ↑ s , sup s s≤s a ⊔f where ⊔f : _ ⊔f b with proj₂ (findW (f b)) ... | sup r r<s a g = sup r (s≤s≤s r<s (s≤⊔f (proj₁ ∘ findW ∘ f) b s≤s)) a g -- The axiom of choice specialized to sized W types, "choosing" a size ac : ∀ a → (B a → Σ[ s ∈ Size ] W A B s) → Σ[ s ∈ Size ] (B a → W A B s) ac a f = ⊔ (proj₁ ∘ f) , f′ where f′ : _ f′ b with proj₂ (f b) ... | sup r r<s a f = sup r (s≤s≤s r<s (s≤⊔f _ b s≤s)) a f -- Constructing a bounded-sized W out of the necessary pieces mkW : ∀ a → (B a → Σ[ s ∈ Size ] W A B s) → Σ[ s ∈ Size ] W A B s mkW a f = let sf = ac a f in sup (proj₁ sf) ? a (proj₂ f)
{ "alphanum_fraction": 0.5256109023, "avg_line_length": 31.5259259259, "ext": "agda", "hexsha": "babfedcba36b4cc9539d108b167d1a3f17458fda", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "ionathanch/msc-thesis", "max_forks_repo_path": "code/SizeOrd.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "ionathanch/msc-thesis", "max_issues_repo_path": "code/SizeOrd.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "ionathanch/msc-thesis", "max_stars_repo_path": "code/SizeOrd.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2043, "size": 4256 }
{-# OPTIONS --cubical --safe #-} module Cubical.Homotopy.Loopspace where open import Cubical.Core.Everything open import Cubical.Data.Nat open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.GroupoidLaws {- loop space of a pointed type -} Ω : {ℓ : Level} → Pointed ℓ → Pointed ℓ Ω (_ , a) = ((a ≡ a) , refl) {- n-fold loop space of a pointed type -} Ω^_ : ∀ {ℓ} → ℕ → Pointed ℓ → Pointed ℓ (Ω^ 0) p = p (Ω^ (suc n)) p = Ω ((Ω^ n) p) {- loop space map -} Ω→ : ∀ {ℓA ℓB} {A : Pointed ℓA} {B : Pointed ℓB} (f : A →∙ B) → (Ω A →∙ Ω B) Ω→ (f , f∙) = (λ p → (sym f∙ ∙ cong f p) ∙ f∙) , cong (λ q → q ∙ f∙) (sym (rUnit (sym f∙))) ∙ lCancel f∙
{ "alphanum_fraction": 0.6025641026, "avg_line_length": 28.08, "ext": "agda", "hexsha": "1ede1968ee02968ea84858b0162f60ef74fe6757", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmester0/cubical", "max_forks_repo_path": "Cubical/Homotopy/Loopspace.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmester0/cubical", "max_issues_repo_path": "Cubical/Homotopy/Loopspace.agda", "max_line_length": 104, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmester0/cubical", "max_stars_repo_path": "Cubical/Homotopy/Loopspace.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "num_tokens": 303, "size": 702 }
module Sets.ImageSet.Oper where open import Data open import Functional open import Logic open import Logic.Propositional open import Logic.Predicate import Lvl open import Sets.ImageSet open import Structure.Function open import Structure.Setoid renaming (_≡_ to _≡ₛ_) open import Type open import Type.Dependent private variable ℓ ℓₑ ℓᵢ ℓᵢ₁ ℓᵢ₂ ℓᵢ₃ ℓᵢₑ ℓ₁ ℓ₂ ℓ₃ : Lvl.Level private variable T X Y Z : Type{ℓ} module _ where open import Data.Boolean open import Data.Boolean.Stmt open import Data.Either as Either using (_‖_) open import Function.Domains ∅ : ImageSet{ℓᵢ}(T) ∅ = intro empty 𝐔 : ImageSet{Lvl.of(T)}(T) 𝐔 = intro id singleton : T → ImageSet{ℓᵢ}(T) singleton(x) = intro{Index = Unit} \{<> → x} pair : T → T → ImageSet{ℓᵢ}(T) pair x y = intro{Index = Lvl.Up(Bool)} \{(Lvl.up 𝐹) → x ; (Lvl.up 𝑇) → y} _∪_ : ImageSet{ℓᵢ₁}(T) → ImageSet{ℓᵢ₂}(T) → ImageSet{ℓᵢ₁ Lvl.⊔ ℓᵢ₂}(T) A ∪ B = intro{Index = Index(A) ‖ Index(B)} (Either.map1 (elem(A)) (elem(B))) ⋃ : ImageSet{ℓᵢ}(ImageSet{ℓᵢ}(T)) → ImageSet{ℓᵢ}(T) ⋃ A = intro{Index = Σ(Index(A)) (Index ∘ elem(A))} \{(intro ia i) → elem(elem(A)(ia))(i)} indexFilter : (A : ImageSet{ℓᵢ}(T)) → (Index(A) → Stmt{ℓ}) → ImageSet{ℓᵢ Lvl.⊔ ℓ}(T) indexFilter A P = intro {Index = Σ(Index(A)) P} (elem(A) ∘ Σ.left) filter : (T → Stmt{ℓ}) → ImageSet{ℓᵢ}(T) → ImageSet{ℓᵢ Lvl.⊔ ℓ}(T) filter P(A) = indexFilter A (P ∘ elem(A)) indexFilterBool : (A : ImageSet{ℓᵢ}(T)) → (Index(A) → Bool) → ImageSet{ℓᵢ}(T) indexFilterBool A f = indexFilter A (IsTrue ∘ f) filterBool : (T → Bool) → ImageSet{ℓᵢ}(T) → ImageSet{ℓᵢ}(T) filterBool f(A) = indexFilterBool A (f ∘ elem(A)) map : (X → Y) → (ImageSet{ℓᵢ}(X) → ImageSet{ℓᵢ}(Y)) map f(A) = intro{Index = Index(A)} (f ∘ elem(A)) unapply : (X → Y) → ⦃ _ : Equiv{ℓₑ}(Y)⦄ → (Y → ImageSet{Lvl.of(X) Lvl.⊔ ℓₑ}(X)) unapply f(y) = intro{Index = ∃(x ↦ f(x) ≡ₛ y)} [∃]-witness -- unmap : (X → Y) → ⦃ _ : Equiv{ℓₑ}(Y)⦄ → (ImageSet{{!Lvl.of(T) Lvl.⊔ ℓₑ!}}(Y) → ImageSet{Lvl.of(T) Lvl.⊔ ℓₑ}(X)) -- unmap f(B) = intro{Index = ∃(x ↦ f(x) ∈ B)} [∃]-witness ℘ : ImageSet{ℓᵢ}(T) → ImageSet{Lvl.𝐒(ℓᵢ)}(ImageSet{ℓᵢ}(T)) ℘(A) = intro{Index = Index(A) → Stmt} (indexFilter A) _∩_ : ⦃ _ : Equiv{ℓᵢ}(T) ⦄ → ImageSet{ℓᵢ}(T) → ImageSet{ℓᵢ}(T) → ImageSet{ℓᵢ}(T) A ∩ B = indexFilter(A) (iA ↦ elem(A) iA ∈ B) ⋂ : ⦃ _ : Equiv{ℓᵢ}(T) ⦄ → ImageSet{Lvl.of(T)}(ImageSet{Lvl.of(T)}(T)) → ImageSet{ℓᵢ Lvl.⊔ Lvl.of(T)}(T) -- ⋂ As = intro{Index = Σ((iAs : Index(As)) → Index(elem(As) iAs)) (f ↦ (∀{iAs₁ iAs₂} → (elem(elem(As) iAs₁)(f iAs₁) ≡ₛ elem(elem(As) iAs₂)(f iAs₂))))} {!!} (TODO: I think this definition only works with excluded middle because one must determine if an A from AS is empty or not and if it is not, then one can apply its index to the function in the Σ) ⋂ As = indexFilter(⋃ As) (iUAs ↦ ∃{Obj = (iAs : Index(As)) → Index(elem(As) iAs)}(f ↦ ∀{iAs} → (elem(⋃ As) iUAs ≡ₛ elem(elem(As) iAs) (f iAs)))) -- ⋂ As = indexFilter(⋃ As) (iUAs ↦ ∀{iAs} → (elem(⋃ As) iUAs ∈ elem(As) iAs)) {- module _ ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where open import Data.Boolean open import Data.Either as Either using (_‖_) open import Data.Tuple as Tuple using (_⨯_ ; _,_) import Structure.Container.SetLike as Sets open import Structure.Function.Domain open import Structure.Operator.Properties open import Structure.Relator open import Structure.Relator.Properties open import Syntax.Transitivity private variable A B C : ImageSet{ℓₑ}(T) private variable x y a b : T [∈]-of-elem : ∀{ia : Index(A)} → (elem(A)(ia) ∈ A) ∃.witness ([∈]-of-elem {ia = ia}) = ia ∃.proof [∈]-of-elem = reflexivity(_≡ₛ_) instance ∅-membership : Sets.EmptySet(_∈_ {T = T}{ℓ}) Sets.EmptySet.∅ ∅-membership = ∅ Sets.EmptySet.membership ∅-membership () instance 𝐔-membership : Sets.UniversalSet(_∈_ {T = T}) Sets.UniversalSet.𝐔 𝐔-membership = 𝐔 Sets.UniversalSet.membership 𝐔-membership {x = x} = [∃]-intro x ⦃ reflexivity(_≡ₛ_) ⦄ instance singleton-membership : Sets.SingletonSet(_∈_ {T = T}{ℓ}) Sets.SingletonSet.singleton singleton-membership = singleton Sets.SingletonSet.membership singleton-membership = proof where proof : (x ∈ singleton{ℓᵢ = ℓᵢ}(a)) ↔ (x ≡ₛ a) Tuple.left proof xin = [∃]-intro <> ⦃ xin ⦄ Tuple.right proof ([∃]-intro i ⦃ eq ⦄ ) = eq instance pair-membership : Sets.PairSet(_∈_ {T = T}{ℓ}) Sets.PairSet.pair pair-membership = pair Sets.PairSet.membership pair-membership = proof where proof : (x ∈ pair a b) ↔ (x ≡ₛ a)∨(x ≡ₛ b) Tuple.left proof ([∨]-introₗ p) = [∃]-intro (Lvl.up 𝐹) ⦃ p ⦄ Tuple.left proof ([∨]-introᵣ p) = [∃]-intro (Lvl.up 𝑇) ⦃ p ⦄ Tuple.right proof ([∃]-intro (Lvl.up 𝐹) ⦃ eq ⦄) = [∨]-introₗ eq Tuple.right proof ([∃]-intro (Lvl.up 𝑇) ⦃ eq ⦄) = [∨]-introᵣ eq instance [∪]-membership : Sets.UnionOperator(_∈_ {T = T}) Sets.UnionOperator._∪_ [∪]-membership = _∪_ Sets.UnionOperator.membership [∪]-membership = proof where proof : (x ∈ (A ∪ B)) ↔ (x ∈ A)∨(x ∈ B) Tuple.left proof ([∨]-introₗ ([∃]-intro ia)) = [∃]-intro (Either.Left ia) Tuple.left proof ([∨]-introᵣ ([∃]-intro ib)) = [∃]-intro (Either.Right ib) Tuple.right proof ([∃]-intro ([∨]-introₗ ia)) = [∨]-introₗ ([∃]-intro ia) Tuple.right proof ([∃]-intro ([∨]-introᵣ ib)) = [∨]-introᵣ ([∃]-intro ib) instance [∩]-membership : Sets.IntersectionOperator(_∈_ {T = T}) Sets.IntersectionOperator._∩_ [∩]-membership = _∩_ Sets.IntersectionOperator.membership [∩]-membership = proof where proof : (x ∈ (A ∩ B)) ↔ (x ∈ A)∧(x ∈ B) _⨯_.left proof ([↔]-intro ([∃]-intro iA ⦃ pA ⦄) ([∃]-intro iB ⦃ pB ⦄)) = [∃]-intro (intro iA ([∃]-intro iB ⦃ symmetry(_≡ₛ_) pA 🝖 pB ⦄)) _⨯_.right proof ([∃]-intro (intro iA ([∃]-intro iB ⦃ pAB ⦄)) ⦃ pxAB ⦄) = [∧]-intro ([∃]-intro iA) ([∃]-intro iB ⦃ pxAB 🝖 pAB ⦄) instance map-membership : Sets.MapFunction(_∈_ {T = T})(_∈_ {T = T}) Sets.MapFunction.map map-membership f = map f Sets.MapFunction.membership map-membership {f = f} ⦃ function ⦄ = proof where proof : (y ∈ map f(A)) ↔ ∃(x ↦ (x ∈ A) ∧ (f(x) ≡ₛ y)) ∃.witness (Tuple.left (proof) ([∃]-intro x ⦃ [∧]-intro xA fxy ⦄)) = [∃]-witness xA ∃.proof (Tuple.left (proof {y = y} {A = A}) ([∃]-intro x ⦃ [∧]-intro xA fxy ⦄)) = y 🝖[ _≡ₛ_ ]-[ fxy ]-sym f(x) 🝖[ _≡ₛ_ ]-[ congruence₁(f) ⦃ function ⦄ ([∃]-proof xA) ] f(elem(A) ([∃]-witness xA)) 🝖[ _≡ₛ_ ]-[] elem (map f(A)) ([∃]-witness xA) 🝖[ _≡ₛ_ ]-end ∃.witness (Tuple.right (proof {A = A}) ([∃]-intro iA)) = elem(A) iA ∃.proof (Tuple.right proof ([∃]-intro iA ⦃ p ⦄)) = [∧]-intro ([∈]-of-elem {ia = iA}) (symmetry(_≡ₛ_) p) indexFilter-membership : ∀{P : Index(A) → Stmt{ℓ}} → (x ∈ indexFilter A P) ↔ ∃(i ↦ (x ≡ₛ elem(A) i) ∧ P(i)) _⨯_.left indexFilter-membership ([∃]-intro iA ⦃ [∧]-intro xe p ⦄) = [∃]-intro (intro iA p) ⦃ xe ⦄ _⨯_.right indexFilter-membership ([∃]-intro (intro iA p) ⦃ xe ⦄) = [∃]-intro iA ⦃ [∧]-intro xe p ⦄ indexFilter-subset : ∀{P : Index(A) → Stmt{ℓₑ}} → (indexFilter{ℓₑ} A P ⊆ A) indexFilter-subset = [∃]-map-proof [∧]-elimₗ ∘ [↔]-to-[→] indexFilter-membership indexFilter-elem-membershipₗ : ∀{P : Index(A) → Stmt{ℓ}}{i : Index(A)} → (elem(A)(i) ∈ indexFilter A P) ← P(i) indexFilter-elem-membershipₗ {i = i} pi = [∃]-intro (intro i pi) ⦃ reflexivity _ ⦄ indexFilter-elem-membershipᵣ : ⦃ _ : Equiv{ℓₑ}(Index(A)) ⦄ ⦃ _ : Injective(elem A) ⦄ → ∀{P : Index(A) → Stmt{ℓ}} ⦃ _ : UnaryRelator(P) ⦄{i : Index(A)} → (elem(A)(i) ∈ indexFilter A P) → P(i) indexFilter-elem-membershipᵣ {A = A}{P = P} {i = i} ([∃]-intro (intro iA PiA) ⦃ p ⦄) = substitute₁ₗ(P) (injective(elem A) p) PiA instance filter-membership : Sets.FilterFunction(_∈_ {T = T}) Sets.FilterFunction.filter filter-membership f = filter{ℓ = ℓₑ} f Sets.FilterFunction.membership filter-membership {P = P} = proof where proof : (x ∈ filter P(A)) ↔ ((x ∈ A) ∧ P(x)) Tuple.left proof ([∧]-intro ([∃]-intro i ⦃ p ⦄) pb) = [∃]-intro (intro i (substitute₁(P) p pb)) ⦃ p ⦄ Tuple.left (Tuple.right proof ([∃]-intro (intro iA PiA))) = [∃]-intro iA Tuple.right (Tuple.right proof ([∃]-intro (intro iA PiA) ⦃ pp ⦄)) = substitute₁ₗ(P) pp PiA filter-subset : ∀{P : T → Stmt{ℓₑ}} → (filter P(A) ⊆ A) filter-subset ([∃]-intro (intro i p) ⦃ xf ⦄) = [∃]-intro i ⦃ xf ⦄ instance postulate [∩]-commutativity : Commutativity(_∩_ {T = T}) -- TODO: These should come from Structure.Container.SetLike, which in turn should come from Structure.Operator.Lattice, which in turn should come from Structure.Relator.Ordering.Lattice postulate [∩]-subset-of-right : (A ⊆ B) → (A ∩ B ≡ₛ B) postulate [∩]-subset-of-left : (B ⊆ A) → (A ∩ B ≡ₛ A) postulate [∩]-subsetₗ : (A ∩ B) ⊆ A [∩]-subsetᵣ : (A ∩ B) ⊆ B [∩]-subsetᵣ {A} {B} {x} xAB = indexFilter-subset ([↔]-to-[→] (commutativity(_∩_) ⦃ [∩]-commutativity ⦄ {A} {B} {x}) xAB) instance ℘-membership : Sets.PowerFunction(_∈_)(_∈_) Sets.PowerFunction.℘ ℘-membership = ℘ Sets.PowerFunction.membership ℘-membership = [↔]-intro l r where l : (B ∈ ℘(A)) ← (B ⊆ A) ∃.witness (l {B} {A} BA) iA = elem(A) iA ∈ B _⨯_.left (∃.proof (l {B}{A} BA) {x}) a = apply a $ A ∩ B 🝖[ _⊆_ ]-[ [∩]-subsetᵣ ] B 🝖[ _⊆_ ]-end _⨯_.right (∃.proof (l {B}{A} BA) {x}) b = apply b $ B 🝖[ _⊆_ ]-[ BA ] A 🝖[ _⊆_ ]-[ sub₂(_≡_)(_⊇_) ([∩]-subset-of-left BA) ] A ∩ B 🝖[ _⊆_ ]-end r : (B ∈ ℘(A)) → (B ⊆ A) r ([∃]-intro _ ⦃ BA ⦄) xB with [↔]-to-[→] BA xB ... | [∃]-intro (intro iA _) ⦃ xe ⦄ = [∃]-intro iA ⦃ xe ⦄ -}
{ "alphanum_fraction": 0.567044764, "avg_line_length": 47.932038835, "ext": "agda", "hexsha": "daaa406e1383befcf7e9065abcd1b9325b813f59", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Sets/ImageSet/Oper.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Sets/ImageSet/Oper.agda", "max_line_length": 353, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Sets/ImageSet/Oper.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 4284, "size": 9874 }
open import Agda.Builtin.IO using (IO) open import Agda.Builtin.String using (String) open import Agda.Builtin.Unit using (⊤) data D : Set where c₁ c₂ : D f : D → Set → String f c₁ = λ _ → "OK" f c₂ = λ _ → "OK" -- The following pragma should refer to the generated Haskell name -- for f. {-# FOREIGN GHC {-# NOINLINE d_f_8 #-} #-} x : String x = f c₁ ⊤ postulate putStrLn : String → IO ⊤ {-# FOREIGN GHC import qualified Data.Text.IO #-} {-# COMPILE GHC putStrLn = Data.Text.IO.putStrLn #-} main : IO ⊤ main = putStrLn x
{ "alphanum_fraction": 0.6516853933, "avg_line_length": 19.0714285714, "ext": "agda", "hexsha": "32e21bab9816aaef2420eeacf7041dad34fab83e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Compiler/simple/Issue5441.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Compiler/simple/Issue5441.agda", "max_line_length": 66, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Compiler/simple/Issue5441.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 164, "size": 534 }
{-# OPTIONS --no-unreachable-check #-} module Issue424 where data _≡_ {A : Set₁} (x : A) : A → Set where refl : x ≡ x f : Set → Set f A = A f A = A fails : (A : Set) → f A ≡ A fails A = refl -- The case tree compiler used to treat f as a definition with an -- absurd pattern.
{ "alphanum_fraction": 0.6007067138, "avg_line_length": 16.6470588235, "ext": "agda", "hexsha": "fe106892d4389a36d96ed3411f2e192e6bd0058b", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue424.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue424.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue424.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 97, "size": 283 }
{-# OPTIONS --cubical --no-import-sorts #-} open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Function.Base using (_∋_; _$_) open import MorePropAlgebra.Bundles import Cubical.Structures.CommRing as Std module MorePropAlgebra.Properties.CommRing {ℓ} (assumptions : CommRing {ℓ}) where open CommRing assumptions renaming (Carrier to R) import MorePropAlgebra.Properties.Ring module Ring'Properties = MorePropAlgebra.Properties.Ring (record { CommRing assumptions }) module Ring' = Ring (record { CommRing assumptions }) ( Ring') = Ring ∋ (record { CommRing assumptions }) stdIsCommRing : Std.IsCommRing 0r 1r _+_ _·_ (-_) stdIsCommRing .Std.IsCommRing.isRing = Ring'Properties.stdIsRing stdIsCommRing .Std.IsCommRing.·-comm = ·-comm stdCommRing : Std.CommRing {ℓ} stdCommRing = record { CommRing assumptions ; isCommRing = stdIsCommRing } -- -- module RingTheory' = Std.Theory stdRing
{ "alphanum_fraction": 0.7019607843, "avg_line_length": 39.2307692308, "ext": "agda", "hexsha": "b112c7b14de2f4d57f5fda6f5021bef812330651", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/MorePropAlgebra/Properties/CommRing.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/MorePropAlgebra/Properties/CommRing.agda", "max_line_length": 92, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/MorePropAlgebra/Properties/CommRing.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 273, "size": 1020 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Trie, basic type and operations ------------------------------------------------------------------------ -- See README.Data.Trie.NonDependent for an example of using a trie to -- build a lexer. {-# OPTIONS --without-K --safe --sized-types #-} open import Relation.Binary using (Rel; StrictTotalOrder) module Data.Trie {k e r} (S : StrictTotalOrder k e r) where open import Level open import Size open import Data.List.Base using (List; []; _∷_; _++_) import Data.List.NonEmpty as List⁺ open import Data.Maybe.Base as Maybe using (Maybe; just; nothing; maybe′) open import Data.Product as Prod using (∃) open import Data.These.Base as These using (These) open import Function open import Relation.Unary using (IUniversal; _⇒_) open StrictTotalOrder S using (module Eq) renaming (Carrier to Key) open import Data.List.Relation.Binary.Equality.Setoid Eq.setoid open import Data.AVL.Value ≋-setoid using (Value) ------------------------------------------------------------------------ -- Definition -- Trie is defined in terms of Trie⁺, the type of non-empty trie. This -- guarantees that the trie is minimal: each path in the tree leads to -- either a value or a number of non-empty sub-tries. open import Data.Trie.NonEmpty S as Trie⁺ public using (Trie⁺; Tries⁺; Word; eat) Trie : ∀ {v} (V : Value v) → Size → Set (v ⊔ k ⊔ e ⊔ r) Trie V i = Maybe (Trie⁺ V i) ------------------------------------------------------------------------ -- Operations -- Functions acting on Trie are wrappers for functions acting on Tries. -- Sometimes the empty case is handled in a special way (e.g. insertWith -- calls singleton when faced with an empty Trie). module _ {v} {V : Value v} where private Val = Value.family V ------------------------------------------------------------------------ -- Lookup lookup : ∀ ks → Trie V ∞ → Maybe (These (Val ks) (Tries⁺ (eat V ks) ∞)) lookup ks t = t Maybe.>>= Trie⁺.lookup ks lookupValue : ∀ ks → Trie V ∞ → Maybe (Val ks) lookupValue ks t = t Maybe.>>= Trie⁺.lookupValue ks lookupTries⁺ : ∀ ks → Trie V ∞ → Maybe (Tries⁺ (eat V ks) ∞) lookupTries⁺ ks t = t Maybe.>>= Trie⁺.lookupTries⁺ ks lookupTrie : ∀ k → Trie V ∞ → Trie (eat V (k ∷ [])) ∞ lookupTrie k t = t Maybe.>>= Trie⁺.lookupTrie⁺ k ------------------------------------------------------------------------ -- Construction empty : Trie V ∞ empty = nothing singleton : ∀ ks → Val ks → Trie V ∞ singleton ks v = just (Trie⁺.singleton ks v) insertWith : ∀ ks → (Maybe (Val ks) → Val ks) → Trie V ∞ → Trie V ∞ insertWith ks f (just t) = just (Trie⁺.insertWith ks f t) insertWith ks f nothing = singleton ks (f nothing) insert : ∀ ks → Val ks → Trie V ∞ → Trie V ∞ insert ks = insertWith ks ∘′ const fromList : List (∃ Val) → Trie V ∞ fromList = Maybe.map Trie⁺.fromList⁺ ∘′ List⁺.fromList toList : Trie V ∞ → List (∃ Val) toList (just t) = List⁺.toList (Trie⁺.toList⁺ t) toList nothing = [] ------------------------------------------------------------------------ -- Modification module _ {v w} {V : Value v} {W : Value w} where private Val = Value.family V Wal = Value.family W map : ∀ {i} → ∀[ Val ⇒ Wal ] → Trie V i → Trie W i map = Maybe.map ∘′ Trie⁺.map V W -- Deletion module _ {v} {V : Value v} where -- Use a function to decide how to modify the sub-Trie⁺ whose root is -- at the end of path ks. deleteWith : ∀ {i} (ks : Word) → (∀ {i} → Trie⁺ (eat V ks) i → Maybe (Trie⁺ (eat V ks) i)) → Trie V i → Trie V i deleteWith ks f t = t Maybe.>>= Trie⁺.deleteWith ks f -- Remove the whole node deleteTrie⁺ : ∀ {i} (ks : Word) → Trie V i → Trie V i deleteTrie⁺ ks t = t Maybe.>>= Trie⁺.deleteTrie⁺ ks -- Remove the value and keep the sub-Tries (if any) deleteValue : ∀ {i} (ks : Word) → Trie V i → Trie V i deleteValue ks t = t Maybe.>>= Trie⁺.deleteValue ks -- Remove the sub-Tries and keep the value (if any) deleteTries⁺ : ∀ {i} (ks : Word) → Trie V i → Trie V i deleteTries⁺ ks t = t Maybe.>>= Trie⁺.deleteTries⁺ ks
{ "alphanum_fraction": 0.5668835864, "avg_line_length": 32.1627906977, "ext": "agda", "hexsha": "442efc84b5dca21dc6668699faf723d8c2d6abff", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Trie.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Trie.agda", "max_line_length": 73, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Trie.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 1231, "size": 4149 }
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Logical relation for erasure (Def. 3.8 and Lemma 3.9) ------------------------------------------------------------------------ import Parametric.Syntax.Type as Type import Parametric.Syntax.Term as Term import Parametric.Denotation.Value as Value import Parametric.Denotation.Evaluation as Evaluation import Parametric.Change.Validity as Validity import Parametric.Change.Specification as Specification import Parametric.Change.Type as ChangeType import Parametric.Change.Value as ChangeValue import Parametric.Change.Derive as Derive module Parametric.Change.Implementation {Base : Type.Structure} (Const : Term.Structure Base) (⟦_⟧Base : Value.Structure Base) (⟦_⟧Const : Evaluation.Structure Const ⟦_⟧Base) (ΔBase : ChangeType.Structure Base) {{validity-structure : Validity.Structure ⟦_⟧Base}} (⟦apply-base⟧ : ChangeValue.ApplyStructure Const ⟦_⟧Base ΔBase) (⟦diff-base⟧ : ChangeValue.DiffStructure Const ⟦_⟧Base ΔBase) (⟦nil-base⟧ : ChangeValue.NilStructure Const ⟦_⟧Base ΔBase) (derive-const : Derive.Structure Const ΔBase) where open Type.Structure Base open Term.Structure Base Const open Value.Structure Base ⟦_⟧Base open Evaluation.Structure Const ⟦_⟧Base ⟦_⟧Const open Validity.Structure ⟦_⟧Base {{validity-structure}} open ChangeType.Structure Base ΔBase open ChangeValue.Structure Const ⟦_⟧Base ΔBase ⟦apply-base⟧ ⟦diff-base⟧ ⟦nil-base⟧ open Derive.Structure Const ΔBase derive-const open import Base.Denotation.Notation open import Relation.Binary.PropositionalEquality open import Postulate.Extensionality record Structure : Set₁ where ---------------- -- Parameters -- ---------------- field -- Extension point 1: Logical relation on base types. -- -- In the paper, we assume that the logical relation is equality on base types -- (see Def. 3.8a). Here, we only require that plugins define what the logical -- relation is on base types, and provide proofs for the two extension points -- below. implements-base : ∀ ι {v : ⟦ ι ⟧Base} → Δ₍ ι ₎ v → ⟦ ΔBase ι ⟧Type → Set -- Extension point 2: Differences on base types are logically related. u⊟v≈u⊝v-base : ∀ ι {u v : ⟦ ι ⟧Base} → implements-base ι (u ⊟₍ ι ₎ v) (⟦diff-base⟧ ι u v) nil-v≈⟦nil⟧-v-base : ∀ ι {v : ⟦ ι ⟧Base} → implements-base ι (nil₍ ι ₎ v) (⟦nil-base⟧ ι v) -- Extension point 3: Lemma 3.1 for base types. carry-over-base : ∀ {ι} {v : ⟦ ι ⟧Base} (Δv : Δ₍ ι ₎ v) {Δv′ : ⟦ ΔBase ι ⟧Type} (Δv≈Δv′ : implements-base ι Δv Δv′) → v ⊞₍ base ι ₎ Δv ≡ v ⟦⊕₍ base ι ₎⟧ Δv′ ------------------------ -- Logical relation ≈ -- ------------------------ infix 4 implements syntax implements τ u v = u ≈₍ τ ₎ v implements : ∀ τ {v} → Δ₍ τ ₎ v → ⟦ ΔType τ ⟧ → Set implements (base ι) Δf Δf′ = implements-base ι Δf Δf′ implements (σ ⇒ τ) {f} Δf Δf′ = (w : ⟦ σ ⟧) (Δw : Δ₍ σ ₎ w) (Δw′ : ⟦ ΔType σ ⟧) (Δw≈Δw′ : implements σ {w} Δw Δw′) → implements τ {f w} (call-change {σ} {τ} Δf w Δw) (Δf′ w Δw′) infix 4 _≈_ _≈_ : ∀ {τ v} → Δ₍ τ ₎ v → ⟦ ΔType τ ⟧ → Set _≈_ {τ} {v} = implements τ {v} data implements-env : ∀ Γ → {ρ : ⟦ Γ ⟧} (dρ : Δ₍ Γ ₎ ρ) → ⟦ mapContext ΔType Γ ⟧ → Set where ∅ : implements-env ∅ {∅} ∅ ∅ _•_ : ∀ {τ Γ v ρ dv dρ v′ ρ′} → (dv≈v′ : implements τ {v} dv v′) → (dρ≈ρ′ : implements-env Γ {ρ} dρ ρ′) → implements-env (τ • Γ) {v • ρ} (dv • dρ) (v′ • ρ′) ---------------- -- carry-over -- ---------------- -- This is lemma 3.10. carry-over : ∀ {τ} {v : ⟦ τ ⟧} (Δv : Δ₍ τ ₎ v) {Δv′ : ⟦ ΔType τ ⟧} (Δv≈Δv′ : Δv ≈₍ τ ₎ Δv′) → after₍ τ ₎ Δv ≡ before₍ τ ₎ Δv ⟦⊕₍ τ ₎⟧ Δv′ u⊟v≈u⊝v : ∀ {τ : Type} {u v : ⟦ τ ⟧} → u ⊟₍ τ ₎ v ≈₍ τ ₎ u ⟦⊝₍ τ ₎⟧ v u⊟v≈u⊝v {base ι} {u} {v} = u⊟v≈u⊝v-base ι {u} {v} u⊟v≈u⊝v {σ ⇒ τ} {g} {f} w Δw Δw′ Δw≈Δw′ = subst (λ □ → (g □ ⊟₍ τ ₎ f (before₍ σ ₎ Δw)) ≈₍ τ ₎ g (before₍ σ ₎ Δw ⟦⊕₍ σ ₎⟧ Δw′) ⟦⊝₍ τ ₎⟧ f (before₍ σ ₎ Δw)) (sym (carry-over {σ} Δw Δw≈Δw′)) (u⊟v≈u⊝v {τ} {g (before₍ σ ₎ Δw ⟦⊕₍ σ ₎⟧ Δw′)} {f (before₍ σ ₎ Δw)}) nil-v≈⟦nil⟧-v : ∀ {τ : Type} {v : ⟦ τ ⟧} → nil₍ τ ₎ v ≈₍ τ ₎ (⟦nil₍ τ ₎⟧ v) nil-v≈⟦nil⟧-v {base ι} = nil-v≈⟦nil⟧-v-base ι nil-v≈⟦nil⟧-v {σ ⇒ τ} {f} = u⊟v≈u⊝v {σ ⇒ τ} {f} {f} carry-over {base ι} Δv Δv≈Δv′ = carry-over-base Δv Δv≈Δv′ carry-over {σ ⇒ τ} {f} Δf {Δf′} Δf≈Δf′ = ext (λ v → carry-over {τ} {f v} (call-change {σ} {τ} Δf v (nil₍ σ ₎ v)) {Δf′ v (⟦nil₍ σ ₎⟧ v)} (Δf≈Δf′ v (nil₍ σ ₎ v) (⟦nil₍ σ ₎⟧ v) (nil-v≈⟦nil⟧-v {σ} {v}))) -- A property relating `alternate` and the subcontext relation Γ≼ΔΓ ⟦Γ≼ΔΓ⟧ : ∀ {Γ} (ρ : ⟦ Γ ⟧) (dρ : ⟦ mapContext ΔType Γ ⟧) → ρ ≡ ⟦ Γ≼ΔΓ ⟧≼ (alternate ρ dρ) ⟦Γ≼ΔΓ⟧ ∅ ∅ = refl ⟦Γ≼ΔΓ⟧ (v • ρ) (dv • dρ) = cong₂ _•_ refl (⟦Γ≼ΔΓ⟧ ρ dρ) -- A specialization of the soundness of weakening ⟦fit⟧ : ∀ {τ Γ} (t : Term Γ τ) (ρ : ⟦ Γ ⟧) (dρ : ⟦ mapContext ΔType Γ ⟧) → ⟦ t ⟧ ρ ≡ ⟦ fit t ⟧ (alternate ρ dρ) ⟦fit⟧ t ρ dρ = trans (cong ⟦ t ⟧ (⟦Γ≼ΔΓ⟧ ρ dρ)) (sym (weaken-sound t _))
{ "alphanum_fraction": 0.545225644, "avg_line_length": 36.6170212766, "ext": "agda", "hexsha": "d2ab9a895df58fd61f0883fb9d3fef4256ece404", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Parametric/Change/Implementation.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Parametric/Change/Implementation.agda", "max_line_length": 112, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Parametric/Change/Implementation.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 2308, "size": 5163 }
open import Agda.Builtin.Nat open import Agda.Builtin.Sigma open import Agda.Builtin.Equality data I : Set where it : I data D : I → Set where d : D it data Box : Set where [_] : Nat → Box mutual data Code : Set where d : I → Code box : Code sg : (a : Code) → (El a → Code) → Code El : Code → Set El (d i) = D i El box = Box El (sg a f) = Σ (El a) λ x → El (f x) foo : (i : I) → Code foo i = sg (d i) aux where aux : D i → Code aux d = sg box λ { [ a ] → box } crash : ∀ i → El (foo i) → Nat crash i (d , p) = p
{ "alphanum_fraction": 0.525483304, "avg_line_length": 16.7352941176, "ext": "agda", "hexsha": "cecf7379cff1d021d295a319cc85b69abcb7f69e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue2883.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue2883.agda", "max_line_length": 43, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue2883.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 226, "size": 569 }
{-# OPTIONS --rewriting #-} open import Agda.Builtin.Equality {-# BUILTIN REWRITE _≡_ #-} module _ (Form : Set) where -- FAILS -- postulate Form : Set -- WORKS data Cxt : Set where ε : Cxt _∙_ : (Γ : Cxt) (A : Form) → Cxt data _≤_ : (Γ Δ : Cxt) → Set where id≤ : ∀{Γ} → Γ ≤ Γ weak : ∀{A Γ Δ} (τ : Γ ≤ Δ) → (Γ ∙ A) ≤ Δ lift : ∀{A Γ Δ} (τ : Γ ≤ Δ) → (Γ ∙ A) ≤ (Δ ∙ A) postulate lift-id≤ : ∀{Γ A} → lift id≤ ≡ id≤ {Γ ∙ A} {-# REWRITE lift-id≤ #-}
{ "alphanum_fraction": 0.5, "avg_line_length": 23, "ext": "agda", "hexsha": "580427716fc8f33b4193a2e1f6d9086fa74c42fa", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue3538.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue3538.agda", "max_line_length": 52, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue3538.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 213, "size": 460 }
open import Agda.Builtin.Nat record R : Set where field x : Nat open R {{...}} f₁ : R -- This is fine. x ⦃ f₁ ⦄ = 0 -- WAS: THIS WORKS BUT MAKES NO SENSE!!! _ : Nat _ = f₁ {{ .x }} -- Should raise an error. -- Illegal hiding in postfix projection ⦃ .x ⦄ -- when scope checking f₁ ⦃ .x ⦄
{ "alphanum_fraction": 0.584717608, "avg_line_length": 13.6818181818, "ext": "agda", "hexsha": "63bdc1c79742d24dfbfa6443f305f661e84e5542", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue3289-rhs.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue3289-rhs.agda", "max_line_length": 47, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue3289-rhs.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 113, "size": 301 }
{-# OPTIONS --without-K #-} module homotopy.3x3.Common where open import HoTT public hiding (↓-='-in; ↓-='-out; ↓-=-in; ↓-=-out; ↓-∘=idf-in) !-∘-ap-inv : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : B → C) (g : A → B) {a b : A} (p : a == b) → ap-∘ f g p == ! (∘-ap f g p) !-∘-ap-inv f g idp = idp !-ap-∘-inv : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : B → C) (g : A → B) {a b : A} (p : a == b) → ∘-ap f g p == ! (ap-∘ f g p) !-ap-∘-inv f g idp = idp !-∘-ap : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : B → C) (g : A → B) {a b : A} (p : a == b) → ! (∘-ap f g p) == ap-∘ f g p !-∘-ap f g idp = idp !-ap-∘ : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : B → C) (g : A → B) {a b : A} (p : a == b) → ! (ap-∘ f g p) == ∘-ap f g p !-ap-∘ f g idp = idp module _ {i} {A : Type i} where _,_=□_,_ : {a b b' c : A} (p : a == b) (q : b == c) (r : a == b') (s : b' == c) → Type i (idp , q =□ r , idp) = (q == r) idp□ : {a b : A} {p : a == b} → idp , p =□ idp , p idp□ {p = idp} = idp idp□-i : {a b : A} {p : a == b} → p , idp =□ idp , p idp□-i {p = idp} = idp idp,=□idp,-in : {a b : A} {p q : a == b} → p == q → idp , p =□ idp , q idp,=□idp,-in {q = idp} α = α idp,=□idp,-out : {a b : A} {p q : a == b} → idp , p =□ idp , q → p == q idp,=□idp,-out {q = idp} α = α idp,=□idp,-β : {a b : A} {p q : a == b} (α : p == q) → idp,=□idp,-out (idp,=□idp,-in α) == α idp,=□idp,-β {q = idp} α = idp idp,=□idp,-η : {a b : A} {p q : a == b} (α : idp , p =□ idp , q) → idp,=□idp,-in (idp,=□idp,-out α) == α idp,=□idp,-η {q = idp} α = idp ,idp=□,idp-in : {a b : A} {p q : a == b} → p == q → p , idp =□ q , idp ,idp=□,idp-in {p = idp} α = α ,idp=□,idp-out : {a b : A} {p q : a == b} → p , idp =□ q , idp → p == q ,idp=□,idp-out {p = idp} α = α ,idp=□,idp-β : {a b : A} {p q : a == b} (α : p == q) → ,idp=□,idp-out (,idp=□,idp-in α) == α ,idp=□,idp-β {p = idp} α = idp ,idp=□,idp-η : {a b : A} {p q : a == b} (α : p , idp =□ q , idp) → ,idp=□,idp-in (,idp=□,idp-out α) == α ,idp=□,idp-η {p = idp} α = idp ,idp=□idp,-in : {a b : A} {p q : a == b} → p == q → p , idp =□ idp , q ,idp=□idp,-in {p = idp} = idp,=□idp,-in ,idp=□idp,-out : {a b : A} {p q : a == b} → p , idp =□ idp , q → p == q ,idp=□idp,-out {p = idp} {q} α = idp,=□idp,-out α ,idp=□idp,-β : {a b : A} {p q : a == b} (α : p == q) → ,idp=□idp,-out (,idp=□idp,-in α) == α ,idp=□idp,-β {p = idp} α = idp,=□idp,-β α ,idp=□idp,-η : {a b : A} {p q : a == b} (α : p , idp =□ idp , q) → ,idp=□idp,-in (,idp=□idp,-out α) == α ,idp=□idp,-η {p = idp} α = idp,=□idp,-η α _∙□-i/_/_/ : {a b b' c : A} {p : a == b} {q q' : b == c} {r r' : a == b'} {s : b' == c} → (p , q =□ r , s) → (q' == q) → (r == r') → (p , q' =□ r' , s) α ∙□-i/ idp / idp / = α _∙□-o/_/_/ : {a b b' c : A} {p p' : a == b} {q : b == c} {r : a == b'} {s s' : b' == c} → (p , q =□ r , s) → (p' == p) → (s == s') → (p' , q =□ r , s') α ∙□-o/ idp / idp / = α _∙□h_ : {a b b' c c' d : A} {p : a == b} {q : b == c} {r : a == b'} {s : b' == c} {t : c == d} {u : b' == c'} {v : c' == d} → (p , q =□ r , s) → (s , t =□ u , v) → (p , q ∙ t =□ r ∙ u , v) _∙□h_ {p = idp} {s = idp} {v = idp} idp idp = idp module _ {i j} {A : Type i} {B : Type j} (f : A → B) where ap□ : {a b b' c : A} {p : a == b} {q : b == c} {r : a == b'} {s : b' == c} → (p , q =□ r , s) → (ap f p , ap f q =□ ap f r , ap f s) ap□ {p = idp} {s = idp} α = ap (ap f) α module _ {i j} {A : Type i} {B : Type j} (f : A → B) where ap□-,idp=□idp,-in : {a b : A} {p q : a == b} (α : p == q) → ap□ f (,idp=□idp,-in α) == ,idp=□idp,-in (ap (ap f) α) ap□-,idp=□idp,-in {p = idp} idp = idp module _ {i j} {A : Type i} {B : A → Type j} where _,_=□d-i_,_ : {a b : A} {p : a == b} {u v : B a} {w x : B b} → (u == v) → (v == w [ B ↓ p ]) → (u == x [ B ↓ p ]) → (x == w) → Type j _,_=□d-i_,_ idp α β idp = (α == β) -- _,_=□d-i_,_ {p = idp} = _,_=□_,_ idp,=□d-iidp,-out : {a : A} {u w : B a} {α β : u == w} → (idp , α =□d-i idp , β) → α == β idp,=□d-iidp,-out {β = idp} x = x ,idp=□d-iidp,-out : {a : A} {u w : B a} {α β : u == w} → (α , idp =□d-i idp , β) → α == β ,idp=□d-iidp,-out {α = idp} x = idp,=□d-iidp,-out x idp,=□d-iidp,-in : {a : A} {u w : B a} {α β : u == w} → α == β → (idp , α =□d-i idp , β) idp,=□d-iidp,-in {β = idp} x = x ,idp=□d-iidp,-in : {a : A} {u w : B a} {α β : u == w} → α == β → (α , idp =□d-i idp , β) ,idp=□d-iidp,-in {α = idp} x = idp,=□d-iidp,-in x _◃/_/_/ : {a b : A} {p : a == b} {u v : B a} {w x : B b} → (v == w [ B ↓ p ]) → (u == v) → (w == x) → (u == x [ B ↓ p ]) α ◃/ idp / idp / = α module _ {i} {A : Type i} where _,_,_=□□_,_,_ : {a0 b0 b'0 c0 a1 b1 b'1 c1 : A} {p0 : a0 == b0} {q0 : b0 == c0} {r0 : a0 == b'0} {s0 : b'0 == c0} {p1 : a1 == b1} {q1 : b1 == c1} {r1 : a1 == b'1} {s1 : b'1 == c1} {a* : a0 == a1} {b* : b0 == b1} {b'* : b'0 == b'1} {c* : c0 == c1} → (p0 , q0 =□ r0 , s0) → (s0 , c* =□ b'* , s1) → (r0 , b'* =□ a* , r1) → (q0 , c* =□ b* , q1) → (p0 , b* =□ a* , p1) → (p1 , q1 =□ r1 , s1) → Type i _,_,_=□□_,_,_ {p0 = idp} {s0 = idp} {p1 = idp} {s1 = idp} idp idp β γ idp idp = β == γ {- Nondependent identity type -} module _ {i j} {A : Type i} {B : Type j} {f g : A → B} where ↓-='-in : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → (u , ap g p =□ ap f p , v) → (u == v [ (λ x → f x == g x) ↓ p ]) ↓-='-in {p = idp} α = ,idp=□idp,-out α ↓-='-out : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → (u == v [ (λ x → f x == g x) ↓ p ]) → (u , ap g p =□ ap f p , v) ↓-='-out {p = idp} α = ,idp=□idp,-in α ↓-='-β : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B} {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} (α : (u , ap g p =□ ap f p , v)) → ↓-='-out (↓-='-in α) == α ↓-='-β {p = idp} α = ,idp=□idp,-η α module _ {i j k} {A : Type i} {B : Type j} (C : Type k) {g h : B → C} (f : A → B) where lemma-a : {x y : A} (p : x == y) {u : g (f x) == h (f x)} {v : g (f y) == h (f y)} {q : f x == f y} (r : ap f p == q) (α : u == v [ (λ z → g z == h z) ↓ q ]) → ↓-='-out (↓-ap-out= (λ z → g z == h z) f p r α) == ↓-='-out α ∙□-i/ ap-∘ h f p ∙ ap (ap h) r / ! (ap (ap g) r) ∙ ∘-ap g f p / lemma-a idp idp idp = idp {- Dependent identity type -} ↓-=-in : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B} {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y} → (u , apd f p =□d-i apd g p , v) → (u == v [ (λ x → g x == f x) ↓ p ]) ↓-=-in {B = B} {p = idp} {u} {v} α = ,idp=□d-iidp,-out α ↓-=-out : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B} {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y} → (u == v [ (λ x → g x == f x) ↓ p ]) → (u , apd f p =□d-i apd g p , v) ↓-=-out {B = B} {p = idp} {u} {v} α = ,idp=□d-iidp,-in α ↓-=□-in : ∀ {i j} {A : Type i} {B : Type j} {f g g' h : A → B} {x y : A} {α : x == y} {p : (x : A) → f x == g x} {q : (x : A) → g x == h x} {r : (x : A) → f x == g' x} {s : (x : A) → g' x == h x} {u : (p x , q x =□ r x , s x)} {v : (p y , q y =□ r y , s y)} → (u , ↓-='-out (apd s α) , ↓-='-out (apd r α) =□□ ↓-='-out (apd q α) , ↓-='-out (apd p α) , v) → (u == v [ (λ x → (p x , q x =□ r x , s x)) ↓ α ]) ↓-=□-in {α = idp} = ch _ _ where ch : ∀ {j} {B : Type j} {f g g' h : B} {p : f == g} {q : g == h} {r : f == g'} {s : g' == h} (u v : p , q =□ r , s) → u , ,idp=□idp,-in idp , ,idp=□idp,-in idp =□□ ,idp=□idp,-in idp , ,idp=□idp,-in idp , v → u == v ch {p = idp} {s = idp} u v = ,idp=□idp,-out ∘ ch2 u idp idp v where ch2 : ∀ {i} {A : Type i} {a b : A} {q q' r r' : a == b} (p : q == r) (p' : r == r') (s' : q == q') (s : q' == r') → (p , idp , ,idp=□idp,-in p' =□□ ,idp=□idp,-in s' , idp , s) → (p , p' =□ s' , s) ch2 idp p' s' idp α = ! (,idp=□idp,-β p') ∙ ap ,idp=□idp,-out α ∙ ,idp=□idp,-β s' -- Dependent path in a type of the form [λ x → x ≡ g (f x)] module _ {i j} {A : Type i} {B : Type j} (g : B → A) (f : A → B) where ↓-idf=∘-in : {x y : A} {p : x == y} {u : x == g (f x)} {v : y == g (f y)} → (u , ap g (ap f p) =□ p , v) → (u == v [ (λ x → x == g (f x)) ↓ p ]) ↓-idf=∘-in {p = idp} q = ,idp=□idp,-out q ↓-∘=idf-in : {x y : A} {p : x == y} {u : g (f x) == x} {v : g (f y) == y} → (u , p =□ ap g (ap f p) , v) → (u == v [ (λ x → g (f x) == x) ↓ p ]) ↓-∘=idf-in {p = idp} q = ,idp=□idp,-out q module _ {i i' j k} {A : Type i} {A' : Type i'} {B : Type j} {C : Type k} (f : B → C) (g : A → B) (h : A' → B) where ap-∙∙`∘`∘ : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : c == d) → ap f (ap g p ∙ q ∙ ap h r) == ap (f ∘ g) p ∙ ap f q ∙ ap (f ∘ h) r ap-∙∙`∘`∘ idp q idp = ap-∙ f q idp ap-∙∙!`∘`∘ : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : d == c) → ap f (ap g p ∙ q ∙ ap h (! r)) == ap (f ∘ g) p ∙ ap f q ∙ ! (ap (f ∘ h) r) ap-∙∙!`∘`∘ idp q idp = ap-∙ f q idp ap-∙∙!'`∘`∘ : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : d == c) → ap f (ap g p ∙ q ∙ ! (ap h r)) == ap (f ∘ g) p ∙ ap f q ∙ ! (ap (f ∘ h) r) ap-∙∙!'`∘`∘ idp q idp = ap-∙ f q idp ap-!∙∙`∘`∘ : {a b : A} {c d : A'} (p : b == a) (q : g b == h c) (r : c == d) → ap f (ap g (! p) ∙ q ∙ ap h r) == ! (ap (f ∘ g) p) ∙ ap f q ∙ ap (f ∘ h) r ap-!∙∙`∘`∘ idp q idp = ap-∙ f q idp ap-!'∙∙`∘`∘ : {a b : A} {c d : A'} (p : b == a) (q : g b == h c) (r : c == d) → ap f (! (ap g p) ∙ q ∙ ap h r) == ! (ap (f ∘ g) p) ∙ ap f q ∙ ap (f ∘ h) r ap-!'∙∙`∘`∘ idp q idp = ap-∙ f q idp module _ {i i' j k} {A : Type i} {A' : Type i'} {B : Type j} {C : B → Type k} (f : Π B C) (g : A → B) (h : A' → B) where apd-∙∙`∘`∘ : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : c == d) → apd f (ap g p ∙ q ∙ ap h r) == ↓-ap-in _ _ (apd (f ∘ g) p) ∙ᵈ apd f q ∙ᵈ ↓-ap-in _ _ (apd (f ∘ h) r) apd-∙∙`∘`∘ idp q idp = ch q where ch : {a b : B} (q : a == b) → apd f (q ∙ idp) == idp ∙ᵈ apd f q ∙ᵈ idp ch idp = idp module _ {i i' j k} {A : Type i} {A' : Type i'} {B : Type j} {C : Type k} {f : A → B} {f' : A' → B} {g h : B → C} where lemma-b : {x y : A} {z t : A'} {p : x == y} {q : z == t} (r : f y == f' z) {a : g (f x) == h (f x)} {b : g (f y) == h (f y)} {c : g (f' z) == h (f' z)} {d : g (f' t) == h (f' t)} (u : a == b [ (λ x → g (f x) == h (f x)) ↓ p ]) (v : (b , ap h r =□ ap g r , c)) (w : c == d [ (λ x → g (f' x) == h (f' x)) ↓ q ]) → ↓-='-out (↓-ap-in _ f u ∙ᵈ ↓-='-in v ∙ᵈ ↓-ap-in _ f' w) == (↓-='-out u ∙□h (v ∙□h ↓-='-out w)) ∙□-i/ ap-∙∙`∘`∘ h f f' p r q / ! (ap-∙∙`∘`∘ g f f' p r q) / lemma-b {p = idp} {q = idp} r idp v idp = ch r v where ch : ∀ {a b : B} (r : a == b) {p : g a == h a} {q : g b == h b} (v : (p , ap h r =□ ap g r , q)) → ↓-='-out (idp ∙ᵈ ↓-='-in v ∙ᵈ idp) == (,idp=□idp,-in idp ∙□h (v ∙□h ,idp=□idp,-in idp)) ∙□-i/ ap-∙ h r idp / ! (ap-∙ g r idp) / ch idp v = ch2 (,idp=□idp,-out v) ∙ (,idp=□idp,-η v |in-ctx (λ u → ,idp=□idp,-in idp ∙□h (u ∙□h ,idp=□idp,-in idp))) where ch2 : ∀ {i} {A : Type i} {a b : A} {p q : a == b} (v' : p == q) → ,idp=□idp,-in (v' ∙ idp) == ,idp=□idp,-in idp ∙□h (,idp=□idp,-in v' ∙□h ,idp=□idp,-in idp) ch2 {p = idp} v' = ch3 v' where ch3 : ∀ {i} {A : Type i} {a : A} {q : a == a} (v' : idp == q) → idp,=□idp,-in (v' ∙ idp) == (,idp=□idp,-in idp ∙□h (idp,=□idp,-in v' ∙□h ,idp=□idp,-in idp)) ch3 idp = idp module _ {i} {A : Type i} where pp-coh : {a b b' c c' d d' e : A} {p : a == b} {q : b == c} {r : c == d} {s : e == d} {t : b' == a} {u : b' == c'} {v : c' == d'} {w : d' == e} → (p , (q ∙ r ∙ (! s)) =□ (! t ∙ u ∙ v) , w) → (u , (v ∙ w ∙ s) =□ (t ∙ p ∙ q) , r) pp-coh {p = idp} {q} {idp} {idp} {idp} {idp} {idp} {idp} α = (! α) ∙ (∙-unit-r q) pp-coh! : {a b b' c c' d d' e : A} {u : b' == c'} {v : c' == d'} {w : d' == e} {s : e == d} {t : b' == a} {p : a == b} {q : b == c} {r : c == d} → (u , (v ∙ w ∙ s) =□ (t ∙ p ∙ q) , r) → (p , (q ∙ r ∙ (! s)) =□ ((! t) ∙ u ∙ v) , w) pp-coh! {u = idp} {idp} {idp} {idp} {idp} {idp} {q} {idp} α = ∙-unit-r q ∙ (! α) pp-coh-β : {a b b' c c' d d' e : A} {u : b' == c'} {v : c' == d'} {w : d' == e} {s : e == d} {t : b' == a} {p : a == b} {q : b == c} {r : c == d} (α : (u , (v ∙ w ∙ s) =□ (t ∙ p ∙ q) , r)) → pp-coh {p = p} {q = q} {r = r} {s = s} {t = t} {u = u} {v = v} {w = w} (pp-coh! {u = u} {v = v} {w = w} {s = s} {t = t} {p = p} {q = q} {r = r} α) == α pp-coh-β {u = idp} {idp} {idp} {idp} {idp} {idp} {.idp} {idp} idp = idp pp-coh!-β : {a b b' c c' d d' e : A} {p : a == b} {q : b == c} {r : c == d} {s : e == d} {t : b' == a} {u : b' == c'} {v : c' == d'} {w : d' == e} (α : (p , (q ∙ r ∙ (! s)) =□ (! t ∙ u ∙ v) , w)) → pp-coh! {u = u} {v} {w} {s} {t} {p} {q} {r} (pp-coh {p = p} {q} {r} {s} {t} {u} {v} {w} α) == α pp-coh!-β {p = idp} {idp} {idp} {idp} {idp} {idp} {.idp} {idp} idp = idp module _ {i j} {A : Type i} {B : Type j} where ap-∙∙ : (f : A → B) {x y z t : A} (p : x == y) (q : y == z) (r : z == t) → ap f (p ∙ q ∙ r) == ap f p ∙ ap f q ∙ ap f r ap-∙∙ f idp q idp = ap-∙ f q idp ap-∙∙! : (f : A → B) {x y z t : A} (p : x == y) (q : y == z) (r : t == z) → ap f (p ∙ q ∙ ! r) == ap f p ∙ ap f q ∙ ! (ap f r) ap-∙∙! f idp q idp = ap-∙ f q idp ap-!∙∙ : (f : A → B) {x y z t : A} (p : y == x) (q : y == z) (r : z == t) → ap f (! p ∙ q ∙ r) == ! (ap f p) ∙ ap f q ∙ ap f r ap-!∙∙ f idp q idp = ap-∙ f q idp module _ {i j k} {A : Type i} {B : Type j} {C₁ C₂ C₃ C₄ : Type k} {g₁ : C₁ → A} {g₂ : C₂ → A} {g₃ : C₃ → A} {g₄ : C₄ → A} (f : A → B) where ap□-pp-coh : {a b b' c c' d d' e : A} {p : a == b} {q : b == c} {r : c == d} {s : e == d} {t : b' == a} {u : b' == c'} {v : c' == d'} {w : d' == e} (α : (p , (q ∙ r ∙ (! s)) =□ (! t ∙ u ∙ v) , w)) → ap□ f (pp-coh {p = p} {q} {r} {s} {t} {u} {v} {w} α) == pp-coh {p = ap f p} {ap f q} {ap f r} {ap f s} {ap f t} {ap f u} {ap f v} {ap f w} (ap□ f α ∙□-i/ ! (ap-∙∙! f q r s) / ap-!∙∙ f t u v /) ∙□-i/ ap-∙∙ f v w s / ! (ap-∙∙ f t p q) / ap□-pp-coh {p = idp} {q} {idp} {idp} {idp} {idp} {idp} {idp} α = c q idp α where c : {a b : A} (q q' : a == b) (α : q ∙ idp == q') → ap (ap f) (! α ∙ ∙-unit-r q) == (! (ap (ap f) α ∙□-i/ ! (ap-∙∙! f q idp idp) / idp /) ∙ ∙-unit-r (ap f q)) ∙□-i/ idp / ! (ap-∙∙ f idp idp q) / c idp q' α = d α where d : {a b : A} {q q' : a == b} (α : q == q') → ap (ap f) (! α ∙ idp) == ! (ap (ap f) α) ∙ idp d idp = idp ap□-coh : {a₁ b₁ : C₁} {a₂ b₂ : C₂} {a₃ b₃ : C₃} {a₄ b₄ : C₄} {p : g₃ b₃ == g₁ a₁} {q : a₁ == b₁} {r : g₁ b₁ == g₂ b₂} {s : a₂ == b₂} {t : a₃ == b₃} {u : g₃ a₃ == g₄ a₄} {v : a₄ == b₄} {w : g₄ b₄ == g₂ a₂} (α : (p , (ap g₁ q ∙ r ∙ (! (ap g₂ s))) =□ (! (ap g₃ t) ∙ u ∙ ap g₄ v) , w)) → ap□ f (pp-coh {p = p} {ap g₁ q} {r} {ap g₂ s} {ap g₃ t} {u} {ap g₄ v} {w} α) == pp-coh {p = ap f p} {ap (f ∘ g₁) q} {ap f r} {ap (f ∘ g₂) s} {ap (f ∘ g₃) t} {ap f u} {ap (f ∘ g₄) v} {ap f w} (ap□ f α ∙□-i/ ! (ap-∙∙!'`∘`∘ f g₁ g₂ q r s) / ap-!'∙∙`∘`∘ f g₃ g₄ t u v /) ∙□-i/ ap-∙∙`∘`∘ f g₄ g₂ v w s / ! (ap-∙∙`∘`∘ f g₃ g₁ t p q) / ap□-coh {p = p} {idp} {r} {idp} {idp} {u} {idp} {w} α = ap□-pp-coh {p = p} {idp} {r} {idp} {idp} {u} {idp} {w} α module _ {i j k} {A : Type i} {B : Type j} {C₁ C₂ C₃ C₄ : Type k} {g₁ : C₁ → A} {g₂ : C₂ → A} {g₃ : C₃ → A} {g₄ : C₄ → A} (f : A → B) where ap□-pp-coh! : {a b b' c c' d d' e : A} {u : b' == c'} {v : c' == d'} {w : d' == e} {s : e == d} {t : b' == a} {p : a == b} {q : b == c} {r : c == d} (α : (u , (v ∙ w ∙ s) =□ (t ∙ p ∙ q) , r)) → ap□ f (pp-coh! {u = u} {v} {w} {s} {t} {p} {q} {r} α) == pp-coh! {u = ap f u} {ap f v} {ap f w} {ap f s} {ap f t} {ap f p} {ap f q} {ap f r} (ap□ f α ∙□-i/ ! (ap-∙∙ f v w s) / ap-∙∙ f t p q /) ∙□-i/ ap-∙∙! f q r s / ! (ap-!∙∙ f t u v) / ap□-pp-coh! {u = idp} {idp} {idp} {idp} {idp} {idp} {.idp} {idp} idp = idp ap□-coh! : {a₁ b₁ : C₁} {a₂ b₂ : C₂} {a₃ b₃ : C₃} {a₄ b₄ : C₄} {u : g₃ a₃ == g₄ a₄} {v : a₄ == b₄} {w : g₄ b₄ == g₂ a₂} {s : a₂ == b₂} {t : a₃ == b₃} {p : g₃ b₃ == g₁ a₁} {q : a₁ == b₁} {r : g₁ b₁ == g₂ b₂} (α : (u , (ap g₄ v ∙ w ∙ ap g₂ s) =□ (ap g₃ t ∙ p ∙ ap g₁ q) , r)) → ap□ f (pp-coh! {u = u} {ap g₄ v} {w} {ap g₂ s} {ap g₃ t} {p} {ap g₁ q} {r} α) == pp-coh! {u = ap f u} {ap (f ∘ g₄) v} {ap f w} {ap (f ∘ g₂) s} {ap (f ∘ g₃) t} {ap f p} {ap (f ∘ g₁) q} {ap f r} (ap□ f α ∙□-i/ ! (ap-∙∙`∘`∘ f g₄ g₂ v w s) / ap-∙∙`∘`∘ f g₃ g₁ t p q /) ∙□-i/ ap-∙∙!'`∘`∘ f g₁ g₂ q r s / ! (ap-!'∙∙`∘`∘ f g₃ g₄ t u v) / ap□-coh! {u = u} {idp} {w} {idp} {idp} {p} {idp} {r} α = ap□-pp-coh! {u = u} {idp} {w} {idp} {idp} {p} {idp} {r} α module _ {i} {A : Type i} where lemma : {a b b' c c' d d' e : A} {u u' : b' == c'} {v : c' == d'} {w w' : d' == e} {s : e == d} {t : b' == a} {p p' : a == b} {q : b == c} {r r' : c == d} (β : u' == u) (γ : w' == w) (δ : p' == p) (ε : r' == r) (α : (u , (v ∙ w ∙ s) =□ (t ∙ p ∙ q) , r)) → pp-coh {p = p'} {q} {r'} {s} {t} {u'} {v} {w'} (pp-coh! {u = u} {v} {w} {s} {t} {p} {q} {r} α ∙□-o/ δ / ! γ / ∙□-i/ ε |in-ctx (λ x → q ∙ x ∙ ! s) / (! β) |in-ctx (λ x → ! t ∙ x ∙ v) /) == α ∙□-o/ β / ! ε / ∙□-i/ γ |in-ctx (λ x → v ∙ x ∙ s) / (! δ) |in-ctx (λ x → t ∙ x ∙ q) / lemma {u = u} {v = v} {w = w} {s = s} {t = t} {p = p} {q = q} {r = r} idp idp idp idp α = pp-coh-β {u = u} {v = v} {w = w} {s = s} {t = t} {p = p} {q = q} {r = r} α lemma! : {a b b' c c' d d' e : A} {p p' : a == b} {q : b == c} {r r' : c == d} {s : e == d} {t : b' == a} {u u' : b' == c'} {v : c' == d'} {w w' : d' == e} (β : p' == p) (γ : r' == r) (δ : u' == u) (ε : w' == w) (α : (p , (q ∙ r ∙ (! s)) =□ (! t ∙ u ∙ v) , w)) → pp-coh! {u = u'} {v} {w'} {s} {t} {p'} {q} {r'} (pp-coh {p = p} {q} {r} {s} {t} {u} {v} {w} α ∙□-o/ δ / ! γ / ∙□-i/ ε |in-ctx (λ w → v ∙ w ∙ s) / (! β) |in-ctx (λ p → t ∙ p ∙ q) /) == α ∙□-o/ β / ! ε / ∙□-i/ γ |in-ctx (λ r → q ∙ r ∙ ! s) / (! δ) |in-ctx (λ u → ! t ∙ u ∙ v) / lemma! {p = p} {q = q} {r = r} {s = s} {t = t} {u = u} {v = v} {w = w} idp idp idp idp α = pp-coh!-β {p = p} {q} {r} {s} {t} {u} {v} {w} α module _ {i j} {A : Type i} {B : A → Type j} where coh1 : {a b : A} {α : a == b} {u v : B a} {w x : B b} {p : u == w [ B ↓ α ]} {q : w == x} {r : u == v} {s : v == x [ B ↓ α ]} → (r , s =□d-i p , q) → p == s ◃/ r / ! q / coh1 {α = idp} {p = idp} {idp} {idp} {s} β = ! β module _ {i j k} {A : Type i} {B : Type j} {C : Type k} (f g : A → B) (h : B → C) where ap↓-↓-='-in-β : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} (α : (u , ap g p =□ ap f p , v)) → ap↓ (ap h) {p = p} {u = u} {v = v} (↓-='-in {p = p} α) == ↓-='-in ((ap□ h α) ∙□-i/ (ap-∘ h g p) / (∘-ap h f p) /) ap↓-↓-='-in-β {p = idp} = t where t : {x y : B} {u v : x == y} (α : (u , idp =□ idp , v)) → ap (ap h) (,idp=□idp,-out α) == ,idp=□idp,-out (ap□ h α) t {u = idp} {v} = t' where t' : {x y : B} {u v : x == y} (α : (idp , u =□ idp , v)) → ap (ap h) (idp,=□idp,-out α) == idp,=□idp,-out (ap□ h α) t' {u} {v = idp} α = idp ap□-↓-='-out-β : {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} (α : u == v [ (λ x → f x == g x) ↓ p ]) → ap□ h (↓-='-out α) == ↓-='-out (ap↓ (ap h) α) ∙□-i/ ∘-ap h g p / ap-∘ h f p / ap□-↓-='-out-β {p = idp} idp = ap□-,idp=□idp,-in h idp thing : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B} {x y : A} {p : x == y} {u u' : f x == g x} {v v' : f y == g y} (α : (u , ap g p =□ ap f p , v)) (r : u' == u) (s : v == v') → ↓-='-out (↓-='-in α ◃/ r / s /) == α ∙□-o/ r / s / thing α idp idp = ↓-='-β α ap↓-∘ : ∀ {i j k l} {A : Type i} {B : A → Type j} {C : A → Type k} {D : A → Type l} (f : {a : A} → C a → D a) (g : {a : A} → B a → C a) {x y : A} {p : x == y} {u : B x} {v : B y} (q : u == v [ B ↓ p ]) → ap↓ (f ∘ g) q == ap↓ f (ap↓ g q) ap↓-∘ f g {p = idp} idp = idp ap↓-◃/ : ∀ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} (f : {a : A} → B a → C a) {x y : A} {p : x == y} {u u' : B x} {v v' : B y} (q : u == v [ B ↓ p ]) (r : u' == u) (s : v == v') → ap↓ f (q ◃/ r / s /) == ap↓ f q ◃/ ap f r / ap f s / ap↓-◃/ f {p = idp} idp idp idp = idp ap□-∙□-i/ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a b b' c : A} {p : a == b} {q q' : b == c} {r r' : a == b'} {s : b' == c} (α : (p , q =□ r , s)) (t : q' == q) (u : r == r') → ap□ f (α ∙□-i/ t / u /) == ap□ f α ∙□-i/ ap (ap f) t / ap (ap f) u / ap□-∙□-i/ f {p = idp} {s = idp} idp idp idp = idp ap-∘^3-coh : ∀ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (h : C → D) (g : B → C) (f : A → B) {a b : A} (p : a == b) → ap (ap h) (∘-ap g f p) ∙ ∘-ap h (g ∘ f) p ∙ ap-∘ (h ∘ g) f p == ∘-ap h g (ap f p) ap-∘^3-coh h g f idp = idp ap-∘^3-coh' : ∀ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (h : C → D) (g : B → C) (f : A → B) {a b : A} (p : a == b) → ∘-ap (h ∘ g) f p ∙ ap-∘ h (g ∘ f) p ∙ ap (ap h) (ap-∘ g f p) == ap-∘ h g (ap f p) ap-∘^3-coh' h g f idp = idp ap-∘-ap-coh : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (g : B → C) (f : A → B) {a b : A} {p q : a == b} (α : p == q) → ap (ap g) (! α |in-ctx (ap f)) ∙ ∘-ap g f p ∙ (α |in-ctx (ap (g ∘ f))) == ∘-ap g f q ap-∘-ap-coh g f idp = ∙-unit-r _ ap-∘-ap-coh' : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (g : B → C) (f : A → B) {a b : A} {p q : a == b} (α : p == q) → (! α |in-ctx (ap (g ∘ f))) ∙ ap-∘ g f p ∙ ap (ap g) (α |in-ctx (ap f)) == ap-∘ g f q ap-∘-ap-coh' g f idp = ∙-unit-r _ ap-∘-ap-coh'2 : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (g : B → C) (f : A → B) {a b : A} {p q : a == b} (α : p == q) → (! (α |in-ctx (ap (g ∘ f)))) ∙ ap-∘ g f p ∙ ap (ap g) (α |in-ctx (ap f)) == ap-∘ g f q ap-∘-ap-coh'2 g f {p = idp} idp = idp module _ {i i' j k l} {A : Type i} {A' : Type i'} {B : Type j} {C : Type k} {D : Type l} (f2 : C → D) (f1 : B → C) (g : A → B) (h : A' → B) where ap-∘-ap-∙∙!`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : d == c) → ! (ap-∙∙!'`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p (ap f1 q) r) ∙ ap (ap f2) (! (ap-∙∙!`∘`∘ f1 g h p q r)) ∙ ∘-ap f2 f1 (ap g p ∙ q ∙ ap h (! r)) ∙ ap-∙∙!`∘`∘ (f2 ∘ f1) g h p q r == ((∘-ap f2 f1 q) |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ! (ap (f2 ∘ f1 ∘ h) r))) ap-∘-ap-∙∙!`∘`∘-coh idp q idp = coh q where coh : {a b : B} (q : a == b) → ! (ap-∙ f2 (ap f1 q) idp) ∙ ap (ap f2) (! (ap-∙ f1 q idp)) ∙ ∘-ap f2 f1 (q ∙ idp) ∙ ap-∙ (f2 ∘ f1) q idp == ap (λ u → u ∙ idp) (∘-ap f2 f1 q) coh idp = idp ap-∘-ap-!∙∙`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) (q : g a == h c) (r : c == d) → ! (ap-!∙∙`∘`∘ (f2 ∘ f1) g h p q r) ∙ ap-∘ f2 f1 (ap g (! p) ∙ q ∙ ap h r) ∙ ap (ap f2) (ap-!∙∙`∘`∘ f1 g h p q r) ∙ ap-!'∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p (ap f1 q) r == ((ap-∘ f2 f1 q) |in-ctx (λ u → ! (ap (f2 ∘ f1 ∘ g) p) ∙ u ∙ ap (f2 ∘ f1 ∘ h) r)) ap-∘-ap-!∙∙`∘`∘-coh idp q idp = coh q where coh : {a b : B} (q : a == b) → ! (ap-∙ (f2 ∘ f1) q idp) ∙ ap-∘ f2 f1 (q ∙ idp) ∙ ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp == ap (λ u → u ∙ idp) (ap-∘ f2 f1 q) coh idp = idp ap-∘-ap-∙∙2`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : c == d) → ! (ap-∙∙`∘`∘ (f2 ∘ f1) g h p q r) ∙ ap-∘ f2 f1 (ap g p ∙ q ∙ ap h r) ∙ ap (ap f2) (ap-∙∙`∘`∘ f1 g h p q r) ∙ ap-∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p (ap f1 q) r == ((ap-∘ f2 f1 q) |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r)) ap-∘-ap-∙∙2`∘`∘-coh idp q idp = coh q where coh : {a b : B} (q : a == b) → ! (ap-∙ (f2 ∘ f1) q idp) ∙ ap-∘ f2 f1 (q ∙ idp) ∙ ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp == ap (λ u → u ∙ idp) (ap-∘ f2 f1 q) coh idp = idp ap-∘-ap-∙∙3`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) (q : g b == h c) (r : c == d) → ! (ap-∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p (ap f1 q) r) ∙ ap (ap f2) (! (ap-∙∙`∘`∘ f1 g h p q r)) ∙ ∘-ap f2 f1 (ap g p ∙ q ∙ ap h r) ∙ ap-∙∙`∘`∘ (f2 ∘ f1) g h p q r == ((∘-ap f2 f1 q) |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r)) ap-∘-ap-∙∙3`∘`∘-coh idp q idp = coh q where coh : {a b : B} (q : a == b) → ! (ap-∙ f2 (ap f1 q) idp) ∙ ap (ap f2) (! (ap-∙ f1 q idp)) ∙ ∘-ap f2 f1 (q ∙ idp) ∙ ap-∙ (f2 ∘ f1) q idp == ap (λ u → u ∙ idp) (∘-ap f2 f1 q) coh idp = idp ap-∘-ap-∙∙4`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} {q' : f1 (g b) == f1 (h c)} (α : ap f1 q == q') (r : c == d) → ap-∘ f2 f1 (ap g p ∙ q ∙ ap h r) ∙ ap (ap f2) (ap-∙∙`∘`∘ f1 g h p q r) ∙ ap (ap f2) (α |in-ctx (λ u → ap (f1 ∘ g) p ∙ u ∙ ap (f1 ∘ h) r)) ∙ ap-∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r == ap-∙∙`∘`∘ (f2 ∘ f1) g h p q r ∙ (ap-∘ f2 f1 q |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r)) ∙ (ap (ap f2) α |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r)) ap-∘-ap-∙∙4`∘`∘-coh idp {q = q} idp idp = coh q where coh : {a b : B} (q : a == b) → ap-∘ f2 f1 (q ∙ idp) ∙ ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp == ap-∙ (f2 ∘ f1) q idp ∙ ap (λ u → u ∙ idp) (ap-∘ f2 f1 q) ∙ idp coh idp = idp ap-∘-ap-∙∙5`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) {q : g a == h c} {q' : f1 (g a) == f1 (h c)} (α : ap f1 q == q') (r : c == d) → ap-∘ f2 f1 (ap g (! p) ∙ q ∙ ap h r) ∙ ap (ap f2) (ap-!∙∙`∘`∘ f1 g h p q r) ∙ ap (ap f2) (α |in-ctx (λ u → ! (ap (f1 ∘ g) p) ∙ u ∙ ap (f1 ∘ h) r)) ∙ ap-!'∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r == ap-∙∙`∘`∘ (f2 ∘ f1) g h (! p) q r ∙ (ap-∘ f2 f1 q |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) (! p) ∙ u ∙ ap (f2 ∘ f1 ∘ h) r)) ∙ (ap (ap f2) α |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) (! p) ∙ u ∙ ap (f2 ∘ f1 ∘ h) r)) ∙ (ap-! (f2 ∘ f1 ∘ g) p |in-ctx (λ u → u ∙ ap f2 q' ∙ ap (f2 ∘ f1 ∘ h) r)) ap-∘-ap-∙∙5`∘`∘-coh idp {q = q} idp idp = coh q where coh : {a b : B} (q : a == b) → ap-∘ f2 f1 (q ∙ idp) ∙ ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp == ap-∙ (f2 ∘ f1) q idp ∙ ap (λ u → u ∙ idp) (ap-∘ f2 f1 q) ∙ idp coh idp = idp ap-∘-ap-∙∙`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} {q' : f1 (g b) == f1 (h c)} (α : ap f1 q == q') (r : c == d) → ap (ap f2) (ap-∙∙`∘`∘ f1 g h p q r) ∙ ap (ap f2) (α |in-ctx (λ u → ap (f1 ∘ g) p ∙ u ∙ ap (f1 ∘ h) r)) ∙ ap-∙∙`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r == ∘-ap f2 f1 (ap g p ∙ q ∙ ap h r) ∙ ap-∙∙`∘`∘ (f2 ∘ f1) g h p q r ∙ (ap-∘ f2 f1 q |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r)) ∙ (ap (ap f2) α |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ap (f2 ∘ f1 ∘ h) r)) ap-∘-ap-∙∙`∘`∘-coh idp {q = q} idp idp = coh q where coh : {a b : B} (q : a == b) → ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp == ∘-ap f2 f1 (q ∙ idp) ∙ ap-∙ (f2 ∘ f1) q idp ∙ ap (λ u → u ∙ idp) (ap-∘ f2 f1 q) ∙ idp coh idp = idp ap-∘-ap-∙∙!'`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} {q' : f1 (g b) == f1 (h c)} (α : ap f1 q == q') (r : d == c) → ap (ap f2) (ap-∙∙!`∘`∘ f1 g h p q r) ∙ ap (ap f2) (α |in-ctx (λ u → ap (f1 ∘ g) p ∙ u ∙ ! (ap (f1 ∘ h) r))) ∙ ap-∙∙!'`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r == ∘-ap f2 f1 (ap g p ∙ q ∙ ap h (! r)) ∙ ap-∙∙!`∘`∘ (f2 ∘ f1) g h p q r ∙ (ap-∘ f2 f1 q |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ! (ap (f2 ∘ f1 ∘ h) r))) ∙ (ap (ap f2) α |in-ctx (λ u → ap (f2 ∘ f1 ∘ g) p ∙ u ∙ ! (ap (f2 ∘ f1 ∘ h) r))) ap-∘-ap-∙∙!'`∘`∘-coh idp {q = q} idp idp = coh q where coh : {a b : B} (q : a == b) → ap (ap f2) (ap-∙ f1 q idp) ∙ ap-∙ f2 (ap f1 q) idp == ∘-ap f2 f1 (q ∙ idp) ∙ ap-∙ (f2 ∘ f1) q idp ∙ ap (λ u → u ∙ idp) (ap-∘ f2 f1 q) ∙ idp coh idp = idp ap-∘-ap-∙∙!'2`∘`∘-coh : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} {q' : f1 (g b) == f1 (h c)} (α : ap f1 q == q') (r : d == c) → ap (ap f2) (ap-∙∙!`∘`∘ f1 g h p q r) ∙ ap (ap f2) (α |in-ctx (λ u → ap (f1 ∘ g) p ∙ u ∙ ! (ap (f1 ∘ h) r))) ∙ ap-∙∙!'`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r == ap (ap f2) (ap-∙∙`∘`∘ f1 g h p q (! r)) ∙ ap (ap f2) (α |in-ctx (λ u → ap (f1 ∘ g) p ∙ u ∙ ap (f1 ∘ h) (! r))) ∙ ap-∙∙!`∘`∘ f2 (f1 ∘ g) (f1 ∘ h) p q' r ap-∘-ap-∙∙!'2`∘`∘-coh idp {q = q} idp idp = idp module _ {i i' j k} {A : Type i} {A' : Type i'} {B : Type j} {C : Type k} (f : B → C) (g : A → B) (h : A' → B) where ap-!∙∙`∘`∘-coh : {a b : A} {c d : A'} (p : b == a) {q : g b == h c} {q' : f (g b) == f (h c)} (α : ap f q == q') (r : c == d) → ap-!∙∙`∘`∘ f g h p q r ∙ ap (λ u → ! (ap (f ∘ g) p) ∙ u ∙ ap (f ∘ h) r) α ∙ ! (ap-! (f ∘ g) p |in-ctx (λ u → u ∙ q' ∙ ap (f ∘ h) r)) == ap-∙∙`∘`∘ f g h (! p) q r ∙' ap (λ u → ap (f ∘ g) (! p) ∙ u ∙ ap (f ∘ h) r) α ap-!∙∙`∘`∘-coh idp {q = q} idp idp = ∙-unit-r (ap-∙ f q idp) ap-∙∙!`∘`∘-coh1 : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} {q' : f (g b) == f (h c)} (α : ap f q == q') (r : d == c) → ap-∙∙!`∘`∘ f g h p q r ∙ ap (λ u → ap (f ∘ g) p ∙ u ∙ ! (ap (f ∘ h) r)) α == ap-∙∙`∘`∘ f g h p q (! r) ∙ ap (λ u → ap (f ∘ g) p ∙ u ∙ ap (f ∘ h) (! r)) α ∙ (ap-! (f ∘ h) r |in-ctx (λ u → ap (f ∘ g) p ∙ q' ∙ u)) ap-∙∙!`∘`∘-coh1 idp {q = q} idp idp = idp ap-∙∙!`∘`∘-coh2 : {a b : A} {c d : A'} (p : a == b) {q : g b == h c} (r : d == c) → (ap-! (f ∘ h) r |in-ctx (λ u → ap (f ∘ g) p ∙ ap f q ∙ u)) ∙ ! (ap-∙∙!`∘`∘ f g h p q r) == ! (ap-∙∙`∘`∘ f g h p q (! r)) ap-∙∙!`∘`∘-coh2 idp {q} idp = idp ap-∘-coh : ∀ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (f : C → D) (g : B → C) (h : A → B) {a b : A} (p : a == b) {p' : h a == h b} (α : ap h p == p') → ap-∘ f (g ∘ h) p ∙ ap (ap f) (ap-∘ g h p) ∙ ap (ap f) (α |in-ctx (ap g)) ∙ ∘-ap f g p' == ap-∘ (f ∘ g) h p ∙ ap (ap (f ∘ g)) α ap-∘-coh f g h idp idp = idp ap-∘-coh2 : ∀ {i j k l} {A : Type i} {B : Type j} {C : Type k} {D : Type l} (f : C → D) (g : B → C) (h : A → B) {a b : A} (p : a == b) {p' : h a == h b} (α : ap h p == p') → ap-∘ f (g ∘ h) p ∙ ap (ap f) (ap-∘ g h p) ∙ ap (ap f) (α |in-ctx (ap g)) == ap-∘ (f ∘ g) h p ∙ ap (ap (f ∘ g)) α ∙ ap-∘ f g p' ap-∘-coh2 f g h idp idp = idp ∙-|in-ctx : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {a b c : A} (p : a == b) (q : b == c) → (p |in-ctx f) ∙ (q |in-ctx f) == ((p ∙ q) |in-ctx f) ∙-|in-ctx f idp idp = idp ∙□-i/-rewrite : ∀ {i} {A : Type i} {a b b' c : A} {p : a == b} {q q' : b == c} {r r' : a == b'} {s : b' == c} (α : (p , q =□ r , s)) {β β' : q' == q} (eqβ : β == β') {γ γ' : r == r'} (eqγ : γ == γ') → (α ∙□-i/ β / γ / == α ∙□-i/ β' / γ' /) ∙□-i/-rewrite α idp idp = idp
{ "alphanum_fraction": 0.3304336981, "avg_line_length": 47.1661764706, "ext": "agda", "hexsha": "5666204cf7ea21f4701010df3749b888e38cfaa0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "homotopy/3x3/Common.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "homotopy/3x3/Common.agda", "max_line_length": 181, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "homotopy/3x3/Common.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 18373, "size": 32073 }
------------------------------------------------------------------------ -- Monotone functions ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} module Partiality-algebra.Monotone where open import Equality.Propositional.Cubical open import Prelude hiding (⊥) open import Bijection equality-with-J using (_↔_) import Equivalence equality-with-J as Eq open import Function-universe equality-with-J hiding (id; _∘_) open import H-level.Closure equality-with-J open import Partiality-algebra as PA hiding (id; _∘_) import Partiality-algebra.Properties as PAP -- Definition of monotone functions. record [_⟶_]⊑ {a₁ p₁ q₁} {A₁ : Type a₁} (P₁ : Partiality-algebra p₁ q₁ A₁) {a₂ p₂ q₂} {A₂ : Type a₂} (P₂ : Partiality-algebra p₂ q₂ A₂) : Type (p₁ ⊔ p₂ ⊔ q₁ ⊔ q₂) where private module P₁ = Partiality-algebra P₁ module P₂ = Partiality-algebra P₂ field function : P₁.T → P₂.T monotone : ∀ {x y} → x P₁.⊑ y → function x P₂.⊑ function y open [_⟶_]⊑ -- Identity. id⊑ : ∀ {a p q} {A : Type a} {P : Partiality-algebra p q A} → [ P ⟶ P ]⊑ function id⊑ = id monotone id⊑ = id -- Composition. infixr 40 _∘⊑_ _∘⊑_ : ∀ {a₁ p₁ q₁} {A₁ : Type a₁} {P₁ : Partiality-algebra p₁ q₁ A₁} {a₂ p₂ q₂} {A₂ : Type a₂} {P₂ : Partiality-algebra p₂ q₂ A₂} {a₃ p₃ q₃} {A₃ : Type a₃} {P₃ : Partiality-algebra p₃ q₃ A₃} → [ P₂ ⟶ P₃ ]⊑ → [ P₁ ⟶ P₂ ]⊑ → [ P₁ ⟶ P₃ ]⊑ function (f ∘⊑ g) = function f ∘ function g monotone (f ∘⊑ g) = monotone f ∘ monotone g -- Equality characterisation lemma for monotone functions. equality-characterisation-monotone : ∀ {a₁ p₁ q₁} {A₁ : Type a₁} {P₁ : Partiality-algebra p₁ q₁ A₁} {a₂ p₂ q₂} {A₂ : Type a₂} {P₂ : Partiality-algebra p₂ q₂ A₂} {f g : [ P₁ ⟶ P₂ ]⊑} → (∀ x → function f x ≡ function g x) ↔ f ≡ g equality-characterisation-monotone {P₁ = P₁} {P₂ = P₂} {f} {g} = (∀ x → function f x ≡ function g x) ↔⟨ Eq.extensionality-isomorphism ext ⟩ function f ≡ function g ↝⟨ ignore-propositional-component (implicit-Π-closure ext 1 λ _ → implicit-Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → P₂.⊑-propositional) ⟩ _↔_.to rearrange f ≡ _↔_.to rearrange g ↔⟨ Eq.≃-≡ (Eq.↔⇒≃ rearrange) ⟩□ f ≡ g □ where module P₁ = Partiality-algebra P₁ module P₂ = Partiality-algebra P₂ rearrange : [ P₁ ⟶ P₂ ]⊑ ↔ ∃ λ (h : P₁.T → P₂.T) → ∀ {x y} → x P₁.⊑ y → h x P₂.⊑ h y rearrange = record { surjection = record { logical-equivalence = record { to = λ f → function f , monotone f ; from = uncurry λ f m → record { function = f; monotone = m } } ; right-inverse-of = λ _ → refl } ; left-inverse-of = λ _ → refl } where open Partiality-algebra -- Composition is associative. ∘⊑-assoc : ∀ {a₁ p₁ q₁} {A₁ : Type a₁} {P₁ : Partiality-algebra p₁ q₁ A₁} {a₂ p₂ q₂} {A₂ : Type a₂} {P₂ : Partiality-algebra p₂ q₂ A₂} {a₃ p₃ q₃} {A₃ : Type a₃} {P₃ : Partiality-algebra p₃ q₃ A₃} {a₄ p₄ q₄} {A₄ : Type a₄} {P₄ : Partiality-algebra p₄ q₄ A₄} (f : [ P₃ ⟶ P₄ ]⊑) (g : [ P₂ ⟶ P₃ ]⊑) {h : [ P₁ ⟶ P₂ ]⊑} → f ∘⊑ (g ∘⊑ h) ≡ (f ∘⊑ g) ∘⊑ h ∘⊑-assoc _ _ = _↔_.to equality-characterisation-monotone λ _ → refl module _ {a₁ p₁ q₁} {A₁ : Type a₁} {P₁ : Partiality-algebra p₁ q₁ A₁} {a₂ p₂ q₂} {A₂ : Type a₂} {P₂ : Partiality-algebra p₂ q₂ A₂} where private module P₁ = Partiality-algebra P₁ module P₂ = Partiality-algebra P₂ module PAP₁ = PAP P₁ module PAP₂ = PAP P₂ -- If a monotone function is applied to an increasing sequence, -- then the result is another increasing sequence. [_$_]-inc : [ P₁ ⟶ P₂ ]⊑ → P₁.Increasing-sequence → P₂.Increasing-sequence [ f $ s ]-inc = (λ n → function f (s P₁.[ n ])) , (λ n → monotone f (P₁.increasing s n)) -- A lemma relating monotone functions and least upper bounds. ⨆$⊑$⨆ : (f : [ P₁ ⟶ P₂ ]⊑) → ∀ s → P₂.⨆ [ f $ s ]-inc P₂.⊑ function f (P₁.⨆ s) ⨆$⊑$⨆ f s = P₂.least-upper-bound _ _ λ n → [ f $ s ]-inc P₂.[ n ] PAP₂.⊑⟨ monotone f ( s P₁.[ n ] PAP₁.⊑⟨ P₁.upper-bound _ _ ⟩■ P₁.⨆ s ■) ⟩■ function f (P₁.⨆ s) ■
{ "alphanum_fraction": 0.5062381053, "avg_line_length": 34.5182481752, "ext": "agda", "hexsha": "d0e2b4a0949415b4f3d399c6f29bda63382029a8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Partiality-algebra/Monotone.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Partiality-algebra/Monotone.agda", "max_line_length": 110, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Partiality-algebra/Monotone.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 1746, "size": 4729 }
-- Exercises for session 3 -- -- If unsure which exercises to do start with those marked with * -- {-# OPTIONS --cubical --allow-unsolved-metas #-} module ExerciseSession3 where open import Part1 open import Part2 open import Part3 open import Part4 open import ExerciseSession1 hiding (B) open import Cubical.Foundations.Isomorphism open import Cubical.Data.Nat open import Cubical.Data.Int hiding (neg) -- Exercise* 1: prove associativity of _++_ for FMSet. -- (hint: mimic the proof of unitr-++) -- Exercise 2: define the integers as a HIT with a pos and neg -- constructor each taking a natural number as well as a path -- constructor equating pos 0 and neg 0. -- Exercise 3 (a little longer, but not very hard): prove that the -- above definition of the integers is equal to the ones in -- Cubical.Data.Int. Deduce that they form a set. -- Exercise* 4: we can define the notion of a surjection as: isSurjection : (A → B) → Type _ isSurjection {A = A} {B = B} f = (b : B) → ∃ A (λ a → f a ≡ b) -- The exercise is now to: -- -- a) prove that being a surjection is a proposition -- -- b) prove that the inclusion ∣_∣ : A → ∥ A ∥ is surjective -- (hint: use rec for ∥_∥) -- Exercise* 5: define intLoop : Int → ΩS¹ intLoop = {!!} -- which given +n return loop^n and given -n returns loop^-n. Then -- prove that: windingIntLoop : (n : Int) → winding (intLoop n) ≡ n windingIntLoop = {!!} -- (The other direction is much more difficult and relies on the -- encode-decode method. See Egbert's course on Friday!) -- Exercise 6 (harder): the suspension of a type can be defined as data Susp (A : Type ℓ) : Type ℓ where north : Susp A south : Susp A merid : (a : A) → north ≡ south -- Prove that the circle is equal to the suspension of Bool S¹≡SuspBool : S¹ ≡ Susp Bool S¹≡SuspBool = {!!} -- Hint: define maps back and forth and prove that they cancel.
{ "alphanum_fraction": 0.6917333333, "avg_line_length": 27.5735294118, "ext": "agda", "hexsha": "5816c41ad06765f1a267b366803a612b09c7eb14", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_forks_event_min_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "EgbertRijke/EPIT-2020", "max_forks_repo_path": "04-cubical-type-theory/material/ExerciseSession3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "EgbertRijke/EPIT-2020", "max_issues_repo_path": "04-cubical-type-theory/material/ExerciseSession3.agda", "max_line_length": 66, "max_stars_count": 1, "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_path": "04-cubical-type-theory/material/ExerciseSession3.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-03T16:28:06.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-03T16:28:06.000Z", "num_tokens": 554, "size": 1875 }
------------------------------------------------------------------------------ -- In the Agda standard library zero divides zero ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Nat.Divisibility.ZeroDividesZero where open import Data.Nat.Divisibility open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------------ 0∣0 : 0 ∣ 0 0∣0 = divides 0 refl
{ "alphanum_fraction": 0.4102964119, "avg_line_length": 33.7368421053, "ext": "agda", "hexsha": "e2b7b88711b32863481a415492eeaf225c938bba", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Data/Nat/Divisibility/ZeroDividesZero.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Data/Nat/Divisibility/ZeroDividesZero.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/Divisibility/ZeroDividesZero.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 107, "size": 641 }
module Inductive.Examples.BinTree where open import Inductive open import Tuple open import Data.Fin open import Data.Product hiding (map) open import Data.List hiding (map) open import Data.Vec hiding (map) BinTree : Set → Set BinTree A = Inductive (([] , []) ∷ (((A ∷ []) , ([] ∷ ([] ∷ []))) ∷ [])) leaf : {A : Set} → BinTree A leaf = construct zero [] [] node : {A : Set} → A → BinTree A → BinTree A → BinTree A node a lt rt = construct (suc zero) (a ∷ []) ((λ _ → lt) ∷ ((λ _ → rt) ∷ [])) map : {A B : Set} → (A → B) → BinTree A → BinTree B map f = rec (leaf ∷ ((λ a lt rlt rt rrt → node (f a) rlt rrt) ∷ [])) import Inductive.Examples.List as List dfs : {A : Set} → BinTree A → List.List A dfs = rec ( List.nil ∷ (λ a lt rlt rt rrt → List.cons a (rlt List.++ rrt)) ∷ [])
{ "alphanum_fraction": 0.5746268657, "avg_line_length": 27.724137931, "ext": "agda", "hexsha": "f9359aa4f2a1ec4827b966aa3f042e67c0c7f9ee", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mr-ohman/general-induction", "max_forks_repo_path": "Inductive/Examples/BinTree.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mr-ohman/general-induction", "max_issues_repo_path": "Inductive/Examples/BinTree.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mr-ohman/general-induction", "max_stars_repo_path": "Inductive/Examples/BinTree.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 277, "size": 804 }
{- This second-order equational theory was created from the following second-order syntax description: syntax Group | G type * : 0-ary term unit : * | ε add : * * -> * | _⊕_ l20 neg : * -> * | ⊖_ r40 theory (εU⊕ᴸ) a |> add (unit, a) = a (εU⊕ᴿ) a |> add (a, unit) = a (⊕A) a b c |> add (add(a, b), c) = add (a, add(b, c)) (⊖N⊕ᴸ) a |> add (neg (a), a) = unit (⊖N⊕ᴿ) a |> add (a, neg (a)) = unit -} module Group.Equality where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Families.Build open import SOAS.ContextMaps.Inductive open import Group.Signature open import Group.Syntax open import SOAS.Metatheory.SecondOrder.Metasubstitution G:Syn open import SOAS.Metatheory.SecondOrder.Equality G:Syn private variable α β γ τ : *T Γ Δ Π : Ctx infix 1 _▹_⊢_≋ₐ_ -- Axioms of equality data _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ G) α Γ → (𝔐 ▷ G) α Γ → Set where εU⊕ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ ε ⊕ 𝔞 ≋ₐ 𝔞 εU⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ ε ≋ₐ 𝔞 ⊕A : ⁅ * ⁆ ⁅ * ⁆ ⁅ * ⁆̣ ▹ ∅ ⊢ (𝔞 ⊕ 𝔟) ⊕ 𝔠 ≋ₐ 𝔞 ⊕ (𝔟 ⊕ 𝔠) ⊖N⊕ᴸ : ⁅ * ⁆̣ ▹ ∅ ⊢ (⊖ 𝔞) ⊕ 𝔞 ≋ₐ ε ⊖N⊕ᴿ : ⁅ * ⁆̣ ▹ ∅ ⊢ 𝔞 ⊕ (⊖ 𝔞) ≋ₐ ε open EqLogic _▹_⊢_≋ₐ_ open ≋-Reasoning
{ "alphanum_fraction": 0.5338582677, "avg_line_length": 23.5185185185, "ext": "agda", "hexsha": "57086400ce456eb25f6753b1323c0ed712a458bd", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/Group/Equality.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/Group/Equality.agda", "max_line_length": 99, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/Group/Equality.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 653, "size": 1270 }
module Issue561.Core where postulate Char : Set {-# BUILTIN CHAR Char #-} open import Agda.Builtin.IO public postulate return : ∀ {a} {A : Set a} → A → IO A {-# COMPILE GHC return = \_ _ -> return #-} {-# COMPILE UHC return = \_ _ x -> UHC.Agda.Builtins.primReturn x #-} {-# COMPILE JS return = function(u0) { return function(u1) { return function(x) { return function(cb) { cb(x); }; }; }; } #-} {-# FOREIGN OCaml let ioReturn _ _ x world = Lwt.return x let ioBind _ _ _ _ x f world = Lwt.bind (x world) (fun x -> f x world) #-} {-# COMPILE OCaml return = ioReturn #-}
{ "alphanum_fraction": 0.6162988115, "avg_line_length": 25.6086956522, "ext": "agda", "hexsha": "0f1c155a45c6954bdaa9766a270ff6b69fdf655e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "xekoukou/agda-ocaml", "max_forks_repo_path": "test/Compiler/simple/Issue561/Core.agda", "max_issues_count": 16, "max_issues_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720", "max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "xekoukou/agda-ocaml", "max_issues_repo_path": "test/Compiler/simple/Issue561/Core.agda", "max_line_length": 105, "max_stars_count": 7, "max_stars_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "xekoukou/agda-ocaml", "max_stars_repo_path": "test/Compiler/simple/Issue561/Core.agda", "max_stars_repo_stars_event_max_datetime": "2018-11-06T16:38:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-05T22:13:36.000Z", "num_tokens": 183, "size": 589 }
module Logic.Base where infix 60 ¬_ infix 30 _/\_ infix 20 _\/_ data True : Set where tt : True data False : Set where elim-False : {A : Set} -> False -> A elim-False () data _/\_ (P Q : Set) : Set where /\-I : P -> Q -> P /\ Q data _\/_ (P Q : Set) : Set where \/-IL : P -> P \/ Q \/-IR : Q -> P \/ Q elimD-\/ : {P Q : Set}(C : P \/ Q -> Set) -> ((p : P) -> C (\/-IL p)) -> ((q : Q) -> C (\/-IR q)) -> (pq : P \/ Q) -> C pq elimD-\/ C left right (\/-IL p) = left p elimD-\/ C left right (\/-IR q) = right q elim-\/ : {P Q R : Set} -> (P -> R) -> (Q -> R) -> P \/ Q -> R elim-\/ = elimD-\/ (\_ -> _) ¬_ : Set -> Set ¬ P = P -> False data ∃ {A : Set}(P : A -> Set) : Set where ∃-I : (w : A) -> P w -> ∃ P ∏ : {A : Set}(P : A -> Set) -> Set ∏ {A} P = (x : A) -> P x
{ "alphanum_fraction": 0.4192740926, "avg_line_length": 19.0238095238, "ext": "agda", "hexsha": "a99b8574e4136d624833deeba61dfb610c547e43", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Base.agda", "max_line_length": 62, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Base.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 347, "size": 799 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Classes where open import Cubical.Core.Everything ------------------------------------------------------------------------ -- Conversion typeclasses -- | A typeclass to coerce values of A to some other type. The coercion used is -- | only dependent on the input type, so the output type does not need to be inferable. -- | -- | Coersion should mainly be used for any case where there is only one -- | unambiguous possible conversion that can happen to some object, such as -- | the coersions of algebras to their carrier types. record Coerce {a} (A : Type a) : Typeω where field b : Level Target : Type b coerce : A → Target open Coerce {{...}} using (coerce) -- | An operator synonym for the typeclass method `coerce`. ⟨_⟩ = coerce instance -- Used for any case where sigma types are used to encode types with structure ΣCoerce : ∀ {ℓ ℓ′} {A : Type ℓ} {P : A → Type ℓ′} → Coerce (Σ A P) ΣCoerce = record { coerce = fst } -- | A typeclass used to cast values of A to values of B. The cast performed is -- | based on both the input and output types, so both need to be inferable. record Cast {a b} (A : Type a) (B : Type b) : Type (ℓ-max a b) where field cast : A → B open Cast {{...}} -- | An operator synonym for the typeclass method `coerce`. [_] = cast ------------------------------------------------------------------------ -- Homomorphism typeclasses -- | A typeclass for function/equivalence types that respect -- | some structure. The input types are different to allow for -- | universe polymorphism. record HomOperators {a b} (A : Type a) (B : Type b) ℓ : Type (ℓ-max (ℓ-max a b) (ℓ-suc ℓ)) where field _⟶ᴴ_ : A → B → Type ℓ _≃ᴴ_ : A → B → Type ℓ open HomOperators {{...}} public
{ "alphanum_fraction": 0.6113249038, "avg_line_length": 30.3166666667, "ext": "agda", "hexsha": "eb44245bddb26e165c910cfc669f5c97188b19da", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Classes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Classes.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Classes.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 504, "size": 1819 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.LawvereTheories where -- Category of Lawvere Theories open import Level open import Categories.Category open import Categories.Functor.Cartesian.Properties open import Categories.NaturalTransformation.NaturalIsomorphism open import Categories.Theory.Lawvere LawvereTheories : (o ℓ e : Level) → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e) LawvereTheories o ℓ e = record { Obj = FiniteProduct o ℓ e ; _⇒_ = LT-Hom ; _≈_ = λ H₁ H₂ → F H₁ ≃ F H₂ ; id = LT-id ; _∘_ = LT-∘ ; assoc = λ { {f = f} {g} {h} → associator (F f) (F g) (F h)} ; sym-assoc = λ { {f = f} {g} {h} → sym-associator (F f) (F g) (F h)} ; identityˡ = unitorˡ ; identityʳ = unitorʳ ; identity² = unitor² ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≈ = _ⓘₕ_ } where open LT-Hom
{ "alphanum_fraction": 0.6342857143, "avg_line_length": 30.1724137931, "ext": "agda", "hexsha": "f00c7609cd98e65bcd7c01f133f2bd8b7db014b7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bond15/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/LawvereTheories.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bond15/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/LawvereTheories.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "6cbfdf3f1be15ef513435e3b85faae92cb1ac36f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bond15/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/LawvereTheories.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 332, "size": 875 }
{-# OPTIONS --cubical --safe #-} module Data.Bits.Order where open import Data.Bits open import Data.Bool open import Level infix 4 _≤ᴮ_ _<ᴮ_ _≤ᴮ_ _<ᴮ_ : Bits → Bits → Bool [] ≤ᴮ ys = true 0∷ xs ≤ᴮ [] = false 0∷ xs ≤ᴮ 0∷ ys = xs ≤ᴮ ys 0∷ xs ≤ᴮ 1∷ ys = true 1∷ xs ≤ᴮ [] = false 1∷ xs ≤ᴮ 0∷ ys = false 1∷ xs ≤ᴮ 1∷ ys = xs ≤ᴮ ys xs <ᴮ [] = false [] <ᴮ 0∷ ys = true 0∷ xs <ᴮ 0∷ ys = xs <ᴮ ys 1∷ xs <ᴮ 0∷ ys = false [] <ᴮ 1∷ ys = true 0∷ xs <ᴮ 1∷ ys = true 1∷ xs <ᴮ 1∷ ys = xs <ᴮ ys infix 4 _≤_ _<_ _≤_ _<_ : Bits → Bits → Type xs ≤ ys = T (xs ≤ᴮ ys) xs < ys = T (xs <ᴮ ys)
{ "alphanum_fraction": 0.5217391304, "avg_line_length": 19.2903225806, "ext": "agda", "hexsha": "f45678892512e334a9f5e8f5aedbd6492852fc82", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Bits/Order.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Bits/Order.agda", "max_line_length": 32, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Bits/Order.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 342, "size": 598 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Empty.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Data.Empty.Base isProp⊥ : isProp ⊥ isProp⊥ () isContr⊥→A : ∀ {ℓ} {A : Type ℓ} → isContr (⊥ → A) fst isContr⊥→A () snd isContr⊥→A f i () uninhabEquiv : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → (A → ⊥) → (B → ⊥) → A ≃ B uninhabEquiv ¬a ¬b = isoToEquiv isom where open Iso isom : Iso _ _ isom .fun a = rec (¬a a) isom .inv b = rec (¬b b) isom .rightInv b = rec (¬b b) isom .leftInv a = rec (¬a a)
{ "alphanum_fraction": 0.6306027821, "avg_line_length": 23.1071428571, "ext": "agda", "hexsha": "1f64d9f831e0f5be4ee73305a327dd4f6afd5876", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Empty/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/Empty/Properties.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Empty/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 260, "size": 647 }
{-# OPTIONS --without-K #-} open import Base open import Homotopy.PullbackDef {- In this file we prove that if two diagrams are equivalent (there are equivalences between the types and the squares are commutative), then the natural map between the pullbacks is also an equivalence -} module Homotopy.PullbackInvariantEquiv {i} (d d' : pullback-diag i) where private pullback-to-pullback : ∀ {i} {A A' : Set i} (p : A ≡ A') {B B' : Set i} (q : B ≡ B') {C C' : Set i} (r : C ≡ C') {f : A → C} {f' : A' → C'} (s : (a : A) → f' ((transport _ p) a) ≡ transport _ r (f a)) {g : B → C} {g' : B' → C'} (t : (b : B) → transport _ r (g b) ≡ g' ((transport _ q) b)) → pullback (diag A , B , C , f , g) → pullback (diag A' , B' , C' , f' , g') pullback-to-pullback p q r s t (a , b , e) = (transport _ p a , transport _ q b , (s a ∘ (ap (transport _ r) e ∘ t b))) transport-pullback : ∀ {i} {A A' : Set i} (p : A ≡ A') {B B' : Set i} (q : B ≡ B') {C C' : Set i} (r : C ≡ C') {f : A → C} {f' : A' → C'} (s : f' ◯ (transport _ p) ≡ transport _ r ◯ f) {g : B → C} {g' : B' → C'} (t : transport _ r ◯ g ≡ g' ◯ (transport _ q)) → transport pullback (pullback-diag-raw-eq p q r {f' = f'} s {g' = g'} t) ≡ pullback-to-pullback p q r (happly s) (happly t) transport-pullback refl refl refl refl refl = funext (λ r → ap (λ u → _ , _ , u) (! (ap-id _) ∘ ! (refl-right-unit _))) transport-pullback-funext : ∀ {i} {A A' : Set i} (p : A ≡ A') {B B' : Set i} (q : B ≡ B') {C C' : Set i} (r : C ≡ C') {f : A → C} {f' : A' → C'} (s : (a : A) → f' ((transport _ p) a) ≡ transport _ r (f a)) {g : B → C} {g' : B' → C'} (t : (b : B) → transport _ r (g b) ≡ g' ((transport _ q) b)) → transport pullback (pullback-diag-raw-eq p q r {f' = f'} (funext s) {g' = g'} (funext t)) ≡ pullback-to-pullback p q r s t transport-pullback-funext p q r s t = transport-pullback p q r (funext s) (funext t) ∘ (ap (λ u → pullback-to-pullback p q r u (happly (funext t))) (happly-funext s) ∘ ap (λ u → pullback-to-pullback p q r s u) (happly-funext t)) path-to-eq-ap : ∀ {i j} {A : Set i} (P : A → Set j) {x y : A} (p : x ≡ y) → π₁ (path-to-eq (ap P p)) ≡ transport P p path-to-eq-ap P refl = refl open pullback-diag d open pullback-diag d' renaming (A to A'; B to B'; C to C'; f to f'; g to g') module PullbackInvariantEquiv (eqA : A ≃ A') (eqB : B ≃ B') (eqC : C ≃ C') (p : (a : A) → f' (eqA ☆ a) ≡ eqC ☆ (f a)) (q : (b : B) → eqC ☆ (g b) ≡ g' (eqB ☆ b)) where private d≡d' : d ≡ d' d≡d' = pullback-diag-eq eqA eqB eqC p q pullback-equiv-pullback : pullback d ≃ pullback d' pullback-equiv-pullback = path-to-eq (ap pullback d≡d') h : (a : A) → f' ((transport (λ v → v) (eq-to-path eqA) a)) ≡ transport (λ v → v) (eq-to-path eqC) (f a) h a = ap f' (trans-id-eq-to-path eqA a) ∘ (p a ∘ (! (trans-id-eq-to-path eqC (f a)))) h' : (b : B) → transport (λ v → v) (eq-to-path eqC) (g b) ≡ g' ((transport (λ v → v) (eq-to-path eqB) b)) h' b = trans-id-eq-to-path eqC (g b) ∘ (q b ∘ ap g' (! (trans-id-eq-to-path eqB b))) pullback-to-equiv-pullback : pullback d → pullback d' pullback-to-equiv-pullback (a , b , e) = ((eqA ☆ a) , (eqB ☆ b) , (p a ∘ (ap (π₁ eqC) e ∘ q b))) private pb-to-pb-equal-pb-to-equiv-pb : (x : pullback d) → pullback-to-pullback (eq-to-path eqA) (eq-to-path eqB) (eq-to-path eqC) h h' x ≡ pullback-to-equiv-pullback x pb-to-pb-equal-pb-to-equiv-pb (a , b , h) = pullback-eq d' (trans-id-eq-to-path eqA a) (trans-id-eq-to-path eqB b) (concat-assoc (ap f' (trans-id (eq-to-path eqA) a ∘ _) ∘ _) _ _ ∘ (concat-assoc (ap f' (trans-id (eq-to-path eqA) a ∘ _)) _ _ ∘ whisker-left (ap f' (trans-id (eq-to-path eqA) a ∘ _)) (concat-assoc (p a) _ _ ∘ whisker-left (p a) (whisker-left (! (trans-id (eq-to-path eqC) (f a) ∘ _)) (concat-assoc (ap (transport (λ v → v) (eq-to-path eqC)) h) _ _ ∘ whisker-left (ap (transport (λ v → v) (eq-to-path eqC)) h) (concat-assoc (trans-id (eq-to-path eqC) (g b) ∘ _) _ _ ∘ whisker-left (trans-id (eq-to-path eqC) (g b) ∘ _) (concat-assoc (q b) _ _ ∘ (whisker-left (q b) (concat-ap g' (! (trans-id (eq-to-path eqB) b ∘ _)) _ ∘ ap (ap g') (opposite-left-inverse (trans-id (eq-to-path eqB) b ∘ _))) ∘ refl-right-unit (q b))))) ∘ move!-right-on-left (trans-id (eq-to-path eqC) (f a) ∘ _) _ _ (! (concat-assoc (ap (transport (λ v → v) (eq-to-path eqC)) h) (trans-id (eq-to-path eqC) (g b) ∘ _) _) ∘ ((whisker-right (q b) (homotopy-naturality (transport (λ v → v) (eq-to-path eqC)) (π₁ eqC) (λ t → trans-id (eq-to-path eqC) t ∘ ap (λ u → π₁ u t) (eq-to-path-right-inverse eqC)) h)) ∘ concat-assoc (trans-id (eq-to-path eqC) (f a) ∘ _) (ap (π₁ eqC) h) (q b))))))) pb-equiv-pb-equal-pb-to-equiv-pb : π₁ pullback-equiv-pullback ≡ pullback-to-equiv-pullback pb-equiv-pb-equal-pb-to-equiv-pb = path-to-eq-ap pullback d≡d' ∘ (transport-pullback-funext (eq-to-path eqA) (eq-to-path eqB) (eq-to-path eqC) h h' ∘ funext pb-to-pb-equal-pb-to-equiv-pb) abstract pullback-invariant-is-equiv : is-equiv pullback-to-equiv-pullback pullback-invariant-is-equiv = transport is-equiv pb-equiv-pb-equal-pb-to-equiv-pb (π₂ pullback-equiv-pullback) pullback-invariant-equiv : pullback d ≃ pullback d' pullback-invariant-equiv = (pullback-to-equiv-pullback , pullback-invariant-is-equiv) open PullbackInvariantEquiv public
{ "alphanum_fraction": 0.5113466954, "avg_line_length": 44.3897058824, "ext": "agda", "hexsha": "1cc15e4eacce802ad878fea14b5f2fe657c31311", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Homotopy/PullbackInvariantEquiv.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Homotopy/PullbackInvariantEquiv.agda", "max_line_length": 80, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/Homotopy/PullbackInvariantEquiv.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 2230, "size": 6037 }
module Formalization.FunctionML where import Lvl open import Numeral.Finite open import Numeral.Natural open import Type{Lvl.𝟎} data Value : ℕ → Type data Expression : ℕ → Type data Value where const : ∀{n} → ℕ → Value n var : ∀{n} → 𝕟(n) → Value n y-combinator : ∀{n} → Value n func : ∀{n} → Value(𝐒 n) → Value n data Expression where val : ∀{n} → Value n → Expression n apply : ∀{n} → Expression n → Expression n
{ "alphanum_fraction": 0.6498855835, "avg_line_length": 20.8095238095, "ext": "agda", "hexsha": "b0540ced55447fbe5c5263c1506f41ecb638a573", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Formalization/FunctionalML.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Formalization/FunctionalML.agda", "max_line_length": 44, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Formalization/FunctionalML.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 150, "size": 437 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Containers core ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Container.Core where open import Level open import Data.Product as Prod using (Σ-syntax) open import Function open import Function.Equality using (_⟨$⟩_) open import Function.Inverse using (_↔_; module Inverse) open import Relation.Unary using (Pred; _⊆_) -- Definition of Containers infix 5 _▷_ record Container (s p : Level) : Set (suc (s ⊔ p)) where constructor _▷_ field Shape : Set s Position : Shape → Set p open Container public -- The semantics ("extension") of a container. ⟦_⟧ : ∀ {s p ℓ} → Container s p → Set ℓ → Set (s ⊔ p ⊔ ℓ) ⟦ S ▷ P ⟧ X = Σ[ s ∈ S ] (P s → X) -- The extension is a functor map : ∀ {s p x y} {C : Container s p} {X : Set x} {Y : Set y} → (X → Y) → ⟦ C ⟧ X → ⟦ C ⟧ Y map f = Prod.map₂ (f ∘_) -- Representation of container morphisms. record _⇒_ {s₁ s₂ p₁ p₂} (C₁ : Container s₁ p₁) (C₂ : Container s₂ p₂) : Set (s₁ ⊔ s₂ ⊔ p₁ ⊔ p₂) where constructor _▷_ field shape : Shape C₁ → Shape C₂ position : ∀ {s} → Position C₂ (shape s) → Position C₁ s ⟪_⟫ : ∀ {x} {X : Set x} → ⟦ C₁ ⟧ X → ⟦ C₂ ⟧ X ⟪_⟫ = Prod.map shape (_∘′ position) open _⇒_ public -- Linear container morphisms record _⊸_ {s₁ s₂ p₁ p₂} (C₁ : Container s₁ p₁) (C₂ : Container s₂ p₂) : Set (s₁ ⊔ s₂ ⊔ p₁ ⊔ p₂) where field shape⊸ : Shape C₁ → Shape C₂ position⊸ : ∀ {s} → Position C₂ (shape⊸ s) ↔ Position C₁ s morphism : C₁ ⇒ C₂ morphism = record { shape = shape⊸ ; position = _⟨$⟩_ (Inverse.to position⊸) } ⟪_⟫⊸ : ∀ {x} {X : Set x} → ⟦ C₁ ⟧ X → ⟦ C₂ ⟧ X ⟪_⟫⊸ = ⟪ morphism ⟫ open _⊸_ public using (shape⊸; position⊸; ⟪_⟫⊸)
{ "alphanum_fraction": 0.5423819742, "avg_line_length": 26.2535211268, "ext": "agda", "hexsha": "933dc01384bc0205a00ffc06c068b967241654ad", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Core.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 689, "size": 1864 }
------------------------------------------------------------------------ -- The Agda standard library -- -- A categorical view of N-ary products ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Product.N-ary.Categorical where open import Agda.Builtin.Nat open import Data.Product hiding (map) open import Data.Product.N-ary open import Function open import Category.Functor open import Category.Applicative open import Category.Monad ------------------------------------------------------------------------ -- Functor and applicative functor : ∀ {ℓ} n → RawFunctor {ℓ} (_^ n) functor n = record { _<$>_ = λ f → map f n } applicative : ∀ {ℓ} n → RawApplicative {ℓ} (_^ n) applicative n = record { pure = replicate n ; _⊛_ = ap n } ------------------------------------------------------------------------ -- Get access to other monadic functions module _ {f F} (App : RawApplicative {f} F) where open RawApplicative App sequenceA : ∀ {n A} → F A ^ n → F (A ^ n) sequenceA {0} _ = pure _ sequenceA {1} fa = fa sequenceA {2+ n} (fa , fas) = _,_ <$> fa ⊛ sequenceA fas mapA : ∀ {n a} {A : Set a} {B} → (A → F B) → A ^ n → F (B ^ n) mapA f = sequenceA ∘ map f _ forA : ∀ {n a} {A : Set a} {B} → A ^ n → (A → F B) → F (B ^ n) forA = flip mapA module _ {m M} (Mon : RawMonad {m} M) where private App = RawMonad.rawIApplicative Mon sequenceM : ∀ {n A} → M A ^ n → M (A ^ n) sequenceM = sequenceA App mapM : ∀ {n a} {A : Set a} {B} → (A → M B) → A ^ n → M (B ^ n) mapM = mapA App forM : ∀ {n a} {A : Set a} {B} → A ^ n → (A → M B) → M (B ^ n) forM = forA App
{ "alphanum_fraction": 0.4788235294, "avg_line_length": 27.4193548387, "ext": "agda", "hexsha": "ba9448972d099fa706d04e02e5efb0b323203107", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/N-ary/Categorical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/N-ary/Categorical.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/N-ary/Categorical.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 526, "size": 1700 }
{-# OPTIONS --without-K #-} open import Base open import Homotopy.Connected module Homotopy.Extensions.ProductPushoutToProductToConnected {i j} {A A′ B B′ : Set i} (f : A → A′) (g : B → B′) (P : A′ → B′ → Set j) {n₁ n₂} ⦃ P-is-trunc : ∀ a′ b′ → is-truncated (n₁ +2+ n₂) (P a′ b′) ⦄ (f-is-conn : has-connected-fibers n₁ f) (g-is-conn : has-connected-fibers n₂ g) (left* : ∀ a′ b → P a′ (g b)) (right* : ∀ a b′ → P (f a) b′) (glue* : ∀ a b → left* (f a) b ≡ right* a (g b)) where open import Homotopy.Truncation open import Homotopy.Extensions.ProductPushoutToProductToConnected.Magic {- -- The pushout diagram you should have in your mind. connected-extend-diag : pushout-diag i connected-extend-diag = record { A = A′ × B ; B = A × B′ ; C = A × B ; f = λ{(a , b) → f a , b} ; g = λ{(a , b) → a , g b} } -} private -- The first part: The extension for a fixed [a] is n₁-truncated. extension₁ : ∀ a′ → Set (max i j) extension₁ a′ = extension g (P a′) (left* a′) extend-magic₁ : ∀ a′ → is-truncated n₁ (extension₁ a′) extend-magic₁ a′ = extension-is-truncated g g-is-conn (P a′) ⦃ P-is-trunc a′ ⦄ (left* a′) -- The second part: The extension of extensions is contractible. extension₂ : Set (max i j) extension₂ = extension f extension₁ (λ a → right* a , glue* a) abstract extend-magic₂ : is-truncated ⟨-2⟩ extension₂ extend-magic₂ = extension-is-truncated f f-is-conn extension₁ ⦃ extend-magic₁ ⦄ (λ a → right* a , glue* a) extend-magic₃ : extension₂ extend-magic₃ = π₁ extend-magic₂ abstract -- Get the buried function. connected-extend : ∀ a′ b′ → P a′ b′ connected-extend a′ b′ = π₁ (π₁ extend-magic₃ a′) b′ -- β rules connected-extend-β-left : ∀ a′ b → connected-extend a′ (g b) ≡ left* a′ b connected-extend-β-left a′ b = ! $ π₂ (π₁ extend-magic₃ a′) b connected-extend-β-right : ∀ a b′ → connected-extend (f a) b′ ≡ right* a b′ connected-extend-β-right a b′ = ! $ happly (base-path (π₂ extend-magic₃ a)) b′ private -- This is a combination of 2~3 basic rules. lemma₁ : ∀ a (k : ∀ b → P (f a) (g b)) {l₁ l₂ : ∀ b′ → P (f a) b′} (p : l₁ ≡ l₂) (q : ∀ b → k b ≡ l₁ (g b)) c → transport (λ l → ∀ b → k b ≡ l (g b)) p q c ≡ q c ∘ happly p (g c) lemma₁ a k refl q c = ! $ refl-right-unit _ connected-extend-triangle : ∀ a b → connected-extend-β-left (f a) b ∘ glue* a b ≡ connected-extend-β-right a (g b) connected-extend-triangle a b = ! (π₂ (π₁ extend-magic₃ (f a)) b) ∘ glue* a b ≡⟨ ap (λ p → ! p ∘ glue* a b) $ ! $ happly (fiber-path (π₂ extend-magic₃ a)) b ⟩ ! (transport (λ l → ∀ b → left* (f a) b ≡ l (g b)) (base-path (π₂ extend-magic₃ a)) (glue* a) b) ∘ glue* a b ≡⟨ ap (λ p → ! p ∘ glue* a b) $ lemma₁ a (left* (f a)) (base-path (π₂ extend-magic₃ a)) (glue* a) b ⟩ ! (glue* a b ∘ happly (base-path (π₂ extend-magic₃ a)) (g b)) ∘ glue* a b ≡⟨ ap (λ p → p ∘ glue* a b) $ opposite-concat (glue* a b) (happly (base-path (π₂ extend-magic₃ a)) (g b)) ⟩ (connected-extend-β-right a (g b) ∘ ! (glue* a b)) ∘ glue* a b ≡⟨ concat-assoc (connected-extend-β-right a (g b)) (! (glue* a b)) (glue* a b) ⟩ connected-extend-β-right a (g b) ∘ ! (glue* a b) ∘ glue* a b ≡⟨ ap (λ p → connected-extend-β-right a (g b) ∘ p) $ opposite-left-inverse (glue* a b) ⟩ connected-extend-β-right a (g b) ∘ refl ≡⟨ refl-right-unit _ ⟩∎ connected-extend-β-right a (g b) ∎
{ "alphanum_fraction": 0.5503726194, "avg_line_length": 39.3804347826, "ext": "agda", "hexsha": "bd29fe45ae5a5da40bf99d096ad6210cdacb55ea", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Homotopy/Extensions/ProductPushoutToProductToConnected.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Homotopy/Extensions/ProductPushoutToProductToConnected.agda", "max_line_length": 115, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/Homotopy/Extensions/ProductPushoutToProductToConnected.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 1402, "size": 3623 }
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇. -- Tarski-style semantics with contexts as concrete worlds, and glueing for □ only. -- Gentzen-style syntax. module BasicIS4.Semantics.TarskiGluedGentzen where open import BasicIS4.Syntax.Common public open import Common.Semantics public -- Intuitionistic Tarski models. record Model : Set₁ where infix 3 _⊩ᵅ_ _[⊢]_ _[⊢⋆]_ field -- Forcing for atomic propositions; monotonic. _⊩ᵅ_ : Cx Ty → Atom → Set mono⊩ᵅ : ∀ {P Γ Γ′} → Γ ⊆ Γ′ → Γ ⊩ᵅ P → Γ′ ⊩ᵅ P -- Gentzen-style syntax representation; monotonic. _[⊢]_ : Cx Ty → Ty → Set _[⊢⋆]_ : Cx Ty → Cx Ty → Set mono[⊢] : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ [⊢] A → Γ′ [⊢] A [var] : ∀ {A Γ} → A ∈ Γ → Γ [⊢] A [lam] : ∀ {A B Γ} → Γ , A [⊢] B → Γ [⊢] A ▻ B [app] : ∀ {A B Γ} → Γ [⊢] A ▻ B → Γ [⊢] A → Γ [⊢] B [multibox] : ∀ {A Δ Γ} → Γ [⊢⋆] □⋆ Δ → □⋆ Δ [⊢] A → Γ [⊢] □ A [down] : ∀ {A Γ} → Γ [⊢] □ A → Γ [⊢] A [pair] : ∀ {A B Γ} → Γ [⊢] A → Γ [⊢] B → Γ [⊢] A ∧ B [fst] : ∀ {A B Γ} → Γ [⊢] A ∧ B → Γ [⊢] A [snd] : ∀ {A B Γ} → Γ [⊢] A ∧ B → Γ [⊢] B [unit] : ∀ {Γ} → Γ [⊢] ⊤ -- TODO: Workarounds for Agda bug #2143. top[⊢⋆] : ∀ {Γ} → (Γ [⊢⋆] ∅) ≡ 𝟙 pop[⊢⋆] : ∀ {Ξ A Γ} → (Γ [⊢⋆] Ξ , A) ≡ (Γ [⊢⋆] Ξ × Γ [⊢] A) infix 3 _[⊢]⋆_ _[⊢]⋆_ : Cx Ty → Cx Ty → Set Γ [⊢]⋆ ∅ = 𝟙 Γ [⊢]⋆ Ξ , A = Γ [⊢]⋆ Ξ × Γ [⊢] A [⊢⋆]→[⊢]⋆ : ∀ {Ξ Γ} → Γ [⊢⋆] Ξ → Γ [⊢]⋆ Ξ [⊢⋆]→[⊢]⋆ {∅} {Γ} ts = ∙ [⊢⋆]→[⊢]⋆ {Ξ , A} {Γ} ts rewrite pop[⊢⋆] {Ξ} {A} {Γ} = [⊢⋆]→[⊢]⋆ (π₁ ts) , π₂ ts [⊢]⋆→[⊢⋆] : ∀ {Ξ Γ} → Γ [⊢]⋆ Ξ → Γ [⊢⋆] Ξ [⊢]⋆→[⊢⋆] {∅} {Γ} ∙ rewrite top[⊢⋆] {Γ} = ∙ [⊢]⋆→[⊢⋆] {Ξ , A} {Γ} (ts , t) rewrite pop[⊢⋆] {Ξ} {A} {Γ} = [⊢]⋆→[⊢⋆] ts , t open Model {{…}} public -- Forcing in a particular model. module _ {{_ : Model}} where infix 3 _⊩_ _⊩_ : Cx Ty → Ty → Set Γ ⊩ α P = Γ ⊩ᵅ P Γ ⊩ A ▻ B = ∀ {Γ′} → Γ ⊆ Γ′ → Γ′ ⊩ A → Γ′ ⊩ B Γ ⊩ □ A = ∀ {Γ′} → Γ ⊆ Γ′ → Glue (Γ′ [⊢] □ A) (Γ′ ⊩ A) Γ ⊩ A ∧ B = Γ ⊩ A × Γ ⊩ B Γ ⊩ ⊤ = 𝟙 infix 3 _⊩⋆_ _⊩⋆_ : Cx Ty → Cx Ty → Set Γ ⊩⋆ ∅ = 𝟙 Γ ⊩⋆ Ξ , A = Γ ⊩⋆ Ξ × Γ ⊩ A -- Monotonicity with respect to context inclusion. module _ {{_ : Model}} where mono⊩ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊩ A → Γ′ ⊩ A mono⊩ {α P} η s = mono⊩ᵅ η s mono⊩ {A ▻ B} η s = λ η′ → s (trans⊆ η η′) mono⊩ {□ A} η s = λ η′ → s (trans⊆ η η′) mono⊩ {A ∧ B} η s = mono⊩ {A} η (π₁ s) , mono⊩ {B} η (π₂ s) mono⊩ {⊤} η s = ∙ mono⊩⋆ : ∀ {Ξ Γ Γ′} → Γ ⊆ Γ′ → Γ ⊩⋆ Ξ → Γ′ ⊩⋆ Ξ mono⊩⋆ {∅} η ∙ = ∙ mono⊩⋆ {Ξ , A} η (ts , t) = mono⊩⋆ {Ξ} η ts , mono⊩ {A} η t -- Shorthand for variables. module _ {{_ : Model}} where [v₀] : ∀ {A Γ} → Γ , A [⊢] A [v₀] = [var] i₀ [v₁] : ∀ {A B Γ} → Γ , A , B [⊢] A [v₁] = [var] i₁ [v₂] : ∀ {A B C Γ} → Γ , A , B , C [⊢] A [v₂] = [var] i₂ -- Useful theorems in functional form. module _ {{_ : Model}} where [multicut] : ∀ {Ξ A Γ} → Γ [⊢]⋆ Ξ → Ξ [⊢] A → Γ [⊢] A [multicut] {∅} ∙ u = mono[⊢] bot⊆ u [multicut] {Ξ , B} (ts , t) u = [app] ([multicut] ts ([lam] u)) t [dist] : ∀ {A B Γ} → Γ [⊢] □ (A ▻ B) → Γ [⊢] □ A → Γ [⊢] □ B [dist] t u = [multibox] ([⊢]⋆→[⊢⋆] ((∙ , t) , u)) ([app] ([down] [v₁]) ([down] [v₀])) [up] : ∀ {A Γ} → Γ [⊢] □ A → Γ [⊢] □ □ A [up] t = [multibox] ([⊢]⋆→[⊢⋆] ((∙ , t))) [v₀] -- Additional useful equipment. module _ {{_ : Model}} where _⟪$⟫_ : ∀ {A B Γ} → Γ ⊩ A ▻ B → Γ ⊩ A → Γ ⊩ B s ⟪$⟫ a = s refl⊆ a ⟪K⟫ : ∀ {A B Γ} → Γ ⊩ A → Γ ⊩ B ▻ A ⟪K⟫ {A} a η = K (mono⊩ {A} η a) ⟪S⟫ : ∀ {A B C Γ} → Γ ⊩ A ▻ B ▻ C → Γ ⊩ A ▻ B → Γ ⊩ A → Γ ⊩ C ⟪S⟫ {A} {B} {C} s₁ s₂ a = _⟪$⟫_ {B} {C} (_⟪$⟫_ {A} {B ▻ C} s₁ a) (_⟪$⟫_ {A} {B} s₂ a) ⟪S⟫′ : ∀ {A B C Γ} → Γ ⊩ A ▻ B ▻ C → Γ ⊩ (A ▻ B) ▻ A ▻ C ⟪S⟫′ {A} {B} {C} s₁ η s₂ η′ a = let s₁′ = mono⊩ {A ▻ B ▻ C} (trans⊆ η η′) s₁ s₂′ = mono⊩ {A ▻ B} η′ s₂ in ⟪S⟫ {A} {B} {C} s₁′ s₂′ a _⟪D⟫_ : ∀ {A B Γ} → Γ ⊩ □ (A ▻ B) → Γ ⊩ □ A → Γ ⊩ □ B _⟪D⟫_ {A} {B} s₁ s₂ η = let t ⅋ s₁′ = s₁ η u ⅋ a = s₂ η in [dist] t u ⅋ _⟪$⟫_ {A} {B} s₁′ a _⟪D⟫′_ : ∀ {A B Γ} → Γ ⊩ □ (A ▻ B) → Γ ⊩ □ A ▻ □ B _⟪D⟫′_ {A} {B} s₁ η = _⟪D⟫_ (mono⊩ {□ (A ▻ B)} η s₁) ⟪↑⟫ : ∀ {A Γ} → Γ ⊩ □ A → Γ ⊩ □ □ A ⟪↑⟫ s η = [up] (syn (s η)) ⅋ λ η′ → s (trans⊆ η η′) ⟪↓⟫ : ∀ {A Γ} → Γ ⊩ □ A → Γ ⊩ A ⟪↓⟫ s = sem (s refl⊆) _⟪,⟫′_ : ∀ {A B Γ} → Γ ⊩ A → Γ ⊩ B ▻ A ∧ B _⟪,⟫′_ {A} {B} a η = _,_ (mono⊩ {A} η a) -- Forcing in a particular world of a particular model, for sequents. module _ {{_ : Model}} where infix 3 _⊩_⇒_ _⊩_⇒_ : Cx Ty → Cx Ty → Ty → Set w ⊩ Γ ⇒ A = w ⊩⋆ Γ → w ⊩ A infix 3 _⊩_⇒⋆_ _⊩_⇒⋆_ : Cx Ty → Cx Ty → Cx Ty → Set w ⊩ Γ ⇒⋆ Ξ = w ⊩⋆ Γ → w ⊩⋆ Ξ -- Entailment, or forcing in all models, for sequents. infix 3 _⊨_ _⊨_ : Cx Ty → Ty → Set₁ Γ ⊨ A = ∀ {{_ : Model}} {w : Cx Ty} → w ⊩ Γ ⇒ A infix 3 _⊨⋆_ _⊨⋆_ : Cx Ty → Cx Ty → Set₁ Γ ⊨⋆ Ξ = ∀ {{_ : Model}} {w : Cx Ty} → w ⊩ Γ ⇒⋆ Ξ -- Additional useful equipment, for sequents. module _ {{_ : Model}} where lookup : ∀ {A Γ w} → A ∈ Γ → w ⊩ Γ ⇒ A lookup top (γ , a) = a lookup (pop i) (γ , b) = lookup i γ _⟦$⟧_ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ▻ B → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ B _⟦$⟧_ {A} {B} s₁ s₂ γ = _⟪$⟫_ {A} {B} (s₁ γ) (s₂ γ) ⟦K⟧ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ B ▻ A ⟦K⟧ {A} {B} a γ = ⟪K⟫ {A} {B} (a γ) ⟦S⟧ : ∀ {A B C Γ w} → w ⊩ Γ ⇒ A ▻ B ▻ C → w ⊩ Γ ⇒ A ▻ B → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ C ⟦S⟧ {A} {B} {C} s₁ s₂ a γ = ⟪S⟫ {A} {B} {C} (s₁ γ) (s₂ γ) (a γ) _⟦D⟧_ : ∀ {A B Γ w} → w ⊩ Γ ⇒ □ (A ▻ B) → w ⊩ Γ ⇒ □ A → w ⊩ Γ ⇒ □ B (s₁ ⟦D⟧ s₂) γ = (s₁ γ) ⟪D⟫ (s₂ γ) ⟦↑⟧ : ∀ {A Γ w} → w ⊩ Γ ⇒ □ A → w ⊩ Γ ⇒ □ □ A ⟦↑⟧ s γ = ⟪↑⟫ (s γ) ⟦↓⟧ : ∀ {A Γ w} → w ⊩ Γ ⇒ □ A → w ⊩ Γ ⇒ A ⟦↓⟧ s γ = ⟪↓⟫ (s γ) _⟦,⟧_ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A → w ⊩ Γ ⇒ B → w ⊩ Γ ⇒ A ∧ B (a ⟦,⟧ b) γ = a γ , b γ ⟦π₁⟧ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ∧ B → w ⊩ Γ ⇒ A ⟦π₁⟧ s γ = π₁ (s γ) ⟦π₂⟧ : ∀ {A B Γ w} → w ⊩ Γ ⇒ A ∧ B → w ⊩ Γ ⇒ B ⟦π₂⟧ s γ = π₂ (s γ)
{ "alphanum_fraction": 0.3654381654, "avg_line_length": 29.7804878049, "ext": "agda", "hexsha": "3764795b031cb6e80968ac5f37d217f7842c9928", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIS4/Semantics/TarskiGluedGentzen.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIS4/Semantics/TarskiGluedGentzen.agda", "max_line_length": 87, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIS4/Semantics/TarskiGluedGentzen.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 3816, "size": 6105 }
module Category where open import Prelude -------------------------------------------------------------------------------- record Category {ℓ ℓ′} (𝒪 : Set ℓ) (_▹_ : 𝒪 → 𝒪 → Set ℓ′) : Set (ℓ ⊔ ℓ′) where field idₓ : ∀ {x} → x ▹ x _⋄_ : ∀ {x y z} → y ▹ x → z ▹ y → z ▹ x lid⋄ : ∀ {x y} → (f : y ▹ x) → idₓ ⋄ f ≡ f rid⋄ : ∀ {x y} → (f : y ▹ x) → f ⋄ idₓ ≡ f assoc⋄ : ∀ {x y z a} → (h : a ▹ z) (g : z ▹ y) (f : y ▹ x) → (f ⋄ g) ⋄ h ≡ f ⋄ (g ⋄ h) 𝗦𝗲𝘁 : (ℓ : Level) → Category (Set ℓ) Π 𝗦𝗲𝘁 ℓ = record { idₓ = id ; _⋄_ = _∘_ ; lid⋄ = λ f → refl ; rid⋄ = λ f → refl ; assoc⋄ = λ h g f → refl } 𝗦𝗲𝘁₀ : Category (Set ℓ₀) Π 𝗦𝗲𝘁₀ = 𝗦𝗲𝘁 ℓ₀ record Functor {ℓ₁ ℓ₁′ ℓ₂ ℓ₂′} {𝒪₁ : Set ℓ₁} {_▹₁_ : 𝒪₁ → 𝒪₁ → Set ℓ₁′} {𝒪₂ : Set ℓ₂} {_▹₂_ : 𝒪₂ → 𝒪₂ → Set ℓ₂′} (𝗖 : Category 𝒪₁ _▹₁_) (𝗗 : Category 𝒪₂ _▹₂_) : Set (ℓ₁ ⊔ ℓ₁′ ⊔ ℓ₂ ⊔ ℓ₂′) where private module C = Category 𝗖 module D = Category 𝗗 field Fₓ : 𝒪₁ → 𝒪₂ F : ∀ {x y} → y ▹₁ x → Fₓ y ▹₂ Fₓ x idF : ∀ {x} → F (C.idₓ {x = x}) ≡ D.idₓ F⋄ : ∀ {x y z} → (g : z ▹₁ y) (f : y ▹₁ x) → F (f C.⋄ g) ≡ F f D.⋄ F g record NaturalTransformation {ℓ₁ ℓ₁′ ℓ₂ ℓ₂′} {𝒪₁ : Set ℓ₁} {_▹₁_ : 𝒪₁ → 𝒪₁ → Set ℓ₁′} {𝒪₂ : Set ℓ₂} {_▹₂_ : 𝒪₂ → 𝒪₂ → Set ℓ₂′} {𝗖 : Category 𝒪₁ _▹₁_} {𝗗 : Category 𝒪₂ _▹₂_} (𝗙 𝗚 : Functor 𝗖 𝗗) : Set (ℓ₁ ⊔ ℓ₁′ ⊔ ℓ₂ ⊔ ℓ₂′) where private open module D = Category 𝗗 using (_⋄_) open module F = Functor 𝗙 using (Fₓ ; F) open module G = Functor 𝗚 using () renaming (Fₓ to Gₓ ; F to G) field N : ∀ {x} → Fₓ x ▹₂ Gₓ x natN : ∀ {x y} → (f : y ▹₁ x) → (N ⋄ F f) ≡ (G f ⋄ N) Opposite : ∀ {ℓ ℓ′} → {𝒪 : Set ℓ} {_▹_ : 𝒪 → 𝒪 → Set ℓ′} → Category 𝒪 _▹_ → Category 𝒪 (flip _▹_) Opposite 𝗖 = record { idₓ = C.idₓ ; _⋄_ = flip C._⋄_ ; lid⋄ = C.rid⋄ ; rid⋄ = C.lid⋄ ; assoc⋄ = λ f g h → C.assoc⋄ h g f ⁻¹ } where module C = Category 𝗖 Presheaf : ∀ ℓ {ℓ′ ℓ″} → {𝒪 : Set ℓ′} {_▹_ : 𝒪 → 𝒪 → Set ℓ″} → (𝗖 : Category 𝒪 _▹_) → Set _ Presheaf ℓ 𝗖 = Functor (Opposite 𝗖) (𝗦𝗲𝘁 ℓ) Presheaf₀ : ∀ {ℓ ℓ′} → {𝒪 : Set ℓ} {_▹_ : 𝒪 → 𝒪 → Set ℓ′} → (𝗖 : Category 𝒪 _▹_) → Set _ Presheaf₀ 𝗖 = Presheaf ℓ₀ 𝗖 --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.3540530716, "avg_line_length": 25.9528301887, "ext": "agda", "hexsha": "946249b7085fc821b87c3e4558243264073db331", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/coquand-kovacs", "max_forks_repo_path": "src/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/coquand-kovacs", "max_issues_repo_path": "src/Category.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/coquand-kovacs", "max_stars_repo_path": "src/Category.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1314, "size": 2751 }
------------------------------------------------------------------------ -- Utility methods ------------------------------------------------------------------------ -- Should be pushed to the standard library {-# OPTIONS --allow-exec #-} open import Algebra.Core using (Op₂) open import Level using (Level) open import Data.Bool.Base using (T; Bool; if_then_else_; not; _∨_) open import Data.Char.Properties using (_≟_) open import Data.String using (String; _++_; lines; toList) open import Data.Nat.Base using (ℕ; suc) open import Data.Vec.Base using (Vec; []; _∷_) open import Data.Vec.Functional using (Vector) open import Data.Vec.Recursive using (_^_; toVec) open import Data.Product using (_,_) open import Data.Float.Base using (Float; _≤ᵇ_) open import Data.List.Base using ([]; _∷_) open import Data.List.Relation.Binary.Infix.Heterogeneous.Properties using (infix?) open import Data.Unit.Base using (⊤; tt) open import Relation.Nullary using (does) open import Relation.Binary.Core using (Rel) module Vehicle.Utils where _⇒_ : Op₂ Bool x ⇒ y = not x ∨ y _≤_ : Rel Float _ x ≤ y = T (x ≤ᵇ y) _⊆_ : String → String → Bool s ⊆ t = does (infix? _≟_ (toList s) (toList t))
{ "alphanum_fraction": 0.6303797468, "avg_line_length": 34.8529411765, "ext": "agda", "hexsha": "454799a3cb022a65ce288a45979c4ebf7716e6e5", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-11-16T14:30:47.000Z", "max_forks_repo_forks_event_min_datetime": "2021-03-15T15:22:31.000Z", "max_forks_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vehicle-lang/vehicle", "max_forks_repo_path": "src/agda/Vehicle/Utils.agda", "max_issues_count": 53, "max_issues_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_issues_repo_issues_event_max_datetime": "2021-12-15T22:42:01.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-16T07:26:42.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "wenkokke/vehicle", "max_issues_repo_path": "src/agda/Vehicle/Utils.agda", "max_line_length": 83, "max_stars_count": 11, "max_stars_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "wenkokke/vehicle", "max_stars_repo_path": "src/agda/Vehicle/Utils.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T01:35:39.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-24T05:55:15.000Z", "num_tokens": 305, "size": 1185 }
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness --no-subtyping #-} module Agda.Builtin.Word.Properties where open import Agda.Builtin.Word open import Agda.Builtin.Equality primitive primWord64ToNatInjective : ∀ a b → primWord64ToNat a ≡ primWord64ToNat b → a ≡ b
{ "alphanum_fraction": 0.7157190635, "avg_line_length": 24.9166666667, "ext": "agda", "hexsha": "d51f3322f2a91a8e21dcef58599cad5251e619d7", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Word/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_issues_event_min_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Word/Properties.agda", "max_line_length": 82, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Word/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-14T11:08:59.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-14T11:08:59.000Z", "num_tokens": 84, "size": 299 }
{- This file contains: - Definition of set quotients -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.SetQuotients.Base where open import Cubical.Core.Primitives -- Set quotients as a higher inductive type: data _/_ {ℓ ℓ'} (A : Type ℓ) (R : A → A → Type ℓ') : Type (ℓ-max ℓ ℓ') where [_] : (a : A) → A / R eq/ : (a b : A) → (r : R a b) → [ a ] ≡ [ b ] squash/ : (x y : A / R) → (p q : x ≡ y) → p ≡ q
{ "alphanum_fraction": 0.5573394495, "avg_line_length": 24.2222222222, "ext": "agda", "hexsha": "202ba845295e52dce13a39588e81f56a3cdfcb15", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/HITs/SetQuotients/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/HITs/SetQuotients/Base.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/SetQuotients/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 170, "size": 436 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution {{eqrel : EqRelSet}} where open import Definition.Untyped hiding (_∷_) open import Definition.Typed open import Definition.LogicalRelation open import Tools.Nat open import Tools.Product open import Tools.Unit private variable k ℓ m n l : Nat Γ : Con Term n -- The validity judgements: -- We consider expressions that satisfy these judgments valid mutual -- Validity of contexts data ⊩ᵛ_ : Con Term n → Set where ε : ⊩ᵛ ε _∙_ : ∀ {A l} ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ l ⟩ A / [Γ] → ⊩ᵛ Γ ∙ A -- Validity of types _⊩ᵛ⟨_⟩_/_ : {n : Nat} (Γ : Con Term n) (l : TypeLevel) (A : Term n) → ⊩ᵛ Γ → Set _⊩ᵛ⟨_⟩_/_ {n} Γ l A [Γ] = ∀ {k : Nat} {Δ : Con Term k} {σ : Subst k n} (⊢Δ : ⊢ Δ) ([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ) → Σ (Δ ⊩⟨ l ⟩ subst σ A) (λ [Aσ] → ∀ {σ′} ([σ′] : Δ ⊩ˢ σ′ ∷ Γ / [Γ] / ⊢Δ) ([σ≡σ′] : Δ ⊩ˢ σ ≡ σ′ ∷ Γ / [Γ] / ⊢Δ / [σ]) → Δ ⊩⟨ l ⟩ subst σ A ≡ subst σ′ A / [Aσ]) -- Logical relation for substitutions from a valid context _⊩ˢ_∷_/_/_ : (Δ : Con Term n) (σ : Subst n m) (Γ : Con Term m) ([Γ] : ⊩ᵛ Γ) (⊢Δ : ⊢ Δ) → Set Δ ⊩ˢ σ ∷ .ε / ε / ⊢Δ = ⊤ Δ ⊩ˢ σ ∷ .(Γ ∙ A) / (_∙_ {Γ = Γ} {A} {l} [Γ] [A]) / ⊢Δ = Σ (Δ ⊩ˢ tail σ ∷ Γ / [Γ] / ⊢Δ) λ [tailσ] → (Δ ⊩⟨ l ⟩ head σ ∷ subst (tail σ) A / proj₁ ([A] ⊢Δ [tailσ])) -- Logical relation for equality of substitutions from a valid context _⊩ˢ_≡_∷_/_/_/_ : (Δ : Con Term n) (σ σ′ : Subst n m) (Γ : Con Term m) ([Γ] : ⊩ᵛ Γ) (⊢Δ : ⊢ Δ) ([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ) → Set --Δ ⊩ˢ σ ≡ σ′ ∷ Γ / x / y / z = {! !} Δ ⊩ˢ σ ≡ σ′ ∷ .ε / ε / ⊢Δ / [σ] = ⊤ Δ ⊩ˢ σ ≡ σ′ ∷ .(Γ ∙ A) / (_∙_ {Γ = Γ} {A} {l} [Γ] [A]) / ⊢Δ / [σ] = (Δ ⊩ˢ tail σ ≡ tail σ′ ∷ Γ / [Γ] / ⊢Δ / proj₁ [σ]) × (Δ ⊩⟨ l ⟩ head σ ≡ head σ′ ∷ subst (tail σ) A / proj₁ ([A] ⊢Δ (proj₁ [σ]))) -- Validity of terms _⊩ᵛ⟨_⟩_∷_/_/_ : (Γ : Con Term n) (l : TypeLevel) (t A : Term n) ([Γ] : ⊩ᵛ Γ) ([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ]) → Set Γ ⊩ᵛ⟨ l ⟩ t ∷ A / [Γ] / [A] = ∀ {k} {Δ : Con Term k} {σ} (⊢Δ : ⊢ Δ) ([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ) → Σ (Δ ⊩⟨ l ⟩ subst σ t ∷ subst σ A / proj₁ ([A] ⊢Δ [σ])) λ [tσ] → ∀ {σ′} → Δ ⊩ˢ σ′ ∷ Γ / [Γ] / ⊢Δ → Δ ⊩ˢ σ ≡ σ′ ∷ Γ / [Γ] / ⊢Δ / [σ] → Δ ⊩⟨ l ⟩ subst σ t ≡ subst σ′ t ∷ subst σ A / proj₁ ([A] ⊢Δ [σ]) -- Validity of type equality _⊩ᵛ⟨_⟩_≡_/_/_ : (Γ : Con Term n) (l : TypeLevel) (A B : Term n) ([Γ] : ⊩ᵛ Γ) ([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ]) → Set Γ ⊩ᵛ⟨ l ⟩ A ≡ B / [Γ] / [A] = ∀ {k} {Δ : Con Term k} {σ} (⊢Δ : ⊢ Δ) ([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ) → Δ ⊩⟨ l ⟩ subst σ A ≡ subst σ B / proj₁ ([A] ⊢Δ [σ]) -- Validity of term equality _⊩ᵛ⟨_⟩_≡_∷_/_/_ : (Γ : Con Term n) (l : TypeLevel) (t u A : Term n) ([Γ] : ⊩ᵛ Γ) ([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ]) → Set Γ ⊩ᵛ⟨ l ⟩ t ≡ u ∷ A / [Γ] / [A] = ∀ {k} {Δ : Con Term k} {σ} → (⊢Δ : ⊢ Δ) ([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ) → Δ ⊩⟨ l ⟩ subst σ t ≡ subst σ u ∷ subst σ A / proj₁ ([A] ⊢Δ [σ]) -- Valid term equality with validity of its type and terms record [_⊩ᵛ⟨_⟩_≡_∷_/_] (Γ : Con Term n) (l : TypeLevel) (t u A : Term n) ([Γ] : ⊩ᵛ Γ) : Set where constructor modelsTermEq field [A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ] [t] : Γ ⊩ᵛ⟨ l ⟩ t ∷ A / [Γ] / [A] [u] : Γ ⊩ᵛ⟨ l ⟩ u ∷ A / [Γ] / [A] [t≡u] : Γ ⊩ᵛ⟨ l ⟩ t ≡ u ∷ A / [Γ] / [A] -- Validity of reduction of terms _⊩ᵛ_⇒_∷_/_ : (Γ : Con Term n) (t u A : Term n) ([Γ] : ⊩ᵛ Γ) → Set Γ ⊩ᵛ t ⇒ u ∷ A / [Γ] = ∀ {k} {Δ : Con Term k} {σ} (⊢Δ : ⊢ Δ) ([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ) → Δ ⊢ subst σ t ⇒ subst σ u ∷ subst σ A
{ "alphanum_fraction": 0.4308724832, "avg_line_length": 39.6276595745, "ext": "agda", "hexsha": "951a6be1c3e6826758e39b3f54a2b61da5621f77", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-11-27T15:58:33.000Z", "max_forks_repo_forks_event_min_datetime": "2017-10-18T14:18:20.000Z", "max_forks_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "fhlkfy/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_issues_repo_issues_event_max_datetime": "2021-02-22T10:37:24.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-22T12:49:23.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "fhlkfy/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution.agda", "max_line_length": 90, "max_stars_count": 30, "max_stars_repo_head_hexsha": "ea83fc4f618d1527d64ecac82d7d17e2f18ac391", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "fhlkfy/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:01:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-20T03:05:21.000Z", "num_tokens": 2005, "size": 3725 }
module Extra where open import Prelude fromTo : Nat -> List Nat fromTo n = f n where f : Nat -> List Nat f 0 = [] f (suc i) = n - i ∷ f i downFrom : Nat -> List Nat downFrom 0 = [] downFrom (suc n) = (suc n) ∷ downFrom n fromTo' : Nat -> List Nat fromTo' = f [] where f : List Nat -> Nat -> List Nat f xs 0 = xs f xs (suc x) = seq xs (f ( suc x ∷ xs ) x) downFrom' : Nat -> List Nat downFrom' n = f [] n where f : List Nat -> Nat -> List Nat f xs 0 = xs f xs (suc x) = seq xs (f ((n - x) ∷ xs) x) blumblumshub : Nat -> (m : Nat) -> {{ nz : NonZero m }} -> Nat blumblumshub xn M = natMod M (xn ^ 2) downFromBbs' : Nat -> Nat -> List Nat downFromBbs' seed = f seed [] where f : Nat -> List Nat -> Nat -> List Nat f _ acc 0 = acc f x acc (suc l) = seq acc $ f (blumblumshub x M) ( x ∷ acc ) l where M M17 M31 : Nat M = M17 * M31 M17 = 2971 M31 = 4111 fromToBbs : Nat -> Nat -> List Nat fromToBbs _ 0 = [] fromToBbs xi (suc n) = xi ∷ fromToBbs (blumblumshub xi m) n where p = 2971 q = 4111 m = p * q
{ "alphanum_fraction": 0.5181576616, "avg_line_length": 21.3018867925, "ext": "agda", "hexsha": "ea88f2b8f8369ca4ad4ff1a5f35483a595d7059f", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:48.000Z", "max_forks_repo_forks_event_min_datetime": "2018-05-24T10:45:59.000Z", "max_forks_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "xekoukou/agda-ocaml", "max_forks_repo_path": "benchmark/agda-ocaml/Extra.agda", "max_issues_count": 16, "max_issues_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720", "max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "xekoukou/agda-ocaml", "max_issues_repo_path": "benchmark/agda-ocaml/Extra.agda", "max_line_length": 64, "max_stars_count": 48, "max_stars_repo_head_hexsha": "e38b699870ba638221828b07b12948d70a1bdaec", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-ocaml", "max_stars_repo_path": "benchmark/agda-ocaml/Extra.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-15T09:08:14.000Z", "max_stars_repo_stars_event_min_datetime": "2017-03-29T14:19:31.000Z", "num_tokens": 451, "size": 1129 }
open import Data.Product using ( ∃ ; _×_ ) open import FRP.LTL.RSet.Core using ( RSet ) open import FRP.LTL.Time using ( _≤_ ) module FRP.LTL.RSet.Future where ◇ : RSet → RSet ◇ A t = ∃ λ u → (t ≤ u) × A u
{ "alphanum_fraction": 0.6267942584, "avg_line_length": 20.9, "ext": "agda", "hexsha": "8473aa19cc82c29297a60dde2f640dc90d5bcb5e", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/RSet/Future.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/RSet/Future.agda", "max_line_length": 44, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/RSet/Future.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 79, "size": 209 }
{-# OPTIONS --sized-types #-} module SList.Order.Properties {A : Set}(_≤_ : A → A → Set) where open import List.Sorted _≤_ open import Size open import SList open import SList.Order _≤_ lemma-slist-sorted : {ι : Size}{x : A}{xs : SList A {ι}} → x *≤ xs → Sorted (unsize A xs) → Sorted (unsize A (x ∙ xs)) lemma-slist-sorted {x = x} genx nils = singls x lemma-slist-sorted (gecx x≤y genx) (singls y) = conss x≤y (singls y) lemma-slist-sorted (gecx x≤y x*≤zys ) syzys = conss x≤y syzys lemma-sorted⊕ : {ι : Size}{x : A}{xs : SList A {ι}} → xs ≤* x → Sorted (unsize A xs) → Sorted (unsize A (_⊕_ A xs (x ∙ snil))) lemma-sorted⊕ {x = x} {xs = snil} _ nils = singls x lemma-sorted⊕ {x = x} {xs = y ∙ snil} (lecx y≤x _) (singls .y) = conss y≤x (singls x) lemma-sorted⊕ {xs = y ∙ (z ∙ ys)} (lecx y≤x zys≤*x) (conss y≤z szys) = conss y≤z (lemma-sorted⊕ zys≤*x szys) lemma-⊕≤* : {ι : Size}{x t : A}{xs : SList A {ι}} → x ≤ t → xs ≤* t → (_⊕_ A xs (x ∙ snil)) ≤* t lemma-⊕≤* x≤t lenx = lecx x≤t lenx lemma-⊕≤* x≤t (lecx y≤t ys≤*t) = lecx y≤t (lemma-⊕≤* x≤t ys≤*t)
{ "alphanum_fraction": 0.5877358491, "avg_line_length": 48.1818181818, "ext": "agda", "hexsha": "1df392bffeeea716d5f3343cbeb06f3fc8b7da65", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/SList/Order/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/SList/Order/Properties.agda", "max_line_length": 126, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/SList/Order/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 515, "size": 1060 }
-- Andreas, 2016-06-17, issue #2018 reported by Nisse -- Shadowing a module parameter with a record parameter -- caused the record parameter to be renamed -- {-# OPTIONS -v tc.rec:20 #-} module _ {A : Set} where data D {A : Set} : Set where c : D record R {A : Set} : Set where constructor rc postulate B : Set test-c : (B : Set) → D {A = B} test-c B = c {A = B} test-rc : (B : Set) → R {A = B} test-rc B = rc {A = B} -- Error WAS: -- Function does not accept argument {A = _} -- when checking that {A = B} is a valid argument to a function of -- type {A₁ : Set} → Set -- Should work now.
{ "alphanum_fraction": 0.6115702479, "avg_line_length": 19.5161290323, "ext": "agda", "hexsha": "9969821dd9dfabd4db5f624d444e9e395be5139e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2018.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2018.agda", "max_line_length": 66, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2018.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 200, "size": 605 }
module Cats.Category.Constructions.CCC where open import Level open import Cats.Category.Base open import Cats.Category.Constructions.Exponential using (HasExponentials) open import Cats.Category.Constructions.Product using (HasFiniteProducts) record IsCCC {lo la l≈} (Cat : Category lo la l≈) : Set (lo ⊔ la ⊔ l≈) where field {{hasFiniteProducts}} : HasFiniteProducts Cat {{hasExponentials}} : HasExponentials Cat
{ "alphanum_fraction": 0.7586206897, "avg_line_length": 25.5882352941, "ext": "agda", "hexsha": "1f3ca30c8ebd347176839fe16e7b529a10620887", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Category/Constructions/CCC.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Category/Constructions/CCC.agda", "max_line_length": 57, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Category/Constructions/CCC.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 116, "size": 435 }
module PLRTree.Heap.Correctness {A : Set}(_≤_ : A → A → Set) where open import BTree.Heap _≤_ open import PLRTree {A} open import PLRTree.Heap _≤_ renaming (Heap to Heap') lemma-heap'-heap : {t : PLRTree} → Heap' t → Heap (forget t) lemma-heap'-heap leaf = leaf lemma-heap'-heap (node {t} {x} (lf≤* .x) (lf≤* .x) _ _) = single x lemma-heap'-heap (node {t} {x} (lf≤* .x) (nd≤* x≤y _ _) _ h'r) = right x≤y (lemma-heap'-heap h'r) lemma-heap'-heap (node {t} {x} (nd≤* x≤y _ _) (lf≤* .x) h'l _) = left x≤y (lemma-heap'-heap h'l) lemma-heap'-heap (node (nd≤* x≤y _ _) (nd≤* x≤y' _ _) h'l h'r) = both x≤y x≤y' (lemma-heap'-heap h'l) (lemma-heap'-heap h'r)
{ "alphanum_fraction": 0.6003062787, "avg_line_length": 50.2307692308, "ext": "agda", "hexsha": "ca2977cb7e67b292511f108c576c3eed97da1a3e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/PLRTree/Heap/Correctness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/PLRTree/Heap/Correctness.agda", "max_line_length": 125, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/PLRTree/Heap/Correctness.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 296, "size": 653 }
-- Andreas, 2018-10-16, runtime erasure -- -- Should not be able to extract erased constructor field. open import Agda.Builtin.Nat data Vec (A : Set) : Nat → Set where [] : Vec A zero _∷_ : {@0 n : Nat} (x : A) (xs : Vec A n) → Vec A (suc n) length : ∀{A} {@0 n} (x : Vec A n) → Nat length [] = zero length (_∷_ {n} _ _) = suc n -- Expected error: -- -- Variable n is declared erased, so it cannot be used here -- when checking that the expression n has type Nat
{ "alphanum_fraction": 0.6242038217, "avg_line_length": 24.7894736842, "ext": "agda", "hexsha": "2831c2d699e29b9e79de071154adc4c3543d13a4", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Erasure-No-Project-Erased-ConArg.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Erasure-No-Project-Erased-ConArg.agda", "max_line_length": 59, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Erasure-No-Project-Erased-ConArg.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 157, "size": 471 }
{-# OPTIONS --without-K #-} open import HoTT open import cohomology.FunctionOver {- The cofiber space of [winl : X → X ∨ Y] is equivalent to [Y], - and the cofiber space of [winr : Y → X ∨ Y] is equivalent to [X]. -} module cohomology.WedgeCofiber where module WedgeCofiber {i} (X Y : Ptd i) where module CofWinl where module Into = CofiberRec {f = winl} (snd Y) (projr X Y) (λ _ → idp) into = Into.f out : fst Y → Cofiber (winl {X = X} {Y = Y}) out = cfcod ∘ winr out-into : (κ : Cofiber (winl {X = X} {Y = Y})) → out (into κ) == κ out-into = Cofiber-elim (! (cfglue (snd X) ∙ ap cfcod wglue)) (Wedge-elim (λ x → ! (cfglue (snd X) ∙ ap cfcod wglue) ∙ cfglue x) (λ y → idp) (↓-='-from-square $ (lemma (cfglue (snd X)) (ap cfcod wglue) ∙h⊡ (ap-∘ out (projr X Y) wglue ∙ ap (ap out) (Projr.glue-β X Y)) ∙v⊡ bl-square (ap cfcod wglue)))) (λ x → ↓-∘=idf-from-square out into $ ! (∙-unit-r _) ∙h⊡ ap (ap out) (Into.glue-β x) ∙v⊡ hid-square {p = (! (cfglue' winl (snd X) ∙ ap cfcod wglue))} ⊡v connection {q = cfglue x}) where lemma : ∀ {i} {A : Type i} {x y z : A} (p : x == y) (q : y == z) → ! (p ∙ q) ∙ p == ! q lemma idp idp = idp ⊙path : ⊙Cof (⊙winl {X = X} {Y = Y}) == Y ⊙path = ⊙ua (⊙≃-in (equiv into out (λ _ → idp) out-into) idp) cfcod-over : ⊙cfcod' ⊙winl == ⊙projr X Y [ (λ U → fst (X ⊙∨ Y ⊙→ U)) ↓ ⊙path ] cfcod-over = codomain-over-⊙equiv (⊙cfcod' ⊙winl) _ ▹ pair= idp (∙-unit-r _ ∙ ap-! into (cfglue (snd X)) ∙ ap ! (Into.glue-β (snd X))) module CofWinr where module Into = CofiberRec {f = winr} (snd X) (projl X Y) (λ _ → idp) into = Into.f out : fst X → Cofiber (winr {X = X} {Y = Y}) out = cfcod ∘ winl out-into : ∀ κ → out (into κ) == κ out-into = Cofiber-elim (ap cfcod wglue ∙ ! (cfglue (snd Y))) (Wedge-elim (λ x → idp) (λ y → (ap cfcod wglue ∙ ! (cfglue (snd Y))) ∙ cfglue y) (↓-='-from-square $ (ap-∘ out (projl X Y) wglue ∙ ap (ap out) (Projl.glue-β X Y)) ∙v⊡ connection ⊡h∙ ! (lemma (ap (cfcod' winr) wglue) (cfglue (snd Y))))) (λ y → ↓-∘=idf-from-square out into $ ! (∙-unit-r _) ∙h⊡ ap (ap out) (Into.glue-β y) ∙v⊡ hid-square {p = (ap (cfcod' winr) wglue ∙ ! (cfglue (snd Y)))} ⊡v connection {q = cfglue y}) where lemma : ∀ {i} {A : Type i} {x y z : A} (p : x == y) (q : z == y) → (p ∙ ! q) ∙ q == p lemma idp idp = idp ⊙path : ⊙Cof ⊙winr == X ⊙path = ⊙ua (⊙≃-in (equiv into out (λ _ → idp) out-into) idp) cfcod-over : ⊙cfcod' ⊙winr == ⊙projl X Y [ (λ U → fst (X ⊙∨ Y ⊙→ U)) ↓ ⊙path ] cfcod-over = codomain-over-⊙equiv (⊙cfcod' ⊙winr) _ ▹ pair= idp lemma where lemma : ap into (ap cfcod (! (! wglue)) ∙ ! (cfglue (snd Y))) ∙ idp == idp lemma = ap into (ap cfcod (! (! wglue)) ∙ ! (cfglue (snd Y))) ∙ idp =⟨ ∙-unit-r _ ⟩ ap into (ap cfcod (! (! wglue)) ∙ ! (cfglue (snd Y))) =⟨ !-! wglue |in-ctx (λ w → ap into (ap cfcod w ∙ ! (cfglue (snd Y)))) ⟩ ap into (ap cfcod wglue ∙ ! (cfglue (snd Y))) =⟨ ap-∙ into (ap cfcod wglue) (! (cfglue (snd Y))) ⟩ ap into (ap cfcod wglue) ∙ ap into (! (cfglue (snd Y))) =⟨ ∘-ap into cfcod wglue |in-ctx (_∙ ap into (! (cfglue (snd Y)))) ⟩ ap (projl X Y) wglue ∙ ap into (! (cfglue (snd Y))) =⟨ Projl.glue-β X Y |in-ctx (_∙ ap into (! (cfglue (snd Y)))) ⟩ ap into (! (cfglue (snd Y))) =⟨ ap-! into (cfglue (snd Y)) ⟩ ! (ap into (cfglue (snd Y))) =⟨ ap ! (Into.glue-β (snd Y)) ⟩ idp ∎
{ "alphanum_fraction": 0.4618126273, "avg_line_length": 36.0366972477, "ext": "agda", "hexsha": "bdce24d875335ef16860dc4f2524e74761315cc4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "theorems/cohomology/WedgeCofiber.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "theorems/cohomology/WedgeCofiber.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "theorems/cohomology/WedgeCofiber.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1649, "size": 3928 }
open import Relation.Binary.Core module PLRTree.Insert.Complete {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) where open import Data.Empty open import Data.Sum renaming (_⊎_ to _∨_) open import PLRTree {A} open import PLRTree.Compound {A} open import PLRTree.Insert _≤_ tot≤ open import PLRTree.Insert.Properties _≤_ tot≤ open import PLRTree.Complete {A} open import PLRTree.Complete.Properties {A} open import PLRTree.Equality {A} open import PLRTree.Equality.Properties {A} lemma-≃-⊥ : {l : PLRTree}(x : A) → l ≃ insert x l → ⊥ lemma-≃-⊥ {leaf} _ () lemma-≃-⊥ {node perfect x' l' r'} x l≃lᵢ with tot≤ x x' | l' | r' | l≃lᵢ ... | inj₁ x≤x' | leaf | leaf | () ... | inj₁ x≤x' | leaf | node _ _ _ _ | () ... | inj₁ x≤x' | node _ _ _ _ | leaf | () ... | inj₁ x≤x' | node _ _ _ _ | node _ _ _ _ | () ... | inj₂ x'≤x | leaf | leaf | () ... | inj₂ x'≤x | leaf | node _ _ _ _ | () ... | inj₂ x'≤x | node _ _ _ _ | leaf | () ... | inj₂ x'≤x | node _ _ _ _ | node _ _ _ _ | () lemma-≃-⊥ {node left _ _ _} _ () lemma-≃-⊥ {node right _ _ _} _ () lemma-⋗-⊥ : {l : PLRTree}(x : A) → l ⋗ insert x l → ⊥ lemma-⋗-⊥ {leaf} _ () lemma-⋗-⊥ {node perfect x' l' r'} x l⋗lᵢ with tot≤ x x' | l' | r' | l⋗lᵢ ... | inj₁ x≤x' | leaf | leaf | () ... | inj₁ x≤x' | leaf | node _ _ _ _ | () ... | inj₁ x≤x' | node _ _ _ _ | leaf | () ... | inj₁ x≤x' | node _ _ _ _ | node _ _ _ _ | () ... | inj₂ x'≤x | leaf | leaf | () ... | inj₂ x'≤x | leaf | node _ _ _ _ | () ... | inj₂ x'≤x | node _ _ _ _ | leaf | () ... | inj₂ x'≤x | node _ _ _ _ | node _ _ _ _ | () lemma-⋗-⊥ {node left _ _ _} _ () lemma-⋗-⊥ {node right _ _ _} _ () lemma-⋙-⊥ : {l r : PLRTree}(x : A) → l ⋙ r → l ⋗ insert x r → ⊥ lemma-⋙-⊥ x (⋙p l⋗r) l⋗rᵢ = lemma-≃-⊥ x (lemma-⋗* l⋗r l⋗rᵢ) lemma-⋙-⊥ x (⋙l {l' = l''} y' y'' l'≃r' l''⋘r'' l'⋗r'') l⋗rᵢ with tot≤ x y'' ... | inj₁ x≤y'' with insert y'' l'' | lemma-insert-compound y'' l'' | l⋗rᵢ ... | node perfect _ _ _ | compound | () ... | node left _ _ _ | compound | () ... | node right _ _ _ | compound | () lemma-⋙-⊥ x (⋙l {l' = l''} y' y'' l'≃r' l''⋘r'' l'⋗r'') l⋗rᵢ | inj₂ y''≤x with insert x l'' | lemma-insert-compound x l'' | l⋗rᵢ ... | node perfect _ _ _ | compound | () ... | node left _ _ _ | compound | () ... | node right _ _ _ | compound | () lemma-⋙-⊥ x (⋙r {r' = r''} y' y'' l'≃r' l''⋙r'' l'≃l'') l⋗rᵢ with tot≤ x y'' ... | inj₁ x≤y'' with insert y'' r'' | lemma-insert-compound y'' r'' | l⋗rᵢ ... | node perfect _ _ _ | compound | ⋗nd .y' .x _ l''≃r''ᵢ l'⋗l'' = lemma-⋗refl-⊥ (lemma-⋗-≃ l'⋗l'' (sym≃ l'≃l'')) ... | node left _ _ _ | compound | () ... | node right _ _ _ | compound | () lemma-⋙-⊥ x (⋙r {r' = r''} y' y'' l'≃r' l''⋙r'' l'≃l'') l⋗rᵢ | inj₂ y''≤x with insert x r'' | lemma-insert-compound x r'' | l⋗rᵢ ... | node perfect _ _ _ | compound | ⋗nd .y' .y'' _ l''≃r''ᵢ l'⋗l'' = lemma-⋗refl-⊥ (lemma-⋗-≃ l'⋗l'' (sym≃ l'≃l'')) ... | node left _ _ _ | compound | () ... | node right _ _ _ | compound | () lemma-insert-≃ : {l r : PLRTree}{x : A} → Compound l → l ≃ r → insert x l ⋘ r lemma-insert-≃ {node perfect y l r} {node perfect y' l' r'} {x} compound (≃nd .y .y' l≃r l'≃r' l≃l') with tot≤ x y | l | r | l≃r | l' | l≃l' ... | inj₁ x≤y | leaf | leaf | ≃lf | leaf | ≃lf = r⋘ x y' (⋙p (⋗lf y)) l'≃r' (⋗lf y) ... | inj₁ x≤y | node perfect z₁ _ _ | node perfect z₂ _ _ | ≃nd .z₁ .z₂ l₁≃r₁ l₂≃r₂ l₁≃l₂ | node perfect z₃ _ _ | ≃nd .z₁ .z₃ _ l₃≃r₃ l₁≃l₃ = l⋘ x y' (lemma-insert-≃ compound (≃nd z₁ z₂ l₁≃r₁ l₂≃r₂ l₁≃l₂)) l'≃r' (≃nd z₂ z₃ l₂≃r₂ l₃≃r₃ (trans≃ (sym≃ l₁≃l₂) l₁≃l₃)) ... | inj₂ y≤x | leaf | leaf | ≃lf | leaf | ≃lf = r⋘ y y' (⋙p (⋗lf x)) l'≃r' (⋗lf x) ... | inj₂ y≤x | node perfect z₁ _ _ | node perfect z₂ _ _ | ≃nd .z₁ .z₂ l₁≃r₁ l₂≃r₂ l₁≃l₂ | node perfect z₃ _ _ | ≃nd .z₁ .z₃ _ l₃≃r₃ l₁≃l₃ = l⋘ y y' (lemma-insert-≃ compound (≃nd z₁ z₂ l₁≃r₁ l₂≃r₂ l₁≃l₂)) l'≃r' (≃nd z₂ z₃ l₂≃r₂ l₃≃r₃ (trans≃ (sym≃ l₁≃l₂) l₁≃l₃)) lemma-insert-⋗' : {l r : PLRTree}(x : A) → l ⋗ r → Compound r → l ⋙ (insert x r) lemma-insert-⋗' x (⋗nd {l} {r} {l'} {r'} y y' l≃r l'≃r' l⋗l') compound with tot≤ x y' | l' | r' | l'≃r' | l | l⋗l' ... | inj₁ x≤y' | leaf | leaf | ≃lf | node perfect x₁ leaf leaf | ⋗lf .x₁ = ⋙r y x l≃r (⋙p (⋗lf y')) (≃nd x₁ y' ≃lf ≃lf ≃lf) ... | inj₁ x≤y' | node perfect x₃ l₃ r₃ | node perfect x₄ l₄ r₄ | ≃nd .x₃ .x₄ l₃≃r₃ l₄≃r₄ l₃≃l₄ | node perfect x₁ l₁ r₁ | ⋗nd .x₁ .x₃ l₁≃r₁ _ l₁⋗l₃ with tot≤ y' x₃ | l₃ | r₃ | l₃≃r₃ | l₁ | l₁⋗l₃ ... | inj₁ y'≤x₃ | leaf | leaf | ≃lf | node perfect x'₁ leaf leaf | ⋗lf .x'₁ with l₄ | l₃≃l₄ ... | leaf | ≃lf = let _l'ᵢ⋘r' = r⋘ y' x₄ (⋙p (⋗lf x₃)) l₄≃r₄ (⋗lf x₃) ; _l⋗r' = lemma-⋗-≃ (⋗nd x₁ y' l₁≃r₁ ≃lf (⋗lf x'₁)) (≃nd y' x₄ ≃lf l₄≃r₄ ≃lf) in ⋙l y x l≃r _l'ᵢ⋘r' _l⋗r' lemma-insert-⋗' x (⋗nd y y' l≃r _ _) compound | inj₁ x≤y' | node perfect x₃ _ _ | node perfect x₄ _ _ | ≃nd .x₃ .x₄ _ l₄≃r₄ l₃≃l₄ | node perfect x₁ _ _ | ⋗nd .x₁ .x₃ l₁≃r₁ _ _ | inj₁ y'≤x₃ | node perfect x'₅ _ _ | node perfect x'₆ _ _ | ≃nd .x'₅ .x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆ | node perfect x'₁ _ _ | ⋗nd .x'₁ .x'₅ l'₁≃r'₁ _ l'₁⋗l'₅ with lemma-⋙-⋗ (lemma-insert-⋗' x₃ (⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅) compound) (lemma-⋗-≃ (⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅) (≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆)) ... | inj₁ _l₃ᵢ⋘r₃ = let _l₁⋗l₃ = ⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅ ; _l₃≃r₃ = ≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆ ; _l'ᵢ⋘r' = l⋘ y' x₄ _l₃ᵢ⋘r₃ l₄≃r₄ (trans≃ (sym≃ _l₃≃r₃) l₃≃l₄) ; _l⋗r' = lemma-⋗-≃ (⋗nd x₁ x₃ l₁≃r₁ _l₃≃r₃ _l₁⋗l₃) (≃nd x₃ x₄ _l₃≃r₃ l₄≃r₄ l₃≃l₄) in ⋙l y x l≃r _l'ᵢ⋘r' _l⋗r' ... | inj₂ _l₃ᵢ≃r₃ with lemma-≃-⊥ x₃ (trans≃ (≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆ ) (sym≃ _l₃ᵢ≃r₃)) ... | () lemma-insert-⋗' x (⋗nd y y' l≃r _ _) compound | inj₁ x≤y' | node perfect x₃ _ _ | node perfect x₄ l₄ _ | ≃nd .x₃ .x₄ _ l₄≃r₄ l₃≃l₄ | node perfect x₁ _ _ | ⋗nd .x₁ .x₃ l₁≃r₁ _ l₁⋗l₃ | inj₂ x₃≤y' | leaf | leaf | ≃lf | node perfect x'₁ leaf leaf | ⋗lf .x'₁ with l₄ | l₃≃l₄ ... | leaf | ≃lf = let _l'ᵢ⋘r' = r⋘ x₃ x₄ (⋙p (⋗lf y')) l₄≃r₄ (⋗lf y') ; _l⋗r' = lemma-⋗-≃ (⋗nd x₁ x₃ l₁≃r₁ ≃lf (⋗lf x'₁)) (≃nd x₃ x₄ ≃lf l₄≃r₄ ≃lf) in ⋙l y x l≃r _l'ᵢ⋘r' _l⋗r' lemma-insert-⋗' x (⋗nd y y' l≃r _ _) compound | inj₁ x≤y' | node perfect x₃ _ _ | node perfect x₄ _ _ | ≃nd .x₃ .x₄ l₃≃r₃ l₄≃r₄ l₃≃l₄ | node perfect x₁ _ _ | ⋗nd .x₁ .x₃ l₁≃r₁ _ l₁⋗l₃ | inj₂ x₃≤y' | node perfect x'₅ _ _ | node perfect x'₆ _ _ | ≃nd .x'₅ .x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆ | node perfect x'₁ _ _ | ⋗nd .x'₁ .x'₅ l'₁≃r'₁ _ l'₁⋗l'₅ with lemma-⋙-⋗ (lemma-insert-⋗' y' (⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅) compound) (lemma-⋗-≃ (⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅) (≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆)) ... | inj₁ _l₃ᵢ⋘r₃ = let _l₁⋗l₃ = ⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅ ; _l₃≃r₃ = ≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆ ; _l'ᵢ⋘r' = l⋘ x₃ x₄ _l₃ᵢ⋘r₃ l₄≃r₄ (trans≃ (sym≃ _l₃≃r₃) l₃≃l₄) ; _l⋗r' = lemma-⋗-≃ (⋗nd x₁ x₃ l₁≃r₁ _l₃≃r₃ _l₁⋗l₃) (≃nd x₃ x₄ _l₃≃r₃ l₄≃r₄ l₃≃l₄) in ⋙l y x l≃r _l'ᵢ⋘r' _l⋗r' ... | inj₂ _l₃ᵢ≃r₃ with lemma-≃-⊥ y' (trans≃ (≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆ ) (sym≃ _l₃ᵢ≃r₃)) ... | () lemma-insert-⋗' x (⋗nd y y' l≃r l'≃r' l⋗l') compound | inj₂ y'≤x | leaf | leaf | ≃lf | node perfect x₁ leaf leaf | ⋗lf .x₁ = ⋙r y y' l≃r (⋙p (⋗lf x)) (≃nd x₁ x ≃lf ≃lf ≃lf) lemma-insert-⋗' x (⋗nd y y' l≃r _ _) compound | inj₂ y'≤x | node perfect x₃ l₃ r₃ | node perfect x₄ l₄ _ | ≃nd .x₃ .x₄ l₃≃r₃ l₄≃r₄ l₃≃l₄ | node perfect x₁ l₁ _ | ⋗nd .x₁ .x₃ l₁≃r₁ _ l₁⋗l₃ with tot≤ x x₃ | l₃ | r₃ | l₃≃r₃ | l₁ | l₁⋗l₃ ... | inj₁ x≤x₃ | leaf | leaf | ≃lf | node perfect x'₁ leaf leaf | ⋗lf .x'₁ with l₄ | l₃≃l₄ ... | leaf | ≃lf = let _l'ᵢ⋘r' = r⋘ x x₄ (⋙p (⋗lf x₃)) l₄≃r₄ (⋗lf x₃) ; _l⋗r' = lemma-⋗-≃ (⋗nd x₁ x l₁≃r₁ ≃lf (⋗lf x'₁)) (≃nd x x₄ ≃lf l₄≃r₄ ≃lf) in ⋙l y y' l≃r _l'ᵢ⋘r' _l⋗r' lemma-insert-⋗' x (⋗nd y y' l≃r _ _) compound | inj₂ y'≤x | node perfect x₃ _ _ | node perfect x₄ _ _ | ≃nd .x₃ .x₄ _ l₄≃r₄ l₃≃l₄ | node perfect x₁ _ _ | ⋗nd .x₁ .x₃ l₁≃r₁ _ _ | inj₁ x≤x₃ | node perfect x'₅ _ _ | node perfect x'₆ _ _ | ≃nd .x'₅ .x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆ | node perfect x'₁ _ _ | ⋗nd .x'₁ .x'₅ l'₁≃r'₁ _ l'₁⋗l'₅ with lemma-⋙-⋗ (lemma-insert-⋗' x₃ (⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅) compound) (lemma-⋗-≃ (⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅) (≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆)) ... | inj₁ _l₃ᵢ⋘r₃ = let _l₁⋗l₃ = ⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅ ; _l₃≃r₃ = ≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆ ; _l'ᵢ⋘r' = l⋘ x x₄ _l₃ᵢ⋘r₃ l₄≃r₄ (trans≃ (sym≃ _l₃≃r₃) l₃≃l₄) ; _l⋗r' = lemma-⋗-≃ (⋗nd x₁ x₃ l₁≃r₁ _l₃≃r₃ _l₁⋗l₃) (≃nd x₃ x₄ _l₃≃r₃ l₄≃r₄ l₃≃l₄) in ⋙l y y' l≃r _l'ᵢ⋘r' _l⋗r' ... | inj₂ _l₃ᵢ≃r₃ with lemma-≃-⊥ x₃ (trans≃ (≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆ ) (sym≃ _l₃ᵢ≃r₃)) ... | () lemma-insert-⋗' x (⋗nd y y' l≃r _ _) compound | inj₂ y'≤x | node perfect x₃ _ _ | node perfect x₄ l₄ _ | ≃nd .x₃ .x₄ _ l₄≃r₄ l₃≃l₄ | node perfect x₁ _ _ | ⋗nd .x₁ .x₃ l₁≃r₁ _ _ | inj₂ x₃≤x | leaf | leaf | ≃lf | node perfect x'₁ leaf leaf | ⋗lf .x'₁ with l₄ | l₃≃l₄ ... | leaf | ≃lf = let _l'ᵢ⋘r' = r⋘ x₃ x₄ (⋙p (⋗lf x)) l₄≃r₄ (⋗lf x) ; _l⋗r' = lemma-⋗-≃ (⋗nd x₁ x₃ l₁≃r₁ ≃lf (⋗lf x'₁)) (≃nd x₃ x₄ ≃lf l₄≃r₄ ≃lf) in ⋙l y y' l≃r _l'ᵢ⋘r' _l⋗r' lemma-insert-⋗' x (⋗nd y y' l≃r _ _) compound | inj₂ y'≤x | node perfect x₃ _ _ | node perfect x₄ _ _ | ≃nd .x₃ .x₄ _ l₄≃r₄ l₃≃l₄ | node perfect x₁ _ _ | ⋗nd .x₁ .x₃ l₁≃r₁ _ _ | inj₂ x₃≤x | node perfect x'₅ _ _ | node perfect x'₆ _ _ | ≃nd .x'₅ .x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆ | node perfect x'₁ _ _ | ⋗nd .x'₁ .x'₅ l'₁≃r'₁ _ l'₁⋗l'₅ with lemma-⋙-⋗ (lemma-insert-⋗' x (⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅) compound) (lemma-⋗-≃ (⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅) (≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆)) ... | inj₁ _l₃ᵢ⋘r₃ = let _l₁⋗l₃ = ⋗nd x'₁ x'₅ l'₁≃r'₁ l'₅≃r'₅ l'₁⋗l'₅ ; _l₃≃r₃ = ≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆ ; _l'ᵢ⋘r' = l⋘ x₃ x₄ _l₃ᵢ⋘r₃ l₄≃r₄ (trans≃ (sym≃ _l₃≃r₃) l₃≃l₄) ; _l⋗r' = lemma-⋗-≃ (⋗nd x₁ x₃ l₁≃r₁ _l₃≃r₃ _l₁⋗l₃) (≃nd x₃ x₄ _l₃≃r₃ l₄≃r₄ l₃≃l₄) in ⋙l y y' l≃r _l'ᵢ⋘r' _l⋗r' ... | inj₂ _l₃ᵢ≃r₃ with lemma-≃-⊥ x (trans≃ (≃nd x'₅ x'₆ l'₅≃r'₅ l'₆≃r'₆ l'₅≃l'₆) (sym≃ _l₃ᵢ≃r₃)) ... | () lemma-insert-⋗ : {l r : PLRTree}(x : A) → l ⋗ r → l ⋙ (insert x r) ∨ l ≃ (insert x r) lemma-insert-⋗ x (⋗lf y) = inj₂ (≃nd y x ≃lf ≃lf ≃lf) lemma-insert-⋗ x (⋗nd y y' l≃r l'≃r' l⋗l') = inj₁ (lemma-insert-⋗' x (⋗nd y y' l≃r l'≃r' l⋗l') compound) mutual lemma-insert-⋘ : {l r : PLRTree}(x : A) → l ⋘ r → (insert x l) ⋘ r ∨ (insert x l) ⋗ r lemma-insert-⋘ x (x⋘ u v w) with tot≤ x u ... | inj₁ x≤u = inj₂ (⋗nd x w (≃nd v u ≃lf ≃lf ≃lf) ≃lf (⋗lf v)) ... | inj₂ u≤x = inj₂ (⋗nd u w (≃nd v x ≃lf ≃lf ≃lf) ≃lf (⋗lf v)) lemma-insert-⋘ x (l⋘ {l = l} y y' l⋘r l'≃r' r≃l') with tot≤ x y ... | inj₁ x≤y with insert y l | lemma-insert-compound y l | lemma-insert-⋘ y l⋘r ... | node left _ _ _ | compound | inj₁ lᵢ⋘r = inj₁ (l⋘ x y' lᵢ⋘r l'≃r' r≃l') ... | node left _ _ _ | compound | inj₂ () ... | node right _ _ _ | compound | inj₁ lᵢ⋙r = inj₁ (l⋘ x y' lᵢ⋙r l'≃r' r≃l') ... | node right _ _ _ | compound | inj₂ () ... | node perfect _ _ _ | compound | inj₂ lᵢ⋗r = inj₁ (r⋘ x y' (⋙p lᵢ⋗r) l'≃r' (lemma-⋗-≃ lᵢ⋗r r≃l')) ... | node perfect _ _ _ | compound | inj₁ () lemma-insert-⋘ x (l⋘ {l = l} y y' l⋘r l'≃r' r≃l') | inj₂ y≤x with insert x l | lemma-insert-compound x l | lemma-insert-⋘ x l⋘r ... | node left _ _ _ | compound | inj₁ lᵢ⋘r = inj₁ (l⋘ y y' lᵢ⋘r l'≃r' r≃l') ... | node left _ _ _ | compound | inj₂ () ... | node right _ _ _ | compound | inj₁ lᵢ⋘r = inj₁ (l⋘ y y' lᵢ⋘r l'≃r' r≃l') ... | node right _ _ _ | compound | inj₂ () ... | node perfect _ _ _ | compound | inj₂ lᵢ⋗r = inj₁ (r⋘ y y' (⋙p lᵢ⋗r) l'≃r' (lemma-⋗-≃ lᵢ⋗r r≃l')) ... | node perfect _ _ _ | compound | inj₁ () lemma-insert-⋘ x (r⋘ {r = r} y y' l⋙r l'≃r' l⋗l') with tot≤ x y ... | inj₁ x≤y with insert y r | lemma-insert-compound y r | lemma-insert-⋙ y l⋙r | lemma-⋙-⊥ y l⋙r ... | node left _ _ _ | compound | inj₁ l⋙rᵢ | _ = inj₁ (r⋘ x y' l⋙rᵢ l'≃r' l⋗l') ... | node left _ _ _ | compound | inj₂ () | _ ... | node right _ _ _ | compound | inj₁ l⋙rᵢ | _ = inj₁ (r⋘ x y' l⋙rᵢ l'≃r' l⋗l') ... | node right _ _ _ | compound | inj₂ () | _ ... | node perfect _ _ _ | compound | inj₂ l≃rᵢ | _ = inj₂ (⋗nd x y' l≃rᵢ l'≃r' l⋗l') ... | node perfect _ _ _ | compound | inj₁ (⋙p l⋗rᵢ) | lemma-⋙-⊥' with lemma-⋙-⊥' l⋗rᵢ ... | () lemma-insert-⋘ x (r⋘ {r = r} y y' l⋙r l'≃r' l⋗l') | inj₂ y'≤x with insert x r | lemma-insert-compound x r | lemma-insert-⋙ x l⋙r | lemma-⋙-⊥ x l⋙r ... | node left _ _ _ | compound | inj₁ l⋙rᵢ | _ = inj₁ (r⋘ y y' l⋙rᵢ l'≃r' l⋗l') ... | node left _ _ _ | compound | inj₂ () | _ ... | node right _ _ _ | compound | inj₁ l⋙rᵢ | _ = inj₁ (r⋘ y y' l⋙rᵢ l'≃r' l⋗l') ... | node right _ _ _ | compound | inj₂ () | _ ... | node perfect _ _ _ | compound | inj₂ l≃rᵢ | _ = inj₂ (⋗nd y y' l≃rᵢ l'≃r' l⋗l') ... | node perfect _ _ _ | compound | inj₁ (⋙p l⋗rᵢ) | lemma-⋙-⊥' with lemma-⋙-⊥' l⋗rᵢ ... | () lemma-insert-⋙ : {l r : PLRTree}(x : A) → l ⋙ r → l ⋙ (insert x r) ∨ l ≃ (insert x r) lemma-insert-⋙ x (⋙p l⋗r) = lemma-insert-⋗ x l⋗r lemma-insert-⋙ x (⋙l {l' = l'} y y' l≃r l'⋘r' l⋗r') with tot≤ x y' ... | inj₁ x≤y' with insert y' l' | lemma-insert-compound y' l' | lemma-insert-⋘ y' l'⋘r' ... | node left _ _ _ | compound | inj₁ l'ᵢ⋘r' = inj₁ (⋙l y x l≃r l'ᵢ⋘r' l⋗r') ... | node left _ _ _ | compound | inj₂ () ... | node right _ _ _ | compound | inj₁ l'ᵢ⋙r' = inj₁ (⋙l y x l≃r l'ᵢ⋙r' l⋗r') ... | node right _ _ _ | compound | inj₂ () ... | node perfect _ _ _ | compound | inj₂ l'ᵢ⋗r' = inj₁ (⋙r y x l≃r (⋙p l'ᵢ⋗r') (lemma-*⋗ l⋗r' l'ᵢ⋗r')) ... | node perfect _ _ _ | compound | inj₁ () lemma-insert-⋙ x (⋙l {l' = l'} y y' l≃r l'⋘r' l⋗r') | inj₂ y'≤x with insert x l' | lemma-insert-compound x l' | lemma-insert-⋘ x l'⋘r' ... | node left _ _ _ | compound | inj₁ l'ᵢ⋘r' = inj₁ (⋙l y y' l≃r l'ᵢ⋘r' l⋗r') ... | node left _ _ _ | compound | inj₂ () ... | node right _ _ _ | compound | inj₁ l'ᵢ⋘r' = inj₁ (⋙l y y' l≃r l'ᵢ⋘r' l⋗r') ... | node right _ _ _ | compound | inj₂ () ... | node perfect _ _ _ | compound | inj₂ l'ᵢ⋗r' = inj₁ (⋙r y y' l≃r (⋙p l'ᵢ⋗r') (lemma-*⋗ l⋗r' l'ᵢ⋗r')) ... | node perfect _ _ _ | compound | inj₁ () lemma-insert-⋙ x (⋙r {r' = r'} y y' l≃r l'⋙r' l≃l') with tot≤ x y' ... | inj₁ x≤y' with insert y' r' | lemma-insert-compound y' r' | lemma-insert-⋙ y' l'⋙r' | lemma-⋙-⊥ y' l'⋙r' ... | node left _ _ _ | compound | inj₁ l'⋙r'ᵢ | _ = inj₁ (⋙r y x l≃r l'⋙r'ᵢ l≃l') ... | node left _ _ _ | compound | inj₂ () | _ ... | node right _ _ _ | compound | inj₁ l'⋙r'ᵢ | _ = inj₁ (⋙r y x l≃r l'⋙r'ᵢ l≃l') ... | node right _ _ _ | compound | inj₂ () | _ ... | node perfect _ _ _ | compound | inj₂ l'≃r'ᵢ | _ = inj₂ (≃nd y x l≃r l'≃r'ᵢ l≃l') ... | node perfect _ _ _ | compound | inj₁ (⋙p l'⋗r'ᵢ) | lemma-⋙-⊥' with lemma-⋙-⊥' l'⋗r'ᵢ ... | () lemma-insert-⋙ x (⋙r {r' = r'} y y' l≃r l'⋙r' l≃l') | inj₂ y'≤x with insert x r' | lemma-insert-compound x r' | lemma-insert-⋙ x l'⋙r' | lemma-⋙-⊥ x l'⋙r' ... | node left _ _ _ | compound | inj₁ l'⋙r'ᵢ | _ = inj₁ (⋙r y y' l≃r l'⋙r'ᵢ l≃l') ... | node left _ _ _ | compound | inj₂ () | _ ... | node right _ _ _ | compound | inj₁ l'⋙r'ᵢ | _ = inj₁ (⋙r y y' l≃r l'⋙r'ᵢ l≃l') ... | node right _ _ _ | compound | inj₂ () | _ ... | node perfect _ _ _ | compound | inj₂ l'≃r'ᵢ | _ = inj₂ (≃nd y y' l≃r l'≃r'ᵢ l≃l') ... | node perfect _ _ _ | compound | inj₁ (⋙p l'⋗r'ᵢ) | lemma-⋙-⊥' with lemma-⋙-⊥' l'⋗r'ᵢ ... | () lemma-insert-complete : {t : PLRTree}(x : A) → Complete t → Complete (insert x t) lemma-insert-complete x leaf = perfect x leaf leaf ≃lf lemma-insert-complete x (perfect {l} {r} y cl cr l≃r) with tot≤ x y | l | r | l≃r | lemma-insert-complete y cl | lemma-insert-complete x cl ... | inj₁ x≤y | leaf | leaf | ≃lf | _ | _ = right x (perfect y cr cr ≃lf) cr (⋙p (⋗lf y)) ... | inj₁ x≤y | node perfect z' _ _ | node perfect z'' _ _ | ≃nd .z' .z'' l'≃r' l''≃r'' l'≃l'' | clᵢ | _ = left x clᵢ cr (lemma-insert-≃ compound (≃nd z' z'' l'≃r' l''≃r'' l'≃l'')) ... | inj₂ y≤x | leaf | leaf | ≃lf | _ | _ = right y (perfect x cr cr ≃lf) cr (⋙p (⋗lf x)) ... | inj₂ y≤x | node perfect z' _ _ | node perfect z'' _ _ | ≃nd .z' .z'' l'≃r' l''≃r'' l'≃l'' | _ | clᵢ = left y clᵢ cr (lemma-insert-≃ compound (≃nd z' z'' l'≃r' l''≃r'' l'≃l'')) lemma-insert-complete x (left {l} {r} y cl cr l⋘r) with tot≤ x y ... | inj₁ x≤y with insert y l | lemma-insert-complete y cl | lemma-insert-⋘ y l⋘r | lemma-insert-compound y l ... | node left _ _ _ | clᵢ | inj₁ lᵢ⋘r | compound = left x clᵢ cr lᵢ⋘r ... | node right _ _ _ | clᵢ | inj₁ lᵢ⋘r | compound = left x clᵢ cr lᵢ⋘r ... | node left _ _ _ | _ | inj₂ () | compound ... | node right _ _ _ | _ | inj₂ () | compound ... | node perfect _ _ _ | clᵢ | inj₂ lᵢ⋗r | compound = right x clᵢ cr (⋙p lᵢ⋗r) ... | node perfect x' l' r' | perfect .x' cl' cr' l'≃r' | inj₁ () | compound lemma-insert-complete x (left {l} {r} y cl cr l⋘r) | inj₂ y≤x with insert x l | lemma-insert-complete x cl | lemma-insert-⋘ x l⋘r | lemma-insert-compound x l ... | node left _ _ _ | clᵢ | inj₁ lᵢ⋘r | compound = left y clᵢ cr lᵢ⋘r ... | node right _ _ _ | clᵢ | inj₁ lᵢ⋘r | compound = left y clᵢ cr lᵢ⋘r ... | node left _ _ _ | _ | inj₂ () | compound ... | node right _ _ _ | _ | inj₂ () | compound ... | node perfect _ _ _ | clᵢ | inj₂ lᵢ⋗r | compound = right y clᵢ cr (⋙p lᵢ⋗r) ... | node perfect x' l' r' | perfect .x' cl' cr' l'≃r' | inj₁ () | compound lemma-insert-complete x (right {l} {r} y cl cr l⋙r) with tot≤ x y ... | inj₁ x≤y with insert y r | lemma-insert-complete y cr | lemma-insert-⋙ y l⋙r | lemma-insert-compound y r | lemma-⋙-⊥ y l⋙r ... | node left _ _ _ | crᵢ | inj₁ l⋙rᵢ | compound | _ = right x cl crᵢ l⋙rᵢ ... | node right _ _ _ | crᵢ | inj₁ l⋙rᵢ | compound | _ = right x cl crᵢ l⋙rᵢ ... | node left _ _ _ | _ | inj₂ () | compound | _ ... | node right _ _ _ | _ | inj₂ () | compound | _ ... | node perfect _ _ _ | crᵢ | inj₂ l≃rᵢ | compound | _ = perfect x cl crᵢ l≃rᵢ ... | node perfect x'' l'' r'' | perfect .x'' cl'' cr'' l''≃r'' | inj₁ (⋙p l⋗rᵢ) | compound | lemma-⋙-⊥' with lemma-⋙-⊥' l⋗rᵢ ... | () lemma-insert-complete x (right {l} {r} y cl cr l⋙r) | inj₂ y≤x with insert x r | lemma-insert-complete x cr | lemma-insert-⋙ x l⋙r | lemma-insert-compound x r | lemma-⋙-⊥ x l⋙r ... | node left _ _ _ | crᵢ | inj₁ l⋙rᵢ | compound | _ = right y cl crᵢ l⋙rᵢ ... | node right _ _ _ | crᵢ | inj₁ l⋙rᵢ | compound | _ = right y cl crᵢ l⋙rᵢ ... | node left _ _ _ | _ | inj₂ () | compound | _ ... | node right _ _ _ | _ | inj₂ () | compound | _ ... | node perfect _ _ _ | crᵢ | inj₂ l≃rᵢ | compound | _ = perfect y cl crᵢ l≃rᵢ ... | node perfect x'' l'' r'' | perfect .x'' cl'' cr'' l''≃r'' | inj₁ (⋙p l⋗rᵢ) | compound | lemma-⋙-⊥' with lemma-⋙-⊥' l⋗rᵢ ... | ()
{ "alphanum_fraction": 0.5004095423, "avg_line_length": 63.8366013072, "ext": "agda", "hexsha": "a0375ce7d7ac4e68781ff42b29dba42d6fe441d8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/PLRTree/Insert/Complete.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/PLRTree/Insert/Complete.agda", "max_line_length": 340, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/PLRTree/Insert/Complete.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 11481, "size": 19534 }
data Bool : Set where true false : Bool postulate and : Bool → Bool → Bool -- WAS: splitting on y removes the x@ as-pattern test : Bool → Bool → Bool test x@true y = {!y!} test x@false y = and x {!y!} -- x will go out of scope if we split on y -- Multiple as-patterns on the same pattern should be preserved in the -- right order. test₂ : Bool → Bool → Bool test₂ x@y@true z = {!z!} test₂ x@y z = {!!} open import Agda.Builtin.String -- As bindings on literals should also be preserved test₃ : String → Bool → Bool test₃ x@"foo" z = {!z!} test₃ _ _ = {!!}
{ "alphanum_fraction": 0.6507936508, "avg_line_length": 23.625, "ext": "agda", "hexsha": "9ca75d4e4e56bde1c9dc0d8db25411c55f34199e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue2414.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue2414.agda", "max_line_length": 72, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue2414.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 181, "size": 567 }
{-# OPTIONS --without-K --exact-split --allow-unsolved-metas #-} module 12-univalence where import 11-function-extensionality open 11-function-extensionality public -- Section 10.1 Type extensionality equiv-eq : {i : Level} {A : UU i} {B : UU i} → Id A B → A ≃ B equiv-eq {A = A} refl = equiv-id A UNIVALENCE : {i : Level} (A B : UU i) → UU (lsuc i) UNIVALENCE A B = is-equiv (equiv-eq {A = A} {B = B}) is-contr-total-equiv-UNIVALENCE : {i : Level} (A : UU i) → ((B : UU i) → UNIVALENCE A B) → is-contr (Σ (UU i) (λ X → A ≃ X)) is-contr-total-equiv-UNIVALENCE A UA = fundamental-theorem-id' A ( equiv-id A) ( λ B → equiv-eq {B = B}) ( UA) UNIVALENCE-is-contr-total-equiv : {i : Level} (A : UU i) → is-contr (Σ (UU i) (λ X → A ≃ X)) → (B : UU i) → UNIVALENCE A B UNIVALENCE-is-contr-total-equiv A c = fundamental-theorem-id A ( equiv-id A) ( c) ( λ B → equiv-eq {B = B}) ev-id : {i j : Level} {A : UU i} (P : (B : UU i) → (A ≃ B) → UU j) → ((B : UU i) (e : A ≃ B) → P B e) → P A (equiv-id A) ev-id {A = A} P f = f A (equiv-id A) IND-EQUIV : {i j : Level} {A : UU i} → ((B : UU i) (e : A ≃ B) → UU j) → UU _ IND-EQUIV P = sec (ev-id P) triangle-ev-id : {i j : Level} {A : UU i} (P : (Σ (UU i) (λ X → A ≃ X)) → UU j) → (ev-pt (Σ (UU i) (λ X → A ≃ X)) (pair A (equiv-id A)) P) ~ ((ev-id (λ X e → P (pair X e))) ∘ (ev-pair {A = UU i} {B = λ X → A ≃ X} {C = P})) triangle-ev-id P f = refl abstract IND-EQUIV-is-contr-total-equiv : {i j : Level} (A : UU i) → is-contr (Σ (UU i) (λ X → A ≃ X)) → (P : (Σ (UU i) (λ X → A ≃ X)) → UU j) → IND-EQUIV (λ B e → P (pair B e)) IND-EQUIV-is-contr-total-equiv {i} {j} A c P = section-comp ( ev-pt (Σ (UU i) (λ X → A ≃ X)) (pair A (equiv-id A)) P) ( ev-id (λ X e → P (pair X e))) ( ev-pair {A = UU i} {B = λ X → A ≃ X} {C = P}) ( triangle-ev-id P) ( sec-ev-pair (UU i) (λ X → A ≃ X) P) ( is-sing-is-contr (Σ (UU i) (λ X → A ≃ X)) ( pair ( pair A (equiv-id A)) ( λ t → ( inv (contraction c (pair A (equiv-id A)))) ∙ ( contraction c t))) ( P) ( pair A (equiv-id A))) abstract is-contr-total-equiv-IND-EQUIV : {i : Level} (A : UU i) → ( {j : Level} (P : (Σ (UU i) (λ X → A ≃ X)) → UU j) → IND-EQUIV (λ B e → P (pair B e))) → is-contr (Σ (UU i) (λ X → A ≃ X)) is-contr-total-equiv-IND-EQUIV {i} A ind = is-contr-is-sing ( Σ (UU i) (λ X → A ≃ X)) ( pair A (equiv-id A)) ( λ P → section-comp' ( ev-pt (Σ (UU i) (λ X → A ≃ X)) (pair A (equiv-id A)) P) ( ev-id (λ X e → P (pair X e))) ( ev-pair {A = UU i} {B = λ X → A ≃ X} {C = P}) ( triangle-ev-id P) ( sec-ev-pair (UU i) (λ X → A ≃ X) P) ( ind P)) -- The univalence axiom postulate univalence : {i : Level} (A B : UU i) → UNIVALENCE A B eq-equiv : {i : Level} (A B : UU i) → (A ≃ B) → Id A B eq-equiv A B = inv-is-equiv (univalence A B) abstract is-contr-total-equiv : {i : Level} (A : UU i) → is-contr (Σ (UU i) (λ X → A ≃ X)) is-contr-total-equiv A = is-contr-total-equiv-UNIVALENCE A (univalence A) inv-inv-equiv : {i j : Level} {A : UU i} {B : UU j} (e : A ≃ B) → Id (inv-equiv (inv-equiv e)) e inv-inv-equiv (pair f (pair (pair g G) (pair h H))) = eq-htpy-equiv refl-htpy is-equiv-inv-equiv : {i j : Level} {A : UU i} {B : UU j} → is-equiv (inv-equiv {A = A} {B = B}) is-equiv-inv-equiv = is-equiv-has-inverse ( inv-equiv) ( inv-inv-equiv) ( inv-inv-equiv) equiv-inv-equiv : {i j : Level} {A : UU i} {B : UU j} → (A ≃ B) ≃ (B ≃ A) equiv-inv-equiv = pair inv-equiv is-equiv-inv-equiv is-contr-total-equiv' : {i : Level} (A : UU i) → is-contr (Σ (UU i) (λ X → X ≃ A)) is-contr-total-equiv' A = is-contr-equiv ( Σ (UU _) (λ X → A ≃ X)) ( equiv-tot (λ X → equiv-inv-equiv)) ( is-contr-total-equiv A) abstract Ind-equiv : {i j : Level} (A : UU i) (P : (B : UU i) (e : A ≃ B) → UU j) → sec (ev-id P) Ind-equiv A P = IND-EQUIV-is-contr-total-equiv A ( is-contr-total-equiv A) ( λ t → P (pr1 t) (pr2 t)) ind-equiv : {i j : Level} (A : UU i) (P : (B : UU i) (e : A ≃ B) → UU j) → P A (equiv-id A) → {B : UU i} (e : A ≃ B) → P B e ind-equiv A P p {B} = pr1 (Ind-equiv A P) p B -- Subuniverses is-subuniverse : {l1 l2 : Level} (P : UU l1 → UU l2) → UU ((lsuc l1) ⊔ l2) is-subuniverse P = is-subtype P subuniverse : (l1 l2 : Level) → UU ((lsuc l1) ⊔ (lsuc l2)) subuniverse l1 l2 = Σ (UU l1 → UU l2) is-subuniverse {- By univalence, subuniverses are closed under equivalences. -} in-subuniverse-equiv : {l1 l2 : Level} (P : UU l1 → UU l2) {X Y : UU l1} → X ≃ Y → P X → P Y in-subuniverse-equiv P e = tr P (eq-equiv _ _ e) in-subuniverse-equiv' : {l1 l2 : Level} (P : UU l1 → UU l2) {X Y : UU l1} → X ≃ Y → P Y → P X in-subuniverse-equiv' P e = tr P (inv (eq-equiv _ _ e)) total-subuniverse : {l1 l2 : Level} (P : subuniverse l1 l2) → UU ((lsuc l1) ⊔ l2) total-subuniverse {l1} P = Σ (UU l1) (pr1 P) {- We also introduce the notion of 'global subuniverse'. The handling of universe levels is a bit more complicated here, since (l : Level) → A l are kinds but not types. -} is-global-subuniverse : (α : Level → Level) (P : (l : Level) → subuniverse l (α l)) → (l1 l2 : Level) → UU _ is-global-subuniverse α P l1 l2 = (X : UU l1) (Y : UU l2) → X ≃ Y → (pr1 (P l1)) X → (pr1 (P l2)) Y {- Next we characterize the identity type of a subuniverse. -} Eq-total-subuniverse : {l1 l2 : Level} (P : subuniverse l1 l2) → (s t : total-subuniverse P) → UU l1 Eq-total-subuniverse (pair P H) (pair X p) t = X ≃ (pr1 t) Eq-total-subuniverse-eq : {l1 l2 : Level} (P : subuniverse l1 l2) → (s t : total-subuniverse P) → Id s t → Eq-total-subuniverse P s t Eq-total-subuniverse-eq (pair P H) (pair X p) .(pair X p) refl = equiv-id X abstract is-contr-total-Eq-total-subuniverse : {l1 l2 : Level} (P : subuniverse l1 l2) (s : total-subuniverse P) → is-contr (Σ (total-subuniverse P) (λ t → Eq-total-subuniverse P s t)) is-contr-total-Eq-total-subuniverse (pair P H) (pair X p) = is-contr-total-Eq-substructure (is-contr-total-equiv X) H X (equiv-id X) p abstract is-equiv-Eq-total-subuniverse-eq : {l1 l2 : Level} (P : subuniverse l1 l2) (s t : total-subuniverse P) → is-equiv (Eq-total-subuniverse-eq P s t) is-equiv-Eq-total-subuniverse-eq (pair P H) (pair X p) = fundamental-theorem-id ( pair X p) ( equiv-id X) ( is-contr-total-Eq-total-subuniverse (pair P H) (pair X p)) ( Eq-total-subuniverse-eq (pair P H) (pair X p)) eq-Eq-total-subuniverse : {l1 l2 : Level} (P : subuniverse l1 l2) → {s t : total-subuniverse P} → Eq-total-subuniverse P s t → Id s t eq-Eq-total-subuniverse P {s} {t} = inv-is-equiv (is-equiv-Eq-total-subuniverse-eq P s t) -- Section 12.2 Univalence implies function extensionality is-equiv-postcomp-univalence : {l1 l2 : Level} {X Y : UU l1} (A : UU l2) (e : X ≃ Y) → is-equiv (postcomp A (map-equiv e)) is-equiv-postcomp-univalence {X = X} A = ind-equiv X ( λ Y e → is-equiv (postcomp A (map-equiv e))) ( is-equiv-id (A → X)) weak-funext-univalence : {l : Level} {A : UU l} {B : A → UU l} → WEAK-FUNEXT A B weak-funext-univalence {A = A} {B} is-contr-B = is-contr-retract-of ( fib (postcomp A (pr1 {B = B})) id) ( pair ( λ f → pair (λ x → pair x (f x)) refl) ( pair ( λ h x → tr B (htpy-eq (pr2 h) x) (pr2 (pr1 h x))) ( refl-htpy))) ( is-contr-map-is-equiv ( is-equiv-postcomp-univalence A (equiv-pr1 is-contr-B)) ( id)) funext-univalence : {l : Level} {A : UU l} {B : A → UU l} (f : (x : A) → B x) → FUNEXT f funext-univalence {A = A} {B} f = FUNEXT-WEAK-FUNEXT (λ A B → weak-funext-univalence) A B f -- Exercises -- Exercise 10.1 tr-equiv-eq-ap : {l1 l2 : Level} {A : UU l1} {B : A → UU l2} {x y : A} (p : Id x y) → (map-equiv (equiv-eq (ap B p))) ~ tr B p tr-equiv-eq-ap refl = refl-htpy -- Exercise 10.2 subuniverse-is-contr : {i : Level} → subuniverse i i subuniverse-is-contr {i} = pair is-contr is-subtype-is-contr unit' : (i : Level) → UU i unit' i = pr1 (Raise i unit) abstract is-contr-unit' : (i : Level) → is-contr (unit' i) is-contr-unit' i = is-contr-equiv' unit (pr2 (Raise i unit)) is-contr-unit abstract center-UU-contr : (i : Level) → total-subuniverse (subuniverse-is-contr {i}) center-UU-contr i = pair (unit' i) (is-contr-unit' i) contraction-UU-contr : {i : Level} (A : Σ (UU i) is-contr) → Id (center-UU-contr i) A contraction-UU-contr (pair A is-contr-A) = eq-Eq-total-subuniverse subuniverse-is-contr ( equiv-is-contr (is-contr-unit' _) is-contr-A) abstract is-contr-UU-contr : (i : Level) → is-contr (Σ (UU i) is-contr) is-contr-UU-contr i = pair (center-UU-contr i) (contraction-UU-contr) is-trunc-UU-trunc : (k : 𝕋) (i : Level) → is-trunc (succ-𝕋 k) (Σ (UU i) (is-trunc k)) is-trunc-UU-trunc k i X Y = is-trunc-is-equiv k ( Id (pr1 X) (pr1 Y)) ( ap pr1) ( is-emb-pr1-is-subtype ( is-prop-is-trunc k) X Y) ( is-trunc-is-equiv k ( (pr1 X) ≃ (pr1 Y)) ( equiv-eq) ( univalence (pr1 X) (pr1 Y)) ( is-trunc-equiv-is-trunc k (pr2 X) (pr2 Y))) ev-true-false : {l : Level} (A : UU l) → (f : bool → A) → A × A ev-true-false A f = pair (f true) (f false) map-universal-property-bool : {l : Level} {A : UU l} → A × A → (bool → A) map-universal-property-bool (pair x y) true = x map-universal-property-bool (pair x y) false = y issec-map-universal-property-bool : {l : Level} {A : UU l} → ((ev-true-false A) ∘ map-universal-property-bool) ~ id issec-map-universal-property-bool (pair x y) = eq-pair-triv (pair refl refl) isretr-map-universal-property-bool' : {l : Level} {A : UU l} (f : bool → A) → (map-universal-property-bool (ev-true-false A f)) ~ f isretr-map-universal-property-bool' f true = refl isretr-map-universal-property-bool' f false = refl isretr-map-universal-property-bool : {l : Level} {A : UU l} → (map-universal-property-bool ∘ (ev-true-false A)) ~ id isretr-map-universal-property-bool f = eq-htpy (isretr-map-universal-property-bool' f) universal-property-bool : {l : Level} (A : UU l) → is-equiv (λ (f : bool → A) → pair (f true) (f false)) universal-property-bool A = is-equiv-has-inverse map-universal-property-bool issec-map-universal-property-bool isretr-map-universal-property-bool ev-true : {l : Level} {A : UU l} → (bool → A) → A ev-true f = f true triangle-ev-true : {l : Level} (A : UU l) → (ev-true) ~ (pr1 ∘ (ev-true-false A)) triangle-ev-true A = refl-htpy aut-bool-bool : bool → (bool ≃ bool) aut-bool-bool true = equiv-id bool aut-bool-bool false = equiv-neg-𝟚 bool-aut-bool : (bool ≃ bool) → bool bool-aut-bool e = map-equiv e true decide-true-false : (b : bool) → coprod (Id b true) (Id b false) decide-true-false true = inl refl decide-true-false false = inr refl eq-false : (b : bool) → (¬ (Id b true)) → (Id b false) eq-false true p = ind-empty (p refl) eq-false false p = refl eq-true : (b : bool) → (¬ (Id b false)) → Id b true eq-true true p = refl eq-true false p = ind-empty (p refl) Eq-𝟚-eq : (x y : bool) → Id x y → Eq-𝟚 x y Eq-𝟚-eq x .x refl = reflexive-Eq-𝟚 x eq-false-equiv' : (e : bool ≃ bool) → Id (map-equiv e true) true → is-decidable (Id (map-equiv e false) false) → Id (map-equiv e false) false eq-false-equiv' e p (inl q) = q eq-false-equiv' e p (inr x) = ind-empty ( Eq-𝟚-eq true false ( ap pr1 ( is-prop-is-contr' ( is-contr-map-is-equiv (is-equiv-map-equiv e) true) ( pair true p) ( pair false (eq-true (map-equiv e false) x))))) {- eq-false-equiv : (e : bool ≃ bool) → Id (map-equiv e true) true → Id (map-equiv e false) false eq-false-equiv e p = eq-false-equiv' e p (has-decidable-equality-𝟚 (map-equiv e false) false) -} {- eq-true-equiv : (e : bool ≃ bool) → ¬ (Id (map-equiv e true) true) → Id (map-equiv e false) true eq-true-equiv e f = {!!} issec-bool-aut-bool' : ( e : bool ≃ bool) (d : is-decidable (Id (map-equiv e true) true)) → htpy-equiv (aut-bool-bool (bool-aut-bool e)) e issec-bool-aut-bool' e (inl p) true = ( htpy-equiv-eq (ap aut-bool-bool p) true) ∙ (inv p) issec-bool-aut-bool' e (inl p) false = ( htpy-equiv-eq (ap aut-bool-bool p) false) ∙ ( inv (eq-false-equiv e p)) issec-bool-aut-bool' e (inr f) true = ( htpy-equiv-eq ( ap aut-bool-bool (eq-false (map-equiv e true) f)) true) ∙ ( inv (eq-false (map-equiv e true) f)) issec-bool-aut-bool' e (inr f) false = ( htpy-equiv-eq (ap aut-bool-bool {!eq-true-equiv e ?!}) {!!}) ∙ ( inv {!!}) issec-bool-aut-bool : (aut-bool-bool ∘ bool-aut-bool) ~ id issec-bool-aut-bool e = eq-htpy-equiv ( issec-bool-aut-bool' e ( has-decidable-equality-𝟚 (map-equiv e true) true)) -}
{ "alphanum_fraction": 0.5734520124, "avg_line_length": 31.6666666667, "ext": "agda", "hexsha": "7153bfad9c70b0a1f5a6d45a77f57e52e5289b36", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "hemangandhi/HoTT-Intro", "max_forks_repo_path": "Agda/12-univalence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "hemangandhi/HoTT-Intro", "max_issues_repo_path": "Agda/12-univalence.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "hemangandhi/HoTT-Intro", "max_stars_repo_path": "Agda/12-univalence.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5120, "size": 12920 }
{-# OPTIONS --no-qualified-instances #-} module NoQualifiedInstances-Import where open import NoQualifiedInstances.Import.A as A postulate f : {{A.I}} → A.I test : A.I test = f
{ "alphanum_fraction": 0.7049180328, "avg_line_length": 15.25, "ext": "agda", "hexsha": "d40f3855fe91568a9dbda1ad57218c840625d6bf", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Succeed/NoQualifiedInstances-Import.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/NoQualifiedInstances-Import.agda", "max_line_length": 46, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/NoQualifiedInstances-Import.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 50, "size": 183 }
{- This file contains: - Elementary properties of homomorphisms - H-level results for the properties of morphisms - Special homomorphisms and operations (id, composition, inversion) - Conversion functions between different notions of group morphisms -} {-# OPTIONS --safe #-} module Cubical.Algebra.Group.MorphismProperties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Structure open import Cubical.Functions.Embedding open import Cubical.Data.Sigma open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.DirProd open import Cubical.Algebra.Group.Properties open import Cubical.Algebra.Group.Morphisms open import Cubical.HITs.PropositionalTruncation renaming (map to pMap) private variable ℓ ℓ' ℓ'' ℓ''' : Level E F G H : Group ℓ open Iso open GroupStr open IsGroupHom open BijectionIso -- Elementary properties of homomorphisms module _ {A : Type ℓ} {B : Type ℓ'} (G : GroupStr A) (f : A → B) (H : GroupStr B) (pres : (x y : A) → f (G ._·_ x y) ≡ H ._·_ (f x) (f y)) where private module G = GroupStr G module H = GroupStr H -- ϕ(1g) ≡ 1g hom1g : f G.1g ≡ H.1g hom1g = f G.1g ≡⟨ sym (H.rid _) ⟩ f G.1g H.· H.1g ≡⟨ (λ i → f G.1g H.· H.invr (f G.1g) (~ i)) ⟩ f G.1g H.· (f G.1g H.· H.inv (f G.1g)) ≡⟨ H.assoc _ _ _ ⟩ (f G.1g H.· f G.1g) H.· H.inv (f G.1g) ≡⟨ sym (cong (λ x → x H.· _) (sym (cong f (G.lid _)) ∙ pres G.1g G.1g)) ⟩ f G.1g H.· H.inv (f G.1g) ≡⟨ H.invr _ ⟩ H.1g ∎ -- ϕ(- x) = - ϕ(x) homInv : ∀ g → f (G.inv g) ≡ H.inv (f g) homInv g = f (G.inv g) ≡⟨ sym (H.rid _) ⟩ f (G.inv g) H.· H.1g ≡⟨ cong (_ H.·_) (sym (H.invr _)) ⟩ f (G.inv g) H.· (f g H.· H.inv (f g)) ≡⟨ H.assoc _ _ _ ⟩ (f (G.inv g) H.· f g) H.· H.inv (f g) ≡⟨ cong (H._· _) (sym (pres _ g) ∙∙ cong f (G.invl g) ∙∙ hom1g) ⟩ H.1g H.· H.inv (f g) ≡⟨ H.lid _ ⟩ H.inv (f g) ∎ module _ {A : Type ℓ} {B : Type ℓ'} {G : GroupStr A} {f : A → B} {H : GroupStr B} (pres : (x y : A) → f (G ._·_ x y) ≡ H ._·_ (f x) (f y)) where makeIsGroupHom : IsGroupHom G f H makeIsGroupHom .pres· = pres makeIsGroupHom .pres1 = hom1g G f H pres makeIsGroupHom .presinv = homInv G f H pres isGroupHomInv : (f : GroupEquiv G H) → IsGroupHom (H .snd) (invEq (fst f)) (G .snd) isGroupHomInv {G = G} {H = H} f = makeIsGroupHom λ h h' → isInj-f _ _ (f' (g (h ⋆² h')) ≡⟨ secEq (fst f) _ ⟩ (h ⋆² h') ≡⟨ sym (cong₂ _⋆²_ (secEq (fst f) h) (secEq (fst f) h')) ⟩ (f' (g h) ⋆² f' (g h')) ≡⟨ sym (pres· (snd f) _ _) ⟩ f' (g h ⋆¹ g h') ∎) where f' = fst (fst f) _⋆¹_ = _·_ (snd G) _⋆²_ = _·_ (snd H) g = invEq (fst f) isInj-f : (x y : ⟨ G ⟩) → f' x ≡ f' y → x ≡ y isInj-f x y = invEq (_ , isEquiv→isEmbedding (snd (fst f)) x y) -- H-level results isPropIsGroupHom : (G : Group ℓ) (H : Group ℓ') {f : ⟨ G ⟩ → ⟨ H ⟩} → isProp (IsGroupHom (G .snd) f (H .snd)) isPropIsGroupHom G H = isOfHLevelRetractFromIso 1 IsGroupHomIsoΣ (isProp× (isPropΠ2 λ _ _ → GroupStr.is-set (snd H) _ _) (isProp× (GroupStr.is-set (snd H) _ _) (isPropΠ λ _ → GroupStr.is-set (snd H) _ _))) isSetGroupHom : isSet (GroupHom G H) isSetGroupHom {G = G} {H = H} = isSetΣ (isSetΠ λ _ → is-set (snd H)) λ _ → isProp→isSet (isPropIsGroupHom G H) isPropIsInIm : (f : GroupHom G H) (x : ⟨ H ⟩) → isProp (isInIm f x) isPropIsInIm f x = squash₁ isSetIm : (f : GroupHom G H) → isSet (Im f) isSetIm {H = H} f = isSetΣ (is-set (snd H)) λ x → isProp→isSet (isPropIsInIm f x) isPropIsInKer : (f : GroupHom G H) (x : ⟨ G ⟩) → isProp (isInKer f x) isPropIsInKer {H = H} f x = is-set (snd H) _ _ isSetKer : (f : GroupHom G H) → isSet (Ker f) isSetKer {G = G} f = isSetΣ (is-set (snd G)) λ x → isProp→isSet (isPropIsInKer f x) isPropIsSurjective : (f : GroupHom G H) → isProp (isSurjective f) isPropIsSurjective f = isPropΠ (λ x → isPropIsInIm f x) isPropIsInjective : (f : GroupHom G H) → isProp (isInjective f) isPropIsInjective {G = G} _ = isPropΠ2 (λ _ _ → is-set (snd G) _ _) isPropIsMono : (f : GroupHom G H) → isProp (isMono f) isPropIsMono {G = G} f = isPropImplicitΠ2 λ _ _ → isPropΠ (λ _ → is-set (snd G) _ _) -- Logically equivalent versions of isInjective isMono→isInjective : (f : GroupHom G H) → isMono f → isInjective f isMono→isInjective f h x p = h (p ∙ sym (f .snd .pres1)) isInjective→isMono : (f : GroupHom G H) → isInjective f → isMono f isInjective→isMono {G = G} {H = H} f h {x = x} {y = y} p = x ≡⟨ sym (G.rid _) ⟩ x G.· G.1g ≡⟨ cong (x G.·_) (sym (G.invl _)) ⟩ x G.· (G.inv y G.· y) ≡⟨ G.assoc _ _ _ ⟩ (x G.· G.inv y) G.· y ≡⟨ cong (G._· y) idHelper ⟩ G.1g G.· y ≡⟨ G.lid _ ⟩ y ∎ where module G = GroupStr (snd G) module H = GroupStr (snd H) idHelper : x G.· G.inv y ≡ G.1g idHelper = h _ (f .snd .pres· _ _ ∙ cong (λ a → f .fst x H.· a) (f .snd .presinv y) ∙ cong (H._· H.inv (f .fst y)) p ∙ H.invr _) -- TODO: maybe it would be better to take this as the definition of isInjective? isInjective→isContrKer : (f : GroupHom G H) → isInjective f → isContr (Ker f) fst (isInjective→isContrKer {G = G} f hf) = 1g (snd G) , f .snd .pres1 snd (isInjective→isContrKer {G = G} f hf) k = Σ≡Prop (isPropIsInKer f) (sym (isInjective→isMono f hf (k .snd ∙ sym (f .snd .pres1)))) isContrKer→isInjective : (f : GroupHom G H) → isContr (Ker f) → isInjective f isContrKer→isInjective {G = G} f ((a , b) , c) x y = cong fst (sym (c (x , y)) ∙ rem) where rem : (a , b) ≡ (1g (snd G) , pres1 (snd f)) rem = c (1g (snd G) , pres1 (snd f)) -- Special homomorphisms and operations (id, composition...) idGroupHom : GroupHom G G idGroupHom .fst x = x idGroupHom .snd = makeIsGroupHom λ _ _ → refl isGroupHomComp : (f : GroupHom F G) → (g : GroupHom G H) → IsGroupHom (F .snd) (fst g ∘ fst f) (H .snd) isGroupHomComp f g = makeIsGroupHom λ _ _ → cong (fst g) (f .snd .pres· _ _) ∙ (g .snd .pres· _ _) compGroupHom : GroupHom F G → GroupHom G H → GroupHom F H fst (compGroupHom f g) = fst g ∘ fst f snd (compGroupHom f g) = isGroupHomComp f g GroupHomDirProd : {A : Group ℓ} {B : Group ℓ'} {C : Group ℓ''} {D : Group ℓ'''} → GroupHom A C → GroupHom B D → GroupHom (DirProd A B) (DirProd C D) fst (GroupHomDirProd mf1 mf2) = map-× (fst mf1) (fst mf2) snd (GroupHomDirProd mf1 mf2) = makeIsGroupHom λ _ _ → ≡-× (mf1 .snd .pres· _ _) (mf2 .snd .pres· _ _) GroupHom≡ : {f g : GroupHom G H} → (fst f ≡ fst g) → f ≡ g fst (GroupHom≡ p i) = p i snd (GroupHom≡ {G = G} {H = H} {f = f} {g = g} p i) = p-hom i where p-hom : PathP (λ i → IsGroupHom (G .snd) (p i) (H .snd)) (f .snd) (g .snd) p-hom = toPathP (isPropIsGroupHom G H _ _) compGroupHomAssoc : (e : GroupHom E F) → (f : GroupHom F G) → (g : GroupHom G H) → compGroupHom (compGroupHom e f) g ≡ compGroupHom e (compGroupHom f g) compGroupHomAssoc e f g = GroupHom≡ refl compGroupHomId : (f : GroupHom F G) → compGroupHom f idGroupHom ≡ f compGroupHomId f = GroupHom≡ refl -- The composition of surjective maps is surjective compSurjective : ∀ {ℓ ℓ' ℓ''} {G : Group ℓ} {H : Group ℓ'} {L : Group ℓ''} → (G→H : GroupHom G H) (H→L : GroupHom H L) → isSurjective G→H → isSurjective H→L → isSurjective (compGroupHom G→H H→L) compSurjective G→H H→L surj1 surj2 l = rec squash₁ (λ {(h , p) → pMap (λ {(g , q) → g , (cong (fst H→L) q ∙ p)}) (surj1 h)}) (surj2 l) -- GroupEquiv identity, composition and inversion idGroupEquiv : GroupEquiv G G fst (idGroupEquiv {G = G}) = idEquiv ⟨ G ⟩ snd idGroupEquiv = makeIsGroupHom λ _ _ → refl compGroupEquiv : GroupEquiv F G → GroupEquiv G H → GroupEquiv F H fst (compGroupEquiv f g) = compEquiv (fst f) (fst g) snd (compGroupEquiv f g) = isGroupHomComp (_ , f .snd) (_ , g .snd) invGroupEquiv : GroupEquiv G H → GroupEquiv H G fst (invGroupEquiv f) = invEquiv (fst f) snd (invGroupEquiv f) = isGroupHomInv f GroupEquivDirProd : {A : Group ℓ} {B : Group ℓ'} {C : Group ℓ''} {D : Group ℓ'''} → GroupEquiv A C → GroupEquiv B D → GroupEquiv (DirProd A B) (DirProd C D) fst (GroupEquivDirProd eq1 eq2) = ≃-× (fst eq1) (fst eq2) snd (GroupEquivDirProd eq1 eq2) = GroupHomDirProd (_ , eq1 .snd) (_ , eq2 .snd) .snd GroupEquiv≡ : {f g : GroupEquiv G H} → fst f ≡ fst g → f ≡ g fst (GroupEquiv≡ p i) = p i snd (GroupEquiv≡ {G = G} {H = H} {f} {g} p i) = p-hom i where p-hom : PathP (λ i → IsGroupHom (G .snd) (p i .fst) (H .snd)) (snd f) (snd g) p-hom = toPathP (isPropIsGroupHom G H _ _) -- GroupIso identity, composition and inversion idGroupIso : GroupIso G G fst idGroupIso = idIso snd idGroupIso = makeIsGroupHom λ _ _ → refl compGroupIso : GroupIso G H → GroupIso H F → GroupIso G F fst (compGroupIso iso1 iso2) = compIso (fst iso1) (fst iso2) snd (compGroupIso iso1 iso2) = isGroupHomComp (_ , snd iso1) (_ , snd iso2) invGroupIso : GroupIso G H → GroupIso H G fst (invGroupIso iso1) = invIso (fst iso1) snd (invGroupIso iso1) = isGroupHomInv (isoToEquiv (fst iso1) , snd iso1) GroupIsoDirProd : {G : Group ℓ} {H : Group ℓ'} {A : Group ℓ''} {B : Group ℓ'''} → GroupIso G H → GroupIso A B → GroupIso (DirProd G A) (DirProd H B) fun (fst (GroupIsoDirProd iso1 iso2)) prod = fun (fst iso1) (fst prod) , fun (fst iso2) (snd prod) inv (fst (GroupIsoDirProd iso1 iso2)) prod = inv (fst iso1) (fst prod) , inv (fst iso2) (snd prod) rightInv (fst (GroupIsoDirProd iso1 iso2)) a = ΣPathP (rightInv (fst iso1) (fst a) , (rightInv (fst iso2) (snd a))) leftInv (fst (GroupIsoDirProd iso1 iso2)) a = ΣPathP (leftInv (fst iso1) (fst a) , (leftInv (fst iso2) (snd a))) snd (GroupIsoDirProd iso1 iso2) = makeIsGroupHom λ a b → ΣPathP (pres· (snd iso1) (fst a) (fst b) , pres· (snd iso2) (snd a) (snd b)) GroupIso≡ : {f g : GroupIso G H} → f .fst ≡ g .fst → f ≡ g fst (GroupIso≡ {G = G} {H = H} {f} {g} p i) = p i snd (GroupIso≡ {G = G} {H = H} {f} {g} p i) = p-hom i where p-hom : PathP (λ i → IsGroupHom (G .snd) (p i .fun) (H .snd)) (snd f) (snd g) p-hom = toPathP (isPropIsGroupHom G H _ _) -- Conversion functions between different notions of group morphisms GroupEquiv→GroupHom : GroupEquiv G H → GroupHom G H fst (GroupEquiv→GroupHom ((f , _) , _)) = f snd (GroupEquiv→GroupHom (_ , isHom)) = isHom GroupIso→GroupEquiv : GroupIso G H → GroupEquiv G H fst (GroupIso→GroupEquiv i) = isoToEquiv (fst i) snd (GroupIso→GroupEquiv i) = snd i GroupEquiv→GroupIso : GroupEquiv G H → GroupIso G H fst (GroupEquiv→GroupIso e) = equivToIso (fst e) snd (GroupEquiv→GroupIso e) = snd e GroupIso→GroupHom : GroupIso G H → GroupHom G H GroupIso→GroupHom i = GroupEquiv→GroupHom (GroupIso→GroupEquiv i) -- TODO: prove the converse BijectionIso→GroupIso : BijectionIso G H → GroupIso G H BijectionIso→GroupIso {G = G} {H = H} i = grIso where f = fst (fun i) helper : (b : _) → isProp (Σ[ a ∈ ⟨ G ⟩ ] f a ≡ b) helper _ (a , ha) (b , hb) = Σ≡Prop (λ _ → is-set (snd H) _ _) (isInjective→isMono (fun i) (inj i) (ha ∙ sym hb) ) grIso : GroupIso G H fun (fst grIso) = f inv (fst grIso) b = rec (helper b) (λ a → a) (surj i b) .fst rightInv (fst grIso) b = rec (helper b) (λ a → a) (surj i b) .snd leftInv (fst grIso) b j = rec (helper (f b)) (λ a → a) (isPropPropTrunc (surj i (f b)) ∣ b , refl ∣₁ j) .fst snd grIso = snd (fun i) BijectionIsoToGroupEquiv : BijectionIso G H → GroupEquiv G H BijectionIsoToGroupEquiv i = GroupIso→GroupEquiv (BijectionIso→GroupIso i)
{ "alphanum_fraction": 0.5991292699, "avg_line_length": 38.6537216828, "ext": "agda", "hexsha": "00ade5bdcd6a5c3152032108420c77cf5f313be9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1d9b9691d375659fa8ebd9cbf8b63678955b196b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "gmagaf/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/MorphismProperties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1d9b9691d375659fa8ebd9cbf8b63678955b196b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "gmagaf/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/MorphismProperties.agda", "max_line_length": 108, "max_stars_count": null, "max_stars_repo_head_hexsha": "1d9b9691d375659fa8ebd9cbf8b63678955b196b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "gmagaf/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/MorphismProperties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4790, "size": 11944 }
----------------------------------------------------------------------- -- The Agda standard library -- -- Properties of the setoid sublist relation ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Setoid; _⇒_; _Preserves_⟶_) module Data.List.Relation.Binary.Sublist.Setoid.Properties {c ℓ} (S : Setoid c ℓ) where open import Data.List.Base hiding (_∷ʳ_) import Data.List.Relation.Binary.Equality.Setoid as SetoidEquality import Data.List.Relation.Binary.Sublist.Setoid as SetoidSublist import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties as HeteroProperties import Data.List.Membership.Setoid as SetoidMembership open import Data.List.Relation.Unary.Any using (Any) open import Data.Nat using (_≤_; _≥_; z≤n; s≤s) import Data.Nat.Properties as ℕₚ import Data.Maybe.Relation.Unary.All as Maybe open import Function open import Function.Bijection using (_⤖_) open import Function.Equivalence using (_⇔_) open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Relation.Unary using (Pred; Decidable; Irrelevant) open import Relation.Nullary using (¬_) open import Relation.Nullary.Negation using (¬?) open Setoid S using (_≈_) renaming (Carrier to A) open SetoidEquality S using (_≋_; ≋-refl) open SetoidSublist S hiding (map) open SetoidMembership S using (_∈_) ------------------------------------------------------------------------ -- Injectivity of constructors ------------------------------------------------------------------------ module _ {xs ys : List A} where ∷-injectiveˡ : ∀ {x y} {px qx : x ≈ y} {pxs qxs : xs ⊆ ys} → ((x ∷ xs) ⊆ (y ∷ ys) ∋ px ∷ pxs) ≡ (qx ∷ qxs) → px ≡ qx ∷-injectiveˡ refl = refl ∷-injectiveʳ : ∀ {x y} {px qx : x ≈ y} {pxs qxs : xs ⊆ ys} → ((x ∷ xs) ⊆ (y ∷ ys) ∋ px ∷ pxs) ≡ (qx ∷ qxs) → pxs ≡ qxs ∷-injectiveʳ refl = refl ∷ʳ-injective : ∀ {y} {pxs qxs : xs ⊆ ys} → y ∷ʳ pxs ≡ y ∷ʳ qxs → pxs ≡ qxs ∷ʳ-injective refl = refl ------------------------------------------------------------------------ -- Various functions' outputs are sublists ------------------------------------------------------------------------ tail-⊆ : ∀ xs → Maybe.All (_⊆ xs) (tail xs) tail-⊆ xs = HeteroProperties.tail-Sublist ⊆-refl take-⊆ : ∀ n xs → take n xs ⊆ xs take-⊆ n xs = HeteroProperties.take-Sublist n ⊆-refl drop-⊆ : ∀ n xs → drop n xs ⊆ xs drop-⊆ n xs = HeteroProperties.drop-Sublist n ⊆-refl module _ {p} {P : Pred A p} (P? : Decidable P) where takeWhile-⊆ : ∀ xs → takeWhile P? xs ⊆ xs takeWhile-⊆ xs = HeteroProperties.takeWhile-Sublist P? ⊆-refl dropWhile-⊆ : ∀ xs → dropWhile P? xs ⊆ xs dropWhile-⊆ xs = HeteroProperties.dropWhile-Sublist P? ⊆-refl filter-⊆ : ∀ xs → filter P? xs ⊆ xs filter-⊆ xs = HeteroProperties.filter-Sublist P? ⊆-refl module _ {p} {P : Pred A p} (P? : Decidable P) where takeWhile⊆filter : ∀ xs → takeWhile P? xs ⊆ filter P? xs takeWhile⊆filter xs = HeteroProperties.takeWhile-filter P? {xs} ≋-refl filter⊆dropWhile : ∀ xs → filter P? xs ⊆ dropWhile (¬? ∘ P?) xs filter⊆dropWhile xs = HeteroProperties.filter-dropWhile P? {xs} ≋-refl ------------------------------------------------------------------------ -- Various list functions are increasing wrt _⊆_ ------------------------------------------------------------------------ -- We write f⁺ for the proof that `xs ⊆ ys → f xs ⊆ f ys` -- and f⁻ for the one that `f xs ⊆ f ys → xs ⊆ ys`. module _ {as bs : List A} where ∷ˡ⁻ : ∀ {a} → a ∷ as ⊆ bs → as ⊆ bs ∷ˡ⁻ = HeteroProperties.∷ˡ⁻ ∷ʳ⁻ : ∀ {a b} → ¬ (a ≈ b) → a ∷ as ⊆ b ∷ bs → a ∷ as ⊆ bs ∷ʳ⁻ = HeteroProperties.∷ʳ⁻ ∷⁻ : ∀ {a b} → a ∷ as ⊆ b ∷ bs → as ⊆ bs ∷⁻ = HeteroProperties.∷⁻ ------------------------------------------------------------------------ -- map module _ {b ℓ} (R : Setoid b ℓ) where open Setoid R using () renaming (Carrier to B; _≈_ to _≈′_) open SetoidSublist R using () renaming (_⊆_ to _⊆′_) map⁺ : ∀ {as bs} {f : A → B} → f Preserves _≈_ ⟶ _≈′_ → as ⊆ bs → map f as ⊆′ map f bs map⁺ {f = f} f-resp as⊆bs = HeteroProperties.map⁺ f f (SetoidSublist.map S f-resp as⊆bs) ------------------------------------------------------------------------ -- _++_ module _ {as bs : List A} where ++⁺ˡ : ∀ cs → as ⊆ bs → as ⊆ cs ++ bs ++⁺ˡ = HeteroProperties.++ˡ ++⁺ʳ : ∀ cs → as ⊆ bs → as ⊆ bs ++ cs ++⁺ʳ = HeteroProperties.++ʳ ++⁺ : ∀ {cs ds} → as ⊆ bs → cs ⊆ ds → as ++ cs ⊆ bs ++ ds ++⁺ = HeteroProperties.++⁺ ++⁻ : ∀ {cs ds} → length as ≡ length bs → as ++ cs ⊆ bs ++ ds → cs ⊆ ds ++⁻ = HeteroProperties.++⁻ ------------------------------------------------------------------------ -- take module _ where take⁺ : ∀ {m n} {xs} → m ≤ n → take m xs ⊆ take n xs take⁺ m≤n = HeteroProperties.take⁺ m≤n ≋-refl ------------------------------------------------------------------------ -- drop module _ {m n} {xs ys : List A} where drop⁺ : m ≥ n → xs ⊆ ys → drop m xs ⊆ drop n ys drop⁺ = HeteroProperties.drop⁺ module _ {m n} {xs : List A} where drop⁺-≥ : m ≥ n → drop m xs ⊆ drop n xs drop⁺-≥ m≥n = drop⁺ m≥n ⊆-refl module _ {xs ys : List A} where drop⁺-⊆ : ∀ n → xs ⊆ ys → drop n xs ⊆ drop n ys drop⁺-⊆ n xs⊆ys = drop⁺ {n} ℕₚ.≤-refl xs⊆ys ------------------------------------------------------------------------ -- takeWhile / dropWhile module _ {p q} {P : Pred A p} {Q : Pred A q} (P? : Decidable P) (Q? : Decidable Q) where takeWhile⁺ : ∀ {xs} → (∀ {a b} → a ≈ b → P a → Q b) → takeWhile P? xs ⊆ takeWhile Q? xs takeWhile⁺ {xs} P⇒Q = HeteroProperties.⊆-takeWhile-Sublist P? Q? {xs} P⇒Q ≋-refl dropWhile⁺ : ∀ {xs} → (∀ {a b} → a ≈ b → Q b → P a) → dropWhile P? xs ⊆ dropWhile Q? xs dropWhile⁺ {xs} P⇒Q = HeteroProperties.⊇-dropWhile-Sublist P? Q? {xs} P⇒Q ≋-refl ------------------------------------------------------------------------ -- filter module _ {p q} {P : Pred A p} {Q : Pred A q} (P? : Decidable P) (Q? : Decidable Q) where filter⁺ : ∀ {as bs} → (∀ {a b} → a ≈ b → P a → Q b) → as ⊆ bs → filter P? as ⊆ filter Q? bs filter⁺ = HeteroProperties.⊆-filter-Sublist P? Q? ------------------------------------------------------------------------ -- reverse module _ {as bs : List A} where reverseAcc⁺ : ∀ {cs ds} → as ⊆ bs → cs ⊆ ds → reverseAcc cs as ⊆ reverseAcc ds bs reverseAcc⁺ = HeteroProperties.reverseAcc⁺ reverse⁺ : as ⊆ bs → reverse as ⊆ reverse bs reverse⁺ = HeteroProperties.reverse⁺ reverse⁻ : reverse as ⊆ reverse bs → as ⊆ bs reverse⁻ = HeteroProperties.reverse⁻ ------------------------------------------------------------------------ -- Inversion lemmas ------------------------------------------------------------------------ module _ {a b} {A : Set a} {B : Set b} {a as b bs} where ∷⁻¹ : a ≈ b → as ⊆ bs ⇔ a ∷ as ⊆ b ∷ bs ∷⁻¹ = HeteroProperties.∷⁻¹ ∷ʳ⁻¹ : ¬ (a ≈ b) → a ∷ as ⊆ bs ⇔ a ∷ as ⊆ b ∷ bs ∷ʳ⁻¹ = HeteroProperties.∷ʳ⁻¹ ------------------------------------------------------------------------ -- Other ------------------------------------------------------------------------ module _ where length-mono-≤ : ∀ {as bs} → as ⊆ bs → length as ≤ length bs length-mono-≤ = HeteroProperties.length-mono-≤ ------------------------------------------------------------------------ -- Conversion to and from list equality to-≋ : ∀ {as bs} → length as ≡ length bs → as ⊆ bs → as ≋ bs to-≋ = HeteroProperties.toPointwise ------------------------------------------------------------------------ -- Irrelevant special case module _ {a b} {A : Set a} {B : Set b} where []⊆-irrelevant : Irrelevant ([] ⊆_) []⊆-irrelevant = HeteroProperties.Sublist-[]-irrelevant ------------------------------------------------------------------------ -- (to/from)∈ is a bijection module _ {x xs} where to∈-injective : ∀ {p q : [ x ] ⊆ xs} → to∈ p ≡ to∈ q → p ≡ q to∈-injective = HeteroProperties.toAny-injective from∈-injective : ∀ {p q : x ∈ xs} → from∈ p ≡ from∈ q → p ≡ q from∈-injective = HeteroProperties.fromAny-injective to∈∘from∈≗id : ∀ (p : x ∈ xs) → to∈ (from∈ p) ≡ p to∈∘from∈≗id = HeteroProperties.toAny∘fromAny≗id [x]⊆xs⤖x∈xs : ([ x ] ⊆ xs) ⤖ (x ∈ xs) [x]⊆xs⤖x∈xs = HeteroProperties.Sublist-[x]-bijection
{ "alphanum_fraction": 0.4840100611, "avg_line_length": 33.396, "ext": "agda", "hexsha": "417d7f075654a0c2f793b1c9ad530df411345ae3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Setoid/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Setoid/Properties.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Setoid/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2873, "size": 8349 }
module Fail.TupleTerm where open import Haskell.Prelude pair2trip : a → b × c → a × b × c pair2trip x xs = x ∷ xs {-# COMPILE AGDA2HS pair2trip #-}
{ "alphanum_fraction": 0.6644736842, "avg_line_length": 15.2, "ext": "agda", "hexsha": "387e27e1928d21c0eee73943e8dce18c06d74a0b", "lang": "Agda", "max_forks_count": 18, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_path": "test/Fail/TupleTerm.agda", "max_issues_count": 63, "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_path": "test/Fail/TupleTerm.agda", "max_line_length": 33, "max_stars_count": 55, "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_path": "test/Fail/TupleTerm.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "num_tokens": 52, "size": 152 }
open import Level using () renaming (_⊔_ to _⊔ˡ_) open import Relation.Binary.Morphism.Structures using (IsRelHomomorphism) open import Algebra.Bundles using (RawMonoid; RawGroup; RawRing) open import Algebra.Morphism.Structures using (IsMonoidHomomorphism; IsMonoidMonomorphism) module AKS.Algebra.Morphism.Structures where module GroupMorphisms {c₁ c₂ ℓ₁ ℓ₂} (G₁ : RawGroup c₁ ℓ₁) (G₂ : RawGroup c₂ ℓ₂) where open RawGroup G₁ using () renaming (Carrier to C₁; _∙_ to _+₁_; _⁻¹ to -₁_; ε to ε₁; _≈_ to _≈₁_; rawMonoid to +₁-rawMonoid) open RawGroup G₂ using () renaming (Carrier to C₂; _∙_ to _+₂_; _⁻¹ to -₂_; ε to ε₂; _≈_ to _≈₂_; rawMonoid to +₂-rawMonoid) open import Algebra.Morphism.Definitions C₁ C₂ _≈₂_ using (Homomorphic₂; Homomorphic₁; Homomorphic₀) open import Function.Definitions _≈₁_ _≈₂_ using (Injective) record IsGroupHomomorphism (⟦_⟧ : C₁ → C₂) : Set (c₁ ⊔ˡ ℓ₁ ⊔ˡ ℓ₂) where field isRelHomomorphism : IsRelHomomorphism _≈₁_ _≈₂_ ⟦_⟧ +-homo : Homomorphic₂ ⟦_⟧ _+₁_ _+₂_ -‿homo : Homomorphic₁ ⟦_⟧ -₁_ -₂_ ε-homo : Homomorphic₀ ⟦_⟧ ε₁ ε₂ open IsRelHomomorphism isRelHomomorphism public renaming (cong to ⟦⟧-cong) +-isMonoidHomomorphism : IsMonoidHomomorphism +₁-rawMonoid +₂-rawMonoid ⟦_⟧ +-isMonoidHomomorphism = record { isMagmaHomomorphism = record { isRelHomomorphism = isRelHomomorphism ; homo = +-homo } ; ε-homo = ε-homo } record IsGroupMonomorphism (⟦_⟧ : C₁ → C₂) : Set (c₁ ⊔ˡ ℓ₁ ⊔ˡ ℓ₂) where field isGroupHomomorphism : IsGroupHomomorphism ⟦_⟧ injective : Injective ⟦_⟧ open IsGroupHomomorphism isGroupHomomorphism public +-isMonoidMonomorphism : IsMonoidMonomorphism +₁-rawMonoid +₂-rawMonoid ⟦_⟧ +-isMonoidMonomorphism = record { isMonoidHomomorphism = +-isMonoidHomomorphism ; injective = injective } open GroupMorphisms public module RingMorphisms {c₁ c₂ ℓ₁ ℓ₂} (R₁ : RawRing c₁ ℓ₁) (R₂ : RawRing c₂ ℓ₂) where open RawRing R₁ using () renaming (Carrier to C₁; _+_ to _+₁_; _*_ to _*₁_; -_ to -₁_; 0# to 0#₁; 1# to 1#₁; _≈_ to _≈₁_) open RawRing R₂ using () renaming (Carrier to C₂; _+_ to _+₂_; _*_ to _*₂_; -_ to -₂_; 0# to 0#₂; 1# to 1#₂; _≈_ to _≈₂_) open import Algebra.Morphism.Definitions C₁ C₂ _≈₂_ using (Homomorphic₂; Homomorphic₁; Homomorphic₀) open import Function.Definitions _≈₁_ _≈₂_ using (Injective) +₁-rawGroup : RawGroup c₁ ℓ₁ +₁-rawGroup = record { Carrier = C₁ ; _≈_ = _≈₁_ ; _∙_ = _+₁_ ; _⁻¹ = -₁_ ; ε = 0#₁ } +₂-rawGroup : RawGroup c₂ ℓ₂ +₂-rawGroup = record { Carrier = C₂ ; _≈_ = _≈₂_ ; _∙_ = _+₂_ ; _⁻¹ = -₂_ ; ε = 0#₂ } *₁-rawMonoid : RawMonoid c₁ ℓ₁ *₁-rawMonoid = record { Carrier = C₁ ; _≈_ = _≈₁_ ; _∙_ = _*₁_ ; ε = 1#₁ } *₂-rawMonoid : RawMonoid c₂ ℓ₂ *₂-rawMonoid = record { Carrier = C₂ ; _≈_ = _≈₂_ ; _∙_ = _*₂_ ; ε = 1#₂ } record IsRingHomomorphism (⟦_⟧ : C₁ → C₂) : Set (c₁ ⊔ˡ ℓ₁ ⊔ˡ ℓ₂) where field isRelHomomorphism : IsRelHomomorphism _≈₁_ _≈₂_ ⟦_⟧ +-homo : Homomorphic₂ ⟦_⟧ _+₁_ _+₂_ *-homo : Homomorphic₂ ⟦_⟧ _*₁_ _*₂_ -‿homo : Homomorphic₁ ⟦_⟧ -₁_ -₂_ 0#-homo : Homomorphic₀ ⟦_⟧ 0#₁ 0#₂ 1#-homo : Homomorphic₀ ⟦_⟧ 1#₁ 1#₂ open IsRelHomomorphism isRelHomomorphism public renaming (cong to ⟦⟧-cong) +-isGroupHomomorphism : IsGroupHomomorphism +₁-rawGroup +₂-rawGroup ⟦_⟧ +-isGroupHomomorphism = record { isRelHomomorphism = isRelHomomorphism ; +-homo = +-homo ; -‿homo = -‿homo ; ε-homo = 0#-homo } *-isMonoidHomomorphism : IsMonoidHomomorphism *₁-rawMonoid *₂-rawMonoid ⟦_⟧ *-isMonoidHomomorphism = record { isMagmaHomomorphism = record { isRelHomomorphism = isRelHomomorphism ; homo = *-homo } ; ε-homo = 1#-homo } record IsRingMonomorphism (⟦_⟧ : C₁ → C₂) : Set (c₁ ⊔ˡ ℓ₁ ⊔ˡ ℓ₂) where field isRingHomomorphism : IsRingHomomorphism ⟦_⟧ injective : Injective ⟦_⟧ open IsRingHomomorphism isRingHomomorphism public +-isGroupMonomorphism : IsGroupMonomorphism +₁-rawGroup +₂-rawGroup ⟦_⟧ +-isGroupMonomorphism = record { isGroupHomomorphism = +-isGroupHomomorphism ; injective = injective } *-isMonoidMonomorphism : IsMonoidMonomorphism *₁-rawMonoid *₂-rawMonoid ⟦_⟧ *-isMonoidMonomorphism = record { isMonoidHomomorphism = *-isMonoidHomomorphism ; injective = injective } open RingMorphisms public
{ "alphanum_fraction": 0.6602592758, "avg_line_length": 38.5689655172, "ext": "agda", "hexsha": "156baffc4bb3314d247372bb10a05299e0e2103e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/thesis", "max_forks_repo_path": "proofs/AKS/Algebra/Morphism/Structures.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/thesis", "max_issues_repo_path": "proofs/AKS/Algebra/Morphism/Structures.agda", "max_line_length": 126, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/thesis", "max_stars_repo_path": "proofs/AKS/Algebra/Morphism/Structures.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z", "num_tokens": 1834, "size": 4474 }
-- Andreas, 2016-07-19 issue #382, duplicate of #278 -- report and test case by Nisse, 2011-01-30 module Issue382 {A : Set} where data _≡_ (x : A) : A → Set where refl : x ≡ x abstract id : A → A id x = y where y = x lemma : ∀ x → id x ≡ x lemma x = refl -- should succeed
{ "alphanum_fraction": 0.5836177474, "avg_line_length": 15.4210526316, "ext": "agda", "hexsha": "ef16125f1d8612f93e65516890c02f4093301526", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue382.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue382.agda", "max_line_length": 52, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue382.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 113, "size": 293 }
-- Andreas, 2015-09-12, issue reported by F Mazzoli -- {-# OPTIONS -v tc.meta.assign.proj:85 #-} open import Common.Product open import Common.Equality module _ (A : Set) where mutual X : A × A → A X = _ test : (x y : A × A) → X (proj₁ x , proj₁ y) ≡ proj₁ x test x y = refl -- In order to solve X, record variables x and y -- have to be expanded. -- Previously, this happend only if projections were -- direct argument to the meta-variable. -- Now, we also accept them inside record constructors. verify : ∀{p} → X p ≡ proj₁ p verify = refl
{ "alphanum_fraction": 0.6606822262, "avg_line_length": 22.28, "ext": "agda", "hexsha": "0cf9e82c8f8ea08d55822a62ffcd186cf28ade42", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue1316.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue1316.agda", "max_line_length": 56, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue1316.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 171, "size": 557 }
import Lvl open import Type module FormalLanguage.RegularExpression {ℓ} (Σ : Type{ℓ}) where open import Data.Boolean open import Data.Boolean.Stmt.Proofs open import Data.List as List using (List) open import FormalLanguage open import FormalLanguage.Proofs open import Functional open import Logic open import Logic.Propositional open import Numeral.Natural open import Relator.Equals data RegExp : Type{ℓ} where ∅ : RegExp -- Empty language (Consisting of no words). ε : RegExp -- Empty word language (Consisting of a single empty word). • : Σ → RegExp -- Singleton language (Consisting of a single one letter word). _++_ : RegExp → RegExp → RegExp -- Concatenation language (Consisting of the words concatenated pairwise). _‖_ : RegExp → RegExp → RegExp -- Union language (Consisting of the words in both languages). _* : RegExp → RegExp -- Infinite concatenations language (Consisting of the words concatenated with themselves any number of times). -- Non-empty infinite concatenations language. _+ : RegExp → RegExp e + = e ++ (e *) -- Optional expression language _?? : RegExp → RegExp e ?? = ε ‖ e -- Finitely repeated expression language exactly : ℕ → RegExp → RegExp exactly 𝟎 e = ε exactly (𝐒(n)) e = e ++ (exactly n e) -- Minimum repetitions of an expression language at-least : ℕ → RegExp → RegExp at-least 𝟎 e = e * at-least (𝐒(n)) e = e ++ (at-least n e) -- Maximum repetitions of an expression language at-most : ℕ → RegExp → RegExp at-most 𝟎 e = ε at-most (𝐒(n)) e = ε ‖ (e ++ (at-most n e)) -- Relation for whether a pattern/expression matches a word (whether the word is in the language that the pattern/expression describes). data _matches_ : RegExp → List(Σ) → Stmt{ℓ} where empty-word : ε matches List.∅ concatenation : ∀{r₁ r₂}{l₁ l₂} → (r₁ matches l₁) → (r₂ matches l₂) → ((r₁ ++ r₂) matches (l₁ List.++ l₂)) disjunctionₗ : ∀{rₗ rᵣ}{l} → (rₗ matches l) → ((rₗ ‖ rᵣ) matches l) disjunctionᵣ : ∀{rₗ rᵣ}{l} → (rᵣ matches l) → ((rₗ ‖ rᵣ) matches l) iteration : ∀{r}{l₁ l₂} → (r matches l₁) → ((r *) matches l₂) → ((r *) matches (l₁ List.++ l₂)) literal : ∀{a} → ((• a) matches List.singleton(a)) -- optional-empty : ∀{e} → ((e ??) matches List.∅) pattern optional-empty = disjunctionₗ empty-word optional-self : ∀{e}{l} → (e matches l) → ((e ??) matches l) optional-self = disjunctionᵣ empty-none : ∀{l} → ¬(∅ matches l) empty-none () module _ ⦃ _ : ComputablyDecidable(_≡_) ⦄ where language : RegExp → Language(Σ) language ∅ = Oper.∅ language ε = Oper.ε language (• x) = Oper.single x language (x ++ y) = language(x) Oper.𝁼 language(y) language (x ‖ y) = language(x) Oper.∪ language(y) language (x *) = language(x) Oper.* postulate matches-language : ∀{e}{l} → (e matches l) → (l Oper.∈ language(e)) {-matches-language {ε} {List.∅} empty-word = [⊤]-intro matches-language {• a} {.a List.⊰ .List.∅} literal = {!!} matches-language {e₁ ++ e₂} {List.∅} p = {!!} matches-language {e₁ ++ e₂} {x List.⊰ l} p = {!!} matches-language {e₁ ‖ e₂} {List.∅} (disjunctionₗ p) = IsTrue.[∨]-introₗ(matches-language {e₁} p) matches-language {e₁ ‖ e₂} {List.∅} (disjunctionᵣ p) = IsTrue.[∨]-introᵣ(matches-language {e₂} p) matches-language {e₁ ‖ e₂} {x List.⊰ l} (disjunctionₗ p) = [↔]-to-[←] ([∪]-containment {x = x List.⊰ l}{A = language(e₁)}{B = language(e₂)}) ([∨]-introₗ (matches-language {e₁} p)) matches-language {e₁ ‖ e₂} {x List.⊰ l} (disjunctionᵣ p) = [↔]-to-[←] ([∪]-containment {x = x List.⊰ l}{A = language(e₁)}{B = language(e₂)}) ([∨]-introᵣ (matches-language {e₂} p)) matches-language {e *} {List.∅} p = {!!} matches-language {e *} {x List.⊰ l} p = {!!} -} postulate language-matches : ∀{e}{l} → (l Oper.∈ language(e)) → (e matches l) {-language-matches {∅} {x List.⊰ l} p with () ← language-matches {∅} {l} p language-matches {ε} {List.∅} [⊤]-intro = empty-word language-matches {ε} {x List.⊰ l} p with () ← [↔]-to-[→] ([ε]-containment {x = x List.⊰ l}) p language-matches {• a} {x List.⊰ l} p with [≡]-intro ← [↔]-to-[→] (single-containment {x = x List.⊰ l}) p = literal language-matches {e₁ ++ e₂} {List.∅} p = {!!} language-matches {e₁ ++ e₂} {x List.⊰ l} p = {!!} language-matches {e₁ ‖ e₂} {l} p = [∨]-elim (disjunctionₗ ∘ language-matches) (disjunctionᵣ ∘ language-matches) ([↔]-to-[→] ([∪]-containment {x = l} {A = language(e₁)} {B = language(e₂)}) p) language-matches {e *} {List.∅} [⊤]-intro = {![*]-containment!} language-matches {e *} {x List.⊰ l} p = {!!} -}
{ "alphanum_fraction": 0.6161528441, "avg_line_length": 46.5252525253, "ext": "agda", "hexsha": "502fb37d337b615833b8b2d4389a5f1e41b3b0e8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "FormalLanguage/RegularExpression.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "FormalLanguage/RegularExpression.agda", "max_line_length": 193, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "FormalLanguage/RegularExpression.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1643, "size": 4606 }
-- Currently primitive functions are not allowed in mutual blocks. -- This might change. module PrimitiveInMutual where postulate String : Set {-# BUILTIN STRING String #-} mutual primitive primStringAppend : String -> String -> String _++_ : String -> String -> String x ++ y = primStringAppend x y
{ "alphanum_fraction": 0.7170418006, "avg_line_length": 20.7333333333, "ext": "agda", "hexsha": "a2f4deb75ae6afe55b960f245684bf5753c09c4f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Fail/PrimitiveInMutual.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Fail/PrimitiveInMutual.agda", "max_line_length": 66, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Fail/PrimitiveInMutual.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 73, "size": 311 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Basic definitions for morphisms between algebraic structures ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary.Core module Algebra.Morphism.Definitions {a} (A : Set a) -- The domain of the morphism {b} (B : Set b) -- The codomain of the morphism {ℓ} (_≈_ : Rel B ℓ) -- The equality relation over the codomain where open import Algebra.Core open import Function.Core ------------------------------------------------------------------------ -- Basic definitions Homomorphic₀ : (A → B) → A → B → Set _ Homomorphic₀ ⟦_⟧ ∙ ∘ = ⟦ ∙ ⟧ ≈ ∘ Homomorphic₁ : (A → B) → Op₁ A → Op₁ B → Set _ Homomorphic₁ ⟦_⟧ ∙_ ∘_ = ∀ x → ⟦ ∙ x ⟧ ≈ (∘ ⟦ x ⟧) Homomorphic₂ : (A → B) → Op₂ A → Op₂ B → Set _ Homomorphic₂ ⟦_⟧ _∙_ _∘_ = ∀ x y → ⟦ x ∙ y ⟧ ≈ (⟦ x ⟧ ∘ ⟦ y ⟧) ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.3 Morphism : Set _ Morphism = A → B {-# WARNING_ON_USAGE Morphism "Warning: Morphism was deprecated in v1.3. Please use the standard function notation (e.g. A → B) instead." #-}
{ "alphanum_fraction": 0.4695467422, "avg_line_length": 28.8163265306, "ext": "agda", "hexsha": "e953d033cc65645cd0b57b77624f4f6472195d27", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Algebra/Morphism/Definitions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Algebra/Morphism/Definitions.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Algebra/Morphism/Definitions.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 375, "size": 1412 }
module 842Isomorphism where -- Library import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; cong-app; sym) -- added last open Eq.≡-Reasoning open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Nat.Properties using (+-comm; +-suc; +-identityʳ) -- added last -- Function composition. _∘_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C) (g ∘ f) x = g (f x) _∘′_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C) g ∘′ f = λ x → g (f x) postulate extensionality : ∀ {A B : Set} {f g : A → B} → (∀ (x : A) → f x ≡ g x) ----------------------- → f ≡ g -- Another definition of addition. _+′_ : ℕ → ℕ → ℕ -- split on n instead, get different code m +′ zero = m m +′ suc n = suc (m +′ n) same-app : ∀ (m n : ℕ) → m +′ n ≡ m + n same-app m zero = sym (+-identityʳ m) same-app m (suc n) rewrite +-suc m n | same-app m n = refl same : _+′_ ≡ _+_ -- this requires extensionality same = extensionality λ x → extensionality λ x₁ → same-app x x₁ -- Isomorphism. infix 0 _≃_ record _≃_ (A B : Set) : Set where constructor mk-≃ -- This has been added, not in PLFA field to : A → B from : B → A from∘to : ∀ (x : A) → from (to x) ≡ x to∘from : ∀ (y : B) → to (from y) ≡ y open _≃_ -- Equivalent to the following: data _≃′_ (A B : Set): Set where mk-≃′ : ∀ (to : A → B) → ∀ (from : B → A) → ∀ (from∘to : (∀ (x : A) → from (to x) ≡ x)) → ∀ (to∘from : (∀ (y : B) → to (from y) ≡ y)) → A ≃′ B to′ : ∀ {A B : Set} → (A ≃′ B) → (A → B) to′ (mk-≃′ f g g∘f f∘g) = f from′ : ∀ {A B : Set} → (A ≃′ B) → (B → A) from′ (mk-≃′ f g g∘f f∘g) = g from∘to′ : ∀ {A B : Set} → (A≃B : A ≃′ B) → (∀ (x : A) → from′ A≃B (to′ A≃B x) ≡ x) from∘to′ (mk-≃′ f g g∘f f∘g) = g∘f to∘from′ : ∀ {A B : Set} → (A≃B : A ≃′ B) → (∀ (y : B) → to′ A≃B (from′ A≃B y) ≡ y) to∘from′ (mk-≃′ f g g∘f f∘g) = f∘g -- End of equivalent formulation (records are faster!) -- Properties of isomorphism. -- Reflexivity. ≃-refl : ∀ {A : Set} ----- → A ≃ A -- in empty hole, split on result, get copatterns (not in PLFA) to ≃-refl x = x from ≃-refl x = x from∘to ≃-refl x = refl to∘from ≃-refl x = refl -- Symmetry. ≃-sym : ∀ {A B : Set} → A ≃ B ----- → B ≃ A to (≃-sym A≃B) = from A≃B from (≃-sym A≃B) = to A≃B from∘to (≃-sym A≃B) = to∘from A≃B to∘from (≃-sym A≃B) = from∘to A≃B -- Transitivity. ≃-trans : ∀ {A B C : Set} → A ≃ B → B ≃ C ----- → A ≃ C to (≃-trans A≃B B≃C) = to B≃C ∘ to A≃B from (≃-trans A≃B B≃C) = from A≃B ∘ from B≃C from∘to (≃-trans A≃B B≃C) x rewrite from∘to B≃C (to A≃B x) = from∘to A≃B x to∘from (≃-trans A≃B B≃C) x rewrite to∘from A≃B (from B≃C x) = to∘from B≃C x -- Isomorphism is an equivalence relation. -- We can create syntax for equational reasoning. module ≃-Reasoning where infix 1 ≃-begin_ infixr 2 _≃⟨_⟩_ infix 3 _≃-∎ ≃-begin_ : ∀ {A B : Set} → A ≃ B ----- → A ≃ B ≃-begin A≃B = A≃B _≃⟨_⟩_ : ∀ (A : Set) {B C : Set} → A ≃ B → B ≃ C ----- → A ≃ C A ≃⟨ A≃B ⟩ B≃C = ≃-trans A≃B B≃C _≃-∎ : ∀ (A : Set) ----- → A ≃ A A ≃-∎ = ≃-refl open ≃-Reasoning -- Embedding (weaker than isomorphism) infix 0 _≲_ record _≲_ (A B : Set) : Set where field to : A → B from : B → A from∘to : ∀ (x : A) → from (to x) ≡ x open _≲_ ≲-refl : ∀ {A : Set} → A ≲ A to ≲-refl x = x from ≲-refl x = x from∘to ≲-refl x = refl ≲-trans : ∀ {A B C : Set} → A ≲ B → B ≲ C → A ≲ C to (≲-trans A≲B B≲C) = to B≲C ∘ to A≲B from (≲-trans A≲B B≲C) = from A≲B ∘ from B≲C from∘to (≲-trans A≲B B≲C) x rewrite from∘to B≲C (to A≲B x) = from∘to A≲B x ≲-antisym : ∀ {A B : Set} → (A≲B : A ≲ B) → (B≲A : B ≲ A) → (to A≲B ≡ from B≲A) → (from A≲B ≡ to B≲A) ------------------- → A ≃ B to (≲-antisym A≲B B≲A to≡from from≡to) = to A≲B from (≲-antisym A≲B B≲A to≡from from≡to) = from A≲B from∘to (≲-antisym A≲B B≲A to≡from from≡to) x = from∘to A≲B x to∘from (≲-antisym A≲B B≲A to≡from from≡to) y rewrite from≡to | to≡from = from∘to B≲A y -- Tabular reasoning for embedding. module ≲-Reasoning where infix 1 ≲-begin_ infixr 2 _≲⟨_⟩_ infix 3 _≲-∎ ≲-begin_ : ∀ {A B : Set} → A ≲ B ----- → A ≲ B ≲-begin A≲B = A≲B _≲⟨_⟩_ : ∀ (A : Set) {B C : Set} → A ≲ B → B ≲ C ----- → A ≲ C A ≲⟨ A≲B ⟩ B≲C = ≲-trans A≲B B≲C _≲-∎ : ∀ (A : Set) ----- → A ≲ A A ≲-∎ = ≲-refl open ≲-Reasoning -- PLFA exercise: Isomorphism implies embedding. ≃-implies-≲ : ∀ {A B : Set} → A ≃ B ----- → A ≲ B to (≃-implies-≲ a≃b) = to a≃b from (≃-implies-≲ a≃b) = from a≃b from∘to (≃-implies-≲ a≃b) = from∘to a≃b -- PLFA exercise: propositional equivalence (weaker than embedding). record _⇔_ (A B : Set) : Set where field to : A → B from : B → A open _⇔_ -- added -- This is also an equivalence relation. ⇔-refl : ∀ {A : Set} ----- → A ⇔ A _⇔_.to ⇔-refl x = x _⇔_.from ⇔-refl x = x ⇔-sym : ∀ {A B : Set} → A ⇔ B ----- → B ⇔ A _⇔_.to (⇔-sym A⇔B) = from A⇔B _⇔_.from (⇔-sym A⇔B) = to A⇔B ⇔-trans : ∀ {A B C : Set} → A ⇔ B → B ⇔ C ----- → A ⇔ C to (⇔-trans A⇔B B⇔C) = to B⇔C ∘ to A⇔B from (⇔-trans A⇔B B⇔C) = from A⇔B ∘ from B⇔C -- 842 extended exercise: Canonical bitstrings. -- Modified and extended from Bin-predicates exercise in PLFA Relations. -- Copied from 842Naturals. data Bin-ℕ : Set where bits : Bin-ℕ _x0 : Bin-ℕ → Bin-ℕ _x1 : Bin-ℕ → Bin-ℕ dbl : ℕ → ℕ dbl zero = zero dbl (suc n) = suc (suc (dbl n)) -- Copy your versions of 'inc', 'tob', and 'fromb' over from earlier files. -- You may choose to change the definitions here to make proofs easier. -- But make sure to test them if you do! -- You may also copy over any theorems that prove useful. inc : Bin-ℕ → Bin-ℕ inc n = {!!} tob : ℕ → Bin-ℕ tob n = {!!} dblb : Bin-ℕ → Bin-ℕ dblb n = {!!} fromb : Bin-ℕ → ℕ fromb n = {!!} -- The reason that we couldn't prove ∀ {n : Bin-ℕ} → tob (fromb n) ≡ n -- is because of the possibility of leading zeroes in a Bin-ℕ value. -- 'bits x0 x0 x1' is such a value that gives a counterexample. -- However, the theorem is true is true for n without leading zeroes. -- We define a predicate to be able to state this in a theorem. -- A value of type One n is evidence that n has a leading one. data One : Bin-ℕ → Set where [bitsx1] : One (bits x1) _[x0] : ∀ {n : Bin-ℕ} → One n → One (n x0) _[x1] : ∀ {n : Bin-ℕ} → One n → One (n x1) -- Here's a proof that 'bits x1 x0 x0' has a leading one. _ : One (bits x1 x0 x0) _ = [bitsx1] [x0] [x0] -- There is no value of type One (bits x0 x0 x1). -- But we can't state and prove this yet, because we don't know -- how to express negation. That comes in the Connectives chapter. -- A canonical binary representation is either zero or has a leading one. data Can : Bin-ℕ → Set where [zero] : Can bits [pos] : ∀ {n : Bin-ℕ} → One n → Can n -- Some obvious examples: _ : Can bits _ = [zero] _ : Can (bits x1 x0) _ = [pos] ([bitsx1] [x0]) -- The Bin-predicates exercise in PLFA Relations gives three properties of canonicity. -- The first is that the increment of a canonical number is canonical. -- Most of the work is done in the following lemma. -- 842 exercise: IncCanOne (2 points) -- The increment of a canonical number has a leading one. one-inc : ∀ {n : Bin-ℕ} → Can n → One (inc n) one-inc cn = {!!} -- The first canonicity property is now an easy corollary. -- 842 exercise: OneInc (1 point) can-inc : ∀ {n : Bin-ℕ} → Can n → Can (inc n) can-inc cn = {!!} -- The second canonicity property is that converting a unary number -- to binary produces a canonical number. -- 842 exercise: CanToB (1 point) to-can : ∀ (n : ℕ) → Can (tob n) to-can n = {!!} -- The third canonicity property is that converting a canonical number -- from binary and back to unary produces the same number. -- This takes more work, and some helper lemmas from 842Induction. -- You will need to discover which ones. -- 842 exercise: OneDblbX0 (1 point) -- This helper function relates binary double to the x0 constructor, -- for numbers with a leading one. dblb-x0 : ∀ {n : Bin-ℕ} → One n → dblb n ≡ n x0 dblb-x0 on = {!!} -- We can now prove the third property for numbers with a leading one. -- 842 exercise: OneToFrom (3 points) one-to∘from : ∀ {n : Bin-ℕ} → One n → tob (fromb n) ≡ n one-to∘from on = {!!} -- The third property is now an easy corollary. -- 842 exercise: CanToFrom (1 point) can-to∘from : ∀ {n : Bin-ℕ} → Can n → tob (fromb n) ≡ n can-to∘from cn = {!!} -- 842 exercise: OneUnique (2 points) -- Proofs of positivity are unique. one-unique : ∀ {n : Bin-ℕ} → (x y : One n) → x ≡ y one-unique x y = {!!} -- 842 exercise: CanUnique (1 point) -- Proofs of canonicity are unique. can-unique : ∀ {n : Bin-ℕ} → (x y : Can n) → x ≡ y can-unique x y = {!!} -- Do we have an isomorphism between ℕ (unary) and canonical binary representations? -- Can is not a set, but a family of sets, so it doesn't quite fit -- into our framework for isomorphism. -- But we can roll all the values into one set which is isomorphic to ℕ. -- A CanR value wraps up a Bin-ℕ and proof it has a canonical representation. data CanR : Set where wrap : ∀ (n : Bin-ℕ) → Can n → CanR -- We can show that there is an isomorphism between ℕ and CanR. -- 842 exercise: IsoNCanR (3 points) iso-ℕ-CanR : ℕ ≃ CanR iso-ℕ-CanR = {!!} -- Can we get an isomorphism between ℕ and some binary encoding, -- without the awkwardness of non-canonical values? -- Yes: we use digits 1 and 2, instead of 0 and 1 (multiplier/base is still 2). -- This is known as bijective binary numbering. -- The counting sequence goes <empty>, 1, 2, 11, 12, 21, 22, 111... data Bij-ℕ : Set where bits : Bij-ℕ _x1 : Bij-ℕ → Bij-ℕ _x2 : Bij-ℕ → Bij-ℕ -- There is an isomorphism between ℕ and Bij-ℕ. -- The proof largely follows the outline of what we did above, -- and is left as an optional exercise. -- See PLFA for remarks on standard library definitions similar to those here. -- Unicode introduced in this chapter: {- ∘ U+2218 RING OPERATOR (\o, \circ, \comp) λ U+03BB GREEK SMALL LETTER LAMBDA (\lambda, \Gl) ≃ U+2243 ASYMPTOTICALLY EQUAL TO (\~-) ≲ U+2272 LESS-THAN OR EQUIVALENT TO (\<~) ⇔ U+21D4 LEFT RIGHT DOUBLE ARROW (\<=>) -}
{ "alphanum_fraction": 0.5667115903, "avg_line_length": 24.1020881671, "ext": "agda", "hexsha": "ac716b16c1985fae07b50ba2209dab9901a63f14", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05-842Isomorphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05-842Isomorphism.agda", "max_line_length": 87, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x05-842Isomorphism.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 4278, "size": 10388 }
module Pi.AuxLemmas where open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Relation.Binary.PropositionalEquality open import Pi.Syntax open import Pi.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₂ : ∀ {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} → (r : ⟨ c ∣ v ∣ κ ⟩ ↦ [ c ∣ v' ∣ κ ]) → base c ⊎ A ≡ B Lemma₃ (↦₁ {b = b}) = inj₁ b Lemma₃ ↦₂ = inj₂ refl Lemma₄ : ∀ {A v v' κ} {c : A ↔ A} → (r : ⟨ c ∣ v ∣ κ ⟩ ↦ [ c ∣ v' ∣ κ ]) → base c ⊎ c ≡ id↔ Lemma₄ {c = swap₊} ↦₁ = inj₁ tt Lemma₄ {c = swap⋆} ↦₁ = inj₁ tt Lemma₄ ↦₂ = inj₂ refl
{ "alphanum_fraction": 0.4657980456, "avg_line_length": 27.0882352941, "ext": "agda", "hexsha": "058369b751660c841bade8cc0f8c93a99a794599", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "Pi/AuxLemmas.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "Pi/AuxLemmas.agda", "max_line_length": 55, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "Pi/AuxLemmas.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 423, "size": 921 }
{-# OPTIONS --sized-types #-} module SBList {A : Set}(_≤_ : A → A → Set) where open import Bound.Total A open import Bound.Total.Order _≤_ open import Data.List open import Data.Product open import Size data SBList : {ι : Size} → Bound → Bound → Set where nil : {ι : Size}{b t : Bound} → LeB b t → SBList {↑ ι} b t cons : {ι : Size}{b t : Bound} (x : A) → LeB b (val x) → LeB (val x) t → SBList {ι} b t → SBList {↑ ι} b t bound : List A → SBList bot top bound [] = nil lebx bound (x ∷ xs) = cons x lebx lext (bound xs) unbound : {b t : Bound} → SBList b t → List A unbound (nil _) = [] unbound (cons x _ _ xs) = x ∷ unbound xs unbound× : {ι : Size}{b t b' t' : Bound} → SBList {ι} b t × SBList {ι} b' t' → List A × List A unbound× (xs , ys) = (unbound xs , unbound ys)
{ "alphanum_fraction": 0.502708559, "avg_line_length": 26.3714285714, "ext": "agda", "hexsha": "110292939c56df05aa900fd12b2926a72c1a449c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/SBList.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/SBList.agda", "max_line_length": 94, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/SBList.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 309, "size": 923 }
module EqProof { A : Set } ( _==_ : A -> A -> Set ) (refl : {x : A} -> x == x) (trans : {x y z : A} -> x == y -> y == z -> x == z) where infix 2 eqProof>_ infixl 2 _===_ infix 3 _by_ eqProof>_ : (x : A) -> x == x eqProof> x = refl _===_ : {x y z : A} -> x == y -> y == z -> x == z xy === yz = trans xy yz _by_ : {x : A}(y : A) -> x == y -> x == y y by eq = eq
{ "alphanum_fraction": 0.3873417722, "avg_line_length": 17.9545454545, "ext": "agda", "hexsha": "a6c7c2d30720d7dd2ecfd00bd3b930ae2fe07798", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "examples/tactics/ac/EqProof.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_path": "examples/tactics/ac/EqProof.agda", "max_line_length": 53, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "examples/tactics/ac/EqProof.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 178, "size": 395 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cohomology.Theory open import homotopy.DisjointlyPointedSet module cohomology.DisjointlyPointedSet {i} (OT : OrdinaryTheory i) where open OrdinaryTheory OT module _ (n : ℤ) (X : Ptd i) (X-is-set : is-set (de⊙ X)) (dec : is-separable X) (ac : has-choice 0 (de⊙ X) i) where private lemma : BigWedge {A = MinusPoint X} (λ _ → ⊙Bool) ≃ de⊙ X lemma = equiv to from to-from from-to where from : de⊙ X → BigWedge {A = MinusPoint X} (λ _ → ⊙Bool) from x with dec x from x | inl p = bwbase from x | inr ¬p = bwin (x , ¬p) false module From = BigWedgeRec {A = MinusPoint X} {X = λ _ → ⊙Bool} (pt X) (λ{_ true → pt X; (x , _) false → x}) (λ _ → idp) to = From.f abstract from-to : ∀ x → from (to x) == x from-to = BigWedge-elim base* in* glue* where base* : from (pt X) == bwbase base* with dec (pt X) base* | inl _ = idp base* | inr ¬p = ⊥-rec (¬p idp) in* : (wp : MinusPoint X) (b : Bool) → from (to (bwin wp b)) == bwin wp b in* wp true with dec (pt X) in* wp true | inl _ = bwglue wp in* wp true | inr pt≠pt = ⊥-rec (pt≠pt idp) in* (x , pt≠x) false with dec x in* (x , pt≠x) false | inl pt=x = ⊥-rec (pt≠x pt=x) in* (x , pt≠x) false | inr pt≠'x = ap (λ ¬p → bwin (x , ¬p) false) $ prop-has-all-paths ¬-is-prop pt≠'x pt≠x glue* : (wp : MinusPoint X) → base* == in* wp true [ (λ x → from (to x) == x) ↓ bwglue wp ] glue* wp = ↓-∘=idf-from-square from to $ ap (ap from) (From.glue-β wp) ∙v⊡ square where square : Square base* idp (bwglue wp) (in* wp true) square with dec (pt X) square | inl _ = br-square (bwglue wp) square | inr ¬p = ⊥-rec (¬p idp) to-from : ∀ x → to (from x) == x to-from x with dec x to-from x | inl pt=x = pt=x to-from x | inr pt≠x = idp C-set : C n X ≃ᴳ Πᴳ (MinusPoint X) (λ _ → C n (⊙Lift ⊙Bool)) C-set = C n X ≃ᴳ⟨ C-emap n (≃-to-⊙≃ lemma idp) ⟩ C n (⊙BigWedge {A = MinusPoint X} (λ _ → ⊙Bool)) ≃ᴳ⟨ C-emap n (⊙BigWedge-emap-r λ _ → ⊙lower-equiv) ⟩ C n (⊙BigWedge {A = MinusPoint X} (λ _ → ⊙Lift ⊙Bool)) ≃ᴳ⟨ C-additive-iso n (λ _ → ⊙Lift ⊙Bool) (MinusPoint-has-choice 0 (separable-has-disjoint-pt dec) ac) ⟩ Πᴳ (MinusPoint X) (λ _ → C n (⊙Lift ⊙Bool)) ≃ᴳ∎ module _ {n : ℤ} (n≠0 : n ≠ 0) (X : Ptd i) (X-is-set : is-set (de⊙ X)) (dec : is-separable X) (ac : has-choice 0 (de⊙ X) i) where C-set-≠-is-trivial : is-trivialᴳ (C n X) C-set-≠-is-trivial = iso-preserves'-trivial (C-set n X X-is-set dec ac) (Πᴳ-is-trivial (MinusPoint X) (λ _ → C n (⊙Lift ⊙Bool)) (λ _ → C-dimension n≠0))
{ "alphanum_fraction": 0.4943521595, "avg_line_length": 37.1604938272, "ext": "agda", "hexsha": "44079398d3bd130fc4ebb7f6474e945b4a7e16c2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/cohomology/DisjointlyPointedSet.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/cohomology/DisjointlyPointedSet.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/cohomology/DisjointlyPointedSet.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1174, "size": 3010 }
-- Data: init commit --{-# OPTIONS --show-implicit #-} --{-# OPTIONS --rewriting #-} module Oscar.Data0 where data ⟦⟧ : Set where ∅ : ⟦⟧ ! : ⟦⟧ → ⟦⟧ data ⟦_⟧ {a} (A : Set a) : Set a where ∅ : ⟦ A ⟧ _∷_ : A → ⟦ A ⟧ → ⟦ A ⟧ data ⟦⟧[_] : ⟦⟧ → Set where ∅ : ∀ {n} → ⟦⟧[ ! n ] ! : ∀ {n} → ⟦⟧[ n ] → ⟦⟧[ ! n ] data ⟦_⟧[_] {a} (A : ⟦⟧ → Set a) : ⟦⟧ → Set a where ∅ : ∀ {n} → ⟦ A ⟧[ ! n ] _∷_ : ∀ {n} → A n → ⟦ A ⟧[ n ] → ⟦ A ⟧[ ! n ] data ⟦⟧[_≤↓_] (m : ⟦⟧) : ⟦⟧ → Set where ∅ : ⟦⟧[ m ≤↓ m ] ! : ∀ {n} → ⟦⟧[ m ≤↓ n ] → ⟦⟧[ m ≤↓ ! n ] data ⟦_⟧[_≤↓_] {a} (A : ⟦⟧ → Set a) (m : ⟦⟧) : ⟦⟧ → Set a where ∅ : ⟦ A ⟧[ m ≤↓ m ] _∷_ : ∀ {n} → A n → ⟦ A ⟧[ m ≤↓ n ] → ⟦ A ⟧[ m ≤↓ ! n ] data ⟦⟧[_↑≤_] (m : ⟦⟧) : ⟦⟧ → Set where ∅ : ⟦⟧[ m ↑≤ m ] ! : ∀ {n} → ⟦⟧[ ! m ↑≤ n ] → ⟦⟧[ m ↑≤ n ] data ⟦_⟧[_↑≤_] {a} (A : ⟦⟧ → Set a) (m : ⟦⟧) : ⟦⟧ → Set a where ∅ : ⟦ A ⟧[ m ↑≤ m ] _∷_ : ∀ {n} → A m → ⟦ A ⟧[ ! m ↑≤ n ] → ⟦ A ⟧[ m ↑≤ n ] data ⟦⟧[_↓≤↓_] : ⟦⟧ → ⟦⟧ → Set where ∅ : ∀ {n} → ⟦⟧[ ∅ ↓≤↓ n ] ! : ∀ {m n} → ⟦⟧[ m ↓≤↓ n ] → ⟦⟧[ ! m ↓≤↓ ! n ] data ⟦_⟧[_↓≤↓_] {a} (A : ⟦⟧ → ⟦⟧ → Set a) : ⟦⟧ → ⟦⟧ → Set a where ∅ : ∀ {n} → ⟦ A ⟧[ ∅ ↓≤↓ n ] ! : ∀ {m n} → A m n → ⟦ A ⟧[ m ↓≤↓ n ] → ⟦ A ⟧[ ! m ↓≤↓ ! n ] -- open import Oscar.Data.Unit -- open import Oscar.Level -- open import Data.Empty -- 𝕋 : ∀ {a} {A : Set a} → A → Set -- 𝕋 = λ _ → ⊤ -- postulate -- ℓ : Level -- Term : Set ℓ -- -- module _ where -- second constructor is recursive -- -- -- Nat -- -- data ⟦⟧ : Set where -- -- ∅ : ⟦⟧ -- -- ! : ⟦⟧ → ⟦⟧ -- -- -- List -- -- data ⟦_⟧ {a} (A : Set a) : Set a where -- -- ∅ : ⟦ A ⟧ -- -- _∷_ : A → ⟦ A ⟧ → ⟦ A ⟧ -- -- -- ⋆⋆ m, size: m -- -- -- [ 0 ] = nothing -- -- -- [ 1 ] = ∅0 -- -- -- [ 4 ] = ∅3 or !2∅3 or !1!2∅3 or !0!1!2∅3 -- -- data ⟦⟧[_] : ⟦⟧ → Set where -- -- ∅ : ∀ {n} → ⟦⟧[ ! n ] -- -- ! : ∀ {n} → ⟦⟧[ n ] → ⟦⟧[ ! n ] -- -- data ⟦_⟧[_] {a} (A : ⟦⟧ → Set a) : ⟦⟧ → Set a where -- -- ∅ : ∀ {n} → ⟦ A ⟧[ ! n ] -- -- _∷_ : ∀ {n} → A n → ⟦ A ⟧[ n ] → ⟦ A ⟧[ ! n ] -- -- -- 0 : ∅ (only) -- -- -- 1 : ∅ or ! ∅ -- -- -- 2 : ∅ or ! ∅ -- -- -- 5 : ∅ or ! -- -- -- size: m + 1 -- -- -- ⋆⋆'' 0 = ∅0 -- -- -- ⋆⋆'' 4 = ∅(m=4) or !3∅4 or !2!3∅4 or !1!2!3∅4 or !0!1!2!3∅4 -- -- data ⋆⋆'' (m : ⟦⟧) : Set where -- -- ∅ : ⋆⋆'' m -- -- ! : ⋆⋆'' (! m) → ⋆⋆'' m -- -- -- ⋆⋆'' ⊂ ⋆⋆ -- -- -- m ≤ n == n - 1 ⋱ m -- -- -- m ↙ n -- -- -- size = n - m -- -- -- AList -- -- -- 4≤↓2 = nothing -- -- -- 2≤↓4 = !23!22∅22 -- -- data ⟦⟧[_≤↓_] (m : ⟦⟧) : ⟦⟧ → Set where -- -- ∅ : ⟦⟧[ m ≤↓ m ] -- -- ! : ∀ {n} → ⟦⟧[ m ≤↓ n ] → ⟦⟧[ m ≤↓ ! n ] -- -- -- A n -- -- (_⋱_] : ⟦⟧ → ⟦⟧ → Set -- -- ( n ⋱ m ] = ⟦⟧[ m ≤↓ n ] -- -- data ⟦_⟧[_≤↓_] {a} (A : ⟦⟧ → Set a) (m : ⟦⟧) : ⟦⟧ → Set where -- -- ∅ : ⟦ A ⟧[ m ≤↓ m ] -- -- ! : ∀ {n} → A n → ⟦ A ⟧[ m ≤↓ n ] → ⟦⟧[ m ≤↓ ! n ] -- -- -- m ≤ n = m ⋰ n - 1 -- -- -- m ↗ n -- -- -- size = n - m (+1?) -- -- -- 2↑≤4 = !24!34∅44 -- -- data _↑≤_ (m : ⟦⟧) : ⟦⟧ → Set where -- -- ∅ : m ↑≤ m -- -- ! : ∀ {n} → ! m ↑≤ n → m ↑≤ n -- -- -- A m -- -- [_⋰_) : ⟦⟧ → ⟦⟧ → Set -- -- [ m ⋰ n ) = m ↑≤ n -- -- -- m ≤ n == n - 1 ⋱ n - m && m - 1 ⋱ 0 -- -- -- size = m (+1?) -- -- -- Inj -- -- -- 2↓≤↓4 = !13!02∅02 -- -- data _↓≤↓_ : ⟦⟧ → ⟦⟧ → Set where -- -- ∅ : ∀ {n} → ∅ ↓≤↓ n -- -- ! : ∀ {m n} → m ↓≤↓ n → ! m ↓≤↓ ! n -- A m n -- -- -- Fin -- -- -- P 0 = ∅0 or !0∅1 or !0!1∅2 or ... -- -- -- P 3 = ∅3 or !3∅4 or !3!4∅5 or ... (infinite) -- -- data P (n : ⋆) : Set where -- -- ∅ : P n -- -- ! : P (! n) → P n -- -- {- -- -- 3 <= 5 = ! (4 <= 5) = ! ! (5 <= 5) = ! ! ∅ -- -- 3≤5 witnesses -- -- n=3,m=5 -- -- 4 5 -- -- -} -- -- -- m ≤ n == m ... n - 1 (this is the same as the two-indexed version) -- -- data _≤_ (n : ⋆) : ⋆ → Set where -- -- ∅ : n ≤ n -- -- ! : ∀ {m} → ! n ≤ m → n ≤ m -- -- -- or -- -- -- m ≤ n == n - 1 ... m -- -- three : ⋆ -- -- three = ! (! (! ∅)) -- -- five : ⋆ -- -- five = ! (! three) -- -- foo : three ≤ five -- -- foo = ! {n = {!!}} (! {n = {!!}} ∅) -- -- -- {- -- -- -- 3 <= 5 = 3 <= ! 4 = ! (3 <= 4) = ! (! (3 <= 3)) = ! ! ∅ -- -- -- 3 ≤ 5 witnesses -- -- -- n=3,m=4 -- -- -- n=3,m=3 -- -- -- -- -- -- -} -- -- -- data _≤_ (n : ⋆) : ⋆ → Set where -- -- -- ∅ : n ≤ n -- -- -- ! : ∀ {m} → n ≤ m → n ≤ ! m -- A m -- -- -- {- -- -- -- 3 <= 5 -- -- -- m=2,n=4 -- -- -- m=1,n=3 -- -- -- m=0,n=2 -- -- -- -} -- -- -- data _≤_ : ⋆ → ⋆ → Set where -- -- -- ∅ : ∀ {n} → ∅ ≤ n -- -- -- ! : ∀ {m n} → m ≤ n → ! m ≤ ! n -- -- -- -- data # (n : ⋆) : Set where -- -- -- -- ∅ : # n -- -- -- -- ! : # ( -- -- -- -- data # : ⋆ → Set where -- -- -- -- ∅ : # n -- -- -- -- ! : ⋆ -- -- -- -- data ⋆[_] {a} (A : Set a) : Set a where -- -- -- -- ∅ : ⋆[ A ] -- -- -- -- _∷_ : A → ⋆[ A ] → ⋆[ A ] -- -- -- -- data _≥_ (n : ⋆) : ⋆ → Set where -- -- -- -- ∅ : n ≥ n -- -- -- -- ! : ∀ {m} → n ≥ ¹⁺ m → n ≥ m -- -- -- -- {- -- -- -- -- data _≤_ (n : ⋆) : ⋆ → Set where -- -- -- -- ∅ : n ≤ n -- -- -- -- ! : ∀ {m} → n ≤ m → n ≤ ¹⁺ m -- -- -- -- -} -- -- -- -- data _≥_ : ⋆ → ⋆ → Set where -- -- -- -- ∅ : ∀ {n} → n ≥ ∅ -- -- -- -- ! : ∀ {m n} → n ≥ m → ¹⁺ m ≤ ¹⁺ n -- -- -- -- _≱_ : ⋆ → ⋆ → Set -- -- -- -- n ≱ m = n ≥ m → ⊥ -- -- -- -- ε : ∀ {m} → m ≥ m -- -- -- -- ε = ≥∅ -- -- -- -- ¹⁺≥ : ∀ {n m} → n ≥ m → ¹⁺ n ≥ m -- -- -- -- ¹⁺≥ ≥∅ = ≥⁻¹ ≥∅ -- -- -- -- ¹⁺≥ (≥⁻¹ n≥m) = ≥⁻¹ (¹⁺≥ n≥m) -- -- -- -- ∅≱¹⁺ : ∀ {n} → ∅ ≱ ¹⁺ n -- -- -- -- ∅≱¹⁺ (≥⁻¹ ∅≥²⁺n) = ∅≱¹⁺ ∅≥²⁺n -- -- -- -- _∙_ : ∀ {n m} → n ≥ m → ∀ {l} → m ≥ l → n ≥ l -- -- -- -- ≥∅ ∙ ≥∅ = ≥∅ -- -- -- -- ≥∅ ∙ ≥⁻¹ x₁ = ⊥-elim ({!∅≱¹⁺ !}) -- -- -- -- ≥⁻¹ x ∙ ≥∅ = {!!} -- -- -- -- _∙_ {n} {m} (≥⁻¹ x) {l} (≥⁻¹ x₁) = ≥⁻¹ (x ∙ ¹⁺≥ x₁) -- -- -- -- stop≥ : ∀ {n} → n ≱ ¹⁺ n -- -- -- -- stop≥ {∅} (≥⁻¹ x) = ∅≱¹⁺ x -- -- -- -- stop≥ {¹⁺ n} (≥⁻¹ (≥⁻¹ x)) = {!stop≥ x!} -- -- -- -- ¹⁺≥¹⁺ : ∀ {n m} → n ≥ m → ¹⁺ n ≥ ¹⁺ m -- -- -- -- ¹⁺≥¹⁺ {∅} ≥∅ = ≥⁻¹ {¹⁺ ∅} {!!} -- -- -- -- ¹⁺≥¹⁺ {¹⁺ n} ≥∅ = {!!} -- -- -- -- ¹⁺≥¹⁺ (≥⁻¹ x) = {!!} -- -- -- -- ⁻¹≥⁻¹ : ∀ {n m} → ¹⁺ n ≥ ¹⁺ m → n ≥ m -- -- -- -- ⁻¹≥⁻¹ {n} {∅} (≥⁻¹ x) = {!!} -- -- -- -- ⁻¹≥⁻¹ {∅} {¹⁺ m} (≥⁻¹ x) = ⊥-elim (∅≱¹⁺ (⁻¹≥⁻¹ x)) -- -- -- -- ⁻¹≥⁻¹ {¹⁺ n} {¹⁺ m} (≥⁻¹ x) = (⁻¹≥⁻¹ x) ∙ ¹⁺≥ {!!} -- -- -- -- -- 1>=1 : ¹⁺ ∅ ≥ ¹⁺ ∅ -- -- -- -- -- 1>=1 = ¹⁺ {!!} -- -- -- -- -- {- ⋮↓ -} -- -- -- -- -- {- h { A ∣ 7 ≥ 4 } = { A 7 4 , A 7 5 , A 7 6 , A 7 7 } -} -- -- -- -- -- {- g { A ∣ 4 ≥ 2 } = { A 4 2 , A 4 3 , A 4 4 } -} -- -- -- -- -- {- h∘g{ A ∣ 7 ≥ 2 } = { A 7 2 , A 7 3 , A 7 4 , A 7 5 , A 7 6 , A 7 7 } -} -- -- -- -- -- {- f { A ∣ 2 ≥ 0 } = { } -} -- -- -- -- -- {- g∘f{ A ∣ 4 ≥ 0 } = { A 4 0 , A 4 1 , A 4 2 , A 4 3 , A 4 4 } -} -- -- -- -- -- data ⋆[_/_≥_] {a} (A : ⋆ → ⋆ → Set a) (m : ⋆) : ⋆ → Set a where -- -- -- -- -- ∅ : ⋆[ A / m ≥ ∅ ] -- -- -- -- -- _∷_ : ∀ {n} → A m n → ⋆[ A / m ≥ ¹⁺ n ] → ⋆[ A / m ≥ n ] -- -- -- -- -- _≥'_ : ⋆ → ⋆ → Set -- -- -- -- -- m ≥' n = ⋆[ (λ _ _ → ⊤) / m ≥ n ] -- -- -- -- -- data _≤_ : ⋆ → ⋆ → Set where -- -- -- -- -- ∅ : ∀ {n} → ∅ ≤ n -- -- -- -- -- ¹⁺_ : ∀ {m n} → m ≤ n → ¹⁺ m ≤ ¹⁺ n -- -- -- -- -- {- ⃔⋱ -} -- -- -- -- -- {- { A ∣ 4 ≤ 7 } = { A 3 6 , A 2 5 , A 1 4 , A 0 3 } -} -- -- -- -- -- {- { A ∣ 2 ≤ 4 } = { A 1 3 , A 0 2 } -} -- -- -- -- -- data ⋆[_/_≤_] {a} (A : ⋆ → ⋆ → Set a) : ⋆ → ⋆ → Set a where -- -- -- -- -- ∅ : ∀ {n} → ⋆[ A / ∅ ≤ n ] -- -- -- -- -- _∷_ : ∀ {m n} → A m n → ⋆[ A / m ≤ n ] → ⋆[ A / ¹⁺ m ≤ ¹⁺ n ] -- -- -- -- -- -- ---- indices on first and second constructors: 1 and 2 -- -- -- -- -- -- data ⋆[_,_] : ⋆ → ⋆ → Set where -- -- -- -- -- -- ∅ : ∀ {n} → ⋆[ n , n ] -- -- -- -- -- -- ! : ∀ {m n} → ⋆[ m , n ] → ⋆[ m , ! n ] -- -- -- -- -- -- data ⋆[_,_] : ⋆ → ⋆ → Set where -- -- -- -- -- -- ∅ : ∀ {m n} → ⋆[ m , n ] -- -- -- -- -- -- ! : ∀ {m n} → ⋆[ m , n ] → ⋆[ ! m , ! n ] -- -- -- -- -- -- -- ? -- -- -- -- -- -- data _≛_ : ⋆ → ⋆ → Set where -- -- -- -- -- -- ∅ : ∅ ≛ ∅ -- -- -- -- -- -- ! : ∀ {m} → ⋆[ m , m ] → ⋆[ ! m , ! m ] -- -- -- -- -- -- data [_/_↦_] {a} (A : ⋆ → ⋆ → Set a) : ⋆ → ⋆ → Set a where -- -- -- -- -- -- ∅ : ∀ {n} → [ A / ∅ ↦ n ] -- -- -- -- -- -- ! : ∀ {m n} → A m n → [ A / ! m ↦ ! n ] -- -- -- -- -- -- module _ where -- Two constructors, where the second constructor adds a payload and a recursive element -- -- -- -- -- -- -- List -- -- -- -- -- -- data [_] {a} (A : Set a) : Set a where -- -- -- -- -- -- ∅ : [ A ] -- -- -- -- -- -- _,_ : A → [ A ] → [ A ] -- -- -- -- -- -- -- Fin -- -- -- -- -- -- ⋆[_] = ⋆[ ∅ ,_] -- -- -- -- -- -- record ⊤ : Set where -- -- -- -- -- -- record ∃ {a} {A : Set a} {b} (B : A → Set b) : Set (a ⊔ b) where -- -- -- -- -- -- field -- -- -- -- -- -- ⟱ : A -- -- -- -- -- -- ⟰ : B ⟱ -- -- -- -- -- -- syntax ∃ (λ x → f) = ∃[ x ] f -- -- -- -- -- -- _×_ : ∀ {a} (A : Set a) {b} (B : Set b) → Set (a ⊔ b) -- -- -- -- -- -- A × B = ∃ {A = A} (λ _ → B) -- -- -- -- -- -- -- -- -- -- -- -- -- [_↦_] : ⋆ → ⋆ → Set -- -- -- -- -- -- [_↦_] = [ (λ m n → ⋆[ ! m ] × {![ m ↦ n ]!}) /_↦_] -- -- -- -- -- -- open import Agda.Builtin.Equality -- -- -- -- -- -- open import Data.Empty
{ "alphanum_fraction": 0.220886951, "avg_line_length": 29.201863354, "ext": "agda", "hexsha": "056b52c233d34d81b350e0c3dbb0ca7ca6660736", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Data0.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Data0.agda", "max_line_length": 121, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Data0.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5280, "size": 9403 }
{-# OPTIONS --universe-polymorphism #-} module Issue464 where open import Common.Level data _×_ {a b}(A : Set a)(B : Set b) : Set (a ⊔ b) where _,_ : A → B → A × B data ⊥ : Set where record ⊤ : Set where ----------------------------------- data nonSP : Set1 where ι : nonSP δ : (A : Set) -> nonSP -> nonSP ⟦_⟧ : nonSP -> (Set × ⊤) -> Set ⟦ ι ⟧ UT = ⊤ ⟦ (δ A γ) ⟧ (U , T) = (U -> A) × ⟦ γ ⟧ (U , T) data U (γ : nonSP) : Set where intro : ⟦ γ ⟧ (U γ , _) -> U γ -- the positivity checker objects (as it should) if "(Set × ⊤)" is changed to "Set" -- in the type of ⟦_⟧ and "(U γ , _)" is changed accordingly to "U γ". bad : Set bad = U (δ ⊥ ι) -- constructor in : (bad -> ⊥) -> bad p : bad -> ⊥ p (intro (x , _)) = x (intro (x , _)) absurd : ⊥ absurd = p (intro (p , _))
{ "alphanum_fraction": 0.4955527319, "avg_line_length": 21.8611111111, "ext": "agda", "hexsha": "63da430bf944eaf2017531547d961d62c95b50a4", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue464.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue464.agda", "max_line_length": 83, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue464.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 310, "size": 787 }
module PropositionalFormula where open import HasNegation open import IsPropositionalFormula open import Formula open import HasNeitherNor record PropositionalFormula : Set where constructor ⟨_⟩ field {formula} : Formula isPropositionalFormula : IsPropositionalFormula formula open PropositionalFormula instance HasNegationPropositionalFormula : HasNegation PropositionalFormula HasNegation.~ HasNegationPropositionalFormula ⟨ φ ⟩ = ⟨ logical φ φ ⟩ instance HasNeitherNorPropositionalFormula : HasNeitherNor PropositionalFormula HasNeitherNor._⊗_ HasNeitherNorPropositionalFormula ⟨ φ₁ ⟩ ⟨ φ₂ ⟩ = ⟨ logical φ₁ φ₂ ⟩ {-# DISPLAY IsPropositionalFormula.logical = _⊗_ #-}
{ "alphanum_fraction": 0.8154069767, "avg_line_length": 27.52, "ext": "agda", "hexsha": "32cafab66e7053e9880c1229e2e1b900a0003461", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/PropositionalFormula.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/PropositionalFormula.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/PropositionalFormula.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 181, "size": 688 }
------------------------------------------------------------------------ -- List equality ------------------------------------------------------------------------ module Data.List.Equality where open import Data.List open import Relation.Nullary open import Relation.Binary module Equality (S : Setoid) where open Setoid S renaming (_≈_ to _≊_) infixr 5 _∷_ infix 4 _≈_ data _≈_ : List carrier → List carrier → Set where [] : [] ≈ [] _∷_ : ∀ {x xs y ys} (x≈y : x ≊ y) (xs≈ys : xs ≈ ys) → x ∷ xs ≈ y ∷ ys setoid : Setoid setoid = record { carrier = List carrier ; _≈_ = _≈_ ; isEquivalence = record { refl = refl' ; sym = sym' ; trans = trans' } } where refl' : Reflexive _≈_ refl' {[]} = [] refl' {x ∷ xs} = refl ∷ refl' {xs} sym' : Symmetric _≈_ sym' [] = [] sym' (x≈y ∷ xs≈ys) = sym x≈y ∷ sym' xs≈ys trans' : Transitive _≈_ trans' [] [] = [] trans' (x≈y ∷ xs≈ys) (y≈z ∷ ys≈zs) = trans x≈y y≈z ∷ trans' xs≈ys ys≈zs open Setoid setoid public hiding (_≈_) module DecidableEquality (D : DecSetoid) where open DecSetoid D hiding (_≈_) open Equality setoid renaming (setoid to List-setoid) decSetoid : DecSetoid decSetoid = record { isDecEquivalence = record { isEquivalence = Setoid.isEquivalence List-setoid ; _≟_ = dec } } where dec : Decidable _≈_ dec [] [] = yes [] dec (x ∷ xs) (y ∷ ys) with x ≟ y | dec xs ys ... | yes x≈y | yes xs≈ys = yes (x≈y ∷ xs≈ys) ... | no ¬x≈y | _ = no helper where helper : ¬ _≈_ (x ∷ xs) (y ∷ ys) helper (x≈y ∷ _) = ¬x≈y x≈y ... | _ | no ¬xs≈ys = no helper where helper : ¬ _≈_ (x ∷ xs) (y ∷ ys) helper (_ ∷ xs≈ys) = ¬xs≈ys xs≈ys dec [] (y ∷ ys) = no λ() dec (x ∷ xs) [] = no λ() open DecSetoid decSetoid public module PropositionalEquality {A : Set} where open import Relation.Binary.PropositionalEquality as PropEq using (_≡_) renaming (refl to ≡-refl) open Equality (PropEq.setoid A) public ≈⇒≡ : _≈_ ⇒ _≡_ ≈⇒≡ [] = ≡-refl ≈⇒≡ (≡-refl ∷ xs≈ys) with ≈⇒≡ xs≈ys ≈⇒≡ (≡-refl ∷ xs≈ys) | ≡-refl = ≡-refl
{ "alphanum_fraction": 0.4778067885, "avg_line_length": 25.8202247191, "ext": "agda", "hexsha": "0e6e6d4c1efa85657fc648cb181a7103dce2b49a", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Data/List/Equality.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Data/List/Equality.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Data/List/Equality.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 860, "size": 2298 }
open import Everything module Test.ProblemWithDerivation where postulate A : Set B : Set _~A~_ : A → A → Set _~B~_ : B → B → Set s1 : A → B f1 : ∀ {x y} → x ~A~ y → s1 x ~B~ s1 y module _ {𝔭} (𝔓 : Ø 𝔭) where open Substitunction 𝔓 test-before : ∀ {m n ℓ} {f : Substitunction m n} (P : LeftExtensionṖroperty ℓ Substitunction Proposextensequality m) (let P₀ = π₀ (π₀ P)) → P₀ f → P₀ (ε ∙ f) test-before P pf = hmap _ P pf -- needs Oscar.Class.Hmap.Transleftidentity.Relprop'idFromTransleftidentity instance 𝓢urjectivity1 : Smap.class _~A~_ _~B~_ s1 s1 𝓢urjectivity1 .⋆ _ _ = f1 test : ∀ {x y} → x ~A~ y → s1 x ~B~ s1 y test {x} {y} = smap test-after : ∀ {m n ℓ} {f : Substitunction m n} (P : LeftExtensionṖroperty ℓ Substitunction Proposextensequality m) (let P₀ = π₀ (π₀ P)) → P₀ f → P₀ (ε ∙ f) test-after P pf = hmap _ P pf
{ "alphanum_fraction": 0.6211251435, "avg_line_length": 28.0967741935, "ext": "agda", "hexsha": "d7a2e644ef75c56ed5a7f3bf8fb35d62e229d8eb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Test/ProblemWithDerivation.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Test/ProblemWithDerivation.agda", "max_line_length": 160, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Test/ProblemWithDerivation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 372, "size": 871 }
module Examples where open import Data.List hiding (reverse) open import Data.List.All open import Data.Nat open import Typing open import Syntax ex1 : Expr [] TUnit ex1 = letbind [] (new [] (delay send!)) (letpair (left []) (here []) (letbind (rght (left [])) (fork (wait (here []))) (close (there UUnit (here []))))) ex1dual : Expr [] TUnit ex1dual = letbind [] (new [] (delay send!)) (letpair (left []) (here []) (letbind (left (rght [])) (fork (close (here []))) (wait (there UUnit (here []))))) -- sending and receiving ex2 : Expr [] TUnit ex2 = letbind [] (new [] (delay (Typing.send TInt (delay send!)))) (letpair (left []) (here []) (letbind (left (rght [])) (fork (letbind (rght []) (nat [] 42) (letbind (left (left [])) (Expr.send (rght (left [])) (here []) (here [])) (letbind (left []) (close (here [])) (var (here [])))))) (letbind (rght (left [])) (Expr.recv (here [])) (letpair (left (rght [])) (here []) (letbind (left (left (rght []))) (wait (here (UInt ∷ []))) (var (here (UUnit ∷ [])))))))) -- higher order sending and receiving ex3 : Expr [] TUnit ex3 = letbind [] (new [] (delay (Typing.send (TChan send!) (delay send!)))) (letbind (rght []) (new [] (delay send!)) (letpair (left (rght [])) (here []) (letpair (rght (rght (left []))) (here []) (letbind (left (rght (left (left [])))) (fork (letbind (left (left (rght []))) (Expr.send (left (rght [])) (here []) (here [])) (letbind (left (rght [])) (close (here [])) (wait (there UUnit (here [])))))) (letbind (left (left [])) (Expr.recv (there UUnit (here []))) (letpair (left []) (here []) (letbind (left (rght [])) (wait (here [])) (letbind (left (left [])) (close (there UUnit (here []))) (var (here [])))))))))) -- branching ex4 : Expr [] TUnit ex4 = letbind [] (new [] (delay (sintern (delay send!) (delay send?)))) (letpair (left []) (here []) (letbind (left (rght [])) (fork (letbind (left []) (select Left (here [])) (close (here [])))) (branch (left (left [])) (there UUnit (here [])) (wait (here [])) (close (here []))))) -- simple lambda: (λx.x)() ex5 : Expr [] TUnit ex5 = letbind [] (llambda [] [] (var (here []))) (letbind (rght []) (unit []) (app (rght (left [])) (here []) (here []))) -- lambda app: (λfx.fx) (λx.x)() ex6 : Expr [] TUnit ex6 = letbind [] (llambda [] [] (llambda (left []) [] (app (rght (left [])) (here []) (here [])))) (letbind (rght []) (llambda [] [] (var (here []))) (letbind (rght (rght [])) (unit []) (letbind (rght (left (left []))) (app (rght (left [])) (here []) (here [])) (app (left (rght [])) (here []) (here [])))))
{ "alphanum_fraction": 0.503021685, "avg_line_length": 33.8915662651, "ext": "agda", "hexsha": "e7e1a3fe3355e7c5488f246cd3313280b70bdbe8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "peterthiemann/definitional-session", "max_forks_repo_path": "src/Examples.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "peterthiemann/definitional-session", "max_issues_repo_path": "src/Examples.agda", "max_line_length": 98, "max_stars_count": 9, "max_stars_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "peterthiemann/definitional-session", "max_stars_repo_path": "src/Examples.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-18T08:10:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-19T16:33:27.000Z", "num_tokens": 915, "size": 2813 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Pointwise products of binary relations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Product.Relation.Binary.Pointwise.NonDependent where open import Data.Product as Prod open import Data.Sum open import Data.Unit.Base using (⊤) open import Function open import Function.Equality as F using (_⟶_; _⟨$⟩_) open import Function.Equivalence as Eq using (Equivalence; _⇔_; module Equivalence) open import Function.Injection as Inj using (Injection; _↣_; module Injection) open import Function.Inverse as Inv using (Inverse; _↔_; module Inverse) open import Function.LeftInverse as LeftInv using (LeftInverse; _↞_; _LeftInverseOf_; module LeftInverse) open import Function.Related open import Function.Surjection as Surj using (Surjection; _↠_; module Surjection) import Relation.Nullary.Decidable as Dec open import Relation.Nullary.Product open import Relation.Binary open import Relation.Binary.PropositionalEquality as P using (_≡_) module _ {a₁ a₂ ℓ₁ ℓ₂} {A₁ : Set a₁} {A₂ : Set a₂} where ------------------------------------------------------------------------ -- Pointwise lifting Pointwise : Rel A₁ ℓ₁ → Rel A₂ ℓ₂ → Rel (A₁ × A₂) _ Pointwise _∼₁_ _∼₂_ = (_∼₁_ on proj₁) -×- (_∼₂_ on proj₂) ------------------------------------------------------------------------ -- Pointwise preserves many relational properties ×-reflexive : ∀ {_≈₁_ _∼₁_ _≈₂_ _∼₂_} → _≈₁_ ⇒ _∼₁_ → _≈₂_ ⇒ _∼₂_ → (Pointwise _≈₁_ _≈₂_) ⇒ (Pointwise _∼₁_ _∼₂_) ×-reflexive refl₁ refl₂ (x∼y₁ , x∼y₂) = refl₁ x∼y₁ , refl₂ x∼y₂ ×-refl : ∀ {_∼₁_ _∼₂_} → Reflexive _∼₁_ → Reflexive _∼₂_ → Reflexive (Pointwise _∼₁_ _∼₂_) ×-refl refl₁ refl₂ = refl₁ , refl₂ ×-irreflexive₁ : ∀ {_≈₁_ _<₁_ _≈₂_ _<₂_} → Irreflexive _≈₁_ _<₁_ → Irreflexive (Pointwise _≈₁_ _≈₂_) (Pointwise _<₁_ _<₂_) ×-irreflexive₁ ir x≈y x<y = ir (proj₁ x≈y) (proj₁ x<y) ×-irreflexive₂ : ∀ {_≈₁_ _<₁_ _≈₂_ _<₂_} → Irreflexive _≈₂_ _<₂_ → Irreflexive (Pointwise _≈₁_ _≈₂_) (Pointwise _<₁_ _<₂_) ×-irreflexive₂ ir x≈y x<y = ir (proj₂ x≈y) (proj₂ x<y) ×-symmetric : ∀ {_∼₁_ _∼₂_} → Symmetric _∼₁_ → Symmetric _∼₂_ → Symmetric (Pointwise _∼₁_ _∼₂_) ×-symmetric sym₁ sym₂ (x∼y₁ , x∼y₂) = sym₁ x∼y₁ , sym₂ x∼y₂ ×-transitive : ∀ {_∼₁_ _∼₂_} → Transitive _∼₁_ → Transitive _∼₂_ → Transitive (Pointwise _∼₁_ _∼₂_) ×-transitive trans₁ trans₂ x∼y y∼z = trans₁ (proj₁ x∼y) (proj₁ y∼z) , trans₂ (proj₂ x∼y) (proj₂ y∼z) ×-antisymmetric : ∀ {_≈₁_ _≤₁_ _≈₂_ _≤₂_} → Antisymmetric _≈₁_ _≤₁_ → Antisymmetric _≈₂_ _≤₂_ → Antisymmetric (Pointwise _≈₁_ _≈₂_) (Pointwise _≤₁_ _≤₂_) ×-antisymmetric antisym₁ antisym₂ (x≤y₁ , x≤y₂) (y≤x₁ , y≤x₂) = (antisym₁ x≤y₁ y≤x₁ , antisym₂ x≤y₂ y≤x₂) ×-asymmetric₁ : ∀ {_<₁_ _∼₂_} → Asymmetric _<₁_ → Asymmetric (Pointwise _<₁_ _∼₂_) ×-asymmetric₁ asym₁ x<y y<x = asym₁ (proj₁ x<y) (proj₁ y<x) ×-asymmetric₂ : ∀ {_∼₁_ _<₂_} → Asymmetric _<₂_ → Asymmetric (Pointwise _∼₁_ _<₂_) ×-asymmetric₂ asym₂ x<y y<x = asym₂ (proj₂ x<y) (proj₂ y<x) ×-respects₂ : ∀ {_≈₁_ _∼₁_ _≈₂_ _∼₂_} → _∼₁_ Respects₂ _≈₁_ → _∼₂_ Respects₂ _≈₂_ → (Pointwise _∼₁_ _∼₂_) Respects₂ (Pointwise _≈₁_ _≈₂_) ×-respects₂ {_≈₁_} {_∼₁_} {_≈₂_} {_∼₂_} resp₁ resp₂ = resp¹ , resp² where _∼_ = Pointwise _∼₁_ _∼₂_ _≈_ = Pointwise _≈₁_ _≈₂_ resp¹ : ∀ {x} → (x ∼_) Respects _≈_ resp¹ y≈y' x∼y = proj₁ resp₁ (proj₁ y≈y') (proj₁ x∼y) , proj₁ resp₂ (proj₂ y≈y') (proj₂ x∼y) resp² : ∀ {y} → (_∼ y) Respects _≈_ resp² x≈x' x∼y = proj₂ resp₁ (proj₁ x≈x') (proj₁ x∼y) , proj₂ resp₂ (proj₂ x≈x') (proj₂ x∼y) ×-total : ∀ {_∼₁_ _∼₂_} → Symmetric _∼₁_ → Total _∼₁_ → Total _∼₂_ → Total (Pointwise _∼₁_ _∼₂_) ×-total sym₁ total₁ total₂ (x₁ , x₂) (y₁ , y₂) with total₁ x₁ y₁ | total₂ x₂ y₂ ... | inj₁ x₁∼y₁ | inj₁ x₂∼y₂ = inj₁ ( x₁∼y₁ , x₂∼y₂) ... | inj₁ x₁∼y₁ | inj₂ y₂∼x₂ = inj₂ (sym₁ x₁∼y₁ , y₂∼x₂) ... | inj₂ y₁∼x₁ | inj₂ y₂∼x₂ = inj₂ ( y₁∼x₁ , y₂∼x₂) ... | inj₂ y₁∼x₁ | inj₁ x₂∼y₂ = inj₁ (sym₁ y₁∼x₁ , x₂∼y₂) ×-decidable : ∀ {_∼₁_ _∼₂_} → Decidable _∼₁_ → Decidable _∼₂_ → Decidable (Pointwise _∼₁_ _∼₂_) ×-decidable _≟₁_ _≟₂_ (x₁ , x₂) (y₁ , y₂) = (x₁ ≟₁ y₁) ×-dec (x₂ ≟₂ y₂) -- Some collections of properties which are preserved by ×-Rel. ×-isEquivalence : ∀ {_≈₁_ _≈₂_} → IsEquivalence _≈₁_ → IsEquivalence _≈₂_ → IsEquivalence (Pointwise _≈₁_ _≈₂_) ×-isEquivalence {_≈₁_ = _≈₁_} {_≈₂_ = _≈₂_} eq₁ eq₂ = record { refl = ×-refl {_∼₁_ = _≈₁_} {_∼₂_ = _≈₂_} (refl eq₁) (refl eq₂) ; sym = ×-symmetric {_∼₁_ = _≈₁_} {_∼₂_ = _≈₂_} (sym eq₁) (sym eq₂) ; trans = ×-transitive {_∼₁_ = _≈₁_} {_∼₂_ = _≈₂_} (trans eq₁) (trans eq₂) } where open IsEquivalence ×-isDecEquivalence : ∀ {_≈₁_ _≈₂_} → IsDecEquivalence _≈₁_ → IsDecEquivalence _≈₂_ → IsDecEquivalence (Pointwise _≈₁_ _≈₂_) ×-isDecEquivalence eq₁ eq₂ = record { isEquivalence = ×-isEquivalence (isEquivalence eq₁) (isEquivalence eq₂) ; _≟_ = ×-decidable (_≟_ eq₁) (_≟_ eq₂) } where open IsDecEquivalence ×-isPreorder : ∀ {_≈₁_ _∼₁_ _≈₂_ _∼₂_} → IsPreorder _≈₁_ _∼₁_ → IsPreorder _≈₂_ _∼₂_ → IsPreorder (Pointwise _≈₁_ _≈₂_) (Pointwise _∼₁_ _∼₂_) ×-isPreorder {_∼₁_ = _∼₁_} {_∼₂_ = _∼₂_} pre₁ pre₂ = record { isEquivalence = ×-isEquivalence (isEquivalence pre₁) (isEquivalence pre₂) ; reflexive = ×-reflexive {_∼₁_ = _∼₁_} {_∼₂_ = _∼₂_} (reflexive pre₁) (reflexive pre₂) ; trans = ×-transitive {_∼₁_ = _∼₁_} {_∼₂_ = _∼₂_} (trans pre₁) (trans pre₂) } where open IsPreorder ×-isPartialOrder : ∀ {_≈₁_ _≤₁_ _≈₂_ _≤₂_} → IsPartialOrder _≈₁_ _≤₁_ → IsPartialOrder _≈₂_ _≤₂_ → IsPartialOrder (Pointwise _≈₁_ _≈₂_) (Pointwise _≤₁_ _≤₂_) ×-isPartialOrder {_≤₁_ = _≤₁_} {_≤₂_ = _≤₂_} po₁ po₂ = record { isPreorder = ×-isPreorder (isPreorder po₁) (isPreorder po₂) ; antisym = ×-antisymmetric {_≤₁_ = _≤₁_} {_≤₂_ = _≤₂_} (antisym po₁) (antisym po₂) } where open IsPartialOrder ×-isStrictPartialOrder : ∀ {_≈₁_ _<₁_ _≈₂_ _<₂_} → IsStrictPartialOrder _≈₁_ _<₁_ → IsStrictPartialOrder _≈₂_ _<₂_ → IsStrictPartialOrder (Pointwise _≈₁_ _≈₂_) (Pointwise _<₁_ _<₂_) ×-isStrictPartialOrder {_<₁_ = _<₁_} {_≈₂_ = _≈₂_} {_<₂_ = _<₂_} spo₁ spo₂ = record { isEquivalence = ×-isEquivalence (isEquivalence spo₁) (isEquivalence spo₂) ; irrefl = ×-irreflexive₁ {_<₁_ = _<₁_} {_≈₂_} {_<₂_} (irrefl spo₁) ; trans = ×-transitive {_∼₁_ = _<₁_} {_<₂_} (trans spo₁) (trans spo₂) ; <-resp-≈ = ×-respects₂ (<-resp-≈ spo₁) (<-resp-≈ spo₂) } where open IsStrictPartialOrder ------------------------------------------------------------------------ -- "Packages" can also be combined. module _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} where ×-preorder : Preorder ℓ₁ ℓ₂ _ → Preorder ℓ₃ ℓ₄ _ → Preorder _ _ _ ×-preorder p₁ p₂ = record { isPreorder = ×-isPreorder (isPreorder p₁) (isPreorder p₂) } where open Preorder ×-setoid : Setoid ℓ₁ ℓ₂ → Setoid ℓ₃ ℓ₄ → Setoid _ _ ×-setoid s₁ s₂ = record { isEquivalence = ×-isEquivalence (isEquivalence s₁) (isEquivalence s₂) } where open Setoid ×-decSetoid : DecSetoid ℓ₁ ℓ₂ → DecSetoid ℓ₃ ℓ₄ → DecSetoid _ _ ×-decSetoid s₁ s₂ = record { isDecEquivalence = ×-isDecEquivalence (isDecEquivalence s₁) (isDecEquivalence s₂) } where open DecSetoid ×-poset : Poset ℓ₁ ℓ₂ _ → Poset ℓ₃ ℓ₄ _ → Poset _ _ _ ×-poset s₁ s₂ = record { isPartialOrder = ×-isPartialOrder (isPartialOrder s₁) (isPartialOrder s₂) } where open Poset ×-strictPartialOrder : StrictPartialOrder ℓ₁ ℓ₂ _ → StrictPartialOrder ℓ₃ ℓ₄ _ → StrictPartialOrder _ _ _ ×-strictPartialOrder s₁ s₂ = record { isStrictPartialOrder = ×-isStrictPartialOrder (isStrictPartialOrder s₁) (isStrictPartialOrder s₂) } where open StrictPartialOrder -- A piece of infix notation for combining setoids infix 4 _×ₛ_ _×ₛ_ : Setoid ℓ₁ ℓ₂ → Setoid ℓ₃ ℓ₄ → Setoid _ _ _×ₛ_ = ×-setoid ------------------------------------------------------------------------ -- The propositional equality setoid over products can be -- decomposed using ×-Rel module _ {a b} {A : Set a} {B : Set b} where ≡×≡⇒≡ : Pointwise _≡_ _≡_ ⇒ _≡_ {A = A × B} ≡×≡⇒≡ (P.refl , P.refl) = P.refl ≡⇒≡×≡ : _≡_ {A = A × B} ⇒ Pointwise _≡_ _≡_ ≡⇒≡×≡ P.refl = (P.refl , P.refl) Pointwise-≡↔≡ : Inverse (P.setoid A ×ₛ P.setoid B) (P.setoid (A × B)) Pointwise-≡↔≡ = record { to = record { _⟨$⟩_ = id; cong = ≡×≡⇒≡ } ; from = record { _⟨$⟩_ = id; cong = ≡⇒≡×≡ } ; inverse-of = record { left-inverse-of = λ _ → (P.refl , P.refl) ; right-inverse-of = λ _ → P.refl } } ≡?×≡?⇒≡? : Decidable {A = A} _≡_ → Decidable {A = B} _≡_ → Decidable {A = A × B} _≡_ ≡?×≡?⇒≡? ≟₁ ≟₂ p q = Dec.map′ ≡×≡⇒≡ ≡⇒≡×≡ (×-decidable ≟₁ ≟₂ p q) ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 0.15 infixr 2 _×-Rel_ _×-Rel_ = Pointwise {-# WARNING_ON_USAGE _×-Rel_ "Warning: _×-Rel_ was deprecated in v0.15. Please use Pointwise instead." #-} Rel↔≡ = Pointwise-≡↔≡ {-# WARNING_ON_USAGE Rel↔≡ "Warning: Rel↔≡ was deprecated in v0.15. Please use Pointwise-≡↔≡ instead." #-} _×-reflexive_ = ×-reflexive {-# WARNING_ON_USAGE _×-reflexive_ "Warning: _×-reflexive_ was deprecated in v0.15. Please use ×-reflexive instead." #-} _×-refl_ = ×-refl {-# WARNING_ON_USAGE _×-refl_ "Warning: _×-refl_ was deprecated in v0.15. Please use ×-refl instead." #-} _×-symmetric_ = ×-symmetric {-# WARNING_ON_USAGE _×-symmetric_ "Warning: _×-symmetric_ was deprecated in v0.15. Please use ×-symmetric instead." #-} _×-transitive_ = ×-transitive {-# WARNING_ON_USAGE _×-transitive_ "Warning: _×-transitive_ was deprecated in v0.15. Please use ×-transitive instead." #-} _×-antisymmetric_ = ×-antisymmetric {-# WARNING_ON_USAGE _×-antisymmetric_ "Warning: _×-antisymmetric_ was deprecated in v0.15. Please use ×-antisymmetric instead." #-} _×-≈-respects₂_ = ×-respects₂ {-# WARNING_ON_USAGE _×-≈-respects₂_ "Warning: _×-≈-respects₂_ was deprecated in v0.15. Please use ×-respects₂ instead." #-} _×-decidable_ = ×-decidable {-# WARNING_ON_USAGE _×-decidable_ "Warning: _×-decidable_ was deprecated in v0.15. Please use ×-decidable instead." #-} _×-isEquivalence_ = ×-isEquivalence {-# WARNING_ON_USAGE _×-isEquivalence_ "Warning: _×-isEquivalence_ was deprecated in v0.15. Please use ×-isEquivalence instead." #-} _×-isDecEquivalence_ = ×-isDecEquivalence {-# WARNING_ON_USAGE _×-isDecEquivalence_ "Warning: _×-isDecEquivalence_ was deprecated in v0.15. Please use ×-isDecEquivalence instead." #-} _×-isPreorder_ = ×-isPreorder {-# WARNING_ON_USAGE _×-isPreorder_ "Warning: _×-isPreorder_ was deprecated in v0.15. Please use ×-isPreorder instead." #-} _×-isPartialOrder_ = ×-isPartialOrder {-# WARNING_ON_USAGE _×-isPartialOrder_ "Warning: _×-isPartialOrder_ was deprecated in v0.15. Please use ×-isPartialOrder instead." #-} _×-isStrictPartialOrder_ = ×-isStrictPartialOrder {-# WARNING_ON_USAGE _×-isStrictPartialOrder_ "Warning: _×-isStrictPartialOrder_ was deprecated in v0.15. Please use ×-isStrictPartialOrder instead." #-} _×-preorder_ = ×-preorder {-# WARNING_ON_USAGE _×-preorder_ "Warning: _×-preorder_ was deprecated in v0.15. Please use ×-preorder instead." #-} _×-setoid_ = ×-setoid {-# WARNING_ON_USAGE _×-setoid_ "Warning: _×-setoid_ was deprecated in v0.15. Please use ×-setoid instead." #-} _×-decSetoid_ = ×-decSetoid {-# WARNING_ON_USAGE _×-decSetoid_ "Warning: _×-decSetoid_ was deprecated in v0.15. Please use ×-decSetoid instead." #-} _×-poset_ = ×-poset {-# WARNING_ON_USAGE _×-poset_ "Warning: _×-poset_ was deprecated in v0.15. Please use ×-poset instead." #-} _×-strictPartialOrder_ = ×-strictPartialOrder {-# WARNING_ON_USAGE _×-strictPartialOrder_ "Warning: _×-strictPartialOrder_ was deprecated in v0.15. Please use ×-strictPartialOrder instead." #-} _×-≟_ = ≡?×≡?⇒≡? {-# WARNING_ON_USAGE _×-≟_ "Warning: _×-≟_ was deprecated in v0.15. Please use ≡?×≡?⇒≡? instead." #-}
{ "alphanum_fraction": 0.5877441593, "avg_line_length": 36.2638888889, "ext": "agda", "hexsha": "13880ea752bf3453125af2bb6d8bbb7328a46cdb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/NonDependent.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/NonDependent.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/NonDependent.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5166, "size": 13055 }
-- Andreas, 2013-10-25 issue reported by Jesper Cockx -- simplified test case by Nisse -- {-# OPTIONS -v tc.meta:30 #-} module Issue920 where import Common.Level postulate Eq : (A : Set) (x : A) → A → Set cast : (A B : Set) → A → B magic : (P : Set → Set) (A : Set) → P A bad : (A : Set) (x : A) → Eq A (cast A A x) x bad A x = magic (λ B → Eq B (cast A B x) {!x!}) A -- Should produce yellow, since there is no solution for ?0 -- Handling of linearity in constraint solver was buggy: -- ?0 : (A : Set) (x : A) (B : Set) -> B -- ?0 A x A := x -- was simply solved by ?0 := λ A x B → x -- since the non-linear variable did not appear on the rhs. -- However, this solution is ill-typed. -- Instead, we now only attempt pruning in case of non-linearity, -- which fails here: B cannot be pruned since its the return type, -- and A cannot be pruned since its the type of argument x.
{ "alphanum_fraction": 0.6215316315, "avg_line_length": 29.064516129, "ext": "agda", "hexsha": "f2eb61fb62ae1004da9e6db91f1f81895dd915f7", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue920.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue920.agda", "max_line_length": 66, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue920.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 290, "size": 901 }
-- Andreas, 2015-12-29 record ⊤ : Set where data P : ⊤ → Set where c : P record{} d : P record{} test : (x : ⊤) (p : P x) → Set test _ c with Set test _ d | z = ⊤ -- Expected error: with-clause pattern mismatch. -- The error should be printed nicely, like: -- -- With clause pattern d is not an instance of its parent pattern c -- when checking that the clause -- test _ c with Set -- test _ d | z = ⊤ -- has type (x : ⊤) → P x → Set
{ "alphanum_fraction": 0.6108597285, "avg_line_length": 21.0476190476, "ext": "agda", "hexsha": "4ad8d6368987a67f703747de159893b8fe5a6556", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/WithClausePatternMismatch.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/WithClausePatternMismatch.agda", "max_line_length": 67, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/WithClausePatternMismatch.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 146, "size": 442 }
{-# OPTIONS --without-K --safe #-} -- A Category enriched over Setoids is... a Category! module Categories.Enriched.Over.Setoids where open import Level open import Data.Product using (uncurry; proj₁; proj₂; Σ; _,_) open import Data.Unit using (tt) open import Function.Equality using (_⟨$⟩_; cong) open import Relation.Binary.Bundles using (Setoid) open import Categories.Category.Core using () renaming (Category to SCategory) open import Categories.Category.Equivalence using (StrongEquivalence) open import Categories.Category.Monoidal.Instance.Setoids open import Categories.Functor renaming (id to idF) open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_) open import Categories.Enriched.Category import Categories.Morphism.Reasoning as MR Category′ : (o ℓ t : Level) → Set (suc (o ⊔ ℓ ⊔ t)) Category′ o ℓ t = Category (Setoids-Monoidal {t} {ℓ}) o -- Start with the translation functions Cat→Cat′ : {o ℓ t : Level} → SCategory o ℓ t → Category′ o t ℓ Cat→Cat′ C = record { Obj = Obj ; hom = λ a b → record { Carrier = a ⇒ b ; _≈_ = _≈_ ; isEquivalence = equiv } ; id = record { _⟨$⟩_ = λ _ → id ; cong = λ _ → Equiv.refl } ; ⊚ = record { _⟨$⟩_ = uncurry _∘_ ; cong = uncurry ∘-resp-≈ } ; ⊚-assoc = λ { {x = (x₁ , x₂) , x₃} {(y₁ , y₂) , y₃} ((x₁≈y₁ , x₂≈y₂) , x₃≈y₃) → begin (x₁ ∘ x₂) ∘ x₃ ≈⟨ assoc {h = x₁} ⟩ x₁ ∘ x₂ ∘ x₃ ≈⟨ (x₁≈y₁ ⟩∘⟨ x₂≈y₂ ⟩∘⟨ x₃≈y₃) ⟩ y₁ ∘ y₂ ∘ y₃ ∎ } ; unitˡ = λ { {_} {_} {_ , x} {_ , y} (_ , x≈y) → Equiv.trans (identityˡ {f = x}) x≈y } ; unitʳ = λ z → Equiv.trans identityʳ (proj₁ z) } where open SCategory C open HomReasoning Cat′→Cat : {o ℓ t : Level} → Category′ o ℓ t → SCategory o t ℓ Cat′→Cat 𝓒 = record { Obj = Obj ; _⇒_ = λ a b → Carrier (hom a b) ; _≈_ = λ {a} {b} f g → _≈_ (hom a b) f g ; id = id ⟨$⟩ lift tt ; _∘_ = λ f g → ⊚ ⟨$⟩ (f , g) ; assoc = λ {A} {B} {C} {D} → ⊚-assoc ((refl (hom C D) , refl (hom B C)) , refl (hom A B)) ; sym-assoc = λ {A} {B} {C} {D} → sym (hom A D) (⊚-assoc ((refl (hom C D) , refl (hom B C)) , refl (hom A B))) ; identityˡ = λ {A} {B} → unitˡ (lift tt , refl (hom A B)) ; identityʳ = λ {A} {B} → unitʳ (refl (hom A B) , lift tt) ; identity² = λ {A} → unitˡ (lift tt , refl (hom A A)) -- Enriched doesn't have a unit² ; equiv = λ {A} {B} → record { refl = refl (hom A B) ; sym = sym (hom A B) ; trans = trans (hom A B) } ; ∘-resp-≈ = λ f≈h g≈i → cong ⊚ (f≈h , g≈i) } where open Category 𝓒 open Setoid -- Back-and-forth gives the same thing, SCat version -- the details are trivial, but have to be spelled out SCat-Equiv : {o ℓ t : Level} → (C : SCategory o ℓ t) → StrongEquivalence C (Cat′→Cat (Cat→Cat′ C)) SCat-Equiv C = record { F = fwd ; G = bwd ; weak-inverse = record { F∘G≈id = f∘b≃id ; G∘F≈id = b∘f≃id } } where open SCategory C open MR C fwd : Functor C (Cat′→Cat (Cat→Cat′ C)) fwd = record { F₀ = λ x → x ; F₁ = λ f → f ; identity = Equiv.refl ; homomorphism = Equiv.refl ; F-resp-≈ = λ ≈ → ≈ } bwd : Functor (Cat′→Cat (Cat→Cat′ C)) C bwd = record { F₀ = λ x → x ; F₁ = λ f → f ; identity = Equiv.refl ; homomorphism = Equiv.refl ; F-resp-≈ = λ ≈ → ≈ } f∘b≃id : fwd ∘F bwd ≃ idF f∘b≃id = record { F⇒G = record { η = λ A → id {A} ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; F⇐G = record { η = λ A → id {A} ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; iso = λ X → record { isoˡ = identity² ; isoʳ = identity² } } b∘f≃id : bwd ∘F fwd ≃ idF b∘f≃id = record { F⇒G = record { η = λ A → id {A} ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; F⇐G = record { η = λ A → id {A} ; commute = λ _ → id-comm-sym ; sym-commute = λ _ → id-comm } ; iso = λ X → record { isoˡ = identity² ; isoʳ = identity² } }
{ "alphanum_fraction": 0.5613316261, "avg_line_length": 33.6637931034, "ext": "agda", "hexsha": "a9dc633b8e1970b22c93925269d5d0503d84c896", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Enriched/Over/Setoids.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Enriched/Over/Setoids.agda", "max_line_length": 112, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Enriched/Over/Setoids.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 1624, "size": 3905 }
{-# OPTIONS --rewriting --confluence-check #-} open import Agda.Builtin.Bool open import Agda.Builtin.Nat open import Agda.Builtin.Equality {-# BUILTIN REWRITE _≡_ #-} data D : Set₁ where c : Set → D unD : D → Set unD (c X) = X id : unD (c (Nat → Nat)) id x = x postulate rew : c (Nat → Nat) ≡ c (Nat → Bool) {-# REWRITE rew #-} 0' : Bool 0' = id 0
{ "alphanum_fraction": 0.6117318436, "avg_line_length": 15.5652173913, "ext": "agda", "hexsha": "81e9618def7d312159760ee3db2a6ac6719b6ea3", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue3538-2.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue3538-2.agda", "max_line_length": 46, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue3538-2.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 127, "size": 358 }
module _ where module LocalSetoidCalc (Node : Set) where module _ (A : Node) where module _IsRelatedTo_ where module SGFunctorSetup (Obj₁ Obj₂ : Set) where open LocalSetoidCalc Obj₁ public renaming (module _IsRelatedTo_ to _IsRelatedTo₁_) open LocalSetoidCalc Obj₂ public renaming (module _IsRelatedTo_ to _IsRelatedTo₂_) postulate X Y : Set open SGFunctorSetup X Y
{ "alphanum_fraction": 0.7894736842, "avg_line_length": 27.1428571429, "ext": "agda", "hexsha": "4550973d0efadafada4f09f3cba4c9f299faba55", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue1874.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue1874.agda", "max_line_length": 84, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue1874.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 115, "size": 380 }
------------------------------------------------------------------------------ -- Exclusive disjunction base ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOL.ExclusiveDisjunction.Base where open import FOL.Base infixr 1 _⊻_ ------------------------------------------------------------------------------ -- Exclusive disjunction. _⊻_ : Set → Set → Set P ⊻ Q = (P ∨ Q) ∧ ¬ (P ∧ Q)
{ "alphanum_fraction": 0.3433835846, "avg_line_length": 29.85, "ext": "agda", "hexsha": "cfc7aa8b6ccd7b3868c102ffcf62480aca2ac621", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOL/ExclusiveDisjunction/Base.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOL/ExclusiveDisjunction/Base.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOL/ExclusiveDisjunction/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 105, "size": 597 }
-- Partly based on code due to Andrea Vezzosi. {-# OPTIONS --without-K --safe #-} open import Agda.Builtin.Bool data D : Set where run-time : Bool → D @0 compile-time : Bool → D l : @0 D → D l (run-time true) = run-time true l (run-time false) = run-time false l (compile-time x) = compile-time x
{ "alphanum_fraction": 0.6325878594, "avg_line_length": 20.8666666667, "ext": "agda", "hexsha": "a2f79e6ee1b21723a7f6c434106cba522086a0b8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "guilhermehas/agda", "max_forks_repo_path": "test/Fail/Issue5079-1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "guilhermehas/agda", "max_issues_repo_path": "test/Fail/Issue5079-1.agda", "max_line_length": 46, "max_stars_count": null, "max_stars_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "guilhermehas/agda", "max_stars_repo_path": "test/Fail/Issue5079-1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 97, "size": 313 }
-- Product of two categories {-# OPTIONS --safe #-} module Cubical.Categories.Constructions.BinProduct where open import Cubical.Categories.Category.Base open import Cubical.Categories.Functor.Base open import Cubical.Data.Sigma renaming (_×_ to _×'_) open import Cubical.Foundations.HLevels open import Cubical.Foundations.Prelude private variable ℓC ℓC' ℓD ℓD' ℓE ℓE' : Level open Category _×_ : (C : Category ℓC ℓC') → (D : Category ℓD ℓD') → Category (ℓ-max ℓC ℓD) (ℓ-max ℓC' ℓD') (C × D) .ob = (ob C) ×' (ob D) (C × D) .Hom[_,_] (c , d) (c' , d') = (C [ c , c' ]) ×' (D [ d , d' ]) (C × D) .id = (id C , id D) (C × D) ._⋆_ _ _ = (_ ⋆⟨ C ⟩ _ , _ ⋆⟨ D ⟩ _) (C × D) .⋆IdL _ = ≡-× (⋆IdL C _) (⋆IdL D _) (C × D) .⋆IdR _ = ≡-× (⋆IdR C _) (⋆IdR D _) (C × D) .⋆Assoc _ _ _ = ≡-× (⋆Assoc C _ _ _) (⋆Assoc D _ _ _) (C × D) .isSetHom = isSet× (isSetHom C) (isSetHom D) infixr 5 _×_ -- Some useful functors module _ (C : Category ℓC ℓC') (D : Category ℓD ℓD') where open Functor module _ (E : Category ℓE ℓE') where -- Associativity of product ×C-assoc : Functor (C × (D × E)) ((C × D) × E) ×C-assoc .F-ob (c , (d , e)) = ((c , d), e) ×C-assoc .F-hom (f , (g , h)) = ((f , g), h) ×C-assoc .F-id = refl ×C-assoc .F-seq _ _ = refl -- Left/right injections into product linj : (d : ob D) → Functor C (C × D) linj d .F-ob c = (c , d) linj d .F-hom f = (f , id D) linj d .F-id = refl linj d .F-seq f g = ≡-× refl (sym (⋆IdL D _)) rinj : (c : ob C) → Functor D (C × D) rinj c .F-ob d = (c , d) rinj c .F-hom f = (id C , f) rinj c .F-id = refl rinj c .F-seq f g = ≡-× (sym (⋆IdL C _)) refl {- TODO: - define inverse to `assoc`, prove isomorphism - prove product is commutative up to isomorphism -}
{ "alphanum_fraction": 0.5498030388, "avg_line_length": 27.3384615385, "ext": "agda", "hexsha": "c6498dc2d3cbf8e3e56210c732a65a17ff6259bc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_path": "Cubical/Categories/Constructions/BinProduct.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Seanpm2001-web/cubical", "max_issues_repo_path": "Cubical/Categories/Constructions/BinProduct.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_path": "Cubical/Categories/Constructions/BinProduct.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "num_tokens": 771, "size": 1777 }
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇. -- Gentzen-style formalisation of syntax with context pairs, after Pfenning-Davies. module BasicIS4.Syntax.DyadicGentzen where open import BasicIS4.Syntax.Common public -- Derivations. infix 3 _⊢_ data _⊢_ : Cx² Ty Ty → Ty → Set where var : ∀ {A Γ Δ} → A ∈ Γ → Γ ⁏ Δ ⊢ A lam : ∀ {A B Γ Δ} → Γ , A ⁏ Δ ⊢ B → Γ ⁏ Δ ⊢ A ▻ B app : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ▻ B → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ B mvar : ∀ {A Γ Δ} → A ∈ Δ → Γ ⁏ Δ ⊢ A box : ∀ {A Γ Δ} → ∅ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ □ A unbox : ∀ {A C Γ Δ} → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ , A ⊢ C → Γ ⁏ Δ ⊢ C pair : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ B → Γ ⁏ Δ ⊢ A ∧ B fst : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ∧ B → Γ ⁏ Δ ⊢ A snd : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ∧ B → Γ ⁏ Δ ⊢ B unit : ∀ {Γ Δ} → Γ ⁏ Δ ⊢ ⊤ infix 3 _⊢⋆_ _⊢⋆_ : Cx² Ty Ty → Cx Ty → Set Γ ⁏ Δ ⊢⋆ ∅ = 𝟙 Γ ⁏ Δ ⊢⋆ Ξ , A = Γ ⁏ Δ ⊢⋆ Ξ × Γ ⁏ Δ ⊢ A -- Monotonicity with respect to context inclusion. mono⊢ : ∀ {A Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊢ A → Γ′ ⁏ Δ ⊢ A mono⊢ η (var i) = var (mono∈ η i) mono⊢ η (lam t) = lam (mono⊢ (keep η) t) mono⊢ η (app t u) = app (mono⊢ η t) (mono⊢ η u) mono⊢ η (mvar i) = mvar i mono⊢ η (box t) = box t mono⊢ η (unbox t u) = unbox (mono⊢ η t) (mono⊢ η u) mono⊢ η (pair t u) = pair (mono⊢ η t) (mono⊢ η u) mono⊢ η (fst t) = fst (mono⊢ η t) mono⊢ η (snd t) = snd (mono⊢ η t) mono⊢ η unit = unit mono⊢⋆ : ∀ {Ξ Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊢⋆ Ξ → Γ′ ⁏ Δ ⊢⋆ Ξ mono⊢⋆ {∅} η ∙ = ∙ mono⊢⋆ {Ξ , A} η (ts , t) = mono⊢⋆ η ts , mono⊢ η t -- Monotonicity with respect to modal context inclusion. mmono⊢ : ∀ {A Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ′ ⊢ A mmono⊢ θ (var i) = var i mmono⊢ θ (lam t) = lam (mmono⊢ θ t) mmono⊢ θ (app t u) = app (mmono⊢ θ t) (mmono⊢ θ u) mmono⊢ θ (mvar i) = mvar (mono∈ θ i) mmono⊢ θ (box t) = box (mmono⊢ θ t) mmono⊢ θ (unbox t u) = unbox (mmono⊢ θ t) (mmono⊢ (keep θ) u) mmono⊢ θ (pair t u) = pair (mmono⊢ θ t) (mmono⊢ θ u) mmono⊢ θ (fst t) = fst (mmono⊢ θ t) mmono⊢ θ (snd t) = snd (mmono⊢ θ t) mmono⊢ θ unit = unit mmono⊢⋆ : ∀ {Ξ Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊢⋆ Ξ → Γ ⁏ Δ′ ⊢⋆ Ξ mmono⊢⋆ {∅} θ ∙ = ∙ mmono⊢⋆ {Ξ , A} θ (ts , t) = mmono⊢⋆ θ ts , mmono⊢ θ t -- Monotonicity using context pairs. mono²⊢ : ∀ {A Π Π′} → Π ⊆² Π′ → Π ⊢ A → Π′ ⊢ A mono²⊢ (η , θ) = mono⊢ η ∘ mmono⊢ θ -- Shorthand for variables. v₀ : ∀ {A Γ Δ} → Γ , A ⁏ Δ ⊢ A v₀ = var i₀ v₁ : ∀ {A B Γ Δ} → Γ , A , B ⁏ Δ ⊢ A v₁ = var i₁ v₂ : ∀ {A B C Γ Δ} → Γ , A , B , C ⁏ Δ ⊢ A v₂ = var i₂ mv₀ : ∀ {A Γ Δ} → Γ ⁏ Δ , A ⊢ A mv₀ = mvar i₀ mv₁ : ∀ {A B Γ Δ} → Γ ⁏ Δ , A , B ⊢ A mv₁ = mvar i₁ mv₂ : ∀ {A B C Γ Δ} → Γ ⁏ Δ , A , B , C ⊢ A mv₂ = mvar i₂ -- Reflexivity. refl⊢⋆ : ∀ {Γ Δ} → Γ ⁏ Δ ⊢⋆ Γ refl⊢⋆ {∅} = ∙ refl⊢⋆ {Γ , A} = mono⊢⋆ weak⊆ refl⊢⋆ , v₀ mrefl⊢⋆ : ∀ {Δ Γ} → Γ ⁏ Δ ⊢⋆ □⋆ Δ mrefl⊢⋆ {∅} = ∙ mrefl⊢⋆ {Δ , A} = mmono⊢⋆ weak⊆ mrefl⊢⋆ , box mv₀ mrefl⊢⋆′ : ∀ {Δ Δ′ Γ Γ′} → (∀ {A} → Γ ⁏ Δ ⊢ □ A → Γ′ ⁏ Δ′ ⊢ A) → Γ′ ⁏ Δ′ ⊢⋆ Δ mrefl⊢⋆′ {∅} f = ∙ mrefl⊢⋆′ {Δ , B} f = mrefl⊢⋆′ (f ∘ mmono⊢ weak⊆) , f (box mv₀) -- Deduction theorem is built-in. lam⋆ : ∀ {Ξ A Γ Δ} → Γ ⧺ Ξ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ Ξ ▻⋯▻ A lam⋆ {∅} = I lam⋆ {Ξ , B} = lam⋆ {Ξ} ∘ lam lam⋆₀ : ∀ {Γ A Δ} → Γ ⁏ Δ ⊢ A → ∅ ⁏ Δ ⊢ Γ ▻⋯▻ A lam⋆₀ {∅} = I lam⋆₀ {Γ , B} = lam⋆₀ ∘ lam -- Modal deduction theorem. mlam : ∀ {A B Γ Δ} → Γ ⁏ Δ , A ⊢ B → Γ ⁏ Δ ⊢ □ A ▻ B mlam t = lam (unbox v₀ (mono⊢ weak⊆ t)) mlam⋆ : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⧺ Ξ ⊢ A → Γ ⁏ Δ ⊢ □⋆ Ξ ▻⋯▻ A mlam⋆ {∅} = I mlam⋆ {Ξ , B} = mlam⋆ {Ξ} ∘ mlam mlam⋆₀ : ∀ {Δ A Γ} → Γ ⁏ Δ ⊢ A → Γ ⁏ ∅ ⊢ □⋆ Δ ▻⋯▻ A mlam⋆₀ {∅} = I mlam⋆₀ {Δ , B} = mlam⋆₀ ∘ mlam -- Detachment theorems. det : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ▻ B → Γ , A ⁏ Δ ⊢ B det t = app (mono⊢ weak⊆ t) v₀ det⋆ : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊢ Ξ ▻⋯▻ A → Γ ⧺ Ξ ⁏ Δ ⊢ A det⋆ {∅} = I det⋆ {Ξ , B} = det ∘ det⋆ {Ξ} det⋆₀ : ∀ {Γ A Δ} → ∅ ⁏ Δ ⊢ Γ ▻⋯▻ A → Γ ⁏ Δ ⊢ A det⋆₀ {∅} = I det⋆₀ {Γ , B} = det ∘ det⋆₀ mdet : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ A ▻ B → Γ ⁏ Δ , A ⊢ B mdet t = app (mmono⊢ weak⊆ t) (box mv₀) mdet⋆ : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊢ □⋆ Ξ ▻⋯▻ A → Γ ⁏ Δ ⧺ Ξ ⊢ A mdet⋆ {∅} = I mdet⋆ {Ξ , B} = mdet ∘ mdet⋆ {Ξ} mdet⋆₀ : ∀ {Δ A Γ} → Γ ⁏ ∅ ⊢ □⋆ Δ ▻⋯▻ A → Γ ⁏ Δ ⊢ A mdet⋆₀ {∅} = I mdet⋆₀ {Δ , B} = mdet ∘ mdet⋆₀ -- Context manipulation. merge : ∀ {Δ A Γ} → Γ ⁏ Δ ⊢ A → Γ ⧺ (□⋆ Δ) ⁏ ∅ ⊢ A merge {Δ} = det⋆ {□⋆ Δ} ∘ mlam⋆₀ mmerge : ∀ {Γ A Δ} → □⋆ Γ ⁏ Δ ⊢ A → ∅ ⁏ Δ ⧺ Γ ⊢ A mmerge {Γ} = mdet⋆ {Γ} ∘ lam⋆₀ split : ∀ {Δ A Γ} → Γ ⧺ (□⋆ Δ) ⁏ ∅ ⊢ A → Γ ⁏ Δ ⊢ A split {Δ} = mdet⋆₀ ∘ lam⋆ {□⋆ Δ} msplit : ∀ {Γ A Δ} → ∅ ⁏ Δ ⧺ Γ ⊢ A → □⋆ Γ ⁏ Δ ⊢ A msplit {Γ} = det⋆₀ ∘ mlam⋆ {Γ} merge⋆ : ∀ {Ξ Δ Γ} → Γ ⁏ Δ ⊢⋆ Ξ → Γ ⧺ (□⋆ Δ) ⁏ ∅ ⊢⋆ Ξ merge⋆ {∅} ∙ = ∙ merge⋆ {Ξ , A} (ts , t) = merge⋆ ts , merge t split⋆ : ∀ {Ξ Δ Γ} → Γ ⧺ (□⋆ Δ) ⁏ ∅ ⊢⋆ Ξ → Γ ⁏ Δ ⊢⋆ Ξ split⋆ {∅} ∙ = ∙ split⋆ {Ξ , A} (ts , t) = split⋆ ts , split t -- Cut and multicut. cut : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A → Γ , A ⁏ Δ ⊢ B → Γ ⁏ Δ ⊢ B cut t u = app (lam u) t mcut : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ , A ⊢ B → Γ ⁏ Δ ⊢ B mcut t u = app (mlam u) t multicut : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊢⋆ Ξ → Ξ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ A multicut {∅} ∙ u = mono⊢ bot⊆ u multicut {Ξ , B} (ts , t) u = app (multicut ts (lam u)) t mmulticut : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊢⋆ □⋆ Ξ → Γ ⁏ Ξ ⊢ A → Γ ⁏ Δ ⊢ A mmulticut {∅} ∙ u = mmono⊢ bot⊆ u mmulticut {Ξ , B} (ts , t) u = app (mmulticut ts (mlam u)) t multicut² : ∀ {Ξ Ξ′ A Γ Δ} → Γ ⁏ Δ ⊢⋆ Ξ → Γ ⁏ Δ ⊢⋆ □⋆ Ξ′ → Ξ ⁏ Ξ′ ⊢ A → Γ ⁏ Δ ⊢ A multicut² {∅} ∙ us v = mmulticut us (mono⊢ bot⊆ v) multicut² {Ξ , B} (ts , t) us v = app (multicut² ts us (lam v)) t -- Transitivity. trans⊢⋆₀ : ∀ {Γ″ Γ′ Γ} → Γ ⁏ ∅ ⊢⋆ Γ′ → Γ′ ⁏ ∅ ⊢⋆ Γ″ → Γ ⁏ ∅ ⊢⋆ Γ″ trans⊢⋆₀ {∅} ts ∙ = ∙ trans⊢⋆₀ {Γ″ , A} ts (us , u) = trans⊢⋆₀ ts us , multicut ts u trans⊢⋆ : ∀ {Ξ Γ Γ′ Δ Δ′} → Γ ⁏ Δ ⊢⋆ Γ′ ⧺ (□⋆ Δ′) → Γ′ ⁏ Δ′ ⊢⋆ Ξ → Γ ⁏ Δ ⊢⋆ Ξ trans⊢⋆ ts us = split⋆ (trans⊢⋆₀ (merge⋆ ts) (merge⋆ us)) -- Contraction. ccont : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ (A ▻ A ▻ B) ▻ A ▻ B ccont = lam (lam (app (app v₁ v₀) v₀)) cont : ∀ {A B Γ Δ} → Γ , A , A ⁏ Δ ⊢ B → Γ , A ⁏ Δ ⊢ B cont t = det (app ccont (lam (lam t))) mcont : ∀ {A B Γ Δ} → Γ ⁏ Δ , A , A ⊢ B → Γ ⁏ Δ , A ⊢ B mcont t = mdet (app ccont (mlam (mlam t))) -- Exchange, or Schönfinkel’s C combinator. cexch : ∀ {A B C Γ Δ} → Γ ⁏ Δ ⊢ (A ▻ B ▻ C) ▻ B ▻ A ▻ C cexch = lam (lam (lam (app (app v₂ v₀) v₁))) exch : ∀ {A B C Γ Δ} → Γ , A , B ⁏ Δ ⊢ C → Γ , B , A ⁏ Δ ⊢ C exch t = det (det (app cexch (lam (lam t)))) mexch : ∀ {A B C Γ Δ} → Γ ⁏ Δ , A , B ⊢ C → Γ ⁏ Δ , B , A ⊢ C mexch t = mdet (mdet (app cexch (mlam (mlam t)))) -- Composition, or Schönfinkel’s B combinator. ccomp : ∀ {A B C Γ Δ} → Γ ⁏ Δ ⊢ (B ▻ C) ▻ (A ▻ B) ▻ A ▻ C ccomp = lam (lam (lam (app v₂ (app v₁ v₀)))) comp : ∀ {A B C Γ Δ} → Γ , B ⁏ Δ ⊢ C → Γ , A ⁏ Δ ⊢ B → Γ , A ⁏ Δ ⊢ C comp t u = det (app (app ccomp (lam t)) (lam u)) mcomp : ∀ {A B C Γ Δ} → Γ ⁏ Δ , B ⊢ □ C → Γ ⁏ Δ , A ⊢ □ B → Γ ⁏ Δ , A ⊢ □ C mcomp t u = mdet (app (app ccomp (mlam t)) (mlam u)) -- Useful theorems in functional form. dist : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (A ▻ B) → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ ⊢ □ B dist t u = unbox t (unbox (mmono⊢ weak⊆ u) (box (app mv₁ mv₀))) up : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ ⊢ □ □ A up t = unbox t (box (box mv₀)) down : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ ⊢ A down t = unbox t mv₀ distup : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (□ A ▻ B) → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ ⊢ □ B distup t u = dist t (up u) -- Useful theorems in combinatory form. ci : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ A ▻ A ci = lam v₀ ck : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ▻ B ▻ A ck = lam (lam v₁) cs : ∀ {A B C Γ Δ} → Γ ⁏ Δ ⊢ (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C cs = lam (lam (lam (app (app v₂ v₀) (app v₁ v₀)))) cdist : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (A ▻ B) ▻ □ A ▻ □ B cdist = lam (lam (dist v₁ v₀)) cup : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ □ A ▻ □ □ A cup = lam (up v₀) cdown : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ □ A ▻ A cdown = lam (down v₀) cdistup : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (□ A ▻ B) ▻ □ A ▻ □ B cdistup = lam (lam (dist v₁ (up v₀))) cunbox : ∀ {A C Γ Δ} → Γ ⁏ Δ ⊢ □ A ▻ (□ A ▻ C) ▻ C cunbox = lam (lam (app v₀ v₁)) cpair : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ▻ B ▻ A ∧ B cpair = lam (lam (pair v₁ v₀)) cfst : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ∧ B ▻ A cfst = lam (fst v₀) csnd : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ∧ B ▻ B csnd = lam (snd v₀) -- Internalisation, or lifting, and additional theorems. lift : ∀ {Γ A Δ} → Γ ⁏ Δ ⊢ A → □⋆ Γ ⁏ Δ ⊢ □ A lift {∅} t = box t lift {Γ , B} t = det (app cdist (lift (lam t))) hypup : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ▻ B → Γ ⁏ Δ ⊢ □ A ▻ B hypup t = lam (app (mono⊢ weak⊆ t) (down v₀)) hypdown : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ □ A ▻ B → Γ ⁏ Δ ⊢ □ A ▻ B hypdown t = lam (app (mono⊢ weak⊆ t) (up v₀)) cxup : ∀ {Γ A Δ} → Γ ⁏ Δ ⊢ A → □⋆ Γ ⁏ Δ ⊢ A cxup {∅} t = t cxup {Γ , B} t = det (hypup (cxup (lam t))) cxdown : ∀ {Γ A Δ} → □⋆ □⋆ Γ ⁏ Δ ⊢ A → □⋆ Γ ⁏ Δ ⊢ A cxdown {∅} t = t cxdown {Γ , B} t = det (hypdown (cxdown (lam t))) box⋆ : ∀ {Ξ Γ Δ} → ∅ ⁏ Δ ⊢⋆ Ξ → Γ ⁏ Δ ⊢⋆ □⋆ Ξ box⋆ {∅} ∙ = ∙ box⋆ {Ξ , A} (ts , t) = box⋆ ts , box t lift⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⋆ Ξ → □⋆ Γ ⁏ Δ ⊢⋆ □⋆ Ξ lift⋆ {∅} ∙ = ∙ lift⋆ {Ξ , A} (ts , t) = lift⋆ ts , lift t up⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⋆ □⋆ Ξ → Γ ⁏ Δ ⊢⋆ □⋆ □⋆ Ξ up⋆ {∅} ∙ = ∙ up⋆ {Ξ , A} (ts , t) = up⋆ ts , up t down⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⋆ □⋆ Ξ → Γ ⁏ Δ ⊢⋆ Ξ down⋆ {∅} ∙ = ∙ down⋆ {Ξ , A} (ts , t) = down⋆ ts , down t multibox : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊢⋆ □⋆ Ξ → □⋆ Ξ ⁏ ∅ ⊢ A → Γ ⁏ Δ ⊢ □ A multibox ts u = multicut (up⋆ ts) (mmono⊢ bot⊆ (lift u)) dist′ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (A ▻ B) → Γ ⁏ Δ ⊢ □ A ▻ □ B dist′ t = lam (dist (mono⊢ weak⊆ t) v₀) mpair : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ ⊢ □ B → Γ ⁏ Δ ⊢ □ (A ∧ B) mpair t u = unbox t (unbox (mmono⊢ weak⊆ u) (box (pair mv₁ mv₀))) mfst : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (A ∧ B) → Γ ⁏ Δ ⊢ □ A mfst t = unbox t (box (fst mv₀)) msnd : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (A ∧ B) → Γ ⁏ Δ ⊢ □ B msnd t = unbox t (box (snd mv₀)) -- Closure under context concatenation. concat : ∀ {A B Γ} Γ′ {Δ} → Γ , A ⁏ Δ ⊢ B → Γ′ ⁏ Δ ⊢ A → Γ ⧺ Γ′ ⁏ Δ ⊢ B concat Γ′ t u = app (mono⊢ (weak⊆⧺₁ Γ′) (lam t)) (mono⊢ weak⊆⧺₂ u) mconcat : ∀ {A B Γ Δ} Δ′ → Γ ⁏ Δ , A ⊢ B → Γ ⁏ Δ′ ⊢ □ A → Γ ⁏ Δ ⧺ Δ′ ⊢ B mconcat Δ′ t u = app (mmono⊢ (weak⊆⧺₁ Δ′) (mlam t)) (mmono⊢ weak⊆⧺₂ u) -- Substitution. [_≔_]_ : ∀ {A B Γ Δ} → (i : A ∈ Γ) → Γ ∖ i ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ B → Γ ∖ i ⁏ Δ ⊢ B [ i ≔ s ] var j with i ≟∈ j [ i ≔ s ] var .i | same = s [ i ≔ s ] var ._ | diff j = var j [ i ≔ s ] lam t = lam ([ pop i ≔ mono⊢ weak⊆ s ] t) [ i ≔ s ] app t u = app ([ i ≔ s ] t) ([ i ≔ s ] u) [ i ≔ s ] mvar j = mvar j [ i ≔ s ] box t = box t [ i ≔ s ] unbox t u = unbox ([ i ≔ s ] t) ([ i ≔ mmono⊢ weak⊆ s ] u) [ i ≔ s ] pair t u = pair ([ i ≔ s ] t) ([ i ≔ s ] u) [ i ≔ s ] fst t = fst ([ i ≔ s ] t) [ i ≔ s ] snd t = snd ([ i ≔ s ] t) [ i ≔ s ] unit = unit [_≔_]⋆_ : ∀ {Ξ A Γ Δ} → (i : A ∈ Γ) → Γ ∖ i ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢⋆ Ξ → Γ ∖ i ⁏ Δ ⊢⋆ Ξ [_≔_]⋆_ {∅} i s ∙ = ∙ [_≔_]⋆_ {Ξ , B} i s (ts , t) = [ i ≔ s ]⋆ ts , [ i ≔ s ] t -- Modal substitution. m[_≔_]_ : ∀ {A B Γ Δ} → (i : A ∈ Δ) → ∅ ⁏ Δ ∖ i ⊢ A → Γ ⁏ Δ ⊢ B → Γ ⁏ Δ ∖ i ⊢ B m[ i ≔ s ] var j = var j m[ i ≔ s ] lam t = lam (m[ i ≔ s ] t) m[ i ≔ s ] app t u = app (m[ i ≔ s ] t) (m[ i ≔ s ] u) m[ i ≔ s ] mvar j with i ≟∈ j m[ i ≔ s ] mvar .i | same = mono⊢ bot⊆ s m[ i ≔ s ] mvar ._ | diff j = mvar j m[ i ≔ s ] box t = box (m[ i ≔ s ] t) m[ i ≔ s ] unbox t u = unbox (m[ i ≔ s ] t) (m[ pop i ≔ mmono⊢ weak⊆ s ] u) m[ i ≔ s ] pair t u = pair (m[ i ≔ s ] t) (m[ i ≔ s ] u) m[ i ≔ s ] fst t = fst (m[ i ≔ s ] t) m[ i ≔ s ] snd t = snd (m[ i ≔ s ] t) m[ i ≔ s ] unit = unit m[_≔_]⋆_ : ∀ {Ξ A Γ Δ} → (i : A ∈ Δ) → ∅ ⁏ Δ ∖ i ⊢ A → Γ ⁏ Δ ⊢⋆ Ξ → Γ ⁏ Δ ∖ i ⊢⋆ Ξ m[_≔_]⋆_ {∅} i s ∙ = ∙ m[_≔_]⋆_ {Ξ , B} i s (ts , t) = m[ i ≔ s ]⋆ ts , m[ i ≔ s ] t -- Convertibility. data _⋙_ {Γ Δ : Cx Ty} : ∀ {A} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ A → Set where refl⋙ : ∀ {A} → {t : Γ ⁏ Δ ⊢ A} → t ⋙ t trans⋙ : ∀ {A} → {t t′ t″ : Γ ⁏ Δ ⊢ A} → t ⋙ t′ → t′ ⋙ t″ → t ⋙ t″ sym⋙ : ∀ {A} → {t t′ : Γ ⁏ Δ ⊢ A} → t ⋙ t′ → t′ ⋙ t conglam⋙ : ∀ {A B} → {t t′ : Γ , A ⁏ Δ ⊢ B} → t ⋙ t′ → lam t ⋙ lam t′ congapp⋙ : ∀ {A B} → {t t′ : Γ ⁏ Δ ⊢ A ▻ B} → {u u′ : Γ ⁏ Δ ⊢ A} → t ⋙ t′ → u ⋙ u′ → app t u ⋙ app t′ u′ -- NOTE: Rejected by Pfenning and Davies. -- congbox⋙ : ∀ {A} → {t t′ : ∅ ⁏ Δ ⊢ A} -- → t ⋙ t′ -- → box {Γ} t ⋙ box {Γ} t′ congunbox⋙ : ∀ {A C} → {t t′ : Γ ⁏ Δ ⊢ □ A} → {u u′ : Γ ⁏ Δ , A ⊢ C} → t ⋙ t′ → u ⋙ u′ → unbox t u ⋙ unbox t′ u′ congpair⋙ : ∀ {A B} → {t t′ : Γ ⁏ Δ ⊢ A} → {u u′ : Γ ⁏ Δ ⊢ B} → t ⋙ t′ → u ⋙ u′ → pair t u ⋙ pair t′ u′ congfst⋙ : ∀ {A B} → {t t′ : Γ ⁏ Δ ⊢ A ∧ B} → t ⋙ t′ → fst t ⋙ fst t′ congsnd⋙ : ∀ {A B} → {t t′ : Γ ⁏ Δ ⊢ A ∧ B} → t ⋙ t′ → snd t ⋙ snd t′ beta▻⋙ : ∀ {A B} → {t : Γ , A ⁏ Δ ⊢ B} → {u : Γ ⁏ Δ ⊢ A} → app (lam t) u ⋙ ([ top ≔ u ] t) eta▻⋙ : ∀ {A B} → {t : Γ ⁏ Δ ⊢ A ▻ B} → t ⋙ lam (app (mono⊢ weak⊆ t) v₀) beta□⋙ : ∀ {A C} → {t : ∅ ⁏ Δ ⊢ A} → {u : Γ ⁏ Δ , A ⊢ C} → unbox (box t) u ⋙ (m[ top ≔ t ] u) eta□⋙ : ∀ {A} → {t : Γ ⁏ Δ ⊢ □ A} → t ⋙ unbox t (box mv₀) -- TODO: What about commuting conversions for □? beta∧₁⋙ : ∀ {A B} → {t : Γ ⁏ Δ ⊢ A} → {u : Γ ⁏ Δ ⊢ B} → fst (pair t u) ⋙ t beta∧₂⋙ : ∀ {A B} → {t : Γ ⁏ Δ ⊢ A} → {u : Γ ⁏ Δ ⊢ B} → snd (pair t u) ⋙ u eta∧⋙ : ∀ {A B} → {t : Γ ⁏ Δ ⊢ A ∧ B} → t ⋙ pair (fst t) (snd t) eta⊤⋙ : ∀ {t : Γ ⁏ Δ ⊢ ⊤} → t ⋙ unit
{ "alphanum_fraction": 0.3837333523, "avg_line_length": 29.8110403397, "ext": "agda", "hexsha": "4c3ec9703b8f21b3993fd5ad595d5da2204211c3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIS4/Syntax/DyadicGentzen.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIS4/Syntax/DyadicGentzen.agda", "max_line_length": 83, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIS4/Syntax/DyadicGentzen.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 8126, "size": 14041 }
-- MIT License -- Copyright (c) 2021 Luca Ciccone and Luca Padovani -- Permission is hereby granted, free of charge, to any person -- obtaining a copy of this software and associated documentation -- files (the "Software"), to deal in the Software without -- restriction, including without limitation the rights to use, -- copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following -- conditions: -- The above copyright notice and this permission notice shall be -- included in all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- OTHER DEALINGS IN THE SOFTWARE. {-# OPTIONS --guardedness #-} open import Data.Empty open import Data.Product open import Data.List using ([]; _∷_; _∷ʳ_; _++_) open import Relation.Nullary open import Relation.Unary using (_∈_; _⊆_;_∉_) open import Relation.Binary.PropositionalEquality using (_≡_; refl) import Relation.Binary.HeterogeneousEquality as Het open import Common module HasTrace {ℙ : Set} (message : Message ℙ) where open import Trace message open import SessionType message open import Transitions message _HasTrace_ : SessionType -> Trace -> Set _HasTrace_ T φ = ∃[ S ] (Defined S × Transitions T φ S) after : ∀{T φ} -> T HasTrace φ -> SessionType after (S , _ , _) = S -- data _HasTrace_ : SessionType -> Trace -> Set where -- does : ∀{T φ S} (tr : Transitions T φ S) (def : Defined S) -> T Does φ _HasTrace?_ : (T : SessionType) (φ : Trace) -> Dec (T HasTrace φ) nil HasTrace? _ = no λ { (_ , () , refl) ; (_ , _ , step () _) } inp f HasTrace? [] = yes (_ , inp , refl) inp f HasTrace? (I x ∷ φ) with x ∈? f ... | no nfx = no λ { (_ , def , step inp tr) → nfx (transitions+defined->defined tr def) } ... | yes fx with f x .force HasTrace? φ ... | yes (_ , def , tr) = yes (_ , def , step inp tr) ... | no ntφ = no λ { (_ , def , step inp tr) → ntφ (_ , def , tr) } inp f HasTrace? (O x ∷ φ) = no λ { (_ , _ , step () _) } out f HasTrace? [] = yes (_ , out , refl) out f HasTrace? (I x ∷ φ) = no λ { (_ , _ , step () _) } out f HasTrace? (O x ∷ φ) with x ∈? f ... | no nfx = no λ { (_ , _ , step (out fx) _) → nfx fx } ... | yes fx with f x .force HasTrace? φ ... | yes (_ , def , tr) = yes (_ , def , step (out fx) tr) ... | no ntφ = no λ { (_ , def , step (out fx) tr) → ntφ (_ , def , tr) } has-trace->defined : ∀{T φ} -> T HasTrace φ -> Defined T has-trace->defined (_ , tdef , tr) = transitions+defined->defined tr tdef inp-has-trace : ∀{f x φ} -> f x .force HasTrace φ -> inp f HasTrace (I x ∷ φ) inp-has-trace (_ , def , tr) = _ , def , step inp tr inp-has-no-trace : ∀{f x φ} -> ¬ f x .force HasTrace φ -> ¬ inp f HasTrace (I x ∷ φ) inp-has-no-trace nφ (_ , def , step inp tr) = nφ (_ , def , tr) out-has-trace : ∀{f x φ} -> f x .force HasTrace φ -> out f HasTrace (O x ∷ φ) out-has-trace (_ , def , tr) = _ , def , step (out (transitions+defined->defined tr def)) tr out-has-no-trace : ∀{f x φ} -> ¬ f x .force HasTrace φ -> ¬ out f HasTrace (O x ∷ φ) out-has-no-trace nφ (_ , def , step (out fx) tr) = nφ (_ , def , tr) out-has-no-trace->undefined : ∀{f x} -> ¬ out f HasTrace (O x ∷ []) -> ¬ Defined (f x .force) out-has-no-trace->undefined {f} {x} nt with x ∈? f ... | yes fx = ⊥-elim (nt (_ , fx , step (out fx) refl)) ... | no nfx = nfx unprefix-some : ∀{α φ ψ} -> (α ∷ ψ) ⊑ (α ∷ φ) -> ψ ⊑ φ unprefix-some (some pre) = pre ⊑-has-trace : ∀{T φ ψ} -> ψ ⊑ φ -> T HasTrace φ -> T HasTrace ψ ⊑-has-trace none (_ , tdef , tr) = _ , transitions+defined->defined tr tdef , refl ⊑-has-trace (some pre) (_ , tdef , step t tr) = let _ , sdef , sr = ⊑-has-trace pre (_ , tdef , tr) in _ , sdef , step t sr split-trace : ∀{T φ ψ} (tφ : T HasTrace φ) -> T HasTrace (φ ++ ψ) -> after tφ HasTrace ψ split-trace (_ , tdef , refl) tφψ = tφψ split-trace (_ , tdef , step inp tr) (_ , sdef , step inp sr) = split-trace (_ , tdef , tr) (_ , sdef , sr) split-trace (_ , tdef , step (out _) tr) (_ , sdef , step (out _) sr) = split-trace (_ , tdef , tr) (_ , sdef , sr) join-trace : ∀{T φ ψ} (tφ : T HasTrace φ) -> after tφ HasTrace ψ -> T HasTrace (φ ++ ψ) join-trace (_ , _ , refl) tφ/ψ = tφ/ψ join-trace (_ , tdef , step t tr) tφ/ψ = let (_ , sdef , sr) = join-trace (_ , tdef , tr) tφ/ψ in _ , sdef , step t sr ⊑-has-co-trace : ∀{T φ ψ} -> φ ⊑ ψ -> T HasTrace (co-trace ψ) -> T HasTrace (co-trace φ) ⊑-has-co-trace le tψ = ⊑-has-trace (⊑-co-trace le) tψ ⊑-tran-has-trace : ∀{T φ ψ χ} (pre1 : φ ⊑ ψ) (pre2 : ψ ⊑ χ) -> (tχ : T HasTrace χ) -> ⊑-has-trace pre1 (⊑-has-trace pre2 tχ) ≡ ⊑-has-trace (⊑-tran pre1 pre2) tχ ⊑-tran-has-trace none none tχ = refl ⊑-tran-has-trace none (some pre2) (fst , fst₁ , step t snd) = refl ⊑-tran-has-trace (some pre1) (some pre2) (_ , def , step _ tr) rewrite ⊑-tran-has-trace pre1 pre2 (_ , def , tr) = refl ⊑-has-trace-after : ∀{T φ} (tφ : T HasTrace φ) -> ⊑-has-trace (⊑-refl φ) tφ ≡ tφ ⊑-has-trace-after (_ , _ , refl) = refl ⊑-has-trace-after (_ , tdef , step inp tr) rewrite ⊑-has-trace-after (_ , tdef , tr) = refl ⊑-has-trace-after (_ , tdef , step (out _) tr) rewrite ⊑-has-trace-after (_ , tdef , tr) = refl nil-has-no-trace : ∀{φ} -> ¬ nil HasTrace φ nil-has-no-trace (_ , () , refl) nil-has-no-trace (_ , _ , step () _) end-has-empty-trace : ∀{φ T} -> End T -> T HasTrace φ -> φ ≡ [] end-has-empty-trace (inp U) (_ , _ , refl) = refl end-has-empty-trace (inp U) (_ , def , step inp refl) = ⊥-elim (U _ def) end-has-empty-trace (inp U) (_ , def , step inp (step t _)) = ⊥-elim (U _ (transition->defined t)) end-has-empty-trace (out U) (_ , _ , refl) = refl end-has-empty-trace (out U) (_ , _ , step (out !x) _) = ⊥-elim (U _ !x) has-trace-++ : ∀{T φ ψ} -> T HasTrace (φ ++ ψ) -> T HasTrace φ has-trace-++ tφψ = ⊑-has-trace ⊑-++ tφψ trace-coherence : ∀{T φ ψ₁ ψ₂ x y} -> T HasTrace (φ ++ I x ∷ ψ₁) -> T HasTrace (φ ++ O y ∷ ψ₂) -> ⊥ trace-coherence {_} {[]} (_ , _ , step inp _) (_ , _ , step () _) trace-coherence {_} {I _ ∷ _} (_ , tdef , step inp tr) (_ , sdef , step inp sr) = trace-coherence (_ , tdef , tr) (_ , sdef , sr) trace-coherence {_} {O _ ∷ _} (_ , tdef , step (out _) tr) (_ , sdef , step (out _) sr) = trace-coherence (_ , tdef , tr) (_ , sdef , sr) defined->has-empty-trace : ∀{T} -> Defined T -> T HasTrace [] defined->has-empty-trace inp = _ , inp , refl defined->has-empty-trace out = _ , out , refl has-trace-double-negation : ∀{T φ} -> ¬ ¬ T HasTrace φ -> T HasTrace φ has-trace-double-negation {T} {φ} p with T HasTrace? φ ... | yes tφ = tφ ... | no ntφ = ⊥-elim (p ntφ) {- New -} not-nil-has-trace : ∀{ϕ} → ¬ (nil HasTrace ϕ) not-nil-has-trace (.(inp _) , inp , step () _) not-nil-has-trace (.(out _) , out , step () _) trace-after-in : ∀{f x ϕ} → (inp f) HasTrace (I x ∷ ϕ) → (f x .force) HasTrace ϕ trace-after-in (_ , def , step inp red) = _ , def , red trace-after-out : ∀{f x ϕ} → (out f) HasTrace (O x ∷ ϕ) → (f x .force) HasTrace ϕ trace-after-out (_ , def , step (out _) red) = _ , def , red inp-hastrace->defined : ∀{f x tr} → (inp f) HasTrace (I x ∷ tr) → x ∈ dom f inp-hastrace->defined (_ , def , step inp refl) = def inp-hastrace->defined (_ , def , step inp (step red _)) = transition->defined red empty-inp-has-empty-trace : ∀{f ϕ} → EmptyContinuation f → (inp f) HasTrace ϕ → ϕ ≡ [] empty-inp-has-empty-trace e (_ , _ , refl) = refl empty-inp-has-empty-trace {f} e (_ , _ , step (inp {x = x}) reds) with Defined? (f x .force) empty-inp-has-empty-trace {f} e (_ , def , step (inp {x = _}) refl) | no ¬def = ⊥-elim (¬def def) empty-inp-has-empty-trace {f} e (_ , _ , step (inp {x = _}) (step t _)) | no ¬def = ⊥-elim (¬def (transition->defined t)) ... | yes def = ⊥-elim (e _ def) empty-out-has-empty-trace : ∀{f ϕ} → EmptyContinuation f → (out f) HasTrace ϕ → ϕ ≡ [] empty-out-has-empty-trace e (_ , _ , refl) = refl empty-out-has-empty-trace e (_ , _ , step (out def) _) = ⊥-elim (e _ def)
{ "alphanum_fraction": 0.6048984468, "avg_line_length": 46.5, "ext": "agda", "hexsha": "e5546ddbbc33eaf9134d78f596b340fbca8c13e5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "boystrange/FairSubtypingAgda", "max_forks_repo_path": "src/HasTrace.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "boystrange/FairSubtypingAgda", "max_issues_repo_path": "src/HasTrace.agda", "max_line_length": 137, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "boystrange/FairSubtypingAgda", "max_stars_repo_path": "src/HasTrace.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-24T14:38:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-29T14:32:30.000Z", "num_tokens": 3032, "size": 8370 }
-- This module introduces parameterised modules. module Introduction.Modules.Parameterised where -- First some familiar datatypes. data Bool : Set where false : Bool true : Bool data List (A : Set) : Set where nil : List A _::_ : A -> List A -> List A infixr 15 _::_ -- see 'Introduction.Operators' for information on infix -- declarations -- Agda supports parameterised modules. A parameterised module is declared by -- giving the parameters after the module name. module Sorting {A : Set}(_<_ : A -> A -> Bool) where insert : A -> List A -> List A insert x nil = x :: nil insert x (y :: ys) = ins (x < y) where ins : Bool -> List A -- local functions can do pattern matching and ins true = x :: y :: ys -- be recursive ins false = y :: insert x ys sort : List A -> List A sort nil = nil sort (x :: xs) = insert x (sort xs) -- Before a parameterised module can be used it has to be instantiated. So, we -- need something to instantiate it with. data Nat : Set where zero : Nat suc : Nat -> Nat _<_ : Nat -> Nat -> Bool zero < zero = false zero < suc _ = true suc _ < zero = false suc n < suc m = n < m -- To instantiate a module you define a new module in terms of the -- parameterised module. Module instantiation also supports the using, hiding -- and renaming modifiers. module SortNat = Sorting _<_ sort' : {A : Set}(_<_ : A -> A -> Bool) -> List A -> List A sort' less = Sort'.sort where module Sort' = Sorting less -- Now the instantiated module can be opened and we can use the sorting -- function. open SortNat test = sort (suc zero :: zero :: suc (suc zero) :: nil)
{ "alphanum_fraction": 0.6379208506, "avg_line_length": 26.0461538462, "ext": "agda", "hexsha": "429c22d08153c4ad77f2cad194fe0c08589d8f2d", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/Introduction/Modules/Parameterised.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/Introduction/Modules/Parameterised.agda", "max_line_length": 78, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/Introduction/Modules/Parameterised.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 467, "size": 1693 }
module MessageClosure where open import Data.Fin using (Fin; zero; suc; toℕ) open import Data.Nat open import Function open import Types.IND1 as IND import Types.Tail1 as Tail private variable m n : ℕ -- message closure guarantees that the type of each message in a session type is closed upS : SType m → SType (suc m) upG : GType m → GType (suc m) upT : Type m → Type (suc m) upS (gdd G) = gdd (upG G) upS (rec G) = rec (upG G) upS (var x) = var (suc x) upG (transmit d T S) = transmit d (upT T) (upS S) upG (choice d m alt) = choice d m (upS ∘ alt) upG end = end upT TUnit = TUnit upT TInt = TInt upT (TPair t t₁) = TPair (upT t) (upT t₁) upT (TChan S) = TChan (upS S) shift : (Fin (m + n) → SType m) → (Fin (suc m + n) → SType (suc m)) shift σ zero = var zero shift σ (suc x) = upS (σ x) applyT : (Fin (m + n) → SType m) → TType (m + n) → TType m applyS : (Fin (m + n) → SType m) → SType (m + n) → SType m applyG : (Fin (m + n) → SType m) → GType (m + n) → GType m applyT σ TUnit = TUnit applyT σ TInt = TInt applyT σ (TPair T T₁) = TPair (applyT σ T) (applyT σ T₁) applyT σ (TChan x) = TChan (applyS σ x) applyS σ (gdd gst) = gdd (applyG σ gst) applyS σ (rec gst) = rec (applyG (shift σ) gst) applyS σ (var x) = σ x applyG σ (transmit d t s) = transmit d (applyT σ t) (applyS σ s) applyG σ (choice d m alt) = choice d m (applyS σ ∘ alt) applyG σ end = end injectT : TType 0 → Tail.Type injectT TUnit = Tail.TUnit injectT TInt = Tail.TInt injectT (TPair t t₁) = Tail.TPair (injectT t) (injectT t₁) injectT (TChan S) = Tail.TChan S ext : (Fin n → SType 0) → SType n → (Fin (suc n) → SType 0) ext σ S zero = applyS σ S ext σ S (suc i) = σ i mcloS : (Fin n → SType 0) → SType n → Tail.SType n mcloG : (Fin n → SType 0) → GType n → Tail.GType n mcloS σ (gdd gst) = Tail.gdd (mcloG σ gst) mcloS σ (rec gst) = Tail.rec (mcloG (ext σ (rec gst)) gst) mcloS σ (var x) = Tail.var x mcloG σ (transmit d t s) = Tail.transmit d (injectT (applyT σ t)) (mcloS σ s) mcloG σ (choice d m alt) = Tail.choice d m (mcloS σ ∘ alt) mcloG σ end = Tail.end mclosureS : SType 0 → Tail.SType 0 mclosureS = mcloS IND.var mclosureG : GType 0 → Tail.GType 0 mclosureG = mcloG IND.var
{ "alphanum_fraction": 0.6386093321, "avg_line_length": 26.6585365854, "ext": "agda", "hexsha": "c1207bb25652dfcccb2d35c3c57be75a6d8ff11f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-07T16:12:50.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-07T16:12:50.000Z", "max_forks_repo_head_hexsha": "7a8bc1f6b2f808bd2a22c592bd482dbcc271979c", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "peterthiemann/dual-session", "max_forks_repo_path": "src/MessageClosure.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7a8bc1f6b2f808bd2a22c592bd482dbcc271979c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "peterthiemann/dual-session", "max_issues_repo_path": "src/MessageClosure.agda", "max_line_length": 87, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7a8bc1f6b2f808bd2a22c592bd482dbcc271979c", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "peterthiemann/dual-session", "max_stars_repo_path": "src/MessageClosure.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-13T05:43:25.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-13T05:43:25.000Z", "num_tokens": 886, "size": 2186 }
module main where import string-format -- for parser for Cedille open import cedille-types -- for parser for options files import options-types import cedille-options -- for parser for Cedille comments & whitespace import cws-types import io open import constants open import general-util open import json record cedille-args : Set where constructor mk-cedille-args field opts-file : maybe filepath file-to-process : maybe filepath about : 𝔹 help : 𝔹 do-elab : maybe filepath confirm-read-stdin : 𝔹 default-cedille-args = record { opts-file = nothing ; file-to-process = nothing ; about = ff ; help = ff ; do-elab = nothing ; confirm-read-stdin = ff} -- get $HOME/.cedille, creating it if it does not exist getHomeCedilleDirectory : IO filepath getHomeCedilleDirectory = getHomeDirectory >>= λ home → let d = dot-cedille-directory home in io.createDirectoryIfMissing ff d >> return d postulate initializeStdinToUTF8 : IO ⊤ setStdinNewlineMode : IO ⊤ compileTime : UTC templatesDir : filepath die : {A : Set} → 𝕃 char → IO A {-# FOREIGN GHC {-# LANGUAGE TemplateHaskell #-} #-} {-# FOREIGN GHC import qualified System.IO #-} {-# FOREIGN GHC import qualified System.Exit #-} {-# FOREIGN GHC import qualified Data.Time.Clock #-} {-# FOREIGN GHC import qualified Data.Time.Format #-} {-# FOREIGN GHC import qualified Data.Time.Clock.POSIX #-} {-# FOREIGN GHC import qualified Language.Haskell.TH.Syntax #-} {-# COMPILE GHC die = \ _ -> System.Exit.die #-} {-# COMPILE GHC initializeStdinToUTF8 = System.IO.hSetEncoding System.IO.stdin System.IO.utf8 #-} {-# COMPILE GHC setStdinNewlineMode = System.IO.hSetNewlineMode System.IO.stdin System.IO.universalNewlineMode #-} {-# COMPILE GHC compileTime = maybe (Data.Time.Clock.POSIX.posixSecondsToUTCTime (fromIntegral 0)) id (Data.Time.Format.parseTimeM True Data.Time.Format.defaultTimeLocale "%s" $(Language.Haskell.TH.Syntax.runIO (Data.Time.Clock.getCurrentTime >>= \ t -> return (Language.Haskell.TH.Syntax.LitE (Language.Haskell.TH.Syntax.StringL (Data.Time.Format.formatTime Data.Time.Format.defaultTimeLocale "%s" t))))) :: Maybe Data.Time.Clock.UTCTime) #-} say-about : filepath → IO ⊤ say-about optfp = putStrLn $ "Compiled: " ^ (utcToString compileTime) ^ "\n" ^ "Options file: " ^ optfp ^ "\n" createOptionsFile : (dot-ced-dir : string) → IO ⊤ createOptionsFile dot-ced-dir = let ops-fp = combineFileNames dot-ced-dir options-file-name in createDirectoryIfMissing ff (takeDirectory ops-fp) >> withFile ops-fp WriteMode (flip hPutRope (cedille-options.options-to-rope cedille-options.default-options)) options-absolute-path : (options-fp some-fp : filepath) → IO filepath options-absolute-path ofp fp = (filepath-replace-tilde fp >>= flip maybe-else return (doesFileExist fp >>=r λ fpₑ → if fpₑ then fp else combineFileNames (takeDirectory (takeDirectory ofp)) fp)) >>= canonicalizePath opts-to-options : filepath → options-types.opts → IO cedille-options.options opts-to-options ofp (options-types.OptsCons (options-types.Lib fps) ops) = opts-to-options ofp ops >>= λ ops → paths-to-stringset fps >>=r λ ip → record ops { include-path = ip } where paths-to-stringset : options-types.paths → IO (𝕃 string × stringset) paths-to-stringset (options-types.PathsCons fp fps) = let rfp = combineFileNames (takeDirectory (takeDirectory ofp)) fp in paths-to-stringset fps >>= λ ps → doesDirectoryExist rfp >>= λ rfpₑ → doesDirectoryExist fp >>= λ fpₑ → (if rfpₑ then (canonicalizePath rfp >>= λ rfp → return (cedille-options.include-path-insert rfp ps)) else return ps) >>= λ ps → if fpₑ then (canonicalizePath fp >>= λ fp → return (cedille-options.include-path-insert fp ps)) else return ps paths-to-stringset options-types.PathsNil = return ([] , empty-stringset) opts-to-options ofp (options-types.OptsCons (options-types.UseCedeFiles b) ops) = opts-to-options ofp ops >>=r λ ops → record ops { use-cede-files = b } opts-to-options ofp (options-types.OptsCons (options-types.MakeRktFiles b) ops) = opts-to-options ofp ops >>=r λ ops → record ops { make-rkt-files = b } opts-to-options ofp (options-types.OptsCons (options-types.GenerateLogs b) ops) = opts-to-options ofp ops >>=r λ ops → record ops { generate-logs = b } opts-to-options ofp (options-types.OptsCons (options-types.ShowQualifiedVars b) ops) = opts-to-options ofp ops >>=r λ ops → record ops { show-qualified-vars = b } opts-to-options ofp (options-types.OptsCons (options-types.EraseTypes b) ops) = opts-to-options ofp ops >>=r λ ops → record ops { erase-types = b } opts-to-options ofp (options-types.OptsCons (options-types.PrettyPrintColumns b) ops) = opts-to-options ofp ops >>=r λ ops → record ops { pretty-print-columns = string-to-ℕ0 b } opts-to-options ofp (options-types.OptsCons (options-types.DatatypeEncoding fp?) ops) = maybe-map (options-absolute-path ofp) fp? >>=? λ fp? → opts-to-options ofp ops >>=r λ ops → record ops { datatype-encoding = (_, nothing) <$> fp? } opts-to-options ofp options-types.OptsNil = return cedille-options.default-options -- helper function to try to parse the options file processOptions : filepath → string → IO (string ⊎ cedille-options.options) processOptions filename s with options-types.scanOptions s ...| options-types.Left cs = return (inj₁ ("Parse error in file " ^ filename ^ " " ^ cs ^ ".")) ...| options-types.Right (options-types.File oo) = opts-to-options filename oo >>= λ opts → if cedille-options.options.make-rkt-files opts then return ∘ inj₁ $ "Racket compilation disabled, please set to false in " ^ filename ^ "." else (return ∘ inj₂ $ opts) getOptionsFile : (filepath : string) → string getOptionsFile fp = combineFileNames (dot-cedille-directory fp) options-file-name findOptionsFile' : (filepath : string) → IO (maybe string) findOptionsFile' fp = traverseParents fp (fp-fuel fp) >>= λ where fpc?@(just fpc) → return fpc? nothing → getHomeDirectory >>= getOptions? where getOptions? : (filepath : string) → IO ∘ maybe $ string getOptions? fp = let fpc = getOptionsFile fp in doesFileExist fpc >>= λ where ff → return nothing tt → return ∘ just $ fpc traverseParents : string → ℕ → IO (maybe string) traverseParents fp 0 = return nothing traverseParents fp (suc n) = getOptions? fp >>= λ where nothing → traverseParents (takeDirectory fp) n fpc?@(just fpc) → return fpc? fp-fuel : (filepath : string) → ℕ fp-fuel fp = pred ∘' length ∘' splitPath $ fp findOptionsFile : IO (maybe string) findOptionsFile = (getCurrentDirectory >>= canonicalizePath) >>= findOptionsFile' readOptions : maybe filepath → IO (filepath × cedille-options.options) readOptions nothing = getHomeCedilleDirectory >>= λ home → createOptionsFile home >>r dot-cedille-directory home , cedille-options.default-options readOptions (just fp) = readFiniteFile fp >>= λ fc → processOptions fp fc >>= λ where (inj₁ err) → putStrLn (global-error-string err) >>r fp , cedille-options.default-options (inj₂ ops) → return (fp , ops) showCedilleUsage : IO ⊤ showCedilleUsage = putStrLn ("Command-line usage: cedille [--e elab-dir | --options options-file | --about ] file-to-check\n" ^ "With no arguments, read commands from the front-end on stdin.") module main-with-options (compileTime : UTC) (options-filepath : filepath) (options : cedille-options.options) (die : {A : Set} → 𝕃 char → IO A) where open import ctxt --open import instances open import process-cmd options {IO} open import parser open import spans options {IO} open import syntax-util open import to-string options open import toplevel-state options {IO} open import interactive-cmds options open import rkt options open import elab-util options open import communication-util options logFilePathIO : IO filepath logFilePathIO = getHomeCedilleDirectory >>=r (flip combineFileNames $ "log") maybeClearLogFile : IO filepath maybeClearLogFile = logFilePathIO >>= λ logFilePath → ifM (cedille-options.options.generate-logs options) (clearFile logFilePath) >> return logFilePath fileBaseName : filepath → string fileBaseName fn = base-filename (takeFileName fn) fileSuffix : filepath → string fileSuffix = maybe-else cedille-extension id ∘ var-suffix {------------------------------------------------------------------------------- .cede support -------------------------------------------------------------------------------} cede-suffix = ".cede" rkt-suffix = ".rkt" ced-aux-filename : (suffix ced-path : filepath) → filepath ced-aux-filename sfx ced-path = let dir = takeDirectory ced-path in combineFileNames (dot-cedille-directory dir) (fileBaseName ced-path ^ sfx) cede-filename = ced-aux-filename cede-suffix rkt-filename = ced-aux-filename rkt-suffix maybe-write-aux-file : toplevel-state → include-elt → (create-dot-ced-if-missing : IO ⊤) → (filename file-suffix : filepath) → (cedille-options.options → 𝔹) → (include-elt → 𝔹) → rope → IO ⊤ maybe-write-aux-file s ie mk-dot-ced fn sfx f f' r with f options && ~ f' ie ...| ff = return triv ...| tt = mk-dot-ced >> logMsg s ("Starting writing " ^ sfx ^ " file " ^ fn) >> writeRopeToFile fn r >> logMsg s ("Finished writing " ^ sfx ^ " file " ^ fn) write-aux-files : toplevel-state → filepath → IO ⊤ write-aux-files s filename with get-include-elt-if s filename ...| nothing = return triv ...| just ie = let dot-ced = createDirectoryIfMissing ff (dot-cedille-directory (takeDirectory filename)) in maybe-write-aux-file s ie dot-ced (cede-filename filename) cede-suffix cedille-options.options.use-cede-files include-elt.cede-up-to-date ((if include-elt.err ie then [[ "e" ]] else [[]]) ⊹⊹ json-to-rope (include-elt-spans-to-json ie)) >> maybe-write-aux-file s ie dot-ced (rkt-filename filename) rkt-suffix cedille-options.options.make-rkt-files include-elt.rkt-up-to-date (to-rkt-file filename (toplevel-state.Γ s) ie rkt-filename) -- we assume the cede file is known to exist at this point read-cede-file : toplevel-state → (ced-path : filepath) → IO (𝔹 × string) read-cede-file s ced-path = let cede = cede-filename ced-path in logMsg s ("Started reading .cede file " ^ cede) >> (get-file-contents cede >>= finish) >≯ logMsg s ("Finished reading .cede file " ^ cede) where finish : maybe string → IO (𝔹 × string) finish nothing = return (tt , global-error-string ("Could not read the file " ^ cede-filename ced-path ^ ".")) finish (just ss) with string-to-𝕃char ss finish (just ss) | ('e' :: ss') = forceFileRead ss >>r tt , 𝕃char-to-string ss' finish (just ss) | _ = forceFileRead ss >>r ff , ss --add-cedille-extension : string → string --add-cedille-extension x = x ^ "." ^ cedille-extension --add-cdle-extension : string → string --add-cdle-extension x = x ^ "." ^ cdle-extension -- Allows you to say "import FOO.BAR.BAZ" rather than "import FOO/BAR/BAZ" replace-dots : filepath → filepath replace-dots s = 𝕃char-to-string (h (string-to-𝕃char s)) where h : 𝕃 char → 𝕃 char h ('.' :: '.' :: cs) = '.' :: '.' :: h cs h ('.' :: cs) = pathSeparator :: h cs h (c :: cs) = c :: h cs h [] = [] find-imported-file : (sfx : string) → (dirs : 𝕃 filepath) → (unit-name : string) → IO (maybe filepath) find-imported-file sfx [] unit-name = return nothing find-imported-file sfx (dir :: dirs) unit-name = let e = combineFileNames dir (unit-name ^ "." ^ sfx) in doesFileExist e >>= λ where tt → canonicalizePath e >>=r just ff → find-imported-file sfx dirs unit-name {- find-imported-file sfx (dir :: dirs) unit-name = let e₁ = combineFileNames dir (add-cedille-extension unit-name) e₂ = combineFileNames dir (add-cdle-extension unit-name) e? = λ e → doesFileExist e >>=r λ e? → ifMaybej e? e in (e? e₁ >>= λ e₁ → e? e₂ >>=r λ e₂ → e₁ maybe-or e₂) >>= λ where nothing → find-imported-file sfx dirs unit-name (just e) → canonicalizePath e >>=r just -} find-imported-files : toplevel-state → (sfx : string) → (dirs : 𝕃 filepath) → (imports : 𝕃 string) → IO (𝕃 (string × filepath)) find-imported-files s sfx dirs (u :: us) = find-imported-file sfx dirs (replace-dots u) >>= λ where nothing → logMsg s ("Error finding file: " ^ replace-dots u) >> find-imported-files s sfx dirs us (just fp) → logMsg s ("Found import: " ^ fp) >> find-imported-files s sfx dirs us >>=r (u , fp) ::_ find-imported-files s sfx dirs [] = return [] get-imports : ex-file → 𝕃 string get-imports (ExModule is _ _ mn _ cs _) = map (λ {(ExImport _ _ _ x _ _ _) → x}) (is ++ ex-cmds-to-imps cs) {- new parser test integration -} reparse : toplevel-state → filepath → IO toplevel-state reparse st filename = doesFileExist filename >>= λ fileExists → (if fileExists then (readFiniteFile filename >>= λ source → getCurrentTime >>= λ time → processText source >>= λ ie → return (set-last-parse-time-include-elt ie time) >>=r λ ie -> set-source-include-elt ie source) else return (error-include-elt ("The file " ^ filename ^ " could not be opened for reading."))) >>=r set-include-elt st filename where processText : string → IO include-elt processText x with parseStart x processText x | Left (Left cs) = return (error-span-include-elt ("Error in file " ^ filename ^ ".") "Lexical error." cs) processText x | Left (Right cs) = return (error-span-include-elt ("Error in file " ^ filename ^ ".") "Parsing error." cs) processText x | Right t with cws-types.scanComments x processText x | Right t | t2 = find-imported-files st (fileSuffix filename) (fst (cedille-options.include-path-insert (takeDirectory filename) (toplevel-state.include-path st))) (get-imports t) >>= λ deps → logMsg st ("deps for file " ^ filename ^ ": " ^ 𝕃-to-string (λ {(a , b) → "short: " ^ a ^ ", long: " ^ b}) ", " deps) >>r new-include-elt filename deps t t2 nothing reparse-file : filepath → toplevel-state → IO toplevel-state reparse-file filename s = reparse s filename >>=r λ s → set-include-elt s filename (set-cede-file-up-to-date-include-elt (set-do-type-check-include-elt (get-include-elt s filename) tt) ff) infixl 2 _&&>>_ _&&>>_ : IO 𝔹 → IO 𝔹 → IO 𝔹 (a &&>> b) = a >>= λ a → if a then b else return ff aux-up-to-date : filepath → toplevel-state → IO toplevel-state aux-up-to-date filename s = let rkt = rkt-filename filename in (doesFileExist rkt &&>> fileIsOlder filename rkt) >>=r (set-include-elt s filename ∘ (set-rkt-file-up-to-date-include-elt (get-include-elt s filename))) ie-up-to-date : filepath → include-elt → IO 𝔹 ie-up-to-date filename ie = getModificationTime filename >>=r λ mt → maybe-else ff (λ lpt → lpt utc-after mt) (include-elt.last-parse-time ie) import-changed : toplevel-state → filepath → (import-file : string) → IO 𝔹 import-changed s filename import-file = let dtc = include-elt.do-type-check (get-include-elt s import-file) cede = cede-filename filename cede' = cede-filename import-file in case cedille-options.options.use-cede-files options of λ where ff → return dtc tt → (doesFileExist cede &&>> doesFileExist cede') >>= λ where ff → return ff tt → fileIsOlder cede cede' >>=r λ fio → dtc || fio any-imports-changed : toplevel-state → filepath → (imports : 𝕃 string) → IO 𝔹 any-imports-changed s filename [] = return ff any-imports-changed s filename (h :: t) = import-changed s filename h >>= λ where tt → return tt ff → any-imports-changed s filename t file-after-compile : filepath → IO 𝔹 file-after-compile fn = getModificationTime fn >>= λ mt → case mt utc-after compileTime of λ where tt → doesFileExist options-filepath &&>> fileIsOlder options-filepath fn ff → return ff ensure-ast-depsh : filepath → toplevel-state → IO toplevel-state ensure-ast-depsh filename s with get-include-elt-if s filename ...| just ie = ie-up-to-date filename ie >>= λ where ff → reparse-file filename s tt → return s ...| nothing = let cede = cede-filename filename in (return (cedille-options.options.use-cede-files options) &&>> doesFileExist cede &&>> fileIsOlder filename cede &&>> file-after-compile cede) >>= λ where ff → reparse-file filename s tt → reparse s filename >>= λ s → read-cede-file s filename >>= λ where (err , ss) → return (set-include-elt s filename (set-do-type-check-include-elt (set-need-to-add-symbols-to-context-include-elt (set-spans-string-include-elt (get-include-elt s filename) err ss) tt) ff)) {- helper function for update-asts, which keeps track of the files we have seen so we avoid importing the same file twice, and also avoid following cycles in the import graph. -} {-# TERMINATING #-} update-astsh : stringset {- seen already -} → toplevel-state → filepath → IO (stringset {- seen already -} × toplevel-state) update-astsh seen s filename = if stringset-contains seen filename then return (seen , s) else ((ensure-ast-depsh filename s >>= aux-up-to-date filename) >>= cont (stringset-insert seen filename)) where cont : stringset → toplevel-state → IO (stringset × toplevel-state) cont seen s with get-include-elt s filename cont seen s | ie with include-elt.deps ie cont seen s | ie | ds = proc seen s ds where proc : stringset → toplevel-state → 𝕃 string → IO (stringset × toplevel-state) proc seen s [] = any-imports-changed s filename ds >>=r λ changed → seen , set-include-elt s filename (set-do-type-check-include-elt ie (include-elt.do-type-check ie || changed)) proc seen s (d :: ds) = update-astsh seen s d >>= λ p → proc (fst p) (snd p) ds {- this function updates the ast associated with the given filename in the toplevel state. So if we do not have an up-to-date .cede file (i.e., there is no such file at all, or it is older than the given file), reparse the file. We do this recursively for all dependencies (i.e., imports) of the file. -} update-asts : toplevel-state → filepath → IO toplevel-state update-asts s filename = update-astsh empty-stringset s filename >>=r snd log-files-to-check : toplevel-state → IO ⊤ log-files-to-check s = logRope s ([[ "\n" ]] ⊹⊹ (h (trie-mappings (toplevel-state.is s)))) where h : 𝕃 (string × include-elt) → rope h [] = [[]] h ((fn , ie) :: t) = [[ "file: " ]] ⊹⊹ [[ fn ]] ⊹⊹ [[ "\nadd-symbols: " ]] ⊹⊹ [[ 𝔹-to-string (include-elt.need-to-add-symbols-to-context ie) ]] ⊹⊹ [[ "\ndo-type-check: " ]] ⊹⊹ [[ 𝔹-to-string (include-elt.do-type-check ie) ]] ⊹⊹ [[ "\n\n" ]] ⊹⊹ h t {- this function checks the given file (if necessary), updates .cede and .rkt files (again, if necessary), and replies on stdout if appropriate -} checkFile : (string → IO ⊤) → toplevel-state → filepath → (should-print-spans : 𝔹) → IO toplevel-state checkFile progressUpdate s filename should-print-spans = update-asts s filename >>= λ s → log-files-to-check s >> logMsg s (𝕃-to-string (λ {(im , fn) → "im: " ^ im ^ ", fn: " ^ fn}) "; " (trie-mappings (include-elt.import-to-dep (get-include-elt s filename)))) >> process-file progressUpdate (logMsg s) s filename (fileBaseName filename) >>= finish where reply : toplevel-state → IO ⊤ reply s with get-include-elt-if s filename reply s | nothing = putStrLn (global-error-string ("Internal error looking up information for file " ^ filename ^ ".")) reply s | just ie = if should-print-spans then putJson (include-elt-spans-to-json ie) else return triv finish : (toplevel-state × file × string × string × params × qualif) → IO toplevel-state finish (s @ (mk-toplevel-state ip mod is Γ logFilePath) , f , ret-mod) = logMsg s ("Started reply for file " ^ filename) >> -- Lazy, so checking has not been calculated yet? reply s >> logMsg s ("Finished reply for file " ^ filename) >> logMsg s ("Files with updated spans:\n" ^ 𝕃-to-string (λ x → x) "\n" mod) >> let Γ = ctxt-set-current-mod Γ ret-mod in writeo mod >>r -- Should process-file now always add files to the list of modified ones because now the cede-/rkt-up-to-date fields take care of whether to rewrite them? mk-toplevel-state ip [] is Γ logFilePath -- Reset files with updated spans where writeo : 𝕃 string → IO ⊤ writeo [] = return triv writeo (f :: us) = writeo us >> --let ie = get-include-elt s f in write-aux-files s f -- (if cedille-options.options.make-rkt-files options && ~ include-elt.rkt-up-to-date ie then (write-rkt-file f (toplevel-state.Γ s) ie rkt-filename) else return triv) -- this is the function that handles requests (from the frontend) on standard input {-# TERMINATING #-} readCommandsFromFrontend : toplevel-state → IO ⊤ readCommandsFromFrontend s = getLine >>= λ input → logMsg s ("Frontend input: " ^ input) >> let input-list : 𝕃 string input-list = string-split (undo-escape-string input) delimiter in handleCommands input-list s >>= readCommandsFromFrontend where errorCommand : 𝕃 string → toplevel-state → IO ⊤ errorCommand ls s = putStrLn (global-error-string "Invalid command sequence \\\\\"" ^ (𝕃-to-string (λ x → x) ", " ls) ^ "\\\\\".") debugCommand : toplevel-state → IO ⊤ debugCommand s = putStrLn (escape-string (toplevel-state-to-string s)) checkCommand : 𝕃 string → toplevel-state → IO toplevel-state checkCommand (input :: []) s = canonicalizePath input >>= λ input-filename → checkFile progressUpdate (set-include-path s (cedille-options.include-path-insert (takeDirectory input-filename) (toplevel-state.include-path s))) input-filename tt {- should-print-spans -} checkCommand ls s = errorCommand ls s >>r s createArchive-h : toplevel-state → trie json → 𝕃 string → json createArchive-h s t (filename :: filenames) with trie-contains t filename | get-include-elt-if s filename ...| ff | just ie = createArchive-h s (trie-insert t filename $ include-elt-to-archive ie) (filenames ++ include-elt.deps ie) ...| _ | _ = createArchive-h s t filenames createArchive-h s t [] = json-object $ trie-mappings t createArchive : toplevel-state → string → json createArchive s filename = createArchive-h s empty-trie (filename :: []) archiveCommand : 𝕃 string → toplevel-state → IO toplevel-state archiveCommand (input :: []) s = canonicalizePath input >>= λ filename → update-asts s filename >>= λ s → process-file (λ _ → return triv) (λ _ → return triv) s filename (fileBaseName filename) >>=c λ s _ → putRopeLn (json-to-rope (createArchive s filename)) >>r s archiveCommand ls s = errorCommand ls s >>r s handleCommands : 𝕃 string → toplevel-state → IO toplevel-state handleCommands ("progress stub" :: xs) = return handleCommands ("status ping" :: xs) s = putStrLn "idle" >> return s handleCommands ("check" :: xs) s = checkCommand xs s handleCommands ("debug" :: []) s = debugCommand s >>r s handleCommands ("elaborate" :: fm :: to :: []) s = elab-all s fm to >>r s handleCommands ("interactive" :: xs) s = interactive-cmd xs s >>r s handleCommands ("archive" :: xs) s = archiveCommand xs s handleCommands ("br" :: xs) s = putJson interactive-not-br-cmd-msg >>r s -- handleCommands ("find" :: xs) s = findCommand xs s handleCommands xs s = errorCommand xs s >>r s {- mk-new-toplevel-state : IO toplevel-state mk-new-toplevel-state = let s = new-toplevel-state (cedille-options.options.include-path options) in maybe-else' (cedille-options.options.datatype-encoding options) (return s) λ fp → readFiniteFile fp >>= λ de → case parseStart de of λ where (Left (Left e)) → putStrLn ("Lexical error in datatype encoding at position " ^ e) >>r s (Left (Right e)) → putStrLn ("Parse error in datatype encoding at position " ^ e) >>r s (Right de) → {!!} -} processFile : (logFilePath : filepath) → string → IO toplevel-state processFile logFilePath input-filename = checkFile progressUpdate (new-toplevel-state logFilePath (cedille-options.include-path-insert (takeDirectory input-filename) (cedille-options.options.include-path options))) input-filename ff typecheckFile : (logFilePath : filepath) → string → IO toplevel-state typecheckFile logFilePath f = processFile logFilePath f >>= λ s → let ie = get-include-elt s f in if include-elt.err ie then die (string-to-𝕃char ("Type Checking Failed")) else return s -- function to process command-line arguments processArgs : (logFilePath : filepath) → cedille-args → IO ⊤ -- this is the case for when we are called with a single command-line argument, the name of the file to process processArgs logFilePath (mk-cedille-args _ minput-filename about help do-elab confirm-read-stdin) = if help then showCedilleUsage else if about then say-about options-filepath else maybe-else' minput-filename (ifM confirm-read-stdin $ readCommandsFromFrontend (new-toplevel-state logFilePath (cedille-options.options.include-path options))) (λ input-filename → canonicalizePath input-filename >>= λ input-filename' → typecheckFile logFilePath input-filename' >>= λ s → whenM do-elab (λ target-dir → elab-all s input-filename' target-dir)) main' : cedille-args → IO ⊤ main' args = maybeClearLogFile >>= λ logFilePath → logMsg' logFilePath ("Started Cedille process (compiled at: " ^ utcToString compileTime ^ ")") >> processArgs logFilePath args getCedilleArgs : IO cedille-args getCedilleArgs = getArgs >>= λ where -- only read from stdin if there are no args at all [] → return $ record default-cedille-args {confirm-read-stdin = tt} args → getCedilleArgsH args default-cedille-args where bad-opts-flag : IO ⊤ bad-opts-flag = putStrLn "warning: flag --options should be followed by a Cedille options file" unknown-flag : string → IO ⊤ unknown-flag f = putStrLn $ "warning: unknown flag " ^ f -- allow for later --options to override earlier. This is a bash idiom getCedilleArgsH : 𝕃 string → cedille-args → IO cedille-args getCedilleArgsH ("--options" :: y :: xs) args = getCedilleArgsH xs (record args { opts-file = just y}) getCedilleArgsH ("--options" :: []) args = bad-opts-flag >> return args getCedilleArgsH ("--about" :: xs) args = getCedilleArgsH xs (record args { about = tt }) getCedilleArgsH ("--help" :: xs) args = getCedilleArgsH xs (record args { help = tt }) getCedilleArgsH ("--elab" :: to :: xs) args = getCedilleArgsH xs (record args { do-elab = just to}) getCedilleArgsH (x :: []) args = -- assume it is a .ced file to check return $ record args {file-to-process = just x} getCedilleArgsH (x :: y :: xs) args = unknown-flag x >> return args getCedilleArgsH [] args = return args process-encoding : filepath → cedille-options.options → IO cedille-options.options process-encoding ofp ops @ (cedille-options.mk-options ip _ _ _ _ _ de _ _ _ _) = maybe-else' de (return ops) λ de-f → let de = fst de-f s = new-toplevel-state "no logfile path" (cedille-options.include-path-insert (takeDirectory de) ip) in update-asts s de >>= λ s → process-encoding-file s de >>= λ f? → maybe-else' f? (return ops) λ ast~ → return (record ops {datatype-encoding = just (de , just ast~)}) where ops' = record ops {datatype-encoding = nothing; use-cede-files = ff} open main-with-options compileTime ofp ops' die open import spans ops' {IO} open import toplevel-state ops' {IO} open import process-cmd ops' {IO} (λ _ → return triv) (λ _ → return triv) open import syntax-util open import ctxt process-encoding-file : toplevel-state → filepath → IO (maybe file) process-encoding-file s fp with get-include-elt-if s fp >>= include-elt.ast ...| nothing = putStrLn ("Error looking up datatype encoding information from file " ^ fp) >> return nothing ...| just (ExModule is pi1 pi2 mn ps cs pi3) = (process-cmds (record s {Γ = ctxt-initiate-file (toplevel-state.Γ s) fp mn}) (map ExCmdImport is) >>=c λ s is' → process-params s first-position [] >>=c λ s _ → check-and-add-params (toplevel-state.Γ s) (params-end-pos first-position ps) ps >>=c λ Γₚₛ ps~ → process-cmds (record s {Γ = Γₚₛ}) cs >>=c λ s cs → return2 ps~ (is' ++ cs)) empty-spans >>=c uncurry λ ps cs _ → return (just (Module mn ps cs)) -- main entrypoint for the backend main : IO ⊤ main = initializeStdoutToUTF8 >> initializeStdinToUTF8 >> setStdoutNewlineMode >> setStdinNewlineMode >> setToLineBuffering >> getCedilleArgs >>= λ args → maybe-else' (cedille-args.opts-file args) (findOptionsFile >>= readOptions) (readOptions ∘ just) >>=c λ ofp ops → let log = cedille-options.options.generate-logs ops in process-encoding ofp (record ops {generate-logs = ff}) >>= λ ops → let args = record args { opts-file = just ofp } in let ops = record ops { generate-logs = log ; show-progress-updates = ~ (cedille-args.confirm-read-stdin args) } in main-with-options.main' compileTime ofp ops die args
{ "alphanum_fraction": 0.6441305407, "avg_line_length": 47.231595092, "ext": "agda", "hexsha": "992bceb044cc52a16a474f1658c7f990c077c809", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ice1k/cedille", "max_forks_repo_path": "src/main.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ice1k/cedille", "max_issues_repo_path": "src/main.agda", "max_line_length": 251, "max_stars_count": null, "max_stars_repo_head_hexsha": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ice1k/cedille", "max_stars_repo_path": "src/main.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8464, "size": 30795 }
------------------------------------------------------------------------------ -- The inductive PA universe ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- This file contains some core definitions which are reexported by -- PA.Inductive.Base. module PA.Inductive.Base.Core where -- PA universe. data ℕ : Set where zero : ℕ succ : ℕ → ℕ
{ "alphanum_fraction": 0.4259927798, "avg_line_length": 29.1578947368, "ext": "agda", "hexsha": "44fa74a15681802757d5bed8e0cdb5a4da45e2fd", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/PA/Inductive/Base/Core.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/PA/Inductive/Base/Core.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/PA/Inductive/Base/Core.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 96, "size": 554 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Commutative semirings with some additional structure ("almost" -- commutative rings), used by the ring solver ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Algebra.Solver.Ring.AlmostCommutativeRing where open import Algebra open import Algebra.Structures open import Algebra.Definitions import Algebra.Morphism as Morphism import Algebra.Morphism.Definitions as MorphismDefinitions open import Function open import Level open import Relation.Binary record IsAlmostCommutativeRing {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where field isCommutativeSemiring : IsCommutativeSemiring _≈_ _+_ _*_ 0# 1# -‿cong : Congruent₁ _≈_ -_ -‿*-distribˡ : ∀ x y → ((- x) * y) ≈ (- (x * y)) -‿+-comm : ∀ x y → ((- x) + (- y)) ≈ (- (x + y)) open IsCommutativeSemiring isCommutativeSemiring public record AlmostCommutativeRing c ℓ : Set (suc (c ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier isAlmostCommutativeRing : IsAlmostCommutativeRing _≈_ _+_ _*_ -_ 0# 1# open IsAlmostCommutativeRing isAlmostCommutativeRing public commutativeSemiring : CommutativeSemiring _ _ commutativeSemiring = record { isCommutativeSemiring = isCommutativeSemiring } open CommutativeSemiring commutativeSemiring public using ( +-magma; +-semigroup ; *-magma; *-semigroup; *-commutativeSemigroup ; +-monoid; +-commutativeMonoid ; *-monoid; *-commutativeMonoid ; semiring ) rawRing : RawRing _ _ rawRing = record { _≈_ = _≈_ ; _+_ = _+_ ; _*_ = _*_ ; -_ = -_ ; 0# = 0# ; 1# = 1# } ------------------------------------------------------------------------ -- Homomorphisms record _-Raw-AlmostCommutative⟶_ {r₁ r₂ r₃ r₄} (From : RawRing r₁ r₄) (To : AlmostCommutativeRing r₂ r₃) : Set (r₁ ⊔ r₂ ⊔ r₃) where private module F = RawRing From module T = AlmostCommutativeRing To open MorphismDefinitions F.Carrier T.Carrier T._≈_ field ⟦_⟧ : Morphism +-homo : Homomorphic₂ ⟦_⟧ F._+_ T._+_ *-homo : Homomorphic₂ ⟦_⟧ F._*_ T._*_ -‿homo : Homomorphic₁ ⟦_⟧ F.-_ T.-_ 0-homo : Homomorphic₀ ⟦_⟧ F.0# T.0# 1-homo : Homomorphic₀ ⟦_⟧ F.1# T.1# -raw-almostCommutative⟶ : ∀ {r₁ r₂} (R : AlmostCommutativeRing r₁ r₂) → AlmostCommutativeRing.rawRing R -Raw-AlmostCommutative⟶ R -raw-almostCommutative⟶ R = record { ⟦_⟧ = id ; +-homo = λ _ _ → refl ; *-homo = λ _ _ → refl ; -‿homo = λ _ → refl ; 0-homo = refl ; 1-homo = refl } where open AlmostCommutativeRing R Induced-equivalence : ∀ {c₁ c₂ ℓ₁ ℓ₂} {Coeff : RawRing c₁ ℓ₁} {R : AlmostCommutativeRing c₂ ℓ₂} → Coeff -Raw-AlmostCommutative⟶ R → Rel (RawRing.Carrier Coeff) ℓ₂ Induced-equivalence {R = R} morphism a b = ⟦ a ⟧ ≈ ⟦ b ⟧ where open AlmostCommutativeRing R open _-Raw-AlmostCommutative⟶_ morphism ------------------------------------------------------------------------ -- Conversions -- Commutative rings are almost commutative rings. fromCommutativeRing : ∀ {r₁ r₂} → CommutativeRing r₁ r₂ → AlmostCommutativeRing r₁ r₂ fromCommutativeRing CR = record { isAlmostCommutativeRing = record { isCommutativeSemiring = isCommutativeSemiring ; -‿cong = -‿cong ; -‿*-distribˡ = -‿*-distribˡ ; -‿+-comm = ⁻¹-∙-comm } } where open CommutativeRing CR open import Algebra.Properties.Ring ring open import Algebra.Properties.AbelianGroup +-abelianGroup -- Commutative semirings can be viewed as almost commutative rings by -- using identity as the "almost negation". fromCommutativeSemiring : ∀ {r₁ r₂} → CommutativeSemiring r₁ r₂ → AlmostCommutativeRing _ _ fromCommutativeSemiring CS = record { -_ = id ; isAlmostCommutativeRing = record { isCommutativeSemiring = isCommutativeSemiring ; -‿cong = id ; -‿*-distribˡ = λ _ _ → refl ; -‿+-comm = λ _ _ → refl } } where open CommutativeSemiring CS
{ "alphanum_fraction": 0.5621656324, "avg_line_length": 31.1533333333, "ext": "agda", "hexsha": "20a01ef9cc23f176aa52df98acf2480cd4316d72", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Algebra/Solver/Ring/AlmostCommutativeRing.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Algebra/Solver/Ring/AlmostCommutativeRing.agda", "max_line_length": 91, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Algebra/Solver/Ring/AlmostCommutativeRing.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 1515, "size": 4673 }
data Nat : Set where zero : Nat suc : Nat → Nat {-# BUILTIN NATURAL Nat #-} data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x {-# NON_TERMINATING #-} loop : Nat → Nat loop n = loop n thm : ∀ n → loop n ≡ 42 thm n = refl
{ "alphanum_fraction": 0.5420168067, "avg_line_length": 14, "ext": "agda", "hexsha": "59dec94f304a0ebcc557c96ca53eb8b19b428010", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/NonTerminatingReduce.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/NonTerminatingReduce.agda", "max_line_length": 42, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/NonTerminatingReduce.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 92, "size": 238 }
module ParseTreeOperations where open import ParseTree open import Data.List.NonEmpty open import Data.Bool open import Data.List hiding ([_]) open import Data.Nat open import Relation.Nullary open import Data.String -- go from ((f a) b) representation to f [a, b] expressionToList : Expr -> List⁺ Expr expressionToList (functionApp e e₁ {false}) = expressionToList e ⁺∷ʳ e₁ expressionToList x = [ x ] typeToList : Expr -> List⁺ Expr typeToList (functionApp e e₁ {true}) = e ∷⁺ typeToList e₁ typeToList x = [ x ] -- go from f [a, b] representation to ((f a) b) {-# TERMINATING #-} listToExpression : List⁺ Expr -> Expr listToExpression (head₁ ∷ []) = head₁ listToExpression (head₁ ∷ x ∷ tail₁) = listToExpression (functionApp head₁ x {false} ∷ tail₁) {-# TERMINATING #-} listToType : List⁺ Expr -> Expr listToType (head₁ ∷ []) = head₁ listToType (head₁ ∷ y ∷ tail) = functionApp head₁ (listToType (y ∷ tail)) {true} emptyRange : Range emptyRange = range 0 0 newHole : Expr newHole = hole {""} {emptyRange} {[]} {[]} newUnderscore : Expr newUnderscore = underscore {emptyRange} {[]} {[]} sameId : Identifier -> Identifier -> Bool sameId (identifier name isInRange scope declaration) (identifier name₁ isInRange₁ scope₁ declaration₁) with declaration Data.Nat.≟ declaration₁ sameId (identifier name isInRange scope declaration) (identifier name₁ isInRange₁ scope₁ declaration₁) | yes p = true sameId (identifier name isInRange scope declaration) (identifier name₁ isInRange₁ scope₁ declaration₁) | no ¬p = false sameName : Identifier -> Identifier -> Bool sameName (identifier name isInRange scope declaration) (identifier name₁ isInRange₁ scope₁ declaration₁) = name₁ == name _doesNotAppearInExp_ : Identifier -> Expr -> Bool x doesNotAppearInExp numLit = true identifier name₁ isInRange₁ scope₁ declaration₁ doesNotAppearInExp ident (identifier name isInRange scope declaration) with compare declaration₁ declaration (identifier name₁ isInRange₁ scope₁ declaration₁) doesNotAppearInExp (ident (identifier name isInRange scope .declaration₁)) | equal .declaration₁ = false ... | _ = true x doesNotAppearInExp hole = true x doesNotAppearInExp namedArgument (typeSignature funcName funcType) = x doesNotAppearInExp funcType x doesNotAppearInExp functionApp y y₁ = (x doesNotAppearInExp y) ∧ (x doesNotAppearInExp y₁) x doesNotAppearInExp implicit x1 = x doesNotAppearInExp x1 x doesNotAppearInExp underscore = true isImplicit : Expr -> Bool isImplicit (implicit e) = true isImplicit (namedArgument arg {explicit}) = not explicit isImplicit x = false
{ "alphanum_fraction": 0.7591155935, "avg_line_length": 37.9117647059, "ext": "agda", "hexsha": "d3f9a99d2a0fc621e5137fd86b6270fe639a4608", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "omega12345/RefactorAgda", "max_forks_repo_path": "RefactorAgdaEngine/ParseTreeOperations.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "omega12345/RefactorAgda", "max_issues_repo_path": "RefactorAgdaEngine/ParseTreeOperations.agda", "max_line_length": 154, "max_stars_count": 5, "max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "omega12345/RefactorAgda", "max_stars_repo_path": "RefactorAgdaEngine/ParseTreeOperations.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z", "num_tokens": 712, "size": 2578 }
{-# OPTIONS --without-K #-} open import HoTT open import cw.CW open import homotopy.PinSn module cw.Degree {i} {n : ℕ} (skel : Skeleton {i} (S (S n))) (skel-has-dec-cells : has-dec-cells skel) (skel-is-aligned : is-aligned skel) -- the cells at the upper and lower dimensions (upper : cells-last skel) (lower : cells-nth (inr ltS) skel) where private lower-skel = cw-take (inr ltS) skel lower-cells = cells-last lower-skel lower-cells-has-dec-eq = snd (fst skel-has-dec-cells) -- squash the lower CW complex except one of its cells [lower] cw-squash-lower-to-Sphere : ⟦ lower-skel ⟧ → Sphere (S n) cw-squash-lower-to-Sphere = Attached-rec (λ _ → north) squash-hubs squash-spokes where -- squash cells except [lower] squash-hubs : lower-cells → Sphere (S n) squash-hubs c with lower-cells-has-dec-eq c lower ... | (inl _) = south ... | (inr _) = north -- squash cells except [lower] squash-spokes : (c : lower-cells) → Sphere n → north == squash-hubs c squash-spokes c s with lower-cells-has-dec-eq c lower ... | (inl _) = merid s ... | (inr _) = idp degree-map : Sphere (S n) → Sphere (S n) degree-map = cw-squash-lower-to-Sphere ∘ attaching-last skel upper degree-⊙map : fst (⊙Sphere (S n) ⊙→ ⊙Sphere (S n)) degree-⊙map = degree-map , ap cw-squash-lower-to-Sphere (! (snd (snd skel-is-aligned upper))) degree' : ℤ → ℤ degree' = transport Group.El (πₙ₊₁Sⁿ⁺¹ n) ∘ GroupHom.f (πS-fmap n degree-⊙map) ∘ transport! Group.El (πₙ₊₁Sⁿ⁺¹ n) degree : ℤ degree = degree' 1
{ "alphanum_fraction": 0.6505551927, "avg_line_length": 31.2448979592, "ext": "agda", "hexsha": "39569708c11c34c18312220c15c5ec3c51dceaa6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "theorems/cw/Degree.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "theorems/cw/Degree.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "theorems/cw/Degree.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 544, "size": 1531 }
{-# OPTIONS --without-K --allow-unsolved-metas --exact-split #-} module 22-descent where import 21-cubical-diagrams open 21-cubical-diagrams public -- Section 18.1 Five equivalent characterizations of pushouts dep-cocone : { l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} ( f : S → A) (g : S → B) (c : cocone f g X) (P : X → UU l5) → UU (l1 ⊔ l2 ⊔ l3 ⊔ l5) dep-cocone {S = S} {A} {B} f g c P = Σ ((a : A) → P ((pr1 c) a)) (λ hA → Σ ((b : B) → P (pr1 (pr2 c) b)) (λ hB → (s : S) → Id (tr P (pr2 (pr2 c) s) (hA (f s))) (hB (g s)))) dep-cocone-map : { l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} ( f : S → A) (g : S → B) (c : cocone f g X) (P : X → UU l5) → ( (x : X) → P x) → dep-cocone f g c P dep-cocone-map f g c P h = pair (λ a → h (pr1 c a)) (pair (λ b → h (pr1 (pr2 c) b)) (λ s → apd h (pr2 (pr2 c) s))) {- Definition 18.1.1 The induction principle of pushouts -} Ind-pushout : { l1 l2 l3 l4 : Level} (l : Level) → { S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} → ( f : S → A) (g : S → B) (c : cocone f g X) → UU (lsuc l ⊔ l1 ⊔ l2 ⊔ l3 ⊔ l4) Ind-pushout l {X = X} f g c = (P : X → UU l) → sec (dep-cocone-map f g c P) {- Definition 18.1.2 The dependent universal property of pushouts -} dependent-universal-property-pushout : {l1 l2 l3 l4 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) → UU _ dependent-universal-property-pushout l f g {X} c = (P : X → UU l) → is-equiv (dep-cocone-map f g c P) {- Remark 18.1.3. We compute the identity type of dep-cocone in order to express the computation rules of the induction principle for pushouts. -} coherence-htpy-dep-cocone : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) (c' c'' : dep-cocone f g c P) (K : (pr1 c') ~ (pr1 c'')) (L : (pr1 (pr2 c')) ~ (pr1 (pr2 c''))) → UU (l1 ⊔ l5) coherence-htpy-dep-cocone {S = S} f g c P h h' K L = (s : S) → Id ( ((pr2 (pr2 h)) s) ∙ (L (g s))) ( (ap (tr P (pr2 (pr2 c) s)) (K (f s))) ∙ ((pr2 (pr2 h')) s)) htpy-dep-cocone : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) → (s t : dep-cocone f g c P) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l5))) htpy-dep-cocone {S = S} f g c P h h' = Σ ( (pr1 h) ~ (pr1 h')) (λ K → Σ ( (pr1 (pr2 h)) ~ (pr1 (pr2 h'))) ( coherence-htpy-dep-cocone f g c P h h' K)) reflexive-htpy-dep-cocone : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) → (s : dep-cocone f g c P) → htpy-dep-cocone f g c P s s reflexive-htpy-dep-cocone f g (pair i (pair j H)) P (pair hA (pair hB hS)) = pair htpy-refl (pair htpy-refl htpy-right-unit) htpy-dep-cocone-eq : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) → {s t : dep-cocone f g c P} → Id s t → htpy-dep-cocone f g c P s t htpy-dep-cocone-eq f g c P {s} {.s} refl = reflexive-htpy-dep-cocone f g c P s abstract is-contr-total-htpy-dep-cocone : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) → (s : dep-cocone f g c P) → is-contr ( Σ (dep-cocone f g c P) ( htpy-dep-cocone f g c P s)) is-contr-total-htpy-dep-cocone {S = S} {A} {B} f g {X} (pair i (pair j H)) P (pair hA (pair hB hS)) = is-contr-total-Eq-structure ( λ α βγ K → Σ (hB ~ (pr1 βγ)) (λ L → coherence-htpy-dep-cocone f g ( pair i (pair j H)) P (pair hA (pair hB hS)) (pair α βγ) K L)) ( is-contr-total-htpy hA) ( pair hA htpy-refl) ( is-contr-total-Eq-structure ( λ β γ L → coherence-htpy-dep-cocone f g ( pair i (pair j H)) ( P) ( pair hA (pair hB hS)) ( pair hA (pair β γ)) ( htpy-refl) ( L)) ( is-contr-total-htpy hB) ( pair hB htpy-refl) ( is-contr-is-equiv ( Σ ((s : S) → Id (tr P (H s) (hA (f s))) (hB (g s))) (λ γ → hS ~ γ)) ( tot (htpy-concat (htpy-inv htpy-right-unit))) ( is-equiv-tot-is-fiberwise-equiv ( is-equiv-htpy-concat (htpy-inv htpy-right-unit))) ( is-contr-total-htpy hS))) abstract is-equiv-htpy-dep-cocone-eq : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) → (s t : dep-cocone f g c P) → is-equiv (htpy-dep-cocone-eq f g c P {s} {t}) is-equiv-htpy-dep-cocone-eq f g c P s = fundamental-theorem-id s ( reflexive-htpy-dep-cocone f g c P s) ( is-contr-total-htpy-dep-cocone f g c P s) ( λ t → htpy-dep-cocone-eq f g c P {s} {t}) eq-htpy-dep-cocone : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) → (s t : dep-cocone f g c P) → htpy-dep-cocone f g c P s t → Id s t eq-htpy-dep-cocone f g c P s t = inv-is-equiv (is-equiv-htpy-dep-cocone-eq f g c P s t) issec-eq-htpy-dep-cocone : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) → (s t : dep-cocone f g c P) → ( ( htpy-dep-cocone-eq f g c P {s} {t}) ∘ ( eq-htpy-dep-cocone f g c P s t)) ~ id issec-eq-htpy-dep-cocone f g c P s t = issec-inv-is-equiv ( is-equiv-htpy-dep-cocone-eq f g c P s t) isretr-eq-htpy-dep-cocone : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) → (s t : dep-cocone f g c P) → ( ( eq-htpy-dep-cocone f g c P s t) ∘ ( htpy-dep-cocone-eq f g c P {s} {t})) ~ id isretr-eq-htpy-dep-cocone f g c P s t = isretr-inv-is-equiv ( is-equiv-htpy-dep-cocone-eq f g c P s t) ind-pushout : { l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} → ( f : S → A) (g : S → B) (c : cocone f g X) → Ind-pushout l f g c → (P : X → UU l) → dep-cocone f g c P → (x : X) → P x ind-pushout f g c ind-c P = pr1 (ind-c P) comp-pushout : { l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} → ( f : S → A) (g : S → B) (c : cocone f g X) → ( ind-c : Ind-pushout l f g c) (P : X → UU l) (h : dep-cocone f g c P) → htpy-dep-cocone f g c P ( dep-cocone-map f g c P (ind-pushout f g c ind-c P h)) ( h) comp-pushout f g c ind-c P h = htpy-dep-cocone-eq f g c P (pr2 (ind-c P) h) left-comp-pushout : { l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} → ( f : S → A) (g : S → B) (c : cocone f g X) → ( ind-c : Ind-pushout l f g c) (P : X → UU l) (h : dep-cocone f g c P) → ( a : A) → Id (ind-pushout f g c ind-c P h (pr1 c a)) (pr1 h a) left-comp-pushout f g c ind-c P h = pr1 (comp-pushout f g c ind-c P h) right-comp-pushout : { l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} → ( f : S → A) (g : S → B) (c : cocone f g X) → ( ind-c : Ind-pushout l f g c) (P : X → UU l) (h : dep-cocone f g c P) → ( b : B) → Id (ind-pushout f g c ind-c P h (pr1 (pr2 c) b)) (pr1 (pr2 h) b) right-comp-pushout f g c ind-c P h = pr1 (pr2 (comp-pushout f g c ind-c P h)) path-comp-pushout : { l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} → ( f : S → A) (g : S → B) (c : cocone f g X) → ( ind-c : Ind-pushout l f g c) (P : X → UU l) (h : dep-cocone f g c P) → coherence-htpy-dep-cocone f g c P ( dep-cocone-map f g c P (ind-pushout f g c ind-c P h)) ( h) ( left-comp-pushout f g c ind-c P h) ( right-comp-pushout f g c ind-c P h) path-comp-pushout f g c ind-c P h = pr2 (pr2 (comp-pushout f g c ind-c P h)) abstract uniqueness-dependent-universal-property-pushout : { l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} → ( f : S → A) (g : S → B) (c : cocone f g X) ( dup-c : dependent-universal-property-pushout l f g c) → ( P : X → UU l) ( h : dep-cocone f g c P) → is-contr ( Σ ((x : X) → P x) (λ k → htpy-dep-cocone f g c P (dep-cocone-map f g c P k) h)) uniqueness-dependent-universal-property-pushout f g c dup-c P h = is-contr-is-equiv' ( fib (dep-cocone-map f g c P) h) ( tot (λ k → htpy-dep-cocone-eq f g c P)) ( is-equiv-tot-is-fiberwise-equiv ( λ k → is-equiv-htpy-dep-cocone-eq f g c P ( dep-cocone-map f g c P k) h)) ( is-contr-map-is-equiv (dup-c P) h) {- This finishes the formalization of remark 18.1.3. -} {- Before we state the main theorem of this section, we also state a dependent version of the pullback property of pushouts. -} cone-dependent-pullback-property-pushout : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) → let i = pr1 c j = pr1 (pr2 c) H = pr2 (pr2 c) in cone ( λ (h : (a : A) → P (i a)) → λ (s : S) → tr P (H s) (h (f s))) ( λ (h : (b : B) → P (j b)) → λ s → h (g s)) ( (x : X) → P x) cone-dependent-pullback-property-pushout f g (pair i (pair j H)) P = pair ( λ h → λ a → h (i a)) ( pair ( λ h → λ b → h (j b)) ( λ h → eq-htpy (λ s → apd h (H s)))) dependent-pullback-property-pushout : {l1 l2 l3 l4 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ (l4 ⊔ lsuc l)))) dependent-pullback-property-pushout l {S} {A} {B} f g {X} (pair i (pair j H)) = (P : X → UU l) → is-pullback ( λ (h : (a : A) → P (i a)) → λ s → tr P (H s) (h (f s))) ( λ (h : (b : B) → P (j b)) → λ s → h (g s)) ( cone-dependent-pullback-property-pushout f g (pair i (pair j H)) P) {- Theorem 18.1.4 The following properties are all equivalent: 1. universal-property-pushout 2. pullback-property-pushout 3. dependent-pullback-property-pushout 4. dependent-universal-property-pushout 5. Ind-pushout We have already shown that 1 ↔ 2. Therefore we will first show that 3 ↔ 4 ↔ 5. Finally, we will show that 2 ↔ 3. Here are the precise references to the proofs of those parts: Proof of 1 → 2. pullback-property-pushout-universal-property-pushout Proof of 2 → 1 universal-property-pushout-pullback-property-pushout Proof of 2 → 3 dependent-pullback-property-pullback-property-pushout Proof of 3 → 2 pullback-property-dependent-pullback-property-pushout Proof of 3 → 4 dependent-universal-property-dependent-pullback-property-pushout Proof of 4 → 3 dependent-pullback-property-dependent-universal-property-pushout Proof of 4 → 5 Ind-pushout-dependent-universal-property-pushout Proof of 5 → 4 dependent-universal-property-pushout-Ind-pushout -} {- Proof of Theorem 18.1.4, (v) implies (iv). -} dependent-naturality-square : {l1 l2 : Level} {A : UU l1} {B : A → UU l2} (f f' : (x : A) → B x) {x x' : A} (p : Id x x') {q : Id (f x) (f' x)} {q' : Id (f x') (f' x')} → Id ((apd f p) ∙ q') ((ap (tr B p) q) ∙ (apd f' p)) → Id (tr (λ y → Id (f y) (f' y)) p q) q' dependent-naturality-square f f' refl {q} {q'} s = inv (s ∙ (right-unit ∙ (ap-id q))) htpy-eq-dep-cocone-map : { l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} ( f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) → ( H : Ind-pushout l f g c) { P : X → UU l} (h h' : (x : X) → P x) → Id (dep-cocone-map f g c P h) (dep-cocone-map f g c P h') → h ~ h' htpy-eq-dep-cocone-map f g c ind-c {P} h h' p = ind-pushout f g c ind-c ( λ x → Id (h x) (h' x)) ( pair ( pr1 (htpy-dep-cocone-eq f g c P p)) ( pair ( pr1 (pr2 (htpy-dep-cocone-eq f g c P p))) ( λ s → dependent-naturality-square h h' (pr2 (pr2 c) s) ( pr2 (pr2 (htpy-dep-cocone-eq f g c P p)) s)))) dependent-universal-property-pushout-Ind-pushout : {l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) → ((l : Level) → Ind-pushout l f g c) → ((l : Level) → dependent-universal-property-pushout l f g c) dependent-universal-property-pushout-Ind-pushout f g c ind-c l P = is-equiv-has-inverse ( ind-pushout f g c (ind-c l) P) ( pr2 (ind-c l P)) ( λ h → eq-htpy (htpy-eq-dep-cocone-map f g c (ind-c l) ( ind-pushout f g c (ind-c l) P (dep-cocone-map f g c P h)) ( h) ( pr2 (ind-c l P) (dep-cocone-map f g c P h)))) {- Proof of Theorem 18.1.4, (iv) implies (v). -} Ind-pushout-dependent-universal-property-pushout : {l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) → ((l : Level) → dependent-universal-property-pushout l f g c) → ((l : Level) → Ind-pushout l f g c) Ind-pushout-dependent-universal-property-pushout f g c dup-c l P = pr1 (dup-c l P) {- Proof of Theorem 18.1.4, (iv) implies (iii). -} triangle-dependent-pullback-property-pushout : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (P : X → UU l5) → let i = pr1 c j = pr1 (pr2 c) H = pr2 (pr2 c) in ( dep-cocone-map f g c P) ~ ( ( tot (λ h → tot (λ h' → htpy-eq))) ∘ ( gap ( λ (h : (a : A) → P (i a)) → λ s → tr P (H s) (h (f s))) ( λ (h : (b : B) → P (j b)) → λ s → h (g s)) ( cone-dependent-pullback-property-pushout f g c P))) triangle-dependent-pullback-property-pushout f g (pair i (pair j H)) P h = eq-pair refl (eq-pair refl (inv (issec-eq-htpy (λ x → apd h (H x))))) dependent-pullback-property-dependent-universal-property-pushout : {l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) → ((l : Level) → dependent-universal-property-pushout l f g c) → ((l : Level) → dependent-pullback-property-pushout l f g c) dependent-pullback-property-dependent-universal-property-pushout f g (pair i (pair j H)) I l P = let c = (pair i (pair j H)) in is-equiv-right-factor ( dep-cocone-map f g c P) ( tot (λ h → tot λ h' → htpy-eq)) ( gap ( λ h x → tr P (H x) (h (f x))) ( λ h x → h (g x)) ( cone-dependent-pullback-property-pushout f g c P)) ( triangle-dependent-pullback-property-pushout f g c P) ( is-equiv-tot-is-fiberwise-equiv ( λ h → is-equiv-tot-is-fiberwise-equiv ( λ h' → funext (λ x → tr P (H x) (h (f x))) (λ x → h' (g x))))) ( I l P) {- Proof of Theorem 18.1.4, (iv) implies (iii). -} dependent-universal-property-dependent-pullback-property-pushout : {l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) → ((l : Level) → dependent-pullback-property-pushout l f g c) → ((l : Level) → dependent-universal-property-pushout l f g c) dependent-universal-property-dependent-pullback-property-pushout f g (pair i (pair j H)) dpullback-c l P = let c = (pair i (pair j H)) in is-equiv-comp ( dep-cocone-map f g c P) ( tot (λ h → tot λ h' → htpy-eq)) ( gap ( λ h x → tr P (H x) (h (f x))) ( λ h x → h (g x)) ( cone-dependent-pullback-property-pushout f g c P)) ( triangle-dependent-pullback-property-pushout f g c P) ( dpullback-c l P) ( is-equiv-tot-is-fiberwise-equiv ( λ h → is-equiv-tot-is-fiberwise-equiv ( λ h' → funext (λ x → tr P (H x) (h (f x))) (λ x → h' (g x))))) {- Proof of Theorem 18.1.4, (iii) implies (ii). -} concat-eq-htpy : {l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x} (H : f ~ g) (K : g ~ h) → Id (eq-htpy (H ∙h K)) ((eq-htpy H) ∙ (eq-htpy K)) concat-eq-htpy {A = A} {B} {f} H K = ind-htpy f ( λ g H → ( h : (x : A) → B x) (K : g ~ h) → Id (eq-htpy (H ∙h K)) ((eq-htpy H) ∙ (eq-htpy K))) ( λ h K → ap (concat' f (eq-htpy K)) (inv (eq-htpy-htpy-refl _))) H _ K pullback-property-dependent-pullback-property-pushout : {l1 l2 l3 l4 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) → dependent-pullback-property-pushout l f g c → pullback-property-pushout l f g c pullback-property-dependent-pullback-property-pushout l f g (pair i (pair j H)) dpb Y = is-pullback-htpy ( λ h s → tr (λ x → Y) (H s) (h (f s))) ( λ h → eq-htpy (λ s → inv (tr-triv (H s) (h (f s))))) ( λ h s → h (g s)) ( htpy-refl) { c = pair ( λ h a → h (i a)) ( pair (λ h b → h (j b)) (λ h → eq-htpy (h ·l H)))} ( cone-dependent-pullback-property-pushout f g (pair i (pair j H)) (λ x → Y)) ( pair ( λ h → refl) ( pair ( λ h → refl) ( λ h → right-unit ∙ ( ( ap eq-htpy ( eq-htpy (λ s → inv-con ( tr-triv (H s) (h (i (f s)))) ( ap h (H s)) ( apd h (H s)) ( inv (apd-triv h (H s)))))) ∙ ( concat-eq-htpy ( λ s → inv (tr-triv (H s) (h (i (f s))))) ( λ s → apd h (H s))))))) ( dpb (λ x → Y)) {- Proof of Theorem 18.1.4, (ii) implies (iii). -} {- We first define the family of lifts, which is indexed by maps Y → X. -} fam-lifts : {l1 l2 l3 : Level} (Y : UU l1) {X : UU l2} (P : X → UU l3) → (Y → X) → UU (l1 ⊔ l3) fam-lifts Y P h = (y : Y) → P (h y) tr-fam-lifts' : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) → (h : B → X) {f g : A → B} (H : f ~ g) → fam-lifts A P (h ∘ f) → fam-lifts A P (h ∘ g) tr-fam-lifts' P h {f} {g} H k s = tr (P ∘ h) (H s) (k s) TR-EQ-HTPY-FAM-LIFTS : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) → (h : B → X) {f g : A → B} (H : f ~ g) → UU (l1 ⊔ l4) TR-EQ-HTPY-FAM-LIFTS {A = A} P h H = tr (fam-lifts A P) (eq-htpy (h ·l H)) ~ (tr-fam-lifts' P h H) tr-eq-htpy-fam-lifts-htpy-refl : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) → (h : B → X) (f : A → B) → TR-EQ-HTPY-FAM-LIFTS P h (htpy-refl' f) tr-eq-htpy-fam-lifts-htpy-refl P h f k = ap (λ t → tr (fam-lifts _ P) t k) (eq-htpy-htpy-refl (h ∘ f)) abstract tr-eq-htpy-fam-lifts : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) → (h : B → X) {f g : A → B} (H : f ~ g) → TR-EQ-HTPY-FAM-LIFTS P h H tr-eq-htpy-fam-lifts P h {f} = ind-htpy f ( λ g H → TR-EQ-HTPY-FAM-LIFTS P h H) ( tr-eq-htpy-fam-lifts-htpy-refl P h f) compute-tr-eq-htpy-fam-lifts : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) → (h : B → X) (f : A → B) → Id ( tr-eq-htpy-fam-lifts P h (htpy-refl' f)) ( tr-eq-htpy-fam-lifts-htpy-refl P h f) compute-tr-eq-htpy-fam-lifts P h f = comp-htpy f ( λ g H → TR-EQ-HTPY-FAM-LIFTS P h H) ( tr-eq-htpy-fam-lifts-htpy-refl P h f) {- One of the basic operations on lifts is precomposition by an ordinary function. -} precompose-lifts : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) → (f : A → B) → (h : B → X) → (fam-lifts B P h) → (fam-lifts A P (h ∘ f)) precompose-lifts P f h h' a = h' (f a) {- Given two homotopic maps, their precomposition functions have different codomains. However, there is a commuting triangle. We obtain this triangle by homotopy induction. -} TRIANGLE-PRECOMPOSE-LIFTS : { l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} ( P : X → UU l4) {f g : A → B} (H : f ~ g) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4))) TRIANGLE-PRECOMPOSE-LIFTS {A = A} {B} {X} P {f} {g} H = (h : B → X) → ( (tr (fam-lifts A P) (eq-htpy (h ·l H))) ∘ (precompose-lifts P f h)) ~ ( precompose-lifts P g h) triangle-precompose-lifts-htpy-refl : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) (f : A → B) → TRIANGLE-PRECOMPOSE-LIFTS P (htpy-refl' f) triangle-precompose-lifts-htpy-refl {A = A} P f h h' = tr-eq-htpy-fam-lifts-htpy-refl P h f (λ a → h' (f a)) abstract triangle-precompose-lifts : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) {f g : A → B} (H : f ~ g) → TRIANGLE-PRECOMPOSE-LIFTS P H triangle-precompose-lifts {A = A} P {f} = ind-htpy f ( λ g H → TRIANGLE-PRECOMPOSE-LIFTS P H) ( triangle-precompose-lifts-htpy-refl P f) compute-triangle-precompose-lifts : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) (f : A → B) → Id ( triangle-precompose-lifts P (htpy-refl' f)) ( triangle-precompose-lifts-htpy-refl P f) compute-triangle-precompose-lifts P f = comp-htpy f ( λ g H → TRIANGLE-PRECOMPOSE-LIFTS P H) ( triangle-precompose-lifts-htpy-refl P f) {- There is a similar commuting triangle with the computed transport function. This time we don't use homotopy induction to construct the homotopy. We give an explicit definition instead. -} triangle-precompose-lifts' : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) {f g : A → B} (H : f ~ g) → (h : B → X) → ( (tr-fam-lifts' P h H) ∘ (precompose-lifts P f h)) ~ ( precompose-lifts P g h) triangle-precompose-lifts' P H h k = eq-htpy (λ a → apd k (H a)) compute-triangle-precompose-lifts' : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) (f : A → B) → (h : B → X) → ( triangle-precompose-lifts' P (htpy-refl' f) h) ~ ( htpy-refl' ( precompose-lifts P f h)) compute-triangle-precompose-lifts' P f h k = eq-htpy-htpy-refl _ {- There is a coherence between the two commuting triangles. This coherence is again constructed by homotopy induction. -} COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) {f g : A → B} (H : f ~ g) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4))) COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS {A = A} {B} {X} P {f} {g} H = (h : B → X) → ( triangle-precompose-lifts P H h) ~ ( ( ( tr-eq-htpy-fam-lifts P h H) ·r (precompose-lifts P f h)) ∙h ( triangle-precompose-lifts' P H h)) coherence-triangle-precompose-lifts-htpy-refl : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) (f : A → B) → COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS P (htpy-refl' f) coherence-triangle-precompose-lifts-htpy-refl P f h = ( htpy-eq (htpy-eq (compute-triangle-precompose-lifts P f) h)) ∙h ( ( ( htpy-inv htpy-right-unit) ∙h ( htpy-ap-concat ( λ h' → tr-eq-htpy-fam-lifts-htpy-refl P h f (λ a → h' (f a))) ( htpy-refl) ( triangle-precompose-lifts' P htpy-refl h) ( htpy-inv (compute-triangle-precompose-lifts' P f h)))) ∙h ( htpy-eq ( ap ( λ t → ( t ·r (precompose-lifts P f h)) ∙h ( triangle-precompose-lifts' P htpy-refl h)) ( inv (compute-tr-eq-htpy-fam-lifts P h f))))) abstract coherence-triangle-precompose-lifts : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) {f g : A → B} (H : f ~ g) → COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS P H coherence-triangle-precompose-lifts P {f} = ind-htpy f ( λ g H → COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS P H) ( coherence-triangle-precompose-lifts-htpy-refl P f) compute-coherence-triangle-precompose-lifts : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) (f : A → B) → Id ( coherence-triangle-precompose-lifts P (htpy-refl' f)) ( coherence-triangle-precompose-lifts-htpy-refl P f) compute-coherence-triangle-precompose-lifts P f = comp-htpy f ( λ g H → COHERENCE-TRIANGLE-PRECOMPOSE-LIFTS P H) ( coherence-triangle-precompose-lifts-htpy-refl P f) total-lifts : {l1 l2 l3 : Level} (A : UU l1) {X : UU l2} (P : X → UU l3) → UU _ total-lifts A {X} P = type-choice-∞ {A = A} {B = λ a → X} (λ a → P) precompose-total-lifts : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) → (A → B) → total-lifts B P → total-lifts A P precompose-total-lifts {A = A} P f = toto ( λ h → (a : A) → P (h a)) ( λ h → h ∘ f) ( precompose-lifts P f) coherence-square-inv-choice-∞ : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) (f : A → B) → coherence-square ( precompose-total-lifts P f) ( inv-choice-∞ {A = B} {B = λ x → X} {C = λ x y → P y}) ( inv-choice-∞) ( λ h → h ∘ f) coherence-square-inv-choice-∞ P f = htpy-refl {- Our goal is now to produce a homotopy between (precompose-total-lifts P f) and (precompose-total-lifts P g) for homotopic maps f and g, and a coherence filling a cilinder. -} HTPY-PRECOMPOSE-TOTAL-LIFTS : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) {f g : A → B} (H : f ~ g) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4))) HTPY-PRECOMPOSE-TOTAL-LIFTS P {f} {g} H = (precompose-total-lifts P f) ~ (precompose-total-lifts P g) htpy-precompose-total-lifts : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) {f g : A → B} (H : f ~ g) → HTPY-PRECOMPOSE-TOTAL-LIFTS P H htpy-precompose-total-lifts {A = A} {B} P {f} {g} H = htpy-toto { P = fam-lifts B P} ( fam-lifts A P) ( λ h → eq-htpy (h ·l H)) ( precompose-lifts P f) ( triangle-precompose-lifts P H) {- We show that when htpy-precompose-total-lifts is applied to htpy-refl, it computes to htpy-refl. -} tr-id-left-subst : {i j : Level} {A : UU i} {B : UU j} {f : A → B} {x y : A} (p : Id x y) (b : B) → (q : Id (f x) b) → Id (tr (λ (a : A) → Id (f a) b) p q) ((inv (ap f p)) ∙ q) tr-id-left-subst refl b q = refl compute-htpy-precompose-total-lifts : { l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) ( f : A → B) → ( htpy-precompose-total-lifts P (htpy-refl' f)) ~ ( htpy-refl' (toto (fam-lifts A P) (λ h → h ∘ f) (precompose-lifts P f))) compute-htpy-precompose-total-lifts {A = A} P f (pair h h') = let α = λ (t : Id (h ∘ f) (h ∘ f)) → tr (fam-lifts A P) t (λ a → h' (f a)) in ap eq-pair' ( eq-pair ( eq-htpy-htpy-refl (h ∘ f)) ( ( tr-id-left-subst { f = α} ( eq-htpy-htpy-refl (h ∘ f)) ( λ a → h' (f a)) ( triangle-precompose-lifts P htpy-refl h h')) ∙ ( ( ap ( λ t → inv (ap α (eq-htpy-htpy-refl (λ a → h (f a)))) ∙ t) ( htpy-eq ( htpy-eq (compute-triangle-precompose-lifts P f) h) h')) ∙ ( left-inv (triangle-precompose-lifts-htpy-refl P f h h'))))) COHERENCE-HTPY-INV-CHOICE-∞ : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) {f g : A → B} (H : f ~ g) → UU _ COHERENCE-HTPY-INV-CHOICE-∞ P {f} {g} H = ( ( coherence-square-inv-choice-∞ P f) ∙h ( inv-choice-∞ ·l ( htpy-precompose-total-lifts P H))) ~ ( ( ( λ h → eq-htpy (h ·l H)) ·r inv-choice-∞) ∙h ( coherence-square-inv-choice-∞ P g)) coherence-htpy-inv-choice-∞-htpy-refl : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) (f : A → B) → COHERENCE-HTPY-INV-CHOICE-∞ P (htpy-refl' f) coherence-htpy-inv-choice-∞-htpy-refl {X = X} P f = ( htpy-ap-concat ( coherence-square-inv-choice-∞ P f) ( inv-choice-∞ ·l ( htpy-precompose-total-lifts P htpy-refl)) ( htpy-refl) ( λ h → ap (ap inv-choice-∞) (compute-htpy-precompose-total-lifts P f h))) ∙h ( htpy-inv ( htpy-ap-concat' ( ( htpy-precomp htpy-refl (Σ X P)) ·r inv-choice-∞) ( htpy-refl) ( htpy-refl) ( λ h → compute-htpy-precomp f (Σ X P) (inv-choice-∞ h)))) abstract coherence-htpy-inv-choice-∞ : {l1 l2 l3 l4 : Level} {A : UU l1} {B : UU l2} {X : UU l3} (P : X → UU l4) {f g : A → B} (H : f ~ g) → COHERENCE-HTPY-INV-CHOICE-∞ P H coherence-htpy-inv-choice-∞ P {f} = ind-htpy f ( λ g H → COHERENCE-HTPY-INV-CHOICE-∞ P H) ( coherence-htpy-inv-choice-∞-htpy-refl P f) cone-family-dependent-pullback-property : {l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} (f : S → A) (g : S → B) (c : cocone f g X) (P : X → UU l) → cone-family ( fam-lifts S P) ( precompose-lifts P f) ( precompose-lifts P g) ( cone-pullback-property-pushout f g c X) ( fam-lifts X P) cone-family-dependent-pullback-property f g c P γ = pair ( precompose-lifts P (pr1 c) γ) ( pair ( precompose-lifts P (pr1 (pr2 c)) γ) ( triangle-precompose-lifts P (pr2 (pr2 c)) γ)) is-pullback-cone-family-dependent-pullback-property : {l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} (f : S → A) (g : S → B) (c : cocone f g X) → ((l : Level) → pullback-property-pushout l f g c) → {l : Level} (P : X → UU l) (γ : X → X) → is-pullback ( ( tr (fam-lifts S P) (eq-htpy (γ ·l (pr2 (pr2 c))))) ∘ ( precompose-lifts P f (γ ∘ (pr1 c)))) ( precompose-lifts P g (γ ∘ (pr1 (pr2 c)))) ( cone-family-dependent-pullback-property f g c P γ) is-pullback-cone-family-dependent-pullback-property {S = S} {A} {B} {X} f g (pair i (pair j H)) pb-c P = let c = pair i (pair j H) in is-pullback-family-is-pullback-tot ( fam-lifts S P) ( precompose-lifts P f) ( precompose-lifts P g) ( cone-pullback-property-pushout f g c X) ( cone-family-dependent-pullback-property f g c P) ( pb-c _ X) ( is-pullback-top-is-pullback-bottom-cube-is-equiv ( precomp i (Σ X P)) ( precomp j (Σ X P)) ( precomp f (Σ X P)) ( precomp g (Σ X P)) ( toto (fam-lifts A P) (precomp i X) (precompose-lifts P i)) ( toto (fam-lifts B P) (precomp j X) (precompose-lifts P j)) ( toto (fam-lifts S P) (precomp f X) (precompose-lifts P f)) ( toto (fam-lifts S P) (precomp g X) (precompose-lifts P g)) ( inv-choice-∞) ( inv-choice-∞) ( inv-choice-∞) ( inv-choice-∞) ( htpy-precompose-total-lifts P H) ( htpy-refl) ( htpy-refl) ( htpy-refl) ( htpy-refl) ( htpy-precomp H (Σ X P)) ( coherence-htpy-inv-choice-∞ P H) ( is-equiv-inv-choice-∞) ( is-equiv-inv-choice-∞) ( is-equiv-inv-choice-∞) ( is-equiv-inv-choice-∞) ( pb-c _ (Σ X P))) dependent-pullback-property-pullback-property-pushout : {l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} (f : S → A) (g : S → B) (c : cocone f g X) → ((l : Level) → pullback-property-pushout l f g c) → ((l : Level) → dependent-pullback-property-pushout l f g c) dependent-pullback-property-pullback-property-pushout {S = S} {A} {B} {X} f g (pair i (pair j H)) pullback-c l P = let c = pair i (pair j H) in is-pullback-htpy' ( (tr (fam-lifts S P) (eq-htpy (id ·l H))) ∘ (precompose-lifts P f i)) ( (tr-eq-htpy-fam-lifts P id H) ·r (precompose-lifts P f i)) ( precompose-lifts P g j) ( htpy-refl) ( cone-family-dependent-pullback-property f g c P id) { c' = cone-dependent-pullback-property-pushout f g c P} ( pair htpy-refl ( pair htpy-refl ( htpy-right-unit ∙h (coherence-triangle-precompose-lifts P H id)))) ( is-pullback-cone-family-dependent-pullback-property f g c pullback-c P id) {- This concludes the proof of Theorem 18.1.4. -} {- We give some further useful implications -} dependent-universal-property-universal-property-pushout : { l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} ( f : S → A) (g : S → B) (c : cocone f g X) → ( (l : Level) → universal-property-pushout l f g c) → ( (l : Level) → dependent-universal-property-pushout l f g c) dependent-universal-property-universal-property-pushout f g c up-X = dependent-universal-property-dependent-pullback-property-pushout f g c ( dependent-pullback-property-pullback-property-pushout f g c ( λ l → pullback-property-pushout-universal-property-pushout l f g c ( up-X l))) -- Section 16.2 Families over pushouts {- Definition 18.2.1 -} Fam-pushout : {l1 l2 l3 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3} (f : S → A) (g : S → B) → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ lsuc l))) Fam-pushout l {S} {A} {B} f g = Σ ( A → UU l) ( λ PA → Σ (B → UU l) ( λ PB → (s : S) → PA (f s) ≃ PB (g s))) {- We characterize the identity type of Fam-pushout. -} coherence-equiv-Fam-pushout : { l1 l2 l3 l l' : Level} {S : UU l1} {A : UU l2} {B : UU l3} { f : S → A} {g : S → B} ( P : Fam-pushout l f g) (Q : Fam-pushout l' f g) → ( eA : (a : A) → (pr1 P a) ≃ (pr1 Q a)) ( eB : (b : B) → (pr1 (pr2 P) b) ≃ (pr1 (pr2 Q) b)) → UU (l1 ⊔ l ⊔ l') coherence-equiv-Fam-pushout {S = S} {f = f} {g} P Q eA eB = ( s : S) → ( (map-equiv (eB (g s))) ∘ (map-equiv (pr2 (pr2 P) s))) ~ ( (map-equiv (pr2 (pr2 Q) s)) ∘ (map-equiv (eA (f s)))) equiv-Fam-pushout : {l1 l2 l3 l l' : Level} {S : UU l1} {A : UU l2} {B : UU l3} {f : S → A} {g : S → B} → Fam-pushout l f g → Fam-pushout l' f g → UU (l1 ⊔ l2 ⊔ l3 ⊔ l ⊔ l') equiv-Fam-pushout {S = S} {A} {B} {f} {g} P Q = Σ ( (a : A) → (pr1 P a) ≃ (pr1 Q a)) ( λ eA → Σ ( (b : B) → (pr1 (pr2 P) b) ≃ (pr1 (pr2 Q) b)) ( coherence-equiv-Fam-pushout P Q eA)) reflexive-equiv-Fam-pushout : {l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {f : S → A} {g : S → B} (P : Fam-pushout l f g) → equiv-Fam-pushout P P reflexive-equiv-Fam-pushout (pair PA (pair PB PS)) = pair (λ a → equiv-id (PA a)) ( pair ( λ b → equiv-id (PB b)) ( λ s → htpy-refl)) equiv-Fam-pushout-eq : {l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {f : S → A} {g : S → B} {P Q : Fam-pushout l f g} → Id P Q → equiv-Fam-pushout P Q equiv-Fam-pushout-eq {P = P} {.P} refl = reflexive-equiv-Fam-pushout P is-contr-total-equiv-Fam-pushout : {l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {f : S → A} {g : S → B} (P : Fam-pushout l f g) → is-contr (Σ (Fam-pushout l f g) (equiv-Fam-pushout P)) is-contr-total-equiv-Fam-pushout {S = S} {A} {B} {f} {g} P = is-contr-total-Eq-structure ( λ PA' t eA → Σ ( (b : B) → (pr1 (pr2 P) b) ≃ (pr1 t b)) ( coherence-equiv-Fam-pushout P (pair PA' t) eA)) ( is-contr-total-Eq-Π ( λ a X → (pr1 P a) ≃ X) ( λ a → is-contr-total-equiv (pr1 P a)) ( pr1 P)) ( pair (pr1 P) (λ a → equiv-id (pr1 P a))) ( is-contr-total-Eq-structure ( λ PB' PS' eB → coherence-equiv-Fam-pushout P (pair (pr1 P) (pair PB' PS')) (λ a → equiv-id (pr1 P a)) eB) ( is-contr-total-Eq-Π ( λ b Y → (pr1 (pr2 P) b) ≃ Y) ( λ b → is-contr-total-equiv (pr1 (pr2 P) b)) ( pr1 (pr2 P))) ( pair (pr1 (pr2 P)) (λ b → equiv-id (pr1 (pr2 P) b))) ( is-contr-total-Eq-Π ( λ s e → (map-equiv (pr2 (pr2 P) s)) ~ (map-equiv e)) ( λ s → is-contr-total-htpy-equiv (pr2 (pr2 P) s)) ( pr2 (pr2 P)))) is-equiv-equiv-Fam-pushout-eq : {l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {f : S → A} {g : S → B} (P Q : Fam-pushout l f g) → is-equiv (equiv-Fam-pushout-eq {P = P} {Q}) is-equiv-equiv-Fam-pushout-eq P = fundamental-theorem-id P ( reflexive-equiv-Fam-pushout P) ( is-contr-total-equiv-Fam-pushout P) ( λ Q → equiv-Fam-pushout-eq {P = P} {Q}) equiv-equiv-Fam-pushout : {l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {f : S → A} {g : S → B} (P Q : Fam-pushout l f g) → Id P Q ≃ equiv-Fam-pushout P Q equiv-equiv-Fam-pushout P Q = pair ( equiv-Fam-pushout-eq) ( is-equiv-equiv-Fam-pushout-eq P Q) eq-equiv-Fam-pushout : {l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {f : S → A} {g : S → B} {P Q : Fam-pushout l f g} → (equiv-Fam-pushout P Q) → Id P Q eq-equiv-Fam-pushout {P = P} {Q} = inv-is-equiv (is-equiv-equiv-Fam-pushout-eq P Q) issec-eq-equiv-Fam-pushout : { l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} { f : S → A} {g : S → B} {P Q : Fam-pushout l f g} → ( ( equiv-Fam-pushout-eq {P = P} {Q}) ∘ ( eq-equiv-Fam-pushout {P = P} {Q})) ~ id issec-eq-equiv-Fam-pushout {P = P} {Q} = issec-inv-is-equiv (is-equiv-equiv-Fam-pushout-eq P Q) isretr-eq-equiv-Fam-pushout : {l1 l2 l3 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {f : S → A} {g : S → B} {P Q : Fam-pushout l f g} → ( ( eq-equiv-Fam-pushout {P = P} {Q}) ∘ ( equiv-Fam-pushout-eq {P = P} {Q})) ~ id isretr-eq-equiv-Fam-pushout {P = P} {Q} = isretr-inv-is-equiv (is-equiv-equiv-Fam-pushout-eq P Q) {- This concludes the characterization of the identity type of Fam-pushout. -} {- Definition 18.2.2 -} desc-fam : {l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} {f : S → A} {g : S → B} (c : cocone f g X) → (P : X → UU l) → Fam-pushout l f g desc-fam c P = pair ( P ∘ (pr1 c)) ( pair ( P ∘ (pr1 (pr2 c))) ( λ s → (pair (tr P (pr2 (pr2 c) s)) (is-equiv-tr P (pr2 (pr2 c) s))))) {- Theorem 18.2.3 -} Fam-pushout-cocone-UU : {l1 l2 l3 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3} {f : S → A} {g : S → B} → cocone f g (UU l) → Fam-pushout l f g Fam-pushout-cocone-UU l = tot (λ PA → (tot (λ PB H s → equiv-eq (H s)))) is-equiv-Fam-pushout-cocone-UU : {l1 l2 l3 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3} {f : S → A} {g : S → B} → is-equiv (Fam-pushout-cocone-UU l {f = f} {g}) is-equiv-Fam-pushout-cocone-UU l {f = f} {g} = is-equiv-tot-is-fiberwise-equiv ( λ PA → is-equiv-tot-is-fiberwise-equiv ( λ PB → is-equiv-postcomp-Π ( λ s → equiv-eq) ( λ s → univalence (PA (f s)) (PB (g s))))) htpy-equiv-eq-ap-fam : {l1 l2 : Level} {A : UU l1} (B : A → UU l2) {x y : A} (p : Id x y) → htpy-equiv (equiv-tr B p) (equiv-eq (ap B p)) htpy-equiv-eq-ap-fam B {x} {.x} refl = reflexive-htpy-equiv (equiv-id (B x)) triangle-desc-fam : {l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} {f : S → A} {g : S → B} (c : cocone f g X) → ( desc-fam {l = l} c) ~ ( ( Fam-pushout-cocone-UU l {f = f} {g}) ∘ ( cocone-map f g {Y = UU l} c)) triangle-desc-fam {l = l} {S} {A} {B} {X} (pair i (pair j H)) P = eq-equiv-Fam-pushout ( pair ( λ a → equiv-id (P (i a))) ( pair ( λ b → equiv-id (P (j b))) ( λ s → htpy-equiv-eq-ap-fam P (H s)))) is-equiv-desc-fam : {l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} {f : S → A} {g : S → B} (c : cocone f g X) → ((l' : Level) → universal-property-pushout l' f g c) → is-equiv (desc-fam {l = l} {f = f} {g} c) is-equiv-desc-fam {l = l} {f = f} {g} c up-c = is-equiv-comp ( desc-fam c) ( Fam-pushout-cocone-UU l) ( cocone-map f g c) ( triangle-desc-fam c) ( up-c (lsuc l) (UU l)) ( is-equiv-Fam-pushout-cocone-UU l) equiv-desc-fam : {l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} {f : S → A} {g : S → B} (c : cocone f g X) → ((l' : Level) → universal-property-pushout l' f g c) → (X → UU l) ≃ Fam-pushout l f g equiv-desc-fam c up-c = pair ( desc-fam c) ( is-equiv-desc-fam c up-c) {- Corollary 18.2.4 -} uniqueness-Fam-pushout : {l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} (f : S → A) (g : S → B) (c : cocone f g X) → ((l' : Level) → universal-property-pushout l' f g c) → ( P : Fam-pushout l f g) → is-contr ( Σ (X → UU l) (λ Q → equiv-Fam-pushout P (desc-fam c Q))) uniqueness-Fam-pushout {l = l} f g c up-c P = is-contr-equiv' ( fib (desc-fam c) P) ( equiv-tot (λ Q → ( equiv-equiv-Fam-pushout P (desc-fam c Q)) ∘e ( equiv-inv (desc-fam c Q) P))) ( is-contr-map-is-equiv (is-equiv-desc-fam c up-c) P) fam-Fam-pushout : {l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} {f : S → A} {g : S → B} (c : cocone f g X) → (up-X : (l' : Level) → universal-property-pushout l' f g c) → Fam-pushout l f g → (X → UU l) fam-Fam-pushout {f = f} {g} c up-X P = pr1 (center (uniqueness-Fam-pushout f g c up-X P)) issec-fam-Fam-pushout : {l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} {f : S → A} {g : S → B} (c : cocone f g X) → (up-X : (l' : Level) → universal-property-pushout l' f g c) → ((desc-fam {l = l} c) ∘ (fam-Fam-pushout c up-X)) ~ id issec-fam-Fam-pushout {f = f} {g} c up-X P = inv (eq-equiv-Fam-pushout (pr2 (center (uniqueness-Fam-pushout f g c up-X P)))) comp-left-fam-Fam-pushout : { l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} { f : S → A} {g : S → B} (c : cocone f g X) → ( up-X : (l' : Level) → universal-property-pushout l' f g c) → ( P : Fam-pushout l f g) → ( a : A) → (pr1 P a) ≃ (fam-Fam-pushout c up-X P (pr1 c a)) comp-left-fam-Fam-pushout {f = f} {g} c up-X P = pr1 (pr2 (center (uniqueness-Fam-pushout f g c up-X P))) comp-right-fam-Fam-pushout : { l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} { f : S → A} {g : S → B} (c : cocone f g X) → ( up-X : (l' : Level) → universal-property-pushout l' f g c) → ( P : Fam-pushout l f g) → ( b : B) → (pr1 (pr2 P) b) ≃ (fam-Fam-pushout c up-X P (pr1 (pr2 c) b)) comp-right-fam-Fam-pushout {f = f} {g} c up-X P = pr1 (pr2 (pr2 (center (uniqueness-Fam-pushout f g c up-X P)))) comp-path-fam-Fam-pushout : { l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} { f : S → A} {g : S → B} (c : cocone f g X) → ( up-X : (l' : Level) → universal-property-pushout l' f g c) → ( P : Fam-pushout l f g) → ( s : S) → ( ( map-equiv (comp-right-fam-Fam-pushout c up-X P (g s))) ∘ ( map-equiv (pr2 (pr2 P) s))) ~ ( ( tr (fam-Fam-pushout c up-X P) (pr2 (pr2 c) s)) ∘ ( map-equiv (comp-left-fam-Fam-pushout c up-X P (f s)))) comp-path-fam-Fam-pushout {f = f} {g} c up-X P = pr2 (pr2 (pr2 (center (uniqueness-Fam-pushout f g c up-X P)))) {- -- Section 18.3 The Flattening lemma for pushouts {- Definition 18.3.1 -} cocone-flattening-pushout : { l1 l2 l3 l4 l5 : Level} { S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} ( f : S → A) (g : S → B) (c : cocone f g X) ( P : Fam-pushout l5 f g) ( Q : X → UU l5) ( e : equiv-Fam-pushout P (desc-fam f g c Q)) → cocone ( toto (pr1 P) f (λ s → id)) ( toto (pr1 (pr2 P)) g (λ s → map-equiv (pr2 (pr2 P) s))) ( Σ X Q) cocone-flattening-pushout f g c P Q e = pair ( toto Q ( pr1 c) ( λ a → map-equiv (pr1 e a))) ( pair ( toto Q ( pr1 (pr2 c)) ( λ b → map-equiv (pr1 (pr2 e) b))) ( htpy-toto Q ( pr2 (pr2 c)) ( λ s → map-equiv (pr1 e (f s))) ( λ s → htpy-inv (pr2 (pr2 e) s)))) {- Theorem 18.3.2 The flattening lemma -} coherence-bottom-flattening-lemma' : {l1 l2 l3 : Level} {B : UU l1} {Q : B → UU l2} {T : UU l3} {b b' : B} (α : Id b b') {y : Q b} {y' : Q b'} (β : Id (tr Q α y) y') (h : (b : B) → Q b → T) → Id (h b y) (h b' y') coherence-bottom-flattening-lemma' refl refl h = refl coherence-bottom-flattening-lemma : {l1 l2 l3 l4 l5 : Level} {A : UU l1} {B : UU l2} {P : A → UU l3} {Q : B → UU l4} {T : UU l5} {f f' : A → B} (H : f ~ f') {g : (a : A) → P a → Q (f a)} {g' : (a : A) → P a → Q (f' a)} (K : (a : A) → ((tr Q (H a)) ∘ (g a)) ~ (g' a)) (h : (b : B) → Q b → T) → (a : A) (p : P a) → Id (h (f a) (g a p)) (h (f' a) (g' a p)) coherence-bottom-flattening-lemma H K h a p = coherence-bottom-flattening-lemma' (H a) (K a p) h coherence-cube-flattening-lemma : {l1 l2 l3 l4 l5 : Level} {A : UU l1} {B : UU l2} {P : A → UU l3} {Q : B → UU l4} {T : UU l5} {f f' : A → B} (H : f ~ f') {g : (a : A) → P a → Q (f a)} {g' : (a : A) → P a → Q (f' a)} (K : (a : A) → ((tr Q (H a)) ∘ (g a)) ~ (g' a)) (h : Σ B Q → T) → Id ( eq-htpy ( λ a → eq-htpy ( coherence-bottom-flattening-lemma H K (ev-pair h) a))) ( ap ev-pair ( htpy-precomp (htpy-toto Q H g K) T h)) coherence-cube-flattening-lemma {A = A} {B} {P} {Q} {T} {f = f} {f'} H {g} {g'} K = ind-htpy f ( λ f' H' → (g : (a : A) → P a → Q (f a)) (g' : (a : A) → P a → Q (f' a)) (K : (a : A) → ((tr Q (H' a)) ∘ (g a)) ~ (g' a)) (h : Σ B Q → T) → Id ( eq-htpy ( λ a → eq-htpy ( coherence-bottom-flattening-lemma H' K (ev-pair h) a))) ( ap ev-pair ( htpy-precomp (htpy-toto Q H' g K) T h))) ( λ g g' K h → {!ind-htpy g (λ g' K' → (h : Σ B Q → T) → Id ( eq-htpy ( λ a → eq-htpy ( coherence-bottom-flattening-lemma htpy-refl (λ a → htpy-eq (K' a)) (ev-pair h) a))) ( ap ev-pair ( htpy-precomp (htpy-toto Q htpy-refl g (λ a → htpy-eq (K' a))) T h))) ? (λ a → eq-htpy (K a)) h!}) H g g' K flattening-pushout' : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} (f : S → A) (g : S → B) (c : cocone f g X) → ( P : Fam-pushout l5 f g) ( Q : X → UU l5) ( e : equiv-Fam-pushout P (desc-fam f g c Q)) → (l : Level) → pullback-property-pushout l ( toto (pr1 P) f (λ s → id)) ( toto (pr1 (pr2 P)) g (λ s → map-equiv (pr2 (pr2 P) s))) ( cocone-flattening-pushout f g c P Q e) flattening-pushout' f g c P Q e l T = is-pullback-top-is-pullback-bottom-cube-is-equiv ( ( postcomp-Π (λ x → precomp-Π (map-equiv (pr1 e x)) (λ q → T))) ∘ ( precomp-Π (pr1 c) (λ x → (Q x) → T))) ( ( postcomp-Π (λ x → precomp-Π (map-equiv (pr1 (pr2 e) x)) (λ q → T))) ∘ ( precomp-Π (pr1 (pr2 c)) (λ x → (Q x) → T))) ( precomp-Π f (λ a → (pr1 P a) → T)) ( ( postcomp-Π (λ s → precomp (map-equiv (pr2 (pr2 P) s)) T)) ∘ ( precomp-Π g (λ b → (pr1 (pr2 P) b) → T))) ( precomp (toto Q (pr1 c) (λ a → map-equiv (pr1 e a))) T) ( precomp (toto Q (pr1 (pr2 c)) (λ b → map-equiv (pr1 (pr2 e) b))) T) ( precomp (toto (pr1 P) f (λ s → id)) T) ( precomp (toto (pr1 (pr2 P)) g (λ s → map-equiv (pr2 (pr2 P) s))) T) ev-pair ev-pair ev-pair ev-pair ( htpy-precomp ( htpy-toto Q ( pr2 (pr2 c)) ( λ s → map-equiv (pr1 e (f s))) ( λ s → htpy-inv (pr2 (pr2 e) s))) ( T)) htpy-refl htpy-refl htpy-refl htpy-refl ( λ h → eq-htpy (λ s → eq-htpy ( coherence-bottom-flattening-lemma ( pr2 (pr2 c)) ( λ s → htpy-inv (pr2 (pr2 e) s)) ( h) ( s)))) {!!} is-equiv-ev-pair is-equiv-ev-pair is-equiv-ev-pair is-equiv-ev-pair {!!} flattening-pushout : {l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {X : UU l4} (f : S → A) (g : S → B) (c : cocone f g X) → ( P : Fam-pushout l5 f g) ( Q : X → UU l5) ( e : equiv-Fam-pushout P (desc-fam f g c Q)) → (l : Level) → universal-property-pushout l ( toto (pr1 P) f (λ s → id)) ( toto (pr1 (pr2 P)) g (λ s → map-equiv (pr2 (pr2 P) s))) ( cocone-flattening-pushout f g c P Q e) flattening-pushout f g c P Q e l = universal-property-pushout-pullback-property-pushout l ( toto (pr1 P) f (λ s → id)) ( toto (pr1 (pr2 P)) g (λ s → map-equiv (pr2 (pr2 P) s))) ( cocone-flattening-pushout f g c P Q e) ( flattening-pushout' f g c P Q e l) -}
{ "alphanum_fraction": 0.5287387921, "avg_line_length": 38.135483871, "ext": "agda", "hexsha": "4a843eefe7ad4b663c1939b3725cba18567a08fe", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "hemangandhi/HoTT-Intro", "max_forks_repo_path": "Agda/22-descent.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "hemangandhi/HoTT-Intro", "max_issues_repo_path": "Agda/22-descent.agda", "max_line_length": 110, "max_stars_count": null, "max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "hemangandhi/HoTT-Intro", "max_stars_repo_path": "Agda/22-descent.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 20667, "size": 47288 }
open import Agda.Builtin.Nat open import Agda.Builtin.Sigma record Monad (M : Set → Set) : Set₁ where field return : {A : Set} → A → M A _>>=_ : {A B : Set} → M A → (A → M B) → M B open Monad ⦃ … ⦄ postulate F G : Set → Set instance postulate G-monad : Monad G F-monad : Monad F f : Σ Nat (λ _ → Nat) → F Nat f p = do m , n ← return p return (m n) -- Should jump to `m n` and list the F-monad candidate error first.
{ "alphanum_fraction": 0.5764966741, "avg_line_length": 16.7037037037, "ext": "agda", "hexsha": "3b4b32599837d52bf36dccc958a8e4fd8f9a4c93", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue3676.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue3676.agda", "max_line_length": 67, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue3676.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 171, "size": 451 }
{-# OPTIONS --without-K #-} module Model.Nat where open import Model.Size as MS using ( Size ; Sizes ; _≤_ ; _<_ ; ≤-IsProp ; nat ) open import Model.Type.Core open import Util.HoTT.HLevel open import Util.Prelude open import Util.Relation.Binary.PropositionalEquality using (Σ-≡⁺) import Data.Nat.Properties as ℕ open Size ℕ≤ : Size → Set ℕ≤ n = ∃[ m ] (nat m ≤ n) ℕ≤-IsSet : ∀ {n} → IsSet (ℕ≤ n) ℕ≤-IsSet = Σ-IsSet ℕ.≡-irrelevant λ m → IsOfHLevel-suc 1 ≤-IsProp abstract ℕ≤-≡⁺ : ∀ {n} {m m′} (m≤n : nat m ≤ n) (m′≤n : nat m′ ≤ n) → m ≡ m′ → (m , m≤n) ≡ (m′ , m′≤n) ℕ≤-≡⁺ _ _ m≡m′ = Σ-≡⁺ (m≡m′ , ≤-IsProp _ _) Nat : ⟦Type⟧ Sizes Nat = record { ObjHSet = λ n → HLevel⁺ (ℕ≤ n) ℕ≤-IsSet ; eqHProp = λ { _ (n , _) (m , _) → HLevel⁺ (n ≡ m) ℕ.≡-irrelevant } ; eq-refl = λ _ → refl } castℕ≤ : ∀ {n m} → n ≤ m → ℕ≤ n → ℕ≤ m castℕ≤ n≤m (k , k≤n) = k , go where abstract go = MS.≤-trans k≤n n≤m zero≤ : ∀ n → ℕ≤ n zero≤ n = 0 , MS.0≤n suc≤ : ∀ n m → m < n → ℕ≤ m → ℕ≤ n suc≤ n m m<n (x , x≤m) = suc x , MS.n<m→Sn≤m (MS.≤→<→< x≤m m<n) caseℕ≤ : ∀ {α} {A : Set α} {n} → ℕ≤ n → A → (∀ m → m < n → ℕ≤ m → A) → A caseℕ≤ (zero , _) z s = z caseℕ≤ (suc x , Sx≤n) z s = s (nat x) (MS.Sn≤m→n<m Sx≤n) (x , MS.≤-refl) caseℕ≤-pres : ∀ {α β γ} {A : Set α} {A′ : Set β} {n n′} → (R : A → A′ → Set γ) → (i : ℕ≤ n) (i′ : ℕ≤ n′) → (z : A) (z′ : A′) → (s : ∀ m → m < n → ℕ≤ m → A) (s′ : ∀ m → m < n′ → ℕ≤ m → A′) → proj₁ i ≡ proj₁ i′ → R z z′ → (∀ m m<n m′ m′<n′ j j′ → proj₁ j ≡ proj₁ j′ → R (s m m<n j) (s′ m′ m′<n′ j′)) → R (caseℕ≤ i z s) (caseℕ≤ i′ z′ s′) caseℕ≤-pres R (zero , _) (_ , _) z z′ s s′ refl zRz′ sRs′ = zRz′ caseℕ≤-pres R (suc i , _) (_ , _) z z′ s s′ refl zRz′ sRs′ = sRs′ _ _ _ _ _ _ refl
{ "alphanum_fraction": 0.4693877551, "avg_line_length": 23.52, "ext": "agda", "hexsha": "71fb991fc3b8af18477a3b10f51f854e3a8c5e30", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/msc-thesis-code", "max_forks_repo_path": "src/Model/Nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JLimperg/msc-thesis-code", "max_issues_repo_path": "src/Model/Nat.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/msc-thesis-code", "max_stars_repo_path": "src/Model/Nat.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z", "num_tokens": 952, "size": 1764 }
open import Data.Nat using (ℕ; zero; suc; _+_) open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Data.Nat.Properties using (+-assoc; +-comm) module Exercises.One where _*_ : ℕ → ℕ → ℕ zero * y = zero suc x * y = y + (x * y) -- Prove that multiplication is commutative *-idʳ : ∀ x → x * 0 ≡ 0 *-idʳ zero = refl *-idʳ (suc x) = *-idʳ x *-suc : ∀ x y → x + (x * y) ≡ (x * suc y) *-suc zero y = refl *-suc (suc x) y rewrite sym (+-assoc x y (x * y)) | +-comm x y | +-assoc y x (x * y) | *-suc x y = refl *-comm : ∀ x y → x * y ≡ y * x *-comm zero y rewrite *-idʳ y = refl *-comm (suc x) y rewrite *-comm x y | *-suc y x = refl -- Prove that if x + x ≡ y + y then x ≡ y (taken from CodeWars) suc-injective : ∀ x y → suc x ≡ suc y → x ≡ y suc-injective zero zero p = refl suc-injective (suc x) (suc .x) refl = refl xxyy : ∀ x y → x + x ≡ y + y → x ≡ y xxyy zero zero refl = refl xxyy (suc x) (suc y) p rewrite +-comm x (suc x) | +-comm y (suc y) = cong suc (xxyy x y (suc-injective _ _ (suc-injective _ _ p)))
{ "alphanum_fraction": 0.5772511848, "avg_line_length": 29.3055555556, "ext": "agda", "hexsha": "66ae97b0751728a78b1792092b2e3d296b12c3a3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "UoG-Agda/Agda101", "max_forks_repo_path": "Exercises/One.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "UoG-Agda/Agda101", "max_issues_repo_path": "Exercises/One.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UoG-Agda/Agda101", "max_stars_repo_path": "Exercises/One.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 429, "size": 1055 }
{-# OPTIONS --cubical --safe #-} open import Prelude open import Categories module Categories.Pullback {ℓ₁ ℓ₂} (C : Category ℓ₁ ℓ₂) where open Category C record Pullback (f : X ⟶ Z) (g : Y ⟶ Z) : Type (ℓ₁ ℓ⊔ ℓ₂) where field {P} : Ob p₁ : P ⟶ X p₂ : P ⟶ Y commute : f · p₁ ≡ g · p₂ ump : ∀ {A : Ob} (h₁ : A ⟶ X) (h₂ : A ⟶ Y) → f · h₁ ≡ g · h₂ → ∃![ u ] ((p₁ · u ≡ h₁) × (p₂ · u ≡ h₂)) HasPullbacks : Type (ℓ₁ ℓ⊔ ℓ₂) HasPullbacks = ∀ {X Y Z} (f : X ⟶ Z) (g : Y ⟶ Z) → Pullback f g
{ "alphanum_fraction": 0.4990403071, "avg_line_length": 23.6818181818, "ext": "agda", "hexsha": "cc107d1c71f61dd307cabab22cd25ceef2906a65", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Categories/Pullback.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Categories/Pullback.agda", "max_line_length": 66, "max_stars_count": 4, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Categories/Pullback.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "num_tokens": 241, "size": 521 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.Instances.Pointwise where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Algebra.CommRing.Base private variable ℓ : Level pointwiseRing : (X : Type ℓ) (R : CommRing ℓ) → CommRing ℓ pointwiseRing X R = (X → fst R) , str where open CommRingStr (snd R) isSetX→R = isOfHLevelΠ 2 (λ _ → isSetCommRing R) str : CommRingStr (X → fst R) CommRingStr.0r str = λ _ → 0r CommRingStr.1r str = λ _ → 1r CommRingStr._+_ str = λ f g → (λ x → f x + g x) CommRingStr._·_ str = λ f g → (λ x → f x · g x) CommRingStr.- str = λ f → (λ x → - f x) CommRingStr.isCommRing str = makeIsCommRing isSetX→R (λ f g h i x → +Assoc (f x) (g x) (h x) i) (λ f i x → +IdR (f x) i) (λ f i x → +InvR (f x) i) (λ f g i x → +Comm (f x) (g x) i) (λ f g h i x → ·Assoc (f x) (g x) (h x) i) (λ f i x → ·IdR (f x) i) (λ f g h i x → ·DistR+ (f x) (g x) (h x) i) λ f g i x → ·Comm (f x) (g x) i
{ "alphanum_fraction": 0.5251101322, "avg_line_length": 30.6756756757, "ext": "agda", "hexsha": "f47804ccc030def3a52db832270fcfc882654077", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/Pointwise.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/Pointwise.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/Pointwise.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 429, "size": 1135 }