Search is not available for this dataset
text
string
meta
dict
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types open import LibraBFT.Impl.OBM.Logging.Logging open import LibraBFT.ImplShared.Consensus.Types hiding (getEpoch) open import Optics.All import Util.KVMap as Map open import Util.Prelude ------------------------------------------------------------------------------ open import Data.String using (String) module LibraBFT.Impl.Storage.DiemDB.LedgerStore.LedgerStore where record EpochEndingLedgerInfoIter : Set where constructor EpochEndingLedgerInfoIter∙new field _eeliiObmLIWS : List LedgerInfoWithSignatures open EpochEndingLedgerInfoIter public new : LedgerStore new = mkLedgerStore Map.empty Map.empty nothing -- OBM-LBFT-DIFF : the entire Haskell impl file is VERY different from the Rust code. -- The Agda below mirrors Haskell. getEpoch : LedgerStore → Version → Either ErrLog Epoch getEpoch self version = maybeS (Map.lookup version (self ^∙ lsObmVersionToEpoch)) -- COMMENT FROM RUST CODE: -- There should be a genesis LedgerInfo at version 0. -- This normally doesn't happen. -- This part of impl does not need to rely on this assumption. (pure 0) pure getEpochEndingLedgerInfo : LedgerStore → Version → Either ErrLog LedgerInfoWithSignatures getEpochEndingLedgerInfo self version = do epoch ← getEpoch self version case Map.lookup epoch (self ^∙ lsObmEpochToLIWS) of λ where nothing → Left fakeErr -- ["DiemDbError::NotFound", "LedgerInfo for epoch", lsE epoch] (just li) → grd‖ li ^∙ liwsLedgerInfo ∙ liVersion /= version ≔ Left fakeErr --["epoch did not end at version", lsE epoch, lsVersion version] ‖ is-nothing (li ^∙ liwsLedgerInfo ∙ liNextEpochState) ≔ Left fakeErr -- ["not an epoch change at version", lsVersion version] ‖ otherwise≔ pure li --where -- here t = "LedgerStore":"getEpochEndingLedgerInfo":t getEpochState : LedgerStore → Epoch → Either ErrLog EpochState getEpochState self epoch = do lcheck (epoch >? 0) (here' ("EpochState only queryable for epoch >= 1" {-∷ lsE epoch-} ∷ [])) case Map.lookup (epoch ∸ 1) (self ^∙ lsObmEpochToLIWS) of λ where nothing → Left fakeErr --[ "DiemDbError::NotFound" --, "last LedgerInfo of epoch", lsE (epoch - 1) ])) (just ledgerInfoWithSigs) → maybeS (ledgerInfoWithSigs ^∙ liwsNextEpochState) (Left fakeErr) --[ "last LedgerInfo in epoch must carry nextEpochState" --, lsE epoch, lsLI (ledgerInfoWithSigs^.liwsLedgerInfo) ] pure where here' : List String → List String here' t = "LedgerStore" ∷ "getEPochState" ∷ t -- iterator that yields epoch ending ledger infos -- starting from `start_epoch` -- ends at the one before `end_epoch` getEpochEndingLedgerInfoIter : LedgerStore → Epoch → Epoch → Either ErrLog EpochEndingLedgerInfoIter getEpochEndingLedgerInfoIter self startEpoch endEpoch = -- TODO-2: prove endEpoch > 0 -- Use of monus in context where it is not clear that endEpoch > 0. -- If not, Agda and Haskell code would behave differently. -- TODO-2: IMPL-DIFF: Haskell uses a list comprehension; Agda uses homegrown 'fromToList' -- The combination of monus and fromToList risks misunderstanding/misuse of fromToList later. -- Ranges would differ in Haskell and Agda if, say, startEpoch were negative and endEpoch was 0. -- It could be correct and verified in Agda, but wrong in Haskell -- (e.g., if the Haskell code accidentally calculates a negative epoch). EpochEndingLedgerInfoIter∙new <$> (foldM) go [] (fromToList startEpoch (endEpoch ∸ 1)) where go : List LedgerInfoWithSignatures → Epoch → Either ErrLog (List LedgerInfoWithSignatures) go acc e = maybeS (Map.lookup e (self ^∙ lsObmEpochToLIWS)) (Left fakeErr) --[ "LedgerStore", "getEpochEndingLedgerInfoIter" --, "no LIWS for epoch", lsE e ] (λ x → Right (acc ++ (x ∷ []))) -- TODO putLedgerInfo : LedgerStore → LedgerInfoWithSignatures → Either ErrLog LedgerStore putLedgerInfo self ledgerInfoWithSigs = let ledgerInfo = ledgerInfoWithSigs ^∙ liwsLedgerInfo in pure $ mkLedgerStore ((if ledgerInfo ^∙ liEndsEpoch then Map.insert (ledgerInfo ^∙ liVersion) (ledgerInfo ^∙ liEpoch) else identity) (self ^∙ lsObmVersionToEpoch)) (Map.insert (ledgerInfo ^∙ liEpoch) ledgerInfoWithSigs (self ^∙ lsObmEpochToLIWS)) (self ^∙ lsLatestLedgerInfo) obmEELIICollect : EpochEndingLedgerInfoIter → List LedgerInfoWithSignatures obmEELIICollect = _eeliiObmLIWS
{ "alphanum_fraction": 0.6857200976, "avg_line_length": 45.9439252336, "ext": "agda", "hexsha": "1e7a6ee7e0e427ccb1c197b3f761f3e1912f2eac", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/Storage/DiemDB/LedgerStore/LedgerStore.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/Storage/DiemDB/LedgerStore/LedgerStore.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/Storage/DiemDB/LedgerStore/LedgerStore.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1340, "size": 4916 }
{-# OPTIONS --cubical --no-import-sorts --allow-unsolved-metas #-} module SyntheticReals where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) private variable ℓ ℓ' ℓ'' : Level open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Structures.CommRing open import Cubical.Relation.Nullary.Base -- ¬_ open import Cubical.Relation.Binary.Base -- Rel open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim` -- open import Cubical.Structures.Poset open import Cubical.Foundations.Function open import Function.Base using (_∋_) -- open import Function.Reasoning using (∋-syntax) open import Function.Base using (it) -- instance search open import Utils open import MoreLogic open MoreLogic.Reasoning open MoreLogic.Properties open import MoreAlgebra open MoreAlgebra.Definitions open MoreAlgebra.Consequences open import Bundles -- open MoreAlgebra.Properties.Group -- https://www.cs.bham.ac.uk/~abb538/thesis.pdf -- Booij 2020 - Analysis in Univalent Type Theory -- Lemma 4.1.6. import Properties.ConstructiveField -- Lemma 4.1.11. import Properties.AlmostOrderedField -- Lemma 4.1.12. An ordered field (F, 0, 1, +, · , min, max, <) is a constructive field (F, 0, 1, +, · , #). lemma-4-1-12 : -- NOTE: we do a slightly different thing here ∀{ℓ ℓ'} (OF : OrderedField {ℓ} {ℓ'}) → let open OrderedField OF ---------------------------------------------------- in (IsConstructiveField 0f 1f _+_ _·_ -_ _#_ _⁻¹ᶠ) lemma-4-1-12 {ℓ} {ℓ'} OF = let -- NOTE: for mentioning the ℓ and ℓ' and not taking them as new "variables" we bring them into scope open OrderedField OF in record -- We need to show that + is #-extensional, and that # is tight. { OrderedField OF ; isApartnessRel = #'-isApartnessRel <-isStrictPartialOrder -- NOTE: We've proved this before -- First, assume w + x # y + z. We need to show w # y ∨ x # z. ; +-#-extensional = λ where -- Consider the case w + x < y + z, so that we can use (†) to obtain w < y ∨ x < z, -- which gives w # y ∨ x # z in either case. w x y z (inl w+x<y+z) → case +-<-extensional _ _ _ _ w+x<y+z of ( (_ → (w # y) ⊎ (x # z)) ∋ λ -- NOTE: here we had to add a (return-)type annotation to the λ { (inl w<y) → inl (inl w<y) ; (inr x<z) → inr (inl x<z) }) -- The case w + x > y + z is similar. w x y z (inr y+z<w+x) → case +-<-extensional _ _ _ _ y+z<w+x of ( (_ → (w # y) ⊎ (x # z)) ∋ λ { (inl y<w) → inl (inr y<w) ; (inr z<x) → inr (inr z<x) }) -- Tightness follows from the fact that ≤ is antisymmetric, combined with the fact -- that ¬(P ∨ Q) is equivalent to ¬P ∧ ¬Q. ; #-tight = λ x y ¬[x<y]⊎¬[y<x] → let (¬[x<y] , ¬[y<x]) = deMorgan₂' ¬[x<y]⊎¬[y<x] in ≤-antisym _ _ ¬[y<x] ¬[x<y] } -- We will mainly be concerned with ordered fields, as opposed to the more general con- -- structive fields. This is because the Archimedean property can be phrased straightforwardly -- for ordered fields, as in Section 4.3, and because the ordering relation allows us to define loca- -- tors, as in Chapter 6. -- -- We have defined ordered fields, which capture the algebraic structure of the real numbers. -- 4.2 Rationals -- ... -- NOTE: we have in cubical -- import Cubical.HITs.Rationals.HITQ -- ℚ as a higher inductive type -- import Cubical.HITs.Rationals.QuoQ -- ℚ as a set quotient of ℤ × ℕ₊₁ (as in the HoTT book) -- import Cubical.HITs.Rationals.SigmaQ -- ℚ as the set of coprime pairs in ℤ × ℕ₊₁ import Cubical.HITs.Rationals.QuoQ renaming (ℚ to ℚ-Carrier) postulate ℚℓ : Level ℚOF : OrderedField {ℓ-zero} {ℚℓ} {- ℚ = λ where .OrderedField.Carrier → ℚ-Carrier .OrderedField.0f → 0 .OrderedField.1f → 1 .OrderedField._+_ → _+_ .OrderedField.-_ → -_ .OrderedField._·_ → _*_ .OrderedField.min → {!!} .OrderedField.max → {!!} .OrderedField._<_ → {!!} .OrderedField.<-isProp → {!!} .OrderedField._⁻¹ᶠ → {!!} .OrderedField.isOrderedField → {!!} -} -- 4.3 Archimedean property -- -- We now define the notion of Archimedean ordered fields. We phrase this in terms of a certain -- interpolation property, that can be defined from the fact that there is a unique morphism of -- ordered fields from the rationals to every ordered field. -- Lemma 4.3.3. For every ordered field (F, 0 F , 1 F , + F , · F , min F , max F , < F ), there is a unique morphism -- i of ordered fields from the rationals to F . Additionally, i preserves < in the sense that for every q, r : Q -- q < r ⇒ i (q) < F i (r ). -- ∃! : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ') -- ∃! A B = isContr (Σ A B) -- isContr' A = Σ[ x ∈ A ] (∀ y → x ≡ y) ℚ-IsInitialObject : ∀(OF : OrderedField {ℓ} {ℓ'}) → isContr (OrderedFieldMor ℚOF OF) ℚ-IsInitialObject OF = {!!} , {!!} -- Definition 4.3.5. Let (F, 0 F , 1 F , + F , · F , min F , max F , < F ) be an ordered field, so that we get a -- canonical morphism i : Q → F of ordered fields, as in Lemma 4.3.3. We say the ordered field -- (F, 0 F , 1 F , + F , · F , min F , max F , < F ) is Archimedean if -- (∀x, y : F )(∃q : Q)x < i (q) < y. IsArchimedian : OrderedField {ℓ} {ℓ'} → Type (ℓ-max ℓ ℓ') IsArchimedian OF = let (orderedfieldmor i _) = fst (ℚ-IsInitialObject OF) open OrderedField OF ℚ = OrderedField.Carrier ℚOF in ∀ x y → ∃[ q ∈ ℚ ] (x < i q) × (i q < y) -- If the ordered field is clear from the context, we will identify rationals q : Q with their in- -- clusion i (q) in the ordered field, so that we may also say that (F, 0 F , 1 F , + F , · F , min F , max F , < F ) -- is Archimedean if -- (∀x, y : F )(∃q : Q)x < q < y. -- Example 4.3.6. In an Archimedean ordered field, all numbers are bounded by rationals. That -- is, for a given x : F , there exist q, r : Q with q < x < r . Example-4-3-6 : (OF : OrderedField {ℓ} {ℓ'}) → IsArchimedian OF → let open OrderedField OF renaming (Carrier to F) (orderedfieldmor i _) = fst (ℚ-IsInitialObject OF) ℚ = OrderedField.Carrier ℚOF in ∀(x : F) → (∃[ q ∈ ℚ ] i q < x) × (∃[ r ∈ ℚ ] x < i r) -- This follows from applying the Archimedean property to x − 1 < x and x < x + 1. Example-4-3-6 OF isArchimedian = {!!} -- 4.4 Cauchy completeness of real numbers -- -- We focus on Cauchy completeness, rather than Dedekind or Dedekind-MacNeille completeness, -- as we will focus on the computation of digit expansions, for which Cauchy completeness suffices. -- In order to state that an ordered field is Cauchy complete, we need to define when sequences -- are Cauchy, and when a sequence has a limit. We also take the opportunity to define -- the set of Cauchy reals in Definition 4.4.9. Surprisingly, this ordered field cannot be shown to -- be Cauchy complete. -- NOTE: in the following we make use of ℚ⁺ a few times. Maybe this should be a primitive? -- Fix an ordered field (F, 0 F , 1 F , + F , · F , min F , max F , < F ). module _ (OF : OrderedField {ℓ} {ℓ'}) where open OrderedField OF renaming (Carrier to F) -- module ℚ = OrderedField ℚ open OrderedField ℚOF using () renaming (_<_ to _<ᵣ_; 0f to 0ᵣ) ℚ = OrderedField.Carrier ℚOF iᵣ = OrderedFieldMor.fun (fst (ℚ-IsInitialObject OF)) open import Data.Nat.Base using (ℕ) renaming (_≤_ to _≤ₙ_) -- We get a notion of distance, given by the absolute value as -- |x − y| := max F (x − y, −(x − y)). distance : ∀(x y : F) → F distance x y = max (x - y) (- (x - y)) -- Consider a sequence x : N → F of elements of F . Classically, we may state that x is Cauchy as -- (∀ε : Q + )(∃N : N)(∀m, n : N)m, n ≥ N ⇒ |x m − x n | < ε, IsCauchy : (x : ℕ → F) → Type (ℓ-max ℓ' ℚℓ) IsCauchy x = ∀(ε : ℚ) → 0ᵣ <ᵣ ε → ∃[ N ∈ ℕ ] ∀(m n : ℕ) → N ≤ₙ m → N ≤ₙ n → distance (x m) (x n) < iᵣ ε -- We can interpret the quantifiers as in Definition 2.4.5. -- NOTE: this is the case, since `∃ A B = ∥ Σ A B ∥` -- Following a propositions-as-types interpretation, we may also state that x is Cauchy as the -- structure -- (Πε : Q + )(ΣN : N)(Πm, n : N)m, n ≥ N → |x m − x n | < ε. -- The dependent sum represents a choice of index N for every error ε, and so we have arrived at the following definition. -- Definition 4.4.1. -- For a sequence of reals x : N → F , a a modulus of Cauchy convergence is a map M : Q + → N such that -- (∀ε : Q + )(∀m, n : N)m, n ≥ M (ε) ⇒ |x m − x n | < ε. -- NOTE: do we already call these x "reals" ? -- NOTE: we are using the Modulus-type `((y : ℚ) → {{0ᵣ <ᵣ y}} → ℕ)` a few times and might abbreviate it IsModulusOfCauchyConvergence : (x : ℕ → F) → (M : ((y : ℚ) → {{0ᵣ <ᵣ y}} → ℕ)) → Type (ℓ-max ℓ' ℚℓ) IsModulusOfCauchyConvergence x M = ∀(ε : ℚ) → (p : 0ᵣ <ᵣ ε) → ∀(m n : ℕ) → let instance _ = p in M ε ≤ₙ m → M ε ≤ₙ n → distance (x m) (x n) < iᵣ ε -- In constructive mathematics, we typically use such sequences with modulus, for example, -- because they can sometimes be used to compute limits of Cauchy sequences, avoiding choice axioms. -- Definition 4.4.2. -- A number l : F is the limit of a sequence x : N → F if the sequence -- converges to l in the usual sense: -- (∀ε : Q + )(∃N : N)(∀n : N)n ≥ N ⇒ |x n − l | < ε. IsLimit : (x : ℕ → F) → (l : F) → Type (ℓ-max ℓ' ℚℓ) IsLimit x l = ∀(ε : ℚ) → (0ᵣ <ᵣ ε) → ∃[ N ∈ ℕ ] ∀(n : ℕ) → N ≤ₙ n → distance (x n) l < iᵣ ε -- Remark 4.4.3. We do not consider the statement of convergence in propositions-as-types -- -- (Πε : Q + )(ΣN : N)(Πn : N)n ≥ N → |x n − l | < ε, -- -- because if the sequence has a modulus of Cauchy convergence M, then λε.M (ε/2) is a -- modulus of convergence to the limit l, so that we get an element of the above type. -- Definition 4.4.4. -- The ordered field (F, 0 F , 1 F , + F , · F , min F , max F , < F ) is said to be Cauchy complete -- if for every sequence x with modulus of Cauchy convergence M, we have a limit of x. -- In other words, an ordered field is Cauchy complete iff from a sequence–modulus pair (x, M), we can compute a limit of x. IsCauchyComplete : Type (ℓ-max (ℓ-max ℓ ℓ') ℚℓ) IsCauchyComplete = (x : ℕ → F) → (M : ((y : ℚ) → {{0ᵣ <ᵣ y}} → ℕ)) → IsModulusOfCauchyConvergence x M → Σ[ l ∈ F ] IsLimit x l -- For the remainder of this section, additionally assume that F is Archimedean. module _ (isArchimedian : IsArchimedian OF) where -- Lemma 4.4.5. -- The type of limits of a fixed sequence x : N → F is a proposition. Lemma-4-4-5 : ∀(x : ℕ → F) → isProp (Σ[ l ∈ F ] IsLimit x l) -- Proof. This can be shown using the usual proof that limits are unique in Archimedean ordered fields, followed by an application of Lemma 2.6.20. Lemma-4-4-5 x = {!!} -- Corollary 4.4.6. -- Fix a given sequence x : N → F . Suppose that we know that there exists a -- limit of the sequence. Then we can compute a limit of the sequence. Corollary-4-4-6 : ∀(x : ℕ → F) → (∃[ l ∈ F ] IsLimit x l) → Σ[ l ∈ F ] IsLimit x l -- Proof. By applying the induction principle of propositional truncations of Definition 2.4.3. Corollary-4-4-6 x p = {!!} , {!!} -- Corollary 4.4.7. -- Fix a given sequence x : N → F . Suppose that, from a modulus of Cauchy -- convergence, we can compute a limit of the sequence. Then from the existence of the modulus of -- Cauchy convergence we can compute a limit of the sequence. Corollary-4-4-7 : (x : ℕ → F) → ( (M : ((y : ℚ) → {{0ᵣ <ᵣ y}} → ℕ)) → (isMCC : IsModulusOfCauchyConvergence x M) → Σ[ l ∈ F ] IsLimit x l ) ----------------------------------------------------------------------- → ∃[ M ∈ ((y : ℚ) → {{0ᵣ <ᵣ y}} → ℕ) ] IsModulusOfCauchyConvergence x M → Σ[ l ∈ F ] IsLimit x l -- Proof. By applying the induction principle of propositional truncations of Definition 2.4.3. Corollary-4-4-7 x f p = {!!} -- We can thus compute the limit of x : N → F as the number lim(x, p), where p is a proof -- that the limit of x exists. We will rather use the more traditional notation lim n→∞ x n for this -- number. -- Example 4.4.8 (Exponential function). -- In a Cauchy complete Archimedean ordered field, we can define an exponential function exp : F → F by -- -- exp(x) = Σ_{k=0}^{∞} (xᵏ) / (k!) -- -- For a given input x, we obtain the existence of a modulus of Cauchy convergence for the output from boundedness of -- x, that is, from the fact that (∃q, r : Q) q < x < r . exp : F → F exp x = {!!} Example-4-4-8 : ∀(x : F) → ∃[ M ∈ ((y : ℚ) → {{0ᵣ <ᵣ y}} → ℕ) ] IsModulusOfCauchyConvergence {!!} M Example-4-4-8 x with Example-4-3-6 OF isArchimedian x ... | q' , r' = let q : ∃[ q ∈ ℚ ] iᵣ q < x q = q' r : ∃[ r ∈ ℚ ] x < iᵣ r r = r' in {!!} -- The point of this work is that, because we have a single language for properties and struc- -- ture, we can see more precisely what is needed for certain computations. In the above example, -- we explicitly do not require that inputs come equipped with a modulus of Cauchy convergence, -- but rather that there exists such a modulus. On the one hand, we do need a modulus to obtain -- the limit, but as the limit value is independent of the chosen modulus, existence of such a -- modulus suffices. -- Definition 4.4.9. The Cauchy reals ℝC is the collection of rational sequences equipped with -- a modulus of Cauchy convergence, quotiented (as in Section 2.7) by an equivalence relation -- that relates two sequence–modulus pairs (x, M) and (y, N ) iff -- (∀ε : Q + ) x M (ε/4) − y M (ε/4) < ε. ℝC : {!!} ℝC = {!!} -- The Cauchy reals form an Archimedean ordered field in a natural way. The natural strategy -- to prove that the Cauchy reals are Cauchy complete, perhaps surprisingly, does not work, and -- in some constructive foundations the Cauchy completeness of the Cauchy reals is known to -- be false [68]. -- -- ... -- -- An alternative interpretation of the non-completeness of the Cauchy reals is that the sequential -- definition of completeness ought to be amended [80]. -- NOTE: now we're back to https://github.com/agda/cubical/issues/286 ? -- Auke would send an email to Ayberk Tosun and Martin Escardo -- I could prepare a PR for the cubical standard library -- the cubical standard library does not supersede the standard library -- using setoids need not to be a shortcoming but can be a concious decision -- Postulating the rationals as an ordered field for which there exists a unique morphism to every other ordered field should be sufficient -- (we went a little bit into the coprime and quotient construction of the rational numbers) -- I can prepare some statements that I would like to formalize (with just guessing) to have a more concrete guidance for the necessary detail of a real number formulation -- the impredicative `--prop` is not equivalent to hProp -- therefore, one should make props explicit arguments or at least be aware of them at all times {- in a world where we "just have" real numbers in Agda, I would do the following: Adjoint theory Vector space normed space Banach space Inner Product space unbounded Linear operator adjoint linear operator orthogonal decomposition of Banach spaces inf-sup conditions lax-milgram Local Multilinear Algebra euclidean space linear representation of hodge star locally euclidean Global Multilinear Algebra locally euclidean topological space chart representation -}
{ "alphanum_fraction": 0.6011825751, "avg_line_length": 45.532967033, "ext": "agda", "hexsha": "dbe67365bd63bf2c16cd0a3e5761168575b9d2b0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/SyntheticReals.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/SyntheticReals.agda", "max_line_length": 171, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/SyntheticReals.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 5266, "size": 16574 }
{-# OPTIONS --without-K --safe #-} -- Enriched category over a Monoidal category V open import Categories.Category using (categoryHelper) renaming (Category to Setoid-Category) open import Categories.Category.Monoidal using (Monoidal) module Categories.Enriched.Category {o ℓ e} {V : Setoid-Category o ℓ e} (M : Monoidal V) where open import Level open import Function using (_$_) open import Categories.Category.Monoidal.Properties M using (module Kelly's) open import Categories.Category.Monoidal.Reasoning M open import Categories.Category.Monoidal.Utilities M using (module Shorthands) open import Categories.Functor using (Functor) open import Categories.Morphism.Reasoning V import Categories.Morphism.IsoEquiv V as IsoEquiv open Setoid-Category V renaming (Obj to ObjV; id to idV) open Commutation open Monoidal M open Shorthands open IsoEquiv._≃_ record Category v : Set (o ⊔ ℓ ⊔ e ⊔ suc v) where field Obj : Set v hom : (A B : Obj) → ObjV id : {A : Obj} → unit ⇒ hom A A ⊚ : {A B C : Obj} → hom B C ⊗₀ hom A B ⇒ hom A C ⊚-assoc : {A B C D : Obj} → [ (hom C D ⊗₀ hom B C) ⊗₀ hom A B ⇒ hom A D ]⟨ ⊚ ⊗₁ idV ⇒⟨ hom B D ⊗₀ hom A B ⟩ ⊚ ≈ associator.from ⇒⟨ hom C D ⊗₀ (hom B C ⊗₀ hom A B) ⟩ idV ⊗₁ ⊚ ⇒⟨ hom C D ⊗₀ hom A C ⟩ ⊚ ⟩ unitˡ : {A B : Obj} → [ unit ⊗₀ hom A B ⇒ hom A B ]⟨ id ⊗₁ idV ⇒⟨ hom B B ⊗₀ hom A B ⟩ ⊚ ≈ unitorˡ.from ⟩ unitʳ : {A B : Obj} → [ hom A B ⊗₀ unit ⇒ hom A B ]⟨ idV ⊗₁ id ⇒⟨ hom A B ⊗₀ hom A A ⟩ ⊚ ≈ unitorʳ.from ⟩ -- A version of ⊚-assoc using generalized hom-variables. -- -- In this version of associativity, the generalized variables f, g -- and h represent V-morphisms, or rather, morphism-valued maps, -- such as V-natural transofrmations or V-functorial actions. This -- version is therefore well-suited for proving derived equations, -- such as functorial laws or commuting diagrams, that involve such -- maps. For examples, see Underlying.assoc below, or the modules -- Enriched.Functor and Enriched.NaturalTransformation. ⊚-assoc-var : {X Y Z : ObjV} {A B C D : Obj} {f : X ⇒ hom C D} {g : Y ⇒ hom B C} {h : Z ⇒ hom A B} → [ (X ⊗₀ Y) ⊗₀ Z ⇒ hom A D ]⟨ (⊚ ∘ f ⊗₁ g) ⊗₁ h ⇒⟨ hom B D ⊗₀ hom A B ⟩ ⊚ ≈ associator.from ⇒⟨ X ⊗₀ (Y ⊗₀ Z) ⟩ f ⊗₁ (⊚ ∘ g ⊗₁ h) ⇒⟨ hom C D ⊗₀ hom A C ⟩ ⊚ ⟩ ⊚-assoc-var {f = f} {g} {h} = begin ⊚ ∘ (⊚ ∘ f ⊗₁ g) ⊗₁ h ≈⟨ refl⟩∘⟨ split₁ˡ ⟩ ⊚ ∘ ⊚ ⊗₁ idV ∘ (f ⊗₁ g) ⊗₁ h ≈⟨ pullˡ ⊚-assoc ⟩ (⊚ ∘ idV ⊗₁ ⊚ ∘ α⇒) ∘ (f ⊗₁ g) ⊗₁ h ≈⟨ pullʳ (pullʳ assoc-commute-from) ⟩ ⊚ ∘ idV ⊗₁ ⊚ ∘ f ⊗₁ (g ⊗₁ h) ∘ α⇒ ≈˘⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩ ⊚ ∘ f ⊗₁ (⊚ ∘ g ⊗₁ h) ∘ α⇒ ∎ -- The usual shorthand for hom-objects of an arbitrary category. infix 15 _[_,_] _[_,_] : ∀ {c} (C : Category c) (X Y : Category.Obj C) → ObjV _[_,_] = Category.hom -- A V-category C does not have morphisms of its own, but the -- collection of V-morphisms from the monoidal unit into the -- hom-objects of C forms a setoid. This induces the *underlying* -- category of C. Underlying : ∀ {c} (C : Category c) → Setoid-Category c ℓ e Underlying C = categoryHelper (record { Obj = Obj ; _⇒_ = λ A B → unit ⇒ hom A B ; _≈_ = λ f g → f ≈ g ; id = id ; _∘_ = λ f g → ⊚ ∘ f ⊗₁ g ∘ λ⇐ ; assoc = λ {_} {_} {_} {_} {f} {g} {h} → begin ⊚ ∘ (⊚ ∘ h ⊗₁ g ∘ λ⇐) ⊗₁ f ∘ λ⇐ ≈˘⟨ refl⟩∘⟨ assoc ⟩⊗⟨refl ⟩∘⟨refl ⟩ ⊚ ∘ ((⊚ ∘ h ⊗₁ g) ∘ λ⇐) ⊗₁ f ∘ λ⇐ ≈⟨ refl⟩∘⟨ pushˡ split₁ʳ ⟩ ⊚ ∘ (⊚ ∘ h ⊗₁ g) ⊗₁ f ∘ (λ⇐ ⊗₁ idV) ∘ λ⇐ ≈⟨ pullˡ ⊚-assoc-var ⟩ (⊚ ∘ h ⊗₁ (⊚ ∘ g ⊗₁ f) ∘ α⇒) ∘ (λ⇐ ⊗₁ idV) ∘ λ⇐ ≈˘⟨ pushˡ (pushʳ (pushʳ (switch-tofromˡ associator (to-≈ Kelly's.coherence-iso₁)))) ⟩ (⊚ ∘ h ⊗₁ (⊚ ∘ g ⊗₁ f) ∘ λ⇐) ∘ λ⇐ ≈⟨ pullʳ (pullʳ unitorˡ-commute-to) ⟩ ⊚ ∘ h ⊗₁ (⊚ ∘ g ⊗₁ f) ∘ idV ⊗₁ λ⇐ ∘ λ⇐ ≈˘⟨ refl⟩∘⟨ pushˡ split₂ʳ ⟩ ⊚ ∘ h ⊗₁ ((⊚ ∘ g ⊗₁ f) ∘ λ⇐) ∘ λ⇐ ≈⟨ refl⟩∘⟨ refl⟩⊗⟨ assoc ⟩∘⟨refl ⟩ ⊚ ∘ h ⊗₁ (⊚ ∘ g ⊗₁ f ∘ λ⇐) ∘ λ⇐ ∎ ; identityˡ = λ {_} {_} {f} → begin ⊚ ∘ id ⊗₁ f ∘ λ⇐ ≈⟨ refl⟩∘⟨ serialize₁₂ ⟩∘⟨refl ⟩ ⊚ ∘ (id ⊗₁ idV ∘ idV ⊗₁ f) ∘ λ⇐ ≈˘⟨ refl⟩∘⟨ pushʳ unitorˡ-commute-to ⟩ ⊚ ∘ id ⊗₁ idV ∘ λ⇐ ∘ f ≈⟨ pullˡ unitˡ ⟩ λ⇒ ∘ λ⇐ ∘ f ≈⟨ cancelˡ unitorˡ.isoʳ ⟩ f ∎ ; identityʳ = λ {_} {_} {f} → begin ⊚ ∘ f ⊗₁ id ∘ λ⇐ ≈⟨ refl⟩∘⟨ serialize₂₁ ⟩∘⟨refl ⟩ ⊚ ∘ (idV ⊗₁ id ∘ f ⊗₁ idV) ∘ λ⇐ ≈⟨ pullˡ (pullˡ unitʳ) ⟩ (unitorʳ.from ∘ f ⊗₁ idV) ∘ λ⇐ ≈⟨ unitorʳ-commute-from ⟩∘⟨refl ⟩ (f ∘ unitorʳ.from) ∘ λ⇐ ≈˘⟨ (refl⟩∘⟨ Kelly's.coherence₃) ⟩∘⟨refl ⟩ (f ∘ λ⇒) ∘ λ⇐ ≈⟨ cancelʳ unitorˡ.isoʳ ⟩ f ∎ ; equiv = equiv ; ∘-resp-≈ = λ eq₁ eq₂ → ∘-resp-≈ʳ $ ∘-resp-≈ˡ $ ⊗-resp-≈ eq₁ eq₂ }) where open Category C module Underlying {c} (C : Category c) = Setoid-Category (Underlying C)
{ "alphanum_fraction": 0.5057803468, "avg_line_length": 37.3381294964, "ext": "agda", "hexsha": "be3815b5190a2a5126d4462d0e1c236cc0a6833f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Enriched/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Enriched/Category.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Enriched/Category.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2374, "size": 5190 }
{-# OPTIONS --safe --experimental-lossy-unification #-} {- This file contains: 1. An iso πₙ'(Sⁿ) ≅ ℤ, where πₙ'(Sⁿ) = ∥ Sⁿ →∙ Sⁿ ∥₀ 2. A proof that idfun∙ : Sⁿ →∙ Sⁿ is the generator of πₙ'(Sⁿ) -} module Cubical.Homotopy.Group.PinSn where open import Cubical.Homotopy.Loopspace open import Cubical.Homotopy.Group.Base open import Cubical.Homotopy.Group.SuspensionMap open import Cubical.Homotopy.Connected open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Path open import Cubical.Foundations.Isomorphism open import Cubical.HITs.SetTruncation renaming (elim to sElim ; elim2 to sElim2 ; map to sMap) open import Cubical.HITs.Truncation renaming (elim to trElim ; elim2 to trElim2) open import Cubical.HITs.S1 open import Cubical.HITs.Sn open import Cubical.HITs.Susp open import Cubical.Data.Sigma open import Cubical.Data.Nat open import Cubical.Data.Int renaming (_+_ to _+ℤ_) open import Cubical.ZCohomology.Properties open import Cubical.Algebra.Group open import Cubical.Algebra.Group.Instances.Int open import Cubical.Algebra.Group.ZAction open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open Iso -- The goal is to prove that πₙSⁿ ≅ ℤ. This is of course trivial, given -- that ΩⁿK(ℤ,n) ≅ ℤ is already proved. However, we would like to do -- this for πₙSⁿ defined via (Sⁿ →∙ Sⁿ) and prove that the generator -- of this group is idfun∙ : Sⁿ → Sⁿ. private suspMapS^ : (n : ℕ) → (S₊∙ (suc n) →∙ S₊∙ (suc n)) → S₊∙ (2 + n) →∙ S₊∙ (2 + n) suspMapS^ n = suspMap {A = S₊∙ (suc n)} n is2ConnectedSuspMap : (n : ℕ) → isConnectedFun 2 (suspMapS^ (suc n)) is2ConnectedSuspMap n = isConnectedFunSubtr 2 n _ (subst (λ x → isConnectedFun x (suspMapS^ (suc n))) (subtrLem n (suc (suc n)) ∙ +-comm 2 n) (isConnectedSuspMap (suc n) (suc n))) where subtrLem : (n m : ℕ) → (n + m ∸ n) ≡ m subtrLem zero m = refl subtrLem (suc n) m = subtrLem n m -- From the connectedness of the suspension map, -- we get an iso πₙSⁿ ≅ πₙ₊₁(Sⁿ⁺¹) for n ≥ 2. SphereSuspIso : (n : ℕ) → Iso (π' (2 + n) (S₊∙ (2 + n))) (π' (3 + n) (S₊∙ (3 + n))) SphereSuspIso n = compIso setTruncTrunc2Iso (compIso (connectedTruncIso 2 (suspMap {A = S₊∙ (suc (suc n))} (suc n)) (is2ConnectedSuspMap n)) (invIso (setTruncTrunc2Iso))) SphereSuspGrIso : (n : ℕ) → GroupIso (π'Gr (suc n) (S₊∙ (2 + n))) (π'Gr (2 + n) (S₊∙ (3 + n))) fst (SphereSuspGrIso n) = SphereSuspIso n snd (SphereSuspGrIso n) = makeIsGroupHom (sElim2 (λ _ _ → isSetPathImplicit) λ f g → IsGroupHom.pres· (suspMapπ'Hom (suc n) .snd) ∣ f ∣₂ ∣ g ∣₂) private stLoop₁ : π 2 (S₊∙ 2) stLoop₁ = ∣ sym (rCancel (merid base)) ∙∙ (λ i → merid (loop i) ∙ sym (merid base)) ∙∙ rCancel (merid base) ∣₂ stLoop₁flip : π 2 (S₊∙ 2) stLoop₁flip = sMap flipSquare stLoop₁ flipSquareIso : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) → GroupIso (πGr (suc n) A) (πGr (suc n) A) fun (fst (flipSquareIso n)) = sMap flipSquare inv (fst (flipSquareIso n)) = sMap flipSquare rightInv (fst (flipSquareIso n)) = sElim (λ _ → isSetPathImplicit) λ _ → refl leftInv (fst (flipSquareIso n)) = sElim (λ _ → isSetPathImplicit) λ _ → refl snd (flipSquareIso n) = makeIsGroupHom (sElim2 (λ _ _ → isSetPathImplicit) λ f g → cong ∣_∣₂ ((sym (sym≡flipSquare (f ∙ g)) ∙∙ symDistr f g ∙∙ cong₂ _∙_ (sym≡flipSquare g) (sym≡flipSquare f) ∙ EH n (flipSquare g) (flipSquare f)))) -- We now want to prove π₁S¹≅π₂S². This will be done by passing through -- The loop space defintion of the groups π'₂S²≅π₂S² : GroupIso (π'Gr 1 (S₊∙ 2)) (πGr 1 (S₊∙ 2)) π'₂S²≅π₂S² = π'Gr≅πGr 1 (S₊∙ 2) {- We now define the iso π₂S² ≅ π₁S¹ -} π₂S²≅π₁S¹ : GroupIso (πGr 1 (S₊∙ 2)) (πGr 0 (S₊∙ 1)) fst π₂S²≅π₁S¹ = compIso setTruncTrunc2Iso (compIso (compIso (invIso (PathIdTruncIso 2)) (compIso (congIso (invIso (PathIdTruncIso 3))) (compIso (congIso (invIso (Iso-Kn-ΩKn+1 1))) (PathIdTruncIso 2)))) (invIso setTruncTrunc2Iso)) snd π₂S²≅π₁S¹ = makeIsGroupHom (sElim2 (λ _ _ → isSetPathImplicit) λ f g → cong (inv setTruncTrunc2Iso) (cong (fun (PathIdTruncIso 2)) (cong (cong (ΩKn+1→Kn 1)) (cong (cong (inv (PathIdTruncIso 3))) (cong (inv (PathIdTruncIso 2)) (refl {x = ∣ f ∙ g ∣}) ∙ cong-∙ ∣_∣ₕ f g) ∙ cong-∙ (inv (PathIdTruncIso 3)) (cong ∣_∣ₕ f) (cong ∣_∣ₕ g)) ∙ cong-∙ (ΩKn+1→Kn 1) (cong (inv (PathIdTruncIso 3)) (cong ∣_∣ₕ f)) (cong (inv (PathIdTruncIso 3)) (cong ∣_∣ₕ g))) ∙ PathIdTruncIsoFunct 1 (cong (ΩKn+1→Kn 1) (λ i → inv (PathIdTruncIso 3) ∣ f i ∣ₕ)) (cong (ΩKn+1→Kn 1) (λ i → inv (PathIdTruncIso 3) ∣ g i ∣ₕ))) ∙ setTruncTrunc2IsoFunct ((fun (PathIdTruncIso 2)) (cong (ΩKn+1→Kn 1) (λ i → inv (PathIdTruncIso 3) ∣ f i ∣ₕ))) ((fun (PathIdTruncIso 2)) (cong (ΩKn+1→Kn 1) (λ i → inv (PathIdTruncIso 3) ∣ g i ∣ₕ)))) where setTruncTrunc2IsoFunct : ∀ {ℓ} {A : Type ℓ} {x : A} (p q : hLevelTrunc 2 (x ≡ x)) → inv setTruncTrunc2Iso (Cubical.HITs.Truncation.map2 _∙_ p q) ≡ ·π 0 (inv setTruncTrunc2Iso p) (inv setTruncTrunc2Iso q) setTruncTrunc2IsoFunct = trElim2 (λ _ _ → isSetPathImplicit) λ _ _ → refl π₂'S²≅π₁'S¹ : GroupIso (π'Gr 1 (S₊∙ 2)) (π'Gr 0 (S₊∙ 1)) π₂'S²≅π₁'S¹ = compGroupIso (π'Gr≅πGr 1 (S₊∙ 2)) (compGroupIso (flipSquareIso 0) (compGroupIso π₂S²≅π₁S¹ (invGroupIso (π'Gr≅πGr 0 (S₊∙ 1))))) -- We get our iso πₙ'Sⁿ≅ℤ : (n : ℕ) → GroupIso (π'Gr n (S₊∙ (suc n))) ℤGroup πₙ'Sⁿ≅ℤ zero = compGroupIso (π'Gr≅πGr zero (S₊∙ 1)) ((compIso (setTruncIdempotentIso (isGroupoidS¹ _ _)) ΩS¹Isoℤ) , makeIsGroupHom (sElim2 (λ _ _ → isProp→isSet (isSetℤ _ _)) winding-hom)) πₙ'Sⁿ≅ℤ (suc zero) = compGroupIso π₂'S²≅π₁'S¹ (πₙ'Sⁿ≅ℤ zero) πₙ'Sⁿ≅ℤ (suc (suc n)) = compGroupIso (invGroupIso (SphereSuspGrIso n)) (πₙ'Sⁿ≅ℤ (suc n)) -- Same thing for the loop space definition πₙSⁿ≅ℤ : (n : ℕ) → GroupIso (πGr n (S₊∙ (suc n))) ℤGroup πₙSⁿ≅ℤ n = compGroupIso (invGroupIso (π'Gr≅πGr n (S₊∙ (suc n)))) (πₙ'Sⁿ≅ℤ n) -- The goal now is to show that πₙ'Sⁿ≅ℤ takes idfun∙ : Sⁿ → Sⁿ to 1. -- For this, we need a bunch of identities: private Isoπ₁S¹ℤ = (compIso (setTruncIdempotentIso (isGroupoidS¹ _ _)) ΩS¹Isoℤ) π'₂S²≅π₂S²⁻-stLoop' : inv (fst (π'₂S²≅π₂S²)) stLoop₁flip ≡ ∣ idfun∙ _ ∣₂ π'₂S²≅π₂S²⁻-stLoop' = cong ∣_∣₂ (ΣPathP ((funExt (λ { north → refl ; south → merid base ; (merid base i) j → hcomp (λ k → λ {(i = i0) → north ; (i = i1) → merid base (j ∧ k) ; (j = i0) → rUnit (λ _ → north) k i ; (j = i1) → merid base (i ∧ k)}) north ; (merid (loop k) i) j → hcomp (λ r → λ {(i = i0) → north ; (i = i1) → merid base (j ∧ r) ; (j = i0) → rUnit (funExt⁻ (cong fst (cong (Ω→SphereMap 1) (flipSquare (sym (rCancel (merid base)) ∙∙ (λ i₁ → merid (loop i₁) ∙ sym (merid base)) ∙∙ rCancel (merid base))))) (loop k)) r i ; (j = i1) → lem₂ r i k}) (((sym (rCancel (merid base)) ∙∙ (λ i₁ → merid (loop i₁) ∙ sym (merid base)) ∙∙ rCancel (merid base))) k i)})) , refl)) where genBot+side : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y) → Cube {A = A} (λ j r → x) (λ j r → p (~ j ∨ r)) (λ i r → p i) (λ i r → p (i ∧ r)) (λ i j → p (i ∧ ~ j)) (λ i j → p i) × Cube {A = A} (λ j r → p (~ j ∨ r)) (λ j r → p (r ∧ j)) (λ k r → p (~ k)) (λ k r → p r) (λ k j → p (~ k ∧ ~ j)) λ k j → p (j ∨ ~ k) genBot+side {A = A} {x = x} = J (λ y p → Cube {A = A} (λ j r → x) (λ j r → p (~ j ∨ r)) (λ i r → p i) (λ i r → p (i ∧ r)) (λ i j → p (i ∧ ~ j)) (λ i j → p i) × Cube {A = A} (λ j r → p (~ j ∨ r)) (λ j r → p (r ∧ j)) (λ k r → p (~ k)) (λ k r → p r) (λ k j → p (~ k ∧ ~ j)) λ k j → p (j ∨ ~ k)) (refl , refl) lem₁ : I → I → I → S₊ 2 lem₁ j i r = hcomp (λ k → λ {(i = i0) → north ; (i = i1) → genBot+side (merid base) .snd k j r ; (j = i0) → compPath-filler (merid base) (sym (merid base)) k i ; (j = i1) → merid base (i ∧ r) ; (r = i0) → rCancel-filler (merid base) k j i ; (r = i1) → compPath-filler (merid base) (sym (merid base)) (~ j ∧ k) i}) (genBot+side (merid base) .fst i j r) lem₂ : I → I → I → S₊ 2 lem₂ r i k = hcomp (λ j → λ {(i = i0) → north ; (i = i1) → merid base (r ∧ j) ; (r = i0) → doubleCompPath-filler (sym (rCancel (merid base))) (λ i₁ → merid (loop i₁) ∙ sym (merid base)) (rCancel (merid base)) j k i ; (r = i1) → compPath-filler (merid (loop k)) (sym (merid base)) (~ j) i ; (k = i0) → lem₁ j i r ; (k = i1) → lem₁ j i r}) ((merid (loop k) ∙ sym (merid base)) i) π₂S²≅π₁S¹-stLoop : fun (fst π₂S²≅π₁S¹) stLoop₁ ≡ ∣ loop ∣₂ π₂S²≅π₁S¹-stLoop = sym (leftInv Isoπ₁S¹ℤ (fun (fst π₂S²≅π₁S¹) stLoop₁)) ∙∙ cong (inv Isoπ₁S¹ℤ) compute ∙∙ leftInv (compIso (setTruncIdempotentIso (isGroupoidS¹ _ _)) ΩS¹Isoℤ) ∣ loop ∣₂ where compute : fun Isoπ₁S¹ℤ (fun (fst π₂S²≅π₁S¹) stLoop₁) ≡ fun Isoπ₁S¹ℤ ∣ loop ∣₂ compute = refl π₂'S²≅π₁'S¹≡ : fun (fst π₂'S²≅π₁'S¹) ∣ idfun∙ _ ∣₂ ≡ ∣ idfun∙ _ ∣₂ π₂'S²≅π₁'S¹≡ = lem₁ ∣ idfun∙ _ ∣₂ stLoop₁ (sym π'₂S²≅π₂S²⁻-stLoop') (cong (inv (fst (π'Gr≅πGr zero (S₊∙ 1)))) π₂S²≅π₁S¹-stLoop ∙ lem₂) where lem₁ : (x : _) (y : π 2 (S₊∙ 2)) → (x ≡ inv (fst π'₂S²≅π₂S²) (fun (fst (flipSquareIso 0)) y)) → inv (fst (π'Gr≅πGr zero (S₊∙ 1))) (fun (fst π₂S²≅π₁S¹) y) ≡ ∣ idfun∙ _ ∣₂ → fun (fst π₂'S²≅π₁'S¹) x ≡ ∣ idfun∙ _ ∣₂ lem₁ x y p q = cong (fun (fst π₂'S²≅π₁'S¹)) p ∙∙ (λ i → inv (fst (π'Gr≅πGr zero (S₊∙ (suc zero)))) (fun (fst π₂S²≅π₁S¹) (fun (fst (flipSquareIso zero)) (rightInv (fst (π'Gr≅πGr (suc zero) (S₊∙ (suc (suc zero))))) (inv (fst (flipSquareIso zero)) y) i) ))) ∙∙ cong (inv (fst (π'Gr≅πGr zero (S₊∙ (suc zero))))) (cong (fun (fst π₂S²≅π₁S¹)) (rightInv (fst (flipSquareIso zero)) y)) ∙ q lem₂ : inv (fst (π'Gr≅πGr zero (S₊∙ 1))) ∣ loop ∣₂ ≡ ∣ idfun∙ _ ∣₂ lem₂ = cong ∣_∣₂ (ΣPathP (funExt (λ { base → refl ; (loop i) → refl}) , refl)) suspPresIdfun : (n : ℕ) → suspMap n (idfun∙ (S₊∙ (suc n))) ≡ idfun∙ _ suspPresIdfun n = ΣPathP ((funExt (λ { north → refl ; south → merid (ptSn (suc n)) ; (merid a i) j → compPath-filler (merid a) (sym (merid (ptSn (suc n)))) (~ j) i})) , refl) suspPresIdfun2 : (n : ℕ) → fun (fst (invGroupIso (SphereSuspGrIso n))) ∣ idfun∙ (S₊∙ (suc (suc (suc n)))) ∣₂ ≡ ∣ idfun∙ _ ∣₂ suspPresIdfun2 n = sym (cong (fun (fst (invGroupIso (SphereSuspGrIso n)))) (cong ∣_∣₂ (suspPresIdfun (suc n)))) ∙ leftInv (SphereSuspIso n) ∣ idfun∙ _ ∣₂ -- We finally have our results πₙ'Sⁿ≅ℤ-idfun∙ : (n : ℕ) → fun (fst (πₙ'Sⁿ≅ℤ n)) ∣ idfun∙ _ ∣₂ ≡ (pos (suc zero)) πₙ'Sⁿ≅ℤ-idfun∙ zero = refl πₙ'Sⁿ≅ℤ-idfun∙ (suc zero) = speedUp ∣ idfun∙ _ ∣₂ π₂'S²≅π₁'S¹≡ where speedUp : (x : _) -- stated like this for faster type checking → fun (fst π₂'S²≅π₁'S¹) x ≡ ∣ idfun∙ _ ∣₂ → fun (fst (πₙ'Sⁿ≅ℤ (suc zero))) x ≡ pos (suc zero) speedUp x p = cong (fun (fst (πₙ'Sⁿ≅ℤ zero))) p πₙ'Sⁿ≅ℤ-idfun∙ (suc (suc n)) = cong (fun (fst (πₙ'Sⁿ≅ℤ (suc n)))) (suspPresIdfun2 n) ∙ πₙ'Sⁿ≅ℤ-idfun∙ (suc n) πₙ'Sⁿ-gen-by-idfun : (n : ℕ) → gen₁-by (π'Gr n (S₊∙ (suc n))) ∣ idfun∙ _ ∣₂ πₙ'Sⁿ-gen-by-idfun n = subst (gen₁-by (π'Gr n (S₊∙ (suc n)))) (sym (cong (inv (fst (πₙ'Sⁿ≅ℤ n))) (πₙ'Sⁿ≅ℤ-idfun∙ n)) ∙ leftInv (fst (πₙ'Sⁿ≅ℤ n)) ∣ idfun∙ _ ∣₂) (Iso-pres-gen₁ ℤGroup (π'Gr n (S₊∙ (suc n))) (pos (suc zero)) (λ h → h , (sym (·Comm h (pos 1)) ∙ ℤ·≡· h (pos 1))) (invGroupIso (πₙ'Sⁿ≅ℤ n)))
{ "alphanum_fraction": 0.5172257136, "avg_line_length": 39.1899109792, "ext": "agda", "hexsha": "90b346cf35f1c85495354658f3b67b1f611b80cf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Homotopy/Group/PinSn.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Homotopy/Group/PinSn.agda", "max_line_length": 80, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Homotopy/Group/PinSn.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 5571, "size": 13207 }
module IgnoreWarnings where -- all of the following files have warnings, which should be ignored -- because of the command-line flag import Issue2243 import Issue708quote import OldCompilerPragmas import RewritingEmptyPragma import Unreachable -- this should also be ignored {-# REWRITE #-}
{ "alphanum_fraction": 0.806122449, "avg_line_length": 21, "ext": "agda", "hexsha": "df90d73942af7797d1fc66d2d4786c8a5fcd1687", "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": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "phadej/agda", "max_forks_repo_path": "test/Succeed/IgnoreWarnings.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "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": "phadej/agda", "max_issues_repo_path": "test/Succeed/IgnoreWarnings.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "2fa8ede09451d43647f918dbfb24ff7b27c52edc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "phadej/agda", "max_stars_repo_path": "test/Succeed/IgnoreWarnings.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 65, "size": 294 }
-- Andreas, 2012-01-12 module Common.Irrelevance where open import Common.Level record Squash {a}(A : Set a) : Set a where constructor squash field .unsquash : A open Squash public
{ "alphanum_fraction": 0.722513089, "avg_line_length": 17.3636363636, "ext": "agda", "hexsha": "ecfedfa12f9ab94b18973d254712905293b7eada", "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/Common/Irrelevance.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/Common/Irrelevance.agda", "max_line_length": 42, "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/Common/Irrelevance.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": 60, "size": 191 }
------------------------------------------------------------------------------ -- FOTC natural numbers ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Nat where open import FOTC.Base open import FOTC.Data.Nat.Type public infixl 7 _*_ infixl 6 _+_ _∸_ ------------------------------------------------------------------------------ -- Arithmetic operations postulate _+_ : D → D → D +-0x : ∀ n → zero + n ≡ n +-Sx : ∀ m n → succ₁ m + n ≡ succ₁ (m + n) {-# ATP axioms +-0x +-Sx #-} postulate _∸_ : D → D → D ∸-x0 : ∀ n → n ∸ zero ≡ n ∸-xS : ∀ m n → m ∸ succ₁ n ≡ pred₁ (m ∸ n) {-# ATP axioms ∸-x0 ∸-xS #-} postulate _*_ : D → D → D *-0x : ∀ n → zero * n ≡ zero *-Sx : ∀ m n → succ₁ m * n ≡ n + m * n {-# ATP axioms *-0x *-Sx #-}
{ "alphanum_fraction": 0.3737373737, "avg_line_length": 26.0526315789, "ext": "agda", "hexsha": "9833a9c97e759aa8583d960e9e1a85f7690b611b", "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.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.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/Nat.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": 303, "size": 990 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.ZCohomology.CohomologyRings.Unit where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Isomorphism open import Cubical.Data.Nat renaming (_+_ to _+n_ ; _·_ to _·n_) open import Cubical.Data.Int open import Cubical.Data.Vec open import Cubical.Data.FinData open import Cubical.Algebra.Group open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.Instances.Int renaming (ℤGroup to ℤG) open import Cubical.Algebra.DirectSum.DirectSumHIT.Base open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Instances.Int renaming (ℤCommRing to ℤCR) open import Cubical.Algebra.CommRing.FGIdeal open import Cubical.Algebra.CommRing.QuotientRing open import Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly open import Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly-Quotient open import Cubical.Algebra.CommRing.Instances.Polynomials.MultivariatePoly-notationZ open import Cubical.Algebra.Polynomials.Multivariate.EquivCarac.A[X]X-A open import Cubical.HITs.Truncation open import Cubical.HITs.SetQuotients as SQ renaming (_/_ to _/sq_) open import Cubical.HITs.PropositionalTruncation as PT open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.RingStructure.CupProduct open import Cubical.ZCohomology.RingStructure.CohomologyRing open import Cubical.ZCohomology.Groups.Unit open Iso module Equiv-Unit-Properties where open CommRingStr (snd ℤCR) using () renaming ( 0r to 0ℤ ; 1r to 1ℤ ; _+_ to _+ℤ_ ; -_ to -ℤ_ ; _·_ to _·ℤ_ ; +Assoc to +ℤAssoc ; +IdL to +ℤIdL ; +IdR to +ℤIdR ; +Comm to +ℤComm ; ·Assoc to ·ℤAssoc ; ·IdL to ·ℤIdL ; ·IdR to ·ℤIdR ; ·DistR+ to ·ℤDistR+ ; is-set to isSetℤ ) open RingStr (snd (H*R Unit)) using () renaming ( 0r to 0H* ; 1r to 1H* ; _+_ to _+H*_ ; -_ to -H*_ ; _·_ to _cup_ ; +Assoc to +H*Assoc ; +IdL to +H*IdL ; +IdR to +H*IdR ; +Comm to +H*Comm ; ·Assoc to ·H*Assoc ; ·IdL to ·H*IdL ; ·IdR to ·H*IdR ; ·DistR+ to ·H*DistR+ ; is-set to isSetH* ) open CommRingStr (snd ℤ[X]) using () renaming ( 0r to 0Pℤ ; 1r to 1Pℤ ; _+_ to _+Pℤ_ ; -_ to -Pℤ_ ; _·_ to _·Pℤ_ ; +Assoc to +PℤAssoc ; +IdL to +PℤIdL ; +IdR to +PℤIdR ; +Comm to +PℤComm ; ·Assoc to ·PℤAssoc ; ·IdL to ·PℤIdL ; ·IdR to ·PℤIdR ; ·DistR+ to ·PℤDistR+ ; is-set to isSetPℤ ) open CommRingStr (snd ℤ[X]/X) using () renaming ( 0r to 0PℤI ; 1r to 1PℤI ; _+_ to _+PℤI_ ; -_ to -PℤI_ ; _·_ to _·PℤI_ ; +Assoc to +PℤIAssoc ; +IdL to +PℤIIdL ; +IdR to +PℤIIdR ; +Comm to +PℤIComm ; ·Assoc to ·PℤIAssoc ; ·IdL to ·PℤIIdL ; ·IdR to ·PℤIIdR ; ·DistR+ to ·PℤIDistR+ ; is-set to isSetPℤI ) ----------------------------------------------------------------------------- -- Direct Sens on ℤ[x] ℤ[x]→H*-Unit : ℤ[x] → H* Unit ℤ[x]→H*-Unit = DS-Rec-Set.f _ _ _ _ isSetH* 0H* base-trad _+H*_ +H*Assoc +H*IdR +H*Comm base-neutral-eq base-add-eq where base-trad : _ base-trad (zero ∷ []) a = base zero (inv (fst H⁰-Unit≅ℤ) a) base-trad (suc n ∷ []) a = 0H* base-neutral-eq : _ base-neutral-eq (zero ∷ []) = base-neutral _ base-neutral-eq (suc n ∷ []) = refl base-add-eq : _ base-add-eq (zero ∷ []) a b = base-add _ _ _ base-add-eq (suc n ∷ []) a b = +H*IdR _ ℤ[x]→H*-Unit-pres1Pℤ : ℤ[x]→H*-Unit (1Pℤ) ≡ 1H* ℤ[x]→H*-Unit-pres1Pℤ = refl ℤ[x]→H*-Unit-pres+ : (x y : ℤ[x]) → ℤ[x]→H*-Unit (x +Pℤ y) ≡ ℤ[x]→H*-Unit x +H* ℤ[x]→H*-Unit y ℤ[x]→H*-Unit-pres+ x y = refl -- -- Proving the morphism on the cup product T0 : (z : ℤ) → coHom 0 Unit T0 = λ z → inv (fst H⁰-Unit≅ℤ) z T0g : IsGroupHom (ℤG .snd) (fst (invGroupIso H⁰-Unit≅ℤ) .fun) (coHomGr 0 Unit .snd) T0g = snd (invGroupIso H⁰-Unit≅ℤ) -- idea : control of the unfolding + simplification of T0 on the left pres·-base-case-00 : (a : ℤ) → (b : ℤ) → T0 (a ·ℤ b) ≡ (T0 a) ⌣ (T0 b) pres·-base-case-00 (pos zero) b = (IsGroupHom.pres1 T0g) pres·-base-case-00 (pos (suc n)) b = ((IsGroupHom.pres· T0g b (pos n ·ℤ b))) ∙ (cong (λ X → (T0 b) +ₕ X) (pres·-base-case-00 (pos n) b)) pres·-base-case-00 (negsuc zero) b = IsGroupHom.presinv T0g b pres·-base-case-00 (negsuc (suc n)) b = cong T0 (+ℤComm (-ℤ b) (negsuc n ·ℤ b)) -- ·ℤ and ·₀ are defined asymetrically ! ∙ IsGroupHom.pres· T0g (negsuc n ·ℤ b) (-ℤ b) ∙ cong₂ _+ₕ_ (pres·-base-case-00 (negsuc n) b) (IsGroupHom.presinv T0g b) pres·-base-case-int : (n : ℕ) → (a : ℤ) → (m : ℕ) → (b : ℤ) → ℤ[x]→H*-Unit (base (n ∷ []) a ·Pℤ base (m ∷ []) b) ≡ ℤ[x]→H*-Unit (base (n ∷ []) a) cup ℤ[x]→H*-Unit (base (m ∷ []) b) pres·-base-case-int zero a zero b = cong (base 0) (pres·-base-case-00 a b) pres·-base-case-int zero a (suc m) b = refl pres·-base-case-int (suc n) a m b = refl pres·-base-case-vec : (v : Vec ℕ 1) → (a : ℤ) → (v' : Vec ℕ 1) → (b : ℤ) → ℤ[x]→H*-Unit (base v a ·Pℤ base v' b) ≡ ℤ[x]→H*-Unit (base v a) cup ℤ[x]→H*-Unit (base v' b) pres·-base-case-vec (n ∷ []) a (m ∷ []) b = pres·-base-case-int n a m b ℤ[x]→H*-Unit-pres· : (x y : ℤ[x]) → ℤ[x]→H*-Unit (x ·Pℤ y) ≡ ℤ[x]→H*-Unit x cup ℤ[x]→H*-Unit y ℤ[x]→H*-Unit-pres· = DS-Ind-Prop.f _ _ _ _ (λ x p q i y j → isSetH* _ _ (p y) (q y) i j) (λ y → refl) base-case λ {U V} ind-U ind-V y → cong₂ _+H*_ (ind-U y) (ind-V y) where base-case : _ base-case (n ∷ []) a = DS-Ind-Prop.f _ _ _ _ (λ _ → isSetH* _ _) (sym (RingTheory.0RightAnnihilates (H*R Unit) _)) (λ v' b → pres·-base-case-vec (n ∷ []) a v' b) λ {U V} ind-U ind-V → (cong₂ _+H*_ ind-U ind-V) ∙ sym (·H*DistR+ _ _ _) -- raising to the product ℤ[x]→H*-Unit-cancelX : (k : Fin 1) → ℤ[x]→H*-Unit (<X> k) ≡ 0H* ℤ[x]→H*-Unit-cancelX zero = refl ℤ[X]→H*-Unit : RingHom (CommRing→Ring ℤ[X]) (H*R Unit) fst ℤ[X]→H*-Unit = ℤ[x]→H*-Unit snd ℤ[X]→H*-Unit = makeIsRingHom ℤ[x]→H*-Unit-pres1Pℤ ℤ[x]→H*-Unit-pres+ ℤ[x]→H*-Unit-pres· ℤ[X]/X→H*R-Unit : RingHom (CommRing→Ring ℤ[X]/X) (H*R Unit) ℤ[X]/X→H*R-Unit = Quotient-FGideal-CommRing-Ring.inducedHom ℤ[X] (H*R Unit) ℤ[X]→H*-Unit <X> ℤ[x]→H*-Unit-cancelX ℤ[x]/x→H*-Unit : ℤ[x]/x → H* Unit ℤ[x]/x→H*-Unit = fst ℤ[X]/X→H*R-Unit ----------------------------------------------------------------------------- -- Converse Sens on ℤ[X] H*-Unit→ℤ[x] : H* Unit → ℤ[x] H*-Unit→ℤ[x] = DS-Rec-Set.f _ _ _ _ isSetPℤ 0Pℤ base-trad _+Pℤ_ +PℤAssoc +PℤIdR +PℤComm base-neutral-eq base-add-eq where base-trad : (n : ℕ) → coHom n Unit → ℤ[x] base-trad zero a = base (0 ∷ []) (fun (fst H⁰-Unit≅ℤ) a) base-trad (suc n) a = 0Pℤ base-neutral-eq : _ base-neutral-eq zero = base-neutral _ base-neutral-eq (suc n) = refl base-add-eq : _ base-add-eq zero a b = base-add _ _ _ ∙ cong (base (0 ∷ [])) (sym (IsGroupHom.pres· (snd H⁰-Unit≅ℤ) a b)) base-add-eq (suc n) a b = +PℤIdR _ H*-Unit→ℤ[x]-pres+ : (x y : H* Unit) → H*-Unit→ℤ[x] ( x +H* y) ≡ H*-Unit→ℤ[x] x +Pℤ H*-Unit→ℤ[x] y H*-Unit→ℤ[x]-pres+ x y = refl H*-Unit→ℤ[x]/x : H* Unit → ℤ[x]/x H*-Unit→ℤ[x]/x = [_] ∘ H*-Unit→ℤ[x] H*-Unit→ℤ[x]/x-pres+ : (x y : H* Unit) → H*-Unit→ℤ[x]/x (x +H* y) ≡ (H*-Unit→ℤ[x]/x x) +PℤI (H*-Unit→ℤ[x]/x y) H*-Unit→ℤ[x]/x-pres+ x y = cong [_] (H*-Unit→ℤ[x]-pres+ x y) ----------------------------------------------------------------------------- -- Section e-sect : (x : H* Unit) → ℤ[x]/x→H*-Unit (H*-Unit→ℤ[x]/x x) ≡ x e-sect = DS-Ind-Prop.f _ _ _ _ (λ _ → isSetH* _ _) refl base-case λ {U V} ind-U ind-V → cong ℤ[x]/x→H*-Unit (H*-Unit→ℤ[x]/x-pres+ U V) ∙ IsRingHom.pres+ (snd ℤ[X]/X→H*R-Unit) (H*-Unit→ℤ[x]/x U) (H*-Unit→ℤ[x]/x V) ∙ cong₂ _+H*_ ind-U ind-V where base-case : _ base-case zero a = cong (base 0) (leftInv (fst H⁰-Unit≅ℤ) a) base-case (suc n) a = (sym (base-neutral (suc n))) ∙ (cong (base (suc n)) ((isContr→isProp (isContrHⁿ-Unit n) _ a))) ----------------------------------------------------------------------------- -- Retraction e-retr : (x : ℤ[x]/x) → H*-Unit→ℤ[x]/x (ℤ[x]/x→H*-Unit x) ≡ x e-retr = SQ.elimProp (λ _ → isSetPℤI _ _) (DS-Ind-Prop.f _ _ _ _ (λ _ → isSetPℤI _ _) refl base-case λ {U V} ind-U ind-V → cong₂ _+PℤI_ ind-U ind-V) where base-case : _ base-case (zero ∷ []) a = refl base-case (suc n ∷ []) a = eq/ 0Pℤ (base (suc n ∷ []) a) ∣ ((λ x → base (n ∷ []) (-ℤ a)) , foo) ∣₁ where foo : (0Pℤ +Pℤ base (suc n ∷ []) (- a)) ≡ (base (n +n 1 ∷ []) (- a · pos 1) +Pℤ 0Pℤ) foo = (0Pℤ +Pℤ base (suc n ∷ []) (- a)) ≡⟨ +PℤIdL _ ⟩ base (suc n ∷ []) (- a) ≡⟨ cong₂ base (cong (λ X → X ∷ []) (sym ((+-suc n 0) ∙ (cong suc (+-zero n))))) (sym (·ℤIdR _)) ⟩ base (n +n suc 0 ∷ []) (- a ·ℤ 1ℤ) ≡⟨ refl ⟩ base (n +n 1 ∷ []) (- a · pos 1) ≡⟨ sym (+PℤIdR _) ⟩ (base (n +n 1 ∷ []) (- a · pos 1) +Pℤ 0Pℤ) ∎ ----------------------------------------------------------------------------- -- Computation of the Cohomology Ring module _ where open Equiv-Unit-Properties open RingEquivs Unit-CohomologyRingP : RingEquiv (CommRing→Ring ℤ[X]/X) (H*R Unit) fst Unit-CohomologyRingP = isoToEquiv is where is : Iso ℤ[x]/x (H* Unit) fun is = ℤ[x]/x→H*-Unit inv is = H*-Unit→ℤ[x]/x rightInv is = e-sect leftInv is = e-retr snd Unit-CohomologyRingP = snd ℤ[X]/X→H*R-Unit CohomologyRing-UnitP : RingEquiv (H*R Unit) (CommRing→Ring ℤ[X]/X) CohomologyRing-UnitP = invRingEquiv Unit-CohomologyRingP Unit-CohomologyRingℤ : RingEquiv (CommRing→Ring ℤCR) (H*R Unit) Unit-CohomologyRingℤ = compRingEquiv (invRingEquiv Equiv-ℤ[X]/X-ℤ) Unit-CohomologyRingP CohomologyRing-Unitℤ : RingEquiv (H*R Unit) (CommRing→Ring ℤCR) CohomologyRing-Unitℤ = compRingEquiv CohomologyRing-UnitP Equiv-ℤ[X]/X-ℤ
{ "alphanum_fraction": 0.4927188624, "avg_line_length": 37.0603174603, "ext": "agda", "hexsha": "a562100d4da2b694646b0bdc523295b12f07717d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/ZCohomology/CohomologyRings/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/ZCohomology/CohomologyRings/Unit.agda", "max_line_length": 122, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/ZCohomology/CohomologyRings/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4416, "size": 11674 }
module Implicits.Resolution.Embedding where open import Prelude open import Data.Vec open import Data.List as List hiding (map) open import Implicits.Syntax open import SystemF.Everything as F using () ⟦_⟧tp← : ∀ {ν} → F.Type ν → Type ν ⟦ F.tc x ⟧tp← = simpl (tc x) ⟦ F.tvar n ⟧tp← = simpl (tvar n) ⟦ a F.→' b ⟧tp← = (⟦ a ⟧tp← ⇒ ⟦ b ⟧tp←) ⟦ a F.⟶ b ⟧tp← = simpl (⟦ a ⟧tp← →' ⟦ b ⟧tp←) ⟦ F.∀' x ⟧tp← = ∀' ⟦ x ⟧tp← ⟦_⟧tps← : ∀ {ν n} → Vec (F.Type ν) n → Vec (Type ν) n ⟦ v ⟧tps← = map (⟦_⟧tp←) v ⟦_⟧ctx← : ∀ {ν n} → Vec (F.Type ν) n → List (Type ν) ⟦ v ⟧ctx← = toList $ map ⟦_⟧tp← v ⟦_⟧tp→ : ∀ {ν} → Type ν → F.Type ν ⟦ simpl (tc x) ⟧tp→ = F.tc x ⟦ simpl (tvar n) ⟧tp→ = F.tvar n ⟦ simpl (a →' b) ⟧tp→ = ⟦ a ⟧tp→ F.⟶ ⟦ b ⟧tp→ ⟦ a ⇒ b ⟧tp→ = ⟦ a ⟧tp→ F.→' ⟦ b ⟧tp→ ⟦ ∀' x ⟧tp→ = F.∀' ⟦ x ⟧tp→ ⟦_⟧tps→ : ∀ {ν n} → Vec (Type ν) n → Vec (F.Type ν) n ⟦ v ⟧tps→ = map (⟦_⟧tp→) v ⟦_⟧ctx→ : ∀ {ν} → (Δ : ICtx ν) → Vec (F.Type ν) (List.length (List.map ⟦_⟧tp→ Δ)) ⟦ Δ ⟧ctx→ = fromList (List.map ⟦_⟧tp→ Δ)
{ "alphanum_fraction": 0.5044865404, "avg_line_length": 27.8611111111, "ext": "agda", "hexsha": "ce2e639325c91892cd42e13e4065f2c2ba9d551e", "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/Implicits/Resolution/Embedding.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/Implicits/Resolution/Embedding.agda", "max_line_length": 81, "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/Implicits/Resolution/Embedding.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": 535, "size": 1003 }
------------------------------------------------------------------------ -- A parametrised specification of "natrec", along with a proof that -- the specification is propositional (assuming extensionality) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality open import Prelude hiding (ℕ; zero; suc) -- The module is parametrised by equality and some type that is closed -- under "zero" and "suc". module Nat.Eliminator {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) (ℕ : Type) (zero : ℕ) (suc : ℕ → ℕ) where open import Bijection eq using (_↔_) open Derived-definitions-and-properties eq import Equivalence eq as Eq open import Function-universe eq hiding (_∘_) open import H-level eq as H-level open import H-level.Closure eq open import Surjection eq using (_↠_) -- Specification of natrec. Natrec : (ℓ : Level) → Type (lsuc ℓ) Natrec ℓ = (P : ℕ → Type ℓ) (z : P zero) (s : ∀ n → P n → P (suc n)) → ∃ λ (natrec : ∀ n → P n) → natrec zero ≡ z × ∀ n → natrec (suc n) ≡ s n (natrec n) -- This specification is propositional (assuming extensionality). -- -- Note that the proof uses some lemmas that are defined by recursion -- on natural numbers. I suspect that it would be easy (although -- perhaps somewhat tedious) to avoid such recursion. -- -- I got the idea for this result from Christian Sattler, who -- mentioned the work of Awodey, Gambino and Sojakova: in "Inductive -- types in homotopy type theory" they prove something similar for a -- non-dependent eliminator. Natrec-propositional : ∀ {ℓ} → Extensionality (lsuc ℓ) ℓ → Is-proposition (Natrec ℓ) Natrec-propositional {ℓ} ext₊ = [inhabited⇒+]⇒+ 0 λ natrec₀ → Π-closure ext₊ 1 λ P → Π-closure ext₌ 1 λ z → Π-closure ext₌ 1 λ s → H-level.respects-surjection (∃-cong (lemma natrec₀ P z s)) 1 (mono₁ 0 (singleton-contractible _)) where ext₌ : Extensionality ℓ ℓ ext₌ = lower-extensionality _ lzero ext₊ ext₀ : Extensionality lzero ℓ ext₀ = lower-extensionality _ lzero ext₊ ext : Extensionality lzero ℓ ext = Eq.good-ext ext₀ lemma : (natrec₀ : Natrec ℓ) (P : ℕ → Type ℓ) (z : P zero) (s : ∀ n → P n → P (suc n)) (natrec : ∀ n → P n) → natrec ≡ proj₁ (natrec₀ P z s) ↠ (natrec zero ≡ z × ∀ n → natrec (suc n) ≡ s n (natrec n)) lemma natrec₀ P z s natrec = record { logical-equivalence = record { to = λ eq → (natrec zero ≡⟨ cong (_$ zero) eq ⟩ rec₀ P z s zero ≡⟨ nz₀ P z s ⟩∎ z ∎) , λ n → natrec (suc n) ≡⟨ cong (_$ suc n) eq ⟩ rec₀ P z s (suc n) ≡⟨ ns₀ P z s n ⟩ s n (rec₀ P z s n) ≡⟨ sym $ cong (s n) $ cong (_$ n) eq ⟩∎ s n (natrec n) ∎ ; from = λ { (nz , ns) → apply-ext ext $ lower ∘ rec₀ (λ n → ↑ ℓ (natrec n ≡ rec₀ P z s n)) (lift ( natrec zero ≡⟨ nz ⟩ z ≡⟨ sym $ nz₀ P z s ⟩∎ rec₀ P z s zero ∎)) (λ n ih → lift ( natrec (suc n) ≡⟨ ns n ⟩ s n (natrec n) ≡⟨ cong (s n) (lower ih) ⟩ s n (rec₀ P z s n) ≡⟨ sym $ ns₀ P z s n ⟩∎ rec₀ P z s (suc n) ∎)) } } ; right-inverse-of = λ { (nz , ns) → let f = lower ∘ rec₀ _ (lift (trans nz (sym $ nz₀ P z s))) (λ n ih → lift (trans (ns n) (trans (cong (s n) (lower ih)) (sym $ ns₀ P z s n)))) in _↔_.to ≡×≡↔≡ ( (trans (cong (_$ zero) (apply-ext ext f)) (nz₀ P z s) ≡⟨ cong (flip trans (nz₀ P z s)) $ Eq.cong-good-ext ext₀ f ⟩ trans (f zero) (nz₀ P z s) ≡⟨ cong (flip trans (nz₀ P z s) ∘ lower) $ nz₀ _ _ _ ⟩ trans (trans nz (sym $ nz₀ P z s)) (nz₀ P z s) ≡⟨ trans-[trans-sym]- _ (nz₀ P z s) ⟩∎ nz ∎) , apply-ext ext λ n → trans (cong (_$ suc n) (apply-ext ext f)) (trans (ns₀ P z s n) (sym $ cong (s n) $ cong (_$ n) (apply-ext ext f))) ≡⟨ cong₂ (λ p q → trans p (trans (ns₀ P z s n) (sym $ cong (s n) q))) (Eq.cong-good-ext ext₀ f) (Eq.cong-good-ext ext₀ f) ⟩ trans (f (suc n)) (trans (ns₀ P z s n) (sym $ cong (s n) (f n))) ≡⟨ cong (flip trans (trans _ (sym $ cong (s n) (f n))) ∘ lower) $ ns₀ _ _ _ _ ⟩ trans (trans (ns n) (trans (cong (s n) (f n)) (sym $ ns₀ P z s n))) (trans (ns₀ P z s n) (sym $ cong (s n) (f n))) ≡⟨ cong (flip trans (trans _ (sym $ cong (s n) (f n)))) $ sym $ trans-assoc _ _ (sym $ ns₀ P z s n) ⟩ trans (trans (trans (ns n) (cong (s n) (f n))) (sym $ ns₀ P z s n)) (trans (ns₀ P z s n) (sym $ cong (s n) (f n))) ≡⟨ sym $ trans-assoc _ _ (sym $ cong (s n) (f n)) ⟩ trans (trans (trans (trans (ns n) (cong (s n) (f n))) (sym $ ns₀ P z s n)) (ns₀ P z s n)) (sym $ cong (s n) (f n)) ≡⟨ cong (flip trans (sym $ cong (s n) (f n))) $ trans-[trans-sym]- _ (ns₀ P z s n) ⟩ trans (trans (ns n) (cong (s n) (f n))) (sym $ cong (s n) (f n)) ≡⟨ trans-[trans]-sym _ (cong (s n) (f n)) ⟩∎ ns n ∎ ) } } where rec₀ : (P : ℕ → Type ℓ) (z : P zero) (s : ∀ n → P n → P (suc n)) → ∀ n → P n rec₀ P z s = proj₁ (natrec₀ P z s) nz₀ : (P : ℕ → Type ℓ) (z : P zero) (s : ∀ n → P n → P (suc n)) → rec₀ P z s zero ≡ z nz₀ P z s = proj₁ (proj₂ (natrec₀ P z s)) ns₀ : (P : ℕ → Type ℓ) (z : P zero) (s : ∀ n → P n → P (suc n)) → ∀ n → rec₀ P z s (suc n) ≡ s n (rec₀ P z s n) ns₀ P z s = proj₂ (proj₂ (natrec₀ P z s))
{ "alphanum_fraction": 0.4119515012, "avg_line_length": 40.9940828402, "ext": "agda", "hexsha": "40e95b5648ad0850cd940eb8e372136506a7a426", "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/Nat/Eliminator.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/Nat/Eliminator.agda", "max_line_length": 146, "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/Nat/Eliminator.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": 2126, "size": 6928 }
{-# OPTIONS --allow-unsolved-metas #-} module turing where open import Level renaming ( suc to succ ; zero to Zero ) open import Data.Nat -- hiding ( erase ) open import Data.List open import Data.Maybe hiding ( map ) -- open import Data.Bool using ( Bool ; true ; false ) renaming ( not to negate ) open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Relation.Nullary using (¬_; Dec; yes; no) open import Level renaming ( suc to succ ; zero to Zero ) open import Data.Product hiding ( map ) open import logic data Write ( Σ : Set ) : Set where write : Σ → Write Σ wnone : Write Σ -- erase write tnone data Move : Set where left : Move right : Move mnone : Move -- at tδ both stack is poped -- write S push S , push SR -- erase push SL , push tone -- none push SL , push SR -- left push SR , pop -- right pop , push SL {-# TERMINATING #-} move : {Q Σ : Set } → { tnone : Σ} → {tδ : Q → Σ → Q × ( Write Σ ) × Move } → (q : Q ) ( L : List Σ ) ( L : List Σ ) → ( Q × List Σ × List Σ ) move {Q} {Σ} {tnone} {tδ} q L [] = move {Q} {Σ} {tnone} {tδ} q L ( tnone ∷ [] ) move {Q} {Σ} {tnone} {tδ} q [] R = move {Q} {Σ} {tnone} {tδ} q ( tnone ∷ [] ) R move {Q} {Σ} {tnone} {tδ} q ( LH ∷ LT ) ( RH ∷ RT ) with tδ q LH ... | nq , write x , left = ( nq , ( RH ∷ x ∷ LT ) , RT ) ... | nq , write x , right = ( nq , LT , ( x ∷ RH ∷ RT ) ) ... | nq , write x , mnone = ( nq , ( x ∷ LT ) , ( RH ∷ RT ) ) ... | nq , wnone , left = ( nq , ( RH ∷ LH ∷ LT ) , RT ) ... | nq , wnone , right = ( nq , LT , ( LH ∷ RH ∷ RT ) ) ... | nq , wnone , mnone = ( nq , ( LH ∷ LT ) , ( RH ∷ RT ) ) {-# TERMINATING #-} move-loop : {Q Σ : Set } → {tend : Q → Bool} → { tnone : Σ} → {tδ : Q → Σ → Q × ( Write Σ ) × Move } → (q : Q ) ( L : List Σ ) ( L : List Σ ) → ( Q × List Σ × List Σ ) move-loop {Q} {Σ} {tend} {tnone} {tδ} q L R with tend q ... | true = ( q , L , R ) ... | flase = move-loop {Q} {Σ} {tend} {tnone} {tδ} ( proj₁ next ) ( proj₁ ( proj₂ next ) ) ( proj₂ ( proj₂ next ) ) where next = move {Q} {Σ} {tnone} {tδ} q L R {-# TERMINATING #-} move0 : {Q Σ : Set } ( tend : Q → Bool ) (tnone : Σ ) (tδ : Q → Σ → Q × ( Write Σ ) × Move) (q : Q ) ( L : List Σ ) ( L : List Σ ) → ( Q × List Σ × List Σ ) move0 tend tnone tδ q L R with tend q ... | true = ( q , L , R ) move0 tend tnone tδ q L [] | false = move0 tend tnone tδ q L ( tnone ∷ [] ) move0 tend tnone tδ q [] R | false = move0 tend tnone tδ q ( tnone ∷ [] ) R move0 tend tnone tδ q ( LH ∷ LT ) ( RH ∷ RT ) | false with tδ q LH ... | nq , write x , left = move0 tend tnone tδ nq ( RH ∷ x ∷ LT ) RT ... | nq , write x , right = move0 tend tnone tδ nq LT ( x ∷ RH ∷ RT ) ... | nq , write x , mnone = move0 tend tnone tδ nq ( x ∷ LT ) ( RH ∷ RT ) ... | nq , wnone , left = move0 tend tnone tδ nq ( RH ∷ LH ∷ LT ) RT ... | nq , wnone , right = move0 tend tnone tδ nq LT ( LH ∷ RH ∷ RT ) ... | nq , wnone , mnone = move0 tend tnone tδ nq ( LH ∷ LT ) ( RH ∷ RT ) record Turing ( Q : Set ) ( Σ : Set ) : Set where field tδ : Q → Σ → Q × ( Write Σ ) × Move tstart : Q tend : Q → Bool tnone : Σ taccept : List Σ → ( Q × List Σ × List Σ ) taccept L = move0 tend tnone tδ tstart L [] open import automaton open Automaton {-# TERMINATING #-} move1 : {Q Σ : Set } ( tend : Q → Bool ) (tnone : Σ ) (δ : Q → Σ → Q ) (tδ : Q → Σ → Write Σ × Move) (q : Q ) ( L : List Σ ) ( R : List Σ ) → Q × List Σ × List Σ move1 tend tnone δ tδ q L R with tend q ... | true = ( q , L , R ) move1 tend tnone δ tδ q L [] | false = move1 tend tnone δ tδ q L ( tnone ∷ [] ) move1 tend tnone δ tδ q [] R | false = move1 tend tnone δ tδ q ( tnone ∷ [] ) R move1 tend tnone δ tδ q ( LH ∷ LT ) ( RH ∷ RT ) | false with tδ (δ q LH) LH ... | write x , left = move1 tend tnone δ tδ (δ q LH) ( RH ∷ x ∷ LT ) RT ... | write x , right = move1 tend tnone δ tδ (δ q LH) LT ( x ∷ RH ∷ RT ) ... | write x , mnone = move1 tend tnone δ tδ (δ q LH) ( x ∷ LT ) ( RH ∷ RT ) ... | wnone , left = move1 tend tnone δ tδ (δ q LH) ( RH ∷ LH ∷ LT ) RT ... | wnone , right = move1 tend tnone δ tδ (δ q LH) LT ( LH ∷ RH ∷ RT ) ... | wnone , mnone = move1 tend tnone δ tδ (δ q LH) ( LH ∷ LT ) ( RH ∷ RT ) record TM ( Q : Set ) ( Σ : Set ) : Set where field automaton : Automaton Q Σ tδ : Q → Σ → Write Σ × Move tnone : Σ taccept : Q → List Σ → ( Q × List Σ × List Σ ) taccept q L = move1 (aend automaton) tnone (δ automaton) tδ q L [] data CopyStates : Set where s1 : CopyStates s2 : CopyStates s3 : CopyStates s4 : CopyStates s5 : CopyStates H : CopyStates Copyδ : CopyStates → ℕ → CopyStates × ( Write ℕ ) × Move Copyδ s1 0 = H , wnone , mnone Copyδ s1 1 = s2 , write 0 , right Copyδ s2 0 = s3 , write 0 , right Copyδ s2 1 = s2 , write 1 , right Copyδ s3 0 = s4 , write 1 , left Copyδ s3 1 = s3 , write 1 , right Copyδ s4 0 = s5 , write 0 , left Copyδ s4 1 = s4 , write 1 , left Copyδ s5 0 = s1 , write 1 , right Copyδ s5 1 = s5 , write 1 , left Copyδ H _ = H , wnone , mnone Copyδ _ (suc (suc _)) = H , wnone , mnone copyMachine : Turing CopyStates ℕ copyMachine = record { tδ = Copyδ ; tstart = s1 ; tend = tend ; tnone = 0 } where tend : CopyStates → Bool tend H = true tend _ = false copyTM : TM CopyStates ℕ copyTM = record { automaton = record { δ = λ q i → proj₁ (Copyδ q i) ; aend = tend } ; tδ = λ q i → proj₂ (Copyδ q i ) ; tnone = 0 } where tend : CopyStates → Bool tend H = true tend _ = false test1 : CopyStates × ( List ℕ ) × ( List ℕ ) test1 = Turing.taccept copyMachine ( 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ [] ) test2 : ℕ → CopyStates × ( List ℕ ) × ( List ℕ ) test2 n = loop n (Turing.tstart copyMachine) ( 1 ∷ 1 ∷ 0 ∷ 0 ∷ 0 ∷ [] ) [] where loop : ℕ → CopyStates → ( List ℕ ) → ( List ℕ ) → CopyStates × ( List ℕ ) × ( List ℕ ) loop zero q L R = ( q , L , R ) loop (suc n) q L R = loop n ( proj₁ t1 ) ( proj₁ ( proj₂ t1 ) ) ( proj₂ ( proj₂ t1 ) ) where t1 = move {CopyStates} {ℕ} {0} {Copyδ} q L R -- testn = map (\ n -> test2 n) ( 0 ∷ 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ 6 ∷ [] ) testn : ℕ → List ( CopyStates × ( List ℕ ) × ( List ℕ ) ) testn 0 = test2 0 ∷ [] testn (suc n) = test2 n ∷ testn n
{ "alphanum_fraction": 0.4959677419, "avg_line_length": 39.8571428571, "ext": "agda", "hexsha": "82979c44c04d12355623b9a5a1e4df133b8b3c1f", "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": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_path": "src/turing.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "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/automaton-in-agda", "max_issues_repo_path": "src/turing.agda", "max_line_length": 150, "max_stars_count": null, "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_path": "src/turing.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2753, "size": 6696 }
open import Agda.Primitive using (_⊔_) import Categories.Category as Category import Categories.Category.Cartesian as Cartesian open import SingleSorted.Context module SingleSorted.Power {o ℓ e} (𝒞 : Category.Category o ℓ e) where open Category.Category 𝒞 open HomReasoning record Powered (A : Obj) : Set (o ⊔ ℓ ⊔ e) where field pow : Context → Obj π : ∀ {Γ} → var Γ → pow Γ ⇒ A tuple : ∀ Γ {B} → (var Γ → B ⇒ A) → B ⇒ pow Γ project : ∀ {Γ} {B} {x : var Γ} {fs : var Γ → B ⇒ A} → π x ∘ tuple Γ fs ≈ fs x unique : ∀ {Γ} {B} {fs : var Γ → B ⇒ A} {g : B ⇒ pow Γ} → (∀ i → π i ∘ g ≈ fs i) → tuple Γ fs ≈ g η : ∀ {Γ} → tuple Γ π ≈ id η = unique (λ i → identityʳ) ! : ∀ {B : Obj} → B ⇒ pow ctx-empty ! = tuple ctx-empty ctx-empty-absurd !-unique : ∀ {B : Obj} {f : B ⇒ pow ctx-empty} → ! ≈ f !-unique = unique λ i → ctx-empty-absurd i !-unique₂ : ∀ {B : Obj} {f g : B ⇒ pow ctx-empty} → f ≈ g !-unique₂ = (⟺ !-unique) ○ !-unique tuple-cong : ∀ {B : Obj} {Γ} {fs gs : var Γ → B ⇒ A} → (∀ i → fs i ≈ gs i) → tuple Γ fs ≈ tuple Γ gs tuple-cong ξ = unique (λ i → project ○ ⟺ (ξ i)) ∘-distribʳ-tuple : ∀ {B C} {Γ} {fs : var Γ → B ⇒ A} {g : C ⇒ B} → tuple Γ (λ x → fs x ∘ g) ≈ tuple Γ fs ∘ g ∘-distribʳ-tuple = unique (λ i → ⟺ assoc ○ ∘-resp-≈ˡ project) -- A cartesian category has a standard power structure (which we need not use) module _ (cartesian-𝒞 : Cartesian.Cartesian 𝒞) (A : Obj) where open Cartesian.Cartesian cartesian-𝒞 standard-pow : Context → Obj standard-pow ctx-empty = ⊤ standard-pow ctx-slot = A standard-pow (ctx-concat Γ Δ) = standard-pow Γ × standard-pow Δ standard-π : ∀ {Γ} → var Γ → standard-pow Γ ⇒ A standard-π var-var = id standard-π (var-inl i) = standard-π i ∘ π₁ standard-π (var-inr i) = standard-π i ∘ π₂ standard-tuple : ∀ Γ {B} → (var Γ → B ⇒ A) → B ⇒ standard-pow Γ standard-tuple ctx-empty fs = ! standard-tuple ctx-slot fs = fs var-var standard-tuple (ctx-concat Γ Δ) fs = ⟨ standard-tuple Γ (λ i → fs (var-inl i)) , standard-tuple Δ (λ j → fs (var-inr j)) ⟩ standard-project : ∀ {Γ} {B} {x : var Γ} {fs : var Γ → B ⇒ A} → standard-π x ∘ standard-tuple Γ fs ≈ fs x standard-project {x = var-var} = identityˡ standard-project {x = var-inl x} = assoc ○ ((∘-resp-≈ʳ project₁) ○ standard-project {x = x}) standard-project {x = var-inr x} = assoc ○ ((∘-resp-≈ʳ project₂) ○ standard-project {x = x}) standard-unique : ∀ {Γ} {B} {fs : var Γ → B ⇒ A} {g : B ⇒ standard-pow Γ} → (∀ i → standard-π i ∘ g ≈ fs i) → standard-tuple Γ fs ≈ g standard-unique {ctx-empty} ξ = !-unique _ standard-unique {ctx-slot} ξ = ⟺ (ξ var-var) ○ identityˡ standard-unique {ctx-concat Γ Δ} {fs = fs} ξ = unique (⟺ (standard-unique (λ x → sym-assoc ○ (ξ (var-inl x))))) (⟺ (standard-unique (λ y → sym-assoc ○ (ξ (var-inr y))))) StandardPowered : Powered A StandardPowered = record { pow = standard-pow ; π = standard-π ; tuple = standard-tuple ; project = λ {Γ} → standard-project {Γ} ; unique = standard-unique }
{ "alphanum_fraction": 0.5453712191, "avg_line_length": 38.0581395349, "ext": "agda", "hexsha": "856214e58e002c75c3c1b52951f9277ceedc90e8", "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/SingleSorted/Power.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/SingleSorted/Power.agda", "max_line_length": 126, "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/SingleSorted/Power.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": 1193, "size": 3273 }
-- {-# OPTIONS -v tc.conv.coerce:10 -v tc.conv.size:40 -v tc.size.solve:40 #-} -- Andreas, 2014-06-16 Coercion for sizes open import Common.Size data Nat (i : Size) : Set where zero : Nat i suc : (j : Size< i) → Nat j → Nat i three : (i : Size) → Nat (↑ ↑ ↑ i) three i = suc _ (suc _ (suc i zero)) -- Should be ok, but we get the error: -- ∞ !=< i of type Size -- when checking that the expression _ has type Size< (↑ (↑ (↑ i))) -- Works now.
{ "alphanum_fraction": 0.592920354, "avg_line_length": 26.5882352941, "ext": "agda", "hexsha": "6dc3863f5be3255533377487767a2bee872201f9", "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/Issue1203.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/Issue1203.agda", "max_line_length": 78, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue1203.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": 157, "size": 452 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} {-# OPTIONS --allow-unsolved-metas #-} module Light.Implementation.Standard.Data.Product where open import Light.Library.Data.Product using (Library ; Dependencies) open import Light.Library.Relation.Binary.Equality.Decidable using (DecidableEquality) open import Light.Variable.Sets instance dependencies : Dependencies dependencies = record {} instance library : Library dependencies library = record { Implementation } where module Implementation where open import Data.Product using (Σ) renaming (proj₁ to first ; proj₂ to second ; _,_ to both) public equals : ∀ ⦃ a‐c‐equals : DecidableEquality 𝕒 𝕔 ⦄ ⦃ b‐d‐equals : DecidableEquality 𝕓 𝕕 ⦄ → DecidableEquality (Σ 𝕒 (λ _ → 𝕓)) (Σ 𝕔 (λ _ → 𝕕)) equals = {!!}
{ "alphanum_fraction": 0.6704035874, "avg_line_length": 38.7826086957, "ext": "agda", "hexsha": "2ad8cdecc15c9b133cb3d9281277ea4631e9253f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "bindings/stdlib/Light/Implementation/Standard/Data/Product.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "bindings/stdlib/Light/Implementation/Standard/Data/Product.agda", "max_line_length": 111, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "bindings/stdlib/Light/Implementation/Standard/Data/Product.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 217, "size": 892 }
open import Level hiding ( suc ; zero ) open import Algebra module sym2 where open import Symmetric open import Data.Unit open import Function.Inverse as Inverse using (_↔_; Inverse; _InverseOf_) open import Function open import Data.Nat hiding (_⊔_) -- using (ℕ; suc; zero) open import Relation.Nullary open import Data.Empty open import Data.Product open import Gutil open import Putil open import FLutil open import Solvable using (solvable) open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Data.Fin open import Data.Fin.Permutation sym2solvable : solvable (Symmetric 2) solvable.dervied-length sym2solvable = 1 solvable.end sym2solvable x d = solved x d where open import Data.List using ( List ; [] ; _∷_ ) open Solvable (Symmetric 2) -- open Group (Symmetric 2) using (_⁻¹) p0 : FL→perm ((# 0) :: ((# 0 ) :: f0)) =p= pid p0 = pleq _ _ refl p0r : perm→FL pid ≡ ((# 0) :: ((# 0 ) :: f0)) p0r = refl p1 : FL→perm ((# 1) :: ((# 0 ) :: f0)) =p= pswap pid p1 = pleq _ _ refl p1r : perm→FL (pswap pid) ≡ ((# 1) :: ((# 0 ) :: f0)) p1r = refl -- FL→iso : (fl : FL 2 ) → perm→FL ( FL→perm fl ) ≡ fl -- FL→iso (zero :: (zero :: f0)) = refl -- FL→iso ((suc zero) :: (zero :: f0)) = refl open _=p=_ open ≡-Reasoning sym2lem0 : ( g h : Permutation 2 2 ) → (q : Fin 2) → ([ g , h ] ⟨$⟩ʳ q) ≡ (pid ⟨$⟩ʳ q) sym2lem0 g h q with perm→FL g | perm→FL h | inspect perm→FL g | inspect perm→FL h sym2lem0 g h q | zero :: (zero :: f0) | _ | record { eq = g=00} | record { eq = h=00} = begin [ g , h ] ⟨$⟩ʳ q ≡⟨⟩ h ⟨$⟩ʳ (g ⟨$⟩ʳ ( h ⟨$⟩ˡ ( g ⟨$⟩ˡ q ))) ≡⟨ cong (λ k → h ⟨$⟩ʳ (g ⟨$⟩ʳ ( h ⟨$⟩ˡ k))) ((peqˡ sym2lem1 _ )) ⟩ h ⟨$⟩ʳ (g ⟨$⟩ʳ ( h ⟨$⟩ˡ ( pid ⟨$⟩ˡ q ))) ≡⟨ cong (λ k → h ⟨$⟩ʳ k ) (peq sym2lem1 _ ) ⟩ h ⟨$⟩ʳ (pid ⟨$⟩ʳ ( h ⟨$⟩ˡ ( pid ⟨$⟩ˡ q ))) ≡⟨⟩ [ pid , h ] ⟨$⟩ʳ q ≡⟨ peq (idcomtl h) q ⟩ q ∎ where sym2lem1 : g =p= pid sym2lem1 = FL-inject g=00 sym2lem0 g h q | _ | zero :: (zero :: f0) | record { eq = g=00} | record { eq = h=00} = begin [ g , h ] ⟨$⟩ʳ q ≡⟨⟩ h ⟨$⟩ʳ (g ⟨$⟩ʳ ( h ⟨$⟩ˡ ( g ⟨$⟩ˡ q ))) ≡⟨ peq sym2lem2 _ ⟩ pid ⟨$⟩ʳ (g ⟨$⟩ʳ ( h ⟨$⟩ˡ ( g ⟨$⟩ˡ q ))) ≡⟨ cong (λ k → pid ⟨$⟩ʳ (g ⟨$⟩ʳ k)) (peqˡ sym2lem2 _ ) ⟩ pid ⟨$⟩ʳ (g ⟨$⟩ʳ ( pid ⟨$⟩ˡ ( g ⟨$⟩ˡ q ))) ≡⟨⟩ [ g , pid ] ⟨$⟩ʳ q ≡⟨ peq (idcomtr g) q ⟩ q ∎ where sym2lem2 : h =p= pid sym2lem2 = FL-inject h=00 sym2lem0 g h q | suc zero :: (zero :: f0) | suc zero :: (zero :: f0) | record { eq = g=00} | record { eq = h=00}= begin [ g , h ] ⟨$⟩ʳ q ≡⟨⟩ h ⟨$⟩ʳ (g ⟨$⟩ʳ ( h ⟨$⟩ˡ ( g ⟨$⟩ˡ q ))) ≡⟨ peq (psym g=h ) _ ⟩ g ⟨$⟩ʳ (g ⟨$⟩ʳ ( h ⟨$⟩ˡ ( g ⟨$⟩ˡ q ))) ≡⟨ cong (λ k → g ⟨$⟩ʳ (g ⟨$⟩ʳ k) ) (peqˡ (psym g=h) _) ⟩ g ⟨$⟩ʳ (g ⟨$⟩ʳ ( g ⟨$⟩ˡ ( g ⟨$⟩ˡ q ))) ≡⟨ cong (λ k → g ⟨$⟩ʳ k) ( inverseʳ g ) ⟩ g ⟨$⟩ʳ ( g ⟨$⟩ˡ q ) ≡⟨ inverseʳ g ⟩ q ∎ where g=h : g =p= h g=h = FL-inject (trans g=00 (sym h=00)) solved : (x : Permutation 2 2) → Commutator (λ x₁ → Lift (Level.suc Level.zero) ⊤) x → x =p= pid solved x (comm {g} {h} _ _) = record { peq = sym2lem0 g h } solved x (ccong {f} {g} (record {peq = f=g}) d) with solved f d ... | record { peq = f=e } = record { peq = λ q → cc q } where cc : ( q : Fin 2 ) → x ⟨$⟩ʳ q ≡ q cc q = begin x ⟨$⟩ʳ q ≡⟨ sym (f=g q) ⟩ f ⟨$⟩ʳ q ≡⟨ f=e q ⟩ q ∎ where open ≡-Reasoning
{ "alphanum_fraction": 0.432934589, "avg_line_length": 34.1652173913, "ext": "agda", "hexsha": "7ffee4fe73e8c328d467096582fe29baa5010afb", "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": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/Galois", "max_forks_repo_path": "src/sym2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "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/Galois", "max_issues_repo_path": "src/sym2.agda", "max_line_length": 122, "max_stars_count": 1, "max_stars_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/Galois", "max_stars_repo_path": "src/sym2.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-16T03:37:05.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-16T03:37:05.000Z", "num_tokens": 1674, "size": 3929 }
open import Nat open import Prelude open import List open import core open import contexts open import typed-expansion open import lemmas-freevars module livelit-reasoning-principles where record reasoning-principles (Φ : livelitctx) (Γ : tctx) (a : livelitname) (dm : iexp) (τsplice : typ) (êsplice : uexp) (eresult : eexp) (τresult : typ) : Set where field π : livelitdef domain : dom (Φ ₁) a eexpanded : eexp esplice : eexp expanded-application-form : eresult == (eexpanded ·: τsplice ==> τresult) ∘ esplice expansion-typing : (Γ ⊢ eresult => τresult) × (τresult == livelitdef.expansion-type π) responsibility : Σ[ denc ∈ iexp ] (((livelitdef.expand π) ∘ dm) ⇓ denc × denc ↑ eexpanded) splice-typing : Φ , Γ ⊢ êsplice ~~> esplice ⇐ τsplice × Γ ⊢ esplice <= τsplice context-independence : free-vars (eexpanded ·: τsplice ==> τresult) == [] livelit-reasoning-principles : ∀{Φ Γ a dm τsplice psplice eresult τresult u} → Φ , Γ ⊢ $ a ⟨ dm ⁏ (τsplice , psplice) :: [] ⟩[ u ] ~~> eresult ⇒ τresult → reasoning-principles Φ Γ a dm τsplice psplice eresult τresult livelit-reasoning-principles h@(SPEApLivelit {dm = dm} {π} {denc} {eexpanded} {esplice = esplice} x x₁ x₂ x₃ x₄ x₅ x₆ x₇) = record { π = π ; domain = _ , x₂ ; eexpanded = eexpanded ; esplice = esplice ; expanded-application-form = refl ; expansion-typing = typed-expansion-synth h , refl ; responsibility = denc , x₄ , x₅ ; splice-typing = x₆ , typed-expansion-ana x₆ ; context-independence = ∅∈l→l==[] (λ x → fv-lemma-ana refl x₇) }
{ "alphanum_fraction": 0.5117762512, "avg_line_length": 45.2888888889, "ext": "agda", "hexsha": "b2c5ce5cddbe2699daf46feae2784e8e4d1565fd", "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": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-livelits-agda", "max_forks_repo_path": "livelit-reasoning-principles.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_issues_repo_issues_event_max_datetime": "2020-10-20T20:44:13.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-30T20:27:56.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazel-palette-agda", "max_issues_repo_path": "livelit-reasoning-principles.agda", "max_line_length": 125, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazel-palette-agda", "max_stars_repo_path": "livelit-reasoning-principles.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T15:38:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-04T06:45:06.000Z", "num_tokens": 592, "size": 2038 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude -- This module defines functionality modeling an RWS monad, which we use to -- define an implementation, and functionality for proving properties about -- programs written using this RWS monad. The main definitions are: -- 1. RWS, a datatype for the ASTs of stateful programs that read from an -- environment and produce output. -- This datatype includes constructors for branching code, to aid in the -- verification effort (see below). -- 2. RWS-weakestPre, a large elimination that, given an RWS program and a -- post condition for the program, produces the weakest precondition needed -- to satisfy that post condition. Branches in code using the constructors -- `RWS-if` and friends are translated into products, with each component of -- the product corresponding to a possible branch taken. -- 3. RWS-Contract is the type of proofs that, given a stateful computation and -- a post condition, the weakest precondition suffices to prove that post -- condition. -- 4. RWS-contract proves RWS-Contract, i.e., for every stateful computation -- `m` and post condition `P`, given a proof over a pre-state `pre` the -- weakest precondition for `P` holds, then postcondition `P` holds for the -- post-state obtained from running `m` in state `pre`. -- TODO-2: this module is independent of any particular implementation -- and arguably belongs somewhere more general, such as next to Optics. module LibraBFT.ImplShared.Util.Dijkstra.RWS where -- RWS, the AST of computations with state `St` reading from an environment -- `Ev` and producing a list of outputs of type `Wr` data RWS (Ev Wr St : Set) : Set → Set₁ where -- Primitive combinators RWS-return : ∀ {A} → A → RWS Ev Wr St A RWS-bind : ∀ {A B} → RWS Ev Wr St A → (A → RWS Ev Wr St B) → RWS Ev Wr St B RWS-gets : ∀ {A} → (St → A) → RWS Ev Wr St A RWS-put : St → RWS Ev Wr St Unit RWS-ask : RWS Ev Wr St Ev RWS-tell : List Wr → RWS Ev Wr St Unit -- Branching combinators (used for creating more convenient contracts) RWS-if : ∀ {A} → Guards (RWS Ev Wr St A) → RWS Ev Wr St A RWS-either : ∀ {A B C} → Either B C → (B → RWS Ev Wr St A) → (C → RWS Ev Wr St A) → RWS Ev Wr St A RWS-ebind : ∀ {A B C} → RWS Ev Wr St (Either C A) → (A → RWS Ev Wr St (Either C B)) → RWS Ev Wr St (Either C B) RWS-maybe : ∀ {A B} → Maybe B → (RWS Ev Wr St A) → (B → RWS Ev Wr St A) → RWS Ev Wr St A private variable Ev Wr St : Set A B C : Set -- To execute an RWS program, you provide an environment and prestate. This -- produces a result value, poststate, and list of outputs. RWS-run : RWS Ev Wr St A → Ev → St → A × St × List Wr RWS-run (RWS-return x) ev st = x , st , [] RWS-run (RWS-bind m f) ev st with RWS-run m ev st ...| x₁ , st₁ , outs₁ with RWS-run (f x₁) ev st₁ ...| x₂ , st₂ , outs₂ = x₂ , st₂ , outs₁ ++ outs₂ RWS-run (RWS-gets f) ev st = f st , st , [] RWS-run (RWS-put st) ev _ = unit , st , [] RWS-run RWS-ask ev st = ev , st , [] RWS-run (RWS-tell outs) ev st = unit , st , outs RWS-run (RWS-if (clause (b ≔ c) gs)) ev st = if toBool b then RWS-run c ev st else RWS-run (RWS-if gs) ev st RWS-run (RWS-if (otherwise≔ c)) ev st = RWS-run c ev st RWS-run (RWS-either (Left x) f₁ f₂) ev st = RWS-run (f₁ x) ev st RWS-run (RWS-either (Right y) f₁ f₂) ev st = RWS-run (f₂ y) ev st RWS-run (RWS-ebind m f) ev st with RWS-run m ev st ...| Left c , st₁ , outs₁ = Left c , st₁ , outs₁ ...| Right a , st₁ , outs₁ with RWS-run (f a) ev st₁ ...| r , st₂ , outs₂ = r , st₂ , outs₁ ++ outs₂ RWS-run (RWS-maybe nothing f₁ f₂) ev st = RWS-run f₁ ev st RWS-run (RWS-maybe (just x) f₁ f₂) ev st = RWS-run (f₂ x) ev st -- Accessors for the result, poststate, and outputs. RWS-result : RWS Ev Wr St A → Ev → St → A RWS-result m ev st = proj₁ (RWS-run m ev st) RWS-post : RWS Ev Wr St A → Ev → St → St RWS-post m ev st = proj₁ (proj₂ (RWS-run m ev st)) RWS-outs : RWS Ev Wr St A → Ev → St → List Wr RWS-outs m ev st = proj₂ (proj₂ (RWS-run m ev st)) -- Preconditions are predicates over environments and prestates. RWS-Pre : (Ev St : Set) → Set₁ RWS-Pre Ev St = (ev : Ev) (pre : St) → Set -- Postconditions are predicates over a result, poststate, and list of outputs. RWS-Post : (Wr St A : Set) → Set₁ RWS-Post Wr St A = (x : A) (post : St) (outs : List Wr) → Set RWS-Post-⇒ : (P Q : RWS-Post Wr St A) → Set RWS-Post-⇒ P Q = ∀ r st outs → P r st outs → Q r st outs -- RWS-weakestPre computes a predicate transformer: it maps a RWS -- computation `m` and desired postcondition `Post` to the weakest precondition -- needed to prove `P` holds after running `m`. RWS-PredTrans : (Ev Wr St A : Set) → Set₁ RWS-PredTrans Ev Wr St A = RWS-Post Wr St A → RWS-Pre Ev St -- When RWS computations are sequenced, e.g., `RWS-bind m λ x → f x`, -- outputs are concatenated. The postcondition desired for the above sequence -- becomes a postcondition for `f x` in which the outputs of `m` are prepended -- to the outputs of `f x`. RWS-Post++ : ∀ {Wr St A} → RWS-Post Wr St A → List Wr → RWS-Post Wr St A RWS-Post++ P outs x post outs₁ = P x post (outs ++ outs₁) -- Consider again the sequence `RWS-bind m₁ λ x → f x`. We also translate a -- postcondition `P` for the sequence into a postcondition for `m` --- -- specifically, the post condition we want for `m` is that the weakest -- precondition for `RWS-Post++ P outs` holds, where `outs` are the outputs of -- `m`. RWS-weakestPre-bindPost : (ev : Ev) (f : A → RWS Ev Wr St B) → RWS-Post Wr St B → RWS-Post Wr St A RWS-weakestPre-ebindPost : (ev : Ev) (f : A → RWS Ev Wr St (C ⊎ B)) → RWS-Post Wr St (C ⊎ B) → RWS-Post Wr St (C ⊎ A) RWS-weakestPre : (m : RWS Ev Wr St A) → RWS-PredTrans Ev Wr St A RWS-weakestPre (RWS-return x) P ev pre = P x pre [] RWS-weakestPre (RWS-bind m f) P ev pre = RWS-weakestPre m (RWS-weakestPre-bindPost ev f P) ev pre RWS-weakestPre (RWS-gets f) P ev pre = P (f pre) pre [] RWS-weakestPre (RWS-put post) P ev pre = P unit post [] RWS-weakestPre RWS-ask P ev pre = P ev pre [] RWS-weakestPre (RWS-tell outs) P ev pre = P unit pre outs RWS-weakestPre (RWS-if (clause (b ≔ c) gs)) P ev pre = (toBool b ≡ true → RWS-weakestPre c P ev pre) × (toBool b ≡ false → RWS-weakestPre (RWS-if gs) P ev pre) RWS-weakestPre (RWS-if (otherwise≔ c)) P ev pre = RWS-weakestPre c P ev pre RWS-weakestPre (RWS-either e f₁ f₂) P ev pre = (∀ x → (e ≡ Left x) → RWS-weakestPre (f₁ x) P ev pre) × (∀ y → (e ≡ Right y) → RWS-weakestPre (f₂ y) P ev pre) RWS-weakestPre (RWS-ebind m f) P ev pre = RWS-weakestPre m (RWS-weakestPre-ebindPost ev f P) ev pre RWS-weakestPre (RWS-maybe m f₁ f₂) P ev pre = (m ≡ nothing → RWS-weakestPre f₁ P ev pre) × (∀ j → m ≡ just j → RWS-weakestPre (f₂ j) P ev pre) RWS-weakestPre-ebindPost ev f Post (Left r) post outs = Post (Left r) post outs RWS-weakestPre-ebindPost ev f Post (Right r) post outs = ∀ c → c ≡ r → RWS-weakestPre (f c) (RWS-Post++ Post outs) ev post RWS-weakestPre-bindPost ev f Post x post outs = ∀ r → r ≡ x → RWS-weakestPre (f r) (RWS-Post++ Post outs) ev post -- The post condition `P` holds for `m` with environment `ev` and prestate `pre` RWS-Post-True : (P : RWS-Post Wr St A) (m : RWS Ev Wr St A) (ev : Ev) (pre : St) → Set RWS-Post-True P m ev pre = let (x , post , outs) = RWS-run m ev pre in P x post outs -- For every RWS computation `m`, `RWS-Contract m` is the type of proofs that, -- for all post conditions `P`, starting environments `ev` and prestates `pre`, -- to prove that `P` holds after running `m` in `ev` and `pre`, it suffices to -- provide a proof of the weakest precondition for `P` with respect to `m`, -- `ev`, and `pre`. RWS-Contract : (m : RWS Ev Wr St A) → Set₁ RWS-Contract{Ev}{Wr}{St}{A} m = (P : RWS-Post Wr St A) → (ev : Ev) (pre : St) → RWS-weakestPre m P ev pre → RWS-Post-True P m ev pre -- This proves that `RWS-weakestPre` gives a *sufficient* precondition for -- establishing a desired postcondition. Note thought that it does not prove -- that this precondition is the weakest such one; even though this is true, it -- is not important for our purposes. RWS-contract : (m : RWS Ev Wr St A) → RWS-Contract m RWS-contract (RWS-return x₁) P ev pre wp = wp RWS-contract (RWS-bind m f) P ev pre wp with RWS-contract m _ ev pre wp ...| con with RWS-run m ev pre ...| x₁ , st₁ , outs₁ = RWS-contract (f x₁) _ ev st₁ (con x₁ refl) RWS-contract (RWS-gets f) P ev pre wp = wp RWS-contract (RWS-put x₁) P ev pre wp = wp RWS-contract RWS-ask P ev pre wp = wp RWS-contract (RWS-tell x₁) P ev pre wp = wp RWS-contract{Ev}{Wr}{St}{A} (RWS-if gs) P ev pre wp = RWS-contract-if gs P ev pre wp where RWS-contract-if : (gs : Guards (RWS Ev Wr St A)) → RWS-Contract (RWS-if gs) RWS-contract-if (clause (b ≔ c) gs) P ev pre (wp₁ , wp₂) with toBool b ...| true = RWS-contract c _ ev pre (wp₁ refl) ...| false = RWS-contract-if gs _ ev pre (wp₂ refl) RWS-contract-if (otherwise≔ x) P ev pre wp = RWS-contract x P ev pre wp RWS-contract (RWS-either (Left x) f₁ f₂) P ev pre (wp₁ , wp₂) = RWS-contract (f₁ x) _ ev pre (wp₁ x refl) RWS-contract (RWS-either (Right y) f₁ f₂) P ev pre (wp₁ , wp₂) = RWS-contract (f₂ y) _ ev pre (wp₂ y refl) RWS-contract (RWS-ebind m f) P ev pre wp with RWS-contract m _ ev pre wp ...| con with RWS-run m ev pre ... | Left x , st₁ , outs₁ = con ... | Right y , st₁ , outs₁ = RWS-contract (f y) _ ev st₁ (con y refl) RWS-contract (RWS-maybe nothing f₁ f₂) P ev pre (wp₁ , wp₂) = RWS-contract f₁ _ ev pre (wp₁ refl) RWS-contract (RWS-maybe (just x) f₁ f₂) P ev pre (wp₁ , wp₂) = RWS-contract (f₂ x) _ ev pre (wp₂ x refl) -- This helper function is primarily used to take a proof concerning one -- computation `m` and show that that proof implies a property concerning a -- larger computation which contains `m`. RWS-⇒ : (P Q : RWS-Post Wr St A) → (RWS-Post-⇒ P Q) → ∀ m (ev : Ev) st → RWS-weakestPre m P ev st → RWS-weakestPre m Q ev st RWS-⇒ P Q pf (RWS-return x) ev st pre = pf x st [] pre RWS-⇒ P Q pf (RWS-bind m f) ev st pre = RWS-⇒ _ _ (λ r₁ st₁ outs₁ pf₁ x x≡ → RWS-⇒ _ _ (λ r₂ st₂ outs₂ pf₂ → pf r₂ st₂ (outs₁ ++ outs₂) pf₂) (f x) ev st₁ (pf₁ x x≡)) m ev st pre RWS-⇒ P Q pf (RWS-gets f) ev st pre = pf _ _ _ pre RWS-⇒ P Q pf (RWS-put x) ev st pre = pf _ _ _ pre RWS-⇒ P Q pf RWS-ask ev st pre = pf _ _ _ pre RWS-⇒ P Q pf (RWS-tell x) ev st pre = pf _ _ _ pre RWS-⇒ P Q pf (RWS-if (otherwise≔ x)) ev st pre = RWS-⇒ _ _ pf x ev st pre RWS-⇒ P Q pf (RWS-if (clause (b ≔ c) cs)) ev st (pre₁ , pre₂) = (λ pf' → RWS-⇒ _ _ pf c ev st (pre₁ pf')) , λ pf' → RWS-⇒ _ _ pf (RWS-if cs) ev st (pre₂ pf') proj₁ (RWS-⇒ P Q pf (RWS-either (Left x) f₁ f₂) ev st (pre₁ , pre₂)) x₁ x₁≡ = RWS-⇒ _ _ pf (f₁ x₁) ev st (pre₁ x₁ x₁≡) proj₂ (RWS-⇒ P Q pf (RWS-either (Left x) f₁ f₂) ev st (pre₁ , pre₂)) y () proj₁ (RWS-⇒ P Q pf (RWS-either (Right y) f₁ f₂) ev st (pre₁ , pre₂)) y₁ () proj₂ (RWS-⇒ P Q pf (RWS-either (Right y) f₁ f₂) ev st (pre₁ , pre₂)) y₁ y₁≡ = RWS-⇒ _ _ pf (f₂ y₁) ev st (pre₂ y₁ y₁≡) RWS-⇒ P Q pf (RWS-ebind m f) ev st pre = RWS-⇒ _ _ (λ { (Left x₁) st₁ outs x → pf _ _ _ x ; (Right y) st₁ outs x → λ c x₁ → RWS-⇒ _ _ (λ r st₂ outs₁ x₂ → pf r st₂ (outs ++ outs₁) x₂) (f c) ev st₁ (x c x₁)}) m ev st pre proj₁ (RWS-⇒ P Q pf (RWS-maybe x m f) ev st (pre₁ , pre₂)) ≡nothing = RWS-⇒ _ _ pf m ev st (pre₁ ≡nothing) proj₂ (RWS-⇒ P Q pf (RWS-maybe x m f) ev st (pre₁ , pre₂)) b b≡ = RWS-⇒ _ _ pf (f b) ev st (pre₂ b b≡) RWS-⇒-bind : (P : RWS-Post Wr St A) (Q : RWS-Post Wr St B) → (f : A → RWS Ev Wr St B) (ev : Ev) → RWS-Post-⇒ P (RWS-weakestPre-bindPost ev f Q) → ∀ m st → RWS-weakestPre m P ev st → RWS-weakestPre (RWS-bind m f) Q ev st RWS-⇒-bind P Q f ev pf m st con = RWS-⇒ P ((RWS-weakestPre-bindPost ev f Q)) pf m ev st con RWS-⇒-ebind : (P : RWS-Post Wr St (Either C A)) (Q : RWS-Post Wr St (Either C B)) → (f : A → RWS Ev Wr St (Either C B)) (ev : Ev) → RWS-Post-⇒ P (RWS-weakestPre-ebindPost ev f Q) → ∀ m st → RWS-weakestPre m P ev st → RWS-weakestPre (RWS-ebind m f) Q ev st RWS-⇒-ebind P Q f ev pf m st con = RWS-⇒ P ((RWS-weakestPre-ebindPost ev f Q)) pf m ev st con
{ "alphanum_fraction": 0.6225987818, "avg_line_length": 47.2546125461, "ext": "agda", "hexsha": "a29d07e54b95247f8ad0140151a19086a5f7b0a4", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2022-02-18T01:04:32.000Z", "max_forks_repo_forks_event_min_datetime": "2020-12-16T19:43:52.000Z", "max_forks_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "oracle/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/ImplShared/Util/Dijkstra/RWS.agda", "max_issues_count": 72, "max_issues_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_issues_repo_issues_event_max_datetime": "2022-03-25T05:36:11.000Z", "max_issues_repo_issues_event_min_datetime": "2021-02-04T05:04:33.000Z", "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "oracle/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/ImplShared/Util/Dijkstra/RWS.agda", "max_line_length": 117, "max_stars_count": 4, "max_stars_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "oracle/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/ImplShared/Util/Dijkstra/RWS.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-18T19:24:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-16T19:43:41.000Z", "num_tokens": 4728, "size": 12806 }
{-# OPTIONS --cubical-compatible #-} module Issue388 where data P (A : Set₁) : A → Set₁ where p : ∀ x → P A x data D : Set → Set₁ where d : ∀ A → D A Foo : ∀ A → P (D A) (d A) → Set Foo A x = {!x!}
{ "alphanum_fraction": 0.5219512195, "avg_line_length": 17.0833333333, "ext": "agda", "hexsha": "f503a277bb18bf4aceb99c90ced753650d63f9e6", "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/interaction/Issue388.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/interaction/Issue388.agda", "max_line_length": 36, "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/interaction/Issue388.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 81, "size": 205 }
{-# OPTIONS -v treeless.opt:20 #-} module _ where open import Common.Prelude module _ {a} {A : Set a} (_<_ : A → A → Bool) where merge : List A → List A → List A merge [] ys = ys merge xs [] = xs merge xs@(x ∷ xs₁) ys@(y ∷ ys₁) = if x < y then (x ∷ merge xs₁ ys) -- Generated treeless code should preserve else (y ∷ merge xs ys₁) -- xs and ys (and not expand to _∷_). open import Agda.Builtin.Nat mapM! : {A : Set} → (A → IO Unit) → List A → IO Unit mapM! f [] = return unit mapM! f (x ∷ xs) = f x >>= λ _ → mapM! f xs xs ys : List Nat xs = 2 ∷ 3 ∷ 5 ∷ 10 ∷ 20 ∷ [] ys = 0 ∷ 1 ∷ 2 ∷ 8 ∷ 10 ∷ 15 ∷ [] main : IO Unit main = mapM! printNat (merge _<_ xs ys)
{ "alphanum_fraction": 0.5523255814, "avg_line_length": 26.4615384615, "ext": "agda", "hexsha": "e3a76e90f9ef47c257cc67dae4a75ca2862aee2e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Compiler/simple/CompileAsPattern.agda", "max_issues_count": 16, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Compiler/simple/CompileAsPattern.agda", "max_line_length": 80, "max_stars_count": 7, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Compiler/simple/CompileAsPattern.agda", "max_stars_repo_stars_event_max_datetime": "2018-11-06T16:38:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-05T22:13:36.000Z", "num_tokens": 276, "size": 688 }
{-# OPTIONS --warning=error #-} module UselessAbstractAbstract where A : Set₁ abstract abstract A = Set
{ "alphanum_fraction": 0.6964285714, "avg_line_length": 12.4444444444, "ext": "agda", "hexsha": "3b7e25055280a68ef2146c58bc2f47b5b69cf63c", "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/UselessAbstractAbstract.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/UselessAbstractAbstract.agda", "max_line_length": 36, "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/UselessAbstractAbstract.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": 29, "size": 112 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommAlgebra.Instances.Initial where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Data.Unit open import Cubical.Data.Sigma.Properties using (Σ≡Prop) open import Cubical.Algebra.CommRing open import Cubical.Algebra.Ring open import Cubical.Algebra.Algebra.Base using (IsAlgebraHom) open import Cubical.Algebra.CommAlgebra.Base private variable ℓ : Level module _ ((R , str) : CommRing ℓ) where initialCAlg : CommAlgebra (R , str) ℓ initialCAlg = let open CommRingStr str in (R , commalgebrastr _ _ _ _ _ (λ r x → r · x) (makeIsCommAlgebra (isSetRing (CommRing→Ring (R , str))) +Assoc +Rid +Rinv +Comm ·Assoc ·Lid ·Ldist+ ·Comm (λ x y z → sym (·Assoc x y z)) ·Ldist+ ·Rdist+ ·Lid λ x y z → sym (·Assoc x y z))) module _ (A : CommAlgebra (R , str) ℓ) where open CommAlgebraStr ⦃... ⦄ private instance _ : CommAlgebraStr (R , str) (fst A) _ = snd A _ : CommAlgebraStr (R , str) R _ = snd initialCAlg _*_ : R → (fst A) → (fst A) r * a = CommAlgebraStr._⋆_ (snd A) r a initialMap : CommAlgebraHom initialCAlg A initialMap = makeCommAlgebraHom {M = initialCAlg} {N = A} (λ r → r * 1a) (⋆-lid _) (λ x y → ⋆-ldist x y 1a) (λ x y → (x · y) * 1a ≡⟨ ⋆-assoc _ _ _ ⟩ x * (y * 1a) ≡[ i ]⟨ x * (·Lid (y * 1a) (~ i)) ⟩ x * (1a · (y * 1a)) ≡⟨ sym (⋆-lassoc _ _ _) ⟩ (x * 1a) · (y * 1a) ∎) (λ r x → (r · x) * 1a ≡⟨ ⋆-assoc _ _ _ ⟩ (r * (x * 1a)) ∎) initialMapEq : (f : CommAlgebraHom initialCAlg A) → f ≡ initialMap initialMapEq f = let open IsAlgebraHom (snd f) in Σ≡Prop (isPropIsCommAlgebraHom {M = initialCAlg} {N = A}) λ i x → ((fst f) x ≡⟨ cong (fst f) (sym (·Rid _)) ⟩ fst f (x · 1a) ≡⟨ pres⋆ x 1a ⟩ CommAlgebraStr._⋆_ (snd A) x (fst f 1a) ≡⟨ cong (λ u → (snd A CommAlgebraStr.⋆ x) u) pres1 ⟩ (CommAlgebraStr._⋆_ (snd A) x 1a) ∎) i initialityIso : Iso (CommAlgebraHom initialCAlg A) (Unit* {ℓ = ℓ}) initialityIso = iso (λ _ → tt*) (λ _ → initialMap) (λ {tt*x → refl}) λ f → sym (initialMapEq f) initialityPath : CommAlgebraHom initialCAlg A ≡ Unit* initialityPath = isoToPath initialityIso
{ "alphanum_fraction": 0.4815321477, "avg_line_length": 36.0987654321, "ext": "agda", "hexsha": "8e8e630997d1567a08f71348f9f5aa3fc6bdec83", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_path": "Cubical/Algebra/CommAlgebra/Instances/Initial.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Seanpm2001-web/cubical", "max_issues_repo_path": "Cubical/Algebra/CommAlgebra/Instances/Initial.agda", "max_line_length": 95, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_path": "Cubical/Algebra/CommAlgebra/Instances/Initial.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "num_tokens": 946, "size": 2924 }
module z02-theorem-proving-with-booleans where open import bool open import eq open import level -- p 28 ~~tt : ~ ~ tt ≡ tt ~~tt = refl -- p 32 ~~ff : ~ ~ ff ≡ ff ~~ff = refl -- p 33 ~~-elim : ∀ (b : 𝔹) → ~ ~ b ≡ b ~~-elim tt = refl ~~-elim ff = refl -- p 34 ~~-elim2 : ∀ (b : 𝔹) → ~ ~ b ≡ b ~~-elim2 tt = ~~tt ~~-elim2 ff = ~~ff {- -- p 34 - does not typecheck (on purpose) because of IMPLICIT ARGS -- IMPLICIT ARGS: stated inside curly brackets (like IF previously) ~~-elim3 : ∀ (b : 𝔹) → ~ ~ b ≡ b ~~-elim3 tt = ~~ff ~~-elim3 ff = ~~tt 'refl' has implicit args - the expression 'x' in 'x ≡ x' (e.g., in ~~tt the implicit is 'tt') - in ~~-elim3 implicit arg 'tt' does not match '~~ff' -} {- -- p 35 : HOLES ~~-elim4 : ∀ (b : 𝔹) → ~ ~ b ≡ b ~~-elim4 tt = ? ~~-elim4 ff = ? -} -- p 36 &&-same : ∀ (b : 𝔹) → b && b ≡ b &&-same tt = refl &&-same ff = refl -- infer type of 'b' &&-same2 : ∀ b → b && b ≡ b &&-same2 tt = refl &&-same2 ff = refl -- 'b' as implicit argument &&-same3 : ∀ {b} → b && b ≡ b &&-same3 {tt} = refl &&-same3 {ff} = refl -- p 37 -- so no need to supply implicit arg to &&-same3 test-&&-same : tt && tt ≡ tt test-&&-same = &&-same3 -- ok to explicitly supply implicit arg test-&&-same2 : tt && tt ≡ tt test-&&-same2 = &&-same3 {tt} -- p 38 ||-same : ∀ {b} → b || b ≡ b ||-same {tt} = refl ||-same {ff} = refl ------------------------------------------------------------------------------ -- p. 38 2.4 Theorems with Hypotheses {- to express an assumption, write fun that - takes a proof of assumption - returns proof of desired result -} -- if b1 || b2 is false, then b1 must be false ||≡ff₁ : ∀ {b1 b2} → b1 || b2 ≡ ff -- assumption → b1 ≡ ff -- desired result -- 1st (implicit) arg is 'ff' -- 2nd (explicit) arg is ((b1 || b2) ≡ ff) bound to 'p' (but not used) ||≡ff₁ {ff} p = refl -- b1 = ff ≡ ff -- absurd pattern '()' ||≡ff₁ {tt} () -- no '=' sign because impossible {- To prove the impossible, but only if some impossible assumption is true, use absurd, since that impossible assumption can never be satisfied by a use of this theorem. -} -- p 41 alternative ||≡ff₁-2 : ∀ {b1 b2} → b1 || b2 ≡ ff → b1 ≡ ff ||≡ff₁-2 {ff} p = refl ||≡ff₁-2 {tt} p = p -- 'p' is equal to 'tt ≡ ff' -- the desired result of 'b1' instantiated to 'tt' -- prefer version that uses absurd -- more robust to later changes ------------------------------------------------------------------------------ -- p 42 2.4.3 Matching on equality proofs {- special case on CONGRUENCE if X equals Y then any TYPE containing X is equal to that same TYPE with X's replaced by Y Congruence holds for definitional equality automatically. Congruence must be proved for PROPOSITIONAL equalities 'a ≡ b' -} ||-cong₁ : ∀ {b1 b1’ b2} -- implicit args → b1 ≡ b1’ -- explicit arg → b1 || b2 ≡ b1’ || b2 -- desired result ||-cong₁ refl = refl {- -- p 43 only one way to construct an equality proof : via 'refl' constructor refl can only prove something of the form x ≡ x - so Agda deduces b1 must be exactly b1’ Agda uses definitional - knows b1 must be definitionally equal to b1’ - so refines the desired type using this definitional equality So only need to prove : ((b1 || b2) ≡ (b1 || b2)) -- b1' replaced with b1 since equal - via 'refl' ------------------------------------------------------------------------------ REFL Important rule about using type refinements (refl). Not allowed in such a way that non-variable terms are discovered to be definitionally equal to other such terms. e.g., two non-variable terms are definitionally equal: b1 || b2 ff ------------------------------------------------------------------------------ DOT PATTERN b1, b1’, and b2 are implicit arguments above. To include them in the pattern on the left-hand side of the equation: ||-cong₁ : ∀ {b1 b1’ b2} -- implicit args → b1 ≡ b1’ -- explicit arg → b1 || b2 ≡ b1’ || b2 -- desired result ||-cong₁ {b1}{b1’}{b2} refl = refl but Agda will complain because to type check this pattern, b1 and b1' can NOT be distinct. Agda deduces b1 and b1’ to be definitionally equal. Workaround : dot pattern: ||-cong₁ : ∀ {b1 b1’ b2} -- implicit args → b1 ≡ b1’ -- explicit arg → b1 || b2 ≡ b1’ || b2 -- desired result ||-cong₁ {b1}{.b1}{b2} refl = refl Writing “.” in front of term in pattern tells Agda that term is not a subpattern to match. Rather it has a form which is dictated by the type of the whole pattern. -} ------------------------------------------------------------------------------ -- p 44 2.4.4 The REWRITE directive ||-cong₂ : ∀ {b1 b2 b2'} → b2 ≡ b2' → b1 || b2 ≡ b1 || b2' ||-cong₂ p rewrite p = refl {- pattern variable p : with type b2 ≡ b2’ rewrite every occurrence of the left-hand side, as it appears in the current goal, with the right-hand side. goal is formula to prove on right-hand side of current equation rewrite p : transform the b2 (the left side of p) in b1 || b2 ≡ b1 || b2' to b2' (the right side of p) so goal (the type Agda is checking against the right-hand side of the equation) becomes b1 || b2’ ≡ b1 || b2’ REWRITE given proof 'p' of some equation X ≡ Y (any expression which has X ≡ Y as its type, e.g., call to lemma of that type) look in goal for any occurrences of X transform those into Y X and Y can be complex expressions (not just variables) ------------------------------------------------------------------------------ -- p 44 2.5 Further examples proving a polymorphic theorem for every type level ℓ and every type A at that level and for all booleans the given ITE holds -} ite-same : ∀ {ℓ} {A : Set ℓ} -- two implicit args -- so no patterns needed on left hand side of equations → ∀ (b : 𝔹) (x : A) -- two explicit args → if b then x else x ≡ x -- reason by cases on 'b' ite-same tt _ = refl -- x ≡ x ite-same ff _ = refl ------------------------------------------------------------------------------ -- p 45 B-contra : ff ≡ tt -- if ff ≡ tt holds → (∀ {P : Set} → P) -- then can prove anything -- every formula P is true (which is NOT true) B-contra () ------------------------------------------------------------------------------ -- p 46 SUMMARY {- - equality TYPE t ≡ t’ expresses equality of expressions t and t’, which must have the same type - prove equality with refl; will prove t ≡ t' for any definitionally equal t and t’ - two exprs definitionally equal if they can be proved equal using their defining equations - proof is program defined using pattern matching - Pattern matching can instantiate universally quantified variables which appear in the type. Has the effect of specializing the desired formula to the specific instances of those variables. - Args can be declared implicit with curly braces in the type. Can pattern match on implicit arguments, using curly braces around the pattern on left-hand side of equation - assumptions in theorems are args to programs which serve as proofs of those theorems - absurd pattern can be used when an assumption is definitionally equal to an impossible equality, where the equated terms start with different constructors - When using refl as the pattern for an equality assumption t ≡ t’, Agda will try to refine the type by making t and t’ definitionally equal. -} ------------------------------------------------------------------------------ -- p 47 Exercises -- 1 &&-idem : ∀ {b} -- implicit arg → b && b ≡ b -- result &&-idem {tt} = refl &&-idem {ff} = refl ||-idem : ∀ {b} -- implicit arg → b || b ≡ b -- result ||-idem {tt} = refl ||-idem {ff} = refl ||≡ff₂ : ∀ {b1 b2} -- implicit args → b1 || b2 ≡ ff -- explicit arg → b2 ≡ ff -- result ||≡ff₂ {ff}{ff} _ = refl {- ||≡ff₂ {tt} () ||≡ff₂ {ff}{tt} () -} ||-tt : ∀ (b : 𝔹) -- explicit arg → b || tt ≡ tt -- result ||-tt tt = refl ||-tt ff = refl ite-arg : ∀{ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} -- implicit args → (f : A → B) (b : 𝔹) (x y : A) -- explicit args → (f (if b then x else y)) ≡ (if b then f x else f y) -- result ite-arg _ tt _ _ = refl ite-arg _ ff _ _ = refl 𝔹-contra : ff ≡ tt → ∀{ℓ} {P : Set ℓ} → P 𝔹-contra () {- open import sum ||-split : ∀ {b b' : 𝔹} → b || b' ≡ tt → b ≡ tt ⊎ b' ≡ tt ||-split{tt}{tt} p = inj₁ refl ||-split{tt}{ff} p = inj₁ refl ||-split{ff}{tt} p = inj₂ refl ||-split{ff}{ff} () 𝔹-dec : ∀ (b : 𝔹) → b ≡ tt ⊎ b ≡ ff 𝔹-dec tt = inj₁ refl 𝔹-dec ff = inj₂ refl -} &&-snd : {p1 p2 : 𝔹} -- implicit args → p1 && p2 ≡ tt -- explicit arg → p2 ≡ tt -- result &&-snd {tt} {tt} _ = refl --&&-snd{ff} () &&-fst : {p1 p2 : 𝔹} → p1 && p2 ≡ tt → p1 ≡ tt &&-fst {tt} {tt} _ = refl -- &&-fst{ff} () &&-combo : {p1 p2 : 𝔹} -- implicit → p1 ≡ tt -- explcit → p2 ≡ tt -- explcit → p1 && p2 ≡ tt -- result &&-combo {tt} {tt} _ _ = refl {- alternative &&-combo{tt} pr1 pr2 = pr2 &&-combo{ff} pr1 pr2 = 𝔹-contra pr1 -} &&-ff : ∀(b : 𝔹) → b && ff ≡ ff &&-ff tt = refl &&-ff ff = refl ------------------------------------------------------------------------------ -- 2 ff-imp : ∀ (b : 𝔹) → ff imp b ≡ tt ff-imp tt = refl ff-imp ff = refl imp-tt : ∀ (b : 𝔹) → b imp tt ≡ tt imp-tt tt = refl imp-tt ff = refl imp-ff : ∀ (b : 𝔹) → b imp ff ≡ ~ b imp-ff tt = refl imp-ff ff = refl tt-imp : ∀ (b : 𝔹) → tt imp b ≡ b tt-imp tt = refl tt-imp ff = refl &&-tt : ∀ (b : 𝔹) → b && tt ≡ b &&-tt tt = refl &&-tt ff = refl ||-ff : ∀ (b : 𝔹) → b || ff ≡ b ||-ff tt = refl ||-ff ff = refl &&-contra : ∀ (b : 𝔹) → b && ~ b ≡ ff &&-contra tt = refl &&-contra ff = refl &&-comm : ∀ (b1 b2 : 𝔹) → b1 && b2 ≡ b2 && b1 &&-comm ff ff = refl &&-comm ff tt = refl &&-comm tt ff = refl &&-comm tt tt = refl ||-comm : ∀ (b1 b2 : 𝔹) → b1 || b2 ≡ b2 || b1 ||-comm ff ff = refl ||-comm ff tt = refl ||-comm tt ff = refl ||-comm tt tt = refl &&-assoc : ∀ (b1 b2 b3 : 𝔹) → b1 && (b2 && b3) ≡ (b1 && b2) && b3 &&-assoc ff ff ff = refl &&-assoc ff ff tt = refl &&-assoc ff tt ff = refl &&-assoc ff tt tt = refl &&-assoc tt ff ff = refl &&-assoc tt ff tt = refl &&-assoc tt tt ff = refl &&-assoc tt tt tt = refl ||-assoc : ∀ (b1 b2 b3 : 𝔹) → b1 || (b2 || b3) ≡ (b1 || b2) || b3 ||-assoc ff ff ff = refl ||-assoc ff ff tt = refl ||-assoc ff tt ff = refl ||-assoc ff tt tt = refl ||-assoc tt ff ff = refl ||-assoc tt ff tt = refl ||-assoc tt tt ff = refl ||-assoc tt tt tt = refl ~-over-&& : ∀ (b1 b2 : 𝔹) → ~ ( b1 && b2 ) ≡ (~ b1 || ~ b2) ~-over-&& ff ff = refl ~-over-&& ff tt = refl ~-over-&& tt ff = refl ~-over-&& tt tt = refl ~-over-|| : ∀ (b1 b2 : 𝔹) → ~ ( b1 || b2 ) ≡ (~ b1 && ~ b2) ~-over-|| ff ff = refl ~-over-|| ff tt = refl ~-over-|| tt ff = refl ~-over-|| tt tt = refl &&-over-||-l : ∀ (a b c : 𝔹) → a && (b || c) ≡ (a && b) || (a && c) &&-over-||-l ff ff ff = refl &&-over-||-l ff ff tt = refl &&-over-||-l ff tt ff = refl &&-over-||-l ff tt tt = refl &&-over-||-l tt ff ff = refl &&-over-||-l tt ff tt = refl &&-over-||-l tt tt ff = refl &&-over-||-l tt tt tt = refl {- &&-over-||-r : ∀ (a b c : 𝔹) → (a || b) && c ≡ (a && c) || (b && c) ||-over-&&-l : ∀ (a b c : 𝔹) → a || (b && c) ≡ (a || b) && (a || c) ||-over-&&-r : ∀ (a b c : 𝔹) → (a && b) || c ≡ (a || c) && (b || c) &&-cong₁ : ∀ {b1 b1' b2 : 𝔹} → b1 ≡ b1' → b1 && b2 ≡ b1' && b2 &&-cong₂ : ∀ {b1 b2 b2' : 𝔹} → b2 ≡ b2' → b1 && b2 ≡ b1 && b2' &&-intro : ∀ {b1 b2 : 𝔹} → b1 ≡ tt → b2 ≡ tt → b1 && b2 ≡ tt ||-intro1 : ∀ {b1 b2 : 𝔹} → b1 ≡ tt → b1 || b2 ≡ tt --&&-elim : ∀ {b1 b2 : 𝔹} → b1 && b2 ≡ tt → b1 ≡ tt ∧ b2 ≡ tt &&-elim1 : ∀ {b1 b2 : 𝔹} → b1 && b2 ≡ tt → b1 ≡ tt &&-elim2 : ∀ {b1 b2 : 𝔹} → b1 && b2 ≡ tt → b2 ≡ tt --||-elim : ∀ {b1 b2 : 𝔹} → b1 || b2 ≡ tt → b1 ≡ tt ∨ b2 ≡ tt -} ~-cong : ∀ {b b' : 𝔹} → b ≡ b' → ~ b ≡ ~ b' ~-cong refl = refl ite-cong₁ : ∀{ℓ}{A : Set ℓ} {b b' : 𝔹} (x y : A) → b ≡ b' → (if b then x else y) ≡ (if b' then x else y) ite-cong₁ _ _ refl = refl ite-cong₂ : ∀{ℓ} {A : Set ℓ} (b : 𝔹) {x x' : A} (y : A) → x ≡ x' → (if b then x else y) ≡ (if b then x' else y) ite-cong₂ _ _ refl = refl ite-cong₃ : ∀{ℓ}{A : Set ℓ} (b : 𝔹) (x : A) {y y' : A} → y ≡ y' → (if b then x else y) ≡ (if b then x else y') ite-cong₃ _ _ refl = refl --&&-split : ∀ {b b' : 𝔹} → b || b' ≡ ff → b ≡ ff ⊎ b' ≡ ff {- imp-same : ∀ (b : 𝔹) → b imp b ≡ tt imp-to-|| : ∀ (b1 b2 : 𝔹) → (b1 imp b2) ≡ (~ b1 || b2) imp-mp : ∀ {b b' : 𝔹} → b imp b' ≡ tt → b ≡ tt → b' ≡ tt imp-antisymm : ∀ {b1 b2 : 𝔹} → b1 imp b2 ≡ tt → b2 imp b1 ≡ tt → b1 ≡ b2 ff-xor : ∀ (b : 𝔹) → ff xor b ≡ b tt-xor : ∀ (b : 𝔹) → tt xor b ≡ ~ b ~-xor-distrb : ∀ (a b : 𝔹) → ~ (a xor b) ≡ ~ a xor b xor-distrib-&& : ∀ (x y : 𝔹) → x xor (y && x) ≡ ~ y && x xor~hop : ∀ (a b : 𝔹) → ~ a xor b ≡ a xor ~ b xor-comm : ∀ (b1 b2 : 𝔹) → b1 xor b2 ≡ b2 xor b1 xor-assoc : (b1 b2 b3 : 𝔹) → b1 xor (b2 xor b3) ≡ (b1 xor b2) xor b3 xor-anti-idem : (b : 𝔹) → b xor b ≡ ff xor-≡ : {b1 b2 : 𝔹} → b1 xor b2 ≡ ff → b1 ≡ b2 nor-not : ∀ (b : 𝔹) → b nor b ≡ ~ b nor-or : ∀ (b1 b2 : 𝔹) → (b1 nor b2) nor (b1 nor b2) ≡ b1 || b2 nor-and : ∀ (b1 b2 : 𝔹) → (b1 nor b1) nor (b2 nor b2) ≡ b1 && b2 nor-comm : ∀ (b1 b2 : 𝔹) → b1 nor b2 ≡ b2 nor b1 nand-comm : ∀ (b1 b2 : 𝔹) → b1 nand b2 ≡ b2 nand b1 -} ------------------------------------------------------------------------------ -- 3 z02-3a : tt ≡ tt z02-3a = refl z02-3b : ff ≡ ff z02-3b = refl -- NO z02-3c : ff ≡ tt z02-3d : ff && ff ≡ ~ tt z02-3d = refl z02-3e : ∀ (x : 𝔹) → tt && x ≡ x z02-3e _ = refl z02-3f : ∀ (x : 𝔹) → x && tt ≡ x z02-3f tt = refl z02-3f ff = refl
{ "alphanum_fraction": 0.4928746929, "avg_line_length": 26.6261682243, "ext": "agda", "hexsha": "27b1dba633d802f7f985bb2e090faa2c83c66f13", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z02-theorem-proving-with-booleans.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z02-theorem-proving-with-booleans.agda", "max_line_length": 99, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z02-theorem-proving-with-booleans.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 5283, "size": 14245 }
open import Nat open import Prelude open import dynamics-core open import contexts open import typed-elaboration open import lemmas-gcomplete open import lemmas-complete module complete-elaboration where mutual complete-elaboration-synth : ∀{e τ Γ Δ d} → Γ gcomplete → e ecomplete → Γ ⊢ e ⇒ τ ~> d ⊣ Δ → (d dcomplete × τ tcomplete × Δ == ∅) complete-elaboration-synth gc ec ESNum = DCNum , TCNum , refl complete-elaboration-synth gc (ECPlus ec₁ ec₂) (ESPlus {Δ1 = Δ1} {Δ2 = Δ2} apt dis x₁ x₂) with complete-elaboration-ana gc ec₁ TCNum x₁ | complete-elaboration-ana gc ec₂ TCNum x₂ ... | d1comp , t1comp , refl | d2comp , t2comp , refl = DCPlus (DCCast d1comp t1comp TCNum) (DCCast d2comp t2comp TCNum) , TCNum , refl complete-elaboration-synth gc ec (ESVar x₁) = DCVar , gc _ _ x₁ , refl complete-elaboration-synth gc (ECLam2 ec x₁) (ESLam x₂ exp) with complete-elaboration-synth (gcomp-extend gc x₁ x₂) ec exp ... | ih1 , ih2 , ih3 = DCLam ih1 x₁ , TCArr x₁ ih2 , ih3 complete-elaboration-synth gc (ECAp ec ec₁) (ESAp _ _ x MAHole x₂ x₃) with comp-synth gc ec x ... | () complete-elaboration-synth gc (ECAp ec ec₁) (ESAp {Δ1 = Δ1} {Δ2 = Δ2} _ _ x MAArr x₂ x₃) with comp-synth gc ec x ... | TCArr t1 t2 with complete-elaboration-ana gc ec (TCArr t1 t2) x₂ | complete-elaboration-ana gc ec₁ t1 x₃ ... | ih1 , _ , ih4 | ih2 , _ , ih3 = DCAp (DCCast ih1 (comp-ana gc x₂ ih1) (TCArr t1 t2)) (DCCast ih2 (comp-ana gc x₃ ih2) t1) , t2 , tr (λ qq → (qq ∪ Δ2) == ∅) (! ih4) (tr (λ qq → (∅ ∪ qq) == ∅) (! ih3) refl) complete-elaboration-synth gc () ESEHole complete-elaboration-synth gc () (ESNEHole _ exp) complete-elaboration-synth gc (ECAsc x ec) (ESAsc x₁) with complete-elaboration-ana gc ec x x₁ ... | ih1 , _ , ih2 = DCCast ih1 (comp-ana gc x₁ ih1) x , x , ih2 complete-elaboration-synth gc (ECPair ec ec₁) (ESPair {Δ1 = Δ1} {Δ2 = Δ2} x x₁ x₂ x₃) with complete-elaboration-synth gc ec x₂ | complete-elaboration-synth gc ec₁ x₃ ... | ih1 , ih2 , ih3 | ih1' , ih2' , ih3' = DCPair ih1 ih1' , TCProd ih2 ih2' , tr (λ qq → (qq ∪ Δ2) == ∅) (! ih3) ih3' complete-elaboration-synth gc (ECFst ec) (ESFst x MPHole x₂) with comp-synth gc ec x ... | () complete-elaboration-synth gc (ECFst ec) (ESFst x MPProd x₂) with comp-synth gc ec x ... | TCProd τc1 τc2 with complete-elaboration-ana gc ec (TCProd τc1 τc2) x₂ ... | ih1 , ih2 , ih3 = DCFst (DCCast ih1 ih2 (TCProd τc1 τc2)) , τc1 , ih3 complete-elaboration-synth gc (ECSnd ec) (ESSnd x MPHole x₂) with comp-synth gc ec x ... | () complete-elaboration-synth gc (ECSnd ec) (ESSnd x MPProd x₂) with comp-synth gc ec x ... | TCProd τc1 τc2 with complete-elaboration-ana gc ec (TCProd τc1 τc2) x₂ ... | ih1 , ih2 , ih3 = DCSnd (DCCast ih1 ih2 (TCProd τc1 τc2)) , τc2 , ih3 complete-elaboration-ana : ∀{e τ τ' Γ Δ d} → Γ gcomplete → e ecomplete → τ tcomplete → Γ ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ → (d dcomplete × τ' tcomplete × Δ == ∅) complete-elaboration-ana gc (ECLam1 ec) () (EALam x₁ MAHole exp) complete-elaboration-ana gc (ECLam1 ec) (TCArr t1 t2) (EALam x₁ MAArr exp) with complete-elaboration-ana (gcomp-extend gc t1 x₁) ec t2 exp ... | ih , ih3 , ih2 = DCLam ih t1 , TCArr t1 ih3 , ih2 complete-elaboration-ana gc ec tc (EASubsume x x₁ x₂ x₃) with complete-elaboration-synth gc ec x₂ ... | ih1 , ih2 , ih3 = ih1 , ih2 , ih3 complete-elaboration-ana gc (ECInl ec) (TCSum tc tc₁) (EAInl MSSum x₁) with complete-elaboration-ana gc ec tc x₁ ... | ih1 , ih2 , ih3 = DCInl tc₁ ih1 , TCSum ih2 tc₁ , ih3 complete-elaboration-ana gc (ECInr ec) (TCSum tc tc₁) (EAInr MSSum x₁) with complete-elaboration-ana gc ec tc₁ x₁ ... | ih1 , ih2 , ih3 = DCInr tc ih1 , TCSum tc ih2 , ih3 complete-elaboration-ana gc (ECCase ec ec₁ ec₂) tc (EACase x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ MSHole x₁₀ x₁₁) with complete-elaboration-synth gc ec x₈ ... | ih1 , () , ih3 complete-elaboration-ana gc (ECCase ec ec₁ ec₂) tc (EACase {Δ = Δ} {Δ1 = Δ1} {Δ2 = Δ2} x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ MSSum x₁₀ x₁₁) with complete-elaboration-synth gc ec x₈ ... | ih1 , TCSum ih2 ih4 , ih3 with complete-elaboration-ana (gcomp-extend gc ih2 x₆) ec₁ tc x₁₀ ... | ih1' , ih2' , ih3' with complete-elaboration-ana (gcomp-extend gc ih4 x₇) ec₂ tc x₁₁ ... | ih1'' , ih2'' , ih3'' = DCCase (DCCast ih1 (TCSum ih2 ih4) (TCSum ih2 ih4)) (DCCast ih1' ih2' tc) (DCCast ih1'' ih2'' tc) , tc , tr (λ qq → qq ∪ (Δ1 ∪ Δ2) == ∅) (! ih3) (tr (λ qq → ∅ ∪ (qq ∪ Δ2) == ∅) (! ih3') (tr (λ qq → ∅ ∪ (∅ ∪ qq) == ∅) (! ih3'') refl)) -- this is just a convenience since it shows up a few times above comp-ana : ∀{Γ e τ d τ' Δ} → Γ gcomplete → Γ ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ → d dcomplete → τ' tcomplete comp-ana gc ex dc = complete-ta gc (π2 (typed-elaboration-ana ex)) dc
{ "alphanum_fraction": 0.5772676372, "avg_line_length": 57.6129032258, "ext": "agda", "hexsha": "680b87d94e479f914450940f6c5c717bd70d31d6", "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": "complete-elaboration.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": "complete-elaboration.agda", "max_line_length": 268, "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": "complete-elaboration.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2039, "size": 5358 }
{-# OPTIONS --without-K #-} module hott.univalence where open import level using (lsuc) open import sum using (_,_ ; proj₁) open import equality.core open import equality.calculus open import equality.reasoning open import function.core open import function.isomorphism.core using (_≅_ ; module _≅_) open import hott.equivalence.core -- mapping from equality to function coerce : ∀ {i} {X Y : Set i} → X ≡ Y → X → Y coerce refl = id coerce-equiv : ∀ {i} {X Y : Set i} → (p : X ≡ Y) → weak-equiv (coerce p) coerce-equiv refl x = (x , refl) , λ { (.x , refl) → refl } coerce-hom : ∀ {i} {X Y Z : Set i} → (p : X ≡ Y)(q : Y ≡ Z) → coerce (p · q) ≡ coerce q ∘ coerce p coerce-hom refl q = refl -- mapping from propositional equality to weak equivalence ≡⇒≈ : ∀ {i} {X Y : Set i} → X ≡ Y → X ≈ Y ≡⇒≈ p = coerce p , coerce-equiv p Univalence : ∀ i → Set (lsuc i) Univalence i = {X Y : Set i} → weak-equiv $ ≡⇒≈ {X = X} {Y = Y} postulate univalence : ∀ {i} → Univalence i private module Properties {i} {X Y : Set i} where uni-equiv : (X ≡ Y) ≈ (X ≈ Y) uni-equiv = ≡⇒≈ , univalence uni-iso : (X ≡ Y) ≅ (X ≈ Y) uni-iso = ≈⇒≅ uni-equiv open _≅_ uni-iso public using () renaming (from to ≈⇒≡) uni-coherence : (f : X ≈ Y) → coerce (≈⇒≡ f) ≡ proj₁ f uni-coherence f = begin coerce (≈⇒≡ f) ≡⟨ refl ⟩ proj₁ (≡⇒≈ (≈⇒≡ f)) ≡⟨ ap proj₁ (iso₂ f) ⟩ proj₁ f ∎ where open ≡-Reasoning open _≅_ uni-iso using (iso₂) open Properties public
{ "alphanum_fraction": 0.5671834625, "avg_line_length": 27.1578947368, "ext": "agda", "hexsha": "c9860a0424b7fc81ca0442258fe77fbe1da0bcfa", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_path": "hott/univalence.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_path": "hott/univalence.agda", "max_line_length": 72, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "hott/univalence.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 586, "size": 1548 }
module Luau.Type where open import FFI.Data.Maybe using (Maybe; just; nothing; just-inv) open import Agda.Builtin.Equality using (_≡_; refl) open import Properties.Dec using (Dec; yes; no) open import Properties.Equality using (cong) open import FFI.Data.Maybe using (Maybe; just; nothing) data Type : Set where nil : Type _⇒_ : Type → Type → Type never : Type unknown : Type boolean : Type number : Type string : Type _∪_ : Type → Type → Type _∩_ : Type → Type → Type data Scalar : Type → Set where number : Scalar number boolean : Scalar boolean string : Scalar string nil : Scalar nil lhs : Type → Type lhs (T ⇒ _) = T lhs (T ∪ _) = T lhs (T ∩ _) = T lhs nil = nil lhs never = never lhs unknown = unknown lhs number = number lhs boolean = boolean lhs string = string rhs : Type → Type rhs (_ ⇒ T) = T rhs (_ ∪ T) = T rhs (_ ∩ T) = T rhs nil = nil rhs never = never rhs unknown = unknown rhs number = number rhs boolean = boolean rhs string = string _≡ᵀ_ : ∀ (T U : Type) → Dec(T ≡ U) nil ≡ᵀ nil = yes refl nil ≡ᵀ (S ⇒ T) = no (λ ()) nil ≡ᵀ never = no (λ ()) nil ≡ᵀ unknown = no (λ ()) nil ≡ᵀ number = no (λ ()) nil ≡ᵀ boolean = no (λ ()) nil ≡ᵀ (S ∪ T) = no (λ ()) nil ≡ᵀ (S ∩ T) = no (λ ()) nil ≡ᵀ string = no (λ ()) (S ⇒ T) ≡ᵀ string = no (λ ()) never ≡ᵀ string = no (λ ()) unknown ≡ᵀ string = no (λ ()) boolean ≡ᵀ string = no (λ ()) number ≡ᵀ string = no (λ ()) (S ∪ T) ≡ᵀ string = no (λ ()) (S ∩ T) ≡ᵀ string = no (λ ()) (S ⇒ T) ≡ᵀ nil = no (λ ()) (S ⇒ T) ≡ᵀ (U ⇒ V) with (S ≡ᵀ U) | (T ≡ᵀ V) (S ⇒ T) ≡ᵀ (S ⇒ T) | yes refl | yes refl = yes refl (S ⇒ T) ≡ᵀ (U ⇒ V) | _ | no p = no (λ q → p (cong rhs q)) (S ⇒ T) ≡ᵀ (U ⇒ V) | no p | _ = no (λ q → p (cong lhs q)) (S ⇒ T) ≡ᵀ never = no (λ ()) (S ⇒ T) ≡ᵀ unknown = no (λ ()) (S ⇒ T) ≡ᵀ number = no (λ ()) (S ⇒ T) ≡ᵀ boolean = no (λ ()) (S ⇒ T) ≡ᵀ (U ∪ V) = no (λ ()) (S ⇒ T) ≡ᵀ (U ∩ V) = no (λ ()) never ≡ᵀ nil = no (λ ()) never ≡ᵀ (U ⇒ V) = no (λ ()) never ≡ᵀ never = yes refl never ≡ᵀ unknown = no (λ ()) never ≡ᵀ number = no (λ ()) never ≡ᵀ boolean = no (λ ()) never ≡ᵀ (U ∪ V) = no (λ ()) never ≡ᵀ (U ∩ V) = no (λ ()) unknown ≡ᵀ nil = no (λ ()) unknown ≡ᵀ (U ⇒ V) = no (λ ()) unknown ≡ᵀ never = no (λ ()) unknown ≡ᵀ unknown = yes refl unknown ≡ᵀ number = no (λ ()) unknown ≡ᵀ boolean = no (λ ()) unknown ≡ᵀ (U ∪ V) = no (λ ()) unknown ≡ᵀ (U ∩ V) = no (λ ()) number ≡ᵀ nil = no (λ ()) number ≡ᵀ (T ⇒ U) = no (λ ()) number ≡ᵀ never = no (λ ()) number ≡ᵀ unknown = no (λ ()) number ≡ᵀ number = yes refl number ≡ᵀ boolean = no (λ ()) number ≡ᵀ (T ∪ U) = no (λ ()) number ≡ᵀ (T ∩ U) = no (λ ()) boolean ≡ᵀ nil = no (λ ()) boolean ≡ᵀ (T ⇒ U) = no (λ ()) boolean ≡ᵀ never = no (λ ()) boolean ≡ᵀ unknown = no (λ ()) boolean ≡ᵀ boolean = yes refl boolean ≡ᵀ number = no (λ ()) boolean ≡ᵀ (T ∪ U) = no (λ ()) boolean ≡ᵀ (T ∩ U) = no (λ ()) string ≡ᵀ nil = no (λ ()) string ≡ᵀ (x ⇒ x₁) = no (λ ()) string ≡ᵀ never = no (λ ()) string ≡ᵀ unknown = no (λ ()) string ≡ᵀ boolean = no (λ ()) string ≡ᵀ number = no (λ ()) string ≡ᵀ string = yes refl string ≡ᵀ (U ∪ V) = no (λ ()) string ≡ᵀ (U ∩ V) = no (λ ()) (S ∪ T) ≡ᵀ nil = no (λ ()) (S ∪ T) ≡ᵀ (U ⇒ V) = no (λ ()) (S ∪ T) ≡ᵀ never = no (λ ()) (S ∪ T) ≡ᵀ unknown = no (λ ()) (S ∪ T) ≡ᵀ number = no (λ ()) (S ∪ T) ≡ᵀ boolean = no (λ ()) (S ∪ T) ≡ᵀ (U ∪ V) with (S ≡ᵀ U) | (T ≡ᵀ V) (S ∪ T) ≡ᵀ (S ∪ T) | yes refl | yes refl = yes refl (S ∪ T) ≡ᵀ (U ∪ V) | _ | no p = no (λ q → p (cong rhs q)) (S ∪ T) ≡ᵀ (U ∪ V) | no p | _ = no (λ q → p (cong lhs q)) (S ∪ T) ≡ᵀ (U ∩ V) = no (λ ()) (S ∩ T) ≡ᵀ nil = no (λ ()) (S ∩ T) ≡ᵀ (U ⇒ V) = no (λ ()) (S ∩ T) ≡ᵀ never = no (λ ()) (S ∩ T) ≡ᵀ unknown = no (λ ()) (S ∩ T) ≡ᵀ number = no (λ ()) (S ∩ T) ≡ᵀ boolean = no (λ ()) (S ∩ T) ≡ᵀ (U ∪ V) = no (λ ()) (S ∩ T) ≡ᵀ (U ∩ V) with (S ≡ᵀ U) | (T ≡ᵀ V) (S ∩ T) ≡ᵀ (U ∩ V) | yes refl | yes refl = yes refl (S ∩ T) ≡ᵀ (U ∩ V) | _ | no p = no (λ q → p (cong rhs q)) (S ∩ T) ≡ᵀ (U ∩ V) | no p | _ = no (λ q → p (cong lhs q)) _≡ᴹᵀ_ : ∀ (T U : Maybe Type) → Dec(T ≡ U) nothing ≡ᴹᵀ nothing = yes refl nothing ≡ᴹᵀ just U = no (λ ()) just T ≡ᴹᵀ nothing = no (λ ()) just T ≡ᴹᵀ just U with T ≡ᵀ U (just T ≡ᴹᵀ just T) | yes refl = yes refl (just T ≡ᴹᵀ just U) | no p = no (λ q → p (just-inv q)) src : Type → Type src nil = never src number = never src boolean = never src string = never src (S ⇒ T) = S src (S ∪ T) = (src S) ∩ (src T) src (S ∩ T) = (src S) ∪ (src T) src never = unknown src unknown = never tgt : Type → Type tgt nil = never tgt (S ⇒ T) = T tgt never = never tgt unknown = unknown tgt number = never tgt boolean = never tgt string = never tgt (S ∪ T) = (tgt S) ∪ (tgt T) tgt (S ∩ T) = (tgt S) ∩ (tgt T) optional : Type → Type optional nil = nil optional (T ∪ nil) = (T ∪ nil) optional T = (T ∪ nil) normalizeOptional : Type → Type normalizeOptional (S ∪ T) with normalizeOptional S | normalizeOptional T normalizeOptional (S ∪ T) | (S′ ∪ nil) | (T′ ∪ nil) = (S′ ∪ T′) ∪ nil normalizeOptional (S ∪ T) | S′ | (T′ ∪ nil) = (S′ ∪ T′) ∪ nil normalizeOptional (S ∪ T) | (S′ ∪ nil) | T′ = (S′ ∪ T′) ∪ nil normalizeOptional (S ∪ T) | S′ | nil = optional S′ normalizeOptional (S ∪ T) | nil | T′ = optional T′ normalizeOptional (S ∪ T) | S′ | T′ = S′ ∪ T′ normalizeOptional T = T
{ "alphanum_fraction": 0.5179115854, "avg_line_length": 28.3675675676, "ext": "agda", "hexsha": "59d1107fcd84a5116bd6798e7e2af5cf7812d87c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5bb9f379b07e378db0a170e7c4030e3a943b2f14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MeltzDev/luau", "max_forks_repo_path": "prototyping/Luau/Type.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5bb9f379b07e378db0a170e7c4030e3a943b2f14", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MeltzDev/luau", "max_issues_repo_path": "prototyping/Luau/Type.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "5bb9f379b07e378db0a170e7c4030e3a943b2f14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MeltzDev/luau", "max_stars_repo_path": "prototyping/Luau/Type.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2377, "size": 5248 }
{-# OPTIONS --without-K --rewriting #-} module LogicalTopology where open import Basics open import lib.types.Truncation -- For convenience, we define the "power type" ℘ A ℘ : {i : ULevel} (j : ULevel) (A : Type i) → Type _ ℘ j A = A → Prop j _∩_ : {i j k : ULevel} {A : Type i} → ℘ j A → ℘ k A → ℘ _ A U ∩ V = λ a → (U a) ∧ (V a) _∪_ : ∀ {i j k} {A : Type i} → ℘ j A → ℘ k A → ℘ _ A P ∪ Q = λ a → (P a) ∨ (Q a) ⋃ : {i j : ULevel} {A : Type i} {I : Type j} (U : I → ℘ (lmax i j) A) → ℘ _ A ⋃ U = λ a → ∃ₚ λ i → (U i a) infix 30 _⊆_ _⊆_ : ∀ {i j k} {A : Type i} (P : ℘ j A) (Q : ℘ k A) → Prop _ _⊆_ {A = A} P Q = ∀ₚ \(a : A) → (P a) ⇒ (Q a) -- The definition of logically (Penon) open. _is-open : {i j : ULevel} {A : Type i} (U : ℘ j A) → Type (lmax i j) U is-open = ∀ x y → (p : (U x) holds) → ∥ (x ≠ y) ⊔ ((U y) holds) ∥ _is-closed : ∀ {i j} {A : Type i} (U : ℘ j A) → Type (lmax i j) C is-closed = (not ∘ C) is-open maps-are-cts : {i j k : ULevel} {A : Type i} {B : Type j} {f : A → B} {U : ℘ k B} (p : U is-open) → (U ∘ f) is-open maps-are-cts {A = A} {f = f} {U = U} p x y q = let[ p' ]:= (p (f x) (f y) q) in- [ (case₀ ⊔→ case₁) p' ] where case₀ : (f x ≠ f y) → x ≠ y case₀ ne p = ne (ap f p) case₁ : (U (f y)) holds → (U (f y)) holds case₁ z = z maps-are-cts-closed : {i j k : ULevel} {A : Type i} {B : Type j} {f : A → B} {C : ℘ k B} (p : C is-closed) → (C ∘ f) is-closed maps-are-cts-closed {C = C} = maps-are-cts {U = not ∘ C} unions-of-opens-are-open : {i j : ULevel} {A : Type i} {I : Type j} (U : I → ℘ _ A) (o : (i : I) → (U i) is-open) → (⋃ U) is-open unions-of-opens-are-open U o x y p = -- Supposing that x is in ⋃ U, let[ q ]:= p in- -- We know that x is in some particular U i (i ≡ fst q), so let[ z ]:= (o (fst q) x y (snd q)) in- -- we use the open-ness of U i to split into two cases [ z |> -- z : (x ≠ y) ⊔ (U i y) holds ((idf (x ≠ y)) -- Case₀: x already isn't y ⊔→ ((λ (w : U (fst q) y holds) → -- Case₁: y is in U i and therefore ⋃ U [ (fst q) , w ]))) ] _is-logically-connected : ∀ {i j} {A : Type i} (U : ℘ j A) → Prop _ _is-logically-connected {j = j} {A = A} U = ∀ₚ λ (P : ℘ j A) → (U ⊆ (P ∪ (not ∘ P))) ⇒ ((U ⊆ P) ∨ (U ⊆ not ∘ P)) _is-detachable : ∀ {i j} {A : Type i} (P : ℘ j A) → Prop _ _is-detachable {A = A} P = ∀ₚ λ (a : A) → (P a) ∨ (not $ P a) _is-inhabited : ∀ {i j} {A : Type i} (P : ℘ j A) → Prop _ _is-inhabited {A = A} P = ∃ₚ λ (a : A) → P a _is-logical-ctd-cmp : ∀ {i j} {A : Type i} (P : ℘ j A) → Prop _ P is-logical-ctd-cmp = (P is-inhabited) ∧ (P is-detachable) ∧ (P is-logically-connected)
{ "alphanum_fraction": 0.4164737016, "avg_line_length": 34.3522727273, "ext": "agda", "hexsha": "5a62c01b874300912204f0c3c928fd4973ac9671", "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": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "glangmead/formalization", "max_forks_repo_path": "cohesion/david_jaz_261/LogicalTopology.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "glangmead/formalization", "max_issues_repo_path": "cohesion/david_jaz_261/LogicalTopology.agda", "max_line_length": 99, "max_stars_count": 6, "max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "glangmead/formalization", "max_stars_repo_path": "cohesion/david_jaz_261/LogicalTopology.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z", "num_tokens": 1273, "size": 3023 }
{-# OPTIONS --copatterns --sized-types #-} {- In this module, we show that languages are represented by causal stream functions. To this end, let A be a non-empty set (the alphabet) and 2 the Booleans. For a stream s, we denote the list of the first n elements in s by s ↓ n and by s[n] the element at the n-th position of s. A function f : Aω → 2ω from streams over A to Boolean streams is _causal_, if for all natural numbers n : ℕ and streams s,t : Aω, if s ↓ n = t ↓ n implies that F(s)[n] = F(t)[n]. We denote by C(Aω,2ω) = {f : Aω → 2ω | F causal} the set of all causal stream functions. A _language_ is a subset of A⋆, the set of finite words over A. Thus the set of all languages over A is given by the function space A⋆ → 2. Now we can show that C(Aω,2ω) ≅ A⋆ → 2 by establishing an isomorphism α : (A⋆ → 2) → C(Aω,2ω) with its inverse β : C(Aω,2ω) → (A⋆ → 2). This explains, why the set of languages is the final coalgebra for the functor F = 2 × (A → Id). The coinductive extension of a coalgebra c : X → F X is thereby given by ĉ : X → C(Aω,2ω) (ĉ x s)[0] = c₁ x (ĉ x s)' = ĉ (c₂ x s[0]) s' where cᵢ = πᵢ ∘ c. -} module CausIsLang where open import Size open import Function open import Relation.Binary.PropositionalEquality as P using (_≡_; refl; sym; trans; cong; module ≡-Reasoning) open ≡-Reasoning open import Data.Bool using (Bool) open import Data.List open import Data.Nat open import Data.Product open import Stream -- Convenience ∥_∥ : ∀ {a} {A : Set a} → List A → ℕ ∥ l ∥ = length l _⋆ : Set → Set A ⋆ = List A ε : ∀{A} → A ⋆ ε = [] -- Non-empty sets record NonEmptyS (A : Set) : Set where field x : A -- | Causal stream functions record Causal (A B : Set) : Set where field F : Stream {∞} A → Stream {∞} B caus : ∀ {n : ℕ} {s t : Stream A} → s ↓ (1 + n) ≡ t ↓ (1 + n) → (F s) at n ≡ (F t) at n record IsCaus {A B : Set} (f : Stream A → Stream B) : Set where coinductive field out : ∀ {s t} → hd s ≡ hd t → hd (f s) ≡ hd (f t) × (IsCaus (λ x → tl (f(scons (hd s) x)))) open IsCaus public foo : ∀{A : Set} {x y : A} {u v : List A} → _≡_ {A = List A} (x ∷ u) (y ∷ v) → x ≡ y foo refl = refl bar : ∀{A : Set} {x y : A} {u v : List A} → _≡_ {A = List A} (x ∷ u) (y ∷ v) → u ≡ v bar refl = refl -- Cheat! postulate baz : ∀{A} (s : Stream A) → s ≡ scons (hd s) (tl s) lem : ∀{A B} {f : Stream A → Stream B} → IsCaus f → ∀ {n s t} → s ↓ (1 + n) ≡ t ↓ (1 + n) → (f s) at n ≡ (f t) at n lem caus {zero} sn=tn = proj₁ (IsCaus.out caus (foo sn=tn)) lem caus {suc n} {s} {t} sn=tn with IsCaus.out caus {s} {t} (foo sn=tn) lem {f = f} caus {suc n} {s} {t} sn=tn | p , q = let r = q u = bar sn=tn v = lem r u in begin tl (f s) at n ≡⟨ cong (λ x → tl (f x) at n) (baz s) ⟩ tl (f (scons (hd s) (tl s))) at n ≡⟨ v ⟩ tl (f (scons (hd s) (tl t))) at n ≡⟨ cong (λ x → tl (f (scons x (tl t))) at n) (foo sn=tn) ⟩ tl (f (scons (hd t) (tl t))) at n ≡⟨ cong (λ x → tl (f x) at n) (sym (baz t)) ⟩ tl (f t) at n ∎ lem₂ : ∀{A B} {f : Stream A → Stream B} → (∀ {n s t} → s ↓ (1 + n) ≡ t ↓ (1 + n) → (f s) at n ≡ (f t) at n) → IsCaus f out (lem₂ p) q = p {0} (cong (λ x → x ∷ []) q) , lem₂ {!x!} lang-to-caus : ∀{A} → (A ⋆ → Bool) → (Stream A → Stream Bool) hd (lang-to-caus L s) = L ε tl (lang-to-caus L s) = lang-to-caus (λ w → L (hd s ∷ w)) (tl s) lang-to-caus-explicit : ∀{A} {L : A ⋆ → Bool} {s : Stream A} → (n : ℕ) → (lang-to-caus L s) at n ≡ L(s ↓ n) lang-to-caus-explicit zero = refl lang-to-caus-explicit {A} {L} {s} (suc n) = begin (lang-to-caus L s) at (suc n) ≡⟨ refl ⟩ hd (δ (suc n) (lang-to-caus L s)) ≡⟨ refl ⟩ hd (δ n (tl (lang-to-caus L s))) ≡⟨ refl ⟩ hd (δ n (lang-to-caus (λ w → L (hd s ∷ w)) (tl s))) ≡⟨ refl ⟩ (lang-to-caus (λ w → L (hd s ∷ w)) (tl s)) at n ≡⟨ lang-to-caus-explicit n ⟩ (λ w → L (hd s ∷ w))((tl s) ↓ n) ≡⟨ refl ⟩ L (hd s ∷ ((tl s) ↓ n)) ≡⟨ refl ⟩ L (s ↓ (suc n)) ∎ lang-to-caus-is-causal : ∀{A} {L : A ⋆ → Bool} → ∀ {n : ℕ} {s t : Stream A} → s ↓ n ≡ t ↓ n → (lang-to-caus L s) at n ≡ (lang-to-caus L t) at n lang-to-caus-is-causal {A} {L} {n} {s} {t} p = begin (lang-to-caus L s) at n ≡⟨ lang-to-caus-explicit n ⟩ L(s ↓ n) ≡⟨ cong (λ u → L u) p ⟩ L(t ↓ n) ≡⟨ sym (lang-to-caus-explicit n) ⟩ (lang-to-caus L t) at n ∎ -- Isomorphisms between languages and causal stream transformations α : ∀{A} → (A ⋆ → Bool) → (Causal A Bool) α L = record { F = lang-to-caus L ; caus = lang-to-caus-is-causal } β : ∀{A} {p : NonEmptyS A} → (Causal A Bool) → (A ⋆ → Bool) β {A} {p} F′ w = let open Causal F′ in F (w ++ˢ repeat (NonEmptyS.x p)) at ∥ w ∥ lemma-restr-extension-to-length-is-id : ∀ {A} {s : Stream A} (w : A ⋆) → (w ++ˢ s) ↓ ∥ w ∥ ≡ w lemma-restr-extension-to-length-is-id [] = refl lemma-restr-extension-to-length-is-id {A} {s} (a ∷ w) = begin ((a ∷ w) ++ˢ s) ↓ ∥ a ∷ w ∥ ≡⟨ refl ⟩ ((a ∷ w) ++ˢ s) ↓ (suc ∥ w ∥) ≡⟨ refl ⟩ (hd ((a ∷ w) ++ˢ s)) ∷ ((tl ((a ∷ w) ++ˢ s)) ↓ ∥ w ∥) ≡⟨ refl ⟩ a ∷ ((tl ((a ∷ w) ++ˢ s)) ↓ ∥ w ∥) ≡⟨ refl ⟩ a ∷ ((w ++ˢ s) ↓ ∥ w ∥) ≡⟨ cong (λ u → a ∷ u) (lemma-restr-extension-to-length-is-id w) ⟩ a ∷ w ∎ {- lemma-β-indep-of-choice : ∀ {A} {F′ : Causal A Bool} {p q : NonEmptyS A} {w : A ⋆} → β {A} {p} F′ w ≡ β {A} {q} F′ w lemma-β-indep-of-choice {A} {F′} {p} {q} {w} = let open Causal F′ n = ∥ w ∥ x = NonEmptyS.x p y = NonEmptyS.x q in begin β {A} {p} F′ w ≡⟨ refl ⟩ F (w ++ˢ repeat x) at n ≡⟨ caus {n} {(w ++ˢ repeat x)} {(w ++ˢ repeat y)} (trans (lemma-restr-extension-to-length-is-id w) (sym (lemma-restr-extension-to-length-is-id w))) ⟩ F (w ++ˢ repeat y) at n ≡⟨ refl ⟩ β {A} {q} F′ w ∎ lang-iso-caus→ : ∀{A} {p : NonEmptyS A} {L : A ⋆ → Bool} (w : A ⋆) → β {A} {p} (α L) w ≡ L w lang-iso-caus→ [] = refl lang-iso-caus→ {A} {p} {L} (a ∷ w) = let F′ = α L F = Causal.F F′ n = ∥ w ∥ x = NonEmptyS.x p s = (a ∷ w) ++ˢ repeat x K = (λ w → L (hd s ∷ w)) G′ = α K G = Causal.F G′ in begin β F′ (a ∷ w) ≡⟨ refl ⟩ F ((a ∷ w) ++ˢ repeat x) at (suc n) ≡⟨ refl ⟩ F s at (suc n) ≡⟨ refl ⟩ lang-to-caus L s at (suc n) ≡⟨ refl ⟩ hd (δ (suc n) (lang-to-caus L s)) ≡⟨ refl ⟩ hd (δ n (tl (lang-to-caus L s))) ≡⟨ refl ⟩ tl (lang-to-caus L s) at n ≡⟨ refl ⟩ lang-to-caus (λ w → L (hd s ∷ w)) (tl s) at n ≡⟨ refl ⟩ G (tl s) at n ≡⟨ refl ⟩ G (w ++ˢ repeat x) at n ≡⟨ refl ⟩ β G′ w ≡⟨ refl ⟩ β (α K) w ≡⟨ lang-iso-caus→ w ⟩ K w ≡⟨ refl ⟩ L (a ∷ w) ∎ -- This doesn't work as long as we don't have a notion of causality -- that does not depend on explicit indexing. {- .lang-iso-caus← : ∀{A} {x : A} {F′ : Causal A Bool} (s : Stream A) → Causal.F (α (β x F′)) s ∼ˢ Causal.F F′ s hd≡ (lang-iso-caus← {A} {x} {F′} s) = let F = Causal.F F′ L = β x F′ G′ = α L G = Causal.F G′ in begin hd (G s) ≡⟨ refl ⟩ hd (lang-to-caus L s) ≡⟨ refl ⟩ L ε ≡⟨ refl ⟩ F (ε ++ˢ repeat x) at ∥ ε {A} ∥ ≡⟨ refl ⟩ F (repeat x) at 0 ≡⟨ refl ⟩ F (repeat x) at 0 ≡⟨ Causal.caus F′ {0} {repeat x} {s} refl ⟩ F s at 0 ≡⟨ refl ⟩ hd (F s) ∎ tl∼ (lang-iso-caus← {A} {x} {F′} s) = let F = Causal.F F′ L = β x F′ G′ = α L G = Causal.F G′ K = (λ w → L (hd s ∷ w)) in beginˢ tl (G s) ∼ˢ⟨ s-bisim-refl ⟩ tl (lang-to-caus L s) ∼ˢ⟨ s-bisim-refl ⟩ lang-to-caus (λ w → L (hd s ∷ w)) (tl s) ∼ˢ⟨ s-bisim-refl ⟩ lang-to-caus K (tl s) ∼ˢ⟨ s-bisim-refl ⟩ Causal.F (α K) (tl s) ∼ˢ⟨ {!!} ⟩ tl (F s) ∎ˢ -} lemma-length-restr : ∀ {A} {s : Stream A} (n : ℕ) → ∥ (s ↓ n) ∥ ≡ n lemma-length-restr zero = refl lemma-length-restr {A} {s} (suc n) = begin ∥ (s ↓ (suc n)) ∥ ≡⟨ refl ⟩ ∥ hd s ∷ ((tl s) ↓ n) ∥ ≡⟨ refl ⟩ suc ∥ (tl s) ↓ n ∥ ≡⟨ cong (λ u → suc u) (lemma-length-restr n) ⟩ suc n ∎ lang-iso-caus← : ∀ {A} {p : NonEmptyS A} {F′ : Causal A Bool} {s : Stream A} (n : ℕ) → Causal.F (α (β F′)) s at n ≡ Causal.F F′ s at n lang-iso-caus← {A} {p} {F′} {s} n = let F = Causal.F F′ L = β F′ in begin Causal.F (α L) s at n ≡⟨ refl ⟩ lang-to-caus L s at n ≡⟨ lang-to-caus-explicit n ⟩ L (s ↓ n) ≡⟨ refl ⟩ F ((s ↓ n) ++ˢ repeat x) at ∥ s ↓ n ∥ ≡⟨ Causal.caus F′ {∥ s ↓ n ∥} {(s ↓ n) ++ˢ repeat x} {s} lemma-restr-ext ⟩ F s at ∥ (s ↓ n) ∥ ≡⟨ cong (λ u → F s at u) (lemma-length-restr n) ⟩ F s at n ∎ where x = NonEmptyS.x p lemma-restr-ext : ((s ↓ n) ++ˢ repeat x) ↓ ∥ s ↓ n ∥ ≡ s ↓ ∥ s ↓ n ∥ lemma-restr-ext = begin ((s ↓ n) ++ˢ repeat x) ↓ ∥ s ↓ n ∥ ≡⟨ lemma-restr-extension-to-length-is-id (s ↓ n) ⟩ s ↓ n ≡⟨ cong (λ u → s ↓ u) (sym (lemma-length-restr n)) ⟩ s ↓ ∥ s ↓ n ∥ ∎ -}
{ "alphanum_fraction": 0.4785869565, "avg_line_length": 26.1363636364, "ext": "agda", "hexsha": "3e7f769c48225c8bae6daf68605978fcad62c3eb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "Languages/CausIsLang.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "Languages/CausIsLang.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "Languages/CausIsLang.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4188, "size": 9200 }
{- Conatural number properties (Tesla Ice Zhang et al., Feb. 2019) This file defines operations and properties on conatural numbers: - Infinity (∞). - Proof that ∞ + 1 is equivalent to ∞. - Proof that conatural is an hSet. - Bisimulation on conatural - Proof that bisimulation is equivalent to equivalence (Coinductive Proof Principle). - Proof that this bisimulation is prop valued The standard library also defines bisimulation on conaturals: https://github.com/agda/agda-stdlib/blob/master/src/Codata/Conat/Bisimilarity.agda -} {-# OPTIONS --safe --guardedness #-} module Cubical.Codata.Conat.Properties where open import Cubical.Data.Unit open import Cubical.Data.Sum open import Cubical.Data.Sigma open import Cubical.Data.Empty as ⊥ open import Cubical.Data.Bool renaming (Bool→Type to ⟨_⟩) import Cubical.Data.Nat as Nat import Cubical.Data.Nat.Order.Recursive as Nat open import Cubical.Core.Everything open import Cubical.Functions.Embedding open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Path open import Cubical.Foundations.Transport open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Relation.Nullary open import Cubical.Codata.Conat.Base import Cubical.Axiom.Omniscience as Omni Unwrap-prev : Conat′ → Type₀ Unwrap-prev zero = Unit Unwrap-prev (suc _) = Conat unwrap-prev : (n : Conat′) -> Unwrap-prev n unwrap-prev zero = _ unwrap-prev (suc x) = x private -- tests 𝟘 = conat zero 𝟙 = succ 𝟘 𝟚 = succ 𝟙 succ𝟙≡𝟚 : succ 𝟙 ≡ 𝟚 succ𝟙≡𝟚 i = 𝟚 pred𝟚≡𝟙 : unwrap-prev (force 𝟚) ≡ 𝟙 pred𝟚≡𝟙 i = 𝟙 ∞ : Conat force ∞ = suc ∞ ∞+1≡∞ : succ ∞ ≡ ∞ force (∞+1≡∞ _) = suc ∞ ∞+2≡∞ : succ (succ ∞) ≡ ∞ ∞+2≡∞ = (cong succ ∞+1≡∞) ∙ ∞+1≡∞ _+_ : Conat → Conat → Conat _+′_ : Conat′ → Conat → Conat′ force (x + y) = force x +′ y zero +′ y = force y suc x +′ y = suc (x + y) n+∞≡∞ : ∀ n → n + ∞ ≡ ∞ n+′∞≡∞′ : ∀ n → n +′ ∞ ≡ suc ∞ force (n+∞≡∞ n i) = n+′∞≡∞′ (force n) i n+′∞≡∞′ zero = refl n+′∞≡∞′ (suc n) = λ i → suc (n+∞≡∞ n i) ∞+∞≡∞ : ∞ + ∞ ≡ ∞ force (∞+∞≡∞ i) = suc (∞+∞≡∞ i) +-zeroˡ : ∀ n → 𝟘 + n ≡ n force (+-zeroˡ n _) = force n +-zeroʳ : ∀ n → n + 𝟘 ≡ n +′-zeroʳ : ∀ n → n +′ 𝟘 ≡ n force (+-zeroʳ n i) = +′-zeroʳ (force n) i +′-zeroʳ zero _ = zero +′-zeroʳ (suc n) i = suc (+-zeroʳ n i) +-assoc : ∀ m n p → (m + n) + p ≡ m + (n + p) +′-assoc : ∀ m n p → (m +′ n) +′ p ≡ m +′ (n + p) force (+-assoc m n p i) = +′-assoc (force m) n p i +′-assoc zero _ _ = refl +′-assoc (suc m) n p i = suc (+-assoc m n p i) conat-absurd : ∀ {y : Conat} {ℓ} {Whatever : Type ℓ} → zero ≡ suc y → Whatever conat-absurd eq = ⊥.rec (transport (cong diag eq) tt) where diag : Conat′ → Type₀ diag zero = Unit diag (suc _) = ⊥ embed : Nat.ℕ → Conat embed Nat.zero .force = zero embed (Nat.suc n) .force = suc (embed n) embed-inj : ∀ m n → embed m ≡ embed n → m ≡ n embed-inj m n p with ⊎Path.encode _ _ (cong force p) embed-inj Nat.zero Nat.zero _ | _ = refl embed-inj (Nat.suc m) (Nat.suc n) _ | lift q = cong Nat.suc (embed-inj m n q) embed≢∞ : ∀ n → embed n ≡ ∞ → ⊥ embed≢∞ Nat.zero = lower ∘ ⊎Path.encode _ _ ∘ cong force embed≢∞ (Nat.suc n) = embed≢∞ n ∘ lower ∘ ⊎Path.encode _ _ ∘ cong force cover : Nat.ℕ → Conat cover Nat.zero = ∞ cover (Nat.suc n) = embed n cover-inj : ∀ m n → cover m ≡ cover n → m ≡ n cover-inj Nat.zero Nat.zero _ = refl cover-inj (Nat.suc m) (Nat.suc n) p = cong Nat.suc (embed-inj m n p) cover-inj Nat.zero (Nat.suc n) = ⊥.rec ∘ embed≢∞ n ∘ sym cover-inj (Nat.suc m) Nat.zero = ⊥.rec ∘ embed≢∞ m module IsSet where ≡-stable : {x y : Conat} → Stable (x ≡ y) ≡′-stable : {x y : Conat′} → Stable (x ≡ y) force (≡-stable ¬¬p i) = ≡′-stable (λ ¬p → ¬¬p (λ p → ¬p (cong force p))) i ≡′-stable {zero} {zero} ¬¬p′ = refl ≡′-stable {suc x} {suc y} ¬¬p′ = cong′ suc (≡-stable λ ¬p → ¬¬p′ λ p → ¬p (cong pred′′ p)) ≡′-stable {zero} {suc y} ¬¬p′ = ⊥.rec (¬¬p′ conat-absurd) ≡′-stable {suc x} {zero} ¬¬p′ = ⊥.rec (¬¬p′ λ p → conat-absurd (sym p)) isSetConat : isSet Conat isSetConat _ _ = Separated→isSet (λ _ _ → ≡-stable) _ _ isSetConat′ : isSet Conat′ isSetConat′ m n p′ q′ = cong (cong force) (isSetConat (conat m) (conat n) p q) where p = λ where i .force → p′ i q = λ where i .force → q′ i module Bisimulation where open IsSet using (isSetConat) record _≈_ (x y : Conat) : Type₀ data _≈′_ (x y : Conat′) : Type₀ _≈′′_ : Conat′ → Conat′ → Type₀ zero ≈′′ zero = Unit suc x ≈′′ suc y = x ≈ y -- So impossible proofs are preserved x ≈′′ y = ⊥ record _≈_ x y where coinductive field prove : force x ≈′ force y data _≈′_ x y where con : x ≈′′ y → x ≈′ y open _≈_ public bisim : ∀ {x y} → x ≈ y → x ≡ y bisim′ : ∀ {x y} → x ≈′ y → x ≡ y bisim′ {zero} {zero} (con tt) = refl bisim′ {zero} {suc x} (con ()) bisim′ {suc x} {zero} (con ()) bisim′ {suc x} {suc y} (con eq) i = suc (bisim eq i) force (bisim eq i) = bisim′ (prove eq) i misib : ∀ {x y} → x ≡ y → x ≈ y misib′ : ∀ {x y} → x ≡ y → x ≈′ y misib′ {zero} {zero} _ = con tt misib′ {zero} {suc x} = conat-absurd misib′ {suc x} {zero} p = conat-absurd (sym p) -- misib′ {suc x} {suc y} p = con λ where .prove → misib′ (cong pred′ p) misib′ {suc x} {suc y} p = con (misib (cong pred′′ p)) prove (misib x≡y) = misib′ (cong force x≡y) iso″ : ∀ {x y} → (p : x ≈ y) → misib (bisim p) ≡ p iso′ : ∀ {x y} → (p : x ≈′ y) → misib′ (bisim′ p) ≡ p iso′ {zero} {zero} (con p) = refl iso′ {zero} {suc x} (con ()) iso′ {suc x} {zero} (con ()) iso′ {suc x} {suc y} (con p) = cong con (iso″ p) prove (iso″ p i) = iso′ (prove p) i osi : ∀ {x y} → (p : x ≡ y) → bisim (misib p) ≡ p osi p = isSetConat _ _ _ p path≃bisim : ∀ {x y} → (x ≡ y) ≃ (x ≈ y) path≃bisim = isoToEquiv (iso misib bisim iso″ osi) path≡bisim : ∀ {x y} → (x ≡ y) ≡ (x ≈ y) path≡bisim = ua path≃bisim isProp≈ : ∀ {x y} → isProp (x ≈ y) isProp≈ = subst isProp path≡bisim (isSetConat _ _) module WLPO where -- search a decidable predicate on ℕ for the first true search : (Nat.ℕ → Bool) → Conat search′ : (Nat.ℕ → Bool) → Bool → Conat′ search f .force = search′ f (f 0) search′ _ true = zero search′ f false = suc (search (f ∘ Nat.suc)) -- the constantly false predicate searches to ∞ search-false : search (const false) ≡ ∞ search-false i .force = suc (search-false i) wrap : Conat′ → Conat wrap zero = ∞ wrap (suc m) = m search-lemma : ∀ α n → search α ≡ ∞ → α n ≡ false search-lemma α Nat.zero p with α 0 | cong force p ... | false | q = refl ... | true | q = ⊥.rec (⊎Path.encode zero (suc ∞) q .lower) search-lemma α (Nat.suc n) p with α 0 | cong force p ... | false | q = search-lemma (α ∘ Nat.suc) n (cong wrap q) ... | true | q = ⊥.rec (⊎Path.encode zero (suc ∞) q .lower) search-n : ∀ α n → search α ≡ embed n → α n ≡ true search-n α Nat.zero p with α 0 | ⊎Path.encode _ _ (cong force p) ... | true | _ = refl search-n α (Nat.suc n) p with α 0 | ⊎Path.encode _ _ (cong force p) ... | false | q = search-n (α ∘ Nat.suc) n (q .lower) module _ (f : Conat → Nat.ℕ) (emb : isEmbedding f) where discreteConat : Discrete Conat discreteConat = Embedding-into-Discrete→Discrete (f , emb) Nat.discreteℕ wlpo' : Omni.WLPO' Nat.ℕ wlpo' α with discreteConat (search α) ∞ ... | yes p = yes λ i n → search-lemma α n p i ... | no ¬p = no (¬p ∘ _∙ search-false ∘ cong search) module LPO where open WLPO using (search; search-lemma; search-n) module Un (uncover : Conat → Nat.ℕ) (sect : section cover uncover) where search-0 : ∀ α → uncover (search α) ≡ 0 → ∀ n → α n ≡ false search-0 α p n = search-lemma α n (sym (sect (search α)) ∙ cong cover p) search-n' : ∀ α n → uncover (search α) ≡ Nat.suc n → α n ≡ true search-n' α n p = search-n α n (sym (sect (search α)) ∙ cong cover p) -- So, surjectivity of `cover` implies LPO, since `cover` has -- already been shown injective, and surjectivity would make it an -- equivalence (as ℕ and Conat are sets). lpo' : Omni.LPO∞ Nat.ℕ lpo' α = disc (uncover (search α)) refl where disc : ∀ n → uncover (search α) ≡ n → _ disc Nat.zero p = inl λ n → subst ⟨_⟩ (search-0 α p n) disc (Nat.suc n) p = inr (n , subst⁻ ⟨_⟩ (search-n' α n p) _)
{ "alphanum_fraction": 0.588082289, "avg_line_length": 29.2664359862, "ext": "agda", "hexsha": "4e099b9292cb45557c3d5d0a15441822c646dd8b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Codata/Conat/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Codata/Conat/Properties.agda", "max_line_length": 82, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Codata/Conat/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 3540, "size": 8458 }
{-# OPTIONS --universe-polymorphism #-} module PatternMatchingOnCodata where data Level : Set where zero : Level suc : (i : Level) → Level _⊔_ : Level → Level → Level zero ⊔ j = j suc i ⊔ zero = suc i suc i ⊔ suc j = suc (i ⊔ j) {-# BUILTIN LEVEL Level #-} {-# BUILTIN LEVELZERO zero #-} {-# BUILTIN LEVELSUC suc #-} {-# BUILTIN LEVELMAX _⊔_ #-} infix 1000 ♯_ {-# BUILTIN INFINITY ∞ #-} {-# BUILTIN SHARP ♯_ #-} {-# BUILTIN FLAT ♭ #-} my-♭ : ∀ {a} {A : Set a} → ∞ A → A my-♭ (♯ x) = x
{ "alphanum_fraction": 0.5430210325, "avg_line_length": 19.3703703704, "ext": "agda", "hexsha": "84f40754e2c27dc7f71575c6ca0586cb3f15ad7a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Fail/PatternMatchingOnCodata.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Fail/PatternMatchingOnCodata.agda", "max_line_length": 39, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Fail/PatternMatchingOnCodata.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-07T10:49:57.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-07T10:49:57.000Z", "num_tokens": 196, "size": 523 }
module lemmas where open import prelude open import defns postulate NH-CONG : ∀ {D} (H H′ : NavigationHistory(D)) → let open NavigationHistory H in let open NavigationHistory H′ using () renaming ( A to A′ ; Fo to Fo′ ; Eq to Eq′ ; FTO to FTO′ ) in (A ⊆ A′) → (A′ ⊆ A) → (Fo ≣ Fo′) → (Eq ≣ Eq′) → (FTO ≣ FTO′) → (H ≣ H′) BT-hd : ∀ {D} {H : NavigationHistory(D)} {n} d (ds : D ^ n) → ((d ∷ ds) ∈ BackTarget*(H)) → (d ∈ BackTarget(H)) BT-hd {D} {H} {n} d ds d∷ds∈BT with Max-hd ((A ∪ JointSessionPast) ∩ CanGoBack) d ds d∷ds∈BT where open NavigationHistory H BT-hd {D} {H} {n} d ds d∷ds∈BT | ((in₁ d∈A , d∈CGB), d-max′) = ((d∈A , d∈CGB) , d-max) where open NavigationHistory H d-max : ∀ e → (e ∈ (A ∩ CanGoBack) → (e ≤ d)) d-max e (e∈A , e∈CGB) = d-max′ e ((in₁ e∈A) , e∈CGB) BT-hd {D} {H} {n} d ds d∷ds∈BT | ((in₂ (a , (a∈A , (d<a , d~a))) , d∈CGB), d-max) = contradiction (<-impl-≱ d<a (d-max a ((in₁ a∈A) , (d , (d<a , d~a))))) where open NavigationHistory H BT-tl : ∀ {D} {H : NavigationHistory(D)} {n} d d∈CGB (ds : D ^ n) → ((d ∷ ds) ∈ BackTarget*(H)) → (ds ∈ BackTarget*(H traverse-from d ∵ d∈CGB)) BT-tl {D} {H} {n} d d∈CGB ds d∷ds∈BT with Max-tl ((A ∪ JointSessionPast) ∩ CanGoBack) d ds d∷ds∈BT where open NavigationHistory H BT-tl {D} {H} {n} d d∈CGB ds d∷ds∈BT | ((d>ds , (ds↓ , ds∈BT′)) , ds-max′) with max(SessionPast(d)) ∵ d∈CGB where open NavigationHistory H BT-tl {D} {H} {n} d d∈CGB ds d∷ds∈BT | ((d>ds , (ds↓ , ds∈BT′)) , ds-max′) | (c , ((c<d , c~d) , c-max)) = ((ds↓ , ds∈BT) , ds-max) where open NavigationHistory H open NavigationHistory (H traverse-to c) using () renaming (A to A′ ; JointSessionPast to JointSessionPast′) d∈A : (d ∈ A) d∈A with BT-hd {H = H} d ds d∷ds∈BT d∈A | ((d∈A , _) , _) = d∈A d-max : ∀ e → (e ∈ (A ∩ CanGoBack) → (e ≤ d)) d-max with BT-hd {H = H} d ds d∷ds∈BT d-max | ((_ , _) , d-max) = d-max lemma : (Past(d) ∩ ((A ∪ JointSessionPast) ∩ CanGoBack)) ⊆ ((A′ ∪ JointSessionPast′) ∩ CanGoBack) lemma e (e<d , (_ , e∈CGB)) with c ~? e lemma e (e<d , (_ , e∈CGB)) | in₁ c~e with ≤-total c e lemma e (e<d , (_ , e∈CGB)) | in₁ c~e | in₁ c≤e with ≤-asym c≤e (c-max e (e<d , ~-trans (~-sym c~e) c~d)) lemma ._ (e<d , (_ , e∈CGB)) | in₁ c~e | in₁ c≤e | refl = ((in₁ (in₂ refl)) , e∈CGB) lemma e (e<d , (_ , e∈CGB)) | in₁ c~e | in₂ e<c = (in₂ (_ , (in₂ refl , (e<c , ~-sym c~e))) , e∈CGB) lemma e (e<d , (in₁ e∈A , e∈CGB)) | in₂ c≁e = ((in₁ (in₁ (c≁e , e∈A))) , e∈CGB) lemma e (e<d , (in₂ (a , (a∈A , (e<a , e~a))) , e∈CGB)) | in₂ c≁e = (in₂ (a , (in₁ ((λ c~a → c≁e (~-trans c~a (~-sym e~a))) , a∈A) , (e<a , e~a))) , e∈CGB) lemma′ : ((A′ ∪ JointSessionPast′) ∩ CanGoBack) ⊆ ((A ∪ JointSessionPast) ∩ CanGoBack) lemma′ e (in₁ (in₁ (c≁e , e∈A)) , e∈CGB) = ((in₁ e∈A) , e∈CGB) lemma′ ._ (in₁ (in₂ refl) , c∈CGB) = ((in₂ (d , (d∈A , (c<d , c~d)))) , c∈CGB) lemma′ e (in₂ (a , (in₁ (c≁a , a∈A) , e≲a)) , e∈CGB) = (in₂ (a , (a∈A , e≲a)) , e∈CGB) lemma′ e (in₂ (._ , (in₂ refl , e≲c)) , e∈CGB) = ((in₂ (d , (d∈A , ≲-trans e≲c (c<d , c~d)))) , e∈CGB) lemma″ : ((A′ ∪ JointSessionPast′) ∩ CanGoBack) ⊆ (Past(d)) lemma″ e (in₁ (in₁ (c≁e , e∈A)) , e∈CGB) = (d-max e (e∈A , e∈CGB) , (λ e≡d → c≁e (~-trans c~d (≡-impl-~ (sym e≡d))))) lemma″ ._ (in₁ (in₂ refl) , c∈CGB) = c<d lemma″ e (in₂ (a , (in₁ (c≁a , a∈A) , e≲a)) , e∈CGB) = <-trans-≤ (≲-impl-< e≲a) (d-max a (a∈A , (e , e≲a))) lemma″ e (in₂ (._ , (in₂ refl , (e<c , e~c))) , e∈CGB) = <-trans e<c c<d ds∈BT : ds ∈ All((A′ ∪ JointSessionPast′) ∩ CanGoBack) ds∈BT = All-resp-⊆ lemma ds (All-resp-∩ ds (d>ds , ds∈BT′)) ds-max : ∀ es → (es ∈ (Decreasing ∩ All((A′ ∪ JointSessionPast′) ∩ CanGoBack))) → (es ≤* ds) ds-max es (es↓ , es∈BT′) = ds-max′ es (All-resp-⊆ lemma″ es es∈BT′ , (es↓ , All-resp-⊆ lemma′ es es∈BT′)) BT-nil : ∀ {D} {H : NavigationHistory(D)} → (nil ∈ BackTarget*(H)) BT-nil = ((tt , tt) , λ { nil (tt , tt) → tt }) BT-cons : ∀ {D} {H : NavigationHistory(D)} {n} d d∈CGB (ds : D ^ n) → (d ∈ BackTarget(H)) → (ds ∈ BackTarget*(H traverse-from d ∵ d∈CGB)) → ((d ∷ ds) ∈ BackTarget*(H)) BT-cons {D} {H} d d∈CGB ds ((d∈A , _) , d-max) ((ds↓ , ds∈JSP′∩CGB) , ds-max) with max(SessionPast(d)) ∵ d∈CGB where open NavigationHistory H BT-cons {D} {H} d d∈CGB ds ((d∈A , _) , d-max) ((ds↓ , ds∈JSP′∩CGB) , ds-max) | (c , ((c<d , c~d) , c-max)) = (((d<ds , ds↓) , (((in₁ d∈A) , d∈CGB) , All-resp-⊆ lemma′ ds ds∈JSP′∩CGB)) , d∷ds-max) where open NavigationHistory H open NavigationHistory (H traverse-to c) using () renaming (A to A′ ; JointSessionPast to JointSessionPast′) lemma : (Past(d) ∩ ((A ∪ JointSessionPast) ∩ CanGoBack)) ⊆ ((A′ ∪ JointSessionPast′) ∩ CanGoBack) lemma e (e<d , (_ , e∈CGB)) with c ~? e lemma e (e<d , (_ , e∈CGB)) | in₁ c~e with ≤-total c e lemma e (e<d , (_ , e∈CGB)) | in₁ c~e | in₁ c≤e with ≤-asym c≤e (c-max e (e<d , ~-trans (~-sym c~e) c~d)) lemma ._ (e<d , (_ , e∈CGB)) | in₁ c~e | in₁ c≤e | refl = ((in₁ (in₂ refl)) , e∈CGB) lemma e (e<d , (_ , e∈CGB)) | in₁ c~e | in₂ e<c = (in₂ (_ , (in₂ refl , (e<c , ~-sym c~e))) , e∈CGB) lemma e (e<d , (in₁ e∈A , e∈CGB)) | in₂ c≁e = ((in₁ (in₁ (c≁e , e∈A))) , e∈CGB) lemma e (e<d , (in₂ (a , (a∈A , (e<a , e~a))) , e∈CGB)) | in₂ c≁e = (in₂ (a , (in₁ ((λ c~a → c≁e (~-trans c~a (~-sym e~a))) , a∈A) , (e<a , e~a))) , e∈CGB) lemma′ : ((A′ ∪ JointSessionPast′) ∩ CanGoBack) ⊆ ((A ∪ JointSessionPast) ∩ CanGoBack) lemma′ e (in₁ (in₁ (c≁e , e∈A)) , e∈CGB) = ((in₁ e∈A) , e∈CGB) lemma′ ._ (in₁ (in₂ refl) , c∈CGB) = ((in₂ (d , (d∈A , (c<d , c~d)))) , c∈CGB) lemma′ e (in₂ (a , (in₁ (c≁a , a∈A) , e≲a)) , e∈CGB) = (in₂ (a , (a∈A , e≲a)) , e∈CGB) lemma′ e (in₂ (._ , (in₂ refl , e≲c)) , e∈CGB) = ((in₂ (d , (d∈A , ≲-trans e≲c (c<d , c~d)))) , e∈CGB) lemma″ : ((A′ ∪ JointSessionPast′) ∩ CanGoBack) ⊆ (Past(d)) lemma″ e (in₁ (in₁ (c≁e , e∈A)) , e∈CGB) = (d-max e (e∈A , e∈CGB) , (λ e≡d → c≁e (~-trans c~d (≡-impl-~ (sym e≡d))))) lemma″ ._ (in₁ (in₂ refl) , c∈CGB) = c<d lemma″ e (in₂ (a , (in₁ (c≁a , a∈A) , e≲a)) , e∈CGB) = <-trans-≤ (≲-impl-< e≲a) (d-max a (a∈A , (e , e≲a))) lemma″ e (in₂ (._ , (in₂ refl , (e<c , e~c))) , e∈CGB) = <-trans e<c c<d d<ds : (ds ∈ All(Past(d))) d<ds = All-resp-⊆ lemma″ ds ds∈JSP′∩CGB d∷ds-max : ∀ es → es ∈ (Decreasing ∩ All ((A ∪ JointSessionPast) ∩ CanGoBack)) → (es ≤* (d ∷ ds)) d∷ds-max (e ∷ es) ((es<e , es↓) , ((e∈A∪JSP , e∈CGB) , es∈A∪JSP∩CGB)) = (e≤d , es≤ds) where lemma‴ : ∀ f → (f ∈ ((A ∪ JointSessionPast) ∩ CanGoBack)) → (f ≤ d) lemma‴ f (in₁ f∈A , f∈CGB) = d-max f (f∈A , f∈CGB) lemma‴ f (in₂ (a , (a∈A , ((f≤a , f≠a) , f~a))) , f∈CGB) = ≤-trans f≤a (d-max a (a∈A , (f , ((f≤a , f≠a) , f~a)))) e≤d : (e ≤ d) e≤d = lemma‴ e (e∈A∪JSP , e∈CGB) es<d : es ∈ All(Past(d)) es<d = All-resp-⊆ (λ f f<e → <-trans-≤ f<e e≤d) es es<e es≤ds : es ≤* ds es≤ds = ds-max es (es↓ , All-resp-⊆ lemma es (All-resp-∩ es (es<d , es∈A∪JSP∩CGB))) fwd? : ∀ {D} {H : NavigationHistory(D)} {δ} (ds : D ^ δ) → (ds ∈ FwdTarget*(H)) → (H traverses-by (+ve δ) to (H traverses-to ds)) fwd? {D} {H} {δ = zero} nil nil∈FT = back nil tt (BT-nil {H = H}) fwd? {D} {H} {δ = succ δ} ds ds∈FT = fwd ds ds∈FT FT-hd : ∀ {D} {H : NavigationHistory(D)} {n} d (ds : D ^ n) → ((d ∷ ds) ∈ FwdTarget*(H)) → (d ∈ FwdTarget(H)) FT-hd {D} {H} d ds (((d<ds , ds↑) , (d∈JSF , ds∈JSF)) , d∷ds-min) = (d∈JSF , d-min) where open NavigationHistory H d-min : ∀ e → (e ∈ JointSessionFuture) → (d ≤ e) d-min e e∈JSF with ≤-total d e d-min e e∈JSF | in₁ d≤e = d≤e d-min e e∈JSF | in₂ e<d with d∷ds-min (e ∷ ds) (((All-resp-⊆ (λ f → <-trans e<d) ds d<ds) , ds↑) , (e∈JSF , ds∈JSF)) d-min e e∈JSF | in₂ e<d | (d≤e , ds≤ds) = d≤e FT-tl : ∀ {D} {H : NavigationHistory(D)} {n} d (ds : D ^ n) → ((d ∷ ds) ∈ FwdTarget*(H)) → (ds ∈ FwdTarget*(H traverse-to d)) FT-tl {D} {H} d ds (((d<ds , ds↑) , ((a , (a∈A , (a<d , a~d))) , ds∈JSF)) , d∷ds-min) = ((ds↑ , ds∈JSF′) , ds-min) where H′ = (H traverse-to d) open NavigationHistory H open NavigationHistory H′ using () renaming (JointSessionFuture to JointSessionFuture′) lemma : ((Future(d) ∩ JointSessionFuture) ⊆ JointSessionFuture′) lemma e (d<e , (b , (b∈A , (b<e , b~e)))) with d ~? b lemma e (d<e , (b , (b∈A , (b<e , b~e)))) | in₁ d~b = (d , (in₂ refl , (d<e , (~-trans d~b b~e)))) lemma e (d<e , (b , (b∈A , (b<e , b~e)))) | in₂ d≁b = (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) lemma′ : (JointSessionFuture′ ⊆ Future(d)) lemma′ e (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) with ≤-total e d lemma′ e (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) | in₁ e≤d with d∷ds-min (e ∷ ds) (((All-resp-⊆ (λ f → ≤-trans-< e≤d) ds d<ds) , ds↑) , ((b , (b∈A , (b<e , b~e))) , ds∈JSF)) lemma′ e (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) | in₁ e≤d | (d≤e , ds≤ds) = contradiction (d≁b (~-trans (≡-impl-~ (≤-asym d≤e e≤d)) (~-sym b~e))) lemma′ e (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) | in₂ d<e = d<e lemma′ e (.d , (in₂ refl , (d<e , d~e))) = d<e lemma″ : (JointSessionFuture′ ⊆ JointSessionFuture) lemma″ e (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) = (b , (b∈A , (b<e , b~e))) lemma″ e (.d , (in₂ refl , (d<e , d~e))) = a , (a∈A , (<-trans a<d d<e , ~-trans a~d d~e)) ds∈JSF′ : (ds ∈ All(JointSessionFuture′)) ds∈JSF′ = All-resp-⊆ lemma ds (All-resp-∩ ds (d<ds , ds∈JSF)) ds-min : ∀ es → (es ∈ (Increasing ∩ All(JointSessionFuture′))) → (ds ≤* es) ds-min es (es↑ , es∈JSF′) with d∷ds-min (d ∷ es) ((d<es , es↑) , ((a , (a∈A , (a<d , a~d))) , es∈JSF)) where d<es : es ∈ All(Future(d)) d<es = All-resp-⊆ lemma′ es es∈JSF′ es∈JSF : es ∈ All(JointSessionFuture) es∈JSF = All-resp-⊆ lemma″ es es∈JSF′ ds-min es (es↑ , es∈JSF′) | (d≤d , ds≤es) = ds≤es FT-nil : ∀ {D} {H : NavigationHistory(D)} → (nil ∈ FwdTarget*(H)) FT-nil = ((tt , tt) , λ { nil (tt , tt) → tt }) FT-cons : ∀ {D} {H : NavigationHistory(D)} {n} d (ds : D ^ n) → (d ∈ FwdTarget(H)) → (ds ∈ FwdTarget*(H traverse-to d)) → ((d ∷ ds) ∈ FwdTarget*(H)) FT-cons {D} {H} d ds ((a , (a∈A , (a<d , a~d))) , d-min) ((ds↑ , ds∈JSF′) , ds-min) = (((d<ds , ds↑) , ((a , (a∈A , (a<d , a~d))) , ds∈JSF)) , d∷ds-min) where H′ = (H traverse-to d) open NavigationHistory H open NavigationHistory H′ using () renaming (JointSessionFuture to JointSessionFuture′) lemma : ((Future(d) ∩ JointSessionFuture) ⊆ JointSessionFuture′) lemma e (d<e , (b , (b∈A , (b<e , b~e)))) with d ~? b lemma e (d<e , (b , (b∈A , (b<e , b~e)))) | in₁ d~b = (d , (in₂ refl , (d<e , (~-trans d~b b~e)))) lemma e (d<e , (b , (b∈A , (b<e , b~e)))) | in₂ d≁b = (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) lemma′ : (JointSessionFuture′ ⊆ Future(d)) lemma′ e (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) with ≤-total e d lemma′ e (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) | in₁ e≤d with d-min e (b , (b∈A , (b<e , b~e))) lemma′ e (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) | in₁ e≤d | d≤e = contradiction (d≁b (~-trans (≡-impl-~ (≤-asym d≤e e≤d)) (~-sym b~e))) lemma′ e (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) | in₂ d<e = d<e lemma′ e (.d , (in₂ refl , (d<e , d~e))) = d<e lemma″ : (JointSessionFuture′ ⊆ JointSessionFuture) lemma″ e (b , (in₁ (d≁b , b∈A) , (b<e , b~e))) = (b , (b∈A , (b<e , b~e))) lemma″ e (.d , (in₂ refl , (d<e , d~e))) = (a , (a∈A , (<-trans a<d d<e , ~-trans a~d d~e))) d<ds : ds ∈ All(Future(d)) d<ds = All-resp-⊆ lemma′ ds ds∈JSF′ ds∈JSF : ds ∈ All(JointSessionFuture) ds∈JSF = All-resp-⊆ lemma″ ds ds∈JSF′ d∷ds-min : ∀ es → (es ∈ (Increasing ∩ All(JointSessionFuture))) → ((d ∷ ds) ≤* es) d∷ds-min (e ∷ es) ((e<es , es↑) , (e∈JSF , es∈JSF)) = (d≤e , ds≤es) where d≤e : (d ≤ e) d≤e = d-min e e∈JSF d<es : es ∈ All(Future(d)) d<es = All-resp-⊆ (λ f → ≤-trans-< d≤e) es e<es es∈JSF′ : (es ∈ All(JointSessionFuture′)) es∈JSF′ = All-resp-⊆ lemma es (All-resp-∩ es (d<es , es∈JSF)) ds≤es : (ds ≤* es) ds≤es = ds-min es (es↑ , es∈JSF′) from-to : ∀ {D} {H : NavigationHistory(D)} d e d∈CGB → (WellFormed(H)) → (d ∈ BackTarget(H)) → (e ∈ FwdTarget(H traverse-from d ∵ d∈CGB)) → (H ≣ ((H traverse-from d ∵ d∈CGB) traverse-to e)) from-to {D} {H} d e d∈CGB H∈WF ((d∈A , _) , d-max) e∈FT′ with lemma e∈FT′ where H′ = (H traverse-from d ∵ d∈CGB) open NavigationHistory H open NavigationHistory H′ using () renaming (JointSessionFuture to JointSessionFuture′ ; FwdTarget to FwdTarget′) lemma : (e ∈ FwdTarget′) → (d ≡ e) lemma (e∈JSP′ , e-min) with max(SessionPast(d)) ∵ d∈CGB | ≤-total d e lemma (e∈JSP′ , e-min) | (c , ((c<d , c~d) , c-max)) | in₁ d≤e = ≤-asym d≤e (e-min d (c , (in₂ refl , (c<d , c~d)))) lemma ((a , (in₁ (c≁a , a∈A) , (a<e , a~e))) , e-min) | c , ((c<d , c~d) , c-max) | in₂ e<d = contradiction (<-impl-≱ e<d (H∈WF (a<e , a~e) (c<d , c~d) a∈A d∈A)) lemma ((.c , (in₂ refl , (c<e , c~e))) , e-min) | c , ((c<d , c~d) , c-max) | in₂ e<d = contradiction (<-impl-≱ c<e (c-max e (e<d , ~-trans (~-sym c~e) c~d))) from-to {D} {H} d .d d∈CGB H∈WF ((d∈A , _) , d-max) e∈FT′ | refl = H=H″ where H′ = (H traverse-from d ∵ d∈CGB) H″ = (H′ traverse-to d) open NavigationHistory H open NavigationHistory H″ using () renaming (A to A″) A⊆A″ : (A ⊆ A″) A⊆A″ f f∈A with d ~? f A⊆A″ f f∈A | in₁ d~f with active-~-impl-≡ d∈A f∈A d~f A⊆A″ .d _ | in₁ d~f | refl = in₂ refl A⊆A″ f f∈A | in₂ d≁f with max(SessionPast(d)) ∵ d∈CGB A⊆A″ f f∈A | in₂ d≁f | (c , ((c<d , c~d) , c-max)) = in₁ (d≁f , (in₁ ((λ c~f → d≁f (~-trans (~-sym c~d) c~f)) , f∈A))) A″⊆A : (A″ ⊆ A) A″⊆A f (in₁ (d≁f , in₁ (c≁f , f∈A))) = f∈A A″⊆A ._ (in₁ (d≁c , in₂ refl)) with max(SessionPast(d)) ∵ d∈CGB A″⊆A ._ (in₁ (d≁c , in₂ refl)) | (c , ((c<d , c~d) , c-max)) = contradiction (d≁c (~-sym c~d)) A″⊆A ._ (in₂ refl) = d∈A H=H″ : (H ≣ H″) H=H″ = NH-CONG H H″ A⊆A″ A″⊆A REFL REFL REFL to-from : ∀ {D} {H : NavigationHistory(D)} d e e∈CGB → (WellFormed(H)) → (d ∈ FwdTarget(H)) → (e ∈ BackTarget(H traverse-to d)) → (H ≣ ((H traverse-to d) traverse-from e ∵ e∈CGB)) to-from {D} {H} d e e∈CGB H∈WF ((a , (a∈A , (a<d , a~d))) , d-min) e∈BT′ with lemma e∈BT′ | max(SessionPast(e)) ∵ e∈CGB where H′ = (H traverse-to d) open NavigationHistory H open NavigationHistory H′ using () renaming (BackTarget to BackTarget′) lemma : (e ∈ BackTarget′) → (d ≡ e) lemma ((in₁ (d≁e , e∈A) , (b , (b<e , b~e))) , e-max) = ≤-asym d≤e e≤d where d≤e : (d ≤ e) d≤e = e-max d (in₂ refl , (a , (a<d , a~d))) e≤d : (e ≤ d) e≤d = H∈WF (a<d , a~d) (b<e , b~e) a∈A e∈A lemma ((in₂ d≡e , _) , _) = d≡e to-from {D} {H} d .d d∈CGB H∈WF ((a , (a∈A , (a<d , a~d))) , d-min) (_ , d-max) | refl | (c , ((c<d , c~d) , c-max)) with ≤-asym a≤c c≤a where open NavigationHistory H c≤a : (c ≤ a) c≤a with ≤-total c a c≤a | in₁ c≤a = c≤a c≤a | in₂ a<c = contradiction (<-impl-≱ (<-trans-≤ c<d (d-min c (a , (a∈A , (a<c , (~-trans a~d (~-sym c~d))))))) ≤-refl) a≤c : (a ≤ c) a≤c = c-max a (a<d , a~d) to-from {D} {H} d .d d∈CGB H∈WF ((a , (a∈A , (a<d , a~d))) , d-min) (_ , d-max) | refl | (.a , ((_ , _) , a-max)) | refl = H=H″ where H′ = (H traverse-to d) H″ = (H′ traverse-to a) open NavigationHistory H open NavigationHistory H″ using () renaming (A to A″) A⊆A″ : (A ⊆ A″) A⊆A″ f f∈A with a ~? f A⊆A″ f f∈A | in₁ a~f = in₂ (active-~-impl-≡ a∈A f∈A (~-trans (~-trans a~d (~-sym a~d)) a~f)) A⊆A″ f f∈A | in₂ a≁f = in₁ (a≁f , (in₁ ((λ d~f → a≁f (~-trans a~d d~f)) , f∈A))) A″⊆A : (A″ ⊆ A) A″⊆A f (in₁ (_ , in₁ (_ , f∈A))) = f∈A A″⊆A .d (in₁ (a≁d , in₂ refl)) = contradiction (a≁d a~d) A″⊆A .a (in₂ refl) = a∈A H=H″ : (H ≣ H″) H=H″ = NH-CONG H H″ A⊆A″ A″⊆A REFL REFL REFL fwd-WF : ∀ {D} (H : NavigationHistory(D)) e → WellFormed(H) → (e ∈ FwdTarget(H)) → WellFormed(H traverse-to e) fwd-WF H e H∈WF ((f , (f∈A , f≲e)) , e-min) a≲b c≲d (in₁ (e≁a , a∈A)) (in₁ (e≁d , d∈A)) = H∈WF a≲b c≲d a∈A d∈A fwd-WF H e H∈WF ((f , (f∈A , f≲e)) , e-min) a≲b c≲e (in₁ (e≁a , a∈A)) (in₂ refl) = e-min _ (_ , (a∈A , a≲b)) fwd-WF H e H∈WF ((f , (f∈A , f≲e)) , e-min) e≲b c≲d (in₂ refl) (in₁ (e≁d , d∈A)) = H∈WF (≲-trans f≲e e≲b) c≲d f∈A d∈A where open NavigationHistory H fwd-WF H e H∈WF ((f , (f∈A , f≲e)) , e-min) e≲b c≲e (in₂ refl) (in₂ refl) = e-min _ (f , (f∈A , ≲-trans f≲e e≲b)) where open NavigationHistory H back-WF : ∀ {D} (H : NavigationHistory(D)) e e∈CGB → WellFormed(H) → (e ∈ BackTarget(H)) → WellFormed(H traverse-from e ∵ e∈CGB) back-WF H e e∈CGB H∈WF ((e∈A , _) , e-max) (a<b , a~b) c≲d a∈A′ d∈A′ with max(SessionPast(e)) ∵ e∈CGB where open NavigationHistory H back-WF H e e∈CGB H∈WF ((e∈A , _) , e-max) (a<b , a~b) c≲d (in₁ (f≁a , a∈A)) (in₁ (f≁d , d∈A)) | (f , ((f<e , f~e) , f-max)) = H∈WF (a<b , a~b) c≲d a∈A d∈A back-WF H e e∈CGB H∈WF ((e∈A , _) , e-max) (a<b , a~b) c≲f (in₁ (f≁a , a∈A)) (in₂ refl) | (f , ((f<e , f~e) , f-max)) = ≤-trans (<-impl-≤ f<e) (H∈WF (a<b , a~b) (f<e , f~e) a∈A e∈A) where open NavigationHistory H back-WF H e e∈CGB H∈WF ((e∈A , _) , e-max) {b = b} (f<b , f~b) c≲d (in₂ refl) (in₁ (f≁d , d∈A)) | (f , ((f<e , f~e) , f-max)) with ≤-total b e | ≤-total e b where open NavigationHistory H back-WF H e e∈CGB H∈WF ((e∈A , _) , e-max) (f<b , f~b) c≲d (in₂ refl) (in₁ (f≁d , d∈A)) | (f , ((f<e , f~e) , f-max)) | in₁ b≤e | in₁ e≤b with ≤-asym b≤e e≤b where open NavigationHistory H back-WF H e e∈CGB H∈WF ((e∈A , _) , e-max) (f<b , f~b) c≲d (in₂ refl) (in₁ (f≁d , d∈A)) | (f , ((f<e , f~e) , f-max)) | in₁ b≤e | in₁ e≤b | refl = e-max _ (d∈A , (_ , c≲d)) back-WF H e e∈CGB H∈WF ((e∈A , _) , e-max) (f<b , f~b) c≲d (in₂ refl) (in₁ (f≁d , d∈A)) | (f , ((f<e , f~e) , f-max)) | in₁ b≤e | in₂ b<e = contradiction (<-impl-≱ f<b (f-max _ (b<e , ~-trans (~-sym f~b) f~e))) where open NavigationHistory H back-WF H e e∈CGB H∈WF ((e∈A , _) , e-max) (f<b , f~b) c≲d (in₂ refl) (in₁ (f≁d , d∈A)) | (f , ((f<e , f~e) , f-max)) | in₂ e<b | _ = H∈WF (e<b , ~-trans (~-sym f~e) f~b) c≲d e∈A d∈A where open NavigationHistory H back-WF H e e∈CGB H∈WF ((e∈A , _) , e-max) (f<b , f~b) c≲f (in₂ refl) (in₂ refl) | (f , ((f<e , f~e) , f-max)) = <-impl-≤ f<b where open NavigationHistory H
{ "alphanum_fraction": 0.4831225889, "avg_line_length": 52.5746478873, "ext": "agda", "hexsha": "7392da45fcea15e0323456c6ab4eddd029d3a3da", "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": "cea700aea1488df1d27092c8f3d79d5d99f7e09a", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "cbrewster/ServoNavigation", "max_forks_repo_path": "notes/lemmas.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cea700aea1488df1d27092c8f3d79d5d99f7e09a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "cbrewster/ServoNavigation", "max_issues_repo_path": "notes/lemmas.agda", "max_line_length": 262, "max_stars_count": 1, "max_stars_repo_head_hexsha": "cea700aea1488df1d27092c8f3d79d5d99f7e09a", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "cbrewster/ServoNavigation", "max_stars_repo_path": "notes/lemmas.agda", "max_stars_repo_stars_event_max_datetime": "2017-04-22T01:51:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-22T01:51:07.000Z", "num_tokens": 9433, "size": 18664 }
open import FRP.LTL.RSet.Core using ( RSet ; ⟦_⟧ ) open import FRP.LTL.RSet.Stateless using ( _⇒_ ) open import FRP.LTL.Time using ( _≤_ ; ≤-refl ; _≤-trans_ ) module FRP.LTL.RSet.Globally where -- □ A is "A holds globally in the future" □ : RSet → RSet □ A t = ∀ {u} → (t ≤ u) → A u -- Comonad structure of □ extend : ∀ {A B} → ⟦ A ⇒ B ⟧ → ⟦ □ A ⇒ □ B ⟧ extend f a s≤t = f (a s≤t) extract : ∀ {A} → ⟦ □ A ⇒ A ⟧ extract a = a ≤-refl duplicate : ∀ {A} → ⟦ □ A ⇒ □ (□ A) ⟧ duplicate a s≤t t≤u = a (s≤t ≤-trans t≤u) -- Applicative structure of □ [_] : ∀ {A} → ⟦ A ⟧ → ⟦ □ A ⟧ [ a ] s≤t = a _⟨*⟩_ : ∀ {A B} → ⟦ □ (A ⇒ B) ⇒ □ A ⇒ □ B ⟧ (f ⟨*⟩ a) s≤t = f s≤t (a s≤t)
{ "alphanum_fraction": 0.4940298507, "avg_line_length": 23.1034482759, "ext": "agda", "hexsha": "c07a160a3ac72845e782d230464d4ba04dc90821", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z", "max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-frp-ltl", "max_forks_repo_path": "src/FRP/LTL/RSet/Globally.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-frp-ltl", "max_issues_repo_path": "src/FRP/LTL/RSet/Globally.agda", "max_line_length": 59, "max_stars_count": 21, "max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-frp-ltl", "max_stars_repo_path": "src/FRP/LTL/RSet/Globally.agda", "max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z", "num_tokens": 340, "size": 670 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import Optics.All open import LibraBFT.Prelude open import LibraBFT.Lemmas open import LibraBFT.Hash open import LibraBFT.Base.ByteString open import LibraBFT.Base.Encode open import LibraBFT.Base.PKCS open import LibraBFT.Impl.Consensus.Types.EpochIndep -- This module postulates a collision-resistant cryptographic hash -- function (we call it sha256 for concreteness, but it could be any -- collision-resistant cryptographic hash function), and defines hash -- functions used in (an earlier version of) LibraBFT, properties -- about it, and how Votes and Blocks are signed. module LibraBFT.Impl.Util.Crypto where -- Note that this is an abstraction of a collision-resistant hash function. It could be any such -- hash function, not necessarily sha256. We just call it sha256 for "concreteness", to remind -- ourselves it's modeling such a function. postulate -- valid assumption (collision-resistant hash function) sha256 : BitString → Hash sha256-cr : ∀{x y} → sha256 x ≡ sha256 y → Collision sha256 x y ⊎ x ≡ y open WithCryptoHash sha256 sha256-cr blockInfoBSList : BlockInfo → List ByteString blockInfoBSList (BlockInfo∙new epoch round id) = encode epoch ∷ encode round ∷ encode id ∷ [] hashBI : BlockInfo → HashValue hashBI = sha256 ∘ bs-concat ∘ blockInfoBSList hashBI-inj : ∀ {bi1 bi2} → hashBI bi1 ≡ hashBI bi2 → NonInjective-≡ sha256 ⊎ bi1 ≡ bi2 hashBI-inj {bi1} {bi2} hyp with sha256-cr hyp ...| inj₁ col = inj₁ (_ , col) ...| inj₂ res with bs-concat-inj (blockInfoBSList bi1) (blockInfoBSList bi2) res ...| final = inj₂ (BlockInfo-η (encode-inj (proj₁ (∷-injective final))) (encode-inj (proj₁ (∷-injective (proj₂ (∷-injective final))))) (encode-inj (proj₁ (∷-injective (proj₂ (∷-injective (proj₂ (∷-injective final)))))))) voteDataHashList : VoteData → List Hash voteDataHashList (VoteData∙new proposed parent) = hProposed ∷ hParent ∷ [] where hProposed = hashBI proposed hParent = hashBI parent hashVD : VoteData → HashValue hashVD = hash-concat ∘ voteDataHashList VoteData-≢-eid : ∀ {vd1 vd2 : VoteData} → vd1 ^∙ vdProposed ∙ biEpoch ≢ vd2 ^∙ vdProposed ∙ biEpoch → vd1 ≢ vd2 VoteData-≢-eid neq = λ x → neq (cong (_^∙ vdProposed ∙ biEpoch) x) VoteData-hb : ∀ {vd1 vd2 : VoteData} → vd1 ^∙ vdProposed ∙ biEpoch ≢ vd2 ^∙ vdProposed ∙ biEpoch → hashVD vd1 ≡ hashVD vd2 → NonInjective-≡ sha256 VoteData-hb {vd1} {vd2} neq hvd≡ with hash-concat-inj {voteDataHashList vd1} {voteDataHashList vd2} hvd≡ ...| inj₁ hb = hb ...| inj₂ xxx with cong head xxx ...| yyy with cong tail xxx ...| yyy' with cong head (just-injective yyy') ...| yyy'' with just-injective yyy | just-injective yyy'' ...| zzz | zzz' with hashBI-inj {vd1 ^∙ vdProposed} {vd2 ^∙ vdProposed} zzz | hashBI-inj {vd1 ^∙ vdParent} {vd2 ^∙ vdParent} zzz' ...| inj₁ hb | _ = hb ...| inj₂ _ | inj₁ hb = hb ...| inj₂ aaa | inj₂ aaa' = ⊥-elim (VoteData-≢-eid {vd1} {vd2} neq (VoteData-η aaa aaa')) hashVD-inj : ∀ {vd1 vd2} → hashVD vd1 ≡ hashVD vd2 → NonInjective-≡ sha256 ⊎ vd1 ≡ vd2 hashVD-inj {vd1} {vd2} prf with hash-concat-inj {voteDataHashList vd1} {voteDataHashList vd2} prf ...| inj₁ hb = inj₁ hb ...| inj₂ vdLists≡ with hashBI-inj (proj₁ (∷-injective vdLists≡)) | hashBI-inj (proj₁ (∷-injective (proj₂ (∷-injective vdLists≡)))) ...| inj₁ hb | _ = inj₁ hb ...| inj₂ _ | inj₁ hb = inj₁ hb ...| inj₂ prop≡ | inj₂ par≡ = inj₂ (VoteData-η prop≡ par≡) hashLI : LedgerInfo → HashValue hashLI (LedgerInfo∙new commitInfo consensusDataHash) = hash-concat (hashBI commitInfo ∷ consensusDataHash ∷ []) hashLI-inj : ∀ {li1 li2} → hashLI li1 ≡ hashLI li2 → NonInjective-≡ sha256 ⊎ li1 ≡ li2 hashLI-inj {LedgerInfo∙new ci1 cd1} {LedgerInfo∙new ci2 cd2} prf with hash-concat-inj {hashBI ci1 ∷ cd1 ∷ []} {hashBI ci2 ∷ cd2 ∷ []} prf ...| inj₁ hb = inj₁ hb ...| inj₂ li1≡li2 with ∷-injective li1≡li2 ...| ci≡ , rest≡ with ∷-injective rest≡ ...| cdh≡ , _ with hashBI-inj ci≡ ...| inj₁ hb = inj₁ hb ...| inj₂ cis≡ = inj₂ (LedgerInfo-η cis≡ cdh≡) constructLI : Vote → LedgerInfo constructLI v = LedgerInfo∙new (₋liCommitInfo (₋vLedgerInfo v)) (hashVD (₋vVoteData v)) hashVote : Vote → HashValue hashVote = hashLI ∘ constructLI hashVote-inj1 : ∀ {v1 v2} → hashVote v1 ≡ hashVote v2 → NonInjective-≡ sha256 ⊎ ₋vVoteData v1 ≡ ₋vVoteData v2 hashVote-inj1 {v1} {v2} hyp with hashLI-inj {constructLI v1} {constructLI v2} hyp ...| inj₁ hb = inj₁ hb ...| inj₂ ok = hashVD-inj {₋vVoteData v1} {₋vVoteData v2} (cong ₋liConsensusDataHash ok) -- A vote is always signed; as seen by the 'Unit' -- in the definition of Signed. instance sig-Vote : WithSig Vote sig-Vote = record { Signed = λ _ → Unit ; Signed-pi = λ _ _ _ → Unit-pi ; isSigned? = λ _ → yes unit ; signature = λ v _ → ₋vSignature v ; signableFields = encodeH ∘ hashVote } -- Captures a proof that a vote was cast by α by recording that 'verify' returns true. VoteSigVerifies : PK → Vote → Set VoteSigVerifies pk v = T (verify (signableFields ⦃ sig-Vote ⦄ v) (₋vSignature v) pk) Signed-pi-Blk : (b : Block) → (is1 is2 : (Is-just ∘ ₋bSignature) b) → is1 ≡ is2 Signed-pi-Blk (Block∙new _ _ .(just _)) (just _) (just _) = cong just refl -- A Block might carry a signature instance sig-Block : WithSig Block sig-Block = record { Signed = Is-just ∘ ₋bSignature ; Signed-pi = Signed-pi-Blk ; isSigned? = λ b → Maybe-Any-dec (λ _ → yes tt) (b ^∙ bSignature) ; signature = λ { _ prf → to-witness prf } ; signableFields = λ b → concat (encodeH (₋bId b) ∷ encode (b ^∙ bBlockData) ∷ []) }
{ "alphanum_fraction": 0.6313606636, "avg_line_length": 40.9738562092, "ext": "agda", "hexsha": "cd4ccae16b0ebdabf7adc9dcb74d0efa912c4c71", "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/Impl/Util/Crypto.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/Impl/Util/Crypto.agda", "max_line_length": 118, "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/Impl/Util/Crypto.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2190, "size": 6269 }
-- Andreas, 2016-10-12 AIM XXIV, issue #2256 open import Common.Equality module _ a (A : Set a) where data ⊥ : Set where abs : ⊥ → Set a abs = λ() test : (x : ⊥) → abs x ≡ A test x = refl -- ERROR WAS: -- (λ ()) a A x != A of type Set a -- when checking that the expression refl has type abs x ≡ A -- EXPECTED: -- (λ ()) x != A of type Set a -- when checking that the expression refl has type abs x ≡ A
{ "alphanum_fraction": 0.6073170732, "avg_line_length": 18.6363636364, "ext": "agda", "hexsha": "32ba409e74a87801d91ef9bca7014319d5337db1", "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/Issue2256.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/Issue2256.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/Issue2256.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": 139, "size": 410 }
module Equiv where import Prelude import Eq open Prelude open Eq data Equiv (a : Set) : Set1 where equiv : (_==_ : a -> a -> Set) -> (refl : (x : a) -> x == x) -> (sym : (x y : a) -> x == y -> y == x) -> (trans : (x y z : a) -> x == y -> y == z -> x == z) -> Equiv a rel : {a : Set} -> Equiv a -> (a -> a -> Set) rel (equiv _==_ _ _ _) = _==_ data Decidable {a : Set} (eq : a -> a -> Set) : Set where dec : ((x y : a) -> Either (eq x y) (Not (eq x y))) -> Decidable eq private boolFunctionsDecidable' : {a : Set} -> (f : a -> a -> Bool) -> (x y : a) -> (b : Bool) -> (b =^= f x y) -> Either (T' f x y) (Not (T' f x y)) boolFunctionsDecidable' eq x y True p = left (leibnizSubst p T unit) boolFunctionsDecidable' eq x y False p = right (not (\xy -> leibnizSubst (leibnizSym p) T xy)) boolFunctionsDecidable : {a : Set} -> (f : a -> a -> Bool) -> Decidable (T' f) boolFunctionsDecidable f = dec (\x y -> boolFunctionsDecidable' f x y (f x y) leibnizRefl) data DecidableEquiv (a : Set) : Set1 where decEquiv : (eq : Equiv a) -> Decidable (rel eq) -> DecidableEquiv a rel' : {a : Set} -> (eq : DecidableEquiv a) -> (a -> a -> Set) rel' (decEquiv eq _) = rel eq refl : {a : Set} -> (eq : DecidableEquiv a) -> {x : a} -> rel' eq x x refl (decEquiv (equiv _ refl' _ _) _) = refl' _ sym : {a : Set} -> (eq : DecidableEquiv a) -> {x y : a} -> rel' eq x y -> rel' eq y x sym (decEquiv (equiv _ _ sym' _) _) = sym' _ _ trans : {a : Set} -> (eq : DecidableEquiv a) -> {x y z : a} -> rel' eq x y -> rel' eq y z -> rel' eq x z trans (decEquiv (equiv _ _ _ trans') _) = trans' _ _ _ decRel : {a : Set} -> (eq : DecidableEquiv a) -> (x y : a) -> Either (rel' eq x y) (Not (rel' eq x y)) decRel (decEquiv _ (dec f)) = f private decRelI : {a : Set} -> (eq : a -> a -> Set) -> {x y : a} -> Either (eq x y) (Not (eq x y)) -> Bool decRelI _ (left _) = True decRelI _ (right _) = False decRel' : {a : Set} -> DecidableEquiv a -> (a -> a -> Bool) decRel' eq x y = decRelI (rel' eq) (decRel eq x y) private pairEq : {a b : Set} -> DecidableEquiv a -> DecidableEquiv b -> (p1 p2 : Pair a b) -> Set pairEq a b (pair x1 x2) (pair y1 y2) = Pair (rel' a x1 y1) (rel' b x2 y2) refl' : {a b : Set} -> (da : DecidableEquiv a) -> (db : DecidableEquiv b) -> (x : Pair a b) -> pairEq da db x x refl' a b (pair x1 x2) = pair (refl a) (refl b) sym' : {a b : Set} -> (da : DecidableEquiv a) -> (db : DecidableEquiv b) -> (x y : Pair a b) -> pairEq da db x y -> pairEq da db y x sym' a b (pair x1 x2) (pair y1 y2) (pair xy1 xy2) = pair (sym a xy1) (sym b xy2) trans' : {a b : Set} -> (da : DecidableEquiv a) -> (db : DecidableEquiv b) -> (x y z : Pair a b) -> pairEq da db x y -> pairEq da db y z -> pairEq da db x z trans' a b (pair x1 x2) (pair y1 y2) (pair z1 z2) (pair xy1 xy2) (pair yz1 yz2) = pair (trans a xy1 yz1) (trans b xy2 yz2) dec'' : {a b : Set} -> {da : DecidableEquiv a} -> {db : DecidableEquiv b} -> {x1 y1 : a} -> {x2 y2 : b} -> Either (rel' da x1 y1) (Not (rel' da x1 y1)) -> Either (rel' db x2 y2) (Not (rel' db x2 y2)) -> Either (pairEq da db (pair x1 x2) (pair y1 y2)) (Not (pairEq da db (pair x1 x2) (pair y1 y2))) dec'' (left xy1) (left xy2) = left (pair xy1 xy2) dec'' _ (right (not nxy2)) = right (not (\xy -> nxy2 (snd xy))) dec'' (right (not nxy1)) (left _) = right (not (\xy -> nxy1 (fst xy))) dec' : {a b : Set} -> (da : DecidableEquiv a) -> (db : DecidableEquiv b) -> (x y : Pair a b) -> Either (pairEq da db x y) (Not (pairEq da db x y)) dec' a b (pair x1 x2) (pair y1 y2) = dec'' {_} {_} {a} {b} (decRel a x1 y1) (decRel b x2 y2) pairEquiv : {a b : Set} -> DecidableEquiv a -> DecidableEquiv b -> DecidableEquiv (Pair a b) pairEquiv a b = decEquiv (equiv (pairEq a b) (refl' a b) (sym' a b) (trans' a b)) (dec (dec' a b))
{ "alphanum_fraction": 0.4893023256, "avg_line_length": 36.7521367521, "ext": "agda", "hexsha": "15d1dbad074635dcf1ea40deae9b2665c0a29c3f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/AIM4/bag/Equiv.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/AIM4/bag/Equiv.agda", "max_line_length": 82, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/AIM4/bag/Equiv.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": 1636, "size": 4300 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Matrix where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Structure open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport open import Cubical.Functions.FunExtEquiv import Cubical.Data.Empty as ⊥ open import Cubical.Data.Bool open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc ; ·-assoc to ·ℕ-assoc) open import Cubical.Data.Vec open import Cubical.Data.Sigma.Base open import Cubical.Data.FinData open import Cubical.Relation.Nullary open import Cubical.Algebra.Group open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.Ring open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.CommRing open Iso private variable ℓ ℓ' : Level A : Type ℓ -- Equivalence between Vec matrix and Fin function matrix FinMatrix : (A : Type ℓ) (m n : ℕ) → Type ℓ FinMatrix A m n = FinVec (FinVec A n) m VecMatrix : (A : Type ℓ) (m n : ℕ) → Type ℓ VecMatrix A m n = Vec (Vec A n) m FinMatrix→VecMatrix : {m n : ℕ} → FinMatrix A m n → VecMatrix A m n FinMatrix→VecMatrix M = FinVec→Vec (λ fm → FinVec→Vec (M fm)) VecMatrix→FinMatrix : {m n : ℕ} → VecMatrix A m n → FinMatrix A m n VecMatrix→FinMatrix M fn fm = lookup fm (lookup fn M) FinMatrix→VecMatrix→FinMatrix : {m n : ℕ} (M : FinMatrix A m n) → VecMatrix→FinMatrix (FinMatrix→VecMatrix M) ≡ M FinMatrix→VecMatrix→FinMatrix {m = zero} M = funExt (⊥.rec ∘ ¬Fin0) FinMatrix→VecMatrix→FinMatrix {n = zero} M = funExt₂ (λ _ → ⊥.rec ∘ ¬Fin0) FinMatrix→VecMatrix→FinMatrix {m = suc m} {n = suc n} M = funExt₂ goal where goal : (fm : Fin (suc m)) (fn : Fin (suc n)) → VecMatrix→FinMatrix (_ ∷ FinMatrix→VecMatrix (M ∘ suc)) fm fn ≡ M fm fn goal zero zero = refl goal zero (suc fn) i = FinVec→Vec→FinVec (M zero ∘ suc) i fn goal (suc fm) fn i = FinMatrix→VecMatrix→FinMatrix (M ∘ suc) i fm fn VecMatrix→FinMatrix→VecMatrix : {m n : ℕ} (M : VecMatrix A m n) → FinMatrix→VecMatrix (VecMatrix→FinMatrix M) ≡ M VecMatrix→FinMatrix→VecMatrix {m = zero} [] = refl VecMatrix→FinMatrix→VecMatrix {m = suc m} (M ∷ MS) i = Vec→FinVec→Vec M i ∷ VecMatrix→FinMatrix→VecMatrix MS i FinMatrixIsoVecMatrix : (A : Type ℓ) (m n : ℕ) → Iso (FinMatrix A m n) (VecMatrix A m n) fun (FinMatrixIsoVecMatrix A m n) = FinMatrix→VecMatrix inv (FinMatrixIsoVecMatrix A m n) = VecMatrix→FinMatrix rightInv (FinMatrixIsoVecMatrix A m n) = VecMatrix→FinMatrix→VecMatrix leftInv (FinMatrixIsoVecMatrix A m n) = FinMatrix→VecMatrix→FinMatrix FinMatrix≃VecMatrix : {m n : ℕ} → FinMatrix A m n ≃ VecMatrix A m n FinMatrix≃VecMatrix {_} {A} {m} {n} = isoToEquiv (FinMatrixIsoVecMatrix A m n) FinMatrix≡VecMatrix : (A : Type ℓ) (m n : ℕ) → FinMatrix A m n ≡ VecMatrix A m n FinMatrix≡VecMatrix _ _ _ = ua FinMatrix≃VecMatrix -- Define abelian group structure on matrices module FinMatrixAbGroup (G' : AbGroup ℓ) where open AbGroupStr (snd G') renaming ( is-set to isSetG ) private G = ⟨ G' ⟩ zeroFinMatrix : ∀ {m n} → FinMatrix G m n zeroFinMatrix _ _ = 0g negFinMatrix : ∀ {m n} → FinMatrix G m n → FinMatrix G m n negFinMatrix M i j = - M i j addFinMatrix : ∀ {m n} → FinMatrix G m n → FinMatrix G m n → FinMatrix G m n addFinMatrix M N i j = M i j + N i j isSetFinMatrix : ∀ {m n} → isSet (FinMatrix G m n) isSetFinMatrix = isSetΠ2 λ _ _ → isSetG addFinMatrixAssoc : ∀ {m n} → (M N K : FinMatrix G m n) → addFinMatrix M (addFinMatrix N K) ≡ addFinMatrix (addFinMatrix M N) K addFinMatrixAssoc M N K i j k = assoc (M j k) (N j k) (K j k) i addFinMatrix0r : ∀ {m n} → (M : FinMatrix G m n) → addFinMatrix M zeroFinMatrix ≡ M addFinMatrix0r M i j k = rid (M j k) i addFinMatrix0l : ∀ {m n} → (M : FinMatrix G m n) → addFinMatrix zeroFinMatrix M ≡ M addFinMatrix0l M i j k = lid (M j k) i addFinMatrixNegMatrixr : ∀ {m n} → (M : FinMatrix G m n) → addFinMatrix M (negFinMatrix M) ≡ zeroFinMatrix addFinMatrixNegMatrixr M i j k = invr (M j k) i addFinMatrixNegMatrixl : ∀ {m n} → (M : FinMatrix G m n) → addFinMatrix (negFinMatrix M) M ≡ zeroFinMatrix addFinMatrixNegMatrixl M i j k = invl (M j k) i addFinMatrixComm : ∀ {m n} → (M N : FinMatrix G m n) → addFinMatrix M N ≡ addFinMatrix N M addFinMatrixComm M N i k l = comm (M k l) (N k l) i FinMatrixAbGroup : (m n : ℕ) → AbGroup ℓ FinMatrixAbGroup m n = makeAbGroup {G = FinMatrix G m n} zeroFinMatrix addFinMatrix negFinMatrix isSetFinMatrix addFinMatrixAssoc addFinMatrix0r addFinMatrixNegMatrixr addFinMatrixComm -- Define a abelian group structure on vector matrices and prove that -- it is equal to FinMatrixAbGroup using the SIP module _ (G' : AbGroup ℓ) where open AbGroupStr (snd G') private G = ⟨ G' ⟩ zeroVecMatrix : ∀ {m n} → VecMatrix G m n zeroVecMatrix = replicate (replicate 0g) negVecMatrix : ∀ {m n} → VecMatrix G m n → VecMatrix G m n negVecMatrix = map (map (λ x → - x)) addVec : ∀ {m} → Vec G m → Vec G m → Vec G m addVec [] [] = [] addVec (x ∷ xs) (y ∷ ys) = x + y ∷ addVec xs ys addVecMatrix : ∀ {m n} → VecMatrix G m n → VecMatrix G m n → VecMatrix G m n addVecMatrix [] [] = [] addVecMatrix (M ∷ MS) (N ∷ NS) = addVec M N ∷ addVecMatrix MS NS open FinMatrixAbGroup -- Proof that FinMatrix→VecMatrix is a group homorphism FinMatrix→VecMatrixHomAdd : (m n : ℕ) (M N : FinMatrix G m n) → FinMatrix→VecMatrix (addFinMatrix G' M N) ≡ addVecMatrix (FinMatrix→VecMatrix M) (FinMatrix→VecMatrix N) FinMatrix→VecMatrixHomAdd zero n M N = refl FinMatrix→VecMatrixHomAdd (suc m) n M N = λ i → lem n (M zero) (N zero) i ∷ FinMatrix→VecMatrixHomAdd m n (λ i j → M (suc i) j) (λ i j → N (suc i) j) i where lem : (n : ℕ) (V W : FinVec G n) → FinVec→Vec (λ j → V j + W j) ≡ addVec (FinVec→Vec V) (FinVec→Vec W) lem zero V W = refl lem (suc n) V W = λ i → V zero + W zero ∷ lem n (V ∘ suc) (W ∘ suc) i -- Combine everything to get an induced abelian group structure of -- VecMatrix that is equal to the one on FinMatrix VecMatrixAbGroup : (m n : ℕ) → AbGroup ℓ VecMatrixAbGroup m n = InducedAbGroup (FinMatrixAbGroup G' m n) addVecMatrix FinMatrix≃VecMatrix (FinMatrix→VecMatrixHomAdd m n) FinMatrixAbGroup≡VecMatrixAbGroup : (m n : ℕ) → FinMatrixAbGroup G' m n ≡ VecMatrixAbGroup m n FinMatrixAbGroup≡VecMatrixAbGroup m n = InducedAbGroupPath (FinMatrixAbGroup G' m n) addVecMatrix FinMatrix≃VecMatrix (FinMatrix→VecMatrixHomAdd m n) -- Define identity matrix and matrix multiplication for FinMatrix and -- prove that square matrices form a ring module _ (R' : Ring ℓ) where open RingStr (snd R') renaming ( is-set to isSetR ) open RingTheory R' open KroneckerDelta R' open Sum R' open FinMatrixAbGroup (_ , abgroupstr _ _ _ (snd R' .RingStr.+IsAbGroup)) private R = ⟨ R' ⟩ oneFinMatrix : ∀ {n} → FinMatrix R n n oneFinMatrix i j = δ i j mulFinMatrix : ∀ {m1 m2 m3} → FinMatrix R m1 m2 → FinMatrix R m2 m3 → FinMatrix R m1 m3 mulFinMatrix M N i k = ∑ λ j → M i j · N j k ∑Exchange : ∀ {m n} → (M : FinMatrix R m n) → ∑ (λ i → ∑ (λ j → M i j)) ≡ ∑ (λ j → ∑ (λ i → M i j)) ∑Exchange {m = zero} {n = n} M = sym (∑0r n) ∑Exchange {m = suc m} {n = zero} M = cong (λ x → 0r + x) (∑0r m) ∙ +Rid 0r ∑Exchange {m = suc m} {n = suc n} M = let a = M zero zero L = ∑ λ j → M zero (suc j) C = ∑ λ i → M (suc i) zero N = ∑ λ i → ∑ λ j → M (suc i) (suc j) -- N reindexed N' = ∑ λ j → ∑ λ i → M (suc i) (suc j) in a + L + ∑ (λ i → ∑ (λ j → M (suc i) j)) ≡⟨ (λ k → a + L + ∑Split (λ i → M (suc i) zero) (λ i → ∑ (λ j → M (suc i) (suc j))) k) ⟩ a + L + (C + N) ≡⟨ (λ k → a + L + (C + ∑Exchange (λ i j → M (suc i) (suc j)) k)) ⟩ a + L + (C + N') ≡⟨ sym (+Assoc _ _ _) ⟩ a + (L + (C + N')) ≡⟨ (λ k → a + +Assoc-comm1 L C N' k) ⟩ a + (C + (L + N')) ≡⟨ +Assoc _ _ _ ⟩ a + C + (L + N') ≡⟨ (λ k → a + C + ∑Split (λ j → M zero (suc j)) (λ j → ∑ (λ i → M (suc i) (suc j))) (~ k)) ⟩ a + C + ∑ (λ j → ∑ (λ i → M i (suc j))) ∎ mulFinMatrixAssoc : ∀ {m n k l} → (M : FinMatrix R m n) → (N : FinMatrix R n k) → (K : FinMatrix R k l) → mulFinMatrix M (mulFinMatrix N K) ≡ mulFinMatrix (mulFinMatrix M N) K mulFinMatrixAssoc M N K = funExt₂ λ i j → ∑ (λ k → M i k · ∑ (λ l → N k l · K l j)) ≡⟨ ∑Ext (λ k → ∑Mulrdist (M i k) (λ l → N k l · K l j)) ⟩ ∑ (λ k → ∑ (λ l → M i k · (N k l · K l j))) ≡⟨ ∑Ext (λ k → ∑Ext (λ l → ·Assoc (M i k) (N k l) (K l j))) ⟩ ∑ (λ k → ∑ (λ l → M i k · N k l · K l j)) ≡⟨ ∑Exchange (λ k l → M i k · N k l · K l j) ⟩ ∑ (λ l → ∑ (λ k → M i k · N k l · K l j)) ≡⟨ ∑Ext (λ l → sym (∑Mulldist (K l j) (λ k → M i k · N k l))) ⟩ ∑ (λ l → ∑ (λ k → M i k · N k l) · K l j) ∎ mulFinMatrixr1 : ∀ {m n} → (M : FinMatrix R m n) → mulFinMatrix M oneFinMatrix ≡ M mulFinMatrixr1 M = funExt₂ λ i j → ∑Mulr1 _ (M i) j mulFinMatrix1r : ∀ {m n} → (M : FinMatrix R m n) → mulFinMatrix oneFinMatrix M ≡ M mulFinMatrix1r M = funExt₂ λ i j → ∑Mul1r _ (λ x → M x j) i mulFinMatrixrDistrAddFinMatrix : ∀ {n} (M N K : FinMatrix R n n) → mulFinMatrix M (addFinMatrix N K) ≡ addFinMatrix (mulFinMatrix M N) (mulFinMatrix M K) mulFinMatrixrDistrAddFinMatrix M N K = funExt₂ λ i j → ∑ (λ k → M i k · (N k j + K k j)) ≡⟨ ∑Ext (λ k → ·Rdist+ (M i k) (N k j) (K k j)) ⟩ ∑ (λ k → M i k · N k j + M i k · K k j) ≡⟨ ∑Split (λ k → M i k · N k j) (λ k → M i k · K k j) ⟩ ∑ (λ k → M i k · N k j) + ∑ (λ k → M i k · K k j) ∎ mulFinMatrixlDistrAddFinMatrix : ∀ {n} (M N K : FinMatrix R n n) → mulFinMatrix (addFinMatrix M N) K ≡ addFinMatrix (mulFinMatrix M K) (mulFinMatrix N K) mulFinMatrixlDistrAddFinMatrix M N K = funExt₂ λ i j → ∑ (λ k → (M i k + N i k) · K k j) ≡⟨ ∑Ext (λ k → ·Ldist+ (M i k) (N i k) (K k j)) ⟩ ∑ (λ k → M i k · K k j + N i k · K k j) ≡⟨ ∑Split (λ k → M i k · K k j) (λ k → N i k · K k j) ⟩ ∑ (λ k → M i k · K k j) + ∑ (λ k → N i k · K k j) ∎ FinMatrixRing : (n : ℕ) → Ring ℓ FinMatrixRing n = makeRing {R = FinMatrix R n n} zeroFinMatrix oneFinMatrix addFinMatrix mulFinMatrix negFinMatrix isSetFinMatrix addFinMatrixAssoc addFinMatrix0r addFinMatrixNegMatrixr addFinMatrixComm mulFinMatrixAssoc mulFinMatrixr1 mulFinMatrix1r mulFinMatrixrDistrAddFinMatrix mulFinMatrixlDistrAddFinMatrix -- Generators of product of two ideals flatten : {n m : ℕ} → FinMatrix A n m → FinVec A (n ·ℕ m) flatten {n = zero} _ () flatten {n = suc n} M = M zero ++Fin flatten (M ∘ suc) flattenElim : {P : A → Type ℓ'} {n m : ℕ} (M : FinMatrix A n m) → (∀ i j → P (M i j)) → (∀ i → P (flatten M i)) flattenElim {n = zero} M PMHyp () flattenElim {n = suc n} {m = zero} M PMHyp ind = ⊥.rec (¬Fin0 (transport (λ i → Fin (0≡m·0 n (~ i))) ind)) flattenElim {n = suc n} {m = suc m} M PMHyp zero = PMHyp zero zero flattenElim {P = P} {n = suc n} {m = suc m} M PMHyp (suc i) = ++FinElim {P = P} (M zero ∘ suc) (flatten (M ∘ suc)) (PMHyp zero ∘ suc) (flattenElim {P = P} (M ∘ suc) (PMHyp ∘ suc)) i module ProdFin (R' : CommRing ℓ) where private R = fst R' open CommRingStr (snd R') renaming ( is-set to isSetR ) open CommRingTheory R' open RingTheory (CommRing→Ring R') open KroneckerDelta (CommRing→Ring R') open Sum (CommRing→Ring R') toMatrix : {n m : ℕ} → FinVec R n → FinVec R m → FinMatrix R n m toMatrix V W i j = V i · W j _··Fin_ : {n m : ℕ} → FinVec R n → FinVec R m → FinVec R (n ·ℕ m) V ··Fin W = flatten (toMatrix V W) Length1··Fin : ∀ (x y : R) → replicateFinVec 1 (x · y) ≡ (replicateFinVec 1 x) ··Fin (replicateFinVec 1 y) Length1··Fin x y = sym (++FinRid (replicateFinVec 1 (x · y)) _) ∑Dist··Fin : {n m : ℕ} (U : FinVec R n) (V : FinVec R m) → (∑ U) · (∑ V) ≡ ∑ (U ··Fin V) ∑Dist··Fin {n = zero} U V = 0LeftAnnihilates _ ∑Dist··Fin {n = suc n} U V = (U zero + ∑ (U ∘ suc)) · (∑ V) ≡⟨ ·Ldist+ _ _ _ ⟩ U zero · (∑ V) + (∑ (U ∘ suc)) · (∑ V) ≡⟨ cong₂ (_+_) (∑Mulrdist _ V) (∑Dist··Fin (U ∘ suc) V) ⟩ ∑ (λ j → U zero · V j) + ∑ ((U ∘ suc) ··Fin V) ≡⟨ sym (∑Split++ (λ j → U zero · V j) _) ⟩ ∑ ((λ j → U zero · V j) ++Fin ((U ∘ suc) ··Fin V)) ∎ ·Dist··Fin : {n m : ℕ} (α U : FinVec R n) (β V : FinVec R m) → ∀ j → ((λ i → α i · U i) ··Fin (λ i → β i · V i)) j ≡ (α ··Fin β) j · (U ··Fin V) j ·Dist··Fin {n = n} {m = m} α U β V = equivΠ e (equivHelper α U β V ) .fst λ _ → ·-commAssocSwap _ _ _ _ where e = (FinProdChar.Equiv n m) equivHelper : {n m : ℕ} (α U : FinVec R n) (β V : FinVec R m) (a : Fin n × Fin m) → (α (fst a) · U (fst a) · (β (snd a) · V (snd a)) ≡ α (fst a) · β (snd a) · (U (fst a) · V (snd a))) ≃ (((λ i → α i · U i) ··Fin (λ i → β i · V i)) (FinProdChar.Equiv n m .fst a) ≡ (α ··Fin β) (FinProdChar.Equiv n m .fst a) · (U ··Fin V) (FinProdChar.Equiv n m .fst a)) equivHelper {n = suc n} {m = suc m} α U β V (zero , zero) = idEquiv _ equivHelper {n = suc n} {m = suc m} α U β V (zero , suc j) = transport (λ 𝕚 → (α zero · U zero · (β (suc j) · V (suc j)) ≡ α zero · β (suc j) · (U zero · V (suc j))) ≃ (FinSumChar.++FinInl m (n ·ℕ suc m) (λ x → α zero · U zero · (β (suc x) · V (suc x))) (flatten (λ x y → α (suc x) · U (suc x) · (β y · V y))) j 𝕚 ≡ (FinSumChar.++FinInl m (n ·ℕ suc m) (λ x → α zero · β (suc x)) (flatten (λ x y → α (suc x) · β y)) j 𝕚) · (FinSumChar.++FinInl m (n ·ℕ suc m) (λ x → U zero · V (suc x)) (flatten (λ x y → U (suc x) · V y)) j 𝕚))) (idEquiv _) equivHelper {n = suc n} {m = suc m} α U β V (suc i , j) = transport (λ 𝕚 → (α (suc i) · U (suc i) · (β j · V j) ≡ α (suc i) · β j · (U (suc i) · V j)) ≃ (FinSumChar.++FinInr m (n ·ℕ suc m) (λ x → α zero · U zero · (β (suc x) · V (suc x))) (flatten (λ x y → α (suc x) · U (suc x) · (β y · V y))) (FinProdChar.Equiv n (suc m) .fst (i , j)) 𝕚 ≡ (FinSumChar.++FinInr m (n ·ℕ suc m) (λ x → α zero · β (suc x)) (flatten (λ x y → α (suc x) · β y)) (FinProdChar.Equiv n (suc m) .fst (i , j)) 𝕚) · (FinSumChar.++FinInr m (n ·ℕ suc m) (λ x → U zero · V (suc x)) (flatten (λ x y → U (suc x) · V y)) (FinProdChar.Equiv n (suc m) .fst (i , j)) 𝕚))) (equivHelper (α ∘ suc) (U ∘ suc) β V _)
{ "alphanum_fraction": 0.5583213867, "avg_line_length": 45.5370919881, "ext": "agda", "hexsha": "7b93e223ae2fb22c9c92e8ec26f4ae0101aed856", "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": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dolio/cubical", "max_forks_repo_path": "Cubical/Algebra/Matrix.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "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": "dolio/cubical", "max_issues_repo_path": "Cubical/Algebra/Matrix.agda", "max_line_length": 140, "max_stars_count": null, "max_stars_repo_head_hexsha": "8d687c1a6237ad2db1396c6b0af6667bd203f548", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dolio/cubical", "max_stars_repo_path": "Cubical/Algebra/Matrix.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5919, "size": 15346 }
-- {-# OPTIONS -v term:30 #-} -- 2010-10-14 module ProjectionsPreserveGuardednessTrivialExample where open import Common.Level open import Common.Coinduction open import Common.Product -- Streams infixr 5 _∷_ data Stream (A : Set) : Set where _∷_ : (x : A) (xs : ∞ (Stream A)) → Stream A mutual repeat : {A : Set}(a : A) → Stream A repeat a = a ∷ proj₂ (repeat' a) repeat' : {A : Set}(a : A) → A × ∞ (Stream A) repeat' a = a , ♯ repeat a
{ "alphanum_fraction": 0.6285714286, "avg_line_length": 19.7826086957, "ext": "agda", "hexsha": "148568f2bfc61dbdec3003eaa376ac20547434ae", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/ProjectionsPreserveGuardednessTrivialExample.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/ProjectionsPreserveGuardednessTrivialExample.agda", "max_line_length": 57, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/ProjectionsPreserveGuardednessTrivialExample.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": 163, "size": 455 }
-- Testing how the pragmas are saved in the Agda interface files (using -- the program dump-agdai interface). -- 13 July 2012. Because for example the pragma BUILTIN is not a -- PragmaOption it is not saved in iPragmaOptions, i.e. -- -- iPragmaOptions = [] module NoOptionPragma where data Bool : Set where true false : Bool {-# BUILTIN BOOL Bool #-} {-# BUILTIN TRUE true #-} {-# BUILTIN FALSE false #-}
{ "alphanum_fraction": 0.6987951807, "avg_line_length": 24.4117647059, "ext": "agda", "hexsha": "eff824d600d74ae4986540d98f956a6a52daa9b4", "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": "notes/agda-interface/NoOptionPragma.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": "notes/agda-interface/NoOptionPragma.agda", "max_line_length": 71, "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": "notes/agda-interface/NoOptionPragma.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": 108, "size": 415 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Level where open import Agda.Primitive using (Level ; _⊔_ ; Setω) renaming (lzero to 0ℓ ; lsuc to ++_) public record Lifted ℓ {aℓ} (𝕒 : Set aℓ) : Set (ℓ ⊔ aℓ) where constructor lift field lower : 𝕒
{ "alphanum_fraction": 0.6699346405, "avg_line_length": 30.6, "ext": "agda", "hexsha": "5d457eefea534e5dedde1d5070ee0bb5ad08c388", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "Light/Level.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "Light/Level.agda", "max_line_length": 97, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "Light/Level.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 104, "size": 306 }
open import Kaleid as K using () open import Extract (K.kompile-funp) using (kompile) open import ReflHelper open import Data.Nat open import Data.Nat.Properties open import Data.List as L using (List; []; _∷_) open import Data.Fin using (Fin; zero; suc; fromℕ<) open import Relation.Binary.PropositionalEquality open import Relation.Nullary open import Reflection hiding (_≟_; _>>=_; return) open import Structures open import Function test1-f : ℕ → ℕ test1-f x = 1 + x test₁ : kompile test1-f [] [] ≡ ok _ test₁ = refl test2-f : ℕ → ℕ → ℕ test2-f (suc x) (suc y) = suc $ test2-f x y test2-f _ _ = 0 test₂ : kompile test2-f [] [] ≡ ok _ test₂ = refl test3-f : (a b : ℕ) → a ≡ b → ℕ test3-f a b _ = a ∸ b test₃ : kompile test3-f [] [] ≡ ok _ test₃ = refl test4-f : (x : ℕ) → x ≡ 0 → (y : ℕ) → x ≡ y → ℕ test4-f x () (suc y) refl test4-f x x=0 zero x=y = 0 test₄ : kompile test4-f [] [] ≡ ok _ test₄ = refl -- _>_ is not (yet) supported, so no test₅ for now. test5-f : (x y : ℕ) → x > y → ℕ test5-f 0 0 () test5-f 0 x _ = x test5-f (suc x) y _ = x + y test6-f : (x y : ℕ) → ℕ test6-f x y with x ≟ y ... | yes pf = 1 ... | _ = 2 test₆ = kompile test6-f (quote _≟_ ∷ []) [] test7-f : (n : ℕ) → Fin (suc (n * n)) test7-f n = fromℕ< ≤-refl test8-f : ℕ → ℕ test8-f x = let a = x * x + 3 * x + 5 in a + a test-args : (a b c d : ℕ) → ℕ test-args a b c d = a + b + c + d test-args2 : (a b : ℕ) → ℕ test-args2 a b = test-args a b a b
{ "alphanum_fraction": 0.5867768595, "avg_line_length": 18.8571428571, "ext": "agda", "hexsha": "aab38af70b496f4661453a6b7bcd9400c7f0d8c6", "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": "c8954c8acd8089ced82af9e05084fbbc7fedb36c", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "ashinkarov/agda-extractor", "max_forks_repo_path": "KalExample-00.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c8954c8acd8089ced82af9e05084fbbc7fedb36c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "ashinkarov/agda-extractor", "max_issues_repo_path": "KalExample-00.agda", "max_line_length": 52, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c8954c8acd8089ced82af9e05084fbbc7fedb36c", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "ashinkarov/agda-extractor", "max_stars_repo_path": "KalExample-00.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-11T14:52:59.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-11T14:52:59.000Z", "num_tokens": 590, "size": 1452 }
module AnyRelational where open import Data.Function open import Data.Unit open import Data.Empty open import Data.Bool open import Data.Nat open import Data.List hiding (any) open import Data.Sum open import Data.Product open import Relation.Nullary open import Relation.Nullary.Decidable renaming (map to dec-map) open import Relation.Binary.PropositionalEquality Pred : Set → Set₁ Pred A = A → Set _∈_ : {A : Set} → A → Pred A → Set a ∈ P = P a data Even : ℕ → Set where zero : Even 0 suc : {n : ℕ} → Even n → Even (suc (suc n)) 6-Even : 6 ∈ Even 6-Even = suc (suc (suc zero)) data Odd : ℕ → Set where zero : Odd 1 suc : {n : ℕ} → Odd n → Odd (suc (suc n)) 5-Odd : 5 ∈ Odd 5-Odd = suc (suc zero) data Any {A : Set} (P : Pred A) : List A → Set where here : ∀ {x xs} → x ∈ P → Any P (x ∷ xs) there : ∀ {x xs} → Any P xs → Any P (x ∷ xs) test-any-even : Any Even (3 ∷ 6 ∷ 9 ∷ []) test-any-even = there (here 6-Even) test-any-odd : Any Odd (3 ∷ 5 ∷ 10 ∷ []) test-any-odd = there (here 5-Odd) U : {A : Set} → Pred A U _ = ⊤ 42-U : 42 ∈ U 42-U = tt true-U : true ∈ U true-U = tt Universal : {A : Set} → Pred A → Set Universal P = ∀ a → a ∈ P U-Universal : {A : Set} → Universal {A} U U-Universal _ = tt _∪_ : {A : Set} → Pred A → Pred A → Pred A P ∪ Q = λ a → P a ⊎ Q a evenOrOdd : Universal (Even ∪ Odd) evenOrOdd 0 = inj₁ zero evenOrOdd 1 = inj₂ zero evenOrOdd (suc n) with evenOrOdd n ... | inj₁ p = inj₂ (evenSucOdd p) where evenSucOdd : ∀ {n} → Even n → Odd (suc n) evenSucOdd zero = zero evenSucOdd (suc n) = suc (evenSucOdd n) ... | inj₂ p = inj₁ (oddSucEven p) where oddSucEven : ∀ {n} → Odd n → Even (suc n) oddSucEven zero = suc zero oddSucEven (suc n) = suc (oddSucEven n) ∁ : {A : Set} → Pred A → Pred A ∁ P = λ a → ¬ (P a) _⇒_ : {A : Set} → Pred A → Pred A → Set P ⇒ Q = ∀ {a} → P a → Q a predOdd : ∀ {n} → Odd (suc (suc n)) → Odd n predOdd (suc n) = n even⇒¬odd : Even ⇒ ∁ Odd even⇒¬odd zero = λ() even⇒¬odd (suc e) with even⇒¬odd e even⇒¬odd (suc e) | f = λ o → f (predOdd o) ∅ : {A : Set} → Pred A ∅ _ = ⊥ _∉_ : {A : Set} → A → Pred A → Set a ∉ P = ¬ (a ∈ P) 42-¬∅ : 42 ∉ ∅ 42-¬∅ () true-¬∅ : true ∉ ∅ true-¬∅ () Empty : {A : Set} → Pred A → Set Empty P = ∀ a → a ∉ P ∅-Empty : {A : Set} → Empty {A} ∅ ∅-Empty _ () ∁∅-Universal : {A : Set} → Universal {A} (∁ ∅) ∁∅-Universal _ () ∁U-Empty : {A : Set} → Empty {A} (∁ U) ∁U-Empty _ ∁U = ∁U tt test-any-6≡ : Any ( _≡_ 6) (3 ∷ 6 ∷ 9 ∷ []) test-any-6≡ = there (here refl) find : ∀ {A : Set} {P : Pred A} {as : List A} → Any P as → ∃ (λ a → Any (_≡_ a) as × a ∈ P) find (here p) = _ , (here refl , p) find (there ps) = Data.Product.map id (Data.Product.map there id) (find ps) -- test-any-even : Any Even (3 ∷ 6 ∷ 9 ∷ []) -- test-any-even = there (here (suc (suc (suc zero)))) -- 6-found : proj₁ (find test-any-even) ≡ 6 -- 6-found = refl -- 6-Even : 6 ∈ Even -- 6-Even = proj₂ (proj₂ (find test-any-even)) -- test-any-6≡ : Any (_≡_ 6) (3 ∷ 6 ∷ 9 ∷ []) -- test-any-6≡ = proj₁ (proj₂ (find test-any-even)) tail : ∀ {A x xs} {P : Pred A} → x ∉ P → Any P (x ∷ xs) → Any P xs tail ¬p (here p) = ⊥-elim (¬p p) tail ¬p (there ps) = ps any : {A : Set} {P : Pred A} → (∀ x → Dec (x ∈ P)) → (xs : List A) → Dec (Any P xs) any f [] = no λ() any f (x ∷ xs) with f x any f (x ∷ xs) | yes p = yes (here p) any f (x ∷ xs) | no ¬p = dec-map (there , tail ¬p) (any f xs) predEven : ∀ {n} → Even (suc (suc n)) → Even n predEven (suc n) = n even¬Consecutive : ∀ {n} → n ∈ Even → suc n ∉ Even even¬Consecutive zero = λ () even¬Consecutive (suc n) with even¬Consecutive n ... | ¬p = λ e → ¬p (predEven e) postulate ¬even¬Consecutive : ∀ {n} → n ∉ Even → suc n ∈ Even Dec-Even : ∀ n → Dec (n ∈ Even) Dec-Even zero = yes zero Dec-Even (suc zero) = no λ() Dec-Even (suc n) with Dec-Even n ... | yes p = no (even¬Consecutive p) ... | no ¬p = yes (¬even¬Consecutive ¬p) dec-any-even : Dec (Any Even (3 ∷ 6 ∷ 9 ∷ [])) dec-any-even = any Dec-Even (3 ∷ 6 ∷ 9 ∷ [])
{ "alphanum_fraction": 0.5485316078, "avg_line_length": 24.0598802395, "ext": "agda", "hexsha": "61b9884ede15724e6404878a9d92f94dce59ebd3", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T12:03:09.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T12:03:09.000Z", "max_forks_repo_head_hexsha": "60f71d369015b83b9ef5fabc75a70f367d20ac97", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/bahug-april2010", "max_forks_repo_path": "AnyRelational.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "60f71d369015b83b9ef5fabc75a70f367d20ac97", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/bahug-april2010", "max_issues_repo_path": "AnyRelational.agda", "max_line_length": 66, "max_stars_count": null, "max_stars_repo_head_hexsha": "60f71d369015b83b9ef5fabc75a70f367d20ac97", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/bahug-april2010", "max_stars_repo_path": "AnyRelational.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1668, "size": 4018 }
module Abstract where data Bool : Set where true false : Bool not : Bool → Bool not true = false not false = true abstract Answer : Set Answer = Bool yes : Answer yes = true no : Answer no = false data _≡_ {A : Set}(x : A) : A → Set where refl : x ≡ x data Box : Set where [_] : Answer → Box bad-box : Box bad-box = [ true ]
{ "alphanum_fraction": 0.6022727273, "avg_line_length": 12.5714285714, "ext": "agda", "hexsha": "8763067f5ca2eaf9889c8363b4f404240c22f2dc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/Abstract.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/Abstract.agda", "max_line_length": 41, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/fail/Abstract.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 119, "size": 352 }
{-# OPTIONS --rewriting #-} module Examples.Run where open import Agda.Builtin.Equality using (_≡_; refl) open import Luau.Syntax using (nil; var; _$_; function_is_end; return; _∙_; done; _⟨_⟩; number; binexp; +) open import Luau.Value using (nil; number) open import Luau.Run using (run; return) open import Luau.Heap using (lookup-next; next-emp; lookup-next-emp) import Agda.Builtin.Equality.Rewrite {-# REWRITE lookup-next next-emp lookup-next-emp #-} ex1 : (run (function "id" ⟨ var "x" ⟩ is return (var "x") ∙ done end ∙ return (var "id" $ nil) ∙ done) ≡ return nil _) ex1 = refl ex2 : (run (function "fn" ⟨ var "x" ⟩ is return (number 123.0) ∙ done end ∙ return (var "fn" $ nil) ∙ done) ≡ return (number 123.0) _) ex2 = refl ex3 : (run (function "fn" ⟨ var "x" ⟩ is return (binexp (number 1.0) + (number 2.0)) ∙ done end ∙ return (var "fn" $ nil) ∙ done) ≡ return (number 3.0) _) ex3 = refl
{ "alphanum_fraction": 0.6592920354, "avg_line_length": 41.0909090909, "ext": "agda", "hexsha": "534bb122b3a20baecf1262f05e1ccc3bb5930a51", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_path": "prototyping/Examples/Run.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Tr4shh/Roblox-Luau", "max_issues_repo_path": "prototyping/Examples/Run.agda", "max_line_length": 154, "max_stars_count": null, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/Examples/Run.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 320, "size": 904 }
-- Andreas, 2013-05-02 This ain't a bug, it is a feature. -- {-# OPTIONS -v scope.name:10 #-} -- {-# OPTIONS -v scope:10 #-} module Issue836 where module M where record R : Set₁ where field X : Set open M using (R) X : R → Set X = R.X -- A glimpse at the scope (showing only concrete names, though): -- modules -- * scope Issue836 -- private names R --> [Issue836.M.R] -- public modules M --> [Issue836.M] -- * scope Issue836.M -- public names R --> [Issue836.M.R] -- modules R --> [Issue836.M.R] -- * scope Issue836.M.R -- public names X --> [Issue836.M.R.X] -- Nisse: -- The open directive did not mention the /module/ R, so (I think -- that) the code above should be rejected. -- Andreas: -- NO, it is a feature that projections can also be accessed via -- the record /type/. -- Ulf: -- With the fix to 836 using (R) now means using (R; module R).
{ "alphanum_fraction": 0.5916398714, "avg_line_length": 23.9230769231, "ext": "agda", "hexsha": "074c3409f61d116e5b73502ad7038fc619359cdc", "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/Issue836.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/Issue836.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue836.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": 272, "size": 933 }
{-# OPTIONS --rewriting --without-K #-} open import Agda.Primitive open import Prelude import GSeTT.Typed-Syntax import Globular-TT.Syntax {- Type theory for globular sets -} module Globular-TT.Typed-Syntax {l} (index : Set l) (rule : index → GSeTT.Typed-Syntax.Ctx × (Globular-TT.Syntax.Pre-Ty index)) (eqdec-index : eqdec index) where open import Globular-TT.Syntax index open import Globular-TT.Rules index rule open import Globular-TT.Eqdec-syntax index eqdec-index open import Globular-TT.Uniqueness-Derivations index rule eqdec-index Ctx : Set (lsuc l) Ctx = Σ Pre-Ctx (λ Γ → Γ ⊢C) Ty : Ctx → Set (lsuc l) Ty (Γ , _) = Σ Pre-Ty (λ A → Γ ⊢T A) Tm : ∀ (Γ : Ctx) → Ty Γ → Set (lsuc l) Tm (Γ , _) (A , _) = Σ Pre-Tm (λ t → Γ ⊢t t # A) Sub : ∀ (Δ : Ctx) (Γ : Ctx) → Set (lsuc l) Sub (Δ , _) (Γ , _) = Σ Pre-Sub (λ γ → Δ ⊢S γ > Γ) eqC : ∀ (Γ Δ : Ctx) → fst Γ == fst Δ → Γ == Δ eqC (Γ , Γ⊢) (.Γ , Γ⊢') idp = Σ= idp (has-all-paths-⊢C _ _) eqT : ∀ {Γ} (A B : Ty Γ) → fst A == fst B → A == B eqT (A , Γ⊢A) (.A , Γ⊢'A) idp = Σ= idp (has-all-paths-⊢T _ _) eqt : ∀ {Γ A} (t u : Tm Γ A) → fst t == fst u → t == u eqt (t , Γ⊢t:A) (.t , Γ⊢':A) idp = Σ= idp (has-all-paths-⊢t _ _) eqS : ∀ {Γ Δ} (γ δ : Sub Γ Δ) → fst γ == fst δ → γ == δ eqS (γ , Γ⊢γ:Δ) (.γ , Γ⊢'γ:Δ) idp = Σ= idp (has-all-paths-⊢S _ _) trS : ∀ {Γ Δ Θ : Ctx} → (p : Δ == Θ) → {γ : Sub Γ Δ} → {δ : Sub Γ Θ} → fst γ == fst δ → transport p γ == δ trS {Γ} {Δ} {Θ} idp {γ} {δ} x = eqS {Γ} {Θ} γ δ x private eqdec-typedTy : ∀ Γ → eqdec (Ty Γ) eqdec-typedTy Γ (A , Γ⊢A) (B , Γ⊢B) with eqdec-Ty A B ... | inl idp = inl (eqT {Γ} (A , Γ⊢A) (B , Γ⊢B) idp) ... | inr A≠B = inr λ p → A≠B (fst-is-inj p) is-set-Ty : ∀ Γ → is-set (Ty Γ) is-set-Ty Γ = eqdec-is-set (eqdec-typedTy Γ)
{ "alphanum_fraction": 0.5323741007, "avg_line_length": 33.462962963, "ext": "agda", "hexsha": "778bab7ffcc6c9a234d164ec0c5db0598106c7cd", "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": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thibautbenjamin/catt-formalization", "max_forks_repo_path": "Globular-TT/Typed-Syntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "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": "thibautbenjamin/catt-formalization", "max_issues_repo_path": "Globular-TT/Typed-Syntax.agda", "max_line_length": 128, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thibautbenjamin/catt-formalization", "max_stars_repo_path": "Globular-TT/Typed-Syntax.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 859, "size": 1807 }
{- Comparison view and associated lemmas -} module TemporalOps.Common.Compare where open import CategoryTheory.Categories open import Relation.Binary.PropositionalEquality as ≡ open import Relation.Binary.HeterogeneousEquality as ≅ open import Data.Nat.Properties using (+-identityʳ ; +-assoc ; +-suc) open import Data.Nat using (ℕ ; zero ; suc ; _+_) public -- (Very verbose) comparison view -- Like 'compare', but only distinguishes ≤ or >. data LeqOrdering : ℕ -> ℕ -> Set where snd==[_+_] : ∀ k l → LeqOrdering k (k + l) fst==suc[_+_] : ∀ k l → LeqOrdering (k + suc l) k -- Auxiliary function to compareLeq compareLeq-suc : ∀ n k -> LeqOrdering n k -> LeqOrdering (suc n) (suc k) compareLeq-suc n .(n + l) snd==[ .n + l ] = snd==[ suc n + l ] compareLeq-suc .(k + suc l) k fst==suc[ .k + l ] = fst==suc[ suc k + l ] compareLeq : ∀ n k -> LeqOrdering n k compareLeq zero k = snd==[ zero + k ] compareLeq (suc n) zero = fst==suc[ zero + n ] compareLeq (suc n) (suc k) = compareLeq-suc n k (compareLeq n k) -- Lemmas for compareLeq -- Comparing n and (n + k) always gives snd==[ n + k ] compare-snd : ∀ (n k : ℕ) -> compareLeq n (n + k) ≡ snd==[ n + k ] compare-snd zero k = refl compare-snd (suc n) k rewrite compare-snd n k = refl -- If n ≤ n + k, then l + n  ≤ (l + n) + k compare-snd-+ : ∀ (n k l : ℕ) -> compareLeq n (n + k) ≡ snd==[ n + k ] -> compareLeq (l + n) ((l + n) + k) ≡ snd==[ (l + n) + k ] compare-snd-+ n k zero pf = pf compare-snd-+ zero k (suc l) pf rewrite +-identityʳ l = compare-snd (suc l) k compare-snd-+ (suc n) k (suc l) pf rewrite +-suc l n | compare-snd (l + n) k = refl -- Heterogeneous version of compare-snd-+ with associativity compare-snd-+-assoc : ∀ (n k l : ℕ) -> compareLeq n (n + k) ≡ snd==[ n + k ] -> compareLeq (l + n) (l + (n + k)) ≅ snd==[ (l + n) + k ] compare-snd-+-assoc n k l pf = begin compareLeq (l + n) (l + (n + k)) ≅⟨ ≅.cong (λ x → compareLeq (l + n) x) (≡-to-≅ (≡.sym (+-assoc l n k))) ⟩ compareLeq (l + n) ((l + n) + k) ≅⟨ ≡-to-≅ (compare-snd-+ n k l pf) ⟩ snd==[ (l + n) + k ] ∎ where open ≅.≅-Reasoning -- Comparing (n + suc k and n always gives fst==suc[ n + k ] compare-fst : ∀ (n k : ℕ) -> compareLeq (n + suc k) n ≡ fst==suc[ n + k ] compare-fst zero k = refl compare-fst (suc n) k rewrite compare-fst n k = refl -- If n + suc k > n, then (l + n) + suc k  > l + n compare-fst-+ : ∀ (n k l : ℕ) -> compareLeq (n + suc k) n ≡ fst==suc[ n + k ] -> compareLeq ((l + n) + suc k) (l + n) ≡ fst==suc[ (l + n) + k ] compare-fst-+ n k zero pf = pf compare-fst-+ zero k (suc l) pf rewrite +-identityʳ l = compare-fst (suc l) k compare-fst-+ (suc n) k (suc l) pf rewrite +-suc l n | compare-fst (l + n) k = refl -- Heterogeneous version of compare-fst-+ with associativity compare-fst-+-assoc : ∀ (n k l : ℕ) -> compareLeq (n + suc k) n ≡ fst==suc[ n + k ] -> compareLeq (l + (n + suc k)) (l + n) ≅ fst==suc[ (l + n) + k ] compare-fst-+-assoc n k l pf = begin compareLeq (l + (n + suc k)) (l + n) ≅⟨ ≅.cong (λ x → compareLeq x (l + n)) (≡-to-≅ (≡.sym (+-assoc l n (suc k)))) ⟩ compareLeq ((l + n) + suc k) (l + n) ≅⟨ ≡-to-≅ (compare-fst-+ n k l pf) ⟩ fst==suc[ (l + n) + k ] ∎ where open ≅.≅-Reasoning
{ "alphanum_fraction": 0.5458320973, "avg_line_length": 41.1097560976, "ext": "agda", "hexsha": "1c593d6d6378f8c02fb35a84789ca6020d8c26be", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_path": "src/TemporalOps/Common/Compare.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DimaSamoz/temporal-type-systems", "max_issues_repo_path": "src/TemporalOps/Common/Compare.agda", "max_line_length": 84, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_path": "src/TemporalOps/Common/Compare.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "num_tokens": 1332, "size": 3371 }
open import Oscar.Prelude open import Oscar.Class.HasEquivalence open import Oscar.Data.Substitunction open import Oscar.Data.Proposequality import Oscar.Property.Setoid.Proposextensequality open import Oscar.Class import Oscar.Data.Constraint module Oscar.Class.HasEquivalence.Substitunction where module _ {𝔭} {𝔓 : Ø 𝔭} where open Substitunction 𝔓 instance HasEquivalenceSubstitunction : ∀ {x y} → HasEquivalence (Substitunction x y) _ HasEquivalenceSubstitunction = ∁ Proposextensequality
{ "alphanum_fraction": 0.8098039216, "avg_line_length": 25.5, "ext": "agda", "hexsha": "01a1b5d27cc970b4b51884a36237cfc405d008b7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/HasEquivalence/Substitunction.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/HasEquivalence/Substitunction.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/HasEquivalence/Substitunction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 135, "size": 510 }
{-# OPTIONS --safe #-} module Cubical.HITs.S2.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Pointed open import Cubical.Foundations.Function open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Path open import Cubical.HITs.S1.Base open import Cubical.HITs.S2.Base open import Cubical.HITs.Susp open import Cubical.Homotopy.Loopspace S²ToSetElim : ∀ {ℓ} {A : S² → Type ℓ} → ((x : S²) → isSet (A x)) → A base → (x : S²) → A x S²ToSetElim set b base = b S²ToSetElim set b (surf i j) = isOfHLevel→isOfHLevelDep 2 set b b {a0 = refl} {a1 = refl} refl refl surf i j -- Wedge connectivity lemmas for S² (binary maps 2-groupoids) wedgeconFunS² : ∀ {ℓ} {P : S² → S² → Type ℓ} → ((x y : _) → isOfHLevel 4 (P x y)) → (l : ((x : S²) → P x base)) → (r : (x : S²) → P base x) → l base ≡ r base → (x y : _) → P x y wedgeconFunS² {P = P} hlev l r p base y = r y wedgeconFunS² {P = P} hlev l r p (surf i i₁) y = help y i i₁ where help : (y : S²) → SquareP (λ i j → P (surf i j) y) (λ _ → r y) (λ _ → r y) (λ _ → r y) λ _ → r y help = S²ToSetElim (λ _ → isOfHLevelPathP' 2 (isOfHLevelPathP' 3 (hlev _ _) _ _) _ _) λ w j → hcomp (λ k → λ { (j = i0) → p k ; (j = i1) → p k ; (w = i0) → p k ; (w = i1) → p k}) (l (surf w j)) wedgeconFunS²Id : ∀ {ℓ} {P : S² → S² → Type ℓ} → (h : ((x y : _) → isOfHLevel 4 (P x y))) → (l : ((x : S²) → P x base)) → (r : (x : S²) → P base x) → (p : l base ≡ r base) → (x : S²) → wedgeconFunS² h l r p x base ≡ l x wedgeconFunS²Id h l r p base = sym p wedgeconFunS²Id h l r p (surf i j) k = hcomp (λ w → λ {(i = i0) → p (~ k ∧ w) ; (i = i1) → p (~ k ∧ w) ; (j = i0) → p (~ k ∧ w) ; (j = i1) → p (~ k ∧ w) ; (k = i1) → l (surf i j)}) (l (surf i j)) S¹×S¹→S² : S¹ → S¹ → S² S¹×S¹→S² base y = base S¹×S¹→S² (loop i) base = base S¹×S¹→S² (loop i) (loop j) = surf i j invS² : S² → S² invS² base = base invS² (surf i j) = surf j i S¹×S¹→S²-anticomm : (x y : S¹) → invS² (S¹×S¹→S² x y) ≡ S¹×S¹→S² y x S¹×S¹→S²-anticomm base base = refl S¹×S¹→S²-anticomm base (loop i) = refl S¹×S¹→S²-anticomm (loop i) base = refl S¹×S¹→S²-anticomm (loop i) (loop i₁) = refl toSuspPresInvS² : (x : S²) → toSusp S²∙ (invS² x) ≡ sym (toSusp S²∙ x) toSuspPresInvS² base = rCancel (merid base) ∙∙ refl ∙∙ cong sym (sym (rCancel (merid base))) toSuspPresInvS² (surf i j) k r = hcomp (λ l → λ {(i = i0) → cc l k r ; (i = i1) → cc l k r ; (j = i0) → cc l k r ; (j = i1) → cc l k r ; (k = i0) → l1-fill j i r (~ l) ; (k = i1) → l1-fill i j (~ r) (~ l) ; (r = i0) → north ; (r = i1) → north}) (l1≡l2 k j i r) where cc : Cube {A = Susp S²} _ _ _ _ _ _ cc = doubleCompPath-filler (rCancel (merid base)) refl (cong sym (sym (rCancel (merid base)))) l1-fill : (i j k r : I) → Susp S² l1-fill i j k r = hfill (λ r → λ {(i = i0) → rCancel (merid base) r k ; (i = i1) → rCancel (merid base) r k ; (j = i0) → rCancel (merid base) r k ; (j = i1) → rCancel (merid base) r k ; (k = i0) → north ; (k = i1) → north}) (inS (toSusp S²∙ (surf i j) k)) r l1 : (Ω^ 3) (Susp∙ S²) .fst l1 i j k = l1-fill i j k i1 l2 : (Ω^ 3) (Susp∙ S²) .fst l2 i j k = l1 j i (~ k) sym≡cong-sym-refl : ∀ {ℓ} {A : Type ℓ} {x : A} → sym≡cong-sym (λ _ _ → x) ≡ refl sym≡cong-sym-refl {x = x} = transportRefl (λ _ _ _ → x) l1≡l2 : l1 ≡ l2 l1≡l2 = sym (sym≡flipSquare (λ i j → l1 j i)) ∙ ((λ _ i j k → l1 j (~ i) k) ∙ λ r i j k → hcomp (λ l → λ {(i = i0) → north ; (i = i1) → north ; (j = i0) → sym≡cong-sym-refl {x = north} r (~ l) i k ; (j = i1) → sym≡cong-sym-refl {x = north} r (~ l) i k ; (k = i0) → north ; (k = i1) → north ; (r = i0) → sym≡cong-sym (λ i k → l1 j i k) (~ l) i k ; (r = i1) → l2 i j k}) (l2 i j k)) S¹×S¹→S²-sym : (x y : S¹) → toSusp S²∙ (S¹×S¹→S² x y) ≡ sym (toSusp S²∙ (S¹×S¹→S² y x)) S¹×S¹→S²-sym x y = cong sym (sym (toSuspPresInvS² (S¹×S¹→S² x y))) ∙ cong (sym ∘ toSusp S²∙) (S¹×S¹→S²-anticomm x y)
{ "alphanum_fraction": 0.4632554222, "avg_line_length": 35.4402985075, "ext": "agda", "hexsha": "3d4b60fe14d2b6ae34d48fcacfd255392e8fa665", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/S2/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/HITs/S2/Properties.agda", "max_line_length": 87, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/S2/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 1964, "size": 4749 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Product.Properties where -- properties of the product _※_ of Functors (so probably should be renamed?) open import Level open import Data.Product open import Categories.Category open import Categories.Functor renaming (id to idF) open import Categories.NaturalTransformation using (NaturalTransformation; ntHelper) renaming (id to idNI) open import Categories.NaturalTransformation.NaturalIsomorphism open import Categories.Category.Product open import Categories.Morphism import Categories.Morphism.Reasoning as MR private variable o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ : Level -- variables don't work quite right, use anonymous module instead module _ {A : Category o ℓ e} {B : Category o′ ℓ′ e′} {C : Category o″ ℓ″ e″} {i : Functor C A} {j : Functor C B} where project₁ : πˡ ∘F (i ※ j) ≃ i project₁ = record { F⇒G = ntHelper record { η = λ _ → id ; commute = λ _ → id-comm-sym } ; F⇐G = ntHelper record { η = λ _ → id ; commute = λ _ → id-comm-sym } ; iso = λ X → record { isoˡ = identityˡ ; isoʳ = identityʳ } } where open Category A; open MR.Basic A project₂ : πʳ ∘F (i ※ j) ≃ j project₂ = record { F⇒G = ntHelper record { η = λ _ → id ; commute = λ _ → id-comm-sym } ; F⇐G = ntHelper record { η = λ _ → id ; commute = λ _ → id-comm-sym } ; iso = λ X → record { isoˡ = identityˡ ; isoʳ = identityʳ } } where open Category B; open MR.Basic B unique : {h : Functor C (Product A B)} → πˡ ∘F h ≃ i → πʳ ∘F h ≃ j → (i ※ j) ≃ h unique πˡ→i πʳ→j = record { F⇒G = ntHelper record { η = < L⇐.η , R⇐.η > ; commute = < L⇐.commute , R⇐.commute > } ; F⇐G = ntHelper record { η = < L⇒.η , R⇒.η > ; commute = < L⇒.commute , R⇒.commute > } ; iso = λ X → let L = iso πˡ→i X R = iso πʳ→j X in record { isoˡ = isoʳ L , isoʳ R ; isoʳ = isoˡ L , isoˡ R } } where open NaturalIsomorphism module L⇐ = NaturalTransformation (F⇐G πˡ→i) module R⇐ = NaturalTransformation (F⇐G πʳ→j) module L⇒ = NaturalTransformation (F⇒G πˡ→i) module R⇒ = NaturalTransformation (F⇒G πʳ→j) open Iso -- further properties of products module _ (C : Category o ℓ e) (D : Category o′ ℓ′ e′) where private C×D : Category _ _ _ C×D = Product C D module C×D = Category C×D module C = Category C module D = Category D -- TODO: write an "essentially-equal" combinator for cases such as these? πˡ※πʳ≃id : (πˡ ※ πʳ) ≃ idF {C = C×D} πˡ※πʳ≃id = record { F⇒G = ntHelper record { η = λ _ → C×D.id ; commute = λ _ → MR.id-comm-sym C , MR.id-comm-sym D } ; F⇐G = ntHelper record { η = λ _ → C×D.id ; commute = λ _ → MR.id-comm-sym C , MR.id-comm-sym D } ; iso = λ X → record { isoˡ = C.identityˡ , D.identityˡ ; isoʳ = C.identityʳ , D.identityʳ } } ※-distrib : {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ : Level} {A : Category o₁ ℓ₁ e₁} {B : Category o₂ ℓ₂ e₂} → (F : Functor B C) → (G : Functor B D) → (H : Functor A B) → ((F ∘F H) ※ (G ∘F H)) ≃ ((F ※ G) ∘F H) ※-distrib F G H = record { F⇒G = ntHelper record { η = λ _ → C×D.id ; commute = λ _ → MR.id-comm-sym C , MR.id-comm-sym D } ; F⇐G = ntHelper record { η = λ _ → C×D.id ; commute = λ _ → MR.id-comm-sym C , MR.id-comm-sym D } ; iso = λ X → record { isoˡ = C.identityˡ , D.identityˡ ; isoʳ = C.identityʳ , D.identityʳ } } ※-distrib₂ : {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ : Level} {A : Category o₁ ℓ₁ e₁} {B : Category o₂ ℓ₂ e₂} → (F : Functor B C) → (G : Functor B D) → ((F ∘F πˡ) ※ (G ∘F πʳ)) ≃ (F ⁂ G) ※-distrib₂ F G = record { F⇒G = ntHelper record { η = λ X → C.id , D.id ; commute = λ _ → MR.id-comm-sym C , MR.id-comm-sym D } ; F⇐G = ntHelper record { η = λ X → C.id , D.id ; commute = λ _ → MR.id-comm-sym C , MR.id-comm-sym D } ; iso = λ X → record { isoˡ = C.identityˡ , D.identityʳ ; isoʳ = C.identityʳ , D.identityʳ } }
{ "alphanum_fraction": 0.5735660848, "avg_line_length": 37.476635514, "ext": "agda", "hexsha": "a994c4cc9436b451aede59786caa254bdd0388df", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Product/Properties.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Product/Properties.agda", "max_line_length": 107, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Product/Properties.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": 1538, "size": 4010 }
module Trans where open import Prelude Rel : Set -> Set1 Rel A = A -> A -> Set data [_]* {A : Set}(R : Rel A)(x : A) : A -> Set where ref : [ R ]* x x _▹_ : {y z : A} -> R x y -> [ R ]* y z -> [ R ]* x z infixr 40 _▹_ _▹◃_ length : {A : Set}{R : Rel A}{x y : A} -> [ R ]* x y -> Nat length ref = zero length (x ▹ xs) = suc (length xs) _=[_]=>_ : {A B : Set}(R : Rel A)(i : A -> B)(S : Rel B) -> Set R =[ i ]=> S = forall {x y} -> R x y -> S (i x) (i y) map : {A B : Set}{R : Rel A}{S : Rel B}(i : A -> B) -> (R =[ i ]=> S) -> {x y : A} -> [ R ]* x y -> [ S ]* (i x) (i y) map i f ref = ref map i f (x ▹ xs) = f x ▹ map i f xs lem-length-map : {A B : Set}{R : Rel A}{S : Rel B}(i : A -> B) (f : R =[ i ]=> S){x y : A}(xs : [ R ]* x y) -> length xs ≡ length (map {S = S} i f xs) lem-length-map i f ref = refl lem-length-map i f (x ▹ xs) = cong suc (lem-length-map i f xs) _▹◃_ : {A : Set}{R : Rel A}{x y z : A} -> [ R ]* x y -> [ R ]* y z -> [ R ]* x z ref ▹◃ ys = ys (x ▹ xs) ▹◃ ys = x ▹ (xs ▹◃ ys) lem-length▹◃ : {A : Set}{R : Rel A}{x y z : A} (r₁ : [ R ]* x y)(r₂ : [ R ]* y z) -> length r₁ + length r₂ ≡ length (r₁ ▹◃ r₂) lem-length▹◃ ref ys = refl lem-length▹◃ (x ▹ xs) ys = cong suc (lem-length▹◃ xs ys)
{ "alphanum_fraction": 0.4171732523, "avg_line_length": 29.2444444444, "ext": "agda", "hexsha": "fb55825eecdcabc7543dc1794bbd8658f356f29f", "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": "examples/outdated-and-incorrect/tait/Trans.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": "examples/outdated-and-incorrect/tait/Trans.agda", "max_line_length": 63, "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": "examples/outdated-and-incorrect/tait/Trans.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": 581, "size": 1316 }
module Coirc.Parser where open import Data.Unit open import Data.Bool open import Data.Nat open import Data.Char open import Data.String open import Data.Maybe open import Data.List hiding (_++_) open import Data.Sum open import Data.Product open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Coirc open import Coirc.Format readTo-! : List Char → Maybe (String × List Char) readTo-! [] = nothing readTo-! ('!' ∷ xs) = just ("" , '!' ∷ xs) readTo-! (x ∷ xs) with readTo-! xs ... | nothing = nothing ... | just (a , ys) = just ( fromList [ x ] ++ a , ys ) readTo-sp : List Char → Maybe (String × List Char) readTo-sp [] = nothing readTo-sp (' ' ∷ xs) = just ("" , ' ' ∷ xs) readTo-sp (x ∷ xs) with readTo-sp xs ... | nothing = nothing ... | just (a , ys) = just ( fromList [ x ] ++ a , ys ) readTo-crlf : List Char → Maybe (String × List Char) readTo-crlf [] = nothing readTo-crlf ('\r' ∷ '\n' ∷ xs) = just ("" , '\r' ∷ '\n' ∷ xs) readTo-crlf (x ∷ xs) with readTo-crlf xs ... | nothing = nothing ... | just (a , ys) = just ( fromList (x ∷ []) ++ a , ys ) read : (u : U) → List Char → Maybe (El u × List Char) read CHAR (x ∷ xs) = just (x , xs) read (DAR n) (x ∷ xs) with Data.Nat._≟_ n (toNat x) ... | no _ = nothing ... | yes p rewrite p = just (dar x , xs) read (DAR-RANGE n m) (x ∷ xs) with Data.Bool._≟_ true (within? x n m) ... | no _ = nothing ... | yes p rewrite p = just (dar x , xs) read `*! xs = readTo-! xs read `*sp xs = readTo-sp xs read `*crlf xs = readTo-crlf xs read _ [] = nothing parse : (f : Format) → List Char → Maybe (⟦ f ⟧ × List Char) parse Fail _ = nothing parse End xs = just (tt , xs) parse (As val) xs = just (val , xs) parse (Base u) xs = read u xs parse (Skip f₁ f₂) xs with parse f₁ xs ... | nothing = nothing ... | just (_ , ys) = parse f₂ ys parse (Or f₁ f₂) xs with parse f₁ xs ... | just (a , ys) = just (inj₁ a , ys) ... | nothing with parse f₂ xs ... | just (a , ys) = just (inj₂ a , ys) ... | nothing = nothing parse (And f₁ f₂) xs with parse f₁ xs ... | nothing = nothing ... | just (a , ys) with parse f₂ ys ... | nothing = nothing ... | just (b , zs) = just ((a , b) , zs) parse (Use f₁ f₂) xs with parse f₁ xs ... | nothing = nothing ... | just (a , ys) with parse (f₂ a) ys ... | nothing = nothing ... | just (b , zs) = just ((a , b) , zs) parse-Event : List Char → Maybe Event parse-Event xs with parse Notice xs ... | just (x , _) = just x ... | nothing with parse NumericReply xs ... | just (x , _) = just x ... | nothing with parse Mode xs ... | just (x , _) = just x ... | nothing with parse Ping xs ... | just (x , _) = just x ... | nothing with parse Privmsg xs ... | just ((_ , _ , x) , _) = just x ... | nothing = nothing private test : Event → String → Set test e s = just e ≡ parse-Event (toList (s ++ "\r\n")) test-Notice : test notice ":verne.freenode.net NOTICE * :*** Looking up your hostname..." test-Notice = refl test-NumericReply : test numeric ":verne.freenode.net 001 foobot-name :Welcome to the freenode Internet Relay Chat Network coalgbot" test-NumericReply = refl test-Mode : test mode ":coalgbot MODE coalgbot :+i" test-Mode = refl test-Ping : test ping "PING :verne.freenode.net" test-Ping = refl test-Privmsg : test (privmsg "amiller" "PING 3073265598") ":amiller!debian-tor@gateway/tor-sasl/socrates1024 PRIVMSG coalgbot :PING 3073265598" test-Privmsg = refl
{ "alphanum_fraction": 0.6113537118, "avg_line_length": 29.358974359, "ext": "agda", "hexsha": "ee912e794d584b13c4c27a93f3e3eba5fbd86d13", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:53:29.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:53:29.000Z", "max_forks_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/coirc", "max_forks_repo_path": "src/Coirc/Parser.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/coirc", "max_issues_repo_path": "src/Coirc/Parser.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/coirc", "max_stars_repo_path": "src/Coirc/Parser.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1164, "size": 3435 }
postulate A : Set record R : Set where constructor r field f : A test : R → R test x = let r a = x foo : R → A foo x = let r a = x in a in r (foo (r a))
{ "alphanum_fraction": 0.4615384615, "avg_line_length": 15, "ext": "agda", "hexsha": "3de4e08a6752ca02c257d732848f70ebf197f0fe", "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/ShadowingLetWithLet.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/ShadowingLetWithLet.agda", "max_line_length": 37, "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/ShadowingLetWithLet.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": 66, "size": 195 }
{-# OPTIONS --without-K --safe #-} module Dodo.Unary.Dec where -- Stdlib imports open import Level using (Level; _⊔_) open import Relation.Nullary using (Dec) open import Relation.Unary using (Pred) DecPred : {a ℓ : Level} {A : Set a} → Pred A ℓ → Set (a ⊔ ℓ) DecPred P = ∀ x → Dec (P x)
{ "alphanum_fraction": 0.6496598639, "avg_line_length": 21, "ext": "agda", "hexsha": "c06d7d7849ed503cf16a91161c6d654f908465a7", "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": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "sourcedennis/agda-dodo", "max_forks_repo_path": "src/Dodo/Unary/Dec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "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": "sourcedennis/agda-dodo", "max_issues_repo_path": "src/Dodo/Unary/Dec.agda", "max_line_length": 40, "max_stars_count": null, "max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "sourcedennis/agda-dodo", "max_stars_repo_path": "src/Dodo/Unary/Dec.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 94, "size": 294 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Closures of a unary relation with respect to a strict partial order ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Unary.Closure.StrictPartialOrder {a r e} (P : StrictPartialOrder a e r) where open StrictPartialOrder P renaming (_<_ to _∼_) open import Relation.Unary using (Pred) -- Specialising the results proven generically in `Base`. import Relation.Unary.Closure.Base _∼_ as Base open Base public using (□; map; Closed) module _ {t} {T : Pred Carrier t} where reindex : ∀ {x y} → x ∼ y → □ T x → □ T y reindex = Base.reindex trans duplicate : ∀ {x} → □ T x → □ (□ T) x duplicate = Base.duplicate trans □-closed : ∀ {t} {T : Pred Carrier t} → Closed (□ T) □-closed = Base.□-closed trans
{ "alphanum_fraction": 0.5683530678, "avg_line_length": 29.9677419355, "ext": "agda", "hexsha": "54741cf27cbf9a64dedd81db0089f470fda86885", "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/Relation/Unary/Closure/StrictPartialOrder.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/Unary/Closure/StrictPartialOrder.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Closure/StrictPartialOrder.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": 242, "size": 929 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Group.Morphism where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Structure open import Cubical.Algebra.Group.Base open import Cubical.Data.Sigma private variable ℓ ℓ' ℓ'' ℓ''' : Level -- The following definition of GroupHom and GroupEquiv are level-wise heterogeneous. -- This allows for example to deduce that G ≡ F from a chain of isomorphisms -- G ≃ H ≃ F, even if H does not lie in the same level as G and F. isGroupHom : (G : Group {ℓ}) (H : Group {ℓ'}) (f : ⟨ G ⟩ → ⟨ H ⟩) → Type _ isGroupHom G H f = (x y : ⟨ G ⟩) → f (x G.+ y) ≡ (f x H.+ f y) where module G = GroupStr (snd G) module H = GroupStr (snd H) record GroupHom (G : Group {ℓ}) (H : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where constructor grouphom field fun : ⟨ G ⟩ → ⟨ H ⟩ isHom : isGroupHom G H fun record GroupEquiv (G : Group {ℓ}) (H : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where constructor groupequiv field eq : ⟨ G ⟩ ≃ ⟨ H ⟩ isHom : isGroupHom G H (equivFun eq) hom : GroupHom G H hom = grouphom (equivFun eq) isHom open GroupHom open GroupStr ×hom : {A : Group {ℓ}} {B : Group {ℓ'}} {C : Group {ℓ''}} {D : Group {ℓ'''}} → GroupHom A C → GroupHom B D → GroupHom (dirProd A B) (dirProd C D) fun (×hom mf1 mf2) = map-× (fun mf1) (fun mf2) isHom (×hom mf1 mf2) a b = ≡-× (isHom mf1 _ _) (isHom mf2 _ _) isInIm : (G : Group {ℓ}) (H : Group {ℓ'}) → GroupHom G H → ⟨ H ⟩ → Type (ℓ-max ℓ ℓ') isInIm G H ϕ h = ∃[ g ∈ ⟨ G ⟩ ] ϕ .fun g ≡ h isInKer : (G : Group {ℓ}) (H : Group {ℓ'}) → GroupHom G H → ⟨ G ⟩ → Type ℓ' isInKer G H ϕ g = ϕ .fun g ≡ 0g (snd H) isSurjective : (G : Group {ℓ}) (H : Group {ℓ'}) → GroupHom G H → Type (ℓ-max ℓ ℓ') isSurjective G H ϕ = (x : ⟨ H ⟩) → isInIm G H ϕ x isInjective : (G : Group {ℓ}) (H : Group {ℓ'}) → GroupHom G H → Type (ℓ-max ℓ ℓ') isInjective G H ϕ = (x : ⟨ G ⟩) → isInKer G H ϕ x → x ≡ 0g (snd G)
{ "alphanum_fraction": 0.600402617, "avg_line_length": 33.6779661017, "ext": "agda", "hexsha": "81f4fbabc0f42ce65ed1379471bce97128ec70b1", "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": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ayberkt/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/Morphism.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "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": "ayberkt/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/Morphism.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ayberkt/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/Morphism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 789, "size": 1987 }
module combinators where open import bool open import bool-thms2 import closures open import eq open import list open import list-thms open import nat open import nat-thms open import product open import product-thms open import sum open import string open import termination data comb : Set where S : comb K : comb app : comb → comb → comb size : comb → ℕ size S = 1 size K = 1 size (app a b) = suc (size a + size b) data _↝_ : comb → comb → Set where ↝K : (a b : comb) → (app (app K a) b) ↝ a ↝S : (a b c : comb) → (app (app (app S a) b) c) ↝ (app (app a c) (app b c)) ↝Cong1 : {a a' : comb} (b : comb) → a ↝ a' → (app a b) ↝ (app a' b) ↝Cong2 : (a : comb) {b b' : comb} → b ↝ b' → (app a b) ↝ (app a b') Sfree : comb → 𝔹 Sfree S = ff Sfree K = tt Sfree (app a b) = Sfree a && Sfree b Sfree-↝-size> : ∀{a b : comb} → Sfree a ≡ tt → a ↝ b → size a > size b ≡ tt Sfree-↝-size> p (↝K a b) = ≤<-trans {size a} (≤+1 (size a) (size b)) (<+2 {size a + size b} {2}) Sfree-↝-size> () (↝S a b c) Sfree-↝-size> p (↝Cong1{a}{a'} b u) with &&-elim{Sfree a} p Sfree-↝-size> p (↝Cong1{a}{a'} b u) | p1 , _ = <+mono2 {size a'} (Sfree-↝-size> p1 u) Sfree-↝-size> p (↝Cong2 a u) with &&-elim{Sfree a} p Sfree-↝-size> p (↝Cong2 a u) | _ , p2 = <+mono1{size a} (Sfree-↝-size> p2 u) ↝-preserves-Sfree : ∀{a b : comb} → Sfree a ≡ tt → a ↝ b → Sfree b ≡ tt ↝-preserves-Sfree p (↝K a b) = fst (&&-elim p) ↝-preserves-Sfree () (↝S a b c) ↝-preserves-Sfree p (↝Cong1 b u) with &&-elim p ↝-preserves-Sfree p (↝Cong1 b u) | p1 , p2 = &&-intro (↝-preserves-Sfree p1 u) p2 ↝-preserves-Sfree p (↝Cong2 a u) with &&-elim{Sfree a} p ↝-preserves-Sfree p (↝Cong2 a u) | p1 , p2 = &&-intro p1 (↝-preserves-Sfree p2 u) Sfree-comb : Set Sfree-comb = Σ comb (λ a → Sfree a ≡ tt) ↝-Sfree-comb : Sfree-comb → Sfree-comb → Set ↝-Sfree-comb (a , _) (b , _) = a ↝ b size-Sfree-comb : Sfree-comb → ℕ size-Sfree-comb (a , _) = size a decrease-size : ∀ {x y : Sfree-comb} → ↝-Sfree-comb x y → size-Sfree-comb x > size-Sfree-comb y ≡ tt decrease-size{a , u}{b , _} p = Sfree-↝-size> u p open measure{A = Sfree-comb} ↝-Sfree-comb (λ x y → x > y ≡ tt) size-Sfree-comb decrease-size measure-decreases : ∀(a : Sfree-comb) → ↓ ↝-Sfree-comb a measure-decreases a = measure-↓ (↓-> (size-Sfree-comb a)) Sfree-terminatesh : ∀{a : comb}{p : Sfree a ≡ tt} → ↓ ↝-Sfree-comb (a , p) → ↓ _↝_ a Sfree-terminatesh{a}{p} (pf↓ f) = pf↓ h where h : {y : comb} → a ↝ y → ↓ _↝_ y h{y} u = Sfree-terminatesh (f {y , ↝-preserves-Sfree p u} u) Sfree-terminates : ∀(a : comb) → Sfree a ≡ tt → ↓ _↝_ a Sfree-terminates a p = Sfree-terminatesh (measure-decreases (a , p)) data varcomb : Set where S : varcomb K : varcomb app : varcomb → varcomb → varcomb var : (s : string) → varcomb λ* : (s : string) → varcomb → varcomb λ* s S = app K S λ* s K = app K K λ* s (app c1 c2) = app (app S (λ* s c1)) (λ* s c2) λ* s (var s') = if (s =string s') then (app (app S K) K) else (app K (var s')) subst : varcomb → string → varcomb → varcomb subst c s S = S subst c s K = K subst c s (app c1 c2) = app (subst c s c1) (subst c s c2) subst c s (var s') = if (s =string s') then c else var s' data _↝vc_ : varcomb → varcomb → Set where ↝K : (a b : varcomb) → (app (app K a) b) ↝vc a ↝S : (a b c : varcomb) → (app (app (app S a) b) c) ↝vc (app (app a c) (app b c)) ↝Cong1 : {a a' : varcomb} (b : varcomb) → a ↝vc a' → (app a b) ↝vc (app a' b) ↝Cong2 : (a : varcomb) {b b' : varcomb} → b ↝vc b' → (app a b) ↝vc (app a b') -- open closures.basics _↝vc_ -- _↝vc+_ : varcomb → varcomb → Set -- _↝vc+_ = tc -- id↝ : ∀ (a : varcomb) → app (app (app S K) K) a ↝vc+ a -- id↝ a = (tc-trans (tc-step (↝S K K a)) (tc-step (↝K a (app K a)))) -- trans-Cong1 : ∀{a a' : varcomb} (b : varcomb) → a ↝vc+ a' → (app a b) ↝vc+ (app a' b) -- trans-Cong1 b (tc-trans d1 d2) = (tc-trans (trans-Cong1 b d1) (trans-Cong1 b d2)) -- trans-Cong1 b (tc-step d) = tc-step (↝Cong1 b d) -- trans-Cong2 : ∀(a : varcomb) {b b' : varcomb} → b ↝vc+ b' → (app a b) ↝vc+ (app a b') -- trans-Cong2 a (tc-trans d1 d2) = (tc-trans (trans-Cong2 a d1) (trans-Cong2 a d2)) -- trans-Cong2 a (tc-step d) = tc-step (↝Cong2 a d) -- contains-var : string → varcomb → 𝔹 -- contains-var s S = ff -- contains-var s K = ff -- contains-var s (app c1 c2) = contains-var s c1 || contains-var s c2 -- contains-var s (var s') = s =string s' -- λ*-binds : ∀(s : string)(v : varcomb) → contains-var s (λ* s v) ≡ ff -- λ*-binds s S = refl -- λ*-binds s K = refl -- λ*-binds s (app c1 c2) rewrite λ*-binds s c1 | λ*-binds s c2 = refl -- λ*-binds s (var s') with keep (s =string s') -- λ*-binds s (var s') | tt , p rewrite p = refl -- λ*-binds s (var s') | ff , p rewrite p = p -- λ*-↝ : ∀ (v1 v2 : varcomb)(s : string) → (app (λ* s v1) v2) ↝vc+ (subst v2 s v1) -- λ*-↝ S v2 s = tc-step (↝K S v2) -- λ*-↝ K v2 s = tc-step (↝K K v2) -- λ*-↝ (app c1 c2) v2 s = -- (tc-trans (tc-step (↝S (λ* s c1) (λ* s c2) v2)) -- (tc-trans (trans-Cong1 (app (λ* s c2) v2) (λ*-↝ c1 v2 s)) -- (trans-Cong2 (subst v2 s c1) (λ*-↝ c2 v2 s)))) -- λ*-↝ (var s') v2 s with s =string s' -- λ*-↝ (var s') v2 s | tt = id↝ v2 -- λ*-↝ (var s') v2 s | ff = tc-step (↝K (var s') v2)
{ "alphanum_fraction": 0.5566417481, "avg_line_length": 36.2291666667, "ext": "agda", "hexsha": "fb4f33e6375f8d4a7ccbcfd1ade82bde97ccc7f7", "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": "combinators.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": "combinators.agda", "max_line_length": 100, "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": "combinators.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2333, "size": 5217 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Convenient syntax for "equational reasoning" using a strict partial -- order. ------------------------------------------------------------------------ -- Example uses: -- -- u≤x : u ≤ x -- u≤x = begin -- u ≈⟨ u≈v ⟩ -- v ≡⟨ v≡w ⟩ -- w <⟨ w≤x ⟩ -- x ∎ -- -- u<x : u < x -- u<x = begin-strict -- u ≈⟨ u≈v ⟩ -- v ≡⟨ v≡w ⟩ -- w <⟨ w≤x ⟩ -- x ∎ -- -- u<e : u < e -- u<e = begin-strict -- u ≈⟨ u≈v ⟩ -- v ≡⟨ v≡w ⟩ -- w <⟨ w<x ⟩ -- x ≤⟨ x≤y ⟩ -- y <⟨ y<z ⟩ -- z ≡˘⟨ d≡z ⟩ -- d ≈˘⟨ e≈d ⟩ -- e ∎ -- -- u≈w : u ≈ w -- u≈w = begin-equality -- u ≈⟨ u≈v ⟩ -- v ≡⟨ v≡w ⟩ -- w ∎ {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Binary.Reasoning.StrictPartialOrder {p₁ p₂ p₃} (S : StrictPartialOrder p₁ p₂ p₃) where open StrictPartialOrder S import Relation.Binary.Construct.StrictToNonStrict _≈_ _<_ as NonStrict ------------------------------------------------------------------------ -- Publicly re-export the contents of the base module open import Relation.Binary.Reasoning.Base.Triple (NonStrict.isPreorder₂ isStrictPartialOrder) trans <-resp-≈ NonStrict.<⇒≤ (NonStrict.<-≤-trans trans <-respʳ-≈) public
{ "alphanum_fraction": 0.4251798561, "avg_line_length": 22.7868852459, "ext": "agda", "hexsha": "3eeb609178609ac44e230abbd9a4f9a7761276af", "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/Relation/Binary/Reasoning/StrictPartialOrder.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/Reasoning/StrictPartialOrder.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Reasoning/StrictPartialOrder.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": 522, "size": 1390 }
{-# OPTIONS --cubical #-} module Type.Cubical.Path where open import Type open import Type.Cubical postulate PathP : ∀{ℓ}(P : Interval → Type{ℓ}) → P(Interval.𝟎) → P(Interval.𝟏) → Type{ℓ} {-# BUILTIN PATHP PathP #-} -- The type of paths. -- Can be seen as a path between two points in the space P. -- (A continuous function from the closed unit interval to the space). Path : ∀{ℓ}{P : Type{ℓ}} → P → P → Type{ℓ} Path {P = P} = PathP(\i → P) {-# BUILTIN PATH Path #-}
{ "alphanum_fraction": 0.6433121019, "avg_line_length": 27.7058823529, "ext": "agda", "hexsha": "65c592a85c564749f7188ad277c06c46d4881af6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Type/Cubical/Path.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Type/Cubical/Path.agda", "max_line_length": 88, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Type/Cubical/Path.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": 156, "size": 471 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category using (Category; module Commutation) open import Categories.Category.Monoidal.Core using (Monoidal) -- The "four middle interchange" for monoidal categories. -- -- Aka the "interchange law" or "exchange law" (though those terms are -- more comonly used in the more general context of composition in -- 2-categories). module Categories.Category.Monoidal.Interchange {o ℓ e} {C : Category o ℓ e} where open import Level using (_⊔_) open import Data.Product using (_,_) import Categories.Category.Monoidal.Construction.Product as MonoidalProduct open import Categories.Category.Monoidal.Braided using (Braided) open import Categories.Category.Monoidal.Braided.Properties using (braiding-coherence; inv-Braided; inv-braiding-coherence) open import Categories.Category.Monoidal.Properties using (module Kelly's) import Categories.Category.Monoidal.Reasoning as MonoidalReasoning open import Categories.Category.Monoidal.Symmetric using (Symmetric) import Categories.Category.Monoidal.Utilities as MonoidalUtilities open import Categories.Category.Product using (_⁂_; assocˡ) open import Categories.Functor using (_∘F_) open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_; niHelper) open import Categories.Morphism C using (_≅_; module ≅) open import Categories.Morphism.IsoEquiv C using (module _≃_) open import Categories.Morphism.Reasoning C private module C = Category C open C open Commutation C private variable W W₁ W₂ X X₁ X₂ Y Y₁ Y₂ Z Z₁ Z₂ : Obj f g h i : X ⇒ Y -- An abstract definition of an interchange map with the minimal set -- of coherence laws required to make the tensor product ⊗ of C a -- monoidal functor. (See also Categories.Functor.Monoidal.Tensor.) record HasInterchange (M : Monoidal C) : Set (o ⊔ ℓ ⊔ e) where open Monoidal M open MonoidalUtilities.Shorthands M -- The "four middle interchange" for tensor products. field swapInner : ∀ {W X Y Z} → (W ⊗₀ X) ⊗₀ (Y ⊗₀ Z) ≅ (W ⊗₀ Y) ⊗₀ (X ⊗₀ Z) module swapInner {W X Y Z} = _≅_ (swapInner {W} {X} {Y} {Z}) private i⇒ = swapInner.from i⇐ = swapInner.to -- Naturality and coherence laws of the interchange. field natural : i⇒ ∘ (f ⊗₁ g) ⊗₁ (h ⊗₁ i) ≈ (f ⊗₁ h) ⊗₁ (g ⊗₁ i) ∘ i⇒ assoc : [ ((X₁ ⊗₀ X₂) ⊗₀ (Y₁ ⊗₀ Y₂)) ⊗₀ (Z₁ ⊗₀ Z₂) ⇒ (X₁ ⊗₀ (Y₁ ⊗₀ Z₁)) ⊗₀ (X₂ ⊗₀ (Y₂ ⊗₀ Z₂)) ]⟨ i⇒ ⊗₁ id ⇒⟨ ((X₁ ⊗₀ Y₁) ⊗₀ (X₂ ⊗₀ Y₂)) ⊗₀ (Z₁ ⊗₀ Z₂) ⟩ i⇒ ⇒⟨ ((X₁ ⊗₀ Y₁) ⊗₀ Z₁) ⊗₀ ((X₂ ⊗₀ Y₂) ⊗₀ Z₂) ⟩ α⇒ ⊗₁ α⇒ ≈ α⇒ ⇒⟨ (X₁ ⊗₀ X₂) ⊗₀ ((Y₁ ⊗₀ Y₂) ⊗₀ (Z₁ ⊗₀ Z₂)) ⟩ id ⊗₁ i⇒ ⇒⟨ (X₁ ⊗₀ X₂) ⊗₀ ((Y₁ ⊗₀ Z₁) ⊗₀ (Y₂ ⊗₀ Z₂)) ⟩ i⇒ ⟩ unitˡ : [ unit ⊗₀ (X ⊗₀ Y) ⇒ (X ⊗₀ Y) ]⟨ λ⇐ ⊗₁ id ⇒⟨ (unit ⊗₀ unit) ⊗₀ (X ⊗₀ Y) ⟩ i⇒ ⇒⟨ (unit ⊗₀ X) ⊗₀ (unit ⊗₀ Y) ⟩ λ⇒ ⊗₁ λ⇒ ≈ λ⇒ ⟩ unitʳ : [ (X ⊗₀ Y) ⊗₀ unit ⇒ (X ⊗₀ Y) ]⟨ id ⊗₁ λ⇐ ⇒⟨ (X ⊗₀ Y) ⊗₀ (unit ⊗₀ unit) ⟩ i⇒ ⇒⟨ (X ⊗₀ unit) ⊗₀ (Y ⊗₀ unit) ⟩ ρ⇒ ⊗₁ ρ⇒ ≈ ρ⇒ ⟩ -- The interchange is a natural isomorphism. naturalIso : ⊗ ∘F (⊗ ⁂ ⊗) ≃ ⊗ ∘F MonoidalProduct.⊗ M M naturalIso = niHelper (record { η = λ _ → i⇒ ; η⁻¹ = λ _ → i⇐ ; commute = λ _ → natural ; iso = λ _ → swapInner.iso }) -- Shorthands for composing and inverting isomorphisms. open ≅ using () renaming (refl to idᵢ; sym to _⁻¹) private infixr 9 _∘ᵢ_ _∘ᵢ_ = λ {X Y Z} f g → ≅.trans {X} {Y} {Z} g f -- Braided monoidal categories have an interchange map. module BraidedInterchange {M : Monoidal C} (B : Braided M) where open MonoidalReasoning M open MonoidalUtilities M open Braided B renaming (associator to α) open Shorthands -- Shorthands for braiding. private σ : X ⊗₀ Y ≅ Y ⊗₀ X σ = braiding.FX≅GX module σ {X Y} = _≅_ (σ {X} {Y}) σ⇒ = σ.from σ⇐ = σ.to -- The "four middle interchange" for braided tensor products. swapInner : (W ⊗₀ X) ⊗₀ (Y ⊗₀ Z) ≅ (W ⊗₀ Y) ⊗₀ (X ⊗₀ Z) swapInner = α ⁻¹ ∘ᵢ idᵢ ⊗ᵢ (α ∘ᵢ σ ⊗ᵢ idᵢ ∘ᵢ α ⁻¹) ∘ᵢ α module swapInner {W X Y Z} = _≅_ (swapInner {W} {X} {Y} {Z}) private i⇒ = swapInner.from i⇐ = swapInner.to -- The interchange is a natural isomorphism. swapInner-natural : i⇒ ∘ (f ⊗₁ g) ⊗₁ (h ⊗₁ i) ≈ (f ⊗₁ h) ⊗₁ (g ⊗₁ i) ∘ i⇒ swapInner-natural {f = f} {g = g} {h = h} {i = i} = begin (α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘ (f ⊗₁ g) ⊗₁ (h ⊗₁ i) ≈⟨ pullʳ (pullʳ assoc-commute-from) ⟩ α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ f ⊗₁ g ⊗₁ (h ⊗₁ i) ∘ α⇒ ≈⟨ refl⟩∘⟨ extendʳ (parallel id-comm-sym (begin (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ g ⊗₁ (h ⊗₁ i) ≈⟨ pullʳ (pullʳ assoc-commute-to) ⟩ α⇒ ∘ σ⇒ ⊗₁ id ∘ (g ⊗₁ h) ⊗₁ i ∘ α⇐ ≈⟨ refl⟩∘⟨ extendʳ (parallel (braiding.⇒.commute _) id-comm-sym) ⟩ α⇒ ∘ (h ⊗₁ g) ⊗₁ i ∘ σ⇒ ⊗₁ id ∘ α⇐ ≈⟨ extendʳ assoc-commute-from ⟩ h ⊗₁ (g ⊗₁ i) ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐ ∎)) ⟩ α⇐ ∘ f ⊗₁ h ⊗₁ (g ⊗₁ i) ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ extendʳ assoc-commute-to ⟩ (f ⊗₁ h) ⊗₁ (g ⊗₁ i) ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ∎ swapInner-naturalIsomorphism : ⊗ ∘F (⊗ ⁂ ⊗) ≃ ⊗ ∘F MonoidalProduct.⊗ M M swapInner-naturalIsomorphism = niHelper (record { η = λ _ → i⇒ ; η⁻¹ = λ _ → i⇐ ; commute = λ _ → swapInner-natural ; iso = λ _ → swapInner.iso }) -- Another version of the interchange that associates differently. -- -- Why are there two versions and what's the difference? The domain -- (X₁ ⊗ X₂) ⊗₀ (Y₁ ⊗ Y₂) and codomain (X₁ ⊗ Y₁) ⊗₀ (X₁ ⊗ Y₂) of the -- interchange map are perfectly symmetric/balanced. But in order to -- apply the braiding to the middle X₂ and Y₁, we need to -- re-associate and that breaks the symmetry. We must first -- re-associate the whole expression in one direction and then the -- larger subterm in the other. This can be done in two ways, -- associate to the right first, then to the left, resulting in X₁ ⊗ -- ((Y₂ ⊗₀ X₁) ⊗ Y₂), or vice versa, resulting in (X₁ ⊗ (Y₂ ⊗₀ X₁)) -- ⊗ Y₂. The choice is arbitrary and results in two distinct -- interchange maps that behave the same way (as witnessed by -- swapInner-coherent below). -- -- Why define both? Because the proofs of some coherence laws become -- easier when the core of the expression is associated in one -- direction vs. the other. For example swapInner-unitˡ is easier to -- prove for the second definition, while swapInner-unitʳ is easier -- to prove for the first; swapInner-assoc uses both. swapInner′ : (W ⊗₀ X) ⊗₀ (Y ⊗₀ Z) ≅ (W ⊗₀ Y) ⊗₀ (X ⊗₀ Z) swapInner′ = α ∘ᵢ (α ⁻¹ ∘ᵢ idᵢ ⊗ᵢ σ ∘ᵢ α) ⊗ᵢ idᵢ ∘ᵢ α ⁻¹ module swapInner′ {W X Y Z} = _≅_ (swapInner′ {W} {X} {Y} {Z}) private j⇒ = swapInner′.from j⇐ = swapInner′.to -- Derived coherence laws. swapInner-coherent : [ (X₁ ⊗₀ X₂) ⊗₀ (Y₁ ⊗₀ Y₂) ⇒ (X₁ ⊗₀ Y₁) ⊗₀ (X₂ ⊗₀ Y₂) ]⟨ i⇒ ≈ j⇒ ⟩ swapInner-coherent = begin α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩ α⇐ ∘ id ⊗₁ α⇒ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩ α⇐ ∘ id ⊗₁ α⇒ ∘ id ⊗₁ (σ⇒ ⊗₁ id) ∘ id ⊗₁ α⇐ ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ conjugate-from α (idᵢ ⊗ᵢ α) (⟺ pentagon) ⟩ α⇐ ∘ id ⊗₁ α⇒ ∘ id ⊗₁ (σ⇒ ⊗₁ id) ∘ (α⇒ ∘ α⇒ ⊗₁ id) ∘ α⇐ ≈˘⟨ pullʳ (pullʳ (extendʳ (pushˡ assoc-commute-from))) ⟩ (α⇐ ∘ id ⊗₁ α⇒ ∘ α⇒ ∘ (id ⊗₁ σ⇒) ⊗₁ id) ∘ α⇒ ⊗₁ id ∘ α⇐ ≈⟨ pushʳ sym-assoc ⟩∘⟨refl ⟩ ((α⇐ ∘ id ⊗₁ α⇒ ∘ α⇒) ∘ (id ⊗₁ σ⇒) ⊗₁ id) ∘ α⇒ ⊗₁ id ∘ α⇐ ≈⟨ pushˡ (conjugate-from (α ⊗ᵢ idᵢ) α (assoc ○ pentagon)) ⟩∘⟨refl ⟩ (α⇒ ∘ α⇐ ⊗₁ id ∘ (id ⊗₁ σ⇒) ⊗₁ id) ∘ α⇒ ⊗₁ id ∘ α⇐ ≈˘⟨ pushʳ (pushʳ (pushˡ split₁ˡ)) ⟩ α⇒ ∘ α⇐ ⊗₁ id ∘ (id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈˘⟨ refl⟩∘⟨ pushˡ split₁ˡ ⟩ α⇒ ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ∎ swapInner-assoc : [ ((X₁ ⊗₀ X₂) ⊗₀ (Y₁ ⊗₀ Y₂)) ⊗₀ (Z₁ ⊗₀ Z₂) ⇒ (X₁ ⊗₀ (Y₁ ⊗₀ Z₁)) ⊗₀ (X₂ ⊗₀ (Y₂ ⊗₀ Z₂)) ]⟨ i⇒ ⊗₁ id ⇒⟨ ((X₁ ⊗₀ Y₁) ⊗₀ (X₂ ⊗₀ Y₂)) ⊗₀ (Z₁ ⊗₀ Z₂) ⟩ i⇒ ⇒⟨ ((X₁ ⊗₀ Y₁) ⊗₀ Z₁) ⊗₀ ((X₂ ⊗₀ Y₂) ⊗₀ Z₂) ⟩ α⇒ ⊗₁ α⇒ ≈ α⇒ ⇒⟨ (X₁ ⊗₀ X₂) ⊗₀ ((Y₁ ⊗₀ Y₂) ⊗₀ (Z₁ ⊗₀ Z₂)) ⟩ id ⊗₁ i⇒ ⇒⟨ (X₁ ⊗₀ X₂) ⊗₀ ((Y₁ ⊗₀ Z₁) ⊗₀ (Y₂ ⊗₀ Z₂)) ⟩ i⇒ ⟩ swapInner-assoc = begin α⇒ ⊗₁ α⇒ ∘ i⇒ ∘ i⇒ ⊗₁ id ≈⟨ (begin α⇒ ⊗₁ α⇒ ≈⟨ serialize₂₁ ⟩ id ⊗₁ α⇒ ∘ α⇒ ⊗₁ id ≈⟨ refl⟩∘⟨ switch-fromtoˡ α (switch-fromtoˡ (idᵢ ⊗ᵢ α) pentagon) ⟩ id ⊗₁ α⇒ ∘ α⇐ ∘ id ⊗₁ α⇐ ∘ α⇒ ∘ α⇒ ≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩⊗⟨ cancelˡ α.isoʳ ⟩∘⟨refl ⟩ id ⊗₁ α⇒ ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇐ ∘ α⇐) ∘ α⇒ ∘ α⇒ ≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩⊗⟨ pullʳ inv-pentagon ⟩∘⟨refl ⟩ id ⊗₁ α⇒ ∘ α⇐ ∘ id ⊗₁ ((α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ id ⊗₁ α⇐) ∘ α⇒ ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩ id ⊗₁ α⇒ ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ id ⊗₁ (id ⊗₁ α⇐) ∘ α⇒ ∘ α⇒ ≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ extendʳ assoc-commute-from ⟩ id ⊗₁ α⇒ ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ (id ⊗₁ id) ⊗₁ α⇐ ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ ⊗.identity ⟩⊗⟨refl ⟩∘⟨refl ⟩ id ⊗₁ α⇒ ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ id ⊗₁ α⇐ ∘ α⇒ ∎) ⟩∘⟨refl ⟩ (id ⊗₁ α⇒ ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ id ⊗₁ α⇐ ∘ α⇒) ∘ i⇒ ∘ i⇒ ⊗₁ id ≈˘⟨ pullˡ (pushˡ (⊗.identity ⟩⊗⟨refl ⟩∘⟨refl)) ⟩ ((id ⊗₁ id) ⊗₁ α⇒ ∘ α⇐) ∘ (id ⊗₁ (α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ id ⊗₁ α⇐ ∘ α⇒) ∘ (α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘ i⇒ ⊗₁ id ≈⟨ ⟺ assoc-commute-to ⟩∘⟨ pullʳ (pullʳ (pushʳ (pushˡ (pushʳ (pushˡ split₂ˡ))))) ⟩ (α⇐ ∘ id ⊗₁ (id ⊗₁ α⇒)) ∘ id ⊗₁ (α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ ((id ⊗₁ α⇐ ∘ α⇒) ∘ α⇐ ∘ id ⊗₁ α⇒) ∘ (id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘ (α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ⊗₁ id ≈⟨ pullʳ (refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ elimˡ (_≅_.isoˡ (α ⁻¹ ∘ᵢ idᵢ ⊗ᵢ α))) ⟩ α⇐ ∘ id ⊗₁ (id ⊗₁ α⇒) ∘ id ⊗₁ (α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ (id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘ (α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ⊗₁ id ≈⟨ refl⟩∘⟨ merge₂ sym-assoc ⟩∘⟨ pushʳ ((⟺ ⊗.identity ⟩⊗⟨refl) ⟩∘⟨refl ⟩∘⟨ split₁ˡ) ⟩ α⇐ ∘ id ⊗₁ ((id ⊗₁ α⇒ ∘ α⇒) ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ (α⇒ ∘ (id ⊗₁ id) ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘ α⇐ ⊗₁ id ∘ (id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ⊗₁ id ≈⟨ refl⟩∘⟨ refl⟩⊗⟨ extendʳ (pushˡ (switch-fromtoʳ (α ⊗ᵢ idᵢ) (assoc ○ pentagon))) ⟩∘⟨ extendʳ assoc-commute-from ⟩∘⟨refl ⟩ α⇐ ∘ id ⊗₁ ((α⇒ ∘ α⇒) ∘ (α⇐ ⊗₁ id ∘ α⇐ ⊗₁ id) ∘ α⇐) ∘ (id ⊗₁ (id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐)) ∘ (α⇒ ∘ α⇒)) ∘ α⇐ ⊗₁ id ∘ (id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ⊗₁ id ≈˘⟨ refl⟩∘⟨ refl⟩⊗⟨ pushʳ (refl⟩∘⟨ split₁ˡ ⟩∘⟨refl) ⟩∘⟨ pushʳ (extendʳ (switch-fromtoʳ (α ⊗ᵢ idᵢ) (assoc ○ pentagon))) ⟩ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐) ∘ id ⊗₁ (id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐)) ∘ id ⊗₁ α⇒ ∘ α⇒ ∘ (id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ⊗₁ id ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ split₁ˡ ⟩ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐) ∘ id ⊗₁ (id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐)) ∘ id ⊗₁ α⇒ ∘ α⇒ ∘ (id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐)) ⊗₁ id ∘ α⇒ ⊗₁ id ≈⟨ refl⟩∘⟨ merge₂ assoc²' ○ (refl⟩∘⟨ refl⟩∘⟨ assoc) ⟩∘⟨ refl⟩∘⟨ extendʳ assoc-commute-from ⟩ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐)) ∘ id ⊗₁ α⇒ ∘ id ⊗₁ ((α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id) ∘ α⇒ ∘ α⇒ ⊗₁ id ≈⟨ refl⟩∘⟨ merge₂ (assoc²' ○ (refl⟩∘⟨ refl⟩∘⟨ assoc²')) ⟩∘⟨ refl⟩∘⟨ switch-fromtoˡ (idᵢ ⊗ᵢ α) pentagon ⟩ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘ id ⊗₁ ((α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id) ∘ id ⊗₁ α⇐ ∘ α⇒ ∘ α⇒ ≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘ id ⊗₁ ((α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ α⇒ ≈⟨ refl⟩∘⟨ merge₂ assoc²' ○ (refl⟩∘⟨ refl⟩∘⟨ (assoc²' ○ (refl⟩∘⟨ refl⟩∘⟨ assoc))) ⟩∘⟨ Equiv.refl ⟩ α⇐ ∘ id ⊗₁ (α⇒ ∘ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩⊗⟨ pushʳ (begin α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ extendʳ (pushˡ split₂ˡ) ⟩ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id) ∘ (id ⊗₁ α⇐ ∘ α⇒) ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ (extendʳ assoc-commute-to ○ (refl⟩∘⟨ sym-assoc)) ⟩ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ (id ⊗₁ σ⇒) ⊗₁ id ∘ (α⇐ ∘ (id ⊗₁ α⇐ ∘ α⇒)) ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐ ≈⟨ refl⟩∘⟨ refl⟩∘⟨ refl⟩∘⟨ (sym-assoc ○ (conjugate-to α (α ⊗ᵢ idᵢ) (sym-assoc ○ inv-pentagon))) ⟩∘⟨refl ⟩ α⇒ ∘ (α⇐ ∘ α⇐) ⊗₁ id ∘ (id ⊗₁ σ⇒) ⊗₁ id ∘ (α⇒ ⊗₁ id ∘ α⇐) ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐ ≈˘⟨ refl⟩∘⟨ split₁ Equiv.refl ⟩∘⟨ pushʳ (refl⟩∘⟨ refl⟩⊗⟨ ⊗.identity ⟩∘⟨refl) ⟩ α⇒ ∘ ((α⇐ ∘ α⇐) ∘ id ⊗₁ σ⇒) ⊗₁ id ∘ α⇒ ⊗₁ id ∘ α⇐ ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ (id ⊗₁ id) ∘ α⇐ ≈⟨ refl⟩∘⟨ merge₁ assoc² ⟩∘⟨ extendʳ assoc-commute-to ⟩ α⇒ ∘ (α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ ((α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id) ⊗₁ id ∘ α⇐ ∘ α⇐ ≈˘⟨ refl⟩∘⟨ pushˡ split₁ˡ ⟩ α⇒ ∘ ((α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id) ⊗₁ id ∘ α⇐ ∘ α⇐ ≈˘⟨ refl⟩∘⟨ refl⟩∘⟨ (sym-assoc ○ inv-pentagon) ⟩ α⇒ ∘ ((α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id) ⊗₁ id ∘ α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇐ ≈⟨ refl⟩∘⟨ pullˡ (⟺ split₁ˡ ○ (assoc ⟩⊗⟨refl)) ⟩ α⇒ ∘ ((α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇐ ≈⟨ refl⟩∘⟨ (begin (α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐ ≈⟨ pushˡ (pushʳ sym-assoc) ⟩ (α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒ ∘ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐ ≈⟨ (refl⟩∘⟨ extendʳ (pushʳ split₁ˡ)) ⟩ (α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒) ∘ (α⇒ ∘ α⇒ ⊗₁ id) ∘ (σ⇒ ⊗₁ id ∘ α⇐) ⊗₁ id ∘ α⇐ ≈⟨ pushʳ (switch-fromtoˡ (idᵢ ⊗ᵢ α) pentagon ⟩∘⟨ pushˡ split₁ˡ) ⟩ ((α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒) ∘ (id ⊗₁ α⇐ ∘ α⇒ ∘ α⇒)) ∘ (σ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐ ⊗₁ id ∘ α⇐ ≈⟨ pushˡ (sym-assoc ○ (pullˡ (pullʳ assoc ⟩∘⟨refl))) ⟩ ((α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ id ⊗₁ α⇐) ∘ α⇒) ∘ α⇒ ∘ (σ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐ ⊗₁ id ∘ α⇐ ≈⟨ pullʳ (refl⟩∘⟨ extendʳ assoc-commute-from) ⟩ (α⇐ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ id ⊗₁ α⇐) ∘ α⇒ ∘ σ⇒ ⊗₁ (id ⊗₁ id) ∘ α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐ ≈⟨ (refl⟩∘⟨ refl⟩∘⟨ ⟺ split₂ˡ) ⟩∘⟨ refl⟩∘⟨ (refl⟩⊗⟨ ⊗.identity ⟩∘⟨ conjugate-from (idᵢ ⊗ᵢ (α ⁻¹)) (α ⁻¹) inv-pentagon) ⟩ (α⇐ ∘ α⇐ ∘ id ⊗₁ (σ⇒ ∘ α⇐)) ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈˘⟨ extendʳ (sym-assoc ○ inv-pentagon) ⟩∘⟨refl ⟩ (α⇐ ⊗₁ id ∘ (α⇐ ∘ id ⊗₁ α⇐) ∘ id ⊗₁ (σ⇒ ∘ α⇐)) ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈˘⟨ (refl⟩∘⟨ pushʳ split₂ˡ) ⟩∘⟨refl ⟩ (α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (α⇐ ∘ σ⇒ ∘ α⇐)) ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈˘⟨ pushˡ ((refl⟩∘⟨ refl⟩∘⟨ refl⟩⊗⟨ (sym-assoc ○ hexagon₂ ○ assoc)) ⟩∘⟨refl) ⟩ ((α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ σ⇒)) ∘ α⇒) ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ pushˡ (pushʳ (pushʳ split₂ˡ)) ⟩∘⟨refl ⟩ ((α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ σ⇒ ⊗₁ id) ∘ id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒) ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ pushʳ (pushˡ split₂ˡ) ⟩∘⟨refl ⟩ (((α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ σ⇒ ⊗₁ id) ∘ id ⊗₁ α⇐) ∘ id ⊗₁ id ⊗₁ σ⇒ ∘ α⇒) ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ ((pushˡ (pushʳ assoc-commute-to) ⟩∘⟨ ⟺ assoc-commute-from) ○ (pullʳ sym-assoc)) ⟩∘⟨refl ⟩ ((α⇐ ⊗₁ id ∘ (id ⊗₁ σ⇒) ⊗₁ id) ∘ ((α⇐ ∘ id ⊗₁ α⇐) ∘ α⇒) ∘ (id ⊗₁ id) ⊗₁ σ⇒) ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ pullˡ (⟺ split₁ˡ ⟩∘⟨ conjugate-from α (idᵢ ⊗ᵢ α ∘ᵢ α) (⟺ (assoc ○ pentagon))) ⟩∘⟨refl ⟩ (((α⇐ ∘ id ⊗₁ σ⇒) ⊗₁ id ∘ α⇒ ⊗₁ id ∘ α⇐) ∘ (id ⊗₁ id) ⊗₁ σ⇒) ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ (pullˡ (⟺ split₁ˡ) ⟩∘⟨ ⊗.identity ⟩⊗⟨refl) ⟩∘⟨refl ⟩ ((((α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒) ⊗₁ id ∘ α⇐) ∘ id ⊗₁ σ⇒) ∘ σ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ extend² (⟺ serialize₂₁ ○ serialize₁₂) ⟩ ((((α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒) ⊗₁ id ∘ α⇐) ∘ σ⇒ ⊗₁ id) ∘ id ⊗₁ σ⇒ ∘ α⇐ ∘ id ⊗₁ α⇒ ≈˘⟨ pushʳ (refl⟩∘⟨ refl⟩⊗⟨ ⊗.identity) ⟩∘⟨ ⊗.identity ⟩⊗⟨refl ⟩∘⟨refl ⟩ (((α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒) ⊗₁ id ∘ α⇐ ∘ σ⇒ ⊗₁ id ⊗₁ id) ∘ (id ⊗₁ id) ⊗₁ σ⇒ ∘ α⇐ ∘ id ⊗₁ α⇒ ≈⟨ pushʳ assoc-commute-to ⟩∘⟨ extendʳ (⟺ assoc-commute-to) ⟩ ((((α⇐ ∘ id ⊗₁ σ⇒) ∘ α⇒) ⊗₁ id ∘ (σ⇒ ⊗₁ id) ⊗₁ id) ∘ α⇐) ∘ α⇐ ∘ id ⊗₁ id ⊗₁ σ⇒ ∘ id ⊗₁ α⇒ ≈˘⟨ ((sym-assoc ○ sym-assoc) ⟩⊗⟨refl ○ split₁ˡ) ⟩∘⟨refl ⟩∘⟨ refl⟩∘⟨ split₂ˡ ⟩ (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ⊗₁ id) ∘ α⇐) ∘ α⇐ ∘ id ⊗₁ (id ⊗₁ σ⇒ ∘ α⇒) ≈˘⟨ extend² (sym-assoc ○ inv-pentagon) ⟩ (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ⊗₁ id) ∘ α⇐ ⊗₁ id) ∘ (α⇐ ∘ id ⊗₁ α⇐) ∘ id ⊗₁ (id ⊗₁ σ⇒ ∘ α⇒) ≈˘⟨ split₁ˡ ⟩∘⟨ pushʳ split₂ˡ ⟩ ((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ∎) ⟩⊗⟨refl ⟩∘⟨refl ⟩ α⇒ ∘ (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒)) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇐ ≈⟨ (refl⟩∘⟨ pushˡ ((sym-assoc ⟩⊗⟨refl) ○ split₁ˡ)) ⟩ α⇒ ∘ (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id ∘ α⇐) ⊗₁ id ∘ (id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒)) ⊗₁ id ∘ α⇐ ∘ id ⊗₁ α⇐ ≈⟨ (refl⟩∘⟨ split₁ˡ ⟩∘⟨ extendʳ (⟺ assoc-commute-to)) ○ pushʳ assoc ⟩ (α⇒ ∘ (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id) ⊗₁ id) ∘ α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ id ⊗₁ α⇐ ≈⟨ pushˡ assoc-commute-from ⟩ ((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ (id ⊗₁ id) ∘ α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ id ⊗₁ α⇐ ≈˘⟨ refl⟩∘⟨ pullʳ (pullʳ (refl⟩∘⟨ split₂ˡ)) ⟩ ((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ (id ⊗₁ id) ∘ (α⇒ ∘ α⇐ ⊗₁ id ∘ α⇐) ∘ id ⊗₁ ((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ≈˘⟨ pullʳ (pullˡ (conjugate-from (α ∘ᵢ α ⊗ᵢ idᵢ) α pentagon)) ⟩ (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ (id ⊗₁ id) ∘ α⇐) ∘ id ⊗₁ α⇒ ∘ id ⊗₁ ((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ≈⟨ refl⟩⊗⟨ ⊗.identity ⟩∘⟨refl ⟩∘⟨ ⟺ split₂ˡ ⟩ (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id ∘ α⇐) ∘ id ⊗₁ (α⇒ ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ≡⟨⟩ (((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐) ⊗₁ id ∘ α⇐) ∘ id ⊗₁ j⇒ ≈˘⟨ switch-fromtoʳ α (switch-fromtoˡ α (⟺ hexagon₁)) ⟩⊗⟨refl ⟩∘⟨refl ⟩∘⟨refl ⟩ (σ⇒ ⊗₁ id ∘ α⇐) ∘ id ⊗₁ j⇒ ∎) ⟩∘⟨refl ⟩ α⇐ ∘ id ⊗₁ ((α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ id ⊗₁ j⇒) ∘ α⇒ ∘ α⇒ ≈⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩ α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ id ⊗₁ id ⊗₁ j⇒ ∘ α⇒ ∘ α⇒ ≈˘⟨ pullʳ (pullʳ (extendʳ assoc-commute-from)) ⟩ (α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘ (id ⊗₁ id) ⊗₁ j⇒ ∘ α⇒ ≡⟨⟩ i⇒ ∘ (id ⊗₁ id) ⊗₁ j⇒ ∘ α⇒ ≈⟨ refl⟩∘⟨ ⊗.identity ⟩⊗⟨ ⟺ swapInner-coherent ⟩∘⟨refl ⟩ i⇒ ∘ id ⊗₁ i⇒ ∘ α⇒ ∎ where inv-pentagon = λ {W X Y Z} → _≃_.to-≈ (pentagon-iso {W} {X} {Y} {Z}) swapInner-unitˡ : [ unit ⊗₀ (X ⊗₀ Y) ⇒ (X ⊗₀ Y) ]⟨ λ⇐ ⊗₁ id ⇒⟨ (unit ⊗₀ unit) ⊗₀ (X ⊗₀ Y) ⟩ i⇒ ⇒⟨ (unit ⊗₀ X) ⊗₀ (unit ⊗₀ Y) ⟩ λ⇒ ⊗₁ λ⇒ ≈ λ⇒ ⟩ swapInner-unitˡ = begin λ⇒ ⊗₁ λ⇒ ∘ i⇒ ∘ λ⇐ ⊗₁ id ≈⟨ refl⟩∘⟨ swapInner-coherent ⟩∘⟨ (Kelly₃′ ⟩⊗⟨refl) ⟩ λ⇒ ⊗₁ λ⇒ ∘ j⇒ ∘ ρ⇐ ⊗₁ id ≡⟨⟩ λ⇒ ⊗₁ λ⇒ ∘ (α⇒ ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ∘ ρ⇐ ⊗₁ id ≈⟨ pullˡ (pushˡ serialize₁₂) ⟩ (λ⇒ ⊗₁ id ∘ id ⊗₁ λ⇒ ∘ α⇒ ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ∘ ρ⇐ ⊗₁ id ≈⟨ (refl⟩∘⟨ (begin id ⊗₁ λ⇒ ∘ α⇒ ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈⟨ pullˡ triangle ⟩ ρ⇒ ⊗₁ id ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈˘⟨ pushˡ split₁ˡ ⟩ (ρ⇒ ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈⟨ (pullˡ Kelly₂′ ⟩⊗⟨refl ⟩∘⟨refl) ⟩ (id ⊗₁ ρ⇒ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈˘⟨ pushˡ split₂ˡ ⟩⊗⟨refl ⟩∘⟨refl ⟩ (id ⊗₁ (ρ⇒ ∘ σ⇒) ∘ α⇒) ⊗₁ id ∘ α⇐ ≈⟨ (refl⟩⊗⟨ σ⁻¹-coherence ⟩∘⟨refl) ⟩⊗⟨refl ⟩∘⟨refl ⟩ (id ⊗₁ λ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐ ≈⟨ triangle ⟩⊗⟨refl ⟩∘⟨refl ⟩ (ρ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐ ≈˘⟨ assoc-commute-to ⟩ α⇐ ∘ ρ⇒ ⊗₁ (id ⊗₁ id) ∎)) ⟩∘⟨refl ⟩ (λ⇒ ⊗₁ id ∘ α⇐ ∘ ρ⇒ ⊗₁ (id ⊗₁ id)) ∘ ρ⇐ ⊗₁ id ≈⟨ (sym-assoc ○ (Kelly₁′ ⟩∘⟨ refl⟩⊗⟨ ⊗.identity)) ⟩∘⟨refl ⟩ (λ⇒ ∘ ρ⇒ ⊗₁ id) ∘ ρ⇐ ⊗₁ id ≈⟨ cancelʳ (_≅_.isoʳ (unitorʳ ⊗ᵢ idᵢ)) ⟩ λ⇒ ∎ where Kelly₁′ = ⟺ (switch-fromtoʳ α (Kelly's.coherence₁ M)) Kelly₂′ = ⟺ (switch-fromtoʳ α (Kelly's.coherence₂ M)) Kelly₃′ = _≃_.to-≈ (Kelly's.coherence-iso₃ M) σ⁻¹-coherence = inv-braiding-coherence (inv-Braided B) swapInner-unitʳ : [ (X ⊗₀ Y) ⊗₀ unit ⇒ (X ⊗₀ Y) ]⟨ id ⊗₁ λ⇐ ⇒⟨ (X ⊗₀ Y) ⊗₀ (unit ⊗₀ unit) ⟩ i⇒ ⇒⟨ (X ⊗₀ unit) ⊗₀ (Y ⊗₀ unit) ⟩ ρ⇒ ⊗₁ ρ⇒ ≈ ρ⇒ ⟩ swapInner-unitʳ = begin ρ⇒ ⊗₁ ρ⇒ ∘ i⇒ ∘ id ⊗₁ λ⇐ ≡⟨⟩ ρ⇒ ⊗₁ ρ⇒ ∘ (α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘ id ⊗₁ λ⇐ ≈⟨ pullˡ (pushˡ serialize₂₁) ⟩ (id ⊗₁ ρ⇒ ∘ ρ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒) ∘ id ⊗₁ λ⇐ ≈⟨ (refl⟩∘⟨ (begin ρ⇒ ⊗₁ id ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈˘⟨ pushˡ (switch-fromtoʳ α triangle) ⟩ id ⊗₁ λ⇒ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈˘⟨ pushˡ split₂ˡ ⟩ id ⊗₁ (λ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ refl⟩⊗⟨ pullˡ (Kelly's.coherence₁ M) ⟩∘⟨refl ⟩ id ⊗₁ (λ⇒ ⊗₁ id ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈˘⟨ refl⟩⊗⟨ pushˡ split₁ˡ ⟩∘⟨refl ⟩ id ⊗₁ ((λ⇒ ∘ σ⇒) ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ refl⟩⊗⟨ (braiding-coherence B ⟩⊗⟨refl ⟩∘⟨refl) ⟩∘⟨refl ⟩ id ⊗₁ (ρ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈˘⟨ refl⟩⊗⟨ switch-fromtoʳ α triangle ⟩∘⟨refl ⟩ id ⊗₁ (id ⊗₁ λ⇒) ∘ α⇒ ≈˘⟨ assoc-commute-from ⟩ α⇒ ∘ (id ⊗₁ id) ⊗₁ λ⇒ ∎)) ⟩∘⟨refl ⟩ (id ⊗₁ ρ⇒ ∘ α⇒ ∘ (id ⊗₁ id) ⊗₁ λ⇒) ∘ id ⊗₁ λ⇐ ≈⟨ (sym-assoc ○ (Kelly's.coherence₂ M ⟩∘⟨ ⊗.identity ⟩⊗⟨refl)) ⟩∘⟨refl ⟩ (ρ⇒ ∘ id ⊗₁ λ⇒) ∘ id ⊗₁ λ⇐ ≈⟨ cancelʳ (_≅_.isoʳ (idᵢ ⊗ᵢ unitorˡ)) ⟩ ρ⇒ ∎ swapInner-braiding : [ (W ⊗₀ X) ⊗₀ (Y ⊗₀ Z) ⇒ (Y ⊗₀ Z) ⊗₀ (W ⊗₀ X) ]⟨ i⇒ ⇒⟨ (W ⊗₀ Y) ⊗₀ (X ⊗₀ Z) ⟩ σ⇒ ⊗₁ σ⇒ ⇒⟨ (Y ⊗₀ W) ⊗₀ (Z ⊗₀ X) ⟩ i⇒ ≈ σ⇒ ⟩ swapInner-braiding = begin i⇒ ∘ σ⇒ ⊗₁ σ⇒ ∘ i⇒ ≡⟨⟩ i⇒ ∘ σ⇒ ⊗₁ σ⇒ ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ swapInner-coherent ⟩∘⟨ pushˡ serialize₁₂ ⟩ j⇒ ∘ σ⇒ ⊗₁ id ∘ id ⊗₁ σ⇒ ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈˘⟨ ((refl⟩∘⟨ refl⟩⊗⟨ ⊗.identity) ⟩∘⟨ ⊗.identity ⟩⊗⟨refl ⟩∘⟨refl) ○ assoc ⟩ ((α⇒ ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ∘ σ⇒ ⊗₁ (id ⊗₁ id)) ∘ (id ⊗₁ id) ⊗₁ σ⇒ ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ pullʳ (pullʳ assoc-commute-to) ⟩∘⟨ extendʳ (⟺ assoc-commute-to) ⟩ (α⇒ ∘ (α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ⊗₁ id ∘ (σ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐) ∘ α⇐ ∘ id ⊗₁ (id ⊗₁ σ⇒) ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈˘⟨ (refl⟩∘⟨ pushˡ split₁ˡ) ⟩∘⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩ (α⇒ ∘ ((α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒) ∘ σ⇒ ⊗₁ id) ⊗₁ id ∘ α⇐) ∘ α⇐ ∘ id ⊗₁ (id ⊗₁ σ⇒ ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ (refl⟩∘⟨ pullʳ (assoc ○ hexagon₁) ⟩⊗⟨refl ⟩∘⟨refl) ⟩∘⟨ refl⟩∘⟨ refl⟩⊗⟨ (⟺ assoc ○ (pullˡ (assoc ○ hexagon₁))) ⟩∘⟨refl ⟩ (α⇒ ∘ (α⇐ ∘ α⇒ ∘ σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ∘ α⇐ ∘ id ⊗₁ ((α⇒ ∘ σ⇒ ∘ α⇒) ∘ α⇐) ∘ α⇒ ≈⟨ (refl⟩∘⟨ cancelˡ α.isoˡ ⟩⊗⟨refl ⟩∘⟨refl) ⟩∘⟨ refl⟩∘⟨ refl⟩⊗⟨ pullʳ (cancelʳ α.isoʳ) ⟩∘⟨refl ⟩ (α⇒ ∘ (σ⇒ ∘ α⇒) ⊗₁ id ∘ α⇐) ∘ α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒) ∘ α⇒ ≈⟨ extendʳ (pushʳ split₁ˡ) ⟩∘⟨ extendʳ (pushʳ split₂ˡ) ⟩ ((α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇒ ⊗₁ id ∘ α⇐) ∘ (α⇐ ∘ id ⊗₁ α⇒) ∘ id ⊗₁ σ⇒ ∘ α⇒ ≈˘⟨ extendʳ (pushʳ (pushʳ assoc)) ⟩ (α⇒ ∘ σ⇒ ⊗₁ id) ∘ (α⇒ ⊗₁ id ∘ (α⇐ ∘ α⇐) ∘ id ⊗₁ α⇒) ∘ id ⊗₁ σ⇒ ∘ α⇒ ≈˘⟨ refl⟩∘⟨ switch-tofromˡ (α ⊗ᵢ idᵢ) (switch-tofromʳ (idᵢ ⊗ᵢ α) inv-pentagon) ⟩∘⟨refl ⟩ (α⇒ ∘ σ⇒ ⊗₁ id) ∘ α⇐ ∘ id ⊗₁ σ⇒ ∘ α⇒ ≈⟨ pullʳ (sym-assoc ○ pullˡ hexagon₂) ⟩ α⇒ ∘ ((α⇐ ∘ σ⇒) ∘ α⇐) ∘ α⇒ ≈⟨ (refl⟩∘⟨ cancelʳ α.isoˡ) ⟩ α⇒ ∘ (α⇐ ∘ σ⇒) ≈⟨ cancelˡ α.isoʳ ⟩ σ⇒ ∎ where inv-pentagon = _≃_.to-≈ pentagon-iso -- Braided monoidal categories have an interchange. hasInterchange : HasInterchange M hasInterchange = record { swapInner = swapInner ; natural = swapInner-natural ; assoc = swapInner-assoc ; unitˡ = swapInner-unitˡ ; unitʳ = swapInner-unitʳ } open HasInterchange hasInterchange public using (naturalIso) -- Extra identities that hold only for symmetric monoidal categories. module SymmetricInterchange {M : Monoidal C} (S : Symmetric M) where open MonoidalReasoning M open MonoidalUtilities M open Symmetric S renaming (associator to α) open Shorthands open BraidedInterchange braided public private i⇒ = swapInner.from i⇐ = swapInner.to σ⇒ = λ {X Y} → braiding.⇒.η (X , Y) σ⇐ = λ {X Y} → braiding.⇐.η (X , Y) swapInner-commutative : [ (X₁ ⊗₀ X₂) ⊗₀ (Y₁ ⊗₀ Y₂) ⇒ (X₁ ⊗₀ X₂) ⊗₀ (Y₁ ⊗₀ Y₂) ]⟨ i⇒ ⇒⟨ (X₁ ⊗₀ Y₁) ⊗₀ (X₂ ⊗₀ Y₂) ⟩ i⇒ ≈ id ⟩ swapInner-commutative = begin i⇒ ∘ i⇒ ≈⟨ pullʳ (cancelInner α.isoʳ) ⟩ α⇐ ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ id ⊗₁ (α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈˘⟨ refl⟩∘⟨ pushˡ split₂ˡ ⟩ α⇐ ∘ id ⊗₁ ((α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ∘ σ⇒ ⊗₁ id ∘ α⇐) ∘ α⇒ ≈⟨ refl⟩∘⟨ refl⟩⊗⟨ (∘-resp-≈ʳ sym-assoc ○ α[σ⊗1]α⁻¹.isoʳ) ⟩∘⟨refl ⟩ α⇐ ∘ id ⊗₁ id ∘ α⇒ ≈⟨ refl⟩∘⟨ ⊗.identity ⟩∘⟨refl ⟩ α⇐ ∘ id ∘ α⇒ ≈⟨ ∘-resp-≈ʳ identityˡ ○ α.isoˡ ⟩ id ∎ where module α[σ⊗1]α⁻¹ = _≅_ (α ∘ᵢ braided-iso ⊗ᵢ idᵢ ∘ᵢ α ⁻¹) swapInner-iso : (W ⊗₀ X) ⊗₀ (Y ⊗₀ Z) ≅ (W ⊗₀ Y) ⊗₀ (X ⊗₀ Z) swapInner-iso = record { from = i⇒ ; to = i⇒ ; iso = record { isoˡ = swapInner-commutative ; isoʳ = swapInner-commutative } } swapInner-braiding′ : [ (W ⊗₀ X) ⊗₀ (Y ⊗₀ Z) ⇒ (Y ⊗₀ W) ⊗₀ (Z ⊗₀ X) ]⟨ i⇒ ⇒⟨ (W ⊗₀ Y) ⊗₀ (X ⊗₀ Z) ⟩ σ⇒ ⊗₁ σ⇒ ≈ σ⇒ ⇒⟨ (Y ⊗₀ Z) ⊗₀ (W ⊗₀ X) ⟩ i⇒ ⟩ swapInner-braiding′ = switch-fromtoˡ swapInner-iso swapInner-braiding
{ "alphanum_fraction": 0.424222123, "avg_line_length": 43.0576923077, "ext": "agda", "hexsha": "58f14596118a77fd037f41983143702cf988c784", "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": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "TOTBWF/agda-categories", "max_forks_repo_path": "src/Categories/Category/Monoidal/Interchange.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "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": "TOTBWF/agda-categories", "max_issues_repo_path": "src/Categories/Category/Monoidal/Interchange.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TOTBWF/agda-categories", "max_stars_repo_path": "src/Categories/Category/Monoidal/Interchange.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 16929, "size": 26868 }
module Issue848 where A : Set1 A = B module _ where B : Set1 B = Set C : Set1 C = B D : Set1 D = E module _ where E : Set1 E = Set F : Set1 F = G module _ where G : Set1 G = H module _ where H : Set1 H = Set
{ "alphanum_fraction": 0.5512820513, "avg_line_length": 9.75, "ext": "agda", "hexsha": "b363f621850c5e7f2bf858624fb911d447adcaa3", "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/Issue848.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/Issue848.agda", "max_line_length": 22, "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/Issue848.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 97, "size": 234 }
{-# OPTIONS --cubical --postfix-projections #-} open import Prelude open import Algebra open import Container module Control.Monad.ListT {ℓ} (𝔽 : Container ℓ ℓ) (is-mon : IsMonad {ℓ} ⟦ 𝔽 ⟧ ) where open IsMonad is-mon postulate cmap-return : (f : A → B) (x : ⟦ 𝔽 ⟧ A) → (cmap f x ≡ (x >>= return ∘ f)) infixr 5 _∷_ mutual List : Type ℓ → Type _ List A = ⟦ 𝔽 ⟧ (Cons A) data Cons (A : Type ℓ) : Type ℓ where [] : Cons A _∷_ : (x : A) → (xs : List A) → Cons A data ℭ𝔬𝔫𝔰 (A : Type ℓ) (P : List A → Type ℓ) : Type ℓ where [] : ℭ𝔬𝔫𝔰 A P _∷_⟨_⟩ : (x : A) → (xs : List A) → (P⟨xs⟩ : P xs) → ℭ𝔬𝔫𝔰 A P module _ (P : List A → Type ℓ) where wrapc : ℭ𝔬𝔫𝔰 A P → Cons A wrapc [] = [] wrapc (x ∷ xs ⟨ P⟨xs⟩ ⟩) = x ∷ xs wrap : ⟦ 𝔽 ⟧ (ℭ𝔬𝔫𝔰 A P) → List A wrap = cmap wrapc {-# INLINE wrap #-} module _ (ψ : (x : ⟦ 𝔽 ⟧ (ℭ𝔬𝔫𝔰 A P)) → P (wrap x)) where elim : (x : List A) → P x elimc : Cons A → ℭ𝔬𝔫𝔰 A P wrapc-elimc : (c : Cons A) → wrapc (elimc c) ≡ c wrapc-elimc [] i = [] wrapc-elimc (x ∷ xs) i = x ∷ xs elimc [] = [] elimc (x ∷ xs) = x ∷ xs ⟨ elim xs ⟩ elim xs = subst P (cong (xs .fst ,_) (funExt (λ x → wrapc-elimc (xs .snd x)))) (ψ (cmap elimc xs)) module _ (ϕ : ⟦ 𝔽 ⟧ (ℭ𝔬𝔫𝔰 A (const B)) → B) where para : List A → B parac : Cons A → ℭ𝔬𝔫𝔰 A (const B) para xs = ϕ (cmap parac xs) parac [] = [] parac (x ∷ xs) = x ∷ xs ⟨ para xs ⟩ ++-ϕ : List A → ⟦ 𝔽 ⟧ (ℭ𝔬𝔫𝔰 A (const (List A))) → List A ++-ϕ ys xs = xs >>= λ { [] → ys ; (x ∷ _ ⟨ xs ⟩) → return (x ∷ xs) } infixr 5 _++_ _++_ : List A → List A → List A xs ++ ys = para (++-ϕ ys) xs cmap-comp : (f : B → C) (g : A → B) (x : ⟦ 𝔽 ⟧ A) → cmap f (cmap g x) ≡ cmap (f ∘ g) x cmap-comp f g x = refl cmap-id : (x : ⟦ 𝔽 ⟧ A) → cmap id x ≡ x cmap-id x = refl open import Path.Reasoning ++-id : (xs : List A) → xs ++ return [] ≡ xs ++-id {A = A} = elim P ψ where P : List A → Type ℓ P xs = xs ++ return [] ≡ xs ϕ : ⟦ 𝔽 ⟧ (ℭ𝔬𝔫𝔰 A (const (List A))) → List A ϕ = ++-ϕ (return []) ϕ′ : ℭ𝔬𝔫𝔰 A (const (List A)) → Cons A ϕ′ [] = [] ϕ′ (x ∷ xs ⟨ P⟨xs⟩ ⟩) = x ∷ P⟨xs⟩ ϕ≡ : ∀ xs → ϕ xs ≡ (xs >>= return ∘′ ϕ′) ϕ≡ xs = cong (xs >>=_) (funExt (λ { [] → refl ; (x ∷ xs ⟨ P⟨xs⟩ ⟩) → refl })) lemma : (xs : ℭ𝔬𝔫𝔰 A P) → ϕ′ (parac ϕ (wrapc P xs)) ≡ wrapc P xs lemma [] = refl lemma (x ∷ xs ⟨ P⟨xs⟩ ⟩) = cong (x ∷_) P⟨xs⟩ ψ : (xs : ⟦ 𝔽 ⟧ (ℭ𝔬𝔫𝔰 A P)) → P (wrap P xs) ψ xs = wrap P xs ++ return [] ≡⟨⟩ para ϕ (wrap P xs) ≡⟨⟩ ϕ (cmap (parac ϕ) (wrap P xs)) ≡⟨ ϕ≡ _ ⟩ (cmap (parac ϕ) (wrap P xs) >>= return ∘′ ϕ′) ≡˘⟨ cmap-return ϕ′ _ ⟩ cmap ϕ′ (cmap (parac ϕ) (wrap P xs)) ≡⟨⟩ cmap (ϕ′ ∘ parac ϕ) (wrap P xs) ≡⟨⟩ cmap (ϕ′ ∘ parac ϕ) (cmap (wrapc P) xs) ≡⟨⟩ cmap (ϕ′ ∘ parac ϕ ∘ wrapc P) xs ≡⟨ cong (flip cmap xs) (funExt lemma) ⟩ wrap P xs ∎ -- open import Cubical.Data.Sigma.Properties -- ++-assoc : (xs ys zs : List A) → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs) -- ++-assoc {A = A} xs ys zs = elim P ψ xs -- where -- P : List A → Type ℓ -- P xs′ = (xs′ ++ ys) ++ zs ≡ xs′ ++ (ys ++ zs) -- {-# INLINE P #-} -- ψ : (x : ⟦ 𝔽 ⟧ (ℭ𝔬𝔫𝔰 A P)) → P (wrap P x) -- ψ xs = ΣPathTransport→PathΣ _ _ ({!refl!} , {!!}) -- _>>=′_ : List A → (A → List B) → List B -- _>>=′_ {A = A} {B = B} xs k = para ϕ xs -- where -- ϕ : ⟦ 𝔽 ⟧ (ℭ𝔬𝔫𝔰 A (List B)) → List B -- ϕ xs = xs >>= λ { [] → return [] ; (x ∷ xs) → k x ++ xs }
{ "alphanum_fraction": 0.4658564815, "avg_line_length": 25.7910447761, "ext": "agda", "hexsha": "24f306952202f0c8fb042dd98b3cb9ed35224a0b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Control/Monad/ListT.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Control/Monad/ListT.agda", "max_line_length": 86, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Control/Monad/ListT.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 1760, "size": 3456 }
-- 2014-05-27 Jesper and Andreas postulate A : Set a : A → A → A {-# BUILTIN REWRITE a #-} -- Expected error: -- a does not have the right type for a rewriting relation -- because its type does not end in a sort, but in A -- when checking the pragma BUILTIN REWRITE a
{ "alphanum_fraction": 0.6726618705, "avg_line_length": 19.8571428571, "ext": "agda", "hexsha": "e8ad2c017da8c090af0bb396df5bc6e37c1be92c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/RewriteRelationNotSort.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/RewriteRelationNotSort.agda", "max_line_length": 59, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/fail/RewriteRelationNotSort.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 82, "size": 278 }
{-# OPTIONS --without-K --safe #-} module Categories.NaturalTransformation where -- all the important stuff about NaturalTransformation are defined in .Core open import Categories.NaturalTransformation.Core public
{ "alphanum_fraction": 0.8055555556, "avg_line_length": 30.8571428571, "ext": "agda", "hexsha": "be992cc5eb48eb6dff59088d5d59effe7eb59ad5", "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/NaturalTransformation.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/NaturalTransformation.agda", "max_line_length": 75, "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/NaturalTransformation.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": 38, "size": 216 }
open import Issue481PonderBase open import Issue481PonderImportMe as as module Issue481PonderMaster where module M = as as as
{ "alphanum_fraction": 0.8372093023, "avg_line_length": 16.125, "ext": "agda", "hexsha": "44dc616721a809a62dc419e7d5801c588fcc4d5d", "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/Issue481PonderMaster.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/Issue481PonderMaster.agda", "max_line_length": 40, "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/Issue481PonderMaster.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": 34, "size": 129 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Diagram.Pullback.Properties {o ℓ e} (C : Category o ℓ e) where open import Function using (_$_) open import Categories.Category.Cartesian C open import Categories.Diagram.Pullback C open import Categories.Diagram.Equalizer C open import Categories.Object.Product C open import Categories.Object.Terminal C open import Categories.Morphism.Reasoning C private open Category C variable X Y Z : Obj f g h i : X ⇒ Y open HomReasoning -- pullback from a terminal object is the same as a product module _ (t : Terminal) where open Terminal t pullback-⊤⇒product : Pullback (! {X}) (! {Y}) → Product X Y pullback-⊤⇒product p = record { A×B = P ; π₁ = p₁ ; π₂ = p₂ ; ⟨_,_⟩ = λ f g → universal (!-unique₂ {f = ! ∘ f} {g = ! ∘ g}) ; project₁ = p₁∘universal≈h₁ ; project₂ = p₂∘universal≈h₂ ; unique = λ eq eq′ → ⟺ (unique eq eq′) } where open Pullback p product⇒pullback-⊤ : Product X Y → Pullback (! {X}) (! {Y}) product⇒pullback-⊤ p = record { p₁ = π₁ ; p₂ = π₂ ; isPullback = record { commute = !-unique₂ ; universal = λ {_ f g} _ → ⟨ f , g ⟩ ; unique = λ eq eq′ → ⟺ (unique eq eq′) ; p₁∘universal≈h₁ = project₁ ; p₂∘universal≈h₂ = project₂ } } where open Product p -- pullbacks respect _≈_ module _ (p : Pullback f g) where open Pullback p pullback-resp-≈ : f ≈ h → g ≈ i → Pullback h i pullback-resp-≈ eq eq′ = record { p₁ = p₁ ; p₂ = p₂ ; isPullback = record { commute = ∘-resp-≈ˡ (⟺ eq) ○ commute ○ ∘-resp-≈ˡ eq′ ; universal = λ eq″ → universal (∘-resp-≈ˡ eq ○ eq″ ○ ∘-resp-≈ˡ (⟺ eq′)) ; unique = unique ; p₁∘universal≈h₁ = p₁∘universal≈h₁ ; p₂∘universal≈h₂ = p₂∘universal≈h₂ } } -- Some facts about pulling back along identity module _ (p : Pullback id f) where open Pullback p -- This is a more subtle way of saying that 'p₂ ≈ id', without involving heterogenous equality. pullback-identity : universal id-comm-sym ∘ p₂ ≈ id pullback-identity = begin universal Basic.id-comm-sym ∘ p₂ ≈⟨ unique ( pullˡ p₁∘universal≈h₁ ) (pullˡ p₂∘universal≈h₂) ⟩ universal eq ≈⟨ universal-resp-≈ (⟺ commute ○ identityˡ) identityˡ ⟩ universal commute ≈˘⟨ Pullback.id-unique p ⟩ id ∎ where eq : id ∘ f ∘ p₂ ≈ f ∘ id ∘ p₂ eq = begin (id ∘ f ∘ p₂) ≈⟨ elimˡ Equiv.refl ⟩ (f ∘ p₂) ≈˘⟨ refl⟩∘⟨ identityˡ ⟩ (f ∘ id ∘ p₂) ∎ module _ (pullbacks : ∀ {X Y Z} (f : X ⇒ Z) (g : Y ⇒ Z) → Pullback f g) (cartesian : Cartesian) where open Cartesian cartesian pullback×cartesian⇒equalizer : Equalizer f g pullback×cartesian⇒equalizer {f = f} {g = g} = record { arr = p.p₁ ; equality = equality ; equalize = λ {_ h} eq → p.universal $ begin ⟨ f , g ⟩ ∘ h ≈⟨ ⟨⟩∘ ⟩ ⟨ f ∘ h , g ∘ h ⟩ ≈˘⟨ ⟨⟩-cong₂ identityˡ (identityˡ ○ eq) ⟩ ⟨ id ∘ f ∘ h , id ∘ f ∘ h ⟩ ≈˘⟨ ⟨⟩∘ ⟩ ⟨ id , id ⟩ ∘ f ∘ h ∎ ; universal = ⟺ p.p₁∘universal≈h₁ ; unique = λ eq → p.unique (⟺ eq) (⟺ (pullˡ eq′) ○ ⟺ (∘-resp-≈ʳ eq)) } where p : Pullback ⟨ f , g ⟩ ⟨ id , id ⟩ p = pullbacks _ _ module p = Pullback p eq : ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈ ⟨ p.p₂ , p.p₂ ⟩ eq = begin ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈˘⟨ ⟨⟩∘ ⟩ ⟨ f , g ⟩ ∘ p.p₁ ≈⟨ p.commute ⟩ ⟨ id , id ⟩ ∘ p.p₂ ≈⟨ ⟨⟩∘ ⟩ ⟨ id ∘ p.p₂ , id ∘ p.p₂ ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ identityˡ ⟩ ⟨ p.p₂ , p.p₂ ⟩ ∎ eq′ : f ∘ p.p₁ ≈ p.p₂ eq′ = begin f ∘ p.p₁ ≈˘⟨ project₁ ⟩ π₁ ∘ ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈⟨ refl⟩∘⟨ eq ⟩ π₁ ∘ ⟨ p.p₂ , p.p₂ ⟩ ≈⟨ project₁ ⟩ p.p₂ ∎ equality : f ∘ p.p₁ ≈ g ∘ p.p₁ equality = begin f ∘ p.p₁ ≈⟨ eq′ ⟩ p.p₂ ≈˘⟨ project₂ ⟩ π₂ ∘ ⟨ p.p₂ , p.p₂ ⟩ ≈˘⟨ refl⟩∘⟨ eq ⟩ π₂ ∘ ⟨ f ∘ p.p₁ , g ∘ p.p₁ ⟩ ≈⟨ project₂ ⟩ g ∘ p.p₁ ∎
{ "alphanum_fraction": 0.4759009009, "avg_line_length": 34.4186046512, "ext": "agda", "hexsha": "d67e96790e7f01ad475e01ed7a038e21f7a40ddf", "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": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bolt12/agda-categories", "max_forks_repo_path": "src/Categories/Diagram/Pullback/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "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": "bolt12/agda-categories", "max_issues_repo_path": "src/Categories/Diagram/Pullback/Properties.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "b813fa3e685eb4713bace6204b8084a343d549a3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bolt12/agda-categories", "max_stars_repo_path": "src/Categories/Diagram/Pullback/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1700, "size": 4440 }
open import Agda.Primitive using (lzero; lsuc; _⊔_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; subst) open import Relation.Binary import MultiSorted.Context as MSC import MultiSorted.AlgebraicTheory as MST import SingleSorted.AlgebraicTheory module MultiSorted.FromSingleSorted (Σ : SingleSorted.AlgebraicTheory.Signature) (𝒯 : SingleSorted.AlgebraicTheory.Theory lzero Σ) where module SS where open SingleSorted.AlgebraicTheory public open SingleSorted.AlgebraicTheory.Signature Σ public data 𝒜 : Set where A : 𝒜 single-sort : ∀ (X : 𝒜) → X ≡ A single-sort A = refl -- We have to transform the following constructions from the single sorted to the multi sorted setting -- contexts, variables, operations, terms, equations, theory singleSortedToMultiSortedContext : ∀ {𝓈} {Sort : Set 𝓈} (X : Sort) → SS.Context → MSC.Context Sort singleSortedToMultiSortedContext _ SS.ctx-empty = MSC.Context.ctx-empty singleSortedToMultiSortedContext X SS.ctx-slot = MSC.Context.ctx-slot X singleSortedToMultiSortedContext X (SS.ctx-concat Γ Δ) = MSC.Context.ctx-concat (singleSortedToMultiSortedContext X Γ) (singleSortedToMultiSortedContext X Δ) multiSortedToSingleSortedContext : ∀ {𝓈} {Sort : Set 𝓈} (X : Sort) → MSC.Context Sort → SS.Context multiSortedToSingleSortedContext X MSC.ctx-empty = SS.ctx-empty multiSortedToSingleSortedContext X (MSC.ctx-slot x) = SS.ctx-slot multiSortedToSingleSortedContext X (MSC.ctx-concat Γ Δ) = SS.ctx-concat (multiSortedToSingleSortedContext X Γ) (multiSortedToSingleSortedContext X Δ) S : MST.Signature S = record { sort = 𝒜 ; oper = SS.Signature.oper Σ ; oper-arity = λ{ f → singleSortedToMultiSortedContext A (SS.Signature.oper-arity Σ f) } ; oper-sort = λ{ f → A } } module MS where open MST.Signature S public singleSortedToMultiSortedVar : ∀ {Γ : SS.Context} → SS.var Γ → MS.var (singleSortedToMultiSortedContext A Γ) singleSortedToMultiSortedVar SS.var-var = MS.var-var singleSortedToMultiSortedVar (SS.var-inl x) = MS.var-inl (singleSortedToMultiSortedVar x) singleSortedToMultiSortedVar (SS.var-inr x) = MS.var-inr (singleSortedToMultiSortedVar x) coerce : ∀ {Γ : MS.Context} {X} {Y} → MS.Term Γ X → MS.Term Γ Y coerce {Γ} {A} {A} t = subst (MS.Term Γ) refl t argToArg : ∀ {Δ : SS.Context} → MS.arg (singleSortedToMultiSortedContext A Δ) → SS.arg Δ argToArg {SS.ctx-slot} i = SS.var-var argToArg {SS.ctx-concat Δ Γ} (MSC.var-inl i) = SS.var-inl (argToArg i) argToArg {SS.ctx-concat Δ Γ} (MSC.var-inr i) = SS.var-inr (argToArg i) singleSortedToMultiSortedTerm : ∀ {Γ : SS.Context} → SS.Term Γ → MS.Term (singleSortedToMultiSortedContext A Γ) A singleSortedToMultiSortedTerm {Γ} (SS.tm-var x) = coerce (MS.tm-var (singleSortedToMultiSortedVar x)) singleSortedToMultiSortedTerm (SS.tm-oper f ts) = MS.tm-oper f (λ i → coerce (singleSortedToMultiSortedTerm (ts (argToArg i)))) singleSortedToMultiSortedEquation : SS.Equation → MST.Equation S singleSortedToMultiSortedEquation eq = MST.make-eq (singleSortedToMultiSortedContext A (SS.Equation.eq-ctx eq)) A (singleSortedToMultiSortedTerm (SS.Equation.eq-lhs eq)) (singleSortedToMultiSortedTerm (SS.Equation.eq-rhs eq)) 𝓣 : MST.Theory lzero S 𝓣 = record { ax = SS.Theory.ax 𝒯 ; ax-eq = λ{ a → singleSortedToMultiSortedEquation (SS.Theory.ax-eq 𝒯 a)} }
{ "alphanum_fraction": 0.7390279823, "avg_line_length": 38.5795454545, "ext": "agda", "hexsha": "26884c7558d535ad73c67070477a53d04e86e9d1", "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/FromSingleSorted.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/FromSingleSorted.agda", "max_line_length": 102, "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/FromSingleSorted.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": 1020, "size": 3395 }
------------------------------------------------------------------------ -- Polymorphic and iso-recursive types ------------------------------------------------------------------------ module SystemF.Type where open import Data.Fin using (Fin; zero; suc) open import Data.Fin.Substitution open import Data.Fin.Substitution.Lemmas open import Data.Nat using (ℕ; _+_) open import Data.Star using (Star; ε; _◅_) open import Data.Vec using (Vec; []; _∷_; lookup; map) open import Relation.Binary.PropositionalEquality as PropEq using (refl; _≡_; cong; cong₂; sym) open PropEq.≡-Reasoning ------------------------------------------------------------------------ -- Polymorphic and iso-recursive types infixr 7 _→'_ -- Types with up to n free type variables data Type (n : ℕ) : Set where var : Fin n → Type n -- type variable _→'_ : Type n → Type n → Type n -- arrow/function type ∀' : Type (1 + n) → Type n -- universal type μ : Type (1 + n) → Type n -- recursive type ------------------------------------------------------------------------ -- Substitutions in types module TypeSubst where module TypeApp {T : ℕ → Set} (l : Lift T Type) where open Lift l hiding (var) infixl 8 _/_ -- Apply a substitution to a type _/_ : ∀ {m n} → Type m → Sub T m n → Type n var x / σ = lift (lookup σ x) (a →' b) / σ = (a / σ) →' (b / σ) ∀' a / σ = ∀' (a / σ ↑) μ a / σ = μ (a / σ ↑) open Application (record { _/_ = _/_ }) using (_/✶_) -- Helper lemmas relating application of simple substitutions (_/_) -- to application of sequences of substititions (_/✶_). These are -- used to derive other (more general) lemmas below. →'-/✶-↑✶ : ∀ k {m n a b} (ρs : Subs T m n) → (a →' b) /✶ ρs ↑✶ k ≡ (a /✶ ρs ↑✶ k) →' (b /✶ ρs ↑✶ k) →'-/✶-↑✶ k ε = refl →'-/✶-↑✶ k (ρ ◅ ρs) = cong₂ _/_ (→'-/✶-↑✶ k ρs) refl ∀'-/✶-↑✶ : ∀ k {m n a} (ρs : Subs T m n) → (∀' a) /✶ ρs ↑✶ k ≡ ∀' (a /✶ ρs ↑✶ (1 + k)) ∀'-/✶-↑✶ k ε = refl ∀'-/✶-↑✶ k (ρ ◅ ρs) = cong₂ _/_ (∀'-/✶-↑✶ k ρs) refl μT-/✶-↑✶ : ∀ k {m n a} (ρs : Subs T m n) → (μ a) /✶ ρs ↑✶ k ≡ μ (a /✶ ρs ↑✶ (1 + k)) μT-/✶-↑✶ k ε = refl μT-/✶-↑✶ k (ρ ◅ ρs) = cong₂ _/_ (μT-/✶-↑✶ k ρs) refl -- Defining the abstract members var and _/_ in -- Data.Fin.Substitution.TermSubst for T = Type gives us access to a -- number of (generic) substitution functions out-of-the-box. typeSubst : TermSubst Type typeSubst = record { var = var; app = TypeApp._/_ } open TermSubst typeSubst public hiding (var) weaken↑ : ∀ {n} → Type (1 + n) → Type (2 + n) weaken↑ a = a / wk ↑ infix 8 _[/_] -- Shorthand for single-variable type substitutions _[/_] : ∀ {n} → Type (1 + n) → Type n → Type n a [/ b ] = a / sub b -- Substitution lemmas. module TypeLemmas where -- FIXME: The following lemmas are generic and should go somewhere -- else. module AdditionalLemmas {T} (lemmas : TermLemmas T) where open TermLemmas lemmas -- Weakening commutes with single-variable substitution weaken-sub : ∀ {n} (a : T (1 + n)) (b : T n) → weaken (a / sub b) ≡ a / wk ↑ / sub (weaken b) weaken-sub a b = begin weaken (a / sub b) ≡⟨ sym (/-wk′ (a / sub b)) ⟩ a / sub b / wk ≡⟨ sub-commutes a ⟩ a / wk ↑ / sub (b / wk) ≡⟨ cong (λ c → a / wk ↑ / sub c) (/-wk′ b) ⟩ a / wk ↑ / sub (weaken b) ∎ where /-wk′ : ∀ {n} (a : T n) → a / wk ≡ weaken a /-wk′ a = /-wk {t = a} -- Weakening commutes with reverse composition of substitutions. map-weaken-⊙ : ∀ {m n k} (σ₁ : Sub T m n) (σ₂ : Sub T n k) → map weaken (σ₁ ⊙ σ₂) ≡ (map weaken σ₁) ⊙ (σ₂ ↑) map-weaken-⊙ σ₁ σ₂ = begin map weaken (σ₁ ⊙ σ₂) ≡⟨ map-weaken ⟩ (σ₁ ⊙ σ₂) ⊙ wk ≡⟨ sym ⊙-assoc ⟩ σ₁ ⊙ (σ₂ ⊙ wk) ≡⟨ cong (λ σ₂ → σ₁ ⊙ σ₂) ⊙-wk ⟩ σ₁ ⊙ (wk ⊙ (σ₂ ↑)) ≡⟨ ⊙-assoc ⟩ (σ₁ ⊙ wk) ⊙ (σ₂ ↑) ≡⟨ cong (λ σ₁ → σ₁ ⊙ (σ₂ ↑)) (sym map-weaken) ⟩ (map weaken σ₁) ⊙ (σ₂ ↑) ∎ -- Giving concrete definitions (i.e. proofs) for the abstract members -- (i.e. lemmas) in Data.Fin.Substitution.Lemmas.TermLemmas for T = -- Type gives us access to a number of (generic) substitutions lemmas -- out-of-the-box. typeLemmas : TermLemmas Type typeLemmas = record { termSubst = TypeSubst.typeSubst ; app-var = refl ; /✶-↑✶ = Lemma./✶-↑✶ } where module Lemma {T₁ T₂} {lift₁ : Lift T₁ Type} {lift₂ : Lift T₂ Type} where open TypeSubst open Lifted lift₁ using () renaming (_↑✶_ to _↑✶₁_; _/✶_ to _/✶₁_) open Lifted lift₂ using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂_) /✶-↑✶ : ∀ {m n} (ρs₁ : Subs T₁ m n) (ρs₂ : Subs T₂ m n) → (∀ k x → var x /✶₁ ρs₁ ↑✶₁ k ≡ var x /✶₂ ρs₂ ↑✶₂ k) → ∀ k t → t /✶₁ ρs₁ ↑✶₁ k ≡ t /✶₂ ρs₂ ↑✶₂ k /✶-↑✶ ρs₁ ρs₂ hyp k (var x) = hyp k x /✶-↑✶ ρs₁ ρs₂ hyp k (a →' b) = begin (a →' b) /✶₁ ρs₁ ↑✶₁ k ≡⟨ TypeApp.→'-/✶-↑✶ _ k ρs₁ ⟩ (a /✶₁ ρs₁ ↑✶₁ k) →' (b /✶₁ ρs₁ ↑✶₁ k) ≡⟨ cong₂ _→'_ (/✶-↑✶ ρs₁ ρs₂ hyp k a) (/✶-↑✶ ρs₁ ρs₂ hyp k b) ⟩ (a /✶₂ ρs₂ ↑✶₂ k) →' (b /✶₂ ρs₂ ↑✶₂ k) ≡⟨ sym (TypeApp.→'-/✶-↑✶ _ k ρs₂) ⟩ (a →' b) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (∀' a) = begin (∀' a) /✶₁ ρs₁ ↑✶₁ k ≡⟨ TypeApp.∀'-/✶-↑✶ _ k ρs₁ ⟩ ∀' (a /✶₁ ρs₁ ↑✶₁ (1 + k)) ≡⟨ cong ∀' (/✶-↑✶ ρs₁ ρs₂ hyp (1 + k) a) ⟩ ∀' (a /✶₂ ρs₂ ↑✶₂ (1 + k)) ≡⟨ sym (TypeApp.∀'-/✶-↑✶ _ k ρs₂) ⟩ (∀' a) /✶₂ ρs₂ ↑✶₂ k ∎ /✶-↑✶ ρs₁ ρs₂ hyp k (μ a) = begin (μ a) /✶₁ ρs₁ ↑✶₁ k ≡⟨ TypeApp.μT-/✶-↑✶ _ k ρs₁ ⟩ μ (a /✶₁ ρs₁ ↑✶₁ (1 + k)) ≡⟨ cong μ (/✶-↑✶ ρs₁ ρs₂ hyp (1 + k) a) ⟩ μ (a /✶₂ ρs₂ ↑✶₂ (1 + k)) ≡⟨ sym (TypeApp.μT-/✶-↑✶ _ k ρs₂) ⟩ (μ a) /✶₂ ρs₂ ↑✶₂ k ∎ open TermLemmas typeLemmas public hiding (var) open TypeSubst public using (_[/_]; _/Var_; weaken↑; module Lifted) -- The above lemma /✶-↑✶ specialized to single substitutions /-↑⋆ : ∀ {T₁ T₂} {lift₁ : Lift T₁ Type} {lift₂ : Lift T₂ Type} → let open Lifted lift₁ using () renaming (_↑⋆_ to _↑⋆₁_; _/_ to _/₁_) open Lifted lift₂ using () renaming (_↑⋆_ to _↑⋆₂_; _/_ to _/₂_) in ∀ {n k} (ρ₁ : Sub T₁ n k) (ρ₂ : Sub T₂ n k) → (∀ i x → var x /₁ ρ₁ ↑⋆₁ i ≡ var x /₂ ρ₂ ↑⋆₂ i) → ∀ i a → a /₁ ρ₁ ↑⋆₁ i ≡ a /₂ ρ₂ ↑⋆₂ i /-↑⋆ ρ₁ ρ₂ hyp i a = /✶-↑✶ (ρ₁ ◅ ε) (ρ₂ ◅ ε) hyp i a open AdditionalLemmas typeLemmas public ------------------------------------------------------------------------ -- Encoding/translation of additional type operators module TypeOperators where open TypeLemmas hiding (id) -- Type of the polymorphic identity id : ∀ {n} → Type n id = ∀' ((var zero) →' (var zero)) -- Bottom/initial/zero type ⊥ : ∀ {n} → Type n ⊥ = ∀' (var zero) -- Top/terminal/unit type ⊤ : ∀ {n} → Type n ⊤ = id -- Existential type ∃ : ∀ {n} → Type (1 + n) → Type n ∃ a = ∀' (∀' (weaken↑ a →' var (suc zero)) →' var zero) infixr 7 _→ⁿ_ -- n-ary function type _→ⁿ_ : ∀ {n k} → Vec (Type n) k → Type n → Type n [] →ⁿ z = z (a ∷ as) →ⁿ z = as →ⁿ a →' z -- Record/finite tuple rec : ∀ {n k} → Vec (Type n) k → Type n rec [] = ⊤ rec (a ∷ as) = ∀' ((map weaken (a ∷ as) →ⁿ var zero) →' var zero) ------------------------------------------------------------------------ -- Lemmas about encoded type operators module TypeOperatorLemmas where open TypeOperators open TypeLemmas hiding (_/_; id) module TypeOperatorAppLemmas {T} (l : Lift T Type) where open TypeSubst.TypeApp l -- Type substitution commutes with the translation of of n-ary -- function types /-→ⁿ : ∀ {m n k} (as : Vec (Type m) k) (b : Type m) (σ : Sub T m n) → (as →ⁿ b) / σ ≡ map (λ a → a / σ) as →ⁿ b / σ /-→ⁿ [] _ _ = refl /-→ⁿ (a ∷ as) b σ = /-→ⁿ as (a →' b) σ -- FIXME: Write similar lemmas for the remaining type operators private module WeakeningLemmas where open TypeOperatorAppLemmas TypeSubst.varLift -- Weakening commutes with the translation of of n-ary function -- types weaken-→ⁿ : ∀ {n k} (as : Vec (Type n) k) (b : Type n) → weaken (as →ⁿ b) ≡ map weaken as →ⁿ weaken b weaken-→ⁿ as b = /-→ⁿ as b VarSubst.wk -- FIXME: Write similar lemmas for the remaining type operators open TypeOperatorAppLemmas TypeSubst.termLift public open WeakeningLemmas public
{ "alphanum_fraction": 0.4849150387, "avg_line_length": 36.0458333333, "ext": "agda", "hexsha": "9aeced51f58c66988f04db3d0485158da12f7db1", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-07-06T23:12:48.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-29T12:24:46.000Z", "max_forks_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "sstucki/system-f-agda", "max_forks_repo_path": "src/SystemF/Type.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d", "max_issues_repo_issues_event_max_datetime": "2019-05-11T19:23:26.000Z", "max_issues_repo_issues_event_min_datetime": "2017-05-30T06:43:04.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "sstucki/system-f-agda", "max_issues_repo_path": "src/SystemF/Type.agda", "max_line_length": 78, "max_stars_count": 68, "max_stars_repo_head_hexsha": "ea262cf7714cdb762643f10275c568596f57cd1d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "sstucki/system-f-agda", "max_stars_repo_path": "src/SystemF/Type.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-01T01:25:16.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-26T13:12:56.000Z", "num_tokens": 3548, "size": 8651 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Universe {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Weakening open import Definition.LogicalRelation open import Definition.LogicalRelation.Weakening as Lwk open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance as Irr open import Definition.Typed.Properties open import Definition.LogicalRelation.Properties.MaybeEmb open import Definition.LogicalRelation.Properties.Escape open import Definition.LogicalRelation.Properties.Reduction open import Definition.LogicalRelation.Properties.Conversion open import Tools.Product import Tools.PropositionalEquality as PE open import Tools.Empty using (⊥; ⊥-elim) import Data.Fin as Fin import Data.Nat as Nat Ugen : ∀ {Γ rU l} → (⊢Γ : ⊢ Γ) → Γ ⊩⟨ next l ⟩ Univ rU l ^ [ ! , next l ] Ugen {Γ} {rU} {⁰} ⊢Γ = Uᵣ′ (Univ rU ⁰) (ι ¹) rU ⁰ emb< PE.refl ((idRed:*: (Ugenⱼ ⊢Γ))) Ugen {Γ} {rU} {¹} ⊢Γ = Uᵣ′ (Univ rU ¹) ∞ rU ¹ ∞< PE.refl (idRed:*: (Uⱼ ⊢Γ)) U-Relevance-Level : ∀ {l ll Γ A} ([U] : Γ ⊩⟨ l ⟩U A ^ ll) → Relevance × Level U-Relevance-Level (noemb (Uᵣ r l′ l< eq d)) = r , l′ U-Relevance-Level (emb x X) = U-Relevance-Level X univRedTerm : ∀ {Γ r l u t ti} → Γ ⊢ Univ r l ⇒ u ∷ t ^ ti → ⊥ univRedTerm (conv d′ A≡t) = univRedTerm d′ univRed* : ∀ {Γ r l r′ l′ ti} → Γ ⊢ Univ r l ⇒* Univ r′ l′ ^ ti → (r PE.≡ r′) × (l PE.≡ l′) univRed* (id x) = PE.refl , PE.refl univRed* (univ x ⇨ D) = ⊥-elim (univRedTerm x) -- Reducible terms of type U are reducible types. univEq : ∀ {l Γ A r l′ ll′} → ([U] : Γ ⊩⟨ l ⟩ Univ r l′ ^ [ ! , ll′ ] ) → Γ ⊩⟨ l ⟩ A ∷ Univ r l′ ^ [ ! , ll′ ] / [U] → Γ ⊩⟨ ι l′ ⟩ A ^ [ r , ι l′ ] univEq {ι ⁰} {Γ} {A} {r} {l′} (Uᵣ (Uᵣ r₁ l′₁ () eq [[ ⊢A , ⊢B , D ]])) (Uₜ K d₁ typeK K≡K [t]) univEq {ι ¹} {Γ} {A} {r} {l′} (Uᵣ (Uᵣ r₁ ⁰ emb< eq [[ ⊢A , ⊢B , D ]])) (Uₜ K d₁ typeK K≡K [t]) = let ⊢Γ = wf ⊢A r≡r₁ , l′≡l′₁ = univRed* D [t]′ : Γ ⊩⟨ ι ⁰ ⟩ A ^ [ r₁ , ι ⁰ ] [t]′ = PE.subst (λ X → Γ ⊩⟨ _ ⟩ X ^ [ _ , _ ]) (Definition.Untyped.Properties.wk-id A) ([t] Definition.Typed.Weakening.id ⊢Γ) in PE.subst₂ (λ X Y → Γ ⊩⟨ ι Y ⟩ A ^ [ X , ι Y ]) (PE.sym r≡r₁) (PE.sym l′≡l′₁) [t]′ univEq {∞} {Γ} {A} {r} {l′} (Uᵣ (Uᵣ r₁ ¹ _ eq [[ ⊢A , ⊢B , D ]])) (Uₜ K d₁ typeK K≡K [t]) = let ⊢Γ = wf ⊢A r≡r₁ , l′≡l′₁ = univRed* D [t]′ : Γ ⊩⟨ ι ¹ ⟩ A ^ [ r₁ , ι ¹ ] [t]′ = PE.subst (λ X → Γ ⊩⟨ _ ⟩ X ^ [ _ , _ ]) (Definition.Untyped.Properties.wk-id A) ([t] Definition.Typed.Weakening.id ⊢Γ) in PE.subst₂ (λ X Y → Γ ⊩⟨ ι Y ⟩ A ^ [ X , ι Y ]) (PE.sym r≡r₁) (PE.sym l′≡l′₁) [t]′ univEq (ℕᵣ [[ ⊢A , ⊢B , univ x ⇨ D ]]) [A] = ⊥-elim (univRedTerm x) univEq (ne′ K [[ ⊢A , ⊢B , univ x ⇨ D ]] neK K≡K) [A] = ⊥-elim (univRedTerm x) univEq (Πᵣ′ rF lF lG _ _ F G [[ ⊢A , ⊢B , univ x ⇨ D ]] ⊢F ⊢G A≡A [F] [G] G-ext) [A] = ⊥-elim (univRedTerm x) univEq {ι ¹} (emb _ [U]′) [A] = univEq [U]′ [A] univEq {∞} (emb _ [U]′) [A] = univEq [U]′ [A] univEqGen : ∀ {Γ UA A l′} → ([U] : ((next l′) LogRel.⊩¹U logRelRec (next l′) ^ Γ) UA (next l′)) → Γ ⊩⟨ next l′ ⟩ A ∷ UA ^ [ ! , next l′ ] / Uᵣ [U] → Γ ⊩⟨ ι l′ ⟩ A ^ [ LogRel._⊩¹U_^_.r [U] , ι l′ ] univEqGen {Γ} {UA} {A} {l′} [UA] [A] = let (Uᵣ r l′₁ l< e [[ ⊢A , ⊢B , D ]]) = [UA] [U] = Ugen {l = l′} (wf ⊢A) [UA]' , [UAeq] = redSubst* (PE.subst (λ X → Γ ⊢ UA ⇒* Univ r X ^ [ ! , next X ]) (next-inj e) D) [U] in univEq [U] (convTerm₁ {t = A} [UA]' [U] [UAeq] (irrelevanceTerm (Uᵣ [UA]) [UA]' [A])) univ⊩ : ∀ {A Γ rU lU lU' l} ([U] : Γ ⊩⟨ l ⟩ Univ rU lU ^ [ ! , lU' ]) → Γ ⊩⟨ l ⟩ A ∷ Univ rU lU ^ [ ! , lU' ] / [U] → Γ ⊩⟨ ι lU ⟩ A ^ [ rU , ι lU ] univ⊩ {lU = lU} {l = l} [U] [A] = irrelevance-≤ (≡is≤ PE.refl) (univEq [U] [A]) univEqTerm : ∀ {Γ A t r l′ ll′} → ([U] : Γ ⊩⟨ ∞ ⟩ Univ r l′ ^ [ ! , ll′ ] ) → ([A] : Γ ⊩⟨ ∞ ⟩ A ∷ Univ r l′ ^ [ ! , ll′ ] / [U]) → Γ ⊩⟨ ∞ ⟩ t ∷ A ^ [ r , ι l′ ] / maybeEmb (univ⊩ [U] [A]) → Γ ⊩⟨ ι l′ ⟩ t ∷ A ^ [ r , ι l′ ] / univEq [U] [A] univEqTerm {Γ} {A} {t} {r} {⁰} [U] [A] [t] = [t] univEqTerm {Γ} {A} {t} {r} {¹} [U] [A] [t] = [t] -- Helper function for reducible term equality of type U for specific type derivations. univEqEq′ : ∀ {l ll l′ Γ X A B} ([U] : Γ ⊩⟨ l ⟩U X ^ ll) → let r = toTypeInfo (U-Relevance-Level [U]) in ([A] : Γ ⊩⟨ l′ ⟩ A ^ r) → Γ ⊩⟨ l ⟩ A ≡ B ∷ X ^ [ ! , ll ] / U-intr [U] → Γ ⊩⟨ l′ ⟩ A ≡ B ^ r / [A] univEqEq′ {l} {ll} {l″} {Γ} {X} {A} {B} (noemb (Uᵣ r l′ l< eq [[ ⊢A , ⊢B , D ]])) [A] (Uₜ₌ (Uₜ K d typeK K≡K [t]) [u] A≡B [t≡u]) = let ⊢Γ = wf ⊢A in irrelevanceEq″ (Definition.Untyped.Properties.wk-id A) (Definition.Untyped.Properties.wk-id B) PE.refl PE.refl (emb l< ([t] Definition.Typed.Weakening.id ⊢Γ)) [A] ([t≡u] Definition.Typed.Weakening.id ⊢Γ) univEqEq′ (emb emb< X) [A] [A≡B] = univEqEq′ X [A] [A≡B] univEqEq′ (emb ∞< X) [A] [A≡B] = univEqEq′ X [A] [A≡B] UnivNotℕ : ∀ {Γ r ll} → Γ ⊩ℕ Univ r ll → ⊥ UnivNotℕ {ll = ⁰} [[ ⊢A , ⊢B , D ]] = U≢ℕ (whrDet* (id (univ (univ 0<1 (wf ⊢A))) , Uₙ) (D , ℕₙ)) UnivNotℕ {ll = ¹} [[ ⊢A , ⊢B , D ]] = U≢ℕ (whrDet* (id (Uⱼ (wf ⊢A)) , Uₙ) (D , ℕₙ)) UnivNotΠ : ∀ {Γ r r' lΠ l ll} → (l LogRel.⊩¹Π logRelRec l ^[ Γ , Univ r ll ]) r' lΠ → ⊥ UnivNotΠ {ll = ⁰} (Πᵣ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = U≢Π (whrDet* (id (univ (univ 0<1 (wf ⊢F))) , Uₙ) (red D , Πₙ)) UnivNotΠ {ll = ¹} (Πᵣ rF lF lG _ _ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = U≢Π (whrDet* (id (Uⱼ (wf ⊢F)) , Uₙ) (red D , Πₙ)) U-Relevance-Level-eq : ∀ {l Γ r ll ll'} ([U] : Γ ⊩⟨ l ⟩ Univ r ll ^ [ ! , ll' ]) → U-Relevance-Level (U-elim [U]) PE.≡ (r , ll) U-Relevance-Level-eq {ll = ⁰} (Uᵣ (Uᵣ r ⁰ l< eq d)) = ×-eq (Univ-PE-injectivity (whrDet* (red d , Uₙ) (id (univ (univ 0<1 (wf (_⊢_:⇒*:_^_.⊢A d)))) , Uₙ))) U-Relevance-Level-eq {ll = ¹} (Uᵣ (Uᵣ r ⁰ l< eq d)) = let _ , X = (Univ-PE-injectivity (whrDet* (red d , Uₙ) (id (Uⱼ (wf (_⊢_:⇒*:_^_.⊢A d))) , Uₙ))) in ⊥-elim (⁰≢¹ X) U-Relevance-Level-eq {ll = ¹} (Uᵣ (Uᵣ r ¹ l< eq d)) = ×-eq (Univ-PE-injectivity (whrDet* (red d , Uₙ) (id (Uⱼ (wf (_⊢_:⇒*:_^_.⊢A d))) , Uₙ))) U-Relevance-Level-eq (ℕᵣ X) = ⊥-elim (UnivNotℕ X) U-Relevance-Level-eq (ne′ K D neK K≡K) = ⊥-elim (U≢ne neK (whnfRed* (red D) Uₙ)) U-Relevance-Level-eq (Πᵣ X) = ⊥-elim (UnivNotΠ X) U-Relevance-Level-eq {ι ¹} (emb l< (ℕᵣ X)) = ⊥-elim (UnivNotℕ X) U-Relevance-Level-eq {ι ¹} (emb l< (ne′ K D neK K≡K)) = ⊥-elim (U≢ne neK (whnfRed* (red D) Uₙ)) U-Relevance-Level-eq {ι ¹} (emb l< (Πᵣ X)) = ⊥-elim (UnivNotΠ X) U-Relevance-Level-eq {∞} {ll = ⁰} (emb ∞< (Uᵣ (Uᵣ r ⁰ l<₁ eq d))) = ×-eq (Univ-PE-injectivity (whrDet* (red d , Uₙ) (id (univ (univ 0<1 (wf (_⊢_:⇒*:_^_.⊢A d)))) , Uₙ))) U-Relevance-Level-eq {∞} {ll = ¹} (emb ∞< (Uᵣ (Uᵣ r ⁰ l<₁ eq d))) = let _ , X = (Univ-PE-injectivity (whrDet* (red d , Uₙ) (id (Uⱼ (wf (_⊢_:⇒*:_^_.⊢A d))) , Uₙ))) in ⊥-elim (⁰≢¹ X) U-Relevance-Level-eq {∞} {ll = ¹} (emb ∞< (Uᵣ (Uᵣ r ¹ l<₁ eq d))) = ×-eq (Univ-PE-injectivity (whrDet* (red d , Uₙ) (id (Uⱼ (wf (_⊢_:⇒*:_^_.⊢A d))) , Uₙ))) U-Relevance-Level-eq {∞} (emb {l′ = ι ¹} l< (ℕᵣ X)) = ⊥-elim (UnivNotℕ X) U-Relevance-Level-eq {∞} (emb {l′ = ι ¹} l< (ne′ K D neK K≡K)) = ⊥-elim (U≢ne neK (whnfRed* (red D) Uₙ)) U-Relevance-Level-eq {∞} (emb {l′ = ι ¹} l< (Πᵣ x)) = ⊥-elim (UnivNotΠ x) U-Relevance-Level-eq {∞} (emb {l′ = ι ¹} l< (emb {l′ = ι ⁰} emb< (ℕᵣ x))) = ⊥-elim (UnivNotℕ x) U-Relevance-Level-eq {∞} (emb {l′ = ι ¹} l< (emb {l′ = ι ⁰} emb< (ne′ K D neK K≡K))) = ⊥-elim (U≢ne neK (whnfRed* (red D) Uₙ)) U-Relevance-Level-eq {∞} (emb {l′ = ι ¹} l< (emb {l′ = ι ⁰} emb< (Πᵣ x))) = ⊥-elim (UnivNotΠ x) helper-eq : ∀ {l Γ A B r r'} {[A] : Γ ⊩⟨ l ⟩ A ^ r} (e : r PE.≡ r' ) → Γ ⊩⟨ l ⟩ A ≡ B ^ r' / (PE.subst _ e [A]) → Γ ⊩⟨ l ⟩ A ≡ B ^ r / [A] helper-eq PE.refl X = X -- Reducible term equality of type U is reducible type equality. univEqEq : ∀ {l l′ Γ A B r ll} ([U] : Γ ⊩⟨ l ⟩ Univ r ll ^ [ ! , next ll ]) ([A] : Γ ⊩⟨ l′ ⟩ A ^ [ r , ι ll ]) → Γ ⊩⟨ l ⟩ A ≡ B ∷ Univ r ll ^ [ ! , next ll ] / [U] → Γ ⊩⟨ l′ ⟩ A ≡ B ^ [ r , ι ll ] / [A] univEqEq {l} {l′} {Γ} {A} {B} {r} {ll} [U] [A] [A≡B] = let [A≡B]′ = irrelevanceEqTerm [U] (U-intr (U-elim [U])) [A≡B] X = univEqEq′ (U-elim [U]) (PE.subst (λ r → Γ ⊩⟨ l′ ⟩ A ^ r) (PE.sym (PE.cong toTypeInfo (U-Relevance-Level-eq [U]))) [A]) [A≡B]′ in helper-eq (PE.sym (PE.cong toTypeInfo (U-Relevance-Level-eq [U]))) X univEqEqTerm : ∀ {Γ A t u r l′ ll} → ([U] : Γ ⊩⟨ ∞ ⟩ Univ r l′ ^ [ ! , ll ] ) → ([A] : Γ ⊩⟨ ∞ ⟩ A ∷ Univ r l′ ^ [ ! , ll ] / [U]) → Γ ⊩⟨ ∞ ⟩ t ∷ A ^ [ r , ι l′ ] / maybeEmb (univ⊩ [U] [A]) → Γ ⊩⟨ ∞ ⟩ t ≡ u ∷ A ^ [ r , ι l′ ] / maybeEmb (univ⊩ [U] [A]) → Γ ⊩⟨ ι l′ ⟩ t ≡ u ∷ A ^ [ r , ι l′ ] / univEq [U] [A] univEqEqTerm {Γ} {A} {t} {u} {r} {⁰} [U] [A] [t] [t≡u] = [t≡u] univEqEqTerm {Γ} {A} {t} {u} {r} {¹} [U] [A] [t] [t≡u] = [t≡u] un-univEq : ∀ {l Γ A r } → ([A] : Γ ⊩⟨ ι l ⟩ A ^ [ r , ι l ]) → let [U] : Γ ⊩⟨ next l ⟩ Univ r l ^ [ ! , next l ] [U] = Ugen (wf (escape [A])) in Γ ⊩⟨ next l ⟩ A ∷ Univ r l ^ [ ! , next l ] / [U] un-univEq {⁰} {Γ} {A} {.!} (ℕᵣ [[ ⊢A , ⊢ℕ , D ]] ) = Uₜ ℕ (un-univ:⇒*: [[ ⊢A , ⊢ℕ , D ]]) ℕₙ (≅ₜ-ℕrefl (wf ⊢A)) (λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (ℕᵣ [[ ⊢A , ⊢ℕ , D ]] )) un-univEq {⁰} {Γ} {A} {.%} (Emptyᵣ [[ ⊢A , ⊢Empty , D ]]) = Uₜ (Empty ⁰) (un-univ:⇒*: [[ ⊢A , ⊢Empty , D ]]) Emptyₙ (≅ₜ-Emptyrefl (wf ⊢A)) (λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (Emptyᵣ [[ ⊢A , ⊢Empty , D ]] )) un-univEq {⁰} {Γ} {A} {r} (ne′ K D neK K≡K) = Uₜ K (un-univ:⇒*: D) (ne neK) (~-to-≅ₜ K≡K) (λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (ne′ K D neK K≡K)) un-univEq {⁰} {Γ} {A} {r} (Πᵣ′ rF .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext) = Uₜ (Π F ^ rF ° ⁰ ▹ G ° ⁰ ° ⁰) (un-univ:⇒*: D) Πₙ (≅-un-univ A≡A) λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (Πᵣ′ rF ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext) un-univEq {⁰} {Γ} {A} {.%} (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = Uₜ (∃ F ▹ G) (un-univ:⇒*: D) ∃ₙ (≅-un-univ A≡A) λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) un-univEq {¹} {Γ} {A} {.!} (Uᵣ (Uᵣ r .⁰ emb< eq [[ ⊢A , ⊢B , D ]])) = Uₜ (Univ r ⁰) (un-univ:⇒*: [[ ⊢A , ⊢B , D ]]) Uₙ (≅-U⁰refl (wf ⊢A)) (λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (Uᵣ (Uᵣ r ⁰ emb< eq [[ ⊢A , ⊢B , D ]] ))) un-univEq {¹} {Γ} {A} {.%} (Emptyᵣ [[ ⊢A , ⊢Empty , D ]]) = Uₜ (Empty ¹) (un-univ:⇒*: [[ ⊢A , ⊢Empty , D ]]) Emptyₙ (≅ₜ-Emptyrefl (wf ⊢A)) (λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (Emptyᵣ [[ ⊢A , ⊢Empty , D ]] )) un-univEq {¹} {Γ} {A} {r} (ne′ K D neK K≡K) = Uₜ K (un-univ:⇒*: D) (ne neK) (~-to-≅ₜ K≡K) (λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (ne′ K D neK K≡K)) un-univEq {¹} {Γ} {A} {r} (Πᵣ′ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext) = Uₜ (Π F ^ rF ° lF ▹ G ° lG ° ¹ ) (un-univ:⇒*: D) Πₙ (≅-un-univ A≡A) λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (Πᵣ′ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext) un-univEq {¹} {Γ} {A} {.%} (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) = Uₜ (∃ F ▹ G) (un-univ:⇒*: D) ∃ₙ (≅-un-univ A≡A) λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) un-univEq {¹} {Γ} {A} {.%} (emb emb< (Emptyᵣ [[ ⊢A , ⊢Empty , D ]])) = Uₜ (Empty ¹) (un-univ:⇒*: [[ ⊢A , ⊢Empty , D ]]) Emptyₙ (≅ₜ-Emptyrefl (wf ⊢A)) (λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (Emptyᵣ [[ ⊢A , ⊢Empty , D ]] )) un-univEq {¹} {Γ} {A} {r} (emb emb< (ne′ K D neK K≡K)) = Uₜ K (un-univ:⇒*: D) (ne neK) (~-to-≅ₜ K≡K) (λ [ρ] ⊢Δ → Lwk.wk [ρ] ⊢Δ (ne′ K D neK K≡K)) un-univEq {¹} {Γ} {A} {r} (emb emb< (Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext)) = Uₜ (Π F ^ rF ° lF ▹ G ° lG ° ¹) (un-univ:⇒*: D) Πₙ (≅-un-univ A≡A) λ [ρ] ⊢Δ → let X = Lwk.wk [ρ] ⊢Δ (Πᵣ′ rF lF lG lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext) in maybeEmb′ (<is≤ 0<1) X un-univEq {¹} {Γ} {A} {.%} (emb emb< (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext)) = Uₜ (∃ F ▹ G) (un-univ:⇒*: D) ∃ₙ (≅-un-univ A≡A) λ [ρ] ⊢Δ → let X = Lwk.wk [ρ] ⊢Δ (∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) in maybeEmb′ (<is≤ 0<1) X un-univEqEq-Shape : ∀ {l Γ A B r } ([A] : Γ ⊩⟨ ι l ⟩ A ^ [ r , ι l ]) ([B] : Γ ⊩⟨ ι l ⟩ B ^ [ r , ι l ]) (ShapeA : ShapeView Γ (ι l) (ι l) A B [ r , ι l ] [ r , ι l ] [A] [B]) ([A≡B] : Γ ⊩⟨ ι l ⟩ A ≡ B ^ [ r , ι l ] / [A]) → let [U] : Γ ⊩⟨ next l ⟩ Univ r l ^ [ ! , next l ] [U] = Ugen (wf (escape [A])) in Γ ⊩⟨ next l ⟩ A ≡ B ∷ Univ r l ^ [ ! , next l ] / [U] un-univEqEq-Shape {⁰} {Γ} {A} {B} {.!} _ _ (ℕᵥ [[ ⊢A , ⊢ℕ , D ]] ℕB) [A≡B] = let [A] = ℕᵣ [[ ⊢A , ⊢ℕ , D ]] [B] = ℕᵣ [[ redFirst* [A≡B] , ⊢ℕ , [A≡B] ]] in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ⁰} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅ₜ-ℕrefl (wf ⊢A)) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {⁰} {Γ} {A} {B} {.%} _ _ (Emptyᵥ [[ ⊢A , ⊢Empty , D ]] EmptyB) [A≡B] = let [A] = Emptyᵣ [[ ⊢A , ⊢Empty , D ]] [B] = Emptyᵣ [[ redFirst* [A≡B] , ⊢Empty , [A≡B] ]] in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ⁰} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅ₜ-Emptyrefl (wf ⊢A)) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {⁰} {Γ} {A} {B} {r} _ _ (ne (ne K D neK K≡K) neB) (ne₌ M D′ neM K≡M) = let [A] = ne′ K D neK K≡K [B] = ne′ M D′ neM (~-trans (~-sym K≡M) K≡M) [A≡B] = ne₌ M D′ neM K≡M in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ⁰} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (~-to-≅ₜ K≡M) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {⁰} {Γ} {A} {B} {r} _ _ (Πᵥ (Πᵣ rF .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF' .⁰ .⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext')) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = Πᵣ′ rF ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = Πᵣ′ rF' ⁰ ⁰ (≡is≤ PE.refl) (≡is≤ PE.refl) F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , rF≡rF , _ , G≡G , _ = Π-PE-injectivity (whrDet* (D′ , Whnf.Πₙ) (red D' , Whnf.Πₙ)) in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ⁰} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅-un-univ ( PE.subst (λ X → _ ⊢ Π F ^ rF ° ⁰ ▹ G ° ⁰ ° _ ≅ Π F' ^ rF' ° ⁰ ▹ X ° ⁰ ° _ ^ _ ) G≡G (PE.subst (λ X → _ ⊢ Π F ^ rF ° ⁰ ▹ G ° ⁰ ° _ ≅ Π X ^ rF' ° ⁰ ▹ G′ ° ⁰ ° _ ^ _ ) F≡F (PE.subst (λ X → _ ⊢ Π F ^ rF ° ⁰ ▹ G ° ⁰ ° _ ≅ Π F′ ^ X ° ⁰ ▹ G′ ° ⁰ ° _ ^ _ ) rF≡rF A≡B)))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {⁰} {Γ} {A} {B} {.%} _ _ (∃ᵥ (∃ᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (∃ᵣ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext')) (∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = ∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = ∃ᵣ′ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = ∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , G≡G = ∃-PE-injectivity (whrDet* (D′ , Whnf.∃ₙ) (red D' , Whnf.∃ₙ)) in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ⁰} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅-un-univ ( PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ F' ▹ X ^ _ ) G≡G (PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ X ▹ G′ ^ _ ) F≡F A≡B))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {.!} _ _ (Uᵥ (Uᵣ r .⁰ emb< eq d) (Uᵣ r₁ .⁰ emb< eq₁ d₁)) [A≡B] = let [A] = Uᵣ (Uᵣ r ⁰ emb< eq d) [B] = Uᵣ (Uᵣ r₁ ⁰ emb< eq₁ d₁) [[ ⊢A , _ , _ ]] = d r≡r , _ = Univ-PE-injectivity (whrDet* (red d₁ , Whnf.Uₙ) ([A≡B] , Whnf.Uₙ)) in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (PE.subst (λ X → _ ⊢ Univ r ⁰ ≅ Univ X ⁰ ∷ U _ ^ _ ) (PE.sym r≡r) (≅-U⁰refl (wf ⊢A))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {.%} _ _ (Emptyᵥ [[ ⊢A , ⊢Empty , D ]] EmptyB) [A≡B] = let [A] = Emptyᵣ [[ ⊢A , ⊢Empty , D ]] [B] = Emptyᵣ [[ redFirst* [A≡B] , ⊢Empty , [A≡B] ]] in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅ₜ-Emptyrefl (wf ⊢A)) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {r} _ _ (ne (ne K D neK K≡K) neB) (ne₌ M D′ neM K≡M) = let [A] = ne′ K D neK K≡K [B] = ne′ M D′ neM (~-trans (~-sym K≡M) K≡M) [A≡B] = ne₌ M D′ neM K≡M in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (~-to-≅ₜ K≡M) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {r} _ _ (Πᵥ (Πᵣ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF' lF' lG' lF<' lG<' F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext')) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = Πᵣ′ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = Πᵣ′ rF' lF' lG' lF<' lG<' F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , rF≡rF , lF≡lF , G≡G , lG≡lG , _ = Π-PE-injectivity (whrDet* (D′ , Whnf.Πₙ) (red D' , Whnf.Πₙ)) in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅-un-univ ( PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F' ^ rF' ° lF' ▹ X ° lG' ° _ ^ _ ) G≡G (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π X ^ rF' ° lF' ▹ G′ ° lG' ° _ ^ _ ) F≡F (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ rF' ° lF' ▹ G′ ° X ° _ ^ _ ) lG≡lG (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ rF' ° X ▹ G′ ° lG ° _ ^ _ ) lF≡lF (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ X ° lF ▹ G′ ° lG ° _ ^ _ ) rF≡rF A≡B)))))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {.%} _ _ (∃ᵥ (∃ᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (∃ᵣ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext')) (∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = ∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = ∃ᵣ′ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = ∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , G≡G = ∃-PE-injectivity (whrDet* (D′ , Whnf.∃ₙ) (red D' , Whnf.∃ₙ)) in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅-un-univ ( PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ F' ▹ X ^ _ ) G≡G (PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ X ▹ G′ ^ _ ) F≡F A≡B))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {.%} _ _ (emb⁰¹ (Emptyᵥ [[ ⊢A , ⊢Empty , D ]] EmptyB)) [A≡B] = let [A] = Emptyᵣ [[ ⊢A , ⊢Empty , D ]] [B] = Emptyᵣ [[ redFirst* [A≡B] , ⊢Empty , [A≡B] ]] in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅ₜ-Emptyrefl (wf ⊢A)) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {r} _ _ (emb⁰¹ (ne (ne K D neK K≡K) neB)) (ne₌ M D′ neM K≡M) = let [A] = ne′ K D neK K≡K [B] = ne′ M D′ neM (~-trans (~-sym K≡M) K≡M) [A≡B] = ne₌ M D′ neM K≡M in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (~-to-≅ₜ K≡M) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {r} _ _ (emb⁰¹ (Πᵥ (Πᵣ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF' lF' lG' lF<' lG<' F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext'))) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = Πᵣ′ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = Πᵣ′ rF' lF' lG' lF<' lG<' F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , rF≡rF , lF≡lF , G≡G , lG≡lG , _ = Π-PE-injectivity (whrDet* (D′ , Whnf.Πₙ) (red D' , Whnf.Πₙ)) in Uₜ₌ (un-univEq (maybeEmb′ (<is≤ 0<1) [A])) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅-un-univ ( PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F' ^ rF' ° lF' ▹ X ° lG' ° _ ^ _ ) G≡G (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π X ^ rF' ° lF' ▹ G′ ° lG' ° _ ^ _ ) F≡F (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ rF' ° lF' ▹ G′ ° X ° _ ^ _ ) lG≡lG (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ rF' ° X ▹ G′ ° lG ° _ ^ _ ) lF≡lF (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ X ° lF ▹ G′ ° lG ° _ ^ _ ) rF≡rF A≡B)))))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {.%} _ _ (emb⁰¹ (∃ᵥ (∃ᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (∃ᵣ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext'))) (∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = ∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = ∃ᵣ′ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = ∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , G≡G = ∃-PE-injectivity (whrDet* (D′ , Whnf.∃ₙ) (red D' , Whnf.∃ₙ)) in Uₜ₌ (un-univEq (maybeEmb′ (<is≤ 0<1) [A])) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅-un-univ ( PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ F' ▹ X ^ _ ) G≡G (PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ X ▹ G′ ^ _ ) F≡F A≡B))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {.%} _ _ (emb⁰¹ (emb¹⁰ (Emptyᵥ [[ ⊢A , ⊢Empty , D ]] EmptyB))) [A≡B] = let [A] = Emptyᵣ [[ ⊢A , ⊢Empty , D ]] [B] = Emptyᵣ [[ redFirst* [A≡B] , ⊢Empty , [A≡B] ]] in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅ₜ-Emptyrefl (wf ⊢A)) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {r} _ _ (emb⁰¹ (emb¹⁰ (ne (ne K D neK K≡K) neB))) (ne₌ M D′ neM K≡M) = let [A] = ne′ K D neK K≡K [B] = ne′ M D′ neM (~-trans (~-sym K≡M) K≡M) [A≡B] = ne₌ M D′ neM K≡M in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (~-to-≅ₜ K≡M) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {r} _ _ (emb⁰¹ (emb¹⁰ (Πᵥ (Πᵣ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF' lF' lG' lF<' lG<' F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext')))) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = Πᵣ′ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = Πᵣ′ rF' lF' lG' lF<' lG<' F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , rF≡rF , lF≡lF , G≡G , lG≡lG , _ = Π-PE-injectivity (whrDet* (D′ , Whnf.Πₙ) (red D' , Whnf.Πₙ)) in Uₜ₌ (un-univEq (maybeEmb′ (<is≤ 0<1) [A])) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq (maybeEmb′ (<is≤ 0<1) [B]))) (≅-un-univ ( PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F' ^ rF' ° lF' ▹ X ° lG' ° _ ^ _ ) G≡G (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π X ^ rF' ° lF' ▹ G′ ° lG' ° _ ^ _ ) F≡F (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ rF' ° lF' ▹ G′ ° X ° _ ^ _ ) lG≡lG (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ rF' ° X ▹ G′ ° lG ° _ ^ _ ) lF≡lF (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ X ° lF ▹ G′ ° lG ° _ ^ _ ) rF≡rF A≡B)))))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {.%} _ _ (emb⁰¹ (emb¹⁰ (∃ᵥ (∃ᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (∃ᵣ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext')))) (∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = ∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = ∃ᵣ′ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = ∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , G≡G = ∃-PE-injectivity (whrDet* (D′ , Whnf.∃ₙ) (red D' , Whnf.∃ₙ)) in Uₜ₌ (un-univEq (maybeEmb′ (<is≤ 0<1) [A])) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq (maybeEmb′ (<is≤ 0<1) [B]))) (≅-un-univ ( PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ F' ▹ X ^ _ ) G≡G (PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ X ▹ G′ ^ _ ) F≡F A≡B))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {.%} _ _ (emb¹⁰ (Emptyᵥ [[ ⊢A , ⊢Empty , D ]] EmptyB)) [A≡B] = let [A] = Emptyᵣ [[ ⊢A , ⊢Empty , D ]] [B] = Emptyᵣ [[ redFirst* [A≡B] , ⊢Empty , [A≡B] ]] in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅ₜ-Emptyrefl (wf ⊢A)) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {r} _ _ (emb¹⁰ (ne (ne K D neK K≡K) neB)) (ne₌ M D′ neM K≡M) = let [A] = ne′ K D neK K≡K [B] = ne′ M D′ neM (~-trans (~-sym K≡M) K≡M) [A≡B] = ne₌ M D′ neM K≡M in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (~-to-≅ₜ K≡M) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {r} _ _ (emb¹⁰ (Πᵥ (Πᵣ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF' lF' lG' lF<' lG<' F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext'))) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = Πᵣ′ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = Πᵣ′ rF' lF' lG' lF<' lG<' F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , rF≡rF , lF≡lF , G≡G , lG≡lG , _ = Π-PE-injectivity (whrDet* (D′ , Whnf.Πₙ) (red D' , Whnf.Πₙ)) in Uₜ₌ (un-univEq [A] ) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq (maybeEmb′ (<is≤ 0<1) [B]))) (≅-un-univ ( PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F' ^ rF' ° lF' ▹ X ° lG' ° _ ^ _ ) G≡G (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π X ^ rF' ° lF' ▹ G′ ° lG' ° _ ^ _ ) F≡F (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ rF' ° lF' ▹ G′ ° X ° _ ^ _ ) lG≡lG (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ rF' ° X ▹ G′ ° lG ° _ ^ _ ) lF≡lF (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ X ° lF ▹ G′ ° lG ° _ ^ _ ) rF≡rF A≡B)))))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {.%} _ _ (emb¹⁰ (∃ᵥ (∃ᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (∃ᵣ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext'))) (∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = ∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = ∃ᵣ′ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = ∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , G≡G = ∃-PE-injectivity (whrDet* (D′ , Whnf.∃ₙ) (red D' , Whnf.∃ₙ)) in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq (maybeEmb′ (<is≤ 0<1) [B]))) (≅-un-univ ( PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ F' ▹ X ^ _ ) G≡G (PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ X ▹ G′ ^ _ ) F≡F A≡B))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {.%} _ _ (emb¹⁰ (emb⁰¹ (Emptyᵥ [[ ⊢A , ⊢Empty , D ]] EmptyB))) [A≡B] = let [A] = Emptyᵣ [[ ⊢A , ⊢Empty , D ]] [B] = Emptyᵣ [[ redFirst* [A≡B] , ⊢Empty , [A≡B] ]] in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (≅ₜ-Emptyrefl (wf ⊢A)) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {r} _ _ (emb¹⁰ (emb⁰¹ (ne (ne K D neK K≡K) neB))) (ne₌ M D′ neM K≡M) = let [A] = ne′ K D neK K≡K [B] = ne′ M D′ neM (~-trans (~-sym K≡M) K≡M) [A≡B] = ne₌ M D′ neM K≡M in Uₜ₌ (un-univEq [A]) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq [B])) (~-to-≅ₜ K≡M) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {r} _ _ (emb¹⁰ (emb⁰¹ (Πᵥ (Πᵣ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πᵣ rF' lF' lG' lF<' lG<' F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext')))) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = Πᵣ′ rF lF lG lF< lG< F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = Πᵣ′ rF' lF' lG' lF<' lG<' F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , rF≡rF , lF≡lF , G≡G , lG≡lG , _ = Π-PE-injectivity (whrDet* (D′ , Whnf.Πₙ) (red D' , Whnf.Πₙ)) in Uₜ₌ (un-univEq (maybeEmb′ (<is≤ 0<1) [A])) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq (maybeEmb′ (<is≤ 0<1) [B]))) (≅-un-univ ( PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F' ^ rF' ° lF' ▹ X ° lG' ° _ ^ _ ) G≡G (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π X ^ rF' ° lF' ▹ G′ ° lG' ° _ ^ _ ) F≡F (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ rF' ° lF' ▹ G′ ° X ° _ ^ _ ) lG≡lG (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ rF' ° X ▹ G′ ° lG ° _ ^ _ ) lF≡lF (PE.subst (λ X → _ ⊢ Π F ^ rF ° lF ▹ G ° lG ° _ ≅ Π F′ ^ X ° lF ▹ G′ ° lG ° _ ^ _ ) rF≡rF A≡B)))))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq-Shape {¹} {Γ} {A} {B} {.%} _ _ (emb¹⁰ (emb⁰¹ (∃ᵥ (∃ᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (∃ᵣ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext')))) (∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let [A] = ∃ᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext [B] = ∃ᵣ′ F' G' D' ⊢F' ⊢G' A≡A' [F'] [G'] G-ext' [A≡B] = ∃₌ F′ G′ D′ A≡B [F≡F′] [G≡G′] F≡F , G≡G = ∃-PE-injectivity (whrDet* (D′ , Whnf.∃ₙ) (red D' , Whnf.∃ₙ)) in Uₜ₌ (un-univEq (maybeEmb′ (<is≤ 0<1) [A])) (irrelevanceTerm {l = next ¹} (Ugen (wf (escape [B]))) (Ugen (wf (escape [A]))) (un-univEq (maybeEmb′ (<is≤ 0<1) [B]))) (≅-un-univ ( PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ F' ▹ X ^ _ ) G≡G (PE.subst (λ X → _ ⊢ ∃ F ▹ G ≅ ∃ X ▹ G′ ^ _ ) F≡F A≡B))) λ [ρ] ⊢Δ → Lwk.wkEq [ρ] ⊢Δ [A] [A≡B] un-univEqEq : ∀ {l Γ A B r } ([A] : Γ ⊩⟨ ι l ⟩ A ^ [ r , ι l ]) ([B] : Γ ⊩⟨ ι l ⟩ B ^ [ r , ι l ]) ([A≡B] : Γ ⊩⟨ ι l ⟩ A ≡ B ^ [ r , ι l ] / [A]) → let [U] : Γ ⊩⟨ next l ⟩ Univ r l ^ [ ! , next l ] [U] = Ugen (wf (escape [A])) in Γ ⊩⟨ next l ⟩ A ≡ B ∷ Univ r l ^ [ ! , next l ] / [U] un-univEqEq [A] [B] [A≡B] = un-univEqEq-Shape [A] [B] (goodCases [A] [B] [A≡B]) [A≡B]
{ "alphanum_fraction": 0.4217802184, "avg_line_length": 70.7042889391, "ext": "agda", "hexsha": "da1c9a96048c149649b5d1780cf85172a447e9df", "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/Universe.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/Universe.agda", "max_line_length": 180, "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/Universe.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": 17811, "size": 31322 }
-- Products and Cartesian categories module CategoryTheory.BCCCs.Cartesian where open import CategoryTheory.Categories open import Relation.Binary using (IsEquivalence) module _ {n} (ℂ : Category n) where open Category ℂ -- Terminal object in a category record TerminalObj : Set (lsuc n) where field -- | Data -- The terminal object ⊤ : obj -- Canonical morphism ! : {A : obj} -> (A ~> ⊤) -- | Laws -- Need to show that the canonical morphism ! is unique !-unique : {A : obj} -> (m : A ~> ⊤) -> m ≈ ! -- Product of two objects -- Based on github.com/copumpkin/categories record Product (A B : obj) : Set (lsuc n) where infix 10 ⟨_,_⟩ field -- | Data -- Product of A and B A⊗B : obj -- First projection π₁ : A⊗B ~> A -- Second projection π₂ : A⊗B ~> B -- Canonical mediator ⟨_,_⟩ : ∀{P} -> (P ~> A) -> (P ~> B) -> (P ~> A⊗B) -- | Laws -- ⟨_,_⟩ expresses that given another candidate product C -- and candidate projections to A and B there is a morphism -- from P to A⊗B. We need to check that this mediator makes -- the product diagram commute and is unique. π₁-comm : ∀{P} -> {p₁ : P ~> A} {p₂ : P ~> B} -> π₁ ∘ ⟨ p₁ , p₂ ⟩ ≈ p₁ π₂-comm : ∀{P} -> {p₁ : P ~> A} {p₂ : P ~> B} -> π₂ ∘ ⟨ p₁ , p₂ ⟩ ≈ p₂ ⊗-unique : ∀{P} -> {p₁ : P ~> A} {p₂ : P ~> B} {m : P ~> A⊗B} -> π₁ ∘ m ≈ p₁ -> π₂ ∘ m ≈ p₂ -> ⟨ p₁ , p₂ ⟩ ≈ m -- η-expansion of function pairs (via morphisms) ⊗-η-exp : ∀{P} -> {m : P ~> A⊗B} -> ⟨ π₁ ∘ m , π₂ ∘ m ⟩ ≈ m ⊗-η-exp = ⊗-unique r≈ r≈ -- Pairing of projection functions is the identity ⊗-η-id : ⟨ π₁ , π₂ ⟩ ≈ id ⊗-η-id = ⊗-unique id-right id-right -- Congruence over function pairing ⟨,⟩-cong : ∀{P} -> {p₁ q₁ : P ~> A} {p₂ q₂ : P ~> B} -> p₁ ≈ q₁ -> p₂ ≈ q₂ -> ⟨ p₁ , p₂ ⟩ ≈ ⟨ q₁ , q₂ ⟩ ⟨,⟩-cong pr1 pr2 = ⊗-unique (π₁-comm ≈> pr1 [sym]) (π₂-comm ≈> pr2 [sym]) ⟨,⟩-distrib : ∀{P Q} -> {h : P ~> Q} {f : Q ~> A} {g : Q ~> B} -> ⟨ f , g ⟩ ∘ h ≈ ⟨ f ∘ h , g ∘ h ⟩ ⟨,⟩-distrib = ⊗-unique (∘-assoc [sym] ≈> ≈-cong-left π₁-comm) (∘-assoc [sym] ≈> ≈-cong-left π₂-comm) [sym] -- Type class for Cartesian categories record Cartesian {n} (ℂ : Category n) : Set (lsuc n) where open Category ℂ field -- | Data -- Terminal object term : TerminalObj ℂ -- Binary products for all pairs of objects prod : ∀(A B : obj) -> Product ℂ A B open TerminalObj term public open module P {A} {B} = Product (prod A B) public -- Shorthand for sum object infixl 25 _⊗_ _⊗_ : (A B : obj) -> obj A ⊗ B = A⊗B {A} {B} -- Parallel product of morphisms infixl 65 _*_ _*_ : {A B P Q : obj} -> (A ~> P) -> (B ~> Q) -> (A ⊗ B ~> P ⊗ Q) _*_ {A} {B} {P} {Q} f g = ⟨ f ∘ π₁ , g ∘ π₂ ⟩ -- Parallel product with an idempotent morphism distributes over ∘ *-idemp-dist-∘ : {A B C D : obj}{g : B ~> C}{f : A ~> B}{h : D ~> D} -> h ∘ h ≈ h -> g * h ∘ f * h ≈ (g ∘ f) * h *-idemp-dist-∘ {g = g}{f}{h} idemp = ⊗-unique u₁ u₂ [sym] where u₁ : π₁ ∘ (g * h ∘ f * h) ≈ (g ∘ f) ∘ π₁ u₁ = ∘-assoc [sym] ≈> ≈-cong-left π₁-comm ≈> ∘-assoc ≈> ≈-cong-right π₁-comm ≈> ∘-assoc [sym] u₂ : π₂ ∘ (g * h ∘ f * h) ≈ h ∘ π₂ u₂ = ∘-assoc [sym] ≈> ≈-cong-left π₂-comm ≈> ∘-assoc ≈> ≈-cong-right π₂-comm ≈> ∘-assoc [sym] ≈> ≈-cong-left idemp -- Parallel product with an idempotent morphism distributes over ∘ *-id-dist-∘ : {A B C : obj}{g : B ~> C}{f : A ~> B} -> (_*_ {B = B} g id) ∘ f * id ≈ (g ∘ f) * id *-id-dist-∘ = *-idemp-dist-∘ id-right -- Commutativity of product comm : {A B : obj} -> A ⊗ B ~> B ⊗ A comm {A}{B} = ⟨ π₂ , π₁ ⟩ -- Associativity of product assoc-left : {A B C : obj} -> A ⊗ (B ⊗ C) ~> (A ⊗ B) ⊗ C assoc-left = ⟨ ⟨ π₁ , (π₁ ∘ π₂) ⟩ , π₂ ∘ π₂ ⟩ assoc-right : {A B C : obj} -> (A ⊗ B) ⊗ C ~> A ⊗ (B ⊗ C) assoc-right = ⟨ π₁ ∘ π₁ , ⟨ (π₂ ∘ π₁) , π₂ ⟩ ⟩ -- Left and right unit for product unit-left : {A : obj} -> ⊤ ⊗ A ~> A unit-left = π₂ unit-right : {A : obj} -> A ⊗ ⊤ ~> A unit-right = π₁ -- The terminal object is the unit for product ⊤-left-cancel : ∀{A} -> ⊤ ⊗ A <~> A ⊤-left-cancel {A} = record { iso~> = π₂ ; iso<~ = ⟨ ! , id ⟩ ; iso-id₁ = iso-id₁-⊤ ; iso-id₂ = π₂-comm } where iso-id₁-⊤ : ⟨ ! , id ⟩ ∘ π₂ ≈ id iso-id₁-⊤ = begin ⟨ ! , id ⟩ ∘ π₂ ≈⟨ ⟨,⟩-distrib ⟩ ⟨ ! ∘ π₂ , id ∘ π₂ ⟩ ≈⟨ ⟨,⟩-cong r≈ id-left ⟩ ⟨ ! ∘ π₂ , π₂ ⟩ ≈⟨ ⟨,⟩-cong (!-unique (! ∘ π₂)) r≈ ⟩ ⟨ ! , π₂ ⟩ ≈⟨ ⟨,⟩-cong ((!-unique π₁) [sym]) r≈ ⟩ ⟨ π₁ , π₂ ⟩ ≈⟨ ⊗-η-id ⟩ id ∎ ⊤-right-cancel : ∀{A} -> A ⊗ ⊤ <~> A ⊤-right-cancel {A} = record { iso~> = π₁ ; iso<~ = ⟨ id , ! ⟩ ; iso-id₁ = iso-id₁-⊤ ; iso-id₂ = π₁-comm } where iso-id₁-⊤ : ⟨ id , ! ⟩ ∘ π₁ ≈ id iso-id₁-⊤ = begin ⟨ id , ! ⟩ ∘ π₁ ≈⟨ ⟨,⟩-distrib ⟩ ⟨ id ∘ π₁ , ! ∘ π₁ ⟩ ≈⟨ ⟨,⟩-cong id-left r≈ ⟩ ⟨ π₁ , ! ∘ π₁ ⟩ ≈⟨ ⟨,⟩-cong r≈ (!-unique (! ∘ π₁)) ⟩ ⟨ π₁ , ! ⟩ ≈⟨ ⟨,⟩-cong r≈ ((!-unique π₂) [sym]) ⟩ ⟨ π₁ , π₂ ⟩ ≈⟨ ⊗-η-id ⟩ id ∎
{ "alphanum_fraction": 0.4014913007, "avg_line_length": 32.7989130435, "ext": "agda", "hexsha": "1de94c62b949743b2b972fe536cbbbbfe82fc982", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DimaSamoz/temporal-type-systems", "max_forks_repo_path": "src/CategoryTheory/BCCCs/Cartesian.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DimaSamoz/temporal-type-systems", "max_issues_repo_path": "src/CategoryTheory/BCCCs/Cartesian.agda", "max_line_length": 81, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DimaSamoz/temporal-type-systems", "max_stars_repo_path": "src/CategoryTheory/BCCCs/Cartesian.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z", "num_tokens": 2333, "size": 6035 }
module Issue309b where data D : Set where d : D → D syntax d x = f g : D → D g (d x) = f
{ "alphanum_fraction": 0.5531914894, "avg_line_length": 9.4, "ext": "agda", "hexsha": "34ad8d8792d936a15386732c37502f9d635be633", "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/Issue309b.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/Issue309b.agda", "max_line_length": 22, "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/Issue309b.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": 39, "size": 94 }
module TerminationListInsertionNaive where data List (A : Set) : Set where [] : List A _::_ : A -> List A -> List A infixr 50 _::_ -- non-deterministic choice postulate _⊕_ : {A : Set} -> A -> A -> A infixl 10 _⊕_ -- a funny formulation of insert -- insert (a :: l) inserts a into l -- -- this example cannot be handled with subpatterns -- it is done with structured orders -- could also be done with sized types insert : {A : Set} -> List A -> List A insert [] = [] insert (a :: []) = a :: [] insert (a :: b :: bs) = a :: b :: bs ⊕ -- case a <= b b :: insert (a :: bs) -- case a > b -- list flattening -- termination using structured orders flat : {A : Set} -> List (List A) -> List A flat [] = [] flat ([] :: ll) = flat ll flat ((x :: l) :: ll) = x :: flat (l :: ll) {- generates two recursive calls with the following call matrices [] :: ll (x :: l) ll ll < l < . ll . = during composition, the second is collapsed to =, so the call graph is already complete. Both matrices are idempotent and contain a strictly decreasing argument. It could also be done with sized types; lexicographic in (i,j) with type flat : {A : Set} -> (1 + Listʲ A × List^i (List^∞ A)) -> List^∞ A -}
{ "alphanum_fraction": 0.5349344978, "avg_line_length": 25.4444444444, "ext": "agda", "hexsha": "2e258e4904583087ad01650a12c3bdc30b499544", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/TerminationListInsertionNaive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/TerminationListInsertionNaive.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/TerminationListInsertionNaive.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 394, "size": 1374 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Unit.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Data.Nat open import Cubical.Data.Unit.Base open import Cubical.Data.Prod.Base open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence open import Cubical.Reflection.StrictEquiv isContrUnit : isContr Unit isContrUnit = tt , λ {tt → refl} isPropUnit : isProp Unit isPropUnit _ _ i = tt -- definitionally equal to: isContr→isProp isContrUnit isSetUnit : isSet Unit isSetUnit = isProp→isSet isPropUnit isOfHLevelUnit : (n : HLevel) → isOfHLevel n Unit isOfHLevelUnit n = isContr→isOfHLevel n isContrUnit module _ {ℓ} (A : Type ℓ) where UnitToType≃ : (Unit → A) ≃ A unquoteDef UnitToType≃ = defStrictEquiv UnitToType≃ (λ f → f _) const UnitToTypePath : ∀ {ℓ} (A : Type ℓ) → (Unit → A) ≡ A UnitToTypePath A = ua (UnitToType≃ A) isContr→Iso2 : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → isContr A → Iso (A → B) B Iso.fun (isContr→Iso2 iscontr) f = f (fst iscontr) Iso.inv (isContr→Iso2 iscontr) b _ = b Iso.rightInv (isContr→Iso2 iscontr) _ = refl Iso.leftInv (isContr→Iso2 iscontr) f = funExt λ x → cong f (snd iscontr x) diagonal-unit : Unit ≡ Unit × Unit diagonal-unit = isoToPath (iso (λ x → tt , tt) (λ x → tt) (λ {(tt , tt) i → tt , tt}) λ {tt i → tt}) fibId : ∀ {ℓ} (A : Type ℓ) → (fiber (λ (x : A) → tt) tt) ≡ A fibId A = ua e where unquoteDecl e = declStrictEquiv e fst (λ a → a , refl) isContr→≃Unit : ∀ {ℓ} {A : Type ℓ} → isContr A → A ≃ Unit isContr→≃Unit contr = isoToEquiv (iso (λ _ → tt) (λ _ → fst contr) (λ _ → refl) λ _ → snd contr _) isContr→≡Unit : {A : Type₀} → isContr A → A ≡ Unit isContr→≡Unit contr = ua (isContr→≃Unit contr) isContrUnit* : ∀ {ℓ} → isContr (Unit* {ℓ}) isContrUnit* = tt* , λ _ → refl isPropUnit* : ∀ {ℓ} → isProp (Unit* {ℓ}) isPropUnit* _ _ = refl isOfHLevelUnit* : ∀ {ℓ} (n : HLevel) → isOfHLevel n (Unit* {ℓ}) isOfHLevelUnit* zero = tt* , λ _ → refl isOfHLevelUnit* (suc zero) _ _ = refl isOfHLevelUnit* (suc (suc zero)) _ _ _ _ _ _ = tt* isOfHLevelUnit* (suc (suc (suc n))) = isOfHLevelPlus 3 (isOfHLevelUnit* n)
{ "alphanum_fraction": 0.6868901146, "avg_line_length": 33.1971830986, "ext": "agda", "hexsha": "fb5f049657bb8a70353b60ef42f9260c5ac811f3", "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/Unit/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/Unit/Properties.agda", "max_line_length": 100, "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/Unit/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 875, "size": 2357 }
open import Common.Prelude _test_ : Nat → Nat → Nat _test n = _+ n
{ "alphanum_fraction": 0.6764705882, "avg_line_length": 13.6, "ext": "agda", "hexsha": "f7104839b88eb419e88c541317ccd516b67973dc", "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/Sections-11.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/Sections-11.agda", "max_line_length": 26, "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/Sections-11.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": 68 }
module ChainRule where import Sets import Functor import Logic.ChainReasoning.Poly as CR import Isomorphism import Derivative open Derivative open Sets open Functor open Semantics open Isomorphism module Chain = CR _==_ (\x -> refl{x = x}) (\x y z -> trans{x = x}{y}{z}) open Chain chain-rule : (F G : U)(X : Set) -> ⟦ ∂ (F [ G ]) ⟧ X ≅ ⟦ ∂ F [ G ] × ∂ G ⟧ X chain-rule F G X = iso (i F) (j F) (ji F) (ij F) where i : (F : U) -> ⟦ ∂ (F [ G ]) ⟧ X -> ⟦ ∂ F [ G ] × ∂ G ⟧ X i (K A) () i Id x = < <> , x > i (F₁ + F₂) (inl c) = (inl <×> id) (i F₁ c) i (F₁ + F₂) (inr c) = (inr <×> id) (i F₂ c) i (F₁ × F₂) (inl < c , f₂ >) = (inl ∘ <∙, f₂ > <×> id) (i F₁ c) i (F₁ × F₂) (inr < f₁ , c >) = (inr ∘ < f₁ ,∙> <×> id) (i F₂ c) j : (F : U) -> ⟦ ∂ F [ G ] × ∂ G ⟧ X -> ⟦ ∂ (F [ G ]) ⟧ X j (K A) < () , _ > j Id < <> , x > = x j (F₁ + F₂) < inl x , y > = inl (j F₁ < x , y >) j (F₁ + F₂) < inr x , y > = inr (j F₂ < x , y >) j (F₁ × F₂) < inl < x , y > , z > = inl < j F₁ < x , z > , y > j (F₁ × F₂) < inr < x , y > , z > = inr < x , j F₂ < y , z > > ij : (F : U)(x : _) -> i F (j F x) == x ij (K A) < () , _ > ij Id < <> , x > = refl ij (F₁ + F₂) < lx@(inl x) , y > = subst (\ ∙ -> (inl <×> id) ∙ == < lx , y >) (ij F₁ < x , y >) refl ij (F₁ + F₂) < rx@(inr x) , y > = subst (\ ∙ -> (inr <×> id) ∙ == < rx , y >) (ij F₂ < x , y >) refl ij (F₁ × F₂) < xy@(inl < x , y >) , z > = subst (\ ∙ -> (inl ∘ <∙, y > <×> id) ∙ == < xy , z >) (ij F₁ < x , z >) refl ij (F₁ × F₂) < xy@(inr < x , y >) , z > = subst (\ ∙ -> (inr ∘ < x ,∙> <×> id) ∙ == < xy , z >) (ij F₂ < y , z >) refl ji : (F : U)(y : _) -> j F (i F y) == y ji (K A) () ji Id x = refl ji (F₁ + F₂) (inl c) = chain> j (F₁ + F₂) ((inl <×> id) (i F₁ c)) === inl (j F₁ _) by cong (j (F₁ + F₂) ∘ (inl <×> id)) (η-[×] (i F₁ c)) === inl (j F₁ (i F₁ c)) by cong (inl ∘ j F₁) (sym $ η-[×] (i F₁ c)) === inl c by cong inl (ji F₁ c) ji (F₁ + F₂) rc @ (inr c) = subst (\ ∙ -> j (F₁ + F₂) ((inr <×> id) ∙) == rc) (η-[×] (i F₂ c)) $ subst (\ ∙ -> inr (j F₂ ∙) == rc) (sym $ η-[×] (i F₂ c)) $ subst (\ ∙ -> inr ∙ == rc) (ji F₂ c) refl ji (F₁ × F₂) l @ (inl < c , f₂ >) = subst (\ ∙ -> j (F₁ × F₂) ((inl ∘ <∙, f₂ > <×> id) ∙) == l) (η-[×] (i F₁ c)) $ subst (\ ∙ -> inl < j F₁ ∙ , f₂ > == l) (sym $ η-[×] (i F₁ c)) $ subst (\ ∙ -> inl < ∙ , f₂ > == l) (ji F₁ c) refl ji (F₁ × F₂) r @ (inr < f₁ , c >) = subst (\ ∙ -> j (F₁ × F₂) ((inr ∘ < f₁ ,∙> <×> id) ∙) == r) (η-[×] (i F₂ c)) $ subst (\ ∙ -> inr < f₁ , j F₂ ∙ > == r) (sym $ η-[×] (i F₂ c)) $ subst (\ ∙ -> inr < f₁ , ∙ > == r) (ji F₂ c) refl
{ "alphanum_fraction": 0.3512557481, "avg_line_length": 38.2027027027, "ext": "agda", "hexsha": "de5d14e873be49218ac7cc8246f0d41733302a0b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/clowns/ChainRule.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/clowns/ChainRule.agda", "max_line_length": 78, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/outdated-and-incorrect/clowns/ChainRule.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 1407, "size": 2827 }
module Data.List.Relation where import Lvl import Data open import Data.List open import Logic open import Logic.Propositional open import Structure.Setoid open import Type private variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level private variable T : Type{ℓ} data Empty {ℓ}{T : Type{ℓ}} : List(T) → Stmt{Lvl.𝐒(ℓ)} where intro : Empty(∅) -- Statement of whether a list is contained in the beginning of another list _isPrefixOf_ : ⦃ equiv : Equiv{ℓₑ}(T) ⦄ → List(T) → List(T) → Stmt{Lvl.of(T) Lvl.⊔ ℓₑ} ∅ isPrefixOf _ = Data.Unit (p ⊰ prefix) isPrefixOf ∅ = Data.Empty (p ⊰ prefix) isPrefixOf (x ⊰ l) = (p ≡ x) ∧ (prefix isPrefixOf l) -- _isPrefixOf_ prefix l = (∃ \rest → l ≡ (prefix ++ rest)) -- Statement of whether a list is contained in the end of another list _isSuffixOf_ : ⦃ equiv : Equiv{ℓₑ₁}(T) ⦄ → ⦃ equiv-list : Equiv{ℓₑ₂}(List(T)) ⦄ → List(T) → List(T) → Stmt{Lvl.of(T) Lvl.⊔ ℓₑ₁ Lvl.⊔ ℓₑ₂} ∅ isSuffixOf _ = Data.Unit (p ⊰ prefix) isSuffixOf ∅ = Data.Empty (p ⊰ prefix) isSuffixOf (x ⊰ l) = ((p ⊰ prefix) isSuffixOf l) ∨ ((p ⊰ prefix) ≡ (x ⊰ l)) -- _isSuffixOf_ suffix l = (∃ \rest → l ≡ (rest ++ suffix))
{ "alphanum_fraction": 0.6283261803, "avg_line_length": 38.8333333333, "ext": "agda", "hexsha": "70e9bd55f345f5da1107e9db579fcccf5ec04f68", "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": "Data/List/Relation.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": "Data/List/Relation.agda", "max_line_length": 137, "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": "Data/List/Relation.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": 448, "size": 1165 }
-- An example of something where normalization is surprisingly slow {-# OPTIONS --cubical --safe #-} module Cubical.Experiments.Problem where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Data.Int open import Cubical.HITs.S1 open import Cubical.HITs.S2 open import Cubical.HITs.S3 open import Cubical.HITs.Join open import Cubical.HITs.Hopf ptType : Type _ ptType = Σ Type₀ \ A → A pt : (A : ptType) → A .fst pt A = A .snd S¹pt : ptType S¹pt = (S¹ , base) S²pt : ptType S²pt = (S² , base) S³pt : ptType S³pt = (S³ , base) joinpt : ptType joinpt = (join S¹ S¹ , inl base) Ω : (A : ptType) → ptType Ω A = Path _ (pt A) (pt A) , refl Ω² : (A : ptType) → ptType Ω² A = Ω (Ω A) Ω³ : (A : ptType) → ptType Ω³ A = Ω² (Ω A) α : join S¹ S¹ → S² α (inl _) = base α (inr _) = base α (push x y i) = (merid y ∙ merid x) i where merid : S¹ → Path S² base base merid base = refl merid (loop i) = λ j → surf i j -- The tests test0To2 : Ω³ S³pt .fst test0To2 i j k = surf i j k f3 : Ω³ S³pt .fst → Ω³ joinpt .fst f3 p i j k = S³→joinS¹S¹ (p i j k) test0To3 : Ω³ joinpt .fst test0To3 = f3 test0To2 f4 : Ω³ joinpt .fst → Ω³ S²pt .fst f4 p i j k = α (p i j k) test0To4 : Ω³ S²pt .fst test0To4 = f4 test0To3 innerpath : ∀ i j → HopfS² (test0To4 i j i1) innerpath i j = transp (λ k → HopfS² (test0To4 i j k)) i0 base -- C-c C-n problem uses a lot of memory problem : pos 0 ≡ pos 0 problem i = transp (λ j → helix (innerpath i j)) i0 (pos 0) -- Lots of tests: (thanks Evan!) winding2 : Path (Path S² base base) refl refl → Int winding2 p = winding (λ j → transp (λ i → HopfS² (p i j)) i0 base) test0 : Int test0 = winding2 (λ i j → surf i j) test1 : Int test1 = winding2 (λ i j → surf j i) test2 : Int test2 = winding2 (λ i j → hcomp (λ _ → λ { (i = i0) → base ; (i = i1) → base ; (j = i0) → base ; (j = i1) → base}) (surf i j)) test3 : Int test3 = winding2 (λ i j → hcomp (λ k → λ { (i = i0) → surf j k ; (i = i1) → base ; (j = i0) → base ; (j = i1) → base}) base) test4 : Int test4 = winding2 (λ i j → hcomp (λ k → λ { (i = i0) → surf j k ; (i = i1) → base ; (j = i0) → base ; (j = i1) → base}) base) test5 : Int test5 = winding2 (λ i j → hcomp (λ k → λ { (i = i0) → base ; (i = i1) → base ; (j = i0) → surf k i ; (j = i1) → base}) base) test6 : Int test6 = winding2 (λ i j → hcomp (λ k → λ { (i = i0) → base ; (i = i1) → base ; (j = i0) → base ; (j = i1) → surf k i}) base) test7 : Int test7 = winding2 (λ i j → hcomp (λ k → λ { (i = i0) → base ; (i = i1) → surf j k ; (j = i0) → base ; (j = i1) → base}) (surf i j)) test8 : Int test8 = winding2 (λ i j → hcomp (λ k → λ { (i = i0) → base ; (i = i1) → base ; (j = i0) → surf k i ; (j = i1) → base}) (surf i j)) test9 : Int test9 = winding2 (λ i j → hcomp (λ k → λ { (i = i0) → base ; (i = i1) → base ; (j = i0) → base ; (j = i1) → surf k i}) (surf i j)) test10 : Int test10 = winding2 (λ i j → hcomp (λ k → λ { (i = i0) → surf j k ; (i = i1) → base ; (j = i0) → base ; (j = i1) → base}) (surf i j)) -- Tests using HopfS²' winding2' : Path (Path S² base base) refl refl → Int winding2' p = winding (λ j → transp (λ i → HopfS²' (p i j)) i0 base) test0' : Int test0' = winding2' (λ i j → surf i j) test1' : Int test1' = winding2' (λ i j → surf j i) test2' : Int test2' = winding2' (λ i j → hcomp (λ _ → λ { (i = i0) → base ; (i = i1) → base ; (j = i0) → base ; (j = i1) → base}) (surf i j)) test3' : Int test3' = winding2' (λ i j → hcomp (λ k → λ { (i = i0) → surf j k ; (i = i1) → base ; (j = i0) → base ; (j = i1) → base}) base) test4' : Int test4' = winding2' (λ i j → hcomp (λ k → λ { (i = i0) → surf j k ; (i = i1) → base ; (j = i0) → base ; (j = i1) → base}) base) test5' : Int test5' = winding2' (λ i j → hcomp (λ k → λ { (i = i0) → base ; (i = i1) → base ; (j = i0) → surf k i ; (j = i1) → base}) base) test6' : Int test6' = winding2' (λ i j → hcomp (λ k → λ { (i = i0) → base ; (i = i1) → base ; (j = i0) → base ; (j = i1) → surf k i}) base) test7' : Int test7' = winding2' (λ i j → hcomp (λ k → λ { (i = i0) → base ; (i = i1) → surf j k ; (j = i0) → base ; (j = i1) → base}) (surf i j)) test8' : Int test8' = winding2' (λ i j → hcomp (λ k → λ { (i = i0) → base ; (i = i1) → base ; (j = i0) → surf k i ; (j = i1) → base}) (surf i j)) test9' : Int test9' = winding2' (λ i j → hcomp (λ k → λ { (i = i0) → base ; (i = i1) → base ; (j = i0) → base ; (j = i1) → surf k i}) (surf i j)) test10' : Int test10' = winding2' (λ i j → hcomp (λ k → λ { (i = i0) → surf j k ; (i = i1) → base ; (j = i0) → base ; (j = i1) → base}) (surf i j))
{ "alphanum_fraction": 0.5472854641, "avg_line_length": 30.2516556291, "ext": "agda", "hexsha": "08e4ae8c25825d58aebfe907e254a98fd3ac49ee", "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": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/Experiments/Problem.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "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": "cj-xu/cubical", "max_issues_repo_path": "Cubical/Experiments/Problem.agda", "max_line_length": 133, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/Experiments/Problem.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2016, "size": 4568 }
{-# OPTIONS --without-K #-} open import HoTT.Base open import HoTT.Equivalence module HoTT.Equivalence.Coproduct where open variables private variable A' B' : 𝒰 i +-empty₁ : 𝟎 {i} + B ≃ B +-empty₁ = let open Iso in iso→eqv λ where .f (inl ()) .f (inr b) → b .g → inr .η (inl ()) .η (inr b) → refl .ε _ → refl +-empty₂ : A + 𝟎 {j} ≃ A +-empty₂ = let open Iso in iso→eqv λ where .f (inl a) → a .f (inr ()) .g → inl .η (inl b) → refl .η (inr ()) .ε _ → refl +-comm : A + B ≃ B + A +-comm = let open Iso in iso→eqv λ where .f (inl a) → inr a .f (inr b) → inl b .g (inl b) → inr b .g (inr a) → inl a .η (inl a) → refl .η (inr b) → refl .ε (inl b) → refl .ε (inr a) → refl +-equiv : A ≃ A' → B ≃ B' → A + B ≃ A' + B' +-equiv e₁ e₂ = iso→eqv λ where .f (inl a) → inl (f₁ a) .f (inr b) → inr (f₂ b) .g (inl a') → inl (g₁ a') .g (inr b') → inr (g₂ b') .η (inl a) → ap inl (η₁ a) .η (inr b) → ap inr (η₂ b) .ε (inl a') → ap inl (ε₁ a') .ε (inr b') → ap inr (ε₂ b') where open Iso open Iso (eqv→iso e₁) renaming (f to f₁ ; g to g₁ ; η to η₁ ; ε to ε₁) open Iso (eqv→iso e₂) renaming (f to f₂ ; g to g₂ ; η to η₂ ; ε to ε₂)
{ "alphanum_fraction": 0.4926948052, "avg_line_length": 22.8148148148, "ext": "agda", "hexsha": "ba912e967f227f48893547f5ae0160d08cb08048", "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": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_path": "HoTT/Equivalence/Coproduct.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_path": "HoTT/Equivalence/Coproduct.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_path": "HoTT/Equivalence/Coproduct.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 589, "size": 1232 }
module Datoid where import Equiv import Prelude open Equiv open Prelude data Datoid : Set1 where datoid : (a : Set) -> DecidableEquiv a -> Datoid El : Datoid -> Set El (datoid a _) = a datoidEq : (a : Datoid) -> DecidableEquiv (El a) datoidEq (datoid _ eq) = eq datoidRel : (a : Datoid) -> El a -> El a -> Set datoidRel d = rel' (datoidEq d) datoidDecRel : (a : Datoid) -> (x y : El a) -> Either (datoidRel a x y) (Not (datoidRel a x y)) datoidDecRel d = decRel (datoidEq d) dRefl : (a : Datoid) -> {x : El a} -> datoidRel a x x dRefl a = refl (datoidEq a) dSym : (a : Datoid) -> {x y : El a} -> datoidRel a x y -> datoidRel a y x dSym a = sym (datoidEq a) dTrans : (a : Datoid) -> {x y z : El a} -> datoidRel a x y -> datoidRel a y z -> datoidRel a x z dTrans a = trans (datoidEq a) data Respects (a : Datoid) (P : El a -> Set) : Set where respects : ((x y : El a) -> datoidRel a x y -> P x -> P y) -> Respects a P subst : {a : Datoid} -> {P : El a -> Set} -> Respects a P -> (x y : El a) -> datoidRel a x y -> P x -> P y subst (respects f) = f pairDatoid : (a b : Datoid) -> Datoid pairDatoid a b = datoid (Pair (El a) (El b)) (pairEquiv (datoidEq a) (datoidEq b))
{ "alphanum_fraction": 0.5480399693, "avg_line_length": 27.1041666667, "ext": "agda", "hexsha": "cfb8a7044c604cdf556730997eaacbf0deba2a1c", "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": "examples/AIM4/bag/Datoid.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": "examples/AIM4/bag/Datoid.agda", "max_line_length": 78, "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": "examples/AIM4/bag/Datoid.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": 495, "size": 1301 }
open import MLib.Prelude.FromStdlib open import Relation.Binary using (Decidable; IsStrictTotalOrder) module MLib.Prelude.DFS {v p e} {V : Set v} (_⇒_ : V → V → Set e) {_<_ : V → V → Set p} (isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_) where open import MLib.Prelude.Path open Bool using (T) open import Function.Equivalence using (Equivalence) import Data.AVL isStrictTotalOrder as Tree open Tree using (Tree) -- A (directed) graph is a map from vertices to the list of edges out of that -- vertex. Graph = Tree (λ x → List (∃ λ y → x ⇒ y)) private module Seen where -- Represents a set of vertices that have been seen. At most 'n' vertices -- have /not/ been seen. record SeenSet (n : ℕ) : Set (v ⊔ˡ e ⊔ˡ p) where constructor mkSeen field getSeen : Tree (λ _ → ⊤) isSeen : ∀ {n} → V → SeenSet n → Bool isSeen x (mkSeen t) = x Tree.∈? t -- Mark a vertex as seen, thus reducing the number of /unseen/ vertices. mark : ∀ {n} → V → SeenSet (Nat.suc n) → Maybe (SeenSet n) mark x u@(mkSeen t) = if Bool.not (isSeen x u) then just (mkSeen (Tree.insert x tt t)) else nothing -- Make a seen set for a particular graph. The number of unseen vertices in -- the result is bounded above by the number of vertices in the graph. forGraph : Graph → ∃ SeenSet forGraph gr = (countVertices gr , mkSeen Tree.empty) where -- this overcounts but that doesn't matter because the index is only there -- to ensure termination of the DFS countVertices : Graph → ℕ countVertices = List.foldr (λ { (_ , es) n → List.foldr (λ _ → Nat.suc) n es }) 0 ∘ Tree.toList inj : ∀ {n} → SeenSet n → SeenSet (Nat.suc n) inj (mkSeen t) = mkSeen t open Seen using (SeenSet) private infixl 1 _>>=ₛ_ MonadDfs : ∀ {a} → ℕ → Set a → Set (v ⊔ˡ (p ⊔ˡ (e ⊔ˡ a))) MonadDfs n A = SeenSet n → A × SeenSet n runMonadDfs : ∀ {n a} {A : Set a} → MonadDfs n A → SeenSet n → A runMonadDfs f = proj₁ ∘ f _>>=ₛ_ : ∀ {n a b} {A : Set a} {B : Set b} → MonadDfs n A → (A → MonadDfs n B) → MonadDfs n B (f >>=ₛ g) s = let x , s′ = f s in g x s′ returnₛ : ∀ {n a} {A : Set a} → A → MonadDfs n A returnₛ x s = x , s withMarked : ∀ {n a} {A : Set a} V → MonadDfs n A → MonadDfs (Nat.suc n) (Maybe A) withMarked v f s = case Seen.mark v s of λ { (just s′) → let x , s′′ = f s′ in just x , Seen.inj s′′ ; nothing → nothing , s } module _ (graph : Graph) where private PathsFrom = List ∘ ∃ ∘ Path _⇒_ -- Calculates paths from the given source to every reachable target not in -- the seen set. Returns the new seen set, the list of paths found, and -- a boolean indicating whether this source was previously in the seen -- set. pathsFromSource : ∀ {n} (source : V) → MonadDfs n (Maybe (PathsFrom source)) -- Calculates paths from the given source to every reachable target not in -- the seen set, whose first edge is among the list given. pathsViaEdges : ∀ {n} {source : V} → List (∃ (λ dest → source ⇒ dest)) → MonadDfs n (PathsFrom source) -- Calculates paths via the edge given to every reachable target not in the -- seen set. pathsViaEdge : ∀ {n} {source dest : V} → source ⇒ dest → MonadDfs n (PathsFrom source) -- The base case of induction on the size of the seen set. This is only here -- to satisfy the termination checker. pathsFromSource {Nat.zero} source = returnₛ nothing pathsFromSource {Nat.suc _} source = withMarked source ( case Tree.lookup source graph of λ -- We have a list of edges from this source to some other vertex. For -- each of these, a recursive call will only return paths from that -- vertex if it is yet unseen. Note the recursive call is on a seen set -- with an index one lower, satisfying Agda's termination checker. { (just es) → pathsViaEdges es >>=ₛ returnₛ ∘ just -- there are no edges from this source so nothing is reachable from it ; nothing → returnₛ (just []) }) >>=ₛ maybe returnₛ (returnₛ nothing) pathsViaEdges [] = returnₛ [] pathsViaEdges ((d , e) ∷ es) = pathsViaEdge e >>=ₛ λ pathsVia-d → pathsViaEdges es >>=ₛ λ restPaths → returnₛ (pathsVia-d List.++ restPaths) pathsViaEdge {dest = d} e = pathsFromSource d >>=ₛ λ { (just pathsFrom-d) → let pathsVia-d = List.map (λ {(d′ , p) → d′ , connect (edge e) p}) pathsFrom-d in returnₛ ((_ , edge e) ∷ pathsVia-d) ; nothing → returnₛ [] } -- Given a source vertex S, finds all vertices T such that there is a path -- from S to T, and returns the path. No target vertex is returned more than -- once. allTargetsFrom : (source : V) → List (∃ (Path _⇒_ source)) allTargetsFrom source = let _ , seen = Seen.forGraph graph in maybe id [] (runMonadDfs (pathsFromSource source) seen) module _ (graph : Graph) (matches : V → Bool) where private findMatchingFrom : ∀ {n} (source : V) → MonadDfs n (Maybe (∃ λ dest → Path _⇒_ source dest × T (matches dest))) findMatchingViaEdges : ∀ {n} {source : V} → List (∃ (λ inter → source ⇒ inter)) → MonadDfs n (Maybe (∃ λ dest → Path _⇒_ source dest × T (matches dest))) findMatchingViaEdge : ∀ {n} {source inter : V} → source ⇒ inter → MonadDfs n (Maybe (∃ λ dest → Path _⇒_ source dest × T (matches dest))) -- The base case of induction on the size of the seen set. This is only here -- to satisfy the termination checker. findMatchingFrom {Nat.zero} source = returnₛ nothing findMatchingFrom {Nat.suc _} source = withMarked source ( case Tree.lookup source graph of λ -- We have a list of edges from this source to some other vertex. For -- each of these, a recursive call will only return paths from that -- vertex if it is yet unseen. Note the recursive call is on a seen set -- with an index one lower, satisfying Agda's termination checker. { (just es) → findMatchingViaEdges es -- there are no edges from this source so nothing is reachable from it ; nothing → returnₛ nothing }) >>=ₛ maybe returnₛ (returnₛ nothing) findMatchingViaEdges [] = returnₛ nothing findMatchingViaEdges ((d , e) ∷ es) = findMatchingViaEdge e >>=ₛ λ { (just r) → returnₛ (just r) ; nothing → findMatchingViaEdges es } findMatchingViaEdge {inter = d} e with matches d | ≡.inspect matches d findMatchingViaEdge {inter = _} e | true | ≡.[ eq ] = returnₛ (just (_ , edge e , Equivalence.from Bool.T-≡ ⟨$⟩ eq)) findMatchingViaEdge {inter = d} e | false | _ = findMatchingFrom d >>=ₛ λ { (just (_ , p , q)) → returnₛ (just (_ , connect (edge e) p , q)) ; nothing → returnₛ nothing } -- Given a source vertex S, finds all vertices T such that there is a path -- from S to T, and returns the path. No target vertex is returned more than -- once. findMatching : (source : V) → Maybe (∃ λ dest → Path _⇒_ source dest × T (matches dest)) findMatching source = let _ , seen = Seen.forGraph graph in runMonadDfs (findMatchingFrom source) seen module _ (graph : Graph) {dest} (isDest : ∀ v → Dec (v ≡ dest)) where -- Given a source vertex S, finds all vertices T such that there is a path -- from S to T, and returns the path. No target vertex is returned more than -- once. findDest : (source : V) → Maybe (Path _⇒_ source dest) findDest source with findMatching graph (⌊_⌋ ∘ isDest) source ... | just (dest′ , p , q) with isDest dest′ ... | yes ≡.refl = just p findDest source | just (_ , _ , ()) | no _ findDest source | nothing = nothing
{ "alphanum_fraction": 0.63443519, "avg_line_length": 40.4421052632, "ext": "agda", "hexsha": "fcff168286f395ee78aa62829ca544c16b2d6a73", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bch29/agda-matrices", "max_forks_repo_path": "src/MLib/DFS.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bch29/agda-matrices", "max_issues_repo_path": "src/MLib/DFS.agda", "max_line_length": 157, "max_stars_count": null, "max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bch29/agda-matrices", "max_stars_repo_path": "src/MLib/DFS.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2344, "size": 7684 }
open import Oscar.Prelude open import Oscar.Class.[ExtensibleType] open import Oscar.Data.Proposequality module Oscar.Class.[ExtensibleType].Proposequality where instance [ExtensibleType]Proposequality : ∀ {a} {b} {A : Set a} {B : A → Set b} → [ExtensibleType] (λ {w} → Proposequality⟦ B w ⟧) [ExtensibleType]Proposequality = ∁
{ "alphanum_fraction": 0.7351190476, "avg_line_length": 28, "ext": "agda", "hexsha": "28358fcda475632255be011e1f25284a21271ee1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/[ExtensibleType]/Proposequality.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/[ExtensibleType]/Proposequality.agda", "max_line_length": 123, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/[ExtensibleType]/Proposequality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 105, "size": 336 }
{-# OPTIONS --cubical --safe #-} module TreeFold where open import Prelude open import Data.List open import Algebra using (Associative) open import Data.List.Properties using (foldr-fusion; foldl-fusion; foldl′-foldl) infixr 5 _^_&_ data Spine (A : Type a) : Type a where &0 : Spine A _^_&_ : A → ℕ → Spine A → Spine A private variable n : ℕ module Cons (f : A → A → A) where infixr 5 _^_∹_ _^_∹_ : A → ℕ → Spine A → Spine A x ^ n ∹ &0 = x ^ n & &0 x ^ n ∹ y ^ zero & xs = f x y ^ suc n ∹ xs x ^ n ∹ y ^ suc m & xs = x ^ n & y ^ m & xs _∹_ : A → Spine A → Spine A _∹_ = _^ zero ∹_ module TreeFoldR (f : A → A → A) (z : A) where open Cons f public fold : Spine A → A fold &0 = z fold (x ^ n & xs) = f x (fold xs) spine : List A → Spine A spine = foldr _∹_ &0 treeFold : List A → A treeFold = fold ∘ spine ∹-hom : Associative f → ∀ x xs → fold (x ^ n ∹ xs) ≡ f x (fold xs) ∹-hom p x &0 = refl ∹-hom p x (y ^ zero & xs) = ∹-hom p (f x y) xs ; p x y (fold xs) ∹-hom p x (y ^ suc n & xs) = refl treeFoldHom : Associative f → ∀ xs → treeFold xs ≡ foldr f z xs treeFoldHom f-assoc = foldr-fusion fold &0 (∹-hom f-assoc) module TreeFold1 (f : A → A → A) where open import Data.Maybe open import Data.Maybe.Properties open import Data.List.Properties f? : Maybe A → Maybe A → Maybe A f? nothing = id f? (just x) = just ∘ maybe x (f x) open TreeFoldR f? nothing treeFoldMay : List A → Maybe A treeFoldMay = treeFold ∘ map just treeFoldMayHom : Associative f → ∀ xs → treeFoldMay xs ≡ foldrMay f xs treeFoldMayHom f-assoc xs = treeFoldHom f?-assoc (map just xs) ; map-fusion f? nothing just xs where f?-assoc : Associative f? f?-assoc nothing y z = refl f?-assoc (just x) nothing z = refl f?-assoc (just x) (just y) nothing = refl f?-assoc (just x) (just y) (just z) = cong just (f-assoc x y z) isJustSpine? : Spine (Maybe A) → Bool isJustSpine? &0 = false isJustSpine? (x ^ y & xs) = is-just x IsJustSpine : Spine (Maybe A) → Type IsJustSpine = T ∘ isJustSpine? isJust-cons : ∀ x n xs → IsJustSpine (just x ^ n ∹ xs) isJust-cons x n &0 = tt isJust-cons x n (y ^ zero & xs) = isJust-cons (maybe x (f x) y) (suc n) xs isJust-cons x n (y ^ suc m & xs) = tt isJust-spine : ∀ xs → NonEmpty xs → IsJustSpine (spine (map just xs)) isJust-spine (x ∷ xs) p = isJust-cons x 0 (spine (map just xs)) isJust-fold : ∀ xs → IsJustSpine xs → IsJust (fold xs) isJust-fold (just _ ^ _ & _) _ = tt isJust-treeFoldMay : ∀ xs → NonEmpty xs → IsJust (treeFoldMay xs) isJust-treeFoldMay xs xsne = isJust-fold (spine (map just xs)) (isJust-spine xs xsne) treeFold1 : (xs : List A) → ⦃ NonEmpty xs ⦄ → A treeFold1 xs ⦃ xsne ⦄ = fromJust (treeFoldMay xs) where instance _ = isJust-treeFoldMay xs xsne -- treeFold1-hom : Associative f → ∀ xs → ⦃ xsne : NonEmpty xs ⦄ → treeFold1 xs ≡ foldr1 f xs -- treeFold1-hom f-assoc xs ⦃ xsne ⦄ = {!!} open TreeFold1 using (treeFoldMay; treeFoldMayHom; treeFold1) public open TreeFoldR using (treeFold; treeFoldHom) public module TreeFoldL (f : A → A → A) (z : A) where open TreeFoldR (flip f) z using (_∹_; fold; ∹-hom) public spine : List A → Spine A spine = foldl (flip _∹_) &0 treeFoldL : List A → A treeFoldL = fold ∘ spine treeFoldLHom : Associative f → ∀ xs → treeFoldL xs ≡ foldl f z xs treeFoldLHom p = foldl-fusion fold &0 (flip (∹-hom λ x y z → sym (p z y x))) open TreeFoldL using (treeFoldL; treeFoldLHom) public module StrictCons (f : A → A → A) where infixr 5 _^_∹_ _^_∹_ : A → ℕ → Spine A → Spine A x ^ n ∹ &0 = x ^ n & &0 x ^ n ∹ y ^ zero & xs = (_^ suc n ∹ xs) $! (f x y) x ^ n ∹ y ^ suc m & xs = x ^ n & y ^ m & xs _∹_ : A → Spine A → Spine A _∹_ = _^ zero ∹_ private module Lazy = Cons f strict-lazy-cons : ∀ x n xs → x ^ n ∹ xs ≡ x Lazy.^ n ∹ xs strict-lazy-cons x n &0 = refl strict-lazy-cons x n (y ^ zero & xs) = $!-≡ (_^ suc n ∹ xs) (f x y) ; strict-lazy-cons (f x y) (suc n) xs strict-lazy-cons x n (y ^ suc m & xs) = refl module TreeFoldL′ (f : A → A → A) (z : A) where open StrictCons (flip f) spine : List A → Spine A spine = foldl′ (flip _∹_) &0 private module Lazy = TreeFoldL f z open Lazy using (fold) treeFoldL′ : List A → A treeFoldL′ = fold ∘ spine treeFoldL′Hom : Associative f → ∀ xs → treeFoldL′ xs ≡ foldl f z xs treeFoldL′Hom p xs = cong fold (foldl′-foldl (flip _∹_) &0 xs ; cong (λ c → foldl c &0 xs) (funExt λ ys → funExt λ y → strict-lazy-cons y 0 ys)) ; Lazy.treeFoldLHom p xs open TreeFoldL′ using (treeFoldL′; treeFoldL′Hom) public
{ "alphanum_fraction": 0.6047063903, "avg_line_length": 30.4736842105, "ext": "agda", "hexsha": "262193d7973291e82e6954a8c08ba0e446fa9c07", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "TreeFold.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "TreeFold.agda", "max_line_length": 129, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "TreeFold.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 1822, "size": 4632 }
------------------------------------------------------------------------------ -- Testing the translation of definitions ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Definition05 where postulate D : Set _≡_ : D → D → Set op : D → D a : D b : D b = a {-# ATP definition b #-} c : D c = op b {-# ATP definition c #-} -- We test the use of an ATP definition inside other ATP definition. postulate foo : c ≡ op a {-# ATP prove foo #-}
{ "alphanum_fraction": 0.4238310709, "avg_line_length": 22.8620689655, "ext": "agda", "hexsha": "a9b7d408047ba4b0b9fab3c98fa64714a6474c6d", "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/Definition05.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/Definition05.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/Definition05.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": 139, "size": 663 }
module Bound.Lower (A : Set) where data Bound : Set where bot : Bound val : A → Bound
{ "alphanum_fraction": 0.6276595745, "avg_line_length": 11.75, "ext": "agda", "hexsha": "cce11d51e44574d9520aa950ce97ddc2772ab583", "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/Bound/Lower.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/Bound/Lower.agda", "max_line_length": 34, "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/Bound/Lower.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 29, "size": 94 }
-- 2014-05-16 Andreas: Question mark not recognized by emacs module _ where data Nat : Set where suc : Nat → Nat data Fin : Nat → Set where zero : ∀ n → Fin (suc n) test : ∀ n → Fin n → Set test .? (zero n) = Nat -- The questionmark in the dot pattern is not recognized by emacs-mode. -- This cannot be tested by test/interaction, but I still put the test case here.
{ "alphanum_fraction": 0.6763925729, "avg_line_length": 22.1764705882, "ext": "agda", "hexsha": "c8d1c92087ff9895ce0269833a7ce994a798005f", "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/Issue1132.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/Issue1132.agda", "max_line_length": 81, "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/Issue1132.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": 108, "size": 377 }
module BHeap.Order {A : Set}(_≤_ : A → A → Set) where open import BHeap _≤_ open import Bound.Lower A open import Bound.Lower.Order _≤_ open import Data.Nat _≺_ : {b b' : Bound} → BHeap b → BHeap b' → Set h ≺ h' = # h <′ # h' data Acc {b' : Bound}(h' : BHeap b') : Set where acc : (∀ {b} h → (_≺_ {b} {b'} h h') → Acc h) → Acc h'
{ "alphanum_fraction": 0.5608308605, "avg_line_length": 24.0714285714, "ext": "agda", "hexsha": "1028a561a94590a76c4c79c6a7b0aa39848b5d21", "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/BHeap/Order.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/BHeap/Order.agda", "max_line_length": 56, "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/BHeap/Order.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": 140, "size": 337 }
open import Data.Boolean open import Type module Data.BinaryTree.Heap {ℓ} {T : Type{ℓ}} (_≤?_ : T → T → Bool) where import Lvl open import Data hiding (empty) open import Data.BinaryTree BinaryHeap = BinaryTree (Unit{Lvl.𝟎}) (T) private variable ℓᵣ : Lvl.Level private variable R : Type{ℓᵣ} open import Data.Option open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Functional as Fn using (_∘_ ; _∘₂_ ; _$_) merge : BinaryHeap → BinaryHeap → BinaryHeap merge (Leaf <>) (Leaf <>) = Leaf <> merge x@(Node _ _ _) (Leaf <>) = x merge (Leaf <>) y@(Node _ _ _) = y merge x@(Node xa xl xr) y@(Node ya yl yr) with (xa ≤? ya) | (\_ → merge y xr) | (\_ → merge x yr) ... | 𝑇 | 𝑇-branch | _ = Node xa (𝑇-branch(<>{Lvl.𝟎})) xl ... | 𝐹 | _ | 𝐹-branch = Node ya (𝐹-branch(<>{Lvl.𝟎})) yl insert : T → BinaryHeap → BinaryHeap insert a = merge(singleton a) pop : BinaryHeap → Option(T ⨯ BinaryHeap) pop (Leaf <>) = None pop (Node a l r) = Some(a , merge l r) {-# TERMINATING #-} foldOrdered : (T → R → R) → R → BinaryHeap → R foldOrdered(_▫_) id (Leaf <>) = id foldOrdered(_▫_) id (Node a l r) = a ▫ foldOrdered(_▫_) id (merge l r) filterFold : (T → R → Option(R)) → R → BinaryHeap → (R ⨯ BinaryHeap) filterFold (_▫_) r₀ (Leaf <>) = (r₀ , Leaf <>) filterFold (_▫_) r₀ (Node a l r) with (r₁ , il) ← filterFold (_▫_) r₀ l with (r₂ , ir) ← filterFold (_▫_) r₁ r with (a ▫ r₂) ... | Some r₃ = (r₃ , merge il ir) ... | None = (r₂ , Node a il ir) filter : (T → Bool) → BinaryHeap → BinaryHeap filter f = Tuple.right ∘ filterFold (\{a <> → (\{𝐹 → None ; 𝑇 → Some <>}) $ f(a)}) (<>{Lvl.𝟎}) open import Data.List import Data.List.Functions as List separate : (T → Bool) → BinaryHeap → (List(T) ⨯ BinaryHeap) separate f = filterFold (\a l → (\{𝐹 → None ; 𝑇 → Some(a ⊰ l)}) $ f(a)) ∅ update : (T → Bool) → (T → T) → BinaryHeap → BinaryHeap update p f a with (as , b) ← separate p a = List.foldᵣ insert b (List.map f as)
{ "alphanum_fraction": 0.5911854103, "avg_line_length": 33.4576271186, "ext": "agda", "hexsha": "d74df8ce415bd463cfd67a3a808475bbaee16621", "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": "Data/BinaryTree/Heap.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": "Data/BinaryTree/Heap.agda", "max_line_length": 97, "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": "Data/BinaryTree/Heap.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": 736, "size": 1974 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- Thm: (∃x)A(x), (∀x)(A(x) ⇒ B(x)) ⊢ (∃x)B(x) -- From: Elliott Mendelson. Introduction to mathematical logic. Chapman & -- Hall, 4th edition, 1997, p. 155. -- Rule A4: (∀x)A(x) ⇒ A(t) (with some conditions) -- Rule E4: A(t) ⇒ (∃x)A(x) (with some conditions) -- Rule C: From (∃x)A(x) to A(t) (with some conditions) -- 1. (∃x)A(x) Hyp -- 2. (∀x)(A(x) ⇒ B(x)) Hyp -- 3. A(b) 1, rule C -- 4. A(b) ⇒ B(b) 2, rule A4 -- 5. B(b) 4,3 MP -- 6. (∃x)B(x) 5, rule E4 module FOT.Common.FOL.Existential.Witness where postulate D : Set A B : D → Set module Witness where infixr 7 _,_ data ∃ (A : D → Set) : Set where _,_ : ∀ x → A x → ∃ A ∃-elim : {A : D → Set}{B : Set} → ∃ A → (∀ x → A x → B) → B ∃-elim (x , Ax) h = h x Ax -- A proof using the existential elimination. prf₁ : ∃ A → (∀ {x} → A x → B x) → ∃ B prf₁ h₁ h₂ = ∃-elim h₁ (λ x Ax → x , (h₂ Ax)) -- A proof using pattern matching. prf₂ : ∃ A → (∀ {x} → A x → B x) → ∃ B prf₂ (x , Ax) h = x , h Ax module NonWitness₁ where data ∃ (A : D → Set) : Set where ∃-intro : ∀ {x} → A x → ∃ A ∃-elim : {A : D → Set}{B : Set} → ∃ A → (∀ {x} → A x → B) → B ∃-elim (∃-intro Ax) h = h Ax -- A proof using the existential elimination. prf₁ : ∃ A → (∀ {x} → A x → B x) → ∃ B prf₁ h₁ h₂ = ∃-elim h₁ (λ Ax → ∃-intro (h₂ Ax)) -- A proof using pattern matching. prf₂ : ∃ A → (∀ {x} → A x → B x) → ∃ B prf₂ (∃-intro Ax) h = ∃-intro (h Ax) module NonWitness₂ where -- We add 3 to the fixities of the Agda standard library 0.8.1 (see -- Relation/Nullary/Core.agda). infix 6 ¬_ -- The empty type. data ⊥ : Set where ⊥-elim : {A : Set} → ⊥ → A ⊥-elim () ¬_ : Set → Set ¬ A = A → ⊥ ∃ : (D → Set) → Set ∃ A = ¬ (∀ x → ¬ (A x)) prf : ∃ A → (∀ x → A x → B x) → ∃ B prf h₁ h₂ h₃ = h₁ (λ x Ax → h₃ x (h₂ x Ax))
{ "alphanum_fraction": 0.4797659678, "avg_line_length": 25.012195122, "ext": "agda", "hexsha": "be10016b3d14858f640d69e218528028b2ce00c8", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/Common/FOL/Existential/Witness.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/Common/FOL/Existential/Witness.agda", "max_line_length": 73, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/Common/FOL/Existential/Witness.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": 873, "size": 2051 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Monoidal open import Categories.Functor.Monoidal module Categories.NaturalTransformation.NaturalIsomorphism.Monoidal where open import Level open import Data.Product using (_,_) open import Relation.Binary using (IsEquivalence; Setoid) open import Categories.Category.Product import Categories.Category.Monoidal.Reasoning as MonoidalReasoning import Categories.Category.Monoidal.Utilities as MonoidalUtilities open import Categories.Functor hiding (id) open import Categories.Functor.Monoidal.Properties using () renaming ( idF-Monoidal to idFˡ ; idF-StrongMonoidal to idFˢ ; ∘-Monoidal to _∘Fˡ_ ; ∘-StrongMonoidal to _∘Fˢ_ ) import Categories.Morphism.Reasoning as MorphismReasoning import Categories.NaturalTransformation.Monoidal as NT open import Categories.NaturalTransformation.NaturalIsomorphism as NI using (NaturalIsomorphism) open NaturalIsomorphism using (F⇒G; F⇐G) -- Monoidal natural isomorphisms between lax monoidal functors. module Lax where open NT.Lax hiding (id) module _ {o ℓ e o′ ℓ′ e′} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} (F G : MonoidalFunctor C D) where private module C = MonoidalCategory C module D = MonoidalCategory D module F = MonoidalFunctor F renaming (F to U) module G = MonoidalFunctor G renaming (F to U) IsMonoidalNaturalIsomorphism : NaturalIsomorphism F.U G.U → Set (o ⊔ ℓ′ ⊔ e′) IsMonoidalNaturalIsomorphism α = IsMonoidalNaturalTransformation F G (F⇒G α) record MonoidalNaturalIsomorphism : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where field U : NaturalIsomorphism F.U G.U F⇒G-isMonoidal : IsMonoidalNaturalIsomorphism U open NaturalIsomorphism U public open IsMonoidalNaturalTransformation F⇒G-isMonoidal public open D using (module Equiv) open MorphismReasoning D.U using (switch-fromtoˡ; conjugate-from) open MonoidalUtilities D.monoidal using (_⊗ᵢ_) F⇐G-isMonoidal : IsMonoidalNaturalTransformation G F (F⇐G U) F⇐G-isMonoidal = record { ε-compat = Equiv.sym (switch-fromtoˡ FX≅GX ε-compat) ; ⊗-homo-compat = conjugate-from (FX≅GX ⊗ᵢ FX≅GX) FX≅GX (Equiv.sym ⊗-homo-compat) } F⇒G-monoidal : MonoidalNaturalTransformation F G F⇒G-monoidal = record { U = F⇒G U ; isMonoidal = F⇒G-isMonoidal } F⇐G-monoidal : MonoidalNaturalTransformation G F F⇐G-monoidal = record { U = F⇐G U ; isMonoidal = F⇐G-isMonoidal } infix 4 _≃_ _≃_ = MonoidalNaturalIsomorphism open MonoidalNaturalTransformation using (isMonoidal) open MonoidalNaturalIsomorphism -- Identity and compositions module _ {o ℓ e o′ ℓ′ e′} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} where infixr 9 _ⓘᵥ_ id : {F : MonoidalFunctor C D} → F ≃ F id = record { U = NI.refl ; F⇒G-isMonoidal = isMonoidal NT.Lax.id } _ⓘᵥ_ : {F G H : MonoidalFunctor C D} → G ≃ H → F ≃ G → F ≃ H _ⓘᵥ_ α β = record { U = U α NI.ⓘᵥ U β ; F⇒G-isMonoidal = isMonoidal (F⇒G-monoidal α ∘ᵥ F⇒G-monoidal β) } isEquivalence : IsEquivalence _≃_ isEquivalence = record { refl = id ; sym = λ α → record { U = NI.sym (U α) ; F⇒G-isMonoidal = F⇐G-isMonoidal α } ; trans = λ α β → β ⓘᵥ α } module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} {E : MonoidalCategory o″ ℓ″ e″} where infixr 9 _ⓘₕ_ _ⓘˡ_ _ⓘʳ_ _ⓘₕ_ : {F G : MonoidalFunctor C D} {H I : MonoidalFunctor D E} → H ≃ I → F ≃ G → (H ∘Fˡ F) ≃ (I ∘Fˡ G) _ⓘₕ_ α β = record { U = U α NI.ⓘₕ U β ; F⇒G-isMonoidal = isMonoidal (F⇒G-monoidal α ∘ₕ F⇒G-monoidal β) } _ⓘˡ_ : {F G : MonoidalFunctor C D} (H : MonoidalFunctor D E) → F ≃ G → (H ∘Fˡ F) ≃ (H ∘Fˡ G) H ⓘˡ α = id {F = H} ⓘₕ α _ⓘʳ_ : {G H : MonoidalFunctor D E} → G ≃ H → (F : MonoidalFunctor C D) → (G ∘Fˡ F) ≃ (H ∘Fˡ F) α ⓘʳ F = α ⓘₕ id {F = F} -- Left and right unitors. module _ {o ℓ e o′ ℓ′ e′} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} {F : MonoidalFunctor C D} where private module C = MonoidalCategory C module D = MonoidalCategory D module F = MonoidalFunctor F open D hiding (U; id; unitorˡ; unitorʳ) open MorphismReasoning D.U using (id-comm-sym) open MonoidalReasoning D.monoidal unitorˡ : idFˡ D ∘Fˡ F ≃ F unitorˡ = record { U = NI.unitorˡ ; F⇒G-isMonoidal = record { ε-compat = identityˡ ○ identityʳ ; ⊗-homo-compat = λ {X Y} → begin D.id D.∘ F.⊗-homo.η (X , Y) D.∘ D.id ≈⟨ identityˡ ⟩ F.⊗-homo.η (X , Y) D.∘ D.id ≈˘⟨ refl⟩∘⟨ ⊗.identity ⟩ F.⊗-homo.η (X , Y) D.∘ D.id ⊗₁ D.id ∎ } } unitorʳ : F ∘Fˡ idFˡ C ≃ F unitorʳ = record { U = NI.unitorʳ ; F⇒G-isMonoidal = record { ε-compat = begin D.id ∘ F.₁ C.id ∘ F.ε ≈⟨ identityˡ ⟩ F.₁ C.id ∘ F.ε ≈⟨ F.identity ⟩∘⟨refl ⟩ D.id ∘ F.ε ≈⟨ identityˡ ⟩ F.ε ∎ ; ⊗-homo-compat = λ {X Y} → begin D.id D.∘ F.₁ C.id ∘ F.⊗-homo.η (X , Y) ≈⟨ identityˡ ⟩ F.₁ C.id ∘ F.⊗-homo.η (X , Y) ≈⟨ F.identity ⟩∘⟨refl ⟩ D.id ∘ F.⊗-homo.η (X , Y) ≈⟨ id-comm-sym ⟩ F.⊗-homo.η (X , Y) D.∘ D.id ≈˘⟨ refl⟩∘⟨ ⊗.identity ⟩ F.⊗-homo.η (X , Y) D.∘ D.id ⊗₁ D.id ∎ } } -- Associator. module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ o‴ ℓ‴ e‴} {B : MonoidalCategory o ℓ e} {C : MonoidalCategory o′ ℓ′ e′} {D : MonoidalCategory o″ ℓ″ e″} {E : MonoidalCategory o‴ ℓ‴ e‴} {F : MonoidalFunctor B C} {G : MonoidalFunctor C D} {H : MonoidalFunctor D E} where private module D = MonoidalCategory D module E = MonoidalCategory E module F = MonoidalFunctor F module G = MonoidalFunctor G module H = MonoidalFunctor H open E hiding (U; id; associator) open MorphismReasoning E.U open MonoidalReasoning E.monoidal associator : (H ∘Fˡ G) ∘Fˡ F ≃ H ∘Fˡ (G ∘Fˡ F) associator = record { U = NI.associator (F.F) (G.F) (H.F) ; F⇒G-isMonoidal = record { ε-compat = begin E.id ∘ H.₁ (G.₁ F.ε) ∘ H.₁ G.ε ∘ H.ε ≈⟨ identityˡ ⟩ H.₁ (G.₁ F.ε) ∘ H.₁ G.ε ∘ H.ε ≈˘⟨ pushˡ H.homomorphism ⟩ H.₁ (G.₁ F.ε D.∘ G.ε) ∘ H.ε ∎ ; ⊗-homo-compat = λ {X Y} → begin E.id ∘ H.₁ (G.₁ (F.⊗-homo.η (X , Y))) ∘ H.₁ (G.⊗-homo.η (F.F₀ X , F.F₀ Y)) ∘ H.⊗-homo.η (G.F₀ (F.F₀ X) , G.F₀ (F.F₀ Y)) ≈⟨ identityˡ ⟩ H.₁ (G.₁ (F.⊗-homo.η (X , Y))) ∘ H.₁ (G.⊗-homo.η (F.F₀ X , F.F₀ Y)) ∘ H.⊗-homo.η (G.F₀ (F.F₀ X) , G.F₀ (F.F₀ Y)) ≈˘⟨ pushˡ H.homomorphism ⟩ H.₁ (G.₁ (F.⊗-homo.η (X , Y)) D.∘ G.⊗-homo.η (F.F₀ X , F.F₀ Y)) ∘ H.⊗-homo.η (G.F₀ (F.F₀ X) , G.F₀ (F.F₀ Y)) ≈˘⟨ identityʳ ⟩ (H.₁ (G.₁ (F.⊗-homo.η (X , Y)) D.∘ G.⊗-homo.η (F.F₀ X , F.F₀ Y)) ∘ H.⊗-homo.η (G.F₀ (F.F₀ X) , G.F₀ (F.F₀ Y))) ∘ E.id ≈˘⟨ refl⟩∘⟨ ⊗.identity ⟩ (H.₁ (G.₁ (F.⊗-homo.η (X , Y)) D.∘ G.⊗-homo.η (F.F₀ X , F.F₀ Y)) ∘ H.⊗-homo.η (G.F₀ (F.F₀ X) , G.F₀ (F.F₀ Y))) ∘ E.id ⊗₁ E.id ∎ } } -- Monoidal natural isomorphisms between strong monoidal functors. module Strong where open NT.Strong using (IsMonoidalNaturalTransformation) open StrongMonoidalFunctor renaming (F to UF; monoidalFunctor to laxF) module _ {o ℓ e o′ ℓ′ e′} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} (F G : StrongMonoidalFunctor C D) where IsMonoidalNaturalIsomorphism : NaturalIsomorphism (UF F) (UF G) → Set (o ⊔ ℓ′ ⊔ e′) IsMonoidalNaturalIsomorphism α = IsMonoidalNaturalTransformation F G (F⇒G α) -- NOTE. This record contains the same data as the lax version, -- but the type arguments are different. This helps type -- inference by providing the right constraints. record MonoidalNaturalIsomorphism : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where field U : NaturalIsomorphism (UF F) (UF G) F⇒G-isMonoidal : IsMonoidalNaturalIsomorphism U laxNI : Lax.MonoidalNaturalIsomorphism (laxF F) (laxF G) laxNI = record { U = U ; F⇒G-isMonoidal = F⇒G-isMonoidal } open Lax.MonoidalNaturalIsomorphism laxNI public hiding (U; F⇒G-isMonoidal) infix 4 _≃_ _≃_ = MonoidalNaturalIsomorphism open MonoidalNaturalIsomorphism module _ {o ℓ e o′ ℓ′ e′} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} where infixr 9 _ⓘᵥ_ -- Since they contain the same data, we can strengthen a lax -- monoidal isomorphism to a strong one. strengthen : {F G : StrongMonoidalFunctor C D} → (laxF F) Lax.≃ (laxF G) → F ≃ G strengthen α = record { U = L.U ; F⇒G-isMonoidal = L.F⇒G-isMonoidal } where module L = Lax.MonoidalNaturalIsomorphism α -- Identity and compositions id : {F : StrongMonoidalFunctor C D} → F ≃ F id = strengthen Lax.id _ⓘᵥ_ : {F G H : StrongMonoidalFunctor C D} → G ≃ H → F ≃ G → F ≃ H α ⓘᵥ β = strengthen (laxNI α Lax.ⓘᵥ laxNI β) isEquivalence : IsEquivalence _≃_ isEquivalence = record { refl = λ {F} → id {F} ; sym = λ α → record { U = NI.sym (U α) ; F⇒G-isMonoidal = F⇐G-isMonoidal α } ; trans = λ {F} {G} {H} α β → _ⓘᵥ_ {F} {G} {H} β α } module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} {E : MonoidalCategory o″ ℓ″ e″} where open Lax.MonoidalNaturalIsomorphism infixr 9 _ⓘₕ_ _ⓘˡ_ _ⓘʳ_ _ⓘₕ_ : {F G : StrongMonoidalFunctor C D} {H I : StrongMonoidalFunctor D E} → H ≃ I → F ≃ G → (H ∘Fˢ F) ≃ (I ∘Fˢ G) -- FIXME: this definition is clearly equivalent to -- -- α ⓘₕ β = strengthen (laxNI α Lax.ⓘₕ laxNI β) -- -- but the latter takes an unreasonably long time to typecheck, -- while the unfolded version typechecks almost immediately. α ⓘₕ β = record { U = L.U ; F⇒G-isMonoidal = record { ε-compat = L.ε-compat ; ⊗-homo-compat = L.⊗-homo-compat } } where module L = Lax.MonoidalNaturalIsomorphism (laxNI α Lax.ⓘₕ laxNI β) _ⓘˡ_ : {F G : StrongMonoidalFunctor C D} (H : StrongMonoidalFunctor D E) → F ≃ G → (H ∘Fˢ F) ≃ (H ∘Fˢ G) H ⓘˡ α = id {F = H} ⓘₕ α _ⓘʳ_ : {G H : StrongMonoidalFunctor D E} → G ≃ H → (F : StrongMonoidalFunctor C D) → (G ∘Fˢ F) ≃ (H ∘Fˢ F) α ⓘʳ F = α ⓘₕ id {F = F} -- Left and right unitors. module _ {o ℓ e o′ ℓ′ e′} {C : MonoidalCategory o ℓ e} {D : MonoidalCategory o′ ℓ′ e′} {F : StrongMonoidalFunctor C D} where unitorˡ : idFˢ D ∘Fˢ F ≃ F -- FIXME: Again, this unfolded definition typechecks considerably -- faster than the equivalent -- -- strengthen (Lax.unitorʳ {F = laxF F}) unitorˡ = record { U = L.U ; F⇒G-isMonoidal = record { ε-compat = L.ε-compat ; ⊗-homo-compat = L.⊗-homo-compat } } where module L = Lax.MonoidalNaturalIsomorphism (Lax.unitorˡ {F = laxF F}) unitorʳ : F ∘Fˢ idFˢ C ≃ F -- FIXME: ... same here ... unitorʳ = record { U = L.U ; F⇒G-isMonoidal = record { ε-compat = L.ε-compat ; ⊗-homo-compat = L.⊗-homo-compat } } where module L = Lax.MonoidalNaturalIsomorphism (Lax.unitorʳ {F = laxF F}) -- Associator. module _ {o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ o‴ ℓ‴ e‴} {B : MonoidalCategory o ℓ e} {C : MonoidalCategory o′ ℓ′ e′} {D : MonoidalCategory o″ ℓ″ e″} {E : MonoidalCategory o‴ ℓ‴ e‴} {F : StrongMonoidalFunctor B C} {G : StrongMonoidalFunctor C D} {H : StrongMonoidalFunctor D E} where associator : (H ∘Fˢ G) ∘Fˢ F ≃ H ∘Fˢ (G ∘Fˢ F) -- FIXME: ... and here. Though, for this one, even the unfolded -- version takes a lot of time. associator = record { U = L.U ; F⇒G-isMonoidal = record { ε-compat = L.ε-compat ; ⊗-homo-compat = L.⊗-homo-compat } } where α = Lax.associator {F = laxF F} {laxF G} {laxF H} module L = Lax.MonoidalNaturalIsomorphism α
{ "alphanum_fraction": 0.5495579339, "avg_line_length": 35.3260273973, "ext": "agda", "hexsha": "a44d8163434da34c79f487469d618166568a10b1", "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": "d07746023503cc8f49670e309a6170dc4b404b95", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/agda-categories", "max_forks_repo_path": "src/Categories/NaturalTransformation/NaturalIsomorphism/Monoidal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d07746023503cc8f49670e309a6170dc4b404b95", "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": "andrejbauer/agda-categories", "max_issues_repo_path": "src/Categories/NaturalTransformation/NaturalIsomorphism/Monoidal.agda", "max_line_length": 81, "max_stars_count": 1, "max_stars_repo_head_hexsha": "8cd50f92ce3c91dbb325b4b0a66d231df809d0a9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "iblech/agda-categories", "max_stars_repo_path": "src/Categories/NaturalTransformation/NaturalIsomorphism/Monoidal.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-18T18:21:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-18T18:21:47.000Z", "num_tokens": 5026, "size": 12894 }
postulate ∞ : ∀ {a} (A : Set a) → Set a ♯_ : ∀ {a} {A : Set a} → A → ∞ A ♭ : ∀ {a} {A : Set a} → ∞ A → A {-# BUILTIN INFINITY ∞ #-} {-# BUILTIN SHARP ♯_ #-} {-# BUILTIN FLAT ♭ #-} {-# COMPILE GHC ♭ as flat #-}
{ "alphanum_fraction": 0.3973799127, "avg_line_length": 20.8181818182, "ext": "agda", "hexsha": "6724d45814ab4740e5a112e9a326ca1ccd385114", "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/Issue2909-5.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/Issue2909-5.agda", "max_line_length": 34, "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/Issue2909-5.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": 104, "size": 229 }
-- Some basic stuff for Conor's talk. module SomeBasicStuff where infixr 40 _::_ _↦_∣_ infix 30 _∈_ _==_ infixr 10 _,_ data _==_ {A : Set}(x : A) : A -> Set where refl : x == x data Σ (A : Set)(B : A -> Set) : Set where _,_ : (x : A) -> B x -> Σ A B _×_ : Set -> Set -> Set A × B = Σ A \_ -> B fst : {A : Set}{B : A -> Set} -> Σ A B -> A fst (x , y) = x snd : {A : Set}{B : A -> Set}(p : Σ A B) -> B (fst p) snd (x , y) = y data False : Set where record True : Set where data Nat : Set where zero : Nat suc : Nat -> Nat data [_] (A : Set) : Set where [] : [ A ] _::_ : A -> [ A ] -> [ A ] data _∈_ {A : Set} : A -> [ A ] -> Set where zero : forall {x xs} -> x ∈ x :: xs suc : forall {x y xs} -> x ∈ xs -> x ∈ y :: xs postulate Tag : Set {-# BUILTIN STRING Tag #-} Enumeration = [ Tag ] data Enum (ts : Enumeration) : Set where enum : (t : Tag) -> t ∈ ts -> Enum ts data Table (A : Set1) : Enumeration -> Set1 where [] : Table A [] _↦_∣_ : forall {ts} -> (t : Tag) -> A -> Table A ts -> Table A (t :: ts) lookup : forall {A ts} -> Table A ts -> Enum ts -> A lookup [] (enum _ ()) lookup (.t ↦ v ∣ tbl) (enum t zero) = v lookup (_ ↦ v ∣ tbl) (enum t (suc p)) = lookup tbl (enum t p)
{ "alphanum_fraction": 0.4916334661, "avg_line_length": 22.4107142857, "ext": "agda", "hexsha": "bb535dbc5fdd688607e83ef7d1e21c4d873b0267", "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": "examples/DTP08/conor/SomeBasicStuff.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": "examples/DTP08/conor/SomeBasicStuff.agda", "max_line_length": 62, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/DTP08/conor/SomeBasicStuff.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": 487, "size": 1255 }
module sn-calculus-confluence.potpot where open import utility open import sn-calculus open import context-properties using (->pot-view) open import Esterel.Lang open import Esterel.Lang.CanFunction using (Can ; Canₛ ; Canₛₕ ; Canθ ; Canθₛ ; Canθₛₕ) open import Esterel.Lang.CanFunction.Properties using ( canθₛ-set-sig-monotonic-absence-lemma ; canθₛₕ-set-sig-monotonic-absence-lemma ; canθ-shr-var-irr ) open import Esterel.Environment as Env using (Env ; Θ ; _←_ ; module SigMap ; module ShrMap ; module VarMap) open import Esterel.Context open import Esterel.CompletionCode as Code using () renaming (CompletionCode to Code) open import Esterel.Variable.Signal as Signal using (Signal) open import Esterel.Variable.Shared as SharedVar using (SharedVar) open import Esterel.Variable.Sequential as SeqVar using (SeqVar) open import Data.Bool using (Bool ; true ; false ; if_then_else_) open import Data.Empty using (⊥ ; ⊥-elim) open import Data.List using (List ; [] ; _∷_ ; [_]) open import Data.List.Any using (Any ; here ; there ; any) open import Data.Maybe using (Maybe ; just ; nothing) open import Data.Nat using (ℕ ; _≟_ ; zero ; suc ; _+_) open import Data.Nat.Properties.Simple using ( +-comm ; +-assoc) open import Data.Product using (Σ ; Σ-syntax ; _,_ ; proj₁ ; proj₂ ; _,′_ ; _×_) open import Data.Sum using (_⊎_ ; inj₁ ; inj₂) open import Function using (_∘_ ; id ; _∋_) open import Relation.Nullary using (¬_ ; Dec ; yes ; no) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; sym ; trans ; cong ; subst ; module ≡-Reasoning) open ->pot-view open ≡-Reasoning using (begin_ ; _∎ ; _≡⟨_⟩_ ; _≡⟨⟩_) open import Data.OrderedListMap Signal Signal.unwrap Signal.Status as SigM open import Data.OrderedListMap SharedVar SharedVar.unwrap (Σ SharedVar.Status (λ _ → ℕ)) as ShrM open import Data.OrderedListMap SeqVar SeqVar.unwrap ℕ as SeqM pot-pot-conf-rec : ∀{p θ ql θl qr θr eql eqr A Al Ar Aql Arl} → {ρθ·psn⟶₁ρθl·ql : (ρ⟨ θ , A ⟩· p) sn⟶₁ (ρ⟨ θl , Al ⟩· ql)} → {ρθ·psn⟶₁ρθr·qr : (ρ⟨ θ , A ⟩· p) sn⟶₁ (ρ⟨ θr , Ar ⟩· qr)} → ->pot-view ρθ·psn⟶₁ρθl·ql eql Aql → ->pot-view ρθ·psn⟶₁ρθr·qr eqr Arl → (ρ⟨ θl , Al ⟩· ql ≡ ρ⟨ θr , Ar ⟩· qr) ⊎ Σ[ θo ∈ Env ] (ρ⟨ θl , Al ⟩· ql) sn⟶₁ (ρ⟨ θo , A ⟩· p) × (ρ⟨ θr , Ar ⟩· qr) sn⟶₁ (ρ⟨ θo , A ⟩· p) pot-pot-conf-rec {p} {θ} {.p} {θl} {.p} {θr} {_} {_} {A} {.A} {.A} {refl} {refl} {.(rabsence {θ} {p} {S} S∈ θS≡unknown S∉can-p-θ)} {.(rabsence {θ} {p} {S'} S'∈ θS'≡unknown S'∉can-p-θ)} (vabsence S S∈ θS≡unknown S∉can-p-θ) (vabsence S' S'∈ θS'≡unknown S'∉can-p-θ) with S Signal.≟ S' ... | yes refl = inj₁ refl ... | no S≢S' = inj₂ (_ , subst (λ sig* → ρ⟨ θl , A ⟩· p sn⟶₁ ρ⟨ (Θ sig* (Env.shr θl) (Env.var θl)) , A ⟩· p) (SigMap.put-comm {_} {Env.sig θ} {S} {S'} {Signal.absent} {Signal.absent} S≢S') (rabsence {θl} {p} {S'} S'∈Domθl θlS'≡unknown (λ S'∈can-p-θl → S'∉can-p-θ (canθₛ-set-sig-monotonic-absence-lemma (Env.sig θ) 0 p S Env.[]env S∈ θS≡unknown (Signal.unwrap S') S'∈can-p-θl))) ,′ rabsence {θr} {p} {S} S∈Domθr θrS≡unknown (λ S∈can-p-θr → S∉can-p-θ (canθₛ-set-sig-monotonic-absence-lemma (Env.sig θ) 0 p S' Env.[]env S'∈ θS'≡unknown (Signal.unwrap S) S∈can-p-θr))) where S∈Domθr = Env.sig-set-mono' {S} {S'} {θ} {Signal.absent} {S'∈} S∈ S'∈Domθl = Env.sig-set-mono' {S'} {S} {θ} {Signal.absent} {S∈} S'∈ θrS≡unknown = SigMap.putputget {_} {Env.sig θ} {S} {S'} {Signal.unknown} {Signal.absent} S≢S' S∈ S∈Domθr θS≡unknown θlS'≡unknown = SigMap.putputget {_} {Env.sig θ} {S'} {S} {Signal.unknown} {Signal.absent} (S≢S' ∘ sym) S'∈ S'∈Domθl θS'≡unknown pot-pot-conf-rec {p} {θ} {.p} {θl} {.p} {θr} {_} {_} {A} {.A} {.A} {refl} {refl} {.(rabsence {θ} {p} {S} S∈ θS≡unknown S∉can-p-θ)} {.(rreadyness {θ} {p} {s} s∈ θs≡old⊎θs≡new s∉can-p-θ)} (vabsence S S∈ θS≡unknown S∉can-p-θ) (vreadyness s s∈ θs≡old⊎θs≡new s∉can-p-θ) = inj₂ (_ , rreadyness {θl} {p} {s} s∈ θs≡old⊎θs≡new (λ s∈can-p-θl → s∉can-p-θ (canθₛₕ-set-sig-monotonic-absence-lemma (Env.sig θ) 0 p S Env.[]env S∈ θS≡unknown (SharedVar.unwrap s) s∈can-p-θl)) ,′ rabsence {θr} {p} {S} S∈ θS≡unknown (λ S∈can-p-θr → S∉can-p-θ (subst (Signal.unwrap S ∈_) (cong proj₁ (canθ-shr-var-irr (Env.sig θ) 0 p Env.[]env Env.[]env refl)) S∈can-p-θr))) pot-pot-conf-rec {p} {θ} {.p} {θl} {.p} {θr} {_} {_} {A} {.A} {.A} {refl} {refl} {.(rreadyness {θ} {p} {s} s∈ θs≡old⊎θs≡new s∉can-p-θ)} {.(rabsence {θ} {p} {S} S∈ θS≡unknown S∉can-p-θ)} (vreadyness s s∈ θs≡old⊎θs≡new s∉can-p-θ) (vabsence S S∈ θS≡unknown S∉can-p-θ) = inj₂ (_ , rabsence {θl} {p} {S} S∈ θS≡unknown (λ S∈can-p-θl → S∉can-p-θ (subst (Signal.unwrap S ∈_) (cong proj₁ (canθ-shr-var-irr (Env.sig θ) 0 p Env.[]env Env.[]env refl)) S∈can-p-θl)) ,′ rreadyness {θr} {p} {s} s∈ θs≡old⊎θs≡new (λ s∈can-p-θr → s∉can-p-θ (canθₛₕ-set-sig-monotonic-absence-lemma (Env.sig θ) 0 p S Env.[]env S∈ θS≡unknown (SharedVar.unwrap s) s∈can-p-θr))) pot-pot-conf-rec {p} {θ} {.p} {θl} {.p} {θr} {_} {_} {A} {.A} {.A} {refl} {refl} {.(rreadyness {θ} {p} {s} s∈ θs≡old⊎θs≡new s∉can-p-θ)} {.(rreadyness {θ} {p} {s'} s'∈ θs'≡old⊎θs'≡new s'∉can-p-θ)} (vreadyness s s∈ θs≡old⊎θs≡new s∉can-p-θ) (vreadyness s' s'∈ θs'≡old⊎θs'≡new s'∉can-p-θ) with s SharedVar.≟ s' ... | yes refl rewrite Env.shr-vals-∈-irr {s'} {θ} s∈ s'∈ = inj₁ refl ... | no s≢s' = inj₂ (_ , subst (λ shr* → ρ⟨ θl , A ⟩· p sn⟶₁ ρ⟨ (Θ (Env.sig θl) shr* (Env.var θl)) , A ⟩· p) (cong Env.shr (begin Env.set-shr {s'} θl s'∈Domθl SharedVar.ready (Env.shr-vals {s'} θl s'∈Domθl) ≡⟨ cong (Env.set-shr {s'} θl s'∈Domθl SharedVar.ready ∘ proj₂) θls'≡θs' ⟩ Env.set-shr {s'} θl s'∈Domθl SharedVar.ready θs' ≡⟨ cong (λ shr* → Θ (Env.sig θ) shr* (Env.var θ)) (ShrMap.put-comm {_} {Env.shr θ} {s} {s'} {SharedVar.ready , θs} {SharedVar.ready , θs'} s≢s') ⟩ Env.set-shr {s} θr s∈Domθr SharedVar.ready θs ≡⟨ cong (Env.set-shr {s} θr s∈Domθr SharedVar.ready ∘ proj₂) (sym θrs≡θs) ⟩ Env.set-shr {s} θr s∈Domθr SharedVar.ready (Env.shr-vals {s} θr s∈Domθr) ∎)) (rreadyness {θl} {p} {s'} s'∈Domθl (Data.Sum.map (trans (cong proj₁ θls'≡θs')) (trans (cong proj₁ θls'≡θs')) θs'≡old⊎θs'≡new) (λ s'∈can-p-θl → s'∉can-p-θ (subst (SharedVar.unwrap s' ∈_) (cong (proj₂ ∘ proj₂) (canθ-shr-var-irr (Env.sig θ) 0 p Env.[]env Env.[]env refl)) s'∈can-p-θl))) ,′ rreadyness {θr} {p} {s} s∈Domθr (Data.Sum.map (trans (cong proj₁ θrs≡θs)) (trans (cong proj₁ θrs≡θs)) θs≡old⊎θs≡new) (λ s∈can-p-θr → s∉can-p-θ (subst (SharedVar.unwrap s ∈_) (cong (proj₂ ∘ proj₂) (canθ-shr-var-irr (Env.sig θ) 0 p Env.[]env Env.[]env refl)) s∈can-p-θr))) where θs = Env.shr-vals {s} θ s∈ θs' = Env.shr-vals {s'} θ s'∈ s∈Domθr = Env.shr-set-mono' {s} {s'} {θ} {SharedVar.ready} {θs'} {s'∈} s∈ s'∈Domθl = Env.shr-set-mono' {s'} {s} {θ} {SharedVar.ready} {θs} {s∈} s'∈ θrs≡θs = ShrMap.putputget {_} {Env.shr θ} {s} {s'} {_} {SharedVar.ready ,′ θs'} s≢s' s∈ s∈Domθr refl θls'≡θs' = ShrMap.putputget {_} {Env.shr θ} {s'} {s} {_} {SharedVar.ready ,′ θs} (s≢s' ∘ sym) s'∈ s'∈Domθl refl
{ "alphanum_fraction": 0.5273913579, "avg_line_length": 41.2335025381, "ext": "agda", "hexsha": "ccb5da3c8f74d61d13d50844c05bc77b1890167d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/sn-calculus-confluence/potpot.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/sn-calculus-confluence/potpot.agda", "max_line_length": 97, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/sn-calculus-confluence/potpot.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 3632, "size": 8123 }
{-# OPTIONS --safe #-} module Issue2487.d where -- trying to import a two-level, non-safe module open import Issue2487.e
{ "alphanum_fraction": 0.7213114754, "avg_line_length": 20.3333333333, "ext": "agda", "hexsha": "6cde35d19d7a0151ead9e8fb81292cde3a290e56", "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/Issue2487/d.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/Issue2487/d.agda", "max_line_length": 48, "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/Issue2487/d.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": 31, "size": 122 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Support.EqReasoning where open import Categories.Support.Equivalence using (Setoid; module Setoid) open import Relation.Binary.PropositionalEquality using () renaming (_≡_ to _≣_; trans to ≣-trans; sym to ≣-sym; refl to ≣-refl) module SetoidReasoning {s₁ s₂} (S : Setoid s₁ s₂) where open Setoid S infix 4 _IsRelatedTo_ infix 1 begin_ infixr 2 _≈⟨_⟩_ _↓⟨_⟩_ _↑⟨_⟩_ _↓≣⟨_⟩_ _↑≣⟨_⟩_ _↕_ infix 3 _∎ -- This seemingly unnecessary type is used to make it possible to -- infer arguments even if the underlying equality evaluates. data _IsRelatedTo_ (x y : Carrier) : Set s₂ where relTo : (x∼y : x ≈ y) → x IsRelatedTo y .begin_ : ∀ {x y} → x IsRelatedTo y → x ≈ y begin relTo x∼y = x∼y ._↓⟨_⟩_ : ∀ x {y z} → x ≈ y → y IsRelatedTo z → x IsRelatedTo z _ ↓⟨ x∼y ⟩ relTo y∼z = relTo (trans x∼y y∼z) -- where open IsEquivalence isEquivalence ._↑⟨_⟩_ : ∀ x {y z} → y ≈ x → y IsRelatedTo z → x IsRelatedTo z _ ↑⟨ y∼x ⟩ relTo y∼z = relTo (trans (sym y∼x) y∼z) -- where open IsEquivalence isEquivalence -- the syntax of the ancients, for compatibility ._≈⟨_⟩_ : ∀ x {y z} → x ≈ y → y IsRelatedTo z → x IsRelatedTo z _≈⟨_⟩_ = _↓⟨_⟩_ ._↓≣⟨_⟩_ : ∀ x {y z} → x ≣ y → y IsRelatedTo z → x IsRelatedTo z _ ↓≣⟨ ≣-refl ⟩ y∼z = y∼z ._↑≣⟨_⟩_ : ∀ x {y z} → y ≣ x → y IsRelatedTo z → x IsRelatedTo z _ ↑≣⟨ ≣-refl ⟩ y∼z = y∼z ._↕_ : ∀ x {z} → x IsRelatedTo z → x IsRelatedTo z _ ↕ x∼z = x∼z ._∎ : ∀ x → x IsRelatedTo x _∎ _ = relTo refl -- where open IsEquivalence isEquivalence module ≣-reasoning {ℓ} (S : Set ℓ) where infix 4 _IsRelatedTo_ infix 2 _∎ infixr 2 _≈⟨_⟩_ infixr 2 _↓⟨_⟩_ infixr 2 _↑⟨_⟩_ infixr 2 _↕_ infix 1 begin_ -- This seemingly unnecessary type is used to make it possible to -- infer arguments even if the underlying equality evaluates. data _IsRelatedTo_ (x y : S) : Set ℓ where relTo : (x∼y : x ≣ y) → x IsRelatedTo y begin_ : ∀ {x y} → x IsRelatedTo y → x ≣ y begin relTo x∼y = x∼y -- the syntax of the ancients, for compatibility _≈⟨_⟩_ : ∀ x {y z} → x ≣ y → y IsRelatedTo z → x IsRelatedTo z _ ≈⟨ x∼y ⟩ relTo y∼z = relTo (≣-trans x∼y y∼z) _↓⟨_⟩_ : ∀ x {y z} → x ≣ y → y IsRelatedTo z → x IsRelatedTo z _ ↓⟨ x∼y ⟩ relTo y∼z = relTo (≣-trans x∼y y∼z) _↑⟨_⟩_ : ∀ x {y z} → y ≣ x → y IsRelatedTo z → x IsRelatedTo z _ ↑⟨ y∼x ⟩ relTo y∼z = relTo (≣-trans (≣-sym y∼x) y∼z) _↕_ : ∀ x {z} → x IsRelatedTo z → x IsRelatedTo z _ ↕ x∼z = x∼z _∎ : ∀ x → x IsRelatedTo x _∎ _ = relTo ≣-refl
{ "alphanum_fraction": 0.6003098373, "avg_line_length": 30.7380952381, "ext": "agda", "hexsha": "dcfacdeee67a710d81c1876827ffeac891055452", "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": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Support/EqReasoning.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "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": "p-pavel/categories", "max_issues_repo_path": "Categories/Support/EqReasoning.agda", "max_line_length": 128, "max_stars_count": 1, "max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "p-pavel/categories", "max_stars_repo_path": "Categories/Support/EqReasoning.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z", "max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z", "num_tokens": 1169, "size": 2582 }
{- This file contains a summary of what remains for π₄(S³) ≡ ℤ/2ℤ to be proved. See the module π₄S³ at the end of this file. -} {-# OPTIONS --safe #-} module Cubical.Homotopy.Group.Pi4S3.Summary where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Data.Nat.Base open import Cubical.Data.Sigma.Base open import Cubical.Data.Int renaming (ℤ to Int) hiding (_+_) open import Cubical.HITs.Sn open import Cubical.HITs.SetTruncation open import Cubical.Homotopy.Group.Base hiding (π) open import Cubical.Homotopy.HopfInvariant.Base open import Cubical.Homotopy.HopfInvariant.Homomorphism open import Cubical.Homotopy.HopfInvariant.HopfMap open import Cubical.Homotopy.Whitehead open import Cubical.Homotopy.Group.Pi3S2 open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.Instances.Int open import Cubical.Algebra.Group.Instances.IntMod open import Cubical.Algebra.Group.ZAction private variable ℓ : Level -- TODO: ideally this would not be off by one in the definition of π'Gr π : ℕ → Pointed ℓ → Group ℓ π n X = π'Gr (predℕ n) X -- Nicer notation for the spheres (as pointed types) 𝕊² 𝕊³ : Pointed₀ 𝕊² = S₊∙ 2 𝕊³ = S₊∙ 3 -- Whitehead product [_]× : {X : Pointed ℓ} {n m : ℕ} → π' (suc n) X × π' (suc m) X → π' (suc (n + m)) X [_]× (f , g) = [ f ∣ g ]π' -- Some type abbreviations (unproved results) π₄S³≡ℤ/something : GroupEquiv (π 3 𝕊²) ℤ → Type₁ π₄S³≡ℤ/something eq = π 4 𝕊³ ≡ ℤ/ abs (eq .fst .fst [ ∣ idfun∙ _ ∣₂ , ∣ idfun∙ _ ∣₂ ]×) -- Summary of the last steps of the proof module π₄S³ (π₃S²≃ℤ : GroupEquiv (π 3 𝕊²) ℤ) (gen-by-HopfMap : gen₁-by (π 3 𝕊²) ∣ HopfMap ∣₂) (π₄S³≡ℤ/whitehead : π₄S³≡ℤ/something π₃S²≃ℤ) (hopfWhitehead : abs (HopfInvariant-π' 0 ([ (∣ idfun∙ _ ∣₂ , ∣ idfun∙ _ ∣₂) ]×)) ≡ 2) where -- Package the Hopf invariant up into a group equivalence hopfInvariantEquiv : GroupEquiv (π 3 𝕊²) ℤ fst (fst hopfInvariantEquiv) = HopfInvariant-π' 0 snd (fst hopfInvariantEquiv) = GroupEquivℤ-isEquiv (invGroupEquiv π₃S²≃ℤ) ∣ HopfMap ∣₂ gen-by-HopfMap (GroupHom-HopfInvariant-π' 0) (abs→⊎ _ _ HopfInvariant-HopfMap) snd hopfInvariantEquiv = snd (GroupHom-HopfInvariant-π' 0) -- The two equivalences map [ (∣ idfun∙ _ ∣₂ , ∣ idfun∙ _ ∣₂) ]× to -- the same number, modulo the sign remAbs : abs (groupEquivFun π₃S²≃ℤ [ (∣ idfun∙ _ ∣₂ , ∣ idfun∙ _ ∣₂) ]×) ≡ abs (groupEquivFun hopfInvariantEquiv [ (∣ idfun∙ _ ∣₂ , ∣ idfun∙ _ ∣₂) ]×) remAbs = absGroupEquivℤGroup (invGroupEquiv π₃S²≃ℤ) (invGroupEquiv hopfInvariantEquiv) _ -- So the image of [ (∣ idfun∙ _ ∣₂ , ∣ idfun∙ _ ∣₂) ]× under π₃S²≃ℤ -- is 2 (modulo the sign) remAbs₂ : abs (groupEquivFun π₃S²≃ℤ [ (∣ idfun∙ _ ∣₂ , ∣ idfun∙ _ ∣₂) ]×) ≡ 2 remAbs₂ = remAbs ∙ hopfWhitehead -- The final result then follows π₄S³≡ℤ : π 4 𝕊³ ≡ ℤ/ 2 π₄S³≡ℤ = π₄S³≡ℤ/whitehead ∙ cong (ℤ/_) remAbs₂ -- In order to instantiate the module, we need the four following lemmas: -- Proved: 2/4 {- Lemma 1 -} Lemma₁ : GroupEquiv ℤ (π'Gr 2 (S₊∙ 2)) Lemma₁ = invGroupEquiv π₃S²≅ℤ {- Lemma 2 -} Lemma₂ : gen₁-by (π 3 𝕊²) ∣ HopfMap ∣₂ Lemma₂ = π₂S³-gen-by-HopfMap {- Lemma 3 (WIP) -} {- Lemma₃ : π₄S³≡ℤ/something (invGroupEquiv π₃S²≅ℤ) Lemma₃ = ? -} {- Lemma 4 (WIP) -} {- Lemma₄ : abs (HopfInvariant-π' 0 ([ (∣ idfun∙ _ ∣₂ , ∣ idfun∙ _ ∣₂) ]×)) ≡ 2) Lemma₄ = ? -}
{ "alphanum_fraction": 0.6714163579, "avg_line_length": 31.3303571429, "ext": "agda", "hexsha": "0f91508edadbd8e48c3f06e445d9a59cee9c6b27", "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": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "FernandoLarrain/cubical", "max_forks_repo_path": "Cubical/Homotopy/Group/Pi4S3/Summary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "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": "FernandoLarrain/cubical", "max_issues_repo_path": "Cubical/Homotopy/Group/Pi4S3/Summary.agda", "max_line_length": 90, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_path": "Cubical/Homotopy/Group/Pi4S3/Summary.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T21:49:23.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-05T21:49:23.000Z", "num_tokens": 1476, "size": 3509 }
------------------------------------------------------------------------ -- The Agda standard library -- -- More efficient mod and divMod operations (require the K axiom) ------------------------------------------------------------------------ {-# OPTIONS --with-K --safe #-} module Data.Nat.DivMod.WithK where open import Data.Nat using (ℕ; _+_; _*_; _≟_; zero; suc) open import Data.Nat.DivMod hiding (_mod_; _divMod_) open import Data.Nat.Properties using (≤⇒≤″) open import Data.Nat.WithK open import Data.Fin using (Fin; toℕ; fromℕ≤″) open import Data.Fin.Properties using (toℕ-fromℕ≤″) open import Function using (_$_) open import Relation.Nullary.Decidable using (False) open import Relation.Binary.PropositionalEquality using (refl; sym; cong; module ≡-Reasoning) open import Relation.Binary.PropositionalEquality.WithK open ≡-Reasoning infixl 7 _mod_ _divMod_ ------------------------------------------------------------------------ -- Certified modulus _mod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → Fin divisor (a mod 0) {} (a mod suc n) = fromℕ≤″ (a % suc n) (≤″-erase (≤⇒≤″ (a%n<n a n))) ------------------------------------------------------------------------ -- Returns modulus and division result with correctness proof _divMod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → DivMod dividend divisor (a divMod 0) {} (a divMod suc n) = result (a div suc n) (a mod suc n) $ ≡-erase $ begin a ≡⟨ a≡a%n+[a/n]*n a n ⟩ a % suc n + [a/n]*n ≡⟨ cong (_+ [a/n]*n) (sym (toℕ-fromℕ≤″ lemma′)) ⟩ toℕ (fromℕ≤″ _ lemma′) + [a/n]*n ∎ where lemma′ = ≤″-erase (≤⇒≤″ (a%n<n a n)) [a/n]*n = a div suc n * suc n
{ "alphanum_fraction": 0.5263466042, "avg_line_length": 36.3404255319, "ext": "agda", "hexsha": "c90a32ff99cec8a00b2e747cd8a6230033d92797", "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/Nat/DivMod/WithK.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/Nat/DivMod/WithK.agda", "max_line_length": 85, "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/Nat/DivMod/WithK.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 513, "size": 1708 }
{-# OPTIONS --cubical-compatible #-} mutual record R : Set₁ where constructor c field @0 A : Set x : _ _ : (@0 A : Set) → A → R _ = c
{ "alphanum_fraction": 0.4819277108, "avg_line_length": 12.7692307692, "ext": "agda", "hexsha": "e594a036a83e5c6fe39f5b01421681a48449788f", "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/Fail/Issue5434-4.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/Fail/Issue5434-4.agda", "max_line_length": 36, "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/Fail/Issue5434-4.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 57, "size": 166 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Lemmas open import LibraBFT.Base.PKCS -- This module provides a utility function to make it easy to -- provide the bft-lemma for implementations in which the -- participants can have different voting power. -- The module is parametrized with the number of participants - -- `authorsN`, and with a function - `votPower` - that assigns to -- each participant its voting power. The parameter `N` corresponds -- to the total voting power of all participants, as required by the -- parameter `totalVotPower` in the inner module. These -- implementations should assume a fixed unknown subset of malicious -- nodes - Byzantine - but should also assume a security threshold -- `bizF`, such that N > 3 * bizF, which should be provided in -- parameter `isBFT`. Finally, the `bft-assumption` states that the -- combined voting power of Byzantine nodes must not exceed the -- security threshold `bizF`. -- The bft-lemma is the last lemma in this file and proves that in -- the intersection of any quorums, whose combined voting power is -- greater than or equal to `N - bizF`, there is an honest Member. module LibraBFT.Abstract.BFT (authorsN : ℕ) (votPower : Fin authorsN → ℕ) (bizF : ℕ) (isBFT : f-sum votPower (allFin authorsN) ≥ suc (3 * bizF)) (getPubKey : Fin authorsN → PK) where -- The set of members of this epoch. Member : Set Member = Fin authorsN Meta-dishonest? : ∀ (m : Member) → Dec (Meta-Dishonest-PK (getPubKey m)) Meta-dishonest? m = Meta-DishonestPK? (getPubKey m) CombinedPower : List Member → ℕ CombinedPower = f-sum votPower TotalVotPower : ℕ TotalVotPower = f-sum votPower (allFin authorsN) open DecLemmas {A = Member} _≟Fin_ -- The bft-assumption states that the combined voting power of -- Byzantine nodes must not exceed the security threshold -- `bizF`. Therefore, for any list of distinct participants, the -- combined power of the dishonest nodes is less than or equal to -- `bizF`. module _ (bft-assumption : ∀ (xs : List Member) → allDistinct xs → CombinedPower (List-filter Meta-dishonest? xs) ≤ bizF) where participants : List Member participants = allFin authorsN members⊆ : ∀ {xs : List Member} → xs ⊆List participants members⊆ {_} {x} _ = Any-tabulate⁺ {f = id} x refl union-votPower≤N : ∀ (xs ys : List Member) → allDistinct xs → allDistinct ys → CombinedPower (union xs ys) ≤ TotalVotPower union-votPower≤N xs ys dxs dys = sum-⊆-≤ (union xs ys) votPower (unionDistinct xs ys dxs dys) members⊆ union-votPower≡ : ∀ (xs ys : List Member) → allDistinct xs → allDistinct ys → CombinedPower (union xs ys) ≡ CombinedPower (xs ++ ys) ∸ CombinedPower (intersect xs ys) union-votPower≡ xs [] dxs dys rewrite ++-identityʳ xs = refl union-votPower≡ xs (y ∷ ys) dxs dys with y ∈? xs ...| yes y∈xs rewrite union-votPower≡ xs ys dxs (allDistinctTail dys) | sym (m+n∸n≡m (CombinedPower (xs ++ ys)) (votPower y)) | ∸-+-assoc (CombinedPower (xs ++ ys) + votPower y) (votPower y) (CombinedPower (intersect xs ys)) | map-++-commute votPower xs ys | sum-++-commute (List-map votPower xs) (List-map votPower ys) | +-assoc (CombinedPower xs) (CombinedPower ys) (votPower y) | +-comm (CombinedPower ys) (votPower y) | sym (sum-++-commute (List-map votPower xs) (List-map votPower (y ∷ ys))) | sym (map-++-commute votPower xs (y ∷ ys)) = refl ...| no y∉xs rewrite union-votPower≡ xs ys dxs (allDistinctTail dys) | sym (+-∸-assoc (votPower y) (sumIntersect≤ xs ys votPower)) | map-++-commute votPower xs ys | sum-++-commute (List-map votPower xs) (List-map votPower ys) | sym (+-assoc (votPower y) (CombinedPower xs) (CombinedPower ys)) | +-comm (votPower y) (CombinedPower xs) | +-assoc (CombinedPower xs) (votPower y) (CombinedPower ys) | sym (sum-++-commute (List-map votPower xs) (List-map votPower (y ∷ ys))) | sym (map-++-commute votPower xs (y ∷ ys)) = refl quorumInt>biz : ∀ (xs ys : List Member) → TotalVotPower ∸ bizF ≤ CombinedPower xs → TotalVotPower ∸ bizF ≤ CombinedPower ys → CombinedPower (xs ++ ys) ∸ TotalVotPower ≤ CombinedPower (intersect xs ys) → bizF + 1 ≤ CombinedPower (intersect xs ys) quorumInt>biz xs ys q≤x q≤y ≤combPower rewrite map-++-commute votPower xs ys | sum-++-commute (List-map votPower xs) (List-map votPower ys) = let powInt = CombinedPower (intersect xs ys) p₁ = ≤-trans (∸-monoˡ-≤ TotalVotPower (+-mono-≤ q≤x q≤y)) ≤combPower p₂ = subst (_≤ powInt) (simpExp₁ TotalVotPower bizF) p₁ p₃ = ≤-trans (∸-monoˡ-≤ (2 * bizF) isBFT) p₂ in subst (_≤ powInt) (simpExp₂ bizF) p₃ where simpExp₁ : ∀ (x y : ℕ) → (x ∸ y) + (x ∸ y) ∸ x ≡ x ∸ (2 * y) simpExp₁ x y rewrite sym (*-identityʳ (x ∸ y)) | sym (*-distribˡ-+ (x ∸ y) 1 1) | *-comm (x ∸ y) 2 | *-distribˡ-∸ 2 x y | ∸-+-assoc (2 * x) (2 * y) x | +-comm (2 * y) x | sym (∸-+-assoc (2 * x) x (2 * y)) | +-identityʳ x | m+n∸n≡m x x = refl simpExp₂ : ∀ (x : ℕ) → suc (3 * x) ∸ 2 * x ≡ x + 1 simpExp₂ x rewrite +-∸-assoc 1 (*-monoˡ-≤ x {2} {3} (s≤s (s≤s z≤n))) | sym (*-distribʳ-∸ x 3 2) | sym (+-suc x 0) = refl partition-hon : ∀ {xs dis hon : List Member} {x : Member} → partition Meta-dishonest? xs ≡ (dis , x ∷ hon) → x ∈ xs × Meta-Honest-PK (getPubKey x) partition-hon {x ∷ xs} eq with Meta-dishonest? x | eq ...| no imp | refl = here refl , imp ...| yes _ | eq₁ with partition Meta-dishonest? xs | inspect (partition Meta-dishonest?) xs ...| _ , x₂ ∷ _ | [ eq₂ ] rewrite just-injective (cong (head ∘ proj₂) eq₁) = ×-map₁ there (partition-hon eq₂) partition-dis : ∀ {xs dis : List Member} → partition Meta-dishonest? xs ≡ (dis , []) → List-filter Meta-dishonest? xs ≡ xs partition-dis {[]} _ = refl partition-dis {x ∷ xs} eq with Meta-dishonest? x | eq ...| no ¬dis | () ...| yes _ | _ with partition Meta-dishonest? xs | inspect (partition Meta-dishonest?) xs ...| _ , [] | [ eq₁ ] = cong (x ∷_) (partition-dis {xs} eq₁) -- TODO-1 : An alternative to prove this lemma would be: -- - First prove that -- CombinedPower (List-filter Meta-dishonest? xs) ≤ CombinedPower xs. -- - Then prove that: -- - If CombinedPower (List-filter Meta-dishonest? xs) < CombinedPower xs -- then ∃[ α ] (α ∈ xs × Meta-Honest-PK (getPubKey α)). -- - If CombinedPower (List-filter Meta-dishonest? xs ≡ CombinedPower xs we -- get a contradiction using the bft assumption (as we have now). find-honest : ∀ {xs : List Member} → allDistinct xs → bizF < CombinedPower xs → ∃[ α ] (α ∈ xs × Meta-Honest-PK (getPubKey α)) find-honest {xs} sxs biz< with partition Meta-dishonest? xs | inspect (partition Meta-dishonest?) xs ...| dis , [] | [ eq ] = let bft = bft-assumption xs sxs xsVot≤f = subst (_≤ bizF) (cong CombinedPower (partition-dis {xs} eq)) bft in ⊥-elim (<⇒≱ biz< xsVot≤f) ...| dis , x ∷ hon | [ eq ] = x , partition-hon eq bft-lemma : {xs ys : List Member} → allDistinct xs → allDistinct ys → TotalVotPower ∸ bizF ≤ CombinedPower xs → TotalVotPower ∸ bizF ≤ CombinedPower ys → ∃[ α ] (α ∈ xs × α ∈ ys × Meta-Honest-PK (getPubKey α)) bft-lemma {xs} {ys} all≢xs all≢ys q≤≢xs q≤≢ys = let |q₁|+|q₂| = CombinedPower (xs ++ ys) |q₁∩q₂| = CombinedPower (intersect xs ys) |q₁∪q₂|≤n = union-votPower≤N xs ys all≢xs all≢ys |q₁∪q₂|≡ = union-votPower≡ xs ys all≢xs all≢ys exp₁ = subst (_≤ TotalVotPower) |q₁∪q₂|≡ |q₁∪q₂|≤n exp₂ = m∸n≤o⇒m∸o≤n |q₁|+|q₂| |q₁∩q₂| TotalVotPower exp₁ f+1≤|q₁∩q₂| = quorumInt>biz xs ys q≤≢xs q≤≢ys exp₂ f<|q₁∩q₂| = subst (_≤ |q₁∩q₂|) (+-comm bizF 1) f+1≤|q₁∩q₂| intDist = intersectDistinct xs ys all≢xs all≢ys honInf = find-honest {intersect xs ys} intDist f<|q₁∩q₂| h∈∩ = ∈-intersect xs ys ((proj₁ ∘ proj₂) honInf) in proj₁ honInf , proj₁ h∈∩ , proj₂ h∈∩ , (proj₂ ∘ proj₂) honInf
{ "alphanum_fraction": 0.5465104221, "avg_line_length": 49.1989795918, "ext": "agda", "hexsha": "6c6fdf0bd8b07bc2bd3273ea2fa97385bbf87a57", "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/Abstract/BFT.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/Abstract/BFT.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/Abstract/BFT.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2971, "size": 9643 }
module Coirc.Bot where open import Coirc open import Coirc.Network open import Coinduction open import IO open import Data.String server = "irc.freenode.org" name = "coalgbot" real = "Coalgebra Bot" bot : Bot bot = put (nick name) (♯ put (user name real) (♯ loop)) where loop = get f where f : Event → Bot f notice = put (print "<notice>") (♯ loop) f numeric = put (print "<numeric-reply>") (♯ loop) f mode = put (print "<mode>") (♯ loop) f ping = put (print "<ping/pong>") (♯ put (pong name) (♯ loop)) f (privmsg source "/quit") = put (privmsg source "ciao") (♯ put (quit (source ++ " told me to leave")) (♯ loop)) f (privmsg source text) = put (print ("<privmsg>: " ++ text)) (♯ put (privmsg source "interesting, tell me more!") (♯ loop)) main = run (runBot bot server)
{ "alphanum_fraction": 0.5948174323, "avg_line_length": 24.9705882353, "ext": "agda", "hexsha": "71365282f5dcf28948e3c0e0dff313cc49bed907", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:53:29.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:53:29.000Z", "max_forks_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/coirc", "max_forks_repo_path": "src/Coirc/Bot.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/coirc", "max_issues_repo_path": "src/Coirc/Bot.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd5b9aeb84851da56ce018ed15a7da1dcc949461", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/coirc", "max_stars_repo_path": "src/Coirc/Bot.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 265, "size": 849 }
{-# OPTIONS --cubical --safe #-} open import Prelude open import Relation.Binary module LexPerm where
{ "alphanum_fraction": 0.7403846154, "avg_line_length": 14.8571428571, "ext": "agda", "hexsha": "7e7aaa5b22553b8a99f7675f70c527ac5e27ef78", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "LexPerm.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "LexPerm.agda", "max_line_length": 32, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "LexPerm.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 23, "size": 104 }
open import Prelude module Implicits.Resolution.Finite.Resolution where open import Coinduction open import Data.Fin.Substitution open import Data.List open import Data.List.Any open Membership-≡ open import Implicits.Syntax open import Implicits.Substitutions open import Implicits.Resolution.Termination open import Induction open import Induction.Nat open import Relation.Binary using (Rel) mutual data _⊢_↓_ {ν} (Δ : ICtx ν) : Type ν → SimpleType ν → Set where i-simp : ∀ a → Δ ⊢ simpl a ↓ a i-iabs : ∀ {ρ₁ ρ₂ a} → (, ρ₁) hρ< (, ρ₂) → Δ ⊢ᵣ ρ₁ → Δ ⊢ ρ₂ ↓ a → Δ ⊢ ρ₁ ⇒ ρ₂ ↓ a i-tabs : ∀ {ρ a} b → Δ ⊢ ρ tp[/tp b ] ↓ a → Δ ⊢ ∀' ρ ↓ a data _⊢ᵣ_ {ν} (Δ : ICtx ν) : Type ν → Set where r-simp : ∀ {r τ} → r ∈ Δ → Δ ⊢ r ↓ τ → Δ ⊢ᵣ simpl τ r-iabs : ∀ {ρ₁ ρ₂} → ((ρ₁ ∷ Δ) ⊢ᵣ ρ₂) → Δ ⊢ᵣ (ρ₁ ⇒ ρ₂) r-tabs : ∀ {ρ} → ictx-weaken Δ ⊢ᵣ ρ → Δ ⊢ᵣ ∀' ρ
{ "alphanum_fraction": 0.6112385321, "avg_line_length": 31.1428571429, "ext": "agda", "hexsha": "c7bd71c9711765c7b70ba4794c7c086179d5ada9", "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/Implicits/Resolution/Finite/Resolution.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/Implicits/Resolution/Finite/Resolution.agda", "max_line_length": 85, "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/Implicits/Resolution/Finite/Resolution.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": 379, "size": 872 }
module Data.Fin.Sigma where open import Prelude open import Data.Nat open import Data.Nat.Properties Fin : ℕ → Type Fin n = ∃ m × (m < n) open import Data.List _!!_ : (xs : List A) → Fin (length xs) → A (x ∷ xs) !! (zero , p) = x (x ∷ xs) !! (suc n , p) = xs !! (n , p)
{ "alphanum_fraction": 0.5781818182, "avg_line_length": 18.3333333333, "ext": "agda", "hexsha": "aaacc2f764feaa66f027c6a7f6d92829467968d3", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Fin/Sigma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Fin/Sigma.agda", "max_line_length": 42, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Fin/Sigma.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 103, "size": 275 }