Search is not available for this dataset
text
string
meta
dict
------------------------------------------------------------------------ -- Non-dependent and dependent lenses -- Nils Anders Danielsson ------------------------------------------------------------------------ {-# OPTIONS --cubical --guardedness #-} module README where -- Non-dependent lenses. import Lens.Non-dependent import Lens.Non-dependent.Traditional import Lens.Non-dependent.Traditional.Combinators import Lens.Non-dependent.Higher import Lens.Non-dependent.Higher.Combinators import Lens.Non-dependent.Higher.Capriotti.Variant import Lens.Non-dependent.Higher.Capriotti import Lens.Non-dependent.Higher.Coherently.Not-coinductive import Lens.Non-dependent.Higher.Coherently.Coinductive import Lens.Non-dependent.Higher.Coinductive import Lens.Non-dependent.Higher.Coinductive.Small import Lens.Non-dependent.Higher.Surjective-remainder import Lens.Non-dependent.Equivalent-preimages import Lens.Non-dependent.Bijection -- Non-dependent lenses with erased proofs. import Lens.Non-dependent.Traditional.Erased import Lens.Non-dependent.Higher.Erased import Lens.Non-dependent.Higher.Capriotti.Variant.Erased import Lens.Non-dependent.Higher.Capriotti.Variant.Erased.Variant import Lens.Non-dependent.Higher.Coinductive.Erased import Lens.Non-dependent.Higher.Coinductive.Small.Erased import Lens.Non-dependent.Higher.Coherently.Coinductive.Erased -- Dependent lenses. import Lens.Dependent -- Comparisons of different kinds of lenses, focusing on the -- definition of composable record getters and setters. import README.Record-getters-and-setters -- Some code suggesting that types used in "programs" might not -- necessarily be sets. (If lenses are only used in programs, and -- types used in programs are always sets, then higher lenses might be -- pointless.) import README.Not-a-set -- Pointers to code corresponding to many definitions and results from -- the paper "Higher Lenses" by Paolo Capriotti, Nils Anders -- Danielsson and Andrea Vezzosi. import README.Higher-Lenses -- The lenses fst and snd. import README.Fst-snd -- Pointers to code corresponding to some definitions and results from -- the paper "Compiling Programs with Erased Univalence" by Andreas -- Abel, Nils Anders Danielsson and Andrea Vezzosi. import README.Compiling-Programs-with-Erased-Univalence
{ "alphanum_fraction": 0.7626898048, "avg_line_length": 33.8970588235, "ext": "agda", "hexsha": "c2fc39d12f084d08eefd99de018f58fb524f3097", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_forks_event_min_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependent-lenses", "max_forks_repo_path": "README.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "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/dependent-lenses", "max_issues_repo_path": "README.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependent-lenses", "max_stars_repo_path": "README.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:55:52.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:10:46.000Z", "num_tokens": 501, "size": 2305 }
------------------------------------------------------------------------ -- A library of parser combinators ------------------------------------------------------------------------ module RecursiveDescent.Coinductive.Lib where open import Utilities open import RecursiveDescent.Coinductive import RecursiveDescent.Coinductive.Internal as Internal open import RecursiveDescent.Index open import Data.Bool hiding (_≟_) open import Data.Nat hiding (_≟_) open import Data.Product.Record using (_,_) open import Data.Product renaming (_,_ to pair) open import Data.List hiding (any) open import Data.Function open import Data.Maybe open import Data.Unit hiding (_≟_) import Data.Char as C open import Relation.Nullary open import Relation.Binary ------------------------------------------------------------------------ -- Applicative functor parsers -- We could get these for free with better library support. infixl 50 _⊛_ _<⊛_ _⊛>_ _<$>_ _<$_ -- Note that all the resulting indices can be inferred. _⊛_ : forall {tok i₁ i₂ r₁ r₂} -> Parser tok i₁ (r₁ -> r₂) -> Parser tok i₂ r₁ -> Parser tok _ r₂ p₁ ⊛ p₂ = p₁ >>= \f -> p₂ >>= \x -> return (f x) _<$>_ : forall {tok r₁ r₂ i} -> (r₁ -> r₂) -> Parser tok i r₁ -> Parser tok _ r₂ f <$> x = return f ⊛ x _<⊛_ : forall {tok i₁ i₂ r₁ r₂} -> Parser tok i₁ r₁ -> Parser tok i₂ r₂ -> Parser tok _ r₁ x <⊛ y = const <$> x ⊛ y _⊛>_ : forall {tok i₁ i₂ r₁ r₂} -> Parser tok i₁ r₁ -> Parser tok i₂ r₂ -> Parser tok _ r₂ x ⊛> y = flip const <$> x ⊛ y _<$_ : forall {tok r₁ r₂ i} -> r₁ -> Parser tok i r₂ -> Parser tok _ r₁ x <$ y = const x <$> y ------------------------------------------------------------------------ -- Parsers for sequences infix 60 _⋆ _+ -- Not accepted by the productivity checker: -- mutual -- _⋆ : forall {tok r d} -> -- Parser tok (false , d) r -> -- Parser tok _ (List r) -- p ⋆ ~ return [] ∣ p + -- _+ : forall {tok r d} -> -- Parser tok (false , d) r -> -- Parser tok _ (List r) -- p + ~ _∷_ <$> p ⊛ p ⋆ -- By inlining some definitions we can show that the definitions are -- productive, though. The following definitions have also been -- simplified: mutual _⋆ : forall {tok r d} -> Parser tok (false , d) r -> Parser tok _ (List r) p ⋆ ~ Internal.alt₀ (return []) (p +) _+ : forall {tok r d} -> Parser tok (false , d) r -> Parser tok _ (List r) p + ~ Internal.bind₁ p \x -> Internal.bind₀ (p ⋆) \xs -> return (x ∷ xs) -- p sepBy sep parses one or more ps separated by seps. _sepBy_ : forall {tok r r' i d} -> Parser tok i r -> Parser tok (false , d) r' -> Parser tok _ (List r) p sepBy sep = _∷_ <$> p ⊛ (sep ⊛> p) ⋆ chain₁ : forall {tok d₁ i₂ r} -> Assoc -> Parser tok (false , d₁) r -> Parser tok i₂ (r -> r -> r) -> Parser tok _ r chain₁ a p op = chain₁-combine a <$> (pair <$> p ⊛ op) ⋆ ⊛ p chain : forall {tok d₁ i₂ r} -> Assoc -> Parser tok (false , d₁) r -> Parser tok i₂ (r -> r -> r) -> r -> Parser tok _ r chain a p op x = return x ∣ chain₁ a p op ------------------------------------------------------------------------ -- sat and friends sat : forall {tok r} -> (tok -> Maybe r) -> Parser tok _ r sat {tok} {r} p = symbol !>>= \c -> ok (p c) where okIndex : Maybe r -> Index okIndex nothing = _ okIndex (just _) = _ ok : (x : Maybe r) -> Parser tok (okIndex x) r ok nothing = fail ok (just x) = return x sat' : forall {tok} -> (tok -> Bool) -> Parser tok _ ⊤ sat' p = sat (boolToMaybe ∘ p) any : forall {tok} -> Parser tok _ tok any = sat just ------------------------------------------------------------------------ -- Parsing a given token (symbol) module Sym (a : DecSetoid) where open DecSetoid a using (_≟_) renaming (carrier to tok) sym : tok -> Parser tok _ tok sym x = sat p where p : tok -> Maybe tok p y with x ≟ y ... | yes _ = just y ... | no _ = nothing ------------------------------------------------------------------------ -- Character parsers digit : Parser C.Char _ ℕ digit = 0 <$ sym '0' ∣ 1 <$ sym '1' ∣ 2 <$ sym '2' ∣ 3 <$ sym '3' ∣ 4 <$ sym '4' ∣ 5 <$ sym '5' ∣ 6 <$ sym '6' ∣ 7 <$ sym '7' ∣ 8 <$ sym '8' ∣ 9 <$ sym '9' where open Sym C.decSetoid number : Parser C.Char _ ℕ number = toNum <$> digit + where toNum = foldr (\n x -> 10 * x + n) 0 ∘ reverse
{ "alphanum_fraction": 0.4984662577, "avg_line_length": 27.1666666667, "ext": "agda", "hexsha": "6efe3027f1dc7a1ace79739acaa3815d74e39608", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "misc/RecursiveDescent/Coinductive/Lib.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "misc/RecursiveDescent/Coinductive/Lib.agda", "max_line_length": 72, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "misc/RecursiveDescent/Coinductive/Lib.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 1370, "size": 4564 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Relation.Binary open import Cubical.Algebra.Semigroup module Cubical.Algebra.Semigroup.Construct.Quotient {c ℓ} (S : Semigroup c) {R : Rel (Semigroup.Carrier S) ℓ} (isEq : IsEquivalence R) (closed : Congruent₂ R (Semigroup._•_ S)) where open import Cubical.Foundations.Prelude open import Cubical.Algebra.Properties open import Cubical.HITs.SetQuotients open Semigroup S open IsEquivalence isEq import Cubical.Algebra.Magma.Construct.Quotient magma isEq closed as QMagma open QMagma public hiding (M/R-isMagma; M/R) •ᴿ-assoc : Associative _•ᴿ_ •ᴿ-assoc = elimProp3 (λ _ _ _ → squash/ _ _) (λ x y z → cong [_] (assoc x y z)) S/R-isSemigroup : IsSemigroup Carrier/R _•ᴿ_ S/R-isSemigroup = record { isMagma = QMagma.M/R-isMagma ; assoc = •ᴿ-assoc } S/R : Semigroup (ℓ-max c ℓ) S/R = record { isSemigroup = S/R-isSemigroup }
{ "alphanum_fraction": 0.6891757696, "avg_line_length": 31.46875, "ext": "agda", "hexsha": "897c3a5c3c006ca81c8d6e0cd87ca9ae6f1ad1af", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Semigroup/Construct/Quotient.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Semigroup/Construct/Quotient.agda", "max_line_length": 134, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Semigroup/Construct/Quotient.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 319, "size": 1007 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Fin.Properties where open import Cubical.Core.Everything open import Cubical.Functions.Embedding open import Cubical.Functions.Surjection open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Prelude open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Data.Fin.Base as Fin open import Cubical.Data.Nat open import Cubical.Data.Nat.Order open import Cubical.Data.Empty as Empty open import Cubical.Data.Unit open import Cubical.Data.Sum open import Cubical.Data.Sigma open import Cubical.Data.FinData.Base renaming (Fin to FinData) hiding (¬Fin0 ; toℕ) open import Cubical.Relation.Nullary open import Cubical.Relation.Nullary.DecidableEq open import Cubical.Induction.WellFounded open import Cubical.Relation.Nullary private variable a b ℓ : Level n : ℕ A : Type a -- Fin 0 is empty, and thus a proposition. isPropFin0 : isProp (Fin 0) isPropFin0 = Empty.rec ∘ ¬Fin0 -- Fin 1 has only one value. isContrFin1 : isContr (Fin 1) isContrFin1 = fzero , λ { (zero , _) → toℕ-injective refl ; (suc k , sk<1) → Empty.rec (¬-<-zero (pred-≤-pred sk<1)) } Unit≃Fin1 : Unit ≃ Fin 1 Unit≃Fin1 = isoToEquiv (iso (const fzero) (const tt) (isContrFin1 .snd) (isContrUnit .snd) ) -- Regardless of k, Fin k is a set. isSetFin : ∀{k} → isSet (Fin k) isSetFin {k} = isSetΣ isSetℕ (λ _ → isProp→isSet m≤n-isProp) discreteFin : ∀ {n} → Discrete (Fin n) discreteFin {n} (x , hx) (y , hy) with discreteℕ x y ... | yes prf = yes (Σ≡Prop (λ _ → m≤n-isProp) prf) ... | no prf = no λ h → prf (cong fst h) inject<-ne : ∀ {n} (i : Fin n) → ¬ inject< ≤-refl i ≡ (n , ≤-refl) inject<-ne {n} (k , k<n) p = <→≢ k<n (cong fst p) Fin-fst-≡ : ∀ {n} {i j : Fin n} → fst i ≡ fst j → i ≡ j Fin-fst-≡ = Σ≡Prop (λ _ → m≤n-isProp) private subst-app : (B : A → Type b) (f : (x : A) → B x) {x y : A} (x≡y : x ≡ y) → subst B x≡y (f x) ≡ f y subst-app B f {x = x} = J (λ y e → subst B e (f x) ≡ f y) (substRefl {B = B} (f x)) -- Computation rules for the eliminator. module _ (P : ∀ {k} → Fin k → Type ℓ) (fz : ∀ {k} → P {suc k} fzero) (fs : ∀ {k} {fn : Fin k} → P fn → P (fsuc fn)) {k : ℕ} where elim-fzero : Fin.elim P fz fs {k = suc k} fzero ≡ fz elim-fzero = subst P (toℕ-injective _) fz ≡⟨ cong (λ p → subst P p fz) (isSetFin _ _ _ _) ⟩ subst P refl fz ≡⟨ substRefl {B = P} fz ⟩ fz ∎ elim-fsuc : (fk : Fin k) → Fin.elim P fz fs (fsuc fk) ≡ fs (Fin.elim P fz fs fk) elim-fsuc fk = subst P (toℕ-injective (λ _ → toℕ (fsuc fk′))) (fs (Fin.elim P fz fs fk′)) ≡⟨ cong (λ p → subst P p (fs (Fin.elim P fz fs fk′)) ) (isSetFin _ _ _ _) ⟩ subst P (cong fsuc fk′≡fk) (fs (Fin.elim P fz fs fk′)) ≡⟨ subst-app _ (λ fj → fs (Fin.elim P fz fs fj)) fk′≡fk ⟩ fs (Fin.elim P fz fs fk) ∎ where fk′ = fst fk , pred-≤-pred (snd (fsuc fk)) fk′≡fk : fk′ ≡ fk fk′≡fk = toℕ-injective refl -- Helper function for the reduction procedure below. -- -- If n = expand o k m, then n is congruent to m modulo k. expand : ℕ → ℕ → ℕ → ℕ expand 0 k m = m expand (suc o) k m = k + expand o k m expand≡ : ∀ k m o → expand o k m ≡ o · k + m expand≡ k m zero = refl expand≡ k m (suc o) = cong (k +_) (expand≡ k m o) ∙ +-assoc k (o · k) m -- Expand a pair. This is useful because the whole function is -- injective. expand× : ∀{k} → (Fin k × ℕ) → ℕ expand× {k} (f , o) = expand o k (toℕ f) private lemma₀ : ∀{k m n r} → r ≡ n → k + m ≡ n → k ≤ r lemma₀ {k = k} {m} p q = m , +-comm m k ∙ q ∙ sym p expand×Inj : ∀ k → {t1 t2 : Fin (suc k) × ℕ} → expand× t1 ≡ expand× t2 → t1 ≡ t2 expand×Inj k {f1 , zero} {f2 , zero} p i = toℕ-injective {fj = f1} {f2} p i , zero expand×Inj k {f1 , suc o1} {(r , r<sk) , zero} p = Empty.rec (<-asym r<sk (lemma₀ refl p)) expand×Inj k {(r , r<sk) , zero} {f2 , suc o2} p = Empty.rec (<-asym r<sk (lemma₀ refl (sym p))) expand×Inj k {f1 , suc o1} {f2 , suc o2} = cong (λ { (f , o) → (f , suc o) }) ∘ expand×Inj k {f1 , o1} {f2 , o2} ∘ inj-m+ {suc k} expand×Emb : ∀ k → isEmbedding (expand× {k}) expand×Emb 0 = Empty.rec ∘ ¬Fin0 ∘ fst expand×Emb (suc k) = injEmbedding (isSetΣ isSetFin (λ _ → isSetℕ)) isSetℕ (expand×Inj k) -- A Residue is a family of types representing evidence that a -- natural is congruent to a value of a finite type. Residue : ℕ → ℕ → Type₀ Residue k n = Σ[ tup ∈ Fin k × ℕ ] expand× tup ≡ n -- There is at most one canonical finite value congruent to each -- natural. isPropResidue : ∀ k n → isProp (Residue k n) isPropResidue k = isEmbedding→hasPropFibers (expand×Emb k) -- A value of a finite type is its own residue. Fin→Residue : ∀{k} → (f : Fin k) → Residue k (toℕ f) Fin→Residue f = (f , 0) , refl -- Fibers of numbers that differ by k are equivalent in a more obvious -- way than via the fact that they are propositions. Residue+k : (k n : ℕ) → Residue k n → Residue k (k + n) Residue+k k n ((f , o) , p) = (f , suc o) , cong (k +_) p Residue-k : (k n : ℕ) → Residue k (k + n) → Residue k n Residue-k k n (((r , r<k) , zero) , p) = Empty.rec (<-asym r<k (lemma₀ p refl)) Residue-k k n ((f , suc o) , p) = ((f , o) , inj-m+ p) Residue+k-k : (k n : ℕ) → (R : Residue k (k + n)) → Residue+k k n (Residue-k k n R) ≡ R Residue+k-k k n (((r , r<k) , zero) , p) = Empty.rec (<-asym r<k (lemma₀ p refl)) Residue+k-k k n ((f , suc o) , p) = Σ≡Prop (λ tup → isSetℕ (expand× tup) (k + n)) refl Residue-k+k : (k n : ℕ) → (R : Residue k n) → Residue-k k n (Residue+k k n R) ≡ R Residue-k+k k n ((f , o) , p) = Σ≡Prop (λ tup → isSetℕ (expand× tup) n) refl private Residue≃ : ∀ k n → Residue k n ≃ Residue k (k + n) Residue≃ k n = Residue+k k n , isoToIsEquiv (iso (Residue+k k n) (Residue-k k n) (Residue+k-k k n) (Residue-k+k k n)) Residue≡ : ∀ k n → Residue k n ≡ Residue k (k + n) Residue≡ k n = ua (Residue≃ k n) -- For positive `k`, all `n` have a canonical residue mod `k`. module Reduce (k₀ : ℕ) where k : ℕ k = suc k₀ base : ∀ n (n<k : n < k) → Residue k n base n n<k = Fin→Residue (n , n<k) step : ∀ n → Residue k n → Residue k (k + n) step n = transport (Residue≡ k n) reduce : ∀ n → Residue k n reduce = +induction k₀ (Residue k) base step reduce≡ : ∀ n → transport (Residue≡ k n) (reduce n) ≡ reduce (k + n) reduce≡ n = sym (+inductionStep k₀ _ base step n) reduceP : ∀ n → PathP (λ i → Residue≡ k n i) (reduce n) (reduce (k + n)) reduceP n = toPathP (reduce≡ n) open Reduce using (reduce; reduce≡) public extract : ∀{k n} → Residue k n → Fin k extract = fst ∘ fst private lemma₅ : ∀ k n (R : Residue k n) → extract R ≡ extract (transport (Residue≡ k n) R) lemma₅ k n = sym ∘ cong extract ∘ uaβ (Residue≃ k n) -- The residue of n modulo k is the same as the residue of k + n. extract≡ : ∀ k n → extract (reduce k n) ≡ extract (reduce k (suc k + n)) extract≡ k n = lemma₅ (suc k) n (reduce k n) ∙ cong extract (Reduce.reduce≡ k n) isContrResidue : ∀{k n} → isContr (Residue (suc k) n) isContrResidue {k} {n} = inhProp→isContr (reduce k n) (isPropResidue (suc k) n) -- the modulo operator on ℕ _%_ : ℕ → ℕ → ℕ n % zero = n n % (suc k) = toℕ (extract (reduce k n)) _/_ : ℕ → ℕ → ℕ n / zero = zero n / (suc k) = reduce k n .fst .snd moddiv : ∀ n k → (n / k) · k + n % k ≡ n moddiv n zero = refl moddiv n (suc k) = sym (expand≡ _ _ (n / suc k)) ∙ reduce k n .snd n%k≡n[modk] : ∀ n k → Σ[ o ∈ ℕ ] o · k + n % k ≡ n n%k≡n[modk] n k = (n / k) , moddiv n k n%sk<sk : (n k : ℕ) → (n % suc k) < suc k n%sk<sk n k = extract (reduce k n) .snd fznotfs : ∀ {m : ℕ} {k : Fin m} → ¬ fzero ≡ fsuc k fznotfs {m} p = subst F p tt where F : Fin (suc m) → Type₀ F (zero , _) = Unit F (suc _ , _) = ⊥ fsuc-inj : {fj fk : Fin n} → fsuc fj ≡ fsuc fk → fj ≡ fk fsuc-inj = toℕ-injective ∘ injSuc ∘ cong toℕ punchOut : ∀ {m} {i j : Fin (suc m)} → (¬ i ≡ j) → Fin m punchOut {_} {i} {j} p with fsplit i | fsplit j punchOut {_} {i} {j} p | inl prfi | inl prfj = Empty.elim (p (i ≡⟨ sym prfi ⟩ fzero ≡⟨ prfj ⟩ j ∎)) punchOut {_} {i} {j} p | inl prfi | inr (kj , prfj) = kj punchOut {zero} {i} {j} p | inr (ki , prfi) | inl prfj = Empty.elim (p ( i ≡⟨ sym (isContrFin1 .snd i) ⟩ c ≡⟨ isContrFin1 .snd j ⟩ j ∎ )) where c = isContrFin1 .fst punchOut {suc _} {i} {j} p | inr (ki , prfi) | inl prfj = fzero punchOut {zero} {i} {j} p | inr (ki , prfi) | inr (kj , prfj) = Empty.elim ((p ( i ≡⟨ sym (isContrFin1 .snd i) ⟩ c ≡⟨ isContrFin1 .snd j ⟩ j ∎) )) where c = isContrFin1 .fst punchOut {suc _} {i} {j} p | inr (ki , prfi) | inr (kj , prfj) = fsuc (punchOut {i = ki} {j = kj} (λ q → p (i ≡⟨ sym prfi ⟩ fsuc ki ≡⟨ cong fsuc q ⟩ fsuc kj ≡⟨ prfj ⟩ j ∎)) ) punchOut-inj : ∀ {m} {i j k : Fin (suc m)} (i≢j : ¬ i ≡ j) (i≢k : ¬ i ≡ k) → punchOut i≢j ≡ punchOut i≢k → j ≡ k punchOut-inj {_} {i} {j} {k} i≢j i≢k p with fsplit i | fsplit j | fsplit k punchOut-inj {zero} {i} {j} {k} i≢j i≢k p | _ | _ | _ = Empty.elim (i≢j (i ≡⟨ sym (isContrFin1 .snd i) ⟩ c ≡⟨ isContrFin1 .snd j ⟩ j ∎)) where c = isContrFin1 .fst punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inl prfi | inl prfj | _ = Empty.elim (i≢j (i ≡⟨ sym prfi ⟩ fzero ≡⟨ prfj ⟩ j ∎)) punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inl prfi | _ | inl prfk = Empty.elim (i≢k (i ≡⟨ sym prfi ⟩ fzero ≡⟨ prfk ⟩ k ∎)) punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inl prfi | inr (kj , prfj) | inr (kk , prfk) = j ≡⟨ sym prfj ⟩ fsuc kj ≡⟨ cong fsuc p ⟩ fsuc kk ≡⟨ prfk ⟩ k ∎ punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inr (ki , prfi) | inl prfj | inl prfk = j ≡⟨ sym prfj ⟩ fzero ≡⟨ prfk ⟩ k ∎ punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inr (ki , prfi) | inr (kj , prfj) | inr (kk , prfk) = j ≡⟨ sym prfj ⟩ fsuc kj ≡⟨ cong fsuc lemma4 ⟩ fsuc kk ≡⟨ prfk ⟩ k ∎ where lemma1 = λ q → i≢j (i ≡⟨ sym prfi ⟩ fsuc ki ≡⟨ cong fsuc q ⟩ fsuc kj ≡⟨ prfj ⟩ j ∎) lemma2 = λ q → i≢k (i ≡⟨ sym prfi ⟩ fsuc ki ≡⟨ cong fsuc q ⟩ fsuc kk ≡⟨ prfk ⟩ k ∎) lemma3 = fsuc-inj p lemma4 = punchOut-inj lemma1 lemma2 lemma3 punchOut-inj {suc m} {i} {j} {k} i≢j i≢k p | inr (ki , prfi) | inl prfj | inr (kk , prfk) = Empty.rec (fznotfs p) punchOut-inj {suc _} {i} {j} {k} i≢j i≢k p | inr (ki , prfi) | inr (kj , prfj) | inl prfk = Empty.rec (fznotfs (sym p)) pigeonhole-special : ∀ {n} → (f : Fin (suc n) → Fin n) → Σ[ i ∈ Fin (suc n) ] Σ[ j ∈ Fin (suc n) ] (¬ i ≡ j) × (f i ≡ f j) pigeonhole-special {zero} f = Empty.rec (¬Fin0 (f fzero)) pigeonhole-special {suc n} f = proof (any? (λ (i : Fin (suc n)) → discreteFin (f (inject< ≤-refl i)) (f (suc n , ≤-refl)) )) where proof : Dec (Σ (Fin (suc n)) (λ z → f (inject< ≤-refl z) ≡ f (suc n , ≤-refl))) → Σ[ i ∈ Fin (suc (suc n)) ] Σ[ j ∈ Fin (suc (suc n)) ] (¬ i ≡ j) × (f i ≡ f j) proof (yes (i , prf)) = inject< ≤-refl i , (suc n , ≤-refl) , inject<-ne i , prf proof (no h) = let g : Fin (suc n) → Fin n g k = punchOut {i = f (suc n , ≤-refl)} {j = f (inject< ≤-refl k)} (λ p → h (k , Fin-fst-≡ (sym (cong fst p)))) i , j , i≢j , p = pigeonhole-special g in inject< ≤-refl i , inject< ≤-refl j , (λ q → i≢j (Fin-fst-≡ (cong fst q))) , punchOut-inj {i = f (suc n , ≤-refl)} {j = f (inject< ≤-refl i)} {k = f (inject< ≤-refl j)} (λ q → h (i , Fin-fst-≡ (sym (cong fst q)))) (λ q → h (j , Fin-fst-≡ (sym (cong fst q)))) (Fin-fst-≡ (cong fst p)) pigeonhole : ∀ {m n} → m < n → (f : Fin n → Fin m) → Σ[ i ∈ Fin n ] Σ[ j ∈ Fin n ] (¬ i ≡ j) × (f i ≡ f j) pigeonhole {m} {n} (zero , sm≡n) f = transport transport-prf (pigeonhole-special f′) where f′ : Fin (suc m) → Fin m f′ = subst (λ h → Fin h → Fin m) (sym sm≡n) f f′≡f : PathP (λ i → Fin (sm≡n i) → Fin m) f′ f f′≡f i = transport-fillerExt (cong (λ h → Fin h → Fin m) (sym sm≡n)) (~ i) f transport-prf : (Σ[ i ∈ Fin (suc m) ] Σ[ j ∈ Fin (suc m) ] (¬ i ≡ j) × (f′ i ≡ f′ j)) ≡ (Σ[ i ∈ Fin n ] Σ[ j ∈ Fin n ] (¬ i ≡ j) × (f i ≡ f j)) transport-prf φ = Σ[ i ∈ Fin (sm≡n φ) ] Σ[ j ∈ Fin (sm≡n φ) ] (¬ i ≡ j) × (f′≡f φ i ≡ f′≡f φ j) pigeonhole {m} {n} (suc k , prf) f = let g : Fin (suc n′) → Fin n′ g k = fst (f′ k) , <-trans (snd (f′ k)) m<n′ i , j , ¬q , r = pigeonhole-special g in transport transport-prf (i , j , ¬q , Σ≡Prop (λ _ → m≤n-isProp) (cong fst r)) where n′ : ℕ n′ = k + suc m n≡sn′ : n ≡ suc n′ n≡sn′ = n ≡⟨ sym prf ⟩ suc (k + suc m) ≡⟨ refl ⟩ suc n′ ∎ m<n′ : m < n′ m<n′ = k , injSuc (suc (k + suc m) ≡⟨ prf ⟩ n ≡⟨ n≡sn′ ⟩ suc n′ ∎) f′ : Fin (suc n′) → Fin m f′ = subst (λ h → Fin h → Fin m) n≡sn′ f f′≡f : PathP (λ i → Fin (n≡sn′ (~ i)) → Fin m) f′ f f′≡f i = transport-fillerExt (cong (λ h → Fin h → Fin m) n≡sn′) (~ i) f transport-prf : (Σ[ i ∈ Fin (suc n′) ] Σ[ j ∈ Fin (suc n′) ] (¬ i ≡ j) × (f′ i ≡ f′ j)) ≡ (Σ[ i ∈ Fin n ] Σ[ j ∈ Fin n ] (¬ i ≡ j) × (f i ≡ f j)) transport-prf φ = Σ[ i ∈ Fin (n≡sn′ (~ φ)) ] Σ[ j ∈ Fin (n≡sn′ (~ φ)) ] (¬ i ≡ j) × (f′≡f φ i ≡ f′≡f φ j) Fin-inj′ : {n m : ℕ} → n < m → ¬ Fin m ≡ Fin n Fin-inj′ n<m p = let i , j , i≢j , q = pigeonhole n<m (transport p) in i≢j ( i ≡⟨ refl ⟩ fst (pigeonhole n<m (transport p)) ≡⟨ transport-p-inj {p = p} q ⟩ fst (snd (pigeonhole n<m (transport p))) ≡⟨ refl ⟩ j ∎ ) where transport-p-inj : ∀ {A B : Type ℓ} {x y : A} {p : A ≡ B} → transport p x ≡ transport p y → x ≡ y transport-p-inj {x = x} {y = y} {p = p} q = x ≡⟨ sym (transport⁻Transport p x) ⟩ transport (sym p) (transport p x) ≡⟨ cong (transport (sym p)) q ⟩ transport (sym p) (transport p y) ≡⟨ transport⁻Transport p y ⟩ y ∎ Fin-inj : (n m : ℕ) → Fin n ≡ Fin m → n ≡ m Fin-inj n m p with n ≟ m ... | eq prf = prf ... | lt n<m = Empty.rec (Fin-inj′ n<m (sym p)) ... | gt n>m = Empty.rec (Fin-inj′ n>m p) ≤-·sk-cancel : ∀ {m} {k} {n} → m · suc k ≤ n · suc k → m ≤ n ≤-·sk-cancel {m} {k} {n} (d , p) = o , inj-·sm {m = k} goal where r = d % suc k o = d / suc k resn·k : Residue (suc k) (n · suc k) resn·k = ((r , n%sk<sk d k) , (o + m)) , reason where reason = expand× ((r , n%sk<sk d k) , o + m) ≡⟨ expand≡ (suc k) r (o + m) ⟩ (o + m) · suc k + r ≡[ i ]⟨ +-comm (·-distribʳ o m (suc k) (~ i)) r i ⟩ r + (o · suc k + m · suc k) ≡⟨ +-assoc r (o · suc k) (m · suc k) ⟩ (r + o · suc k) + m · suc k ≡⟨ cong (_+ m · suc k) (+-comm r (o · suc k) ∙ moddiv d (suc k)) ⟩ d + m · suc k ≡⟨ p ⟩ n · suc k ∎ residuek·n : ∀ k n → (r : Residue (suc k) (n · suc k)) → ((fzero , n) , expand≡ (suc k) 0 n ∙ +-zero _) ≡ r residuek·n _ _ = isContr→isProp isContrResidue _ r≡0 : r ≡ 0 r≡0 = cong (toℕ ∘ extract) (sym (residuek·n k n resn·k)) d≡o·sk : d ≡ o · suc k d≡o·sk = sym (moddiv d (suc k)) ∙∙ cong (o · suc k +_) r≡0 ∙∙ +-zero _ goal : (o + m) · suc k ≡ n · suc k goal = sym (·-distribʳ o m (suc k)) ∙∙ cong (_+ m · suc k) (sym d≡o·sk) ∙∙ p <-·sk-cancel : ∀ {m} {k} {n} → m · suc k < n · suc k → m < n <-·sk-cancel {m} {k} {n} p = goal where ≤-helper : m ≤ n ≤-helper = ≤-·sk-cancel (pred-≤-pred (<≤-trans p (≤-suc ≤-refl))) goal : m < n goal = case <-split (suc-≤-suc ≤-helper) of λ { (inl g) → g ; (inr e) → Empty.rec (¬m<m (subst (λ m → m · suc k < n · suc k) e p)) } factorEquiv : ∀ {n} {m} → Fin n × Fin m ≃ Fin (n · m) factorEquiv {zero} {m} = uninhabEquiv (¬Fin0 ∘ fst) ¬Fin0 factorEquiv {suc n} {m} = intro , isEmbedding×isSurjection→isEquiv (isEmbeddingIntro , isSurjectionIntro) where intro : Fin (suc n) × Fin m → Fin (suc n · m) intro (nn , mm) = nm , subst (λ nm₁ → nm₁ < suc n · m) (sym (expand≡ _ (toℕ nn) (toℕ mm))) nm<n·m where nm : ℕ nm = expand× (nn , toℕ mm) nm<n·m : toℕ mm · suc n + toℕ nn < suc n · m nm<n·m = toℕ mm · suc n + toℕ nn <≤⟨ <-k+ (snd nn) ⟩ toℕ mm · suc n + suc n ≡≤⟨ +-comm _ (suc n) ⟩ suc (toℕ mm) · suc n ≤≡⟨ ≤-·k (snd mm) ⟩ m · suc n ≡⟨ ·-comm _ (suc n) ⟩ suc n · m ∎ where open <-Reasoning intro-injective : ∀ {o} {p} → intro o ≡ intro p → o ≡ p intro-injective {o} {p} io≡ip = λ i → io′≡ip′ i .fst , toℕ-injective {fj = snd o} {fk = snd p} (cong snd io′≡ip′) i where io′≡ip′ : (fst o , toℕ (snd o)) ≡ (fst p , toℕ (snd p)) io′≡ip′ = expand×Inj _ (cong fst io≡ip) isEmbeddingIntro : isEmbedding intro isEmbeddingIntro = injEmbedding (isSet× isSetFin isSetFin) isSetFin intro-injective elimF : ∀ nm → fiber intro nm elimF nm = ((nn , nn<n) , (mm , mm<m)) , toℕ-injective (reduce n (toℕ nm) .snd) where mm = toℕ nm / suc n nn = toℕ nm % suc n nmmoddiv : mm · suc n + nn ≡ toℕ nm nmmoddiv = moddiv _ (suc n) nn<n : nn < suc n nn<n = n%sk<sk (toℕ nm) _ nmsnd : mm · suc n + nn < suc n · m nmsnd = subst (λ l → l < suc n · m) (sym nmmoddiv) (snd nm) mm·sn<m·sn : mm · suc n < m · suc n mm·sn<m·sn = mm · suc n ≤<⟨ nn , +-comm nn (mm · suc n) ⟩ mm · suc n + nn <≡⟨ nmsnd ⟩ suc n · m ≡⟨ ·-comm (suc n) m ⟩ m · suc n ∎ where open <-Reasoning mm<m : mm < m mm<m = <-·sk-cancel mm·sn<m·sn isSurjectionIntro : isSurjection intro isSurjectionIntro = ∣_∣ ∘ elimF -- Fin (m + n) ≡ Fin m ⊎ Fin n -- =========================== o<m→o<m+n : (m n o : ℕ) → o < m → o < (m + n) o<m→o<m+n m n o (k , p) = (n + k) , (n + k + suc o ≡⟨ sym (+-assoc n k _) ⟩ n + (k + suc o) ≡⟨ cong (λ - → n + -) p ⟩ n + m ≡⟨ +-comm n m ⟩ m + n ∎) ∸-<-lemma : (m n o : ℕ) → o < m + n → m ≤ o → o ∸ m < n ∸-<-lemma zero n o o<m+n m<o = o<m+n ∸-<-lemma (suc m) n zero o<m+n m<o = Empty.rec (¬-<-zero m<o) ∸-<-lemma (suc m) n (suc o) o<m+n m<o = ∸-<-lemma m n o (pred-≤-pred o<m+n) (pred-≤-pred m<o) -- A convenient wrapper on top of trichotomy, as we will be interested in -- whether `m < n` or `n ≤ m`. _≤?_ : (m n : ℕ) → (m < n) ⊎ (n ≤ m) _≤?_ m n with m ≟ n _≤?_ m n | lt m<n = inl m<n _≤?_ m n | eq m=n = inr (subst (λ - → - ≤ m) m=n ≤-refl) _≤?_ m n | gt n<m = inr (<-weaken n<m) ¬-<-and-≥ : {m n : ℕ} → m < n → ¬ n ≤ m ¬-<-and-≥ {m} {zero} m<n n≤m = ¬-<-zero m<n ¬-<-and-≥ {zero} {suc n} m<n n≤m = ¬-<-zero n≤m ¬-<-and-≥ {suc m} {suc n} m<n n≤m = ¬-<-and-≥ (pred-≤-pred m<n) (pred-≤-pred n≤m) m+n∸n=m : (n m : ℕ) → (m + n) ∸ n ≡ m m+n∸n=m zero k = +-zero k m+n∸n=m (suc m) k = (k + suc m) ∸ suc m ≡⟨ cong (λ - → - ∸ suc m) (+-suc k m) ⟩ suc (k + m) ∸ (suc m) ≡⟨ refl ⟩ (k + m) ∸ m ≡⟨ m+n∸n=m m k ⟩ k ∎ ∸-lemma : {m n : ℕ} → m ≤ n → m + (n ∸ m) ≡ n ∸-lemma {zero} {k} _ = refl {x = k} ∸-lemma {suc m} {zero} m≤k = Empty.rec (¬-<-and-≥ (suc-≤-suc zero-≤) m≤k) ∸-lemma {suc m} {suc k} m≤k = suc m + (suc k ∸ suc m) ≡⟨ refl ⟩ suc (m + (suc k ∸ suc m)) ≡⟨ refl ⟩ suc (m + (k ∸ m)) ≡⟨ cong suc (∸-lemma (pred-≤-pred m≤k)) ⟩ suc k ∎ Fin+≅Fin⊎Fin : (m n : ℕ) → Iso (Fin (m + n)) (Fin m ⊎ Fin n) Iso.fun (Fin+≅Fin⊎Fin m n) = f where f : Fin (m + n) → Fin m ⊎ Fin n f (k , k<m+n) with k ≤? m f (k , k<m+n) | inl k<m = inl (k , k<m) f (k , k<m+n) | inr k≥m = inr (k ∸ m , ∸-<-lemma m n k k<m+n k≥m) Iso.inv (Fin+≅Fin⊎Fin m n) = g where g : Fin m ⊎ Fin n → Fin (m + n) g (inl (k , k<m)) = k , o<m→o<m+n m n k k<m g (inr (k , k<n)) = m + k , <-k+ k<n Iso.rightInv (Fin+≅Fin⊎Fin m n) = sec-f-g where sec-f-g : _ sec-f-g (inl (k , k<m)) with k ≤? m sec-f-g (inl (k , k<m)) | inl _ = cong inl (Σ≡Prop (λ _ → m≤n-isProp) refl) sec-f-g (inl (k , k<m)) | inr m≤k = Empty.rec (¬-<-and-≥ k<m m≤k) sec-f-g (inr (k , k<n)) with (m + k) ≤? m sec-f-g (inr (k , k<n)) | inl p = Empty.rec (¬m+n<m {m} {k} p) sec-f-g (inr (k , k<n)) | inr k≥m = cong inr (Σ≡Prop (λ _ → m≤n-isProp) rem) where rem : (m + k) ∸ m ≡ k rem = subst (λ - → - ∸ m ≡ k) (+-comm k m) (m+n∸n=m m k) Iso.leftInv (Fin+≅Fin⊎Fin m n) = ret-f-g where ret-f-g : _ ret-f-g (k , k<m+n) with k ≤? m ret-f-g (k , k<m+n) | inl _ = Σ≡Prop (λ _ → m≤n-isProp) refl ret-f-g (k , k<m+n) | inr m≥k = Σ≡Prop (λ _ → m≤n-isProp) (∸-lemma m≥k) Fin+≡Fin⊎Fin : (m n : ℕ) → Fin (m + n) ≡ Fin m ⊎ Fin n Fin+≡Fin⊎Fin m n = isoToPath (Fin+≅Fin⊎Fin m n) -- Equivalence between FinData and Fin sucFin : {N : ℕ} → Fin N → Fin (suc N) sucFin (k , n , p) = suc k , n , (+-suc _ _ ∙ cong suc p) FinData→Fin : (N : ℕ) → FinData N → Fin N FinData→Fin zero () FinData→Fin (suc N) zero = 0 , suc-≤-suc zero-≤ FinData→Fin (suc N) (suc k) = sucFin (FinData→Fin N k) Fin→FinData : (N : ℕ) → Fin N → FinData N Fin→FinData zero (k , n , p) = Empty.rec (snotz (sym (+-suc n k) ∙ p)) Fin→FinData (suc N) (0 , n , p) = zero Fin→FinData (suc N) ((suc k) , n , p) = suc (Fin→FinData N (k , n , p')) where p' : n + suc k ≡ N p' = injSuc (sym (+-suc n (suc k)) ∙ p) secFin : (n : ℕ) → section (FinData→Fin n) (Fin→FinData n) secFin 0 (k , n , p) = Empty.rec (snotz (sym (+-suc n k) ∙ p)) secFin (suc N) (0 , n , p) = Fin-fst-≡ refl secFin (suc N) (suc k , n , p) = Fin-fst-≡ (cong suc (cong fst (secFin N (k , n , p')))) where p' : n + suc k ≡ N p' = injSuc (sym (+-suc n (suc k)) ∙ p) retFin : (n : ℕ) → retract (FinData→Fin n) (Fin→FinData n) retFin 0 () retFin (suc N) zero = refl retFin (suc N) (suc k) = cong FinData.suc (cong (Fin→FinData N) (Fin-fst-≡ refl) ∙ retFin N k) FinDataIsoFin : (N : ℕ) → Iso (FinData N) (Fin N) Iso.fun (FinDataIsoFin N) = FinData→Fin N Iso.inv (FinDataIsoFin N) = Fin→FinData N Iso.rightInv (FinDataIsoFin N) = secFin N Iso.leftInv (FinDataIsoFin N) = retFin N FinData≃Fin : (N : ℕ) → FinData N ≃ Fin N FinData≃Fin N = isoToEquiv (FinDataIsoFin N) FinData≡Fin : (N : ℕ) → FinData N ≡ Fin N FinData≡Fin N = ua (FinData≃Fin N)
{ "alphanum_fraction": 0.5076366205, "avg_line_length": 35.5635792779, "ext": "agda", "hexsha": "7234ad7f4f15a86542138e787d0266d143f1e108", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_path": "Cubical/Data/Fin/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Edlyr/cubical", "max_issues_repo_path": "Cubical/Data/Fin/Properties.agda", "max_line_length": 123, "max_stars_count": null, "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_path": "Cubical/Data/Fin/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 10169, "size": 22654 }
import Lvl open import Structure.Setoid open import Type module Structure.Operator.Vector.Subspaces.Kernel {ℓₛ ℓₛₑ} {S : Type{ℓₛ}} ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ {_+ₛ_ _⋅ₛ_ : S → S → S} where open import Logic.Predicate open import Sets.ExtensionalPredicateSet as PredSet using (PredSet ; _∈_ ; [∋]-binaryRelator) open import Structure.Container.SetLike as SetLike using (SetElement) open import Structure.Function.Multi open import Structure.Operator open import Structure.Operator.Properties open import Structure.Operator.Vector open import Structure.Operator.Vector.LinearMap open import Structure.Operator.Vector.Proofs open import Structure.Operator.Vector.Subspace open import Structure.Relator.Properties open import Syntax.Implication open import Syntax.Transitivity open VectorSpace ⦃ … ⦄ open VectorSpaceVObject ⦃ … ⦄ using (_+ᵥ_; _⋅ₛᵥ_) open VectorSpaceVObject using (Vector) private variable ℓ ℓᵥ ℓᵥₑ : Lvl.Level private variable V W : VectorSpaceVObject {ℓᵥ = ℓᵥ} {ℓᵥₑ = ℓᵥₑ} ⦃ equiv-S = equiv-S ⦄ (_+ₛ_)(_⋅ₛ_) private variable F : V →ˡⁱⁿᵉᵃʳᵐᵃᵖ W kernel : (V →ˡⁱⁿᵉᵃʳᵐᵃᵖ W) → PredSet(Vector(V)) kernel {V = V}{W = W} ([∃]-intro f) = PredSet.unapply f(𝟎ᵥ) kernel-subspace : Subspace(kernel(F)) SetLike.FunctionProperties._closed-under₂_.proof (Subspace.add-closure (kernel-subspace {_} {_} {V} {_} {_} {W} {F = F@([∃]-intro f)})) {x} {y} xkern ykern = • ( xkern ⇒ x ∈ kernel(F) ⇒-[] f(x) ≡ 𝟎ᵥ ⇒-end ) • ( ykern ⇒ y ∈ kernel(F) ⇒-[] f(y) ≡ 𝟎ᵥ ⇒-end ) ⇒₂-[ congruence₂{A₁ = Vector(W)}{A₂ = Vector(W)}(_+ᵥ_) ] f(x) +ᵥ f(y) ≡ 𝟎ᵥ +ᵥ 𝟎ᵥ ⇒-[ _🝖 identityᵣ(_+ᵥ_)(𝟎ᵥ) ] f(x) +ᵥ f(y) ≡ 𝟎ᵥ ⇒-[ preserving₂(f)(_+ᵥ_)(_+ᵥ_) 🝖_ ] f(x +ᵥ y) ≡ 𝟎ᵥ ⇒-[] (x +ᵥ y) ∈ kernel(F) ⇒-end where instance _ = V instance _ = W SetLike.FunctionProperties._closed-under₁_.proof (Subspace.mul-closure (kernel-subspace {_}{_}{V}{_}{_}{W} {F = F@([∃]-intro f)}) {s}) {v} vkern = vkern ⇒ v ∈ kernel(F) ⇒-[] f(v) ≡ 𝟎ᵥ ⇒-[ congruence₂ᵣ(_⋅ₛᵥ_)(s) ] s ⋅ₛᵥ f(v) ≡ s ⋅ₛᵥ 𝟎ᵥ ⇒-[ _🝖 [⋅ₛᵥ]-absorberᵣ ] s ⋅ₛᵥ f(v) ≡ 𝟎ᵥ ⇒-[ preserving₁(f)(s ⋅ₛᵥ_)(s ⋅ₛᵥ_) 🝖_ ] f(s ⋅ₛᵥ v) ≡ 𝟎ᵥ ⇒-[] (s ⋅ₛᵥ v) ∈ kernel(F) ⇒-end where instance _ = V instance _ = W
{ "alphanum_fraction": 0.6171875, "avg_line_length": 34.3880597015, "ext": "agda", "hexsha": "c6620bd8f3dfb5674c2bf6c64647c2b59b2b6d92", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Operator/Vector/Subspaces/Kernel.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Operator/Vector/Subspaces/Kernel.agda", "max_line_length": 157, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Operator/Vector/Subspaces/Kernel.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": 1044, "size": 2304 }
-- Andreas and James, Nov 2011 and Oct 2012 -- function with flexible arity -- {-# OPTIONS -v tc.cover:20 #-} module FlexibleInterpreter where open import Common.Equality open import Common.IO open import Common.Nat renaming (zero to Z; suc to S) hiding (pred) data Ty : Set where nat : Ty arr : Ty -> Ty -> Ty data Exp : Ty -> Set where zero : Exp nat suc : Exp (arr nat nat) pred : Exp (arr nat nat) app : {a b : Ty} -> Exp (arr a b) -> Exp a -> Exp b Sem : Ty -> Set Sem nat = Nat Sem (arr a b) = Sem a -> Sem b module Flex where -- Haskell does not seem to handle this eval' : (a : Ty) -> Exp a -> Sem a eval' ._ zero = Z eval' ._ suc = S eval' b (app f e) = eval' _ f (eval' _ e) eval' .(arr nat nat) pred Z = Z eval' ._ pred (S n) = n eval : {a : Ty} -> Exp a -> Sem a eval zero = Z eval suc = S eval pred Z = Z eval pred (S n) = n eval (app f e) = eval f (eval e) testEvalSuc : ∀ {n} → eval suc n ≡ S n testEvalSuc = refl testEvalPredZero : eval pred Z ≡ Z testEvalPredZero = refl testEvalPredSuc : ∀ {n} → eval pred (S n) ≡ n testEvalPredSuc = refl module Rigid where -- This executes fine eval : {a : Ty} -> Exp a -> Sem a eval zero = Z eval suc = S eval pred = λ { Z -> Z ; (S n) -> n } eval (app f e) = eval f (eval e) open Flex expr = (app pred (app suc (app suc zero))) test = eval expr main = printNat test -- should print 1
{ "alphanum_fraction": 0.5593895156, "avg_line_length": 22.4925373134, "ext": "agda", "hexsha": "277c49e785f34fc1b83fcc07344c398931ee1517", "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/Compiler/simple/FlexibleInterpreter.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/Compiler/simple/FlexibleInterpreter.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/Compiler/simple/FlexibleInterpreter.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": 509, "size": 1507 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Nat.Coprime where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Data.Sigma open import Cubical.Data.NatPlusOne open import Cubical.HITs.PropositionalTruncation as PropTrunc open import Cubical.Data.Nat.Base open import Cubical.Data.Nat.Properties open import Cubical.Data.Nat.Divisibility open import Cubical.Data.Nat.GCD areCoprime : ℕ × ℕ → Type₀ areCoprime (m , n) = isGCD m n 1 -- Any pair (m , n) can be converted to a coprime pair (m' , n') s.t. -- m' ∣ m, n' ∣ n if and only if one of m or n is nonzero module _ ((m , n) : ℕ × ℕ₊₁) where private d = gcd m (ℕ₊₁→ℕ n) d∣m = gcdIsGCD m (ℕ₊₁→ℕ n) .fst .fst d∣sn = gcdIsGCD m (ℕ₊₁→ℕ n) .fst .snd gr = gcdIsGCD m (ℕ₊₁→ℕ n) .snd c₁ : ℕ p₁ : c₁ * d ≡ m c₁ = ∣-untrunc d∣m .fst; p₁ = ∣-untrunc d∣m .snd c₂ : ℕ₊₁ p₂ : (ℕ₊₁→ℕ c₂) * d ≡ (ℕ₊₁→ℕ n) c₂ = 1+ (∣s-untrunc d∣sn .fst); p₂ = ∣s-untrunc d∣sn .snd toCoprime : ℕ × ℕ₊₁ → ℕ × ℕ₊₁ toCoprime (m , n) = (c₁ , c₂) private lem : ∀ a {b c d e} → a * b ≡ c → c * d ≡ e → a * (b * d) ≡ e lem a p q = *-assoc a _ _ ∙ cong (_* _) p ∙ q gr' : ∀ d' → prediv d' c₁ → prediv d' (ℕ₊₁→ℕ c₂) → (d' * d) ∣ d gr' d' (b₁ , q₁) (b₂ , q₂) = gr (d' * d) ((∣ b₁ , lem b₁ q₁ p₁ ∣) , (∣ b₂ , lem b₂ q₂ p₂ ∣)) -- this only works because d > 0 (<=> m > 0 or n > 0) d-cancelʳ : ∀ d' → (d' * d) ∣ d → d' ∣ 1 d-cancelʳ d' div = ∣-cancelʳ d-1 (∣-trans (subst (λ x → (d' * x) ∣ x) p div) (∣-refl (sym (*-identityˡ _)))) where d-1 = m∣sn→z<m d∣sn .fst p : d ≡ suc d-1 p = sym (+-comm 1 d-1 ∙ m∣sn→z<m d∣sn .snd) toCoprimeAreCoprime : areCoprime (c₁ , ℕ₊₁→ℕ c₂) fst toCoprimeAreCoprime = ∣-oneˡ c₁ , ∣-oneˡ (ℕ₊₁→ℕ c₂) snd toCoprimeAreCoprime d' (d'∣c₁ , d'∣sc₂) = PropTrunc.rec isProp∣ (λ a → PropTrunc.rec isProp∣ (λ b → d-cancelʳ d' (gr' d' a b)) d'∣sc₂) d'∣c₁ toCoprime∣ : (c₁ ∣ m) × (ℕ₊₁→ℕ c₂ ∣ ℕ₊₁→ℕ n) toCoprime∣ = ∣ d , *-comm d c₁ ∙ p₁ ∣ , ∣ d , *-comm d (ℕ₊₁→ℕ c₂) ∙ p₂ ∣
{ "alphanum_fraction": 0.5054800526, "avg_line_length": 35.0923076923, "ext": "agda", "hexsha": "55ee07dd23aedf9e71321702b85c7609cf09d9cf", "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/Data/Nat/Coprime.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/Data/Nat/Coprime.agda", "max_line_length": 89, "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/Data/Nat/Coprime.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": 1044, "size": 2281 }
-- Andreas, 2015-02-24 data Wrap (A : Set) : Set where wrap : A → Wrap A data D : Set → Set1 where c : (A : Set) → D (Wrap A) test : (A : Set) → D A → Set test .(Wrap A) (c A) = A -- this should crash Epic as long as A is considered forced in constructor c -- should succeed now
{ "alphanum_fraction": 0.6041666667, "avg_line_length": 19.2, "ext": "agda", "hexsha": "f2104badcfde9f1fb19a56a78d1968511cf25e04", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Fail/Issue1441-3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Fail/Issue1441-3.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/Issue1441-3.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 100, "size": 288 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Comonads ------------------------------------------------------------------------ -- Note that currently the monad laws are not included here. {-# OPTIONS --without-K --safe #-} module Category.Comonad where open import Level open import Function record RawComonad {f} (W : Set f → Set f) : Set (suc f) where infixl 1 _=>>_ _=>=_ infixr 1 _<<=_ _=<=_ field extract : ∀ {A} → W A → A extend : ∀ {A B} → (W A → B) → (W A → W B) duplicate : ∀ {A} → W A → W (W A) duplicate = extend id liftW : ∀ {A B} → (A → B) → W A → W B liftW f = extend (f ∘′ extract) _=>>_ : ∀ {A B} → W A → (W A → B) → W B _=>>_ = flip extend _=>=_ : ∀ {c A B} {C : Set c} → (W A → B) → (W B → C) → W A → C f =>= g = g ∘′ extend f _<<=_ : ∀ {A B} → (W A → B) → W A → W B _<<=_ = extend _=<=_ : ∀ {A B c} {C : Set c} → (W B → C) → (W A → B) → W A → C _=<=_ = flip _=>=_
{ "alphanum_fraction": 0.4098196393, "avg_line_length": 23.7619047619, "ext": "agda", "hexsha": "53fa21ca930df8fb0bf619c9b191b75d9ceb7b12", "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/Category/Comonad.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/Category/Comonad.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/Category/Comonad.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 362, "size": 998 }
------------------------------------------------------------------------ -- The Agda standard library -- -- A pointwise lifting of a relation to incorporate an additional point. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- This module is designed to be used with -- Relation.Nullary.Construct.Add.Point open import Relation.Binary module Relation.Binary.Construct.Add.Point.Equality {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where open import Level using (_⊔_) open import Function import Relation.Binary.PropositionalEquality as P open import Relation.Nullary open import Relation.Nullary.Construct.Add.Point import Relation.Nullary.Decidable as Dec ------------------------------------------------------------------------ -- Definition data _≈∙_ : Rel (Pointed A) (a ⊔ ℓ) where ∙≈∙ : ∙ ≈∙ ∙ [_] : {k l : A} → k ≈ l → [ k ] ≈∙ [ l ] ------------------------------------------------------------------------ -- Relational properties [≈]-injective : ∀ {k l} → [ k ] ≈∙ [ l ] → k ≈ l [≈]-injective [ k≈l ] = k≈l ≈∙-refl : Reflexive _≈_ → Reflexive _≈∙_ ≈∙-refl ≈-refl {∙} = ∙≈∙ ≈∙-refl ≈-refl {[ k ]} = [ ≈-refl ] ≈∙-sym : Symmetric _≈_ → Symmetric _≈∙_ ≈∙-sym ≈-sym ∙≈∙ = ∙≈∙ ≈∙-sym ≈-sym [ x≈y ] = [ ≈-sym x≈y ] ≈∙-trans : Transitive _≈_ → Transitive _≈∙_ ≈∙-trans ≈-trans ∙≈∙ ∙≈z = ∙≈z ≈∙-trans ≈-trans [ x≈y ] [ y≈z ] = [ ≈-trans x≈y y≈z ] ≈∙-dec : Decidable _≈_ → Decidable _≈∙_ ≈∙-dec _≟_ ∙ ∙ = yes ∙≈∙ ≈∙-dec _≟_ ∙ [ l ] = no (λ ()) ≈∙-dec _≟_ [ k ] ∙ = no (λ ()) ≈∙-dec _≟_ [ k ] [ l ] = Dec.map′ [_] [≈]-injective (k ≟ l) ≈∙-irrelevant : Irrelevant _≈_ → Irrelevant _≈∙_ ≈∙-irrelevant ≈-irr ∙≈∙ ∙≈∙ = P.refl ≈∙-irrelevant ≈-irr [ p ] [ q ] = P.cong _ (≈-irr p q) ≈∙-substitutive : ∀ {ℓ} → Substitutive _≈_ ℓ → Substitutive _≈∙_ ℓ ≈∙-substitutive ≈-subst P ∙≈∙ = id ≈∙-substitutive ≈-subst P [ p ] = ≈-subst (P ∘′ [_]) p ------------------------------------------------------------------------ -- Structures ≈∙-isEquivalence : IsEquivalence _≈_ → IsEquivalence _≈∙_ ≈∙-isEquivalence ≈-isEquivalence = record { refl = ≈∙-refl refl ; sym = ≈∙-sym sym ; trans = ≈∙-trans trans } where open IsEquivalence ≈-isEquivalence ≈∙-isDecEquivalence : IsDecEquivalence _≈_ → IsDecEquivalence _≈∙_ ≈∙-isDecEquivalence ≈-isDecEquivalence = record { isEquivalence = ≈∙-isEquivalence isEquivalence ; _≟_ = ≈∙-dec _≟_ } where open IsDecEquivalence ≈-isDecEquivalence
{ "alphanum_fraction": 0.4986138614, "avg_line_length": 32.3717948718, "ext": "agda", "hexsha": "42ce4591bcec4518d46db71022cf18bbe779ecd0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Add/Point/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Add/Point/Equality.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Add/Point/Equality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1002, "size": 2525 }
module _ where module A where postulate _∷_ _∙_ bind : Set infixr 5 _∷_ infixr 5 _∙_ infix 1 bind syntax bind c (λ x → d) = x ← c , d module B where postulate _∷_ _∙_ bind : Set infix 5 _∷_ infixr 4 _∙_ infixl 2 bind syntax bind c d = c ∙ d module C where postulate bind : Set infixr 2 bind syntax bind c d = c ∙ d open A open B open C -- _∷_ is infix 5. -- _∙_ has two fixities: infixr 4 and infixr 5. -- A.bind's notation is infix 1. -- B.bind and C.bind's notations are infix 2. -- There is one instance of _∷_ in the grammar. -- There are three instances of _∙_ in the grammar, one -- corresponding to A._∙_, one corresponding to B._∙_, and one -- corresponding to both B.bind and C.bind. Foo : Set Foo = ∷ ∙ ← ,
{ "alphanum_fraction": 0.6317829457, "avg_line_length": 15.1764705882, "ext": "agda", "hexsha": "85c3c0c73f52a70965dd24ebe241c5073398984e", "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/Issue1436-17.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/Issue1436-17.agda", "max_line_length": 62, "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/Issue1436-17.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": 289, "size": 774 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Groups.Lemmas open import Groups.Definition open import Setoids.Orders.Partial.Definition open import Setoids.Setoids open import Functions.Definition open import Sets.EquivalenceRelations open import Rings.Definition open import Rings.Orders.Partial.Definition open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order module Rings.Orders.Partial.Lemmas {n m p : _} {A : Set n} {S : Setoid {n} {m} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {_} {p} A} {R : Ring S _+_ _*_} {pOrder : SetoidPartialOrder S _<_} (pRing : PartiallyOrderedRing R pOrder) where abstract open PartiallyOrderedRing pRing open Setoid S open SetoidPartialOrder pOrder open Ring R open Group additiveGroup open Equivalence eq open import Rings.Lemmas R ringAddInequalities : {w x y z : A} → w < x → y < z → (w + y) < (x + z) ringAddInequalities {w = w} {x} {y} {z} w<x y<z = <Transitive (orderRespectsAddition w<x y) (<WellDefined groupIsAbelian groupIsAbelian (orderRespectsAddition y<z x)) ringCanMultiplyByPositive : {x y c : A} → (Ring.0R R) < c → x < y → (x * c) < (y * c) ringCanMultiplyByPositive {x} {y} {c} 0<c x<y = SetoidPartialOrder.<WellDefined pOrder reflexive (Group.identRight additiveGroup) q' where have : 0R < (y + Group.inverse additiveGroup x) have = SetoidPartialOrder.<WellDefined pOrder (Group.invRight additiveGroup) reflexive (orderRespectsAddition x<y (Group.inverse additiveGroup x)) p1 : 0R < ((y * c) + ((Group.inverse additiveGroup x) * c)) p1 = SetoidPartialOrder.<WellDefined pOrder reflexive (transitive *Commutative (transitive *DistributesOver+ ((Group.+WellDefined additiveGroup) *Commutative *Commutative))) (orderRespectsMultiplication have 0<c) p' : 0R < ((y * c) + (Group.inverse additiveGroup (x * c))) p' = SetoidPartialOrder.<WellDefined pOrder reflexive (Group.+WellDefined additiveGroup reflexive (transitive (transitive *Commutative ringMinusExtracts) (inverseWellDefined additiveGroup *Commutative))) p1 q : (0R + (x * c)) < (((y * c) + (Group.inverse additiveGroup (x * c))) + (x * c)) q = orderRespectsAddition p' (x * c) q' : (x * c) < ((y * c) + 0R) q' = SetoidPartialOrder.<WellDefined pOrder (Group.identLeft additiveGroup) (transitive (symmetric (Group.+Associative additiveGroup)) (Group.+WellDefined additiveGroup reflexive (Group.invLeft additiveGroup))) q ringCanMultiplyByPositive' : {x y c : A} → (Ring.0R R) < c → x < y → (c * x) < (c * y) ringCanMultiplyByPositive' {x} {y} {c} 0<c x<y = SetoidPartialOrder.<WellDefined pOrder *Commutative *Commutative (ringCanMultiplyByPositive 0<c x<y) ringMultiplyPositives : {x y a b : A} → 0R < x → 0R < a → (x < y) → (a < b) → (x * a) < (y * b) ringMultiplyPositives {x} {y} {a} {b} 0<x 0<a x<y a<b = SetoidPartialOrder.<Transitive pOrder (ringCanMultiplyByPositive 0<a x<y) (<WellDefined *Commutative *Commutative (ringCanMultiplyByPositive (SetoidPartialOrder.<Transitive pOrder 0<x x<y) a<b)) ringSwapNegatives : {x y : A} → (Group.inverse (Ring.additiveGroup R) x) < (Group.inverse (Ring.additiveGroup R) y) → y < x ringSwapNegatives {x} {y} -x<-y = SetoidPartialOrder.<WellDefined pOrder (transitive (symmetric (Group.+Associative additiveGroup)) (transitive (Group.+WellDefined additiveGroup reflexive (Group.invLeft additiveGroup)) (Group.identRight additiveGroup))) (Group.identLeft additiveGroup) v where t : ((Group.inverse additiveGroup x) + y) < ((Group.inverse additiveGroup y) + y) t = orderRespectsAddition -x<-y y u : (y + (Group.inverse additiveGroup x)) < 0R u = SetoidPartialOrder.<WellDefined pOrder (groupIsAbelian) (Group.invLeft additiveGroup) t v : ((y + (Group.inverse additiveGroup x)) + x) < (0R + x) v = orderRespectsAddition u x ringSwapNegatives' : {x y : A} → x < y → (Group.inverse (Ring.additiveGroup R) y) < (Group.inverse (Ring.additiveGroup R) x) ringSwapNegatives' {x} {y} x<y = ringSwapNegatives (<WellDefined (Equivalence.symmetric eq (invTwice additiveGroup _)) (Equivalence.symmetric eq (invTwice additiveGroup _)) x<y) ringCanMultiplyByNegative : {x y c : A} → c < (Ring.0R R) → x < y → (y * c) < (x * c) ringCanMultiplyByNegative {x} {y} {c} c<0 x<y = ringSwapNegatives u where open Equivalence eq p1 : (c + Group.inverse additiveGroup c) < (0R + Group.inverse additiveGroup c) p1 = orderRespectsAddition c<0 _ 0<-c : 0R < (Group.inverse additiveGroup c) 0<-c = SetoidPartialOrder.<WellDefined pOrder (Group.invRight additiveGroup) (Group.identLeft additiveGroup) p1 t : (x * Group.inverse additiveGroup c) < (y * Group.inverse additiveGroup c) t = ringCanMultiplyByPositive 0<-c x<y u : (Group.inverse additiveGroup (x * c)) < Group.inverse additiveGroup (y * c) u = SetoidPartialOrder.<WellDefined pOrder ringMinusExtracts ringMinusExtracts t anyComparisonImpliesNontrivial : {a b : A} → a < b → (0R ∼ 1R) → False anyComparisonImpliesNontrivial {a} {b} a<b 0=1 = irreflexive (<WellDefined (oneZeroImpliesAllZero 0=1) (oneZeroImpliesAllZero 0=1) a<b) moveInequality : {a b : A} → a < b → 0R < (b + inverse a) moveInequality {a} {b} a<b = <WellDefined invRight reflexive (orderRespectsAddition a<b (inverse a)) moveInequality' : {a b : A} → a < b → (a + inverse b) < 0R moveInequality' {a} {b} a<b = <WellDefined reflexive invRight (orderRespectsAddition a<b (inverse b)) greaterImpliesNotEqual : {a b : A} → a < b → (a ∼ b → False) greaterImpliesNotEqual {a} {b} a<b a=b = irreflexive (<WellDefined a=b reflexive a<b) greaterImpliesNotEqual' : {a b : A} → a < b → (b ∼ a → False) greaterImpliesNotEqual' {a} {b} a<b a=b = irreflexive (<WellDefined reflexive a=b a<b) negativeInequality : {a : A} → a < 0G → 0G < inverse a negativeInequality {a} a<0 = <WellDefined invRight identLeft (orderRespectsAddition a<0 (inverse a)) negativeInequality' : {a : A} → 0G < a → inverse a < 0G negativeInequality' {a} 0<a = <WellDefined identLeft invRight (orderRespectsAddition 0<a (inverse a)) open import Rings.InitialRing R fromNIncreasing : (0R < 1R) → (n : ℕ) → (fromN n) < (fromN (succ n)) fromNIncreasing 0<1 zero = <WellDefined reflexive (symmetric identRight) 0<1 fromNIncreasing 0<1 (succ n) = <WellDefined groupIsAbelian groupIsAbelian (orderRespectsAddition (fromNIncreasing 0<1 n) 1R) fromNPreservesOrder : (0R < 1R) → {a b : ℕ} → (a <N b) → (fromN a) < (fromN b) fromNPreservesOrder 0<1 {zero} {succ zero} a<b = fromNIncreasing 0<1 0 fromNPreservesOrder 0<1 {zero} {succ (succ b)} a<b = <Transitive (fromNPreservesOrder 0<1 (succIsPositive b)) (fromNIncreasing 0<1 (succ b)) fromNPreservesOrder 0<1 {succ a} {succ b} a<b = <WellDefined groupIsAbelian groupIsAbelian (orderRespectsAddition (fromNPreservesOrder 0<1 (canRemoveSuccFrom<N a<b)) 1R)
{ "alphanum_fraction": 0.6982933179, "avg_line_length": 64.0185185185, "ext": "agda", "hexsha": "54d01734c53af87717113c209f6e2cf678e243cf", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Rings/Orders/Partial/Lemmas.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Rings/Orders/Partial/Lemmas.agda", "max_line_length": 289, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Rings/Orders/Partial/Lemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 2286, "size": 6914 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Endomorphisms on a Setoid ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Function.Endomorphism.Setoid {c e} (S : Setoid c e) where open import Agda.Builtin.Equality open import Algebra open import Algebra.Structures open import Algebra.Morphism; open Definitions open import Function.Equality open import Data.Nat.Base using (ℕ; _+_); open ℕ open import Data.Nat.Properties open import Data.Product import Relation.Binary.Indexed.Heterogeneous.Construct.Trivial as Trivial private module E = Setoid (setoid S (Trivial.indexedSetoid S)) open E hiding (refl) ------------------------------------------------------------------------ -- Basic type and functions Endo : Set _ Endo = S ⟶ S _^_ : Endo → ℕ → Endo f ^ zero = id f ^ suc n = f ∘ (f ^ n) ^-cong₂ : ∀ f → (f ^_) Preserves _≡_ ⟶ _≈_ ^-cong₂ f {n} refl = cong (f ^ n) ^-homo : ∀ f → Homomorphic₂ ℕ Endo _≈_ (f ^_) _+_ _∘_ ^-homo f zero n x≈y = cong (f ^ n) x≈y ^-homo f (suc m) n x≈y = cong f (^-homo f m n x≈y) ------------------------------------------------------------------------ -- Structures ∘-isMagma : IsMagma _≈_ _∘_ ∘-isMagma = record { isEquivalence = isEquivalence ; ∙-cong = λ g f x → g (f x) } ∘-magma : Magma _ _ ∘-magma = record { isMagma = ∘-isMagma } ∘-isSemigroup : IsSemigroup _≈_ _∘_ ∘-isSemigroup = record { isMagma = ∘-isMagma ; assoc = λ h g f x≈y → cong h (cong g (cong f x≈y)) } ∘-semigroup : Semigroup _ _ ∘-semigroup = record { isSemigroup = ∘-isSemigroup } ∘-id-isMonoid : IsMonoid _≈_ _∘_ id ∘-id-isMonoid = record { isSemigroup = ∘-isSemigroup ; identity = cong , cong } ∘-id-monoid : Monoid _ _ ∘-id-monoid = record { isMonoid = ∘-id-isMonoid } ------------------------------------------------------------------------ -- Homomorphism ^-isSemigroupMorphism : ∀ f → IsSemigroupMorphism +-semigroup ∘-semigroup (f ^_) ^-isSemigroupMorphism f = record { ⟦⟧-cong = ^-cong₂ f ; ∙-homo = ^-homo f } ^-isMonoidMorphism : ∀ f → IsMonoidMorphism +-0-monoid ∘-id-monoid (f ^_) ^-isMonoidMorphism f = record { sm-homo = ^-isSemigroupMorphism f ; ε-homo = λ x≈y → x≈y }
{ "alphanum_fraction": 0.5458853942, "avg_line_length": 25.7888888889, "ext": "agda", "hexsha": "9897d8b32b437556110555039176084ab13a6a80", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Function/Endomorphism/Setoid.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/Function/Endomorphism/Setoid.agda", "max_line_length": 80, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Function/Endomorphism/Setoid.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": 766, "size": 2321 }
{-# OPTIONS --without-K #-} open import lib.Basics open import lib.NType2 open import lib.types.TLevel open import lib.types.Sigma open import lib.types.Pi module lib.types.Groupoid where record GroupoidStructure {i j} {El : Type i} (Arr : El → El → Type j) (_ : ∀ x y → has-level 0 (Arr x y)) : Type (lmax i j) where field id : ∀ {x} → Arr x x inv : ∀ {x y} → Arr x y → Arr y x comp : ∀ {x y z} → Arr x y → Arr y z → Arr x z unit-l : ∀ {x y} (a : Arr x y) → comp id a == a unit-r : ∀ {x y} (a : Arr x y) → comp a id == a assoc : ∀ {x y z w} (a : Arr x y) (b : Arr y z) (c : Arr z w) → comp (comp a b) c == comp a (comp b c) inv-r : ∀ {x y} (a : Arr x y) → (comp a (inv a)) == id inv-l : ∀ {x y } (a : Arr x y) → (comp (inv a) a) == id record Groupoid {i j} : Type (lsucc (lmax i j)) where constructor groupoid field El : Type i Arr : El → El → Type j Arr-level : ∀ x y → has-level 0 (Arr x y) groupoid-struct : GroupoidStructure Arr Arr-level
{ "alphanum_fraction": 0.5409356725, "avg_line_length": 33.0967741935, "ext": "agda", "hexsha": "27cb7d3918d7d37d6f10ba8b155273c98d9461b7", "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": "core/lib/types/Groupoid.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": "core/lib/types/Groupoid.agda", "max_line_length": 69, "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": "core/lib/types/Groupoid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 377, "size": 1026 }
{-# OPTIONS --without-K #-} module Data.ByteString.Primitive where open import Data.Word8.Primitive using (Word8) open import Data.Nat using (ℕ; _<_) open import Data.Colist using (Colist) open import Data.List using (List; length) open import Agda.Builtin.String using (String) open import Agda.Builtin.Bool using (Bool) open import Agda.Builtin.IO using (IO) open import Data.Tuple.Base using (Pair) open import Relation.Binary.PropositionalEquality using (_≡_) open import Relation.Binary.PropositionalEquality.TrustMe using (trustMe) {-# FOREIGN GHC import qualified Data.ByteString.Lazy #-} open import Data.ByteString.Primitive.Int open import Data.ByteString.Primitive.Lazy open import Data.ByteString.Primitive.Strict -- properties module _ where List→Strict→List : (l : List Word8) → List←Strict (List→Strict l) ≡ l List→Strict→List l = trustMe Strict→List→Strict : (bs : ByteStringStrict) → List→Strict (List←Strict bs) ≡ bs Strict→List→Strict bs = trustMe ∣Strict∣≡∣List∣ : (bs : ByteStringStrict) → IntToℕ (lengthStrict bs) ≡ length (List←Strict bs) ∣Strict∣≡∣List∣ bs = trustMe 2³¹ = 2147483648 ∣List∣≡∣Strict∣ : (l : List Word8) → (l-small : length l < 2³¹) → IntToℕ (lengthStrict (List→Strict l)) ≡ length l ∣List∣≡∣Strict∣ l l-small = trustMe postulate toLazy : ByteStringStrict → ByteStringLazy toStrict : ByteStringLazy → ByteStringStrict lazy≟lazy : ByteStringLazy → ByteStringLazy → Bool strict≟strict : ByteStringStrict → ByteStringStrict → Bool {-# COMPILE GHC toLazy = (Data.ByteString.Lazy.fromStrict) #-} {-# COMPILE GHC toStrict = (Data.ByteString.Lazy.toStrict) #-} {-# COMPILE GHC lazy≟lazy = (==) #-} {-# COMPILE GHC strict≟strict = (==) #-} lazy≟strict : ByteStringLazy → ByteStringStrict → Bool lazy≟strict l s = lazy≟lazy l (toLazy s) strict≟lazy : ByteStringStrict → ByteStringLazy → Bool strict≟lazy s l = lazy≟lazy (toLazy s) l postulate fromChunks : List ByteStringStrict → ByteStringLazy toChunks : ByteStringLazy → List ByteStringStrict {-# COMPILE GHC fromChunks = (Data.ByteString.Lazy.fromChunks) #-} {-# COMPILE GHC toChunks = (Data.ByteString.Lazy.toChunks) #-}
{ "alphanum_fraction": 0.7332713755, "avg_line_length": 36.4745762712, "ext": "agda", "hexsha": "0629f93ac4df9c419d77e21c5840f2507c979818", "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": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/bytes-agda", "max_forks_repo_path": "src/Data/ByteString/Primitive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "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": "semenov-vladyslav/bytes-agda", "max_issues_repo_path": "src/Data/ByteString/Primitive.agda", "max_line_length": 116, "max_stars_count": null, "max_stars_repo_head_hexsha": "98a53f35fca27e3379cf851a9a6bdfe5bd8c9626", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/bytes-agda", "max_stars_repo_path": "src/Data/ByteString/Primitive.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 621, "size": 2152 }
------------------------------------------------------------------------ -- Integers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Integer {e⁺} (eq : ∀ {a p} → Equality-with-J a p e⁺) where open Derived-definitions-and-properties eq open import Prelude as P hiding (suc) renaming (_+_ to _⊕_; _*_ to _⊛_) open import Bijection eq using (_↔_) open import Equivalence eq as Eq using (_≃_) open import Function-universe eq hiding (_∘_) open import Group eq using (Group; Abelian) open import H-level eq open import H-level.Closure eq import Nat eq as Nat open import Integer.Basics eq public private variable i j : ℤ ------------------------------------------------------------------------ -- Some lemmas -- The sum of i and - i is zero. +-right-inverse : ∀ i → i + - i ≡ + 0 +-right-inverse = λ where (+ zero) → refl _ (+ P.suc n) → lemma n -[1+ n ] → lemma n where lemma : ∀ n → + P.suc n +-[1+ n ] ≡ + 0 lemma n with P.suc n Nat.<= n | T[<=]↔≤ {m = P.suc n} {n = n} … | false | _ = cong (+_) $ Nat.∸≡0 n … | true | eq = ⊥-elim $ Nat.<-irreflexive (_↔_.to eq _) -- The sum of - i and i is zero. +-left-inverse : ∀ i → - i + i ≡ + 0 +-left-inverse i = - i + i ≡⟨ +-comm (- i) ⟩ i + - i ≡⟨ +-right-inverse i ⟩∎ + 0 ∎ -- + 0 is a left identity for addition. +-left-identity : + 0 + i ≡ i +-left-identity {i = + _} = refl _ +-left-identity {i = -[1+ _ ]} = refl _ -- + 0 is a right identity for addition. +-right-identity : i + + 0 ≡ i +-right-identity {i = + _} = cong (+_) Nat.+-right-identity +-right-identity {i = -[1+ _ ]} = refl _ -- Addition is associative. +-assoc : ∀ i {j k} → i + (j + k) ≡ (i + j) + k +-assoc = λ where (+ m) {j = + _} {k = + _} → cong (+_) $ Nat.+-assoc m -[1+ m ] {j = -[1+ n ]} {k = -[1+ o ]} → cong (-[1+_] ∘ P.suc) (m ⊕ P.suc (n ⊕ o) ≡⟨ sym $ Nat.suc+≡+suc m ⟩ P.suc m ⊕ (n ⊕ o) ≡⟨ Nat.+-assoc (P.suc m) ⟩∎ (P.suc m ⊕ n) ⊕ o ∎) -[1+ m ] {j = + n} {k = + o} → sym $ ++-[1+]++ _ n _ (+ m) {j = -[1+ n ]} {k = -[1+ o ]} → sym $ ++-[1+]+-[1+] m _ _ (+ m) {j = + n} {k = -[1+ o ]} → lemma₁ m _ _ (+ m) {j = -[1+ n ]} {k = + o} → lemma₂ m _ _ -[1+ m ] {j = -[1+ n ]} {k = + o} → lemma₃ _ o _ -[1+ m ] {j = + n} {k = -[1+ o ]} → lemma₄ _ n _ where ++-[1+]++ : ∀ m n o → + n +-[1+ m ] + + o ≡ (+ (n ⊕ o) +-[1+ m ]) ++-[1+]++ m zero o = refl _ ++-[1+]++ zero (P.suc n) o = refl _ ++-[1+]++ (P.suc m) (P.suc n) o = ++-[1+]++ m n o ++-[1+]+-[1+] : ∀ m n o → + m +-[1+ n ] + -[1+ o ] ≡ (+ m +-[1+ 1 ⊕ n ⊕ o ]) ++-[1+]+-[1+] zero n o = refl _ ++-[1+]+-[1+] (P.suc m) zero o = refl _ ++-[1+]+-[1+] (P.suc m) (P.suc n) o = ++-[1+]+-[1+] m n o lemma₁ : ∀ m n o → + m + (+ n +-[1+ o ]) ≡ (+ m ⊕ n +-[1+ o ]) lemma₁ m n o = + m + (+ n +-[1+ o ]) ≡⟨ +-comm (+ m) {j = + n +-[1+ o ]} ⟩ (+ n +-[1+ o ]) + + m ≡⟨ ++-[1+]++ _ n _ ⟩ (+ n ⊕ m +-[1+ o ]) ≡⟨ cong +_+-[1+ o ] $ Nat.+-comm n ⟩∎ (+ m ⊕ n +-[1+ o ]) ∎ lemma₂ : ∀ m n o → + m + (+ n +-[1+ o ]) ≡ (+ m +-[1+ o ]) + + n lemma₂ m n o = + m + (+ n +-[1+ o ]) ≡⟨ lemma₁ m n o ⟩ (+ m ⊕ n +-[1+ o ]) ≡⟨ sym $ ++-[1+]++ _ m _ ⟩∎ (+ m +-[1+ o ]) + + n ∎ lemma₃ : ∀ m n o → -[1+ m ] + (+ n +-[1+ o ]) ≡ (+ n +-[1+ 1 ⊕ m ⊕ o ]) lemma₃ m n o = -[1+ m ] + (+ n +-[1+ o ]) ≡⟨ +-comm -[1+ m ] {j = + n +-[1+ o ]} ⟩ (+ n +-[1+ o ]) + -[1+ m ] ≡⟨ ++-[1+]+-[1+] n o m ⟩ (+ n +-[1+ 1 ⊕ o ⊕ m ]) ≡⟨ cong + n +-[1+_] $ cong (1 ⊕_) $ Nat.+-comm o ⟩∎ (+ n +-[1+ 1 ⊕ m ⊕ o ]) ∎ lemma₄ : ∀ m n o → -[1+ m ] + (+ n +-[1+ o ]) ≡ (+ n +-[1+ m ]) + -[1+ o ] lemma₄ m n o = -[1+ m ] + (+ n +-[1+ o ]) ≡⟨ lemma₃ m n o ⟩ (+ n +-[1+ 1 ⊕ m ⊕ o ]) ≡⟨ sym $ ++-[1+]+-[1+] n _ _ ⟩∎ (+ n +-[1+ m ]) + -[1+ o ] ∎ ------------------------------------------------------------------------ -- Successor and predecessor -- The successor function. suc : ℤ → ℤ suc (+ n) = + P.suc n suc -[1+ zero ] = + zero suc -[1+ P.suc n ] = -[1+ n ] -- The successor function adds one to its input. suc≡1+ : ∀ i → suc i ≡ + 1 + i suc≡1+ (+ _) = refl _ suc≡1+ -[1+ zero ] = refl _ suc≡1+ -[1+ P.suc _ ] = refl _ -- The predecessor function. pred : ℤ → ℤ pred (+ zero) = -[1+ zero ] pred (+ P.suc n) = + n pred -[1+ n ] = -[1+ P.suc n ] -- The predecessor function adds minus one to its input. pred≡-1+ : ∀ i → pred i ≡ -[ 1 ] + i pred≡-1+ (+ zero) = refl _ pred≡-1+ (+ P.suc _) = refl _ pred≡-1+ -[1+ _ ] = refl _ -- An equivalence between ℤ and ℤ corresponding to the successor -- function. successor : ℤ ≃ ℤ successor = Eq.↔→≃ suc pred suc-pred pred-suc where suc-pred : ∀ i → suc (pred i) ≡ i suc-pred (+ zero) = refl _ suc-pred (+ P.suc _) = refl _ suc-pred -[1+ _ ] = refl _ pred-suc : ∀ i → pred (suc i) ≡ i pred-suc (+ _) = refl _ pred-suc -[1+ zero ] = refl _ pred-suc -[1+ P.suc _ ] = refl _ ------------------------------------------------------------------------ -- Positive, negative -- The property of being positive. Positive : ℤ → Type Positive (+ zero) = ⊥ Positive (+ P.suc _) = ⊤ Positive -[1+ _ ] = ⊥ -- Positive is propositional. Positive-propositional : Is-proposition (Positive i) Positive-propositional {i = + zero} = ⊥-propositional Positive-propositional {i = + P.suc _} = mono₁ 0 ⊤-contractible Positive-propositional {i = -[1+ _ ]} = ⊥-propositional -- The property of being negative. Negative : ℤ → Type Negative (+ _) = ⊥ Negative -[1+ _ ] = ⊤ -- Negative is propositional. Negative-propositional : Is-proposition (Negative i) Negative-propositional {i = + _} = ⊥-propositional Negative-propositional {i = -[1+ _ ]} = mono₁ 0 ⊤-contractible -- No integer is both positive and negative. ¬+- : Positive i → Negative i → ⊥₀ ¬+- {i = + _} _ neg = neg ¬+- {i = -[1+ _ ]} pos _ = pos -- No integer is both positive and equal to zero. ¬+0 : Positive i → i ≡ + 0 → ⊥₀ ¬+0 {i = + zero} pos _ = pos ¬+0 {i = + P.suc _} _ ≡0 = Nat.0≢+ $ sym $ +-cancellative ≡0 ¬+0 {i = -[1+ _ ]} pos _ = pos -- No integer is both negative and equal to zero. ¬-0 : Negative i → i ≡ + 0 → ⊥₀ ¬-0 {i = + _} neg _ = neg ¬-0 {i = -[1+ _ ]} _ ≡0 = +≢-[1+] $ sym ≡0 -- One can decide if an integer is negative, zero or positive. -⊎0⊎+ : ∀ i → Negative i ⊎ i ≡ + 0 ⊎ Positive i -⊎0⊎+ (+ zero) = inj₂ (inj₁ (refl _)) -⊎0⊎+ (+ P.suc _) = inj₂ (inj₂ _) -⊎0⊎+ -[1+ _ ] = inj₁ _ -- If i and j are positive, then i + j is positive. >0→>0→+>0 : ∀ i j → Positive i → Positive j → Positive (i + j) >0→>0→+>0 (+ P.suc _) (+ P.suc _) _ _ = _ -- If i and j are negative, then i + j is negative. <0→<0→+<0 : ∀ i j → Negative i → Negative j → Negative (i + j) <0→<0→+<0 -[1+ _ ] -[1+ _ ] _ _ = _ ------------------------------------------------------------------------ -- The group of integers -- The group of integers. ℤ-group : Group lzero ℤ-group .Group.Carrier = ℤ ℤ-group .Group.Carrier-is-set = ℤ-set ℤ-group .Group._∘_ = _+_ ℤ-group .Group.id = + 0 ℤ-group .Group._⁻¹ = -_ ℤ-group .Group.left-identity _ = +-left-identity ℤ-group .Group.right-identity _ = +-right-identity ℤ-group .Group.assoc i _ _ = +-assoc i ℤ-group .Group.right-inverse = +-right-inverse ℤ-group .Group.left-inverse = +-left-inverse -- The group of integers is abelian. ℤ-abelian : Abelian ℤ-group ℤ-abelian i _ = +-comm i private module ℤG = Group ℤ-group open ℤG public using () renaming (_^+_ to infixl 7 _*+_; _^_ to infixl 7 _*_) -- + 1 is a left identity for multiplication. *-left-identity : ∀ i → + 1 * i ≡ i *-left-identity = lemma where +lemma : ∀ n → + 1 *+ n ≡ + n +lemma zero = refl _ +lemma (P.suc n) = + 1 + (+ 1) *+ n ≡⟨ cong (λ i → + 1 + i) $ +lemma n ⟩ + 1 + + n ≡⟨⟩ + P.suc n ∎ -lemma : ∀ n → -[ 1 ] *+ n ≡ -[ n ] -lemma zero = refl _ -lemma (P.suc zero) = refl _ -lemma (P.suc (P.suc n)) = -[ 1 ] + -[ 1 ] *+ P.suc n ≡⟨ cong (λ i → -[ 1 ] + i) $ -lemma (P.suc n) ⟩ -[ 1 ] + -[ P.suc n ] ≡⟨⟩ -[ P.suc (P.suc n) ] ∎ lemma : ∀ i → + 1 * i ≡ i lemma (+ n) = +lemma n lemma -[1+ n ] = -lemma (P.suc n) -- _*+ n distributes over addition. *+-distrib-+ : ∀ n → (i + j) *+ n ≡ i *+ n + j *+ n *+-distrib-+ {i = i} n = ℤG.∘^+≡^+∘^+ (+-comm i) n -- If a positive number is multiplied by a positive number, then -- the result is positive. >0→*+suc> : ∀ i m → Positive i → Positive (i *+ P.suc m) >0→*+suc> i zero = Positive i ↝⟨ subst Positive (sym $ ℤG.right-identity i) ⟩ Positive (i + + 0) ↔⟨⟩ Positive (i *+ 1) □ >0→*+suc> i (P.suc m) = Positive i ↝⟨ (λ p → p , >0→*+suc> i m p) ⟩ Positive i × Positive (i *+ P.suc m) ↝⟨ uncurry (>0→>0→+>0 i (i *+ P.suc m)) ⟩ Positive (i + i *+ P.suc m) ↔⟨⟩ Positive (i *+ P.suc (P.suc m)) □ -- If a negative number is multiplied by a positive number, then -- the result is negative. <0→*+suc<0 : ∀ i m → Negative i → Negative (i *+ P.suc m) <0→*+suc<0 i zero = Negative i ↝⟨ subst Negative (sym $ ℤG.right-identity i) ⟩ Negative (i + + 0) ↔⟨⟩ Negative (i *+ 1) □ <0→*+suc<0 i (P.suc m) = Negative i ↝⟨ (λ p → p , <0→*+suc<0 i m p) ⟩ Negative i × Negative (i *+ P.suc m) ↝⟨ uncurry (<0→<0→+<0 i (i *+ P.suc m)) ⟩ Negative (i + i *+ P.suc m) ↔⟨⟩ Negative (i *+ P.suc (P.suc m)) □ ------------------------------------------------------------------------ -- Integer division by two -- Division by two, rounded downwards. ⌊_/2⌋ : ℤ → ℤ ⌊ + n /2⌋ = + Nat.⌊ n /2⌋ ⌊ -[1+ n ] /2⌋ = -[ Nat.⌈ P.suc n /2⌉ ] -- A kind of distributivity property for ⌊_/2⌋ and _+_. ⌊+*+2/2⌋≡ : ∀ i {j} → ⌊ i + j *+ 2 /2⌋ ≡ ⌊ i /2⌋ + j ⌊+*+2/2⌋≡ = λ where (+ m) {j = + n} → cong +_ (Nat.⌊ m ⊕ 2 ⊛ n /2⌋ ≡⟨ cong Nat.⌊_/2⌋ $ Nat.+-comm m ⟩ Nat.⌊ 2 ⊛ n ⊕ m /2⌋ ≡⟨ Nat.⌊2*+/2⌋≡ n ⟩ n ⊕ Nat.⌊ m /2⌋ ≡⟨ Nat.+-comm n ⟩∎ Nat.⌊ m /2⌋ ⊕ n ∎) -[1+ zero ] {j = -[1+ n ]} → cong -[1+_] (Nat.⌈ P.suc (n ⊕ n) /2⌉ ≡⟨ cong (Nat.⌈_/2⌉ ∘ P.suc) $ ⊕-lemma n ⟩ Nat.⌈ 1 ⊕ 2 ⊛ n /2⌉ ≡⟨ cong Nat.⌈_/2⌉ $ Nat.+-comm 1 ⟩ Nat.⌈ 2 ⊛ n ⊕ 1 /2⌉ ≡⟨ Nat.⌈2*+/2⌉≡ n ⟩ n ⊕ Nat.⌈ 1 /2⌉ ≡⟨ Nat.+-comm n ⟩∎ P.suc n ∎) -[1+ P.suc m ] {j = -[1+ n ]} → cong -[1+_] (Nat.⌈ P.suc m ⊕ P.suc (n ⊕ n) /2⌉ ≡⟨ cong (Nat.⌈_/2⌉ ∘ P.suc) $ sym $ Nat.suc+≡+suc m ⟩ P.suc Nat.⌈ m ⊕ (n ⊕ n) /2⌉ ≡⟨ cong (P.suc ∘ Nat.⌈_/2⌉ ∘ (m ⊕_)) $ ⊕-lemma n ⟩ P.suc Nat.⌈ m ⊕ 2 ⊛ n /2⌉ ≡⟨ cong (P.suc ∘ Nat.⌈_/2⌉) $ Nat.+-comm m ⟩ P.suc Nat.⌈ 2 ⊛ n ⊕ m /2⌉ ≡⟨ cong P.suc $ Nat.⌈2*+/2⌉≡ n ⟩ P.suc (n ⊕ Nat.⌈ m /2⌉) ≡⟨ cong P.suc $ Nat.+-comm n ⟩∎ P.suc (Nat.⌈ m /2⌉ ⊕ n) ∎) (+ m) {j = -[1+ n ]} → ⌊ + m +-[1+ P.suc (n ⊕ n) ] /2⌋ ≡⟨ cong (λ n → ⌊ + m +-[1+ P.suc n ] /2⌋) $ ⊕-lemma n ⟩ ⌊ + m +-[1+ P.suc (2 ⊛ n) ] /2⌋ ≡⟨ lemma₁ m n ⟩∎ + Nat.⌊ m /2⌋ +-[1+ n ] ∎ -[1+ 0 ] {j = + 0} → -[ 1 ] ≡⟨⟩ -[ 1 ] ∎ -[1+ 0 ] {j = + P.suc n} → cong +_ (Nat.⌊ n ⊕ P.suc (n ⊕ 0) /2⌋ ≡⟨ cong Nat.⌊_/2⌋ $ sym $ Nat.suc+≡+suc n ⟩ Nat.⌊ 1 ⊕ 2 ⊛ n /2⌋ ≡⟨ Nat.⌊1+2*/2⌋≡ n ⟩∎ n ∎) -[1+ P.suc m ] {j = + n} → ⌊ + 2 ⊛ n +-[1+ P.suc m ] /2⌋ ≡⟨ lemma₂ m n ⟩∎ + n +-[1+ Nat.⌈ m /2⌉ ] ∎ where ⊕-lemma : ∀ n → n ⊕ n ≡ 2 ⊛ n ⊕-lemma n = cong (n ⊕_) $ sym Nat.+-right-identity lemma₁ : ∀ m n → ⌊ + m +-[1+ P.suc (2 ⊛ n) ] /2⌋ ≡ + Nat.⌊ m /2⌋ +-[1+ n ] lemma₁ zero n = cong -[1+_] (Nat.⌈ 2 ⊛ n /2⌉ ≡⟨ Nat.⌈2*/2⌉≡ n ⟩∎ n ∎) lemma₁ (P.suc zero) n = -[ Nat.⌈ 1 ⊕ 2 ⊛ n /2⌉ ] ≡⟨ cong -[_] $ Nat.⌈1+2*/2⌉≡ n ⟩∎ -[1+ n ] ∎ lemma₁ (P.suc (P.suc m)) zero = ⌊ + m /2⌋ ≡⟨⟩ + Nat.⌊ m /2⌋ ∎ lemma₁ (P.suc (P.suc m)) (P.suc n) = ⌊ + m +-[1+ n ⊕ P.suc (n ⊕ 0) ] /2⌋ ≡⟨ cong (⌊_/2⌋ ∘ + m +-[1+_]) $ sym $ Nat.suc+≡+suc n ⟩ ⌊ + m +-[1+ P.suc (2 ⊛ n) ] /2⌋ ≡⟨ lemma₁ m n ⟩∎ + Nat.⌊ m /2⌋ +-[1+ n ] ∎ mutual lemma₂ : ∀ m n → ⌊ + 2 ⊛ n +-[1+ P.suc m ] /2⌋ ≡ + n +-[1+ Nat.⌈ m /2⌉ ] lemma₂ m zero = ⌊ -[1+ P.suc m ] /2⌋ ≡⟨⟩ -[1+ Nat.⌈ m /2⌉ ] ∎ lemma₂ m (P.suc n) = ⌊ + n ⊕ P.suc (n ⊕ 0) +-[1+ m ] /2⌋ ≡⟨ cong (⌊_/2⌋ ∘ +_+-[1+ m ]) $ sym $ Nat.suc+≡+suc n ⟩ ⌊ + P.suc (2 ⊛ n) +-[1+ m ] /2⌋ ≡⟨ lemma₃ m n ⟩∎ + P.suc n +-[1+ Nat.⌈ m /2⌉ ] ∎ lemma₃ : ∀ m n → ⌊ + P.suc (2 ⊛ n) +-[1+ m ] /2⌋ ≡ + P.suc n +-[1+ Nat.⌈ m /2⌉ ] lemma₃ zero n = cong +_ (Nat.⌊ 2 ⊛ n /2⌋ ≡⟨ Nat.⌊2*/2⌋≡ n ⟩∎ n ∎) lemma₃ (P.suc zero) zero = -[ 1 ] ≡⟨⟩ -[ 1 ] ∎ lemma₃ (P.suc zero) (P.suc n) = cong +_ (Nat.⌊ n ⊕ P.suc (n ⊕ zero) /2⌋ ≡⟨ cong Nat.⌊_/2⌋ $ sym $ Nat.suc+≡+suc n ⟩ Nat.⌊ 1 ⊕ 2 ⊛ n /2⌋ ≡⟨ Nat.⌊1+2*/2⌋≡ n ⟩∎ n ∎) lemma₃ (P.suc (P.suc m)) n = ⌊ + 2 ⊛ n +-[1+ P.suc m ] /2⌋ ≡⟨ lemma₂ m n ⟩∎ + n +-[1+ Nat.⌈ m /2⌉ ] ∎ -- If you double and then halve an integer, then you get back what you -- started with. ⌊*+2/2⌋≡ : ∀ i → ⌊ i *+ 2 /2⌋ ≡ i ⌊*+2/2⌋≡ i = ⌊ i *+ 2 /2⌋ ≡⟨ cong ⌊_/2⌋ $ sym $ +-left-identity {i = i *+ 2} ⟩ ⌊ + 0 + i *+ 2 /2⌋ ≡⟨ ⌊+*+2/2⌋≡ (+ 0) {j = i} ⟩ ⌊ + 0 /2⌋ + i ≡⟨⟩ + 0 + i ≡⟨ +-left-identity ⟩∎ i ∎
{ "alphanum_fraction": 0.4047038577, "avg_line_length": 31.5520361991, "ext": "agda", "hexsha": "41d5ee072c55102d3ac4ce8f2a3046cb1fef0f8e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Integer.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Integer.agda", "max_line_length": 98, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Integer.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 6536, "size": 13946 }
open import Coinduction using ( ♯_ ) open import Data.Bool using ( Bool ; true ; false ; not ) open import Data.ByteString using ( null ) renaming ( span to #span ) open import Data.Natural using ( Natural ) open import Data.Product using ( _×_ ; _,_ ) open import Data.Word using ( Byte ) open import System.IO.Transducers.Lazy using ( _⇒_ ; inp ; out ; done ; _⟫_ ; π₁ ; π₂ ; _[&]_ ) open import System.IO.Transducers.Weight using ( weight ) open import System.IO.Transducers.Stateful using ( loop ) open import System.IO.Transducers.Session using ( ⟨_⟩ ; _&_ ; ¿ ; * ; _&*_ ) open import System.IO.Transducers.Strict using ( _⇛_ ) module System.IO.Transducers.Bytes where open System.IO.Transducers.Session public using ( Bytes ; Bytes' ) mutual span' : (Byte → Bool) → Bytes' ⇛ (Bytes & Bytes) span' φ x with #span φ x span' φ x | (x₁ , x₂) with null x₁ | null x₂ span' φ x | (x₁ , x₂) | true | true = inp (♯ span φ) span' φ x | (x₁ , x₂) | true | false = out false (out true (out x₂ done)) span' φ x | (x₁ , x₂) | false | true = out true (out x₁ (inp (♯ span φ))) span' φ x | (x₁ , x₂) | false | false = out true (out x₁ (out false (out true (out x₂ done)))) span : (Byte → Bool) → Bytes ⇛ (Bytes & Bytes) span φ false = out false (out false done) span φ true = inp (♯ span' φ) break : (Byte → Bool) → Bytes ⇛ (Bytes & Bytes) break φ = span (λ x → not (φ x)) mutual nonempty' : Bytes' & Bytes ⇛ ¿ Bytes & Bytes nonempty' x with null x nonempty' x | true = inp (♯ nonempty) nonempty' x | false = out true (out true (out x done)) nonempty : Bytes & Bytes ⇛ ¿ Bytes & Bytes nonempty true = inp (♯ nonempty') nonempty false = out false done split? : (Byte → Bool) → Bytes ⇒ (¿ Bytes & Bytes) split? φ = inp (♯ span φ) ⟫ π₂ {Bytes} ⟫ inp (♯ break φ) ⟫ inp (♯ nonempty) split : (Byte → Bool) → Bytes ⇒ * Bytes split φ = loop {Bytes} (split? φ) ⟫ π₁ bytes : Bytes ⇒ ⟨ Natural ⟩ bytes = weight
{ "alphanum_fraction": 0.6266050334, "avg_line_length": 36.7358490566, "ext": "agda", "hexsha": "3044004f66adc0053010d8b4016de52087a34aa3", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z", "max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z", "max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/System/IO/Transducers/Bytes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "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": "ilya-fiveisky/agda-system-io", "max_issues_repo_path": "src/System/IO/Transducers/Bytes.agda", "max_line_length": 96, "max_stars_count": 10, "max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ilya-fiveisky/agda-system-io", "max_stars_repo_path": "src/System/IO/Transducers/Bytes.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z", "num_tokens": 641, "size": 1947 }
-- Andreas, 2016-02-02 added Ambiguous module Issue480 where module Simple where data Q : Set where a : Q f : _ → Q f a = a postulate helper : ∀ {T : Set} → (T → T) → Q test₁ : Q → Q test₁ = λ { a → a } test₂ : Q test₂ = helper test₁ -- Same as test₂ and test₁, but stuck together. test₃ : Q test₃ = helper λ { a → a } -- this says "Type mismatch when checking that the pattern a has type _45" module Ambiguous where data Q : Set where a : Q data Overlap : Set where a : Overlap postulate helper : ∀ {T : Set} → (T → T) → T -- result type needs to be propagated test₁ : Q → Q test₁ = λ { a → a } test₃ : Q test₃ = helper λ { a → a } _$_ : ∀ {T : Set} → (T → T) → T → T f $ x = f x test : Q test = (λ { a → a }) $ a test₂ : _ test₂ = (λ { a → a }) $ Q.a module Example where infixr 5 _∷_ data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ data List : Set₁ where [] : List _∷_ : Set → List → List data Tree (L : Set) : List → Set₁ where tip : Tree L [] node : ∀ {T Ts} → (cs : T → Tree L Ts) → Tree L (T ∷ Ts) data Q (n : ℕ) : Set where a : Q n b : Q n test₁ : Q zero → Tree ℕ (Q zero ∷ []) test₁ = λ { a → node λ { a → tip ; b → tip } ; b → node λ { a → tip ; b → tip } } test₂ = node test₁ test₃ : Tree ℕ (Q zero ∷ Q zero ∷ []) test₃ = node λ { a → node λ { a → tip ; b → tip } ; b → node λ { a → tip ; b → tip } }
{ "alphanum_fraction": 0.49932341, "avg_line_length": 17.5952380952, "ext": "agda", "hexsha": "5732a40ace6430d9dfbaeb7b4d68cff2f318b054", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Succeed/Issue480.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Succeed/Issue480.agda", "max_line_length": 103, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/Issue480.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": 567, "size": 1478 }
{-# OPTIONS --guardedness #-} module Builtin.Coinduction where open import Agda.Builtin.Coinduction public
{ "alphanum_fraction": 0.787037037, "avg_line_length": 21.6, "ext": "agda", "hexsha": "e7478a7e51afae45ecd213e0e2c997cc0d7269bf", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "d704381936db6bd393e63aa2740345e7364f9732", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "UlfNorell/agda-prelude", "max_forks_repo_path": "src/Builtin/Coinduction.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "d704381936db6bd393e63aa2740345e7364f9732", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "UlfNorell/agda-prelude", "max_issues_repo_path": "src/Builtin/Coinduction.agda", "max_line_length": 43, "max_stars_count": 111, "max_stars_repo_head_hexsha": "d704381936db6bd393e63aa2740345e7364f9732", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UlfNorell/agda-prelude", "max_stars_repo_path": "src/Builtin/Coinduction.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 25, "size": 108 }
module FFI.Data.Either where {-# FOREIGN GHC import qualified Data.Either #-} data Either (A B : Set) : Set where Left : A → Either A B Right : B → Either A B {-# COMPILE GHC Either = data Data.Either.Either (Data.Either.Left|Data.Either.Right) #-} swapLR : ∀ {A B} → Either A B → Either B A swapLR (Left x) = Right x swapLR (Right x) = Left x mapL : ∀ {A B C} → (A → B) → Either A C → Either B C mapL f (Left x) = Left (f x) mapL f (Right x) = Right x mapR : ∀ {A B C} → (B → C) → Either A B → Either A C mapR f (Left x) = Left x mapR f (Right x) = Right (f x) mapLR : ∀ {A B C D} → (A → B) → (C → D) → Either A C → Either B D mapLR f g (Left x) = Left (f x) mapLR f g (Right x) = Right (g x) cond : ∀ {A B C : Set} → (A → C) → (B → C) → (Either A B) → C cond f g (Left x) = f x cond f g (Right x) = g x
{ "alphanum_fraction": 0.5698529412, "avg_line_length": 28.1379310345, "ext": "agda", "hexsha": "8a5d3e6655a47f74c8514c7947dc52f9f6d41ca7", "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": "72d8d443431875607fd457a13fe36ea62804d327", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "TheGreatSageEqualToHeaven/luau", "max_forks_repo_path": "prototyping/FFI/Data/Either.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "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": "TheGreatSageEqualToHeaven/luau", "max_issues_repo_path": "prototyping/FFI/Data/Either.agda", "max_line_length": 89, "max_stars_count": 1, "max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TheGreatSageEqualToHeaven/luau", "max_stars_repo_path": "prototyping/FFI/Data/Either.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z", "num_tokens": 316, "size": 816 }
-- Andreas, 2018-10-27, issue #3324 reported by Guillaume Brunerie -- Missing 'reduce' leads to arbitrary rejection of pattern matching on props {-# OPTIONS --prop #-} -- {-# OPTIONS -v tc.cover:60 #-} data Unit : Prop where tt : Unit -- Works f : {A : Set} → Unit → Unit f tt = tt -- Should work g : Unit → Unit g tt = tt
{ "alphanum_fraction": 0.6393939394, "avg_line_length": 18.3333333333, "ext": "agda", "hexsha": "eecd10ae84ea0729cc08c0ec326d9cf02c6f9bba", "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/Issue3324.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/Issue3324.agda", "max_line_length": 77, "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/Issue3324.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 99, "size": 330 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Transitive closures ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Binary.Construct.Closure.Transitive where open import Function open import Function.Equivalence as Equiv using (_⇔_) open import Level open import Relation.Binary open import Relation.Binary.PropositionalEquality using (_≡_ ; refl) ------------------------------------------------------------------------ -- Transitive closure infix 4 Plus syntax Plus R x y = x [ R ]⁺ y data Plus {a ℓ} {A : Set a} (_∼_ : Rel A ℓ) : Rel A (a ⊔ ℓ) where [_] : ∀ {x y} (x∼y : x ∼ y) → x [ _∼_ ]⁺ y _∼⁺⟨_⟩_ : ∀ x {y z} (x∼⁺y : x [ _∼_ ]⁺ y) (y∼⁺z : y [ _∼_ ]⁺ z) → x [ _∼_ ]⁺ z module _ {a ℓ} {A : Set a} {_∼_ : Rel A ℓ} where []-injective : ∀ {x y p q} → (x [ _∼_ ]⁺ y ∋ [ p ]) ≡ [ q ] → p ≡ q []-injective refl = refl -- See also ∼⁺⟨⟩-injectiveˡ and ∼⁺⟨⟩-injectiveʳ in -- Relation.Binary.Construct.Closure.Transitive.WithK. -- "Equational" reasoning notation. Example: -- -- lemma = -- x ∼⁺⟨ [ lemma₁ ] ⟩ -- y ∼⁺⟨ lemma₂ ⟩∎ -- z ∎ finally : ∀ {a ℓ} {A : Set a} {_∼_ : Rel A ℓ} x y → x [ _∼_ ]⁺ y → x [ _∼_ ]⁺ y finally _ _ = id syntax finally x y x∼⁺y = x ∼⁺⟨ x∼⁺y ⟩∎ y ∎ infixr 2 _∼⁺⟨_⟩_ infix 3 finally -- Map. map : ∀ {a a′ ℓ ℓ′} {A : Set a} {A′ : Set a′} {_R_ : Rel A ℓ} {_R′_ : Rel A′ ℓ′} {f : A → A′} → _R_ =[ f ]⇒ _R′_ → Plus _R_ =[ f ]⇒ Plus _R′_ map R⇒R′ [ xRy ] = [ R⇒R′ xRy ] map R⇒R′ (x ∼⁺⟨ xR⁺z ⟩ zR⁺y) = _ ∼⁺⟨ map R⇒R′ xR⁺z ⟩ map R⇒R′ zR⁺y ------------------------------------------------------------------------ -- Alternative definition of transitive closure -- A generalisation of Data.List.Nonempty.List⁺. infixr 5 _∷_ _++_ infix 4 Plus′ syntax Plus′ R x y = x ⟨ R ⟩⁺ y data Plus′ {a ℓ} {A : Set a} (_∼_ : Rel A ℓ) : Rel A (a ⊔ ℓ) where [_] : ∀ {x y} (x∼y : x ∼ y) → x ⟨ _∼_ ⟩⁺ y _∷_ : ∀ {x y z} (x∼y : x ∼ y) (y∼⁺z : y ⟨ _∼_ ⟩⁺ z) → x ⟨ _∼_ ⟩⁺ z -- Transitivity. _++_ : ∀ {a ℓ} {A : Set a} {_∼_ : Rel A ℓ} {x y z} → x ⟨ _∼_ ⟩⁺ y → y ⟨ _∼_ ⟩⁺ z → x ⟨ _∼_ ⟩⁺ z [ x∼y ] ++ y∼⁺z = x∼y ∷ y∼⁺z (x∼y ∷ y∼⁺z) ++ z∼⁺u = x∼y ∷ (y∼⁺z ++ z∼⁺u) -- Plus and Plus′ are equivalent. equivalent : ∀ {a ℓ} {A : Set a} {_∼_ : Rel A ℓ} {x y} → Plus _∼_ x y ⇔ Plus′ _∼_ x y equivalent {_∼_ = _∼_} = Equiv.equivalence complete sound where complete : Plus _∼_ ⇒ Plus′ _∼_ complete [ x∼y ] = [ x∼y ] complete (x ∼⁺⟨ x∼⁺y ⟩ y∼⁺z) = complete x∼⁺y ++ complete y∼⁺z sound : Plus′ _∼_ ⇒ Plus _∼_ sound [ x∼y ] = [ x∼y ] sound (x∼y ∷ y∼⁺z) = _ ∼⁺⟨ [ x∼y ] ⟩ sound y∼⁺z
{ "alphanum_fraction": 0.4432765495, "avg_line_length": 28.7395833333, "ext": "agda", "hexsha": "933016059883652f812f8215f3b5773585e989e9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/Transitive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/Transitive.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/Transitive.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1261, "size": 2759 }
------------------------------------------------------------------------ -- Imports every module so that it is easy to see if everything builds ------------------------------------------------------------------------ module Everything where import Parallel import Parallel.Examples import Parallel.Index import Parallel.Lib import RecursiveDescent.Coinductive import RecursiveDescent.Coinductive.Examples import RecursiveDescent.Coinductive.Internal import RecursiveDescent.Coinductive.Lib import RecursiveDescent.Hybrid import RecursiveDescent.Hybrid.Examples import RecursiveDescent.Hybrid.Lib -- import RecursiveDescent.Hybrid.Memoised -- Agda is too slow... import RecursiveDescent.Hybrid.Memoised.Monad import RecursiveDescent.Hybrid.Mixfix hiding (module Expr) -- Necessary due to an Agda bug. import RecursiveDescent.Hybrid.Mixfix.Example import RecursiveDescent.Hybrid.Mixfix.Expr import RecursiveDescent.Hybrid.Mixfix.Fixity import RecursiveDescent.Hybrid.PBM import RecursiveDescent.Hybrid.Simple import RecursiveDescent.Hybrid.Type import RecursiveDescent.Index import RecursiveDescent.Inductive import RecursiveDescent.Inductive.Char import RecursiveDescent.Inductive.Examples import RecursiveDescent.Inductive.Internal import RecursiveDescent.Inductive.Lib import RecursiveDescent.Inductive.Semantics import RecursiveDescent.Inductive.SimpleLib import RecursiveDescent.Inductive.Token import RecursiveDescent.InductiveWithFix import RecursiveDescent.InductiveWithFix.Examples import RecursiveDescent.InductiveWithFix.Internal import RecursiveDescent.InductiveWithFix.Lib import RecursiveDescent.InductiveWithFix.PBM import Utilities
{ "alphanum_fraction": 0.7996368039, "avg_line_length": 38.4186046512, "ext": "agda", "hexsha": "c5c93ba809e480b2a797ed2a3e0c13ae7c9deacf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "misc/Everything.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "misc/Everything.agda", "max_line_length": 72, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "misc/Everything.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 355, "size": 1652 }
open import Prelude open import Prelude.List.Relations.Any open import Prelude.List.Relations.Properties open import Tactic.Deriving.Eq open import Tactic.Reflection module DeriveEqTest where module Test₀ where eqVec : deriveEqType Vec unquoteDef eqVec = deriveEqDef eqVec (quote Vec) module Test₁ where data D (A : Set) (B : A → Set) : Set where c : (x : A) → B x → D A B eqD : {A : Set} {B : A → Set} {{_ : Eq A}} {{_ : {x : A} → Eq (B x)}} (p q : D A B) → Dec (p ≡ q) unquoteDef eqD = deriveEqDef eqD (quote D) module Test₂ where data D (A B : Set) (C : A → B → Set) : B → Set where c : (x : A)(y : B)(z : C x y) → D A B C y eqD : {A B : Set} {C : A → B → Set} {{_ : Eq A}} {{_ : Eq B}} {{_ : ∀ {x y} → Eq (C x y)}} → ∀ {x} (p q : D A B C x) → Dec (p ≡ q) unquoteDef eqD = deriveEqDef eqD (quote D) module Test₃ where data Test : Set where test : {x : Nat} → Vec Nat x → Test instance EqTest : Eq Test EqTest = record { _==_ = eqTest } where eqTest : (p q : Test) → Dec (p ≡ q) unquoteDef eqTest = deriveEqDef eqTest (quote Test) module Test₄ where data Test : Nat → Set where test : (x : Nat) → Test x unquoteDecl EqTest = deriveEq EqTest (quote Test) module Test₅ where data Test (B : Nat → Set) : Set where test : B zero → Test B unquoteDecl EqTest = deriveEq EqTest (quote Test) prf : (x y : Test (Vec Nat)) → Dec (x ≡ y) prf x y = x == y module Test₆ where data Test (A : Set) (xs : List A) (x : A) : Set where test : x ∈ xs → Test A xs x unquoteDecl EqTest = deriveEq EqTest (quote Test) module Issue-#2 where data Test : Set where test : {x : Nat} → Vec Nat x → Test unquoteDecl EqTest = deriveEq EqTest (quote Test) module Issue-#3 where data Test : Nat → Set where test : (x : Nat) → Test x unquoteDecl EqTest = deriveEq EqTest (quote Test)
{ "alphanum_fraction": 0.5683308119, "avg_line_length": 24.7875, "ext": "agda", "hexsha": "d72ab20a57bd8be0ca9cee40e6173ee94d647356", "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": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_path": "test/DeriveEqTest.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "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": "t-more/agda-prelude", "max_issues_repo_path": "test/DeriveEqTest.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_path": "test/DeriveEqTest.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 680, "size": 1983 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.MaybeEmb {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.LogicalRelation import Tools.PropositionalEquality as PE import Data.Nat as Nat -- Any level can be embedded into the highest level. maybeEmb : ∀ {l A r Γ} → Γ ⊩⟨ l ⟩ A ^ r → Γ ⊩⟨ ∞ ⟩ A ^ r maybeEmb {ι ⁰} [A] = emb ∞< (emb emb< [A]) maybeEmb {ι ¹} [A] = emb ∞< [A] maybeEmb {∞} [A] = [A] -- Any level can be embedded into the highest level. maybeEmbTerm : ∀ {l A t r Γ} → ([A] : Γ ⊩⟨ l ⟩ A ^ r) → Γ ⊩⟨ l ⟩ t ∷ A ^ r / [A] → Γ ⊩⟨ ∞ ⟩ t ∷ A ^ r / maybeEmb [A] maybeEmbTerm {ι ⁰} [A] [t] = [t] maybeEmbTerm {ι ¹} [A] [t] = [t] maybeEmbTerm {∞} [A] [t] = [t] -- The lowest level can be embedded in any level. maybeEmb′ : ∀ {l l' A r Γ} → l ≤ l' → Γ ⊩⟨ ι l ⟩ A ^ r → Γ ⊩⟨ ι l' ⟩ A ^ r maybeEmb′ (<is≤ 0<1) [A] = emb emb< [A] maybeEmb′ (≡is≤ PE.refl) [A] = [A] maybeEmb″ : ∀ {l A r Γ} → Γ ⊩⟨ ι ⁰ ⟩ A ^ r → Γ ⊩⟨ l ⟩ A ^ r maybeEmb″ {ι ⁰} [A] = [A] maybeEmb″ {ι ¹} [A] = emb emb< [A] maybeEmb″ {∞} [A] = emb ∞< (emb emb< [A])
{ "alphanum_fraction": 0.5309803922, "avg_line_length": 27.1276595745, "ext": "agda", "hexsha": "9bab37b0f41bb084c72ae500f2a614ffdee7c275", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Properties/MaybeEmb.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Properties/MaybeEmb.agda", "max_line_length": 80, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Properties/MaybeEmb.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 519, "size": 1275 }
{- Descriptor language for easily defining relational structures -} {-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Structures.Relational.Macro where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Structure open import Cubical.Foundations.RelationalStructure open import Cubical.Structures.Relational.Constant open import Cubical.Structures.Relational.Product open import Cubical.Structures.Relational.Maybe open import Cubical.Structures.Relational.Parameterized open import Cubical.Structures.Relational.Pointed open import Cubical.Structures.Relational.UnaryOp open import Cubical.Structures.Macro data RelDesc (ℓ : Level) : Typeω where -- constant structure: X ↦ A constant : ∀ {ℓ'} → hSet ℓ' → RelDesc ℓ -- pointed structure: X ↦ X var : RelDesc ℓ -- join of structures S,T : X ↦ (S X × T X) _,_ : RelDesc ℓ → RelDesc ℓ → RelDesc ℓ -- structure S parameterized by constant A : X ↦ (A → S X) param : ∀ {ℓ'} → (A : Type ℓ') → RelDesc ℓ → RelDesc ℓ -- structure S parameterized by variable argument: X ↦ (X → S X) recvar : RelDesc ℓ → RelDesc ℓ -- Maybe on a structure S: X ↦ Maybe (S X) maybe : RelDesc ℓ → RelDesc ℓ infixr 4 _,_ {- Universe level calculations -} relDesc→Desc : ∀ {ℓ} → RelDesc ℓ → Desc ℓ relDesc→Desc (constant A) = constant (A .fst) relDesc→Desc var = var relDesc→Desc (d₀ , d₁) = relDesc→Desc d₀ , relDesc→Desc d₁ relDesc→Desc (param A d) = param A (relDesc→Desc d) relDesc→Desc (recvar d) = recvar (relDesc→Desc d) relDesc→Desc (maybe d) = maybe (relDesc→Desc d) relMacroStrLevel : ∀ {ℓ} → RelDesc ℓ → Level relMacroStrLevel d = macroStrLevel (relDesc→Desc d) relMacroRelLevel : ∀ {ℓ} → RelDesc ℓ → Level relMacroRelLevel d = macroEquivLevel (relDesc→Desc d) RelMacroStructure : ∀ {ℓ} → (d : RelDesc ℓ) → Type ℓ → Type (relMacroStrLevel d) RelMacroStructure d = MacroStructure (relDesc→Desc d) preservesSetsRelMacro : ∀ {ℓ} → (d : RelDesc ℓ) {X : Type ℓ} → isSet X → isSet (RelMacroStructure d X) preservesSetsRelMacro (constant A) = preservesSetsConstant A preservesSetsRelMacro var = preservesSetsPointed preservesSetsRelMacro (d₀ , d₁) = preservesSetsProduct (preservesSetsRelMacro d₀) (preservesSetsRelMacro d₁) preservesSetsRelMacro (param A d) = preservesSetsParam A (λ _ → preservesSetsRelMacro d) preservesSetsRelMacro (recvar d) = preservesSetsUnaryFun (preservesSetsRelMacro d) preservesSetsRelMacro (maybe d) = preservesSetsMaybe (preservesSetsRelMacro d) -- Notion of structured relation defined by a descriptor RelMacroRelStr : ∀ {ℓ} → (d : RelDesc ℓ) → StrRel {ℓ} (RelMacroStructure d) (relMacroRelLevel d) RelMacroRelStr (constant A) = ConstantRelStr A RelMacroRelStr var = PointedRelStr RelMacroRelStr (d₀ , d₁) = ProductRelStr (RelMacroRelStr d₀) (RelMacroRelStr d₁) RelMacroRelStr (param A d) = ParamRelStr A (λ _ → RelMacroRelStr d) RelMacroRelStr (recvar d) = UnaryFunRelStr (RelMacroRelStr d) RelMacroRelStr (maybe d) = MaybeRelStr (RelMacroRelStr d) -- Proof that structure induced by descriptor is suitable relMacroSuitableRel : ∀ {ℓ} → (d : RelDesc ℓ) → SuitableStrRel _ (RelMacroRelStr d) relMacroSuitableRel (constant A) = constantSuitableRel A relMacroSuitableRel var = pointedSuitableRel relMacroSuitableRel (d₀ , d₁) = productSuitableRel (relMacroSuitableRel d₀) (relMacroSuitableRel d₁) relMacroSuitableRel (param A d) = paramSuitableRel A (λ _ → relMacroSuitableRel d) relMacroSuitableRel (recvar d) = unaryFunSuitableRel (preservesSetsRelMacro d) (relMacroSuitableRel d) relMacroSuitableRel (maybe d) = maybeSuitableRel (relMacroSuitableRel d) -- Proof that structured relations and equivalences agree relMacroMatchesEquiv : ∀ {ℓ} → (d : RelDesc ℓ) → StrRelMatchesEquiv (RelMacroRelStr d) (MacroEquivStr (relDesc→Desc d)) relMacroMatchesEquiv (constant A) = constantRelMatchesEquiv A relMacroMatchesEquiv var = pointedRelMatchesEquiv relMacroMatchesEquiv (d₁ , d₂) = productRelMatchesEquiv (RelMacroRelStr d₁) (RelMacroRelStr d₂) (relMacroMatchesEquiv d₁) (relMacroMatchesEquiv d₂) relMacroMatchesEquiv (param A d) = paramRelMatchesEquiv A (λ _ → RelMacroRelStr d) (λ _ → relMacroMatchesEquiv d) relMacroMatchesEquiv (recvar d) = unaryFunRelMatchesEquiv (RelMacroRelStr d) (relMacroMatchesEquiv d) relMacroMatchesEquiv (maybe d) = maybeRelMatchesEquiv (RelMacroRelStr d) (relMacroMatchesEquiv d) -- Module for easy importing module RelMacro ℓ (d : RelDesc ℓ) where relation = RelMacroRelStr d suitable = relMacroSuitableRel d matches = relMacroMatchesEquiv d open Macro ℓ (relDesc→Desc d) public
{ "alphanum_fraction": 0.7623570041, "avg_line_length": 41.7387387387, "ext": "agda", "hexsha": "ba7a09c3a9032b1ab1737cc52688d81c26f49ccb", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "RobertHarper/cubical", "max_forks_repo_path": "Cubical/Structures/Relational/Macro.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "RobertHarper/cubical", "max_issues_repo_path": "Cubical/Structures/Relational/Macro.agda", "max_line_length": 102, "max_stars_count": null, "max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "RobertHarper/cubical", "max_stars_repo_path": "Cubical/Structures/Relational/Macro.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1459, "size": 4633 }
infix 50 _∼_ postulate A : Set x : A _∼_ : A → A → Set record T : Set where -- This fixity declaration should not be ignored. infix 60 _∘_ _∘_ : A → A → A _∘_ _ _ = x field law : x ∘ x ∼ x -- Some more examples record R : Set₁ where infixl 6 _+_ field _+_ : Set → Set → Set Times : Set → Set → Set Sigma : (A : Set) → (A → Set) → Set One : Set infixl 7 _*_ _*_ = _+_ infixr 3 Σ syntax Σ A (λ a → B) = a ∈ A × B Σ = Sigma field three : One + One * One * One + One pair : x ∈ One × One + One
{ "alphanum_fraction": 0.5115452931, "avg_line_length": 15.2162162162, "ext": "agda", "hexsha": "26fb99f920181d75d239bfb31df0d21d3f985bc8", "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/Issue2634.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/Issue2634.agda", "max_line_length": 51, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2634.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": 236, "size": 563 }
{-# OPTIONS --prop --rewriting #-} open import Examples.Sorting.Sequential.Comparable module Examples.Sorting.Sequential.MergeSort.Merge (M : Comparable) where open Comparable M open import Examples.Sorting.Sequential.Core M open import Calf costMonoid open import Calf.Types.Bool open import Calf.Types.Nat open import Calf.Types.List open import Calf.Types.Eq open import Calf.Types.Bounded costMonoid open import Relation.Nullary open import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl; module ≡-Reasoning) open import Data.Product using (_×_; _,_; ∃; proj₁; proj₂) open import Function open import Data.Nat as Nat using (ℕ; zero; suc; z≤n; s≤s; _+_; _*_) import Data.Nat.Properties as N open import Examples.Sorting.Sequential.MergeSort.Split M merge/clocked : cmp (Π nat λ _ → Π pair λ _ → F (list A)) merge/clocked zero (l₁ , l₂ ) = ret (l₁ ++ l₂) merge/clocked (suc k) ([] , l₂ ) = ret l₂ merge/clocked (suc k) (x ∷ xs , [] ) = ret (x ∷ xs) merge/clocked (suc k) (x ∷ xs , y ∷ ys) = bind (F (list A)) (x ≤ᵇ y) λ b → if b then (bind (F (list A)) (merge/clocked k (xs , y ∷ ys)) (ret ∘ (x ∷_))) else (bind (F (list A)) (merge/clocked k (x ∷ xs , ys)) (ret ∘ (y ∷_))) merge/clocked/correct : ∀ k l₁ l₂ → ◯ (∃ λ l → merge/clocked k (l₁ , l₂) ≡ ret l × (length l₁ + length l₂ Nat.≤ k → Sorted l₁ → Sorted l₂ → SortedOf (l₁ ++ l₂) l)) merge/clocked/correct zero l₁ l₂ u = l₁ ++ l₂ , refl , λ { h [] [] → refl , [] } merge/clocked/correct (suc k) [] l₂ u = l₂ , refl , λ { h [] sorted₂ → refl , sorted₂ } merge/clocked/correct (suc k) (x ∷ xs) [] u = x ∷ xs , refl , λ { h sorted₁ [] → ++-identityʳ (x ∷ xs) , sorted₁ } merge/clocked/correct (suc k) (x ∷ xs) (y ∷ ys) u with h-cost x y merge/clocked/correct (suc k) (x ∷ xs) (y ∷ ys) u | ⇓ b withCost q [ _ , h-eq ] rewrite eq/ref h-eq with ≤ᵇ-reflects-≤ u (Eq.trans (eq/ref h-eq) (step/ext (F bool) (ret b) q u)) merge/clocked/correct (suc k) (x ∷ xs) (y ∷ ys) u | ⇓ false withCost q [ _ , h-eq ] | ofⁿ ¬p = let (l , ≡ , h-sorted) = merge/clocked/correct k (x ∷ xs) ys u in y ∷ l , ( let open ≡-Reasoning in begin step (F (list A)) q (bind (F (list A)) (merge/clocked k (x ∷ xs , ys)) (ret ∘ (y ∷_))) ≡⟨ step/ext (F (list A)) (bind (F (list A)) (merge/clocked k _) _) q u ⟩ bind (F (list A)) (merge/clocked k (x ∷ xs , ys)) (ret ∘ (y ∷_)) ≡⟨ Eq.cong (λ e → bind (F (list A)) e _) ≡ ⟩ ret (y ∷ l) ∎ ) , ( λ { (s≤s h) (h₁ ∷ sorted₁) (h₂ ∷ sorted₂) → let h = Eq.subst (Nat._≤ k) (N.+-suc (length xs) (length ys)) h in let (↭ , sorted) = h-sorted h (h₁ ∷ sorted₁) sorted₂ in ( let open PermutationReasoning in begin (x ∷ xs ++ y ∷ ys) ↭⟨ ++-comm-↭ (x ∷ xs) (y ∷ ys) ⟩ (y ∷ ys ++ x ∷ xs) ≡⟨⟩ y ∷ (ys ++ x ∷ xs) <⟨ ++-comm-↭ ys (x ∷ xs) ⟩ y ∷ (x ∷ xs ++ ys) <⟨ ↭ ⟩ y ∷ l ∎ ) , ( let p = ≰⇒≥ ¬p in All-resp-↭ (↭) (++⁺-All (p ∷ ≤-≤* p h₁) h₂) ∷ sorted ) } ) merge/clocked/correct (suc k) (x ∷ xs) (y ∷ ys) u | ⇓ true withCost q [ _ , h-eq ] | ofʸ p = let (l , ≡ , h-sorted) = merge/clocked/correct k xs (y ∷ ys) u in x ∷ l , ( let open ≡-Reasoning in begin step (F (list A)) q (bind (F (list A)) (merge/clocked k (xs , y ∷ ys)) (ret ∘ (x ∷_))) ≡⟨ step/ext (F (list A)) (bind (F (list A)) (merge/clocked k _) _) q u ⟩ bind (F (list A)) (merge/clocked k (xs , y ∷ ys)) (ret ∘ (x ∷_)) ≡⟨ Eq.cong (λ e → bind (F (list A)) e _) ≡ ⟩ ret (x ∷ l) ∎ ) , ( λ { (s≤s h) (h₁ ∷ sorted₁) (h₂ ∷ sorted₂) → let (↭ , sorted) = h-sorted h sorted₁ (h₂ ∷ sorted₂) in prep x ↭ , All-resp-↭ (↭) (++⁺-All h₁ (p ∷ ≤-≤* p h₂)) ∷ sorted } ) merge/clocked/cost : cmp (Π nat λ _ → Π pair λ _ → cost) merge/clocked/cost zero (l₁ , l₂ ) = zero merge/clocked/cost (suc k) ([] , l₂ ) = zero merge/clocked/cost (suc k) (x ∷ xs , [] ) = zero merge/clocked/cost (suc k) (x ∷ xs , y ∷ ys) = bind cost (x ≤ᵇ y) λ b → 1 + ( if b then (bind cost (merge/clocked k (xs , y ∷ ys)) (λ l → merge/clocked/cost k (xs , y ∷ ys) + 0)) else (bind cost (merge/clocked k (x ∷ xs , ys)) (λ l → merge/clocked/cost k (x ∷ xs , ys) + 0)) ) merge/clocked/cost/closed : cmp (Π nat λ _ → Π pair λ _ → cost) merge/clocked/cost/closed k _ = k merge/clocked/cost≤merge/clocked/cost/closed : ∀ k p → ◯ (merge/clocked/cost k p Nat.≤ merge/clocked/cost/closed k p) merge/clocked/cost≤merge/clocked/cost/closed zero (l₁ , l₂ ) u = N.≤-refl merge/clocked/cost≤merge/clocked/cost/closed (suc k) ([] , l₂ ) u = z≤n merge/clocked/cost≤merge/clocked/cost/closed (suc k) (x ∷ xs , [] ) u = z≤n merge/clocked/cost≤merge/clocked/cost/closed (suc k) (x ∷ xs , y ∷ ys) u with h-cost x y ... | ⇓ false withCost q [ _ , h-eq ] rewrite eq/ref h-eq = let (l , ≡ , _) = merge/clocked/correct k (x ∷ xs) ys u in begin step cost q (1 + bind cost (merge/clocked k (x ∷ xs , ys)) (λ l → merge/clocked/cost k (x ∷ xs , ys) + 0)) ≡⟨ step/ext cost _ q u ⟩ 1 + bind cost (merge/clocked k (x ∷ xs , ys)) (λ l → merge/clocked/cost k (x ∷ xs , ys) + 0) ≡⟨⟩ suc (bind cost (merge/clocked k (x ∷ xs , ys)) (λ l → merge/clocked/cost k (x ∷ xs , ys) + 0)) ≡⟨ Eq.cong (λ e → suc (bind cost e λ l → merge/clocked/cost k (x ∷ xs , ys) + 0)) (≡) ⟩ suc (merge/clocked/cost k (x ∷ xs , ys) + 0) ≡⟨ Eq.cong suc (N.+-identityʳ _) ⟩ suc (merge/clocked/cost k (x ∷ xs , ys)) ≤⟨ s≤s (merge/clocked/cost≤merge/clocked/cost/closed k (x ∷ xs , ys) u) ⟩ suc (merge/clocked/cost/closed k (x ∷ xs , ys)) ≡⟨⟩ suc k ∎ where open ≤-Reasoning ... | ⇓ true withCost q [ _ , h-eq ] rewrite eq/ref h-eq = let (l , ≡ , _) = merge/clocked/correct k xs (y ∷ ys) u in begin step cost q (1 + bind cost (merge/clocked k (xs , y ∷ ys)) (λ l → merge/clocked/cost k (xs , y ∷ ys) + 0)) ≡⟨ step/ext cost _ q u ⟩ 1 + bind cost (merge/clocked k (xs , y ∷ ys)) (λ l → merge/clocked/cost k (xs , y ∷ ys) + 0) ≡⟨⟩ suc (bind cost (merge/clocked k (xs , y ∷ ys)) (λ l → merge/clocked/cost k (xs , y ∷ ys) + 0)) ≡⟨ Eq.cong (λ e → suc (bind cost e λ l → merge/clocked/cost k (xs , y ∷ ys) + 0)) (≡) ⟩ suc (merge/clocked/cost k (xs , y ∷ ys) + 0) ≡⟨ Eq.cong suc (N.+-identityʳ _) ⟩ suc (merge/clocked/cost k (xs , y ∷ ys)) ≤⟨ s≤s (merge/clocked/cost≤merge/clocked/cost/closed k (xs , y ∷ ys) u) ⟩ suc (merge/clocked/cost/closed k (xs , y ∷ ys)) ≡⟨⟩ suc k ∎ where open ≤-Reasoning merge/clocked≤merge/clocked/cost : ∀ k p → IsBounded (list A) (merge/clocked k p) (merge/clocked/cost k p) merge/clocked≤merge/clocked/cost zero (l₁ , l₂ ) = bound/ret merge/clocked≤merge/clocked/cost (suc k) ([] , l₂ ) = bound/ret merge/clocked≤merge/clocked/cost (suc k) (x ∷ xs , [] ) = bound/ret merge/clocked≤merge/clocked/cost (suc k) (x ∷ xs , y ∷ ys) = bound/bind 1 _ (h-cost x y) λ b → bound/bool {p = λ b → if_then_else_ b _ _} b (bound/bind (merge/clocked/cost k (x ∷ xs , ys)) _ (merge/clocked≤merge/clocked/cost k (x ∷ xs , ys)) λ l → bound/ret) (bound/bind (merge/clocked/cost k (xs , y ∷ ys)) _ (merge/clocked≤merge/clocked/cost k (xs , y ∷ ys)) λ l → bound/ret) merge/clocked≤merge/clocked/cost/closed : ∀ k p → IsBounded (list A) (merge/clocked k p) (merge/clocked/cost/closed k p) merge/clocked≤merge/clocked/cost/closed k p = bound/relax (merge/clocked/cost≤merge/clocked/cost/closed k p) (merge/clocked≤merge/clocked/cost k p) merge : cmp (Π pair λ _ → F (list A)) merge (l₁ , l₂) = merge/clocked (length l₁ + length l₂) (l₁ , l₂) merge/correct : ∀ l₁ l₂ → ◯ (∃ λ l → merge (l₁ , l₂) ≡ ret l × (Sorted l₁ → Sorted l₂ → SortedOf (l₁ ++ l₂) l)) merge/correct l₁ l₂ u = let (l , ≡ , h-sorted) = merge/clocked/correct (length l₁ + length l₂) l₁ l₂ u in l , ≡ , h-sorted N.≤-refl merge/cost : cmp (Π pair λ _ → cost) merge/cost (l₁ , l₂) = merge/clocked/cost (length l₁ + length l₂) (l₁ , l₂) merge/cost/closed : cmp (Π pair λ _ → cost) merge/cost/closed (l₁ , l₂) = merge/clocked/cost/closed (length l₁ + length l₂) (l₁ , l₂) merge≤merge/cost : ∀ p → IsBounded (list A) (merge p) (merge/cost p) merge≤merge/cost (l₁ , l₂) = merge/clocked≤merge/clocked/cost (length l₁ + length l₂) (l₁ , l₂) merge≤merge/cost/closed : ∀ p → IsBounded (list A) (merge p) (merge/cost/closed p) merge≤merge/cost/closed (l₁ , l₂) = merge/clocked≤merge/clocked/cost/closed (length l₁ + length l₂) (l₁ , l₂)
{ "alphanum_fraction": 0.5657542225, "avg_line_length": 45.9090909091, "ext": "agda", "hexsha": "acc0042418bd928c7c82e75f1710e86174137ed1", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_path": "src/Examples/Sorting/Sequential/MergeSort/Merge.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "jonsterling/agda-calf", "max_issues_repo_path": "src/Examples/Sorting/Sequential/MergeSort/Merge.agda", "max_line_length": 147, "max_stars_count": 29, "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_path": "src/Examples/Sorting/Sequential/MergeSort/Merge.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "num_tokens": 3503, "size": 8585 }
-- Andreas, 2014-10-18 AIM XX module EvalInTopLevel where data Bool : Set where true false : Bool not : Bool → Bool not true = false not false = true -- Evaluate @not false@ in top level.
{ "alphanum_fraction": 0.703125, "avg_line_length": 16, "ext": "agda", "hexsha": "4c116e40888dd011ed4c6ba5fb821677eae2683d", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/EvalInTopLevel.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/EvalInTopLevel.agda", "max_line_length": 39, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/EvalInTopLevel.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": 56, "size": 192 }
{-# OPTIONS --without-K #-} module PathStructure.UnitNoEta where open import Equivalence open import Types split-path : {x y : Unit} → x ≡ y → Unit split-path _ = tt merge-path : {x y : Unit} → Unit → x ≡ y merge-path _ = 1-elim (λ x → ∀ y → x ≡ y) (1-elim (λ y → tt ≡ y) refl) _ _ split-merge-eq : {x y : Unit} → (x ≡ y) ≃ Unit split-merge-eq = split-path , (merge-path , 1-elim (λ x → tt ≡ x) refl) , (merge-path , J (λ _ _ p → merge-path (split-path p) ≡ p) (1-elim (λ x → merge-path {x} {x} (split-path {x} {x} refl) ≡ refl) refl) _ _)
{ "alphanum_fraction": 0.5425170068, "avg_line_length": 23.52, "ext": "agda", "hexsha": "959abe90a03733996f12b1cd598ae0793ab43009", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_path": "src/PathStructure/UnitNoEta.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_path": "src/PathStructure/UnitNoEta.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_path": "src/PathStructure/UnitNoEta.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 225, "size": 588 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.EilenbergMacLane open import homotopy.EilenbergMacLane1 open import homotopy.EilenbergMacLaneFunctor open import homotopy.EM1HSpaceAssoc open import lib.types.TwoSemiCategory open import lib.two-semi-categories.FunCategory open import lib.two-semi-categories.FundamentalCategory module cohomology.CupProduct.OnEM.InLowDegrees {i} {j} (G : AbGroup i) (H : AbGroup j) where private module G = AbGroup G module H = AbGroup H module G⊗H = TensorProduct G H open G⊗H using (_⊗_) open EMExplicit ⊙×-cp₀₀' : G.⊙El ⊙× H.⊙El ⊙→ G⊗H.⊙El ⊙×-cp₀₀' = uncurry G⊗H._⊗_ , G⊗H.⊗-unit-l H.ident ⊙×-cp₀₀-seq : (⊙EM G 0 ⊙× ⊙EM H 0) ⊙–→ ⊙EM G⊗H.abgroup 0 ⊙×-cp₀₀-seq = ⊙–> (⊙emloop-equiv G⊗H.grp) ◃⊙∘ ⊙×-cp₀₀' ◃⊙∘ ⊙×-fmap (⊙<– (⊙emloop-equiv G.grp)) (⊙<– (⊙emloop-equiv H.grp)) ◃⊙idf ⊙×-cp₀₀ : ⊙EM G 0 ⊙× ⊙EM H 0 ⊙→ ⊙EM G⊗H.abgroup 0 ⊙×-cp₀₀ = ⊙compose ⊙×-cp₀₀-seq ×-cp₀₀ : EM G 0 × EM H 0 → EM G⊗H.abgroup 0 ×-cp₀₀ = fst ⊙×-cp₀₀ open EM₁HSpaceAssoc G⊗H.abgroup hiding (comp-functor) renaming (mult to EM₁-mult) public cp₀₁ : G.El → EM₁ H.grp → EM₁ G⊗H.grp cp₀₁ g = EM₁-fmap (G⊗H.ins-r-hom g) abstract cp₀₁-emloop-β : ∀ g h → ap (cp₀₁ g) (emloop h) == emloop (g ⊗ h) cp₀₁-emloop-β g = EM₁-fmap-emloop-β (G⊗H.ins-r-hom g) cp₀₁-distr-l : (g₁ g₂ : G.El) (y : EM₁ H.grp) → cp₀₁ (G.comp g₁ g₂) y == EM₁-mult (cp₀₁ g₁ y) (cp₀₁ g₂ y) cp₀₁-distr-l g₁ g₂ = EM₁-set-elim {P = λ x → f x == g x} {{λ x → has-level-apply (EM₁-level₁ G⊗H.grp) _ _}} idp loop' where f : EM₁ H.grp → EM₁ G⊗H.grp f x = cp₀₁ (G.comp g₁ g₂) x g : EM₁ H.grp → EM₁ G⊗H.grp g x = EM₁-mult (cp₀₁ g₁ x) (cp₀₁ g₂ x) abstract loop' : (h : H.El) → idp == idp [ (λ x → f x == g x) ↓ emloop h ] loop' h = ↓-='-in {f = f} {g = g} {p = emloop h} {u = idp} {v = idp} $ idp ∙' ap g (emloop h) =⟨ ∙'-unit-l (ap g (emloop h)) ⟩ ap g (emloop h) =⟨ ! (ap2-diag (λ x y → EM₁-mult (cp₀₁ g₁ x) (cp₀₁ g₂ y)) (emloop h)) ⟩ ap2 (λ x y → EM₁-mult (cp₀₁ g₁ x) (cp₀₁ g₂ y)) (emloop h) (emloop h) =⟨ =ₛ-out $ ap2-out (λ x y → EM₁-mult (cp₀₁ g₁ x) (cp₀₁ g₂ y)) (emloop h) (emloop h) ⟩ ap (λ x → EM₁-mult (cp₀₁ g₁ x) embase) (emloop h) ∙ ap (cp₀₁ g₂) (emloop h) =⟨ ap2 _∙_ part (cp₀₁-emloop-β g₂ h) ⟩ emloop (g₁ ⊗ h) ∙ emloop (g₂ ⊗ h) =⟨ ! (emloop-comp (g₁ ⊗ h) (g₂ ⊗ h)) ⟩ emloop (G⊗H.comp (g₁ ⊗ h) (g₂ ⊗ h)) =⟨ ap emloop (! (G⊗H.⊗-lin-l g₁ g₂ h)) ⟩ emloop (G.comp g₁ g₂ ⊗ h) =⟨ ! (cp₀₁-emloop-β (G.comp g₁ g₂) h) ⟩ ap f (emloop h) =⟨ ! (∙-unit-r (ap f (emloop h))) ⟩ ap f (emloop h) ∙ idp =∎ where part : ap (λ x → EM₁-mult (cp₀₁ g₁ x) embase) (emloop h) == emloop (g₁ ⊗ h) part = ap (λ x → EM₁-mult (cp₀₁ g₁ x) embase) (emloop h) =⟨ ap-∘ (λ u → EM₁-mult u embase) (cp₀₁ g₁) (emloop h) ⟩ ap (λ u → EM₁-mult u embase) (ap (cp₀₁ g₁) (emloop h)) =⟨ ap (ap (λ u → EM₁-mult u embase)) (cp₀₁-emloop-β g₁ h) ⟩ ap (λ u → EM₁-mult u embase) (emloop (g₁ ⊗ h)) =⟨ mult-emloop-β (g₁ ⊗ h) embase ⟩ emloop (g₁ ⊗ h) =∎ module _ (g₁ g₂ g₃ : G.El) (y : EM₁ H.grp) where cp₀₁-distr-l₁ : cp₀₁ (G.comp (G.comp g₁ g₂) g₃) y =-= EM₁-mult (cp₀₁ g₁ y) (EM₁-mult (cp₀₁ g₂ y) (cp₀₁ g₃ y)) cp₀₁-distr-l₁ = cp₀₁ (G.comp (G.comp g₁ g₂) g₃) y =⟪ cp₀₁-distr-l (G.comp g₁ g₂) g₃ y ⟫ EM₁-mult (cp₀₁ (G.comp g₁ g₂) y) (cp₀₁ g₃ y) =⟪ ap (λ s → EM₁-mult s (cp₀₁ g₃ y)) (cp₀₁-distr-l g₁ g₂ y) ⟫ EM₁-mult (EM₁-mult (cp₀₁ g₁ y) (cp₀₁ g₂ y)) (cp₀₁ g₃ y) =⟪ H-⊙EM₁-assoc (cp₀₁ g₁ y) (cp₀₁ g₂ y) (cp₀₁ g₃ y) ⟫ EM₁-mult (cp₀₁ g₁ y) (EM₁-mult (cp₀₁ g₂ y) (cp₀₁ g₃ y)) ∎∎ cp₀₁-distr-l₂ : cp₀₁ (G.comp (G.comp g₁ g₂) g₃) y =-= EM₁-mult (cp₀₁ g₁ y) (EM₁-mult (cp₀₁ g₂ y) (cp₀₁ g₃ y)) cp₀₁-distr-l₂ = cp₀₁ (G.comp (G.comp g₁ g₂) g₃) y =⟪ ap (λ s → cp₀₁ s y) (G.assoc g₁ g₂ g₃) ⟫ cp₀₁ (G.comp g₁ (G.comp g₂ g₃)) y =⟪ cp₀₁-distr-l g₁ (G.comp g₂ g₃) y ⟫ EM₁-mult (cp₀₁ g₁ y) (cp₀₁ (G.comp g₂ g₃) y) =⟪ ap (EM₁-mult (cp₀₁ g₁ y)) (cp₀₁-distr-l g₂ g₃ y) ⟫ EM₁-mult (cp₀₁ g₁ y) (EM₁-mult (cp₀₁ g₂ y) (cp₀₁ g₃ y)) ∎∎ abstract cp₀₁-distr-l-coh : (g₁ g₂ g₃ : G.El) (y : EM₁ H.grp) → cp₀₁-distr-l₁ g₁ g₂ g₃ y =ₛ cp₀₁-distr-l₂ g₁ g₂ g₃ y cp₀₁-distr-l-coh g₁ g₂ g₃ = EM₁-prop-elim {P = λ y → cp₀₁-distr-l₁ g₁ g₂ g₃ y =ₛ cp₀₁-distr-l₂ g₁ g₂ g₃ y} {{λ y → =ₛ-level (EM₁-level₁ G⊗H.grp)}} $ idp ◃∙ idp ◃∙ idp ◃∎ =ₛ₁⟨ 0 & 1 & ! (ap-cst embase (G.assoc g₁ g₂ g₃)) ⟩ ap (cst embase) (G.assoc g₁ g₂ g₃) ◃∙ idp ◃∙ idp ◃∎ ∎ₛ cp₀₁-functor : TwoSemiFunctor (group-to-cat G.grp) (fun-cat (EM₁ H.grp) EM₁-2-semi-category) cp₀₁-functor = record { F₀ = λ _ _ → unit ; F₁ = λ g x → cp₀₁ g x ; pres-comp = λ g₁ g₂ → λ= (cp₀₁-distr-l g₁ g₂) ; pres-comp-coh = λ g₁ g₂ g₃ → pres-comp-coh g₁ g₂ g₃ -- TODO: for some reason, this last field takes a really long time to check -- it is recommended to comment it out } where abstract pres-comp-coh : ∀ g₁ g₂ g₃ → λ= (cp₀₁-distr-l (G.comp g₁ g₂) g₃) ◃∙ ap (λ s y → EM₁-mult (s y) (cp₀₁ g₃ y)) (λ= (cp₀₁-distr-l g₁ g₂)) ◃∙ λ= (λ y → H-⊙EM₁-assoc (cp₀₁ g₁ y) (cp₀₁ g₂ y) (cp₀₁ g₃ y)) ◃∎ =ₛ ap (λ s → cp₀₁ s) (G.assoc g₁ g₂ g₃) ◃∙ λ= (cp₀₁-distr-l g₁ (G.comp g₂ g₃)) ◃∙ ap (λ s y → EM₁-mult (cp₀₁ g₁ y) (s y)) (λ= (cp₀₁-distr-l g₂ g₃)) ◃∎ pres-comp-coh g₁ g₂ g₃ = λ= (cp₀₁-distr-l (G.comp g₁ g₂) g₃) ◃∙ ap (λ s y → EM₁-mult (s y) (cp₀₁ g₃ y)) (λ= (cp₀₁-distr-l g₁ g₂)) ◃∙ λ= (λ y → H-⊙EM₁-assoc (cp₀₁ g₁ y) (cp₀₁ g₂ y) (cp₀₁ g₃ y)) ◃∎ =ₛ₁⟨ 1 & 1 & λ=-ap (λ y s → EM₁-mult s (cp₀₁ g₃ y)) (cp₀₁-distr-l g₁ g₂) ⟩ λ= (cp₀₁-distr-l (G.comp g₁ g₂) g₃) ◃∙ λ= (λ y → ap (λ s → EM₁-mult s (cp₀₁ g₃ y)) (cp₀₁-distr-l g₁ g₂ y)) ◃∙ λ= (λ y → H-⊙EM₁-assoc (cp₀₁ g₁ y) (cp₀₁ g₂ y) (cp₀₁ g₃ y)) ◃∎ =ₛ⟨ ∙∙-λ= (cp₀₁-distr-l (G.comp g₁ g₂) g₃) (λ y → ap (λ s → EM₁-mult s (cp₀₁ g₃ y)) (cp₀₁-distr-l g₁ g₂ y)) (λ y → H-⊙EM₁-assoc (cp₀₁ g₁ y) (cp₀₁ g₂ y) (cp₀₁ g₃ y)) ⟩ λ= (λ y → ↯ (cp₀₁-distr-l₁ g₁ g₂ g₃ y)) ◃∎ =ₛ₁⟨ ap λ= (λ= (λ y → =ₛ-out (cp₀₁-distr-l-coh g₁ g₂ g₃ y))) ⟩ λ= (λ y → ↯ (cp₀₁-distr-l₂ g₁ g₂ g₃ y)) ◃∎ =ₛ⟨ λ=-∙∙ (λ y → ap (λ s → cp₀₁ s y) (G.assoc g₁ g₂ g₃)) (cp₀₁-distr-l g₁ (G.comp g₂ g₃)) (λ y → ap (EM₁-mult (cp₀₁ g₁ y)) (cp₀₁-distr-l g₂ g₃ y)) ⟩ λ= (λ y → ap (λ s → cp₀₁ s y) (G.assoc g₁ g₂ g₃)) ◃∙ λ= (cp₀₁-distr-l g₁ (G.comp g₂ g₃)) ◃∙ λ= (λ y → ap (EM₁-mult (cp₀₁ g₁ y)) (cp₀₁-distr-l g₂ g₃ y)) ◃∎ =ₛ₁⟨ 0 & 1 & ap λ= (λ= (λ y → ap-∘ (λ f → f y) cp₀₁ (G.assoc g₁ g₂ g₃))) ⟩ λ= (app= (ap (λ s → cp₀₁ s) (G.assoc g₁ g₂ g₃))) ◃∙ λ= (cp₀₁-distr-l g₁ (G.comp g₂ g₃)) ◃∙ λ= (λ y → ap (EM₁-mult (cp₀₁ g₁ y)) (cp₀₁-distr-l g₂ g₃ y)) ◃∎ =ₛ₁⟨ 0 & 1 & ! (λ=-η (ap (λ s → cp₀₁ s) (G.assoc g₁ g₂ g₃))) ⟩ ap (λ s → cp₀₁ s) (G.assoc g₁ g₂ g₃) ◃∙ λ= (cp₀₁-distr-l g₁ (G.comp g₂ g₃)) ◃∙ λ= (λ y → ap (EM₁-mult (cp₀₁ g₁ y)) (cp₀₁-distr-l g₂ g₃ y)) ◃∎ =ₛ₁⟨ 2 & 1 & ! (λ=-ap (λ y s → EM₁-mult (cp₀₁ g₁ y) s) (cp₀₁-distr-l g₂ g₃)) ⟩ ap (λ s → cp₀₁ s) (G.assoc g₁ g₂ g₃) ◃∙ λ= (cp₀₁-distr-l g₁ (G.comp g₂ g₃)) ◃∙ ap (λ s y → EM₁-mult (cp₀₁ g₁ y) (s y)) (λ= (cp₀₁-distr-l g₂ g₃)) ◃∎ ∎ₛ comp-functor : TwoSemiFunctor EM₁-2-semi-category (=ₜ-fundamental-cat (Susp (EM₁ G⊗H.grp))) comp-functor = record { F₀ = λ _ → [ north ] ; F₁ = λ x → [ η x ] ; pres-comp = comp ; pres-comp-coh = comp-coh } -- this is *exactly* the same as -- `EM₁HSpaceAssoc.comp-functor G⊗H.abgroup` -- inlined but Agda chokes on this shorter definition module _ where private T : TwoSemiCategory (lmax i j) (lmax i j) T = fun-cat (EM₁ H.grp) (=ₜ-fundamental-cat (Susp (EM₁ G⊗H.grp))) module T = TwoSemiCategory T cst-north : T.El cst-north = λ _ → [ north ] T-comp' = T.comp {x = cst-north} {y = cst-north} {z = cst-north} T-assoc' = T.assoc {x = cst-north} {y = cst-north} {z = cst-north} {w = cst-north} group-to-EM₁→EM₂ : TwoSemiFunctor (group-to-cat G.grp) T group-to-EM₁→EM₂ = cp₀₁-functor –F→ fun-functor-map (EM₁ H.grp) comp-functor abstract app=-group-to-EM₁→EM₂-pres-comp-embase : ∀ g₁ g₂ → app= (TwoSemiFunctor.pres-comp group-to-EM₁→EM₂ g₁ g₂) embase == comp embase embase app=-group-to-EM₁→EM₂-pres-comp-embase g₁ g₂ = =ₛ-out $ app= (TwoSemiFunctor.pres-comp group-to-EM₁→EM₂ g₁ g₂) embase ◃∎ =ₛ⟨ ap-seq-=ₛ (λ f → f embase) (comp-functors-pres-comp-β cp₀₁-functor G₁₂ g₁ g₂) ⟩ app= (ap (TwoSemiFunctor.F₁ G₁₂) (TwoSemiFunctor.pres-comp cp₀₁-functor g₁ g₂)) embase ◃∙ app= (TwoSemiFunctor.pres-comp G₁₂ (cp₀₁ g₁) (cp₀₁ g₂)) embase ◃∎ =ₛ⟨ 0 & 1 & =ₛ-in {t = []} $ app= (ap (λ f x → [ η (f x) ]) (λ= (cp₀₁-distr-l g₁ g₂))) embase =⟨ ap (λ w → app= w embase) (λ=-ap (λ _ y → [ η y ]) (cp₀₁-distr-l g₁ g₂)) ⟩ app= (λ= (λ a → ap (λ y → [ η y ]) (cp₀₁-distr-l g₁ g₂ a))) embase =⟨ app=-β (λ a → ap (λ y → [ η y ]) (cp₀₁-distr-l g₁ g₂ a)) embase ⟩ idp =∎ ⟩ app= (TwoSemiFunctor.pres-comp G₁₂ (cp₀₁ g₁) (cp₀₁ g₂)) embase ◃∎ =ₛ₁⟨ app=-β (λ y → comp (cp₀₁ g₁ y) (cp₀₁ g₂ y)) embase ⟩ comp embase embase ◃∎ ∎ₛ where G₁₂ = fun-functor-map (EM₁ H.grp) comp-functor module CP₁₁ where private C : Type (lmax i j) C = EM₁ H.grp → EM G⊗H.abgroup 2 C-level : has-level 2 C C-level = Π-level (λ _ → EM-level G⊗H.abgroup 2) D₀ : TwoSemiCategory lzero i D₀ = group-to-cat G.grp D₁' : TwoSemiCategory (lmax i j) (lmax i j) D₁' = =ₜ-fundamental-cat (Susp (EM₁ G⊗H.grp)) D₁ : TwoSemiCategory (lmax i j) (lmax i j) D₁ = fun-cat (EM₁ H.grp) D₁' D₂' : TwoSemiCategory (lmax i j) (lmax i j) D₂' = 2-type-fundamental-cat (EM G⊗H.abgroup 2) D₂ : TwoSemiCategory (lmax i j) (lmax i j) D₂ = fun-cat (EM₁ H.grp) D₂' D₃ : TwoSemiCategory (lmax i j) (lmax i j) D₃ = 2-type-fundamental-cat (EM₁ H.grp → EM G⊗H.abgroup 2) {{C-level}} F₀₁ : TwoSemiFunctor D₀ D₁ F₀₁ = group-to-EM₁→EM₂ F₁₂' : TwoSemiFunctor D₁' D₂' F₁₂' = =ₜ-to-2-type-fundamental-cat (Susp (EM₁ G⊗H.grp)) F₁₂ : TwoSemiFunctor D₁ D₂ F₁₂ = fun-functor-map (EM₁ H.grp) F₁₂' F₀₂ : TwoSemiFunctor D₀ D₂ F₀₂ = F₀₁ –F→ F₁₂ module F₂₃-Funext = FunextFunctors (EM₁ H.grp) (EM G⊗H.abgroup 2) {{⟨⟩}} F₂₃ : TwoSemiFunctor D₂ D₃ F₂₃ = F₂₃-Funext.λ=-functor module F₀₂ = TwoSemiFunctor F₀₂ module F₂₃ = TwoSemiFunctor F₂₃ private module F₀₃-Comp = FunctorComposition F₀₂ F₂₃ F₀₃ : TwoSemiFunctor D₀ D₃ F₀₃ = F₀₃-Comp.composition module F₀₁ = TwoSemiFunctor F₀₁ module F₁₂ = TwoSemiFunctor F₁₂ module F₁₂' = TwoSemiFunctor F₁₂' module F₀₃ = TwoSemiFunctor F₀₃ module CP₁₁-Rec = EM₁Rec {G = G.grp} {C = C} {{C-level}} F₀₃ abstract cp₁₁ : EM₁ G.grp → EM₁ H.grp → EM G⊗H.abgroup 2 cp₁₁ = CP₁₁-Rec.f cp₁₁-embase-β : cp₁₁ embase ↦ (λ _ → [ north ]) cp₁₁-embase-β = CP₁₁-Rec.embase-β {-# REWRITE cp₁₁-embase-β #-} cp₁₁-emloop-β : ∀ g → ap cp₁₁ (emloop g) == λ= (λ y → ap [_] (η (cp₀₁ g y))) cp₁₁-emloop-β g = CP₁₁-Rec.emloop-β g app=-F₀₂-pres-comp-embase-β : ∀ g₁ g₂ → app= (F₀₂.pres-comp g₁ g₂) embase ◃∎ =ₛ ap (ap [_]) (comp-l embase) ◃∙ ap-∙ [_] (η embase) (η embase) ◃∎ app=-F₀₂-pres-comp-embase-β g₁ g₂ = app= (F₀₂.pres-comp g₁ g₂) embase ◃∎ =ₛ⟨ ap-seq-=ₛ (λ f → f embase) (comp-functors-pres-comp-β F₀₁ F₁₂ g₁ g₂) ⟩ app= (ap (λ α y → <– (=ₜ-equiv [ north ] [ north ]) (α y)) (F₀₁.pres-comp g₁ g₂)) embase ◃∙ app= (F₁₂.pres-comp {x = λ _ → [ north ]} {y = λ _ → [ north ]} {z = λ _ → [ north ]} (λ y → [ η (cp₀₁ g₁ y) ]₁) (λ y → [ η (cp₀₁ g₂ y) ]₁)) embase ◃∎ =ₛ₁⟨ 0 & 1 & step₂ ⟩ ap (ap [_]) (comp-l embase) ◃∙ app= (F₁₂.pres-comp {x = λ _ → [ north ]} {y = λ _ → [ north ]} {z = λ _ → [ north ]} (λ y → [ η (cp₀₁ g₁ y) ]₁) (λ y → [ η (cp₀₁ g₂ y) ]₁)) embase ◃∎ =ₛ₁⟨ 1 & 1 & step₃ ⟩ ap (ap [_]) (comp-l embase) ◃∙ ap-∙ [_] (η embase) (η embase) ◃∎ ∎ₛ where step₂ : app= (ap (λ α y → <– (=ₜ-equiv [ north ] [ north ]) (α y)) (F₀₁.pres-comp g₁ g₂)) embase == ap (ap [_]) (comp-l embase) step₂ = app= (ap (λ α y → <– (=ₜ-equiv [ north ] [ north ]) (α y)) (F₀₁.pres-comp g₁ g₂)) embase =⟨ ∘-ap (λ f → f embase) (λ α y → <– (=ₜ-equiv [ north ] [ north ]) (α y)) (F₀₁.pres-comp g₁ g₂) ⟩ ap (λ α → <– (=ₜ-equiv [ north ] [ north ]) (α embase)) (F₀₁.pres-comp g₁ g₂) =⟨ ap-∘ (<– (=ₜ-equiv [ north ] [ north ])) (λ f → f embase) (F₀₁.pres-comp g₁ g₂) ⟩ ap (<– (=ₜ-equiv [ north ] [ north ])) (app= (F₀₁.pres-comp g₁ g₂) embase) =⟨ ap (ap (<– (=ₜ-equiv [ north ] [ north ]))) (app=-group-to-EM₁→EM₂-pres-comp-embase g₁ g₂) ⟩ ap (<– (=ₜ-equiv [ north ] [ north ])) (comp embase embase) =⟨ ap (ap (<– (=ₜ-equiv [ north ] [ north ]))) (comp-unit-l embase) ⟩ ap (<– (=ₜ-equiv [ north ] [ north ])) (comp-l₁ embase) =⟨ ∘-ap (<– (=ₜ-equiv [ north ] [ north ])) [_]₁ (comp-l embase) ⟩ ap (ap [_]) (comp-l embase) =∎ step₃ : app= (F₁₂.pres-comp {x = λ _ → [ north ]₂} {y = λ _ → [ north ]₂} {z = λ _ → [ north ]₂} (λ y → [ η (cp₀₁ g₁ y) ]₁) (λ y → [ η (cp₀₁ g₂ y) ]₁)) embase == ap-∙ [_] (η embase) (η embase) step₃ = app= (F₁₂.pres-comp {x = λ _ → [ north ]} {y = λ _ → [ north ]} {z = λ _ → [ north ]} (λ y → [ η (cp₀₁ g₁ y) ]₁) (λ y → [ η (cp₀₁ g₂ y) ]₁)) embase =⟨ app=-β (λ y → F₁₂'.pres-comp {x = [ north ]} {y = [ north ]} {z = [ north ]} [ η (cp₀₁ g₁ y) ]₁ [ η (cp₀₁ g₂ y) ]₁) embase ⟩ F₁₂'.pres-comp {x = [ north ]} {y = [ north ]} {z = [ north ]} [ η embase ]₁ [ η embase ]₁ =⟨ =ₜ-to-2-type-fundamental-cat-pres-comp-β (Susp (EM₁ G⊗H.grp)) (η embase) (η embase) ⟩ ap-∙ [_] (η embase) (η embase) =∎ app=-F₀₂-pres-comp-embase-coh : ∀ g₁ g₂ → app= (F₀₂.pres-comp g₁ g₂) embase ◃∙ ap2 _∙_ (ap (ap [_]) (!-inv-r (merid embase))) (ap (ap [_]) (!-inv-r (merid embase))) ◃∎ =ₛ ap (ap [_]) (!-inv-r (merid embase)) ◃∎ app=-F₀₂-pres-comp-embase-coh g₁ g₂ = app= (F₀₂.pres-comp g₁ g₂) embase ◃∙ ap2 _∙_ (ap (ap [_]) (!-inv-r (merid embase))) (ap (ap [_]) (!-inv-r (merid embase))) ◃∎ =ₛ⟨ 0 & 1 & app=-F₀₂-pres-comp-embase-β g₁ g₂ ⟩ ap (ap [_]) (comp-l embase) ◃∙ ap-∙ [_] (η embase) (η embase) ◃∙ ap2 _∙_ (ap (ap [_]) (!-inv-r (merid embase))) (ap (ap [_]) (!-inv-r (merid embase))) ◃∎ =ₛ₁⟨ 2 & 1 & ap2-ap-lr _∙_ (ap [_]) (ap [_]) (!-inv-r (merid embase)) (!-inv-r (merid embase)) ⟩ ap (ap [_]) (comp-l embase) ◃∙ ap-∙ [_] (η embase) (η embase) ◃∙ ap2 (λ s t → ap [_] s ∙ ap [_] t) (!-inv-r (merid embase)) (!-inv-r (merid embase)) ◃∎ =ₛ⟨ 1 & 2 & !ₛ $ homotopy-naturality2 (λ s t → ap [_] (s ∙ t)) (λ s t → ap [_] s ∙ ap [_] t) (ap-∙ [_]) (!-inv-r (merid embase)) (!-inv-r (merid embase)) ⟩ ap (ap [_]) (comp-l embase) ◃∙ ap2 (λ s t → ap [_] (s ∙ t)) (!-inv-r (merid embase)) (!-inv-r (merid embase)) ◃∙ idp ◃∎ =ₛ⟨ 2 & 1 & expand [] ⟩ ap (ap [_]) (comp-l embase) ◃∙ ap2 (λ s t → ap [_] (s ∙ t)) (!-inv-r (merid embase)) (!-inv-r (merid embase)) ◃∎ =ₛ₁⟨ 1 & 1 & ! (ap-ap2 (ap [_]) _∙_ (!-inv-r (merid embase)) (!-inv-r (merid embase))) ⟩ ap (ap [_]) (comp-l embase) ◃∙ ap (ap [_]) (ap2 _∙_ (!-inv-r (merid embase)) (!-inv-r (merid embase))) ◃∎ =ₛ⟨ ap-seq-=ₛ (ap [_]) step₇' ⟩ ap (ap [_]) (!-inv-r (merid embase)) ◃∎ ∎ₛ where helper : ∀ {i} {A : Type i} {a₀ a₁ : A} (p : a₀ == a₁) → add-path-inverse-l (p ∙ ! p) p ◃∙ ap2 _∙_ (!-inv-r p) (!-inv-r p) ◃∎ =ₛ !-inv-r p ◃∎ helper idp = =ₛ-in idp step₇' : comp-l embase ◃∙ ap2 _∙_ (!-inv-r (merid embase)) (!-inv-r (merid embase)) ◃∎ =ₛ !-inv-r (merid embase) ◃∎ step₇' = helper (merid embase) app=-ap-cp₁₁-seq : ∀ g y → app= (ap cp₁₁ (emloop g)) y =-= ap [_] (η (cp₀₁ g y)) app=-ap-cp₁₁-seq g y = app= (ap cp₁₁ (emloop g)) y =⟪ ap (λ p → app= p y) (cp₁₁-emloop-β g) ⟫ app= (λ= (λ x → ap [_] (η (cp₀₁ g x)))) y =⟪ app=-β (λ x → ap [_] (η (cp₀₁ g x))) y ⟫ ap [_] (η (cp₀₁ g y)) ∎∎ app=-ap-cp₁₁ : ∀ g y → app= (ap cp₁₁ (emloop g)) y == ap [_] (η (cp₀₁ g y)) app=-ap-cp₁₁ g y = ↯ (app=-ap-cp₁₁-seq g y) app=-ap-cp₁₁-coh-seq₁ : ∀ g₁ g₂ y → app= (ap cp₁₁ (emloop (G.comp g₁ g₂))) y =-= ap [_] (η (cp₀₁ g₁ y)) ∙ ap [_] (η (cp₀₁ g₂ y)) app=-ap-cp₁₁-coh-seq₁ g₁ g₂ y = app= (ap cp₁₁ (emloop (G.comp g₁ g₂))) y =⟪ ap (λ u → app= (ap cp₁₁ u) y) (emloop-comp g₁ g₂) ⟫ app= (ap cp₁₁ (emloop g₁ ∙ emloop g₂)) y =⟪ ap (λ u → app= u y) (ap-∙ cp₁₁ (emloop g₁) (emloop g₂)) ⟫ app= (ap cp₁₁ (emloop g₁) ∙ ap cp₁₁ (emloop g₂)) y =⟪ ap-∙ (λ f → f y) (ap cp₁₁ (emloop g₁)) (ap cp₁₁ (emloop g₂)) ⟫ app= (ap cp₁₁ (emloop g₁)) y ∙ app= (ap cp₁₁ (emloop g₂)) y =⟪ ap2 _∙_ (app=-ap-cp₁₁ g₁ y) (app=-ap-cp₁₁ g₂ y) ⟫ ap [_] (η (cp₀₁ g₁ y)) ∙ ap [_] (η (cp₀₁ g₂ y)) ∎∎ app=-ap-cp₁₁-coh-seq₂ : ∀ g₁ g₂ y → app= (ap cp₁₁ (emloop (G.comp g₁ g₂))) y =-= ap [_] (η (cp₀₁ g₁ y)) ∙ ap [_] (η (cp₀₁ g₂ y)) app=-ap-cp₁₁-coh-seq₂ g₁ g₂ y = app= (ap cp₁₁ (emloop (G.comp g₁ g₂))) y =⟪ app=-ap-cp₁₁ (G.comp g₁ g₂) y ⟫ ap [_] (η (cp₀₁ (G.comp g₁ g₂) y)) =⟪ app= (F₀₂.pres-comp g₁ g₂) y ⟫ ap [_] (η (cp₀₁ g₁ y)) ∙ ap [_] (η (cp₀₁ g₂ y)) ∎∎ abstract app=-ap-cp₁₁-coh : ∀ g₁ g₂ y → app=-ap-cp₁₁-coh-seq₁ g₁ g₂ y =ₛ app=-ap-cp₁₁-coh-seq₂ g₁ g₂ y app=-ap-cp₁₁-coh g₁ g₂ y = ap (λ u → app= (ap cp₁₁ u) y) (emloop-comp g₁ g₂) ◃∙ ap (λ u → app= u y) (ap-∙ cp₁₁ (emloop g₁) (emloop g₂)) ◃∙ ap-∙ (λ f → f y) (ap cp₁₁ (emloop g₁)) (ap cp₁₁ (emloop g₂)) ◃∙ ap2 _∙_ (app=-ap-cp₁₁ g₁ y) (app=-ap-cp₁₁ g₂ y) ◃∎ =ₛ⟨ 3 & 2 & ap2-seq-∙ _∙_ (app=-ap-cp₁₁-seq g₁ y) (app=-ap-cp₁₁-seq g₂ y) ⟩ ap (λ u → app= (ap cp₁₁ u) y) (emloop-comp g₁ g₂) ◃∙ ap (λ u → app= u y) (ap-∙ cp₁₁ (emloop g₁) (emloop g₂)) ◃∙ ap-∙ (λ f → f y) (ap cp₁₁ (emloop g₁)) (ap cp₁₁ (emloop g₂)) ◃∙ ap2 _∙_ (ap (λ z → app= z y) (cp₁₁-emloop-β g₁)) (ap (λ z → app= z y) (cp₁₁-emloop-β g₂)) ◃∙ ap2 _∙_ (app=-β (λ x → ap [_] (η (cp₀₁ g₁ x))) y) (app=-β (λ x → ap [_] (η (cp₀₁ g₂ x))) y) ◃∎ =ₛ₁⟨ 3 & 1 & ap2-ap-lr _∙_ (λ z → app= z y) (λ z → app= z y) (cp₁₁-emloop-β g₁) (cp₁₁-emloop-β g₂) ⟩ ap (λ u → app= (ap cp₁₁ u) y) (emloop-comp g₁ g₂) ◃∙ ap (λ u → app= u y) (ap-∙ cp₁₁ (emloop g₁) (emloop g₂)) ◃∙ ap-∙ (λ f → f y) (ap cp₁₁ (emloop g₁)) (ap cp₁₁ (emloop g₂)) ◃∙ ap2 (λ a b → app= a y ∙ app= b y) (cp₁₁-emloop-β g₁) (cp₁₁-emloop-β g₂) ◃∙ ap2 _∙_ (app=-β (λ x → ap [_] (η (cp₀₁ g₁ x))) y) (app=-β (λ x → ap [_] (η (cp₀₁ g₂ x))) y) ◃∎ =ₛ⟨ 2 & 2 & !ₛ $ homotopy-naturality2 (λ a b → app= (a ∙ b) y) (λ a b → app= a y ∙ app= b y) (ap-∙ (λ f → f y)) (cp₁₁-emloop-β g₁) (cp₁₁-emloop-β g₂) ⟩ ap (λ u → app= (ap cp₁₁ u) y) (emloop-comp g₁ g₂) ◃∙ ap (λ u → app= u y) (ap-∙ cp₁₁ (emloop g₁) (emloop g₂)) ◃∙ ap2 (λ a b → app= (a ∙ b) y) (cp₁₁-emloop-β g₁) (cp₁₁-emloop-β g₂) ◃∙ ap-∙ (λ f → f y) (λ= (λ y' → ap [_] (η (cp₀₁ g₁ y')))) (λ= (λ y' → ap [_] (η (cp₀₁ g₂ y')))) ◃∙ ap2 _∙_ (app=-β (λ x → ap [_] (η (cp₀₁ g₁ x))) y) (app=-β (λ x → ap [_] (η (cp₀₁ g₂ x))) y) ◃∎ =ₛ⟨ 3 & 2 & app=-β-coh (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x))) y ⟩ ap (λ x → app= (ap cp₁₁ x) y) (emloop-comp g₁ g₂) ◃∙ ap (λ p → app= p y) (ap-∙ cp₁₁ (emloop g₁) (emloop g₂)) ◃∙ ap2 (λ a b → app= (a ∙ b) y) (cp₁₁-emloop-β g₁) (cp₁₁-emloop-β g₂) ◃∙ ap (λ p → app= p y) (=ₛ-out (∙-λ= (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x))))) ◃∙ app=-β (λ x → ap [_] (η (cp₀₁ g₁ x)) ∙ ap [_] (η (cp₀₁ g₂ x))) y ◃∎ =ₛ₁⟨ 0 & 1 & ap-∘ (λ p → app= p y) (ap cp₁₁) (emloop-comp g₁ g₂) ⟩ ap (λ p → app= p y) (ap (ap cp₁₁) (emloop-comp g₁ g₂)) ◃∙ ap (λ p → app= p y) (ap-∙ cp₁₁ (emloop g₁) (emloop g₂)) ◃∙ ap2 (λ a b → app= (a ∙ b) y) (cp₁₁-emloop-β g₁) (cp₁₁-emloop-β g₂) ◃∙ ap (λ p → app= p y) (=ₛ-out (∙-λ= (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x))))) ◃∙ app=-β (λ x → ap [_] (η (cp₀₁ g₁ x)) ∙ ap [_] (η (cp₀₁ g₂ x))) y ◃∎ =ₛ₁⟨ 2 & 1 & ! (ap-ap2 (λ p → app= p y) _∙_ (cp₁₁-emloop-β g₁) (cp₁₁-emloop-β g₂)) ⟩ ap (λ p → app= p y) (ap (ap cp₁₁) (emloop-comp g₁ g₂)) ◃∙ ap (λ p → app= p y) (ap-∙ cp₁₁ (emloop g₁) (emloop g₂)) ◃∙ ap (λ p → app= p y) (ap2 _∙_ (cp₁₁-emloop-β g₁) (cp₁₁-emloop-β g₂)) ◃∙ ap (λ p → app= p y) (=ₛ-out (∙-λ= (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x))))) ◃∙ app=-β (λ x → ap [_] (η (cp₀₁ g₁ x)) ∙ ap [_] (η (cp₀₁ g₂ x))) y ◃∎ =ₛ⟨ 0 & 3 & ap-seq-=ₛ (λ p → app= p y) (CP₁₁-Rec.emloop-comp-path g₁ g₂) ⟩ ap (λ p → app= p y) (cp₁₁-emloop-β (G.comp g₁ g₂)) ◃∙ ap (λ p → app= p y) (F₀₃.pres-comp g₁ g₂) ◃∙ ap (λ p → app= p y) (=ₛ-out (∙-λ= (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x))))) ◃∙ app=-β (λ x → ap [_] (η (cp₀₁ g₁ x)) ∙ ap [_] (η (cp₀₁ g₂ x))) y ◃∎ =ₛ⟨ 1 & 2 & step₈ ⟩ ap (λ p → app= p y) (cp₁₁-emloop-β (G.comp g₁ g₂)) ◃∙ ap (λ p → app= p y) (ap λ= (F₀₂.pres-comp g₁ g₂)) ◃∙ app=-β (λ x → ap [_] (η (cp₀₁ g₁ x)) ∙ ap [_] (η (cp₀₁ g₂ x))) y ◃∎ =ₛ₁⟨ 1 & 1 & ∘-ap (λ p → app= p y) λ= (F₀₂.pres-comp g₁ g₂) ⟩ ap (λ p → app= p y) (cp₁₁-emloop-β (G.comp g₁ g₂)) ◃∙ ap (λ γ → app= (λ= γ) y) (F₀₂.pres-comp g₁ g₂) ◃∙ app=-β (λ x → ap [_] (η (cp₀₁ g₁ x)) ∙ ap [_] (η (cp₀₁ g₂ x))) y ◃∎ =ₛ⟨ 1 & 2 & homotopy-naturality (λ γ → app= (λ= γ) y) (λ γ → γ y) (λ γ → app=-β γ y) (F₀₂.pres-comp g₁ g₂) ⟩ ap (λ p → app= p y) (cp₁₁-emloop-β (G.comp g₁ g₂)) ◃∙ app=-β (λ x → ap [_] (η (cp₀₁ (G.comp g₁ g₂) x))) y ◃∙ app= (F₀₂.pres-comp g₁ g₂) y ◃∎ =ₛ⟨ 0 & 2 & contract ⟩ app=-ap-cp₁₁ (G.comp g₁ g₂) y ◃∙ app= (F₀₂.pres-comp g₁ g₂) y ◃∎ ∎ₛ where step₈ : ap (λ p → app= p y) (F₀₃.pres-comp g₁ g₂) ◃∙ ap (λ p → app= p y) (=ₛ-out (∙-λ= (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x))))) ◃∎ =ₛ ap (λ p → app= p y) (ap λ= (F₀₂.pres-comp g₁ g₂)) ◃∎ step₈ = ap-seq-=ₛ (λ p → app= p y) $ F₀₃.pres-comp g₁ g₂ ◃∙ =ₛ-out (∙-λ= (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x)))) ◃∎ =ₛ⟨ 0 & 1 & F₀₃-Comp.pres-comp-β g₁ g₂ ⟩ ap λ= (F₀₂.pres-comp g₁ g₂) ◃∙ F₂₃.pres-comp (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x))) ◃∙ =ₛ-out (∙-λ= (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x)))) ◃∎ =ₛ₁⟨ 1 & 1 & F₂₃-Funext.λ=-functor-pres-comp=λ=-∙ (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x))) ⟩ ap λ= (F₀₂.pres-comp g₁ g₂) ◃∙ =ₛ-out (λ=-∙ (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x)))) ◃∙ =ₛ-out (∙-λ= (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x)))) ◃∎ =ₛ⟨ 1 & 2 & seq-!-inv-l (=ₛ-out (∙-λ= (λ x → ap [_] (η (cp₀₁ g₁ x))) (λ x → ap [_] (η (cp₀₁ g₂ x)))) ◃∎) ⟩ ap λ= (F₀₂.pres-comp g₁ g₂) ◃∎ ∎ₛ ap-cp₁₁-seq : ∀ g y → ap (λ x → cp₁₁ x y) (emloop g) =-= ap [_] (η (cp₀₁ g y)) ap-cp₁₁-seq g y = ap (λ x → cp₁₁ x y) (emloop g) =⟪ ap-∘ (λ f → f y) cp₁₁ (emloop g) ⟫ ap (λ f → f y) (ap cp₁₁ (emloop g)) =⟪ app=-ap-cp₁₁ g y ⟫ ap [_] (η (cp₀₁ g y)) ∎∎ ap-cp₁₁ : ∀ g y → ap (λ x → cp₁₁ x y) (emloop g) == ap [_] (η (cp₀₁ g y)) ap-cp₁₁ g y = ↯ (ap-cp₁₁-seq g y) ap-cp₁₁-coh-seq₁ : ∀ g₁ g₂ y → ap (λ x → cp₁₁ x y) (emloop (G.comp g₁ g₂)) =-= ap [_] (η (cp₀₁ g₁ y)) ∙ ap [_] (η (cp₀₁ g₂ y)) ap-cp₁₁-coh-seq₁ g₁ g₂ y = ap (λ x → cp₁₁ x y) (emloop (G.comp g₁ g₂)) =⟪ ap (ap (λ x → cp₁₁ x y)) (emloop-comp g₁ g₂) ⟫ ap (λ x → cp₁₁ x y) (emloop g₁ ∙ emloop g₂) =⟪ ap-∙ (λ x → cp₁₁ x y) (emloop g₁) (emloop g₂) ⟫ ap (λ x → cp₁₁ x y) (emloop g₁) ∙ ap (λ x → cp₁₁ x y) (emloop g₂) =⟪ ap2 _∙_ (ap-cp₁₁ g₁ y) (ap-cp₁₁ g₂ y) ⟫ ap [_] (η (cp₀₁ g₁ y)) ∙ ap [_] (η (cp₀₁ g₂ y)) ∎∎ ap-cp₁₁-coh-seq₂ : ∀ g₁ g₂ y → ap (λ x → cp₁₁ x y) (emloop (G.comp g₁ g₂)) =-= ap [_] (η (cp₀₁ g₁ y)) ∙ ap [_] (η (cp₀₁ g₂ y)) ap-cp₁₁-coh-seq₂ g₁ g₂ y = ap (λ x → cp₁₁ x y) (emloop (G.comp g₁ g₂)) =⟪ ap-cp₁₁ (G.comp g₁ g₂) y ⟫ ap [_] (η (cp₀₁ (G.comp g₁ g₂) y)) =⟪ app= (F₀₂.pres-comp g₁ g₂) y ⟫ ap [_] (η (cp₀₁ g₁ y)) ∙ ap [_] (η (cp₀₁ g₂ y)) ∎∎ abstract ap-cp₁₁-coh : ∀ g₁ g₂ y → ap-cp₁₁-coh-seq₁ g₁ g₂ y =ₛ ap-cp₁₁-coh-seq₂ g₁ g₂ y ap-cp₁₁-coh g₁ g₂ y = ap (ap (λ x → cp₁₁ x y)) (emloop-comp g₁ g₂) ◃∙ ap-∙ (λ x → cp₁₁ x y) (emloop g₁) (emloop g₂) ◃∙ ap2 _∙_ (ap-cp₁₁ g₁ y) (ap-cp₁₁ g₂ y) ◃∎ =ₛ⟨ 2 & 1 & ap2-seq-∙ _∙_ (ap-cp₁₁-seq g₁ y) (ap-cp₁₁-seq g₂ y) ⟩ ap (ap (λ x → cp₁₁ x y)) (emloop-comp g₁ g₂) ◃∙ ap-∙ (λ x → cp₁₁ x y) (emloop g₁) (emloop g₂) ◃∙ ap2 _∙_ (ap-∘ (λ f → f y) cp₁₁ (emloop g₁)) (ap-∘ (λ f → f y) cp₁₁ (emloop g₂)) ◃∙ ap2 _∙_ (app=-ap-cp₁₁ g₁ y) (app=-ap-cp₁₁ g₂ y) ◃∎ =ₛ⟨ 1 & 2 & ap-∘-∙-coh (λ f → f y) cp₁₁ (emloop g₁) (emloop g₂) ⟩ ap (ap (λ x → cp₁₁ x y)) (emloop-comp g₁ g₂) ◃∙ ap-∘ (λ f → f y) cp₁₁ (emloop g₁ ∙ emloop g₂) ◃∙ ap (ap (λ f → f y)) (ap-∙ cp₁₁ (emloop g₁) (emloop g₂)) ◃∙ ap-∙ (λ f → f y) (ap cp₁₁ (emloop g₁)) (ap cp₁₁ (emloop g₂)) ◃∙ ap2 _∙_ (app=-ap-cp₁₁ g₁ y) (app=-ap-cp₁₁ g₂ y) ◃∎ =ₛ⟨ 0 & 2 & homotopy-naturality {A = embase' G.grp == embase} {B = cp₁₁ embase y == cp₁₁ embase y} (ap (λ x → cp₁₁ x y)) (λ p → app= (ap cp₁₁ p) y) (ap-∘ (λ f → f y) cp₁₁) (emloop-comp g₁ g₂) ⟩ ap-∘ (λ f → f y) cp₁₁ (emloop (G.comp g₁ g₂)) ◃∙ ap (λ p → app= (ap cp₁₁ p) y) (emloop-comp g₁ g₂) ◃∙ ap (ap (λ f → f y)) (ap-∙ cp₁₁ (emloop g₁) (emloop g₂)) ◃∙ ap-∙ (λ f → f y) (ap cp₁₁ (emloop g₁)) (ap cp₁₁ (emloop g₂)) ◃∙ ap2 _∙_ (app=-ap-cp₁₁ g₁ y) (app=-ap-cp₁₁ g₂ y) ◃∎ =ₛ⟨ 1 & 4 & app=-ap-cp₁₁-coh g₁ g₂ y ⟩ ap-∘ (λ f → f y) cp₁₁ (emloop (G.comp g₁ g₂)) ◃∙ app=-ap-cp₁₁ (G.comp g₁ g₂) y ◃∙ app= (F₀₂.pres-comp g₁ g₂) y ◃∎ =ₛ₁⟨ 0 & 2 & idp ⟩ ap-cp₁₁ (G.comp g₁ g₂) y ◃∙ app= (F₀₂.pres-comp g₁ g₂) y ◃∎ ∎ₛ ap-cp₁₁-embase-seq : ∀ g → ap (λ x → cp₁₁ x embase) (emloop g) =-= idp ap-cp₁₁-embase-seq g = ap (λ x → cp₁₁ x embase) (emloop g) =⟪ ap-cp₁₁ g embase ⟫ ap [_] (η (cp₀₁ g embase)) =⟪idp⟫ ap [_] (η embase) =⟪ ap (ap [_]) (!-inv-r (merid embase)) ⟫ ap [_] (idp {a = north}) =⟪idp⟫ idp ∎∎ ap-cp₁₁-embase : ∀ g → ap (λ x → cp₁₁ x embase) (emloop g) == idp ap-cp₁₁-embase g = ↯ (ap-cp₁₁-embase-seq g) ap-cp₁₁-embase-coh-seq : ∀ g₁ g₂ → ap (λ x → cp₁₁ x embase) (emloop (G.comp g₁ g₂)) =-= idp ap-cp₁₁-embase-coh-seq g₁ g₂ = ap (λ x → cp₁₁ x embase) (emloop (G.comp g₁ g₂)) =⟪ ap (ap (λ x → cp₁₁ x embase)) (emloop-comp g₁ g₂) ⟫ ap (λ x → cp₁₁ x embase) (emloop g₁ ∙ emloop g₂) =⟪ ap-∙ (λ x → cp₁₁ x embase) (emloop g₁) (emloop g₂) ⟫ ap (λ x → cp₁₁ x embase) (emloop g₁) ∙ ap (λ x → cp₁₁ x embase) (emloop g₂) =⟪ ap2 _∙_ (ap-cp₁₁-embase g₁) (ap-cp₁₁-embase g₂) ⟫ idp ∎∎ ap-cp₁₁-embase-coh : ∀ g₁ g₂ → ap-cp₁₁-embase (G.comp g₁ g₂) ◃∎ =ₛ ap-cp₁₁-embase-coh-seq g₁ g₂ ap-cp₁₁-embase-coh g₁ g₂ = ap-cp₁₁-embase (G.comp g₁ g₂) ◃∎ =ₛ⟨ expand (ap-cp₁₁-embase-seq (G.comp g₁ g₂)) ⟩ ap-cp₁₁ (G.comp g₁ g₂) embase ◃∙ ap (ap [_]) (!-inv-r (merid embase)) ◃∎ =ₛ⟨ 1 & 1 & !ₛ (app=-F₀₂-pres-comp-embase-coh g₁ g₂) ⟩ ap-cp₁₁ (G.comp g₁ g₂) embase ◃∙ app= (F₀₂.pres-comp g₁ g₂) embase ◃∙ ap2 _∙_ (ap (ap [_]) (!-inv-r (merid embase))) (ap (ap [_]) (!-inv-r (merid embase))) ◃∎ =ₛ⟨ 0 & 2 & !ₛ (ap-cp₁₁-coh g₁ g₂ embase) ⟩ ap (ap (λ x → cp₁₁ x embase)) (emloop-comp g₁ g₂) ◃∙ ap-∙ (λ x → cp₁₁ x embase) (emloop g₁) (emloop g₂) ◃∙ ap2 _∙_ (ap-cp₁₁ g₁ embase) (ap-cp₁₁ g₂ embase) ◃∙ ap2 _∙_ (ap (ap [_]) (!-inv-r (merid embase))) (ap (ap [_]) (!-inv-r (merid embase))) ◃∎ =ₛ⟨ 2 & 2 & ∙-ap2-seq _∙_ (ap-cp₁₁-embase-seq g₁) (ap-cp₁₁-embase-seq g₂) ⟩ ap (ap (λ x → cp₁₁ x embase)) (emloop-comp g₁ g₂) ◃∙ ap-∙ (λ x → cp₁₁ x embase) (emloop g₁) (emloop g₂) ◃∙ ap2 _∙_ (ap-cp₁₁-embase g₁) (ap-cp₁₁-embase g₂) ◃∎ ∎ₛ open CP₁₁ public
{ "alphanum_fraction": 0.4851759303, "avg_line_length": 45.8421052632, "ext": "agda", "hexsha": "fd59ca1e8e8fd37e1ee0c998863e04aa91a08403", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "theorems/cohomology/CupProduct/OnEM/InLowDegrees.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "theorems/cohomology/CupProduct/OnEM/InLowDegrees.agda", "max_line_length": 123, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "theorems/cohomology/CupProduct/OnEM/InLowDegrees.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": 14856, "size": 29614 }
------------------------------------------------------------------------ -- Strings ------------------------------------------------------------------------ module Data.String where open import Data.List as List using (List) open import Data.Vec as Vec using (Vec) open import Data.Colist as Colist using (Colist) open import Data.Char using (Char) open import Data.Bool using (Bool; true; false) open import Data.Function open import Relation.Nullary open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_) ------------------------------------------------------------------------ -- Types -- Finite strings. postulate String : Set {-# BUILTIN STRING String #-} {-# COMPILED_TYPE String String #-} -- Possibly infinite strings. Costring : Set Costring = Colist Char ------------------------------------------------------------------------ -- Operations private primitive primStringAppend : String → String → String primStringToList : String → List Char primStringFromList : List Char → String primStringEquality : String → String → Bool infixr 5 _++_ _++_ : String → String → String _++_ = primStringAppend toList : String → List Char toList = primStringToList fromList : List Char → String fromList = primStringFromList toVec : (s : String) → Vec Char (List.length (toList s)) toVec s = Vec.fromList (toList s) toCostring : String → Costring toCostring = Colist.fromList ∘ toList infix 4 _==_ _==_ : String → String → Bool _==_ = primStringEquality _≟_ : Decidable {String} _≡_ s₁ ≟ s₂ with s₁ == s₂ ... | true = yes trustMe where postulate trustMe : _ ... | false = no trustMe where postulate trustMe : _ setoid : Setoid setoid = PropEq.setoid String decSetoid : DecSetoid decSetoid = PropEq.decSetoid _≟_
{ "alphanum_fraction": 0.6090351366, "avg_line_length": 23.2857142857, "ext": "agda", "hexsha": "aa697becbed39b70a7749ff731ab6befda56be6b", "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/String.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/String.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/String.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": 428, "size": 1793 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020 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.Prelude open import LibraBFT.Base.ByteString module LibraBFT.Base.Encode where -- An encoder for values of type A is -- an injective mapping of 'A's into 'ByteString's record Encoder {a}(A : Set a) : Set a where constructor mkEncoder field encode : A → ByteString encode-inj : ∀{a₁ a₂} → encode a₁ ≡ encode a₂ → a₁ ≡ a₂ open Encoder {{...}} public ≡-Encoder : ∀ {a} {A : Set a} → Encoder A → DecidableEquality A ≡-Encoder (mkEncoder enc enc-inj) x y with enc x ≟ByteString enc y ...| yes enc≡ = yes (enc-inj enc≡) ...| no neq = no (⊥-elim ∘ neq ∘ cong enc) postulate -- valid assumption instance encℕ : Encoder ℕ encBS : Encoder ByteString instance encFin : {n : ℕ} → Encoder (Fin n) encFin {n} = record { encode = encode ⦃ encℕ ⦄ ∘ toℕ ; encode-inj = toℕ-injective ∘ encode-inj ⦃ encℕ ⦄ }
{ "alphanum_fraction": 0.6482939633, "avg_line_length": 32.6571428571, "ext": "agda", "hexsha": "4f5a85f1465e5490953773b365e3684621a20058", "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": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Base/Encode.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "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": "cwjnkins/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Base/Encode.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "cwjnkins/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Base/Encode.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 368, "size": 1143 }
data U : Set T : U -> Set record V u (t : T u) : Set -- note that u's Set is found by unification
{ "alphanum_fraction": 0.6060606061, "avg_line_length": 19.8, "ext": "agda", "hexsha": "035b58e869b76dfbf2c7129e086369f5a37ef6d6", "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/MissingDefinitionDataOrRec.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/MissingDefinitionDataOrRec.agda", "max_line_length": 71, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/MissingDefinitionDataOrRec.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 35, "size": 99 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Functor.Compose where open import Cubical.Foundations.Prelude open import Cubical.Categories.Category open import Cubical.Categories.Functor.Base open import Cubical.Categories.NaturalTransformation.Base open import Cubical.Categories.Instances.Functors module _ {ℓC ℓC' ℓD ℓD' ℓE ℓE'} {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} (E : Precategory ℓE ℓE') ⦃ isCatE : isCategory E ⦄ (F : Functor C D) where open Functor open NatTrans precomposeF : Functor (FUNCTOR D E) (FUNCTOR C E) precomposeF .F-ob G = funcComp G F precomposeF .F-hom α .N-ob c = α .N-ob (F .F-ob c) precomposeF .F-hom α .N-hom f = α .N-hom (F .F-hom f) precomposeF .F-id = refl precomposeF .F-seq f g = refl module _ {ℓC ℓC' ℓD ℓD' ℓE ℓE'} (C : Precategory ℓC ℓC') {D : Precategory ℓD ℓD'} ⦃ isCatD : isCategory D ⦄ {E : Precategory ℓE ℓE'} ⦃ isCatE : isCategory E ⦄ (G : Functor D E) where open Functor open NatTrans postcomposeF : Functor (FUNCTOR C D) (FUNCTOR C E) postcomposeF .F-ob F = funcComp G F postcomposeF .F-hom α .N-ob c = G. F-hom (α .N-ob c) postcomposeF .F-hom {F₀} {F₁} α .N-hom {x} {y} f = sym (G .F-seq (F₀ ⟪ f ⟫) (α ⟦ y ⟧)) ∙∙ cong (G ⟪_⟫) (α .N-hom f) ∙∙ G .F-seq (α ⟦ x ⟧) (F₁ ⟪ f ⟫) postcomposeF .F-id = makeNatTransPath (funExt λ _ → G .F-id) postcomposeF .F-seq f g = makeNatTransPath (funExt λ _ → G .F-seq _ _)
{ "alphanum_fraction": 0.6479835954, "avg_line_length": 30.4791666667, "ext": "agda", "hexsha": "5f4094dc0dc7d985b9707f489da834e17bfed88d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Edlyr/cubical", "max_forks_repo_path": "Cubical/Categories/Functor/Compose.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Edlyr/cubical", "max_issues_repo_path": "Cubical/Categories/Functor/Compose.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Edlyr/cubical", "max_stars_repo_path": "Cubical/Categories/Functor/Compose.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 600, "size": 1463 }
module NoSuchModule where open X
{ "alphanum_fraction": 0.8235294118, "avg_line_length": 8.5, "ext": "agda", "hexsha": "360da3588805192a112c0137c419b040f8961055", "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/NoSuchModule.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/NoSuchModule.agda", "max_line_length": 25, "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/NoSuchModule.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": 8, "size": 34 }
{- Mapping cones or the homotopy cofiber/cokernel -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.MappingCones.Base where open import Cubical.Foundations.Prelude private variable ℓ ℓ' ℓ'' : Level data Cone {X : Type ℓ} {Y : Type ℓ'} (f : X → Y) : Type (ℓ-max ℓ ℓ') where inj : Y → Cone f hub : Cone f spoke : (x : X) → hub ≡ inj (f x) -- the attachment of multiple mapping cones data Cones {X : Type ℓ} {Y : Type ℓ'} (A : Type ℓ'') (f : A → X → Y) : Type (ℓ-max (ℓ-max ℓ ℓ') ℓ'') where inj : Y → Cones A f hub : A → Cones A f spoke : (a : A) (x : X) → hub a ≡ inj (f a x)
{ "alphanum_fraction": 0.5759493671, "avg_line_length": 23.4074074074, "ext": "agda", "hexsha": "5e92923cd8051b9cd4a094292faacbe3cc5099be", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/HITs/MappingCones/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/MappingCones/Base.agda", "max_line_length": 106, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/MappingCones/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 248, "size": 632 }
module Util.Equality where open import Relation.Binary.PropositionalEquality app-≡ : ∀ {A : Set} {B : A → Set} {f g : (x : A) → B x} (x : A) → f ≡ g → f x ≡ g x app-≡ x refl = refl
{ "alphanum_fraction": 0.5792349727, "avg_line_length": 26.1428571429, "ext": "agda", "hexsha": "726f446a550168ea820d2dd7065939a3b68f88a1", "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": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andreasabel/cubical", "max_forks_repo_path": "src/Util/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "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": "andreasabel/cubical", "max_issues_repo_path": "src/Util/Equality.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "914f655c7c0417754c2ffe494d3f6ea7a357b1c3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andreasabel/cubical", "max_stars_repo_path": "src/Util/Equality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 73, "size": 183 }
{-# OPTIONS --without-K --exact-split --safe #-} module Fragment.Setoid.Morphism.Properties where open import Fragment.Setoid.Morphism.Base open import Fragment.Setoid.Morphism.Setoid open import Level using (Level) open import Relation.Binary using (Setoid) private variable a b c d ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level A : Setoid a ℓ₁ B : Setoid b ℓ₂ C : Setoid c ℓ₃ D : Setoid d ℓ₄ id-unitˡ : ∀ {f : A ↝ B} → id · f ≗ f id-unitˡ {B = B} = Setoid.refl B id-unitʳ : ∀ {f : A ↝ B} → f · id ≗ f id-unitʳ {B = B} = Setoid.refl B ·-assoc : ∀ (h : C ↝ D) (g : B ↝ C) (f : A ↝ B) → (h · g) · f ≗ h · (g · f) ·-assoc {D = D} _ _ _ = Setoid.refl D ·-congˡ : ∀ (h : B ↝ C) (f g : A ↝ B) → f ≗ g → h · f ≗ h · g ·-congˡ h _ _ f≗g = ∣ h ∣-cong f≗g ·-congʳ : ∀ (h : A ↝ B) (f g : B ↝ C) → f ≗ g → f · h ≗ g · h ·-congʳ _ _ _ f≗g = f≗g
{ "alphanum_fraction": 0.509009009, "avg_line_length": 23.3684210526, "ext": "agda", "hexsha": "7e52e558bc5303949bb5b39886f6e4b7db4bb6e7", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Setoid/Morphism/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Setoid/Morphism/Properties.agda", "max_line_length": 48, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Setoid/Morphism/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "num_tokens": 397, "size": 888 }
module Thesis.SIRelBigStep.OpSem where open import Data.Nat open import Thesis.SIRelBigStep.Syntax public data Val : Type → Set import Base.Denotation.Environment open Base.Denotation.Environment Type Val public open import Base.Data.DependentList public data Val where closure : ∀ {Γ σ τ} → (t : Term (σ • Γ) τ) → (ρ : ⟦ Γ ⟧Context) → Val (σ ⇒ τ) natV : ∀ (n : ℕ) → Val nat pairV : ∀ {σ τ} → Val σ → Val τ → Val (pair σ τ) eval-const : ∀ {τ} → Const τ → Val τ eval-const (lit n) = natV n eval : ∀ {Γ τ} (sv : SVal Γ τ) (ρ : ⟦ Γ ⟧Context) → Val τ eval (var x) ρ = ⟦ x ⟧Var ρ eval (abs t) ρ = closure t ρ eval (cons sv1 sv2) ρ = pairV (eval sv1 ρ) (eval sv2 ρ) eval (const c) ρ = eval-const c eval-primitive : ∀ {σ τ} → Primitive (σ ⇒ τ) → Val σ → Val τ eval-primitive succ (natV n) = natV (suc n) eval-primitive add (pairV (natV n1) (natV n2)) = natV (n1 + n2) -- Yann's idea. data HasIdx : Set where true : HasIdx false : HasIdx data Idx : HasIdx → Set where i' : ℕ → Idx true no : Idx false i : {hasIdx : HasIdx} → ℕ → Idx hasIdx i {false} j = no i {true} j = i' j module _ {hasIdx : HasIdx} where data _⊢_↓[_]_ {Γ} (ρ : ⟦ Γ ⟧Context) : ∀ {τ} → Term Γ τ → Idx hasIdx → Val τ → Set where val : ∀ {τ} (sv : SVal Γ τ) → ρ ⊢ val sv ↓[ i 0 ] eval sv ρ primapp : ∀ {σ τ} (p : Primitive (σ ⇒ τ)) (sv : SVal Γ σ) → ρ ⊢ primapp p sv ↓[ i 1 ] eval-primitive p (eval sv ρ) app : ∀ n {Γ′ σ τ ρ′} vtv {v} {vs : SVal Γ (σ ⇒ τ)} {vt : SVal Γ σ} {t : Term (σ • Γ′) τ} → ρ ⊢ val vs ↓[ i 0 ] closure t ρ′ → ρ ⊢ val vt ↓[ i 0 ] vtv → (vtv • ρ′) ⊢ t ↓[ i n ] v → ρ ⊢ app vs vt ↓[ i (suc n) ] v lett : ∀ n1 n2 {σ τ} vsv {v} (s : Term Γ σ) (t : Term (σ • Γ) τ) → ρ ⊢ s ↓[ i n1 ] vsv → (vsv • ρ) ⊢ t ↓[ i n2 ] v → ρ ⊢ lett s t ↓[ i (suc n1 + n2) ] v
{ "alphanum_fraction": 0.5412342982, "avg_line_length": 31.5689655172, "ext": "agda", "hexsha": "c43657202a477da9b598e6035e8d6a605340f0da", "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": "Thesis/SIRelBigStep/OpSem.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": "Thesis/SIRelBigStep/OpSem.agda", "max_line_length": 95, "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": "Thesis/SIRelBigStep/OpSem.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": 796, "size": 1831 }
{-# OPTIONS --safe #-} module Extraction where open import Data.Empty open import Data.Unit open import Data.Product open import Data.Sum open import Data.Maybe open import Relation.Binary.PropositionalEquality open import Relation.Binary.HeterogeneousEquality open import Relation.Nullary open import PiPointedFrac as Pi/ hiding (𝕌; ⟦_⟧; eval) open import PiFracDyn Inj𝕌 : Pi/.𝕌 → 𝕌 Inj𝕌 𝟘 = 𝟘 Inj𝕌 𝟙 = 𝟙 Inj𝕌 (t₁ +ᵤ t₂) = Inj𝕌 t₁ +ᵤ Inj𝕌 t₂ Inj𝕌 (t₁ ×ᵤ t₂) = Inj𝕌 t₁ ×ᵤ Inj𝕌 t₂ Inj𝕌≡ : (t : Pi/.𝕌) → Pi/.⟦ t ⟧ ≡ ⟦ Inj𝕌 t ⟧ Inj𝕌≡ 𝟘 = refl Inj𝕌≡ 𝟙 = refl Inj𝕌≡ (t₁ +ᵤ t₂) rewrite (Inj𝕌≡ t₁) | (Inj𝕌≡ t₂) = refl Inj𝕌≡ (t₁ ×ᵤ t₂) rewrite (Inj𝕌≡ t₁) | (Inj𝕌≡ t₂) = refl Inj⟦𝕌⟧ : {t : Pi/.𝕌} → Pi/.⟦ t ⟧ → ⟦ Inj𝕌 t ⟧ Inj⟦𝕌⟧ {𝟙} tt = tt Inj⟦𝕌⟧ {t₁ +ᵤ t₂} (inj₁ x) = inj₁ (Inj⟦𝕌⟧ x) Inj⟦𝕌⟧ {t₁ +ᵤ t₂} (inj₂ y) = inj₂ (Inj⟦𝕌⟧ y) Inj⟦𝕌⟧ {t₁ ×ᵤ t₂} (x , y) = Inj⟦𝕌⟧ x , Inj⟦𝕌⟧ y Inj⟦𝕌⟧≅ : {t : Pi/.𝕌} (x : Pi/.⟦ t ⟧) → x ≅ Inj⟦𝕌⟧ x Inj⟦𝕌⟧≅ {𝟙} tt = refl Inj⟦𝕌⟧≅ {t₁ +ᵤ t₂} (inj₁ x) = inj1 (Inj𝕌≡ t₂) (Inj⟦𝕌⟧≅ x) where inj1 : {A B A' B' : Set} {x : A} {x' : A'} → B ≡ B' → x ≅ x' → inj₁ {B = B} x ≅ inj₁ {B = B'} x' inj1 refl refl = refl Inj⟦𝕌⟧≅ {t₁ +ᵤ t₂} (inj₂ y) = inj2 (Inj𝕌≡ t₁) (Inj⟦𝕌⟧≅ y) where inj2 : {A B A' B' : Set} {y : B} {y' : B'} → A ≡ A' → y ≅ y' → inj₂ {A = A} y ≅ inj₂ {A = A'} y' inj2 refl refl = refl Inj⟦𝕌⟧≅ {t₁ ×ᵤ t₂} (x , y) = ⦅ Inj⟦𝕌⟧≅ x , Inj⟦𝕌⟧≅ y ⦆ where ⦅_,_⦆ : {A B A' B' : Set} {x : A} {y : B} {x' : A'} {y' : B'} → x ≅ x' → y ≅ y' → (x , y) ≅ (x' , y') ⦅ refl , refl ⦆ = refl Inj⟷ : ∀ {t₁ t₂} → t₁ ⟷ t₂ → Inj𝕌 t₁ ↔ Inj𝕌 t₂ Inj⟷ unite₊l = unite₊l Inj⟷ uniti₊l = uniti₊l Inj⟷ unite₊r = unite₊r Inj⟷ uniti₊r = uniti₊r Inj⟷ swap₊ = swap₊ Inj⟷ assocl₊ = assocl₊ Inj⟷ assocr₊ = assocr₊ Inj⟷ unite⋆l = unite⋆l Inj⟷ uniti⋆l = uniti⋆l Inj⟷ unite⋆r = unite⋆r Inj⟷ uniti⋆r = uniti⋆r Inj⟷ swap⋆ = swap⋆ Inj⟷ assocl⋆ = assocl⋆ Inj⟷ assocr⋆ = assocr⋆ Inj⟷ absorbr = absorbr Inj⟷ absorbl = absorbl Inj⟷ factorzr = factorzr Inj⟷ factorzl = factorzl Inj⟷ dist = dist Inj⟷ factor = factor Inj⟷ distl = distl Inj⟷ factorl = factorl Inj⟷ id⟷ = id↔ Inj⟷ (c₁ ⊚ c₂) = Inj⟷ c₁ ⊚ Inj⟷ c₂ Inj⟷ (c₁ ⊕ c₂) = Inj⟷ c₁ ⊕ Inj⟷ c₂ Inj⟷ (c₁ ⊗ c₂) = Inj⟷ c₁ ⊗ Inj⟷ c₂ Ext𝕌 : ∙𝕌 → Σ[ t ∈ 𝕌 ] ⟦ t ⟧ Ext𝕌 (t # v) = (Inj𝕌 t , Inj⟦𝕌⟧ v) Ext𝕌 (t₁ ∙×ᵤ t₂) with Ext𝕌 t₁ | Ext𝕌 t₂ ... | (t₁' , v₁') | (t₂' , v₂') = t₁' ×ᵤ t₂' , v₁' , v₂' Ext𝕌 (t₁ ∙+ᵤl t₂) with Ext𝕌 t₁ | Ext𝕌 t₂ ... | (t₁' , v₁') | (t₂' , v₂') = t₁' +ᵤ t₂' , inj₁ v₁' Ext𝕌 (t₁ ∙+ᵤr t₂) with Ext𝕌 t₁ | Ext𝕌 t₂ ... | (t₁' , v₁') | (t₂' , v₂') = t₁' +ᵤ t₂' , inj₂ v₂' Ext𝕌 (Singᵤ T) with Ext𝕌 T ... | (t , v) = t , v Ext𝕌 (Recipᵤ T) with Ext𝕌 T ... | (t , v) = 𝟙/ v , ○ Ext∙⟶ : ∀ {t₁ t₂} → t₁ ∙⟶ t₂ → proj₁ (Ext𝕌 t₁) ↔ proj₁ (Ext𝕌 t₂) Ext∙⟶ (∙c c) = Inj⟷ c Ext∙⟶ ∙times# = id↔ Ext∙⟶ ∙#times = id↔ Ext∙⟶ ∙id⟷ = id↔ Ext∙⟶ (c₁ ∙⊚ c₂) = Ext∙⟶ c₁ ⊚ Ext∙⟶ c₂ Ext∙⟶ ∙unite⋆l = unite⋆l Ext∙⟶ ∙uniti⋆l = uniti⋆l Ext∙⟶ ∙unite⋆r = unite⋆r Ext∙⟶ ∙uniti⋆r = uniti⋆r Ext∙⟶ ∙swap⋆ = swap⋆ Ext∙⟶ ∙assocl⋆ = assocl⋆ Ext∙⟶ ∙assocr⋆ = assocr⋆ Ext∙⟶ (c₁ ∙⊗ c₂) = Ext∙⟶ c₁ ⊗ Ext∙⟶ c₂ Ext∙⟶ (c₁ ∙⊕ₗ c₂) = Ext∙⟶ c₁ ⊕ Ext∙⟶ c₂ Ext∙⟶ (c₁ ∙⊕ᵣ c₂) = Ext∙⟶ c₁ ⊕ Ext∙⟶ c₂ Ext∙⟶ (return T) = id↔ Ext∙⟶ (extract T) = id↔ Ext∙⟶ (η T) = η (proj₂ (Ext𝕌 T)) Ext∙⟶ (ε T) = ε (proj₂ (Ext𝕌 T)) Eval≡ : ∀ {t₁ t₂} {v} (c : t₁ ⟷ t₂) → interp (Inj⟷ c) (Inj⟦𝕌⟧ v) ≡ just (Inj⟦𝕌⟧ (Pi/.eval c v)) Eval≡ {_} {_} {inj₂ y} unite₊l = refl Eval≡ {_} {_} {x} uniti₊l = refl Eval≡ {_} {_} {inj₁ x} unite₊r = refl Eval≡ {_} {_} {x} uniti₊r = refl Eval≡ {_} {_} {inj₁ x} swap₊ = refl Eval≡ {_} {_} {inj₂ y} swap₊ = refl Eval≡ {_} {_} {inj₁ x} assocl₊ = refl Eval≡ {_} {_} {inj₂ (inj₁ y)} assocl₊ = refl Eval≡ {_} {_} {inj₂ (inj₂ z)} assocl₊ = refl Eval≡ {_} {_} {inj₁ (inj₁ x)} assocr₊ = refl Eval≡ {_} {_} {inj₁ (inj₂ y)} assocr₊ = refl Eval≡ {_} {_} {inj₂ z} assocr₊ = refl Eval≡ {_} {_} {x} unite⋆l = refl Eval≡ {_} {_} {x} uniti⋆l = refl Eval≡ {_} {_} {x} unite⋆r = refl Eval≡ {_} {_} {x} uniti⋆r = refl Eval≡ {_} {_} {x , y} swap⋆ = refl Eval≡ {_} {_} {x , y , z} assocl⋆ = refl Eval≡ {_} {_} {(x , y) , z} assocr⋆ = refl Eval≡ {_} {_} {inj₁ x , z} dist = refl Eval≡ {_} {_} {inj₂ y , z} dist = refl Eval≡ {_} {_} {inj₁ (x , z)} factor = refl Eval≡ {_} {_} {inj₂ (y , z)} factor = refl Eval≡ {_} {_} {x , inj₁ y} distl = refl Eval≡ {_} {_} {x , inj₂ z} distl = refl Eval≡ {_} {_} {inj₁ (x , y)} factorl = refl Eval≡ {_} {_} {inj₂ (x , z)} factorl = refl Eval≡ {_} {_} {x} id⟷ = refl Eval≡ {_} {_} {x} (c₁ ⊚ c₂) rewrite Eval≡ {v = x} c₁ = Eval≡ c₂ Eval≡ {_} {_} {inj₁ x} (c₁ ⊕ c₂) rewrite Eval≡ {v = x} c₁ = refl Eval≡ {_} {_} {inj₂ y} (c₁ ⊕ c₂) rewrite Eval≡ {v = y} c₂ = refl Eval≡ {_} {_} {x , y} (c₁ ⊗ c₂) rewrite Eval≡ {v = x} c₁ | Eval≡ {v = y} c₂ = refl Ext≡ : ∀ {t₁ t₂} → (c : t₁ ∙⟶ t₂) → let c' = Ext∙⟶ c (t₁' , v₁') = Ext𝕌 t₁ (t₂' , v₂') = Ext𝕌 t₂ in interp c' v₁' ≡ just v₂' Ext≡ (∙c c) = Eval≡ c Ext≡ (∙times# {t₁} {t₂}) = refl Ext≡ (∙#times {t₁} {t₂}) = refl Ext≡ ∙id⟷ = refl Ext≡ (c₁ ∙⊚ c₂) rewrite Ext≡ c₁ | Ext≡ c₂ = refl Ext≡ (c₁ ∙⊕ₗ c₂) rewrite Ext≡ c₁ = refl Ext≡ (c₁ ∙⊕ᵣ c₂) rewrite Ext≡ c₂ = refl Ext≡ ∙unite⋆l = refl Ext≡ ∙uniti⋆l = refl Ext≡ ∙unite⋆r = refl Ext≡ ∙uniti⋆r = refl Ext≡ ∙swap⋆ = refl Ext≡ ∙assocl⋆ = refl Ext≡ ∙assocr⋆ = refl Ext≡ (c₁ ∙⊗ c₂) rewrite Ext≡ c₁ | Ext≡ c₂ = refl Ext≡ (return T) = refl Ext≡ (extract T) = refl Ext≡ (η T) = refl Ext≡ (ε T) with 𝕌dec _ (proj₂ (Ext𝕌 T)) (proj₂ (Ext𝕌 T)) Ext≡ (ε T) | yes p = refl Ext≡ (ε T) | no ¬p = ⊥-elim (¬p refl) 𝔹 : Pi/.𝕌 𝔹 = 𝟙 +ᵤ 𝟙 infixr 2 _→⟨_⟩_ infix 3 _□ _→⟨_⟩_ : (T₁ : ∙𝕌) → {T₂ T₃ : ∙𝕌} → (T₁ ∙⟶ T₂) → (T₂ ∙⟶ T₃) → (T₁ ∙⟶ T₃) _ →⟨ α ⟩ β = α ∙⊚ β _□ : (T : ∙𝕌) → {T : ∙𝕌} → (T ∙⟶ T) _□ T = ∙id⟷ zigzag : ∀ b → 𝔹 # b ∙⟶ 𝔹 # b zigzag b = ∙c uniti⋆l ∙⊚ ∙times# ∙⊚ (∙id⟷ ∙⊗ return ((𝟙 +ᵤ 𝟙) # b)) ∙⊚ (η ((𝟙 +ᵤ 𝟙) # b) ∙⊗ ∙id⟷) ∙⊚ ∙assocr⋆ ∙⊚ (∙id⟷ ∙⊗ ∙swap⋆) ∙⊚ (∙id⟷ ∙⊗ ε ((𝟙 +ᵤ 𝟙) # b)) ∙⊚ (extract ((𝟙 +ᵤ 𝟙) # b) ∙⊗ ∙id⟷) ∙⊚ ∙#times ∙⊚ ∙c unite⋆r ∙⊚ ∙id⟷ zigzag-ext : ∀ b → Σ[ c ∈ 𝟙 +ᵤ 𝟙 ↔ 𝟙 +ᵤ 𝟙 ] interp c (Inj⟦𝕌⟧ b) ≡ just (Inj⟦𝕌⟧ b) zigzag-ext b = Ext∙⟶ (zigzag b) , Ext≡ (zigzag b)
{ "alphanum_fraction": 0.5, "avg_line_length": 30.855721393, "ext": "agda", "hexsha": "5be8188fd52c4e363f5b1f52ede696860feececa", "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/Extraction.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/Extraction.agda", "max_line_length": 95, "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/Extraction.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": 3875, "size": 6202 }
module UnquoteDef where open import Common.Reflection open import Common.Prelude module Target where mutual even : Nat → Bool even zero = true even (suc n) = odd n odd : Nat → Bool odd zero = false odd (suc n) = even n pattern `false = con (quote false) [] pattern `true = con (quote true) [] pattern `zero = con (quote zero) [] pattern `suc n = con (quote suc) (vArg n ∷ []) pattern _`→_ a b = pi (vArg a) (abs "A" b) pattern `Nat = def (quote Nat) [] pattern `Bool = def (quote Bool) [] `idType = `Nat `→ `Nat -- Simple non-mutual case `id : QName → FunDef `id f = funDef `idType ( clause (vArg `zero ∷ []) `zero ∷ clause (vArg (`suc (var "n")) ∷ []) (`suc (def f (vArg (var 0 []) ∷ []))) ∷ []) `idDef : QName → List Clause `idDef f = clause (vArg `zero ∷ []) `zero ∷ clause (vArg (`suc (var "n")) ∷ []) (`suc (def f (vArg (var 0 []) ∷ []))) ∷ [] -- id : Nat → Nat -- unquoteDef id = `idDef id -- Now for the mutal ones `evenOdd : Term → QName → List Clause `evenOdd base step = clause (vArg `zero ∷ []) base ∷ clause (vArg (`suc (var "n")) ∷ []) (def step (vArg (var 0 []) ∷ [])) ∷ [] _>>_ : TC ⊤ → TC ⊤ → TC ⊤ m >> m₁ = bindTC m λ _ → m₁ even odd : Nat → Bool unquoteDef even odd = defineFun even (`evenOdd `true odd) >> defineFun odd (`evenOdd `false even)
{ "alphanum_fraction": 0.5458483755, "avg_line_length": 23.8793103448, "ext": "agda", "hexsha": "c205bb18036369a2fda7cb388a98ff64f3b03851", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Succeed/UnquoteDef.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Succeed/UnquoteDef.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/UnquoteDef.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 486, "size": 1385 }
{- Basic properties about Σ-types - Characterization of equality in Σ-types using transport ([pathSigma≡sigmaPath]) -} {-# OPTIONS --cubical --safe #-} module Cubical.Data.Sigma.Properties where open import Cubical.Data.Sigma.Base open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Path open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Relation.Nullary open import Cubical.Relation.Nullary.DecidableEq open import Cubical.Data.Unit.Base private variable ℓ : Level A A' : Type ℓ B B' : (a : A) → Type ℓ C : (a : A) (b : B a) → Type ℓ mapʳ : (∀ {a} → B a → B' a) → Σ A B → Σ A B' mapʳ f (a , b) = (a , f b) mapˡ : {B : Type ℓ} → (f : A → A') → Σ A (λ _ → B) → Σ A' (λ _ → B) mapˡ f (a , b) = (f a , b) ΣPathP : ∀ {x y} → Σ (fst x ≡ fst y) (λ a≡ → PathP (λ i → B (a≡ i)) (snd x) (snd y)) → x ≡ y ΣPathP eq i = fst eq i , snd eq i Σ-split-iso : {x y : Σ A B} → Iso (Σ[ q ∈ fst x ≡ fst y ] (PathP (λ i → B (q i)) (snd x) (snd y))) (x ≡ y) Iso.fun (Σ-split-iso) = ΣPathP Iso.inv (Σ-split-iso) eq = (λ i → fst (eq i)) , (λ i → snd (eq i)) Iso.rightInv (Σ-split-iso) x = refl {x = x} Iso.leftInv (Σ-split-iso) x = refl {x = x} Σ≃ : {x y : Σ A B} → Σ (fst x ≡ fst y) (λ p → PathP (λ i → B (p i)) (snd x) (snd y)) ≃ (x ≡ y) Σ≃ {A = A} {B = B} {x} {y} = isoToEquiv (Σ-split-iso) Σ≡ : {a a' : A} {b : B a} {b' : B a'} → (Σ (a ≡ a') (λ q → PathP (λ i → B (q i)) b b')) ≡ ((a , b) ≡ (a' , b')) Σ≡ = isoToPath Σ-split-iso -- ua Σ≃ ΣProp≡ : ((x : A) → isProp (B x)) → {u v : Σ A B} → (p : u .fst ≡ v .fst) → u ≡ v ΣProp≡ pB {u} {v} p i = (p i) , isProp→PathP (λ i → pB (p i)) (u .snd) (v .snd) i -- Alternative version for path in Σ-types, as in the HoTT book sigmaPathTransport : (a b : Σ A B) → Type _ sigmaPathTransport {B = B} a b = Σ (fst a ≡ fst b) (λ p → transport (λ i → B (p i)) (snd a) ≡ snd b) _Σ≡T_ : (a b : Σ A B) → Type _ a Σ≡T b = sigmaPathTransport a b -- now we prove that the alternative path space a Σ≡ b is equal to the usual path space a ≡ b -- forward direction private pathSigma-π1 : {a b : Σ A B} → a ≡ b → fst a ≡ fst b pathSigma-π1 p i = fst (p i) filler-π2 : {a b : Σ A B} → (p : a ≡ b) → I → (i : I) → B (fst (p i)) filler-π2 {B = B} {a = a} p i = fill (λ i → B (fst (p i))) (λ t → λ { (i = i0) → transport-filler (λ j → B (fst (p j))) (snd a) t ; (i = i1) → snd (p t) }) (inS (snd a)) pathSigma-π2 : {a b : Σ A B} → (p : a ≡ b) → subst B (pathSigma-π1 p) (snd a) ≡ snd b pathSigma-π2 p i = filler-π2 p i i1 pathSigma→sigmaPath : (a b : Σ A B) → a ≡ b → a Σ≡T b pathSigma→sigmaPath _ _ p = (pathSigma-π1 p , pathSigma-π2 p) -- backward direction private filler-comp : (a b : Σ A B) → a Σ≡T b → I → I → Σ A B filler-comp {B = B} a b (p , q) i = hfill (λ t → λ { (i = i0) → a ; (i = i1) → (p i1 , q t) }) (inS (p i , transport-filler (λ j → B (p j)) (snd a) i)) sigmaPath→pathSigma : (a b : Σ A B) → a Σ≡T b → (a ≡ b) sigmaPath→pathSigma a b x i = filler-comp a b x i i1 -- first homotopy private homotopy-π1 : (a b : Σ A B) → ∀ (x : a Σ≡T b) → pathSigma-π1 (sigmaPath→pathSigma a b x) ≡ fst x homotopy-π1 a b x i j = fst (filler-comp a b x j (~ i)) homotopy-π2 : (a b : Σ A B) → (p : a Σ≡T b) → (i : I) → (transport (λ j → B (fst (filler-comp a b p j i))) (snd a) ≡ snd b) homotopy-π2 {B = B} a b p i j = comp (λ t → B (fst (filler-comp a b p t (i ∨ j)))) (λ t → λ { (j = i0) → transport-filler (λ t → B (fst (filler-comp a b p t i))) (snd a) t ; (j = i1) → snd (sigmaPath→pathSigma a b p t) ; (i = i0) → snd (filler-comp a b p t j) ; (i = i1) → filler-π2 (sigmaPath→pathSigma a b p) j t }) (snd a) pathSigma→sigmaPath→pathSigma : {a b : Σ A B} → ∀ (x : a Σ≡T b) → pathSigma→sigmaPath _ _ (sigmaPath→pathSigma a b x) ≡ x pathSigma→sigmaPath→pathSigma {a = a} p i = (homotopy-π1 a _ p i , homotopy-π2 a _ p (~ i)) -- second homotopy sigmaPath→pathSigma→sigmaPath : {a b : Σ A B} → ∀ (x : a ≡ b) → sigmaPath→pathSigma a b (pathSigma→sigmaPath _ _ x) ≡ x sigmaPath→pathSigma→sigmaPath {B = B} {a = a} {b = b} p i j = hcomp (λ t → λ { (i = i1) → (fst (p j) , filler-π2 p t j) ; (i = i0) → filler-comp a b (pathSigma→sigmaPath _ _ p) j t ; (j = i0) → (fst a , snd a) ; (j = i1) → (fst b , filler-π2 p t i1) }) (fst (p j) , transport-filler (λ k → B (fst (p k))) (snd a) j) pathSigma≡sigmaPath : (a b : Σ A B) → (a ≡ b) ≡ (a Σ≡T b) pathSigma≡sigmaPath a b = isoToPath (iso (pathSigma→sigmaPath a b) (sigmaPath→pathSigma a b) (pathSigma→sigmaPath→pathSigma {a = a}) sigmaPath→pathSigma→sigmaPath) discreteΣ : Discrete A → ((a : A) → Discrete (B a)) → Discrete (Σ A B) discreteΣ {B = B} Adis Bdis (a0 , b0) (a1 , b1) = discreteΣ' (Adis a0 a1) where discreteΣ' : Dec (a0 ≡ a1) → Dec ((a0 , b0) ≡ (a1 , b1)) discreteΣ' (yes p) = J (λ a1 p → ∀ b1 → Dec ((a0 , b0) ≡ (a1 , b1))) (discreteΣ'') p b1 where discreteΣ'' : (b1 : B a0) → Dec ((a0 , b0) ≡ (a0 , b1)) discreteΣ'' b1 with Bdis a0 b0 b1 ... | (yes q) = yes (transport (ua Σ≃) (refl , q)) ... | (no ¬q) = no (λ r → ¬q (subst (λ X → PathP (λ i → B (X i)) b0 b1) (Discrete→isSet Adis a0 a0 (cong fst r) refl) (cong snd r))) discreteΣ' (no ¬p) = no (λ r → ¬p (cong fst r)) Σ-contractFst : ∀ {ℓ ℓ'} {A : Type ℓ} {B : A → Type ℓ'} (c : isContr A) → Σ A B ≃ B (c .fst) Σ-contractFst {B = B} c = isoToEquiv (iso (λ {(a , b) → subst B (sym (c .snd a)) b}) (c .fst ,_) (λ b → cong (λ p → subst B p b) (isProp→isSet (isContr→isProp c) _ _ _ _) ∙ transportRefl _) (λ {(a , b) → sigmaPath→pathSigma _ _ (c .snd a , transportTransport⁻ (cong B (c .snd a)) _)})) -- a special case of the above ΣUnit : ∀ {ℓ} (A : Unit → Type ℓ) → Σ Unit A ≃ A tt ΣUnit A = isoToEquiv (iso snd (λ { x → (tt , x) }) (λ _ → refl) (λ _ → refl)) assocΣ : (Σ[ (a , b) ∈ Σ A B ] C a b) ≃ (Σ[ a ∈ A ] Σ[ b ∈ B a ] C a b) assocΣ = isoToEquiv (iso (λ { ((x , y) , z) → (x , (y , z)) }) (λ { (x , (y , z)) → ((x , y) , z) }) (λ _ → refl) (λ _ → refl)) congΣEquiv : (∀ a → B a ≃ B' a) → Σ A B ≃ Σ A B' congΣEquiv h = isoToEquiv (iso (λ { (x , y) → (x , equivFun (h x) y) }) (λ { (x , y) → (x , invEq (h x) y) }) (λ { (x , y) i → (x , retEq (h x) y i) }) (λ { (x , y) i → (x , secEq (h x) y i) })) PiΣ : ((a : A) → Σ[ b ∈ B a ] C a b) ≃ (Σ[ f ∈ ((a : A) → B a) ] ∀ a → C a (f a)) PiΣ = isoToEquiv (iso (λ f → fst ∘ f , snd ∘ f) (λ (f , g) → (λ x → f x , g x)) (λ _ → refl) (λ _ → refl)) swapΣEquiv : ∀ {ℓ'} (A : Type ℓ) (B : Type ℓ') → A × B ≃ B × A swapΣEquiv A B = isoToEquiv (iso (λ x → x .snd , x .fst) (λ z → z .snd , z .fst) (\ _ → refl) (\ _ → refl)) Σ-ap-iso₁ : ∀ {ℓ} {ℓ'} {A A' : Type ℓ} {B : A' → Type ℓ'} → (isom : Iso A A') → Iso (Σ A (B ∘ (Iso.fun isom))) (Σ A' B) Iso.fun (Σ-ap-iso₁ isom) x = (Iso.fun isom) (x .fst) , x .snd Iso.inv (Σ-ap-iso₁ {B = B} isom) x = (Iso.inv isom) (x .fst) , subst B (sym (ε' (x .fst))) (x .snd) where ε' = fst (vogt isom) Iso.rightInv (Σ-ap-iso₁ {B = B} isom) (x , y) = ΣPathP (ε' x , transport (sym (PathP≡Path (λ j → cong B (ε' x) j) (subst B (sym (ε' x)) y) y)) (subst B (ε' x) (subst B (sym (ε' x)) y) ≡⟨ sym (substComposite B (sym (ε' x)) (ε' x) y) ⟩ subst B ((sym (ε' x)) ∙ (ε' x)) y ≡⟨ (cong (λ a → subst B a y) (lCancel (ε' x))) ⟩ subst B refl y ≡⟨ substRefl {B = B} y ⟩ y ∎)) where ε' = fst (vogt isom) Iso.leftInv (Σ-ap-iso₁ {A = A} {B = B} isom@(iso f g ε η)) (x , y) = ΣPathP (η x , transport (sym (PathP≡Path (λ j → cong B (cong f (η x)) j) (subst B (sym (ε' (f x))) y) y)) (subst B (cong f (η x)) (subst B (sym (ε' (f x))) y) ≡⟨ sym (substComposite B (sym (ε' (f x))) (cong f (η x)) y) ⟩ subst B (sym (ε' (f x)) ∙ (cong f (η x))) y ≡⟨ cong (λ a → subst B a y) (lem x) ⟩ subst B (refl) y ≡⟨ substRefl {B = B} y ⟩ y ∎)) where ε' = fst (vogt isom) γ = snd (vogt isom) lem : (x : A) → sym (ε' (f x)) ∙ cong f (η x) ≡ refl lem x = cong (λ a → sym (ε' (f x)) ∙ a) (γ x) ∙ lCancel (ε' (f x)) Σ-ap₁ : (isom : A ≡ A') → Σ A (B ∘ transport isom) ≡ Σ A' B Σ-ap₁ isom = isoToPath (Σ-ap-iso₁ (pathToIso isom)) Σ-ap-iso₂ : ((x : A) → Iso (B x) (B' x)) → Iso (Σ A B) (Σ A B') Iso.fun (Σ-ap-iso₂ isom) (x , y) = x , Iso.fun (isom x) y Iso.inv (Σ-ap-iso₂ isom) (x , y') = x , Iso.inv (isom x) y' Iso.rightInv (Σ-ap-iso₂ isom) (x , y) = ΣPathP (refl , Iso.rightInv (isom x) y) Iso.leftInv (Σ-ap-iso₂ isom) (x , y') = ΣPathP (refl , Iso.leftInv (isom x) y') Σ-ap₂ : ((x : A) → B x ≡ B' x) → Σ A B ≡ Σ A B' Σ-ap₂ isom = isoToPath (Σ-ap-iso₂ (pathToIso ∘ isom)) Σ-ap-iso : ∀ {ℓ ℓ'} {A A' : Type ℓ} → {B : A → Type ℓ'} {B' : A' → Type ℓ'} → (isom : Iso A A') → ((x : A) → Iso (B x) (B' (Iso.fun isom x))) ------------------------ → Iso (Σ A B) (Σ A' B') Σ-ap-iso isom isom' = compIso (Σ-ap-iso₂ isom') (Σ-ap-iso₁ isom) Σ-ap : ∀ {ℓ ℓ'} {X X' : Type ℓ} {Y : X → Type ℓ'} {Y' : X' → Type ℓ'} → (isom : X ≡ X') → ((x : X) → Y x ≡ Y' (transport isom x)) ---------- → (Σ X Y) ≡ (Σ X' Y') Σ-ap isom isom' = isoToPath (Σ-ap-iso (pathToIso isom) (pathToIso ∘ isom')) Σ-ap' : ∀ {ℓ ℓ'} {X X' : Type ℓ} {Y : X → Type ℓ'} {Y' : X' → Type ℓ'} → (isom : X ≡ X') → (PathP (λ i → isom i → Type ℓ') Y Y') ---------- → (Σ X Y) ≡ (Σ X' Y') Σ-ap' {ℓ} {ℓ'} isom isom' = cong₂ (λ (a : Type ℓ) (b : a → Type ℓ') → Σ a λ x → b x) isom isom'
{ "alphanum_fraction": 0.4905512582, "avg_line_length": 37.1381818182, "ext": "agda", "hexsha": "f170aa76e72fbb300e936a5e568ef97294f0d546", "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/Data/Sigma/Properties.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/Data/Sigma/Properties.agda", "max_line_length": 140, "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/Data/Sigma/Properties.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": 4526, "size": 10213 }
-- Andreas, 2016-06-20 issue #2051 -- Try to preserve rhs when splitting a clause data D : Set where d : D c : D → D -- A simple RHS that should be preserved by splitting: con : (x : D) → D con x = c {!x!} -- C-c C-c -- More delicate, a meta variable applied to something: -- This means the hole is not at the rightmost position. app : (x : D) → D app x = {!x!} x -- A let-binding (not represented in internal syntax): test : (x : D) → D test x = let y = c in {!x!} -- C-c C-c -- Case splitting replaces entire RHS by hole -- test c = ?
{ "alphanum_fraction": 0.6148282098, "avg_line_length": 21.2692307692, "ext": "agda", "hexsha": "2d85e9650889c53efea4b9a552735682fdc9770c", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue2051.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue2051.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/interaction/Issue2051.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": 177, "size": 553 }
module Prelude where open import Agda.Builtin.IO public using (IO) open import Data.Empty public using () renaming (⊥ to 𝟘 ; ⊥-elim to elim𝟘) open import Data.Nat public using (ℕ ; zero ; suc ; decTotalOrder ; _⊔_) renaming (_≤_ to _⊑_ ; z≤n to z⊑n ; s≤s to n⊑m→sn⊑sm ; _≤′_ to _≤_ ; ≤′-refl to refl≤ ; ≤′-step to step≤ ; _≤?_ to _⊑?_ ; _≰_ to _⋢_ ; _<′_ to _<_ ; _≟_ to _≡?_) open import Data.Nat.Properties public using () renaming (≤⇒≤′ to ⊑→≤ ; ≤′⇒≤ to ≤→⊑ ; z≤′n to z≤n ; s≤′s to n≤m→sn≤sm) open import Data.Nat.Show public using (show) open import Data.Product public using (Σ ; _×_ ; _,_) renaming (proj₁ to π₁ ; proj₂ to π₂) open import Data.String public using (String) renaming (_≟_ to _≡ₛ?_ ; _++_ to _⧺_) open import Data.Sum public using (_⊎_) renaming (inj₁ to ι₁ ; inj₂ to ι₂) open import Data.Unit public using () renaming (⊤ to Unit ; tt to unit) open import Function public using (_∘_) open import Relation.Binary public using (Antisymmetric ; Decidable ; DecTotalOrder ; Reflexive ; Rel ; Symmetric ; Total ; Transitive ; Trichotomous ; Tri) renaming (tri< to τ₍ ; tri≈ to τ₌ ; tri> to τ₎) open module NDTO = DecTotalOrder decTotalOrder public using () renaming (antisym to antisym⊑ ; trans to trans⊑ ; total to total⊑) open import Relation.Binary.PropositionalEquality public using (_≡_ ; _≢_ ; refl ; trans ; sym ; cong ; cong₂ ; subst) open import Relation.Binary.HeterogeneousEquality public using (_≅_ ; _≇_) renaming (refl to refl≅ ; trans to trans≅ ; sym to sym≅ ; cong to cong≅ ; cong₂ to cong₂≅ ; subst to subst≅ ; ≅-to-≡ to ≅→≡ ; ≡-to-≅ to ≡→≅) open import Relation.Nullary public using (¬_ ; Dec ; yes ; no) open import Relation.Nullary.Negation public using () renaming (contradiction to _↯_) -- I/O. postulate return : ∀ {a} {A : Set a} → A → IO A _≫=_ : ∀ {a b} {A : Set a} {B : Set b} → IO A → (A → IO B) → IO B {-# COMPILED return (\_ _ -> return) #-} {-# COMPILED _≫=_ (\_ _ _ _ -> (>>=)) #-} _≫_ : ∀ {a b} {A : Set a} {B : Set b} → IO A → IO B → IO B m₁ ≫ m₂ = m₁ ≫= λ _ → m₂ postulate putStr : String → IO Unit putStrLn : String → IO Unit {-# COMPILED putStr putStr #-} {-# COMPILED putStrLn putStrLn #-} -- Notation for I/O. infix -10 do_ do_ : ∀ {a} {A : Set a} → A → A do x = x case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B case x of f = f x infixr 0 do-bind syntax do-bind m₁ (λ x → m₂) = x ← m₁ ⁏ m₂ do-bind = _≫=_ infixr 0 do-seq syntax do-seq m₁ m₂ = m₁ ⁏ m₂ do-seq = _≫_ infixr 0 do-let syntax do-let m₁ (λ x → m₂) = x := m₁ ⁏ m₂ do-let = case_of_ -- Properties of binary relations. Irreflexive : ∀ {a ℓ} {A : Set a} → Rel A ℓ → Set _ Irreflexive _∼_ = ∀ {x} → ¬ (x ∼ x) -- Properties of _≡_. n≡m→sn≡sm : ∀ {n m} → n ≡ m → suc n ≡ suc m n≡m→sn≡sm refl = refl sn≡sm→n≡m : ∀ {n m} → suc n ≡ suc m → n ≡ m sn≡sm→n≡m refl = refl n≢m→sn≢sm : ∀ {n m} → n ≢ m → suc n ≢ suc m n≢m→sn≢sm n≢m refl = refl ↯ n≢m sn≢sm→n≢m : ∀ {n m} → suc n ≢ suc m → n ≢ m sn≢sm→n≢m sn≢sm refl = refl ↯ sn≢sm sym≢ : ∀ {a} {A : Set a} → Symmetric (_≢_ {A = A}) sym≢ x≢y refl = refl ↯ x≢y -- Properties of _≤_. _≰_ : ℕ → ℕ → Set n ≰ m = ¬ (n ≤ m) sn≤m→n≤m : ∀ {n m} → suc n ≤ m → n ≤ m sn≤m→n≤m refl≤ = step≤ refl≤ sn≤m→n≤m (step≤ sn≤m) = step≤ (sn≤m→n≤m sn≤m) sn≤sm→n≤m : ∀ {n m} → suc n ≤ suc m → n ≤ m sn≤sm→n≤m refl≤ = refl≤ sn≤sm→n≤m (step≤ sn≤m) = sn≤m→n≤m sn≤m n≰m→sn≰sm : ∀ {n m} → n ≰ m → suc n ≰ suc m n≰m→sn≰sm n≰m refl≤ = refl≤ ↯ n≰m n≰m→sn≰sm n≰m (step≤ sn≤m) = sn≤m→n≤m sn≤m ↯ n≰m sn≰sm→n≰m : ∀ {n m} → suc n ≰ suc m → n ≰ m sn≰sm→n≰m sn≰sm refl≤ = refl≤ ↯ sn≰sm sn≰sm→n≰m sn≰sm (step≤ n≤m) = sn≰sm→n≰m (sn≰sm ∘ step≤) n≤m sn≰n : ∀ {n} → suc n ≰ n sn≰n {zero} = λ () sn≰n {suc n} = n≰m→sn≰sm sn≰n n≤m⊔n : (n m : ℕ) → n ≤ m ⊔ n n≤m⊔n zero zero = refl≤ n≤m⊔n zero (suc m) = z≤n n≤m⊔n (suc n) zero = refl≤ n≤m⊔n (suc n) (suc m) = n≤m→sn≤sm (n≤m⊔n n m) -- Properties of _<_. _≮_ : ℕ → ℕ → Set n ≮ m = ¬ (n < m) z<sn : ∀ {n} → zero < suc n z<sn = n≤m→sn≤sm z≤n n<m→sn<sm : ∀ {n m} → n < m → suc n < suc m n<m→sn<sm = n≤m→sn≤sm sn<m→n<m : ∀ {n m} → suc n < m → n < m sn<m→n<m = sn≤m→n≤m sn<sm→n<m : ∀ {n m} → suc n < suc m → n < m sn<sm→n<m = sn≤sm→n≤m n≮m→sn≮sm : ∀ {n m} → n ≮ m → suc n ≮ suc m n≮m→sn≮sm = n≰m→sn≰sm sn≮sm→n≮m : ∀ {n m} → suc n ≮ suc m → n ≮ m sn≮sm→n≮m = sn≰sm→n≰m n<s[n⊔m] : (n m : ℕ) → n < suc (n ⊔ m) n<s[n⊔m] zero zero = refl≤ n<s[n⊔m] zero (suc m) = n≤m→sn≤sm z≤n n<s[n⊔m] (suc n) zero = refl≤ n<s[n⊔m] (suc n) (suc m) = n≤m→sn≤sm (n<s[n⊔m] n m) -- Conversion between _⊑_, ⊏, _≤_, _<_, and _≡_. ≰→⋢ : ∀ {n m} → n ≰ m → n ⋢ m ≰→⋢ {zero} {zero} n≰m = refl≤ ↯ n≰m ≰→⋢ {suc n} {zero} n≰m = λ () ≰→⋢ {n} {suc m} n≰m = λ n⊑m → ⊑→≤ n⊑m ↯ n≰m ⋢→≰ : ∀ {n m} → n ⋢ m → n ≰ m ⋢→≰ {zero} {m} n⋢m = z⊑n ↯ n⋢m ⋢→≰ {suc n} {zero} n⋢m = λ () ⋢→≰ {suc n} {suc m} n⋢m = λ n≤m → ≤→⊑ n≤m ↯ n⋢m ≤×≢→< : ∀ {n m} → n ≤ m → n ≢ m → n < m ≤×≢→< refl≤ n≢m = refl ↯ n≢m ≤×≢→< (step≤ n≤m) n≢m = n≤m→sn≤sm n≤m ≤→<⊎≡ : ∀ {n m} → n ≤ m → n < m ⊎ n ≡ m ≤→<⊎≡ refl≤ = ι₂ refl ≤→<⊎≡ (step≤ n≤m) with ≤→<⊎≡ n≤m ≤→<⊎≡ (step≤ n≤m) | ι₁ sn≤m = ι₁ (step≤ sn≤m) ≤→<⊎≡ (step≤ n≤m) | ι₂ refl = ι₁ refl≤ <→≤ : ∀ {n m} → n < m → n ≤ m <→≤ n<m = sn≤m→n≤m n<m ≡→≤ : ∀ {n m} → n ≡ m → n ≤ m ≡→≤ refl = refl≤ -- _≤_ is a decidable non-strict total order on naturals. antisym≤ : Antisymmetric _≡_ _≤_ antisym≤ n≤m m≤n = antisym⊑ (≤→⊑ n≤m) (≤→⊑ m≤n) total≤ : Total _≤_ total≤ n m with total⊑ n m total≤ n m | ι₁ n⊑m = ι₁ (⊑→≤ n⊑m) total≤ n m | ι₂ m⊑n = ι₂ (⊑→≤ m⊑n) trans≤ : Transitive _≤_ trans≤ n≤m m≤z = ⊑→≤ (trans⊑ (≤→⊑ n≤m) (≤→⊑ m≤z)) _≤?_ : Decidable _≤_ n ≤? m with n ⊑? m n ≤? m | yes n⊑m = yes (⊑→≤ n⊑m) n ≤? m | no n⋢m = no (⋢→≰ n⋢m) -- _<_ is a decidable strict total order on naturals. trans< : Transitive _<_ trans< n<m m<l = trans≤ (step≤ n<m) m<l tri< : Trichotomous _≡_ _<_ tri< zero zero = τ₌ (λ ()) refl (λ ()) tri< zero (suc m) = τ₍ z<sn (λ ()) (λ ()) tri< (suc n) zero = τ₎ (λ ()) (λ ()) z<sn tri< (suc n) (suc m) with tri< n m tri< (suc n) (suc m) | τ₍ n<m n≢m m≮n = τ₍ (n<m→sn<sm n<m) (n≢m→sn≢sm n≢m) (n≮m→sn≮sm m≮n) tri< (suc n) (suc m) | τ₌ n≮m n≡m m≮n = τ₌ (n≮m→sn≮sm n≮m) (n≡m→sn≡sm n≡m) (n≮m→sn≮sm m≮n) tri< (suc n) (suc m) | τ₎ n≮m n≢m m<n = τ₎ (n≮m→sn≮sm n≮m) (n≢m→sn≢sm n≢m) (n<m→sn<sm m<n) irrefl< : Irreflexive _<_ irrefl< = sn≰n _<?_ : Decidable _<_ n <? m = suc n ≤? m
{ "alphanum_fraction": 0.5132307692, "avg_line_length": 25.2918287938, "ext": "agda", "hexsha": "813d6c2916c80790bae51ef11cabf01ff025d9c6", "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": "b685baa99230c3d5fd1e41c66d325575b70308c4", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/lamport-timestamps", "max_forks_repo_path": "Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b685baa99230c3d5fd1e41c66d325575b70308c4", "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/lamport-timestamps", "max_issues_repo_path": "Prelude.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "b685baa99230c3d5fd1e41c66d325575b70308c4", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/lamport-timestamps", "max_stars_repo_path": "Prelude.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3572, "size": 6500 }
{-# OPTIONS --without-K --safe #-} -- Define Strong Monad; use the Wikipedia definition -- https://en.wikipedia.org/wiki/Strong_monad -- At the nLab, https://ncatlab.org/nlab/show/strong+monad -- there are two further definitions; the 2-categorical version is too complicated -- and the Moggi definition is a special case of the one here module Categories.Monad.Strong where open import Level open import Data.Product using (_,_) open import Categories.Category open import Categories.Functor renaming (id to idF) open import Categories.Category.Monoidal open import Categories.Category.Product open import Categories.NaturalTransformation hiding (id) -- open import Categories.NaturalTransformation.NaturalIsomorphism open import Categories.Monad private variable o ℓ e : Level record Strength {C : Category o ℓ e} (V : Monoidal C) (m : Monad C) : Set (o ⊔ ℓ ⊔ e) where open Category C open Monoidal V open Monad m using (F) module M = Monad m open NaturalTransformation M.η using (η) open NaturalTransformation M.μ renaming (η to μ) open Functor F field strengthen : NaturalTransformation (⊗ ∘F (idF ⁂ F)) (F ∘F ⊗) private module t = NaturalTransformation strengthen field -- strengthening with 1 is irrelevant identityˡ : {A : Obj} → F₁ (unitorˡ.from) ∘ t.η (unit , A) ≈ unitorˡ.from -- commutes with unit (of monad) η-comm : {A B : Obj} → t.η (A , B) ∘ (id ⊗₁ η B) ≈ η (A ⊗₀ B) -- strength commutes with multiplication μ-η-comm : {A B : Obj} → μ (A ⊗₀ B) ∘ F₁ (t.η (A , B)) ∘ t.η (A , F₀ B) ≈ t.η (A , B) ∘ id ⊗₁ μ B -- consecutive applications of strength commute (i.e. strength is associative) strength-assoc : {A B C : Obj} → F₁ associator.from ∘ t.η (A ⊗₀ B , C) ≈ t.η (A , B ⊗₀ C) ∘ id ⊗₁ t.η (B , C) ∘ associator.from record StrongMonad {C : Category o ℓ e} (V : Monoidal C) : Set (o ⊔ ℓ ⊔ e) where field m : Monad C strength : Strength V m
{ "alphanum_fraction": 0.6724756535, "avg_line_length": 34.8392857143, "ext": "agda", "hexsha": "1ead12ae2237f7f87bf9f5f966716193a23102c9", "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": "89d163f72caa7deeac9413f27bc1b4ed7f9e025b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-categories", "max_forks_repo_path": "Categories/Monad/Strong.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "89d163f72caa7deeac9413f27bc1b4ed7f9e025b", "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": "rei1024/agda-categories", "max_issues_repo_path": "Categories/Monad/Strong.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "89d163f72caa7deeac9413f27bc1b4ed7f9e025b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-categories", "max_stars_repo_path": "Categories/Monad/Strong.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 619, "size": 1951 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Relation.Binary.Raw module Cubical.Relation.Binary.Reasoning.Base.Single {a ℓ} {A : Type a} (_∼_ : RawRel A ℓ) (isPreorder : IsPreorder _∼_) where open IsPreorder isPreorder ------------------------------------------------------------------------ -- Reasoning combinators -- Re-export combinators from partial reasoning open import Cubical.Relation.Binary.Reasoning.Base.Partial _∼_ transitive public hiding (_∎⟨_⟩) -- Redefine the terminating combinator now that we have reflexivity infix 2 _∎ _∎ : ∀ x → x ∼ x x ∎ = reflexive
{ "alphanum_fraction": 0.6523076923, "avg_line_length": 25, "ext": "agda", "hexsha": "ffccd5a089e2fe1c939aacd14115867c1cc8cd70", "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/Relation/Binary/Reasoning/Base/Single.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/Relation/Binary/Reasoning/Base/Single.agda", "max_line_length": 80, "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/Relation/Binary/Reasoning/Base/Single.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 178, "size": 650 }
module PatternSyn where data ⊤ : Set where tt : ⊤ data D (A : Set) : Set where d : A → A → D A pattern p = tt pattern q = tt pattern _,_ x y = d x y f : ⊤ → ⊤ f p = tt g : {A : Set} → D A → A g (x , _) = x
{ "alphanum_fraction": 0.4060150376, "avg_line_length": 6.3333333333, "ext": "agda", "hexsha": "71fc096d17f57857cde8dc94986a0be74e991e88", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msuperdock/agda-unused", "max_forks_repo_path": "data/declaration/PatternSyn.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "msuperdock/agda-unused", "max_issues_repo_path": "data/declaration/PatternSyn.agda", "max_line_length": 23, "max_stars_count": 6, "max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msuperdock/agda-unused", "max_stars_repo_path": "data/declaration/PatternSyn.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z", "num_tokens": 129, "size": 266 }
open import Agda.Primitive using (_⊔_) import Categories.Category as Category import Categories.Category.Cartesian as Cartesian open import MultiSorted.AlgebraicTheory import MultiSorted.Product as Product module MultiSorted.Interpretation {o ℓ e} {𝓈 ℴ} (Σ : Signature {𝓈} {ℴ}) {𝒞 : Category.Category o ℓ e} (cartesian-𝒞 : Cartesian.Cartesian 𝒞) where open Signature Σ open Category.Category 𝒞 -- An interpretation of Σ in 𝒞 record Interpretation : Set (o ⊔ ℓ ⊔ e ⊔ 𝓈 ⊔ ℴ) where field interp-sort : sort → Obj interp-ctx : Product.Producted 𝒞 {Σ = Σ} interp-sort interp-oper : ∀ (f : oper) → Product.Producted.prod interp-ctx (oper-arity f) ⇒ interp-sort (oper-sort f) open Product.Producted interp-ctx -- the interpretation of a term interp-term : ∀ {Γ : Context} {A} → Term Γ A → prod Γ ⇒ interp-sort A interp-term (tm-var x) = π x interp-term (tm-oper f ts) = interp-oper f ∘ tuple (oper-arity f) (λ i → interp-term (ts i)) -- the interpretation of a substitution interp-subst : ∀ {Γ Δ} → Γ ⇒s Δ → prod Γ ⇒ prod Δ interp-subst {Γ} {Δ} σ = tuple Δ λ i → interp-term (σ i) -- the equality of interpretations ⊨_ : (ε : Equation Σ) → Set e open Equation ⊨ ε = interp-term (eq-lhs ε) ≈ interp-term (eq-rhs ε) -- interpretation commutes with substitution open HomReasoning interp-[]s : ∀ {Γ Δ} {A} {t : Term Δ A} {σ : Γ ⇒s Δ} → interp-term (t [ σ ]s) ≈ interp-term t ∘ interp-subst σ interp-[]s {Γ} {Δ} {A} {tm-var x} {σ} = ⟺ (project {Γ = Δ}) interp-[]s {Γ} {Δ} {A} {tm-oper f ts} {σ} = (∘-resp-≈ʳ (tuple-cong {fs = λ i → interp-term (ts i [ σ ]s)} {gs = λ z → interp-term (ts z) ∘ interp-subst σ} (λ i → interp-[]s {t = ts i} {σ = σ}) ○ (∘-distribʳ-tuple {Γ = oper-arity f} {fs = λ z → interp-term (ts z)} {g = interp-subst σ}))) ○ (Equiv.refl ○ sym-assoc) -- -- Every signature has the trivial interpretation open Product 𝒞 Trivial : Interpretation Trivial = let open Cartesian.Cartesian cartesian-𝒞 in record { interp-sort = (λ _ → ⊤) ; interp-ctx = StandardProducted (λ _ → ⊤) cartesian-𝒞 ; interp-oper = λ f → ! } record _⇒I_ (I J : Interpretation) : Set (o ⊔ ℓ ⊔ e ⊔ 𝓈 ⊔ ℴ) where open Interpretation open Producted field hom-morphism : ∀ {A} → interp-sort I A ⇒ interp-sort J A hom-commute : ∀ (f : oper) → hom-morphism ∘ interp-oper I f ≈ interp-oper J f ∘ tuple (interp-ctx J) (oper-arity f) (λ i → hom-morphism ∘ π (interp-ctx I) i) infix 4 _⇒I_ -- The identity homomorphism id-I : ∀ {A : Interpretation} → A ⇒I A id-I {A} = let open Interpretation A in let open HomReasoning in let open Producted interp-sort in record { hom-morphism = id ; hom-commute = λ f → begin (id ∘ interp-oper f) ≈⟨ identityˡ ⟩ interp-oper f ≈˘⟨ identityʳ ⟩ (interp-oper f ∘ id) ≈˘⟨ refl⟩∘⟨ unique interp-ctx (λ i → identityʳ ○ ⟺ identityˡ) ⟩ (interp-oper f ∘ Product.Producted.tuple interp-ctx (oper-arity f) (λ i → id ∘ Product.Producted.π interp-ctx i)) ∎ } -- Compositon of homomorphisms _∘I_ : ∀ {A B C : Interpretation} → B ⇒I C → A ⇒I B → A ⇒I C _∘I_ {A} {B} {C} ϕ ψ = let open _⇒I_ in record { hom-morphism = hom-morphism ϕ ∘ hom-morphism ψ ; hom-commute = let open Interpretation in let open Producted in let open HomReasoning in λ f → begin (((hom-morphism ϕ) ∘ hom-morphism ψ) ∘ interp-oper A f) ≈⟨ assoc ⟩ (hom-morphism ϕ ∘ hom-morphism ψ ∘ interp-oper A f) ≈⟨ (refl⟩∘⟨ hom-commute ψ f) ⟩ (hom-morphism ϕ ∘ interp-oper B f ∘ tuple (interp-ctx B) (oper-arity f) (λ i → hom-morphism ψ ∘ π (interp-ctx A) i)) ≈˘⟨ assoc ⟩ ((hom-morphism ϕ ∘ interp-oper B f) ∘ tuple (interp-ctx B) (oper-arity f) (λ i → hom-morphism ψ ∘ π (interp-ctx A) i)) ≈⟨ (hom-commute ϕ f ⟩∘⟨refl) ⟩ ((interp-oper C f ∘ tuple (interp-ctx C) (oper-arity f) (λ i → hom-morphism ϕ ∘ π (interp-ctx B) i)) ∘ tuple (interp-ctx B) (oper-arity f) (λ i → hom-morphism ψ ∘ π (interp-ctx A) i)) ≈⟨ assoc ⟩ (interp-oper C f ∘ tuple (interp-ctx C) (oper-arity f) (λ i → hom-morphism ϕ ∘ π (interp-ctx B) i) ∘ tuple (interp-ctx B) (oper-arity f) (λ i → hom-morphism ψ ∘ π (interp-ctx A) i)) ≈⟨ (refl⟩∘⟨ ⟺ (∘-distribʳ-tuple (interp-sort C) (interp-ctx C))) ⟩ (interp-oper C f ∘ tuple (interp-ctx C) (oper-arity f) (λ x → (hom-morphism ϕ ∘ π (interp-ctx B) x) ∘ tuple (interp-ctx B) (oper-arity f) (λ i → hom-morphism ψ ∘ π (interp-ctx A) i))) ≈⟨ (refl⟩∘⟨ tuple-cong (interp-sort C) (interp-ctx C) λ i → assoc) ⟩ (interp-oper C f ∘ tuple (interp-ctx C) (oper-arity f) (λ z → hom-morphism ϕ ∘ π (interp-ctx B) z ∘ tuple (interp-ctx B) (oper-arity f) (λ i → hom-morphism ψ ∘ π (interp-ctx A) i))) ≈⟨ (refl⟩∘⟨ tuple-cong (interp-sort C) (interp-ctx C) λ i → refl⟩∘⟨ project (interp-ctx B)) ⟩ (interp-oper C f ∘ tuple (interp-ctx C) (oper-arity f) (λ z → hom-morphism ϕ ∘ hom-morphism ψ ∘ π (interp-ctx A) z)) ≈⟨ (refl⟩∘⟨ tuple-cong (interp-sort C) (interp-ctx C) λ i → sym-assoc) ⟩ (interp-oper C f ∘ tuple (interp-ctx C) (oper-arity f) (λ z → (hom-morphism ϕ ∘ hom-morphism ψ) ∘ π (interp-ctx A) z)) ∎}
{ "alphanum_fraction": 0.4633284242, "avg_line_length": 44.3790849673, "ext": "agda", "hexsha": "0389cc51aa9145cc847ebcea63429d67e29733c8", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/MultiSorted/Interpretation.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/MultiSorted/Interpretation.agda", "max_line_length": 164, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/MultiSorted/Interpretation.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 2074, "size": 6790 }
-- Andreas, 2018-10-18, issue #3289 reported by Ulf -- Andreas, 2021-02-10, fix rhs occurrence -- -- For postfix projections, we have no hiding info -- for the eliminated record value. -- Thus, contrary to the prefix case, it cannot be -- taken into account (e.g. for projection disambiguation). open import Agda.Builtin.Nat record R : Set where field p : Nat open R {{...}} lhs : R lhs .p = 0 rhs : R → Nat rhs r = r .p -- Error WAS: Wrong hiding used for projection R.p -- Should work now.
{ "alphanum_fraction": 0.6732283465, "avg_line_length": 18.8148148148, "ext": "agda", "hexsha": "00eb0d98e7d7aae6f5db8a09507a91c1b22543fb", "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/Issue3289.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/Issue3289.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/Succeed/Issue3289.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": 153, "size": 508 }
open import Nat open import Prelude open import dynamics-core open import contexts module type-assignment-unicity where -- type assignment only assigns one type type-assignment-unicity : {Γ : tctx} {d : ihexp} {τ' τ : htyp} {Δ : hctx} → Δ , Γ ⊢ d :: τ → Δ , Γ ⊢ d :: τ' → τ == τ' type-assignment-unicity TANum TANum = refl type-assignment-unicity (TAPlus x x₁) (TAPlus x₂ x₃) = refl type-assignment-unicity {Γ = Γ} (TAVar x₁) (TAVar x₂) = ctxunicity {Γ = Γ} x₁ x₂ type-assignment-unicity (TALam _ d1) (TALam _ d2) with type-assignment-unicity d1 d2 ... | refl = refl type-assignment-unicity (TAAp x x₁) (TAAp y y₁) with type-assignment-unicity x y ... | refl = refl type-assignment-unicity (TAInl x) (TAInl y) with type-assignment-unicity x y ... | refl = refl type-assignment-unicity (TAInr x) (TAInr y) with type-assignment-unicity x y ... | refl = refl type-assignment-unicity (TACase d _ x _ y) (TACase d₁ _ x₁ _ y₁) with type-assignment-unicity d d₁ ... | refl with type-assignment-unicity x x₁ ... | refl = refl type-assignment-unicity (TAEHole {Δ = Δ} x y) (TAEHole x₁ x₂) with ctxunicity {Γ = Δ} x x₁ ... | refl = refl type-assignment-unicity (TANEHole {Δ = Δ} x d1 y) (TANEHole x₁ d2 x₂) with ctxunicity {Γ = Δ} x₁ x ... | refl = refl type-assignment-unicity (TACast d1 x) (TACast d2 x₁) with type-assignment-unicity d1 d2 ... | refl = refl type-assignment-unicity (TAFailedCast x x₁ x₂ x₃) (TAFailedCast y x₄ x₅ x₆) with type-assignment-unicity x y ... | refl = refl type-assignment-unicity (TAPair x x₁) (TAPair y y₁) with type-assignment-unicity x y ... | refl with type-assignment-unicity x₁ y₁ ... | refl = refl type-assignment-unicity (TAFst x) (TAFst y) with type-assignment-unicity x y ... | refl = refl type-assignment-unicity (TASnd x) (TASnd y) with type-assignment-unicity x y ... | refl = refl
{ "alphanum_fraction": 0.6308225966, "avg_line_length": 38.0754716981, "ext": "agda", "hexsha": "cf7123494d08a7a7fefd3904a4eb2f6b08988ada", "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": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "type-assignment-unicity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "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": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "type-assignment-unicity.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "type-assignment-unicity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 745, "size": 2018 }
{-# OPTIONS --without-K #-} open import SDG.Extra.OrderedAlgebra module SDG.SDG {r₁ r₂} (R : OrderedCommutativeRing r₁ r₂) where open OrderedCommutativeRing R renaming (Carrier to Rc) open import Data.Product open import Data.Sum open import Algebra -- note: SDG should probably be a record if i need to -- use some particular topos model --nilsqr : {!!} nilsqr = λ x → (x * x) ≈ 0# nilsqr-0# : nilsqr 0# nilsqr-0# = zeroˡ 0# --D : {!!} D = Σ[ x ∈ Rc ] (nilsqr x) D→R : D → Rc D→R d = proj₁ d R→D : (x : Rc) → nilsqr x → D R→D x nilsqr = x , nilsqr d0 : D d0 = R→D 0# nilsqr-0# postulate kock-lawvere : ∀ (g : D → Rc) → ∃! _≈_ (λ b → ∀ (d : D) → ((g d) ≈ ((g d0) + (D→R d * b)))) -- these definitions are modified from previous development based on Bell: gₓ : ∀ (f : Rc → Rc) (x : Rc) → (D → Rc) gₓ f x d = f (x + D→R d) ∃!b : ∀ (f : Rc → Rc) (x : Rc) → ∃! _≈_ (λ b → ∀ (d : D) → ((gₓ f x d) ≈ ((gₓ f x d0) + (D→R d * b)))) ∃!b f x = kock-lawvere (gₓ f x) _′ : (f : Rc → Rc) → (Rc → Rc) (f ′) x = proj₁ (∃!b f x)
{ "alphanum_fraction": 0.5373699149, "avg_line_length": 21.5714285714, "ext": "agda", "hexsha": "587a0fc6fd1221bbbb6342d1757fbb08c84ab058", "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": "6814e6f0baffff35efe14ef70d469343cd9b3ba0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wrrnhttn/agda-sdg", "max_forks_repo_path": "SDG/SDG.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "6814e6f0baffff35efe14ef70d469343cd9b3ba0", "max_issues_repo_issues_event_max_datetime": "2019-09-18T15:47:49.000Z", "max_issues_repo_issues_event_min_datetime": "2019-07-18T20:00:23.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "wrrnhttn/agda-sdg", "max_issues_repo_path": "SDG/SDG.agda", "max_line_length": 102, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6814e6f0baffff35efe14ef70d469343cd9b3ba0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wrrnhttn/agda-sdg", "max_stars_repo_path": "SDG/SDG.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-13T09:36:38.000Z", "max_stars_repo_stars_event_min_datetime": "2020-11-13T09:36:38.000Z", "num_tokens": 456, "size": 1057 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.FinData where open import Cubical.Data.FinData.Base public open import Cubical.Data.FinData.Properties public
{ "alphanum_fraction": 0.7802197802, "avg_line_length": 30.3333333333, "ext": "agda", "hexsha": "fc4048cb312e632bbc8aa92a02f0bfe4092ee84c", "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/FinData.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/FinData.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/FinData.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 45, "size": 182 }
module Extensions.Fin where open import Prelude open import Data.Fin hiding (_<_) open import Data.Nat
{ "alphanum_fraction": 0.7980769231, "avg_line_length": 17.3333333333, "ext": "agda", "hexsha": "04657132a85f6b9b0267073316911f70c4e674fb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Extensions/Fin.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Extensions/Fin.agda", "max_line_length": 33, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Extensions/Fin.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 25, "size": 104 }
------------------------------------------------------------------------------ -- Arithmetic properties ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Nat.PropertiesATP where open import FOTC.Base open import FOTC.Data.Nat open import FOTC.Data.Nat.UnaryNumbers ------------------------------------------------------------------------------ -- Totality properties pred-N : ∀ {n} → N n → N (pred₁ n) pred-N nzero = prf where postulate prf : N (pred₁ zero) {-# ATP prove prf #-} pred-N (nsucc {n} Nn) = prf where postulate prf : N (pred₁ (succ₁ n)) {-# ATP prove prf #-} +-N : ∀ {m n} → N m → N n → N (m + n) +-N {n = n} nzero Nn = prf where postulate prf : N (zero + n) {-# ATP prove prf #-} +-N {n = n} (nsucc {m} Nm) Nn = prf (+-N Nm Nn) where postulate prf : N (m + n) → N (succ₁ m + n) {-# ATP prove prf #-} ∸-N : ∀ {m n} → N m → N n → N (m ∸ n) ∸-N {m} Nm nzero = prf where postulate prf : N (m ∸ zero) {-# ATP prove prf #-} ∸-N {m} Nm (nsucc {n} Nn) = prf (∸-N Nm Nn) where postulate prf : N (m ∸ n) → N (m ∸ succ₁ n) {-# ATP prove prf pred-N #-} *-N : ∀ {m n} → N m → N n → N (m * n) *-N {n = n} nzero Nn = prf where postulate prf : N (zero * n) {-# ATP prove prf #-} *-N {n = n} (nsucc {m} Nm) Nn = prf (*-N Nm Nn) where postulate prf : N (m * n) → N (succ₁ m * n) {-# ATP prove prf +-N #-} ------------------------------------------------------------------------------ Sx≢x : ∀ {n} → N n → succ₁ n ≢ n Sx≢x nzero h = prf where postulate prf : ⊥ {-# ATP prove prf #-} Sx≢x (nsucc {n} Nn) h = prf (Sx≢x Nn) where postulate prf : succ₁ n ≢ n → ⊥ {-# ATP prove prf #-} +-leftIdentity : ∀ n → zero + n ≡ n +-leftIdentity n = +-0x n +-rightIdentity : ∀ {n} → N n → n + zero ≡ n +-rightIdentity nzero = +-leftIdentity zero +-rightIdentity (nsucc {n} Nn) = prf (+-rightIdentity Nn) where postulate prf : n + zero ≡ n → succ₁ n + zero ≡ succ₁ n {-# ATP prove prf #-} +-assoc : ∀ {m} → N m → ∀ n o → m + n + o ≡ m + (n + o) +-assoc nzero n o = prf where postulate prf : zero + n + o ≡ zero + (n + o) {-# ATP prove prf #-} +-assoc (nsucc {m} Nm) n o = prf (+-assoc Nm n o) where postulate prf : m + n + o ≡ m + (n + o) → succ₁ m + n + o ≡ succ₁ m + (n + o) {-# ATP prove prf #-} x+Sy≡S[x+y] : ∀ {m} → N m → ∀ n → m + succ₁ n ≡ succ₁ (m + n) x+Sy≡S[x+y] nzero n = prf where postulate prf : zero + succ₁ n ≡ succ₁ (zero + n) {-# ATP prove prf #-} x+Sy≡S[x+y] (nsucc {m} Nm) n = prf (x+Sy≡S[x+y] Nm n) where postulate prf : m + succ₁ n ≡ succ₁ (m + n) → succ₁ m + succ₁ n ≡ succ₁ (succ₁ m + n) {-# ATP prove prf #-} +-comm : ∀ {m n} → N m → N n → m + n ≡ n + m +-comm {n = n} nzero Nn = prf where postulate prf : zero + n ≡ n + zero {-# ATP prove prf +-rightIdentity #-} +-comm {n = n} (nsucc {m} Nm) Nn = prf (+-comm Nm Nn) where postulate prf : m + n ≡ n + m → succ₁ m + n ≡ n + succ₁ m {-# ATP prove prf x+Sy≡S[x+y] #-} x+S0≡Sx : ∀ {n} → N n → n + succ₁ zero ≡ succ₁ n x+S0≡Sx nzero = +-leftIdentity (succ₁ zero) x+S0≡Sx (nsucc {n} Nn) = prf (x+S0≡Sx Nn) where postulate prf : n + succ₁ zero ≡ succ₁ n → succ₁ n + succ₁ zero ≡ succ₁ (succ₁ n) {-# ATP prove prf #-} 0∸x : ∀ {n} → N n → zero ∸ n ≡ zero 0∸x nzero = ∸-x0 zero 0∸x (nsucc {n} Nn) = prf (0∸x Nn) where postulate prf : zero ∸ n ≡ zero → zero ∸ succ₁ n ≡ zero {-# ATP prove prf #-} S∸S : ∀ {m n} → N m → N n → succ₁ m ∸ succ₁ n ≡ m ∸ n S∸S {m} Nm nzero = prf where postulate prf : succ₁ m ∸ succ₁ zero ≡ m ∸ zero {-# ATP prove prf #-} S∸S {m} Nm (nsucc {n} Nn) = prf (S∸S Nm Nn) where postulate prf : succ₁ m ∸ succ₁ n ≡ m ∸ n → succ₁ m ∸ succ₁ (succ₁ n) ≡ m ∸ succ₁ n {-# ATP prove prf #-} x∸x≡0 : ∀ {n} → N n → n ∸ n ≡ zero x∸x≡0 nzero = ∸-x0 zero x∸x≡0 (nsucc {n} Nn) = prf (x∸x≡0 Nn) where postulate prf : n ∸ n ≡ zero → succ₁ n ∸ succ₁ n ≡ zero {-# ATP prove prf S∸S #-} Sx∸x≡S0 : ∀ {n} → N n → succ₁ n ∸ n ≡ succ₁ zero Sx∸x≡S0 nzero = prf where postulate prf : succ₁ zero ∸ zero ≡ succ₁ zero {-# ATP prove prf #-} Sx∸x≡S0 (nsucc {n} Nn) = prf (Sx∸x≡S0 Nn) where postulate prf : succ₁ n ∸ n ≡ succ₁ zero → succ₁ (succ₁ n) ∸ succ₁ n ≡ succ₁ zero {-# ATP prove prf S∸S #-} [x+Sy]∸y≡Sx : ∀ {m n} → N m → N n → (m + succ₁ n) ∸ n ≡ succ₁ m [x+Sy]∸y≡Sx {n = n} nzero Nn = prf where postulate prf : zero + succ₁ n ∸ n ≡ succ₁ zero {-# ATP prove prf Sx∸x≡S0 #-} [x+Sy]∸y≡Sx (nsucc {m} Nm) nzero = prf where postulate prf : succ₁ m + succ₁ zero ∸ zero ≡ succ₁ (succ₁ m) {-# ATP prove prf x+S0≡Sx #-} [x+Sy]∸y≡Sx (nsucc {m} Nm) (nsucc {n} Nn) = prf ([x+Sy]∸y≡Sx (nsucc Nm) Nn) where postulate prf : succ₁ m + succ₁ n ∸ n ≡ succ₁ (succ₁ m) → succ₁ m + succ₁ (succ₁ n) ∸ succ₁ n ≡ succ₁ (succ₁ m) {-# ATP prove prf S∸S +-N x+Sy≡S[x+y] #-} [x+y]∸[x+z]≡y∸z : ∀ {m n o} → N m → N n → N o → (m + n) ∸ (m + o) ≡ n ∸ o [x+y]∸[x+z]≡y∸z {n = n} {o} nzero Nn No = prf where postulate prf : (zero + n) ∸ (zero + o) ≡ n ∸ o {-# ATP prove prf #-} [x+y]∸[x+z]≡y∸z {n = n} {o} (nsucc {m} Nm) Nn No = prf ([x+y]∸[x+z]≡y∸z Nm Nn No) where postulate prf : (m + n) ∸ (m + o) ≡ n ∸ o → (succ₁ m + n) ∸ (succ₁ m + o) ≡ n ∸ o {-# ATP prove prf +-N S∸S #-} *-leftZero : ∀ n → zero * n ≡ zero *-leftZero = *-0x *-rightZero : ∀ {n} → N n → n * zero ≡ zero *-rightZero nzero = *-leftZero zero *-rightZero (nsucc {n} Nn) = prf (*-rightZero Nn) where postulate prf : n * zero ≡ zero → succ₁ n * zero ≡ zero {-# ATP prove prf #-} postulate *-leftIdentity : ∀ {n} → N n → succ₁ zero * n ≡ n {-# ATP prove *-leftIdentity +-rightIdentity #-} x*Sy≡x+xy : ∀ {m n} → N m → N n → m * succ₁ n ≡ m + m * n x*Sy≡x+xy {n = n} nzero Nn = prf where postulate prf : zero * succ₁ n ≡ zero + zero * n {-# ATP prove prf #-} x*Sy≡x+xy {n = n} (nsucc {m} Nm) Nn = prf (x*Sy≡x+xy Nm Nn) (+-assoc Nn m (m * n)) (+-assoc Nm n (m * n)) where -- N.B. We had to feed the ATP with the instances of the associate law postulate prf : m * succ₁ n ≡ m + m * n → (n + m) + (m * n) ≡ n + (m + (m * n)) → -- Associative law (m + n) + (m * n) ≡ m + (n + (m * n)) → -- Associateve law succ₁ m * succ₁ n ≡ succ₁ m + succ₁ m * n {-# ATP prove prf +-comm #-} *-comm : ∀ {m n} → N m → N n → m * n ≡ n * m *-comm {n = n} nzero Nn = prf where postulate prf : zero * n ≡ n * zero {-# ATP prove prf *-rightZero #-} *-comm {n = n} (nsucc {m} Nm) Nn = prf (*-comm Nm Nn) where postulate prf : m * n ≡ n * m → succ₁ m * n ≡ n * succ₁ m {-# ATP prove prf x*Sy≡x+xy #-} *-rightIdentity : ∀ {n} → N n → n * succ₁ zero ≡ n *-rightIdentity nzero = prf where postulate prf : zero * succ₁ zero ≡ zero {-# ATP prove prf #-} *-rightIdentity (nsucc {n} Nn) = prf (*-rightIdentity Nn) where postulate prf : n * succ₁ zero ≡ n → succ₁ n * succ₁ zero ≡ succ₁ n {-# ATP prove prf #-} *∸-leftDistributive : ∀ {m n o} → N m → N n → N o → (m ∸ n) * o ≡ m * o ∸ n * o *∸-leftDistributive {m} {o = o} Nm nzero No = prf where postulate prf : (m ∸ zero) * o ≡ m * o ∸ zero * o {-# ATP prove prf #-} *∸-leftDistributive {o = o} nzero (nsucc {n} Nn) No = prf where postulate prf : (zero ∸ succ₁ n) * o ≡ zero * o ∸ succ₁ n * o {-# ATP prove prf 0∸x *-N #-} *∸-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) nzero = prf where postulate prf : (succ₁ m ∸ succ₁ n) * zero ≡ succ₁ m * zero ∸ succ₁ n * zero {-# ATP prove prf ∸-N *-comm #-} *∸-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) = prf (*∸-leftDistributive Nm Nn (nsucc No)) where postulate prf : (m ∸ n) * succ₁ o ≡ m * succ₁ o ∸ n * succ₁ o → (succ₁ m ∸ succ₁ n) * succ₁ o ≡ succ₁ m * succ₁ o ∸ succ₁ n * succ₁ o {-# ATP prove prf [x+y]∸[x+z]≡y∸z S∸S *-N #-} *+-leftDistributive : ∀ {m n o} → N m → N n → N o → (m + n) * o ≡ m * o + n * o *+-leftDistributive {m} {n} Nm Nn nzero = prf where postulate prf : (m + n) * zero ≡ m * zero + n * zero {-# ATP prove prf *-comm +-rightIdentity *-N +-N #-} *+-leftDistributive {n = n} nzero Nn (nsucc {o} No) = prf where postulate prf : (zero + n) * succ₁ o ≡ zero * succ₁ o + n * succ₁ o {-# ATP prove prf #-} *+-leftDistributive (nsucc {m} Nm) nzero (nsucc {o} No) = prf where postulate prf : (succ₁ m + zero) * succ₁ o ≡ succ₁ m * succ₁ o + zero * succ₁ o {-# ATP prove prf +-rightIdentity *-N #-} *+-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) = prf (*+-leftDistributive Nm (nsucc Nn) (nsucc No)) where postulate prf : (m + succ₁ n) * succ₁ o ≡ m * succ₁ o + succ₁ n * succ₁ o → (succ₁ m + succ₁ n) * succ₁ o ≡ succ₁ m * succ₁ o + succ₁ n * succ₁ o {-# ATP prove prf +-assoc *-N #-} xy≡0→x≡0∨y≡0 : ∀ {m n} → N m → N n → m * n ≡ zero → m ≡ zero ∨ n ≡ zero xy≡0→x≡0∨y≡0 {n = n} nzero Nn h = prf where postulate prf : zero ≡ zero ∨ n ≡ zero {-# ATP prove prf #-} xy≡0→x≡0∨y≡0 (nsucc {m} Nm) nzero h = prf where postulate prf : succ₁ m ≡ zero ∨ zero ≡ zero {-# ATP prove prf #-} xy≡0→x≡0∨y≡0 (nsucc {m} Nm) (nsucc {n} Nn) SmSn≡0 = ⊥-elim (0≢S prf) where postulate prf : zero ≡ succ₁ (n + m * succ₁ n) {-# ATP prove prf #-} xy≡1→x≡1 : ∀ {m n} → N m → N n → m * n ≡ 1' → m ≡ 1' xy≡1→x≡1 {n = n} nzero Nn h = ⊥-elim prf where postulate prf : ⊥ {-# ATP prove prf #-} xy≡1→x≡1 (nsucc nzero) Nn h = refl xy≡1→x≡1 (nsucc (nsucc {m} Nm)) nzero h = ⊥-elim prf where postulate prf : ⊥ {-# ATP prove prf *-rightZero #-} xy≡1→x≡1 (nsucc (nsucc {m} Nm)) (nsucc {n} Nn) h = ⊥-elim (0≢S prf) where postulate prf : zero ≡ succ₁ (m + n * succ₁ (succ₁ m)) {-# ATP prove prf *-comm #-}
{ "alphanum_fraction": 0.4856202188, "avg_line_length": 38.5335820896, "ext": "agda", "hexsha": "9924060cb13ef5194dab73d460efdf337ede92d6", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Data/Nat/PropertiesATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Data/Nat/PropertiesATP.agda", "max_line_length": 81, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/Nat/PropertiesATP.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 4344, "size": 10327 }
-- Sometimes we can't infer a record type module InferRecordTypes-3 where postulate A : Set record R : Set₁ where field x₁ : Set x₂ : Set record R′ : Set₁ where field x₁ : Set x₃ : Set bad = record { x₂ = A; x₃ = A }
{ "alphanum_fraction": 0.6131687243, "avg_line_length": 13.5, "ext": "agda", "hexsha": "1d9c2a4fe0d8365eb72cd4266c37579f134ac780", "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/InferRecordTypes-3.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/InferRecordTypes-3.agda", "max_line_length": 41, "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/InferRecordTypes-3.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 86, "size": 243 }
{-# OPTIONS --without-K #-} open import Base open import Algebra.Groups open import Integers module Algebra.GroupIntegers where _+_ : ℤ → ℤ → ℤ O + m = m pos O + m = succ m pos (S n) + m = succ (pos n + m) neg O + m = pred m neg (S n) + m = pred (neg n + m) -_ : ℤ → ℤ - O = O - (pos m) = neg m - (neg m) = pos m +-succ : (m n : ℤ) → succ m + n ≡ succ (m + n) +-succ O n = refl _ +-succ (pos m) n = refl _ +-succ (neg O) n = ! (succ-pred n) +-succ (neg (S m)) n = ! (succ-pred _) +-pred : (m n : ℤ) → pred m + n ≡ pred (m + n) +-pred O n = refl _ +-pred (pos O) n = ! (pred-succ n) +-pred (pos (S m)) n = ! (pred-succ _) +-pred (neg m) n = refl _ +-assoc : (m n p : ℤ) → (m + n) + p ≡ m + (n + p) +-assoc O n p = refl _ +-assoc (pos O) n p = +-succ n p +-assoc (pos (S m)) n p = +-succ (pos m + n) p ∘ map succ (+-assoc (pos m) n p) +-assoc (neg O) n p = +-pred n p +-assoc (neg (S m)) n p = +-pred (neg m + n) p ∘ map pred (+-assoc (neg m) n p) O-right-unit : (m : ℤ) → m + O ≡ m O-right-unit O = refl _ O-right-unit (pos O) = refl _ O-right-unit (pos (S m)) = map succ (O-right-unit (pos m)) O-right-unit (neg O) = refl _ O-right-unit (neg (S m)) = map pred (O-right-unit (neg m)) succ-+-right : (m n : ℤ) → succ (m + n) ≡ m + succ n succ-+-right O n = refl _ succ-+-right (pos O) n = refl _ succ-+-right (pos (S m)) n = map succ (succ-+-right (pos m) n) succ-+-right (neg O) n = succ-pred n ∘ ! (pred-succ n) succ-+-right (neg (S m)) n = (succ-pred (neg m + n) ∘ ! (pred-succ (neg m + n))) ∘ map pred (succ-+-right (neg m) n) pred-+-right : (m n : ℤ) → pred (m + n) ≡ m + pred n pred-+-right O n = refl _ pred-+-right (pos O) n = pred-succ n ∘ ! (succ-pred n) pred-+-right (pos (S m)) n = (pred-succ (pos m + n) ∘ ! (succ-pred (pos m + n))) ∘ map succ (pred-+-right (pos m) n) pred-+-right (neg O) n = refl _ pred-+-right (neg (S m)) n = map pred (pred-+-right (neg m) n) opp-right-inverse : (m : ℤ) → m + (- m) ≡ O opp-right-inverse O = refl O opp-right-inverse (pos O) = refl O opp-right-inverse (pos (S m)) = succ-+-right (pos m) (neg (S m)) ∘ opp-right-inverse (pos m) opp-right-inverse (neg O) = refl O opp-right-inverse (neg (S m)) = pred-+-right (neg m) (pos (S m)) ∘ opp-right-inverse (neg m) opp-left-inverse : (m : ℤ) → (- m) + m ≡ O opp-left-inverse O = refl O opp-left-inverse (pos O) = refl O opp-left-inverse (pos (S m)) = pred-+-right (neg m) (pos (S m)) ∘ opp-left-inverse (pos m) opp-left-inverse (neg O) = refl O opp-left-inverse (neg (S m)) = succ-+-right (pos m) (neg (S m)) ∘ opp-left-inverse (neg m) -- pred-+-right (neg m) (pos (S m)) ∘ opp-left-inverse (pos m) ℤ-group : Group _ ℤ-group = group (pregroup ℤ _+_ O -_ +-assoc O-right-unit (λ m → refl _) opp-right-inverse opp-left-inverse) ℤ-is-set
{ "alphanum_fraction": 0.5193482688, "avg_line_length": 33.4772727273, "ext": "agda", "hexsha": "95f73622fc740400bc5c071f7c029666426d7995", "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/Algebra/GroupIntegers.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/Algebra/GroupIntegers.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/Algebra/GroupIntegers.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": 1086, "size": 2946 }
------------------------------------------------------------------------------ -- Testing the erasing of proof terms ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module ProofTerm2 where postulate D : Set N : D → Set _≡_ : D → D → Set postulate foo : ∀ {m n} → (Nm : N m) → (Nn : N n) → m ≡ m {-# ATP prove foo #-}
{ "alphanum_fraction": 0.3558052434, "avg_line_length": 28.1052631579, "ext": "agda", "hexsha": "9076d2ec165d73846e6582ebccfc9ce6f2dc49ed", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Succeed/fol-theorems/ProofTerm2.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Succeed/fol-theorems/ProofTerm2.agda", "max_line_length": 78, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Succeed/fol-theorems/ProofTerm2.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 115, "size": 534 }
module LateMetaVariableInstantiation where data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} postulate yippie : (A : Set) → A slow : (A : Set) → ℕ → A slow A zero = yippie A slow A (suc n) = slow _ n data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x foo : slow ℕ 1000 ≡ yippie ℕ foo = refl -- Consider the function slow. Previously normalisation of slow n -- seemed to take time proportional to n². The reason was that, even -- though the meta-variable corresponding to the underscore was -- solved, the stored code still contained a meta-variable: -- slow A (suc n) = slow (_173 A n) n -- (For some value of 173.) The evaluation proceeded as follows: -- slow A 1000 = -- slow (_173 A 999) 999 = -- slow (_173 (_173 A 999) 998) 998 = -- ... -- Furthermore, in every iteration the Set argument was traversed, to -- see if there was any de Bruijn index to raise.
{ "alphanum_fraction": 0.6497297297, "avg_line_length": 24.3421052632, "ext": "agda", "hexsha": "876ad1c707f3ccebf11e500bb53b8b73552bd3f4", "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": "benchmark/misc/LateMetaVariableInstantiation.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": "benchmark/misc/LateMetaVariableInstantiation.agda", "max_line_length": 69, "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": "benchmark/misc/LateMetaVariableInstantiation.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": 293, "size": 925 }
module _ where open import Agda.Primitive open import Agda.Builtin.List open import Agda.Builtin.Nat hiding (_==_) open import Agda.Builtin.Equality open import Agda.Builtin.Unit open import Agda.Builtin.Bool infix -1 _,_ record _×_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where constructor _,_ field fst : A snd : B open _×_ data Constraint : Set₁ where mkConstraint : {A : Set} (x y : A) → x ≡ y → Constraint infix 0 _==_ pattern _==_ x y = mkConstraint x y refl T : Bool → Set T false = Nat T true = Nat → Nat bla : (Nat → Nat) → Nat → Nat bla f zero = zero bla f = f -- underapplied clause! pred : Nat → Nat pred zero = zero pred (suc n) = n -- 0 and 1 are both solutions, so should not be solved. bad! : Constraint bad! = bla pred _ == zero -- Should not fail, since 2 is a solution! more-bad! : Constraint more-bad! = bla pred _ == 1 -- Same thing for projections blabla : Nat → Nat × Nat blabla zero = 1 , 1 blabla (suc n) = 0 , n -- Don't fail: 0 is a valid solution oops : Constraint oops = fst (blabla _) == 1 bla₂ : Bool → Nat × Nat bla₂ false = 0 , 1 bla₂ true .fst = 0 bla₂ true .snd = 1 -- Don't solve: false and true are both solutions wrong : Constraint wrong = bla₂ _ .fst == 0
{ "alphanum_fraction": 0.6512570965, "avg_line_length": 19.8870967742, "ext": "agda", "hexsha": "06d30e15542d2eb3b625e0dcfb0f494f80aa1277", "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/Issue2944.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/Issue2944.agda", "max_line_length": 60, "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/Issue2944.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": 425, "size": 1233 }
{-# OPTIONS --cubical --safe #-} module Multidimensional.Data.Extra.Nat where open import Multidimensional.Data.Extra.Nat.Base public open import Multidimensional.Data.Extra.Nat.Properties public
{ "alphanum_fraction": 0.803030303, "avg_line_length": 28.2857142857, "ext": "agda", "hexsha": "4cd29a7595da762cbf4f3296b3106a224871bf20", "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": "55709dd950e319c4a105ace33ddaf8b955354add", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_forks_repo_path": "Multidimensional/Data/Extra/Nat.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_issues_repo_issues_event_max_datetime": "2019-07-02T16:24:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-19T20:40:07.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_issues_repo_path": "Multidimensional/Data/Extra/Nat.agda", "max_line_length": 61, "max_stars_count": null, "max_stars_repo_head_hexsha": "55709dd950e319c4a105ace33ddaf8b955354add", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wrrnhttn/agda-cubical-multidimensional", "max_stars_repo_path": "Multidimensional/Data/Extra/Nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 46, "size": 198 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT module homotopy.CircleCover {j} where record S¹Cover : Type (lsucc j) where constructor s¹cover field El : Type j {{El-level}} : is-set El El-auto : El ≃ El S¹cover-to-S¹-cover : S¹Cover → Cover S¹ j S¹cover-to-S¹-cover sc = record { Fiber = S¹-rec El (ua El-auto); Fiber-level = λ {a} → S¹-elim {P = λ a → is-set (S¹-rec El (ua El-auto) a)} El-level prop-has-all-paths-↓ a} where open S¹Cover sc S¹-cover-to-S¹cover : Cover S¹ j → S¹Cover S¹-cover-to-S¹cover c = record { El = Fiber base; El-auto = coe-equiv (ap Fiber loop)} where open Cover c S¹cover-equiv-S¹-cover : S¹Cover ≃ Cover S¹ j S¹cover-equiv-S¹-cover = equiv to from to-from from-to where to = S¹cover-to-S¹-cover from = S¹-cover-to-S¹cover to-from : ∀ c → to (from c) == c to-from c = cover=' $ λ= $ S¹-elim idp $ ↓-='-in' $ ! $ ap (S¹-rec (Fiber base) (ua (coe-equiv (ap Fiber loop)))) loop =⟨ S¹Rec.loop-β _ _ ⟩ ua (coe-equiv (ap Fiber loop)) =⟨ ua-η _ ⟩ ap Fiber loop =∎ where open Cover c from-to : ∀ sc → from (to sc) == sc from-to sc = ap (λ eq → s¹cover El eq) $ coe-equiv (ap (S¹-rec El (ua El-auto)) loop) =⟨ ap coe-equiv $ S¹Rec.loop-β _ _ ⟩ coe-equiv (ua El-auto) =⟨ coe-equiv-β El-auto ⟩ El-auto =∎ where open S¹Cover sc
{ "alphanum_fraction": 0.5945165945, "avg_line_length": 28.2857142857, "ext": "agda", "hexsha": "2ab272663861e1e37087f85a17ce07062b6d5954", "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": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/CircleCover.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "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": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/CircleCover.agda", "max_line_length": 110, "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": "theorems/homotopy/CircleCover.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": 500, "size": 1386 }
-- This module closely follows a section of Martín Escardó's HoTT lecture notes: -- https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#equivalenceinduction {-# OPTIONS --without-K #-} module Util.HoTT.Equiv.Induction where open import Util.HoTT.HLevel.Core open import Util.HoTT.Equiv open import Util.HoTT.Univalence.ContrFormulation open import Util.Prelude private variable α β γ : Level G-≃ : {A : Set α} (P : Σ[ B ∈ Set α ] (A ≃ B) → Set β) → P (A , ≃-refl) → ∀ {B} (A≃B : A ≃ B) → P (B , A≃B) G-≃ {A = A} P p {B} A≃B = subst P (univalenceProp A (A , ≃-refl) (B , A≃B)) p abstract G-≃-β : {A : Set α} (P : Σ[ B ∈ Set α ] (A ≃ B) → Set β) → (p : P (A , ≃-refl)) → G-≃ P p ≃-refl ≡ p G-≃-β {A = A} P p = subst (λ q → subst P q p ≡ p) (sym go) refl where go : univalenceProp A (A , ≃-refl) (A , ≃-refl) ≡ refl go = IsContr→IsSet (univalenceContr A) _ _ H-≃ : {A : Set α} (P : (B : Set α) → A ≃ B → Set β) → P A ≃-refl → ∀ {B} (A≃B : A ≃ B) → P B A≃B H-≃ P p A≃B = G-≃ (λ { (B , A≃B) → P B A≃B }) p A≃B abstract H-≃-β : {A : Set α} (P : (B : Set α) → A ≃ B → Set β) → (p : P A ≃-refl) → H-≃ P p ≃-refl ≡ p H-≃-β P p = G-≃-β (λ { (B , A≃B) → P B A≃B }) p J-≃ : (P : (A B : Set α) → A ≃ B → Set β) → (∀ A → P A A ≃-refl) → ∀ {A B} (A≃B : A ≃ B) → P A B A≃B J-≃ P p {A} {B} A≃B = H-≃ (λ B A≃B → P A B A≃B) (p A) A≃B abstract J-≃-β : (P : (A B : Set α) → A ≃ B → Set β) → (p : ∀ A → P A A ≃-refl) → ∀ {A} → J-≃ P p ≃-refl ≡ p A J-≃-β P p {A} = H-≃-β (λ B A≃B → P A B A≃B) (p A) H-IsEquiv : {A : Set α} (P : (B : Set α) → (A → B) → Set β) → P A id → ∀ {B} (f : A → B) → IsEquiv f → P B f H-IsEquiv P p f f-equiv = H-≃ (λ B A≃B → P B (A≃B .forth)) p (record { forth = f ; isEquiv = f-equiv }) J-IsEquiv : (P : (A B : Set α) → (A → B) → Set β) → (∀ A → P A A id) → ∀ {A B} (f : A → B) → IsEquiv f → P A B f J-IsEquiv P p f f-equiv = J-≃ (λ A B A≃B → P A B (A≃B .forth)) p (record { forth = f ; isEquiv = f-equiv })
{ "alphanum_fraction": 0.4685686654, "avg_line_length": 25.5308641975, "ext": "agda", "hexsha": "d8537922917c4f29781878c0ff12df39aa34f817", "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/Util/HoTT/Equiv/Induction.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/Util/HoTT/Equiv/Induction.agda", "max_line_length": 102, "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/Util/HoTT/Equiv/Induction.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": 1058, "size": 2068 }
{-# OPTIONS --warning=error #-} A : Set₁ A = Set {-# POLARITY A #-}
{ "alphanum_fraction": 0.5285714286, "avg_line_length": 10, "ext": "agda", "hexsha": "00b17446f4ca99e0562511f86e842687b05c2103", "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/Polarity-pragma-for-defined-name.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/Polarity-pragma-for-defined-name.agda", "max_line_length": 31, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Polarity-pragma-for-defined-name.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 22, "size": 70 }
module UnSized.Console where open import UnSizedIO.Base hiding (main) open import UnSizedIO.Console hiding (main) open import NativeIO {-# TERMINATING #-} myProgram : IOConsole Unit force myProgram = exec' getLine λ line → delay (exec' (putStrLn line) λ _ → delay (exec' (putStrLn line) λ _ → myProgram )) main : NativeIO Unit main = translateIOConsole myProgram
{ "alphanum_fraction": 0.5856236786, "avg_line_length": 24.8947368421, "ext": "agda", "hexsha": "ba24cde61625ff29d2318f21fbe88cc7f63fbbf2", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/UnSized/Console.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "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": "agda/ooAgda", "max_issues_repo_path": "examples/UnSized/Console.agda", "max_line_length": 58, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/UnSized/Console.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 121, "size": 473 }
module Prelude.Variables where open import Agda.Primitive open import Agda.Builtin.Nat variable ℓ ℓ₁ ℓ₂ ℓ₃ : Level A B : Set ℓ x y : A n m : Nat
{ "alphanum_fraction": 0.6923076923, "avg_line_length": 13, "ext": "agda", "hexsha": "c7099e53930a80e73aa6e4eadffb236fc35a5fb7", "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": "1984cf0341835b2f7bfe678098bd57cfe16ea11f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jespercockx/agda-prelude", "max_forks_repo_path": "src/Prelude/Variables.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1984cf0341835b2f7bfe678098bd57cfe16ea11f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jespercockx/agda-prelude", "max_issues_repo_path": "src/Prelude/Variables.agda", "max_line_length": 30, "max_stars_count": null, "max_stars_repo_head_hexsha": "1984cf0341835b2f7bfe678098bd57cfe16ea11f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jespercockx/agda-prelude", "max_stars_repo_path": "src/Prelude/Variables.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 61, "size": 156 }
open import core module focus-formation where -- every ε is an evaluation context -- trivially, here, since we don't -- include any of the premises in red brackets about finality focus-formation : ∀{d d' ε} → d == ε ⟦ d' ⟧ → ε evalctx focus-formation FHOuter = ECDot focus-formation (FHAp1 sub) = ECAp1 (focus-formation sub) focus-formation (FHAp2 sub) = ECAp2 (focus-formation sub) focus-formation (FHNEHole sub) = ECNEHole (focus-formation sub) focus-formation (FHCast sub) = ECCast (focus-formation sub) focus-formation (FHFailedCast x) = ECFailedCast (focus-formation x)
{ "alphanum_fraction": 0.7255892256, "avg_line_length": 45.6923076923, "ext": "agda", "hexsha": "97d13d9d8809e56600098892991058959dc56677", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_forks_repo_path": "focus-formation.agda", "max_issues_count": 54, "max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_issues_repo_path": "focus-formation.agda", "max_line_length": 72, "max_stars_count": 16, "max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_stars_repo_path": "focus-formation.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z", "max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z", "num_tokens": 183, "size": 594 }
{-# OPTIONS --without-K #-} open import HoTT open import homotopy.PtdAdjoint open import homotopy.SuspAdjointLoop open import cohomology.Exactness open import cohomology.FunctionOver open import cohomology.MayerVietoris open import cohomology.Theory {- Standard Mayer-Vietoris exact sequence (algebraic) derived from - the result in cohomology.MayerVietoris (topological). - This is a whole bunch of algebra which is not very interesting. -} module cohomology.MayerVietorisExact {i} (CT : CohomologyTheory i) (n : ℤ) (ps : ⊙Span {i} {i} {i}) where open MayerVietorisFunctions ps module MV = MayerVietoris ps open ⊙Span ps open CohomologyTheory CT open import cohomology.BaseIndependence CT open import cohomology.Functor CT open import cohomology.InverseInSusp CT open import cohomology.LongExactSequence CT n ⊙reglue open import cohomology.Wedge CT mayer-vietoris-seq : HomSequence _ _ mayer-vietoris-seq = C n (⊙Pushout ps) ⟨ ×ᴳ-hom-in (CF-hom n (⊙left ps)) (CF-hom n (⊙right ps)) ⟩→ C n X ×ᴳ C n Y ⟨ ×ᴳ-sum-hom (C-abelian _ _) (CF-hom n f) (inv-hom _ (C-abelian _ _) ∘ᴳ (CF-hom n g)) ⟩→ C n Z ⟨ CF-hom (succ n) ⊙ext-glue ∘ᴳ fst ((C-Susp n Z)⁻¹ᴳ) ⟩→ C (succ n) (⊙Pushout ps) ⟨ ×ᴳ-hom-in (CF-hom _ (⊙left ps)) (CF-hom _ (⊙right ps)) ⟩→ C (succ n) X ×ᴳ C (succ n) Y ⊣| mayer-vietoris-exact : is-exact-seq mayer-vietoris-seq mayer-vietoris-exact = transport (λ {(r , s) → is-exact-seq s}) (pair= _ $ sequence= _ _ $ idp ∥⟨ ↓-over-×-in _→ᴳ_ idp (CWedge.⊙wedge-rec-over n X Y _ _) ⟩∥ CWedge.path n X Y ∥⟨ ↓-over-×-in' _→ᴳ_ (ap↓ (λ φ → φ ∘ᴳ fst (C-Susp n (X ⊙∨ Y) ⁻¹ᴳ)) (CF-↓cod= (succ n) MV.ext-over) ∙ᵈ codomain-over-iso {χ = diff'} (codomain-over-equiv _ _)) (CWedge.wedge-hom-η n X Y _ ▹ ap2 (×ᴳ-sum-hom (C-abelian n Z)) inl-lemma inr-lemma) ⟩∥ ap (C (succ n)) MV.⊙path ∙ group-ua (C-Susp n Z) ∥⟨ ↓-over-×-in _→ᴳ_ (CF-↓dom= (succ n) MV.cfcod-over ∙ᵈ domain-over-iso (! (ap (λ h → CF _ ⊙ext-glue ∘ h) (λ= (is-equiv.g-f (snd (C-Susp n Z))))) ◃ domain-over-equiv _ _)) idp ⟩∥ idp ∥⟨ ↓-over-×-in _→ᴳ_ idp (CWedge.⊙wedge-rec-over (succ n) X Y _ _) ⟩∥ CWedge.path (succ n) X Y ∥⊣|) long-cofiber-exact where {- shorthand -} diff' = fst (C-Susp n Z) ∘ᴳ CF-hom (succ n) MV.⊙mv-diff ∘ᴳ fst (C-Susp n (X ⊙∨ Y) ⁻¹ᴳ) {- Variations on suspension axiom naturality -} natural-lemma₁ : {X Y : Ptd i} (n : ℤ) (f : fst (X ⊙→ Y)) → (fst (C-Susp n X) ∘ᴳ CF-hom _ (⊙susp-fmap f)) ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ) == CF-hom n f natural-lemma₁ {X} {Y} n f = ap (λ φ → φ ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ)) (C-SuspF n f) ∙ hom= _ _ (λ= (ap (CF n f) ∘ is-equiv.f-g (snd (C-Susp n Y)))) natural-lemma₂ : {X Y : Ptd i} (n : ℤ) (f : fst (X ⊙→ Y)) → CF-hom _ (⊙susp-fmap f) ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ) == fst (C-Susp n X ⁻¹ᴳ) ∘ᴳ CF-hom n f natural-lemma₂ {X} {Y} n f = hom= _ _ (λ= (! ∘ is-equiv.g-f (snd (C-Susp n X)) ∘ CF _ (⊙susp-fmap f) ∘ GroupHom.f (fst (C-Susp n Y ⁻¹ᴳ)))) ∙ ap (λ φ → fst (C-Susp n X ⁻¹ᴳ) ∘ᴳ φ) (natural-lemma₁ n f) {- Associativity lemmas -} assoc-lemma : ∀ {i} {G H K L J : Group i} (φ : L →ᴳ J) (ψ : K →ᴳ L) (χ : H →ᴳ K) (ξ : G →ᴳ H) → (φ ∘ᴳ ψ) ∘ᴳ χ ∘ᴳ ξ == φ ∘ᴳ ((ψ ∘ᴳ χ) ∘ᴳ ξ) assoc-lemma _ _ _ _ = hom= _ _ idp assoc-lemma₂ : ∀ {i} {G H K L J : Group i} (φ : L →ᴳ J) (ψ : K →ᴳ L) (χ : H →ᴳ K) (ξ : G →ᴳ H) → (φ ∘ᴳ ψ ∘ᴳ χ) ∘ᴳ ξ == φ ∘ᴳ ψ ∘ᴳ χ ∘ᴳ ξ assoc-lemma₂ _ _ _ _ = hom= _ _ idp inl-lemma : diff' ∘ᴳ CF-hom n (⊙projl X Y) == CF-hom n f inl-lemma = assoc-lemma₂ (fst (C-Susp n Z)) (CF-hom (succ n) MV.⊙mv-diff) (fst (C-Susp n (X ⊙∨ Y) ⁻¹ᴳ)) (CF-hom n (⊙projl X Y)) ∙ ap (λ φ → fst (C-Susp n Z) ∘ᴳ CF-hom (succ n) MV.⊙mv-diff ∘ᴳ φ) (! (natural-lemma₂ n (⊙projl X Y))) ∙ ! (assoc-lemma₂ (fst (C-Susp n Z)) (CF-hom _ MV.⊙mv-diff) (CF-hom _ (⊙susp-fmap (⊙projl X Y))) (fst (C-Susp n X ⁻¹ᴳ))) ∙ ap (λ φ → (fst (C-Susp n Z) ∘ᴳ φ) ∘ᴳ fst (C-Susp n X ⁻¹ᴳ)) (! (CF-comp _ (⊙susp-fmap (⊙projl X Y)) MV.⊙mv-diff)) ∙ ap (λ φ → (fst (C-Susp n Z) ∘ᴳ φ) ∘ᴳ fst (C-Susp n X ⁻¹ᴳ)) (CF-λ= (succ n) projl-mv-diff) ∙ natural-lemma₁ n f where {- Compute the left projection of mv-diff -} projl-mv-diff : (σz : fst (⊙Susp Z)) → susp-fmap (projl X Y) (MV.mv-diff σz) == susp-fmap (fst f) σz projl-mv-diff = Suspension-elim _ idp (merid _ (snd X)) $ ↓-='-from-square ∘ λ z → (ap-∘ (susp-fmap (projl X Y)) MV.mv-diff (merid _ z) ∙ ap (ap (susp-fmap (projl X Y))) (MV.MVDiff.glue-β z) ∙ ap-∙ (susp-fmap (projl X Y)) (merid _ (winl (fst f z))) (! (merid _ (winr (fst g z)))) ∙ (SuspFmap.glue-β (projl X Y) (winl (fst f z)) ∙2 (ap-! (susp-fmap _) (merid _ (winr (fst g z))) ∙ ap ! (SuspFmap.glue-β (projl X Y) (winr (fst g z)))))) ∙v⊡ (vid-square {p = merid _ (fst f z)} ⊡h rt-square (merid _ (snd X))) ⊡v∙ (∙-unit-r _ ∙ ! (SuspFmap.glue-β (fst f) z)) inr-lemma : diff' ∘ᴳ CF-hom n (⊙projr X Y) == inv-hom _ (C-abelian n Z) ∘ᴳ CF-hom n g inr-lemma = assoc-lemma₂ (fst (C-Susp n Z)) (CF-hom (succ n) MV.⊙mv-diff) (fst (C-Susp n (X ⊙∨ Y) ⁻¹ᴳ)) (CF-hom n (⊙projr X Y)) ∙ ap (λ φ → fst (C-Susp n Z) ∘ᴳ CF-hom (succ n) MV.⊙mv-diff ∘ᴳ φ) (! (natural-lemma₂ n (⊙projr X Y))) ∙ ! (assoc-lemma₂ (fst (C-Susp n Z)) (CF-hom _ MV.⊙mv-diff) (CF-hom _ (⊙susp-fmap (⊙projr X Y))) (fst (C-Susp n Y ⁻¹ᴳ))) ∙ ap (λ φ → (fst (C-Susp n Z) ∘ᴳ φ) ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ)) (! (CF-comp _ (⊙susp-fmap (⊙projr X Y)) MV.⊙mv-diff)) ∙ ∘ᴳ-assoc (fst (C-Susp n Z)) (CF-hom _ (⊙susp-fmap (⊙projr X Y) ⊙∘ MV.⊙mv-diff)) (fst (C-Susp n Y ⁻¹ᴳ)) ∙ ap (λ φ → fst (C-Susp n Z) ∘ᴳ φ ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ)) (CF-λ= (succ n) projr-mv-diff) ∙ ap (λ φ → fst (C-Susp n Z) ∘ᴳ φ ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ)) (CF-comp _ (⊙susp-fmap g) (⊙flip-susp Z)) ∙ ! (assoc-lemma (fst (C-Susp n Z)) (CF-hom _ (⊙flip-susp Z)) (CF-hom _ (⊙susp-fmap g)) (fst (C-Susp n Y ⁻¹ᴳ))) ∙ ap (λ φ → (fst (C-Susp n Z) ∘ᴳ φ) ∘ᴳ CF-hom _ (⊙susp-fmap g) ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ)) (C-flip-susp-is-inv (succ n)) ∙ ap (λ φ → φ ∘ᴳ CF-hom _ (⊙susp-fmap g) ∘ᴳ fst (C-Susp n Y ⁻¹ᴳ)) (inv-hom-natural (C-abelian _ _) (C-abelian _ _) (fst (C-Susp n Z))) ∙ assoc-lemma (inv-hom _ (C-abelian n Z)) (fst (C-Susp n Z)) (CF-hom _ (⊙susp-fmap g)) (fst (C-Susp n Y ⁻¹ᴳ)) ∙ ap (λ φ → inv-hom _ (C-abelian n Z) ∘ᴳ φ) (natural-lemma₁ n g) where {- Compute the right projection of mv-diff -} projr-mv-diff : (σz : fst (⊙Susp Z)) → susp-fmap (projr X Y) (MV.mv-diff σz) == susp-fmap (fst g) (flip-susp σz) projr-mv-diff = Suspension-elim _ (merid _ (snd Y)) idp $ ↓-='-from-square ∘ λ z → (ap-∘ (susp-fmap (projr X Y)) MV.mv-diff (merid _ z) ∙ ap (ap (susp-fmap (projr X Y))) (MV.MVDiff.glue-β z) ∙ ap-∙ (susp-fmap (projr X Y)) (merid _ (winl (fst f z))) (! (merid _ (winr (fst g z)))) ∙ (SuspFmap.glue-β (projr X Y) (winl (fst f z)) ∙2 (ap-! (susp-fmap (projr X Y)) (merid _ (winr (fst g z))) ∙ ap ! (SuspFmap.glue-β (projr X Y) (winr (fst g z)))))) ∙v⊡ ((lt-square (merid _ (snd Y)) ⊡h vid-square {p = ! (merid _ (fst g z))})) ⊡v∙ ! (ap-∘ (susp-fmap (fst g)) flip-susp (merid _ z) ∙ ap (ap (susp-fmap (fst g))) (FlipSusp.glue-β z) ∙ ap-! (susp-fmap (fst g)) (merid _ z) ∙ ap ! (SuspFmap.glue-β (fst g) z))
{ "alphanum_fraction": 0.5036623215, "avg_line_length": 42.8457446809, "ext": "agda", "hexsha": "2fadf9a4840cd810a8e5b1b595764be7069440ac", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "cohomology/MayerVietorisExact.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "cohomology/MayerVietorisExact.agda", "max_line_length": 76, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda", "max_stars_repo_path": "cohomology/MayerVietorisExact.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 3653, "size": 8055 }
--- Sample Sit file {-# OPTIONS --experimental-irrelevance #-} {-# OPTIONS --sized-types #-} open import Base --; --- Leibniz-equality Eq : forall (A : Set) (a b : A) -> Set1 --; Eq = \ A a b -> (P : A -> Set) -> (P a) -> P b --; --- Reflexivity refl : forall (A : Set) (a : A) -> Eq A a a --; refl = \ A a P pa -> pa --; --- Symmetry sym : forall (A : Set) (a b : A) -> Eq A a b -> Eq A b a --; sym = \ A a b eq P pb -> eq (\ x -> P x -> P a) (\ pa -> pa) pb --; --- Transitivity trans : forall (A : Set) (a b c : A) -> Eq A a b -> Eq A b c -> Eq A a c --; trans = \ A a b c p q P pa -> q P (p P pa) --; --- Congruence cong : forall (A B : Set) (f : A -> B) (a a' : A) -> Eq A a a' -> Eq B (f a) (f a') --; cong = \ A B f a a' eq P pfa -> eq (\ x -> P (f x)) pfa --; --- Addition plus : forall .i -> Nat i -> Nat oo -> Nat oo --; plus = \ i x y -> fix (\ i x -> Nat oo) (\ _ f -> \ { (zero _) -> y ; (suc _ x) -> suc oo (f x) }) x --; --- Unit tests for plus inc : Nat oo -> Nat oo --; inc = \ x -> suc oo x --; one : Nat oo --; one = inc (zero oo) --; two : Nat oo --; two = inc one --; three : Nat oo --; three = inc two --; four : Nat oo --; four = inc three --; five : Nat oo --; five = inc four --; six : Nat oo --; six = inc five --; plus_one_zero : Eq (Nat oo) (plus oo one (zero oo)) one --; plus_one_zero = refl (Nat oo) one --; plus_one_one : Eq (Nat oo) (plus oo one one) two --; plus_one_one = refl (Nat oo) two --; --; --- Reduction rules for plus plus_red_zero : forall .i (y : Nat oo) -> Eq (Nat oo) (plus (i + 1) (zero i) y) y --; plus_red_zero = \ i y -> refl (Nat oo) y --; plus_red_suc : forall .i (x : Nat i) (y : Nat oo) -> Eq (Nat oo) (plus (i + 1) (suc i x) y) (suc oo (plus i x y)) --; plus_red_suc = \ i x y -> refl (Nat oo) (suc oo (plus i x y)) --; --; --- Law: x + 0 = x plus_zero : forall .i (x : Nat i) -> Eq (Nat oo) (plus i x (zero oo)) x --; plus_zero = \ i x -> fix (\ i x -> Eq (Nat oo) (plus i x (zero oo)) x) (\ j f -> \ { (zero _) -> refl (Nat oo) (zero oo) ; (suc _ y) -> cong (Nat oo) (Nat oo) inc (plus j y (zero oo)) y (f y) }) x --; --- Law: x + suc y = suc x + y plus_suc : forall .i (x : Nat i) (y : Nat oo) -> Eq (Nat oo) (plus i x (inc y)) (inc (plus i x y)) --; plus_suc = \ i x y -> fix (\ i x -> Eq (Nat oo) (plus i x (inc y)) (inc (plus i x y))) (\ j f -> \ { (zero _) -> refl (Nat oo) (inc y) ; (suc _ x') -> cong (Nat oo) (Nat oo) inc (plus j x' (inc y)) (inc (plus j x' y)) (f x') }) x --; --- Another definition of addition plus' : forall .i -> Nat i -> Nat oo -> Nat oo --; plus' = \ i x -> fix (\ i x -> Nat oo -> Nat oo) (\ _ f -> \ { (zero _) -> \ y -> y ; (suc _ x) -> \ y -> suc oo (f x y) }) x --; --- Predecessor pred : forall .i -> Nat i -> Nat i --; pred = \ i n -> fix (\ i _ -> Nat i) (\ i _ -> \{ (zero _) -> zero i ; (suc _ y) -> y }) n --; --- Subtraction sub : forall .j -> Nat j -> forall .i -> Nat i -> Nat i --; sub = \ j y -> fix (\ _ _ -> forall .i -> Nat i -> Nat i) (\ _ f -> \ { (zero _) -> \ i x -> x ; (suc _ y) -> \ i x -> f y i (pred i x) }) --- pred i (f y i x) }) y --; --- Lemma: x - x == 0 sub_diag : forall .i (x : Nat i) -> Eq (Nat oo) (sub i x i x) (zero oo) --; sub_diag = \ i x -> fix (\ i x -> Eq (Nat oo) (sub i x i x) (zero oo)) (\ _ f -> \ { (zero _) -> refl (Nat oo) (zero oo) ; (suc _ y) -> f y }) x --- Large eliminations --; --- Varying arity Fun : forall .i (n : Nat i) (A : Set) (B : Set) -> Set --; Fun = \ i n A B -> fix (\ _ _ -> Set) (\ _ f -> \ { (zero _) -> B ; (suc _ x) -> A -> f x }) n --; --- Type of n-ary Sum function Sum : forall .i (n : Nat i) -> Set --; Sum = \ i n -> Nat oo -> Fun i n (Nat oo) (Nat oo) --; --- n-ary summation function sum : forall .i (n : Nat i) -> Sum i n --; sum = \ _ n -> fix (\ i n -> Sum i n) (\ _ f -> \ { (zero _) -> \ acc -> acc ; (suc _ x) -> \ acc -> \ k -> f x (plus oo k acc) }) n --; --- Testing sum sum123 : Eq (Nat oo) (sum oo three (zero oo) one two three) six --; sum123 = refl (Nat oo) six
{ "alphanum_fraction": 0.4337294333, "avg_line_length": 24.7231638418, "ext": "agda", "hexsha": "36abe0234eb5abf4650d025c1e52c3554d82d951", "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": "262b8a87db8ab58aa77f60a749eacb8c49c7471f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andreasabel/Sit", "max_forks_repo_path": "test/Test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "262b8a87db8ab58aa77f60a749eacb8c49c7471f", "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": "andreasabel/Sit", "max_issues_repo_path": "test/Test.agda", "max_line_length": 118, "max_stars_count": 6, "max_stars_repo_head_hexsha": "262b8a87db8ab58aa77f60a749eacb8c49c7471f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andreasabel/S", "max_stars_repo_path": "test/Test.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-07T19:52:52.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-16T02:28:36.000Z", "num_tokens": 1598, "size": 4376 }
module PosNat where open import Nats open import Data.Product open import Equality data ℕ⁺ : Set where psuc : ℕ → ℕ⁺ _→ℕ : ℕ⁺ → ℕ psuc zero →ℕ = suc zero psuc (suc x) →ℕ = suc (psuc x →ℕ) _⟨_⟩→ℕ⁺ : (a : ℕ) → ∃ (λ x → a ≡ suc x) → ℕ⁺ .(suc x) ⟨ x , refl ⟩→ℕ⁺ = psuc x
{ "alphanum_fraction": 0.559566787, "avg_line_length": 17.3125, "ext": "agda", "hexsha": "4d59644e80600bd6b8bf4fea1e511c6667957982", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_path": "src/PosNat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_path": "src/PosNat.agda", "max_line_length": 44, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_path": "src/PosNat.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "num_tokens": 136, "size": 277 }
module _ where module M where postulate [_] : Set → Set Foo = [ M.undefined ]
{ "alphanum_fraction": 0.6091954023, "avg_line_length": 9.6666666667, "ext": "agda", "hexsha": "f152fedce22d5de31016a85ada351033bfd6b1ac", "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/Issue1977.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/Issue1977.agda", "max_line_length": 21, "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/Issue1977.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": 26, "size": 87 }
open import Common.Prelude record Number (A : Set) : Set where field fromNat : Nat → A record Negative (A : Set) : Set where field fromNeg : Nat → A open Number {{...}} public open Negative {{...}} public {-# BUILTIN FROMNAT fromNat #-} {-# BUILTIN FROMNEG fromNeg #-} instance NumberNat : Number Nat NumberNat = record { fromNat = λ n → n } data Int : Set where pos : Nat → Int neg : Nat → Int instance NumberInt : Number Int NumberInt = record { fromNat = pos } NegativeInt : Negative Int NegativeInt = record { fromNeg = λ { zero → pos 0 ; (suc n) → neg n } } minusFive : Int minusFive = -5 open import Common.Equality thm : -5 ≡ neg 4 thm = refl
{ "alphanum_fraction": 0.6451612903, "avg_line_length": 17.9473684211, "ext": "agda", "hexsha": "9598fba6b260dd1a20a8958d25d3a9724775de64", "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/NegativeLiterals.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Succeed/NegativeLiterals.agda", "max_line_length": 73, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/NegativeLiterals.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": 208, "size": 682 }
import Lvl open import Type module Type.Functions.Inverse.Proofs {ℓₗ : Lvl.Level}{ℓₒ₁}{ℓₒ₂} {X : Type{ℓₒ₁}} {Y : Type{ℓₒ₂}} where open import Function.Domains open import Relator.Equals open import Type.Functions {ℓₗ} open import Type.Functions.Inverse {ℓₗ} open import Type.Properties.Empty open import Type.Properties.Singleton {ℓₒ₁}{ℓₒ₂} postulate inv-bijective : ∀{f : X → Y} → ⦃ proof : Bijective(f) ⦄ → Bijective(inv f) -- inv-bijective {f} ⦃ Bijective.intro(proof) ⦄ private _≡₁_ = _≡_ {ℓₗ Lvl.⊔ ℓₒ₁} invᵣ-is-inverseᵣ : (f : X → Y) → ⦃ _ : Surjective(f) ⦄ → ∀{y} → (f(invᵣ f(y)) ≡ y) invᵣ-is-inverseᵣ f ⦃ Surjective.intro(proof) ⦄ {y} with proof{y} ... | ◊.intro ⦃ Unapply.intro _ ⦃ out ⦄ ⦄ = out inv-is-inverseᵣ : (f : X → Y) → ⦃ _ : Bijective(f) ⦄ → ∀{y} → (f(inv f(y)) ≡ y) inv-is-inverseᵣ f ⦃ Bijective.intro(proof) ⦄ {y} with proof{y} ... | IsUnit.intro (Unapply.intro _ ⦃ out ⦄) _ = out inv-is-inverseₗ : (f : X → Y) → ⦃ _ : Bijective(f) ⦄ → ∀{x} → (inv f(f(x)) ≡₁ x) inv-is-inverseₗ f ⦃ Bijective.intro(proof) ⦄ {x} with proof{f(x)} ... | IsUnit.intro _ uniqueness with uniqueness {Unapply.intro x ⦃ [≡]-intro ⦄} ... | [≡]-intro = [≡]-intro
{ "alphanum_fraction": 0.6240409207, "avg_line_length": 35.5454545455, "ext": "agda", "hexsha": "351d4d726c1a69d13fe00f11ba41910949ebaf45", "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": "old/Type/Functions/Inverse/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Type/Functions/Inverse/Proofs.agda", "max_line_length": 101, "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": "old/Type/Functions/Inverse/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 516, "size": 1173 }
{-# OPTIONS --without-K #-} open import Types open import Functions open import Paths open import HLevel module Equivalences where hfiber : ∀ {i j} {A : Set i} {B : Set j} (f : A → B) (y : B) → Set (max i j) hfiber {A = A} f y = Σ A (λ x → f x ≡ y) is-equiv : ∀ {i j} {A : Set i} {B : Set j} (f : A → B) → Set (max i j) is-equiv {B = B} f = (y : B) → is-contr (hfiber f y) _~_ : ∀ {i j} {A : Set i} {B : Set j} (f g : A → B) → Set (max i j) _~_ {A = A} f g = (x : A) → (f x ≡ g x) is-iso : ∀ {i j} {A : Set i} {B : Set j} (f : A → B) → Set (max i j) is-iso {A = A} {B = B} f = Σ (B → A) (λ g → ((f ◯ g) ~ id B) × ((g ◯ f) ~ id A)) is-hae : ∀ {i j} {A : Set i} {B : Set j} (f : A → B) → Set (max i j) is-hae {A = A} {B = B} f = Σ (B → A) (λ g → Σ ((g ◯ f) ~ id A) (λ η → Σ ((f ◯ g) ~ id B) (λ ε → (x : A) → ap f (η x) ≡ ε (f x)))) iso-is-hae : ∀ {i j} {A : Set i} {B : Set j} → (f : A → B) → is-iso f → is-hae f iso-is-hae {A = A} {B = B} f (g , (ε , η)) = g , (η , (ε' , τ)) where ε' : (f ◯ g) ~ id B ε' b = ! (ε (f (g b))) ∘ ap f (η (g b)) ∘ ε b lem : (a : A) → η (g (f a)) ≡ ap (g ◯ f) (η a) lem a = η (g (f a)) ≡⟨ ! (refl-right-unit (η (g (f a))) ) ⟩ η (g (f a)) ∘ refl ≡⟨ ap (λ p → η (g (f a)) ∘ p) (! (opposite-right-inverse (η a))) ⟩ η (g (f a)) ∘ (η a ∘ (! (η a))) ≡⟨ ! (concat-assoc (η (g (f a))) (η a) (! (η a))) ⟩ (η (g (f a)) ∘ η a) ∘ (! (η a)) ≡⟨ ap (λ p → p ∘ (! (η a)) ) (! (homotopy-naturality-toid (g ◯ f) η (η a))) ⟩ (ap (g ◯ f) (η a) ∘ η a) ∘ (! (η a)) ≡⟨ concat-assoc (ap (g ◯ f) (η a)) (η a) (! (η a)) ⟩ ap (g ◯ f) (η a) ∘ (η a ∘ (! (η a))) ≡⟨ ap (λ p → ap (g ◯ f) (η a) ∘ p) (opposite-right-inverse (η a)) ⟩ ap (g ◯ f) (η a) ∘ refl ≡⟨ refl-right-unit (ap (g ◯ f) (η a)) ⟩ ap (g ◯ f) (η a) ∎ lem₂ : (a : A) → ε (f (g (f a))) ∘ ap f (η a) ≡ ap f (η (g (f a))) ∘ ε (f a) lem₂ a = ! (ap f (η (g (f a))) ∘ ε (f a) ≡⟨ ap (λ p → ap f p ∘ ε (f a)) (lem a) ⟩ ap f (ap (g ◯ f) (η a)) ∘ ε (f a) ≡⟨ ap (λ p → p ∘ ε (f a)) (compose-ap f (g ◯ f) (η a)) ⟩ ap (f ◯ (g ◯ f)) (η a) ∘ ε (f a) ≡⟨ homotopy-naturality (f ◯ (g ◯ f)) f (λ x → ε (f x)) (η a) ⟩ ε (f (g (f a))) ∘ ap f (η a) ∎) τ : (a : A) → ap f (η a) ≡ ε' (f a) τ a = ap f (η a) ≡⟨ refl ⟩ refl ∘ ap f (η a) ≡⟨ ap (λ p → p ∘ ap f (η a)) (! (opposite-left-inverse (ε (f (g (f a)))))) ⟩ (! (ε (f (g (f a)))) ∘ (ε (f (g (f a))))) ∘ ap f (η a) ≡⟨ concat-assoc (! (ε (f (g (f a))))) (ε (f (g (f a)))) (ap f (η a)) ⟩ ! (ε (f (g (f a)))) ∘ ((ε (f (g (f a)))) ∘ ap f (η a)) ≡⟨ ap (λ p → ! (ε (f (g (f a)))) ∘ p) (lem₂ a) ⟩ ! (ε (f (g (f a)))) ∘ (ap f (η (g (f a))) ∘ ε (f a)) ∎ hae-is-eq : ∀ {i j} {A : Set i} {B : Set j} → (f : A → B) → is-hae f → is-equiv f hae-is-eq f (g , (η , (ε , τ))) y = (g y , ε y) , contr where contr : (xp : hfiber f y) → xp ≡ g y , ε y contr (x , p) = total-Σ-eq ( ((! (η x)) ∘ ap g p) , t) where t : transport (λ z → f z ≡ y) (! (η x) ∘ ap g p) p ≡ ε y t = transport (λ z → f z ≡ y) (! (η x) ∘ ap g p) p ≡⟨ trans-app≡cst f y (! (η x) ∘ ap g p) p ⟩ ! (ap f (! (η x) ∘ ap g p)) ∘ p ≡⟨ ap (λ q → q ∘ p) (opposite-ap f (! (η x) ∘ ap g p)) ⟩ ap f (! (! (η x) ∘ ap g p)) ∘ p ≡⟨ ap (λ q → ap f q ∘ p) (opposite-concat (! (η x)) (ap g p)) ⟩ ap f (! (ap g p) ∘ ! (! (η x))) ∘ p ≡⟨ ap (λ q → ap f (! (ap g p) ∘ q) ∘ p) (opposite-opposite (η x)) ⟩ ap f (! (ap g p) ∘ η x) ∘ p ≡⟨ ap (λ q → q ∘ p) (ap-concat f (! (ap g p)) (η x)) ⟩ (ap f (! (ap g p)) ∘ ap f (η x)) ∘ p ≡⟨ ap (λ q → (q ∘ ap f (η x)) ∘ p) (ap-opposite f (ap g p)) ⟩ (! (ap f (ap g p)) ∘ ap f (η x)) ∘ p ≡⟨ ap (λ q → (! q ∘ ap f (η x)) ∘ p) (compose-ap f g p) ⟩ (! (ap (f ◯ g) p) ∘ ap f (η x)) ∘ p ≡⟨ ap (λ q → ((! (ap (f ◯ g) p)) ∘ q) ∘ p ) (τ x) ⟩ (! (ap (f ◯ g) p) ∘ ε (f x)) ∘ p ≡⟨ ap (λ q → (q ∘ ε (f x)) ∘ p) (opposite-ap (f ◯ g) p) ⟩ (ap (f ◯ g) (! p) ∘ ε (f x)) ∘ p ≡⟨ ap (λ q → q ∘ p) (homotopy-naturality-toid (f ◯ g) ε (! p)) ⟩ (ε y ∘ ! p) ∘ p ≡⟨ concat-assoc (ε y) (! p) p ⟩ ε y ∘ ((! p) ∘ p) ≡⟨ ap (λ q → ε y ∘ q) (opposite-left-inverse p) ⟩ ε y ∘ refl ≡⟨ refl-right-unit (ε y) ⟩ ε y ∎ _≃_ : ∀ {i j} (A : Set i) (B : Set j) → Set (max i j) -- \simeq A ≃ B = Σ (A → B) is-equiv id-is-equiv : ∀ {i} (A : Set i) → is-equiv (id A) id-is-equiv A = pathto-is-contr id-equiv : ∀ {i} (A : Set i) → A ≃ A id-equiv A = (id A , id-is-equiv A) path-to-eq : ∀ {i} {A B : Set i} → (A ≡ B → A ≃ B) path-to-eq refl = id-equiv _ module _ {i} {j} {A : Set i} {B : Set j} where -- Notation for the application of an equivalence to an argument _☆_ : (f : A ≃ B) (x : A) → B f ☆ x = (π₁ f) x inverse : (f : A ≃ B) → B → A inverse (f , e) = λ y → π₁ (π₁ (e y)) abstract inverse-right-inverse : (f : A ≃ B) (y : B) → f ☆ (inverse f y) ≡ y inverse-right-inverse (f , e) y = π₂ (π₁ (e y)) inverse-left-inverse : (f : A ≃ B) (x : A) → inverse f (f ☆ x) ≡ x inverse-left-inverse (f , e) x = ! (base-path (π₂ (e (f x)) (x , refl))) hfiber-triangle : (f : A → B) (z : B) {x y : hfiber f z} (p : x ≡ y) → ap f (base-path p) ∘ π₂ y ≡ π₂ x hfiber-triangle f z {x} {.x} refl = refl inverse-triangle : (f : A ≃ B) (x : A) → inverse-right-inverse f (f ☆ x) ≡ ap (π₁ f) (inverse-left-inverse f x) inverse-triangle (f , e) x = move1!-left-on-left _ _ (hfiber-triangle f _ (π₂ (e (f x)) (x , refl))) ∘ opposite-ap f _ iso-is-eq' : (f : A → B) → is-iso f → is-equiv f iso-is-eq' f iso = hae-is-eq f (iso-is-hae f iso) iso-is-eq : (f : A → B) → (g : B → A) → (∀ y → f (g y) ≡ y) → (∀ x → g (f x) ≡ x) → is-equiv f iso-is-eq f g η ε = iso-is-eq' _ (g , (η , ε)) inverse-iso-is-eq : (f : A → B) → (iso : is-iso f) → inverse (f , iso-is-eq' f iso) ≡ π₁ iso inverse-iso-is-eq f iso = refl -- The inverse of an equivalence is an equivalence inverse-is-equiv : ∀ {i} {j} {A : Set i} {B : Set j} (f : A ≃ B) → is-equiv (inverse f) inverse-is-equiv f = iso-is-eq (inverse f) (π₁ f) (inverse-left-inverse f) (inverse-right-inverse f) _⁻¹ : ∀ {i} {j} {A : Set i} {B : Set j} (f : A ≃ B) → B ≃ A -- \^-\^1 _⁻¹ f = (inverse f , inverse-is-equiv f) -- Equivalences are injective equiv-is-inj : ∀ {i} {j} {A : Set i} {B : Set j} (f : A ≃ B) (x y : A) → (f ☆ x ≡ f ☆ y → x ≡ y) equiv-is-inj f x y p = ! (inverse-left-inverse f x) ∘ (ap (inverse f) p ∘ inverse-left-inverse f y) -- Any contractible type is equivalent to the unit type contr-equiv-unit : ∀ {i j} {A : Set i} → (is-contr A → A ≃ unit {j}) contr-equiv-unit e = ((λ _ → tt) , iso-is-eq _ (λ _ → π₁ e) (λ _ → refl) (λ x → ! (π₂ e x))) -- The composite of two equivalences is an equivalence compose-is-equiv : ∀ {i j k} {A : Set i} {B : Set j} {C : Set k} (f : A ≃ B) (g : B ≃ C) → is-equiv (π₁ g ◯ π₁ f) compose-is-equiv f g = iso-is-eq _ (inverse f ◯ inverse g) (λ y → ap (π₁ g) (inverse-right-inverse f (inverse g y)) ∘ inverse-right-inverse g y) (λ x → ap (inverse f) (inverse-left-inverse g (π₁ f x)) ∘ inverse-left-inverse f x) equiv-compose : ∀ {i j k} {A : Set i} {B : Set j} {C : Set k} → (A ≃ B → B ≃ C → A ≃ C) equiv-compose f g = ((π₁ g ◯ π₁ f) , compose-is-equiv f g) -- An equivalence induces an equivalence on the path spaces -- The proofs here can probably be simplified module _ {i j} {A : Set i} {B : Set j} (f : A ≃ B) (x y : A) where private ap-is-inj : (p : f ☆ x ≡ f ☆ y) → x ≡ y ap-is-inj p = equiv-is-inj f x y p abstract left-inverse : (p : x ≡ y) → ap-is-inj (ap (π₁ f) p) ≡ p left-inverse p = move!-right-on-left (inverse-left-inverse f x) _ p (move-right-on-right (ap (inverse f) (ap (π₁ f) p)) _ _ (compose-ap (inverse f) (π₁ f) p ∘ move!-left-on-right (ap (inverse f ◯ π₁ f) p) (inverse-left-inverse f x ∘ p) (inverse-left-inverse f y) (homotopy-naturality-toid (inverse f ◯ π₁ f) (inverse-left-inverse f) p))) right-inverse : (p : f ☆ x ≡ f ☆ y) → ap (π₁ f) (ap-is-inj p) ≡ p right-inverse p = ap-concat (π₁ f) (! (inverse-left-inverse f x)) _ ∘ (ap (λ u → u ∘ ap (π₁ f) (ap (inverse f) p ∘ inverse-left-inverse f y)) (ap-opposite (π₁ f) (inverse-left-inverse f x)) ∘ move!-right-on-left (ap (π₁ f) (inverse-left-inverse f x)) _ p (ap-concat (π₁ f) (ap (inverse f) p) (inverse-left-inverse f y) ∘ (ap (λ u → u ∘ ap (π₁ f) (inverse-left-inverse f y)) (compose-ap (π₁ f) (inverse f) p) ∘ (whisker-left (ap (π₁ f ◯ inverse f) p) (! (inverse-triangle f y)) ∘ (homotopy-naturality-toid (π₁ f ◯ inverse f) (inverse-right-inverse f) p ∘ whisker-right p (inverse-triangle f x)))))) equiv-ap : (x ≡ y) ≃ (f ☆ x ≡ f ☆ y) equiv-ap = (ap (π₁ f) , iso-is-eq _ ap-is-inj right-inverse left-inverse) abstract total-Σ-eq-is-equiv : ∀ {i j} {A : Set i} {P : A → Set j} {x y : Σ A P} → is-equiv (total-Σ-eq {xu = x} {yv = y}) total-Σ-eq-is-equiv {P = P} = iso-is-eq _ (λ totp → base-path totp , fiber-path totp) Σ-eq-base-path-fiber-path (λ p → Σ-eq (base-path-Σ-eq (π₁ p) (π₂ p)) (fiber-path-Σ-eq {P = P} (π₁ p) (π₂ p))) total-Σ-eq-equiv : ∀ {i j} {A : Set i} {P : A → Set j} {x y : Σ A P} → (Σ (π₁ x ≡ π₁ y) (λ p → transport P p (π₂ x) ≡ (π₂ y))) ≃ (x ≡ y) total-Σ-eq-equiv = (total-Σ-eq , total-Σ-eq-is-equiv)
{ "alphanum_fraction": 0.4404531075, "avg_line_length": 39.9959183673, "ext": "agda", "hexsha": "cfabd229b6b34309fac3333a999a7072bae1bbfe", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Equivalences.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Equivalences.agda", "max_line_length": 96, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda", "max_stars_repo_path": "old/Equivalences.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 4374, "size": 9799 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Functor.Construction.SubCategory {o ℓ e} (C : Category o ℓ e) where open import Categories.Category.SubCategory C open Category C open Equiv open import Level open import Function.Base using () renaming (id to id→) open import Data.Product open import Categories.Functor using (Functor) private variable ℓ′ i : Level I : Set i U : I → Obj Sub : ∀ (sub : SubCat {i} {ℓ′} I) → Functor (SubCategory sub) C Sub (record {U = U}) = record { F₀ = U ; F₁ = proj₁ ; identity = refl ; homomorphism = refl ; F-resp-≈ = id→ } FullSub : Functor (FullSubCategory U) C FullSub {U = U} = record { F₀ = U ; F₁ = id→ ; identity = refl ; homomorphism = refl ; F-resp-≈ = id→ }
{ "alphanum_fraction": 0.6455696203, "avg_line_length": 19.2682926829, "ext": "agda", "hexsha": "5992cb2243f111147c2a5930dff6166d30989518", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Construction/SubCategory.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Construction/SubCategory.agda", "max_line_length": 85, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Construction/SubCategory.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": 260, "size": 790 }
-- Andreas, 2014-10-05 {-# OPTIONS --cubical-compatible --sized-types #-} -- {-# OPTIONS -v tc.size:20 #-} open import Agda.Builtin.Size data Nat : {size : Size} -> Set where zero : {size : Size} -> Nat {↑ size} suc : {size : Size} -> Nat {size} -> Nat {↑ size} -- subtraction is non size increasing sub : {size : Size} -> Nat {size} -> Nat {∞} -> Nat {size} sub zero n = zero sub (suc m) zero = suc m sub (suc m) (suc n) = sub m n -- div' m n computes ceiling(m/(n+1)) div' : {size : Size} -> Nat {size} -> Nat -> Nat {size} div' zero n = zero div' (suc m) n = suc (div' (sub m n) n) -- should termination check even --cubical-compatible -- -}
{ "alphanum_fraction": 0.5680473373, "avg_line_length": 25.037037037, "ext": "agda", "hexsha": "0deda07c7040ba0d112a957ff111340e5532d522", "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": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Succeed/Issue1292b.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Succeed/Issue1292b.agda", "max_line_length": 58, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Succeed/Issue1292b.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 232, "size": 676 }
module FlatDomInequality-1 where postulate A : Set g : A → A g x = x h : (@♭ x : A) → A h = g
{ "alphanum_fraction": 0.5454545455, "avg_line_length": 9, "ext": "agda", "hexsha": "6e67a260f378952e668a01d30b73cbb914ed64b7", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/FlatDomInequality-1.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/FlatDomInequality-1.agda", "max_line_length": 32, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/FlatDomInequality-1.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": 44, "size": 99 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Object.BinaryProducts.Abstract where open import Categories.Support.PropositionalEquality open import Categories.Category open import Categories.Object.BinaryProducts open import Categories.Morphisms module AbstractBinaryProducts {o ℓ e} (C : Category o ℓ e) (BP : BinaryProducts C) where private module P = BinaryProducts C BP open P public using (_×_; π₁; π₂) private open Category C private import Categories.Object.Product as Product mutual first : ∀ {A B C} → (A ⇒ B) → ((A × C) ⇒ (B × C)) first f = f ⁂ id second : ∀ {A C D} → (C ⇒ D) → ((A × C) ⇒ (A × D)) second g = id ⁂ g abstract infix 10 _⁂_ _⁂_ : ∀ {A B C D} → (A ⇒ B) → (C ⇒ D) → ((A × C) ⇒ (B × D)) _⁂_ = P._⁂_ ⟨_,_⟩ : ∀ {A B Q} → (Q ⇒ A) → (Q ⇒ B) → (Q ⇒ (A × B)) ⟨_,_⟩ = P.⟨_,_⟩ ⁂-convert : ∀ {A B C D} (f : A ⇒ B) (g : C ⇒ D) → f ⁂ g ≣ ⟨ f ∘ π₁ , g ∘ π₂ ⟩ ⁂-convert f g = ≣-refl assocˡ : ∀ {A B C} → (((A × B) × C) ⇒ (A × (B × C))) assocˡ = P.assocˡ assocˡ-convert : ∀ {A B C} → assocˡ {A} {B} {C} ≣ ⟨ π₁ ∘ π₁ , ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ assocˡ-convert = ≣-refl assocʳ : ∀ {A B C} → ((A × (B × C)) ⇒ ((A × B) × C)) assocʳ = P.assocʳ assocʳ-convert : ∀ {A B C} → assocʳ {A} {B} {C} ≣ ⟨ ⟨ π₁ , π₁ ∘ π₂ ⟩ , π₂ ∘ π₂ ⟩ assocʳ-convert = ≣-refl .assoc-iso : ∀ {A B C′} → Iso C (assocʳ {A} {B} {C′}) assocˡ assoc-iso = _≅_.iso C P.×-assoc .⁂∘⁂ : ∀ {A B C D E F} → {f : B ⇒ C} → {f′ : A ⇒ B} {g : E ⇒ F} {g′ : D ⇒ E} → (f ⁂ g) ∘ (f′ ⁂ g′) ≡ (f ∘ f′) ⁂ (g ∘ g′) ⁂∘⁂ = P.⁂∘⁂ .⁂∘⟨⟩ : ∀ {A B C D E} → {f : B ⇒ C} {f′ : A ⇒ B} {g : D ⇒ E} {g′ : A ⇒ D} → (f ⁂ g) ∘ ⟨ f′ , g′ ⟩ ≡ ⟨ f ∘ f′ , g ∘ g′ ⟩ ⁂∘⟨⟩ = P.⁂∘⟨⟩ .π₁∘⁂ : ∀ {A B C D} → {f : A ⇒ B} → {g : C ⇒ D} → π₁ ∘ (f ⁂ g) ≡ f ∘ π₁ π₁∘⁂ = P.π₁∘⁂ .π₂∘⁂ : ∀ {A B C D} → {f : A ⇒ B} → {g : C ⇒ D} → π₂ ∘ (f ⁂ g) ≡ g ∘ π₂ π₂∘⁂ = P.π₂∘⁂ .⟨⟩-cong₂ : ∀ {A B C} → {f f′ : C ⇒ A} {g g′ : C ⇒ B} → f ≡ f′ → g ≡ g′ → ⟨ f , g ⟩ ≡ ⟨ f′ , g′ ⟩ ⟨⟩-cong₂ = P.⟨⟩-cong₂ .⟨⟩∘ : ∀ {A B C D} {f : A ⇒ B} {g : A ⇒ C} {q : D ⇒ A} → ⟨ f , g ⟩ ∘ q ≡ ⟨ f ∘ q , g ∘ q ⟩ ⟨⟩∘ = P.⟨⟩∘ .first∘⟨⟩ : ∀ {A B C D} → {f : B ⇒ C} {f′ : A ⇒ B} {g′ : A ⇒ D} → first f ∘ ⟨ f′ , g′ ⟩ ≡ ⟨ f ∘ f′ , g′ ⟩ first∘⟨⟩ = P.first∘⟨⟩ .second∘⟨⟩ : ∀ {A B D E} → {f′ : A ⇒ B} {g : D ⇒ E} {g′ : A ⇒ D} → second g ∘ ⟨ f′ , g′ ⟩ ≡ ⟨ f′ , g ∘ g′ ⟩ second∘⟨⟩ = P.second∘⟨⟩ .η : ∀ {A B} → ⟨ π₁ , π₂ ⟩ ≡ id {A × B} η = P.η .commute₁ : ∀ {A B C} {f : C ⇒ A} {g : C ⇒ B} → π₁ ∘ ⟨ f , g ⟩ ≡ f commute₁ = P.commute₁ .commute₂ : ∀ {A B C} {f : C ⇒ A} {g : C ⇒ B} → π₂ ∘ ⟨ f , g ⟩ ≡ g commute₂ = P.commute₂ .universal : ∀ {A B C} {f : C ⇒ A} {g : C ⇒ B} {i : C ⇒ (A × B)} → π₁ ∘ i ≡ f → π₂ ∘ i ≡ g → ⟨ f , g ⟩ ≡ i universal = P.universal module HomReasoningP {A B : Obj} where open HomReasoning {A} {B} public -- sort of a hack, if you specify the codomain for your top-level -- reasoning you will NOT get what you want from the below infix 3 ⟨_⟩,⟨_⟩ .⟨_⟩,⟨_⟩ : ∀ {C} → {f f′ : A ⇒ B} {g g′ : A ⇒ C} → f ≡ f′ → g ≡ g′ → ⟨ f , g ⟩ ≡ ⟨ f′ , g′ ⟩ ⟨_⟩,⟨_⟩ x y = ⟨⟩-cong₂ x y
{ "alphanum_fraction": 0.401510574, "avg_line_length": 35.5913978495, "ext": "agda", "hexsha": "8f654d302efebe88144eca0651aefb2fb8f7252b", "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/Object/BinaryProducts/Abstract.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/Object/BinaryProducts/Abstract.agda", "max_line_length": 126, "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/Object/BinaryProducts/Abstract.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": 1642, "size": 3310 }
------------------------------------------------------------------------------ -- Inequalities on partial natural numbers ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module LTC-PCF.Data.Nat.Inequalities where open import LTC-PCF.Base infix 4 _<_ _≮_ _>_ _≯_ _≤_ _≰_ _≥_ _≱_ ------------------------------------------------------------------------------ -- The function terms. lth : D → D lth lt = lam (λ m → lam (λ n → if (iszero₁ n) then false else (if (iszero₁ m) then true else (lt · pred₁ m · pred₁ n)))) lt : D → D → D lt m n = fix lth · m · n le : D → D → D le m n = lt m (succ₁ n) gt : D → D → D gt m n = lt n m ge : D → D → D ge m n = le n m ------------------------------------------------------------------------ -- The relations. _<_ : D → D → Set m < n = lt m n ≡ true _≮_ : D → D → Set m ≮ n = lt m n ≡ false _>_ : D → D → Set m > n = gt m n ≡ true _≯_ : D → D → Set m ≯ n = gt m n ≡ false _≤_ : D → D → Set m ≤ n = le m n ≡ true _≰_ : D → D → Set m ≰ n = le m n ≡ false _≥_ : D → D → Set m ≥ n = ge m n ≡ true _≱_ : D → D → Set m ≱ n = ge m n ≡ false ------------------------------------------------------------------------------ -- The lexicographical order. Lexi : D → D → D → D → Set Lexi m n m' n' = m < m' ∨ m ≡ m' ∧ n < n'
{ "alphanum_fraction": 0.3640583554, "avg_line_length": 22.5074626866, "ext": "agda", "hexsha": "4bb8434406315484e1eb24c1acc2770945dbd33a", "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/LTC-PCF/Data/Nat/Inequalities.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/LTC-PCF/Data/Nat/Inequalities.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/LTC-PCF/Data/Nat/Inequalities.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": 465, "size": 1508 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Definitions for types of functions. ------------------------------------------------------------------------ -- The contents of this file should usually be accessed from `Function`. {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Function.Definitions {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} (_≈₁_ : Rel A ℓ₁) -- Equality over the domain (_≈₂_ : Rel B ℓ₂) -- Equality over the codomain where open import Data.Product using (∃; _×_) import Function.Definitions.Core1 as Core₁ import Function.Definitions.Core2 as Core₂ open import Level using (_⊔_) ------------------------------------------------------------------------ -- Definitions Congruent : (A → B) → Set (a ⊔ ℓ₁ ⊔ ℓ₂) Congruent f = ∀ {x y} → x ≈₁ y → f x ≈₂ f y Injective : (A → B) → Set (a ⊔ ℓ₁ ⊔ ℓ₂) Injective f = ∀ {x y} → f x ≈₂ f y → x ≈₁ y open Core₂ _≈₂_ public using (Surjective) Bijective : (A → B) → Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) Bijective f = Injective f × Surjective f open Core₂ _≈₂_ public using (Inverseˡ) open Core₁ _≈₁_ public using (Inverseʳ) Inverseᵇ : (A → B) → (B → A) → Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) Inverseᵇ f g = Inverseˡ f g × Inverseʳ f g
{ "alphanum_fraction": 0.5313741064, "avg_line_length": 26.7872340426, "ext": "agda", "hexsha": "2c139cf3184c7b13677dcf2f8ed143808d375efe", "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/Function/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/Function/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/Function/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": 404, "size": 1259 }
-- Andreas, 2015-07-16, issue reported by Nisse postulate A : Set₁ P : A → Set₁ T : Set₁ → Set₁ Σ : (A : Set₁) → (A → Set₁) → Set₁ T-Σ : {A : Set₁} {B : A → Set₁} → (∀ x → T (B x)) → T (Σ A B) t : T (Σ Set λ _ → Σ (A → A) λ f → Σ (∀ x₁ → P (f x₁)) λ _ → Set) t = T-Σ λ _ → T-Σ λ _ → T-Σ {!!} -- WAS: -- Goal type and context: -- -- Goal: (x : (x₁ : A) → P (x₁ x₁)) → T Set -- ———————————————————————————————————————————————————————————— -- x₁ : A → A -- x : Set -- -- Note the application "x₁ x₁". -- EXPECTED: -- Goal: (x : (x₁ : A) → P (.x₁ x₁)) → T Set -- ———————————————————————————————————————————————————————————— -- .x₁ : A → A -- .x : Set id : (x : A) → A -- id _ = {!!} -- Context displays .x id = λ _ → {!!} -- Context should display .x
{ "alphanum_fraction": 0.3634053367, "avg_line_length": 23.8484848485, "ext": "agda", "hexsha": "c20a9479890a8e4b0755cda75ae07edc6a196209", "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/Issue1534.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/Issue1534.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/interaction/Issue1534.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": 329, "size": 787 }
module Successor where open import OscarPrelude record Successor {ℓᴬ} (A : Set ℓᴬ) {ℓᴮ} (B : Set ℓᴮ) : Set (ℓᴬ ⊔ ℓᴮ) where field ⊹ : A → B open Successor ⦃ … ⦄ public instance SuccessorNat : Successor Nat Nat Successor.⊹ SuccessorNat = suc instance SuccessorLevel : Successor Level Level Successor.⊹ SuccessorLevel = lsuc
{ "alphanum_fraction": 0.7104477612, "avg_line_length": 18.6111111111, "ext": "agda", "hexsha": "0c22eb7475071af36911e97259d6a2d088fda18b", "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/Successor.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/Successor.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/Successor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 135, "size": 335 }
open import Nat open import Prelude open import core open import judgemental-erase open import aasubsume-min module determinism where -- the same action applied to the same type makes the same type actdet-type : {t t' t'' : τ̂} {α : action} → (t + α +> t') → (t + α +> t'') → (t' == t'') actdet-type TMArrChild1 TMArrChild1 = refl actdet-type TMArrChild2 TMArrChild2 = refl actdet-type TMArrParent1 TMArrParent1 = refl actdet-type TMArrParent1 (TMArrZip1 ()) actdet-type TMArrParent2 TMArrParent2 = refl actdet-type TMArrParent2 (TMArrZip2 ()) actdet-type TMDel TMDel = refl actdet-type TMConArrow TMConArrow = refl actdet-type TMConNum TMConNum = refl actdet-type (TMArrZip1 ()) TMArrParent1 actdet-type (TMArrZip1 p1) (TMArrZip1 p2) with actdet-type p1 p2 ... | refl = refl actdet-type (TMArrZip2 ()) TMArrParent2 actdet-type (TMArrZip2 p1) (TMArrZip2 p2) with actdet-type p1 p2 ... | refl = refl -- all expressions only move to one other expression movedet : {e e' e'' : ê} {δ : direction} → (e + move δ +>e e') → (e + move δ +>e e'') → e' == e'' movedet EMAscChild1 EMAscChild1 = refl movedet EMAscChild2 EMAscChild2 = refl movedet EMAscParent1 EMAscParent1 = refl movedet EMAscParent2 EMAscParent2 = refl movedet EMLamChild1 EMLamChild1 = refl movedet EMLamParent EMLamParent = refl movedet EMPlusChild1 EMPlusChild1 = refl movedet EMPlusChild2 EMPlusChild2 = refl movedet EMPlusParent1 EMPlusParent1 = refl movedet EMPlusParent2 EMPlusParent2 = refl movedet EMApChild1 EMApChild1 = refl movedet EMApChild2 EMApChild2 = refl movedet EMApParent1 EMApParent1 = refl movedet EMApParent2 EMApParent2 = refl movedet EMNEHoleChild1 EMNEHoleChild1 = refl movedet EMNEHoleParent EMNEHoleParent = refl -- non-movement lemmas; theses show up pervasively throughout and save a -- lot of pattern matching. lem-nomove-part : ∀ {t t'} → ▹ t ◃ + move parent +> t' → ⊥ lem-nomove-part () lem-nomove-pars : ∀{Γ e t e' t'} → Γ ⊢ ▹ e ◃ => t ~ move parent ~> e' => t' → ⊥ lem-nomove-pars (SAMove ()) lem-nomove-para : ∀{Γ e t e'} → Γ ⊢ ▹ e ◃ ~ move parent ~> e' ⇐ t → ⊥ lem-nomove-para (AASubsume e x x₁ x₂) = lem-nomove-pars x₁ lem-nomove-para (AAMove ()) -- if a move action on a synthetic action makes a new form, it's unique synthmovedet : {Γ : ·ctx} {e e' e'' : ê} {t' t'' : τ̇} {δ : direction} → (Γ ⊢ e => t' ~ move δ ~> e'' => t'') → (e + move δ +>e e') → e'' == e' synthmovedet (SAMove m1) m2 = movedet m1 m2 -- all these cases lead to absurdities based on movement synthmovedet (SAZipAsc1 x) EMAscParent1 = abort (lem-nomove-para x) synthmovedet (SAZipAsc2 x _ _ _) EMAscParent2 = abort (lem-nomove-part x) synthmovedet (SAZipApArr _ _ _ x _) EMApParent1 = abort (lem-nomove-pars x) synthmovedet (SAZipApAna _ _ x) EMApParent2 = abort (lem-nomove-para x) synthmovedet (SAZipPlus1 x) EMPlusParent1 = abort (lem-nomove-para x) synthmovedet (SAZipPlus2 x) EMPlusParent2 = abort (lem-nomove-para x) synthmovedet (SAZipHole _ _ x) EMNEHoleParent = abort (lem-nomove-pars x) anamovedet : {Γ : ·ctx} {e e' e'' : ê} {t : τ̇} {δ : direction} → (Γ ⊢ e ~ move δ ~> e'' ⇐ t) → (e + move δ +>e e') → e'' == e' anamovedet (AASubsume x₂ x x₃ x₁) m = synthmovedet x₃ m anamovedet (AAMove x) m = movedet x m anamovedet (AAZipLam x₁ x₂ d) EMLamParent = abort (lem-nomove-para d) mutual -- an action on an expression in a synthetic position produces one -- resultant expression and type. actdet-synth : {Γ : ·ctx} {e e' e'' : ê} {e◆ : ė} {t t' t'' : τ̇} {α : action} → (E : erase-e e e◆) → (Γ ⊢ e◆ => t) → (d1 : Γ ⊢ e => t ~ α ~> e' => t') → (d2 : Γ ⊢ e => t ~ α ~> e'' => t'') → {p1 : aasubmin-synth d1} → {p2 : aasubmin-synth d2} → (e' == e'' × t' == t'') actdet-synth EETop (SAsc x) (SAMove x₁) (SAMove x₂) = movedet x₁ x₂ , refl actdet-synth EETop (SAsc x) SADel SADel = refl , refl actdet-synth EETop (SAsc x) SAConAsc SAConAsc = refl , refl actdet-synth EETop (SAsc x) (SAConPlus1 x₁) (SAConPlus1 x₂) = refl , refl actdet-synth EETop (SAsc x) (SAConPlus1 x₁) (SAConPlus2 x₂) = abort (x₂ x₁) actdet-synth EETop (SAsc x) (SAConPlus2 x₁) (SAConPlus1 x₂) = abort (x₁ x₂) actdet-synth EETop (SAsc x) (SAConPlus2 x₁) (SAConPlus2 x₂) = refl , refl actdet-synth EETop (SAsc x) (SAConApArr x₁) (SAConApArr x₂) with matcharrunicity x₁ x₂ ... | refl = refl , refl actdet-synth EETop (SAsc x) (SAConApArr x₁) (SAConApOtw x₂) = abort (x₂ (matchconsist x₁)) actdet-synth EETop (SAsc x) (SAConApOtw x₁) (SAConApArr x₂) = abort (x₁ (matchconsist x₂)) actdet-synth EETop (SAsc x) (SAConApOtw x₁) (SAConApOtw x₂) = refl , refl actdet-synth EETop (SAsc x) SAConNEHole SAConNEHole = refl , refl actdet-synth (EEAscL E) (SAsc x) (SAMove x₁) (SAMove x₂) = movedet x₁ x₂ , refl actdet-synth (EEAscL E) (SAsc x) (SAMove EMAscParent1) (SAZipAsc1 x₂) = abort (lem-nomove-para x₂) actdet-synth (EEAscL E) (SAsc x) (SAZipAsc1 x₁) (SAMove EMAscParent1) = abort (lem-nomove-para x₁) actdet-synth (EEAscL E) (SAsc x) (SAZipAsc1 x₁) (SAZipAsc1 x₂) {p1} {p2} with actdet-ana E x x₁ x₂ {p1} {p2} ... | refl = refl , refl actdet-synth (EEAscR x) (SAsc x₁) (SAMove x₂) (SAMove x₃) = movedet x₂ x₃ , refl actdet-synth (EEAscR x) (SAsc x₁) (SAMove EMAscParent2) (SAZipAsc2 a _ _ _) = abort (lem-nomove-part a) actdet-synth (EEAscR x) (SAsc x₁) (SAZipAsc2 a _ _ _) (SAMove EMAscParent2) = abort (lem-nomove-part a) actdet-synth (EEAscR x) (SAsc x₂) (SAZipAsc2 a e1 _ _) (SAZipAsc2 b e2 _ _) with actdet-type a b ... | refl = refl , eraset-det e1 e2 actdet-synth EETop (SVar x) (SAMove x₁) (SAMove x₂) = movedet x₁ x₂ , refl actdet-synth EETop (SVar x) SADel SADel = refl , refl actdet-synth EETop (SVar x) SAConAsc SAConAsc = refl , refl actdet-synth EETop (SVar x) (SAConPlus1 x₁) (SAConPlus1 x₂) = refl , refl actdet-synth EETop (SVar x) (SAConPlus1 x₁) (SAConPlus2 x₂) = abort (x₂ x₁) actdet-synth EETop (SVar x) (SAConPlus2 x₁) (SAConPlus1 x₂) = abort (x₁ x₂) actdet-synth EETop (SVar x) (SAConPlus2 x₁) (SAConPlus2 x₂) = refl , refl actdet-synth EETop (SVar x) (SAConApArr x₁) (SAConApArr x₂) with matcharrunicity x₁ x₂ ... | refl = refl , refl actdet-synth EETop (SVar x) (SAConApArr x₁) (SAConApOtw x₂) = abort (x₂ (matchconsist x₁)) actdet-synth EETop (SVar x) (SAConApOtw x₁) (SAConApArr x₂) = abort (x₁ (matchconsist x₂)) actdet-synth EETop (SVar x) (SAConApOtw x₁) (SAConApOtw x₂) = refl , refl actdet-synth EETop (SVar x) SAConNEHole SAConNEHole = refl , refl actdet-synth EETop (SAp m wt x) (SAMove x₁) (SAMove x₂) = movedet x₁ x₂ , refl actdet-synth EETop (SAp m wt x) SADel SADel = refl , refl actdet-synth EETop (SAp m wt x) SAConAsc SAConAsc = refl , refl actdet-synth EETop (SAp m wt x) (SAConPlus1 x₁) (SAConPlus1 x₂) = refl , refl actdet-synth EETop (SAp m wt x) (SAConPlus1 x₁) (SAConPlus2 x₂) = abort (x₂ x₁) actdet-synth EETop (SAp m wt x) (SAConPlus2 x₁) (SAConPlus1 x₂) = abort (x₁ x₂) actdet-synth EETop (SAp m wt x) (SAConPlus2 x₁) (SAConPlus2 x₂) = refl , refl actdet-synth EETop (SAp m wt x) (SAConApArr x₁) (SAConApArr x₂) with matcharrunicity x₁ x₂ ... | refl = refl , refl actdet-synth EETop (SAp m wt x) (SAConApArr x₁) (SAConApOtw x₂) = abort (x₂ (matchconsist x₁)) actdet-synth EETop (SAp m wt x) (SAConApOtw x₁) (SAConApArr x₂) = abort (x₁ (matchconsist x₂)) actdet-synth EETop (SAp m wt x) (SAConApOtw x₁) (SAConApOtw x₂) = refl , refl actdet-synth EETop (SAp m wt x) SAConNEHole SAConNEHole = refl , refl actdet-synth (EEApL E) (SAp m wt x) (SAMove x₁) (SAMove x₂) = movedet x₁ x₂ , refl actdet-synth (EEApL E) (SAp m wt x) (SAMove EMApParent1) (SAZipApArr _ x₂ x₃ d2 x₄) = abort (lem-nomove-pars d2) actdet-synth (EEApL E) (SAp m wt x) (SAZipApArr _ x₁ x₂ d1 x₃) (SAMove EMApParent1) = abort (lem-nomove-pars d1) actdet-synth (EEApL E) (SAp m wt x) (SAZipApArr a x₁ x₂ d1 x₃) (SAZipApArr b x₄ x₅ d2 x₆) {p1} {p2} with erasee-det x₁ x₄ ... | refl with synthunicity x₂ x₅ ... | refl with erasee-det E x₁ ... | refl with actdet-synth E x₅ d1 d2 {p1} {p2} ... | refl , refl with matcharrunicity a b ... | refl = refl , refl actdet-synth (EEApR E) (SAp m wt x) (SAMove x₁) (SAMove x₂) = movedet x₁ x₂ , refl actdet-synth (EEApR E) (SAp m wt x) (SAMove EMApParent2) (SAZipApAna x₂ x₃ x₄) = abort (lem-nomove-para x₄) actdet-synth (EEApR E) (SAp m wt x) (SAZipApAna x₁ x₂ x₃) (SAMove EMApParent2) = abort (lem-nomove-para x₃) actdet-synth (EEApR E) (SAp m wt x) (SAZipApAna x₁ x₂ d1) (SAZipApAna x₄ x₅ d2) {p1} {p2} with synthunicity m x₂ ... | refl with matcharrunicity x₁ wt ... | refl with synthunicity m x₅ ... | refl with matcharrunicity x₄ wt ... | refl with actdet-ana E x d1 d2 {p1} {p2} ... | refl = refl , refl actdet-synth EETop SNum (SAMove x) (SAMove x₁) = movedet x x₁ , refl actdet-synth EETop SNum SADel SADel = refl , refl actdet-synth EETop SNum SAConAsc SAConAsc = refl , refl actdet-synth EETop SNum (SAConPlus1 x) (SAConPlus1 x₁) = refl , refl actdet-synth EETop SNum (SAConPlus1 x) (SAConPlus2 x₁) = abort (x₁ x) actdet-synth EETop SNum (SAConPlus2 x) (SAConPlus1 x₁) = abort (x x₁) actdet-synth EETop SNum (SAConPlus2 x) (SAConPlus2 x₁) = refl , refl actdet-synth EETop SNum (SAConApArr x) (SAConApArr x₁) with matcharrunicity x x₁ ... | refl = refl , refl actdet-synth EETop SNum (SAConApArr x) (SAConApOtw x₁) = abort (x₁ (matchconsist x)) actdet-synth EETop SNum (SAConApOtw x) (SAConApArr x₁) = abort (x (matchconsist x₁)) actdet-synth EETop SNum (SAConApOtw x) (SAConApOtw x₁) = refl , refl actdet-synth EETop SNum SAConNEHole SAConNEHole = refl , refl actdet-synth EETop (SPlus x x₁) (SAMove x₂) (SAMove x₃) = movedet x₂ x₃ , refl actdet-synth EETop (SPlus x x₁) SADel SADel = refl , refl actdet-synth EETop (SPlus x x₁) SAConAsc SAConAsc = refl , refl actdet-synth EETop (SPlus x x₁) (SAConPlus1 x₂) (SAConPlus1 x₃) = refl , refl actdet-synth EETop (SPlus x x₁) (SAConPlus1 x₂) (SAConPlus2 x₃) = abort (x₃ x₂) actdet-synth EETop (SPlus x x₁) (SAConPlus2 x₂) (SAConPlus1 x₃) = abort (x₂ x₃) actdet-synth EETop (SPlus x x₁) (SAConPlus2 x₂) (SAConPlus2 x₃) = refl , refl actdet-synth EETop (SPlus x x₁) (SAConApArr x₂) (SAConApArr x₃) with matcharrunicity x₂ x₃ ... | refl = refl , refl actdet-synth EETop (SPlus x x₁) (SAConApArr x₂) (SAConApOtw x₃) = abort (matchnotnum x₂) actdet-synth EETop (SPlus x x₁) (SAConApOtw x₂) (SAConApArr x₃) = abort (matchnotnum x₃) actdet-synth EETop (SPlus x x₁) (SAConApOtw x₂) (SAConApOtw x₃) = refl , refl actdet-synth EETop (SPlus x x₁) SAConNEHole SAConNEHole = refl , refl actdet-synth (EEPlusL E) (SPlus x x₁) (SAMove x₂) (SAMove x₃) = movedet x₂ x₃ , refl actdet-synth (EEPlusL E) (SPlus x x₁) (SAMove EMPlusParent1) (SAZipPlus1 d2) = abort (lem-nomove-para d2) actdet-synth (EEPlusL E) (SPlus x x₁) (SAZipPlus1 x₂) (SAMove EMPlusParent1) = abort (lem-nomove-para x₂) actdet-synth (EEPlusL E) (SPlus x x₁) (SAZipPlus1 x₂) (SAZipPlus1 x₃) {p1} {p2} = ap1 (λ x₄ → x₄ ·+₁ _) (actdet-ana E x x₂ x₃ {p1} {p2}) , refl actdet-synth (EEPlusR E) (SPlus x x₁) (SAMove x₂) (SAMove x₃) = movedet x₂ x₃ , refl actdet-synth (EEPlusR E) (SPlus x x₁) (SAMove EMPlusParent2) (SAZipPlus2 x₃) = abort (lem-nomove-para x₃) actdet-synth (EEPlusR E) (SPlus x x₁) (SAZipPlus2 x₂) (SAMove EMPlusParent2) = abort (lem-nomove-para x₂) actdet-synth (EEPlusR E) (SPlus x x₁) (SAZipPlus2 x₂) (SAZipPlus2 x₃) {p1} {p2} = ap1 (_·+₂_ _) (actdet-ana E x₁ x₂ x₃ {p1} {p2}) , refl actdet-synth EETop SEHole (SAMove x) (SAMove x₁) = movedet x x₁ , refl actdet-synth EETop SEHole SADel SADel = refl , refl actdet-synth EETop SEHole SAConAsc SAConAsc = refl , refl actdet-synth EETop SEHole (SAConVar {Γ = G} p) (SAConVar p₁) = refl , (ctxunicity {Γ = G} p p₁) actdet-synth EETop SEHole (SAConLam x₁) (SAConLam x₂) = refl , refl actdet-synth EETop SEHole SAConNumlit SAConNumlit = refl , refl actdet-synth EETop SEHole (SAConPlus1 x) (SAConPlus1 x₁) = refl , refl actdet-synth EETop SEHole (SAConPlus1 x) (SAConPlus2 x₁) = abort (x₁ x) actdet-synth EETop SEHole (SAConPlus2 x) (SAConPlus1 x₁) = abort (x x₁) actdet-synth EETop SEHole (SAConPlus2 x) (SAConPlus2 x₁) = refl , refl actdet-synth EETop SEHole (SAConApArr x) (SAConApArr x₁) with matcharrunicity x x₁ ... | refl = refl , refl actdet-synth EETop SEHole (SAConApArr x) (SAConApOtw x₁) = abort (x₁ TCHole2) actdet-synth EETop SEHole (SAConApOtw x) (SAConApArr x₁) = abort (x TCHole2) actdet-synth EETop SEHole (SAConApOtw x) (SAConApOtw x₁) = refl , refl actdet-synth EETop SEHole SAConNEHole SAConNEHole = refl , refl actdet-synth EETop (SNEHole wt) (SAMove x) (SAMove x₁) = movedet x x₁ , refl actdet-synth EETop (SNEHole wt) SADel SADel = refl , refl actdet-synth EETop (SNEHole wt) SAConAsc SAConAsc = refl , refl actdet-synth EETop (SNEHole wt) (SAConPlus1 x) (SAConPlus1 x₁) = refl , refl actdet-synth EETop (SNEHole wt) (SAConPlus1 x) (SAConPlus2 x₁) = abort (x₁ x) actdet-synth EETop (SNEHole wt) (SAConPlus2 x) (SAConPlus1 x₁) = abort (x x₁) actdet-synth EETop (SNEHole wt) (SAConPlus2 x) (SAConPlus2 x₁) = refl , refl actdet-synth EETop (SNEHole wt) (SAFinish x) (SAFinish x₁) = refl , synthunicity x x₁ actdet-synth EETop (SNEHole wt) (SAConApArr x) (SAConApArr x₁) with matcharrunicity x x₁ ... | refl = refl , refl actdet-synth EETop (SNEHole wt) (SAConApArr x) (SAConApOtw x₁) = abort (x₁ TCHole2) actdet-synth EETop (SNEHole wt) (SAConApOtw x) (SAConApArr x₁) = abort (x TCHole2) actdet-synth EETop (SNEHole wt) (SAConApOtw x) (SAConApOtw x₁) = refl , refl actdet-synth EETop (SNEHole wt) SAConNEHole SAConNEHole = refl , refl actdet-synth (EENEHole E) (SNEHole wt) (SAMove x) (SAMove x₁) = movedet x x₁ , refl actdet-synth (EENEHole E) (SNEHole wt) (SAMove EMNEHoleParent) (SAZipHole _ x₁ d2) = abort (lem-nomove-pars d2) actdet-synth (EENEHole E) (SNEHole wt) (SAZipHole _ x d1) (SAMove EMNEHoleParent) = abort (lem-nomove-pars d1) actdet-synth (EENEHole E) (SNEHole wt) (SAZipHole a x d1) (SAZipHole b x₁ d2) {p1} {p2} with erasee-det a b ... | refl with synthunicity x x₁ ... | refl with actdet-synth a x d1 d2 {p1} {p2} ... | refl , refl = refl , refl -- an action on an expression in an analytic position produces one -- resultant expression and type. actdet-ana : {Γ : ·ctx} {e e' e'' : ê} {e◆ : ė} {t : τ̇} {α : action} → (erase-e e e◆) → (Γ ⊢ e◆ <= t) → (d1 : Γ ⊢ e ~ α ~> e' ⇐ t) → (d2 : Γ ⊢ e ~ α ~> e'' ⇐ t) → {p1 : aasubmin-ana d1} → {p2 : aasubmin-ana d2} → e' == e'' ---- lambda cases first -- an erased lambda can't be typechecked with subsume actdet-ana (EELam _) (ASubsume () _) _ _ -- for things paired with movements, punt to the move determinism case actdet-ana _ _ D (AAMove y) = anamovedet D y actdet-ana _ _ (AAMove y) D = ! (anamovedet D y) -- lambdas never match with subsumption actions, because it won't be well typed. actdet-ana EETop (ALam x₁ x₂ wt) (AASubsume EETop () x₅ x₆) _ actdet-ana (EELam _) (ALam x₁ x₂ wt) (AASubsume (EELam x₃) () x₅ x₆) _ actdet-ana EETop (ALam x₁ x₂ wt) _ (AASubsume EETop () x₅ x₆) actdet-ana (EELam _) (ALam x₁ x₂ wt) _ (AASubsume (EELam x₃) () x₅ x₆) -- with the cursor at the top, there are only two possible actions actdet-ana EETop (ALam x₁ x₂ wt) AADel AADel = refl actdet-ana EETop (ALam x₁ x₂ wt) AAConAsc AAConAsc = refl -- and for the remaining case, recurr on the smaller derivations actdet-ana (EELam er) (ALam x₁ x₂ wt) (AAZipLam x₃ x₄ d1) (AAZipLam x₅ x₆ d2) {p1} {p2} with matcharrunicity x₄ x₆ ... | refl with matcharrunicity x₄ x₂ ... | refl with actdet-ana er wt d1 d2 {p1} {p2} ... | refl = refl ---- now the subsumption cases -- subsume / subsume, so pin things down then recurr actdet-ana er (ASubsume a b) (AASubsume x x₁ x₂ x₃) (AASubsume x₄ x₅ x₆ x₇) {p1} {p2} with erasee-det x₄ x ... | refl with erasee-det er x₄ ... | refl with synthunicity x₅ x₁ ... | refl = π1 (actdet-synth x x₅ x₂ x₆ {min-ana-lem x₂ p1} {min-ana-lem x₆ p2}) -- (these are all repeated below, irritatingly.) actdet-ana EETop (ASubsume a b) (AASubsume EETop x SADel x₁) AADel = refl actdet-ana EETop (ASubsume a b) (AASubsume EETop x SAConAsc x₁) AAConAsc {p1} = abort p1 actdet-ana EETop (ASubsume SEHole b) (AASubsume EETop SEHole (SAConVar {Γ = Γ} p) x₂) (AAConVar x₅ p₁) with ctxunicity {Γ = Γ} p p₁ ... | refl = abort (x₅ x₂) actdet-ana EETop (ASubsume SEHole b) (AASubsume EETop SEHole (SAConLam x₄) x₂) (AAConLam1 x₅ m) {p1} = abort p1 actdet-ana EETop (ASubsume a b) (AASubsume EETop x₁ (SAConLam x₃) x₂) (AAConLam2 x₅ x₆) = abort (x₆ x₂) actdet-ana EETop (ASubsume a b) (AASubsume EETop x₁ SAConNumlit x₂) (AAConNumlit x₄) = abort (x₄ x₂) actdet-ana EETop (ASubsume a b) (AASubsume EETop x (SAFinish x₂) x₁) (AAFinish x₄) = refl -- subsume / del actdet-ana er (ASubsume a b) AADel (AASubsume x x₁ SADel x₃) = refl actdet-ana er (ASubsume a b) AADel AADel = refl -- subsume / conasc actdet-ana EETop (ASubsume a b) AAConAsc (AASubsume EETop x₁ SAConAsc x₃) {p2 = p2} = abort p2 actdet-ana er (ASubsume a b) AAConAsc AAConAsc = refl -- subsume / convar actdet-ana EETop (ASubsume SEHole b) (AAConVar x₁ p) (AASubsume EETop SEHole (SAConVar {Γ = Γ} p₁) x₅) with ctxunicity {Γ = Γ} p p₁ ... | refl = abort (x₁ x₅) actdet-ana er (ASubsume a b) (AAConVar x₁ p) (AAConVar x₂ p₁) = refl -- subsume / conlam1 actdet-ana EETop (ASubsume SEHole b) (AAConLam1 x₁ x₂) (AASubsume EETop SEHole (SAConLam x₃) x₆) {p2 = p2} = abort p2 actdet-ana er (ASubsume a b) (AAConLam1 x₁ MAHole) (AAConLam2 x₃ x₄) = abort (x₄ TCHole2) actdet-ana er (ASubsume a b) (AAConLam1 x₁ MAArr) (AAConLam2 x₃ x₄) = abort (x₄ (TCArr TCHole1 TCHole1)) actdet-ana er (ASubsume a b) (AAConLam1 x₁ x₂) (AAConLam1 x₃ x₄) = refl -- subsume / conlam2 actdet-ana EETop (ASubsume SEHole TCRefl) (AAConLam2 x₁ x₂) (AASubsume EETop SEHole x₅ x₆) = abort (x₂ TCHole2) actdet-ana EETop (ASubsume SEHole TCHole1) (AAConLam2 x₁ x₂) (AASubsume EETop SEHole (SAConLam x₃) x₆) = abort (x₂ x₆) actdet-ana EETop (ASubsume SEHole TCHole2) (AAConLam2 x₁ x₂) (AASubsume EETop SEHole x₅ x₆) = abort (x₂ TCHole2) actdet-ana EETop (ASubsume a b) (AAConLam2 x₂ x₁) (AAConLam1 x₃ MAHole) = abort (x₁ TCHole2) actdet-ana EETop (ASubsume a b) (AAConLam2 x₂ x₁) (AAConLam1 x₃ MAArr) = abort (x₁ (TCArr TCHole1 TCHole1)) actdet-ana er (ASubsume a b) (AAConLam2 x₂ x) (AAConLam2 x₃ x₄) = refl -- subsume / numlit actdet-ana er (ASubsume a b) (AAConNumlit x) (AASubsume x₁ x₂ SAConNumlit x₄) = abort (x x₄) actdet-ana er (ASubsume a b) (AAConNumlit x) (AAConNumlit x₁) = refl -- subsume / finish actdet-ana er (ASubsume a b) (AAFinish x) (AASubsume x₁ x₂ (SAFinish x₃) x₄) = refl actdet-ana er (ASubsume a b) (AAFinish x) (AAFinish x₁) = refl
{ "alphanum_fraction": 0.6524887336, "avg_line_length": 57.0780346821, "ext": "agda", "hexsha": "843b20c8eb610acceb389e9ccb8aee7f9fa726ff", "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": "determinism.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": "determinism.agda", "max_line_length": 122, "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": "determinism.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": 8383, "size": 19749 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.RadicalIdeal where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.Powerset open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Data.Sum hiding (map) open import Cubical.Data.FinData hiding (elim) open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; +-comm to +ℕ-comm ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm ; _choose_ to _ℕchoose_ ; snotz to ℕsnotz) open import Cubical.Data.Nat.Order open import Cubical.HITs.PropositionalTruncation as PT open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Ideal open import Cubical.Algebra.CommRing.FGIdeal open import Cubical.Algebra.CommRing.BinomialThm open import Cubical.Algebra.Ring.Properties open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.RingSolver.ReflectionSolving private variable ℓ : Level module _ (R' : CommRing ℓ) where private R = fst R' open CommRingStr (snd R') open RingTheory (CommRing→Ring R') open Sum (CommRing→Ring R') open CommRingTheory R' open Exponentiation R' open BinomialThm R' open isCommIdeal √ : ℙ R → ℙ R --\surd √ I x = (∃[ n ∈ ℕ ] x ^ n ∈ I) , isPropPropTrunc ^∈√→∈√ : ∀ (I : ℙ R) (x : R) (n : ℕ) → x ^ n ∈ √ I → x ∈ √ I ^∈√→∈√ I x n = map (λ { (m , [xⁿ]ᵐ∈I) → (n ·ℕ m) , subst-∈ I (sym (^-rdist-·ℕ x n m)) [xⁿ]ᵐ∈I }) ∈→∈√ : ∀ (I : ℙ R) (x : R) → x ∈ I → x ∈ √ I ∈→∈√ I _ x∈I = ∣ 1 , subst-∈ I (sym (·Rid _)) x∈I ∣ √OfIdealIsIdeal : ∀ (I : ℙ R) → isCommIdeal R' I → isCommIdeal R' (√ I) +Closed (√OfIdealIsIdeal I ici) {x = x} {y = y} = map2 +ClosedΣ where +ClosedΣ : Σ[ n ∈ ℕ ] x ^ n ∈ I → Σ[ n ∈ ℕ ] y ^ n ∈ I → Σ[ n ∈ ℕ ] (x + y) ^ n ∈ I +ClosedΣ (n , xⁿ∈I) (m , yᵐ∈I) = (n +ℕ m) , subst-∈ I (sym (BinomialThm (n +ℕ m) _ _)) ∑Binomial∈I where binomialCoeff∈I : ∀ i → ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ∈ I binomialCoeff∈I i with ≤-+-split n m (toℕ i) (pred-≤-pred (toℕ<n i)) ... | inl n≤i = subst-∈ I (sym path) (·Closed ici _ xⁿ∈I) where useSolver : ∀ a b c d → a · (b · c) · d ≡ a · b · d · c useSolver = solve R' path : ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡ ((n +ℕ m) choose toℕ i) · x ^ (toℕ i ∸ n) · y ^ (n +ℕ m ∸ toℕ i) · x ^ n path = ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ k → ((n +ℕ m) choose toℕ i) · x ^ k · y ^ (n +ℕ m ∸ toℕ i)) (sym (≤-∸-+-cancel n≤i)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ ((toℕ i ∸ n) +ℕ n) · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ z → ((n +ℕ m) choose toℕ i) · z · y ^ (n +ℕ m ∸ toℕ i)) (sym (·-of-^-is-^-of-+ x (toℕ i ∸ n) n)) ⟩ ((n +ℕ m) choose toℕ i) · (x ^ (toℕ i ∸ n) · x ^ n) · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ useSolver _ _ _ _ ⟩ ((n +ℕ m) choose toℕ i) · x ^ (toℕ i ∸ n) · y ^ (n +ℕ m ∸ toℕ i) · x ^ n ∎ ... | inr m≤n+m-i = subst-∈ I (sym path) (·Closed ici _ yᵐ∈I) where path : ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m path = ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ k → ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ k) (sym (≤-∸-+-cancel m≤n+m-i)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (((n +ℕ m ∸ toℕ i) ∸ m) +ℕ m) ≡⟨ cong (((n +ℕ m) choose toℕ i) · x ^ toℕ i ·_) (sym (·-of-^-is-^-of-+ y ((n +ℕ m ∸ toℕ i) ∸ m) m)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · (y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m) ≡⟨ ·Assoc _ _ _ ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m ∎ ∑Binomial∈I : ∑ (BinomialVec (n +ℕ m) x y) ∈ I ∑Binomial∈I = ∑Closed R' (I , ici) (BinomialVec (n +ℕ m) _ _) binomialCoeff∈I contains0 (√OfIdealIsIdeal I ici) = ∣ 1 , subst-∈ I (sym (0LeftAnnihilates 1r)) (ici .contains0) ∣ ·Closed (√OfIdealIsIdeal I ici) r = map λ { (n , xⁿ∈I) → n , subst-∈ I (sym (^-ldist-· r _ n)) (ici .·Closed (r ^ n) xⁿ∈I) } -- important lemma for characterization of the Zariski lattice √FGIdealChar : {n : ℕ} (V : FinVec R n) (I : CommIdeal R') → √ (fst ⟨ V ⟩[ R' ]) ⊆ √ (fst I) ≃ (∀ i → V i ∈ √ (fst I)) √FGIdealChar V I = isEquivPropBiimpl→Equiv (⊆-isProp (√ (fst ⟨ V ⟩[ R' ])) (√ (fst I))) (isPropΠ (λ _ → √ (fst I) _ .snd)) .fst (ltrImpl , rtlImpl) where open KroneckerDelta (CommRing→Ring R') ltrImpl : √ (fst ⟨ V ⟩[ R' ]) ⊆ √ (fst I) → (∀ i → V i ∈ √ (fst I)) ltrImpl √⟨V⟩⊆√I i = √⟨V⟩⊆√I _ (∈→∈√ (fst ⟨ V ⟩[ R' ]) (V i) ∣ (λ j → δ i j) , sym (∑Mul1r _ _ i) ∣) rtlImpl : (∀ i → V i ∈ √ (fst I)) → √ (fst ⟨ V ⟩[ R' ]) ⊆ √ (fst I) rtlImpl ∀i→Vi∈√I x = PT.elim (λ _ → √ (fst I) x .snd) λ { (n , xⁿ∈⟨V⟩) → ^∈√→∈√ (fst I) x n (elimHelper _ xⁿ∈⟨V⟩) } where isCommIdeal√I = √OfIdealIsIdeal (fst I) (snd I) elimHelper : ∀ (y : R) → y ∈ (fst ⟨ V ⟩[ R' ]) → y ∈ √ (fst I) elimHelper y = PT.elim (λ _ → √ (fst I) y .snd) λ { (α , y≡∑αV) → subst-∈ (√ (fst I)) (sym y≡∑αV) (∑Closed R' (√ (fst I) , isCommIdeal√I) (λ i → α i · V i) (λ i → isCommIdeal√I .·Closed (α i) (∀i→Vi∈√I i))) }
{ "alphanum_fraction": 0.4719140083, "avg_line_length": 46.8943089431, "ext": "agda", "hexsha": "8c847e53c1a2c05cca8a442cfddc660046c44b5e", "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": "707825882556937ebcf15a53eac63f0afc4d0cfe", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "XiaohuWang0921/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/RadicalIdeal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "707825882556937ebcf15a53eac63f0afc4d0cfe", "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": "XiaohuWang0921/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/RadicalIdeal.agda", "max_line_length": 95, "max_stars_count": null, "max_stars_repo_head_hexsha": "707825882556937ebcf15a53eac63f0afc4d0cfe", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "XiaohuWang0921/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/RadicalIdeal.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2535, "size": 5768 }
{-# OPTIONS --cubical --allow-unsolved-metas #-} open import Agda.Primitive.Cubical module _ where postulate PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ {-# BUILTIN PATHP PathP #-} data D {ℓ} (A : Set ℓ) : Set ℓ where c : PathP _ _ _
{ "alphanum_fraction": 0.604, "avg_line_length": 19.2307692308, "ext": "agda", "hexsha": "c744807096bd5d3aa1dcdb722ea2ecfc5ca4986b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.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/Issue3659.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/Issue3659.agda", "max_line_length": 53, "max_stars_count": 2, "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/Issue3659.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 97, "size": 250 }
-- "Ordinal notations via simultaneous definitions" module Experiment.Ord where open import Level renaming (zero to lzero; suc to lsuc) open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Data.Sum data Ord : Set data _<_ : Rel Ord lzero _≥_ : Rel Ord lzero fst : Ord → Ord data Ord where 𝟎 : Ord ω^_+_[_] : (a b : Ord) → a ≥ fst b → Ord data _<_ where <₁ : {a : Ord} → a ≢ 𝟎 → 𝟎 < a <₂ : {a b c d : Ord} (r : a ≥ fst c) (s : b ≥ fst d) → a < b → ω^ a + c [ r ] < ω^ b + d [ s ] <₃ : {a b c : Ord} → (r : a ≥ fst b) (s : a ≥ fst c) → b < c → ω^ a + b [ r ] < ω^ a + c [ s ] fst 𝟎 = 𝟎 fst (ω^ α + _ [ _ ]) = α a ≥ b = (b < a) ⊎ (a ≡ b) _+_ : Ord → Ord → Ord 𝟎 + b = b a@(ω^ _ + _ [ _ ]) + 𝟎 = a ω^ a + c [ r ] + ω^ b + d [ s ] = {! !} _*_ : Ord → Ord → Ord a * b = {! !}
{ "alphanum_fraction": 0.491745283, "avg_line_length": 25.696969697, "ext": "agda", "hexsha": "a92c48ce805cf0d34f77ff86cc12fd23a82ca42f", "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": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Experiment/Ord.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "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": "rei1024/agda-misc", "max_issues_repo_path": "Experiment/Ord.agda", "max_line_length": 96, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Experiment/Ord.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 368, "size": 848 }
module list where open import level open import bool open import eq open import maybe open import nat open import unit open import product open import empty open import sum ---------------------------------------------------------------------- -- datatypes ---------------------------------------------------------------------- data 𝕃 {ℓ} (A : Set ℓ) : Set ℓ where [] : 𝕃 A _::_ : (x : A) (xs : 𝕃 A) → 𝕃 A {-# BUILTIN LIST 𝕃 #-} {-# COMPILE GHC 𝕃 = data [] ([] | (:)) #-} list = 𝕃 ---------------------------------------------------------------------- -- syntax ---------------------------------------------------------------------- infixr 6 _::_ _++_ infixr 5 _shorter_ _longer_ ---------------------------------------------------------------------- -- operations ---------------------------------------------------------------------- [_] : ∀ {ℓ} {A : Set ℓ} → A → 𝕃 A [ x ] = x :: [] is-empty : ∀{ℓ}{A : Set ℓ} → 𝕃 A → 𝔹 is-empty [] = tt is-empty (_ :: _) = ff tail : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → 𝕃 A tail [] = [] tail (x :: xs) = xs head : ∀{ℓ}{A : Set ℓ} → (l : 𝕃 A) → is-empty l ≡ ff → A head [] () head (x :: xs) _ = x head2 : ∀{ℓ}{A : Set ℓ} → (l : 𝕃 A) → maybe A head2 [] = nothing head2 (a :: _) = just a last : ∀{ℓ}{A : Set ℓ} → (l : 𝕃 A) → is-empty l ≡ ff → A last [] () last (x :: []) _ = x last (x :: (y :: xs)) _ = last (y :: xs) refl _++_ : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → 𝕃 A → 𝕃 A [] ++ ys = ys (x :: xs) ++ ys = x :: (xs ++ ys) concat : ∀{ℓ}{A : Set ℓ} → 𝕃 (𝕃 A) → 𝕃 A concat [] = [] concat (l :: ls) = l ++ concat ls repeat : ∀{ℓ}{A : Set ℓ} → ℕ → A → 𝕃 A repeat 0 a = [] repeat (suc n) a = a :: (repeat n a) map : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → (A → B) → 𝕃 A → 𝕃 B map f [] = [] map f (x :: xs) = f x :: map f xs -- The hom part of the list functor. list-funct : {ℓ : Level}{A B : Set ℓ} → (A → B) → (𝕃 A → 𝕃 B) list-funct f l = map f l {- (maybe-map f xs) returns (just ys) if f returns (just y_i) for each x_i in the list xs. Otherwise, (maybe-map f xs) returns nothing. -} 𝕃maybe-map : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → (A → maybe B) → 𝕃 A → maybe (𝕃 B) 𝕃maybe-map f [] = just [] 𝕃maybe-map f (x :: xs) with f x 𝕃maybe-map f (x :: xs) | nothing = nothing 𝕃maybe-map f (x :: xs) | just y with 𝕃maybe-map f xs 𝕃maybe-map f (x :: xs) | just y | nothing = nothing 𝕃maybe-map f (x :: xs) | just y | just ys = just (y :: ys) foldr : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'} → (A → B → B) → B → 𝕃 A → B foldr f b [] = b foldr f b (a :: as) = f a (foldr f b as) length : ∀{ℓ}{A : Set ℓ} → 𝕃 A → ℕ length [] = 0 length (x :: xs) = suc (length xs) reverse-helper : ∀ {ℓ}{A : Set ℓ} → 𝕃 A → 𝕃 A → 𝕃 A reverse-helper h [] = h reverse-helper h (x :: xs) = reverse-helper (x :: h) xs reverse : ∀ {ℓ}{A : Set ℓ} → 𝕃 A → 𝕃 A reverse l = reverse-helper [] l reverse-bad : ∀ {ℓ}{A : Set ℓ} → 𝕃 A → 𝕃 A reverse-bad [] = [] reverse-bad (x :: l) = reverse-bad l ++ [ x ] list-member : ∀{ℓ}{A : Set ℓ}(eq : A → A → 𝔹)(a : A)(l : 𝕃 A) → 𝔹 list-member eq a [] = ff list-member eq a (x :: xs) with eq a x ... | tt = tt ... | ff = list-member eq a xs list-member-prop : ∀{ℓ}{A : Set ℓ}(eq : A → A → 𝔹)(a : A)(l : 𝕃 A) → Set list-member-prop eq a [] = ⊥ list-member-prop eq a (x :: xs) with eq a x ... | tt = ⊤ ... | ff = list-member-prop eq a xs list-minus : ∀{ℓ}{A : Set ℓ}(eq : A → A → 𝔹)(l1 l2 : 𝕃 A) → 𝕃 A list-minus eq [] l2 = [] list-minus eq (x :: xs) l2 = let r = list-minus eq xs l2 in if list-member eq x l2 then r else x :: r _longer_ : ∀{ℓ}{A : Set ℓ}(l1 l2 : 𝕃 A) → 𝔹 [] longer y = ff (x :: xs) longer [] = tt (x :: xs) longer (y :: ys) = xs longer ys _shorter_ : ∀{ℓ}{A : Set ℓ}(l1 l2 : 𝕃 A) → 𝔹 x shorter y = y longer x -- return tt iff all elements in the list satisfy the given predicate pred. list-all : ∀{ℓ}{A : Set ℓ}(pred : A → 𝔹)(l : 𝕃 A) → 𝔹 list-all pred [] = tt list-all pred (x :: xs) = pred x && list-all pred xs all-pred : {ℓ : Level}{X : Set ℓ} → (X → Set ℓ) → 𝕃 X → Set ℓ all-pred f [] = ⊤ all-pred f (x₁ :: xs) = (f x₁) ∧ (all-pred f xs) -- return tt iff at least one element in the list satisfies the given predicate pred. list-any : ∀{ℓ}{A : Set ℓ}(pred : A → 𝔹)(l : 𝕃 A) → 𝔹 list-any pred [] = ff list-any pred (x :: xs) = pred x || list-any pred xs list-and : (l : 𝕃 𝔹) → 𝔹 list-and [] = tt list-and (x :: xs) = x && (list-and xs) list-or : (l : 𝕃 𝔹) → 𝔹 list-or [] = ff list-or (x :: l) = x || list-or l list-max : ∀{ℓ}{A : Set ℓ} (lt : A → A → 𝔹) → 𝕃 A → A → A list-max lt [] x = x list-max lt (y :: ys) x = list-max lt ys (if lt y x then x else y) isSublist : ∀{ℓ}{A : Set ℓ} → 𝕃 A → 𝕃 A → (A → A → 𝔹) → 𝔹 isSublist l1 l2 eq = list-all (λ a → list-member eq a l2) l1 =𝕃 : ∀{ℓ}{A : Set ℓ} → (A → A → 𝔹) → (l1 : 𝕃 A) → (l2 : 𝕃 A) → 𝔹 =𝕃 eq (a :: as) (b :: bs) = eq a b && =𝕃 eq as bs =𝕃 eq [] [] = tt =𝕃 eq _ _ = ff filter : ∀{ℓ}{A : Set ℓ} → (A → 𝔹) → 𝕃 A → 𝕃 A filter p [] = [] filter p (x :: xs) = let r = filter p xs in if p x then x :: r else r -- remove all elements equal to the given one remove : ∀{ℓ}{A : Set ℓ}(eq : A → A → 𝔹)(a : A)(l : 𝕃 A) → 𝕃 A remove eq a l = filter (λ x → ~ (eq a x)) l {- nthTail n l returns the part of the list after the first n elements, or [] if the list has fewer than n elements -} nthTail : ∀{ℓ}{A : Set ℓ} → ℕ → 𝕃 A → 𝕃 A nthTail 0 l = l nthTail n [] = [] nthTail (suc n) (x :: l) = nthTail n l nth : ∀{ℓ}{A : Set ℓ} → ℕ → 𝕃 A → maybe A nth _ [] = nothing nth 0 (x :: xs) = just x nth (suc n) (x :: xs) = nth n xs -- nats-down N returns N :: (N-1) :: ... :: 0 :: [] nats-down : ℕ → 𝕃 ℕ nats-down 0 = [ 0 ] nats-down (suc x) = suc x :: nats-down x zip : ∀{ℓ₁ ℓ₂}{A : Set ℓ₁}{B : Set ℓ₂} → 𝕃 A → 𝕃 B → 𝕃 (A × B) zip [] [] = [] zip [] (x :: l₂) = [] zip (x :: l₁) [] = [] zip (x :: l₁) (y :: l₂) = (x , y) :: zip l₁ l₂ unzip : ∀{ℓ₁ ℓ₂}{A : Set ℓ₁}{B : Set ℓ₂} → 𝕃 (A × B) → (𝕃 A × 𝕃 B) unzip [] = ([] , []) unzip ((x , y) :: ps) with unzip ps ... | (xs , ys) = x :: xs , y :: ys inPairListFst : {A B : Set} → (A → A → 𝔹) → A → 𝕃 (A ∧ B) → Set inPairListFst _ w [] = ⊥ inPairListFst _=A_ w ((a , b) :: c) with w =A a ... | tt = ⊤ ... | ff = inPairListFst _=A_ w c map-⊎ : {ℓ₁ ℓ₂ ℓ₃ : Level} → {A : Set ℓ₁}{B : Set ℓ₂}{C : Set ℓ₃} → (A → C) → (B → C) → 𝕃 (A ⊎ B) → 𝕃 C map-⊎ f g [] = [] map-⊎ f g (inj₁ x :: l) = f x :: map-⊎ f g l map-⊎ f g (inj₂ y :: l) = g y :: map-⊎ f g l proj-⊎₁ : {ℓ ℓ' : Level}{A : Set ℓ}{B : Set ℓ'} → 𝕃 (A ⊎ B) → (𝕃 A) proj-⊎₁ [] = [] proj-⊎₁ (inj₁ x :: l) = x :: proj-⊎₁ l proj-⊎₁ (inj₂ y :: l) = proj-⊎₁ l proj-⊎₂ : {ℓ ℓ' : Level}{A : Set ℓ}{B : Set ℓ'} → 𝕃 (A ⊎ B) → (𝕃 B) proj-⊎₂ [] = [] proj-⊎₂ (inj₁ x :: l) = proj-⊎₂ l proj-⊎₂ (inj₂ y :: l) = y :: proj-⊎₂ l drop-nothing : ∀{ℓ}{A : Set ℓ} → 𝕃 (maybe A) → 𝕃 A drop-nothing [] = [] drop-nothing (nothing :: aa) = drop-nothing aa drop-nothing (just a :: aa) = a :: drop-nothing aa index : ∀{ℓ}{A : Set ℓ} → A → (A → A → 𝔹) → ℕ → 𝕃 A → maybe ℕ index x _ c [] = nothing index x _eq_ c (y :: l) with x eq y ... | tt = just c ... | ff = index x _eq_ (suc c) l
{ "alphanum_fraction": 0.4659723213, "avg_line_length": 29.4495798319, "ext": "agda", "hexsha": "cdc62e900513349939389b58da2e6ff12473bd93", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "list.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "list.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "list.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3094, "size": 7009 }
{- Joseph Eremondi Utrecht University Capita Selecta UU# 4229924 July 22, 2015 -} module SemiLinRE where open import Data.Vec open import Data.Nat import Data.Fin as Fin open import Data.List import Data.List.All open import Data.Bool open import Data.Char open import Data.Maybe open import Data.Product open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Relation.Nullary open import Relation.Nullary.Decidable open import Relation.Binary.Core open import Category.Monad open import Data.Nat.Properties.Simple open import Data.Maybe open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Utils open import Function import RETypes open import Data.Sum open import SemiLin open import Data.Vec.Equality open import Data.Nat.Properties.Simple module VecNatEq = Data.Vec.Equality.DecidableEquality (Relation.Binary.PropositionalEquality.decSetoid Data.Nat._≟_) --Find the Parikh vector of a given word --Here cmap is the mapping of each character to its position --in the Parikh vector wordParikh : {n : ℕ} -> (Char -> Fin.Fin n) -> (w : List Char) -> Parikh n wordParikh cmap [] = v0 wordParikh cmap (x ∷ w) = (basis (cmap x)) +v (wordParikh cmap w) --Show that the Parikh of concatenating two words --Is the sum of their Parikhs wordParikhPlus : {n : ℕ} -> (cmap : Char -> Fin.Fin n) -> (u : List Char) -> (v : List Char) -> wordParikh cmap (u Data.List.++ v) ≡ (wordParikh cmap u) +v (wordParikh cmap v) wordParikhPlus cmap [] v = sym v0identLeft wordParikhPlus {n} cmap (x ∷ u) v = begin basis (cmap x) +v wordParikh cmap (u ++l v) ≡⟨ cong (λ y → basis (cmap x) +v y) (wordParikhPlus cmap u v) ⟩ basis (cmap x) +v (wordParikh cmap u +v wordParikh cmap v) ≡⟨ sym vAssoc ⟩ ((basis (cmap x) +v wordParikh cmap u) +v wordParikh cmap v ∎) where _++l_ = Data.List._++_ --The algorithm mapping regular expressions to the Parikh set of --the language matched by the RE --We prove this correct below reSemiLin : {n : ℕ} {null? : RETypes.Null?} -> (Char -> Fin.Fin n) -> RETypes.RE null? -> SemiLinSet n reSemiLin cmap RETypes.ε = Data.List.[ v0 , 0 , [] ] reSemiLin cmap RETypes.∅ = [] reSemiLin cmap (RETypes.Lit x) = Data.List.[ basis (cmap x ) , 0 , [] ] reSemiLin cmap (r1 RETypes.+ r2) = reSemiLin cmap r1 Data.List.++ reSemiLin cmap r2 reSemiLin cmap (r1 RETypes.· r2) = reSemiLin cmap r1 +s reSemiLin cmap r2 reSemiLin cmap (r RETypes.*) = starSemiLin (reSemiLin cmap r) {- Show that s* ⊆ s +v s* Not implemented due to time restrictions, but should be possible, given that linStarExtend is implemented in SemiLin.agda -} starExtend : {n : ℕ} -> (v1 v2 : Parikh n ) -> ( s ss : SemiLinSet n) -> ss ≡ starSemiLin s -> InSemiLin v1 s -> InSemiLin v2 ss -> InSemiLin (v1 +v v2) (starSemiLin s) starExtend v1 v2 s ss spf inS inSS = {!!} {- Show that s* ⊇ s +v s* Not completely implemented due to time restrictions, but should be possible, given that linStarDecomp is implemented in SemiLin.agda. There are also some hard parts, for example, dealing with the proofs that the returned vectors are non-zero (otherwise, we'd just trivially return v0 and v) -} starDecomp : {n : ℕ} -> (v : Parikh n) -> (s ss : SemiLinSet n) -> v ≢ v0 -> ss ≡ starSemiLin s -> InSemiLin v ss -> (∃ λ v1 -> ∃ λ v2 -> v1 +v v2 ≡ v × InSemiLin v1 s × InSemiLin v2 ss × v1 ≢ v0 ) starDecomp v s ss vpf spf inSemi = {!!} {- starDecomp v sh st .(sh ∷ st) .((v0 , 0 , []) ∷ starSum sh st ∷ []) vnz refl refl (InHead .v .(v0 , 0 , []) .(starSum sh st ∷ []) x) with emptyCombZero v x | vnz (emptyCombZero v x) starDecomp .v0 sh st .(sh ∷ st) .((v0 , zero , []) ∷ [] Data.List.++ starSum sh st ∷ []) vnz refl refl (InHead .v0 .(v0 , zero , []) .(starSum sh st ∷ []) x) | refl | () starDecomp v sh [] .(sh ∷ []) .((v0 , 0 , []) ∷ (proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) ∷ []) vnz refl refl (InTail .v .(v0 , 0 , []) .((proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) ∷ []) (InHead .v .(proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) .[] starComb)) with linStarDecomp v sh _ vnz {!!} refl starComb starDecomp v sh [] .(sh ∷ []) .((v0 , zero , []) ∷ [] Data.List.++ starSum sh [] ∷ []) vnz refl refl (InTail .v .(v0 , zero , []) .(starSum sh [] ∷ []) (InHead .v .(proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) .[] starComb)) | inj₁ lComb = v , v0 , v0identRight , InHead v sh [] lComb , InHead v0 (v0 , zero , []) _ (v0 , refl) , vnz starDecomp v sh [] .(sh ∷ []) .((v0 , zero , []) ∷ [] Data.List.++ starSum sh [] ∷ []) vnz refl refl (InTail .v .(v0 , zero , []) .(starSum sh [] ∷ []) (InHead .v .(proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) .[] starComb)) | inj₂ (v1 , v2 , sumPf , comb1 , comb2 , zpf ) = v1 , v2 , sumPf , InHead v1 sh [] comb1 , InTail v2 (v0 , zero , []) _ (InHead v2 _ [] comb2) , zpf starDecomp v sh [] .(sh ∷ []) .((v0 , 0 , []) ∷ (proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) ∷ []) vnz refl refl (InTail .v .(v0 , 0 , []) .((proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) ∷ []) (InTail .v .(proj₁ sh , suc (proj₁ (proj₂ sh)) , proj₁ sh ∷ proj₂ (proj₂ sh)) .[] ())) starDecomp v sh (x ∷ st) .(sh ∷ x ∷ st) .((v0 , 0 , []) ∷ (proj₁ x +v proj₁ (starSum sh st) , suc (proj₁ (proj₂ x) + proj₁ (proj₂ (starSum sh st))) , proj₁ x ∷ proj₂ (proj₂ x) Data.Vec.++ proj₂ (proj₂ (starSum sh st))) ∷ []) vnz refl refl (InTail .v .(v0 , 0 , []) .((proj₁ x +v proj₁ (starSum sh st) , suc (proj₁ (proj₂ x) + proj₁ (proj₂ (starSum sh st))) , proj₁ x ∷ proj₂ (proj₂ x) Data.Vec.++ proj₂ (proj₂ (starSum sh st))) ∷ []) inSemi) = {!!} -} --Stolen from the stdlib listIdentity : {A : Set} -> (x : List A) -> (x Data.List.++ [] ) ≡ x listIdentity [] = refl listIdentity (x ∷ xs) = cong (_∷_ x) (listIdentity xs) {- Show that +s is actually the sum of two sets, that is, if v1 is in S1, and v2 is in S2, then v1 +v v2 is in S1 +s S2 -} sumPreserved : {n : ℕ} -> (u : Parikh n) -> (v : Parikh n) -- -> (uv : Parikh n) -> (su : SemiLinSet n) -> (sv : SemiLinSet n) -- -> (suv : SemiLinSet n) -- -> (uv ≡ u +v v) -- -> (suv ≡ su +s sv) -> InSemiLin u su -> InSemiLin v sv -> InSemiLin (u +v v) (su +s sv) sumPreserved u v .((ub , um , uvecs) ∷ st) .((vb , vm , vvecs) ∷ st₁) (InHead .u (ub , um , uvecs) st (uconsts , upf)) (InHead .v (vb , vm , vvecs) st₁ (vconsts , vpf)) rewrite upf | vpf = InHead (u +v v) (ub +v vb , um + vm , uvecs Data.Vec.++ vvecs) (Data.List.map (_+l_ (ub , um , uvecs)) st₁ Data.List.++ Data.List.foldr Data.List._++_ [] (Data.List.map (λ z → z +l (vb , vm , vvecs) ∷ Data.List.map (_+l_ z) st₁) st)) ((uconsts Data.Vec.++ vconsts) , trans (combSplit ub vb um vm uvecs vvecs uconsts vconsts) (sym (subst (λ x → u +v v ≡ x +v applyLinComb vb vm vvecs vconsts) (sym upf) (cong (λ x → u +v x) (sym vpf)))) ) sumPreserved u v .(sh ∷ st) .(sh₁ ∷ st₁) (InHead .u sh st x) (InTail .v sh₁ st₁ vIn) = let subCall1 : InSemiLin (u +v v) ((sh ∷ []) +s st₁) subCall1 = sumPreserved u v (sh ∷ []) ( st₁) (InHead u sh [] x) vIn eqTest : (sh ∷ []) +s ( st₁) ≡ Data.List.map (λ l2 → sh +l l2) st₁ eqTest = begin (sh ∷ []) +s (st₁) ≡⟨ refl ⟩ Data.List.map (λ l2 → sh +l l2) ( st₁) Data.List.++ [] ≡⟨ listIdentity (Data.List.map (_+l_ sh) st₁) ⟩ Data.List.map (λ l2 → sh +l l2) (st₁) ≡⟨ refl ⟩ (Data.List.map (λ l2 → sh +l l2) st₁ ∎) newCall = slExtend (u +v v) (Data.List.map (_+l_ sh) st₁) (subst (InSemiLin (u +v v)) eqTest subCall1) (sh +l sh₁) -- in slConcatRight (u +v v) (Data.List.map (λ l2 → sh +l l2) (sh₁ ∷ st₁)) newCall (Data.List.foldr Data.List._++_ [] (Data.List.map (λ z → z +l sh₁ ∷ Data.List.map (_+l_ z) st₁) st)) sumPreserved u v .(sh ∷ st) sv (InTail .u sh st uIn) vIn = (slConcatLeft (u +v v) (st +s sv) (sumPreserved u v st sv uIn vIn) (Data.List.map (λ x → sh +l x) sv)) --A useful lemma, avoids having to dig into the List monoid instance rightCons : {A : Set} -> (l : List A) -> (l Data.List.++ [] ≡ l) rightCons [] = refl rightCons (x ∷ l) rewrite rightCons l = refl {- Show that, if a vector is in the union of two semi-linear sets, then it must be in one of those sets. Used in the proof for Union. Called concat because we represent semi-linear sets as lists, so union is just concatenating two semi-linear sets -} decomposeConcat : {n : ℕ} -> (v : Parikh n) -> (s1 s2 s3 : SemiLinSet n) -> (s3 ≡ s1 Data.List.++ s2 ) -> InSemiLin v s3 -> InSemiLin v s1 ⊎ InSemiLin v s2 decomposeConcat v [] s2 .s2 refl inSemi = inj₂ inSemi decomposeConcat v (x ∷ s1) s2 .(x ∷ s1 Data.List.++ s2) refl (InHead .v .x .(s1 Data.List.++ s2) x₁) = inj₁ (InHead v x s1 x₁) decomposeConcat v (x ∷ s1) s2 .(x ∷ s1 Data.List.++ s2) refl (InTail .v .x .(s1 Data.List.++ s2) inSemi) with decomposeConcat v s1 s2 _ refl inSemi decomposeConcat v (x₁ ∷ s1) s2 .(x₁ ∷ s1 Data.List.++ s2) refl (InTail .v .x₁ .(s1 Data.List.++ s2) inSemi) | inj₁ x = inj₁ (InTail v x₁ s1 x) decomposeConcat v (x ∷ s1) s2 .(x ∷ s1 Data.List.++ s2) refl (InTail .v .x .(s1 Data.List.++ s2) inSemi) | inj₂ y = inj₂ y concatEq : {n : ℕ} -> (l : LinSet n) -> (s : SemiLinSet n) -> (l ∷ []) +s s ≡ (Data.List.map (_+l_ l) s) concatEq l [] = refl concatEq l (x ∷ s) rewrite concatEq l s | listIdentity (l ∷ []) = refl {- Show that if v is in l1 +l l2, then v = v1 +v v2 for some v1 in l1 and v2 in l2. This is the other half of the correcness proof of our sum functions, +l and +s -} decomposeLin : {n : ℕ} -> (v : Parikh n) -> (l1 l2 l3 : LinSet n) -> (l3 ≡ l1 +l l2 ) -> LinComb v l3 -> ∃ λ v1 → ∃ λ v2 -> (v1 +v v2 ≡ v) × (LinComb v1 l1) × (LinComb v2 l2 ) decomposeLin .(applyLinComb (b1 +v b2) (m1 + m2) (vecs1 Data.Vec.++ vecs2) coeffs) (b1 , m1 , vecs1) (b2 , m2 , vecs2) .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) refl (coeffs , refl) with Data.Vec.splitAt m1 coeffs decomposeLin .(applyLinComb (b1 +v b2) (m1 + m2) (vecs1 Data.Vec.++ vecs2) (coeffs1 Data.Vec.++ coeffs2)) (b1 , m1 , vecs1) (b2 , m2 , vecs2) .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) refl (.(coeffs1 Data.Vec.++ coeffs2) , refl) | coeffs1 , coeffs2 , refl rewrite combSplit b1 b2 m1 m2 vecs1 vecs2 coeffs1 coeffs2 = applyLinComb b1 m1 vecs1 coeffs1 , (applyLinComb b2 m2 vecs2 coeffs2 , (refl , ((coeffs1 , refl) , (coeffs2 , refl)))) {- Show that our Parikh function is a superset of the actual Parikh image of a Regular Expression. We do this by showing that, for every word matching an RE, its Parikh vector is in the Parikh Image of the RE -} reParikhCorrect : {n : ℕ} -> {null? : RETypes.Null?} -> (cmap : Char -> Fin.Fin n) -> (r : RETypes.RE null?) -> (w : List Char ) -> RETypes.REMatch w r -> (wordPar : Parikh n) -> (wordParikh cmap w ≡ wordPar) -> (langParikh : SemiLinSet n) -> (langParikh ≡ reSemiLin cmap r ) -> (InSemiLin wordPar langParikh ) reParikhCorrect cmap .RETypes.ε .[] RETypes.EmptyMatch .v0 refl .((v0 , 0 , []) ∷ []) refl = InHead v0 (v0 , zero , []) [] ([] , refl) reParikhCorrect cmap .(RETypes.Lit c) .(c ∷ []) (RETypes.LitMatch c) .(basis (cmap c) +v v0) refl .((basis (cmap c) , 0 , []) ∷ []) refl = InHead (basis (cmap c) +v v0) (basis (cmap c) , zero , []) [] (subst (λ x → LinComb x (basis (cmap c) , zero , [])) (sym v0identRight) (v0 , (v0apply (basis (cmap c)) []))) reParikhCorrect cmap (r1 RETypes.+ .r2) w (RETypes.LeftPlusMatch r2 match) wordPar wpf langParikh lpf = let leftParikh = reSemiLin cmap r1 leftInSemi = reParikhCorrect cmap r1 w match wordPar wpf leftParikh refl --Idea: show that langParikh is leftParikh ++ rightParikh --And that this means that it must be in the concatentation extendToConcat : InSemiLin wordPar ((reSemiLin cmap r1 ) Data.List.++ (reSemiLin cmap r2)) extendToConcat = slConcatRight wordPar (reSemiLin cmap r1) leftInSemi (reSemiLin cmap r2) in subst (λ x → InSemiLin wordPar x) (sym lpf) extendToConcat reParikhCorrect cmap (.r1 RETypes.+ r2) w (RETypes.RightPlusMatch r1 match) wordPar wpf langParikh lpf = let rightParikh = reSemiLin cmap r2 rightInSemi = reParikhCorrect cmap r2 w match wordPar wpf rightParikh refl --Idea: show that langParikh is leftParikh ++ rightParikh --And that this means that it must be in the concatentation extendToConcat : InSemiLin wordPar ((reSemiLin cmap r1 ) Data.List.++ (reSemiLin cmap r2)) extendToConcat = slConcatLeft wordPar (reSemiLin cmap r2) rightInSemi (reSemiLin cmap r1) in subst (λ x → InSemiLin wordPar x) (sym lpf) extendToConcat reParikhCorrect cmap (r1 RETypes.· r2) s3 (RETypes.ConcatMatch {s1 = s1} {s2 = s2} {spf = spf} match1 match2) .(wordParikh cmap s3) refl ._ refl rewrite (sym spf) | (wordParikhPlus cmap s1 s2) = let leftParikh = reSemiLin cmap r1 leftInSemi : InSemiLin (wordParikh cmap s1) leftParikh leftInSemi = reParikhCorrect cmap r1 s1 match1 (wordParikh cmap s1) refl (reSemiLin cmap r1) refl rightParikh = reSemiLin cmap r2 rightInSemi : InSemiLin (wordParikh cmap s2) rightParikh rightInSemi = reParikhCorrect cmap r2 s2 match2 (wordParikh cmap s2) refl (reSemiLin cmap r2) refl wordParikhIsPlus : (wordParikh cmap s1) +v (wordParikh cmap s2) ≡ (wordParikh cmap (s1 Data.List.++ s2 )) wordParikhIsPlus = sym (wordParikhPlus cmap s1 s2) in sumPreserved (wordParikh cmap s1) (wordParikh cmap s2) leftParikh rightParikh leftInSemi rightInSemi reParikhCorrect cmap (r RETypes.*) [] RETypes.EmptyStarMatch .v0 refl .(starSemiLin (reSemiLin cmap r)) refl = zeroInStar (reSemiLin cmap r) (starSemiLin (reSemiLin cmap r)) refl reParikhCorrect cmap (r RETypes.*) .(s1 Data.List.++ s2 ) (RETypes.StarMatch {s1 = s1} {s2 = s2} {spf = refl} m1 m2) ._ refl .(starSemiLin (reSemiLin cmap r)) refl rewrite wordParikhPlus cmap s1 s2 = starExtend (wordParikh cmap s1) (wordParikh cmap s2) (reSemiLin cmap r) _ refl (reParikhCorrect cmap r s1 m1 (wordParikh cmap s1) refl (reSemiLin cmap r) refl) (reParikhCorrect cmap (r RETypes.*) s2 m2 (wordParikh cmap s2) refl (starSemiLin (reSemiLin cmap r)) refl) {- Show that if v is in s1 +s s2, then v = v1 +v v2 for some v1 in s1 and v2 in s2. This is the other half of the correcness proof of our sum functions, +l and +s -} decomposeSum : {n : ℕ} -> (v : Parikh n) -> (s1 s2 s3 : SemiLinSet n) -> (s3 ≡ s1 +s s2 ) -> InSemiLin v s3 -> ∃ λ (v1 : Parikh n) → ∃ λ (v2 : Parikh n) -> (v1 +v v2 ≡ v) × (InSemiLin v1 s1) × (InSemiLin v2 s2 ) decomposeSum v [] [] .[] refl () decomposeSum v [] (x ∷ s2) .[] refl () decomposeSum v (x ∷ s1) [] .(Data.List.foldr Data.List._++_ [] (Data.List.map (λ l1 → []) s1)) refl () decomposeSum v ((b1 , m1 , vecs1) ∷ s1) ((b2 , m2 , vecs2) ∷ s2) ._ refl (InHead .v .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) ._ lcomb) = let (v1 , v2 , plusPf , comb1 , comb2 ) = decomposeLin v (b1 , m1 , vecs1) (b2 , m2 , vecs2) (b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) refl lcomb in v1 , v2 , plusPf , InHead v1 (b1 , m1 , vecs1) s1 comb1 , InHead v2 (b2 , m2 , vecs2) s2 comb2 decomposeSum v ((b1 , m1 , vecs1) ∷ s1) ((b2 , m2 , vecs2) ∷ s2) ._ refl (InTail .v .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) ._ inSemi) with decomposeConcat v (Data.List.map (_+l_ (b1 , m1 , vecs1)) s2) (Data.List.foldr Data.List._++_ [] (Data.List.map (λ z → z +l (b2 , m2 , vecs2) ∷ Data.List.map (_+l_ z) s2) s1)) (Data.List.map (_+l_ (b1 , m1 , vecs1)) s2 Data.List.++ Data.List.foldr Data.List._++_ [] (Data.List.map (λ z → z +l (b2 , m2 , vecs2) ∷ Data.List.map (_+l_ z) s2) s1)) refl inSemi decomposeSum v ((b1 , m1 , vecs1) ∷ s1) ((b2 , m2 , vecs2) ∷ s2) .((b1 , m1 , vecs1) +l (b2 , m2 , vecs2) ∷ Data.List.map (_+l_ (b1 , m1 , vecs1)) s2 Data.List.++ Data.List.foldr Data.List._++_ [] (Data.List.map _ s1)) refl (InTail .v .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) .(Data.List.map (_+l_ (b1 , m1 , vecs1)) s2 Data.List.++ Data.List.foldr Data.List._++_ [] (Data.List.map _ s1)) inSemi) | inj₁ inSub = let subCall1 = decomposeSum v ((b1 , m1 , vecs1) ∷ []) s2 _ refl (subst (λ x → InSemiLin v x) (sym (concatEq (b1 , m1 , vecs1) s2)) inSub) v1 , v2 , pf , xIn , yIn = subCall1 in v1 , (v2 , (pf , (slCons v1 s1 (b1 , m1 , vecs1) xIn , slExtend v2 s2 yIn (b2 , m2 , vecs2)))) decomposeSum v ((b1 , m1 , vecs1) ∷ s1) ((b2 , m2 , vecs2) ∷ s2) .((b1 , m1 , vecs1) +l (b2 , m2 , vecs2) ∷ Data.List.map (_+l_ (b1 , m1 , vecs1)) s2 Data.List.++ Data.List.foldr Data.List._++_ [] (Data.List.map _ s1)) refl (InTail .v .(b1 +v b2 , m1 + m2 , vecs1 Data.Vec.++ vecs2) .(Data.List.map (_+l_ (b1 , m1 , vecs1)) s2 Data.List.++ Data.List.foldr Data.List._++_ [] (Data.List.map _ s1)) inSemi) | inj₂ inSub = let subCall1 = decomposeSum v s1 ((b2 , m2 , vecs2) ∷ s2) _ refl inSub v1 , v2 , pf , xIn , yIn = subCall1 in v1 , v2 , pf , slExtend v1 s1 xIn (b1 , m1 , vecs1) , yIn {- Show that the generated Parikh image is a subset of the actual Parikh image. We do this by showing that, for every vector in the generated Parikh image, there's some word matched by the RE whose Parikh vector is that vector. -} --We have to convince the compiler that this is terminating --Since I didn't have time to implement the proofs of non-zero vectors --Which show that we only recurse on strictly smaller vectors in the Star case {-# TERMINATING #-} reParikhComplete : {n : ℕ} -> {null? : RETypes.Null?} -> (cmap : Char -> Fin.Fin n) -- -> (imap : Fin.Fin n -> Char) -- -> (invPf1 : (x : Char ) -> imap (cmap x) ≡ x) -- -> (invPf2 : (x : Fin.Fin n ) -> cmap (imap x) ≡ x ) -> (r : RETypes.RE null?) -> (v : Parikh n ) -> (langParikh : SemiLinSet n) -> langParikh ≡ (reSemiLin cmap r ) -> (InSemiLin v langParikh ) -> ∃ (λ w -> (v ≡ wordParikh cmap w) × (RETypes.REMatch w r) ) reParikhComplete cmap RETypes.ε .v0 .((v0 , 0 , []) ∷ []) refl (InHead .v0 .(v0 , 0 , []) .[] (combConsts , refl)) = [] , refl , RETypes.EmptyMatch reParikhComplete cmap RETypes.ε v .((v0 , 0 , []) ∷ []) refl (InTail .v .(v0 , 0 , []) .[] ()) --reParikhComplete cmap RETypes.ε v .(sh ∷ st) lpf (InTail .v sh st inSemi) = {!!} reParikhComplete cmap RETypes.∅ v [] lpf () reParikhComplete cmap RETypes.∅ v (h ∷ t) () inSemi reParikhComplete cmap (RETypes.Lit x) langParikh [] inSemi () reParikhComplete cmap (RETypes.Lit x) .(basis (cmap x)) .((basis (cmap x) , 0 , []) ∷ []) refl (InHead .(basis (cmap x)) .(basis (cmap x) , 0 , []) .[] (consts , refl)) = (x ∷ []) , (sym v0identRight , RETypes.LitMatch x) reParikhComplete cmap (RETypes.Lit x) v .((basis (cmap x) , 0 , []) ∷ []) refl (InTail .v .(basis (cmap x) , 0 , []) .[] ()) --reParikhComplete cmap (RETypes.Lit x) v .((basis (cmap x) , 0 , []) ∷ []) refl (InTail .v .(basis (cmap x) , 0 , []) .[] ()) reParikhComplete {null? = null?} cmap (r1 RETypes.+ r2) v langParikh lpf inSemi with decomposeConcat v (reSemiLin cmap r1) (reSemiLin cmap r2) langParikh lpf inSemi ... | inj₁ in1 = let (subw , subPf , subMatch) = reParikhComplete cmap r1 v (reSemiLin cmap r1) refl in1 in subw , (subPf , (RETypes.LeftPlusMatch r2 subMatch)) ... | inj₂ in2 = let (subw , subPf , subMatch) = reParikhComplete cmap r2 v (reSemiLin cmap r2) refl in2 in subw , (subPf , (RETypes.RightPlusMatch r1 subMatch)) reParikhComplete cmap (r1 RETypes.· r2) v ._ refl inSemi with decomposeSum v (reSemiLin cmap r1) (reSemiLin cmap r2) (reSemiLin cmap r1 +s reSemiLin cmap r2) refl inSemi | reParikhComplete cmap r1 (proj₁ (decomposeSum v (reSemiLin cmap r1) (reSemiLin cmap r2) (reSemiLin cmap r1 +s reSemiLin cmap r2) refl inSemi)) (reSemiLin cmap r1) refl (proj₁ (proj₂ (proj₂ (proj₂ (decomposeSum v (reSemiLin cmap r1) (reSemiLin cmap r2) (reSemiLin cmap r1 +s reSemiLin cmap r2) refl inSemi))))) | reParikhComplete cmap r2 (proj₁ (proj₂ (decomposeSum v (reSemiLin cmap r1) (reSemiLin cmap r2) (reSemiLin cmap r1 +s reSemiLin cmap r2) refl inSemi))) (reSemiLin cmap r2) refl (proj₂ (proj₂ (proj₂ (proj₂ (decomposeSum v (reSemiLin cmap r1) (reSemiLin cmap r2) (reSemiLin cmap r1 +s reSemiLin cmap r2) refl inSemi))))) reParikhComplete cmap (r1 RETypes.· r2) .(wordParikh cmap w1 +v wordParikh cmap w2) .(Data.List.foldr Data.List._++_ [] (Data.List.map _ (reSemiLin cmap r1))) refl inSemi | .(wordParikh cmap w1) , .(wordParikh cmap w2) , refl , inSemi1 , inSemi2 | w1 , refl , match1 | w2 , refl , match2 = (w1 Data.List.++ w2) , ((sym (wordParikhPlus cmap w1 w2)) , (RETypes.ConcatMatch match1 match2)) reParikhComplete cmap (r RETypes.*) v langParikh lpf inSemi with (reSemiLin cmap r ) reParikhComplete cmap (r RETypes.*) v .((v0 , 0 , []) ∷ []) refl (InHead .v .(v0 , 0 , []) .[] x) | [] = [] , ((sym (proj₂ x)) , RETypes.EmptyStarMatch) reParikhComplete cmap (r RETypes.*) v .((v0 , 0 , []) ∷ []) refl (InTail .v .(v0 , 0 , []) .[] ()) | [] reParikhComplete cmap (r RETypes.*) v .((v0 , 0 , []) ∷ starSum x rsl ∷ []) refl inSemi | x ∷ rsl = let --The first hole is the non-zero proofs that I couldn't work out --I'm not totally sure about the second, but I think I just need to apply some associativity to inSemi to get it to fit --into the second hole. splitVec = starDecomp v (reSemiLin cmap r) _ {!!} refl {!!} v1 , v2 , vpf , inS , inSS , _ = splitVec subCall1 = reParikhComplete cmap r v1 _ refl inS w1 , wpf1 , match = subCall1 subCall2 = reParikhComplete cmap (r RETypes.*) v2 _ refl inSS w2 , wpf2 , match2 = subCall2 in (w1 Data.List.++ w2) , (trans (sym vpf) (sym (wordParikhPlus cmap w1 w2)) , RETypes.StarMatch match match2)
{ "alphanum_fraction": 0.5539221642, "avg_line_length": 60.2268292683, "ext": "agda", "hexsha": "18ee8850dd3be541c6427a92ba88311a3e42ed04", "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": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "JoeyEremondi/agda-parikh", "max_forks_repo_path": "SemiLinRE.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea", "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": "JoeyEremondi/agda-parikh", "max_issues_repo_path": "SemiLinRE.agda", "max_line_length": 590, "max_stars_count": null, "max_stars_repo_head_hexsha": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "JoeyEremondi/agda-parikh", "max_stars_repo_path": "SemiLinRE.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8494, "size": 24693 }
open import Level open import Ordinals module cardinal {n : Level } (O : Ordinals {n}) where open import zf open import logic import OD import ODC import OPair open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ ) open import Relation.Binary.PropositionalEquality open import Data.Nat.Properties open import Data.Empty open import Relation.Nullary open import Relation.Binary open import Relation.Binary.Core open inOrdinal O open OD O open OD.OD open OPair O open ODAxiom odAxiom import OrdUtil import ODUtil open Ordinals.Ordinals O open Ordinals.IsOrdinals isOrdinal open Ordinals.IsNext isNext open OrdUtil O open ODUtil O open _∧_ open _∨_ open Bool open _==_ open HOD -- _⊗_ : (A B : HOD) → HOD -- A ⊗ B = Union ( Replace B (λ b → Replace A (λ a → < a , b > ) )) Func : OD Func = record { def = λ x → def ZFProduct x ∧ ( (a b c : Ordinal) → odef (* x) (& < * a , * b >) ∧ odef (* x) (& < * a , * c >) → b ≡ c ) } FuncP : ( A B : HOD ) → HOD FuncP A B = record { od = record { def = λ x → odef (ZFP A B) x ∧ ( (x : Ordinal ) (p q : odef (ZFP A B ) x ) → pi1 (proj1 p) ≡ pi1 (proj1 q) → pi2 (proj1 p) ≡ pi2 (proj1 q) ) } ; odmax = odmax (ZFP A B) ; <odmax = λ lt → <odmax (ZFP A B) (proj1 lt) } record Injection (A B : Ordinal ) : Set n where field i→ : (x : Ordinal ) → odef (* A) x → Ordinal iB : (x : Ordinal ) → ( lt : odef (* A) x ) → odef (* B) ( i→ x lt ) iiso : (x y : Ordinal ) → ( ltx : odef (* A) x ) ( lty : odef (* A) y ) → i→ x ltx ≡ i→ y lty → x ≡ y record Bijection (A B : Ordinal ) : Set n where field fun← : (x : Ordinal ) → odef (* A) x → Ordinal fun→ : (x : Ordinal ) → odef (* B) x → Ordinal funB : (x : Ordinal ) → ( lt : odef (* A) x ) → odef (* B) ( fun← x lt ) funA : (x : Ordinal ) → ( lt : odef (* B) x ) → odef (* A) ( fun→ x lt ) fiso← : (x : Ordinal ) → ( lt : odef (* B) x ) → fun← ( fun→ x lt ) ( funA x lt ) ≡ x fiso→ : (x : Ordinal ) → ( lt : odef (* A) x ) → fun→ ( fun← x lt ) ( funB x lt ) ≡ x Bernstein : {a b : Ordinal } → Injection a b → Injection b a → Bijection a b Bernstein = {!!} _=c=_ : ( A B : HOD ) → Set n A =c= B = Bijection ( & A ) ( & B ) _c<_ : ( A B : HOD ) → Set n A c< B = ¬ ( Injection (& A) (& B) ) Card : OD Card = record { def = λ x → (a : Ordinal) → a o< x → ¬ Bijection a x } record Cardinal (a : Ordinal ) : Set (suc n) where field card : Ordinal ciso : Bijection a card cmax : (x : Ordinal) → card o< x → ¬ Bijection a x Cardinal∈ : { s : HOD } → { t : Ordinal } → Ord t ∋ s → s c< Ord t Cardinal∈ = {!!} Cardinal⊆ : { s t : HOD } → s ⊆ t → ( s c< t ) ∨ ( s =c= t ) Cardinal⊆ = {!!} Cantor1 : { u : HOD } → u c< Power u Cantor1 = {!!} Cantor2 : { u : HOD } → ¬ ( u =c= Power u ) Cantor2 = {!!}
{ "alphanum_fraction": 0.5336823735, "avg_line_length": 29.84375, "ext": "agda", "hexsha": "f4d8e704180215b9dbffe0714afb796146746fc9", "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": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/zf-in-agda", "max_forks_repo_path": "src/cardinal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "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": "shinji-kono/zf-in-agda", "max_issues_repo_path": "src/cardinal.agda", "max_line_length": 118, "max_stars_count": 5, "max_stars_repo_head_hexsha": "031f1ea3a3037cd51eb022dbfb5c75b037bf8aa0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/zf-in-agda", "max_stars_repo_path": "src/cardinal.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-10T13:27:48.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-02T13:46:23.000Z", "num_tokens": 1124, "size": 2865 }
{-# OPTIONS --without-K #-} import Level as L open import Type open import Function open import Algebra open import Algebra.FunctionProperties.NP open import Data.Nat.NP hiding (_^_) open import Data.Nat.Properties open import Data.One hiding (_≤_) open import Data.Sum open import Data.Maybe.NP open import Data.Product open import Data.Bits open import Data.Zero open import Data.Bool.NP as Bool import Function.Equality as FE open FE using (_⟨$⟩_ ; ≡-setoid) import Function.Injection as Finj import Function.Inverse as FI open FI using (_↔_; module Inverse) open import Function.LeftInverse using (_RightInverseOf_) import Function.Related as FR open import Function.Related.TypeIsomorphisms.NP open import Relation.Binary.NP open import Relation.Binary.Sum open import Relation.Binary.Product.Pointwise open import Relation.Unary.Logical open import Relation.Binary.Logical import Relation.Binary.PropositionalEquality.NP as ≡ open ≡ using (_≡_; _≗_) open import Search.Type module sum-setoid where SearchExtFun-úber : ∀ {A B} → (SF : Search (A → B)) → SearchInd SF → SearchExtFun SF SearchExtFun-úber sf sf-ind op {f = f}{g} f≈g = sf-ind (λ s → s op f ≡ s op g) (≡.cong₂ op) (λ x → f≈g (λ _ → ≡.refl)) SearchExtFun-úber' : ∀ {A B} → (SF : Search (A → B)) → SearchInd SF → SearchExtFun SF SearchExtFun-úber' sf sf-ind op {f = f}{g} f≈g = sf-ind (λ s → s op f ≡ s op g) (≡.cong₂ op) (λ x → f≈g (λ _ → ≡.refl)) SearchExtoid : ∀ {A : Setoid L.zero L.zero} → Search (Setoid.Carrier A) → ★₁ SearchExtoid {A} sᴬ = ∀ {M} op {f g : A FE.⟶ ≡.setoid M} → Setoid._≈_ (A FE.⇨ ≡.setoid M) f g → sᴬ op (_⟨$⟩_ f) ≡ sᴬ op (_⟨$⟩_ g) sum-lin⇒sum-zero : ∀ {A} → {sum : Sum A} → SumLin sum → SumZero sum sum-lin⇒sum-zero sum-lin = sum-lin (λ _ → 0) 0 sum-mono⇒sum-ext : ∀ {A} → {sum : Sum A} → SumMono sum → SumExt sum sum-mono⇒sum-ext sum-mono f≗g = ℕ≤.antisym (sum-mono (ℕ≤.reflexive ∘ f≗g)) (sum-mono (ℕ≤.reflexive ∘ ≡.sym ∘ f≗g)) sum-ext+sum-hom⇒sum-mono : ∀ {A} → {sum : Sum A} → SumExt sum → SumHom sum → SumMono sum sum-ext+sum-hom⇒sum-mono {sum = sum} sum-ext sum-hom {f} {g} f≤°g = sum f ≤⟨ m≤m+n _ _ ⟩ sum f + sum (λ x → g x ∸ f x) ≡⟨ ≡.sym (sum-hom _ _) ⟩ sum (λ x → f x + (g x ∸ f x)) ≡⟨ sum-ext (m+n∸m≡n ∘ f≤°g) ⟩ sum g ∎ where open ≤-Reasoning record SumPropoid (As : Setoid L.zero L.zero) : ★₁ where constructor _,_ module ≈ᴬ = Setoid As open ≈ᴬ using () renaming (_≈_ to _≈ᴬ_; Carrier to A) field search : Search A search-ind : SearchInd search ⟦search⟧ : ∀ {Aᵣ : A → A → ★} (Aᵣ-refl : Reflexive Aᵣ) → ⟦Search⟧₁ Aᵣ search ⟦search⟧ Aᵣ-refl Mᵣ ∙ᵣ fᵣ = search-ind (λ s → Mᵣ (s _ _) (s _ _)) (λ η → ∙ᵣ η) (λ _ → fᵣ Aᵣ-refl) -- this one is given for completness but the asking for the Aₚ predicate -- to be trivial makes this result useless. [search] : ∀ (Aₚ : A → ★) (Aₚ-triv : ∀ x → Aₚ x) → [Search] Aₚ search [search] Aₚ Aₚ-triv {M} Mₚ ∙ₚ fₚ = search-ind (λ s → Mₚ (s _ _)) (λ η → ∙ₚ η) (λ x → fₚ (Aₚ-triv x)) search-sg-ext : SearchSgExt search search-sg-ext sg {f} {g} f≈°g = search-ind (λ s → s _ f ≈ s _ g) ∙-cong f≈°g where open Sgrp sg foo : ∀ {A : ★} {R : A → A → ★} → Reflexive R → _≡_ ⇒ R foo R-refl ≡.refl = R-refl search-ext : SearchExt search -- search-ext op {g = g} pf = ⟦search⟧ {_≡_} ≡.refl _≡_ (λ η → ≡.cong₂ op η) (≡.trans (pf _) ∘ ≡.cong g) -- (foo (λ {x} → pf x)) search-ext op pf = ⟦search⟧ {_≡_} ≡.refl _≡_ (λ η → ≡.cong₂ op η) (foo (λ {x} → pf x)) -- (λ { {x} .{x} ≡.refl → pf _ }) -- {!search-extoid op = ⟦search⟧ {_≈ᴬ_} ≈ᴬ.refl _≡_ (λ η → ≡.cong₂ op η)!} search-mono : SearchMono search search-mono _⊆_ _∙-mono_ {f} {g} f⊆°g = search-ind (λ s → s _ f ⊆ s _ g) _∙-mono_ f⊆°g search-swap : SearchSwap search search-swap sg f {sᴮ} pf = search-ind (λ s → s _ (sᴮ ∘ f) ≈ sᴮ (s _ ∘ flip f)) (λ p q → trans (∙-cong p q) (sym (pf _ _))) (λ _ → refl) where open Sgrp sg searchMon : SearchMon A searchMon m = search _∙_ where open Mon m search-ε : Searchε searchMon search-ε m = search-ind (λ s → s _ (const ε) ≈ ε) (λ x≈ε y≈ε → trans (∙-cong x≈ε y≈ε) (proj₁ identity ε)) (λ _ → refl) where open Mon m search-hom : SearchMonHom searchMon search-hom cm f g = search-ind (λ s → s _ (f ∙° g) ≈ s _ f ∙ s _ g) (λ p₀ p₁ → trans (∙-cong p₀ p₁) (∙-interchange _ _ _ _)) (λ _ → refl) where open CMon cm search-hom′ : ∀ {S T} (_+_ : Op₂ S) (_*_ : Op₂ T) (f : S → T) (g : A → S) (hom : ∀ x y → f (x + y) ≡ f x * f y) → f (search _+_ g) ≡ search _*_ (f ∘ g) search-hom′ _+_ _*_ f g hom = search-ind (λ s → f (s _+_ g) ≡ s _*_ (f ∘ g)) (λ p q → ≡.trans (hom _ _) (≡.cong₂ _*_ p q)) (λ _ → ≡.refl) StableUnder : As FE.⟶ As → ★₁ StableUnder p = ∀ {B} (op : Op₂ B) f → search op f ≡ search op (f ∘ _⟨$⟩_ p) sum : Sum A sum = search _+_ sum-ind : SumInd sum sum-ind P P+ Pf = search-ind (λ s → P (s _+_)) P+ Pf sum-ext : SumExt sum sum-ext = search-ext _+_ sum-zero : SumZero sum sum-zero = search-ε ℕ+.monoid sum-hom : SumHom sum sum-hom = search-hom ℕ°.+-commutativeMonoid sum-mono : SumMono sum sum-mono = search-mono _≤_ _+-mono_ sum-lin : SumLin sum sum-lin f zero = sum-zero sum-lin f (suc k) = ≡.trans (sum-hom f (λ x → k * f x)) (≡.cong₂ _+_ (≡.refl {x = sum f}) (sum-lin f k)) SumStableUnder : As FE.⟶ As → ★ SumStableUnder p = ∀ (f : As FE.⟶ ≡.setoid ℕ) → sum (_⟨$⟩_ f) ≡ sum (_⟨$⟩_ (f FE.∘ p)) sumStableUnder : ∀ {p} → StableUnder p → SumStableUnder p sumStableUnder SU-p f = SU-p _+_ (_⟨$⟩_ f) Card : ℕ Card = sum (const 1) count : Count A count f = sum (Bool.toℕ ∘ f) count-ext : CountExt count count-ext f≗g = sum-ext (≡.cong Bool.toℕ ∘ f≗g) CountStableUnder : As FE.⟶ As → ★ CountStableUnder p = ∀ (f : As FE.⟶ ≡.setoid Bool) → count (_⟨$⟩_ f) ≡ count (_⟨$⟩_ (f FE.∘ p)) countStableUnder : ∀ {p} → SumStableUnder p → CountStableUnder p countStableUnder sumSU-p f = sumSU-p (≡.:→-to-Π Bool.toℕ FE.∘ f) search-extoid : SearchExtoid {As} search -- search-extoid op {f = f}{g} f≈g = search-ind (λ s₁ → s₁ op (_⟨$⟩_ f) ≡ s₁ op (_⟨$⟩_ g)) (≡.cong₂ op) (λ x → f≈g (Setoid.refl As)) search-extoid op = ⟦search⟧ {_≈ᴬ_} ≈ᴬ.refl _≡_ (λ η → ≡.cong₂ op η) SumProp : ★ → ★₁ SumProp A = SumPropoid (≡.setoid A) open SumPropoid public search-swap' : ∀ {A B} cm (μA : SumPropoid A) (μB : SumPropoid B) f → let open CMon cm sᴬ = search μA _∙_ sᴮ = search μB _∙_ in sᴬ (sᴮ ∘ f) ≈ sᴮ (sᴬ ∘ flip f) search-swap' cm μA μB f = search-swap μA sg f (search-hom μB cm) where open CMon cm sum-swap : ∀ {A B} (μA : SumPropoid A) (μB : SumPropoid B) f → sum μA (sum μB ∘ f) ≡ sum μB (sum μA ∘ flip f) sum-swap = search-swap' ℕ°.+-commutativeMonoid _≈Sum_ : ∀ {A} → (sum₀ sum₁ : Sum A) → ★ sum₀ ≈Sum sum₁ = ∀ f → sum₀ f ≡ sum₁ f _≈Search_ : ∀ {A} → (s₀ s₁ : Search A) → ★₁ s₀ ≈Search s₁ = ∀ {B} (op : Op₂ B) f → s₀ op f ≡ s₁ op f μ𝟙 : SumProp 𝟙 μ𝟙 = srch , ind where srch : Search 𝟙 srch _ f = f _ ind : SearchInd srch ind _ _ Pf = Pf _ μBit : SumProp Bit μBit = searchBit , ind where searchBit : Search Bit searchBit _∙_ f = f 0b ∙ f 1b ind : SearchInd searchBit ind _ _P∙_ Pf = Pf 0b P∙ Pf 1b infixr 4 _+Search_ _+Search_ : ∀ {A B} → Search A → Search B → Search (A ⊎ B) (searchᴬ +Search searchᴮ) _∙_ f = searchᴬ _∙_ (f ∘ inj₁) ∙ searchᴮ _∙_ (f ∘ inj₂) _+SearchInd_ : ∀ {A B} {sᴬ : Search A} {sᴮ : Search B} → SearchInd sᴬ → SearchInd sᴮ → SearchInd (sᴬ +Search sᴮ) (Psᴬ +SearchInd Psᴮ) P P∙ Pf = P∙ (Psᴬ (λ s → P (λ _ f → s _ (f ∘ inj₁))) P∙ (Pf ∘ inj₁)) (Psᴮ (λ s → P (λ _ f → s _ (f ∘ inj₂))) P∙ (Pf ∘ inj₂)) infixr 4 _+Sum_ _+Sum_ : ∀ {A B} → Sum A → Sum B → Sum (A ⊎ B) (sumᴬ +Sum sumᴮ) f = sumᴬ (f ∘ inj₁) + sumᴮ (f ∘ inj₂) _+μ_ : ∀ {A B} → SumPropoid A → SumPropoid B → SumPropoid (A ⊎-setoid B) μA +μ μB = _ , search-ind μA +SearchInd search-ind μB infixr 4 _×Search_ -- liftM2 _,_ in the continuation monad _×Search_ : ∀ {A B} → Search A → Search B → Search (A × B) (searchᴬ ×Search searchᴮ) op f = searchᴬ op (λ x → searchᴮ op (curry f x)) _×SearchInd_ : ∀ {A B} {sᴬ : Search A} {sᴮ : Search B} → SearchInd sᴬ → SearchInd sᴮ → SearchInd (sᴬ ×Search sᴮ) (Psᴬ ×SearchInd Psᴮ) P P∙ Pf = Psᴬ (λ s → P (λ _ _ → s _ _)) P∙ (Psᴮ (λ s → P (λ _ _ → s _ _)) P∙ ∘ curry Pf) _×SearchExt_ : ∀ {A B} {sᴬ : Search A} {sᴮ : Search B} → SearchExt sᴬ → SearchExt sᴮ → SearchExt (sᴬ ×Search sᴮ) (sᴬ-ext ×SearchExt sᴮ-ext) sg f≗g = sᴬ-ext sg (sᴮ-ext sg ∘ curry f≗g) infixr 4 _×Sum_ -- liftM2 _,_ in the continuation monad _×Sum_ : ∀ {A B} → Sum A → Sum B → Sum (A × B) (sumᴬ ×Sum sumᴮ) f = sumᴬ (λ x₀ → sumᴮ (λ x₁ → f (x₀ , x₁))) infixr 4 _×μ_ _×μ_ : ∀ {A B} → SumPropoid A → SumPropoid B → SumPropoid (A ×-setoid B) μA ×μ μB = _ , search-ind μA ×SearchInd search-ind μB sum-const : ∀ {A} (μA : SumProp A) → ∀ k → sum μA (const k) ≡ Card μA * k sum-const μA k rewrite ℕ°.*-comm (Card μA) k | ≡.sym (sum-lin μA (const 1) k) | proj₂ ℕ°.*-identity k = ≡.refl infixr 4 _×Sum-proj₁_ _×Sum-proj₁'_ _×Sum-proj₂_ _×Sum-proj₂'_ _×Sum-proj₁_ : ∀ {A B} (μA : SumProp A) (μB : SumProp B) f → sum (μA ×μ μB) (f ∘ proj₁) ≡ Card μB * sum μA f (μA ×Sum-proj₁ μB) f rewrite sum-ext μA (sum-const μB ∘ f) = sum-lin μA f (Card μB) _×Sum-proj₂_ : ∀ {A B} (μA : SumProp A) (μB : SumProp B) f → sum (μA ×μ μB) (f ∘ proj₂) ≡ Card μA * sum μB f (μA ×Sum-proj₂ μB) f = sum-const μA (sum μB f) _×Sum-proj₁'_ : ∀ {A B} (μA : SumProp A) (μB : SumProp B) {f} {g} → sum μA f ≡ sum μA g → sum (μA ×μ μB) (f ∘ proj₁) ≡ sum (μA ×μ μB) (g ∘ proj₁) (μA ×Sum-proj₁' μB) {f} {g} sumf≡sumg rewrite (μA ×Sum-proj₁ μB) f | (μA ×Sum-proj₁ μB) g | sumf≡sumg = ≡.refl _×Sum-proj₂'_ : ∀ {A B} (μA : SumProp A) (μB : SumProp B) {f} {g} → sum μB f ≡ sum μB g → sum (μA ×μ μB) (f ∘ proj₂) ≡ sum (μA ×μ μB) (g ∘ proj₂) (μA ×Sum-proj₂' μB) sumf≡sumg = sum-ext μA (const sumf≡sumg) μ-view : ∀ {A B} → (A FE.⟶ B) → SumPropoid A → SumPropoid B μ-view {A}{B} A→B μA = searchᴮ , ind where searchᴮ : Search (Setoid.Carrier B) searchᴮ m f = search μA m (f ∘ _⟨$⟩_ A→B) ind : SearchInd searchᴮ ind P P∙ Pf = search-ind μA (λ s → P (λ _ f → s _ (f ∘ _⟨$⟩_ A→B))) P∙ (Pf ∘ _⟨$⟩_ A→B) μ-iso : ∀ {A B} → (FI.Inverse A B) → SumPropoid A → SumPropoid B μ-iso A↔B = μ-view (Inverse.to A↔B) μ-view-preserve : ∀ {A B} (A→B : A FE.⟶ B)(B→A : B FE.⟶ A)(A≈B : A→B RightInverseOf B→A) (f : A FE.⟶ ≡.setoid ℕ) (μA : SumPropoid A) → sum μA (_⟨$⟩_ f) ≡ sum (μ-view A→B μA) (_⟨$⟩_ (f FE.∘ B→A)) μ-view-preserve {A}{B} A→B B→A A≈B f μA = sum-ext μA (λ x → FE.cong f (Setoid.sym A (A≈B x) )) μ-iso-preserve : ∀ {A B} (A↔B : A ↔ B) f (μA : SumProp A) → sum μA f ≡ sum (μ-iso A↔B μA) (f ∘ _⟨$⟩_ (Inverse.from A↔B)) μ-iso-preserve A↔B f μA = μ-view-preserve (Inverse.to A↔B) (Inverse.from A↔B) (Inverse.left-inverse-of A↔B) (≡.:→-to-Π f) μA open import Data.Fin using (Fin; zero; suc) open import Data.Vec.NP as Vec using (Vec; tabulate; _++_) renaming (map to vmap; sum to vsum; foldr to vfoldr; foldr₁ to vfoldr₁) vmsum : ∀ m {n} → let open Mon m in Vec C n → C vmsum m = vfoldr _ _∙_ ε where open Monoid m vsgsum : ∀ sg {n} → let open Sgrp sg in Vec C (suc n) → C vsgsum sg = vfoldr₁ _∙_ where open Sgrp sg -- let's recall that: tabulate f ≗ vmap f (allFin n) -- searchMonFin : ∀ n → SearchMon (Fin n) -- searchMonFin n m f = vmsum m (tabulate f) searchFinSuc : ∀ n → Search (Fin (suc n)) searchFinSuc n _∙_ f = vfoldr₁ _∙_ (tabulate f) μMaybe : ∀ {A} → SumProp A → SumProp (Maybe A) μMaybe μA = srch , ind where srch : Search (Maybe _) srch _∙_ f = f nothing ∙ search μA _∙_ (f ∘ just) ind : SearchInd srch ind P _P∙_ Pf = Pf nothing P∙ search-ind μA (λ s → P (λ op f → s op (f ∘ just)) ) _P∙_ (Pf ∘ just) μMaybeIso : ∀ {A} → SumProp A → SumProp (Maybe A) μMaybeIso μA = μ-iso (FI.sym Maybe↔𝟙⊎ FI.∘ lift-⊎) (μ𝟙 +μ μA) μMaybe^ : ∀ {A} n → SumProp A → SumProp (Maybe^ n A) μMaybe^ zero μA = μA μMaybe^ (suc n) μA = μMaybe (μMaybe^ n μA) μFinSuc : ∀ n → SumProp (Fin (suc n)) μFinSuc n = searchFinSuc n , ind n where ind : ∀ n → SearchInd (searchFinSuc n) ind zero P P∙ Pf = Pf zero ind (suc n) P P∙ Pf = P∙ (Pf zero) (ind n (λ s → P (λ op f → s op (f ∘ suc))) P∙ (Pf ∘ suc)) -- -} -- -} -- -} -- -} -- -} -- -}
{ "alphanum_fraction": 0.5428809326, "avg_line_length": 34.8575197889, "ext": "agda", "hexsha": "74b9379ec865d4609e9bc69ec2f0c9bb6cf29bb5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "crypto-agda/explore", "max_forks_repo_path": "lib/Explore/Old/Sum/sum-setoid.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "crypto-agda/explore", "max_issues_repo_path": "lib/Explore/Old/Sum/sum-setoid.agda", "max_line_length": 137, "max_stars_count": 2, "max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "crypto-agda/explore", "max_stars_repo_path": "lib/Explore/Old/Sum/sum-setoid.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z", "num_tokens": 5703, "size": 13211 }
open import Agda.Primitive open import Equality module Quotient where is-prop : ∀ {ℓ} (A : Set ℓ) → Set ℓ is-prop A = ∀ (x y : A) → x ≡ y record is-equivalence {ℓ k} {A : Set ℓ} (E : A → A → Set k) : Set (ℓ ⊔ k) where field equiv-prop : ∀ {x y} → is-prop (E x y) equiv-refl : ∀ {x} → E x x equiv-symm : ∀ {x y} → E x y → E y x equiv-tran : ∀ {x y z} → E x y → E y z → E x z record Equivalence {ℓ} (A : Set ℓ) : Set (lsuc ℓ) where field equiv-relation : A → A → Set ℓ equiv-is-equivalence : is-equivalence equiv-relation is-set : ∀ {ℓ} (A : Set ℓ) → Set ℓ is-set A = ∀ (x y : A) (p q : x ≡ y) → p ≡ q record HSet ℓ : Set (lsuc ℓ) where field hset-type : Set ℓ hset-is-set : is-set hset-type record Quotient {ℓ} (A : Set ℓ) (E : Equivalence A) : Set (lsuc ℓ) where open Equivalence field quot-type : Set ℓ quot-class : ∀ (x : A) → quot-type quot-≡ : ∀ {x y : A} → equiv-relation E x y → quot-class x ≡ quot-class y quot-is-set : is-set quot-type quot-elim : ∀ (B : ∀ quot-type → Set ℓ) (f : ∀ (x : A) → B (quot-class x)) → (∀ (x y : A) {ε : equiv-relation E x y} → transport B (quot-≡ ε) (f x) ≡ f y) → ∀ (ξ : quot-type) → B ξ quot-compute : ∀ (B : ∀ quot-type → Set ℓ) → (f : ∀ (x : A) → B (quot-class x)) → (η : ∀ (x y : A) {ε : equiv-relation E x y} → transport B (quot-≡ ε) (f x) ≡ f y) → (quot-elim ? quot-class η)
{ "alphanum_fraction": 0.4901574803, "avg_line_length": 31.75, "ext": "agda", "hexsha": "510462dc35b80708c339795b59c0d27dc5a25a19", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/Experimental/Quotient.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/Experimental/Quotient.agda", "max_line_length": 93, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/Experimental/Quotient.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 600, "size": 1524 }
{-# OPTIONS --without-K #-} open import HoTT open import lib.cubical.elims.CubeMove open import lib.cubical.elims.CofWedge module lib.cubical.elims.SuspSmash where module _ {i j k} {X : Ptd i} {Y : Ptd j} {C : Type k} (f : Suspension (X ∧ Y) → C) (g : Suspension (X ∧ Y) → C) (north* : f (north _) == g (north _)) (south* : f (south _) == g (south _)) (cod* : (s : fst X × fst Y) → Square north* (ap f (merid _ (cfcod _ s))) (ap g (merid _ (cfcod _ s))) south*) where private base* = transport (λ κ → Square north* (ap f (merid _ κ)) (ap g (merid _ κ)) south*) (! (cfglue _ (winl (snd X)))) (cod* (snd X , snd Y)) CubeType : (w : X ∨ Y) → Square north* (ap f (merid _ (cfcod _ (∨-in-× X Y w)))) (ap g (merid _ (cfcod _ (∨-in-× X Y w)))) south* → Type _ CubeType w sq = Cube base* sq (natural-square (λ _ → north*) (cfglue _ w)) (natural-square (ap f ∘ merid _) (cfglue _ w)) (natural-square (ap g ∘ merid _) (cfglue _ w)) (natural-square (λ _ → south*) (cfglue _ w)) fill : (w : X ∨ Y) (sq : Square north* (ap f (merid _ (cfcod _ (∨-in-× X Y w)))) (ap g (merid _ (cfcod _ (∨-in-× X Y w)))) south*) → Σ (Square north* idp idp north*) (λ p → CubeType w (p ⊡h sq)) fill w sq = (fst fill' , cube-right-from-front (fst fill') sq (snd fill')) where fill' = fill-cube-right _ _ _ _ _ fill0 = fill (winl (snd X)) (cod* (snd X , snd Y)) fillX = λ x → fill (winl x) (fst fill0 ⊡h cod* (x , snd Y)) fillY = λ y → fill (winr y) (fst fill0 ⊡h cod* (snd X , y)) fillX0 : fst (fillX (snd X)) == hid-square fillX0 = ⊡h-unit-l-unique _ (fst fill0 ⊡h cod* (snd X , snd Y)) (fill-cube-right-unique (snd (fillX (snd X))) ∙ ! (fill-cube-right-unique (snd fill0))) fillY0 : fst (fillY (snd Y)) == hid-square fillY0 = ⊡h-unit-l-unique _ (fst fill0 ⊡h cod* (snd X , snd Y)) (fill-cube-right-unique (snd (fillY (snd Y))) ∙ ! (fill-cube-right-unique (snd (fill (winr (snd Y)) (cod* (snd X , snd Y))))) ∙ ! (ap (λ w → fst (fill w (cod* (∨-in-× X Y w))) ⊡h cod* (snd X , snd Y)) wglue)) where fill-square : (w : X ∨ Y) → Square north* (ap f (merid _ (cfcod _ (∨-in-× X Y w)))) (ap g (merid _ (cfcod _ (∨-in-× X Y w)))) south* fill-square w = fst (fill-cube-right base* (natural-square (λ _ → north*) (cfglue _ w)) (natural-square (ap f ∘ merid _) (cfglue _ w)) (natural-square (ap g ∘ merid _) (cfglue _ w)) (natural-square (λ _ → south*) (cfglue _ w))) abstract coh : (s : X ∧ Y) → north* == south* [ (λ z → f z == g z) ↓ merid _ s ] coh = ↓-='-from-square ∘ cof-wedge-square-elim _ _ _ _ base* (λ {(x , y) → fst (fillX x) ⊡h fst (fillY y) ⊡h fst fill0 ⊡h cod* (x , y)}) (λ x → transport (λ sq → CubeType (winl x) (fst (fillX x) ⊡h sq)) (! (ap (λ sq' → sq' ⊡h fst fill0 ⊡h cod* (x , snd Y)) fillY0 ∙ ⊡h-unit-l (fst fill0 ⊡h cod* (x , snd Y)))) (snd (fillX x))) (λ y → transport (CubeType (winr y)) (! (ap (λ sq' → sq' ⊡h fst (fillY y) ⊡h fst fill0 ⊡h cod* (snd X , y)) fillX0 ∙ ⊡h-unit-l (fst (fillY y) ⊡h fst fill0 ⊡h cod* (snd X , y)))) (snd (fillY y))) susp-smash-path-elim : ((σ : Suspension (X ∧ Y)) → f σ == g σ) susp-smash-path-elim = Suspension-elim _ north* south* coh
{ "alphanum_fraction": 0.4793633666, "avg_line_length": 40.7362637363, "ext": "agda", "hexsha": "d38668c86f31aadffd61bada92ffc430ebd25507", "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": "lib/cubical/elims/SuspSmash.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": "lib/cubical/elims/SuspSmash.agda", "max_line_length": 80, "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": "lib/cubical/elims/SuspSmash.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1315, "size": 3707 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Vectors where at least one element satisfies a given property ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.Relation.Unary.Any {a} {A : Set a} where open import Data.Empty open import Data.Fin open import Data.Nat using (zero; suc) open import Data.Sum using (_⊎_; inj₁; inj₂; [_,_]′) open import Data.Vec as Vec using (Vec; []; [_]; _∷_) open import Data.Product as Prod using (∃; _,_) open import Level using (_⊔_) open import Relation.Nullary using (¬_; yes; no) open import Relation.Nullary.Negation using (contradiction) import Relation.Nullary.Decidable as Dec open import Relation.Unary ------------------------------------------------------------------------ -- Any P xs means that at least one element in xs satisfies P. data Any {p} (P : A → Set p) : ∀ {n} → Vec A n → Set (a ⊔ p) where here : ∀ {n x} {xs : Vec A n} (px : P x) → Any P (x ∷ xs) there : ∀ {n x} {xs : Vec A n} (pxs : Any P xs) → Any P (x ∷ xs) ------------------------------------------------------------------------ -- Operations on Any module _ {p} {P : A → Set p} {n x} {xs : Vec A n} where -- If the tail does not satisfy the predicate, then the head will. head : ¬ Any P xs → Any P (x ∷ xs) → P x head ¬pxs (here px) = px head ¬pxs (there pxs) = contradiction pxs ¬pxs -- If the head does not satisfy the predicate, then the tail will. tail : ¬ P x → Any P (x ∷ xs) → Any P xs tail ¬px (here px) = ⊥-elim (¬px px) tail ¬px (there pxs) = pxs -- Convert back and forth with sum toSum : Any P (x ∷ xs) → P x ⊎ Any P xs toSum (here px) = inj₁ px toSum (there pxs) = inj₂ pxs fromSum : P x ⊎ Any P xs → Any P (x ∷ xs) fromSum = [ here , there ]′ map : ∀ {p q} {P : A → Set p} {Q : A → Set q} → P ⊆ Q → ∀ {n} → Any P {n} ⊆ Any Q {n} map g (here px) = here (g px) map g (there pxs) = there (map g pxs) index : ∀ {p} {P : A → Set p} {n} {xs : Vec A n} → Any P xs → Fin n index (here px) = zero index (there pxs) = suc (index pxs) -- If any element satisfies P, then P is satisfied. satisfied : ∀ {p} {P : A → Set p} {n} {xs : Vec A n} → Any P xs → ∃ P satisfied (here px) = _ , px satisfied (there pxs) = satisfied pxs ------------------------------------------------------------------------ -- Properties of predicates preserved by Any module _ {p} {P : A → Set p} where any : Decidable P → ∀ {n} → Decidable (Any P {n}) any P? [] = no λ() any P? (x ∷ xs) with P? x ... | yes px = yes (here px) ... | no ¬px = Dec.map′ there (tail ¬px) (any P? xs) satisfiable : Satisfiable P → ∀ {n} → Satisfiable (Any P {suc n}) satisfiable (x , p) {zero} = x ∷ [] , here p satisfiable (x , p) {suc n} = Prod.map (x ∷_) there (satisfiable (x , p))
{ "alphanum_fraction": 0.5176715177, "avg_line_length": 35.1951219512, "ext": "agda", "hexsha": "1842f4d7047a05afc31e0a68ece5d47bc38653db", "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/Relation/Unary/Any.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/Relation/Unary/Any.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/Relation/Unary/Any.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 926, "size": 2886 }
{-# OPTIONS --sized-types #-} module BBHeap.Height {A : Set}(_≤_ : A → A → Set) where open import BBHeap _≤_ hiding (#) open import Bound.Lower A open import Bound.Lower.Order _≤_ open import SNat # : {b : Bound} → BBHeap b → SNat # leaf = zero # (left {l = l} {r = r} _ _) = succ (# l + # r) # (right {l = l} {r = r} _ _) = succ (# l + # r) height : {b : Bound} → BBHeap b → SNat height leaf = zero height (left {l = l} _ _) = succ (height l) height (right {l = l} _ _) = succ (height l) #' : {b : Bound} → BBHeap b → SNat #' leaf = zero #' (left {r = r} _ _) = succ (#' r + #' r) #' (right {r = r} _ _) = succ (#' r + #' r) height' : {b : Bound} → BBHeap b → SNat height' leaf = zero height' (left {r = r} _ _) = succ (height' r) height' (right {r = r} _ _) = succ (height' r)
{ "alphanum_fraction": 0.5393401015, "avg_line_length": 26.2666666667, "ext": "agda", "hexsha": "8b43eba04cbad30261357ffd41b04d83bf5cf7cc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/BBHeap/Height.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/BBHeap/Height.agda", "max_line_length": 55, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/BBHeap/Height.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": 297, "size": 788 }
{-# OPTIONS --cubical --safe #-} module Cubical.Relation.Binary.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.HITs.SetQuotients.Base module BinaryRelation {ℓ ℓ' : Level} {A : Type ℓ} (R : A → A → Type ℓ') where isRefl : Type (ℓ-max ℓ ℓ') isRefl = (a : A) → R a a isSym : Type (ℓ-max ℓ ℓ') isSym = (a b : A) → R a b → R b a isTrans : Type (ℓ-max ℓ ℓ') isTrans = (a b c : A) → R a b → R b c → R a c record isEquivRel : Type (ℓ-max ℓ ℓ') where constructor EquivRel field reflexive : isRefl symmetric : isSym transitive : isTrans isPropValued : Type (ℓ-max ℓ ℓ') isPropValued = (a b : A) → isProp (R a b) isEffective : Type (ℓ-max ℓ ℓ') isEffective = (a b : A) → let x : A / R x = [ a ] y : A / R y = [ b ] in (x ≡ y) ≃ R a b
{ "alphanum_fraction": 0.5837897043, "avg_line_length": 24.0263157895, "ext": "agda", "hexsha": "9aaa364f784d33abfae3f2fd8fc3eeede3ddc349", "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": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Relation/Binary/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "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": "limemloh/cubical", "max_issues_repo_path": "Cubical/Relation/Binary/Base.agda", "max_line_length": 77, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Relation/Binary/Base.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": 346, "size": 913 }
{-# OPTIONS --rewriting #-} module Properties where import Properties.Contradiction import Properties.Dec import Properties.DecSubtyping import Properties.Equality import Properties.Functions import Properties.Remember import Properties.Step import Properties.StrictMode import Properties.Subtyping import Properties.TypeCheck import Properties.TypeNormalization
{ "alphanum_fraction": 0.8630136986, "avg_line_length": 22.8125, "ext": "agda", "hexsha": "f883a3ea6dc2b6f033bfeba16dd9fb58cc0ba81f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "39fbd2146a379fb0878369b48764cd7e8772c0fb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "sthagen/Roblox-luau", "max_forks_repo_path": "prototyping/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "39fbd2146a379fb0878369b48764cd7e8772c0fb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "sthagen/Roblox-luau", "max_issues_repo_path": "prototyping/Properties.agda", "max_line_length": 35, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f1b46f4b967f11fabe666da1de0e71b225368260", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Libertus-Lab/luau", "max_stars_repo_path": "prototyping/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-06T08:03:00.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-06T08:03:00.000Z", "num_tokens": 65, "size": 365 }
{-# OPTIONS --rewriting #-} {-# OPTIONS --confluence-check #-} open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite module _ (A : Set) where postulate D : Set f : D → D → D r : (x y z : D) → f x (f y z) ≡ f x z {-# REWRITE r #-} -- WAS: -- Confluence check failed: f x (f y (f y₁ z)) reduces to both -- f x (f y₁ z) and f x (f y z) which are not equal because -- y != y₁ of type D -- when checking confluence of the rewrite rule r with itself module _ (x y y₁ z : D) where -- SUCCEEDS: _ : f x (f y₁ z) ≡ f x (f y z) _ = refl
{ "alphanum_fraction": 0.5683333333, "avg_line_length": 25, "ext": "agda", "hexsha": "676cc247515daa5a0a9c72577323cf3e3d9d68e3", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_head_hexsha": "d6a705ba40d8ba2a5bb550bc40eddc280aedbf2b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Soares/agda", "max_forks_repo_path": "test/Succeed/Issue4383.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "d6a705ba40d8ba2a5bb550bc40eddc280aedbf2b", "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": "Soares/agda", "max_issues_repo_path": "test/Succeed/Issue4383.agda", "max_line_length": 64, "max_stars_count": 1, "max_stars_repo_head_hexsha": "d6a705ba40d8ba2a5bb550bc40eddc280aedbf2b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "Soares/agda", "max_stars_repo_path": "test/Succeed/Issue4383.agda", "max_stars_repo_stars_event_max_datetime": "2016-05-20T13:58:52.000Z", "max_stars_repo_stars_event_min_datetime": "2016-05-20T13:58:52.000Z", "num_tokens": 213, "size": 600 }
{- 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 Util.PKCS open import Util.Prelude open import Yasm.Types -- This module defines the types used to define a SystemModel. module Yasm.Base (ℓ-PeerState : Level) where -- Our system is configured through a value of type -- SystemParameters where we specify: record SystemTypeParameters : Set (ℓ+1 ℓ-PeerState) where constructor mkSysTypeParms field PeerId : Set _≟PeerId_ : ∀ (p₁ p₂ : PeerId) → Dec (p₁ ≡ p₂) Bootstrap : Set -- A relation specifying what Signatures are included in bootstrapInfo ∈BootstrapInfo : Bootstrap → Signature → Set PeerState : Set ℓ-PeerState Msg : Set Part : Set -- Types of interest that can be represented in Msgs -- The messages must be able to carry signatures instance Part-sig : WithSig Part -- A relation specifying what Parts are included in a Msg. -- TODO-2: I changed the name of this to append the G because of the pain disambiguating it from -- NetworkMsg.⊂Msg. This issue https://github.com/agda/agda/issues/2175 suggests I should have -- been able to get this right without renaming, but... I'd like to underastand how to do this -- right, but for expedience, not now. _⊂MsgG_ : Part → Msg → Set module _ (systypes : SystemTypeParameters) where open SystemTypeParameters systypes record SystemInitAndHandlers : Set (ℓ+1 ℓ-PeerState) where constructor mkSysInitAndHandlers field -- The same bootstrap information is given to any uninitialised peer before -- it can handle any messages. bootstrapInfo : Bootstrap -- Represents an uninitialised PeerState, about which we know nothing whatsoever initPS : PeerState -- Bootstraps a peer. Our current system model is simplistic in that unsuccessful -- initialisation of a peer has no side effects. In future, we could change the return type -- of bootstrap to Maybe PeerState × List (Action Msg), allowing for it to return nothing, but -- to include actions such as sending messages, logging, etc. We are not doing so now as it -- is disruptive to existing proofs and modeling and verifying properties about unsuccessful -- initialisation is not a priority. bootstrap : PeerId → Bootstrap → Maybe (PeerState × List (Action Msg)) -- Handles a message on a previously initialized peer. handle : PeerId → Msg → PeerState → PeerState × List (Action Msg)
{ "alphanum_fraction": 0.7125416204, "avg_line_length": 43.5967741935, "ext": "agda", "hexsha": "e36d73fcc1af73a0f37358b20700abea894e3766", "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/Yasm/Base.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/Yasm/Base.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/Yasm/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 674, "size": 2703 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Relation.Nullary.HLevels where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Functions.Fixpoint open import Cubical.Relation.Nullary private variable ℓ : Level A : Type ℓ isPropPopulated : isProp (Populated A) isPropPopulated = isPropΠ λ x → 2-Constant→isPropFixpoint (x .fst) (x .snd) isPropHSeparated : isProp (HSeparated A) isPropHSeparated f g i x y a = HSeparated→isSet f x y (f x y a) (g x y a) i isPropCollapsible≡ : isProp (Collapsible≡ A) isPropCollapsible≡ {A = A} f = (isPropΠ2 λ x y → isPropCollapsiblePointwise) f where sA : isSet A sA = Collapsible≡→isSet f gA : isGroupoid A gA = isSet→isGroupoid sA isPropCollapsiblePointwise : ∀ {x y} → isProp (Collapsible (x ≡ y)) isPropCollapsiblePointwise {x} {y} (a , ca) (b , cb) = λ i → endoFunction i , endoFunctionIsConstant i where endoFunction : a ≡ b endoFunction = funExt λ p → sA _ _ (a p) (b p) isProp2-Constant : (k : I) → isProp (2-Constant (endoFunction k)) isProp2-Constant k = isPropΠ2 λ r s → gA x y (endoFunction k r) (endoFunction k s) endoFunctionIsConstant : PathP (λ i → 2-Constant (endoFunction i)) ca cb endoFunctionIsConstant = isProp→PathP isProp2-Constant ca cb
{ "alphanum_fraction": 0.7168141593, "avg_line_length": 37.6666666667, "ext": "agda", "hexsha": "37ee4f8bb3b99af8b9ab22b6065cf1350ca3d457", "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/Relation/Nullary/HLevels.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/Relation/Nullary/HLevels.agda", "max_line_length": 110, "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/Relation/Nullary/HLevels.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 473, "size": 1356 }
module _ where open import Agda.Builtin.Bool open import Agda.Builtin.List open import Agda.Builtin.Reflection open import Agda.Builtin.Unit module Test₁ where macro Unify-with-⊤ : Term → TC ⊤ Unify-with-⊤ goal = unify goal (quoteTerm ⊤) ⊤′ : Set ⊤′ = Unify-with-⊤ unit-test : ⊤′ unit-test = tt module Test₂ where macro Unify-with-⊤ : Term → TC ⊤ Unify-with-⊤ goal = noConstraints (unify goal (quoteTerm ⊤)) ⊤′ : Set ⊤′ = Unify-with-⊤ unit-test : ⊤′ unit-test = tt module Test₃ where P : Bool → Set P true = Bool P false = Bool f : (b : Bool) → P b f true = true f false = false pattern varg x = arg (arg-info visible relevant) x create-constraint : TC Set create-constraint = unquoteTC (def (quote P) (varg (def (quote f) (varg unknown ∷ [])) ∷ [])) macro Unify-with-⊤ : Term → TC ⊤ Unify-with-⊤ goal = catchTC (noConstraints (bindTC create-constraint λ _ → returnTC tt)) (unify goal (quoteTerm ⊤)) ⊤′ : Set ⊤′ = Unify-with-⊤ unit-test : ⊤′ unit-test = tt
{ "alphanum_fraction": 0.577540107, "avg_line_length": 17.53125, "ext": "agda", "hexsha": "a5c7af64b9643b80f1f1c697316664b792db5a17", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.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/NoConstraints.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/NoConstraints.agda", "max_line_length": 65, "max_stars_count": 2, "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/NoConstraints.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 395, "size": 1122 }