Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --cubical --safe #-} module Cubical.Data.NatMinusTwo where open import Cubical.Data.NatMinusTwo.Base public open import Cubical.Data.NatMinusTwo.Properties public open import Cubical.Data.NatMinusTwo.ToNatMinusOne using (1+_; ℕ₋₁→ℕ₋₂; -1+Path) public
{ "alphanum_fraction": 0.7819548872, "avg_line_length": 29.5555555556, "ext": "agda", "hexsha": "9e999ec17423e4aa6b4df9fe21375a6ff988afa4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmester0/cubical", "max_forks_repo_path": "Cubical/Data/NatMinusTwo.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmester0/cubical", "max_issues_repo_path": "Cubical/Data/NatMinusTwo.agda", "max_line_length": 87, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmester0/cubical", "max_stars_repo_path": "Cubical/Data/NatMinusTwo.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "num_tokens": 79, "size": 266 }
------------------------------------------------------------------------------ -- Mendelson's substitution ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOL.MendelsonSubstATP where -- First-order logic with equality. open import Common.FOL.FOL-Eq public ------------------------------------------------------------------------------ -- Mendelson's [2015] substitution (p. 93). -- (A7) x = y ⇒ (A(x,x) ⇒ B(x,y)) (substitutivity of equality) postulate mendelsonSubst : (A : D → D → Set) → ∀ {x y} → x ≡ y → A x x → A x y {-# ATP prove mendelsonSubst #-} ------------------------------------------------------------------------------ -- References -- Mendelson, Elliott (2015). Introduction to Mathematical Logic. CRC -- Press, 6th edition.
{ "alphanum_fraction": 0.4099378882, "avg_line_length": 32.2, "ext": "agda", "hexsha": "ae93f175e173243d20264f6db9d0bb483cc6f8cf", "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/FOL/MendelsonSubstATP.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/FOL/MendelsonSubstATP.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOL/MendelsonSubstATP.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": 192, "size": 966 }
{-# OPTIONS --cubical-compatible #-} postulate A : Set P : A → Set Q : {x : A} → P x → P x → Set variable B : Set @0 q : B postulate F : ∀ p → Q p q → Set Test : {@0 x : A} ({q} p : P x) (q′ : Q p q) → Set Test = F
{ "alphanum_fraction": 0.4572649573, "avg_line_length": 13.7647058824, "ext": "agda", "hexsha": "f83152b7be54af54b64b004c466784ba68d69064", "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/Issue5058b.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/Issue5058b.agda", "max_line_length": 50, "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/Issue5058b.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 101, "size": 234 }
{-# OPTIONS --prop --rewriting #-} open import Calf.CostMonoid module Calf (costMonoid : CostMonoid) where open CostMonoid costMonoid open import Calf.Prelude public open import Calf.Metalanguage public open import Calf.PhaseDistinction public open import Calf.Step costMonoid public open import Calf.Noninterference costMonoid public
{ "alphanum_fraction": 0.8147058824, "avg_line_length": 22.6666666667, "ext": "agda", "hexsha": "4efab28dd5529a1d93d8d803cc865433de30acd8", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_path": "src/Calf.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "jonsterling/agda-calf", "max_issues_repo_path": "src/Calf.agda", "max_line_length": 50, "max_stars_count": 29, "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_path": "src/Calf.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "num_tokens": 88, "size": 340 }
open import MLib.Finite module MLib.Finite.Properties {c ℓ} (finiteSet : FiniteSet c ℓ) where open import MLib.Prelude import Data.Fin.Permutation as Perm import Relation.Binary as B open FE using (cong) open LeftInverse using () renaming (_∘_ to _ⁱ∘_) open Algebra using (IdempotentCommutativeMonoid) open Table hiding (setoid) open FiniteSet finiteSet renaming (Carrier to A) private enumₜAt : ∀ {N} → OntoFin N → Table A N enumₜAt = tabulate ∘ _⟨$⟩_ ∘ LeftInverse.from module _ {c ℓ} (icMonoid : IdempotentCommutativeMonoid c ℓ) where module S = IdempotentCommutativeMonoid icMonoid open S using (_∙_; ∙-cong) renaming (Carrier to S; _≈_ to _≈′_) open import Algebra.Operations.CommutativeMonoid S.commutativeMonoid open import Algebra.Properties.CommutativeMonoid S.commutativeMonoid foldMap : (A → S) → S foldMap f = sumₜ (Table.map f enumₜ) foldMap-cong : ∀ {f g} → (∀ x → f x ≈′ g x) → foldMap f ≈′ foldMap g foldMap-cong p = sumₜ-cong-≈ (p ∘ lookup enumₜ) private inhabited : ∀ {N} (i : Fin N) → ∃ λ n → N ≡ Nat.suc n inhabited Fin.zero = _ , ≡.refl inhabited (Fin.suc i) = _ , ≡.refl -- Folding with a constant function produces the constant. foldMap-const : ∀ {x} → x ∙ foldMap (λ _ → x) ≈′ x foldMap-const {x} = begin x ∙ foldMap (λ _ → x) ≡⟨⟩ x ∙ sumₜ (Table.map (λ _ → x) enumₜ) ≡⟨⟩ x ∙ sumₜ (Table.replicate {N} x) ≡⟨⟩ sumₜ (Table.replicate {Nat.suc N} x) ≈⟨ sumₜ-idem-replicate N (S.idem x) ⟩ x ∎ where open EqReasoning S.setoid private module _ {n : ℕ} (ontoFin′ : OntoFin (Nat.suc n)) where from = LeftInverse.from ontoFin′ ⟨$⟩_ to = LeftInverse.to ontoFin′ ⟨$⟩_ from-to = LeftInverse.left-inverse-of ontoFin′ enumₜ′ : Table A (Nat.suc n) enumₜ′ = enumₜAt ontoFin′ ap : setoid ⟶ S.setoid → A → S ap = _⟨$⟩_ enumₜ-complete′ : ∀ (func : setoid ⟶ S.setoid) x → (func ⟨$⟩ x) ∙ sumₜ (map (ap func) enumₜ′) ≈′ sumₜ (map (ap func) enumₜ′) enumₜ-complete′ func x = begin f x ∙ sumₜ (map f enumₜ′) ≈⟨ ∙-cong S.refl (sumₜ-permute (map f enumₜ′) (Perm.transpose Fin.zero i)) ⟩ f x ∙ sumₜ (permute (Perm.transpose Fin.zero i) (map f enumₜ′)) ≡⟨⟩ f x ∙ (f (from (to x)) ∙ _) ≈⟨ ∙-cong S.refl (∙-cong (cong func (from-to _)) S.refl) ⟩ f x ∙ (f x ∙ _) ≈⟨ S.sym (S.assoc _ _ _) ⟩ (f x ∙ f x) ∙ _ ≈⟨ ∙-cong (S.idem _) S.refl ⟩ f x ∙ _ ≈⟨ ∙-cong (cong func (sym (from-to _))) S.refl ⟩ f (from (to x)) ∙ _ ≡⟨⟩ sumₜ (permute (Perm.transpose Fin.zero i) (map f enumₜ′)) ≈⟨ S.sym (sumₜ-permute (map f enumₜ′) (Perm.transpose Fin.zero i)) ⟩ sumₜ (map f enumₜ′) ∎ where f = ap func i = to x open EqReasoning S.setoid private enumₜ-complete′′ : ∀ {N} (ontoFin′ : OntoFin N) (f : setoid ⟶ S.setoid) x → (f ⟨$⟩ x) ∙ sumₜ (Table.map (f ⟨$⟩_) (enumₜAt ontoFin′)) ≈′ sumₜ (Table.map (f ⟨$⟩_) (enumₜAt ontoFin′)) enumₜ-complete′′ ontoFin′ f x with inhabited (LeftInverse.to ontoFin′ ⟨$⟩ x) enumₜ-complete′′ ontoFin′ f x | n , ≡.refl = enumₜ-complete′ ontoFin′ f x sum/map-hom : ∀ {n} {a}{A : Set a} (f : A → S) (t : Table A n) → sumₗ (List.map f (toList t)) ≡ sumₜ (map f t) sum/map-hom f t = begin sumₗ (List.map f (toList t)) ≡⟨ ≡.cong sumₗ (Table.map-toList-hom t) ⟩ sumₗ (toList (map f t)) ≡⟨ ≡.sym (sumₜ-toList (map f t)) ⟩ sumₜ (map f t) ∎ where open ≡.Reasoning -- Enumeration is complete: in any idempotent commutative monoid, adding one -- more element to the sum won't change it. In particular, this works in the -- powerset monoid, where 'f' is the singleton at its argument and addition -- is set union. This shows that every member of 'A' is present in the -- enumeration (even though the powerset monoid is quite difficult to -- implement in Agda so this proof is not present). enumₜ-complete : ∀ f x → (f ⟨$⟩ x) ∙ foldMap (f ⟨$⟩_) ≈′ foldMap (f ⟨$⟩_) enumₜ-complete = enumₜ-complete′′ ontoFin enumₗ-complete : ∀ (f : setoid ⟶ S.setoid) x → (f ⟨$⟩ x) ∙ sumₗ (List.map (f ⟨$⟩_) enumₗ) ≈′ sumₗ (List.map (f ⟨$⟩_) enumₗ) enumₗ-complete func x = begin f x ∙ sumₗ (List.map f enumₗ) ≡⟨⟩ f x ∙ sumₗ (List.map f (toList enumₜ)) ≡⟨ ≡.cong₂ _∙_ ≡.refl (sum/map-hom f enumₜ) ⟩ f x ∙ sumₜ (map f enumₜ) ≈⟨ enumₜ-complete func x ⟩ sumₜ (map f enumₜ) ≡⟨ ≡.sym (sum/map-hom f enumₜ) ⟩ sumₗ (List.map f enumₗ) ∎ where f = func ⟨$⟩_ open EqReasoning S.setoid -- A finite set can be strictly totally ordered by its elements' indices Ixorder : B.StrictTotalOrder _ _ _ Ixorder = record { _≈_ = _≈_ ; _<_ = λ x y → toIx x Fin.< toIx y ; isStrictTotalOrder = record { isEquivalence = isEquivalence ; trans = Fin.<-trans ; compare = compare } } where compare : Trichotomous _≈_ (λ x y → toIx x Fin.< toIx y) compare x y with B.StrictTotalOrder.compare (Fin.<-strictTotalOrder N) (toIx x) (toIx y) compare x y | B.tri< a ¬b ¬c = B.tri< a (¬b ∘ cong (LeftInverse.to ontoFin)) ¬c compare x y | B.tri≈ ¬a b ¬c = B.tri≈ ¬a (LeftInverse.injective ontoFin b) ¬c compare x y | B.tri> ¬a ¬b c = B.tri> ¬a (¬b ∘ cong (LeftInverse.to ontoFin)) c -- Equality between members of a finite set is decidable. _≟_ : B.Decidable _≈_ _≟_ = B.StrictTotalOrder._≟_ Ixorder
{ "alphanum_fraction": 0.5506853952, "avg_line_length": 40.1972789116, "ext": "agda", "hexsha": "12908a9a77f51da4c388fe1ad04eb6c12f577e22", "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/Finite/Properties.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/Finite/Properties.agda", "max_line_length": 151, "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/Finite/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2139, "size": 5909 }
open import Common.Prelude hiding (_>>=_) open import Common.Reflection open import Common.Equality module Issue2782 where module Interval where private data I' : Set where Izero' : I' Ione' : I' I : Set I = I' Izero : I Izero = Izero' Ione : I Ione = Ione' {-- postulate Iseg : Izero ≡ Ione --} -- Fails when run with --safe flag in command-line unquoteDecl Iseg = declarePostulate (vArg Iseg) (def (quote _≡_) (vArg (def (quote Izero) []) ∷ vArg (def (quote Ione) []) ∷ [])) open Interval public pf : Izero ≡ Ione pf = Iseg
{ "alphanum_fraction": 0.6230636833, "avg_line_length": 16.6, "ext": "agda", "hexsha": "1382c208a5db00a07191f649c4e8f331e43814e7", "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/Issue2782.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/Issue2782.agda", "max_line_length": 131, "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/Issue2782.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 197, "size": 581 }
open import Agda.Builtin.Reflection using (Name) -- See Tactic.Nat for a description of the various tactics. module Tactic.Nat.Generic (`≤ `toLeq `fromLeq : Name) where open import Prelude open import Tactic.Reflection open import Tactic.Nat.Induction using (nat-induction) open import Tactic.Nat.Subtract using (autosub-tactic; by-tactic; refutesub-tactic; simplifygoal-tactic; simplifysub-tactic) private a→0 : Type → Term a→0 (def op _) = ifYes op == `≤ then def₀ `toLeq else def₀ (quote id) a→0 _ = def₀ (quote id) -- TODO perhaps return unknown? 0→a : Type → Term 0→a (def op _) = ifYes op == `≤ then def₀ `fromLeq else def₀ (quote id) 0→a _ = def₀ (quote id) -- TODO perhaps return unknown? applyTactic : (Type → TC Term) → Term → TC ⊤ applyTactic tac hole = do goal ← inferType hole unify hole ∘ (0→a goal `$_) =<< tac =<< inferNormalisedType (a→0 goal `$ hole) macro auto : Tactic auto hole = applyTactic autosub-tactic hole by : Term → Tactic by prf hole = do Prf ← inferNormalisedType prf applyTactic (by-tactic (a→0 Prf `$ prf)) hole refute : Term → Tactic refute prf hole = do Prf ← inferNormalisedType prf unify hole =<< refutesub-tactic (a→0 Prf `$ prf) simplify-goal : Tactic simplify-goal hole = do goal ← inferFunRange hole s-goal₀ ← simplifygoal-tactic =<< inferFunRange (a→0 goal `∘ hole) hole =′ 0→a goal `∘ s-goal₀ `∘ a→0 goal simplify : Term → Tactic simplify prf hole = do goal ← inferFunRange hole Prf ← inferNormalisedType prf s-goal₀ ← simplifysub-tactic (a→0 Prf `$ prf) =<< inferFunRange (a→0 goal `∘ hole) hole =′ (`λ $ 0→a goal `$ weaken 1 s-goal₀ `$ `λ $ a→0 goal `$ var₁ 1 (0→a Prf `$ var₀ 0)) induction : Tactic induction hole = do pi _ (abs _ goal) ← inferNormalisedType hole where meta x _ → blockOnMeta x _ → typeErrorS "Induction tactic must be applied to a function goal" hole₀ ← (a→0 goal `∘ hole) :′ unknown pi a b ← inferNormalisedType hole₀ where meta x _ → blockOnMeta x _ → typeErrorS "Induction tactic must be applied to a function goal" let P = lam visible b inStepCxt : {A : Set} → TC A → TC A inStepCxt {_} = λ′ (vArg (quoteTerm Nat)) ∘ λ′ (vArg unknown) base ← unknown :′ unknown step ← inStepCxt $ unknown :′ unknown hole =′ 0→a goal `∘ def₃ (quote nat-induction) P base (`λ $ `λ step) unify base =<< autosub-tactic =<< inferNormalisedType base inStepCxt (unify step =<< by-tactic (var₀ 0) =<< inferNormalisedType step)
{ "alphanum_fraction": 0.634469697, "avg_line_length": 36.1643835616, "ext": "agda", "hexsha": "410637d378dd66d4a359a8dbe0ca52cea87ba5e1", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Tactic/Nat/Generic.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Tactic/Nat/Generic.agda", "max_line_length": 124, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Tactic/Nat/Generic.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 864, "size": 2640 }
module Issue550 where data Box (A : Set) : Set where [_] : A → Box A postulate A : Set B : Set b : B f : B -> A ⋯ : {{a : A}} → A ⋯ {{a = a}} = a test : Box A test = let a : A a = f b in [ ⋯ ] -- should succeed. Old message: -- No variable of type A was found in scope. -- when checking that the expression ⋯ has type A
{ "alphanum_fraction": 0.5375722543, "avg_line_length": 14.4166666667, "ext": "agda", "hexsha": "086898c8e72bf37ea218ea5419400979a4d6229c", "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/succeed/Issue550.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/Issue550.agda", "max_line_length": 49, "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/Issue550.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": 131, "size": 346 }
{-# OPTIONS --without-K #-} open import Base open import HLevel module Homotopy.Extensions.ToPropToConstSet {i} {A B : Set i} ⦃ B-is-set : is-set B ⦄ (f : A → B) (f-is-const : ∀ a₁ a₂ → f a₁ ≡ f a₂) where open import Homotopy.Truncation open import Homotopy.Skeleton private skel : Set i skel = π₀ (skeleton₁ f) abstract skel-has-all-paths : has-all-paths skel skel-has-all-paths = π₀-extend ⦃ λ _ → Π-is-set λ _ → ≡-is-set $ π₀-is-set _ ⦄ (skeleton₁-rec (λ s₁ → ∀ s₂ → proj s₁ ≡ s₂) (λ a₁ → π₀-extend ⦃ λ _ → ≡-is-set $ π₀-is-set _ ⦄ (skeleton₁-rec (λ s₂ → proj (point a₁) ≡ proj s₂) (λ a₂ → ap proj $ link a₁ a₂ $ f-is-const a₁ a₂) (λ _ _ _ → prop-has-all-paths (π₀-is-set _ _ _) _ _))) (λ _ _ _ → funext λ _ → prop-has-all-paths (π₀-is-set _ _ _) _ _)) skel-is-prop : is-prop skel skel-is-prop = all-paths-is-prop skel-has-all-paths cst-extend : [ A ] → B cst-extend = π₀-extend-nondep ⦃ B-is-set ⦄ skeleton₁-lifted ◯ []-extend-nondep ⦃ skel-is-prop ⦄ (proj ◯ point)
{ "alphanum_fraction": 0.5574354408, "avg_line_length": 33.0294117647, "ext": "agda", "hexsha": "078738bc799da772183f340caa1b4beeb27e7a73", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Homotopy/Extensions/ToPropToConstSet.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Homotopy/Extensions/ToPropToConstSet.agda", "max_line_length": 78, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/Homotopy/Extensions/ToPropToConstSet.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 423, "size": 1123 }
-- The ATP pragma with the role <axiom> can be used with postulates. module ATPAxiomPostulates where postulate D : Set zero : D succ : D → D N : D → Set postulate zN : N zero sN : ∀ {n} → N n → N (succ n) {-# ATP axiom zN #-}
{ "alphanum_fraction": 0.5910931174, "avg_line_length": 16.4666666667, "ext": "agda", "hexsha": "91d37a6cd38de17a60920aa4c27abae685668fff", "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": "examples/ATPAxiomPostulates.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": "examples/ATPAxiomPostulates.agda", "max_line_length": 68, "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": "examples/ATPAxiomPostulates.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": 89, "size": 247 }
{-# OPTIONS --without-K --safe #-} module Tools.List where open import Data.List public using (List; []; _∷_) module L where open import Data.List public
{ "alphanum_fraction": 0.6918238994, "avg_line_length": 17.6666666667, "ext": "agda", "hexsha": "fc72eae94dc6292c2ac6392f5603d1e6448e5944", "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": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Tools/List.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "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": "Vtec234/logrel-mltt", "max_issues_repo_path": "Tools/List.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Tools/List.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 39, "size": 159 }
------------------------------------------------------------------------------ -- Conversion rules for the greatest common divisor ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.GCD.Partial.ConversionRulesATP where open import FOTC.Base open import FOTC.Base.Loop open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities open import FOTC.Program.GCD.Partial.GCD ------------------------------------------------------------------------------ -- NB. These conversion rules are not used by the ATPs. They use the -- official equation. private postulate gcd-00 : gcd zero zero ≡ error {-# ATP prove gcd-00 #-} postulate gcd-S0 : ∀ n → gcd (succ₁ n) zero ≡ succ₁ n {-# ATP prove gcd-S0 #-} postulate gcd-0S : ∀ n → gcd zero (succ₁ n) ≡ succ₁ n {-# ATP prove gcd-0S #-} postulate gcd-S>S : ∀ m n → succ₁ m > succ₁ n → gcd (succ₁ m) (succ₁ n) ≡ gcd (succ₁ m ∸ succ₁ n) (succ₁ n) {-# ATP prove gcd-S>S #-} postulate gcd-S≯S : ∀ m n → succ₁ m ≯ succ₁ n → gcd (succ₁ m) (succ₁ n) ≡ gcd (succ₁ m) (succ₁ n ∸ succ₁ m) {-# ATP prove gcd-S≯S #-}
{ "alphanum_fraction": 0.500753012, "avg_line_length": 33.2, "ext": "agda", "hexsha": "d5680333ce2d3099817885a6316368384232d675", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Program/GCD/Partial/ConversionRulesATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Program/GCD/Partial/ConversionRulesATP.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/Program/GCD/Partial/ConversionRulesATP.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": 353, "size": 1328 }
-- Andreas, 2019-06-25, issue #3855 reported by nad -- Constraint solver needs to respect erasure. open import Agda.Builtin.Bool module _ where record RB (b : Bool) : Set where bPar : Bool bPar = b myBPar : (@0 b : Bool) → RB b → Bool myBPar b r = RB.bPar {b = {!b!}} r -- should be rejected
{ "alphanum_fraction": 0.6194968553, "avg_line_length": 22.7142857143, "ext": "agda", "hexsha": "17986b682540426934a7f4fd077d58e1a36408f9", "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/Issue3855c.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/Issue3855c.agda", "max_line_length": 66, "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/Issue3855c.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": 105, "size": 318 }
{-# OPTIONS --cubical #-} module Type.Cubical.Quotient where open import Functional import Lvl open import Structure.Type.Identity open import Type.Cubical open import Type.Cubical.Path.Equality open import Type open import Syntax.Function private variable ℓ ℓₗ : Lvl.Level private variable T A B : Type{ℓ} private variable x y : T private variable P : T → Type{ℓ} private variable _▫_ : T → T → Type{ℓ} data Quotient(_▫_ : T → T → Type{ℓ}) : Type{Lvl.of(T) Lvl.⊔ ℓ} where class : T → Quotient(_▫_) class-extensionalityₗ : (class x ≡ class y) ← (x ▫ y) open import Type.Cubical.Path open import Type.Cubical.Univalence open import Type.Properties.MereProposition open import Structure.Relator.Equivalence open import Structure.Relator.Properties module _ (P : Quotient(_▫_) → Type{ℓ}) ⦃ prop-P : ∀{c} → MereProposition(P(c)) ⦄ where Quotient-property-pathP : ∀{x y}{px : P(x)}{py : P(y)} → (xy : x ≡ y) → PathP(\i → P(xy i)) px py Quotient-property-pathP {x}{y}{px}{py} xy = IdentityEliminator.elim Path-identity-eliminator (xy ↦ (∀{px}{py} → PathP(\i → P(xy i)) px py)) (\{c} → uniqueness(P(c))) {x}{y} xy {px}{py} class-property : (∀{a} → P(class a)) → (∀{c} → P(c)) class-property p {class a} = p{a} class-property p {class-extensionalityₗ {x} {y} xy i} = Quotient-property-pathP {px = p{x}}{py = p{y}} (class-extensionalityₗ xy) i -- TODO: Use Structuve.Function.Surjective when it is generalized to support Type.Cubical.Logic.∃. The difference is that Type.Cubical.Logic.∃ is a mere propositions while surjective uses existence defined as Σ which is not open import Type.Cubical.Logic class-surjective : ∀{y} → ∃(x ↦ class{_▫_ = _▫_} x ≡ y) class-surjective{_▫_ = _▫_} = class-property(y ↦ ∃(x ↦ class{_▫_ = _▫_} x ≡ y)) (\{a} → [∃]-intro a ⦃ reflexivity(_≡_) ⦄) -- Note: The following holds by definition: ∀{P : (A → B) → Type{ℓ}}{f}{p} → P(f) → P(Quotient-recursion f p ∘ class). Quotient-recursion : (f : A → B) → (∀{a b} → (a ▫ b) → (f(a) ≡ f(b))) → (Quotient(_▫_) → B) Quotient-recursion f _ (class x) = f(x) Quotient-recursion _ p (class-extensionalityₗ xy i) = p xy i module _ where open import Structure.Function open import Structure.Setoid Quotient-function : ∀{ℓₑ₁ ℓₑ₂}{equiv-A : Equiv{ℓₑ₁}(A)}{equiv-B : Equiv{ℓₑ₂}(B)} ⦃ sub : (Equiv._≡_ equiv-B) ⊆₂ Path ⦄ (f : A → B) ⦃ func : Function ⦃ equiv-A ⦄ ⦃ equiv-B ⦄ f ⦄ → (Quotient(Equiv._≡_ equiv-A) → B) Quotient-function {equiv-B = equiv-B} f(x) = Quotient-recursion f (sub₂(Equiv._≡_ equiv-B)(Path) ∘ congruence₁ ⦃ _ ⦄ ⦃ _ ⦄ (f)) x module _ ⦃ equivalence : Equivalence(_▫_) ⦄ ⦃ prop : ∀{x y} → MereProposition(x ▫ y) ⦄ where class-extensionalityᵣ : (class{_▫_ = _▫_} x ≡ class y) → (x ▫ y) class-extensionalityᵣ {x = x} {y = y} p = sub₂(_≡_)(_→ᶠ_) ⦃ Path-coercion ⦄ xx-xy (reflexivity(_▫_)) where xx-xy : (x ▫ x) ≡ (x ▫ y) xx-xy i = Quotient-recursion (x ▫_) (\ab → propositional-extensionalityₗ ([↔]-intro (swap(transitivity(_▫_)) (symmetry(_▫_) ab)) (swap(transitivity(_▫_)) ab))) (p i) class-extensionality : (class{_▫_ = _▫_} x ≡ class y) ↔ (x ▫ y) class-extensionality = [↔]-intro class-extensionalityₗ class-extensionalityᵣ module Syntax where _/_ : (T : Type{ℓ}) → (T → T → Type{ℓₗ}) → Type _ / (_▫_) = Quotient(_▫_) [_] : T → (T / (_▫_)) [_] = class
{ "alphanum_fraction": 0.6431610942, "avg_line_length": 47.6811594203, "ext": "agda", "hexsha": "cd8507c679a8eaf33a98d55c05bdefbf4e82e5dc", "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/Quotient.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/Quotient.agda", "max_line_length": 223, "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/Quotient.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": 1293, "size": 3290 }
-- Solver for Category {-# OPTIONS --without-K --safe #-} open import Categories.Category module Experiment.Categories.AnotherSolver.Category {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Relation.Binary using (Rel) import Function.Base as Fun open import Categories.Functor renaming (id to idF) open import Categories.NaturalTransformation renaming (id to idN) import Categories.Morphism.Reasoning as MR import Categories.Category.Equivalence as Eq open Category 𝒞 open HomReasoning open MR 𝒞 private variable A B C D E : Obj infixr 9 _:∘_ data Expr : Rel Obj (o ⊔ ℓ) where :id : Expr A A _:∘_ : Expr B C → Expr A B → Expr A C ∥_∥ : A ⇒ B → Expr A B data NExpr : Rel Obj (o ⊔ ℓ) where :id : NExpr A A _:∘_ : B ⇒ C → NExpr A B → NExpr A C -- Semantics ⟦_⟧ : Expr A B → A ⇒ B ⟦ :id ⟧ = id ⟦ e₁ :∘ e₂ ⟧ = ⟦ e₁ ⟧ ∘ ⟦ e₂ ⟧ ⟦ ∥ f ∥ ⟧ = f ⟦_⟧N : NExpr A B → A ⇒ B ⟦ :id ⟧N = id ⟦ f :∘ e ⟧N = f ∘ ⟦ e ⟧N _∘N_ : NExpr B C → NExpr A B → NExpr A C :id ∘N e₂ = e₂ (f :∘ e₁) ∘N e₂ = f :∘ (e₁ ∘N e₂) linear : NExpr A B → Expr A B linear :id = :id linear (f :∘ e) = ∥ f ∥ :∘ linear e normalise : Expr A B → NExpr A B normalise :id = :id normalise (e₁ :∘ e₂) = normalise e₁ ∘N normalise e₂ normalise ∥ f ∥ = f :∘ :id ∘N-homo : (e₁ : NExpr B C) (e₂ : NExpr A B) → ⟦ e₁ ∘N e₂ ⟧N ≈ ⟦ e₁ ⟧N ∘ ⟦ e₂ ⟧N ∘N-homo :id e₂ = sym identityˡ ∘N-homo (f :∘ e₁) e₂ = pushʳ (∘N-homo e₁ e₂) NExpr-assoc : {f : NExpr A B} {g : NExpr B C} {h : NExpr C D} → ⟦ (h ∘N g) ∘N f ⟧N ≈ ⟦ h ∘N (g ∘N f) ⟧N NExpr-assoc {f = f} {g} {:id} = refl NExpr-assoc {f = f} {g} {x :∘ h} = ∘-resp-≈ʳ (NExpr-assoc {f = f} {g} {h}) NExpr-identityʳ : {f : NExpr A B} → ⟦ f ∘N :id ⟧N ≈ ⟦ f ⟧N NExpr-identityʳ {f = :id} = refl NExpr-identityʳ {f = x :∘ f} = ∘-resp-≈ʳ (NExpr-identityʳ {f = f}) normalise-correct : (e : Expr A B) → ⟦ normalise e ⟧N ≈ ⟦ e ⟧ normalise-correct :id = refl normalise-correct (e₁ :∘ e₂) = begin ⟦ normalise e₁ ∘N normalise e₂ ⟧N ≈⟨ ∘N-homo (normalise e₁) (normalise e₂) ⟩ ⟦ normalise e₁ ⟧N ∘ ⟦ normalise e₂ ⟧N ≈⟨ normalise-correct e₁ ⟩∘⟨ normalise-correct e₂ ⟩ ⟦ e₁ ⟧ ∘ ⟦ e₂ ⟧ ∎ normalise-correct ∥ f ∥ = identityʳ normalise-cong : (e₁ e₂ : Expr A B) → ⟦ e₁ ⟧ ≈ ⟦ e₂ ⟧ → ⟦ normalise e₁ ⟧N ≈ ⟦ normalise e₂ ⟧N normalise-cong e₁ e₂ eq = trans (normalise-correct e₁) (trans eq (sym (normalise-correct e₂))) normalise-inj : (e₁ e₂ : Expr A B) → ⟦ normalise e₁ ⟧N ≈ ⟦ normalise e₂ ⟧N → ⟦ e₁ ⟧ ≈ ⟦ e₂ ⟧ normalise-inj e₁ e₂ eq = trans (sym (normalise-correct e₁)) (trans eq (normalise-correct e₂)) linear-correct : (e : NExpr A B) → ⟦ linear e ⟧ ≈ ⟦ e ⟧N linear-correct :id = refl linear-correct (f :∘ e) = ∘-resp-≈ʳ (linear-correct e) Expr-category : Category o (o ⊔ ℓ) e Expr-category = categoryHelper record { Obj = Obj ; _⇒_ = Expr ; _≈_ = λ e₁ e₂ → ⟦ e₁ ⟧ ≈ ⟦ e₂ ⟧ ; id = :id ; _∘_ = _:∘_ ; assoc = assoc ; identityˡ = identityˡ ; identityʳ = identityʳ ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≈ = ∘-resp-≈ } NExpr-category : Category o (o ⊔ ℓ) e NExpr-category = categoryHelper record { Obj = Obj ; _⇒_ = NExpr ; _≈_ = λ e₁ e₂ → ⟦ e₁ ⟧N ≈ ⟦ e₂ ⟧N ; id = :id ; _∘_ = _∘N_ ; assoc = λ {_} {_} {_} {_} {f = f} {g} {h} → NExpr-assoc {f = f} {g} {h} ; identityˡ = refl ; identityʳ = λ {_} {_} {f = f} → NExpr-identityʳ {f = f} ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≈ = λ {_} {_} {_} {f} {h} {g} {i} f≈h g≈i → trans (∘N-homo f g) (trans (∘-resp-≈ f≈h g≈i) (sym (∘N-homo h i))) } ⟦⟧-functor : Functor Expr-category 𝒞 ⟦⟧-functor = record { F₀ = Fun.id ; F₁ = ⟦_⟧ ; identity = refl ; homomorphism = refl ; F-resp-≈ = Fun.id } ⟦⟧N-functor : Functor NExpr-category 𝒞 ⟦⟧N-functor = record { F₀ = Fun.id ; F₁ = ⟦_⟧N ; identity = refl ; homomorphism = λ {_} {_} {_} {f} {g} → ∘N-homo g f ; F-resp-≈ = Fun.id } normalise-functor : Functor Expr-category NExpr-category normalise-functor = record { F₀ = Fun.id ; F₁ = normalise ; identity = refl ; homomorphism = λ {_} {_} {_} {f = f} {g} → refl ; F-resp-≈ = λ {_} {_} {f} {g} f≈g → normalise-cong f g f≈g } linear-functor : Functor NExpr-category Expr-category linear-functor = record { F₀ = Fun.id ; F₁ = linear ; identity = refl ; homomorphism = λ {_} {_} {_} {f} {g} → begin ⟦ linear (g ∘N f) ⟧ ≈⟨ linear-correct (g ∘N f) ⟩ ⟦ g ∘N f ⟧N ≈⟨ ∘N-homo g f ⟩ ⟦ g ⟧N ∘ ⟦ f ⟧N ≈⟨ sym (linear-correct g) ⟩∘⟨ sym (linear-correct f) ⟩ ⟦ linear g ⟧ ∘ ⟦ linear f ⟧ ∎ ; F-resp-≈ = λ {_} {_} {f} {g} eq → begin ⟦ linear f ⟧ ≈⟨ linear-correct f ⟩ ⟦ f ⟧N ≈⟨ eq ⟩ ⟦ g ⟧N ≈⟨ sym (linear-correct g) ⟩ ⟦ linear g ⟧ ∎ } normalise-functor-Faithful : Faithful normalise-functor normalise-functor-Faithful = normalise-inj linear-functor-Faithful : Faithful linear-functor linear-functor-Faithful = λ f g x → trans (sym (linear-correct f)) (trans x (linear-correct g)) ⟦⟧n-functor : Functor Expr-category 𝒞 ⟦⟧n-functor = ⟦⟧N-functor ∘F normalise-functor ⟦⟧l-functor : Functor NExpr-category 𝒞 ⟦⟧l-functor = ⟦⟧-functor ∘F linear-functor normalise-natural : NaturalTransformation ⟦⟧n-functor ⟦⟧-functor normalise-natural = ntHelper record { η = λ X → id ; commute = λ e → begin id ∘ ⟦ normalise e ⟧N ≈⟨ identityˡ ⟩ ⟦ normalise e ⟧N ≈⟨ normalise-correct e ⟩ ⟦ e ⟧ ≈⟨ sym identityʳ ⟩ ⟦ e ⟧ ∘ id ∎ } linear-natural : NaturalTransformation ⟦⟧l-functor ⟦⟧N-functor linear-natural = ntHelper record { η = λ X → id ; commute = λ e → trans identityˡ (trans (linear-correct e) (sym identityʳ)) } embedExpr : Functor 𝒞 Expr-category embedExpr = record { F₀ = Fun.id ; F₁ = ∥_∥ ; identity = refl ; homomorphism = refl ; F-resp-≈ = Fun.id } embedNExpr : Functor 𝒞 NExpr-category embedNExpr = record { F₀ = Fun.id ; F₁ = λ e → e :∘ :id ; identity = identity² ; homomorphism = λ {_} {_} {_} {f} {g} → assoc ; F-resp-≈ = λ f≈g → trans identityʳ (trans f≈g (sym identityʳ)) } {- solve : (e₁ e₂ : Expr A B) → ⟦ e₁ ⟧N ≈ ⟦ e₂ ⟧N → ⟦ e₁ ⟧ ≈ ⟦ e₂ ⟧ solve e₁ e₂ eq = begin ⟦ e₁ ⟧ ≈˘⟨ ⟦e⟧N≈⟦e⟧ e₁ ⟩ ⟦ e₁ ⟧N ≈⟨ eq ⟩ ⟦ e₂ ⟧N ≈⟨ ⟦e⟧N≈⟦e⟧ e₂ ⟩ ⟦ e₂ ⟧ ∎ ∥-∥ : ∀ {f : A ⇒ B} → Expr A B ∥-∥ {f = f} = ∥ f ∥ -}
{ "alphanum_fraction": 0.5285884455, "avg_line_length": 28.9482758621, "ext": "agda", "hexsha": "4c4f967ce9039b13e4b7fa5b9b83fc2dd5aae94c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Experiment/Categories/AnotherSolver/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Experiment/Categories/AnotherSolver/Category.agda", "max_line_length": 95, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Experiment/Categories/AnotherSolver/Category.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 2986, "size": 6716 }
module Luau.TypeNormalization where open import Luau.Type using (Type; nil; number; string; boolean; never; unknown; _⇒_; _∪_; _∩_) -- Operations on normalized types _∪ᶠ_ : Type → Type → Type _∪ⁿˢ_ : Type → Type → Type _∩ⁿˢ_ : Type → Type → Type _∪ⁿ_ : Type → Type → Type _∩ⁿ_ : Type → Type → Type -- Union of function types (F₁ ∩ F₂) ∪ᶠ G = (F₁ ∪ᶠ G) ∩ (F₂ ∪ᶠ G) F ∪ᶠ (G₁ ∩ G₂) = (F ∪ᶠ G₁) ∩ (F ∪ᶠ G₂) (R ⇒ S) ∪ᶠ (T ⇒ U) = (R ∩ⁿ T) ⇒ (S ∪ⁿ U) F ∪ᶠ G = F ∪ G -- Union of normalized types S ∪ⁿ (T₁ ∪ T₂) = (S ∪ⁿ T₁) ∪ T₂ S ∪ⁿ unknown = unknown S ∪ⁿ never = S never ∪ⁿ T = T unknown ∪ⁿ T = unknown (S₁ ∪ S₂) ∪ⁿ G = (S₁ ∪ⁿ G) ∪ S₂ F ∪ⁿ G = F ∪ᶠ G -- Intersection of normalized types S ∩ⁿ (T₁ ∪ T₂) = (S ∩ⁿ T₁) ∪ⁿˢ (S ∩ⁿˢ T₂) S ∩ⁿ unknown = S S ∩ⁿ never = never (S₁ ∪ S₂) ∩ⁿ G = (S₁ ∩ⁿ G) unknown ∩ⁿ G = G never ∩ⁿ G = never F ∩ⁿ G = F ∩ G -- Intersection of normalized types with a scalar (S₁ ∪ nil) ∩ⁿˢ nil = nil (S₁ ∪ boolean) ∩ⁿˢ boolean = boolean (S₁ ∪ number) ∩ⁿˢ number = number (S₁ ∪ string) ∩ⁿˢ string = string (S₁ ∪ S₂) ∩ⁿˢ T = S₁ ∩ⁿˢ T unknown ∩ⁿˢ T = T F ∩ⁿˢ T = never -- Union of normalized types with an optional scalar S ∪ⁿˢ never = S unknown ∪ⁿˢ T = unknown (S₁ ∪ nil) ∪ⁿˢ nil = S₁ ∪ nil (S₁ ∪ boolean) ∪ⁿˢ boolean = S₁ ∪ boolean (S₁ ∪ number) ∪ⁿˢ number = S₁ ∪ number (S₁ ∪ string) ∪ⁿˢ string = S₁ ∪ string (S₁ ∪ S₂) ∪ⁿˢ T = (S₁ ∪ⁿˢ T) ∪ S₂ F ∪ⁿˢ T = F ∪ T -- Normalize! normalize : Type → Type normalize nil = never ∪ nil normalize (S ⇒ T) = (normalize S ⇒ normalize T) normalize never = never normalize unknown = unknown normalize boolean = never ∪ boolean normalize number = never ∪ number normalize string = never ∪ string normalize (S ∪ T) = normalize S ∪ⁿ normalize T normalize (S ∩ T) = normalize S ∩ⁿ normalize T
{ "alphanum_fraction": 0.6125143513, "avg_line_length": 26.3939393939, "ext": "agda", "hexsha": "08f144742a1ed4da8690cd01fed88505839f775b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "39fbd2146a379fb0878369b48764cd7e8772c0fb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "sthagen/Roblox-luau", "max_forks_repo_path": "prototyping/Luau/TypeNormalization.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "39fbd2146a379fb0878369b48764cd7e8772c0fb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "sthagen/Roblox-luau", "max_issues_repo_path": "prototyping/Luau/TypeNormalization.agda", "max_line_length": 95, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f1b46f4b967f11fabe666da1de0e71b225368260", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Libertus-Lab/luau", "max_stars_repo_path": "prototyping/Luau/TypeNormalization.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-06T08:03:00.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-06T08:03:00.000Z", "num_tokens": 846, "size": 1742 }
-- Andreas, 2013-10-21 -- There was a bug in Rules/Builtin such that NATEQUALS' equations -- would be checked at type Nat instead of Bool. -- This bug surfaced only because of today's refactoring in Conversion, -- because then I got a strange unsolved constraint true == true : Nat. module NatEquals where import Common.Level data Bool : Set where true false : Bool {-# BUILTIN BOOL Bool #-} {-# BUILTIN TRUE true #-} {-# BUILTIN FALSE false #-} data Nat : Set where zero : Nat suc : Nat -> Nat {-# BUILTIN NATURAL Nat #-} infix 40 _=?=_ _=?=_ : Nat -> Nat -> Bool zero =?= zero = true zero =?= suc _ = false suc _ =?= zero = false suc n =?= suc m = n =?= m {-# BUILTIN NATEQUALS _=?=_ #-}
{ "alphanum_fraction": 0.6433566434, "avg_line_length": 21.6666666667, "ext": "agda", "hexsha": "8cd05c271dcf1bbb6fa5a45e079b6c06f8babc66", "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/NatEquals.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/NatEquals.agda", "max_line_length": 72, "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/NatEquals.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": 210, "size": 715 }
{-# OPTIONS --cubical --safe #-} module Data.List.Sugar where open import Data.List.Base open import Prelude [_] : A → List A [ x ] = x ∷ [] pure : A → List A pure = [_] _>>=_ : List A → (A → List B) → List B _>>=_ = flip concatMap _>>_ : List A → List B → List B xs >> ys = xs >>= const ys _<*>_ : List (A → B) → List A → List B fs <*> xs = do f ← fs x ← xs [ f x ] guard : Bool → List ⊤ guard false = [] guard true = [ tt ]
{ "alphanum_fraction": 0.5306122449, "avg_line_length": 15.2068965517, "ext": "agda", "hexsha": "d040ea0250e3795a6b16e2d9ea7b09969760e37c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Data/List/Sugar.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Data/List/Sugar.agda", "max_line_length": 38, "max_stars_count": 4, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Data/List/Sugar.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "num_tokens": 157, "size": 441 }
{-# OPTIONS --cubical --safe --postfix-projections #-} module Data.Dyck.Payload where open import Prelude open import Data.Nat using (_+_) open import Data.Vec.Iterated using (Vec; _∷_; []; foldlN; head) private variable n : ℕ -------------------------------------------------------------------------------- -- Binary trees: definition and associated functions -------------------------------------------------------------------------------- infixl 6 _*_ data Tree (A : Type a) : Type a where [_] : A → Tree A _*_ : Tree A → Tree A → Tree A -------------------------------------------------------------------------------- -- Dyckrams: definition and associated functions -------------------------------------------------------------------------------- infixr 5 ⟨_!_ ⟩_ data Dyck (A : Type a) : ℕ → Type a where ⟩⋆ : Dyck A 1 ⟨_!_ : A → Dyck A (1 + n) → Dyck A n ⟩_ : Dyck A (1 + n) → Dyck A (2 + n) -------------------------------------------------------------------------------- -- Conversion from a Dyck to a Tree -------------------------------------------------------------------------------- dyck→tree⊙ : Dyck A n → Vec (Tree A) n → Tree A dyck→tree⊙ ⟩⋆ (v ∷ []) = v dyck→tree⊙ (⟨ v ! is) st = dyck→tree⊙ is ([ v ] ∷ st) dyck→tree⊙ (⟩ is) (t₁ ∷ t₂ ∷ st) = dyck→tree⊙ is (t₂ * t₁ ∷ st) dyck→tree : Dyck A zero → Tree A dyck→tree ds = dyck→tree⊙ ds [] -------------------------------------------------------------------------------- -- Conversion from a Tree to a Dyck -------------------------------------------------------------------------------- tree→dyck⊙ : Tree A → Dyck A (suc n) → Dyck A n tree→dyck⊙ [ x ] = ⟨ x !_ tree→dyck⊙ (xs * ys) = tree→dyck⊙ xs ∘ tree→dyck⊙ ys ∘ ⟩_ tree→dyck : Tree A → Dyck A zero tree→dyck tr = tree→dyck⊙ tr ⟩⋆ -------------------------------------------------------------------------------- -- Proof of isomorphism -------------------------------------------------------------------------------- tree→dyck→tree⊙ : {is : Dyck A (1 + n)} {st : Vec (Tree A) n} (e : Tree A) → dyck→tree⊙ (tree→dyck⊙ e is) st ≡ dyck→tree⊙ is (e ∷ st) tree→dyck→tree⊙ [ x ] = refl tree→dyck→tree⊙ (xs * ys) = tree→dyck→tree⊙ xs ; tree→dyck→tree⊙ ys dyck→tree→dyck⊙ : {st : Vec (Tree A) n} (is : Dyck A n) → tree→dyck (dyck→tree⊙ is st) ≡ foldlN (Dyck A) tree→dyck⊙ is st dyck→tree→dyck⊙ ⟩⋆ = refl dyck→tree→dyck⊙ (⟨ v ! is) = dyck→tree→dyck⊙ is dyck→tree→dyck⊙ (⟩ is) = dyck→tree→dyck⊙ is dyck-iso : Dyck A zero ⇔ Tree A dyck-iso .fun = dyck→tree dyck-iso .inv = tree→dyck dyck-iso .rightInv = tree→dyck→tree⊙ dyck-iso .leftInv = dyck→tree→dyck⊙ _ : tree→dyck (([ 1 ] * ([ 2 ] * [ 3 ])) * [ 4 ]) ≡ ⟨ 1 ! ⟨ 2 ! ⟨ 3 ! ⟩ ⟩ ⟨ 4 ! ⟩ ⟩⋆ _ = refl
{ "alphanum_fraction": 0.4037063953, "avg_line_length": 35.2820512821, "ext": "agda", "hexsha": "7143d12c6d12a561ba17c8548ebc90141b2061ff", "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/Dyck/Payload.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/Dyck/Payload.agda", "max_line_length": 84, "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/Dyck/Payload.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": 934, "size": 2752 }
-- Andreas, 2019-11-08, issue #4154 reported by Yashmine Sharoda. -- Warn if a `renaming` clause clashes with an exported name -- (that is not mentioned in a `using` clause). module _ where module M where postulate A B : Set -- These produce warnings (#4154): module N = M renaming (A to B) open M renaming (A to B) -- These produce errors (see also #3057) -- as they produce ambiguous exports: Test = B TestN = N.B module L = M using (B) renaming (A to B)
{ "alphanum_fraction": 0.685106383, "avg_line_length": 20.4347826087, "ext": "agda", "hexsha": "2d509ae4c2b98538f78c813693d6cac5cfdc9006", "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/Issue4154.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/Issue4154.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/Fail/Issue4154.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": 137, "size": 470 }
{-# OPTIONS --safe #-} module Issue2442-postulate where postulate A : Set
{ "alphanum_fraction": 0.6708860759, "avg_line_length": 9.875, "ext": "agda", "hexsha": "dc1037f8af33f940d9bb721a224ab9caa073d193", "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/Issue2442-postulate.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/Issue2442-postulate.agda", "max_line_length": 32, "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/Issue2442-postulate.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 21, "size": 79 }
{-# OPTIONS --without-K #-} module FT-Nat where open import Data.Empty open import Data.Unit open import Data.Nat renaming (_⊔_ to _⊔ℕ_) open import Data.Sum renaming (map to _⊎→_) open import Data.Product import Data.Fin as F open import Data.Vec import Data.List as L open import Function renaming (_∘_ to _○_) open import FT open import SimpleHoTT using (refl; pathInd; _≡_; ap) open import Equivalences open import TypeEquivalences using (path⊎) open import Path2Equiv open import LeftCancellation ------------------------------------------------------------------ -- Finite Types and the natural numbers are intimately related. -- -- Basically, this is because both of them are models of -- unital semirings, and the natural numbers are the initial object -- in the category of unital semirings. In this case, things are -- deeper still, and so we record many of these facts here. -- -- And, of course, as Pi records the proof-theory of semirings in -- a fairly explicit manner, we can use all this to link up -- normalization of natural-numbers expressions and Pi-based paths. toℕ : FT → ℕ toℕ ZERO = zero toℕ ONE = suc zero toℕ (PLUS b₀ b₁) = (toℕ b₀) + (toℕ b₁) toℕ (TIMES b₀ b₁) = (toℕ b₀) * (toℕ b₁) fromℕ : ℕ → FT fromℕ zero = ZERO fromℕ (suc n) = PLUS ONE (fromℕ n) toℕ∘fromℕ : toℕ ○ fromℕ ∼ id toℕ∘fromℕ zero = refl zero toℕ∘fromℕ (suc n) = pathInd (λ {x} {y} _ → suc x ≡ suc y) (λ m → refl (suc m)) (toℕ∘fromℕ n) assocr : {m : ℕ} (n : ℕ) → (PLUS (fromℕ n) (fromℕ m)) ⇛ fromℕ (n + m) assocr zero = unite₊⇛ assocr (suc n) = assocr₊⇛ ◎ (id⇛ ⊕ (assocr n)) distr : (n₀ : ℕ) {n₁ : ℕ} → TIMES (fromℕ n₀) (fromℕ n₁) ⇛ fromℕ (n₀ * n₁) distr zero = distz⇛ distr (suc n) {m} = dist⇛ ◎ (unite⋆⇛ ⊕ distr n) ◎ assocr m -- normalize a finite type to (1 + (1 + (1 + ... + (1 + 0) ... ))) -- a bunch of ones ending with zero with left biased + in between normalize : FT → FT normalize = fromℕ ○ toℕ normal : (b : FT) → b ⇛ normalize b normal ZERO = id⇛ normal ONE = uniti₊⇛ ◎ swap₊⇛ normal (PLUS b₀ b₁) = (normal b₀ ⊕ normal b₁) ◎ assocr (toℕ b₀) normal (TIMES b₀ b₁) = (normal b₀ ⊗ normal b₁) ◎ distr (toℕ b₀) normalizeC : {B : FT} → ⟦ normalize B ⟧ ≃ ⟦ B ⟧ normalizeC {B} = path2equiv (sym⇛ (normal B)) mapNorm : {B₁ B₂ : FT} → (⟦ B₁ ⟧ ≃ ⟦ B₂ ⟧) → ⟦ normalize B₁ ⟧ ≃ ⟦ normalize B₂ ⟧ mapNorm {B₁} {B₂} eq = trans≃ (trans≃ (normalizeC {B₁}) eq) (sym≃ (normalizeC {B₂})) ⟦_⟧ℕ : ℕ → Set ⟦ zero ⟧ℕ = ⊥ ⟦ suc n ⟧ℕ = ⊤ ⊎ ⟦ n ⟧ℕ ℕrespects⟦⟧ : {n : ℕ} → ⟦ fromℕ n ⟧ ≃ ⟦ n ⟧ℕ ℕrespects⟦⟧ {zero} = id≃ ℕrespects⟦⟧ {suc n} = path⊎ id≃ (ℕrespects⟦⟧ {n}) ------------------------------------------------------------------------------ -- Understanding the syntactic structure of pi combinators with respect -- to normalization data FTNF : Set where Z : FTNF S : FTNF → FTNF fromℕNF : ℕ → FTNF fromℕNF zero = Z fromℕNF (suc n) = S (fromℕNF n) normalizeNF : FT → FTNF normalizeNF = fromℕNF ○ toℕ data FTN : FT → Set where normalized : (b : FT) → FTN (normalize b) -- in both the following two functions we are missing fundamental information -- about how a type relates to its normal form... {-- normalize⇛ : {b₁ b₂ : FT} → (b₁ ⇛ b₂) → (normalize b₁ ⇛ normalize b₂) normalize⇛ unite₊⇛ = id⇛ normalize⇛ uniti₊⇛ = id⇛ normalize⇛ swap₊⇛ = {!!} normalize⇛ assocl₊⇛ = {!!} normalize⇛ assocr₊⇛ = {!!} normalize⇛ unite⋆⇛ = {!!} normalize⇛ uniti⋆⇛ = {!!} normalize⇛ swap⋆⇛ = {!!} normalize⇛ assocl⋆⇛ = {!!} normalize⇛ assocr⋆⇛ = {!!} normalize⇛ distz⇛ = id⇛ normalize⇛ factorz⇛ = id⇛ normalize⇛ dist⇛ = {!!} normalize⇛ factor⇛ = {!!} normalize⇛ id⇛ = id⇛ normalize⇛ (sym⇛ c) = sym⇛ (normalize⇛ c) normalize⇛ (c₁ ◎ c₂) = normalize⇛ c₁ ◎ normalize⇛ c₂ normalize⇛ (c ⊕ c₁) = {!!} normalize⇛ (c ⊗ c₁) = {!!} --} {-- swapii+1 : {b : FT} → (i : ℕ) → (b ⇛ b) swapii+1 {PLUS ONE (PLUS ONE b)} 0 = (assocl₊⇛ {ONE} {ONE} {b}) ◎ (swap₊⇛ ⊕ id⇛) ◎ (assocr₊⇛ {ONE} {ONE} {b}) swapii+1 {PLUS ONE b} (suc n) = id⇛ ⊕ swapii+1 n swapii+1 _ = {!!} --} ------------------------------------------------------------------------------ -- needs LeftCancellation liftℕ : (n₁ n₂ : ℕ) → ⟦ n₁ ⟧ℕ ≃ ⟦ n₂ ⟧ℕ → (fromℕ n₁) ≡ (fromℕ n₂) liftℕ zero zero eq = refl ZERO liftℕ zero (suc n₂) (_ , mkisequiv g α h β) with h (inj₁ tt) liftℕ zero (suc n₂) (_ , mkisequiv g α h β) | () liftℕ (suc n₁) zero (f , _) with f (inj₁ tt) liftℕ (suc n₁) zero (f , _) | () liftℕ (suc n₁) (suc n₂) eq = ap (λ x → PLUS ONE x) (liftℕ n₁ n₂ (left-cancel-⊤ eq)) liftNormal : {B₁ B₂ : FT} → ⟦ normalize B₁ ⟧ ≃ ⟦ normalize B₂ ⟧ → (normalize B₁) ≡ (normalize B₂) liftNormal {B₁} {B₂} eq = liftℕ (toℕ B₁) (toℕ B₂) (⟦ toℕ B₁ ⟧ℕ ≃⟨ sym≃ (ℕrespects⟦⟧ {toℕ B₁}) ⟩ ⟦ normalize B₁ ⟧ ≃⟨ eq ⟩ ⟦ normalize B₂ ⟧ ≃⟨ ℕrespects⟦⟧ {toℕ B₂} ⟩ id≃) sameNorm : {B₁ B₂ : FT} → (⟦ B₁ ⟧ ≃ ⟦ B₂ ⟧) → (normalize B₁) ≡ (normalize B₂) sameNorm {B₁} {B₂} eq = liftNormal {B₁} {B₂} (mapNorm eq) bridge : {B₁ B₂ : FT} → (⟦ B₁ ⟧ ≃ ⟦ B₂ ⟧) → (normalize B₁) ⇛ (normalize B₂) bridge eq = pathInd (λ {B₃} {B₄} _ → B₃ ⇛ B₄) (λ _ → id⇛) (sameNorm eq) {-- Not used exf : ⊤ ⊎ ℕ → ℕ exf (inj₁ tt) = 0 exf (inj₂ n) = suc n exg : ℕ → ⊤ ⊎ ℕ exg 0 = inj₁ tt exg (suc n) = inj₂ n exα : exf ○ exg ∼ id exα 0 = refl 0 exα (suc n) = refl (suc n) exβ : exg ○ exf ∼ id exβ (inj₁ tt) = refl (inj₁ tt) exβ (inj₂ n) = refl (inj₂ n) ex : (⊤ ⊎ ℕ) ≃ ℕ ex = (exf , equiv₁ (mkqinv exg exα exβ)) exf2 : (⊤ ⊎ (⊤ ⊎ ℕ)) → (⊤ ⊎ ℕ) exf2 (inj₁ tt) = inj₂ 0 exf2 (inj₂ (inj₁ tt)) = inj₂ 1 exf2 (inj₂ (inj₂ 0)) = inj₁ tt exf2 (inj₂ (inj₂ (suc n))) = inj₂ (suc (suc n)) exg2 : (⊤ ⊎ ℕ) → (⊤ ⊎ (⊤ ⊎ ℕ)) exg2 (inj₁ tt) = inj₂ (inj₂ 0) exg2 (inj₂ 0) = inj₁ tt exg2 (inj₂ 1) = inj₂ (inj₁ tt) exg2 (inj₂ (suc (suc n))) = inj₂ (inj₂ (suc n)) exα2 : exf2 ○ exg2 ∼ id exα2 (inj₁ tt) = refl (inj₁ tt) exα2 (inj₂ 0) = refl (inj₂ 0) exα2 (inj₂ 1) = refl (inj₂ 1) exα2 (inj₂ (suc (suc n))) = refl (inj₂ (suc (suc n))) exβ2 : exg2 ○ exf2 ∼ id exβ2 (inj₁ tt) = refl (inj₁ tt) exβ2 (inj₂ (inj₁ tt)) = refl (inj₂ (inj₁ tt)) exβ2 (inj₂ (inj₂ 0)) = refl (inj₂ (inj₂ 0)) exβ2 (inj₂ (inj₂ (suc n))) = refl (inj₂ (inj₂ (suc n))) ex2 : (⊤ ⊎ (⊤ ⊎ ℕ)) ≃ (⊤ ⊎ ℕ) ex2 = (exf2 , equiv₁ (mkqinv exg2 exα2 exβ2)) --}
{ "alphanum_fraction": 0.5748941713, "avg_line_length": 28.7009345794, "ext": "agda", "hexsha": "9c71d8e01e6004ab7de88dd5482c1d57268294e6", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/OldUnivalence/FT-Nat.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/OldUnivalence/FT-Nat.agda", "max_line_length": 122, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/OldUnivalence/FT-Nat.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 2850, "size": 6142 }
-- Andreas, 2016-12-31, re issue #1976 -- Allow projection pattern disambiguation by parameters {-# OPTIONS --allow-unsolved-metas #-} postulate A B : Set module M (_ : Set) where record R : Set₂ where field F : Set₁ open R public module Succeeds where open M _ open M B test : M.R B F test = Set module ShouldFail where open M A open M _ test : M.R B F test = Set -- should fail module Fails where open M _ open M A test : M.R B F test = Set
{ "alphanum_fraction": 0.6323232323, "avg_line_length": 13.3783783784, "ext": "agda", "hexsha": "fe3ad412ee6a3fcdbe99a112d0d3211df7ea8857", "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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_path": "test/Fail/Issue1976-constraints.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "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": "pthariensflame/agda", "max_issues_repo_path": "test/Fail/Issue1976-constraints.agda", "max_line_length": 56, "max_stars_count": 3, "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_path": "test/Fail/Issue1976-constraints.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": 495 }
module 747Connectives where -- Library import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) open Eq.≡-Reasoning open import Data.Nat using (ℕ) open import Function using (_∘_) -- Copied from 747Isomorphism. postulate extensionality : ∀ {A B : Set} {f g : A → B} → (∀ (x : A) → f x ≡ g x) ----------------------- → f ≡ g infix 0 _≃_ record _≃_ (A B : Set) : Set where constructor mk-≃ -- This has been added, not in PLFA field to : A → B from : B → A from∘to : ∀ (x : A) → from (to x) ≡ x to∘from : ∀ (y : B) → to (from y) ≡ y open _≃_ infix 0 _≲_ record _≲_ (A B : Set) : Set where field to : A → B from : B → A from∘to : ∀ (x : A) → from (to x) ≡ x open _≲_ record _⇔_ (A B : Set) : Set where field to : A → B from : B → A open _⇔_ -- You may copy over the various reasoning modules if you wish. -- End of code from 747Isomorphism. -- Logical AND is Cartesian product. data _×_ (A : Set) (B : Set) : Set where ⟨_,_⟩ : A → B ----- → A × B -- Destructors (eliminators) for ×. proj₁ : ∀ {A B : Set} → A × B ----- → A proj₁ A×B = {!!} proj₂ : ∀ {A B : Set} → A × B ----- → B proj₂ A×B = {!!} -- An easier (equivalent) construction using records. record _×′_ (A B : Set) : Set where field proj₁′ : A proj₂′ : B open _×′_ -- Eta-equivalence relates constructors and destructors. η-× : ∀ {A B : Set} (w : A × B) → ⟨ proj₁ w , proj₂ w ⟩ ≡ w η-× A×B = {!!} -- Bool (Booleans), a type with exactly two members. infixr 2 _×_ data Bool : Set where true : Bool false : Bool -- A type with three members (useful for examples). data Tri : Set where aa : Tri bb : Tri cc : Tri -- Bool × Tri has six members. -- Here is a function counting them. ×-count : Bool × Tri → ℕ ×-count ⟨ true , aa ⟩ = 1 ×-count ⟨ true , bb ⟩ = 2 ×-count ⟨ true , cc ⟩ = 3 ×-count ⟨ false , aa ⟩ = 4 ×-count ⟨ false , bb ⟩ = 5 ×-count ⟨ false , cc ⟩ = 6 -- Cartesian product is commutative and associative up to isomorphism. ×-comm : ∀ {A B : Set} → A × B ≃ B × A ×-comm = {!!} ×-assoc : ∀ {A B C : Set} → (A × B) × C ≃ A × (B × C) ×-assoc = {!!} -- 747/PLFA exercise: IffIsoIfOnlyIf (1 point) -- Show A ⇔ B is isomorphic to (A → B) × (B → A). iff-iso-if-onlyif : ∀ {A B : Set} → A ⇔ B ≃ (A → B) × (B → A) iff-iso-if-onlyif = {!!} -- Logical True is a type with one member (unit) data ⊤ : Set where tt : -- ⊤ η-⊤ : ∀ (w : ⊤) → tt ≡ w η-⊤ w = {!!} ⊤-count : ⊤ → ℕ ⊤-count tt = 1 -- Unit is the left and right identity of product. ⊤-identityˡ : ∀ {A : Set} → ⊤ × A ≃ A ⊤-identityˡ = {!!} ⊤-identityʳ : ∀ {A : Set} → (A × ⊤) ≃ A ⊤-identityʳ = {!!} -- Logical OR (disjunction) is sum (disjoint union). data _⊎_ : Set → Set → Set where inj₁ : ∀ {A B : Set} → A ----- → A ⊎ B inj₂ : ∀ {A B : Set} → B ----- → A ⊎ B -- One way to eliminate a sum. case-⊎ : ∀ {A B C : Set} → (A → C) → (B → C) → A ⊎ B ----------- → C case-⊎ f g s = {!!} -- We typically use pattern-matching to eliminate sums. -- Eta equivalence for sums. η-⊎ : ∀ {A B : Set} (w : A ⊎ B) → case-⊎ inj₁ inj₂ w ≡ w η-⊎ w = {!!} -- A generalization. uniq-⊎ : ∀ {A B C : Set} (h : A ⊎ B → C) (w : A ⊎ B) → case-⊎ (h ∘ inj₁) (h ∘ inj₂) w ≡ h w uniq-⊎ h w = {!!} infix 1 _⊎_ -- Bool ⊎ Tri has five members ⊎-count : Bool ⊎ Tri → ℕ ⊎-count (inj₁ true) = 1 ⊎-count (inj₁ false) = 2 ⊎-count (inj₂ aa) = 3 ⊎-count (inj₂ bb) = 4 ⊎-count (inj₂ cc) = 5 -- 747/PLFA exercise: SumCommIso (1 point) -- Sum is commutative up to isomorphism. ⊎-comm : ∀ {A B : Set} → A ⊎ B ≃ B ⊎ A ⊎-comm = {!!} -- 747/PLFA exercise: SumAssocIso (1 point) -- Sum is associative up to isomorphism. ⊎-assoc : ∀ {A B C : Set} → (A ⊎ B) ⊎ C ≃ A ⊎ (B ⊎ C) ⊎-assoc = {!!} -- Logical False is the empty type ("bottom", "empty"). data ⊥ : Set where -- no clauses! -- Ex falso quodlibet "from falsehood, anything follows". ⊥-elim : ∀ {A : Set} → ⊥ -- → A ⊥-elim w = {!!} uniq-⊥ : ∀ {C : Set} (h : ⊥ → C) (w : ⊥) → ⊥-elim w ≡ h w uniq-⊥ h w = {!!} ⊥-count : ⊥ → ℕ ⊥-count w = {!!} -- 747/PLFA exercise: EmptyLeftIdSumIso (1 point) -- Empty is the left unit of sum up to isomorphism. ⊎-identityˡ : ∀ {A : Set} → ⊥ ⊎ A ≃ A ⊎-identityˡ = {!!} -- 747/PLFA exercise: EmptyRightIdSumIso (1 point) -- Empty is the right unit of sum up to isomorphism. ⊎-identityʳ : ∀ {A : Set} → A ⊎ ⊥ ≃ A ⊎-identityʳ = {!!} -- Logical implication (if-then) is... the function type constructor! -- Eliminating an if-then (modus ponens) is function application. →-elim : ∀ {A B : Set} → (A → B) → A ------- → B →-elim L M = L M -- This works because eta-reduction for → is built in. η-→ : ∀ {A B : Set} (f : A → B) → (λ (x : A) → f x) ≡ f η-→ f = refl -- The function space A → B is sometimes called the exponential Bᴬ. -- Bool → Tri has 3² or 9 members. →-count : (Bool → Tri) → ℕ →-count f with f true | f false ... | aa | aa = 1 ... | aa | bb = 2 ... | aa | cc = 3 ... | bb | aa = 4 ... | bb | bb = 5 ... | bb | cc = 6 ... | cc | aa = 7 ... | cc | bb = 8 ... | cc | cc = 9 -- In math, (p ^ n) ^ m = p ^ (n * m). -- For types, (A ^ B) ^ C ≃ A ^ (B × C). -- In a language where functions take multiple parameters, -- this is called "currying". currying : ∀ {A B C : Set} → (A → B → C) ≃ (A × B → C) currying = {!!} -- In math, p ^ (n + m) = (p ^ n) * (p ^ m). -- For types, (A ⊎ B → C) ≃ ((A → C) × (B → C)). →-distrib-⊎ : ∀ {A B C : Set} → (A ⊎ B → C) ≃ ((A → C) × (B → C)) →-distrib-⊎ = {!!} -- In math, (p * n) ^ m = (p ^ m) * (n ^ m). -- For types, (A → B × C) ≃ (A → B) × (A → C). →-distrib-× : ∀ {A B C : Set} → (A → B × C) ≃ (A → B) × (A → C) →-distrib-× = {!!} -- More distributive laws. ×-distrib-⊎ : ∀ {A B C : Set} → (A ⊎ B) × C ≃ (A × C) ⊎ (B × C) ×-distrib-⊎ = {!!} ⊎-distrib-× : ∀ {A B C : Set} → (A × B) ⊎ C ≲ (A ⊎ C) × (B ⊎ C) ⊎-distrib-× = {!!} -- Think of a counterexample to show the above isn't an isomorphism. -- 747/PLFA exercise: ImpProdRightDist (1 point) ×-distrib-→ : ∀ {A B C : Set} → (C → (A × B)) ≃ (C → A) × (C → B) ×-distrib-→ = {!!} -- 747/PLFA exercise: ImpSumLeftDist (1 point) ⊎-distrib-→ : ∀ {A B C : Set} → ((A ⊎ B) → C) ≃ (A → C) × (B → C) ⊎-distrib-→ = {!!} -- PLFA exercise: a weak distributive law. -- ⊎-weak-× : ∀ {A B C : Set} → (A ⊎ B) × C → A ⊎ (B × C) -- ⊎-weak-× A⊎B×C = {!!} -- State and prove the strong law, and explain the relationship. -- 747/PLFA exercise: SumOfProdImpProdOfSum (1 point) -- A disjunct of conjuncts implies a conjunct of disjuncts. ⊎×-implies-×⊎ : ∀ {A B C D : Set} → (A × B) ⊎ (C × D) → (A ⊎ C) × (B ⊎ D) ⊎×-implies-×⊎ A×B⊎C×D = {!!} -- PLFA exercise: Is the converse true? If so, prove it; if not, give a counterexample. -- See PLFA for a number of slight differences with the standard library. -- Unicode introduced in this chapter: {- × U+00D7 MULTIPLICATION SIGN (\x) ⊎ U+228E MULTISET UNION (\u+) ⊤ U+22A4 DOWN TACK (\top) ⊥ U+22A5 UP TACK (\bot) η U+03B7 GREEK SMALL LETTER ETA (\eta) ₁ U+2081 SUBSCRIPT ONE (\_1) ₂ U+2082 SUBSCRIPT TWO (\_2) ⇔ U+21D4 LEFT RIGHT DOUBLE ARROW (\<=>, \iff, \lr=) -}
{ "alphanum_fraction": 0.5000674673, "avg_line_length": 21.7970588235, "ext": "agda", "hexsha": "b489f113cc9a952fcef86c8c1a652257f344c93b", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x06-747Connectives.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x06-747Connectives.agda", "max_line_length": 87, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x06-747Connectives.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": 3076, "size": 7411 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.DunceCap.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.GroupoidLaws open import Cubical.HITs.S1 using (S¹; base) import Cubical.HITs.S1 as S¹ open import Cubical.HITs.MappingCones -- definition of the dunce cap as a HIT data Dunce : Type₀ where base : Dunce loop : base ≡ base surf : PathP (λ i → loop i ≡ loop i) loop refl -- definition of the dunce cap as a mapping cone dunceMap : S¹ → S¹ dunceMap base = base dunceMap (S¹.loop i) = (S¹.loop ⁻¹ ∙∙ S¹.loop ∙∙ S¹.loop) i DunceCone : Type₀ DunceCone = Cone dunceMap
{ "alphanum_fraction": 0.71561051, "avg_line_length": 23.1071428571, "ext": "agda", "hexsha": "6d2057fbea7d779a13ed30a8fdc7727ad2a00f46", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/HITs/DunceCap/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/HITs/DunceCap/Base.agda", "max_line_length": 59, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/DunceCap/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 221, "size": 647 }
module agda where open import IO main = run (putStrLn "Fuck You Github")
{ "alphanum_fraction": 0.7432432432, "avg_line_length": 14.8, "ext": "agda", "hexsha": "8852717c36da4a5874141b44fd751422b63c4509", "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": "8c37d0f6be3dbe37d8ff5d9bf22ad997527331dc", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ozcanyarimdunya/FuckYouGithub", "max_forks_repo_path": "a/agda.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8c37d0f6be3dbe37d8ff5d9bf22ad997527331dc", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ozcanyarimdunya/FuckYouGithub", "max_issues_repo_path": "a/agda.agda", "max_line_length": 39, "max_stars_count": null, "max_stars_repo_head_hexsha": "8c37d0f6be3dbe37d8ff5d9bf22ad997527331dc", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ozcanyarimdunya/FuckYouGithub", "max_stars_repo_path": "a/agda.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 20, "size": 74 }
module MLib.Fin.Parts.Nat.Simple where open import MLib.Prelude open import MLib.Fin.Parts.Core open import MLib.Fin.Parts.Nat open Nat using (_*_; _+_; _<_) open Fin using (toℕ; fromℕ≤) open Table repl : ∀ n → ℕ → Table ℕ n repl _ = replicate -- abstract -- TODO: why does this break reduction later? sum-replicate-* : ∀ m n → sum (repl m n) ≡ m * n sum-replicate-* zero _ = ≡.refl sum-replicate-* (suc m) _ = ≡.cong₂ _+_ ≡.refl (sum-replicate-* m _) fromParts : ∀ a b → ℕ × ℕ → ℕ fromParts a b = Partsℕ.fromParts (constParts a b) fromParts³′ : ∀ a b c → ℕ × ℕ × ℕ → ℕ fromParts³′ a b c (i , j , k) = fromParts a (b * c) (i , fromParts b c (j , k)) fromParts³ : ∀ a b c → ℕ × ℕ × ℕ → ℕ fromParts³ a b c (i , j , k) = fromParts (a * b) c (fromParts a b (i , j) , k) open ≡.Reasoning abstract fromParts′-a-irrel : ∀ a k b i j → i < a → j < b → fromParts a b (i , j) ≡ fromParts (a + k) b (i , j) fromParts′-a-irrel a k b zero j p q = ≡.refl fromParts′-a-irrel (suc a) k b (suc i) j (Nat.s≤s p) q = ≡.cong₂ _+_ ≡.refl (fromParts′-a-irrel a k b i j p q) fromParts′-0 : ∀ a b i → i < a → fromParts a b (i , 0) ≡ i * b fromParts′-0 zero b i () fromParts′-0 (suc a) b zero (Nat.s≤s p) = ≡.refl fromParts′-0 (suc a) b (suc i) (Nat.s≤s p) = ≡.cong₂ _+_ ≡.refl (fromParts′-0 a b i p) lem′ : ∀ m a b i j → (m * b) + fromParts a b (i , j) ≡ fromParts (m + a) b (m + i , j) lem′ zero a b i j = ≡.refl lem′ (suc m) a b i j = begin b + m * b + fromParts a b (i , j) ≡⟨ Nat.+-assoc b _ _ ⟩ b + (m * b + fromParts a b (i , j)) ≡⟨ ≡.cong₂ _+_ ≡.refl (lem′ m a b i j) ⟩ b + fromParts (m + a) b (m + i , j) ∎ lem : ∀ a b c i k → i < a → fromParts a (b * c) (i , k) ≡ fromParts (a * b) c (i * b , k) lem zero b c i k () lem (suc a) b c zero k p = ≡.refl lem (suc a) b c (suc i) k (Nat.s≤s p) = begin (b * c) + fromParts a (b * c) (i , k) ≡⟨ ≡.cong₂ _+_ ≡.refl (lem a b c i k p) ⟩ (b * c) + fromParts (a * b) c (i * b , k) ≡⟨ lem′ b (a * b) c (i * b) k ⟩ fromParts (suc a * b) c (suc i * b , k) ∎ fromParts-assoc : ∀ {a b c} i j k → i < a → j < b → k < c → fromParts³′ a b c (i , j , k) ≡ fromParts³ a b c (i , j , k) fromParts-assoc {a} {b} {c} zero zero k p q r = ≡.refl fromParts-assoc {suc a} {suc b} {c} zero (suc j) k (Nat.s≤s p) (Nat.s≤s q) r = begin fromParts³′ (suc a) (suc b) c (0 , suc j , k) ≡⟨⟩ fromParts (suc b) c (suc j , k) ≡⟨⟩ c + fromParts b c (j , k) ≡⟨ ≡.cong₂ _+_ ≡.refl (fromParts′-a-irrel b (a * suc b) c j k q r) ⟩ c + fromParts (b + a * suc b) c (j , k) ≡⟨⟩ fromParts (suc (b + a * suc b)) c (suc j , k) ≡⟨⟩ fromParts (suc a * suc b) c (suc j , k) ≡⟨⟩ fromParts³ (suc a) (suc b) c (0 , suc j , k) ∎ fromParts-assoc {zero} {b} {c} (suc i) j k () q r fromParts-assoc {suc a} {b} {c} (suc i) zero k (Nat.s≤s p) q r = begin fromParts³′ (suc a) b c (suc i , 0 , k) ≡⟨⟩ fromParts (suc a) (b * c) (suc i , k) ≡⟨ lem (suc a) b c (suc i) k (Nat.s≤s p) ⟩ fromParts (suc a * b) c (suc i * b , k) ≡⟨ ≡.cong (λ h → fromParts (suc a * b) c (b + h , k)) (≡.sym (fromParts′-0 a b i p)) ⟩ fromParts (suc a * b) c (b + fromParts a b (i , 0) , k) ≡⟨⟩ fromParts (suc a * b) c (fromParts (suc a) b (suc i , 0) , k) ≡⟨⟩ fromParts³ (suc a) b c (suc i , 0 , k) ∎ fromParts-assoc {suc a} {zero} {c} (suc i) (suc j) k p () r fromParts-assoc {suc a} {suc b} {c} (suc i) (suc j) k (Nat.s≤s p) q r = let sb = suc b sj = suc j in begin fromParts³′ (suc a) sb c (suc i , sj , k) ≡⟨⟩ fromParts (suc a) (sb * c) (suc i , fromParts sb c (sj , k)) ≡⟨⟩ sb * c + fromParts a (sb * c) (i , c + fromParts b c (j , k)) ≡⟨⟩ sb * c + fromParts³′ a sb c (i , sj , k) ≡⟨ ≡.cong₂ _+_ ≡.refl (fromParts-assoc i sj k p q r) ⟩ sb * c + fromParts³ a sb c (i , sj , k) ≡⟨⟩ sb * c + fromParts (a * sb) c (fromParts a sb (i , sj) , k) ≡⟨ Nat.+-assoc c _ _ ⟩ c + (b * c + fromParts (a * sb) c (fromParts a sb (i , sj) , k)) ≡⟨ ≡.cong₂ _+_ ≡.refl (lem′ b (a * sb) c _ k) ⟩ c + fromParts (b + a * sb) c (b + fromParts a sb (i , sj) , k) ≡⟨⟩ fromParts (suc a * sb) c (fromParts (suc a) sb (suc i , sj) , k) ≡⟨⟩ fromParts³ (suc a) sb c (suc i , sj , k) ∎ abstract toParts-1ˡ : ∀ {b} i → i < b → Partsℕ.toParts (constParts 1 b) i ≡ (0 , i) toParts-1ˡ {b} i p with Impl.compare′ i b toParts-1ˡ {.(suc (i + k))} i p | Impl.less .i k = ≡.refl toParts-1ˡ {.m} .(m + k) p | Impl.gte m k = ⊥-elim (Nat.m+n≮m m k p) toParts-1ʳ : ∀ {a} i → i < a → Partsℕ.toParts (constParts a 1) i ≡ (i , 0) toParts-1ʳ {zero} _ () toParts-1ʳ {suc a} zero p = ≡.refl toParts-1ʳ {suc a} (suc i) (Nat.s≤s p) with Σ.≡⇒≡×≡ (toParts-1ʳ {a} i p) toParts-1ʳ {suc a} (suc i) (Nat.s≤s p) | q , r with Impl.compare′ i 0 toParts-1ʳ {suc a} (suc i) (Nat.s≤s p) | q , r | Impl.gte .0 .i = Σ.≡×≡⇒≡ (≡.cong suc q , r)
{ "alphanum_fraction": 0.4903846154, "avg_line_length": 47.1851851852, "ext": "agda", "hexsha": "ca99a91aaf0c4107c8411afe1cc01ed30e6c6c55", "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/Fin/Parts/Nat/Simple.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/Fin/Parts/Nat/Simple.agda", "max_line_length": 132, "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/Fin/Parts/Nat/Simple.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2426, "size": 5096 }
module RandomAccessList.Zeroless.Core where open import BuildingBlock.BinaryLeafTree using (BinaryLeafTree; Node; Leaf) open import Data.Nat open import Data.Nat.Etc -- parameterized by the level of the least significant digit data 1-2-RAL (A : Set) : ℕ → Set where [] : ∀ {n} → 1-2-RAL A n _1∷_ : ∀ {n} → BinaryLeafTree A n → 1-2-RAL A (suc n) → 1-2-RAL A n _,_2∷_ : ∀ {n} → BinaryLeafTree A n → BinaryLeafTree A n → 1-2-RAL A (suc n) → 1-2-RAL A n infixr 2 _1∷_ infixr 2 _,_2∷_ -------------------------------------------------------------------------------- -- to ℕ ⟦_⟧ₙ : ∀ {A n} → 1-2-RAL A n → ℕ ⟦ [] ⟧ₙ = 0 ⟦ x 1∷ xs ⟧ₙ = 1 + 2 * ⟦ xs ⟧ₙ ⟦ x , y 2∷ xs ⟧ₙ = 2 + 2 * ⟦ xs ⟧ₙ ⟦_⟧ : ∀ {n A} → 1-2-RAL A n → ℕ ⟦_⟧ {n} xs = 2 ^ n * ⟦ xs ⟧ₙ
{ "alphanum_fraction": 0.4512761021, "avg_line_length": 33.1538461538, "ext": "agda", "hexsha": "651759fcb3188d8d090c676c2d1ea0e878d69ab6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "legacy/RandomAccessList/Zeroless/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "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": "banacorn/numeral", "max_issues_repo_path": "legacy/RandomAccessList/Zeroless/Core.agda", "max_line_length": 94, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "legacy/RandomAccessList/Zeroless/Core.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 346, "size": 862 }
------------------------------------------------------------------------ -- Second-order abstract syntax -- -- Formalisation of second-order abstract syntax with variable binding. ------------------------------------------------------------------------ module Everything where -- Public exports of modules and definitions used throughout the library. import SOAS.Common -- Abstract categorical definitions of carrier categories with extra structure, -- and associated free constructions. import SOAS.Construction.Free import SOAS.Construction.Structure -- Skew monoidal and closed structure import SOAS.Construction.Skew.SkewClosed -- Add sorting to categories, and prove that various categorical -- structure (CCC, monoidal, etc.) are preserved. import SOAS.Sorting -- Definition of simple contexts as lists of sorts. import SOAS.Context -- The sorted family of variables and generalised context maps import SOAS.Variable -- | Context maps as renamings, substitutions and category morphisms -- Context map combinators import SOAS.ContextMaps.Combinators -- Category of contexts and renamings import SOAS.ContextMaps.CategoryOfRenamings -- Inductive context maps import SOAS.ContextMaps.Inductive -- Common properties of context maps import SOAS.ContextMaps.Properties -- | Families -- Definition of the category of sorted families import SOAS.Families.Core -- Isomorphism between sorted families import SOAS.Families.Isomorphism -- Bi-Cartesian closed and linear monoidal closed structure of families import SOAS.Families.BCCC import SOAS.Families.Linear -- Context extension endofunctor import SOAS.Families.Delta -- Inductive construction of families import SOAS.Families.Build -- | Abstract constructions -- Box modality import SOAS.Abstract.Box -- □-coalgebra on families - renaming structure import SOAS.Abstract.Coalgebra -- Internal hom of families import SOAS.Abstract.Hom -- Closed monoid in families - substitution structure import SOAS.Abstract.Monoid -- Exponential strength import SOAS.Abstract.ExpStrength -- | Constructions built upon coalgebras -- Coalgebraic maps 𝒳 ⇾ 〖𝒫 , 𝒴〗 import SOAS.Coalgebraic.Map -- Lifting and strength import SOAS.Coalgebraic.Lift import SOAS.Coalgebraic.Strength -- Monoids compatible with coalgebra structure import SOAS.Coalgebraic.Monoid -- | Metatheory for a second-order binding signature -- Binding algebras import SOAS.Metatheory.Algebra -- Algebras with variables and metavariables import SOAS.Metatheory.MetaAlgebra -- Signature monoids import SOAS.Metatheory.Monoid -- Initial-algebra semantics import SOAS.Metatheory.Semantics -- Parametrised interpretations import SOAS.Metatheory.Traversal -- Renaming structure by initiality import SOAS.Metatheory.Renaming -- Coalgebraic maps by initiality import SOAS.Metatheory.Coalgebraic -- Substitution structure by initiality import SOAS.Metatheory.Substitution -- Free monoid structure import SOAS.Metatheory.FreeMonoid -- Syntactic structure import SOAS.Metatheory.Syntax -- | Second-order structure -- Metasubstitution import SOAS.Metatheory.SecondOrder.Metasubstitution -- Unit of metasubstitution import SOAS.Metatheory.SecondOrder.Unit -- Equational theory import SOAS.Metatheory.SecondOrder.Equality -- | Term syntax of a second-order signature -- Argument representation import SOAS.Syntax.Arguments -- Second-order binding signature import SOAS.Syntax.Signature -- Shorthand notation import SOAS.Syntax.Shorthands -- Signature construction import SOAS.Syntax.Build -- First-order term syntax import SOAS.Syntax.Term
{ "alphanum_fraction": 0.7736797988, "avg_line_length": 22.9423076923, "ext": "agda", "hexsha": "2ca6df4bad4dfeb0943950bfa1fa4ee525712473", "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": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "k4rtik/agda-soas", "max_forks_repo_path": "Everything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "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": "k4rtik/agda-soas", "max_issues_repo_path": "Everything.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "k4rtik/agda-soas", "max_stars_repo_path": "Everything.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 823, "size": 3579 }
open import Coinduction using ( ∞ ; ♭ ; ♯_ ) open import Data.Empty using ( ⊥ ) open import Data.Bool using ( Bool ; true ; false ; if_then_else_ ) open import Data.Product using ( ∃ ; _×_ ; _,_ ; ,_ ) open import Data.Strict using ( Strict ; ! ) open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ ) open import Data.Unit using ( ⊤ ; tt ) open import System.IO.Transducers.Session using ( Session ; I ; Σ ; _∼_ ; ∼-sym ; Γ ; _/_ ; IsΣ ; IsΣ-≡ ; ⟨_⟩ ; _&_ ; ¿ ; _+_ ) renaming ( unit₁ to ∼-unit₁ ; unit₂ to ∼-unit₂ ; assoc to ∼-assoc ) open import System.IO.Transducers.Trace using ( _≤_ ; _⊑_ ; Trace ; [] ; _∷_ ) open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ) open import Relation.Nullary using ( Dec ; yes ; no ) module System.IO.Transducers.Lazy where -- S ⇛ T is the type of transducers whose inputs -- are traces through S, and whose output are traces through T. -- Note that input is coinductive, but output is inductive, -- which guarantees that transducers will map finite traces -- to finite traces. -- The name transducer comes from automata theory -- these -- are essentially I/O automata, or strategies in a two-player -- game without the move alternation restriction. -- In this module, we give definitions for lazy transducers, -- there is a separate module for stict transducers. infixr 4 _⇒_ _≃_ _≲_ infixr 6 _⟫_ infixr 8 _[&]_ _⟨&⟩_ _⟨+⟩_ _⟨¿⟩_ -- Lazy transducers, which may perform output before input. data _⇒_ : (S T : Session) → Set₁ where inp : ∀ {T A V F} → ∞ ((a : A) → (♭ F a ⇒ T)) → (Σ V F ⇒ T) out : ∀ {S B W G} → (b : B) → (S ⇒ ♭ G b) → (S ⇒ Σ W G) done : ∀ {S} → (S ⇒ S) -- Semantically, we only need done at type I, -- we have it at all types just for efficiency. data _⤇_ : (S T : Session) → Set₁ where inp : ∀ {T A V F} → ∞ ((a : A) → (♭ F a ⤇ T)) → (Σ V F ⤇ T) out : ∀ {S B W G} → (b : B) → (S ⤇ ♭ G b) → (S ⤇ Σ W G) done : (I ⤇ I) ι : ∀ {S T} → (S ⤇ T) → (S ⇒ T) ι (inp P) = inp (♯ λ a → ι (♭ P a)) ι (out b P) = out b (ι P) ι done = done ι⁻¹ : ∀ {S T} → (S ⇒ T) → (S ⤇ T) ι⁻¹ (inp P) = inp (♯ λ a → ι⁻¹ (♭ P a)) ι⁻¹ (out b P) = out b (ι⁻¹ P) ι⁻¹ (done {I}) = done ι⁻¹ (done {Σ V F}) = inp (♯ λ a → out a (ι⁻¹ done)) -- Helper functions to build transducers in terms of Γ and _/_ out' : ∀ {S T} b → (S ⇒ T / b) → (S ⇒ T) out' {S} {I} () P out' {S} {Σ W G} b P = out b P -- Helper function to output a whole trace. out* : ∀ {S T U} → (T ≤ U) → (S ⇒ T) → (S ⇒ U) out* [] P = P out* (b ∷ bs) P = out* bs (out' b P) -- Semantics as a function from partial traces to partial traces ⟦_⟧ : ∀ {S T} → (S ⇒ T) → (Trace S) → (Trace T) ⟦ inp P ⟧ [] = [] ⟦ inp P ⟧ (a ∷ as) = ⟦ ♭ P a ⟧ as ⟦ out b P ⟧ as = b ∷ ⟦ P ⟧ as ⟦ done ⟧ as = as -- Extensional equivalence on trace functions _≃_ : ∀ {S T} → (f g : Trace S → Trace T) → Set f ≃ g = ∀ as → f as ≡ g as -- Improvement order on trace functions _≲_ : ∀ {S T} → (f g : Trace S → Trace T) → Set₁ f ≲ g = ∀ as → f as ⊑ g as -- Equivalent sessions give rise to a transducer equiv : ∀ {S T} → (S ∼ T) → (S ⇒ T) equiv I = done equiv (Σ V F) = inp (♯ λ a → out a (equiv (♭ F a))) -- Transducers form a category with composition given by -- parallel (data flow) composition. This is defined by the -- usual expansion laws for parallel composition, together with -- the unit law for done. Since composition is deterministic, -- we prioritize output over input. _⟫_ : ∀ {S T U} → (S ⇒ T) → (T ⇒ U) → (S ⇒ U) done ⟫ Q = Q P ⟫ done = P P ⟫ out b Q = out b (P ⟫ Q) out b P ⟫ inp Q = P ⟫ ♭ Q b inp P ⟫ Q = inp (♯ λ a → ♭ P a ⟫ Q) -- The category has monoidal structure given by &, with -- action on morphisms: _[&]_ : ∀ {S T U V} → (S ⇒ T) → (U ⇒ V) → ((S & U) ⇒ (T & V)) inp {I} P [&] out c Q = out c (inp P [&] Q) inp P [&] Q = inp (♯ λ a → ♭ P a [&] Q) out b P [&] Q = out b (P [&] Q) done {I} [&] Q = Q done {Σ V F} [&] Q = inp (♯ λ a → out a (done {♭ F a} [&] Q)) -- Units for & unit₁ : ∀ {S} → (I & S) ⇒ S unit₁ = equiv ∼-unit₁ unit₁⁻¹ : ∀ {S} → S ⇒ (I & S) unit₁⁻¹ = equiv (∼-sym ∼-unit₁) unit₂ : ∀ {S} → (S & I) ⇒ S unit₂ = equiv ∼-unit₂ unit₂⁻¹ : ∀ {S} → S ⇒ (S & I) unit₂⁻¹ = equiv (∼-sym ∼-unit₂) -- Associativity of & assoc : ∀ {S T U} → (S & (T & U)) ⇒ ((S & T) & U) assoc {S} = equiv (∼-assoc {S}) assoc⁻¹ : ∀ {S T U} → ((S & T) & U) ⇒ (S & (T & U)) assoc⁻¹ {S} = equiv (∼-sym (∼-assoc {S})) -- Projections discard : ∀ {S} → (S ⇒ I) discard {I} = done discard {Σ V F} = inp (♯ λ a → discard) π₁ : ∀ {S T} → (S & T ⇒ S) π₁ {I} = discard π₁ {Σ V F} = inp (♯ λ a → out a π₁) π₂ : ∀ {S T} → (S & T ⇒ T) π₂ {I} = done π₂ {Σ V F} = inp (♯ λ a → π₂ {♭ F a}) -- The category is almost cartesian, at the cost of -- buffering. WARNING. BUFFERING. This is bad. Do not do this. -- The "almost" is due to a failure of the projection properties: -- P ⟨&⟩ Q ⟫ π₂ is not equivalent to Q, since Q may do output immediately, -- and P ⟨&⟩ Q ⟫ π₂ can only output after it has consumed all its input. -- Similarly π₁ ⟨&⟩ π₂ is not equivalent to done, as π₂'s output will -- be bufferred. -- This implementation uses output buffering, hopefully output -- is usually smaller than input. buffer : ∀ {S T U V} → (S ⇒ T) → (S ⇒ U) → (U ≤ V) → (S ⇒ T & V) buffer (inp P) (inp Q) cs = inp (♯ λ a → buffer (♭ P a) (♭ Q a) cs) buffer (inp P) (out c Q) cs = buffer (inp P) Q (c ∷ cs) buffer (inp P) done cs = inp (♯ λ c → buffer (♭ P c) done (c ∷ cs)) buffer (out b P) Q cs = out b (buffer P Q cs) buffer (done {I}) Q cs = out* cs Q buffer (done {Σ V F}) (inp Q) cs = inp (♯ λ a → out a (buffer done (♭ Q a) cs)) buffer (done {Σ V F}) (out c Q) cs = buffer done Q (c ∷ cs) buffer (done {Σ V F}) done cs = inp (♯ λ c → out c (buffer done done (c ∷ cs))) _⟨&⟩_ : ∀ {S T U} → (S ⇒ T) → (S ⇒ U) → (S ⇒ T & U) P ⟨&⟩ Q = buffer P Q [] -- If you want input buffering, you can implement it using copy and _[&]_. copy : ∀ {S} → (S ⇒ (S & S)) copy = done ⟨&⟩ done -- Braiding structure swap'' : ∀ {T U} → (I ≤ U) → T ⇒ (T & U) swap'' {I} cs = out* cs done swap'' {Σ W G} cs = inp (♯ λ b → out b (swap'' cs)) swap' : ∀ {S T} {isΣ : IsΣ T} {U} → (S ≤ U) → (S & T) ⇒ (T & U) swap' {I} cs = swap'' cs swap' {Σ V F} {Σ W G} cs = inp (♯ λ c → swap' (c ∷ cs)) swap' {Σ V F} {I} {} cs swap : ∀ {S T} → ((S & T) ⇒ (T & S)) swap {I} {T} = unit₂⁻¹ swap {Σ V F} {I} = unit₂ swap {Σ V F} {Σ W G} = swap' {Σ V F} [] -- Choice ι₁ : ∀ {S T} → (S ⇒ S + T) ι₁ = out true done ι₂ : ∀ {S T} → (T ⇒ S + T) ι₂ = out false done choice : ∀ {S T U} → (S ⇒ U) → (T ⇒ U) → ∀ b → ((if b then S else T) ⇒ U) choice P Q true = P choice P Q false = Q _[+]_ : ∀ {S T U V} → (S ⇒ U) → (T ⇒ V) → ((S + T) ⇒ (U + V)) P [+] Q = inp (♯ choice (out true P) (out false Q)) _⟨+⟩_ : ∀ {S T U} {isΣ : IsΣ U} → (S ⇒ U) → (T ⇒ U) → ((S + T) ⇒ U) _⟨+⟩_ {S} {T} {Σ X H} P Q = inp (♯ choice P Q) _⟨+⟩_ {S} {T} {I} {} P Q -- Options. some : ∀ {S} → (S ⇒ ¿ S) some = ι₁ none : ∀ {S} → (I ⇒ ¿ S) none = ι₂ [¿] : ∀ {S T} → (S ⇒ T) → (¿ S ⇒ ¿ T) [¿] P = P [+] done _⟨¿⟩_ : ∀ {S T} {isΣ : IsΣ T} → (S ⇒ T) → (I ⇒ T) → (¿ S ⇒ T) _⟨¿⟩_ {S} {T} {isΣ} = _⟨+⟩_ {S} {I} {T} {isΣ}
{ "alphanum_fraction": 0.5095088247, "avg_line_length": 31.235042735, "ext": "agda", "hexsha": "d378791700277975fde6099f1b5efb4069c92cec", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z", "max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z", "max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/System/IO/Transducers/Lazy.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ilya-fiveisky/agda-system-io", "max_issues_repo_path": "src/System/IO/Transducers/Lazy.agda", "max_line_length": 88, "max_stars_count": 10, "max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ilya-fiveisky/agda-system-io", "max_stars_repo_path": "src/System/IO/Transducers/Lazy.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z", "num_tokens": 3031, "size": 7309 }
{-# OPTIONS --safe #-} module Definition.Conversion.Weakening where open import Definition.Untyped as U hiding (wk) open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Weakening open import Definition.Conversion import Tools.PropositionalEquality as PE mutual -- Weakening of algorithmic equality of neutrals. wk~↑! : ∀ {ρ t u A Γ Δ l} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ → Γ ⊢ t ~ u ↑! A ^ l → Δ ⊢ U.wk ρ t ~ U.wk ρ u ↑! U.wk ρ A ^ l wk~↑! {ρ} [ρ] ⊢Δ (var-refl x₁ x≡y) = var-refl (wkTerm [ρ] ⊢Δ x₁) (PE.cong (wkVar ρ) x≡y) wk~↑! ρ ⊢Δ (app-cong {rF = !} {G = G} t~u x) = PE.subst (λ x → _ ⊢ _ ~ _ ↑! x ^ _) (PE.sym (wk-β G)) (app-cong (wk~↓! ρ ⊢Δ t~u) (wkConv↑Term ρ ⊢Δ x)) wk~↑! ρ ⊢Δ (app-cong {rF = %} {G = G} t~u x) = PE.subst (λ x → _ ⊢ _ ~ _ ↑! x ^ _) (PE.sym (wk-β G)) (app-cong (wk~↓! ρ ⊢Δ t~u) (wk~↑% ρ ⊢Δ x)) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (natrec-cong {k} {l} {h} {g} {a₀} {b₀} {F} {G} {ll} x x₁ x₂ t~u) = PE.subst (λ x → _ ⊢ U.wk ρ (natrec _ F a₀ h k) ~ _ ↑! x ^ _) (PE.sym (wk-β F)) (natrec-cong (wkConv↑ (lift [ρ]) (⊢Δ ∙ (univ (ℕⱼ ⊢Δ))) x) (PE.subst (λ x → _ ⊢ _ [conv↑] _ ∷ x ^ _) (wk-β F) (wkConv↑Term [ρ] ⊢Δ x₁)) (PE.subst (λ x → Δ ⊢ U.wk ρ h [conv↑] U.wk ρ g ∷ x ^ ι ll) (wk-β-natrec _ F ! _) (wkConv↑Term [ρ] ⊢Δ x₂)) (wk~↓! [ρ] ⊢Δ t~u)) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (Emptyrec-cong {k} {l} {F} {G} x t~u) = Emptyrec-cong (wkConv↑ [ρ] ⊢Δ x) (wk~↑% [ρ] ⊢Δ t~u) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (Id-cong X x x₁) = Id-cong (wk~↓! [ρ] ⊢Δ X) (wkConv↑Term [ρ] ⊢Δ x) (wkConv↑Term [ρ] ⊢Δ x₁) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (Id-ℕ x x₁) = Id-ℕ (wk~↓! [ρ] ⊢Δ x) (wkConv↑Term [ρ] ⊢Δ x₁) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (Id-ℕ0 x) = Id-ℕ0 (wk~↓! [ρ] ⊢Δ x) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (Id-ℕS x x₁) = Id-ℕS (wkConv↑Term [ρ] ⊢Δ x) (wk~↓! [ρ] ⊢Δ x₁) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (Id-U x x₁) = Id-U (wk~↓! [ρ] ⊢Δ x) (wkConv↑Term [ρ] ⊢Δ x₁) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (Id-Uℕ x) = Id-Uℕ (wk~↓! [ρ] ⊢Δ x) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (Id-UΠ x x₁) = Id-UΠ (wkConv↑Term [ρ] ⊢Δ x) (wk~↓! [ρ] ⊢Δ x₁) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (cast-cong X x x₁ x₂ x₃) = cast-cong (wk~↓! [ρ] ⊢Δ X) (wkConv↑Term [ρ] ⊢Δ x) (wkConv↑Term [ρ] ⊢Δ x₁) (wkTerm [ρ] ⊢Δ x₂) (wkTerm [ρ] ⊢Δ x₃) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (cast-ℕ X x x₁ x₂) = cast-ℕ (wk~↓! [ρ] ⊢Δ X) (wkConv↑Term [ρ] ⊢Δ x) (wkTerm [ρ] ⊢Δ x₁) (wkTerm [ρ] ⊢Δ x₂) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (cast-ℕℕ X x x₁) = cast-ℕℕ (wk~↓! [ρ] ⊢Δ X) (wkTerm [ρ] ⊢Δ x) (wkTerm [ρ] ⊢Δ x₁) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (cast-Π x X x₁ x₂ x₃) = cast-Π (wkConv↑Term [ρ] ⊢Δ x) (wk~↓! [ρ] ⊢Δ X) (wkConv↑Term [ρ] ⊢Δ x₁) (wkTerm [ρ] ⊢Δ x₂) (wkTerm [ρ] ⊢Δ x₃) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (cast-Πℕ x x₁ x₂ x₃) = cast-Πℕ (wkConv↑Term [ρ] ⊢Δ x) (wkConv↑Term [ρ] ⊢Δ x₁) (wkTerm [ρ] ⊢Δ x₂) (wkTerm [ρ] ⊢Δ x₃) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (cast-ℕΠ x x₁ x₂ x₃) = cast-ℕΠ (wkConv↑Term [ρ] ⊢Δ x) (wkConv↑Term [ρ] ⊢Δ x₁) (wkTerm [ρ] ⊢Δ x₂) (wkTerm [ρ] ⊢Δ x₃) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) = cast-ΠΠ%! (wkConv↑Term [ρ] ⊢Δ x) (wkConv↑Term [ρ] ⊢Δ x₁) (wkConv↑Term [ρ] ⊢Δ x₂) (wkTerm [ρ] ⊢Δ x₃) (wkTerm [ρ] ⊢Δ x₄) wk~↑! {ρ} {Δ = Δ} [ρ] ⊢Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) = cast-ΠΠ!% (wkConv↑Term [ρ] ⊢Δ x) (wkConv↑Term [ρ] ⊢Δ x₁) (wkConv↑Term [ρ] ⊢Δ x₂) (wkTerm [ρ] ⊢Δ x₃) (wkTerm [ρ] ⊢Δ x₄) wk~↑% : ∀ {ρ t u A Γ Δ l } ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ → Γ ⊢ t ~ u ↑% A ^ l → Δ ⊢ U.wk ρ t ~ U.wk ρ u ↑% U.wk ρ A ^ l wk~↑% [ρ] ⊢Δ (%~↑ ⊢k ⊢l) = %~↑ (wkTerm [ρ] ⊢Δ ⊢k) (wkTerm [ρ] ⊢Δ ⊢l) wk~↑ : ∀ {ρ t u A rA lA Γ Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ → Γ ⊢ t ~ u ↑ A ^ [ rA , lA ] → Δ ⊢ U.wk ρ t ~ U.wk ρ u ↑ U.wk ρ A ^ [ rA , lA ] wk~↑ [ρ] ⊢Δ (~↑! x) = ~↑! (wk~↑! [ρ] ⊢Δ x) wk~↑ [ρ] ⊢Δ (~↑% x) = ~↑% (wk~↑% [ρ] ⊢Δ x) -- Weakening of algorithmic equality of neutrals in WHNF. wk~↓! : ∀ {ρ t u A Γ Δ l} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ → Γ ⊢ t ~ u ↓! A ^ l → Δ ⊢ U.wk ρ t ~ U.wk ρ u ↓! U.wk ρ A ^ l wk~↓! {ρ} [ρ] ⊢Δ ([~] A₁ D whnfA k~l) = [~] (U.wk ρ A₁) (wkRed* [ρ] ⊢Δ D) (wkWhnf ρ whnfA) (wk~↑! [ρ] ⊢Δ k~l) -- Weakening of algorithmic equality of types. wkConv↑ : ∀ {ρ A B rA Γ Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ → Γ ⊢ A [conv↑] B ^ rA → Δ ⊢ U.wk ρ A [conv↑] U.wk ρ B ^ rA wkConv↑ {ρ} [ρ] ⊢Δ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) = [↑] (U.wk ρ A′) (U.wk ρ B′) (wkRed* [ρ] ⊢Δ D) (wkRed* [ρ] ⊢Δ D′) (wkWhnf ρ whnfA′) (wkWhnf ρ whnfB′) (wkConv↓ [ρ] ⊢Δ A′<>B′) -- Weakening of algorithmic equality of types in WHNF. wkConv↓ : ∀ {ρ A B rA Γ Δ} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ → Γ ⊢ A [conv↓] B ^ rA → Δ ⊢ U.wk ρ A [conv↓] U.wk ρ B ^ rA wkConv↓ ρ ⊢Δ (U-refl eqr x) = U-refl eqr ⊢Δ wkConv↓ ρ ⊢Δ (univ x) = univ (wkConv↓Term ρ ⊢Δ x) -- Weakening of algorithmic equality of terms. wkConv↑Term : ∀ {ρ t u A Γ Δ l} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ → Γ ⊢ t [conv↑] u ∷ A ^ l → Δ ⊢ U.wk ρ t [conv↑] U.wk ρ u ∷ U.wk ρ A ^ l wkConv↑Term {ρ} [ρ] ⊢Δ ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) = [↑]ₜ (U.wk ρ B) (U.wk ρ t′) (U.wk ρ u′) (wkRed* [ρ] ⊢Δ D) (wkRed*Term [ρ] ⊢Δ d) (wkRed*Term [ρ] ⊢Δ d′) (wkWhnf ρ whnfB) (wkWhnf ρ whnft′) (wkWhnf ρ whnfu′) (wkConv↓Term [ρ] ⊢Δ t<>u) -- Weakening of algorithmic equality of terms in WHNF. wkConv↓Term : ∀ {ρ t u A Γ Δ l} ([ρ] : ρ ∷ Δ ⊆ Γ) → ⊢ Δ → Γ ⊢ t [conv↓] u ∷ A ^ l → Δ ⊢ U.wk ρ t [conv↓] U.wk ρ u ∷ U.wk ρ A ^ l wkConv↓Term ρ ⊢Δ (U-refl eqr x) = U-refl eqr ⊢Δ wkConv↓Term ρ ⊢Δ (ne x) = ne (wk~↓! ρ ⊢Δ x) wkConv↓Term ρ ⊢Δ (ℕ-ins x) = ℕ-ins (wk~↓! ρ ⊢Δ x) -- wkConv↓Term ρ ⊢Δ (Empty-ins x) = -- Empty-ins (wk~↓% ρ ⊢Δ x) wkConv↓Term {ρ} [ρ] ⊢Δ (ne-ins t u x x₁) = ne-ins (wkTerm [ρ] ⊢Δ t) (wkTerm [ρ] ⊢Δ u) (wkNeutral ρ x) (wk~↓! [ρ] ⊢Δ x₁) wkConv↓Term ρ ⊢Δ (zero-refl x) = zero-refl ⊢Δ wkConv↓Term ρ ⊢Δ (suc-cong t<>u) = suc-cong (wkConv↑Term ρ ⊢Δ t<>u) wkConv↓Term {ρ} {Δ = Δ} [ρ] ⊢Δ (η-eq {F = F} {G = G} {rF = rF} {lF = lF} {lG = lG} l< l<' x x₁ x₂ y y₁ t<>u) = let ⊢ρF = wk [ρ] ⊢Δ x in η-eq l< l<' ⊢ρF (wkTerm [ρ] ⊢Δ x₁) (wkTerm [ρ] ⊢Δ x₂) (wkFunction ρ y) (wkFunction ρ y₁) (PE.subst₃ (λ x y z → Δ ∙ U.wk ρ F ^ [ rF , ι lF ] ⊢ x [conv↑] y ∷ z ^ ι lG) (PE.cong₃ _∘_^_ (PE.sym (wk1-wk≡lift-wk1 _ _)) PE.refl PE.refl) (PE.cong₃ _∘_^_ (PE.sym (wk1-wk≡lift-wk1 _ _)) PE.refl PE.refl) PE.refl (wkConv↑Term (lift [ρ]) (⊢Δ ∙ ⊢ρF) t<>u)) wkConv↓Term ρ ⊢Δ (ℕ-refl x) = ℕ-refl ⊢Δ wkConv↓Term ρ ⊢Δ (Empty-refl x _) = Empty-refl x ⊢Δ wkConv↓Term ρ ⊢Δ (Π-cong eql eqr eqlF eqlG l< l<' x A<>B A<>B₁) = let ⊢ρF = wk ρ ⊢Δ x in Π-cong eql eqr eqlF eqlG l< l<' ⊢ρF (wkConv↑Term ρ ⊢Δ A<>B) (wkConv↑Term (lift ρ) (⊢Δ ∙ ⊢ρF) A<>B₁) wkConv↓Term ρ ⊢Δ (∃-cong eql x A<>B A<>B₁) = let ⊢ρF = wk ρ ⊢Δ x in ∃-cong eql ⊢ρF (wkConv↑Term ρ ⊢Δ A<>B) (wkConv↑Term (lift ρ) (⊢Δ ∙ ⊢ρF) A<>B₁)
{ "alphanum_fraction": 0.4518030027, "avg_line_length": 53.1865671642, "ext": "agda", "hexsha": "8eae00c08d4dd1fb6d032dc584e97c9906d107d9", "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/Conversion/Weakening.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/Conversion/Weakening.agda", "max_line_length": 122, "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/Conversion/Weakening.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": 4037, "size": 7127 }
-- {-# OPTIONS --show-implicit --show-irrelevant #-} module Data.QuadTree.LensProofs.Valid-LensAtLocation where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Lens.Lens open import Data.Logic open import Data.QuadTree.InternalAgda open import Agda.Primitive open import Data.Lens.Proofs.LensLaws open import Data.Lens.Proofs.LensPostulates open import Data.Lens.Proofs.LensComposition open import Data.QuadTree.LensProofs.Valid-LensLeaf open import Data.QuadTree.LensProofs.Valid-LensWrappedTree open import Data.QuadTree.LensProofs.Valid-LensA open import Data.QuadTree.LensProofs.Valid-LensBCD open import Data.QuadTree.LensProofs.Valid-LensGo open import Data.QuadTree.Implementation.QuadrantLenses open import Data.QuadTree.Implementation.Definition open import Data.QuadTree.Implementation.ValidTypes open import Data.QuadTree.Implementation.SafeFunctions open import Data.QuadTree.Implementation.PublicFunctions open import Data.QuadTree.Implementation.DataLenses ---- Lens laws for go ValidLens-AtLocation-ViewSet : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {ins : IsTrue (isInsidePow loc dep)} -> ViewSet (atLocation {t} loc dep {ins}) ValidLens-AtLocation-ViewSet (x , y) dep {ins} v s = trans refl (prop-Composition-ViewSet (ValidLens-WrappedTree) (ValidLens-go (x , y) dep {ins}) v s) ValidLens-AtLocation-SetView : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {ins : IsTrue (isInsidePow loc dep)} -> SetView (atLocation {t} loc dep {ins}) ValidLens-AtLocation-SetView (x , y) dep {ins} s = trans refl (prop-Composition-SetView (ValidLens-WrappedTree) (ValidLens-go (x , y) dep {ins}) s) ValidLens-AtLocation-SetSet : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {ins : IsTrue (isInsidePow loc dep)} -> SetSet (atLocation {t} loc dep {ins}) ValidLens-AtLocation-SetSet (x , y) dep {ins} v1 v2 s = trans refl (prop-Composition-SetSet (ValidLens-WrappedTree) (ValidLens-go (x , y) dep {ins}) v1 v2 s) ValidLens-AtLocation : {t : Set} {{eqT : Eq t}} -> (loc : Nat × Nat) -> (dep : Nat) -> {ins : IsTrue (isInsidePow loc dep)} -> ValidLens (VQuadTree t {dep}) t ValidLens-AtLocation {t} {{eqT}} (x , y) dep {ins} = CValidLens (atLocation (x , y) dep {ins}) (ValidLens-AtLocation-ViewSet (x , y) dep {ins}) (ValidLens-AtLocation-SetView (x , y) dep {ins}) (ValidLens-AtLocation-SetSet (x , y) dep {ins})
{ "alphanum_fraction": 0.7100040502, "avg_line_length": 46.5849056604, "ext": "agda", "hexsha": "067819b5d0a7593cb62f46c2690e10a73d80a989", "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": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "JonathanBrouwer/research-project", "max_forks_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensAtLocation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "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": "JonathanBrouwer/research-project", "max_issues_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensAtLocation.agda", "max_line_length": 240, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "JonathanBrouwer/research-project", "max_stars_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensAtLocation.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:10:20.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:10:20.000Z", "num_tokens": 759, "size": 2469 }
open import Relation.Binary using (Rel) open import Algebra.Bundles using (CommutativeRing) open import Algebra.Module.Morphism.Structures open import Algebra.Module.Normed using (NormedModule) module Algebra.Module.Limit {r ℓr} {CR : CommutativeRing r ℓr} (open CommutativeRing CR using () renaming (Carrier to X)) {rel} {_≤_ : Rel X rel} {ma ℓma} (MA : NormedModule CR _≤_ ma ℓma) {mb ℓmb} (MB : NormedModule CR _≤_ mb ℓmb) where open import Data.Product using (Σ-syntax; ∃-syntax; _×_; proj₁) open CommutativeRing CR open import Algebra.Module.Morphism.Module using (⊸-normed) private module MA = NormedModule MA module MB = NormedModule MB module MA⊸MB = NormedModule (⊸-normed MA MB) open NormedModule MA using () renaming ( Carrierᴹ to Carrierᴬ ; _+ᴹ_ to _+ᴬ_ ; _-ᴹ_ to _-ᴬ_ ; ∥_∥ to ∥_∥ᴬ ; ⟨_,_⟩ to ⟨_,_⟩ᴬ ) open NormedModule MB using () renaming ( Carrierᴹ to Carrierᴮ ; _+ᴹ_ to _+ᴮ_ ; _-ᴹ_ to _-ᴮ_ ; ∥_∥ to ∥_∥ᴮ ; ⟨_,_⟩ to ⟨_,_⟩ᴮ ) open import Relation.Binary.Construct.NonStrictToStrict _≈_ _≤_ using (_<_) Limit-syntax : (L : Carrierᴮ) (f : Carrierᴬ → Carrierᴮ) (c : Carrierᴬ) → Set _ Limit-syntax L f c = ∀ ε → 0# < ε → ∃[ δ ] ∀ x → let d = ⟨ c , x ⟩ᴬ in (0# < d) × (d < δ) → ⟨ f x , L ⟩ᴮ < ε syntax Limit-syntax L (λ x → f) c = f ⟶ L As x ⟶ c Limit-syntax-0 : (L : Carrierᴮ) (f : Carrierᴬ → Carrierᴮ) → Set _ Limit-syntax-0 L f = ∀ ε → 0# < ε → ∃[ δ ] ∀ x → let d = ∥ x ∥ᴬ in (0# < d) × (d < δ) → ⟨ f x , L ⟩ᴮ < ε syntax Limit-syntax-0 L (λ x → f) = f ⟶ L As x ⟶0 Limit-syntax-0-0 : (f : Carrierᴬ → Carrierᴮ) → Set _ Limit-syntax-0-0 f = ∀ ε → 0# < ε → ∃[ δ ] ∀ x → let d = ∥ x ∥ᴬ in (0# < d) × (d < δ) → ∥ f x ∥ᴮ < ε syntax Limit-syntax-0-0 (λ x → f) = f ⟶0 As x ⟶0 _Approximates_At_ : (δf : MA⊸MB.Carrierᴹ) → (f : Carrierᴬ → Carrierᴮ) → (x : Carrierᴬ) → Set _ δf Approximates f At x = (f (x +ᴬ dx) -ᴮ (f x +ᴮ proj₁ δf dx)) ⟶0 As dx ⟶0 _Differentiates_ : (δf : Carrierᴬ → MA⊸MB.Carrierᴹ) → (f : Carrierᴬ → Carrierᴮ) → Set _ δf Differentiates f = ∀ x → (f (x +ᴬ dx) -ᴮ (f x +ᴮ proj₁ (δf x) dx)) ⟶0 As dx ⟶0 D[_,_]_~_ : (f : Carrierᴬ → Carrierᴮ) (df : Carrierᴬ → MA⊸MB.Carrierᴹ) → Set _ D[_,_]_~_ f df = df Differentiates f _DifferentiableAt_ : (f : Carrierᴬ → Carrierᴮ) (x : Carrierᴬ) → Set _ f DifferentiableAt x = ∃[ δf ] δf Approximates f At x Differentiable : (f : Carrierᴬ → Carrierᴮ) → Set _ Differentiable f = ∀ x → f DifferentiableAt x D[_,_][_,_] : (f : Carrierᴬ → Carrierᴮ) (x : Carrierᴬ) → Set _ D[_,_][_,_] f x = f DifferentiableAt x -- [_,_]~[_~_]_ -- : (δf : Carrierᴬ → Carrierᴮ) -- → (f : Carrierᴬ → Carrierᴮ) -- → (x : Carrierᴬ) -- → Set _ -- [_,_][_~_]_ df f x = {! df Approximates f At x !}
{ "alphanum_fraction": 0.5903003981, "avg_line_length": 27.3564356436, "ext": "agda", "hexsha": "383b78a173fe79a4700f98e40bba49728b3c1373", "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": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "cspollard/reals", "max_forks_repo_path": "src/Algebra/Module/Limit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "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": "cspollard/reals", "max_issues_repo_path": "src/Algebra/Module/Limit.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "a193aeebf1326f960975b19d3e31b46fddbbfaa2", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "cspollard/reals", "max_stars_repo_path": "src/Algebra/Module/Limit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1238, "size": 2763 }
open import FRP.JS.Geolocation.Angle using ( Angle ) renaming ( toString to toString° ) open import FRP.JS.String using ( String ; _++_ ) module FRP.JS.Geolocation.Coords where -- Not including the optional fields yet. record Coords : Set where field latitude : Angle longitude : Angle open Coords public toString : Coords → String toString c = toString° (latitude c) ++ "," ++ toString° (longitude c)
{ "alphanum_fraction": 0.7146282974, "avg_line_length": 24.5294117647, "ext": "agda", "hexsha": "4f6565dd25a249c02fe900b31285de8e40a65171", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "src/agda/FRP/JS/Geolocation/Coords.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "src/agda/FRP/JS/Geolocation/Coords.agda", "max_line_length": 87, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "src/agda/FRP/JS/Geolocation/Coords.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 104, "size": 417 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Non-dependent product combinators for setoid equality preserving -- functions ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Product.Function.NonDependent.Setoid where open import Data.Product open import Data.Product.Relation.Binary.Pointwise.NonDependent open import Relation.Binary open import Function.Equality as F using (_⟶_; _⟨$⟩_) open import Function.Equivalence as Eq using (Equivalence; _⇔_; module Equivalence) open import Function.Injection as Inj using (Injection; _↣_; module Injection) open import Function.Inverse as Inv using (Inverse; _↔_; module Inverse) open import Function.LeftInverse as LeftInv using (LeftInverse; _↞_; _LeftInverseOf_; module LeftInverse) open import Function.Related open import Function.Surjection as Surj using (Surjection; _↠_; module Surjection) ------------------------------------------------------------------------ -- Combinators for equality preserving functions module _ {a₁ a₂ b₁ b₂ c₁ c₂ d₁ d₂} {A : Setoid a₁ a₂} {B : Setoid b₁ b₂} {C : Setoid c₁ c₂} {D : Setoid d₁ d₂} where _×-⟶_ : (A ⟶ B) → (C ⟶ D) → (A ×ₛ C) ⟶ (B ×ₛ D) _×-⟶_ f g = record { _⟨$⟩_ = fg ; cong = fg-cong } where open Setoid (A ×ₛ C) using () renaming (_≈_ to _≈AC_) open Setoid (B ×ₛ D) using () renaming (_≈_ to _≈BD_) fg = map (f ⟨$⟩_) (g ⟨$⟩_) fg-cong : _≈AC_ =[ fg ]⇒ _≈BD_ fg-cong (_∼₁_ , _∼₂_) = (F.cong f _∼₁_ , F.cong g _∼₂_) module _ {a₁ a₂ b₁ b₂ c₁ c₂} {A : Setoid a₁ a₂} {B : Setoid b₁ b₂} {C : Setoid c₁ c₂} where <_,_>ₛ : (A ⟶ B) → (A ⟶ C) → A ⟶ (B ×ₛ C) < f , g >ₛ = record { _⟨$⟩_ = < f ⟨$⟩_ , g ⟨$⟩_ > ; cong = < F.cong f , F.cong g > } module _ {a₁ a₂ b₁ b₂} {A : Setoid a₁ a₂} {B : Setoid b₁ b₂} where proj₁ₛ : (A ×ₛ B) ⟶ A proj₁ₛ = record { _⟨$⟩_ = proj₁ ; cong = proj₁ } proj₂ₛ : (A ×ₛ B) ⟶ B proj₂ₛ = record { _⟨$⟩_ = proj₂ ; cong = proj₂ } swapₛ : (A ×ₛ B) ⟶ (B ×ₛ A) swapₛ = < proj₂ₛ , proj₁ₛ >ₛ ------------------------------------------------------------------------ -- Combinators for more complex function types module _ {a₁ a₂ b₁ b₂ c₁ c₂ d₁ d₂} {A : Setoid a₁ a₂} {B : Setoid b₁ b₂} {C : Setoid c₁ c₂} {D : Setoid d₁ d₂} where _×-equivalence_ : Equivalence A B → Equivalence C D → Equivalence (A ×ₛ C) (B ×ₛ D) _×-equivalence_ A⇔B C⇔D = record { to = to A⇔B ×-⟶ to C⇔D ; from = from A⇔B ×-⟶ from C⇔D } where open Equivalence _×-injection_ : Injection A B → Injection C D → Injection (A ×ₛ C) (B ×ₛ D) A↣B ×-injection C↣D = record { to = to A↣B ×-⟶ to C↣D ; injective = map (injective A↣B) (injective C↣D) } where open Injection _×-left-inverse_ : LeftInverse A B → LeftInverse C D → LeftInverse (A ×ₛ C) (B ×ₛ D) A↞B ×-left-inverse C↞D = record { to = Equivalence.to eq ; from = Equivalence.from eq ; left-inverse-of = left } where open LeftInverse eq = LeftInverse.equivalence A↞B ×-equivalence LeftInverse.equivalence C↞D left : Equivalence.from eq LeftInverseOf Equivalence.to eq left (x , y) = (left-inverse-of A↞B x , left-inverse-of C↞D y) module _ {a₁ a₂ b₁ b₂ c₁ c₂ d₁ d₂} {A : Setoid a₁ a₂} {B : Setoid b₁ b₂} {C : Setoid c₁ c₂} {D : Setoid d₁ d₂} where _×-surjection_ : Surjection A B → Surjection C D → Surjection (A ×ₛ C) (B ×ₛ D) A↠B ×-surjection C↠D = record { to = LeftInverse.from inv ; surjective = record { from = LeftInverse.to inv ; right-inverse-of = LeftInverse.left-inverse-of inv } } where open Surjection inv = right-inverse A↠B ×-left-inverse right-inverse C↠D _×-inverse_ : Inverse A B → Inverse C D → Inverse (A ×ₛ C) (B ×ₛ D) A↔B ×-inverse C↔D = record { to = Surjection.to surj ; from = Surjection.from surj ; inverse-of = record { left-inverse-of = LeftInverse.left-inverse-of inv ; right-inverse-of = Surjection.right-inverse-of surj } } where open Inverse surj = Inverse.surjection A↔B ×-surjection Inverse.surjection C↔D inv = Inverse.left-inverse A↔B ×-left-inverse Inverse.left-inverse C↔D
{ "alphanum_fraction": 0.5451933702, "avg_line_length": 31.8661971831, "ext": "agda", "hexsha": "afe1ea7f3612dd1995749081ff9e441ca0f999ad", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Function/NonDependent/Setoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Function/NonDependent/Setoid.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Function/NonDependent/Setoid.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 1580, "size": 4525 }
{-# OPTIONS --cubical-compatible #-} open import Agda.Builtin.Equality postulate A : Set B : A → Set data H (@0 A : Set) : Set where con : (@0 x : A) → H A data G : Set where con : (@0 x : A) → (@0 b : B x) → G data D : Set where con : (@0 x : A) → B x → D
{ "alphanum_fraction": 0.5257352941, "avg_line_length": 17, "ext": "agda", "hexsha": "52a3a5be7c5817829116a51d64007826a5723da6", "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/Issue4784b.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/Issue4784b.agda", "max_line_length": 37, "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/Issue4784b.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 105, "size": 272 }
module Graph (Node : Set) where open import Basics data Edge : Set where edge : Node -> Node -> Edge Graph : Set Graph = List Edge Step : Graph -> Node -> Node -> Set Step G x y = Elem (edge x y) G infixr 40 _<>_ data Path (G : Graph) : Node -> Node -> Set where nul : forall {x} -> Path G x x _<>_ : forall {x y z} -> Step G x y -> Path G y z -> Path G x z
{ "alphanum_fraction": 0.5824468085, "avg_line_length": 18.8, "ext": "agda", "hexsha": "d4b8875d885440c46b3969e5f8f01b56d74f37b6", "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/cbs/Graph.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/cbs/Graph.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/cbs/Graph.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 127, "size": 376 }
module Golden.Insertion where open import Agda.Builtin.Nat open import Agda.Builtin.List open import Agda.Builtin.Bool insert : Nat -> List Nat -> List Nat insert a [] = a ∷ [] insert x (a ∷ b) with x < a ... | true = x ∷ a ∷ b ... | false = a ∷ (insert x b) lst : List Nat lst = 2 ∷ [] slst : List Nat slst = insert 3 lst atDef : ∀ {a : Set} → a → List a -> Nat -> a atDef def (x ∷ l) zero = x atDef def (x ∷ l) (suc ix) = atDef def l ix atDef def _ _ = def l0 : Nat l0 = atDef 0 slst 0 l1 : Nat l1 = atDef 0 slst 1
{ "alphanum_fraction": 0.6011450382, "avg_line_length": 18.0689655172, "ext": "agda", "hexsha": "94f285153377a6b83a7fc331a1b191e2ce00e2e2", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:48.000Z", "max_forks_repo_forks_event_min_datetime": "2018-05-24T10:45:59.000Z", "max_forks_repo_head_hexsha": "e38b699870ba638221828b07b12948d70a1bdaec", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-ocaml", "max_forks_repo_path": "test/agda-ocaml/Golden/Insertion.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "e38b699870ba638221828b07b12948d70a1bdaec", "max_issues_repo_issues_event_max_datetime": "2018-11-05T21:28:57.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-29T13:37:52.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-ocaml", "max_issues_repo_path": "test/agda-ocaml/Golden/Insertion.agda", "max_line_length": 44, "max_stars_count": 48, "max_stars_repo_head_hexsha": "e38b699870ba638221828b07b12948d70a1bdaec", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-ocaml", "max_stars_repo_path": "test/agda-ocaml/Golden/Insertion.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-15T09:08:14.000Z", "max_stars_repo_stars_event_min_datetime": "2017-03-29T14:19:31.000Z", "num_tokens": 207, "size": 524 }
module Spire.Examples.Standard where ---------------------------------------------------------------------- data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ data Vec (A : Set) : ℕ → Set where nil : Vec A zero cons : (n : ℕ) (a : A) (xs : Vec A n) → Vec A (suc n) ---------------------------------------------------------------------- elimℕ : (P : ℕ → Set) (pzero : P zero) (psuc : (m : ℕ) → P m → P (suc m)) (n : ℕ) → P n elimℕ P pzero psuc zero = pzero elimℕ P pzero psuc (suc n) = psuc n (elimℕ P pzero psuc n) elimVec : (A : Set) (P : (n : ℕ) → Vec A n → Set) (pnil : P zero nil) (pcons : (n : ℕ) (a : A) (xs : Vec A n) → P n xs → P (suc n) (cons n a xs)) (n : ℕ) (xs : Vec A n) → P n xs elimVec A P pnil pcons .zero nil = pnil elimVec A P pnil pcons .(suc n) (cons n a xs) = pcons n a xs (elimVec A P pnil pcons n xs) ---------------------------------------------------------------------- module PatternMatching where add : ℕ → ℕ → ℕ add zero n = n add (suc m) n = suc (add m n) mult : ℕ → ℕ → ℕ mult zero n = zero mult (suc m) n = add n (mult m n) append : (A : Set) (m : ℕ) (xs : Vec A m) (n : ℕ) (ys : Vec A n) → Vec A (add m n) append A .zero nil n ys = ys append A .(suc m) (cons m x xs) n ys = cons (add m n) x (append A m xs n ys) concat : (A : Set) (m n : ℕ) (xss : Vec (Vec A m) n) → Vec A (mult n m) concat A m .zero nil = nil concat A m .(suc n) (cons n xs xss) = append A m xs (mult n m) (concat A m n xss) ---------------------------------------------------------------------- module Eliminator where add : ℕ → ℕ → ℕ add = elimℕ (λ _ → ℕ → ℕ) (λ n → n) (λ m ih n → suc (ih n)) mult : ℕ → ℕ → ℕ mult = elimℕ (λ _ → ℕ → ℕ) (λ n → zero) (λ m ih n → add n (ih n)) append : (A : Set) (m : ℕ) (xs : Vec A m) (n : ℕ) (ys : Vec A n) → Vec A (add m n) append A = elimVec A (λ m xs → (n : ℕ) (ys : Vec A n) → Vec A (add m n)) (λ n ys → ys) (λ m x xs ih n ys → cons (add m n) x (ih n ys)) concat : (A : Set) (m n : ℕ) (xss : Vec (Vec A m) n) → Vec A (mult n m) concat A m = elimVec (Vec A m) (λ n xss → Vec A (mult n m)) nil (λ n xs xss ih → append A m xs (mult n m) ih) ----------------------------------------------------------------------
{ "alphanum_fraction": 0.4305249228, "avg_line_length": 29.4415584416, "ext": "agda", "hexsha": "fb3bea7423703f96d7fd38011214d0a43598fa13", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-08-17T21:00:07.000Z", "max_forks_repo_forks_event_min_datetime": "2015-08-17T21:00:07.000Z", "max_forks_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "spire/spire", "max_forks_repo_path": "formalization/agda/Spire/Examples/Standard.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "spire/spire", "max_issues_repo_path": "formalization/agda/Spire/Examples/Standard.agda", "max_line_length": 90, "max_stars_count": 43, "max_stars_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "spire/spire", "max_stars_repo_path": "formalization/agda/Spire/Examples/Standard.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T17:10:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-28T23:25:33.000Z", "num_tokens": 829, "size": 2267 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Functions.Definition open import Functions.Lemmas open import LogicalFormulae open import Numbers.Naturals.Definition open import Numbers.Naturals.Order open import Sets.FinSet.Definition module Sets.FinSet.Lemmas where fneSymmetric : {n : ℕ} → {a b : FinSet (succ n)} → FinNotEquals a b → FinNotEquals b a fneSymmetric {.1} {.a1} {.b1} (fne2 a1 b1 (inl x)) = fne2 b1 a1 (inr x) fneSymmetric {.1} {.a1} {.b1} (fne2 a1 b1 (inr x)) = fne2 b1 a1 (inl x) fneSymmetric {.(succ (succ _))} {.fzero} {b} (fneN .fzero b (inl (inl (refl ,, snd)))) = fneN b fzero (inl (inr (snd ,, refl))) fneSymmetric {.(succ (succ _))} {a} {.fzero} (fneN a .fzero (inl (inr (fst ,, refl)))) = fneN fzero a (inl (inl (refl ,, fst))) fneSymmetric {.(succ (succ _))} {a} {b} (fneN a b (inr ((fst ,, snd) , record { one = o ; two = p ; three = q }))) = fneN b a (inr ((snd ,, fst) , record { one = p ; two = o ; three = fneSymmetric q })) private underlyingProof : {l m : _} {L : Set l} {pr : L → Set m} → (a : Sg L pr) → pr (underlying a) underlyingProof (a , b) = b finSetNotEquals : {n : ℕ} → {a b : FinSet (succ n)} → (a ≡ b → False) → FinNotEquals {n} a b finSetNotEquals {zero} {fzero} {fzero} pr = exFalso (pr refl) finSetNotEquals {zero} {fzero} {fsucc ()} pr finSetNotEquals {zero} {fsucc ()} {b} pr finSetNotEquals {succ zero} {fzero} {fzero} pr = exFalso (pr refl) finSetNotEquals {succ zero} {fzero} {fsucc fzero} pr = fne2 fzero (fsucc fzero) (inl (refl ,, refl)) finSetNotEquals {succ zero} {fzero} {fsucc (fsucc ())} pr finSetNotEquals {succ zero} {fsucc fzero} {fzero} pr = fne2 (fsucc fzero) fzero (inr (refl ,, refl)) finSetNotEquals {succ zero} {fsucc fzero} {fsucc fzero} pr = exFalso (pr refl) finSetNotEquals {succ zero} {fsucc fzero} {fsucc (fsucc ())} pr finSetNotEquals {succ zero} {fsucc (fsucc ())} finSetNotEquals {succ (succ n)} {fzero} {fzero} pr = exFalso (pr refl) finSetNotEquals {succ (succ n)} {fzero} {fsucc b} pr = fneN fzero (fsucc b) (inl (inl (refl ,, (b , refl)))) finSetNotEquals {succ (succ n)} {fsucc a} {fzero} pr = fneN (fsucc a) fzero (inl (inr ((a , refl) ,, refl))) finSetNotEquals {succ (succ n)} {fsucc a} {fsucc b} pr = fneN (fsucc a) (fsucc b) (inr ans) where q : a ≡ b → False q refl = pr refl t : FinNotEquals {succ n} a b t = finSetNotEquals {succ n} {a} {b} q ans : Sg (FinSet (succ (succ n)) && FinSet (succ (succ n))) (λ x → (fsucc a ≡ fsucc (_&&_.fst x)) & fsucc b ≡ fsucc (_&&_.snd x) & FinNotEquals (_&&_.fst x) (_&&_.snd x)) ans with t ans | fne2 .fzero .(fsucc fzero) (inl (refl ,, refl)) = (a ,, b) , record { one = refl ; two = refl ; three = fne2 fzero (fsucc fzero) (inl (refl ,, refl)) } ans | fne2 .(fsucc fzero) .fzero (inr (refl ,, refl)) = (a ,, b) , record { one = refl ; two = refl ; three = fne2 (fsucc fzero) fzero (inr (refl ,, refl)) } ans | fneN a b _ = (a ,, b) , record { one = refl ; two = refl ; three = t } fzeroNotFsucc : {n : ℕ} → {a : _} → fzero ≡ fsucc {succ n} a → False fzeroNotFsucc () finSetNotEqualsSame : {n : ℕ} → {a : FinSet (succ n)} → FinNotEquals a a → False finSetNotEqualsSame {.1} {fzero} (fne2 .fzero .fzero (inl (fst ,, ()))) finSetNotEqualsSame {.1} {fzero} (fne2 .fzero .fzero (inr (fst ,, ()))) finSetNotEqualsSame {.(succ (succ _))} {fzero} (fneN .fzero .fzero (inl (inl (refl ,, (a , ()))))) finSetNotEqualsSame {.(succ (succ _))} {fzero} (fneN .fzero .fzero (inl (inr ((a , ()) ,, refl)))) finSetNotEqualsSame {.(succ (succ _))} {fzero} (fneN .fzero .fzero (inr ((fst ,, snd) , record { one = () ; two = p ; three = q }))) finSetNotEqualsSame {.1} {fsucc a} (fne2 .(fsucc a) .(fsucc a) (inl (() ,, snd))) finSetNotEqualsSame {.1} {fsucc a} (fne2 .(fsucc a) .(fsucc a) (inr (() ,, snd))) finSetNotEqualsSame {.(succ (succ _))} {fsucc a} (fneN .(fsucc a) .(fsucc a) (inl (inl (() ,, snd)))) finSetNotEqualsSame {.(succ (succ _))} {fsucc a} (fneN .(fsucc a) .(fsucc a) (inl (inr (fst ,, ())))) finSetNotEqualsSame {.(succ (succ _))} {fsucc a} (fneN .(fsucc a) .(fsucc a) (inr ((.a ,, .a) , record { one = refl ; two = refl ; three = q }))) = finSetNotEqualsSame q finNotEqualsFsucc : {n : ℕ} → {a b : FinSet (succ n)} → FinNotEquals (fsucc a) (fsucc b) → FinNotEquals a b finNotEqualsFsucc {.0} {a} {b} (fne2 .(fsucc a) .(fsucc b) (inl (() ,, snd))) finNotEqualsFsucc {.0} {a} {b} (fne2 .(fsucc a) .(fsucc b) (inr (() ,, snd))) finNotEqualsFsucc {n} {a} {b} (fneN .(fsucc a) .(fsucc b) (inl (inl (() ,, snd)))) finNotEqualsFsucc {n} {a} {b} (fneN .(fsucc a) .(fsucc b) (inl (inr (fst ,, ())))) finNotEqualsFsucc {n} {a} {b} (fneN .(fsucc a) .(fsucc b) (inr ((fst ,, snd) , prf))) = identityOfIndiscernablesRight FinNotEquals ans (equalityCommutative b=snd) where a=fst : a ≡ fst a=fst = fsuccInjective (_&_&_.one prf) b=snd : b ≡ snd b=snd = fsuccInjective (_&_&_.two prf) ans : FinNotEquals a snd ans = identityOfIndiscernablesLeft FinNotEquals (_&_&_.three prf) (equalityCommutative a=fst) finSetNotEquals' : {n : ℕ} → {a b : FinSet (succ n)} → FinNotEquals a b → (a ≡ b → False) finSetNotEquals' {n} {a} {.a} fne refl = finSetNotEqualsSame fne finset0Empty : FinSet zero → False finset0Empty () finset1OnlyOne : (a b : FinSet 1) → a ≡ b finset1OnlyOne fzero fzero = refl finset1OnlyOne fzero (fsucc ()) finset1OnlyOne (fsucc ()) b intoSmaller : {n m : ℕ} → .(n <N m) → (FinSet n → FinSet m) intoSmaller {zero} {m} n<m = t where t : FinSet 0 → FinSet m t () intoSmaller {succ n} {zero} () intoSmaller {succ n} {succ m} n<m with intoSmaller (canRemoveSuccFrom<N n<m) intoSmaller {succ n} {succ m} n<m | prev = t where t : FinSet (succ n) → FinSet (succ m) t fzero = fzero t (fsucc arg) = fsucc (prev arg) intoSmallerInj : {n m : ℕ} → (n<m : n <N m) → Injection (intoSmaller n<m) intoSmallerInj {zero} {zero} (le x ()) intoSmallerInj {zero} {succ m} n<m = inj where t : FinSet 0 → FinSet (succ m) t () inj : {x y : FinSet zero} → intoSmaller (succIsPositive m) x ≡ intoSmaller (succIsPositive m) y → x ≡ y inj {()} {y} intoSmallerInj {succ n} {zero} () intoSmallerInj {succ n} {succ m} n<m with intoSmallerInj (canRemoveSuccFrom<N n<m) intoSmallerInj {succ n} {succ m} n<m | prevInj = inj where inj : Injection (intoSmaller n<m) inj {fzero} {fzero} pr = refl inj {fzero} {fsucc y} () inj {fsucc x} {fzero} () inj {fsucc x} {fsucc y} pr = applyEquality fsucc (prevInj (fsuccInjective pr)) toNat : {n : ℕ} → (a : FinSet n) → ℕ toNat {.(succ _)} fzero = 0 toNat {.(succ _)} (fsucc a) = succ (toNat a) toNatSmaller : {n : ℕ} → (a : FinSet n) → toNat a <N n toNatSmaller {zero} () toNatSmaller {succ n} fzero = succIsPositive n toNatSmaller {succ n} (fsucc a) = succPreservesInequality (toNatSmaller a) ofNat : {n : ℕ} → (m : ℕ) → .(m <N n) → FinSet n ofNat {zero} zero () ofNat {succ n} zero m<n = fzero ofNat {zero} (succ m) () ofNat {succ n} (succ m) m<n = fsucc (ofNat {n} m (canRemoveSuccFrom<N m<n)) ofNatInjective : {n : ℕ} → (x y : ℕ) → .(pr : x <N n) → .(pr2 : y <N n) → ofNat x pr ≡ ofNat y pr2 → x ≡ y ofNatInjective {zero} zero zero () y<n pr ofNatInjective {zero} zero (succ y) () y<n pr ofNatInjective {zero} (succ x) zero x<n () pr ofNatInjective {zero} (succ x) (succ y) () y<n pr ofNatInjective {succ n} zero zero x<n y<n pr = refl ofNatInjective {succ n} zero (succ y) x<n y<n () ofNatInjective {succ n} (succ x) zero x<n y<n () ofNatInjective {succ n} (succ x) (succ y) x<n y<n pr = applyEquality succ (ofNatInjective x y (canRemoveSuccFrom<N x<n) (canRemoveSuccFrom<N y<n) (fsuccInjective pr)) toNatInjective : {n : ℕ} → (x y : FinSet n) → toNat x ≡ toNat y → x ≡ y toNatInjective fzero fzero pr = refl toNatInjective (fsucc x) (fsucc y) pr = applyEquality fsucc (toNatInjective x y (succInjective pr)) toNatOfNat : {n : ℕ} → (a : ℕ) → (a<n : a <N n) → toNat (ofNat a a<n) ≡ a toNatOfNat {zero} zero (le x ()) toNatOfNat {zero} (succ a) (le x ()) toNatOfNat {succ n} zero a<n = refl toNatOfNat {succ n} (succ a) a<n = applyEquality succ (toNatOfNat a (canRemoveSuccFrom<N a<n)) intoSmallerLemm : {n m : ℕ} → {n<m : n <N (succ m)} → {m<sm : m <N succ m} → (b : FinSet n) → intoSmaller n<m b ≡ ofNat m m<sm → False intoSmallerLemm {.(succ _)} {m} {n<m} fzero pr with intoSmaller (canRemoveSuccFrom<N n<m) intoSmallerLemm {.(succ _)} {zero} {n<m} fzero refl | bl = zeroNeverGreater (canRemoveSuccFrom<N n<m) intoSmallerLemm {.(succ _)} {succ m} {n<m} fzero () | bl intoSmallerLemm {.(succ _)} {m} {n<m} (fsucc b) pr with inspect (intoSmaller (canRemoveSuccFrom<N n<m)) intoSmallerLemm {.(succ _)} {zero} {n<m} (fsucc b) pr | bl with≡ _ = zeroNeverGreater (canRemoveSuccFrom<N n<m) intoSmallerLemm {.(succ _)} {succ m} {n<m} {m<sm} (fsucc b) pr | bl with≡ p = intoSmallerLemm {n<m = canRemoveSuccFrom<N n<m} {m<sm = canRemoveSuccFrom<N m<sm} b (fsuccInjective pr) intoSmallerNotSurj : {n m : ℕ} → {n<m : n <N m} → Surjection (intoSmaller n<m) → False intoSmallerNotSurj {n} {zero} {le x ()} property intoSmallerNotSurj {zero} {succ zero} {n<m} property with property fzero ... | () , _ intoSmallerNotSurj {succ n} {succ zero} {n<m} property = zeroNeverGreater (canRemoveSuccFrom<N n<m) intoSmallerNotSurj {0} {succ (succ m)} {n<m} property with property fzero ... | () , _ intoSmallerNotSurj {succ n} {succ (succ m)} {n<m} property = problem where notHit : FinSet (succ (succ m)) notHit = ofNat (succ m) (le zero refl) hitting : Sg (FinSet (succ n)) (λ i → intoSmaller n<m i ≡ notHit) hitting = property notHit problem : False problem with hitting ... | a , pr = intoSmallerLemm {succ n} {succ m} {n<m} {le 0 refl} a pr finsetDecidableEquality : {n : ℕ} → (x y : FinSet n) → (x ≡ y) || ((x ≡ y) → False) finsetDecidableEquality fzero fzero = inl refl finsetDecidableEquality fzero (fsucc y) = inr λ () finsetDecidableEquality (fsucc x) fzero = inr λ () finsetDecidableEquality (fsucc x) (fsucc y) with finsetDecidableEquality x y finsetDecidableEquality (fsucc x) (fsucc y) | inl pr rewrite pr = inl refl finsetDecidableEquality (fsucc x) (fsucc y) | inr pr = inr (λ f → pr (fsuccInjective f)) subInjection : {n : ℕ} → {f : FinSet (succ (succ n)) → FinSet (succ (succ n))} → Injection f → (FinSet (succ n) → FinSet (succ n)) subInjection {n} {f} inj x with inspect (f (fsucc x)) subInjection {f = f} inj x | fzero with≡ _ with inspect (f fzero) subInjection {f = f} inj x | fzero with≡ pr | fzero with≡ pr2 = exFalso (fzeroNotFsucc (inj (transitivity pr2 (equalityCommutative pr)))) subInjection {f = f} inj x | fzero with≡ _ | fsucc bl with≡ _ = bl subInjection {f = f} inj x | fsucc bl with≡ _ = bl subInjIsInjective : {n : ℕ} → {f : FinSet (succ (succ n)) → FinSet (succ (succ n))} → (inj : Injection f) → Injection (subInjection inj) subInjIsInjective {f = f} inj {x} {y} pr with inspect (f (fsucc x)) subInjIsInjective {f = f} inj {x} {y} pr | fzero with≡ _ with inspect (f (fzero)) subInjIsInjective {f = f} inj {x} {y} pr | fzero with≡ pr1 | fzero with≡ pr2 = exFalso (fzeroNotFsucc (inj (transitivity pr2 (equalityCommutative pr1)))) subInjIsInjective {f = f} inj {x} {y} pr | fzero with≡ pr1 | fsucc bl with≡ _ with inspect (f (fsucc y)) subInjIsInjective {f = f} inj {x} {y} pr | fzero with≡ pr1 | fsucc bl with≡ _ | fzero with≡ x₁ with inspect (f (fzero)) subInjIsInjective {f = f} inj {x} {y} pr | fzero with≡ pr1 | fsucc bl with≡ _ | fzero with≡ x1 | fzero with≡ x2 = exFalso (fzeroNotFsucc (inj (transitivity x2 (equalityCommutative x1)))) subInjIsInjective {f = f} inj {x} {y} refl | fzero with≡ pr1 | fsucc .bl2 with≡ _ | fzero with≡ x1 | fsucc bl2 with≡ _ = fsuccInjective (inj (transitivity pr1 (equalityCommutative x1))) subInjIsInjective {f = f} inj {x} {y} refl | fzero with≡ pr1 | fsucc .bl2 with≡ pr2 | fsucc bl2 with≡ pr3 = exFalso (fzeroNotFsucc (inj (transitivity pr2 (equalityCommutative pr3)))) subInjIsInjective {f = f} inj {x} {y} pr | fsucc bl with≡ _ with inspect (f (fsucc y)) subInjIsInjective {f = f} inj {x} {y} pr | fsucc bl with≡ _ | fzero with≡ x₁ with inspect (f fzero) subInjIsInjective {f = f} inj {x} {y} pr | fsucc bl with≡ _ | fzero with≡ x1 | fzero with≡ x2 = exFalso (fzeroNotFsucc (inj (transitivity x2 (equalityCommutative x1)))) subInjIsInjective {f = f} inj {x} {y} refl | fsucc .bl2 with≡ x1 | fzero with≡ x₁ | fsucc bl2 with≡ x2 = exFalso (fzeroNotFsucc (inj (transitivity x2 (equalityCommutative x1)))) subInjIsInjective {f = f} inj {x} {y} refl | fsucc .y1 with≡ pr1 | fsucc y1 with≡ pr2 = fsuccInjective (inj (transitivity pr1 (equalityCommutative pr2))) onepointBij : (f : FinSet 1 → FinSet 1) → Bijection f Bijection.inj (onepointBij f) {x} {y} _ = finset1OnlyOne x y Bijection.surj (onepointBij f) fzero with inspect (f fzero) ... | fzero with≡ pr = fzero , pr ... | fsucc () with≡ _ Bijection.surj (onepointBij f) (fsucc ()) nopointBij : (f : FinSet 0 → FinSet 0) → Bijection f Bijection.inj (nopointBij f) {()} Bijection.surj (nopointBij f) () private flip : {n : ℕ} → (f : FinSet (succ n) → FinSet (succ n)) → FinSet (succ n) → FinSet (succ n) flip {n} f fzero = f fzero flip {n} f (fsucc a) with inspect (f fzero) flip {n} f (fsucc a) | fzero with≡ x = fsucc a flip {n} f (fsucc a) | fsucc y with≡ x with finsetDecidableEquality a y flip {n} f (fsucc a) | fsucc y with≡ x | inl a=y = fzero flip {n} f (fsucc a) | fsucc y with≡ x | inr a!=y = fsucc a flipSwapsF0 : {n : ℕ} → {f : FinSet (succ n) → FinSet (succ n)} → (flip f (f fzero)) ≡ fzero flipSwapsF0 {zero} {f} with inspect (f fzero) flipSwapsF0 {zero} {f} | fzero with≡ x rewrite x = x flipSwapsF0 {zero} {f} | fsucc () with≡ x flipSwapsF0 {succ n} {f = f} with inspect (f fzero) flipSwapsF0 {succ n} {f = f} | fzero with≡ pr rewrite pr = pr flipSwapsF0 {succ n} {f = f} | fsucc b with≡ pr rewrite pr = ans where ans : flip f (fsucc b) ≡ fzero ans with inspect (f fzero) ans | fzero with≡ x = exFalso (fzeroNotFsucc (transitivity (equalityCommutative x) pr)) ans | fsucc y with≡ x with finsetDecidableEquality b y ans | fsucc y with≡ x | inl b=y = refl ans | fsucc y with≡ x | inr b!=y = exFalso (b!=y (fsuccInjective (transitivity (equalityCommutative pr) x))) flipSwapsZero : {n : ℕ} → {f : FinSet (succ n) → FinSet (succ n)} → (flip f fzero) ≡ f fzero flipSwapsZero {n} {f} = refl flipMaintainsEverythingElse : {n : ℕ} → {f : FinSet (succ n) → FinSet (succ n)} → (x : FinSet n) → ((fsucc x ≡ f fzero) → False) → flip f (fsucc x) ≡ fsucc x flipMaintainsEverythingElse {n} {f} x x!=f0 with inspect (f fzero) flipMaintainsEverythingElse {n} {f} x x!=f0 | fzero with≡ pr = refl flipMaintainsEverythingElse {n} {f} x x!=f0 | fsucc bl with≡ pr with finsetDecidableEquality x bl flipMaintainsEverythingElse {n} {f} x x!=f0 | fsucc bl with≡ pr | inl x=bl = exFalso (x!=f0 (transitivity (applyEquality fsucc x=bl) (equalityCommutative pr))) flipMaintainsEverythingElse {n} {f} x x!=f0 | fsucc bl with≡ pr | inr x!=bl = refl bijFlip : {n : ℕ} → {f : FinSet (succ n) → FinSet (succ n)} → Bijection (flip f) bijFlip {zero} {f} = onepointBij (flip f) Bijection.inj (bijFlip {succ n} {f}) {fzero} {fzero} flx=fly = refl Bijection.inj (bijFlip {succ n} {f}) {fzero} {fsucc y} flx=fly with inspect (f fzero) Bijection.inj (bijFlip {succ n} {f}) {fzero} {fsucc y} flx=fly | fzero with≡ x rewrite x = exFalso (fzeroNotFsucc flx=fly) Bijection.inj (bijFlip {succ n} {f}) {fzero} {fsucc y} flx=fly | fsucc f0 with≡ x with finsetDecidableEquality y f0 Bijection.inj (bijFlip {succ n} {f}) {fzero} {fsucc y} flx=fly | fsucc f0 with≡ x | inl x₁ = exFalso (fzeroNotFsucc (transitivity (equalityCommutative flx=fly) x)) Bijection.inj (bijFlip {succ n} {f}) {fzero} {fsucc y} flx=fly | fsucc f0 with≡ x | inr pr = exFalso (pr (fsuccInjective (transitivity (equalityCommutative flx=fly) x))) Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fzero} flx=fly with inspect (f fzero) Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fzero} flx=fly | fzero with≡ pr = transitivity flx=fly pr Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fzero} flx=fly | fsucc f0 with≡ x₁ with finsetDecidableEquality x f0 Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fzero} flx=fly | fsucc f0 with≡ pr | inl x₂ = exFalso (fzeroNotFsucc (transitivity flx=fly pr)) Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fzero} flx=fly | fsucc f0 with≡ x1 | inr x!=f0 = exFalso (x!=f0 (fsuccInjective (transitivity flx=fly x1))) Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fsucc y} flx=fly with inspect (f fzero) Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fsucc y} flx=fly | fzero with≡ x₁ = flx=fly Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fsucc y} flx=fly | fsucc f0 with≡ x₁ with finsetDecidableEquality y f0 Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fsucc y} flx=fly | fsucc f0 with≡ x₁ | inl y=f0 with finsetDecidableEquality x f0 Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fsucc y} flx=fly | fsucc f0 with≡ x₁ | inl y=f0 | inl x=f0 = applyEquality fsucc (transitivity x=f0 (equalityCommutative y=f0)) Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fsucc y} () | fsucc f0 with≡ x₁ | inl y=f0 | inr x!=f0 Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fsucc y} flx=fly | fsucc f0 with≡ x₁ | inr y!=f0 with finsetDecidableEquality x f0 Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fsucc y} () | fsucc f0 with≡ x₁ | inr y!=f0 | inl x=f0 Bijection.inj (bijFlip {succ n} {f}) {fsucc x} {fsucc y} flx=fly | fsucc f0 with≡ x₁ | inr y!=f0 | inr x!=f0 = flx=fly Bijection.surj (bijFlip {succ n} {f}) fzero = f fzero , flipSwapsF0 {f = f} Bijection.surj (bijFlip {succ n} {f}) (fsucc b) with inspect (f fzero) Bijection.surj (bijFlip {succ n} {f}) (fsucc b) | fzero with≡ x = fsucc b , flipMaintainsEverythingElse {f = f} b λ pr → fzeroNotFsucc (transitivity (equalityCommutative x) (equalityCommutative pr)) Bijection.surj (bijFlip {succ n} {f}) (fsucc b) | fsucc y with≡ x with finsetDecidableEquality y b Bijection.surj (bijFlip {succ n} {f}) (fsucc b) | fsucc y with≡ x | inl y=b = fzero , transitivity x (applyEquality fsucc y=b) Bijection.surj (bijFlip {succ n} {f}) (fsucc b) | fsucc y with≡ x | inr y!=b = fsucc b , flipMaintainsEverythingElse {f = f} b λ pr → y!=b (fsuccInjective (transitivity (equalityCommutative x) (equalityCommutative pr))) injectionIsBijectionFinset : {n : ℕ} → {f : FinSet n → FinSet n} → Injection f → Bijection f injectionIsBijectionFinset {zero} {f} inj = record { inj = inj ; surj = λ () } injectionIsBijectionFinset {succ zero} {f} inj = record { inj = inj ; surj = ans } where ans : (b : FinSet (succ zero)) → Sg (FinSet (succ zero)) (λ a → f a ≡ b) ans fzero with inspect (f fzero) ans fzero | fzero with≡ x = fzero , x ans fzero | fsucc () with≡ x ans (fsucc ()) injectionIsBijectionFinset {succ (succ n)} {f} inj with injectionIsBijectionFinset {succ n} (subInjIsInjective inj) ... | sb = ans where subSurj : Surjection (subInjection inj) subSurj = Bijection.surj sb tweakedF : FinSet (succ (succ n)) → FinSet (succ (succ n)) tweakedF fzero = fzero tweakedF (fsucc x) = fsucc (subInjection inj x) tweakedBij : Bijection tweakedF Bijection.inj tweakedBij {fzero} {fzero} f'x=f'y = refl Bijection.inj tweakedBij {fzero} {fsucc y} () Bijection.inj tweakedBij {fsucc x} {fzero} () Bijection.inj tweakedBij {fsucc x} {fsucc y} f'x=f'y = applyEquality fsucc ((subInjIsInjective inj) (fsuccInjective f'x=f'y)) Bijection.surj tweakedBij fzero = fzero , refl Bijection.surj tweakedBij (fsucc b) with subSurj b ... | ans , prop = fsucc ans , applyEquality fsucc prop compBij : Bijection (λ i → flip f (tweakedF i)) compBij = bijectionComp tweakedBij bijFlip undoTweakMakesF : {x : FinSet (succ (succ n))} → flip f (tweakedF x) ≡ f x undoTweakMakesF {fzero} = refl undoTweakMakesF {fsucc x} with inspect (f fzero) undoTweakMakesF {fsucc x} | fzero with≡ x₁ with inspect (f (fsucc x)) undoTweakMakesF {fsucc x} | fzero with≡ x₁ | fzero with≡ x₂ with inspect (f fzero) undoTweakMakesF {fsucc x} | fzero with≡ x₁ | fzero with≡ x2 | fzero with≡ x3 = exFalso (fzeroNotFsucc (inj (transitivity x3 (equalityCommutative x2)))) undoTweakMakesF {fsucc x} | fzero with≡ x1 | fzero with≡ x2 | fsucc y with≡ x3 = exFalso (fzeroNotFsucc (inj (transitivity x1 (equalityCommutative x2)))) undoTweakMakesF {fsucc x} | fzero with≡ x1 | fsucc y with≡ x2 = equalityCommutative x2 undoTweakMakesF {fsucc x} | fsucc y with≡ x₁ with inspect (f (fsucc x)) undoTweakMakesF {fsucc x} | fsucc y with≡ x₁ | fzero with≡ x₂ with inspect (f fzero) undoTweakMakesF {fsucc x} | fsucc y with≡ x₁ | fzero with≡ x2 | fzero with≡ x3 = exFalso (fzeroNotFsucc (inj (transitivity x3 (equalityCommutative x2)))) undoTweakMakesF {fsucc x} | fsucc y with≡ x₁ | fzero with≡ x₂ | fsucc pr with≡ x₃ with finsetDecidableEquality pr y undoTweakMakesF {fsucc x} | fsucc y with≡ x₁ | fzero with≡ x2 | fsucc pr with≡ x₃ | inl x₄ = equalityCommutative x2 undoTweakMakesF {fsucc x} | fsucc y with≡ x1 | fzero with≡ x₂ | fsucc pr with≡ x3 | inr pr!=y = exFalso (pr!=y (fsuccInjective (transitivity (equalityCommutative x3) x1))) undoTweakMakesF {fsucc x} | fsucc y with≡ x₁ | fsucc thi with≡ x₂ with finsetDecidableEquality thi y undoTweakMakesF {fsucc x} | fsucc .thi with≡ x1 | fsucc thi with≡ x2 | inl refl = exFalso false where p : f fzero ≡ f (fsucc x) p = transitivity x1 (equalityCommutative x2) q : fzero ≡ fsucc x q = inj p false : False false = fzeroNotFsucc q undoTweakMakesF {fsucc x} | fsucc y with≡ x₁ | fsucc thi with≡ x2 | inr thi!=y = equalityCommutative x2 ans : Bijection f ans = bijectionPreservedUnderExtensionalEq compBij undoTweakMakesF pigeonhole : {n m : ℕ} → (m <N n) → {f : FinSet n → FinSet m} → Injection f → False pigeonhole {zero} {zero} () {f} property pigeonhole {zero} {succ m} () {f} property pigeonhole {succ n} {zero} m<n {f} property = finset0Empty (f fzero) pigeonhole {succ zero} {succ m} m<n {f} property with canRemoveSuccFrom<N m<n pigeonhole {succ zero} {succ m} m<n {f} property | le x () pigeonhole {succ (succ n)} {succ zero} m<n {f} property = fzeroNotFsucc (property (transitivity f0 (equalityCommutative f1))) where f0 : f (fzero) ≡ fzero f0 with inspect (f fzero) ... | fzero with≡ x = x ... | fsucc () with≡ _ f1 : f (fsucc fzero) ≡ fzero f1 with inspect (f (fsucc fzero)) ... | fzero with≡ x = x ... | fsucc () with≡ _ pigeonhole {succ (succ n)} {succ (succ m)} m<n {f} injF = intoSmallerNotSurj {_}{_} {m<n} surj where inj : Injection ((intoSmaller m<n) ∘ f) inj = injComp injF (intoSmallerInj m<n) bij : Bijection ((intoSmaller m<n) ∘ f) bij = injectionIsBijectionFinset inj surj : Surjection (intoSmaller m<n) surj = compSurjLeftSurj (Bijection.surj bij) --surjectionIsBijectionFinset : {n : ℕ} → {f : FinSet n → FinSet n} → Surjection f → Bijection f --surjectionIsBijectionFinset {zero} {f} surj = nopointBij f --surjectionIsBijectionFinset {succ zero} {f} surj = onepointBij f --surjectionIsBijectionFinset {succ (succ n)} {f} record { property = property } = {!!} ofNatToNat : {n : ℕ} → (a : FinSet n) → ofNat (toNat a) (toNatSmaller a) ≡ a ofNatToNat {zero} () ofNatToNat {succ n} fzero = refl ofNatToNat {succ n} (fsucc a) = applyEquality fsucc (ofNatToNat a)
{ "alphanum_fraction": 0.6518199642, "avg_line_length": 62.2334217507, "ext": "agda", "hexsha": "13dcc9fd443005f7723679c182d80df9803136dd", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Sets/FinSet/Lemmas.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Sets/FinSet/Lemmas.agda", "max_line_length": 221, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Sets/FinSet/Lemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 9202, "size": 23462 }
{-# OPTIONS --without-K --rewriting #-} module C1.LEM where open import Basics open import Bool open import LEM open import NotNot open import Flat open import Sharp open import C1.Base open import lib.NType2 -- UNFINISHED due to ♯-ptwise problems ♯-prop-is-¬¬ : ∀ {i}(P : PropT i) (p : (P holds) is-codiscrete) → (P holds) ≃ ((not (not P)) holds) ♯-prop-is-¬¬ P p = iff-to-≃ {P = P} {Q = not (not P)} -- ⇒ continue -- ⇐ (not (not P) holds –⟨ lemma ⟩→ ♯ (P holds) –⟨ un♯ p ⟩→ P holds →∎) where postulate lemma : not (not P) holds → ♯ (P holds) -- The problem here is that ♯-ptwise won't rewrite to ♯ (P holds) -- So, we can't run the right proof. -- I'm not sure why though... nbhd-is-infinitesimal : ∀ {i} {A : hSet i} (a : ∈ A) → (nbhd a) is-infinitesimal nbhd-is-infinitesimal {A = (A , p)} a = has-level-in (((a , refl≈)^♯) , (λ b' → ♯-=-retract $ let♯ b ^♯:= b' in♯ (♯-=-compare (<– (♯-prop-is-¬¬ (♯ₙ $ (a , refl≈) ==ₚ b) (♯-is-codiscrete ((a , refl≈) == b))) {!snd b!})) ^♯ in-family (λ b' → ((a , refl≈)^♯) == b')))
{ "alphanum_fraction": 0.4556669237, "avg_line_length": 28.8222222222, "ext": "agda", "hexsha": "8673faa1992a1be8ea19e1d922ebc03d809ee309", "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/C1/LEM.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/C1/LEM.agda", "max_line_length": 101, "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/C1/LEM.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": 465, "size": 1297 }
------------------------------------------------------------------------ -- Products implemented using records ------------------------------------------------------------------------ -- It it ever becomes convenient to pattern match on records I might -- make this the default implementation of products. module Data.Product.Record where open import Data.Function infixr 4 _,_ infixr 2 _×_ _-×-_ _-,-_ ------------------------------------------------------------------------ -- Definition record Σ (a : Set) (b : a → Set) : Set where field proj₁ : a proj₂ : b proj₁ open Σ public _×_ : (a b : Set) → Set a × b = Σ a (λ _ → b) ------------------------------------------------------------------------ -- Functions _,_ : ∀ {a b} → (x : a) → b x → Σ a b (x , y) = record {proj₁ = x; proj₂ = y} <_,_> : ∀ {A} {B : A → Set} {C : ∀ {x} → B x → Set} (f : (x : A) → B x) → ((x : A) → C (f x)) → ((x : A) → Σ (B x) C) < f , g > x = (f x , g x) map : ∀ {A B P Q} → (f : A → B) → (∀ {x} → P x → Q (f x)) → Σ A P → Σ B Q map f g = < f ∘ proj₁ , g ∘ proj₂ > swap : ∀ {a b} → a × b → b × a swap = < proj₂ , proj₁ > _-×-_ : ∀ {a b} → (a → b → Set) → (a → b → Set) → (a → b → Set) f -×- g = f -[ _×_ ]₁- g _-,-_ : ∀ {a b c d} → (a → b → c) → (a → b → d) → (a → b → c × d) f -,- g = f -[ _,_ ]- g curry : {a : Set} {b : a → Set} {c : Σ a b → Set} → ((p : Σ a b) → c p) → ((x : a) → (y : b x) → c (x , y)) curry f x y = f (x , y) uncurry : {a : Set} {b : a → Set} {c : Σ a b → Set} → ((x : a) → (y : b x) → c (x , y)) → ((p : Σ a b) → c p) uncurry f p = f (proj₁ p) (proj₂ p)
{ "alphanum_fraction": 0.3499090358, "avg_line_length": 26.5967741935, "ext": "agda", "hexsha": "1a6d53301320b78e3203345dd2023dbe79e75180", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Data/Product/Record.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Data/Product/Record.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Data/Product/Record.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 610, "size": 1649 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Usage examples of the categorical view of the Sum type ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Sum.Categorical.Examples where open import Level open import Data.Sum import Data.Sum.Categorical.Left as Sumₗ open import Category.Functor open import Category.Monad -- Note that these examples are simple unit tests, because the type -- checker verifies them. private module Examplesₗ {a b} {A : Set a} {B : Set b} where open import Agda.Builtin.Equality open import Function module Sₗ = Sumₗ A b open RawFunctor Sₗ.functor -- This type to the right of ⊎ needs to be a "lifted" version of (B : Set b) -- that lives in the universe (Set (a ⊔ b)). fmapId : (x : A ⊎ (Lift a B)) → (id <$> x) ≡ x fmapId (inj₁ x) = refl fmapId (inj₂ y) = refl open RawMonad Sₗ.monad -- Now, let's show that "return" is a unit for >>=. We use Lift in exactly -- the same way as above. The data (x : B) then needs to be "lifted" to -- this new type (Lift B). returnUnitL : ∀ {x : B} {f : Lift a B → A ⊎ (Lift a B)} → ((return (lift x)) >>= f) ≡ f (lift x) returnUnitL = refl returnUnitR : (x : A ⊎ (Lift a B)) → (x >>= return) ≡ x returnUnitR (inj₁ _) = refl returnUnitR (inj₂ _) = refl -- And another (limited version of a) monad law... bindCompose : ∀ {f g : Lift a B → A ⊎ (Lift a B)} → (x : A ⊎ (Lift a B)) → ((x >>= f) >>= g) ≡ (x >>= (λ y → (f y >>= g))) bindCompose (inj₁ x) = refl bindCompose (inj₂ y) = refl
{ "alphanum_fraction": 0.538372764, "avg_line_length": 31.5090909091, "ext": "agda", "hexsha": "fae9aa24bf05a51c35d4272cbcec6232b1cf6063", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/Categorical/Examples.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/Categorical/Examples.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/Categorical/Examples.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 517, "size": 1733 }
{-# OPTIONS --without-K --safe #-} module Data.Empty.Base where open import Level data ⊥ : Type where infix 4.5 ¬_ ¬_ : Type a → Type a ¬ A = A → ⊥ ⊥-elim : ⊥ → A ⊥-elim ()
{ "alphanum_fraction": 0.5674157303, "avg_line_length": 11.8666666667, "ext": "agda", "hexsha": "43a9e65b8a2f23c6723aa009aa932c250d4d9904", "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/Empty/Base.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/Empty/Base.agda", "max_line_length": 34, "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/Empty/Base.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": 67, "size": 178 }
module btls-certs where open import Data.Word8 using (Word8) renaming (primWord8fromNat to to𝕎) open import Data.ByteString using (ByteString; Strict; Lazy; pack) open import Data.ByteString.Primitive using (∣List∣≡∣Strict∣) open import Data.ByteVec using (ByteVec) open import Data.Nat using (ℕ; zero; suc; _<_; z≤n; s≤s; _≤?_; _∸_) open import Data.Nat.DivMod using (_divMod_; result) open import Data.Fin using (Fin; toℕ) open import Data.Vec using (Vec; toList; tabulate) open import Data.List using (List; []; _∷_; length; _++_; take) open import Data.Product using (Σ; _,_; proj₁) open import Relation.Nullary using (Dec; yes; no) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans) import Data.ByteString.IO as BSIO open import IO open import Function using (_∘_) open import ASN1.Util using (base256) import ASN1.BER as BER import ASN1.X509 open import Bee2.Crypto.Belt using (beltHash) open import Bee2.Crypto.Bign using (Pri; Pub; Sig; bignCalcPubkey; bignSign2) b : ℕ → List Word8 b n = toList (tabulate {n} (to𝕎 ∘ toℕ)) b256 = b 256 x : (len : ℕ) → ℕ → Σ (List Word8) (λ l → len ≡ length l) x zero n = [] , refl x (suc len) n with n divMod 256 ... | result q r _ with x len q ... | ns , refl = (to𝕎 (toℕ r) ∷ ns) , refl mkPri : ℕ → Pri mkPri n with x 32 n ... | (ns , prf) = (pack ns) , sym (trans (∣List∣≡∣Strict∣ ns (p prf 32<2³¹)) (sym prf)) where p : ∀ {u v k} → (u≡v : u ≡ v) → u < k → v < k p refl u<k = u<k 32<2³¹ : 32 < _ 32<2³¹ = s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s ( s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s ( s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s ( s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s ( s≤s z≤n)))))))))))))))))))))))))))))))) ca-pri : Pri ca-pri = mkPri 17 ca-pub : Pub ca-pub = bignCalcPubkey ca-pri sign : Pri → ByteString Strict → ByteString Strict sign pri = proj₁ ∘ bignSign2 pri ∘ beltHash ca-cert : ByteString Lazy ca-cert = BER.encode′ cert where open ASN1.X509.mkCert "issuer" "subject" "20170101000000Z" "20190101000000Z" (proj₁ ca-pub) (sign ca-pri) main = run (BSIO.writeBinaryFile "ca.pkc" ca-cert)
{ "alphanum_fraction": 0.6451918522, "avg_line_length": 32.984375, "ext": "agda", "hexsha": "0d2cfc25eeec28c616f54569f09e294a800720b9", "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": "bbbeb679fa2c55a12f0cb345ad920c999c3f8fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/asn1-agda", "max_forks_repo_path": "app/btls-certs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bbbeb679fa2c55a12f0cb345ad920c999c3f8fa8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "semenov-vladyslav/asn1-agda", "max_issues_repo_path": "app/btls-certs.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "bbbeb679fa2c55a12f0cb345ad920c999c3f8fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/asn1-agda", "max_stars_repo_path": "app/btls-certs.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 865, "size": 2111 }
module Functor where open import Category as Cat record Functor (ℂ ⅅ : Cat) : Set1 where field F : Cat.Obj ℂ -> Cat.Obj ⅅ map : {A B : Cat.Obj ℂ} -> Cat._─→_ ℂ A B -> Cat._─→_ ⅅ (F A) (F B) mapEq : {A B : Cat.Obj ℂ}{f g : Cat._─→_ ℂ A B} -> Category._==_ ℂ f g -> Category._==_ ⅅ (map f) (map g) mapId : {A : Cat.Obj ℂ} -> Category._==_ ⅅ (map (Cat.id ℂ {A})) (Cat.id ⅅ) mapCompose : {A B C : Cat.Obj ℂ}{f : Cat._─→_ ℂ B C}{g : Cat._─→_ ℂ A B} -> Category._==_ ⅅ (map (Cat._∘_ ℂ f g)) (Cat._∘_ ⅅ (map f) (map g))
{ "alphanum_fraction": 0.4808013356, "avg_line_length": 37.4375, "ext": "agda", "hexsha": "60060480b8b8f34bcc3bfce0714b1b1d897e123d", "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/outdated-and-incorrect/AIM6/Cat/Functor.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/outdated-and-incorrect/AIM6/Cat/Functor.agda", "max_line_length": 83, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/Functor.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": 253, "size": 599 }
-- Andreas, 2015-07-22 -- {-# OPTIONS -v tc.term:20 -v tc.meta.assign:10 -v tc.conv.coerce:10 #-} open import Common.Size data Nat (i : Size) : Set where suc : (j : Size< i) → Nat j → Nat i min : ∀ i → Nat i → Nat i → Nat i min i (suc j n) (suc k m) = suc i' (min i' n m) where i' = _ -- Size consistency check should not be circumvented -- by putting the meta in a definition.
{ "alphanum_fraction": 0.6108247423, "avg_line_length": 24.25, "ext": "agda", "hexsha": "06ab8a8a37baeb942095a2ba130ac23ad4341791", "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/Fail/Issue1615.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/Fail/Issue1615.agda", "max_line_length": 74, "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/Fail/Issue1615.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": 135, "size": 388 }
open import FRP.JS.Nat using ( ℕ ) open import FRP.JS.String using ( String ) module FRP.JS.Geolocation.Angle where postulate Angle : Set _° : ℕ → Angle _′ : ℕ → Angle _″ : ℕ → Angle _+_ : Angle → Angle → Angle toString : Angle → String {-# COMPILED_JS _° function(x) { return ((x + 180) % 360) - 180; } #-} {-# COMPILED_JS _′ function(x) { return (((x / 60) + 180) % 360) - 180; } #-} {-# COMPILED_JS _″ function(x) { return (((x / 3600) + 180) % 360) - 180; } #-} {-# COMPILED_JS _+_ function(x) { return function (y) { return x + y; }; } #-} {-# COMPILED_JS toString function(x) { return x.toString(); } #-}
{ "alphanum_fraction": 0.5862619808, "avg_line_length": 32.9473684211, "ext": "agda", "hexsha": "be4c8ac7e07cc6c8daab77ca459615a731776d73", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "src/agda/FRP/JS/Geolocation/Angle.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "src/agda/FRP/JS/Geolocation/Angle.agda", "max_line_length": 79, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "src/agda/FRP/JS/Geolocation/Angle.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 216, "size": 626 }
-- Andreas, 2018-11-03, issue #3361 -- -- Empty variable blocks should trigger warning rather than parse error. variable -- Expected warning: -- Empty variable block.
{ "alphanum_fraction": 0.7337278107, "avg_line_length": 18.7777777778, "ext": "agda", "hexsha": "4ad3bef4a1cfdd9fd68ea3cdb4162d1bdc99dfb2", "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/Issue3361.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/Issue3361.agda", "max_line_length": 72, "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/Issue3361.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": 40, "size": 169 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Booleans ------------------------------------------------------------------------ module Data.Bool where open import Function open import Data.Unit using (⊤) open import Data.Empty open import Level open import Relation.Nullary open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl) infixr 6 _∧_ infixr 5 _∨_ _xor_ infix 0 if_then_else_ ------------------------------------------------------------------------ -- The boolean type data Bool : Set where true : Bool false : Bool {-# BUILTIN BOOL Bool #-} {-# BUILTIN TRUE true #-} {-# BUILTIN FALSE false #-} {-# COMPILED_DATA Bool Bool True False #-} ------------------------------------------------------------------------ -- Some operations not : Bool → Bool not true = false not false = true -- A function mapping true to an inhabited type and false to an empty -- type. T : Bool → Set T true = ⊤ T false = ⊥ if_then_else_ : ∀ {a} {A : Set a} → Bool → A → A → A if true then t else f = t if false then t else f = f _∧_ : Bool → Bool → Bool true ∧ b = b false ∧ b = false _∨_ : Bool → Bool → Bool true ∨ b = true false ∨ b = b _xor_ : Bool → Bool → Bool true xor b = not b false xor b = b ------------------------------------------------------------------------ -- Queries _≟_ : Decidable {A = Bool} _≡_ true ≟ true = yes refl false ≟ false = yes refl true ≟ false = no λ() false ≟ true = no λ() ------------------------------------------------------------------------ -- Some properties decSetoid : DecSetoid _ _ decSetoid = PropEq.decSetoid _≟_
{ "alphanum_fraction": 0.4893992933, "avg_line_length": 21.4936708861, "ext": "agda", "hexsha": "8c804248a4d0fad338d3a0bbea6effc71cb9250a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Bool.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Bool.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Bool.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 422, "size": 1698 }
{-# OPTIONS --safe #-} module Definition.Typed.Consequences.Inversion where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.Substitution open import Tools.Product import Tools.PropositionalEquality as PE -- Inversion of Universes inversion-U : ∀ {Γ C rU lU r} → Γ ⊢ Univ rU lU ∷ C ^ r → Γ ⊢ C ≡ U ¹ ^ [ ! , next ¹ ] × r PE.≡ [ ! , next ¹ ] × lU PE.≡ ⁰ inversion-U (univ 0<1 x) = refl (Ugenⱼ x) , PE.refl , PE.refl inversion-U (conv x x₁) with inversion-U x ... | [C≡U] , PE.refl , PE.refl = trans (sym x₁) [C≡U] , PE.refl , PE.refl -- Inversion of natural number type. inversion-ℕ : ∀ {Γ C r} → Γ ⊢ ℕ ∷ C ^ r → Γ ⊢ C ≡ U ⁰ ^ r × r PE.≡ [ ! , next ⁰ ] inversion-ℕ (ℕⱼ x) = refl (Ugenⱼ x) , PE.refl inversion-ℕ (conv x x₁) with inversion-ℕ x ... | [C≡U] , PE.refl = trans (sym x₁) [C≡U] , PE.refl -- Inversion of Π-types. inversion-Π : ∀ {F rF G r Γ C lF lG lΠ} → Γ ⊢ Π F ^ rF ° lF ▹ G ° lG ° lΠ ∷ C ^ r → ∃ λ rG → lF ≤ lΠ × lG ≤ lΠ × Γ ⊢ F ∷ Univ rF lF ^ [ ! , next lF ] × Γ ∙ F ^ [ rF , ι lF ] ⊢ G ∷ Univ rG lG ^ [ ! , next lG ] × Γ ⊢ C ≡ Univ rG lΠ ^ [ ! , next lΠ ] × r PE.≡ [ ! , next lΠ ] inversion-Π (Πⱼ_▹_▹_▹_ {rF = rF} {r = rG} l< l<' x x₁) = rG , l< , l<' , x , x₁ , refl (Ugenⱼ (wfTerm x)) , PE.refl inversion-Π (conv x x₁) = let rG , l< , l<' , a , b , c , r≡! = inversion-Π x in rG , l< , l<' , a , b , trans (sym (PE.subst (λ rx → _ ⊢ _ ≡ _ ^ rx) r≡! x₁)) c , r≡! -- Inversion of ∃-types. inversion-∃ : ∀ {F G Γ C r} → Γ ⊢ ∃ F ▹ G ∷ C ^ r → ∃ λ l∃ → Γ ⊢ F ∷ Univ % l∃ ^ [ ! , next l∃ ] × Γ ∙ F ^ [ % , ι l∃ ] ⊢ G ∷ Univ % l∃ ^ [ ! , next l∃ ] × Γ ⊢ C ≡ Univ % l∃ ^ [ ! , next l∃ ] × r PE.≡ [ ! , next l∃ ] inversion-∃ (∃ⱼ_▹_ {l = l∃} x x₁) = l∃ , x , x₁ , refl (Ugenⱼ (wfTerm x)) , PE.refl inversion-∃ (conv x x₁) = let l∃ , a , b , c , r≡! = inversion-∃ x in l∃ , a , b , trans (sym (PE.subst (λ rx → _ ⊢ _ ≡ _ ^ rx) r≡! x₁)) c , r≡! inversion-Empty : ∀ {Γ C r l} → Γ ⊢ Empty l ∷ C ^ r → Γ ⊢ C ≡ SProp l ^ r × r PE.≡ [ ! , next l ] inversion-Empty (Emptyⱼ x) = refl (Ugenⱼ x) , PE.refl inversion-Empty (conv x x₁) = let C≡SProp , r = inversion-Empty x in trans (sym x₁) C≡SProp , r -- Inversion of zero. inversion-zero : ∀ {Γ C r} → Γ ⊢ zero ∷ C ^ r → Γ ⊢ C ≡ ℕ ^ [ ! , ι ⁰ ] × r PE.≡ [ ! , ι ⁰ ] inversion-zero (zeroⱼ x) = univ (refl (ℕⱼ x)) , PE.refl inversion-zero (conv x x₁) with inversion-zero x ... | [C≡ℕ] , PE.refl = trans (sym x₁) [C≡ℕ] , PE.refl -- Inversion of successor. inversion-suc : ∀ {Γ t C r} → Γ ⊢ suc t ∷ C ^ r → Γ ⊢ t ∷ ℕ ^ [ ! , ι ⁰ ] × Γ ⊢ C ≡ ℕ ^ [ ! , ι ⁰ ] × r PE.≡ [ ! , ι ⁰ ] inversion-suc (sucⱼ x) = x , refl (univ (ℕⱼ (wfTerm x))) , PE.refl inversion-suc (conv x x₁) with inversion-suc x ... | a , b , PE.refl = a , trans (sym x₁) b , PE.refl -- Inversion of natural recursion. inversion-natrec : ∀ {Γ c g n A C rlC lC} → Γ ⊢ natrec lC C c g n ∷ A ^ rlC → ∃ λ rC → (Γ ∙ ℕ ^ [ ! , ι ⁰ ]) ⊢ C ^ [ rC , ι lC ] × Γ ⊢ c ∷ C [ zero ] ^ [ rC , ι lC ] × Γ ⊢ g ∷ Π ℕ ^ ! ° ⁰ ▹ (C ^ rC ° lC ▹▹ C [ suc (var 0) ]↑ ° lC ° lC) ° lC ° lC ^ [ rC , ι lC ] × Γ ⊢ n ∷ ℕ ^ [ ! , ι ⁰ ] × Γ ⊢ A ≡ C [ n ] ^ [ rC , ι lC ] × rlC PE.≡ [ rC , ι lC ] inversion-natrec (natrecⱼ x d d₁ n) = _ , x , d , d₁ , n , refl (substType x n) , PE.refl inversion-natrec (conv d x) = let a' , a , b , c , d , e , e' = inversion-natrec d in a' , a , b , c , d , trans (sym (PE.subst (λ rx → _ ⊢ _ ≡ _ ^ rx) e' x)) e , e' inversion-Emptyrec : ∀ {Γ e A C rlC lEmpty lC} → Γ ⊢ Emptyrec lC lEmpty C e ∷ A ^ rlC → ∃ λ rC → Γ ⊢ C ^ [ rC , ι lC ] × Γ ⊢ e ∷ Empty lEmpty ^ [ % , ι lEmpty ] × Γ ⊢ A ≡ C ^ [ rC , ι lC ] × rlC PE.≡ [ rC , ι lC ] inversion-Emptyrec (Emptyrecⱼ [C] [e]) = _ , [C] , [e] , refl [C] , PE.refl inversion-Emptyrec (conv d x) = let r , a , b , c , e = inversion-Emptyrec d in r , a , b , trans (sym (PE.subst (λ rx → _ ⊢ _ ≡ _ ^ rx) e x)) c , e -- Inversion of application. inversion-app : ∀ {Γ f a A r lΠ} → Γ ⊢ (f ∘ a ^ lΠ) ∷ A ^ r → ∃₂ λ F rF → ∃₂ λ lF G → ∃₂ λ lG rG → Γ ⊢ f ∷ Π F ^ rF ° lF ▹ G ° lG ° lΠ ^ [ rG , ι lΠ ] × Γ ⊢ a ∷ F ^ [ rF , ι lF ] × Γ ⊢ A ≡ G [ a ] ^ [ rG , ι lG ] × r PE.≡ [ rG , ι lG ] inversion-app (d ∘ⱼ d₁) = _ , _ , _ , _ , _ , _ , d , d₁ , refl (substTypeΠ (syntacticTerm d) d₁) , PE.refl inversion-app (conv d x) = let a , b , c , d , e , f , g , h , i , j = inversion-app d in a , b , c , d , e , f , g , h , trans (sym (PE.subst (λ rx → _ ⊢ _ ≡ _ ^ rx) j x)) i , j -- Inversion of lambda. inversion-lam : ∀ {t F A r lΠ Γ} → Γ ⊢ lam F ▹ t ^ lΠ ∷ A ^ r → ∃₂ λ rF lF → ∃₂ λ G rG → ∃ λ lG → Γ ⊢ F ^ [ rF , ι lF ] × Γ ∙ F ^ [ rF , ι lF ] ⊢ t ∷ G ^ [ rG , ι lG ] × Γ ⊢ A ≡ Π F ^ rF ° lF ▹ G ° lG ° lΠ ^ [ rG , ι lΠ ] × r PE.≡ [ rG , ι lΠ ] inversion-lam (lamⱼ l< l<' x x₁) = _ , _ , _ , _ , _ , x , x₁ , refl (univ (Πⱼ l< ▹ l<' ▹ (un-univ x) ▹ un-univ (syntacticTerm x₁))) , PE.refl inversion-lam (conv x x₁) = let a , b , c , d , e , f , g , h , i = inversion-lam x in a , b , c , d , e , f , g , trans (sym (PE.subst (λ rx → _ ⊢ _ ≡ _ ^ rx) i x₁)) h , i -- Inversion of Id-types. inversion-Id : ∀ {A t u C r Γ} → Γ ⊢ Id A t u ∷ C ^ r → ∃ λ l → Γ ⊢ A ∷ U l ^ [ ! , next l ] × Γ ⊢ t ∷ A ^ [ ! , ι l ] × Γ ⊢ u ∷ A ^ [ ! , ι l ] × Γ ⊢ C ≡ SProp l ^ [ ! , next l ] × r PE.≡ [ ! , next l ] inversion-Id (Idⱼ {l = l} A t u) = l , A , t , u , refl (Ugenⱼ (wfTerm A)) , PE.refl inversion-Id (conv x x₁) = let l , a , b , c , d , r≡! = inversion-Id x in l , a , b , c , trans (sym (PE.subst (λ rx → _ ⊢ _ ≡ _ ^ rx) r≡! x₁)) d , r≡! -- Inversion of cast-types. inversion-cast : ∀ {A B e t l C r Γ} → Γ ⊢ cast l A B e t ∷ C ^ r → ∃ λ rA → Γ ⊢ A ∷ Univ rA l ^ [ ! , next ⁰ ] × Γ ⊢ B ∷ Univ rA l ^ [ ! , next ⁰ ] × Γ ⊢ e ∷ Id (Univ rA l) A B ^ [ % , next ⁰ ] × Γ ⊢ t ∷ A ^ [ rA , ι ⁰ ] × Γ ⊢ C ≡ B ^ [ rA , ι ⁰ ] × r PE.≡ [ rA , ι ⁰ ] × l PE.≡ ⁰ inversion-cast (castⱼ X X₁ X₂ X₃) = _ , X , X₁ , X₂ , X₃ , refl (univ X₁) , PE.refl , PE.refl inversion-cast (conv x x₁) = let r , a , b , c , d , e , r≡! , el = inversion-cast x in r , a , b , c , d , trans (sym (PE.subst (λ rx → _ ⊢ _ ≡ _ ^ rx) r≡! x₁)) e , r≡! , el
{ "alphanum_fraction": 0.4391165359, "avg_line_length": 46.8163265306, "ext": "agda", "hexsha": "58593bb8c7bd3e16b24beea37c1141f1d01ce218", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Consequences/Inversion.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Consequences/Inversion.agda", "max_line_length": 121, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Consequences/Inversion.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": 3138, "size": 6882 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Unit {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Introductions.Universe open import Definition.LogicalRelation.Irrelevance open import Tools.Unit open import Tools.Product -- Validity of the Unit type. Unitᵛ : ∀ {Γ l} ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ l ⟩ Unit / [Γ] Unitᵛ [Γ] ⊢Δ [σ] = Unitᵣ (idRed:*: (Unitⱼ ⊢Δ)) , λ _ x₂ → id (Unitⱼ ⊢Δ) -- Validity of the Unit type as a term. Unitᵗᵛ : ∀ {Γ} ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ ¹ ⟩ Unit ∷ U / [Γ] / Uᵛ [Γ] Unitᵗᵛ [Γ] ⊢Δ [σ] = let ⊢Unit = Unitⱼ ⊢Δ [Unit] = Unitᵣ (idRed:*: (Unitⱼ ⊢Δ)) in Uₜ Unit (idRedTerm:*: ⊢Unit) Unitₙ (≅ₜ-Unitrefl ⊢Δ) [Unit] , (λ x x₁ → Uₜ₌ Unit Unit (idRedTerm:*: ⊢Unit) (idRedTerm:*: ⊢Unit) Unitₙ Unitₙ (≅ₜ-Unitrefl ⊢Δ) [Unit] [Unit] (id (Unitⱼ ⊢Δ))) -- Validity of star. starᵛ : ∀ {Γ l} ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ l ⟩ star ∷ Unit / [Γ] / Unitᵛ [Γ] starᵛ [Γ] ⊢Δ [σ] = Unitₜ star (idRedTerm:*: (starⱼ ⊢Δ)) starₙ , (λ _ x₁ → Unitₜ₌ (starⱼ ⊢Δ) (starⱼ ⊢Δ)) -- Validity of η-unit. η-unitᵛ : ∀ {Γ l e e'} ([Γ] : ⊩ᵛ Γ) ([Unit] : Γ ⊩ᵛ⟨ l ⟩ Unit / [Γ]) ([e] : Γ ⊩ᵛ⟨ l ⟩ e ∷ Unit / [Γ] / [Unit]) ([e'] : Γ ⊩ᵛ⟨ l ⟩ e' ∷ Unit / [Γ] / [Unit]) → Γ ⊩ᵛ⟨ l ⟩ e ≡ e' ∷ Unit / [Γ] / [Unit] η-unitᵛ {Γ} {l} {e} {e'} [Γ] [Unit] [e] [e'] {Δ} {σ} ⊢Δ [σ] = let J = proj₁ ([Unit] ⊢Δ [σ]) [σe] = proj₁ ([e] ⊢Δ [σ]) [σe'] = proj₁ ([e'] ⊢Δ [σ]) UnitJ : Δ ⊩⟨ l ⟩ Unit UnitJ = Unitᵣ (idRed:*: (Unitⱼ ⊢Δ)) [σe] = irrelevanceTerm J UnitJ [σe] [σe'] = irrelevanceTerm J UnitJ [σe'] ⊢σe = escapeTerm UnitJ [σe] ⊢σe' = escapeTerm UnitJ [σe'] in irrelevanceEqTerm UnitJ J (Unitₜ₌ ⊢σe ⊢σe')
{ "alphanum_fraction": 0.5613540197, "avg_line_length": 36.6724137931, "ext": "agda", "hexsha": "c4c95a91c7cf42397b6f717a2df1c34ad522b1d9", "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": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "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": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Unit.agda", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 961, "size": 2127 }
module z03-natural-numbers where open import bool open import bool-thms using (𝔹-contra) open import eq open import level -- p 50 data ℕ : Set where zero : ℕ suc : ℕ → ℕ -- p 51 {-# BUILTIN NATURAL ℕ #-} ------------------------- _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc (m + n) -- recursive call on structurally smaller left side 'm' -- termination -- p 53 ------------------------- 0+ : ∀ (x : ℕ) → 0 + x ≡ x 0+ _ = refl -- via definitional equality {- fails because _+_ defined in terms of pattern matching on left arg +0 : ∀ (x : ℕ) → x + 0 ≡ x +0 _ = refl -- p 55 solution is for proof to call itself recursively: ------------------------- -} +0 : ∀ (x : ℕ) → x + 0 ≡ x -- BASE +0 zero = refl -- via definitional equality -- INDUCTIVE -- note: name of 'y' variable, if renamed to 'x', is not same as 'x' in signature +0 (suc y) rewrite +0 y = refl {- ^ | 'x' in sig instantiated to 'suc y' so trying to prove (the goal) : suc y + 0 ≡ suc y goal can be simplified by inductive case of def of _+_ so goal definitionally equal to : suc (y + 0) ≡ suc y rewrite recursive call proves y + 0 ≡ y type of proof is x + 0 ≡ x so Agda with replace occurrences of x + 0 with x leaving : suc y ≡ suc y -- p 57 PROOF BY INDUCTION: recursive proofs ------------------------------------------------------------------------------ + ASSOCIATIVITY When theorem has multiple variables, must decide which one to use for induction. Generally: var used where a recursive fun will patten match on it. If several vars are pattern matched, prefer the one that is matched the most. Since _+_ matches on 1st arg, then do induction here on 1st arg. Here 'x' is matched twice but 'y' only once -- so use 'x'. -} ------------------------- +assoc : ∀ (x y z : ℕ) → x + (y + z) ≡ (x + y) + z {- BASE case goal: zero + (y + z) ≡ (zero + y) + z via def/eq -} +assoc zero y z = refl {- INDUCTIVE case goal : suc (x + (y + z)) ≡ suc ((x + y) + z) need proof of : (x + (y + z)) ≡ ((x + y) + z) that is exactly the inductive hypotheses so use rewrite to recursively apply the proof -} +assoc (suc x) y z rewrite +assoc x y z = refl ------------------------------------------------------------------------------ -- p 60 + COMMUTATIVITY (rewrite with multiple equations) ------------------------- +suc : ∀ (x y : ℕ) → x + (suc y) ≡ suc (x + y) +suc zero y = refl +suc (suc x) y rewrite +suc x y = refl ------------------------- +comm : ∀ (x y : ℕ) → x + y ≡ y + x {- BASE Goal: : y ≡ (y + zero) so rewrite right hand side using +0 proof simplifies to : y ≡ y -} +comm zero y rewrite +0 y = refl {- INDUCTIVE Goal : suc (x + y) ≡ (y + suc x) -} +comm (suc x) y rewrite +suc y x | +comm x y = refl ------------------------------------------------------------------------------ -- p 62 MULTIPLICATION ------------------------- _*_ : ℕ → ℕ → ℕ zero * n = zero suc m * n = n + (m * n) ------------------------- -- p 63 - right distributivity of * over + -- variable counts x : 2; y : 1; z : 0 : so use x *distribr : ∀ (x y z : ℕ) → (x + y) * z ≡ (x * z) + (y * z) -- BASE *distribr zero y z = refl {- INDUCTIVE Goal: ((suc x + y) * z) ≡ ((suc x * z) + (y * z)) Goal: (z + ((x + y) * z)) ≡ ((z + (x * z)) + (y * z)) *distribr (suc x) y z rewrite *distribr x y z = {!!} Goal: (z + ((x * z) + (y * z))) ≡ ((z + (x * z)) + (y * z)) right-associated left-associated so reassociate: to prove A + (B + C) ≡ (A + B) + C ^ ^ ^ | | | z | | x * z | y * z -} *distribr (suc x) y z rewrite *distribr x y z = +assoc z (x * z) (y * z) ------------------------------------------------------------------------------ -- p 65 * COMMUTATIVITY ------------------------- *0 : ∀ (x : ℕ) → x * 0 ≡ 0 -- BASE *0 zero = refl -- def/eq : (zero * 0) ≡ 0 {- INDUCTIVE (suc x * 0) ≡ 0 (x * 0) ≡ 0 -- IH rewrite 0 ≡ 0 -} *0 (suc y) rewrite *0 y = refl ------------------------- *suc : ∀ (x y : ℕ) → x * (suc y) ≡ x + (x * y) {- BASE (zero * suc y) ≡ (zero + (zero * y)) def/eq zero ≡ zero -} *suc zero y = refl {- INDUCTIVE (suc x * suc y) ≡ (suc x + (suc x * y)) def/eq suc (y + (x * suc y)) ≡ suc (x + (y + (x * y))) rw *suc suc (y + (x + (x * y))) ≡ suc (x + (y + (x * y))) rw +assoc suc ((y + x) + (x * y)) ≡ suc (x + (y + (x * y))) rw +assoc suc ((y + x) + (x * y)) ≡ suc ((x + y) + (x * y)) rw +comm suc ((x + y) + (x * y)) ≡ suc ((x + y) + (x * y)) -} *suc (suc x) y rewrite *suc x y | +assoc y x (x * y) | +assoc x y (x * y) | +comm y x = refl ------------------------- *comm : ∀ (x y : ℕ) → x * y ≡ y * x {- BASE (zero * y) ≡ (y * zero) def/eq zero ≡ (y * zero) rs *0 zero ≡ zero -} *comm zero y rewrite *0 y = refl {- INDUCTIVE (suc x * y) ≡ (y * suc x) def/eq (y + (x * y)) ≡ (y * suc x) rw *suc (y + (x * y)) ≡ (y + (y * x)) rw *comm (y + (y * x)) ≡ (y + (y * x)) -} *comm (suc x) y rewrite *suc y x | *comm x y = refl ------------------------------------------------------------------------------ -- p 66 * ASSOCIATIVITY *assoc : ∀ (x y z : ℕ) → x * (y * z) ≡ (x * y) * z {- BASE (zero * (y * z)) ≡ ((zero * y) * z) def/eq zero ≡ zero -} *assoc zero y z = refl {- INDUCTIVE (suc x * (y * z)) ≡ ((suc x * y) * z) def/eq ((y * z) + (x * (y * z))) ≡ ((y + (x * y)) * z) rw *distribr ((y * z) + (x * (y * z))) ≡ ((y * z) + ((x * y) * z)) rw *assoc ((y * z) + ((x * y) * z)) ≡ ((y * z) + ((x * y) * z)) -} *assoc (suc x) y z rewrite *distribr y (x * y) z | *assoc x y z = refl ------------------------------------------------------------------------------ -- p 67 LESS-THEN < _<_ : ℕ → ℕ → 𝔹 0 < 0 = ff 0 < (suc y) = tt (suc x) < (suc y) = x < y (suc x) < 0 = ff ------------------------- -- < is TRANSITIVE {- xx : ∀ {x y z : ℕ} → x < y → y < z → x < z Above will not type check because _<_ returns 𝔹 VALUE, not a type Types have type Set in Agda -- 𝔹 is not the same as Set. Could define _<_ as a relation: ℕ → ℕ → Set. But then _<_ could not be used computationally. Expressions with type Set describe code -- they are NOT code themselves - e.g., cannot pattern-match on expressions of type Set cannot compute with them Transitivity theorem is statement about behavior of the PROGRAM _<_. -} -- p 69 ------------------------- <-0 : ∀ (x : ℕ) → x < 0 ≡ ff <-0 0 = refl -- (zero < 0) ≡ ff; ff ≡ ff <-0 (suc y) = refl -- (suc y < 0) ≡ ff; ff ≡ ff ------------------------- <-trans : ∀ {x y z : ℕ} → x < y ≡ tt → y < z ≡ tt → x < z ≡ tt {- p1 : (x < zero) ≡ tt ; p2 : (zero < z) ≡ tt = Goal: (x < z) ≡ tt rw <-0 p1 : ff ≡ tt ; p2 : (0 < z) ≡ tt = Goal: (x < z) ≡ tt -} <-trans {x} {0} p1 p2 rewrite <-0 x = 𝔹-contra p1 -- can't be called like this so no proof needed <-trans {0} {suc y} {0} p1 () -- p1 : (zero < suc y) ≡ tt ; p2 : (suc y < suc z) ≡ tt = Goal: (zero < suc z) ≡ tt <-trans {0} {suc y} {suc z} p1 p2 = refl -- can't be called like this so no proof needed <-trans {suc x} {suc y} {0} p1 () -- p1 : (suc x < suc y) ≡ tt; p2 : (suc y < suc z) ≡ tt = Goal: (suc x < suc z) ≡ tt <-trans {suc x} {suc y} {suc z} p1 p2 = <-trans {x} {y} {z} p1 p2 -- uses IH via recursive call ------------------------------------------------------------------------------ -- p 71 EQUALITY TEST for ℕ {- so far, rely on - def/eq : done automatically during type checking - ≡ : express, as a TYPE, a proposition that two VALUES are equal there are other kinds of equality, e,g., COMPUTATIONAL EQUALITY : tests VALUE equality -} _=ℕ_ : ℕ → ℕ → 𝔹 0 =ℕ 0 = tt suc x =ℕ suc y = x =ℕ y _ =ℕ _ = ff _≤_ : ℕ → ℕ → 𝔹 x ≤ y = (x < y) || x =ℕ y ------------------------- =ℕ-refl : ∀ (x : ℕ) → (x =ℕ x) ≡ tt =ℕ-refl 0 = refl =ℕ-refl (suc x) = (=ℕ-refl x) ------------------------- -- SOUNDNESS property: things indicated to be true really are true =ℕ-to-≡ : ∀ {x y : ℕ} → x =ℕ y ≡ tt → x ≡ y =ℕ-to-≡ {0} {0} _ = refl =ℕ-to-≡ {suc x} {0} () =ℕ-to-≡ {0} {suc y} () =ℕ-to-≡ {suc x} {suc y} p rewrite =ℕ-to-≡ {x} {y} p = refl ------------------------- =ℕ-from-≡ : ∀ {x y : ℕ} → x ≡ y → x =ℕ y ≡ tt =ℕ-from-≡ {x} refl = =ℕ-refl x ------------------------------------------------------------------------------ -- p 73 EXERCISES -- 1 nat-thms -------------------------------------------------- -- properties of addition -------------------------------------------------- +1 : ∀ (x : ℕ) → x + 1 ≡ suc x +1 zero = refl +1 (suc n) rewrite +1 n = refl +perm : ∀ (x y z : ℕ) → x + (y + z) ≡ y + (x + z) +perm zero y z = refl +perm (suc x) y z -- (suc x + (y + z)) ≡ (y + (suc x + z)) -- suc (x + (y + z)) ≡ (y + suc (x + z)) rewrite +suc y (x + z) -- suc (x + (y + z)) ≡ suc (y + (x + z)) | +assoc x y z -- suc ((x + y) + z) ≡ suc (y + (x + z)) | +comm x y -- suc ((y + x) + z) ≡ suc (y + (x + z)) | +assoc y x z -- suc ((y + x) + z) ≡ suc ((y + x) + z) = refl -------------------------------------------------- -- properties of multiplication -------------------------------------------------- *1 : ∀ {n : ℕ} → n * 1 ≡ n *1 {zero} = refl *1 {suc n} -- (suc n * 1) ≡ suc n -- suc (n * 1) ≡ suc n rewrite *comm n 1 -- suc (n + 0) ≡ suc n | +0 n -- suc n ≡ suc n = refl -------------------------------------------------- -- properties of <, ≤, and =ℕ, iszero -------------------------------------------------- 0-≤ : ∀ (x : ℕ) → 0 ≤ x ≡ tt 0-≤ zero = refl 0-≤ (suc n) -- (0 ≤ suc n) ≡ tt rewrite 0-≤ n -- tt ≡ tt = refl =ℕ-sym : ∀ (x y : ℕ) → (x =ℕ y) ≡ (y =ℕ x) =ℕ-sym zero zero = refl =ℕ-sym (suc x) zero = refl -- (suc x =ℕ zero) ≡ (zero =ℕ suc x); ff ≡ ff =ℕ-sym zero (suc y) = refl -- (zero =ℕ suc y) ≡ (suc y =ℕ zero); ff ≡ ff =ℕ-sym (suc x) (suc y) rewrite =ℕ-sym x y = refl =ℕ-suc : ∀ (x : ℕ) → suc x =ℕ x ≡ ff =ℕ-suc zero = refl =ℕ-suc (suc n) rewrite =ℕ-suc n = refl <-suc : ∀ (n : ℕ) → n < suc n ≡ tt <-suc zero = refl <-suc (suc n) rewrite <-suc n = refl -- TODO: understand suc-inj : ∀ {n m : ℕ} → suc n ≡ suc m → n ≡ m suc-inj {0} {0} _ = refl suc-inj {m = suc m} refl = refl <=ℕff : ∀ (x : ℕ) → 0 < x ≡ tt → x =ℕ 0 ≡ ff <=ℕff (suc x) _ = refl <≤ : ∀ {n m : ℕ} → n < m ≡ tt → n ≤ m ≡ tt <≤ {0} {0} _ = refl <≤ {suc _} {0} () <≤ {0} {suc _} _ = refl <≤ {suc n} {suc m} p rewrite <≤ {n} {m} p = refl -------------------------------------------------- -- ordering properties of < and ≤ℕ -------------------------------------------------- <-irrefl : ∀ (n : ℕ) → n < n ≡ ff <-irrefl zero = refl <-irrefl (suc n) rewrite <-irrefl n = refl <-asym : ∀ {x y : ℕ} → x < y ≡ tt → y < x ≡ ff <-asym {0} {0} _ = refl <-asym {0} {suc _} _ = refl <-asym {suc _} {0} () <-asym {suc x} {suc y} p = <-asym {x} {y} p ℕ-trichotomy𝔹 : ∀ (n m : ℕ) → n < m || n =ℕ m || m < n ≡ tt ℕ-trichotomy𝔹 0 0 = refl ℕ-trichotomy𝔹 0 (suc m) = refl ℕ-trichotomy𝔹 (suc n) 0 = refl ℕ-trichotomy𝔹 (suc n) (suc m) = ℕ-trichotomy𝔹 n m <≤-trans : ∀ {x y z : ℕ} → x < y ≡ tt → y ≤ z ≡ tt → x < z ≡ tt <≤-trans {x} {0} p1 _ rewrite <-0 x = 𝔹-contra p1 <≤-trans {0} {suc y} {0} _ () <≤-trans {0} {suc y} {suc z} _ _ = refl <≤-trans {suc x} {suc y} {0} _ () <≤-trans {suc x} {suc y} {suc z} p1 p2 = <≤-trans {x} {y} {z} p1 p2 ≤-refl : ∀ (x : ℕ) → x ≤ x ≡ tt ≤-refl zero = refl ≤-refl (suc x) rewrite ≤-refl x = refl -------------------------------------------------- -- injectivity properties of addition -------------------------------------------------- +inj1 : ∀ {x y z : ℕ} → x + y ≡ x + z → y ≡ z +inj1 {0} {y} {z} p = p +inj1 {suc x} {y} {z} p = +inj1 {x} {y} {z} (suc-inj p) +inj2 : ∀ {x y z : ℕ} → x + z ≡ y + z → x ≡ y +inj2 {x} {y} {z} p -- p : (x + z) ≡ (y + z); Goal: x ≡ y rewrite +comm x z -- p : (z + x) ≡ (y + z); Goal: x ≡ y | +comm y z -- p : (z + x) ≡ (z + y); Goal: x ≡ y = +inj1 {z} {x} {y} p -- NOTE: '+inj1' ------------------------------------------------------------------------------ -- 2 {- TODO nat.agda >, >= : defined in terms of < and <= Prove versions of theorems like <-trans and <+ - modified to use _>_ instead of _<_ for practice writing out formulas in Agda since the proofs can be written just to invoke the theorems dealing with _<_ -} _>_ : ℕ → ℕ → 𝔹 a > b = b < a _≥_ : ℕ → ℕ → 𝔹 a ≥ b = b ≤ a <-trans2 : ∀ {x y z : ℕ} → y > x ≡ tt → z > y ≡ tt → z > x ≡ tt <-trans2 {x} {y} {z} = <-trans {x} {y} {z} ------------------------------------------------------------------------------ -- 3a f : (n : ℕ) → ℕ f 0 = 1 f (suc x) = (suc x) * (f x) f-is-factorial : f 5 ≡ 120 f-is-factorial = refl -- 3b f' : ℕ → 𝔹 fb : ℕ → 𝔹 -- is-odd f' 0 = ff f' (suc x) = fb x -- is-even fb 0 = tt fb (suc x) = f' x f'-is-odd : f' (suc 0) ≡ tt f'-is-odd = refl fb-is-even : fb (suc (suc 0)) ≡ tt fb-is-even = refl
{ "alphanum_fraction": 0.4037441038, "avg_line_length": 25.0794824399, "ext": "agda", "hexsha": "b8ecc2f982821bf43142fcea0d2d821fe50a33ad", "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/z03-natural-numbers.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/z03-natural-numbers.agda", "max_line_length": 95, "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/z03-natural-numbers.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": 5260, "size": 13568 }
{- Denotational semantics of the contexts in the category of temporal types. -} module Semantics.Context where open import CategoryTheory.Categories open import CategoryTheory.Instances.Reactive open import CategoryTheory.Functor open import CategoryTheory.Comonad open import CategoryTheory.NatTrans open import TemporalOps.Box open import TemporalOps.Diamond open import Syntax.Context open import Semantics.Types open import Data.Product renaming (_,_ to _,,_) open import Relation.Binary.PropositionalEquality open Comonad W-□ private module F-□ = Functor F-□ -- | Denotation of judgements and contexts -- Denotation of judgements ⟦_⟧ⱼ : Judgement -> τ ⟦ A now ⟧ⱼ = ⟦ A ⟧ₜ ⟦ A always ⟧ⱼ = □ ⟦ A ⟧ₜ infix 50 ⟦_⟧ⱼ -- Denotation of contexts as a finite product of temporal types. ⟦_⟧ₓ : Context -> τ ⟦ ∙ ⟧ₓ = ⊤ ⟦ Γ , A ⟧ₓ = ⟦ Γ ⟧ₓ ⊗ ⟦ A ⟧ⱼ infix 50 ⟦_⟧ₓ -- Denotation of context to denotation of stabilised context -- Standard morphism arising from Γ ˢ ⊆ Γ ⟦_ˢ⟧ : ∀ Γ -> ⟦ Γ ⟧ₓ ⇴ ⟦ Γ ˢ ⟧ₓ ⟦ ∙ ˢ⟧ = ! ⟦ Γ , A now ˢ⟧ = ⟦ Γ ˢ⟧ ∘ π₁ ⟦ Γ , A always ˢ⟧ = ⟦ Γ ˢ⟧ * id -- Denotation of context to stable denotation of stabilised context -- Uses the Cartesian functor property of the □ comonad ⟦_ˢ⟧□ : ∀ Γ -> ⟦ Γ ⟧ₓ ⇴ □ ⟦ Γ ˢ ⟧ₓ ⟦ ∙ ˢ⟧□ = u ⟦ Γ , A now ˢ⟧□ = ⟦ Γ ˢ⟧□ ∘ π₁ ⟦ Γ , A always ˢ⟧□ = m (⟦ Γ ˢ ⟧ₓ) (□ ⟦ A ⟧ₜ) ∘ (⟦ Γ ˢ⟧□ * δ.at ⟦ A ⟧ₜ) -- The normal stabilisation transformation factors through -- the comonadic one via ε ⟦ˢ⟧-factor : ∀ Γ -> ⟦ Γ ˢ⟧ ≈ ε.at ⟦ Γ ˢ ⟧ₓ ∘ ⟦ Γ ˢ⟧□ ⟦ˢ⟧-factor ∙ = refl ⟦ˢ⟧-factor (Γ , A now) {n} {x ,, y} = ⟦ˢ⟧-factor Γ ⟦ˢ⟧-factor (Γ , A always) {n} {x ,, y} rewrite ⟦ˢ⟧-factor Γ {n} {x} = refl -- Applying ⟦ˢ⟧□ twice can be replaced with one ⟦ˢ⟧□ and duplication ⟦ˢ⟧□-twice : ∀ Δ -> F-□.fmap ⟦ Δ ˢ ˢ⟧□ ∘ ⟦ Δ ˢ⟧□ ≈ δ.at ⟦ Δ ˢ ˢ ⟧ₓ ∘ ⟦ Δ ˢ ˢ⟧□ ∘ ⟦ Δ ˢ⟧ ⟦ˢ⟧□-twice ∙ = refl ⟦ˢ⟧□-twice (Δ , A now) = ⟦ˢ⟧□-twice Δ ⟦ˢ⟧□-twice (Δ , A always) {n} {⟦Δ⟧ ,, □⟦A⟧} = ext λ k → ext λ l → cong (_,, □⟦A⟧) (lemma k l) where lemma : ∀ k l -> ⟦ Δ ˢ ˢ⟧□ k (⟦ Δ ˢ⟧□ n ⟦Δ⟧ k) l ≡ ⟦ Δ ˢ ˢ⟧□ n (⟦ Δ ˢ⟧ n ⟦Δ⟧) l lemma k l = □-≡ k l (□-≡ n k (⟦ˢ⟧□-twice Δ {n} {⟦Δ⟧}) k) l -- Applying ⟦ˢ⟧□ and ⟦ˢ⟧ can be commuted ⟦ˢ⟧-comm : ∀ Δ -> ⟦ Δ ˢ ˢ⟧□ ∘ ⟦ Δ ˢ⟧ ≈ F-□.fmap ⟦ Δ ˢ ˢ⟧ ∘ ⟦ Δ ˢ⟧□ ⟦ˢ⟧-comm Δ {n} {⟦Δ⟧} = ext (lemma Δ ⟦Δ⟧) where lemma : ∀ Δ ⟦Δ⟧ l -> (⟦ Δ ˢ ˢ⟧□ ∘ ⟦ Δ ˢ⟧) n ⟦Δ⟧ l ≡ (F-□.fmap ⟦ Δ ˢ ˢ⟧ ∘ ⟦ Δ ˢ⟧□) n ⟦Δ⟧ l lemma ∙ ⟦Δ⟧ l = refl lemma (Δ , A now) (⟦Δ⟧ ,, ⟦A⟧) l = lemma Δ ⟦Δ⟧ l lemma (Δ , A always) (⟦Δ⟧ ,, □⟦A⟧) l = cong (_,, □⟦A⟧) (lemma Δ ⟦Δ⟧ l)
{ "alphanum_fraction": 0.5529503712, "avg_line_length": 35.0547945205, "ext": "agda", "hexsha": "1bc2770b994a2bde48ed602ce8b9e4162a3ad61f", "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/Semantics/Context.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/Semantics/Context.agda", "max_line_length": 93, "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/Semantics/Context.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": 1400, "size": 2559 }
module Examples where open import Prelude open import Star open import Modal El : Set -> Rel True El A _ _ = A List : Set -> Set List A = Star (El A) _ _ Nat = List True zero : Nat zero = ε suc : Nat -> Nat suc n = _ • n -- Vectors Vec : Set -> Nat -> Set Vec A = All (\_ -> A) infixr 40 _::_ _::_ : {A : Set}{n : Nat} -> A -> Vec A n -> Vec A (suc n) x :: xs = check x • xs -- Fin Fin : Nat -> Set Fin = Any (\_ -> True) -- Turning a vector to a list vecToList : {A : Set}{n : Nat} -> Vec A n -> List A vecToList {A} = map ! uncheck listToVec : {A : Set}(xs : List A) -> Vec A (length xs) listToVec ε = ε listToVec (x • xs) = x :: listToVec xs -- span test : Vec Nat (suc (suc (suc zero))) test = zero :: suc zero :: suc (suc zero) :: ε
{ "alphanum_fraction": 0.562992126, "avg_line_length": 15.5510204082, "ext": "agda", "hexsha": "3dc38d2517537eaed7978fe2fde624ec9018db94", "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/AIM6/Path/Examples.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/AIM6/Path/Examples.agda", "max_line_length": 58, "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/AIM6/Path/Examples.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": 275, "size": 762 }
module Control.Monad.Maybe where open import Prelude open import Control.Monad.Zero open import Control.Monad.Transformer record MaybeT {a} (M : Set a → Set a) (A : Set a) : Set a where no-eta-equality constructor maybeT field runMaybeT : M (Maybe A) open MaybeT public module _ {a} {M : Set a → Set a} where instance FunctorMaybeT : {{_ : Functor M}} → Functor {a = a} (MaybeT M) runMaybeT (fmap {{FunctorMaybeT}} f m) = fmap f <$> runMaybeT m FunctorZeroMaybeT : {{_ : Monad M}} → FunctorZero {a = a} (MaybeT M) runMaybeT (empty {{FunctorZeroMaybeT}}) = return nothing AlternativeMaybeT : {{_ : Monad M}} → Alternative {a = a} (MaybeT M) runMaybeT (_<|>_ {{AlternativeMaybeT {{monadM}}}} mx my) = do just x ← runMaybeT mx where nothing → runMaybeT my return (just x) module _ {{_ : Monad M}} where private bindMaybeT : ∀ {A B} → MaybeT M A → (A → MaybeT M B) → MaybeT M B runMaybeT (bindMaybeT m f) = do just x ← runMaybeT m where nothing → return nothing runMaybeT (f x) instance ApplicativeMaybeT : Applicative {a = a} (MaybeT M) runMaybeT (pure {{ApplicativeMaybeT}} x) = pure (just x) _<*>_ {{ApplicativeMaybeT}} = monadAp bindMaybeT MonadMaybeT : Monad {a = a} (MaybeT M) _>>=_ {{MonadMaybeT}} = bindMaybeT liftMaybeT : {A : Set a} → M A → MaybeT M A runMaybeT (liftMaybeT m) = just <$> m instance TransformerMaybeT : ∀ {a} → Transformer {a} MaybeT lift {{TransformerMaybeT}} = liftMaybeT
{ "alphanum_fraction": 0.6252414681, "avg_line_length": 29.3018867925, "ext": "agda", "hexsha": "8e6b1bd8c3c04f29413692efedc0e381189beb14", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Control/Monad/Maybe.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Control/Monad/Maybe.agda", "max_line_length": 72, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Control/Monad/Maybe.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 498, "size": 1553 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020 Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import Data.Nat open import Data.Maybe open import Data.Char open import Data.String open import Data.List hiding (product) open import Relation.Binary.PropositionalEquality import Relation.Binary.PropositionalEquality as PE using (_≡_; refl) import Relation.Binary.Definitions as BD import Relation.Binary as RB ------------------------------------------------------------------------------ open import Function open import Optics.All module Optics.Example where infixl 1 _&_ _&_ = Function._|>_ -- First we declare a record; which must be EXACTLY -- like the record 'Person' below. -- that is; must contain a constructor and -- a number of /simple/ fields (of type Set; no proofs please!) record Person : Set where constructor person field pName : String pAge : ℕ -- Then, we do some template agda: -- Yes,I know it looks weird; but it says: -- Put 'pName' and 'pAge' into scope as -- new identifiers; and run the metacomputation mkLens -- passing this newly created identifiers; the mkLens -- will then bind these identifiers to their respective -- generated lenses for the record Person -- -- IMPORTANT: Note how I did NOT /open Person/; otherwise, we'd -- have to give different names to the lenses. -- -- IMPORTANT: the list of names passed to unquoteDecl must come -- in the same order as the fields of Person. unquoteDecl pName pAge = mkLens (quote Person) (pName ∷ pAge ∷ []) -- Ok; lets do more recors for fun record Store : Set where constructor store field sId : ℕ sManager : Person unquoteDecl sId sManager = mkLens (quote Store) (sId ∷ sManager ∷ []) record Product : Set where constructor product field pId : ℕ pTag : String pStore : Store unquoteDecl pId pTag pStore = mkLens (quote Product) (pId ∷ pTag ∷ pStore ∷ []) -- Let's now do a simple example: mary : Person mary = person "Mary" 41 compilers-from-mary : Store compilers-from-mary = store 0 mary ghc : Product ghc = product 13 "v8.0.0" compilers-from-mary -- Now say mary turns 42 years old; ghc-from-older-mary : Product ghc-from-older-mary = ghc & pStore ∙ sManager ∙ pAge ∙~ 42 same-ghc-from-mary : Product same-ghc-from-mary = ghc & pStore ∙ sManager ∙ pAge %~ suc all-is-fine : ghc-from-older-mary ≡ same-ghc-from-mary all-is-fine = refl mary's-age-was-updated : ghc-from-older-mary ^∙ pStore ∙ sManager ∙ pAge ≡ 42 mary's-age-was-updated = refl
{ "alphanum_fraction": 0.6797361671, "avg_line_length": 28.4270833333, "ext": "agda", "hexsha": "34df05fcfee1e8b7b0114d0d49b56de9dba58593", "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/Optics/Example.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/Optics/Example.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/Optics/Example.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 747, "size": 2729 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Equivalence where -- Strong equivalence of categories. Same as ordinary equivalence in Cat. -- May not include everything we'd like to think of as equivalences, namely -- the full, faithful functors that are essentially surjective on objects. open import Level open import Relation.Binary using (IsEquivalence; Setoid) open import Categories.Category.Core using (Category) open import Categories.Functor renaming (id to idF) open import Categories.NaturalTransformation.NaturalIsomorphism as ≃ using (NaturalIsomorphism ; unitorˡ; unitorʳ; associator; _ⓘᵥ_; _ⓘˡ_; _ⓘʳ_) private variable o ℓ e : Level C D E : Category o ℓ e record WeakInverse (F : Functor C D) (G : Functor D C) : Set (levelOfTerm F ⊔ levelOfTerm G) where field F∘G≈id : NaturalIsomorphism (F ∘F G) idF G∘F≈id : NaturalIsomorphism (G ∘F F) idF module F∘G≈id = NaturalIsomorphism F∘G≈id module G∘F≈id = NaturalIsomorphism G∘F≈id record StrongEquivalence {o ℓ e o′ ℓ′ e′} (C : Category o ℓ e) (D : Category o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where field F : Functor C D G : Functor D C weak-inverse : WeakInverse F G open WeakInverse weak-inverse public refl : StrongEquivalence C C refl = record { F = idF ; G = idF ; weak-inverse = record { F∘G≈id = unitorˡ ; G∘F≈id = unitorˡ } } sym : StrongEquivalence C D → StrongEquivalence D C sym e = record { F = G ; G = F ; weak-inverse = record { F∘G≈id = G∘F≈id ; G∘F≈id = F∘G≈id } } where open StrongEquivalence e trans : StrongEquivalence C D → StrongEquivalence D E → StrongEquivalence C E trans {C = C} {D = D} {E = E} e e′ = record { F = e′.F ∘F e.F ; G = e.G ∘F e′.G ; weak-inverse = record { F∘G≈id = let module S = Setoid (≃.Functor-NI-setoid E E) in S.trans (S.trans (associator (e.G ∘F e′.G) e.F e′.F) (e′.F ⓘˡ (unitorˡ ⓘᵥ (e.F∘G≈id ⓘʳ e′.G) ⓘᵥ ≃.sym (associator e′.G e.G e.F)))) e′.F∘G≈id ; G∘F≈id = let module S = Setoid (≃.Functor-NI-setoid C C) in S.trans (S.trans (associator (e′.F ∘F e.F) e′.G e.G) (e.G ⓘˡ (unitorˡ ⓘᵥ (e′.G∘F≈id ⓘʳ e.F) ⓘᵥ ≃.sym (associator e.F e′.F e′.G)))) e.G∘F≈id } } where module e = StrongEquivalence e module e′ = StrongEquivalence e′ isEquivalence : ∀ {o ℓ e} → IsEquivalence (StrongEquivalence {o} {ℓ} {e}) isEquivalence = record { refl = refl ; sym = sym ; trans = trans } setoid : ∀ o ℓ e → Setoid _ _ setoid o ℓ e = record { Carrier = Category o ℓ e ; _≈_ = StrongEquivalence ; isEquivalence = isEquivalence }
{ "alphanum_fraction": 0.581754386, "avg_line_length": 31.6666666667, "ext": "agda", "hexsha": "60c36ac4a5769efba23a5acf637e0ad084b416bb", "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": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-categories", "max_forks_repo_path": "src/Categories/Category/Equivalence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "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": "bblfish/agda-categories", "max_issues_repo_path": "src/Categories/Category/Equivalence.agda", "max_line_length": 125, "max_stars_count": 5, "max_stars_repo_head_hexsha": "7672b7a3185ae77467cc30e05dbe50b36ff2af8a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bblfish/agda-categories", "max_stars_repo_path": "src/Categories/Category/Equivalence.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": 1034, "size": 2850 }
module Numeral.Natural.Oper.Modulo.Proofs where import Lvl open import Data open import Data.Boolean.Stmt open import Functional open import Logic open import Logic.Propositional open import Logic.Predicate open import Numeral.Natural open import Numeral.Natural.Oper open import Numeral.Natural.Oper.Comparisons open import Numeral.Natural.Oper.FlooredDivision open import Numeral.Natural.Oper.Modulo open import Numeral.Natural.Oper.Modulo.Proofs.Algorithm open import Numeral.Natural.Oper.Proofs open import Numeral.Natural.Oper.Proofs.Order open import Numeral.Natural.Relation open import Numeral.Natural.Relation.Divisibility open import Numeral.Natural.Relation.Divisibility.Proofs open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Existence using ([≤]-equivalence) open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs open import Structure.Function open import Structure.Operator open import Structure.Operator.Proofs.Util open import Structure.Operator.Properties open import Structure.Relator.Properties open import Syntax.Function open import Syntax.Implication open import Syntax.Transitivity open import Syntax.Type open import Type open import Numeral.Natural.Oper.DivMod.Proofs -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- mod₀ and mod mod₀-mod : ∀{a b} → ((a mod₀ 𝐒(b)) ≡ (a mod 𝐒(b))) mod₀-mod = [≡]-intro -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- mod open import Numeral.Natural.Inductions open import Structure.Relator open import Structure.Relator.Ordering {- mod-elim : ∀{ℓ} → (P : {ℕ} → ℕ → Type{ℓ}) → ∀{b} ⦃ _ : IsTrue(positive?(b)) ⦄ → (∀{a} → (a < b) → P{a}(a)) → (∀{a} → (a ≥ b) → P{a −₀ b}((a −₀ b) mod b) → P{a}(a mod b)) → (∀{a} → P{a}(a mod b)) mod-elim P {𝐒 b} base step {a} = Strict.Properties.wellfounded-recursion(_<_) {P = a ↦ P(a mod 𝐒(b))} p a where ord : ∀{a b} → (b < a) → (a −₀ 𝐒(b) < a) ord {𝐒 a} {b} _ = succ ([−₀]-lesser {a}{b}) p : (a : ℕ) → ((prev : ℕ) ⦃ _ : prev < a ⦄ → P(prev mod 𝐒(b))) → P(a mod 𝐒(b)) p a prev with [<][≥]-dichotomy {a}{𝐒 b} ... | [∨]-introₗ lt = substitute₁ₗ(P) (mod'-lesser-dividend ([≤]-without-[𝐒] lt)) (base{a} lt) ... | [∨]-introᵣ ge = step ge (prev(a −₀ 𝐒(b)) ⦃ ord{a}{b} ge ⦄) -} -- 0 is 0 in every modulus. mod-of-0 : ∀{b} → (0 mod 𝐒(b) ≡ 0) mod-of-0 = [≡]-intro -- There is only one value when the modulus is 1, and that is 0. mod-of-1 : ∀{a} → (a mod 1 ≡ 0) mod-of-1 {a} = mod'-zero-all-except-dividend {a} -- When the dividend is lesser than the modulus, the result is unchanged. mod-lesser-than-modulus : ∀{a b} → ⦃ _ : a ≤ b ⦄ → (a mod 𝐒(b) ≡ a) mod-lesser-than-modulus {a} {b} ⦃ ab ⦄ = mod'-lesser-dividend ab -- The value of the modulo operation is always strictly less than the modulus. -- This is because the value loops around at the end by definition. mod-maxᵣ : ∀{a b} → ⦃ _ : IsTrue(positive?(b)) ⦄ → (a mod b < b) mod-maxᵣ {𝟎} {𝐒 𝟎} = [≤]-with-[𝐒] mod-maxᵣ {𝟎} {𝐒(𝐒 b)} = [≤]-with-[𝐒] mod-maxᵣ {𝐒 a} {𝐒 𝟎} = mod-maxᵣ {a}{𝐒 𝟎} mod-maxᵣ {𝐒 a} {𝐒(𝐒 b)} = [≤]-with-[𝐒] ⦃ mod'-maxᵣ {1}{b}{a}{b} ⦃ reflexivity(_≤_)⦄ ⦄ -- When proving properties about the modulo operation, only proofs about numbers lesser than the modulus is necessary. mod-intro : ∀{ℓ} → (P : {ℕ} → ℕ → Type{ℓ}) → ∀{b} ⦃ _ : IsTrue(positive?(b)) ⦄ → (∀{a n} → (a < b) → P{a + (n ⋅ b)}(a)) → (∀{a} → P{a}(a mod b)) mod-intro P {𝐒 b} proof {a} with [<][≥]-dichotomy {a}{𝐒 b} ... | [∨]-introₗ lt = substitute₂(\x y → P{x}(y)) (reflexivity(_≡_)) (symmetry(_≡_) (mod-lesser-than-modulus ⦃ [≤]-without-[𝐒] lt ⦄)) (proof{a}{0} lt) ... | [∨]-introᵣ ge = substitute₂(\x y → P{x}(y)) ([↔]-to-[→] ([−₀][+]-nullify2ᵣ {(a ⌊/⌋ 𝐒(b)) ⋅ 𝐒(b)}{a}) (subtransitivityᵣ(_≤_)(_≡_) ([≤]-of-[+]ₗ {(a ⌊/⌋ 𝐒(b)) ⋅ 𝐒(b)}{a mod 𝐒(b)}) ([⌊/⌋][mod]-is-division-with-remainder {a}{b}))) (symmetry(_≡_) ([⌊/⌋][⋅]-inverseOperatorᵣ-error {a}{b})) (proof{a −₀ ((a ⌊/⌋ 𝐒(b)) ⋅ 𝐒(b))}{a ⌊/⌋ 𝐒(b)} (subtransitivityₗ(_<_)(_≡_) (symmetry(_≡_) ([⌊/⌋][⋅]-inverseOperatorᵣ-error {a}{b})) (mod-maxᵣ{a}{𝐒 b}))) mod-intro₂ : ∀{ℓ} → (P : {ℕ} → {ℕ} → ℕ → ℕ → Type{ℓ}) → ∀{m} ⦃ _ : IsTrue(positive?(m)) ⦄ → (∀{a b n₁ n₂} → (a < m) → (b < m) → P{a + (n₁ ⋅ m)}{b + (n₂ ⋅ m)}(a)(b)) → (∀{a b} → P{a}{b}(a mod m)(b mod m)) mod-intro₂ P {m} p {a}{b} = mod-intro(\{a} am → P{a}{b}(am)(b mod m)) {m} (\{a}{n₁} an₁ → mod-intro(\{b} bm → P{a + (n₁ ⋅ m)}{b}(a)(bm)) {m} (\{b}{n₂} bn₂ → p {a}{b}{n₁}{n₂} an₁ bn₂) {b}) {a} -- The modulus is the loop point of the dividend. mod-of-modulus : ∀{b} → (𝐒(b) mod 𝐒(b) ≡ 𝟎) mod-of-modulus {b} = mod'-equal-dividend {𝟎}{b}{b} -- Adding the modulus to the dividend does not alter the result. mod-of-modulus-add : ∀{a b} → ((𝐒(b) + a) mod 𝐒(b) ≡ a mod 𝐒(b)) mod-of-modulus-add {a}{b} = mod'-sumₗ-modulo {𝟎}{b}{a}{b} mod-of-modulus-addᵣ : ∀{a b} → ((a + 𝐒(b)) mod 𝐒(b) ≡ a mod 𝐒(b)) mod-of-modulus-addᵣ {a}{b} = mod'-sumᵣ-modulo {𝟎}{b}{a}{b} -- A multiple of the modulus in the dividend is always 0. mod-of-modulus-multiple : ∀{a b} → ((𝐒(b) ⋅ a) mod 𝐒(b) ≡ 𝟎) mod-of-modulus-multiple {𝟎} {b} = [≡]-intro mod-of-modulus-multiple {𝐒 a} {b} = mod-of-modulus-add {𝐒(b) ⋅ a}{b} 🝖 mod-of-modulus-multiple {a} {b} mod-of-modulus-sum-multiple : ∀{a b c} ⦃ _ : IsTrue(positive?(b)) ⦄ → ((a + (b ⋅ c)) mod b ≡ a mod b) mod-of-modulus-sum-multiple {a} {𝐒 b} {𝟎} = [≡]-intro mod-of-modulus-sum-multiple {a} {𝐒 b} {𝐒 c} = (a + (𝐒(b) ⋅ 𝐒(c))) mod 𝐒(b) 🝖[ _≡_ ]-[] (a + (𝐒(b) + (𝐒(b) ⋅ c))) mod 𝐒(b) 🝖[ _≡_ ]-[ congruence₁(_mod 𝐒(b)) (associativity(_+_) {a}{𝐒(b)}{𝐒(b) ⋅ c}) ]-sym ((a + 𝐒(b)) + (𝐒(b) ⋅ c)) mod 𝐒(b) 🝖[ _≡_ ]-[ mod-of-modulus-sum-multiple {a + 𝐒(b)} {𝐒 b} {c} ] (a + 𝐒(b)) mod 𝐒(b) 🝖[ _≡_ ]-[ mod-of-modulus-addᵣ {a}{b} ] a mod 𝐒(b) 🝖-end mod-of-modulus-sum-multiple-commuted : ∀{a b c} ⦃ _ : IsTrue(positive?(b)) ⦄ → ((a + (c ⋅ b)) mod b ≡ a mod b) mod-of-modulus-sum-multiple-commuted {a}{𝐒 b}{c} = congruence₁(_mod 𝐒(b)) (congruence₂ᵣ(_+_)(a) (commutativity(_⋅_) {c}{𝐒 b})) 🝖 mod-of-modulus-sum-multiple{a}{𝐒 b}{c} -- When the dividend is greater than the modulus, the modulus can be subtracted from the dividend without altering the result. mod-greater-than-modulus : ∀{a b} → ⦃ _ : (a > b) ⦄ → (a mod 𝐒(b) ≡ (a −₀ 𝐒(b)) mod 𝐒(b)) mod-greater-than-modulus {a}{b} ⦃ a>b ⦄ = symmetry(_≡_) ([≡]-with(_mod 𝐒(b)) ([↔]-to-[→] [−₀][+]-nullify2 a>b)) 🝖 mod-of-modulus-add {a −₀ 𝐒(b)} {b} mod-cases : ∀{a b} → (a mod 𝐒(b) ≡ a) ∨ (a mod 𝐒(b) ≡ (a −₀ 𝐒(b)) mod 𝐒(b)) mod-cases {a}{b} with [≤][>]-dichotomy {a}{b} mod-cases {a}{b} | [∨]-introₗ a≤b = [∨]-introₗ (mod-lesser-than-modulus ⦃ a≤b ⦄) mod-cases {a}{b} | [∨]-introᵣ b>a = [∨]-introᵣ (mod-greater-than-modulus ⦃ b>a ⦄) mod-nested : ∀{a b c} → ⦃ b ≤ c ⦄ → ((a mod 𝐒(b)) mod 𝐒(c) ≡ a mod 𝐒(b)) mod-nested {a} {b} {c} ⦃ bc ⦄ = mod-lesser-than-modulus {a mod 𝐒(b)} ⦃ [≤]-without-[𝐒] (mod-maxᵣ {a}) 🝖 bc ⦄ mod-maxₗ : ∀{a b} → ⦃ _ : IsTrue(positive?(b)) ⦄ → (a mod b ≤ a) mod-maxₗ{a}{𝐒 b} = mod'-maxₗ{0}{b}{a}{b} -- Alternative proof: -- • Using [mod][∣ᵣₑₘ]-remainder-equality and that (_∣ᵣₑₘ_) using (r = 0) is equivalent to (_∣_). -- • A special case of: mod-congruence-[𝄩]. mod-divisibility : ∀{a b} → ⦃ _ : IsTrue(positive?(b)) ⦄ → (a mod b ≡ 𝟎) ↔ (b ∣ a) mod-divisibility {a}{𝐒(b)} = [↔]-intro l r where l : ∀{a b} → (a mod 𝐒(b) ≡ 𝟎) ← (𝐒(b) ∣ a) l {.0} {b} Div𝟎 = [≡]-intro l {.(𝐒 (b + a))} {b} (Div𝐒 {x = a} ba) = mod-of-modulus-add {a}{b} 🝖 l ba r : ∀{a b} → (a mod 𝐒(b) ≡ 𝟎) → (𝐒(b) ∣ a) r{a}{b} = Strict.Properties.wellfounded-recursion(_<_) {P = a ↦ ((a mod 𝐒(b) ≡ 𝟎) → (𝐒(b) ∣ a))} p a where p : (a : ℕ) → ((prev : ℕ) ⦃ _ : prev < a ⦄ → (prev mod 𝐒(b) ≡ 𝟎) → (𝐒(b) ∣ prev)) → (a mod 𝐒(b) ≡ 𝟎) → (𝐒(b) ∣ a) p a prev ab0 with [≤][>]-dichotomy {a}{b} ... | [∨]-introₗ ab rewrite symmetry(_≡_) (mod-lesser-than-modulus ⦃ ab ⦄) 🝖 ab0 = Div𝟎 ... | [∨]-introᵣ ba with [↔]-to-[←] [≤]-equivalence ba ... | [∃]-intro p ⦃ [≡]-intro ⦄ = divides-with-[+] divides-reflexivity (prev p ⦃ succ ([≤]-of-[+]ᵣ {b}{p}) ⦄ ( p mod 𝐒(b) 🝖-[ symmetry(_≡_) (mod-of-modulus-add {p}{b}) ] (𝐒(b) + p) mod 𝐒(b) 🝖-[ ab0 ] 𝟎 🝖-end )) mod-of-𝐒 : ∀{a b} → ⦃ pos : IsTrue(positive?(b)) ⦄ → (𝐒(a) mod b ≡ 𝐒(a mod b) mod b) mod-of-𝐒 {a} {𝐒 b} = mod-intro(\{a} → expr ↦ 𝐒(a) mod 𝐒(b) ≡ 𝐒(expr) mod 𝐒(b)) {𝐒(b)} (\{a}{n} → p{a}{n}) {a} where p : ∀{a n} → (a < 𝐒(b)) → (𝐒(a + (n ⋅ 𝐒(b))) mod 𝐒(b)) ≡ (𝐒(a) mod 𝐒(b)) p {a}{n} ab = 𝐒(a + (n ⋅ 𝐒(b))) mod 𝐒(b) 🝖[ _≡_ ]-[] (𝐒(a) + (n ⋅ 𝐒(b))) mod 𝐒(b) 🝖[ _≡_ ]-[ mod-of-modulus-sum-multiple-commuted {𝐒(a)}{𝐒(b)}{n} ] 𝐒(a) mod 𝐒(b) 🝖-end mod-of-[+] : ∀{a b m} → ⦃ pos : IsTrue(positive?(m)) ⦄ → ((a + b) mod m ≡ ((a mod m) + (b mod m)) mod m) mod-of-[+] {a}{b}{𝐒 m} = (a + b) mod 𝐒(m) 🝖[ _≡_ ]-[ congruence₁(_mod 𝐒(m)) (congruence₂(_+_) ([⌊/⌋][mod]-is-division-with-remainder{a}{m}) ([⌊/⌋][mod]-is-division-with-remainder{b}{m})) ]-sym ((((a ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m)) + (a mod 𝐒(m))) + (((b ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m)) + (b mod 𝐒(m)))) mod 𝐒(m) 🝖[ _≡_ ]-[ congruence₁(_mod 𝐒(m)) (One.associate-commute4-c {_▫_ = _+_} {a = (a ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m)}{a mod 𝐒(m)}{(b ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m)}{b mod 𝐒(m)}) ] ((((a ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m)) + ((b ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m))) + ((a mod 𝐒(m)) + (b mod 𝐒(m)))) mod 𝐒(m) 🝖[ _≡_ ]-[ congruence₁(_mod 𝐒(m)) (commutativity(_+_) {((a ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m)) + ((b ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m))}{(a mod 𝐒(m)) + (b mod 𝐒(m))}) ] (((a mod 𝐒(m)) + (b mod 𝐒(m))) + (((a ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m)) + ((b ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m)))) mod 𝐒(m) 🝖[ _≡_ ]-[ congruence₁(_mod 𝐒(m)) (congruence₂ᵣ(_+_)((a mod 𝐒(m)) + (b mod 𝐒(m))) (distributivityᵣ(_⋅_)(_+_) {a ⌊/⌋ 𝐒(m)}{b ⌊/⌋ 𝐒(m)}{𝐒(m)})) ]-sym (((a mod 𝐒(m)) + (b mod 𝐒(m))) + (((a ⌊/⌋ 𝐒(m)) + (b ⌊/⌋ 𝐒(m))) ⋅ 𝐒(m))) mod 𝐒(m) 🝖[ _≡_ ]-[ mod-of-modulus-sum-multiple-commuted{(a mod 𝐒(m)) + (b mod 𝐒(m))}{𝐒(m)}{(a ⌊/⌋ 𝐒(m)) + (b ⌊/⌋ 𝐒(m))} ] ((a mod 𝐒(m)) + (b mod 𝐒(m))) mod 𝐒(m) 🝖-end {- open import Functional open import Structure.Function open import Structure.Function.Domain {-# TERMINATING #-} mod-of-𝐒 : ∀{a b} → ⦃ pos : IsTrue(positive?(b)) ⦄ → (𝐒(a) mod b ≡ 𝐒(a mod b)) ∨ (𝐒(a) mod b ≡ 𝟎) mod-of-𝐒 {𝟎} {𝐒 𝟎} = [∨]-introᵣ [≡]-intro mod-of-𝐒 {𝟎} {𝐒 (𝐒 b)} = [∨]-introₗ [≡]-intro mod-of-𝐒 {a} {𝐒 b} with [<]-trichotomy {a}{b} ... | [∨]-introₗ([∨]-introₗ lt) = [∨]-introₗ $ 𝐒(a) mod 𝐒(b) 🝖[ _≡_ ]-[ mod-lesser-than-modulus ⦃ lt ⦄ ] 𝐒(a) 🝖[ _≡_ ]-[ congruence₁(𝐒) (mod-lesser-than-modulus ⦃ [≤]-predecessor lt ⦄) ]-sym 𝐒(a mod 𝐒(b)) 🝖-end ... | [∨]-introₗ([∨]-introᵣ [≡]-intro) = [∨]-introᵣ(mod-of-modulus{b}) ... | [∨]-introᵣ gt with mod-of-𝐒 {a −₀ 𝐒(b)}{𝐒 b} ... | [∨]-introₗ q = [∨]-introₗ ∘ injective(𝐒) $ 𝐒(𝐒(a) mod 𝐒(b)) 🝖[ _≡_ ]-[ congruence₁(𝐒) (mod-greater-than-modulus ⦃ [≤]-successor gt ⦄) ] 𝐒((𝐒(a) −₀ 𝐒(b)) mod 𝐒(b)) 🝖[ _≡_ ]-[ congruence₁(𝐒) (congruence₁(_mod 𝐒(b)) ([↔]-to-[→] [−₀][𝐒]ₗ-equality gt)) ] 𝐒(𝐒(a −₀ 𝐒(b)) mod 𝐒(b)) 🝖[ _≡_ ]-[ congruence₁(𝐒) q ] 𝐒(𝐒((a −₀ 𝐒(b)) mod 𝐒(b))) 🝖[ _≡_ ]-[ congruence₁(𝐒) (congruence₁(𝐒) (mod-greater-than-modulus ⦃ gt ⦄)) ]-sym 𝐒(𝐒(a mod 𝐒(b))) 🝖-end ... | [∨]-introᵣ q = [∨]-introᵣ $ (𝐒(a) mod 𝐒(b)) 🝖[ _≡_ ]-[ mod-greater-than-modulus ⦃ [≤]-successor gt ⦄ ] ((𝐒(a) −₀ 𝐒(b)) mod 𝐒(b)) 🝖[ _≡_ ]-[ congruence₁(_mod 𝐒(b)) ([↔]-to-[→] [−₀][𝐒]ₗ-equality gt) ] (𝐒(a −₀ 𝐒(b)) mod 𝐒(b)) 🝖[ _≡_ ]-[ q ] 0 🝖-end -} {-mod-congruence-with-𝐒 {a}{b}{𝐒 m} p with mod-of-𝐒 {a}{𝐒 m} | mod-of-𝐒 {b}{𝐒 m} ... | [∨]-introₗ pa | [∨]-introₗ pb = pa 🝖 congruence₁(𝐒) p 🝖 symmetry(_≡_) pb ... | [∨]-introₗ pa | [∨]-introᵣ pb = {!pa 🝖 congruence₁(𝐒) p!} ... | [∨]-introᵣ pa | [∨]-introₗ pb = pa 🝖 {!!} 🝖 symmetry(_≡_) pb ... | [∨]-introᵣ pa | [∨]-introᵣ pb = pa 🝖 symmetry(_≡_) pb-} {-mod-congruence-with-𝐒 {𝟎} {𝟎} {𝐒 m} p = [≡]-intro mod-congruence-with-𝐒 {𝟎} {𝐒 b} {𝐒 m} p = {!!} mod-congruence-with-𝐒 {𝐒 a} {𝟎} {𝐒 m} p = {!!} mod-congruence-with-𝐒 {𝐒 a} {𝐒 b} {𝐒 m} p = {!!}-} {-mod-congruence-without-𝐒 {𝟎} {𝟎} {𝐒 m} p = [≡]-intro mod-congruence-without-𝐒 {𝟎} {𝐒 b} {𝐒 m} p = {!!} mod-congruence-without-𝐒 {𝐒 a} {𝟎} {𝐒 m} p = {!!} mod-congruence-without-𝐒 {𝐒 a} {𝐒 b} {𝐒 m} p = {!!}-} {- -- TODO: Use Structure.Arithmetic instead of the actual ℕ (without the induction principle). Then ℕ with (𝟎 , 𝐒) fulfills such a structure (hom is id), but also ℕ with (a , 𝐒) for any a (hom is (a +_)). Or maybe ℕ with (𝟎 , (a +_)) (hom is (a ⋅_)), or ℕ with (1 , (a ⋅_)). Though this will not help mod-congruence-linear because addition and modulo for example in this new structure also changes. record Homomorphism(f : ℕ → ℕ) : Type{Lvl.𝟎} where field preserves-𝟎 : (f(𝟎) ≡ 𝟎) preserves-𝐒 : ∀{n} → (f(𝐒(n)) ≡ 𝐒(f(n))) preserves-[+] : ∀{a b} → (f(a + b) ≡ f(a) + f(b)) preserves-[+] {a} {𝟎} = symmetry(_≡_) (congruence₂ᵣ(_+_)(f(a)) preserves-𝟎) preserves-[+] {a} {𝐒 b} = preserves-𝐒 🝖 congruence₁(𝐒) (preserves-[+] {a} {b}) 🝖 congruence₂ᵣ(_+_)(f(a)) (symmetry(_≡_) preserves-𝐒) preserves-[⋅]ₗ : ∀{a b} → (f(a ⋅ b) ≡ f(a) ⋅ b) preserves-[⋅]ₗ {a} {𝟎} = preserves-𝟎 preserves-[⋅]ₗ {a} {𝐒 b} = preserves-[+] {a}{a ⋅ b} 🝖 congruence₂ᵣ(_+_)(f(a)) (preserves-[⋅]ₗ {a}{b}) preserves-[−₀] : ∀{a b} → (f(a −₀ b) ≡ f(a) −₀ f(b)) preserves-[−₀] {𝟎} {b} = preserves-𝟎 🝖 congruence₂ₗ(_−₀_)(f(b)) (symmetry(_≡_) preserves-𝟎) preserves-[−₀] {𝐒 a} {𝟎} = congruence₂ᵣ(_−₀_)(f(𝐒(a))) (symmetry(_≡_) preserves-𝟎) preserves-[−₀] {𝐒 a} {𝐒 b} = preserves-[−₀] {a} {b} 🝖 symmetry(_≡_) (congruence₂(_−₀_) (preserves-𝐒{a}) (preserves-𝐒{b})) -- TODO: But we also need to prove that floored division is a function without mentioning modulo (otherwise, circle argument). Below is the proof of modulo being a function depending on floored division being a function open import Syntax.Implication mod-congruence-linear : ∀{a b m} ⦃ pos : IsTrue(positive?(m)) ⦄ {f : ℕ → ℕ} ⦃ hom-f : Homomorphism(f) ⦄ → (a mod m ≡ b mod m) → (f(a) mod m ≡ f(b) mod m) mod-congruence-linear {a}{b}{𝐒 m}{f} ⦃ hom-f ⦄ = a mod 𝐒(m) ≡ b mod 𝐒(m) ⇒-[ (p ↦ symmetry(_≡_) ([⌊/⌋][⋅]-inverseOperatorᵣ-error{a}{m}) 🝖 p 🝖 [⌊/⌋][⋅]-inverseOperatorᵣ-error{b}{m}) ] a −₀ (a ⌊/⌋ 𝐒(m) ⋅ 𝐒(m)) ≡ b −₀ (b ⌊/⌋ 𝐒(m) ⋅ 𝐒(m)) ⇒-[ congruence₁(f) ] f(a −₀ (a ⌊/⌋ 𝐒(m) ⋅ 𝐒(m))) ≡ f(b −₀ (b ⌊/⌋ 𝐒(m) ⋅ 𝐒(m))) ⇒-[ {!!} ] f(a) −₀ f(a ⌊/⌋ 𝐒(m) ⋅ 𝐒(m)) ≡ f(b) −₀ f(b ⌊/⌋ 𝐒(m) ⋅ 𝐒(m)) ⇒-[ {!!} ] f(a) −₀ (f(a ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m)) ≡ f(b) −₀ (f(b ⌊/⌋ 𝐒(m)) ⋅ 𝐒(m)) ⇒-[ {!!} ] f(a) −₀ (f(a) ⌊/⌋ 𝐒(m) ⋅ 𝐒(m)) ≡ f(b) −₀ (f(b) ⌊/⌋ 𝐒(m) ⋅ 𝐒(m)) ⇒-[ {!!} ] f(a) mod 𝐒(m) ≡ f(b) mod 𝐒(m) ⇒-end where open Homomorphism(hom-f) -} postulate [⋅][mod]-distributivityₗ : ∀{a b c} → (c ⋅ (a mod₀ b) ≡ ((c ⋅ a) mod₀ (c ⋅ b))) {-[⋅][mod]-distributivityₗ {𝟎} {𝟎} {𝟎} = [≡]-intro [⋅][mod]-distributivityₗ {𝟎} {𝟎} {𝐒 c} = [≡]-intro [⋅][mod]-distributivityₗ {𝟎} {𝐒 b} {𝟎} = [≡]-intro [⋅][mod]-distributivityₗ {𝟎} {𝐒 b} {𝐒 c} = [≡]-intro [⋅][mod]-distributivityₗ {𝐒 a} {𝟎} {𝟎} = [≡]-intro [⋅][mod]-distributivityₗ {𝐒 a} {𝟎} {𝐒 c} = [≡]-intro [⋅][mod]-distributivityₗ {𝐒 a} {𝐒 b} {𝟎} = [≡]-intro [⋅][mod]-distributivityₗ {𝐒 a} {𝐒 b} {𝐒 c} = ?-} {- TODO: Above is true. Prove using the division theorem (((c ⋅ a) / (c ⋅ b)) ⋅ (c ⋅ b)) + ((c ⋅ a) mod₀ (c ⋅ b)) ≡ c ⋅ a //Division theorem on (c ⋅ a) (((c ⋅ a) / (c ⋅ b)) ⋅ (c ⋅ b)) + (c ⋅ (a mod₀ b)) ≡ ((a / b) ⋅ (c ⋅ b)) + (c ⋅ (a mod₀ b)) ≡ //a/b = (c⋅a)/(c⋅b) (c ⋅ ((a / b) ⋅ b)) + (c ⋅ (a mod₀ b)) ≡ //Commuting and associating ⋅ c ⋅ ((a / b) ⋅ b) + (a mod₀ b) ≡ c ⋅ a //...equal to LHS here by distributivity of (_⋅_) over (_+_), and this identity is division theorem on a with congruenced (c ⋅_) ((a / b) ⋅ b) + (a mod₀ b) ≡ a-} {- mod-equality-diff : ∀{a b m} → (a mod 𝐒(m) ≡ b mod 𝐒(m)) → ((a 𝄩 b) mod 𝐒(m) ≡ 𝟎) mod-equality-diff {𝟎} {𝟎} {m} ab = [≡]-intro mod-equality-diff {𝟎} {𝐒 b} {m} ab = symmetry(_≡_) ab mod-equality-diff {𝐒 a} {𝟎} {m} ab = ab mod-equality-diff {𝐒 a} {𝐒 b} {m} ab = mod-equality-diff {a} {b} {m} {!!} -} -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- mod₀ {- -- mod₀-eq-predecessor : ∀{a b} → ((𝐒(a) mod₀ b) ≡ 𝐒(c)) → ((a mod₀ b) ≡ c) postulate mod₀-of-𝐒 : ∀{a b} → (𝐒(a) mod₀ b ≡ 𝟎) ∨ (𝐒(a) mod₀ b ≡ 𝐒(a mod₀ b)) -- TODO: Should also be satisfied for b, not just 𝐒(b) -- mod₀-of-modulus-pre-eq : ∀{a b} → (𝐒(a) mod₀ 𝐒(b) ≡ 𝟎) → (a mod₀ 𝐒(b) ≡ b) -- mod₀-of-modulus-pre-eq : ∀{a b} → (𝐒(a) mod₀ 𝐒(b) ≡ 𝐒(c)) → (a mod₀ 𝐒(b) ≡ c) postulate mod₀-[⋅]ₗ-equality : ∀{a b k c} → ((a mod₀ c) ≡ (b mod₀ c)) → (((k ⋅ a) mod₀ c) ≡ ((k ⋅ b) mod₀ c)) postulate mod₀-[⋅]ᵣ-equality : ∀{a b k c} → ((a mod₀ c) ≡ (b mod₀ c)) → (((a ⋅ k) mod₀ c) ≡ ((b ⋅ k) mod₀ c)) postulate mod₀-[⋅]-equality : ∀{a₁ b₁ a₂ b₂ c} → ((a₁ mod₀ c) ≡ (b₁ mod₀ c)) → ((a₂ mod₀ c) ≡ (b₂ mod₀ c)) → (((a₁ ⋅ a₂) mod₀ c) ≡ ((b₁ ⋅ b₂) mod₀ c)) -- postulate mod₀-[^]ᵣ-equality : ∀{a b k c} → ((a mod₀ c) ≡ (b mod₀ c)) → (((a ^ k) mod₀ c) ≡ ((b ^ k) mod₀ c)) -- postulate mod₀-[/]ₗ-equality : ∀{a b k c} → ((a mod₀ c) ≡ (b mod₀ c)) → (k ∣ a) → (k ∣ b) → (((k / a) mod₀ c) ≡ ((k / b) mod₀ c)) -- postulate mod₀-[/]ᵣ-equality : ∀{a b k c} → ((a mod₀ c) ≡ (b mod₀ c)) ∧ (k ∣ a) ∧ (k ∣ b) ← (((a / k) mod₀ c) ≡ ((b / k) mod₀ c)) -- postulate modulo-multiplication : ∀{a₁ a₂ b} → (((a₁ ⋅ a₂) mod₀ b) ≡ (((a₁ mod₀ b) ⋅ (a₂ mod₀ b)) mod₀ b)) -}
{ "alphanum_fraction": 0.5157193302, "avg_line_length": 56.4565916399, "ext": "agda", "hexsha": "3c0cb64b9a4d8a842319c5163ae8e91619beb26f", "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": "Numeral/Natural/Oper/Modulo/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Natural/Oper/Modulo/Proofs.agda", "max_line_length": 396, "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": "Numeral/Natural/Oper/Modulo/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 9063, "size": 17558 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Category where open import Level open import Relation.Binary using (Rel; IsEquivalence; module IsEquivalence; Reflexive; Symmetric; Transitive) renaming (_⇒_ to _⊆_) open import Function using (flip) open import Categories.Support.PropositionalEquality open import Categories.Support.Equivalence open import Categories.Support.EqReasoning open import Data.Product postulate .irr : ∀ {a} {A : Set a} → .A → A record Category (o ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where eta-equality infix 4 _≡_ _⇒_ infixr 9 _∘_ field Obj : Set o _⇒_ : Rel Obj ℓ {_≡_} : ∀ {A B} → Rel (A ⇒ B) e {id} : ∀ {A} → (A ⇒ A) {_∘_} : ∀ {A B C} → (B ⇒ C) → (A ⇒ B) → (A ⇒ C) field .{assoc} : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → (h ∘ g) ∘ f ≡ h ∘ (g ∘ f) .{identityˡ} : ∀ {A B} {f : A ⇒ B} → id ∘ f ≡ f .{identityʳ} : ∀ {A B} {f : A ⇒ B} → f ∘ id ≡ f .{equiv} : ∀ {A B} → IsEquivalence (_≡_ {A} {B}) .{∘-resp-≡} : ∀ {A B C} {f h : B ⇒ C} {g i : A ⇒ B} → f ≡ h → g ≡ i → f ∘ g ≡ h ∘ i -- with irrelevant modules this would be: -- module .Equiv {A B : Obj} = IsEquivalence (equiv {A} {B}) module Equiv {A B : Obj} where module e = IsEquivalence private .q : IsEquivalence _≡_ q = equiv {A} {B} .refl : Reflexive _≡_ refl = e.refl q .trans : Transitive _≡_ trans = e.trans q .sym : Symmetric _≡_ sym = e.sym q .reflexive : _≣_ ⊆ _≡_ reflexive = e.reflexive q open Equiv domain : ∀ {A B} → (A ⇒ B) → Obj domain {A} _ = A codomain : ∀ {A B} → (A ⇒ B) → Obj codomain {B = B} _ = B .∘-resp-≡ˡ : ∀ {A B C} {f h : B ⇒ C} {g : A ⇒ B} → f ≡ h → f ∘ g ≡ h ∘ g ∘-resp-≡ˡ pf = ∘-resp-≡ pf refl .∘-resp-≡ʳ : ∀ {A B C} {f h : A ⇒ B} {g : B ⇒ C} → f ≡ h → g ∘ f ≡ g ∘ h ∘-resp-≡ʳ pf = ∘-resp-≡ refl pf hom-setoid : ∀ {A B} → Setoid _ _ hom-setoid {A} {B} = record { Carrier = A ⇒ B ; _≈_ = _≡_ ; isEquivalence = equiv } module HomReasoning {A B : Obj} where open SetoidReasoning (hom-setoid {A} {B}) public infixr 4 _⟩∘⟨_ ._⟩∘⟨_ : ∀ {M} {f h : M ⇒ B} {g i : A ⇒ M} → f ≡ h → g ≡ i → f ∘ g ≡ h ∘ i _⟩∘⟨_ = ∘-resp-≡ op : Category o ℓ e op = record { Obj = Obj ; _⇒_ = flip _⇒_ ; _≡_ = _≡_ ; _∘_ = flip _∘_ ; id = id ; assoc = sym assoc ; identityˡ = identityʳ ; identityʳ = identityˡ ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≡ = flip ∘-resp-≡ } CommutativeSquare : ∀ {A B C D} → (f : A ⇒ B) (g : A ⇒ C) (h : B ⇒ D) (i : C ⇒ D) → Set _ CommutativeSquare f g h i = h ∘ f ≡ i ∘ g .id-unique : ∀ {o} {f : o ⇒ o} → (∀ g → g ∘ f ≡ g) → f ≡ id id-unique g∘f≡g = trans (sym identityˡ) (g∘f≡g id) .id-comm : ∀ {a b} {f : a ⇒ b} → f ∘ id ≡ id ∘ f id-comm = trans identityʳ (sym identityˡ) infix 10 _[_,_] _[_≡_] _[_∘_] _[_,_] : ∀ {o ℓ e} → (C : Category o ℓ e) → (X : Category.Obj C) → (Y : Category.Obj C) → Set ℓ _[_,_] = Category._⇒_ _[_≡_] : ∀ {o ℓ e} → (C : Category o ℓ e) → ∀ {X Y} (f g : C [ X , Y ]) → Set e _[_≡_] = Category._≡_ _[_∘_] : ∀ {o ℓ e} → (C : Category o ℓ e) → ∀ {X Y Z} (f : C [ Y , Z ]) → (g : C [ X , Y ]) → C [ X , Z ] _[_∘_] = Category._∘_ -- Should this live in the Category record itself? It doesn't seem terribly useful for most situations module Heterogeneous {o ℓ e} (C : Category o ℓ e) where open Category C open Equiv renaming (refl to refl′; sym to sym′; trans to trans′; reflexive to reflexive′) infix 4 _∼_ data _∼_ {A B} (f : A ⇒ B) : ∀ {X Y} → (X ⇒ Y) → Set (ℓ ⊔ e) where ≡⇒∼ : {g : A ⇒ B} → .(f ≡ g) → f ∼ g refl : ∀ {A B} {f : A ⇒ B} → f ∼ f refl = ≡⇒∼ refl′ sym : ∀ {A B} {f : A ⇒ B} {D E} {g : D ⇒ E} → f ∼ g → g ∼ f sym (≡⇒∼ f≡g) = ≡⇒∼ (sym′ f≡g) trans : ∀ {A B} {f : A ⇒ B} {D E} {g : D ⇒ E} {F G} {h : F ⇒ G} → f ∼ g → g ∼ h → f ∼ h trans (≡⇒∼ f≡g) (≡⇒∼ g≡h) = ≡⇒∼ (trans′ f≡g g≡h) reflexive : ∀ {A B} {f g : A ⇒ B} → f ≣ g → f ∼ g reflexive f≣g = ≡⇒∼ (reflexive′ f≣g) ∘-resp-∼ : ∀ {A B C A′ B′ C′} {f : B ⇒ C} {h : B′ ⇒ C′} {g : A ⇒ B} {i : A′ ⇒ B′} → f ∼ h → g ∼ i → (f ∘ g) ∼ (h ∘ i) ∘-resp-∼ (≡⇒∼ f≡h) (≡⇒∼ g≡i) = ≡⇒∼ (∘-resp-≡ f≡h g≡i) ∘-resp-∼ˡ : ∀ {A B C C′} {f : B ⇒ C} {h : B ⇒ C′} {g : A ⇒ B} → f ∼ h → (f ∘ g) ∼ (h ∘ g) ∘-resp-∼ˡ (≡⇒∼ f≡h) = ≡⇒∼ (∘-resp-≡ˡ f≡h) ∘-resp-∼ʳ : ∀ {A A′ B C} {f : A ⇒ B} {h : A′ ⇒ B} {g : B ⇒ C} → f ∼ h → (g ∘ f) ∼ (g ∘ h) ∘-resp-∼ʳ (≡⇒∼ f≡h) = ≡⇒∼ (∘-resp-≡ʳ f≡h) .∼⇒≡ : ∀ {A B} {f g : A ⇒ B} → f ∼ g → f ≡ g ∼⇒≡ (≡⇒∼ f≡g) = irr f≡g domain-≣ : ∀ {A A′ B B′} {f : A ⇒ B} {f′ : A′ ⇒ B′} → f ∼ f′ → A ≣ A′ domain-≣ (≡⇒∼ _) = ≣-refl codomain-≣ : ∀ {A A′ B B′} {f : A ⇒ B} {f′ : A′ ⇒ B′} → f ∼ f′ → B ≣ B′ codomain-≣ (≡⇒∼ _) = ≣-refl ∼-cong : ∀ {t : Level} {T : Set t} {dom cod : T → Obj} (f : (x : T) → dom x ⇒ cod x) → ∀ {i j} (eq : i ≣ j) → f i ∼ f j ∼-cong f ≣-refl = refl -- floating morphisms on ≣ float₂ : ∀ {A A′ B B′} → A ≣ A′ → B ≣ B′ → A ⇒ B → A′ ⇒ B′ float₂ = ≣-subst₂ _⇒_ relaxed : ∀ {A B} {f : A ⇒ B} {X Y} {g : X ⇒ Y} -> (A≣X : A ≣ X) (B≣Y : B ≣ Y) -> float₂ A≣X B≣Y f ≡ g -> f ∼ g relaxed ≣-refl ≣-refl f≡g = ≡⇒∼ f≡g floatˡ : ∀ {A B B′} → B ≣ B′ → A ⇒ B → A ⇒ B′ floatˡ {A} = ≣-subst (_⇒_ A) floatˡ-resp-trans : ∀ {A B B′ B″} (B≣B′ : B ≣ B′) (B′≣B″ : B′ ≣ B″) (f : A ⇒ B) → floatˡ (≣-trans B≣B′ B′≣B″) f ≣ floatˡ B′≣B″ (floatˡ B≣B′ f) floatˡ-resp-trans {A} = ≣-subst-trans (_⇒_ A) floatʳ : ∀ {A A′ B} → A ≣ A′ → A ⇒ B → A′ ⇒ B floatʳ {B = B} = ≣-subst (λ X → X ⇒ B) float₂-breakdown-lr : ∀ {A A′} (A≣A′ : A ≣ A′) {B B′} (B≣B′ : B ≣ B′) (f : A ⇒ B) → float₂ A≣A′ B≣B′ f ≣ floatˡ B≣B′ (floatʳ A≣A′ f) float₂-breakdown-lr = ≣-subst₂-breakdown-lr _⇒_ float₂-breakdown-rl : ∀ {A A′} (A≣A′ : A ≣ A′) {B B′} (B≣B′ : B ≣ B′) (f : A ⇒ B) → float₂ A≣A′ B≣B′ f ≣ floatʳ A≣A′ (floatˡ B≣B′ f) float₂-breakdown-rl = ≣-subst₂-breakdown-rl _⇒_ -- henry ford versions .∼⇒≡₂ : ∀ {A A′ B B′} {f : A ⇒ B} {f′ : A′ ⇒ B′} → f ∼ f′ → (A≣A′ : A ≣ A′) (B≣B′ : B ≣ B′) → float₂ A≣A′ B≣B′ f ≡ f′ ∼⇒≡₂ pf ≣-refl ≣-refl = ∼⇒≡ pf .∼⇒≡ˡ : ∀ {A B B′} {f : A ⇒ B} {f′ : A ⇒ B′} → f ∼ f′ → (B≣B′ : B ≣ B′) → floatˡ B≣B′ f ≡ f′ ∼⇒≡ˡ pf ≣-refl = ∼⇒≡ pf .∼⇒≡ʳ : ∀ {A A′ B} {f : A ⇒ B} {f′ : A′ ⇒ B} → f ∼ f′ → (A≣A′ : A ≣ A′) → floatʳ A≣A′ f ≡ f′ ∼⇒≡ʳ pf ≣-refl = ∼⇒≡ pf ≡⇒∼ʳ : ∀ {A A′ B} {f : A ⇒ B} {f′ : A′ ⇒ B} → (A≣A′ : A ≣ A′) → .(floatʳ A≣A′ f ≡ f′) → f ∼ f′ ≡⇒∼ʳ ≣-refl pf = ≡⇒∼ pf float₂-resp-∼ : ∀ {A A′ B B′} (A≣A′ : A ≣ A′) (B≣B′ : B ≣ B′) {f : C [ A , B ]} → f ∼ float₂ A≣A′ B≣B′ f float₂-resp-∼ ≣-refl ≣-refl = refl floatˡ-resp-∼ : ∀ {A B B′} (B≣B′ : B ≣ B′) {f : C [ A , B ]} → f ∼ floatˡ B≣B′ f floatˡ-resp-∼ ≣-refl = refl floatʳ-resp-∼ : ∀ {A A′ B} (A≣A′ : A ≣ A′) {f : C [ A , B ]} → f ∼ floatʳ A≣A′ f floatʳ-resp-∼ ≣-refl = refl _[_∼_] : ∀ {o ℓ e} (C : Category o ℓ e) {A B} (f : C [ A , B ]) {X Y} (g : C [ X , Y ]) → Set (ℓ ⊔ e) C [ f ∼ g ] = Heterogeneous._∼_ C f g
{ "alphanum_fraction": 0.436299435, "avg_line_length": 33.2394366197, "ext": "agda", "hexsha": "005a50990d8062b6a6ee826daca32f5cfb79977c", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Category.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Category.agda", "max_line_length": 144, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Category.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 3855, "size": 7080 }
-- Andreas, 2016-07-20 -- With clauses should follow the parent clause -- what copattern style (prefix/postfix) concerns. record R : Set₂ where field f : Set₁ test : R test .R.f with R -- post-fix here R.f test | _ = Set -- pre-fix there -- That's not nice, thus, it is an error.
{ "alphanum_fraction": 0.6655172414, "avg_line_length": 20.7142857143, "ext": "agda", "hexsha": "8d5bfd605b50c2cb5baa8f3286384704632f96bd", "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/Issue1963WrongFixProjectionInWithClause.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/Issue1963WrongFixProjectionInWithClause.agda", "max_line_length": 50, "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/Issue1963WrongFixProjectionInWithClause.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": 88, "size": 290 }
------------------------------------------------------------------------------ -- Testing the translation of definitions ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Definition07d where infixl 6 _+_ infix 4 _≡_ postulate D : Set zero : D succ : D → D _≡_ : D → D → Set data N : D → Set where nzero : N zero nsucc : ∀ {n} → N n → N (succ n) N-ind : (A : D → Set) → A zero → (∀ {n} → A n → A (succ n)) → ∀ {n} → N n → A n N-ind A A0 h nzero = A0 N-ind A A0 h (nsucc Nn) = h (N-ind A A0 h Nn) postulate _+_ : D → D → D +-0x : ∀ n → zero + n ≡ n +-Sx : ∀ m n → succ m + n ≡ succ (m + n) {-# ATP axioms +-0x +-Sx #-} -- We test the translation of a definition where we need to erase -- proof terms. +-rightIdentity : ∀ {n} → N n → n + zero ≡ n +-rightIdentity Nn = N-ind A A0 is Nn where A : D → Set A i = i + zero ≡ i {-# ATP definition A #-} postulate A0 : A zero {-# ATP prove A0 #-} postulate is : ∀ {i} → A i → A (succ i) {-# ATP prove is #-}
{ "alphanum_fraction": 0.4374495561, "avg_line_length": 23.8269230769, "ext": "agda", "hexsha": "478824c8e052db87870e3c38665f590969f7de68", "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": "issues/Issue81/Definition07d.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": "issues/Issue81/Definition07d.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": "issues/Issue81/Definition07d.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": 399, "size": 1239 }
open import Level using (_⊔_) open import Algebra using (module CommutativeSemiring; module DistributiveLattice) open import Function using (id; const; _∘_; _$_) open import Coinduction using (∞; ♯_; ♭) open import Data.Fin as Fin using (Fin; suc; zero) open import Data.List as List using (List; _∷_; []; [_]; _++_; length; concat; foldr; concatMap) open import Data.Maybe using (Maybe; just; nothing) open import Data.Nat using (ℕ; suc; zero; _≤_; z≤n; s≤s) open import Data.Nat.Properties using (commutativeSemiring; distributiveLattice; ≤-decTotalOrder) open import Data.Product using (∃; _×_; _,_) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Vec as Vec using (Vec; _∷_; []; fromList) open import Relation.Nullary using (Dec; yes; no) open import Relation.Binary using (module DecTotalOrder) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; subst) module ProofSearch (RuleName : Set) (TermName : Set) (_≟-TermName_ : (x y : TermName) → Dec (x ≡ y)) (Literal : Set) (_≟-Literal_ : (x y : Literal) → Dec (x ≡ y)) where open import Unification TermName _≟-TermName_ Literal _≟-Literal_ public hiding (_++_) ---------------------------------------------------------------------------- -- * define rules and utility functions * -- ---------------------------------------------------------------------------- private ∃-syntax : ∀ {a b} {A : Set a} → (A → Set b) → Set (b ⊔ a) ∃-syntax = ∃ syntax ∃-syntax (λ x → B) = ∃[ x ] B -- introduce rules record Rule (n : ℕ) : Set where constructor rule field name : RuleName conclusion : Term n premises : List (Term n) open Rule using (name; conclusion; premises) -- alias for list of rules Rules : Set Rules = List (∃ Rule) -- compute the arity of a rule arity : ∀ {n} (r : Rule n) → ℕ arity = length ∘ premises -- open instances relevant to definitions of difference, inject and raise open CommutativeSemiring commutativeSemiring using (_+_; +-comm) open DistributiveLattice distributiveLattice using (_∧_; ∧-comm) open DecTotalOrder ≤-decTotalOrder using (total) -- compute the difference between two natural numbers, given an -- ordering between them. Δ_ : ∀ {m n} → m ≤ n → ℕ Δ z≤n {k} = k Δ s≤s p = Δ p -- correctness proof of the difference operator Δ. Δ-correct : ∀ {m n} (p : m ≤ n) → n ≡ m + Δ p Δ-correct z≤n = refl Δ-correct (s≤s p) = cong suc (Δ-correct p) -- type class for injections in the fashion of Fin.inject+ record Inject (T : ℕ → Set) : Set where field inject : ∀ {m} n → T m → T (m + n) inject≤ : ∀ {m n} → m ≤ n → T m → T n inject≤ {m} {n} p t = subst T (sym (Δ-correct p)) (inject (Δ p) t) open Inject {{...}} using (inject; inject≤) -- type class for raising in the fashion of Fin.raise record Raise (T : ℕ → Set) : Set where field raise : ∀ {m} n → T m → T (n + m) raise≤ : ∀ {m n} → m ≤ n → T m → T n raise≤ {m} {n} p t = subst T (sym (trans (Δ-correct p) (+-comm m (Δ p)))) (raise (Δ p) t) open Raise {{...}} using (raise; raise≤) -- instances for inject/raise for all used data types instance InjectFin : Inject Fin InjectFin = record { inject = Fin.inject+ } RaiseFin : Raise Fin RaiseFin = record { raise = Fin.raise } InjectTerm : Inject Term InjectTerm = record { inject = λ n → replace (var ∘ inject n) } RaiseTerm : Raise Term RaiseTerm = record { raise = λ m → replace (var ∘ raise m) } InjectTerms : Inject (List ∘ Term) InjectTerms = record { inject = λ n → List.map (inject n) } RaiseTerms : Raise (List ∘ Term) RaiseTerms = record { raise = λ m → List.map (raise m) } InjectGoals : ∀ {k} → Inject (λ n → Vec (Term n) k) InjectGoals = record { inject = λ n → Vec.map (inject n) } RaiseGoals : ∀ {k} → Raise (λ n → Vec (Term n) k) RaiseGoals = record { raise = λ m → Vec.map (raise m) } InjectRule : Inject Rule InjectRule = record { inject = λ n → λ { (rule nm c p) → rule nm (inject n c) (inject n p) } } RaiseRule : Raise Rule RaiseRule = record { raise = λ m → λ { (rule nm c p) → rule nm (raise m c) (raise m p) } } -- could rephrase inject/raise in terms of allowing modification by -- a function ℕ → ℕ, but really... why would I... it makes all the -- other instances much, much more obtuse injectSubst : ∀ {m n} (δ : ℕ) → Subst m n → Subst (m + δ) (n + δ) injectSubst _ nil = nil injectSubst δ (snoc s t x) = snoc (injectSubst δ s) (inject δ t) (inject δ x) private m≤n→m⊔n=n : ∀ {m n} → m ≤ n → m ∧ n ≡ n m≤n→m⊔n=n z≤n = refl m≤n→m⊔n=n (s≤s p) = cong suc (m≤n→m⊔n=n p) -- match indices of injectable data types match : ∀ {m n} {I J} {{i : Inject I}} {{j : Inject J}} → I m → J n → I (m ∧ n) × J (m ∧ n) match {m} {n} i j with total m n ... | inj₁ p rewrite m≤n→m⊔n=n p = (inject≤ p i , j) ... | inj₂ p rewrite ∧-comm m n | m≤n→m⊔n=n p = (i , inject≤ p j) ---------------------------------------------------------------------------- -- * define hint databases * -- ---------------------------------------------------------------------------- record IsHintDB : Set₁ where field HintDB : Set Hint : ℕ → Set Hints : Set Hints = List (∃ Hint) field getHints : HintDB → Hints getRule : ∀ {k} → Hint k → Rule k getTr : ∀ {k} → Hint k → (HintDB → HintDB) ε : HintDB _∙_ : HintDB → HintDB → HintDB return : ∀ {k} → Rule k → HintDB fromRules : Rules → HintDB fromRules [] = ε fromRules ((k , r) ∷ rs) = return r ∙ fromRules rs ---------------------------------------------------------------------------- -- * define simple hint databases * -- ---------------------------------------------------------------------------- simpleHintDB : IsHintDB simpleHintDB = record { HintDB = Rules ; Hint = Rule ; getHints = id ; getRule = id ; getTr = const id ; ε = [] ; _∙_ = _++_ ; return = λ r → [ _ , r ] } ---------------------------------------------------------------------------- -- * define search trees, proofs and partial proofs * -- ---------------------------------------------------------------------------- -- simple alias to set apart the goal term Goal = Term -- search trees data SearchTree (A : Set) : Set where leaf : A → SearchTree A node : List (∞ (SearchTree A)) → SearchTree A -- representation of a failed branch fail : ∀ {A} → SearchTree A fail = node [] data Proof : Set where con : (name : RuleName) (args : List Proof) → Proof -- representation of an incomplete proof Proof′ : ℕ → Set Proof′ m = ∃[ k ] (Vec (Goal m) k × (Vec Proof k → Proof)) con′ : ∀ {n k} (r : Rule n) → Vec Proof (arity r + k) → Vec Proof (suc k) con′ {n} {k} r xs = head ∷ rest where head : Proof head = con (name r) (Vec.toList $ Vec.take (arity r) xs) rest : Vec Proof k rest = Vec.drop (arity r) xs ---------------------------------------------------------------------------- -- * define proof search function * -- ---------------------------------------------------------------------------- module Extensible (isHintDB : IsHintDB) where open IsHintDB isHintDB solve : ∀ {m} → Goal m → HintDB → SearchTree Proof solve {m} g = solveAcc {m} (1 , g ∷ [] , Vec.head) where solveAcc : ∀ {m} → Proof′ m → HintDB → SearchTree Proof solveAcc {m} (0 , [] , p) _ = leaf (p []) solveAcc {m} (suc k , g ∷ gs , p) db = node (steps (getHints db)) where step : ∃[ δ ] (Hint δ) → ∞ (SearchTree Proof) step (δ , h) with unify (inject δ g) (raise m (conclusion (getRule h))) ... | nothing = ♯ node [] -- fail ... | just (n , mgu) = ♯ solveAcc {n} prf (getTr h db) where prf : Proof′ n prf = arity (getRule h) + k , gs′ , (p ∘ con′ (getRule h)) where prm′ = raise m (Vec.fromList (premises (getRule h))) gs′ = Vec.map (replace (sub mgu)) (prm′ Vec.++ inject δ gs) -- equivalent to `map step` due to termination checker steps : List (∃ Hint) → List (∞ (SearchTree Proof)) steps [] = [] steps (h ∷ hs) = step h ∷ steps hs ---------------------------------------------------------------------------- -- * define various search strategies * -- ---------------------------------------------------------------------------- Strategy : Set₁ Strategy = ∀ {A} (depth : ℕ) → SearchTree A → List A dfs : Strategy dfs zero _ = [] dfs (suc k) (leaf x) = x ∷ [] dfs (suc k) (node xs) = concatMap (λ x → dfs k (♭ x)) xs bfs : Strategy bfs depth t = concat (Vec.toList (bfsAcc depth t)) where merge : ∀ {A : Set} {k} → (xs ys : Vec (List A) k) → Vec (List A) k merge [] [] = [] merge (x ∷ xs) (y ∷ ys) = (x ++ y) ∷ merge xs ys empty : ∀ {A : Set} {k} → Vec (List A) k empty {k = zero} = [] empty {k = suc k} = [] ∷ empty bfsAcc : ∀ {A} (depth : ℕ) → SearchTree A → Vec (List A) depth bfsAcc zero _ = [] bfsAcc (suc k) (leaf x) = (x ∷ []) ∷ empty bfsAcc (suc k) (node xs) = [] ∷ foldr merge empty (List.map (λ x → bfsAcc k (♭ x)) xs)
{ "alphanum_fraction": 0.4725663717, "avg_line_length": 36.9818181818, "ext": "agda", "hexsha": "17689d877d2e1b6ab372003524bd1a3912ef46d9", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2019-07-07T07:37:07.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-10T10:47:30.000Z", "max_forks_repo_head_hexsha": "f384b5c236645fcf8ab93179723a7355383a8716", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wenkokke/AutoInAgda", "max_forks_repo_path": "src/ProofSearch.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f384b5c236645fcf8ab93179723a7355383a8716", "max_issues_repo_issues_event_max_datetime": "2017-11-06T16:49:27.000Z", "max_issues_repo_issues_event_min_datetime": "2017-11-03T09:46:19.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "wenkokke/AutoInAgda", "max_issues_repo_path": "src/ProofSearch.agda", "max_line_length": 116, "max_stars_count": 22, "max_stars_repo_head_hexsha": "f384b5c236645fcf8ab93179723a7355383a8716", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/AutoInAgda", "max_stars_repo_path": "src/ProofSearch.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-20T15:04:47.000Z", "max_stars_repo_stars_event_min_datetime": "2017-07-18T18:14:09.000Z", "num_tokens": 2956, "size": 10170 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.HomotopyGroup.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels import Cubical.Foundations.GroupoidLaws as GL open import Cubical.Data.Nat open import Cubical.Data.Group.Base open import Cubical.HITs.SetTruncation Pointed : ∀ {ℓ} → Type (ℓ-suc ℓ) Pointed {ℓ} = Σ[ A ∈ Type ℓ ] A Ω : ∀ {ℓ} → Pointed {ℓ} → Pointed {ℓ} Ω (A , a ) = ( (a ≡ a) , refl) Ω^_ : ∀ {ℓ} → ℕ → Pointed {ℓ} → Pointed {ℓ} (Ω^ 0) p = p (Ω^ (suc n)) p = Ω ((Ω^ n) p) π^_ : ∀ {ℓ} → ℕ → Pointed {ℓ} → Group {ℓ} π^_ {ℓ} n p = group ∥ A ∥₀ squash₀ g where n' : ℕ n' = suc n A : Type ℓ A = (Ω^ n') p .fst g : isGroup ∥ A ∥₀ g = group-struct e _⁻¹ _⊙_ lUnit rUnit assoc lCancel rCancel where e : ∥ A ∥₀ e = ∣ (Ω^ n') p .snd ∣₀ _⁻¹ : ∥ A ∥₀ → ∥ A ∥₀ _⁻¹ = elimSetTrunc {B = λ _ → ∥ A ∥₀} (λ x → squash₀) λ a → ∣ sym a ∣₀ _⊙_ : ∥ A ∥₀ → ∥ A ∥₀ → ∥ A ∥₀ _⊙_ = elimSetTrunc2 (λ _ _ → squash₀) λ a₀ a₁ → ∣ a₀ ∙ a₁ ∣₀ lUnit : (a : ∥ A ∥₀) → (e ⊙ a) ≡ a lUnit = elimSetTrunc (λ _ → isProp→isSet (squash₀ _ _)) (λ a → cong ∣_∣₀ (sym (GL.lUnit a) )) rUnit : (a : ∥ A ∥₀) → a ⊙ e ≡ a rUnit = elimSetTrunc (λ _ → isProp→isSet (squash₀ _ _)) (λ a → cong ∣_∣₀ (sym (GL.rUnit a) )) assoc : (a b c : ∥ A ∥₀) → ((a ⊙ b) ⊙ c) ≡ (a ⊙ (b ⊙ c)) assoc = elimSetTrunc3 (λ _ _ _ → isProp→isSet (squash₀ _ _)) (λ a b c → cong ∣_∣₀ (sym (GL.assoc _ _ _))) lCancel : (a : ∥ A ∥₀) → ((a ⁻¹) ⊙ a) ≡ e lCancel = elimSetTrunc (λ _ → isProp→isSet (squash₀ _ _)) λ a → cong ∣_∣₀ (GL.lCancel _) rCancel : (a : ∥ A ∥₀) → (a ⊙ (a ⁻¹)) ≡ e rCancel = elimSetTrunc (λ _ → isProp→isSet (squash₀ _ _)) λ a → cong ∣_∣₀ (GL.rCancel _)
{ "alphanum_fraction": 0.4882260597, "avg_line_length": 30.3333333333, "ext": "agda", "hexsha": "1c2a8544144d932b0ab915248d59c18245666355", "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/Data/HomotopyGroup/Base.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/Data/HomotopyGroup/Base.agda", "max_line_length": 79, "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/Data/HomotopyGroup/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 861, "size": 1911 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Bool open import lib.types.FunctionSeq open import lib.types.Pointed open import lib.types.Suspension.Core open import lib.types.Suspension.Flip open import lib.types.Suspension.Iterated open import lib.types.Suspension.IteratedEquivs open import lib.types.Suspension.IteratedTrunc open import lib.types.Suspension.Trunc open import lib.types.TLevel open import lib.types.Truncation module lib.types.Suspension.IteratedFlip where module _ {i} {A : Type i} where maybe-Susp^-flip : ∀ (n : ℕ) → Bool → Susp^ n A → Susp^ n A maybe-Susp^-flip 0 _ = idf _ maybe-Susp^-flip (S _) b = maybe-Susp-flip b Susp-fmap-maybe-Susp^-flip : ∀ (n : ℕ) (b : Bool) → (n == 0 → b == false) → maybe-Susp^-flip (S n) b ∼ Susp-fmap (maybe-Susp^-flip n b) Susp-fmap-maybe-Susp^-flip O b h x = maybe-Susp^-flip 1 b x =⟨ ap (λ c → maybe-Susp^-flip 1 c x) (h idp) ⟩ x =⟨ ! (Susp-fmap-idf A x) ⟩ Susp-fmap (idf A) x =∎ Susp-fmap-maybe-Susp^-flip (S n) true h x = ! (Susp-fmap-flip x) Susp-fmap-maybe-Susp^-flip (S n) false h x = ! (Susp-fmap-idf (Susp^ (S n) A) x) module _ {i} {X : Ptd i} where ⊙maybe-Susp^-flip : ∀ (n : ℕ) → Bool → ⊙Susp^ n X ⊙→ ⊙Susp^ n X ⊙maybe-Susp^-flip 0 _ = ⊙idf _ ⊙maybe-Susp^-flip (S n) b = ⊙maybe-Susp-flip (⊙Susp^ n X) b de⊙-⊙maybe-Susp^-flip : ∀ (n : ℕ) (b : Bool) → fst (⊙maybe-Susp^-flip n b) == maybe-Susp^-flip n b de⊙-⊙maybe-Susp^-flip O b = idp de⊙-⊙maybe-Susp^-flip (S n) b = de⊙-⊙maybe-Susp-flip _ b ⊙maybe-Susp^-flip-false : ∀ (n : ℕ) → ⊙maybe-Susp^-flip n false == ⊙idf _ ⊙maybe-Susp^-flip-false O = idp ⊙maybe-Susp^-flip-false (S n) = idp ⊙maybe-Susp^-flip-flip : ∀ (n : ℕ) (b c : Bool) → ⊙maybe-Susp^-flip n b ◃⊙∘ ⊙maybe-Susp^-flip n c ◃⊙idf =⊙∘ ⊙maybe-Susp^-flip n (xor b c) ◃⊙idf ⊙maybe-Susp^-flip-flip 0 _ _ = =⊙∘-in idp ⊙maybe-Susp^-flip-flip (S n) b c = ⊙maybe-Susp-flip-flip (⊙Susp^ n X) b c ⊙Susp-fmap-maybe-Susp^-flip : ∀ (n : ℕ) (b : Bool) → (n == 0 → b == false) → ⊙Susp-fmap (maybe-Susp^-flip n b) == ⊙maybe-Susp^-flip (S n) b ⊙Susp-fmap-maybe-Susp^-flip 0 b h = ⊙Susp-fmap (idf (de⊙ X)) =⟨ =⊙∘-out (⊙Susp-fmap-idf _) ⟩ ⊙idf _ =⟨ ap (⊙maybe-Susp^-flip 1) (! (h idp)) ⟩ ⊙maybe-Susp^-flip 1 b =∎ ⊙Susp-fmap-maybe-Susp^-flip (S n) b h = ⊙Susp-fmap-maybe-Susp-flip b Susp^-fmap-Susp-flip : ∀ {i} (m : ℕ) {A : Type i} (s : Susp^ (S m) (Susp A)) → Susp^-fmap (S m) Susp-flip s == Susp-flip s Susp^-fmap-Susp-flip O {A} s = Susp-fmap-flip s Susp^-fmap-Susp-flip (S m) {A} s = Susp^-fmap (S (S m)) Susp-flip s =⟨ ap (λ f → Susp-fmap f s) (λ= (Susp^-fmap-Susp-flip m)) ⟩ Susp-fmap Susp-flip s =⟨ Susp-fmap-flip s ⟩ Susp-flip s =∎ abstract ⊙Susp^-fmap-⊙Susp-flip : ∀ {i} (m : ℕ) {X : Ptd i} → ⊙Susp^-fmap (S m) (⊙Susp-flip X) == ⊙Susp-flip (⊙Susp^ m (⊙Susp (de⊙ X))) ⊙Susp^-fmap-⊙Susp-flip 0 {X} = ⊙Susp-fmap-Susp-flip ⊙Susp^-fmap-⊙Susp-flip (S m) {X} = ⊙Susp^-fmap (S (S m)) (⊙Susp-flip X) =⟨ ap ⊙Susp-fmap (λ= (Susp^-fmap-Susp-flip m)) ⟩ ⊙Susp-fmap Susp-flip =⟨ ⊙Susp-fmap-Susp-flip ⟩ ⊙Susp-flip (⊙Susp^ (S m) (⊙Susp (de⊙ X))) =∎ ⊙maybe-Susp^-flip-natural : ∀ {i} {j} {X : Ptd i} {Y : Ptd j} (f : X ⊙→ Y) (n : ℕ) (b : Bool) → ⊙Susp^-fmap n f ⊙∘ ⊙maybe-Susp^-flip n b == ⊙maybe-Susp^-flip n b ⊙∘ ⊙Susp^-fmap n f ⊙maybe-Susp^-flip-natural f O b = ! (⊙λ= (⊙∘-unit-l f)) ⊙maybe-Susp^-flip-natural f (S n) b = ⊙maybe-Susp-flip-natural (⊙Susp^-fmap n f) b ⊙maybe-Susp^-flip-natural-=⊙∘ : ∀ {i} {X Y : Ptd i} (f : X ⊙→ Y) (n : ℕ) (b : Bool) → ⊙Susp^-fmap n f ◃⊙∘ ⊙maybe-Susp^-flip n b ◃⊙idf =⊙∘ ⊙maybe-Susp^-flip n b ◃⊙∘ ⊙Susp^-fmap n f ◃⊙idf ⊙maybe-Susp^-flip-natural-=⊙∘ f n b = =⊙∘-in (⊙maybe-Susp^-flip-natural f n b) abstract ⊙Susp^-comm-flip : ∀ {i} (m n : ℕ) (X : Ptd i) → ⊙Susp^-fmap n (⊙Susp-flip (⊙Susp^ m X)) ◃⊙∘ ⊙coe (⊙Susp^-comm (S m) n {X}) ◃⊙idf =⊙∘ ⊙coe (⊙Susp^-comm (S m) n {X}) ◃⊙∘ ⊙Susp-flip (⊙Susp^ m (⊙Susp^ n X)) ◃⊙idf ⊙Susp^-comm-flip m O X = ⊙Susp-flip (⊙Susp^ m X) ◃⊙∘ ⊙coe (⊙Susp^-comm (S m) 0) ◃⊙idf =⊙∘⟨ 1 & 1 & =⊙∘-in {gs = ⊙idf-seq} $ ap ⊙coe (⊙Susp^-comm-0-r (S m) X) ⟩ ⊙Susp-flip (⊙Susp^ m X) ◃⊙idf =⊙∘⟨ 0 & 0 & =⊙∘-in {gs = ⊙coe (⊙Susp^-comm (S m) O) ◃⊙idf} $ ! $ ap ⊙coe (⊙Susp^-comm-0-r (S m) X) ⟩ ⊙coe (⊙Susp^-comm (S m) O) ◃⊙∘ ⊙Susp-flip (⊙Susp^ m (⊙Susp^ O X)) ◃⊙idf ∎⊙∘ ⊙Susp^-comm-flip m (S n) X = ⊙Susp^-fmap (S n) (⊙Susp-flip (⊙Susp^ m X)) ◃⊙∘ ⊙coe (⊙Susp^-comm (S m) (S n)) ◃⊙idf =⊙∘₁⟨ 0 & 1 & ⊙Susp^-fmap-⊙Susp-flip n {⊙Susp^ m X} ⟩ ⊙Susp-flip (⊙Susp^ n (⊙Susp (Susp^ m (de⊙ X)))) ◃⊙∘ ⊙coe (⊙Susp^-comm (S m) (S n)) ◃⊙idf =⊙∘₁⟨ 1 & 1 & p ⟩ ⊙Susp-flip (⊙Susp^ n (⊙Susp (Susp^ m (de⊙ X)))) ◃⊙∘ ⊙Susp-fmap (fst (⊙coe (⊙Susp^-comm m (S n) ∙ ⊙Susp^-comm 1 n))) ◃⊙idf =⊙∘⟨ =⊙∘-in {gs = ⊙Susp-fmap (fst (⊙coe (⊙Susp^-comm m (S n) {X} ∙ ⊙Susp^-comm 1 n {⊙Susp^ m X}))) ◃⊙∘ ⊙Susp-flip (⊙Susp^ m (⊙Susp (Susp^ n (de⊙ X)))) ◃⊙idf} $ ⊙Susp-flip-natural (⊙coe (⊙Susp^-comm m (S n) ∙ ⊙Susp^-comm 1 n)) ⟩ ⊙Susp-fmap (fst (⊙coe (⊙Susp^-comm m (S n) {X} ∙ ⊙Susp^-comm 1 n {⊙Susp^ m X}))) ◃⊙∘ ⊙Susp-flip (⊙Susp^ m (⊙Susp (Susp^ n (de⊙ X)))) ◃⊙idf =⊙∘₁⟨ 0 & 1 & ! p ⟩ ⊙coe (⊙Susp^-comm (S m) (S n)) ◃⊙∘ ⊙Susp-flip (⊙Susp^ m (⊙Susp^ (S n) X)) ◃⊙idf ∎⊙∘ where p : ⊙coe (⊙Susp^-comm (S m) (S n) {X}) == ⊙Susp-fmap (fst (⊙coe (⊙Susp^-comm m (S n) {X} ∙ ⊙Susp^-comm 1 n {⊙Susp^ m X}))) p = ap ⊙coe (⊙Susp^-comm-S-S m n) ∙ ! (⊙transport-⊙coe ⊙Susp (Susp^-comm m (S n) ∙ Susp^-comm 1 n)) ∙ ⊙transport-⊙Susp (Susp^-comm m (S n) ∙ Susp^-comm 1 n) ∙ ap (⊙Susp-fmap ∘ coe) (ap2 _∙_ (! (de⊙-⊙Susp^-comm m (S n) {X})) (! (de⊙-⊙Susp^-comm 1 n {⊙Susp^ m X}))) ∙ ap (⊙Susp-fmap ∘ coe) (∙-ap de⊙ (⊙Susp^-comm m (S n)) (⊙Susp^-comm 1 n)) ⊙maybe-Susp^-flip-⊙Susp^-comm : ∀ {i} (X : Ptd i) (m n : ℕ) (b : Bool) → ⊙Susp^-fmap n (⊙maybe-Susp^-flip m b) ◃⊙∘ ⊙coe (⊙Susp^-comm m n {X}) ◃⊙idf =⊙∘ ⊙coe (⊙Susp^-comm m n {X}) ◃⊙∘ ⊙maybe-Susp^-flip m b ◃⊙idf ⊙maybe-Susp^-flip-⊙Susp^-comm X O n b = ⊙Susp^-fmap n (⊙idf X) ◃⊙∘ ⊙coe (⊙Susp^-comm 0 n) ◃⊙idf =⊙∘⟨ 0 & 1 & ⊙Susp^-fmap-idf n X ⟩ ⊙coe (⊙Susp^-comm 0 n) ◃⊙idf =⊙∘⟨ 1 & 0 & ⊙contract ⟩ ⊙coe (⊙Susp^-comm 0 n) ◃⊙∘ ⊙idf (⊙Susp^ n X) ◃⊙idf ∎⊙∘ ⊙maybe-Susp^-flip-⊙Susp^-comm X (S m) n true = ⊙Susp^-comm-flip m n X ⊙maybe-Susp^-flip-⊙Susp^-comm X (S m) n false = ⊙Susp^-fmap n (⊙idf (⊙Susp^ (S m) X)) ◃⊙∘ ⊙coe (⊙Susp^-comm (S m) n) ◃⊙idf =⊙∘⟨ 0 & 1 & ⊙Susp^-fmap-idf n (⊙Susp^ (S m) X) ⟩ ⊙coe (⊙Susp^-comm (S m) n) ◃⊙idf =⊙∘⟨ 1 & 0 & ⊙contract ⟩ ⊙coe (⊙Susp^-comm (S m) n) ◃⊙∘ ⊙idf (⊙Susp^ (S m) (⊙Susp^ n X)) ◃⊙idf ∎⊙∘ module _ {i} (X : Ptd i) (m : ℕ₋₂) where ⊙Susp^-Trunc-swap-⊙maybe-Susp^-flip : ∀ (n : ℕ) (b : Bool) → ⊙Susp^-Trunc-swap X m n ◃⊙∘ ⊙maybe-Susp^-flip n b ◃⊙idf =⊙∘ ⊙Trunc-fmap (⊙maybe-Susp^-flip n b) ◃⊙∘ ⊙Susp^-Trunc-swap X m n ◃⊙idf ⊙Susp^-Trunc-swap-⊙maybe-Susp^-flip O b = =⊙∘-in (! (⊙λ= ⊙Trunc-fmap-⊙idf)) ⊙Susp^-Trunc-swap-⊙maybe-Susp^-flip (S n) true = ⊙Susp^-Trunc-swap X m (S n) ◃⊙∘ ⊙Susp-flip (⊙Susp^ n (⊙Trunc m X)) ◃⊙idf =⊙∘⟨ 0 & 1 & ⊙expand $ ⊙Susp-Trunc-swap (Susp^ n (de⊙ X)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘ ⊙Susp-fmap (Susp^-Trunc-swap (de⊙ X) m n) ◃⊙idf ⟩ ⊙Susp-Trunc-swap (Susp^ n (de⊙ X)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘ ⊙Susp-fmap (Susp^-Trunc-swap (de⊙ X) m n) ◃⊙∘ ⊙Susp-flip (⊙Susp^ n (⊙Trunc m X)) ◃⊙idf =⊙∘⟨ 1 & 2 & =⊙∘-in {gs = ⊙Susp-flip (⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n X)) ◃⊙∘ ⊙Susp-fmap (Susp^-Trunc-swap (de⊙ X) m n) ◃⊙idf} $ ! $ ⊙Susp-flip-natural (⊙Susp^-Trunc-swap X m n) ⟩ ⊙Susp-Trunc-swap (Susp^ n (de⊙ X)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘ ⊙Susp-flip (⊙Trunc (⟨ n ⟩₋₂ +2+ m) (⊙Susp^ n X)) ◃⊙∘ ⊙Susp-fmap (Susp^-Trunc-swap (de⊙ X) m n) ◃⊙idf =⊙∘⟨ 0 & 2 & ⊙Susp-Trunc-swap-⊙Susp-flip (⟨ n ⟩₋₂ +2+ m) ⟩ ⊙Trunc-fmap (⊙Susp-flip (⊙Susp^ n X)) ◃⊙∘ ⊙Susp-Trunc-swap (Susp^ n (de⊙ X)) (⟨ n ⟩₋₂ +2+ m) ◃⊙∘ ⊙Susp-fmap (Susp^-Trunc-swap (de⊙ X) m n) ◃⊙idf =⊙∘⟨ 1 & 2 & ⊙contract ⟩ ⊙Trunc-fmap (⊙Susp-flip (⊙Susp^ n X)) ◃⊙∘ ⊙Susp^-Trunc-swap X m (S n) ◃⊙idf ∎⊙∘ ⊙Susp^-Trunc-swap-⊙maybe-Susp^-flip (S n) false = ⊙Susp^-Trunc-swap X m (S n) ◃⊙∘ ⊙idf _ ◃⊙idf =⊙∘⟨ 1 & 1 & ⊙expand ⊙idf-seq ⟩ ⊙Susp^-Trunc-swap X m (S n) ◃⊙idf =⊙∘₁⟨ 0 & 0 & ! (⊙λ= ⊙Trunc-fmap-⊙idf) ⟩ ⊙Trunc-fmap (⊙idf (⊙Susp (de⊙ (⊙Susp^ n X)))) ◃⊙∘ ⊙Susp^-Trunc-swap X m (S n) ◃⊙idf ∎⊙∘
{ "alphanum_fraction": 0.4980254993, "avg_line_length": 40.2863636364, "ext": "agda", "hexsha": "c24b73af7f8bcafcc4903b54361beae8f18b523a", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Suspension/IteratedFlip.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Suspension/IteratedFlip.agda", "max_line_length": 108, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Suspension/IteratedFlip.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 4832, "size": 8863 }
open import Agda.Builtin.Bool open import Agda.Builtin.Equality open import Agda.Builtin.Float NaN : Float NaN = primFloatDiv 0.0 0.0 -NaN : Float -NaN = primFloatNegate NaN NaN≮NaN : primFloatNumericalLess NaN NaN ≡ false NaN≮NaN = refl -NaN≮-NaN : primFloatNumericalLess -NaN -NaN ≡ false -NaN≮-NaN = refl NaN≮-NaN : primFloatNumericalLess NaN -NaN ≡ false NaN≮-NaN = refl -NaN<NaN : primFloatNumericalLess -NaN NaN ≡ false -NaN<NaN = refl
{ "alphanum_fraction": 0.7394209354, "avg_line_length": 19.5217391304, "ext": "agda", "hexsha": "0d3030e34dc2147e71c5bc8bb00386b5690777f5", "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/Issue2208.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Succeed/Issue2208.agda", "max_line_length": 52, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/Issue2208.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": 160, "size": 449 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Monoid.Submonoid where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Algebra open import Cubical.Algebra.Monoid.Morphism open import Cubical.Algebra.Semigroup.Subsemigroup open import Cubical.Relation.Unary open import Cubical.Relation.Unary.Subtype open import Cubical.HITs.PropositionalTruncation record IsSubmonoid {c ℓ} (M : Monoid c) (Member : Pred ⟨ M ⟩ ℓ) : Type (ℓ-max c ℓ) where constructor issubmonoid private module M = Monoid M field preservesOp : M._•_ Preserves₂ Member preservesId : M.ε ∈ Member isSubsemigroup : IsSubsemigroup M.semigroup Member isSubsemigroup = record { closed = preservesOp } open IsSubsemigroup isSubsemigroup hiding (closed; _^_) public ε : Carrier ε = M.ε , preservesId identityˡ : LeftIdentity ε _•_ identityˡ _ = ΣPathTransport→PathΣ _ _ (M.identityˡ _ , isProp[ Member ] _ _ _) identityʳ : RightIdentity ε _•_ identityʳ _ = ΣPathTransport→PathΣ _ _ (M.identityʳ _ , isProp[ Member ] _ _ _) identity : Identity ε _•_ identity = identityˡ , identityʳ isMonoid : IsMonoid Carrier _•_ ε isMonoid = record { isSemigroup = isSemigroup ; identity = identity } monoid : Monoid _ monoid = record { isMonoid = isMonoid } open Monoid monoid using (ε-uniqueˡ; ε-uniqueʳ; _^_) public record Submonoid {c} (M : Monoid c) ℓ : Type (ℓ-max c (ℓ-suc ℓ)) where constructor mksubmonoid private module M = Monoid M field Member : Pred ⟨ M ⟩ ℓ isSubmonoid : IsSubmonoid M Member open IsSubmonoid isSubmonoid public subsemigroup : Subsemigroup M.semigroup ℓ subsemigroup = record { isSubsemigroup = isSubsemigroup } open Subsemigroup subsemigroup public using (submagma) instance SubmonoidCarrier : ∀ {c ℓ} {M : Monoid c} → HasCarrier (Submonoid M ℓ) _ SubmonoidCarrier = record { ⟨_⟩ = Submonoid.Carrier } module _ {ℓ} (M : Monoid ℓ) where open Monoid M ε-isSubmonoid : IsSubmonoid M { ε } ε-isSubmonoid = record { preservesOp = map2 λ p q → cong₂ _•_ p q ∙ identityʳ ε ; preservesId = ∣ refl ∣ } ε-submonoid : Submonoid M _ ε-submonoid = record { isSubmonoid = ε-isSubmonoid } U-isSubmonoid : IsSubmonoid M U U-isSubmonoid = record {} -- trivial U-submonoid : Submonoid M _ U-submonoid = record { isSubmonoid = U-isSubmonoid }
{ "alphanum_fraction": 0.7138844302, "avg_line_length": 24.92, "ext": "agda", "hexsha": "421e2252f13cbaa09a7a2b597ebcc5eb72ba84c7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Monoid/Submonoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Monoid/Submonoid.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Monoid/Submonoid.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 822, "size": 2492 }
open import Preliminaries open import Source-lang module Examples-Source where ----- examples nexp = [] |- nat dbl-test4 : nexp dbl-test4 = app dbl (suc (suc z)) four : nexp four = suc (suc (suc (suc z))) eqs4 : evals dbl-test4 four ((0c +c 0c) +c (0c +c (1c +c (0c +c (0c +c (1c +c (0c +c (0c +c (1c +c 0c))))))))) eqs4 = app-evals lam-evals (s-evals (s-evals z-evals)) (rec-evals (s-evals (s-evals z-evals)) (evals-rec-s (s-evals (s-evals (force-evals delay-evals (rec-evals (s-evals z-evals) (evals-rec-s (s-evals (s-evals (force-evals delay-evals (rec-evals z-evals (evals-rec-z z-evals)))))))))))) dbl-test0 : nexp dbl-test0 = app dbl z zero : nexp zero = z eqs0 : evals dbl-test0 zero ((0c +c 0c) +c (0c +c (1c +c 0c))) eqs0 = app-evals lam-evals z-evals (rec-evals z-evals (evals-rec-z z-evals)) add-test0 : nexp add-test0 = app (app add z) z eqs01 : evals add-test0 zero ((((0c +c 0c) +c 0c) +c 0c) +c (0c +c (1c +c 0c))) eqs01 = app-evals (app-evals lam-evals z-evals lam-evals) z-evals (rec-evals z-evals (evals-rec-z z-evals)) one : nexp one = suc z two : nexp two = suc (suc z) add-test1 : nexp add-test1 = app (app add (suc z)) z eqs11 : evals add-test1 one ((((0c +c 0c) +c 0c) +c 0c) +c (0c +c (1c +c (0c +c (0c +c (1c +c 0c)))))) eqs11 = app-evals (app-evals lam-evals (s-evals z-evals) lam-evals) z-evals (rec-evals (s-evals z-evals) (evals-rec-s (s-evals (force-evals delay-evals (rec-evals z-evals (evals-rec-z z-evals)))))) add-test1' : nexp add-test1' = app (app add z) (suc z) eqs11' : evals add-test1' one ((((0c +c 0c) +c 0c) +c 0c) +c (0c +c (1c +c 0c))) eqs11' = app-evals (app-evals lam-evals z-evals lam-evals) (s-evals z-evals) (rec-evals z-evals (evals-rec-z (s-evals z-evals))) add-test2 : nexp add-test2 = app (app add z) four eqs12 : evals add-test2 four ((((0c +c 0c) +c 0c) +c 0c) +c (0c +c (1c +c 0c))) eqs12 = app-evals (app-evals lam-evals z-evals lam-evals) (s-evals (s-evals (s-evals (s-evals z-evals)))) (rec-evals z-evals (evals-rec-z (s-evals (s-evals (s-evals (s-evals z-evals)))))) add-test2' : nexp add-test2' = app (app add four) z eqs12' : evals add-test2' four ((((0c +c 0c) +c 0c) +c 0c) +c (0c +c (1c +c (0c +c (0c +c (1c +c (0c +c (0c +c (1c +c (0c +c (0c +c (1c +c (0c +c (0c +c (1c +c 0c))))))))))))))) eqs12' = app-evals (app-evals lam-evals (s-evals (s-evals (s-evals (s-evals z-evals)))) lam-evals) z-evals (rec-evals (s-evals (s-evals (s-evals (s-evals z-evals)))) (evals-rec-s (s-evals (force-evals delay-evals (rec-evals (s-evals (s-evals (s-evals z-evals))) (evals-rec-s (s-evals (force-evals delay-evals (rec-evals (s-evals (s-evals z-evals)) (evals-rec-s (s-evals (force-evals delay-evals (rec-evals (s-evals z-evals) (evals-rec-s (s-evals (force-evals delay-evals (rec-evals z-evals (evals-rec-z z-evals)))))))))))))))))) mult-test1 : nexp mult-test1 = app (app mult two) two eqs111 : evals mult-test1 four ((((0c +c 0c) +c 0c) +c 0c) +c (0c +c (1c +c ((((0c +c 0c) +c 0c) +c (0c +c (0c +c (1c +c ((((0c +c 0c) +c 0c) +c (0c +c (0c +c (1c +c 0c)))) +c (0c +c (1c +c (0c +c (0c +c (1c +c (0c +c (0c +c (1c +c 0c))))))))))))) +c (0c +c (1c +c (0c +c (0c +c (1c +c (0c +c (0c +c (1c +c 0c)))))))))))) eqs111 = app-evals (app-evals lam-evals (s-evals (s-evals z-evals)) lam-evals) (s-evals (s-evals z-evals)) (rec-evals (s-evals (s-evals z-evals)) (evals-rec-s (app-evals (app-evals lam-evals (s-evals (s-evals z-evals)) lam-evals) (force-evals delay-evals (rec-evals (s-evals z-evals) (evals-rec-s (app-evals (app-evals lam-evals (s-evals (s-evals z-evals)) lam-evals) (force-evals delay-evals (rec-evals z-evals (evals-rec-z z-evals))) (rec-evals (s-evals (s-evals z-evals)) (evals-rec-s (s-evals (force-evals delay-evals (rec-evals (s-evals z-evals) (evals-rec-s (s-evals (force-evals delay-evals (rec-evals z-evals (evals-rec-z z-evals)))))))))))))) (rec-evals (s-evals (s-evals z-evals)) (evals-rec-s (s-evals (force-evals delay-evals (rec-evals (s-evals z-evals) (evals-rec-s (s-evals (force-evals delay-evals (rec-evals z-evals (evals-rec-z (s-evals (s-evals z-evals))))))))))))))) mult-test2 : nexp mult-test2 = app (app mult one) one eqs112 : evals mult-test2 one ((((0c +c 0c) +c 0c) +c 0c) +c (0c +c (1c +c ((((0c +c 0c) +c 0c) +c (0c +c (0c +c (1c +c 0c)))) +c (0c +c (1c +c (0c +c (0c +c (1c +c 0c))))))))) eqs112 = app-evals (app-evals lam-evals (s-evals z-evals) lam-evals) (s-evals z-evals) (rec-evals (s-evals z-evals) (evals-rec-s (app-evals (app-evals lam-evals (s-evals z-evals) lam-evals) (force-evals delay-evals (rec-evals z-evals (evals-rec-z z-evals))) (rec-evals (s-evals z-evals) (evals-rec-s (s-evals (force-evals delay-evals (rec-evals z-evals (evals-rec-z z-evals))))))))) mult-test0 : nexp mult-test0 = app (app mult zero) zero eqs00 : evals mult-test0 zero ((((0c +c 0c) +c 0c) +c 0c) +c (0c +c (1c +c 0c))) eqs00 = app-evals (app-evals lam-evals z-evals lam-evals) z-evals (rec-evals z-evals (evals-rec-z z-evals))
{ "alphanum_fraction": 0.5168200837, "avg_line_length": 63.5638297872, "ext": "agda", "hexsha": "2559dea1cce768c517d0f92f482632280b76f255", "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": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_path": "complexity-drafts/Examples-Source.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_path": "complexity-drafts/Examples-Source.agda", "max_line_length": 888, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_path": "complexity-drafts/Examples-Source.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "num_tokens": 2244, "size": 5975 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.FunctionSeq open import lib.types.Nat open import lib.types.Pointed open import lib.types.Suspension.Core open import lib.types.Suspension.Iterated module lib.types.Suspension.IteratedEquivs where Susp^-+ : ∀ {i} (m n : ℕ) {A : Type i} → Susp^ m (Susp^ n A) == Susp^ (m + n) A Susp^-+ O n = idp Susp^-+ (S m) n = ap Susp (Susp^-+ m n) ⊙Susp^-+ : ∀ {i} (m n : ℕ) {X : Ptd i} → ⊙Susp^ m (⊙Susp^ n X) == ⊙Susp^ (m + n) X ⊙Susp^-+ 0 n {X} = idp ⊙Susp^-+ (S m) n {X} = ap ⊙Susp (Susp^-+ m n) de⊙-⊙Susp^-+ : ∀ {i} (m n : ℕ) {X : Ptd i} → ap de⊙ (⊙Susp^-+ m n {X}) == Susp^-+ m n {de⊙ X} de⊙-⊙Susp^-+ 0 n {X} = idp de⊙-⊙Susp^-+ (S m) n {X} = ∘-ap de⊙ ⊙Susp (Susp^-+ m n) Susp^-+-0-r : ∀ {i} (m : ℕ) {A : Type i} → Susp^-+ m 0 ◃∙ ap (λ k → Susp^ k A) (+-unit-r m) ◃∎ =ₛ [] Susp^-+-0-r O {A} = =ₛ-in $ ap (ap (λ k → Susp^ k A)) (set-path ℕ-level (+-unit-r 0) idp) Susp^-+-0-r (S m) {A} = ap Susp (Susp^-+ m 0) ◃∙ ap (λ k → Susp^ k A) (+-unit-r (S m)) ◃∎ =ₛ₁⟨ 1 & 1 & ap (ap (λ k → Susp^ k A)) $ set-path ℕ-level (+-unit-r (S m)) (ap S (+-unit-r m)) ⟩ ap Susp (Susp^-+ m 0) ◃∙ ap (λ k → Susp^ k A) (ap S (+-unit-r m)) ◃∎ =ₛ₁⟨ 1 & 1 & ∘-ap (λ k → Susp^ k A) S (+-unit-r m) ∙ ap-∘ Susp (λ k → Susp^ k A) (+-unit-r m) ⟩ ap Susp (Susp^-+ m 0) ◃∙ ap Susp (ap (λ k → Susp^ k A) (+-unit-r m)) ◃∎ =ₛ⟨ ap-seq-=ₛ Susp (Susp^-+-0-r m) ⟩ [] ∎ₛ ⊙Susp^-+-0-r : ∀ {i} (m : ℕ) {X : Ptd i} → ⊙Susp^-+ m 0 ◃∙ ap (λ k → ⊙Susp^ k X) (+-unit-r m) ◃∎ =ₛ [] ⊙Susp^-+-0-r 0 {X} = =ₛ-in $ ap (ap (λ k → ⊙Susp^ k X)) (set-path ℕ-level (+-unit-r 0) idp) ⊙Susp^-+-0-r (S m) {X} = ap ⊙Susp (Susp^-+ m 0) ◃∙ ap (λ k → ⊙Susp^ k X) (+-unit-r (S m)) ◃∎ =ₛ₁⟨ 1 & 1 & ap (ap (λ k → ⊙Susp^ k X)) $ set-path ℕ-level (+-unit-r (S m)) (ap S (+-unit-r m)) ⟩ ap ⊙Susp (Susp^-+ m 0) ◃∙ ap (λ k → ⊙Susp^ k X) (ap S (+-unit-r m)) ◃∎ =ₛ₁⟨ 1 & 1 & ∘-ap (λ k → ⊙Susp^ k X) S (+-unit-r m) ∙ ap-∘ ⊙Susp (λ k → Susp^ k (de⊙ X)) (+-unit-r m) ⟩ ap ⊙Susp (Susp^-+ m 0) ◃∙ ap ⊙Susp (ap (λ k → Susp^ k (de⊙ X)) (+-unit-r m)) ◃∎ =ₛ⟨ ap-seq-=ₛ ⊙Susp (Susp^-+-0-r m) ⟩ [] ∎ₛ Susp^-+-assoc-coh : ∀ {i} (m n o : ℕ) {A : Type i} → ap (Susp^ m) (Susp^-+ n o {A}) ◃∙ Susp^-+ m (n + o) {A} ◃∎ =ₛ Susp^-+ m n {Susp^ o A} ◃∙ Susp^-+ (m + n) o ◃∙ ap (λ k → Susp^ k A) (+-assoc m n o) ◃∎ Susp^-+-assoc-coh O n o {A} = ap (idf _) (Susp^-+ n o {A}) ◃∙ idp ◃∎ =ₛ₁⟨ 0 & 1 & ap-idf (Susp^-+ n o {A}) ⟩ Susp^-+ n o {A} ◃∙ idp ◃∎ =ₛ₁⟨ 1 & 1 & ap (ap (λ k → Susp^ k A)) $ set-path ℕ-level idp (+-assoc 0 n o) ⟩ Susp^-+ n o {A} ◃∙ ap (λ k → Susp^ k A) (+-assoc 0 n o) ◃∎ =ₛ⟨ 0 & 0 & contract ⟩ idp ◃∙ Susp^-+ n o {A} ◃∙ ap (λ k → Susp^ k A) (+-assoc 0 n o) ◃∎ ∎ₛ Susp^-+-assoc-coh (S m) n o {A} = ap (Susp ∘ Susp^ m) (Susp^-+ n o {A}) ◃∙ ap Susp (Susp^-+ m (n + o) {A}) ◃∎ =ₛ₁⟨ 0 & 1 & ap-∘ Susp (Susp^ m) (Susp^-+ n o {A}) ⟩ ap Susp (ap (Susp^ m) (Susp^-+ n o {A})) ◃∙ ap Susp (Susp^-+ m (n + o) {A}) ◃∎ =ₛ⟨ ap-seq-=ₛ Susp (Susp^-+-assoc-coh m n o) ⟩ ap Susp (Susp^-+ m n) ◃∙ ap Susp (Susp^-+ (m + n) o) ◃∙ ap Susp (ap (λ k → Susp^ k A) (+-assoc m n o)) ◃∎ =ₛ₁⟨ 2 & 1 & ∘-ap Susp (λ k → Susp^ k A) (+-assoc m n o) ∙ ap-∘ (λ k → Susp^ k A) S (+-assoc m n o) ⟩ ap Susp (Susp^-+ m n) ◃∙ ap Susp (Susp^-+ (m + n) o) ◃∙ ap (λ k → Susp^ k A) (ap S (+-assoc m n o)) ◃∎ =ₛ₁⟨ 2 & 1 & ap (ap (λ k → Susp^ k A)) $ set-path ℕ-level (ap S (+-assoc m n o)) (+-assoc (S m) n o) ⟩ ap Susp (Susp^-+ m n) ◃∙ ap Susp (Susp^-+ (m + n) o) ◃∙ ap (λ k → Susp^ k A) (+-assoc (S m) n o) ◃∎ ∎ₛ ⊙Susp^-+-assoc-coh : ∀ {i} (m n o : ℕ) {X : Ptd i} → ap (⊙Susp^ m) (⊙Susp^-+ n o {X}) ◃∙ ⊙Susp^-+ m (n + o) {X} ◃∎ =ₛ ⊙Susp^-+ m n {⊙Susp^ o X} ◃∙ ⊙Susp^-+ (m + n) o ◃∙ ap (λ k → ⊙Susp^ k X) (+-assoc m n o) ◃∎ ⊙Susp^-+-assoc-coh O n o {X} = ap (idf _) (⊙Susp^-+ n o) ◃∙ idp ◃∎ =ₛ₁⟨ 0 & 1 & ap-idf (⊙Susp^-+ n o) ⟩ ⊙Susp^-+ n o ◃∙ idp ◃∎ =ₛ₁⟨ 1 & 1 & ap (ap (λ k → ⊙Susp^ k X)) $ set-path ℕ-level idp (+-assoc 0 n o) ⟩ ⊙Susp^-+ n o ◃∙ ap (λ k → ⊙Susp^ k X) (+-assoc 0 n o) ◃∎ =ₛ⟨ 0 & 0 & contract ⟩ idp ◃∙ ⊙Susp^-+ n o ◃∙ ap (λ k → ⊙Susp^ k X) (+-assoc 0 n o) ◃∎ ∎ₛ ⊙Susp^-+-assoc-coh (S m) n o {X} = ap (⊙Susp ∘ Susp^ m ∘ de⊙) (⊙Susp^-+ n o {X}) ◃∙ ap ⊙Susp (Susp^-+ m (n + o) {de⊙ X}) ◃∎ =ₛ₁⟨ 0 & 1 & ap-∘ (⊙Susp ∘ Susp^ m) de⊙ (⊙Susp^-+ n o {X}) ⟩ ap (⊙Susp ∘ Susp^ m) (ap de⊙ (⊙Susp^-+ n o {X})) ◃∙ ap ⊙Susp (Susp^-+ m (n + o) {de⊙ X}) ◃∎ =ₛ₁⟨ 0 & 1 & ap (ap (⊙Susp ∘ Susp^ m)) (de⊙-⊙Susp^-+ n o {X}) ⟩ ap (⊙Susp ∘ Susp^ m) (Susp^-+ n o {de⊙ X}) ◃∙ ap ⊙Susp (Susp^-+ m (n + o) {de⊙ X}) ◃∎ =ₛ₁⟨ 0 & 1 & ap-∘ ⊙Susp (Susp^ m) (Susp^-+ n o {de⊙ X}) ⟩ ap ⊙Susp (ap (Susp^ m) (Susp^-+ n o {de⊙ X})) ◃∙ ap ⊙Susp (Susp^-+ m (n + o) {de⊙ X}) ◃∎ =ₛ⟨ ap-seq-=ₛ ⊙Susp (Susp^-+-assoc-coh m n o) ⟩ ap ⊙Susp (Susp^-+ m n) ◃∙ ap ⊙Susp (Susp^-+ (m + n) o) ◃∙ ap ⊙Susp (ap (λ k → Susp^ k (de⊙ X)) (+-assoc m n o)) ◃∎ =ₛ₁⟨ 2 & 1 & ∘-ap ⊙Susp (λ k → Susp^ k (de⊙ X)) (+-assoc m n o) ∙ ap-∘ (λ k → ⊙Susp^ k X) S (+-assoc m n o) ⟩ ap ⊙Susp (Susp^-+ m n) ◃∙ ap ⊙Susp (Susp^-+ (m + n) o) ◃∙ ap (λ k → ⊙Susp^ k X) (ap S (+-assoc m n o)) ◃∎ =ₛ₁⟨ 2 & 1 & ap (ap (λ k → ⊙Susp^ k X)) $ set-path ℕ-level (ap S (+-assoc m n o)) (+-assoc (S m) n o) ⟩ ap ⊙Susp (Susp^-+ m n) ◃∙ ap ⊙Susp (Susp^-+ (m + n) o) ◃∙ ap (λ k → ⊙Susp^ k X) (+-assoc (S m) n o) ◃∎ ∎ₛ Susp^-comm-seq : ∀ {i} (m n : ℕ) {A : Type i} → Susp^ m (Susp^ n A) =-= Susp^ n (Susp^ m A) Susp^-comm-seq m n {A} = Susp^ m (Susp^ n A) =⟪ Susp^-+ m n ⟫ Susp^ (m + n) A =⟪ ap (λ k → Susp^ k A) (+-comm m n) ⟫ Susp^ (n + m) A =⟪ ! (Susp^-+ n m) ⟫ Susp^ n (Susp^ m A) ∎∎ Susp^-comm : ∀ {i} (m n : ℕ) {A : Type i} → Susp^ m (Susp^ n A) == Susp^ n (Susp^ m A) Susp^-comm m n {A} = ↯ (Susp^-comm-seq m n {A}) ⊙Susp^-comm-seq : ∀ {i} (m n : ℕ) {X : Ptd i} → ⊙Susp^ m (⊙Susp^ n X) =-= ⊙Susp^ n (⊙Susp^ m X) ⊙Susp^-comm-seq m n {X} = ⊙Susp^ m (⊙Susp^ n X) =⟪ ⊙Susp^-+ m n ⟫ ⊙Susp^ (m + n) X =⟪ ap (λ k → ⊙Susp^ k X) (+-comm m n) ⟫ ⊙Susp^ (n + m) X =⟪ ! (⊙Susp^-+ n m) ⟫ ⊙Susp^ n (⊙Susp^ m X) ∎∎ ⊙Susp^-comm : ∀ {i} (m n : ℕ) {X : Ptd i} → ⊙Susp^ m (⊙Susp^ n X) == ⊙Susp^ n (⊙Susp^ m X) ⊙Susp^-comm m n {X} = ↯ (⊙Susp^-comm-seq m n {X}) de⊙-⊙Susp^-comm : ∀ {i} (m n : ℕ) {X : Ptd i} → ap de⊙ (⊙Susp^-comm m n {X}) == Susp^-comm m n {de⊙ X} de⊙-⊙Susp^-comm m n {X} = =ₛ-out {t = Susp^-comm m n {de⊙ X} ◃∎} $ ap de⊙ (⊙Susp^-comm m n {X}) ◃∎ =ₛ⟨ ap-seq-∙ de⊙ (⊙Susp^-comm-seq m n {X}) ⟩ ap de⊙ (⊙Susp^-+ m n) ◃∙ ap de⊙ (ap (λ k → ⊙Susp^ k X) (+-comm m n)) ◃∙ ap de⊙ (! (⊙Susp^-+ n m)) ◃∎ =ₛ₁⟨ 0 & 1 & de⊙-⊙Susp^-+ m n ⟩ Susp^-+ m n ◃∙ ap de⊙ (ap (λ k → ⊙Susp^ k X) (+-comm m n)) ◃∙ ap de⊙ (! (⊙Susp^-+ n m)) ◃∎ =ₛ₁⟨ 1 & 1 & ∘-ap de⊙ (λ k → ⊙Susp^ k X) (+-comm m n) ⟩ Susp^-+ m n ◃∙ ap (λ k → Susp^ k (de⊙ X)) (+-comm m n) ◃∙ ap de⊙ (! (⊙Susp^-+ n m)) ◃∎ =ₛ₁⟨ 2 & 1 & ap-! de⊙ (⊙Susp^-+ n m) ⟩ Susp^-+ m n ◃∙ ap (λ k → Susp^ k (de⊙ X)) (+-comm m n) ◃∙ ! (ap de⊙ (⊙Susp^-+ n m)) ◃∎ =ₛ₁⟨ 2 & 1 & ap ! (de⊙-⊙Susp^-+ n m) ⟩ Susp^-+ m n ◃∙ ap (λ k → Susp^ k (de⊙ X)) (+-comm m n) ◃∙ ! (Susp^-+ n m) ◃∎ =ₛ⟨ contract ⟩ Susp^-comm m n ◃∎ ∎ₛ ⊙Susp^-swap : ∀ {i} (m n : ℕ) {X : Ptd i} → ⊙Susp^ m (⊙Susp^ n X) ⊙→ ⊙Susp^ n (⊙Susp^ m X) ⊙Susp^-swap m n {X} = ⊙coe (⊙Susp^-comm m n {X}) abstract ⊙Susp^-comm-diag : ∀ {i} (m : ℕ) {X : Ptd i} → ⊙Susp^-comm m m {X} ◃∎ =ₛ [] ⊙Susp^-comm-diag m {X} = ↯ (⊙Susp^-comm-seq m m {X}) ◃∎ =ₛ⟨ expand (⊙Susp^-comm-seq m m {X}) ⟩ ⊙Susp^-+ m m ◃∙ ap (λ k → ⊙Susp^ k X) (+-comm m m) ◃∙ ! (⊙Susp^-+ m m) ◃∎ =ₛ₁⟨ 1 & 1 & ap (ap (λ k → ⊙Susp^ k X)) (set-path ℕ-level (+-comm m m) idp) ⟩ ⊙Susp^-+ m m ◃∙ idp ◃∙ ! (⊙Susp^-+ m m) ◃∎ =ₛ⟨ 1 & 1 & expand [] ⟩ ⊙Susp^-+ m m ◃∙ ! (⊙Susp^-+ m m) ◃∎ =ₛ⟨ seq-!-inv-r (⊙Susp^-+ m m ◃∎) ⟩ [] ∎ₛ Susp^-comm-! : ∀ {i} (m n : ℕ) {A : Type i} → ! (Susp^-comm m n {A}) == Susp^-comm n m Susp^-comm-! m n {A} = =ₛ-out $ ! (↯ (Susp^-comm-seq m n {A})) ◃∎ =ₛ⟨ !-∙-seq (Susp^-comm-seq m n {A}) ⟩ ! (! (Susp^-+ n m)) ◃∙ ! (ap (λ k → Susp^ k A) (+-comm m n)) ◃∙ ! (Susp^-+ m n) ◃∎ =ₛ₁⟨ 0 & 1 & !-! (Susp^-+ n m) ⟩ Susp^-+ n m ◃∙ ! (ap (λ k → Susp^ k A) (+-comm m n)) ◃∙ ! (Susp^-+ m n) ◃∎ =ₛ₁⟨ 1 & 1 & !-ap (λ k → Susp^ k A) (+-comm m n) ⟩ Susp^-+ n m ◃∙ ap (λ k → Susp^ k A) (! (+-comm m n)) ◃∙ ! (Susp^-+ m n) ◃∎ =ₛ₁⟨ 1 & 1 & ap (ap (λ k → Susp^ k A)) $ set-path ℕ-level (! (+-comm m n)) (+-comm n m) ⟩ Susp^-+ n m ◃∙ ap (λ k → Susp^ k A) (+-comm n m) ◃∙ ! (Susp^-+ m n) ◃∎ ∎ₛ ⊙Susp^-comm-! : ∀ {i} (m n : ℕ) {X : Ptd i} → ! (⊙Susp^-comm m n {X}) == ⊙Susp^-comm n m ⊙Susp^-comm-! m n {X} = =ₛ-out $ ! (↯ (⊙Susp^-comm-seq m n {X})) ◃∎ =ₛ⟨ !-∙-seq (⊙Susp^-comm-seq m n {X}) ⟩ ! (! (⊙Susp^-+ n m)) ◃∙ ! (ap (λ k → ⊙Susp^ k X) (+-comm m n)) ◃∙ ! (⊙Susp^-+ m n) ◃∎ =ₛ₁⟨ 0 & 1 & !-! (⊙Susp^-+ n m) ⟩ ⊙Susp^-+ n m ◃∙ ! (ap (λ k → ⊙Susp^ k X) (+-comm m n)) ◃∙ ! (⊙Susp^-+ m n) ◃∎ =ₛ₁⟨ 1 & 1 & !-ap (λ k → ⊙Susp^ k X) (+-comm m n) ⟩ ⊙Susp^-+ n m ◃∙ ap (λ k → ⊙Susp^ k X) (! (+-comm m n)) ◃∙ ! (⊙Susp^-+ m n) ◃∎ =ₛ₁⟨ 1 & 1 & ap (ap (λ k → ⊙Susp^ k X)) $ set-path ℕ-level (! (+-comm m n)) (+-comm n m) ⟩ ⊙Susp^-+ n m ◃∙ ap (λ k → ⊙Susp^ k X) (+-comm n m) ◃∙ ! (⊙Susp^-+ m n) ◃∎ ∎ₛ ⊙Susp^-comm-0-r : ∀ {i} (m : ℕ) (X : Ptd i) → ⊙Susp^-comm m 0 {X} == idp ⊙Susp^-comm-0-r m X = =ₛ-out $ ⊙Susp^-+ m 0 ◃∙ ap (λ k → ⊙Susp^ k X) (+-comm m 0) ◃∙ ! (⊙Susp^-+ 0 m) ◃∎ =ₛ⟨ 2 & 1 & expand [] ⟩ ⊙Susp^-+ m 0 ◃∙ ap (λ k → ⊙Susp^ k X) (+-comm m 0) ◃∎ =ₛ₁⟨ 1 & 1 & ap (ap (λ k → ⊙Susp^ k X)) $ set-path ℕ-level (+-comm m 0) (+-unit-r m) ⟩ ⊙Susp^-+ m 0 ◃∙ ap (λ k → ⊙Susp^ k X) (+-unit-r m) ◃∎ =ₛ⟨ ⊙Susp^-+-0-r m ⟩ [] ∎ₛ ⊙Susp^-comm-0-l : ∀ {i} (n : ℕ) (X : Ptd i) → ⊙Susp^-comm 0 n {X} == idp ⊙Susp^-comm-0-l n X = ⊙Susp^-comm 0 n {X} =⟨ ! (⊙Susp^-comm-! n 0 {X}) ⟩ ! (⊙Susp^-comm n 0 {X}) =⟨ ap ! (⊙Susp^-comm-0-r n X) ⟩ idp =∎ ⊙Susp^-comm-S-r : ∀ {i} (m n : ℕ) {X : Ptd i} → ⊙Susp^-comm m (S n) {X} ◃∎ =ₛ ⊙Susp^-comm m 1 {⊙Susp^ n X} ◃∙ ap ⊙Susp (Susp^-comm m n) ◃∎ ⊙Susp^-comm-S-r m n {X} = ⊙Susp^-comm m (S n) {X} ◃∎ =ₛ⟨ expand (⊙Susp^-comm-seq m (S n) {X}) ⟩ ⊙Susp^-+ m (S n) ◃∙ ap (λ k → ⊙Susp^ k X) (+-comm m (S n)) ◃∙ ! (⊙Susp^-+ (S n) m {X}) ◃∎ =ₛ⟨ 0 & 0 & contract ⟩ idp ◃∙ ⊙Susp^-+ m (S n) ◃∙ ap (λ k → ⊙Susp^ k X) (+-comm m (S n)) ◃∙ ! (⊙Susp^-+ (S n) m {X}) ◃∎ =ₛ⟨ 0 & 2 & ⊙Susp^-+-assoc-coh m 1 n ⟩ ⊙Susp^-+ m 1 ◃∙ ⊙Susp^-+ (m + 1) n ◃∙ ap (λ k → ⊙Susp^ k X) (+-assoc m 1 n) ◃∙ ap (λ k → ⊙Susp^ k X) (+-comm m (S n)) ◃∙ ! (ap ⊙Susp (Susp^-+ n m)) ◃∎ =ₛ⟨ 2 & 2 & ap-seq-=ₛ (λ k → ⊙Susp^ k X) $ =ₛ-in {s = +-assoc m 1 n ◃∙ +-comm m (S n) ◃∎} {t = ap (_+ n) (+-comm m 1) ◃∙ ap S (+-comm m n) ◃∎} $ set-path ℕ-level _ _ ⟩ ⊙Susp^-+ m 1 ◃∙ ⊙Susp^-+ (m + 1) n ◃∙ ap (λ k → ⊙Susp^ k X) (ap (_+ n) (+-comm m 1)) ◃∙ ap (λ k → ⊙Susp^ k X) (ap S (+-comm m n)) ◃∙ ! (ap ⊙Susp (Susp^-+ n m)) ◃∎ =ₛ₁⟨ 2 & 1 & ∘-ap (λ k → ⊙Susp^ k X) (_+ n) (+-comm m 1) ⟩ ⊙Susp^-+ m 1 ◃∙ ⊙Susp^-+ (m + 1) n ◃∙ ap (λ k → ⊙Susp^ (k + n) X) (+-comm m 1) ◃∙ ap (λ k → ⊙Susp^ k X) (ap S (+-comm m n)) ◃∙ ! (ap ⊙Susp (Susp^-+ n m)) ◃∎ =ₛ⟨ 1 & 2 & !ₛ $ homotopy-naturality (λ l → ⊙Susp^ l (⊙Susp^ n X)) (λ l → ⊙Susp^ (l + n) X) (λ l → ⊙Susp^-+ l n) (+-comm m 1) ⟩ ⊙Susp^-+ m 1 ◃∙ ap (λ l → ⊙Susp^ l (⊙Susp^ n X)) (+-comm m 1) ◃∙ ap ⊙Susp (Susp^-+ m n) ◃∙ ap (λ k → ⊙Susp^ k X) (ap S (+-comm m n)) ◃∙ ! (ap ⊙Susp (Susp^-+ n m)) ◃∎ =ₛ⟨ 2 & 0 & contract ⟩ ⊙Susp^-+ m 1 ◃∙ ap (λ l → ⊙Susp^ l (⊙Susp^ n X)) (+-comm m 1) ◃∙ idp ◃∙ ap ⊙Susp (Susp^-+ m n) ◃∙ ap (λ k → ⊙Susp^ k X) (ap S (+-comm m n)) ◃∙ ! (ap ⊙Susp (Susp^-+ n m)) ◃∎ =ₛ⟨ 0 & 3 & contract ⟩ ⊙Susp^-comm m 1 ◃∙ ap ⊙Susp (Susp^-+ m n) ◃∙ ap (λ k → ⊙Susp^ k X) (ap S (+-comm m n)) ◃∙ ! (ap ⊙Susp (Susp^-+ n m)) ◃∎ =ₛ₁⟨ 2 & 1 & ∘-ap (λ k → ⊙Susp^ k X) S (+-comm m n) ∙ ap-∘ ⊙Susp (λ k → Susp^ k (de⊙ X)) (+-comm m n) ⟩ ⊙Susp^-comm m 1 ◃∙ ap ⊙Susp (Susp^-+ m n) ◃∙ ap ⊙Susp (ap (λ k → Susp^ k (de⊙ X)) (+-comm m n)) ◃∙ ! (ap ⊙Susp (Susp^-+ n m)) ◃∎ =ₛ₁⟨ 3 & 1 & !-ap ⊙Susp (Susp^-+ n m) ⟩ ⊙Susp^-comm m 1 ◃∙ ap ⊙Susp (Susp^-+ m n) ◃∙ ap ⊙Susp (ap (λ k → Susp^ k (de⊙ X)) (+-comm m n)) ◃∙ ap ⊙Susp (! (Susp^-+ n m)) ◃∎ =ₛ⟨ 1 & 3 & ∙-ap-seq ⊙Susp (Susp^-comm-seq m n) ⟩ ⊙Susp^-comm m 1 ◃∙ ap ⊙Susp (Susp^-comm m n) ◃∎ ∎ₛ ⊙Susp^-comm-S-l : ∀ {i} (m n : ℕ) {X : Ptd i} → ⊙Susp^-comm (S m) n {X} ◃∎ =ₛ ap ⊙Susp (Susp^-comm m n) ◃∙ ⊙Susp^-comm 1 n {⊙Susp^ m X} ◃∎ ⊙Susp^-comm-S-l m n {X} = ⊙Susp^-comm (S m) n {X} ◃∎ =ₛ₁⟨ ! (⊙Susp^-comm-! n (S m) {X}) ⟩ ! (⊙Susp^-comm n (S m) {X}) ◃∎ =ₛ⟨ !-=ₛ (⊙Susp^-comm-S-r n m {X}) ⟩ ! (ap ⊙Susp (Susp^-comm n m)) ◃∙ ! (⊙Susp^-comm n 1) ◃∎ =ₛ₁⟨ 0 & 1 & !-ap ⊙Susp (Susp^-comm n m) ⟩ ap ⊙Susp (! (Susp^-comm n m)) ◃∙ ! (⊙Susp^-comm n 1) ◃∎ =ₛ₁⟨ 0 & 1 & ap (ap ⊙Susp) (Susp^-comm-! n m) ⟩ ap ⊙Susp (Susp^-comm m n) ◃∙ ! (⊙Susp^-comm n 1) ◃∎ =ₛ₁⟨ 1 & 1 & ⊙Susp^-comm-! n 1 ⟩ ap ⊙Susp (Susp^-comm m n) ◃∙ ⊙Susp^-comm 1 n ◃∎ ∎ₛ ⊙Susp^-comm-S-1 : ∀ {i} (m : ℕ) {X : Ptd i} → ⊙Susp^-comm (S m) 1 {X} == ap ⊙Susp (Susp^-comm m 1 {de⊙ X}) ⊙Susp^-comm-S-1 m {X} = =ₛ-out $ ⊙Susp^-comm (S m) 1 {X} ◃∎ =ₛ⟨ ⊙Susp^-comm-S-l m 1 ⟩ ap ⊙Susp (Susp^-comm m 1) ◃∙ ⊙Susp^-comm 1 1 ◃∎ =ₛ⟨ 1 & 1 & ⊙Susp^-comm-diag 1 ⟩ ap ⊙Susp (Susp^-comm m 1) ◃∎ ∎ₛ ⊙Susp^-comm-1-S : ∀ {i} (n : ℕ) {X : Ptd i} → ⊙Susp^-comm 1 (S n) {X} == ap ⊙Susp (Susp^-comm 1 n {de⊙ X}) ⊙Susp^-comm-1-S n {X} = ⊙Susp^-comm 1 (S n) {X} =⟨ ! (⊙Susp^-comm-! (S n) 1 {X}) ⟩ ! (⊙Susp^-comm (S n) 1 {X}) =⟨ ap ! (⊙Susp^-comm-S-1 n {X}) ⟩ ! (ap ⊙Susp (Susp^-comm n 1 {de⊙ X})) =⟨ !-ap ⊙Susp (Susp^-comm n 1 {de⊙ X}) ⟩ ap ⊙Susp (! (Susp^-comm n 1 {de⊙ X})) =⟨ ap (ap ⊙Susp) (Susp^-comm-! n 1 {de⊙ X}) ⟩ ap ⊙Susp (Susp^-comm 1 n {de⊙ X}) =∎ ⊙Susp^-comm-S-S : ∀ {i} (m n : ℕ) {X : Ptd i} → ⊙Susp^-comm (S m) (S n) {X} == ap ⊙Susp (Susp^-comm m (S n) ∙ Susp^-comm 1 n) ⊙Susp^-comm-S-S m n {X} = =ₛ-out $ ⊙Susp^-comm (S m) (S n) {X} ◃∎ =ₛ⟨ ⊙Susp^-comm-S-l m (S n) ⟩ ap ⊙Susp (Susp^-comm m (S n)) ◃∙ ⊙Susp^-comm 1 (S n) ◃∎ =ₛ₁⟨ 1 & 1 & ⊙Susp^-comm-1-S n ⟩ ap ⊙Susp (Susp^-comm m (S n)) ◃∙ ap ⊙Susp (Susp^-comm 1 n) ◃∎ =ₛ⟨ ∙-ap-seq ⊙Susp (Susp^-comm m (S n) ◃∙ Susp^-comm 1 n ◃∎) ⟩ ap ⊙Susp (Susp^-comm m (S n) ∙ Susp^-comm 1 n) ◃∎ ∎ₛ abstract Susp^-+-natural : ∀ {i j} (m n : ℕ) {A : Type i} {B : Type j} (f : A → B) → coe (Susp^-+ m n) ∘ Susp^-fmap m (Susp^-fmap n f) ∼ Susp^-fmap (m + n) f ∘ coe (Susp^-+ m n) Susp^-+-natural O n f sa = idp Susp^-+-natural (S m) n f sa = transport Susp (Susp^-+ m n) (Susp^-fmap (S m) (Susp^-fmap n f) sa) =⟨ transport-Susp (Susp^-+ m n) (Susp^-fmap (S m) (Susp^-fmap n f) sa) ⟩ Susp-fmap (coe (Susp^-+ m n)) (Susp^-fmap (S m) (Susp^-fmap n f) sa) =⟨ ! (Susp-fmap-∘ (coe (Susp^-+ m n)) (Susp^-fmap m (Susp^-fmap n f)) sa) ⟩ Susp-fmap (coe (Susp^-+ m n) ∘ Susp^-fmap m (Susp^-fmap n f)) sa =⟨ ap (λ f → Susp-fmap f sa) (λ= (Susp^-+-natural m n f)) ⟩ Susp-fmap (Susp^-fmap (m + n) f ∘ coe (Susp^-+ m n)) sa =⟨ Susp-fmap-∘ (Susp^-fmap (m + n) f) (coe (Susp^-+ m n)) sa ⟩ Susp^-fmap (S m + n) f (Susp-fmap (coe (Susp^-+ m n)) sa) =⟨ ap (Susp^-fmap (S m + n) f) (! (transport-Susp (Susp^-+ m n) sa)) ⟩ Susp^-fmap (S m + n) f (transport Susp (Susp^-+ m n) sa) =∎ ⊙Susp^-+-natural : ∀ {i j} (m n : ℕ) {X : Ptd i} {Y : Ptd j} (f : X ⊙→ Y) → ⊙coe (⊙Susp^-+ m n) ⊙∘ ⊙Susp^-fmap m (⊙Susp^-fmap n f) == ⊙Susp^-fmap (m + n) f ⊙∘ ⊙coe (⊙Susp^-+ m n) ⊙Susp^-+-natural 0 n f = ⊙λ= (⊙∘-unit-l _) ⊙Susp^-+-natural (S m) n f = ⊙coe (ap ⊙Susp (Susp^-+ m n)) ⊙∘ ⊙Susp^-fmap (S m) (⊙Susp^-fmap n f) =⟨ ap (_⊙∘ ⊙Susp^-fmap (S m) (⊙Susp^-fmap n f)) $ ! (⊙transport-⊙coe ⊙Susp (Susp^-+ m n)) ∙ ⊙transport-⊙Susp (Susp^-+ m n) ⟩ ⊙Susp-fmap (coe (Susp^-+ m n)) ⊙∘ ⊙Susp^-fmap (S m) (⊙Susp^-fmap n f) =⟨ ! $ ⊙Susp-fmap-∘ (coe (Susp^-+ m n)) (Susp^-fmap m (Susp^-fmap n (fst f))) ⟩ ⊙Susp-fmap (coe (Susp^-+ m n) ∘ Susp^-fmap m (Susp^-fmap n (fst f))) =⟨ ap ⊙Susp-fmap (λ= (Susp^-+-natural m n (fst f))) ⟩ ⊙Susp-fmap (Susp^-fmap (m + n) (fst f) ∘ coe (Susp^-+ m n)) =⟨ ⊙Susp-fmap-∘ (Susp^-fmap (m + n) (fst f)) (coe (Susp^-+ m n)) ⟩ ⊙Susp-fmap (Susp^-fmap (m + n) (fst f)) ⊙∘ ⊙Susp-fmap (coe (Susp^-+ m n)) =⟨ ap (⊙Susp-fmap (Susp^-fmap (m + n) (fst f)) ⊙∘_) $ ! (⊙transport-⊙Susp (Susp^-+ m n)) ∙ ⊙transport-⊙coe ⊙Susp (Susp^-+ m n) ⟩ ⊙Susp-fmap (Susp^-fmap (m + n) (fst f)) ⊙∘ ⊙coe (ap ⊙Susp (Susp^-+ m n)) =∎ Susp^-+-natural' : ∀ {i j} (m n : ℕ) {A : Type i} {B : Type j} (f : A → B) → Susp^-fmap m (Susp^-fmap n f) ∘ coe (! (Susp^-+ m n)) ∼ coe (! (Susp^-+ m n)) ∘ Susp^-fmap (m + n) f Susp^-+-natural' m n f sa = Susp^-fmap m (Susp^-fmap n f) (coe (! (Susp^-+ m n)) sa) =⟨ ap (λ p → coe p (Susp^-fmap m (Susp^-fmap n f) (coe (! (Susp^-+ m n)) sa))) $ ! $ !-inv-r (Susp^-+ m n) ⟩ coe (Susp^-+ m n ∙ ! (Susp^-+ m n)) (Susp^-fmap m (Susp^-fmap n f) (coe (! (Susp^-+ m n)) sa)) =⟨ coe-∙ (Susp^-+ m n) (! (Susp^-+ m n)) (Susp^-fmap m (Susp^-fmap n f) (coe (! (Susp^-+ m n)) sa)) ⟩ coe (! (Susp^-+ m n)) (coe (Susp^-+ m n) (Susp^-fmap m (Susp^-fmap n f) (coe (! (Susp^-+ m n)) sa))) =⟨ ap (coe (! (Susp^-+ m n))) $ Susp^-+-natural m n f (coe (! (Susp^-+ m n)) sa) ⟩ coe (! (Susp^-+ m n)) (Susp^-fmap (m + n) f (coe (Susp^-+ m n) (coe (! (Susp^-+ m n)) sa))) =⟨ ap (coe (! (Susp^-+ m n)) ∘ Susp^-fmap (m + n) f) $ ! $ coe-∙ (! (Susp^-+ m n)) (Susp^-+ m n) sa ⟩ coe (! (Susp^-+ m n)) (Susp^-fmap (m + n) f (coe (! (Susp^-+ m n) ∙ Susp^-+ m n) sa)) =⟨ ap (λ p → coe (! (Susp^-+ m n)) (Susp^-fmap (m + n) f (coe p sa))) $ !-inv-l (Susp^-+ m n) ⟩ coe (! (Susp^-+ m n)) (Susp^-fmap (m + n) f sa) =∎ ⊙Susp^-+-natural' : ∀ {i j} (m n : ℕ) {X : Ptd i} {Y : Ptd j} (f : X ⊙→ Y) → ⊙Susp^-fmap m (⊙Susp^-fmap n f) ⊙∘ ⊙coe (! (⊙Susp^-+ m n)) == ⊙coe (! (⊙Susp^-+ m n)) ⊙∘ ⊙Susp^-fmap (m + n) f ⊙Susp^-+-natural' m n f = ⊙Susp^-fmap m (⊙Susp^-fmap n f) ⊙∘ ⊙coe (! (⊙Susp^-+ m n)) =⟨ ap (_⊙∘ ⊙coe (! (⊙Susp^-+ m n))) $ ! $ ⊙λ= $ ⊙∘-unit-l (⊙Susp^-fmap m (⊙Susp^-fmap n f)) ⟩ (⊙idf _ ⊙∘ ⊙Susp^-fmap m (⊙Susp^-fmap n f)) ⊙∘ ⊙coe (! (⊙Susp^-+ m n)) =⟨ ap (_⊙∘ ⊙coe (! (⊙Susp^-+ m n))) $ ap (_⊙∘ ⊙Susp^-fmap m (⊙Susp^-fmap n f)) $ ap ⊙coe (! (!-inv-r (⊙Susp^-+ m n))) ∙ =⊙∘-out (⊙coe-∙ (⊙Susp^-+ m n) (! (⊙Susp^-+ m n))) ⟩ ((⊙coe (! (⊙Susp^-+ m n)) ⊙∘ ⊙coe (⊙Susp^-+ m n)) ⊙∘ ⊙Susp^-fmap m (⊙Susp^-fmap n f)) ⊙∘ ⊙coe (! (⊙Susp^-+ m n)) =⟨ ap (_⊙∘ ⊙coe (! (⊙Susp^-+ m n))) $ ⊙λ= $ ⊙∘-assoc (⊙coe (! (⊙Susp^-+ m n))) (⊙coe (⊙Susp^-+ m n)) (⊙Susp^-fmap m (⊙Susp^-fmap n f)) ⟩ (⊙coe (! (⊙Susp^-+ m n)) ⊙∘ ⊙coe (⊙Susp^-+ m n) ⊙∘ ⊙Susp^-fmap m (⊙Susp^-fmap n f)) ⊙∘ ⊙coe (! (⊙Susp^-+ m n)) =⟨ ap (_⊙∘ ⊙coe (! (⊙Susp^-+ m n))) $ ap (⊙coe (! (⊙Susp^-+ m n)) ⊙∘_) $ ⊙Susp^-+-natural m n f ⟩ (⊙coe (! (⊙Susp^-+ m n)) ⊙∘ ⊙Susp^-fmap (m + n) f ⊙∘ ⊙coe (⊙Susp^-+ m n)) ⊙∘ ⊙coe (! (⊙Susp^-+ m n)) =⟨ ⊙λ= $ ⊙∘-assoc (⊙coe (! (⊙Susp^-+ m n))) (⊙Susp^-fmap (m + n) f ⊙∘ ⊙coe (⊙Susp^-+ m n)) (⊙coe (! (⊙Susp^-+ m n))) ⟩ ⊙coe (! (⊙Susp^-+ m n)) ⊙∘ (⊙Susp^-fmap (m + n) f ⊙∘ ⊙coe (⊙Susp^-+ m n)) ⊙∘ ⊙coe (! (⊙Susp^-+ m n)) =⟨ ap (⊙coe (! (⊙Susp^-+ m n)) ⊙∘_) $ ⊙λ= $ ⊙∘-assoc (⊙Susp^-fmap (m + n) f) (⊙coe (⊙Susp^-+ m n)) (⊙coe (! (⊙Susp^-+ m n))) ⟩ ⊙coe (! (⊙Susp^-+ m n)) ⊙∘ ⊙Susp^-fmap (m + n) f ⊙∘ ⊙coe (⊙Susp^-+ m n) ⊙∘ ⊙coe (! (⊙Susp^-+ m n)) =⟨ ap (⊙coe (! (⊙Susp^-+ m n)) ⊙∘_) $ ap (⊙Susp^-fmap (m + n) f ⊙∘_) $ ! (=⊙∘-out (⊙coe-∙ (! (⊙Susp^-+ m n)) (⊙Susp^-+ m n))) ∙ ap ⊙coe (!-inv-l (⊙Susp^-+ m n)) ⟩ ⊙coe (! (⊙Susp^-+ m n)) ⊙∘ ⊙Susp^-fmap (m + n) f =∎ Susp^-comm-natural : ∀ {i j} {A : Type i} {B : Type j} (m n : ℕ) (f : A → B) → coe (Susp^-comm m n) ∘ Susp^-fmap m (Susp^-fmap n f) ∼ Susp^-fmap n (Susp^-fmap m f) ∘ coe (Susp^-comm m n) Susp^-comm-natural {A = A} {B = B} m n f s = coe (Susp^-comm m n) (Susp^-fmap m (Susp^-fmap n f) s) =⟨ coe-∙ (Susp^-+ m n) (ap (λ k → Susp^ k B) (+-comm m n) ∙ ! (Susp^-+ n m)) (Susp^-fmap m (Susp^-fmap n f) s) ⟩ coe (ap (λ k → Susp^ k B) (+-comm m n) ∙ ! (Susp^-+ n m)) (coe (Susp^-+ m n) (Susp^-fmap m (Susp^-fmap n f) s)) =⟨ ap (coe (ap (λ k → Susp^ k B) (+-comm m n) ∙ ! (Susp^-+ n m))) (Susp^-+-natural m n f s) ⟩ coe (ap (λ k → Susp^ k B) (+-comm m n) ∙ ! (Susp^-+ n m)) (Susp^-fmap (m + n) f (coe (Susp^-+ m n) s)) =⟨ coe-∙ (ap (λ k → Susp^ k B) (+-comm m n)) (! (Susp^-+ n m)) (Susp^-fmap (m + n) f (coe (Susp^-+ m n) s)) ⟩ coe (! (Susp^-+ n m)) (transport (λ k → Susp^ k B) (+-comm m n) (Susp^-fmap (m + n) f (coe (Susp^-+ m n) s))) =⟨ ! $ ap (coe (! (Susp^-+ n m))) $ app= (transp-naturality (λ {k} → Susp^-fmap k f) (+-comm m n)) (coe (Susp^-+ m n) s) ⟩ coe (! (Susp^-+ n m)) (Susp^-fmap (n + m) f (transport (λ k → Susp^ k A) (+-comm m n) (coe (Susp^-+ m n) s))) =⟨ ! $ Susp^-+-natural' n m f (transport (λ k → Susp^ k A) (+-comm m n) (coe (Susp^-+ m n) s)) ⟩ Susp^-fmap n (Susp^-fmap m f) (coe (! (Susp^-+ n m)) (transport (λ k → Susp^ k A) (+-comm m n) (coe (Susp^-+ m n) s))) =⟨ ap (Susp^-fmap n (Susp^-fmap m f)) $ ! $ coe-∙ (ap (λ k → Susp^ k A) (+-comm m n)) (! (Susp^-+ n m)) (coe (Susp^-+ m n) s) ⟩ Susp^-fmap n (Susp^-fmap m f) (coe (ap (λ k → Susp^ k A) (+-comm m n) ∙ ! (Susp^-+ n m)) (coe (Susp^-+ m n) s)) =⟨ ! $ ap (Susp^-fmap n (Susp^-fmap m f)) $ coe-∙ (Susp^-+ m n) (ap (λ k → Susp^ k A) (+-comm m n) ∙ ! (Susp^-+ n m)) s ⟩ Susp^-fmap n (Susp^-fmap m f) (coe (Susp^-comm m n) s) =∎ ⊙Susp^-swap-natural : ∀ {i} {X Y : Ptd i} (m n : ℕ) (f : X ⊙→ Y) → ⊙Susp^-swap m n ◃⊙∘ ⊙Susp^-fmap m (⊙Susp^-fmap n f) ◃⊙idf =⊙∘ ⊙Susp^-fmap n (⊙Susp^-fmap m f) ◃⊙∘ ⊙Susp^-swap m n ◃⊙idf ⊙Susp^-swap-natural {X = X} {Y = Y} m n f = ⊙Susp^-swap m n ◃⊙∘ ⊙Susp^-fmap m (⊙Susp^-fmap n f) ◃⊙idf =⊙∘⟨ 0 & 1 & ⊙coe-∙ (⊙Susp^-+ m n) (ap (λ k → ⊙Susp^ k Y) (+-comm m n) ∙ ! (⊙Susp^-+ n m)) ⟩ ⊙coe (ap (λ k → ⊙Susp^ k Y) (+-comm m n) ∙ ! (⊙Susp^-+ n m)) ◃⊙∘ ⊙coe (⊙Susp^-+ m n) ◃⊙∘ ⊙Susp^-fmap m (⊙Susp^-fmap n f) ◃⊙idf =⊙∘⟨ 1 & 2 & =⊙∘-in {gs = ⊙Susp^-fmap (m + n) f ◃⊙∘ ⊙coe (⊙Susp^-+ m n) ◃⊙idf} $ ⊙Susp^-+-natural m n f ⟩ ⊙coe (ap (λ k → ⊙Susp^ k Y) (+-comm m n) ∙ ! (⊙Susp^-+ n m)) ◃⊙∘ ⊙Susp^-fmap (m + n) f ◃⊙∘ ⊙coe (⊙Susp^-+ m n) ◃⊙idf =⊙∘⟨ 0 & 1 & ⊙coe-∙ (ap (λ k → ⊙Susp^ k Y) (+-comm m n)) (! (⊙Susp^-+ n m)) ⟩ ⊙coe (! (⊙Susp^-+ n m)) ◃⊙∘ ⊙coe (ap (λ k → ⊙Susp^ k Y) (+-comm m n)) ◃⊙∘ ⊙Susp^-fmap (m + n) f ◃⊙∘ ⊙coe (⊙Susp^-+ m n) ◃⊙idf =⊙∘₁⟨ 1 & 1 & ! $ ⊙transport-⊙coe (λ k → ⊙Susp^ k Y) (+-comm m n) ⟩ ⊙coe (! (⊙Susp^-+ n m)) ◃⊙∘ ⊙transport (λ k → ⊙Susp^ k Y) (+-comm m n) ◃⊙∘ ⊙Susp^-fmap (m + n) f ◃⊙∘ ⊙coe (⊙Susp^-+ m n) ◃⊙idf =⊙∘⟨ 1 & 2 & !⊙∘ $ ⊙transport-natural-=⊙∘ (+-comm m n) (λ k → ⊙Susp^-fmap k f) ⟩ ⊙coe (! (⊙Susp^-+ n m)) ◃⊙∘ ⊙Susp^-fmap (n + m) f ◃⊙∘ ⊙transport (λ k → ⊙Susp^ k X) (+-comm m n) ◃⊙∘ ⊙coe (⊙Susp^-+ m n) ◃⊙idf =⊙∘₁⟨ 2 & 1 & ⊙transport-⊙coe (λ k → ⊙Susp^ k X) (+-comm m n) ⟩ ⊙coe (! (⊙Susp^-+ n m)) ◃⊙∘ ⊙Susp^-fmap (n + m) f ◃⊙∘ ⊙coe (ap (λ k → ⊙Susp^ k X) (+-comm m n)) ◃⊙∘ ⊙coe (⊙Susp^-+ m n) ◃⊙idf =⊙∘⟨ 0 & 2 & =⊙∘-in {gs = ⊙Susp^-fmap n (⊙Susp^-fmap m f) ◃⊙∘ ⊙coe (! (⊙Susp^-+ n m)) ◃⊙idf} $ ! $ ⊙Susp^-+-natural' n m f ⟩ ⊙Susp^-fmap n (⊙Susp^-fmap m f) ◃⊙∘ ⊙coe (! (⊙Susp^-+ n m)) ◃⊙∘ ⊙coe (ap (λ k → ⊙Susp^ k X) (+-comm m n)) ◃⊙∘ ⊙coe (⊙Susp^-+ m n) ◃⊙idf =⊙∘⟨ 1 & 2 & !⊙∘ $ ⊙coe-∙ (ap (λ k → ⊙Susp^ k X) (+-comm m n)) (! (⊙Susp^-+ n m)) ⟩ ⊙Susp^-fmap n (⊙Susp^-fmap m f) ◃⊙∘ ⊙coe (ap (λ k → ⊙Susp^ k X) (+-comm m n) ∙ ! (⊙Susp^-+ n m)) ◃⊙∘ ⊙coe (⊙Susp^-+ m n) ◃⊙idf =⊙∘⟨ 1 & 2 & !⊙∘ $ ⊙coe-∙ (⊙Susp^-+ m n) (ap (λ k → ⊙Susp^ k X) (+-comm m n) ∙ ! (⊙Susp^-+ n m)) ⟩ ⊙Susp^-fmap n (⊙Susp^-fmap m f) ◃⊙∘ ⊙Susp^-swap m n ◃⊙idf ∎⊙∘ Susp^-Susp-split-iso : ∀ {i} (n : ℕ) (A : Type i) → Susp (Susp^ n A) ≃ Susp^ n (Susp A) Susp^-Susp-split-iso O A = ide _ Susp^-Susp-split-iso (S n) A = Susp-emap (Susp^-Susp-split-iso n A) ⊙Susp^-Susp-split-iso : ∀ {i} (n : ℕ) (A : Type i) → ⊙Susp (Susp^ n A) ⊙≃ ⊙Susp^ n (⊙Susp A) ⊙Susp^-Susp-split-iso O A = ⊙ide _ ⊙Susp^-Susp-split-iso (S n) A = ⊙Susp-emap (Susp^-Susp-split-iso n A)
{ "alphanum_fraction": 0.3985482198, "avg_line_length": 39.6301369863, "ext": "agda", "hexsha": "442689bc86128e6f10115511e69ba767be7ee081", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Suspension/IteratedEquivs.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Suspension/IteratedEquivs.agda", "max_line_length": 104, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Suspension/IteratedEquivs.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 14289, "size": 26037 }
open import Issue481PonderBase using (List) module Issue481PonderImportMe (as bs : List) where
{ "alphanum_fraction": 0.8125, "avg_line_length": 24, "ext": "agda", "hexsha": "4ea78719c60db9cccff4c11f29c696acbc46a1f1", "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/Issue481PonderImportMe.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/Issue481PonderImportMe.agda", "max_line_length": 50, "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/Issue481PonderImportMe.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 26, "size": 96 }
-- Andreas, 2018-06-19, issue #3130 -- Produce parenthesized dot pattern .(p) instead of .p -- when is a projection. -- {-# OPTIONS -v reify.pat:80 #-} record R : Set₁ where field p : Set open R data D : (R → Set) → Set₁ where c : D p test : (f : R → Set) (x : D f) → Set₁ test f x = {!x!} -- split on x -- Expected: -- test .(p) c = ?
{ "alphanum_fraction": 0.5664739884, "avg_line_length": 18.2105263158, "ext": "agda", "hexsha": "58aad59324c28aab06c46f1700442442e7a13f7a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue3130Split.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue3130Split.agda", "max_line_length": 55, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue3130Split.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": 129, "size": 346 }
-- This is the preferred version of the integers in the library. Other -- versions can be found in the MoreInts directory. {-# OPTIONS --safe #-} module Cubical.Data.Int.Base where open import Cubical.Core.Everything open import Cubical.Data.Bool open import Cubical.Data.Nat hiding (_+_ ; _·_) renaming (isEven to isEvenℕ ; isOdd to isOddℕ) infix 8 -_ infixl 7 _·_ infixl 6 _+_ _-_ data ℤ : Type₀ where pos : (n : ℕ) → ℤ negsuc : (n : ℕ) → ℤ neg : (n : ℕ) → ℤ neg zero = pos zero neg (suc n) = negsuc n sucℤ : ℤ → ℤ sucℤ (pos n) = pos (suc n) sucℤ (negsuc zero) = pos zero sucℤ (negsuc (suc n)) = negsuc n predℤ : ℤ → ℤ predℤ (pos zero) = negsuc zero predℤ (pos (suc n)) = pos n predℤ (negsuc n) = negsuc (suc n) isEven : ℤ → Bool isEven (pos n) = isEvenℕ n isEven (negsuc n) = isOddℕ n isOdd : ℤ → Bool isOdd (pos n) = isOddℕ n isOdd (negsuc n) = isEvenℕ n abs : ℤ → ℕ abs (pos n) = n abs (negsuc n) = suc n _ℕ-_ : ℕ → ℕ → ℤ a ℕ- 0 = pos a 0 ℕ- suc b = negsuc b suc a ℕ- suc b = a ℕ- b _+pos_ : ℤ → ℕ → ℤ z +pos 0 = z z +pos (suc n) = sucℤ (z +pos n) _+negsuc_ : ℤ → ℕ → ℤ z +negsuc 0 = predℤ z z +negsuc (suc n) = predℤ (z +negsuc n) _+_ : ℤ → ℤ → ℤ m + pos n = m +pos n m + negsuc n = m +negsuc n -_ : ℤ → ℤ - pos zero = pos zero - pos (suc n) = negsuc n - negsuc n = pos (suc n) _-_ : ℤ → ℤ → ℤ m - n = m + (- n) _·_ : ℤ → ℤ → ℤ pos zero · m = pos zero pos (suc n) · m = m + pos n · m negsuc zero · m = - m negsuc (suc n) · m = - m + negsuc n · m -- Natural number and negative integer literals for ℤ open import Cubical.Data.Nat.Literals public instance fromNatℤ : HasFromNat ℤ fromNatℤ = record { Constraint = λ _ → Unit ; fromNat = λ n → pos n } instance fromNegℤ : HasFromNeg ℤ fromNegℤ = record { Constraint = λ _ → Unit ; fromNeg = λ n → neg n }
{ "alphanum_fraction": 0.6027548209, "avg_line_length": 21.1046511628, "ext": "agda", "hexsha": "b7d9c48b52077693f63820b4c4ac31da9cc040d6", "lang": "Agda", "max_forks_count": 134, "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_path": "Cubical/Data/Int/Base.agda", "max_issues_count": 584, "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_path": "Cubical/Data/Int/Base.agda", "max_line_length": 94, "max_stars_count": 301, "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_path": "Cubical/Data/Int/Base.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "num_tokens": 791, "size": 1815 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Core using (Category) -- Defines BinaryProducts -- for when a Category has all Binary Products module Categories.Category.BinaryProducts {o ℓ e} (𝒞 : Category o ℓ e) where open import Level hiding (suc) open import Data.Product using (uncurry) open Category 𝒞 open HomReasoning open import Categories.Object.Product 𝒞 open import Categories.Morphism 𝒞 using (_≅_; module Iso) open import Categories.Morphism.Reasoning 𝒞 using (pullʳ; pullˡ; elimʳ; cancelˡ) open import Categories.Category.Monoidal.Core using (Monoidal) open import Categories.Functor using (Functor) renaming (id to idF) open import Categories.Functor.Bifunctor using (Bifunctor; appʳ; appˡ) private variable A B C D X Y Z : Obj f f′ g g′ h i : A ⇒ B record BinaryProducts : Set (levelOfTerm 𝒞) where infixr 7 _×_ infixr 8 _⁂_ infix 11 ⟨_,_⟩ field product : ∀ {A B} → Product A B private module product {A} {B} = Product (product {A} {B}) _×_ : Obj → Obj → Obj A × B = Product.A×B (product {A} {B}) ×-comm : A × B ≅ B × A ×-comm = Commutative product product ×-assoc : X × Y × Z ≅ (X × Y) × Z ×-assoc = Associative product product product product open product hiding (⟨_,_⟩; ∘-distribʳ-⟨⟩) public -- define it like this instead of reexporting to redefine fixity ⟨_,_⟩ : X ⇒ A → X ⇒ B → X ⇒ A × B ⟨_,_⟩ = Product.⟨_,_⟩ product _⁂_ : A ⇒ B → C ⇒ D → A × C ⇒ B × D f ⁂ g = [ product ⇒ product ] f × g assocˡ : (A × B) × C ⇒ A × B × C assocˡ = _≅_.to ×-assoc assocʳ : A × B × C ⇒ (A × B) × C assocʳ = _≅_.from ×-assoc assocʳ∘assocˡ : assocʳ {A}{B}{C} ∘ assocˡ {A}{B}{C} ≈ id assocʳ∘assocˡ = Iso.isoʳ (_≅_.iso ×-assoc) assocˡ∘assocʳ : assocˡ {A}{B}{C} ∘ assocʳ {A}{B}{C} ≈ id assocˡ∘assocʳ = Iso.isoˡ (_≅_.iso ×-assoc) ⟨⟩-congʳ : f ≈ f′ → ⟨ f , g ⟩ ≈ ⟨ f′ , g ⟩ ⟨⟩-congʳ pf = ⟨⟩-cong₂ pf Equiv.refl ⟨⟩-congˡ : g ≈ g′ → ⟨ f , g ⟩ ≈ ⟨ f , g′ ⟩ ⟨⟩-congˡ pf = ⟨⟩-cong₂ Equiv.refl pf swap : A × B ⇒ B × A swap = ⟨ π₂ , π₁ ⟩ -- TODO: this is probably harder to use than necessary because of this definition. Maybe make a version -- that doesn't have an explicit id in it, too? first : A ⇒ B → A × C ⇒ B × C first f = f ⁂ id second : C ⇒ D → A × C ⇒ A × D second g = id ⁂ g -- Just to make this more obvious π₁∘⁂ : π₁ ∘ (f ⁂ g) ≈ f ∘ π₁ π₁∘⁂ {f = f} {g} = project₁ π₂∘⁂ : π₂ ∘ (f ⁂ g) ≈ g ∘ π₂ π₂∘⁂ {f = f} {g} = project₂ ⁂-cong₂ : f ≈ g → h ≈ i → f ⁂ h ≈ g ⁂ i ⁂-cong₂ = [ product ⇒ product ]×-cong₂ ⁂∘⟨⟩ : (f ⁂ g) ∘ ⟨ f′ , g′ ⟩ ≈ ⟨ f ∘ f′ , g ∘ g′ ⟩ ⁂∘⟨⟩ = [ product ⇒ product ]×∘⟨⟩ first∘⟨⟩ : first f ∘ ⟨ f′ , g′ ⟩ ≈ ⟨ f ∘ f′ , g′ ⟩ first∘⟨⟩ = [ product ⇒ product ]×id∘⟨⟩ second∘⟨⟩ : second g ∘ ⟨ f′ , g′ ⟩ ≈ ⟨ f′ , g ∘ g′ ⟩ second∘⟨⟩ = [ product ⇒ product ]id×∘⟨⟩ ⁂∘⁂ : (f ⁂ g) ∘ (f′ ⁂ g′) ≈ (f ∘ f′) ⁂ (g ∘ g′) ⁂∘⁂ = [ product ⇒ product ⇒ product ]×∘× ⟨⟩∘ : ⟨ f , g ⟩ ∘ h ≈ ⟨ f ∘ h , g ∘ h ⟩ ⟨⟩∘ = [ product ]⟨⟩∘ first∘first : ∀ {C} → first {C = C} f ∘ first g ≈ first (f ∘ g) first∘first = [ product ⇒ product ⇒ product ]×id∘×id second∘second : ∀ {A} → second {A = A} f ∘ second g ≈ second (f ∘ g) second∘second = [ product ⇒ product ⇒ product ]id×∘id× first∘second : first f ∘ second g ≈ f ⁂ g first∘second {f = f} {g = g} = begin first f ∘ second g ≈⟨ first∘⟨⟩ ⟩ ⟨ f ∘ id ∘ π₁ , g ∘ π₂ ⟩ ≈⟨ ⟨⟩-congʳ (∘-resp-≈ʳ identityˡ) ⟩ f ⁂ g ∎ second∘first : second f ∘ first g ≈ g ⁂ f second∘first {f = f} {g = g} = begin second f ∘ first g ≈⟨ second∘⟨⟩ ⟩ ⟨ g ∘ π₁ , f ∘ id ∘ π₂ ⟩ ≈⟨ ⟨⟩-congˡ (∘-resp-≈ʳ identityˡ) ⟩ g ⁂ f ∎ first↔second : first f ∘ second g ≈ second g ∘ first f first↔second = [ product ⇒ product , product ⇒ product ]first↔second firstid : ∀ {f : A ⇒ A} (g : A ⇒ C) → first {C = C} f ≈ id → f ≈ id firstid {f = f} g eq = begin f ≈˘⟨ elimʳ project₁ ⟩ f ∘ π₁ ∘ ⟨ id , g ⟩ ≈⟨ pullˡ fπ₁≈π₁ ⟩ π₁ ∘ ⟨ id , g ⟩ ≈⟨ project₁ ⟩ id ∎ where fπ₁≈π₁ = begin f ∘ π₁ ≈˘⟨ project₁ ⟩ π₁ ∘ first f ≈⟨ refl⟩∘⟨ eq ⟩ π₁ ∘ id ≈⟨ identityʳ ⟩ π₁ ∎ swap∘⟨⟩ : swap ∘ ⟨ f , g ⟩ ≈ ⟨ g , f ⟩ swap∘⟨⟩ {f = f} {g = g} = begin ⟨ π₂ , π₁ ⟩ ∘ ⟨ f , g ⟩ ≈⟨ ⟨⟩∘ ⟩ ⟨ π₂ ∘ ⟨ f , g ⟩ , π₁ ∘ ⟨ f , g ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ project₂ project₁ ⟩ ⟨ g , f ⟩ ∎ swap∘⁂ : swap ∘ (f ⁂ g) ≈ (g ⁂ f) ∘ swap swap∘⁂ {f = f} {g = g} = begin swap ∘ (f ⁂ g) ≈⟨ swap∘⟨⟩ ⟩ ⟨ g ∘ π₂ , f ∘ π₁ ⟩ ≈˘⟨ ⁂∘⟨⟩ ⟩ (g ⁂ f) ∘ swap ∎ swap∘swap : (swap {A}{B}) ∘ (swap {B}{A}) ≈ id swap∘swap = Equiv.trans swap∘⟨⟩ η assocʳ∘⟨⟩ : assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ≈ ⟨ ⟨ f , g ⟩ , h ⟩ assocʳ∘⟨⟩ {f = f} {g = g} {h = h} = begin assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ≈⟨ ⟨⟩∘ ⟩ ⟨ ⟨ π₁ , π₁ ∘ π₂ ⟩ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ , (π₂ ∘ π₂) ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ ⟨⟩∘ (pullʳ project₂) ⟩ ⟨ ⟨ π₁ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ , (π₁ ∘ π₂) ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ⟩ , π₂ ∘ ⟨ g , h ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ (⟨⟩-cong₂ project₁ (pullʳ project₂ ○ project₁)) project₂ ⟩ ⟨ ⟨ f , g ⟩ , h ⟩ ∎ assocˡ∘⟨⟩ : assocˡ ∘ ⟨ ⟨ f , g ⟩ , h ⟩ ≈ ⟨ f , ⟨ g , h ⟩ ⟩ assocˡ∘⟨⟩ {f = f} {g = g} {h = h} = begin assocˡ ∘ ⟨ ⟨ f , g ⟩ , h ⟩ ≈˘⟨ refl⟩∘⟨ assocʳ∘⟨⟩ ⟩ assocˡ ∘ assocʳ ∘ ⟨ f , ⟨ g , h ⟩ ⟩ ≈⟨ cancelˡ assocˡ∘assocʳ ⟩ ⟨ f , ⟨ g , h ⟩ ⟩ ∎ assocʳ∘⁂ : assocʳ ∘ (f ⁂ (g ⁂ h)) ≈ ((f ⁂ g) ⁂ h) ∘ assocʳ assocʳ∘⁂ {f = f} {g = g} {h = h} = begin assocʳ ∘ (f ⁂ (g ⁂ h)) ≈⟨ refl⟩∘⟨ ⟨⟩-congˡ ⟨⟩∘ ⟩ assocʳ ∘ ⟨ f ∘ π₁ , ⟨ (g ∘ π₁) ∘ π₂ , (h ∘ π₂) ∘ π₂ ⟩ ⟩ ≈⟨ assocʳ∘⟨⟩ ⟩ ⟨ ⟨ f ∘ π₁ , (g ∘ π₁) ∘ π₂ ⟩ , (h ∘ π₂) ∘ π₂ ⟩ ≈⟨ ⟨⟩-cong₂ (⟨⟩-congˡ assoc) assoc ⟩ ⟨ ⟨ f ∘ π₁ , g ∘ π₁ ∘ π₂ ⟩ , h ∘ π₂ ∘ π₂ ⟩ ≈˘⟨ ⟨⟩-congʳ ⁂∘⟨⟩ ⟩ ⟨ (f ⁂ g) ∘ ⟨ π₁ , π₁ ∘ π₂ ⟩ , h ∘ π₂ ∘ π₂ ⟩ ≈˘⟨ ⁂∘⟨⟩ ⟩ ((f ⁂ g) ⁂ h) ∘ assocʳ ∎ assocˡ∘⁂ : assocˡ ∘ ((f ⁂ g) ⁂ h) ≈ (f ⁂ (g ⁂ h)) ∘ assocˡ assocˡ∘⁂ {f = f} {g = g} {h = h} = begin assocˡ ∘ ((f ⁂ g) ⁂ h) ≈⟨ refl⟩∘⟨ ⟨⟩-congʳ ⟨⟩∘ ⟩ assocˡ ∘ ⟨ ⟨ (f ∘ π₁) ∘ π₁ , (g ∘ π₂) ∘ π₁ ⟩ , h ∘ π₂ ⟩ ≈⟨ assocˡ∘⟨⟩ ⟩ ⟨ (f ∘ π₁) ∘ π₁ , ⟨ (g ∘ π₂) ∘ π₁ , h ∘ π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ assoc (⟨⟩-congʳ assoc) ⟩ ⟨ f ∘ π₁ ∘ π₁ , ⟨ g ∘ π₂ ∘ π₁ , h ∘ π₂ ⟩ ⟩ ≈˘⟨ ⟨⟩-congˡ ⁂∘⟨⟩ ⟩ ⟨ f ∘ π₁ ∘ π₁ , (g ⁂ h) ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ≈˘⟨ ⁂∘⟨⟩ ⟩ (f ⁂ (g ⁂ h)) ∘ assocˡ ∎ Δ : ∀ {C} → C ⇒ C × C Δ {C} = ⟨ id {C} , id ⟩ Δ∘ : Δ ∘ f ≈ ⟨ f , f ⟩ Δ∘ {f = f} = begin Δ ∘ f ≈⟨ ⟨⟩∘ ⟩ ⟨ id ∘ f , id ∘ f ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ identityˡ ⟩ ⟨ f , f ⟩ ∎ ⁂∘Δ : (f ⁂ g) ∘ Δ ≈ ⟨ f , g ⟩ ⁂∘Δ {f = f} {g = g} = begin (f ⁂ g) ∘ Δ ≈⟨ ⁂∘⟨⟩ ⟩ ⟨ f ∘ id , g ∘ id ⟩ ≈⟨ ⟨⟩-cong₂ identityʳ identityʳ ⟩ ⟨ f , g ⟩ ∎ -×- : Bifunctor 𝒞 𝒞 𝒞 -×- = record { F₀ = uncurry _×_ ; F₁ = uncurry _⁂_ ; identity = id×id product ; homomorphism = ⟺ ⁂∘⁂ ; F-resp-≈ = uncurry [ product ⇒ product ]×-cong₂ } -×_ : Obj → Functor 𝒞 𝒞 -×_ = appʳ -×- _×- : Obj → Functor 𝒞 𝒞 _×- = appˡ -×-
{ "alphanum_fraction": 0.4297699594, "avg_line_length": 30.5371900826, "ext": "agda", "hexsha": "42371d4cd63955d24fe253cbd259b91ec1d969ac", "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/BinaryProducts.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/BinaryProducts.agda", "max_line_length": 105, "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/BinaryProducts.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": 3746, "size": 7390 }
open import Data.Nat using (ℕ) renaming (_+_ to _+ᵢ_; _≤?_ to _≤?ᵢ_) open import Agda.Builtin.Float renaming (primFloatPlus to _+ᵣ_; primFloatLess to _≤?ᵣ_) open import Data.Bool using (Bool; true; false; not; _∧_) open import Data.Sum using (inj₁; inj₂; _⊎_) open import Data.Product using (_×_; _,_; -,_; _-,-_; ∃; ∃-syntax; proj₂) open import Data.String using (String; _≟_) open import Relation.Nullary using (¬_; yes; no) open import Relation.Nullary.Decidable using (⌊_⌋) open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym) vname = String int = ℕ real = Float bool = Bool data val : Set where Iv : int → val Rv : real → val data aexp : Set where Ic : int → aexp Rc : real → aexp V : vname → aexp Plus : aexp → aexp → aexp data bexp : Set where Bc : Bool → bexp Not : bexp → bexp And : bexp → bexp → bexp Less : aexp → aexp → bexp data com : Set where SKIP : com _::=_ : String → aexp → com _::_ : com → com → com IF_THEN_ELSE_ : bexp → com → com → com WHILE_DO_ : bexp → com → com data ty : Set where Ity : ty Rty : ty tyenv = vname → ty state = vname → val _[_::=_] : state → vname → val → state (s [ X ::= n ]) Y with Y ≟ X ... | yes _ = n ... | no _ = s Y data _⊢ₐ_∷_ : tyenv → aexp → ty → Set where taexpI : ∀{Γ i} → Γ ⊢ₐ Ic i ∷ Ity taexpR : ∀{Γ r} → Γ ⊢ₐ Rc r ∷ Rty taexpV : ∀{Γ x} → Γ ⊢ₐ V x ∷ Γ x taexpP : ∀{Γ a₁ a₂ τ} → Γ ⊢ₐ a₁ ∷ τ → Γ ⊢ₐ a₂ ∷ τ → Γ ⊢ₐ Plus a₁ a₂ ∷ τ data _⊢₆_ : tyenv → bexp → Set where tbexpC : ∀{Γ v} → Γ ⊢₆ Bc v tbexpN : ∀{Γ b} → Γ ⊢₆ b → Γ ⊢₆ Not b tbexpA : ∀{Γ b₁ b₂} → Γ ⊢₆ b₁ → Γ ⊢₆ b₂ → Γ ⊢₆ And b₁ b₂ tbexpL : ∀{Γ a₁ a₂ τ} → Γ ⊢ₐ a₁ ∷ τ → Γ ⊢ₐ a₂ ∷ τ → Γ ⊢₆ Less a₁ a₂ data _⊢_ : tyenv → com → Set where TSkip : ∀{Γ} → Γ ⊢ SKIP TLoc : ∀{Γ a x} → Γ ⊢ₐ a ∷ Γ x → Γ ⊢ (x ::= a) TSeq : ∀{Γ c₁ c₂} → Γ ⊢ c₁ → Γ ⊢ c₂ → Γ ⊢ (c₁ :: c₂) TIf : ∀{Γ b c₁ c₂} → Γ ⊢₆ b → Γ ⊢ c₁ → Γ ⊢ c₂ → Γ ⊢ (IF b THEN c₁ ELSE c₂) TWhile : ∀{Γ b c} → Γ ⊢₆ b → Γ ⊢ c → Γ ⊢ (WHILE b DO c) type : val → ty type (Iv i) = Ity type (Rv r) = Rty _⊢ₛ_ : tyenv → state → Set Γ ⊢ₛ s = ∀ x → type (s x) ≡ Γ x data taval : aexp → state → val → Set where tavalI : ∀{i s} → taval (Ic i) s (Iv i) tavalR : ∀{r s} → taval (Rc r) s (Rv r) tavalV : ∀{x s} → taval (V x) s (s x) tavalSI : ∀{s a₁ a₂ i₁ i₂} → taval a₁ s (Iv i₁) → taval a₂ s (Iv i₂) → taval (Plus a₁ a₂) s (Iv (i₁ +ᵢ i₂)) tavalSR : ∀{s a₁ a₂ r₁ r₂} → taval a₁ s (Rv r₁) → taval a₂ s (Rv r₂) → taval (Plus a₁ a₂) s (Rv (r₁ +ᵣ r₂)) data tbval : bexp → state → bool → Set where tbvalC : ∀{s v} → tbval (Bc v) s v tbvalN : ∀{s b bv} → tbval b s bv → tbval (Not b) s (not bv) tbvalA : ∀{s b₁ b₂ bv₁ bv₂} → tbval b₁ s bv₁ → tbval b₂ s bv₂ → tbval (And b₁ b₂) s (bv₁ ∧ bv₂) tbvalLI : ∀{s a₁ a₂ i₁ i₂} → taval a₁ s (Iv i₁) → taval a₂ s (Iv i₂) → tbval (Less a₁ a₂) s (⌊ i₁ ≤?ᵢ i₂ ⌋) tbvalLR : ∀{s a₁ a₂ r₁ r₂} → taval a₁ s (Rv r₁) → taval a₂ s (Rv r₂) → tbval (Less a₁ a₂) s (r₁ ≤?ᵣ r₂) data ⦅_,_⦆→⦅_,_⦆ : com → state → com → state → Set where Loc : ∀{x a s v} → taval a s v → ⦅ x ::= a , s ⦆→⦅ SKIP , s [ x ::= v ] ⦆ Comp₁ : ∀{c s} → ⦅ SKIP :: c , s ⦆→⦅ c , s ⦆ Comp₂ : ∀{c₁ c₁′ c₂ s s′} → ⦅ c₁ , s ⦆→⦅ c₁′ , s′ ⦆ → ⦅ c₁ :: c₂ , s ⦆→⦅ c₁′ :: c₂ , s′ ⦆ IfTrue : ∀{b s c₁ c₂} → tbval b s true → ⦅ IF b THEN c₁ ELSE c₂ , s ⦆→⦅ c₁ , s ⦆ IfFalse : ∀{b s c₁ c₂} → tbval b s false → ⦅ IF b THEN c₁ ELSE c₂ , s ⦆→⦅ c₂ , s ⦆ While : ∀{b s c} → ⦅ WHILE b DO c , s ⦆→⦅ IF b THEN (c :: (WHILE b DO c)) ELSE SKIP , s ⦆ data ⦅_,_⦆→*⦅_,_⦆ : com → state → com → state → Set where Ref : ∀{c s} → ⦅ c , s ⦆→*⦅ c , s ⦆ Step : ∀{c c′ c² s s′ s²} → ⦅ c , s ⦆→⦅ c′ , s′ ⦆ → ⦅ c′ , s′ ⦆→*⦅ c² , s² ⦆ → ⦅ c , s ⦆→*⦅ c² , s² ⦆ trans : ∀{c c′ c² s s′ s²} → ⦅ c , s ⦆→*⦅ c′ , s′ ⦆ → ⦅ c′ , s′ ⦆→*⦅ c² , s² ⦆ → ⦅ c , s ⦆→*⦅ c² , s² ⦆ trans Ref b = b trans (Step x a) b = Step x (trans a b) preservation-aval : ∀{Γ a s τ v} → Γ ⊢ₐ a ∷ τ → Γ ⊢ₛ s → taval a s v → type v ≡ τ preservation-aval taexpI b tavalI = refl preservation-aval taexpR b tavalR = refl preservation-aval taexpV b (tavalV {x}) = b x preservation-aval (taexpP a a₁) b (tavalSI c c₁) = preservation-aval a₁ b c₁ preservation-aval (taexpP a a₁) b (tavalSR c c₁) = preservation-aval a₁ b c₁ extract-ity : ∀ v → type v ≡ Ity → ∃[ i ] (v ≡ Iv i) extract-ity (Iv x) r = x , refl extract-rty : ∀ v → type v ≡ Rty → ∃[ i ] (v ≡ Rv i) extract-rty (Rv x) r = x , refl progress-aval : ∀{Γ a s τ} → Γ ⊢ₐ a ∷ τ → Γ ⊢ₛ s → ∃[ v ] (taval a s v) progress-aval taexpI b = -, tavalI progress-aval taexpR b = -, tavalR progress-aval taexpV b = -, tavalV progress-aval {τ = Ity} (taexpP a₁ a₂) b with progress-aval a₁ b | progress-aval a₂ b ... | rv , r | mv , m with extract-ity rv (preservation-aval a₁ b r) | extract-ity mv (preservation-aval a₂ b m) ... | v1 , e1 | v2 , e2 rewrite e1 | e2 = -, tavalSI r m progress-aval {τ = Rty} (taexpP a₁ a₂) b with progress-aval a₁ b | progress-aval a₂ b ... | rv , r | mv , m with extract-rty rv (preservation-aval a₁ b r) | extract-rty mv (preservation-aval a₂ b m) ... | v1 , e1 | v2 , e2 rewrite e1 | e2 = -, tavalSR r m progress-bval : ∀{Γ b s} → Γ ⊢₆ b → Γ ⊢ₛ s → ∃[ v ] (tbval b s v) progress-bval tbexpC x₁ = -, tbvalC progress-bval (tbexpN x) x₁ = -, tbvalN (proj₂ (progress-bval x x₁)) progress-bval (tbexpA a b) x = -, tbvalA (proj₂ (progress-bval a x)) (proj₂ (progress-bval b x)) progress-bval (tbexpL {τ = Ity} a₁ a₂) b with progress-aval a₁ b | progress-aval a₂ b ... | rv , r | mv , m with extract-ity rv (preservation-aval a₁ b r) | extract-ity mv (preservation-aval a₂ b m) ... | v1 , e1 | v2 , e2 rewrite e1 | e2 = -, tbvalLI r m progress-bval (tbexpL {τ = Rty} a₁ a₂) b with progress-aval a₁ b | progress-aval a₂ b ... | rv , r | mv , m with extract-rty rv (preservation-aval a₁ b r) | extract-rty mv (preservation-aval a₂ b m) ... | v1 , e1 | v2 , e2 rewrite e1 | e2 = -, tbvalLR r m preservation-com : ∀{Γ c s c′ s′} → ⦅ c , s ⦆→⦅ c′ , s′ ⦆ → Γ ⊢ c → Γ ⊢ c′ preservation-com (Loc x₁) (TLoc x₂) = TSkip preservation-com Comp₁ (TSeq b b₁) = b₁ preservation-com (Comp₂ a) (TSeq b b₁) = TSeq (preservation-com a b) b₁ preservation-com (IfTrue x) (TIf x₁ b b₁) = b preservation-com (IfFalse x) (TIf x₁ b b₁) = b₁ preservation-com While (TWhile x b) = TIf x (TSeq b (TWhile x b)) TSkip preservation-state : ∀{Γ c s c′ s′} → ⦅ c , s ⦆→⦅ c′ , s′ ⦆ → Γ ⊢ c → Γ ⊢ₛ s → Γ ⊢ₛ s′ preservation-state (Loc {x₃} x₁) (TLoc x₂) r x₄ with x₄ ≟ x₃ ... | no ¬p = r x₄ ... | yes p with preservation-aval x₂ r x₁ ... | z rewrite p = z preservation-state Comp₁ (TSeq c c₁) r = r preservation-state (Comp₂ d) (TSeq c c₁) r = preservation-state d c r preservation-state (IfTrue x) (TIf x₁ c c₁) r = r preservation-state (IfFalse x) (TIf x₁ c c₁) r = r preservation-state While (TWhile x c) r = r preservation : ∀{Γ c s c′ s′} → Γ ⊢ c → Γ ⊢ₛ s → ⦅ c , s ⦆→⦅ c′ , s′ ⦆ → Γ ⊢ c′ × Γ ⊢ₛ s′ preservation a b c = preservation-com c a , preservation-state c a b either-skip : ∀ c → c ≡ SKIP ⊎ ¬ c ≡ SKIP either-skip SKIP = inj₁ refl either-skip (x ::= x₁) = inj₂ (λ ()) either-skip (c :: c₁) = inj₂ (λ ()) either-skip (IF x THEN c ELSE c₁) = inj₂ (λ ()) either-skip (WHILE x DO c) = inj₂ (λ ()) progress : ∀{Γ c s} → Γ ⊢ c → Γ ⊢ₛ s → ¬ c ≡ SKIP → ∃[ c′ ] (∃[ s′ ] ( ⦅ c , s ⦆→⦅ c′ , s′ ⦆ )) progress TSkip b c = contradiction refl c progress {s = s} (TLoc x) b _ = SKIP , -, Loc (proj₂ (progress-aval x b)) progress {s = s} (TSeq {_}{c₁}{c₂} a a₁) b _ with either-skip c₁ ... | inj₁ skip rewrite skip = c₂ , s , Comp₁ ... | inj₂ ¬skip = let c₁′ , s′ , r = progress a b ¬skip in c₁′ :: c₂ , s′ , Comp₂ r progress (TIf x a a₁) b _ with progress-bval x b ... | false , tb = -, -, IfFalse tb ... | true , tb = -, -, IfTrue tb progress (TWhile x a) b _ = -, -, While type-soundness : ∀{c s c′ s′ Γ} → ⦅ c , s ⦆→*⦅ c′ , s′ ⦆ → Γ ⊢ c → Γ ⊢ₛ s → ¬ c′ ≡ SKIP → ∃[ c″ ] (∃[ s″ ] ( ⦅ c′ , s′ ⦆→⦅ c″ , s″ ⦆ )) type-soundness Ref c d e = progress c d e type-soundness (Step x r) c d e with preservation c d x ... | ct , st = type-soundness r ct st e
{ "alphanum_fraction": 0.5093894074, "avg_line_length": 29.9427609428, "ext": "agda", "hexsha": "e6c40976aa9ea5d2c2803c073d23c3da6e3fa5d8", "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": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "iwilare/imp-semantics", "max_forks_repo_path": "Types.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc", "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": "iwilare/imp-semantics", "max_issues_repo_path": "Types.agda", "max_line_length": 87, "max_stars_count": 6, "max_stars_repo_head_hexsha": "cb98e3b3b93362654b79152bfdf2c21eb4951fcc", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "iwilare/imp-semantics", "max_stars_repo_path": "Types.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-24T22:29:44.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-08T11:54:07.000Z", "num_tokens": 4039, "size": 8893 }
module Test where open import Agda.Primitive f : Level -> Level f x = x
{ "alphanum_fraction": 0.7027027027, "avg_line_length": 10.5714285714, "ext": "agda", "hexsha": "2975e9dbde598ba28e2d6fdc4db01c1c7581ef41", "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": "fe6be7731e968c78aef73f4fc14bf7976a607c79", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "phile314/agda-build", "max_forks_repo_path": "test-lib/src/Test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fe6be7731e968c78aef73f4fc14bf7976a607c79", "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": "phile314/agda-build", "max_issues_repo_path": "test-lib/src/Test.agda", "max_line_length": 26, "max_stars_count": null, "max_stars_repo_head_hexsha": "fe6be7731e968c78aef73f4fc14bf7976a607c79", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "phile314/agda-build", "max_stars_repo_path": "test-lib/src/Test.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 22, "size": 74 }
{-# OPTIONS --without-K #-} module container where import container.core import container.fixpoint import container.equality import container.m import container.w
{ "alphanum_fraction": 0.8, "avg_line_length": 16.5, "ext": "agda", "hexsha": "a5c161f01fe48cf6f815413823fd4afebfce7fd3", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/container.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/container.agda", "max_line_length": 27, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/container.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 32, "size": 165 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.EilenbergMacLane open import homotopy.EilenbergMacLaneFunctor open import cohomology.CupProduct.OnEM.CommutativityInLowDegrees module cohomology.CupProduct.OnEM.CommutativityInLowDegrees2 {i} {j} (G : AbGroup i) (H : AbGroup j) where private module G = AbGroup G module H = AbGroup H module G⊗H = TensorProduct G H module H⊗G = TensorProduct H G module GHc = CP₁₁-comm G H module HGc = CP₁₁-comm H G import cohomology.CupProduct.OnEM.InLowDegrees2 G H as GH import cohomology.CupProduct.OnEM.InLowDegrees2 H G as HG private ∧-cp₁₁-comm-smgluel : ∀ (x : EM₁ G.grp) → Square (GHc.CP₁₁Comm.f x embase) (ap GH.∧-cp₁₁ (smgluel x)) (ap (GHc.− ∘ HG.∧-cp₁₁ ∘ ∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) (smgluel x)) idp ∧-cp₁₁-comm-smgluel x = GH.∧-cp₁₁-Rec.smgluel-β x ∙v⊡ lt-square (GH.cp₁₁-embase-r x) ⊡v∙ ! bottom-path where bottom-path : ap (GHc.− ∘ HG.∧-cp₁₁ ∘ ∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) (smgluel x) == idp bottom-path = ap (GHc.− ∘ HG.∧-cp₁₁ ∘ ∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) (smgluel x) =⟨ ap-∘ (GHc.− ∘ HG.∧-cp₁₁) (∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) (smgluel x) ⟩ ap (GHc.− ∘ HG.∧-cp₁₁) (ap (∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) (smgluel x)) =⟨ ap (ap (GHc.− ∘ HG.∧-cp₁₁)) (SmashSwap.smgluel-β (⊙EM₁ G.grp) (⊙EM₁ H.grp) x) ⟩ ap (GHc.− ∘ HG.∧-cp₁₁) (∧-norm-r x) =⟨ ap-∘ GHc.− HG.∧-cp₁₁ (∧-norm-r x) ⟩ ap GHc.− (ap HG.∧-cp₁₁ (∧-norm-r x)) =⟨ ap (ap GHc.−) (HG.∧-cp₁₁-Rec.∧-norm-r-β x) ⟩ idp =∎ cp₁₁-comm-sym : ∀ (y : EM₁ H.grp) → ! (GHc.CP₁₁Comm.f embase y) == ap GHc.− (HGc.CP₁₁Comm.f y embase) cp₁₁-comm-sym = EM₁-set-elim {P = λ y → ! (GHc.CP₁₁Comm.f embase y) == ap GHc.− (HGc.CP₁₁Comm.f y embase)} {{λ y → has-level-apply (has-level-apply (Trunc-level {n = 2}) _ _) _ _}} idp $ λ h → ↓-=-in $ idp ◃ apd (λ y → ap GHc.− (HGc.CP₁₁Comm.f y embase)) (emloop h) =⟨ idp◃ (apd (λ y → ap GHc.− (HGc.CP₁₁Comm.f y embase)) (emloop h)) ⟩ apd (λ y → ap GHc.− (HGc.CP₁₁Comm.f y embase)) (emloop h) =⟨ apd-∘' (ap GHc.−) (λ y → HGc.CP₁₁Comm.f y embase) (emloop h) ⟩ ap↓ (ap GHc.−) (apd (λ y → HGc.CP₁₁Comm.f y embase) (emloop h)) =⟨ ap (ap↓ (ap GHc.−)) (HGc.CP₁₁Comm.emloop-embase-β h) ⟩ ap↓ (ap GHc.−) (↓-='-from-square (HGc.comm-emloop-embase h)) =⟨ ↓-='-from-square-post-∘ {h = GHc.−} (HGc.comm-emloop-embase h) ⟩ ↓-='-from-square (ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ∙v⊡ ap-square GHc.− (HGc.comm-emloop-embase h) ⊡v∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h)) =⟨ ap ↓-='-from-square (square-path h) ⟩ ↓-='-from-square (!□v (GHc.comm-embase-emloop h)) =⟨ ! (↓-='-from-square-! (GHc.comm-embase-emloop h)) ⟩ ap↓ ! (↓-='-from-square (GHc.comm-embase-emloop h)) =⟨ ap (ap↓ !) (! (GHc.CP₁₁Comm.embase-emloop-β h)) ⟩ ap↓ ! (apd (λ y → GHc.CP₁₁Comm.f embase y) (emloop h)) =⟨ ! (apd-∘' ! (λ y → GHc.CP₁₁Comm.f embase y) (emloop h)) ⟩ apd (λ y → ! (GHc.CP₁₁Comm.f embase y)) (emloop h) =⟨ ! (▹idp (apd (λ y → ! (GHc.CP₁₁Comm.f embase y)) (emloop h))) ⟩ apd (λ y → ! (GHc.CP₁₁Comm.f embase y)) (emloop h) ▹ idp =∎ where =ₛ-path : ∀ (h : H.El) → ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ◃∙ ap (ap GHc.−) (HGc.comm-emloop-embase' h) ◃∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h) ◃∎ =ₛ ! (GHc.comm-embase-emloop' h) ◃∎ =ₛ-path h = !ₛ $ ! (GHc.comm-embase-emloop' h) ◃∎ =ₛ⟨ !-∙-seq (GHc.comm-embase-emloop-seq h) ⟩ ! (∘-ap GHc.− (λ y → HG.cp₁₁ y embase) (emloop h)) ◃∙ ! (! (ap (ap GHc.−) (HG.ap-cp₁₁-embase h))) ◃∙ ! (ap-cst [ north ] (emloop h)) ◃∎ =ₛ₁⟨ 0 & 1 & ap ! (! (!ap-∘=∘-ap GHc.− (λ y → HG.cp₁₁ y embase) (emloop h))) ∙ !-! (ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h)) ⟩ ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ◃∙ ! (! (ap (ap GHc.−) (HG.ap-cp₁₁-embase h))) ◃∙ ! (ap-cst [ north ] (emloop h)) ◃∎ =ₛ₁⟨ 1 & 1 & !-! (ap (ap GHc.−) (HG.ap-cp₁₁-embase h)) ⟩ ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ◃∙ ap (ap GHc.−) (HG.ap-cp₁₁-embase h) ◃∙ ! (ap-cst [ north ]₂ (emloop h)) ◃∎ =ₛ⟨ 2 & 2 & !ₛ $ post-rotate-in {p = _ ◃∙ _ ◃∎} $ pre-rotate'-in $ ap-∘-cst-coh GHc.− [ north ]₂ (emloop h) ⟩ ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ◃∙ ap (ap GHc.−) (HG.ap-cp₁₁-embase h) ◃∙ ! (ap (ap GHc.−) (ap-cst [ north ] (emloop h))) ◃∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h) ◃∎ =ₛ₁⟨ 2 & 1 & !-ap (ap GHc.−) (ap-cst [ north ]₂ (emloop h)) ⟩ ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ◃∙ ap (ap GHc.−) (HG.ap-cp₁₁-embase h) ◃∙ ap (ap GHc.−) (! (ap-cst [ north ]₂ (emloop h))) ◃∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h) ◃∎ =ₛ⟨ 1 & 2 & ∙-ap-seq (ap GHc.−) (HGc.comm-emloop-embase-seq h) ⟩ ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ◃∙ ap (ap GHc.−) (HGc.comm-emloop-embase' h) ◃∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h) ◃∎ ∎ₛ square-path : ∀ (h : H.El) → ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ∙v⊡ ap-square GHc.− (HGc.comm-emloop-embase h) ⊡v∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h) == !□v (GHc.comm-embase-emloop h) square-path h = ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ∙v⊡ ap-square GHc.− (HGc.comm-emloop-embase h) ⊡v∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h) =⟨ ap (λ u → ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ∙v⊡ u ⊡v∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h)) $ ap-vert-degen-square GHc.− (HGc.comm-emloop-embase' h) ⟩ ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ∙v⊡ vert-degen-square (ap (ap GHc.−) (HGc.comm-emloop-embase' h)) ⊡v∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h) =⟨ ap (ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ∙v⊡_) $ vert-degen-square-⊡v∙ (ap (ap GHc.−) (HGc.comm-emloop-embase' h)) (∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h)) ⟩ ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ∙v⊡ vert-degen-square (ap (ap GHc.−) (HGc.comm-emloop-embase' h) ∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h)) =⟨ vert-degen-square-∙v⊡ (ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h)) (ap (ap GHc.−) (HGc.comm-emloop-embase' h) ∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h)) ⟩ vert-degen-square (ap-∘ GHc.− (λ y → HG.cp₁₁ y embase) (emloop h) ∙ ap (ap GHc.−) (HGc.comm-emloop-embase' h) ∙ ∘-ap GHc.− (λ y → HGc.− (GH.cp₁₁ embase y)) (emloop h)) =⟨ ap vert-degen-square (=ₛ-out (=ₛ-path h)) ⟩ vert-degen-square (! (GHc.comm-embase-emloop' h)) =⟨ ! (!□v-vert-degen-square (GHc.comm-embase-emloop' h)) ⟩ !□v (GHc.comm-embase-emloop h) =∎ ∧-cp₁₁-comm-smgluer : ∀ (y : EM₁ H.grp) → Square (GHc.CP₁₁Comm.f embase y) (ap GH.∧-cp₁₁ (smgluer y)) (ap (GHc.− ∘ HG.∧-cp₁₁ ∘ ∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) (smgluer y)) idp ∧-cp₁₁-comm-smgluer y = GH.∧-cp₁₁-Rec.smgluer-β y ∙v⊡ lb-square (GHc.CP₁₁Comm.f embase y) ⊡v∙ (cp₁₁-comm-sym y ∙ ! bottom-path) where bottom-path : ap (GHc.− ∘ HG.∧-cp₁₁ ∘ ∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) (smgluer y) == ap GHc.− (HG.cp₁₁-embase-r y) bottom-path = ap (GHc.− ∘ HG.∧-cp₁₁ ∘ ∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) (smgluer y) =⟨ ap-∘ (GHc.− ∘ HG.∧-cp₁₁) (∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) (smgluer y) ⟩ ap (GHc.− ∘ HG.∧-cp₁₁) (ap (∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) (smgluer y)) =⟨ ap (ap (GHc.− ∘ HG.∧-cp₁₁)) (SmashSwap.smgluer-β (⊙EM₁ G.grp) (⊙EM₁ H.grp) y) ⟩ ap (GHc.− ∘ HG.∧-cp₁₁) (∧-norm-l y) =⟨ ap-∘ GHc.− HG.∧-cp₁₁ (∧-norm-l y) ⟩ ap GHc.− (ap HG.∧-cp₁₁ (∧-norm-l y)) =⟨ ap (ap GHc.−) (HG.∧-cp₁₁-Rec.∧-norm-l-β y) ⟩ ap GHc.− (HG.cp₁₁-embase-r y ∙ idp) =⟨ ap (ap GHc.−) (∙-unit-r (HG.cp₁₁-embase-r y)) ⟩ ap GHc.− (HG.cp₁₁-embase-r y) =∎ private ∧-cp₁₁-comm' : GH.∧-cp₁₁ ∼ GHc.− ∘ HG.∧-cp₁₁ ∘ ∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp) ∧-cp₁₁-comm' = Smash-Path-elim GH.∧-cp₁₁ (GHc.− ∘ HG.∧-cp₁₁ ∘ ∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp)) GHc.CP₁₁Comm.f idp idp ∧-cp₁₁-comm-smgluel ∧-cp₁₁-comm-smgluer ⊙∧-cp₁₁-comm' : GH.⊙∧-cp₁₁ ◃⊙idf =⊙∘ GHc.⊙− ◃⊙∘ HG.⊙∧-cp₁₁ ◃⊙∘ ⊙∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp) ◃⊙idf ⊙∧-cp₁₁-comm' = =⊙∘-in (⊙λ=' ∧-cp₁₁-comm' idp) ⊙∧-cp₁₁-comm : ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap 2 ◃⊙∘ GH.⊙∧-cp₁₁ ◃⊙idf =⊙∘ ⊙EM-neg H⊗G.abgroup 2 ◃⊙∘ HG.⊙∧-cp₁₁ ◃⊙∘ ⊙∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp) ◃⊙idf ⊙∧-cp₁₁-comm = ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap 2 ◃⊙∘ GH.⊙∧-cp₁₁ ◃⊙idf =⊙∘⟨ 1 & 1 & ⊙∧-cp₁₁-comm' ⟩ ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap 2 ◃⊙∘ GHc.⊙− ◃⊙∘ HG.⊙∧-cp₁₁ ◃⊙∘ ⊙∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp) ◃⊙idf =⊙∘⟨ 1 & 1 & minus ⟩ ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap 2 ◃⊙∘ ⊙EM-fmap H⊗G.abgroup G⊗H.abgroup H⊗G.swap 2 ◃⊙∘ ⊙EM-neg H⊗G.abgroup 2 ◃⊙∘ HG.⊙∧-cp₁₁ ◃⊙∘ ⊙∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp) ◃⊙idf =⊙∘⟨ 0 & 2 & =⊙∘-in {gs = ⊙idf-seq} $ ! (⊙EM-fmap-∘ H⊗G.abgroup G⊗H.abgroup H⊗G.abgroup G⊗H.swap H⊗G.swap 2) ∙ ap (λ φ → ⊙EM-fmap H⊗G.abgroup H⊗G.abgroup φ 2) H⊗G.swap-swap-idhom ∙ ⊙EM-fmap-idhom H⊗G.abgroup 2 ⟩ ⊙EM-neg H⊗G.abgroup 2 ◃⊙∘ HG.⊙∧-cp₁₁ ◃⊙∘ ⊙∧-swap (⊙EM₁ G.grp) (⊙EM₁ H.grp) ◃⊙idf ∎⊙∘ where minus : GHc.⊙− ◃⊙idf =⊙∘ ⊙EM-fmap H⊗G.abgroup G⊗H.abgroup H⊗G.swap 2 ◃⊙∘ ⊙EM-neg H⊗G.abgroup 2 ◃⊙idf minus = =⊙∘-in $ ⊙Trunc-fmap (⊙Susp-fmap (EM₁-fmap (inv-hom G⊗H.abgroup) ∘ EM₁-fmap H⊗G.swap)) =⟨ ap (⊙Trunc-fmap ∘ ⊙Susp-fmap) $ ! $ λ= (EM₁-fmap-∘ (inv-hom G⊗H.abgroup) H⊗G.swap) ⟩ ⊙EM-fmap H⊗G.abgroup G⊗H.abgroup (inv-hom G⊗H.abgroup ∘ᴳ H⊗G.swap) 2 =⟨ ap (λ φ → ⊙EM-fmap H⊗G.abgroup G⊗H.abgroup φ 2) $ ! $ inv-hom-natural H⊗G.abgroup G⊗H.abgroup H⊗G.swap ⟩ ⊙EM-fmap H⊗G.abgroup G⊗H.abgroup (H⊗G.swap ∘ᴳ inv-hom H⊗G.abgroup) 2 =⟨ ⊙EM-fmap-∘ H⊗G.abgroup H⊗G.abgroup G⊗H.abgroup (H⊗G.swap) (inv-hom H⊗G.abgroup) 2 ⟩ ⊙EM-fmap H⊗G.abgroup G⊗H.abgroup H⊗G.swap 2 ⊙∘ ⊙EM-neg H⊗G.abgroup 2 =∎
{ "alphanum_fraction": 0.4984689617, "avg_line_length": 46.8565217391, "ext": "agda", "hexsha": "518b7ec2f8e47b503e3377b8079503d474eebd18", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "theorems/cohomology/CupProduct/OnEM/CommutativityInLowDegrees2.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "theorems/cohomology/CupProduct/OnEM/CommutativityInLowDegrees2.agda", "max_line_length": 120, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "theorems/cohomology/CupProduct/OnEM/CommutativityInLowDegrees2.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 5595, "size": 10777 }
------------------------------------------------------------------------ -- Modules that are not safe because they use --sized-types ------------------------------------------------------------------------ {-# OPTIONS --without-K --sized-types #-} module README.Unsafe.Sized-types where -- Support for sized types. import Prelude.Size -- Some results that could not be placed in Function-universe because -- they make use of --sized-types. import Function-universe.Size -- Conatural numbers. import Conat -- Colists. import Colist -- M-types. import M
{ "alphanum_fraction": 0.5390070922, "avg_line_length": 19.4482758621, "ext": "agda", "hexsha": "72a47654e1ce6722e9f6d91b73081bef323e6d9a", "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": "README/Unsafe/Sized-types.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": "README/Unsafe/Sized-types.agda", "max_line_length": 72, "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": "README/Unsafe/Sized-types.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": 101, "size": 564 }
module unit where open import level open import eq data ⊤ : Set where triv : ⊤ {-# COMPILED_DATA ⊤ () () #-} single-range : ∀{U : Set}{g : U → ⊤} → ∀{u : U} → g u ≡ triv single-range {U}{g}{u} with g u ... | triv = refl
{ "alphanum_fraction": 0.5462555066, "avg_line_length": 16.2142857143, "ext": "agda", "hexsha": "6822ed0f3f2fe000afc1574a3ad5dd3be702b53b", "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": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "logicshan/IAL", "max_forks_repo_path": "unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "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": "logicshan/IAL", "max_issues_repo_path": "unit.agda", "max_line_length": 60, "max_stars_count": null, "max_stars_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "logicshan/IAL", "max_stars_repo_path": "unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 88, "size": 227 }
-- Reported by nad, 2018-12-13. -- The option --no-sized-types should turn off sized types {-# OPTIONS --no-sized-types #-} {-# BUILTIN SIZE Size #-} {-# BUILTIN SIZELT Size<_ #-} record Stream (A : Set) (i : Size) : Set where coinductive field head : A tail : {j : Size< i} → Stream A j open Stream postulate destroy-guardedness : {A : Set} → A → A repeat : ∀ {A i} → A → Stream A i repeat x .head = x repeat x .tail = destroy-guardedness (repeat x)
{ "alphanum_fraction": 0.6181434599, "avg_line_length": 21.5454545455, "ext": "agda", "hexsha": "8210753cacad804cd8f159aa16c8343f61648e04", "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/Issue3451.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/Issue3451.agda", "max_line_length": 58, "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/Issue3451.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": 151, "size": 474 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Operations on nullary relations (like negation and decidability) ------------------------------------------------------------------------ -- Some operations on/properties of nullary relations, i.e. sets. {-# OPTIONS --without-K --safe #-} module Relation.Nullary where open import Data.Empty hiding (⊥-elim) open import Data.Empty.Irrelevant open import Level -- Negation. infix 3 ¬_ ¬_ : ∀ {ℓ} → Set ℓ → Set ℓ ¬ P = P → ⊥ -- Decidable relations. data Dec {p} (P : Set p) : Set p where yes : ( p : P) → Dec P no : (¬p : ¬ P) → Dec P -- Given an irrelevant proof of a decidable type, a proof can -- be recomputed and subsequently used in relevant contexts. recompute : ∀ {a} {A : Set a} → Dec A → .A → A recompute (yes x) _ = x recompute (no ¬p) x = ⊥-elim (¬p x)
{ "alphanum_fraction": 0.5405405405, "avg_line_length": 25.3714285714, "ext": "agda", "hexsha": "74d26ecc73db62c698a5bc0443e787d65535c443", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Nullary.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/Nullary.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Nullary.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 240, "size": 888 }
{-# OPTIONS --sized-types #-} open import Relation.Binary.Core module Quicksort {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) where open import Bound.Total A open import Bound.Total.Order _≤_ open import Data.List open import Data.Product open import Data.Sum open import SBList _≤_ open import Size open import SOList.Total _≤_ deal : {ι : Size}{b t : Bound}{x : A} → LeB b (val x) → LeB (val x) t → SBList {ι} b t → SBList {ι} b (val x) × SBList {ι} (val x) t deal b≤x x≤t (nil b≤t) = (nil b≤x , nil x≤t) deal {x = x} b≤x x≤t (cons y b≤y y≤t ys) with tot≤ x y | deal b≤x x≤t ys ... | inj₁ x≤y | (us , vs) = (us , cons y (lexy x≤y) y≤t vs) ... | inj₂ y≤x | (us , vs) = (cons y b≤y (lexy y≤x) us , vs) quickSort : {ι : Size}{b t : Bound} → SBList {ι} b t → SOList b t quickSort (nil b≤t) = onil b≤t quickSort (cons x b≤x x≤t xs) with deal b≤x x≤t xs ... | (ys , zs) = ocons x (quickSort ys) (quickSort zs)
{ "alphanum_fraction": 0.5736514523, "avg_line_length": 32.1333333333, "ext": "agda", "hexsha": "0af5fdfd67255705eb94c16621e3a84573f28180", "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/Quicksort.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/Quicksort.agda", "max_line_length": 132, "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/Quicksort.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": 403, "size": 964 }
{-# OPTIONS --safe #-} module Confluence where open import Relation.Binary.PropositionalEquality using (_≡_; refl) cong : ∀ {A B : Set} {x y : A} (f : A → B) → x ≡ y → f x ≡ f y cong f refl = refl data ℕ : Set where Z : ℕ S : ℕ → ℕ add : ℕ → ℕ → ℕ add n Z = n add n (S m) = S (add n m) _ : ∀ {a : ℕ} → add a Z ≡ a _ = refl thm : ∀ {a : ℕ} → add Z a ≡ a thm {a = Z} = refl thm {a = (S m)} = cong S thm -- Confluence checking is not supported; -- Check out Jesper Cockx's Phd thesis for overlapping patterns.
{ "alphanum_fraction": 0.5673076923, "avg_line_length": 19.2592592593, "ext": "agda", "hexsha": "fde0b93c08bd4c978581745191f18acfc78435b1", "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": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "anqurvanillapy/fpl", "max_forks_repo_path": "agda/Confluence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "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": "anqurvanillapy/fpl", "max_issues_repo_path": "agda/Confluence.agda", "max_line_length": 64, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "anqurvanillapy/fpl", "max_stars_repo_path": "agda/Confluence.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-24T22:47:47.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-24T22:47:47.000Z", "num_tokens": 200, "size": 520 }
module Prelude.Nat.Core where open import Prelude.Unit open import Prelude.Empty open import Prelude.Number open import Prelude.Semiring open import Agda.Builtin.Nat public renaming ( _+_ to _+N_ ; _*_ to _*N_ ; _-_ to _-N_ ; _==_ to eqNat ; _<_ to lessNat ; div-helper to divAux ; mod-helper to modAux ) {-# DISPLAY _+N_ = _+_ #-} {-# DISPLAY _-N_ = _-_ #-} {-# DISPLAY _*N_ = _*_ #-} --- Semiring --- instance NumberNat : Number Nat Number.Constraint NumberNat _ = ⊤ Number.fromNat NumberNat n = n SemiringNat : Semiring Nat zro {{SemiringNat}} = 0 one {{SemiringNat}} = 1 _+_ {{SemiringNat}} = _+N_ _*_ {{SemiringNat}} = _*N_ SubtractiveNat : Subtractive Nat _-_ {{SubtractiveNat}} = _-N_ negate {{SubtractiveNat}} _ = 0 --- Division and modulo --- NonZero : Nat → Set NonZero zero = ⊥ NonZero (suc _) = ⊤ infixl 7 natDiv natMod syntax natDiv m n = n div m natDiv : (m : Nat) {{nz : NonZero m}} → Nat → Nat natDiv zero {{}} n natDiv (suc m) n = divAux 0 m n m syntax natMod m n = n mod m natMod : (m : Nat) {{nz : NonZero m}} → Nat → Nat natMod zero {{}} n natMod (suc m) n = modAux 0 m n m {-# INLINE natMod #-} {-# INLINE natDiv #-}
{ "alphanum_fraction": 0.5839813375, "avg_line_length": 22.1724137931, "ext": "agda", "hexsha": "a3243523f29500bf304a45c2234d5ac3985051d5", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Prelude/Nat/Core.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Prelude/Nat/Core.agda", "max_line_length": 49, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Prelude/Nat/Core.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 424, "size": 1286 }
import Lvl module Function.Names where open import Functional.Dependent open import Logic.Predicate open import Structure.Setoid open import Type private variable ℓ ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₗ ℓₗ₁ ℓₗ₂ ℓₗ₃ : Lvl.Level module _ {A : Type{ℓₒ₁}} {B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₃}(B(a)) ⦄ where -- Extensional equality on functions. -- Alternative definition: f ⊜ g = (∀{x} → (f(x) ≡ g(x))) _⊜_ : ((a : A) → B(a)) → ((a : A) → B(a)) → Type _⊜_ = ∀¹ ∘₂ pointwise₂,₁(_≡_) _⊜₁_ = _⊜_ module _ {A : Type{ℓₒ₁}} {B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₃}(B(a)) ⦄ where _⊜ᵢ_ : ({a : A} → B(a)) → ({a : A} → B(a)) → Type _⊜ᵢ_ f g = (∀{x} → (f{x} ≡ g{x})) module _ {A : Type{ℓₒ₁}} {B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₃}(B(a)) ⦄ where _⦃⊜⦄_ : (⦃ a : A ⦄ → B(a)) → (⦃ a : A ⦄ → B(a)) → Type _⦃⊜⦄_ f g = (∀{x} → (f ⦃ x ⦄ ≡ g ⦃ x ⦄)) module _ {A₁ : Type{ℓₒ₁}} {A₂ : A₁ → Type{ℓₒ₂}} {B : (a₁ : A₁) → A₂(a₁) → Type{ℓₒ₂}} ⦃ _ : ∀{a₁}{a₂} → Equiv{ℓₗ₃}(B(a₁)(a₂)) ⦄ where -- Alternative definition: f ⊜ g = (∀{x}{y} → (f(x)(y) ≡ g(x)(y))) _⊜₂_ : (f g : ∀(a₁)(a₂) → B(a₁)(a₂)) → Type _⊜₂_ = ∀¹ ∘₂ (∀¹ ∘₃ pointwise₂,₂(_≡_)) module _ {A₁ : Type{ℓₒ₁}} {A₂ : A₁ → Type{ℓₒ₂}} {A₃ : (a₁ : A₁) → A₂(a₁) → Type{ℓₒ₂}} {B : (a₁ : A₁) → (a₂ : A₂(a₁)) → A₃(a₁)(a₂) → Type{ℓₒ₂}} ⦃ _ : ∀{a₁}{a₂}{a₃} → Equiv{ℓₗ₃}(B(a₁)(a₂)(a₃)) ⦄ where -- Alternative definition: f ⊜ g = (∀{x}{y}{z} → (f(x)(y)(z) ≡ g(x)(y)(z))) _⊜₃_ : (f g : ∀(a₁)(a₂)(a₃) → B(a₁)(a₂)(a₃)) → Type _⊜₃_ = ∀¹ ∘₂ (∀¹ ∘₃ (∀¹ ∘₄ pointwise₂,₃(_≡_)))
{ "alphanum_fraction": 0.4888304862, "avg_line_length": 42.2777777778, "ext": "agda", "hexsha": "1dcf737765b94986b7daab4dddcf4349d1a81817", "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": "Function/Names.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": "Function/Names.agda", "max_line_length": 198, "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": "Function/Names.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": 921, "size": 1522 }
{-# OPTIONS --cubical #-} module Data.Boolean.Equiv.Path where open import Data open import Data.Boolean open import Data.Boolean.Stmt open import Functional open import Logic.Propositional open import Structure.Relator.Properties open import Structure.Relator open import Type.Cubical.Path.Equality open import Type.Cubical.Path open import Type.Identity Bool-different-values : ¬(Path 𝐹 𝑇) Bool-different-values p = substitute₁ₗ(IsTrue) p <> Bool-Path-to-Id : ∀{x y : Bool} → (Path x y) → (Id x y) Bool-Path-to-Id {𝑇} {𝑇} _ = intro Bool-Path-to-Id {𝑇} {𝐹} = [⊥]-elim ∘ Bool-different-values ∘ symmetry(Path) Bool-Path-to-Id {𝐹} {𝑇} = [⊥]-elim ∘ Bool-different-values Bool-Path-to-Id {𝐹} {𝐹} _ = intro
{ "alphanum_fraction": 0.7215189873, "avg_line_length": 29.625, "ext": "agda", "hexsha": "a3195564129b1feecc9494779df45a07a8f0b9de", "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/Boolean/Equiv/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": "Data/Boolean/Equiv/Path.agda", "max_line_length": 77, "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/Boolean/Equiv/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": 241, "size": 711 }
{- 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 import LibraBFT.Impl.Types.LedgerInfoWithSignatures as LIWS open import LibraBFT.ImplShared.Consensus.Types open import Optics.All open import Util.Prelude module LibraBFT.Impl.Types.EpochState where verify : EpochState → LedgerInfoWithSignatures → Either ErrLog Unit verify self ledgerInfo = do lcheck (self ^∙ esEpoch == ledgerInfo ^∙ liwsLedgerInfo ∙ liEpoch) ( "EpochState" ∷ "LedgerInfo has unexpected epoch" ∷ []) --, show (self^.esEpoch), show (ledgerInfo^.liwsLedgerInfo.liEpoch) ] LIWS.verifySignatures ledgerInfo (self ^∙ esVerifier) epochChangeVerificationRequired : EpochState → Epoch → Bool epochChangeVerificationRequired self epoch = ⌊ self ^∙ esEpoch <? epoch ⌋ isLedgerInfoStale : EpochState → LedgerInfo → Bool isLedgerInfoStale self ledgerInfo = ⌊ ledgerInfo ^∙ liEpoch <? self ^∙ esEpoch ⌋
{ "alphanum_fraction": 0.7641996558, "avg_line_length": 41.5, "ext": "agda", "hexsha": "73146ed99b1440448c5350d16df2594cae9f5fec", "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/Types/EpochState.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/Types/EpochState.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/Types/EpochState.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 331, "size": 1162 }
open import Level using (_⊔_; suc) open import Data.Empty using (⊥) open import Relation.Binary using (Rel; Decidable; DecSetoid) module AKS.Algebra.Bundles where open import AKS.Nat using (ℕ) open import Algebra.Core using (Op₁; Op₂) open import Algebra.Bundles using (CommutativeRing) public open import AKS.Algebra.Structures using ( IsNonZeroCommutativeRing; IsIntegralDomain; IsGCDDomain ; IsUniqueFactorizationDomain; IsEuclideanDomain; IsField ; IsDecField; IsFiniteField ) public record NonZeroCommutativeRing a ℓ : Set (suc (a ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set a _≈_ : Rel Carrier ℓ infix 4 _≉_ _≉_ : Rel Carrier ℓ x ≉ y = x ≈ y → ⊥ field _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier isNonZeroCommutativeRing : IsNonZeroCommutativeRing Carrier _≈_ _+_ _*_ -_ 0# 1# open IsNonZeroCommutativeRing isNonZeroCommutativeRing using (isCommutativeRing; 0#≉1#; 1#≉0#; 0#≉-1#; -1#≉0#; C/0; 1#-nonzero; -1#-nonzero) public commutativeRing : CommutativeRing a ℓ commutativeRing = record { isCommutativeRing = isCommutativeRing } open CommutativeRing commutativeRing using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; +-group; +-abelianGroup; _-_ ; *-rawMonoid; *-monoid; *-commutativeMonoid ; nearSemiring; semiringWithoutOne ; semiringWithoutAnnihilatingZero; semiring ; commutativeSemiringWithoutOne; commutativeSemiring ; ring; setoid; isEquivalence ) public record IntegralDomain a ℓ : Set (suc (a ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set a _≈_ : Rel Carrier ℓ infix 4 _≉_ _≉_ : Rel Carrier ℓ x ≉ y = x ≈ y → ⊥ field _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier isIntegralDomain : IsIntegralDomain Carrier _≈_ _+_ _*_ -_ 0# 1# open IsIntegralDomain isIntegralDomain using (isNonZeroCommutativeRing; *-cancelˡ; *-cancelʳ; *≉0; _*-nonzero_) public nonZeroCommutativeRing : NonZeroCommutativeRing a ℓ nonZeroCommutativeRing = record { isNonZeroCommutativeRing = isNonZeroCommutativeRing } open NonZeroCommutativeRing nonZeroCommutativeRing using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; +-group; +-abelianGroup; _-_ ; *-rawMonoid; *-monoid; *-commutativeMonoid ; nearSemiring; semiringWithoutOne ; semiringWithoutAnnihilatingZero; semiring ; commutativeSemiringWithoutOne; commutativeSemiring ; ring; commutativeRing ; 0#≉1#; 1#≉0#; 0#≉-1#; -1#≉0#; C/0; 1#-nonzero; -1#-nonzero ; setoid; isEquivalence ) public record GCDDomain a ℓ : Set (suc (a ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set a _≈_ : Rel Carrier ℓ infix 4 _≉_ _≉_ : Rel Carrier ℓ x ≉ y = x ≈ y → ⊥ field _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier gcd : Op₂ Carrier isGCDDomain : IsGCDDomain Carrier _≈_ _+_ _*_ -_ 0# 1# gcd open IsGCDDomain isGCDDomain using (isIntegralDomain) public integralDomain : IntegralDomain a ℓ integralDomain = record { isIntegralDomain = isIntegralDomain } open IntegralDomain integralDomain using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; +-group; +-abelianGroup; _-_ ; *-rawMonoid; *-monoid; *-commutativeMonoid ; nearSemiring; semiringWithoutOne ; semiringWithoutAnnihilatingZero; semiring ; commutativeSemiringWithoutOne; commutativeSemiring ; ring; commutativeRing; nonZeroCommutativeRing ; 0#≉1#; 1#≉0#; 0#≉-1#; -1#≉0# ; C/0; *-cancelˡ; *-cancelʳ; *≉0; _*-nonzero_; 1#-nonzero; -1#-nonzero ; setoid; isEquivalence ) public record UniqueFactorizationDomain a ℓ : Set (suc (a ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set a _≈_ : Rel Carrier ℓ infix 4 _≉_ _≉_ : Rel Carrier ℓ x ≉ y = x ≈ y → ⊥ field _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier gcd : Op₂ Carrier isUniqueFactorizationDomain : IsUniqueFactorizationDomain Carrier _≈_ _+_ _*_ -_ 0# 1# gcd open IsUniqueFactorizationDomain isUniqueFactorizationDomain using (isGCDDomain) public gcdDomain : GCDDomain a ℓ gcdDomain = record { isGCDDomain = isGCDDomain } open GCDDomain gcdDomain using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; +-group; +-abelianGroup; _-_ ; *-rawMonoid; *-monoid; *-commutativeMonoid ; nearSemiring; semiringWithoutOne ; semiringWithoutAnnihilatingZero; semiring ; commutativeSemiringWithoutOne; commutativeSemiring ; ring; commutativeRing; nonZeroCommutativeRing ; 0#≉1#; 1#≉0#; 0#≉-1#; -1#≉0# ; C/0; *-cancelˡ; *-cancelʳ; *≉0; _*-nonzero_; 1#-nonzero; -1#-nonzero ; setoid; isEquivalence ) public record EuclideanDomain a ℓ : Set (suc (a ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 7 _div_ infixl 7 _mod_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set a _≈_ : Rel Carrier ℓ infix 4 _≉_ _≉_ : Rel Carrier ℓ x ≉ y = x ≈ y → ⊥ field _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier ∣_∣ : ∀ n {n≉0 : n ≉ 0#} → ℕ _div_ : ∀ (n m : Carrier) {m≉0 : m ≉ 0#} → Carrier _mod_ : ∀ (n m : Carrier) {m≉0 : m ≉ 0#} → Carrier gcd : Op₂ Carrier isEuclideanDomain : IsEuclideanDomain Carrier _≈_ _+_ _*_ -_ 0# 1# ∣_∣ _div_ _mod_ gcd open import AKS.Algebra.Structures Carrier _≈_ using (module Modulus) open Modulus 0# ∣_∣ _mod_ using (Remainder; 0≈; 0≉) open IsEuclideanDomain isEuclideanDomain using ( isUniqueFactorizationDomain ; division; modulus ) public uniqueFactorizationDomain : UniqueFactorizationDomain a ℓ uniqueFactorizationDomain = record { isUniqueFactorizationDomain = isUniqueFactorizationDomain } open UniqueFactorizationDomain uniqueFactorizationDomain using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; +-group; +-abelianGroup; _-_ ; *-rawMonoid; *-monoid; *-commutativeMonoid ; nearSemiring; semiringWithoutOne ; semiringWithoutAnnihilatingZero; semiring ; commutativeSemiringWithoutOne; commutativeSemiring ; ring; commutativeRing; nonZeroCommutativeRing ; 0#≉1#; 1#≉0#; 0#≉-1#; -1#≉0# ; C/0; *-cancelˡ; *-cancelʳ; *≉0; _*-nonzero_; 1#-nonzero; -1#-nonzero ; setoid; isEquivalence ) public record Field a ℓ : Set (suc (a ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 7 _/_ infixl 6 _+_ infix 4 _≈_ field Carrier : Set a _≈_ : Rel Carrier ℓ infix 4 _≉_ _≉_ : Rel Carrier ℓ x ≉ y = x ≈ y → ⊥ field _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier _/_ : ∀ (n m : Carrier) {m≉0 : m ≉ 0#} → Carrier gcd : Op₂ Carrier isField : IsField Carrier _≈_ _+_ _*_ -_ 0# 1# _/_ gcd open IsField isField using ( isEuclideanDomain ; m*[n/m]≈n; [n/m]*m≈n; /-cong; _/-nonzero_ ; _⁻¹; ⁻¹-inverseʳ; ⁻¹-inverseˡ ; x⁻¹≉0; ⁻¹-cong )public euclideanDomain : EuclideanDomain a ℓ euclideanDomain = record { isEuclideanDomain = isEuclideanDomain } open EuclideanDomain euclideanDomain using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; +-group; +-abelianGroup; _-_ ; *-rawMonoid; *-monoid; *-commutativeMonoid ; nearSemiring; semiringWithoutOne ; semiringWithoutAnnihilatingZero; semiring ; commutativeSemiringWithoutOne; commutativeSemiring ; ring; commutativeRing; nonZeroCommutativeRing ; 0#≉1#; 1#≉0#; 0#≉-1#; -1#≉0# ; C/0; *-cancelˡ; *-cancelʳ; *≉0; _*-nonzero_; 1#-nonzero; -1#-nonzero ; setoid; isEquivalence ) public record DecField a ℓ : Set (suc (a ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 7 _/_ infixl 6 _+_ infix 4 _≈_ infix 4 _≈?_ field Carrier : Set a _≈_ : Rel Carrier ℓ _≈?_ : Decidable _≈_ infix 4 _≉_ _≉_ : Rel Carrier ℓ x ≉ y = x ≈ y → ⊥ field _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier _/_ : ∀ (n m : Carrier) {m≉0 : m ≉ 0#} → Carrier gcd : Op₂ Carrier isDecField : IsDecField Carrier _≈_ _≈?_ _+_ _*_ -_ 0# 1# _/_ gcd open IsDecField isDecField using (isField; isDecEquivalence) public [field] : Field a ℓ [field] = record { isField = isField } decSetoid : DecSetoid a ℓ decSetoid = record { isDecEquivalence = isDecEquivalence } open Field [field] using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; +-group; +-abelianGroup; _-_ ; *-rawMonoid; *-monoid; *-commutativeMonoid ; nearSemiring; semiringWithoutOne ; semiringWithoutAnnihilatingZero; semiring ; commutativeSemiringWithoutOne; commutativeSemiring ; ring; commutativeRing; nonZeroCommutativeRing ; 0#≉1#; 1#≉0#; 0#≉-1#; -1#≉0# ; C/0; *-cancelˡ; *-cancelʳ; *≉0; _*-nonzero_; _/-nonzero_; 1#-nonzero; -1#-nonzero ; m*[n/m]≈n; [n/m]*m≈n; /-cong ; _⁻¹; ⁻¹-inverseʳ; ⁻¹-inverseˡ ; x⁻¹≉0; ⁻¹-cong ; setoid; isEquivalence ) public record FiniteField a ℓ : Set (suc (a ⊔ ℓ)) where infix 8 -_ infixl 7 _*_ infixl 7 _/_ infixl 6 _+_ infix 4 _≈_ infix 4 _≈?_ field Carrier : Set a _≈_ : Rel Carrier ℓ _≈?_ : Decidable _≈_ infix 4 _≉_ _≉_ : Rel Carrier ℓ x ≉ y = x ≈ y → ⊥ field _+_ : Op₂ Carrier _*_ : Op₂ Carrier -_ : Op₁ Carrier 0# : Carrier 1# : Carrier _/_ : ∀ (n m : Carrier) {m≉0 : m ≉ 0#} → Carrier gcd : Op₂ Carrier cardinality : ℕ isFiniteField : IsFiniteField Carrier _≈_ _≈?_ _+_ _*_ -_ 0# 1# _/_ gcd cardinality open IsFiniteField isFiniteField using (isDecField) public decField : DecField a ℓ decField = record { isDecField = isDecField } open DecField decField using ( +-rawMagma; +-magma; +-semigroup ; *-rawMagma; *-magma; *-semigroup ; +-rawMonoid; +-monoid; +-commutativeMonoid ; +-group; +-abelianGroup; _-_ ; *-rawMonoid; *-monoid; *-commutativeMonoid ; nearSemiring; semiringWithoutOne ; semiringWithoutAnnihilatingZero; semiring ; commutativeSemiringWithoutOne; commutativeSemiring ; ring; commutativeRing; nonZeroCommutativeRing ; 0#≉1#; 1#≉0#; 0#≉-1#; -1#≉0# ; C/0; *-cancelˡ; *-cancelʳ; *≉0; _*-nonzero_; _/-nonzero_; 1#-nonzero; -1#-nonzero ; m*[n/m]≈n; [n/m]*m≈n; /-cong ; _⁻¹; ⁻¹-inverseʳ; ⁻¹-inverseˡ ; x⁻¹≉0; ⁻¹-cong ; setoid; isEquivalence; decSetoid; isDecEquivalence ) public
{ "alphanum_fraction": 0.6317088217, "avg_line_length": 29.5494791667, "ext": "agda", "hexsha": "a67ec01c84e6506846aac1189e186be3e9920fa8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/thesis", "max_forks_repo_path": "proofs/AKS/Algebra/Bundles.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/thesis", "max_issues_repo_path": "proofs/AKS/Algebra/Bundles.agda", "max_line_length": 149, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/thesis", "max_stars_repo_path": "proofs/AKS/Algebra/Bundles.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z", "num_tokens": 4503, "size": 11347 }
module Languages.ILL.Syntax where open import level open import bool open import nat open import unit open import empty open import eq open import sum open import product open import Utils.HaskellTypes open import Utils.HaskellFunctions open import Languages.ILL.TypeSyntax True : Set True = ⊤{lzero} False : Set False = ⊥{lzero} Name : Set Name = ℕ name-in : ∀{A : Set} → (A → A → 𝔹) → A → List A → Set name-in eq x ctx with list-member eq x ctx name-in _ x ctx | tt = True name-in _ x ctx | ff = False -- Bound Variable Labels: data VLabel : Set where LLPV : VLabel -- Let-Bound Left Pattern Variable RLPV : VLabel -- Let-Bound Right Pattern Variable LCPV : VLabel -- Copy-Bound Left Pattern Variable RCPV : VLabel -- Copy-Bound Right Pattern Variable BV : VLabel -- λ-Bound Variable PBV : VLabel -- Promote-Bound Variable that is ith in the sequence _vl-eq_ : VLabel → VLabel → 𝔹 LLPV vl-eq LLPV = tt RLPV vl-eq RLPV = tt LCPV vl-eq LCPV = tt RCPV vl-eq RCPV = tt BV vl-eq BV = tt PBV vl-eq PBV = tt _ vl-eq _ = ff data Pattern : Set where PTriv : Pattern PTensor : String → String → Pattern data Term : Set where Triv : Term FVar : String → Term BVar : Name → String → VLabel → Term Let : Term → Type → Pattern → Term → Term Lam : String → Type → Term → Term App : Term → Term → Term Tensor : Term → Term → Term Promote : List (Triple Term String Type) → Term → Term Discard : Term → Term → Term Copy : Term → (Prod String String) → Term → Term Derelict : Term → Term {-# TERMINATING #-} open-t : Name → String → VLabel → Term → Term → Term open-t x xs l u (BVar y ys l') with x =ℕ y | xs str-eq ys | l vl-eq l' ... | tt | tt | tt = u ... | _ | _ | _ = BVar y ys l' open-t x xs BV u (Let t₁ y z t₂) = Let (open-t x xs BV u t₁) y z (open-t x xs BV u t₂) open-t x xs l@LCPV u (Let t₁ y z t₂) = Let (open-t x xs l u t₁) y z (open-t x xs l u t₂) open-t x xs l@RCPV u (Let t₁ y z t₂) = Let (open-t x xs l u t₁) y z (open-t x xs l u t₂) open-t x xs l u (Let t₁ a p t₂) = Let (open-t x xs l u t₁) a p (open-t (suc x) xs l u t₂) open-t x xs BV u (Lam ys a t) = Lam ys a (open-t (suc x) xs BV u t) open-t x xs l u (Lam ys a t) = Lam ys a (open-t x xs l u t) open-t x xs l u (App t₁ t₂) = App (open-t x xs l u t₁) (open-t x xs l u t₂) open-t x xs l u (Tensor t₁ t₂) = Tensor (open-t x xs l u t₁) (open-t x xs l u t₂) open-t x xs l@PBV y (Promote ms n) = Promote oms (open-t (suc x) xs l y n) where oms = map (fstMapT (open-t x xs l y)) ms open-t x xs l y (Promote ms n) = Promote oms (open-t x xs l y n) where oms = map (fstMapT (open-t x xs l y)) ms open-t x xs l@LCPV y (Copy m p n) = Copy (open-t x xs l y m ) p (open-t (suc x) xs l y n) open-t x xs l@RCPV y (Copy m p n) = Copy (open-t x xs l y m ) p (open-t (suc x) xs l y n) open-t x xs l y (Copy m p n) = Copy (open-t x xs l y m ) p (open-t x xs l y n) open-t x xs l y (Discard m n) = Discard (open-t x xs l y m) (open-t x xs l y n) open-t x xs l y (Derelict m) = Derelict (open-t x xs l y m) open-t _ _ _ _ t = t {-# TERMINATING #-} close-t : Name → String → VLabel → String → Term → Term close-t x xs l y (FVar z) with y str-eq z ... | tt = BVar x xs l ... | ff = FVar z close-t x xs l@LLPV y (Let t₁ ty p t₂) = Let (close-t x xs l y t₁) ty p (close-t (suc x) xs l y t₂) close-t x xs l@RLPV y (Let t₁ ty p t₂) = Let (close-t x xs l y t₁) ty p (close-t (suc x) xs l y t₂) close-t x xs l y (Let t₁ ty p t₂) = Let (close-t x xs l y t₁) ty p (close-t x xs l y t₂) close-t x xs l@BV y (Lam ys a t) = Lam ys a (close-t (suc x) xs l y t) close-t x xs l y (Lam ys a t) = Lam ys a (close-t x xs l y t) close-t x xs l y (App t₁ t₂) = App (close-t x xs l y t₁) (close-t x xs l y t₂) close-t x xs l y (Tensor t₁ t₂) = Tensor (close-t x xs l y t₁) (close-t x xs l y t₂) close-t x xs l@PBV y (Promote ms n) = Promote cms (close-t (suc x) xs l y n) where cms = map (fstMapT (close-t x xs l y)) ms close-t x xs l y (Promote ms n) = Promote cms (close-t x xs l y n) where cms = map (fstMapT (close-t x xs l y)) ms close-t x xs l@LCPV y (Copy m p n) = Copy (close-t x xs l y m) p (close-t (suc x) xs l y n) close-t x xs l@RCPV y (Copy m p n) = Copy (close-t x xs l y m) p (close-t (suc x) xs l y n) close-t x xs l y (Copy m p n) = Copy (close-t x xs l y m) p (close-t x xs l y n) close-t x xs l y (Discard m n) = Discard (close-t x xs l y m) (close-t x xs l y n) close-t x xs l y (Derelict m) = Derelict (close-t x xs l y m) close-t _ _ _ _ t = t
{ "alphanum_fraction": 0.6100420261, "avg_line_length": 39.3130434783, "ext": "agda", "hexsha": "58169acfe7220b25ef99199004a73647bc10d75b", "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": "c83f5d8201362b26a749138f6dbff2dd509f85b1", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "heades/Agda-LLS", "max_forks_repo_path": "Source/ALL/Languages/ILL/Syntax.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1", "max_issues_repo_issues_event_max_datetime": "2017-04-05T17:30:16.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-27T14:52:46.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "heades/Agda-LLS", "max_issues_repo_path": "Source/ALL/Languages/ILL/Syntax.agda", "max_line_length": 99, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "heades/Agda-LLS", "max_stars_repo_path": "Source/ALL/Languages/ILL/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-02T23:41:23.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-09T20:53:53.000Z", "num_tokens": 1750, "size": 4521 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.PtdAdjoint module homotopy.SuspAdjointLoop {i} where private SuspFunctor : PtdFunctor i i SuspFunctor = record { obj = ⊙Susp; arr = ⊙Susp-fmap; id = ⊙Susp-fmap-idf; comp = ⊙Susp-fmap-∘} LoopFunctor : PtdFunctor i i LoopFunctor = record { obj = ⊙Ω; arr = ⊙Ω-fmap; id = λ _ → ⊙Ω-fmap-idf; comp = ⊙Ω-fmap-∘} module _ (X : Ptd i) where η : de⊙ X → Ω (⊙Susp X) η x = σloop X x module E = SuspRec (pt X) (pt X) (idf _) ε : de⊙ (⊙Susp (⊙Ω X)) → de⊙ X ε = E.f ⊙η : X ⊙→ ⊙Ω (⊙Susp X) ⊙η = (η , σloop-pt) ⊙ε : ⊙Susp (⊙Ω X) ⊙→ X ⊙ε = (ε , idp) η-natural : {X Y : Ptd i} (f : X ⊙→ Y) → ⊙η Y ⊙∘ f == ⊙Ω-fmap (⊙Susp-fmap f) ⊙∘ ⊙η X η-natural {X = X} (f , idp) = ⊙λ=' (λ x → ! $ ap-∙ (Susp-fmap f) (merid x) (! (merid (pt X))) ∙ SuspFmap.merid-β f x ∙2 (ap-! (Susp-fmap f) (merid (pt X)) ∙ ap ! (SuspFmap.merid-β f (pt X)))) (pt-lemma (Susp-fmap f) (merid (pt X)) (SuspFmap.merid-β f (pt X))) where pt-lemma : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {x y : A} (p : x == y) {q : f x == f y} (α : ap f p == q) → !-inv-r q == ap (ap f) (!-inv-r p) ∙ idp [ _== idp ↓ ! (ap-∙ f p (! p) ∙ α ∙2 (ap-! f p ∙ ap ! α)) ] pt-lemma f idp idp = idp ε-natural : {X Y : Ptd i} (f : X ⊙→ Y) → ⊙ε Y ⊙∘ ⊙Susp-fmap (⊙Ω-fmap f) == f ⊙∘ ⊙ε X ε-natural (f , idp) = ⊙λ=' (SuspElim.f idp idp (λ p → ↓-='-from-square $ vert-degen-square $ ap-∘ (ε _) (Susp-fmap (ap f)) (merid p) ∙ ap (ap (ε _)) (SuspFmap.merid-β (ap f) p) ∙ E.merid-β _ (ap f p) ∙ ap (ap f) (! (E.merid-β _ p)) ∙ ∘-ap f (ε _) (merid p))) idp εΣ-Ση : (X : Ptd i) → ⊙ε (⊙Susp X) ⊙∘ ⊙Susp-fmap (⊙η X) == ⊙idf _ εΣ-Ση X = ⊙λ=' (SuspElim.f idp (merid (pt X)) (λ x → ↓-='-from-square $ (ap-∘ (ε (⊙Susp X)) (Susp-fmap (η X)) (merid x) ∙ ap (ap (ε (⊙Susp X))) (SuspFmap.merid-β (η X) x) ∙ E.merid-β _ (merid x ∙ ! (merid (pt X)))) ∙v⊡ square-lemma (merid x) (merid (pt X)) ⊡v∙ ! (ap-idf (merid x)))) idp where square-lemma : ∀ {i} {A : Type i} {x y z : A} (p : x == y) (q : z == y) → Square idp (p ∙ ! q) p q square-lemma idp idp = ids Ωε-ηΩ : (X : Ptd i) → ⊙Ω-fmap (⊙ε X) ⊙∘ ⊙η (⊙Ω X) == ⊙idf _ Ωε-ηΩ X = ⊙λ=' (λ p → ap-∙ (ε X) (merid p) (! (merid idp)) ∙ (E.merid-β X p ∙2 (ap-! (ε X) (merid idp) ∙ ap ! (E.merid-β X idp))) ∙ ∙-unit-r _) (pt-lemma (ε X) (merid idp) (E.merid-β X idp)) where pt-lemma : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {x y : A} (p : x == y) {q : f x == f y} (α : ap f p == q) → ap (ap f) (!-inv-r p) ∙ idp == idp [ _== idp ↓ ap-∙ f p (! p) ∙ (α ∙2 (ap-! f p ∙ ap ! α)) ∙ !-inv-r q ] pt-lemma f idp idp = idp module Eta = E adj : CounitUnitAdjoint SuspFunctor LoopFunctor adj = record { η = ⊙η; ε = ⊙ε; η-natural = η-natural; ε-natural = ε-natural; εF-Fη = εΣ-Ση; Gε-ηG = Ωε-ηΩ} hadj = counit-unit-to-hom adj open CounitUnitAdjoint adj public open HomAdjoint hadj public
{ "alphanum_fraction": 0.4590979782, "avg_line_length": 27.9565217391, "ext": "agda", "hexsha": "dce20c39a2ab73f91a5444012e8b71b23de87047", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/SuspAdjointLoop.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/SuspAdjointLoop.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/SuspAdjointLoop.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1564, "size": 3215 }
------------------------------------------------------------------------ -- Code related to the paper Beating the Productivity Checker Using -- Embedded Languages -- -- Nils Anders Danielsson ------------------------------------------------------------------------ module Productivity where ------------------------------------------------------------------------ -- Making Programs Guarded -- A definition of the stream of Fibonacci numbers, as well -- as a definition of the Hamming numbers. import StreamProg ------------------------------------------------------------------------ -- Several Types at Once -- By indexing the program and WHNF types on a universe one can handle -- several types at the same time. import UniverseIndex -- Breadth-first labelling of trees, /almost/ implementing the classic -- tie-the-recursive-knot algorithm due to Jeremy Gibbons and Geraint -- Jones (see "Linear-time Breadth-first Tree Algorithms: An Exercise -- in the Arithmetic of Folds and Zips", or Chris Okasaki's -- explanation in "Breadth-First Numbering: Lessons from a Small -- Exercise in Algorithm Design"). Proper sharing is not maintained, -- though, so this implementation is far from being linear in the size -- of the tree. import Stream import Tree import BreadthFirst.Universe import BreadthFirst.Programs import BreadthFirst -- A simplified variant of the code above, without any correctness -- statement or proof. import BreadthFirstWithoutProof ------------------------------------------------------------------------ -- Making Proofs Guarded -- Proofs of the map-iterate property and iterate fusion. import MapIterate -- A formalisation of parts of Ralf Hinze's paper "Streams and Unique -- Fixed Points". import Stream import Stream.Programs import Stream.Equality import Stream.Pointwise import Hinze.Lemmas import Hinze.Section2-4 import Hinze.Section3 import Hinze.Simplified.Section2-4 import Hinze.Simplified.Section3 -- Code not mentioned in the paper: -- An investigation of various ways to define the semantics of an -- untyped λ-calculus and a virtual machine, and a discussion of -- compiler correctness. The module Lambda.Closure.Relational uses the -- language-based technique to establish guardedness. import Lambda import Lambda.Closure.Relational ------------------------------------------------------------------------ -- Destructors -- A somewhat more elaborate/complicated variant of the method which -- can handle functions like tail. import SingletonChunks -- Code not mentioned in the paper: -- Another variant which can handle tail. I believe that this one has -- limited applicability. import LargeCombinators ------------------------------------------------------------------------ -- Other Chunk Sizes -- A generalised variant of (parts of) SingletonChunks, plus some -- extra examples. import ArbitraryChunks -- Implementations of the Thue-Morse sequence, using non-uniform chunk -- sizes. import ThueMorse import ThueMorseLeq ------------------------------------------------------------------------ -- Nested Applications -- An example which shows that nested applications of the defined -- function can be handled. import Nested -- Code not mentioned in the paper: -- A solution to a problem posed by Venanzio Capretta: The equation -- -- φ s = s ⋎ φ (evens (φ s)) -- -- has at most one solution. (Notice the nested uses of φ, and the use -- of evens which removes every other element from its input.) import VenanziosProblem ------------------------------------------------------------------------ -- Related Work -- Formalisation of subtyping for recursive types, partly based on -- "Coinductive Axiomatization of Recursive Type Equality and -- Subtyping" by Michael Brandt and Fritz Henglein. import RecursiveTypes -- The following modules use the language-based technique to establish -- guardedness. The last of them was briefly discussed in the paper. import RecursiveTypes.Subtyping.Semantic.Coinductive import RecursiveTypes.Subtyping.Axiomatic.Coinductive import RecursiveTypes.Subtyping.Axiomatic.Inductive -- An implementation of "A Unifying Approach to Recursive and -- Co-recursive Definitions" by Pietro Di Gianantonio and Marino -- Miculan. Contains one postulate. import Contractive import Contractive.Function import Contractive.Stream import Contractive.Examples ------------------------------------------------------------------------ -- Appendix -- A sound, inductive approximation of stream equality. import InductiveStreamEquality
{ "alphanum_fraction": 0.6595463554, "avg_line_length": 29.2967741935, "ext": "agda", "hexsha": "69dbd0b6d4ae3924e385b1b4b8ed938ceb6126ea", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "Productivity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/codata", "max_issues_repo_path": "Productivity.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "Productivity.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 884, "size": 4541 }
-- Andreas, 2011-04-14 -- {-# OPTIONS -v tc.cover:20 -v tc.lhs.unify:20 #-} module Issue291a where open import Imports.Coinduction data _≡_ {A : Set}(a : A) : A -> Set where refl : a ≡ a data RUnit : Set where runit : ∞ RUnit -> RUnit j : (u : ∞ RUnit) -> ♭ u ≡ runit u -> Set j u () -- needs to fail (reports a Bad split!)
{ "alphanum_fraction": 0.5963855422, "avg_line_length": 20.75, "ext": "agda", "hexsha": "68e6fedebe77e67f7f7be95c7e833b35141a6e5f", "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": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/fail/Issue291a.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "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": "np/agda-git-experiment", "max_issues_repo_path": "test/fail/Issue291a.agda", "max_line_length": 52, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/Issue291a.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": 126, "size": 332 }
open import Agda.Primitive using (_⊔_ ; lsuc ; Level) import Categories.Category as Category import Categories.Category.Cartesian as Cartesian open import Categories.Object.Terminal using (Terminal) open import Categories.Object.Product using (Product) open import MultiSorted.AlgebraicTheory import MultiSorted.Product as Product import MultiSorted.Interpretation module MultiSorted.InterpretationCategory {o ℓ e} {𝓈 ℴ} (Σ : Signature {𝓈} {ℴ}) {𝒞 : Category.Category o ℓ e} (cartesian-𝒞 : Cartesian.Cartesian 𝒞) where open Signature Σ open Category.Category 𝒞 open Cartesian.Cartesian cartesian-𝒞 open MultiSorted.Interpretation Σ cartesian-𝒞 -- Equality of homomorphisms of interpretations _≈I_ : ∀ {I J : Interpretation} → I ⇒I J → I ⇒I J → Set (e ⊔ 𝓈) _≈I_ {I} {J} ϕ ψ = let open _⇒I_ in ∀ (A : sort) → hom-morphism ϕ {A} ≈ hom-morphism ψ -- The category of interpretations of Σ in 𝒞 ℐ𝓃𝓉 : Category.Category (o ⊔ ℓ ⊔ e ⊔ 𝓈 ⊔ ℴ) (o ⊔ ℓ ⊔ e ⊔ 𝓈 ⊔ ℴ) (e ⊔ 𝓈) ℐ𝓃𝓉 = record { Obj = Interpretation ; _⇒_ = _⇒I_ ; _≈_ = _≈I_ ; id = id-I ; _∘_ = _∘I_ ; assoc = λ _ → assoc ; sym-assoc = λ _ → sym-assoc ; identityˡ = λ _ → identityˡ ; identityʳ = λ _ → identityʳ ; identity² = λ _ → identity² ; equiv = record { refl = λ A → Equiv.refl ; sym = λ p A → Equiv.sym (p A) ; trans = λ p₁ p₂ A → Equiv.trans (p₁ A) (p₂ A) } ; ∘-resp-≈ = λ p₁ p₂ A → ∘-resp-≈ (p₁ A) (p₂ A) } -- Cartesian structure on the category on interpretations of Σ in 𝒞 module _ (I J : Interpretation) where open Interpretation open Product.Producted open HomReasoning A×B-ℐ𝓃𝓉 : Interpretation interp-sort A×B-ℐ𝓃𝓉 A = interp-sort I A × interp-sort J A -- Contexts -- -- Structure prod (interp-ctx A×B-ℐ𝓃𝓉) Γ = prod (interp-ctx I) Γ × prod (interp-ctx J) Γ π (interp-ctx A×B-ℐ𝓃𝓉) x = (π (interp-ctx I) x) ⁂ (π (interp-ctx J) x) tuple (interp-ctx A×B-ℐ𝓃𝓉) Γ fs = ⟨ (tuple (interp-ctx I) Γ λ x → π₁ ∘ fs x) , ((tuple (interp-ctx J) Γ λ x → π₂ ∘ fs x)) ⟩ project (interp-ctx A×B-ℐ𝓃𝓉) {Γ} {B} {x} {fs} = begin π (interp-ctx A×B-ℐ𝓃𝓉) x ∘ (tuple (interp-ctx A×B-ℐ𝓃𝓉) Γ fs) ≈⟨ ⁂∘⟨⟩ ⟩ ⟨ π (interp-ctx I) x ∘ tuple (interp-ctx I) Γ (λ x₁ → π₁ ∘ fs x₁) , π (interp-ctx J) x ∘ tuple (interp-ctx J) Γ (λ x₁ → π₂ ∘ fs x₁) ⟩ ≈⟨ ⟨⟩-congʳ (project (interp-ctx I)) ⟩ ⟨ π₁ ∘ fs x , π (interp-ctx J) x ∘ tuple (interp-ctx J) Γ (λ x₁ → π₂ ∘ fs x₁) ⟩ ≈⟨ ⟨⟩-congˡ (project (interp-ctx J)) ⟩ ⟨ π₁ ∘ fs x , π₂ ∘ fs x ⟩ ≈⟨ Product.unique product Equiv.refl Equiv.refl ⟩ fs x ∎ unique (interp-ctx A×B-ℐ𝓃𝓉) {Γ} {A} {g} {fs} ps = Product.unique product (⟺ (unique (interp-ctx I) λ i → begin π (interp-ctx I) i ∘ product.π₁ ∘ fs ≈⟨ sym-assoc ⟩ (π (interp-ctx I) i ∘ product.π₁) ∘ fs ≈⟨ (Π-nat₁ i ⟩∘⟨refl) ⟩ (product.π₁ ∘ (π (interp-ctx A×B-ℐ𝓃𝓉) i)) ∘ fs ≈⟨ assoc ⟩ product.π₁ ∘((π (interp-ctx A×B-ℐ𝓃𝓉) i) ∘ fs) ≈⟨ (refl⟩∘⟨ ps i) ⟩ product.π₁ ∘ g i ∎)) (⟺ (unique (interp-ctx J) λ i → begin (π (interp-ctx J) i ∘ π₂ ∘ fs) ≈⟨ sym-assoc ⟩ ((π (interp-ctx J) i ∘ π₂) ∘ fs) ≈⟨ (Π-nat₂ i ⟩∘⟨refl) ⟩ ((product.π₂ ∘ π (interp-ctx A×B-ℐ𝓃𝓉) i) ∘ fs) ≈⟨ assoc ⟩ (π₂ ∘ π (interp-ctx A×B-ℐ𝓃𝓉) i ∘ fs) ≈⟨ (refl⟩∘⟨ ps i) ⟩ (π₂ ∘ g i) ∎)) where Π-nat₁ : {Γ : Context} → (i : var Γ) → π (interp-ctx I) i ∘ product.π₁ ≈ product.π₁ ∘ π (interp-ctx A×B-ℐ𝓃𝓉) i Π-nat₁ = λ i → ⟺ project₁ Π-nat₂ : {Γ : Context} → (i : var Γ) → π (interp-ctx J) i ∘ product.π₂ ≈ product.π₂ ∘ π (interp-ctx A×B-ℐ𝓃𝓉) i Π-nat₂ = λ i → ⟺ project₂ -- Operations interp-oper A×B-ℐ𝓃𝓉 = λ f → (interp-oper I f) ⁂ (interp-oper J f) -- Useful propoerties for the definition of projections module _ (I J : Interpretation) f where open Product.Producted open Interpretation open HomReasoning Π-nat₁ : {Γ : Context} → (i : var Γ) → π (interp-ctx I) i ∘ product.π₁ ≈ product.π₁ ∘ π (interp-ctx (A×B-ℐ𝓃𝓉 I J)) i Π-nat₁ = λ i → ⟺ project₁ Π-nat₂ : {Γ : Context} → (i : var Γ) → π (interp-ctx J) i ∘ product.π₂ ≈ product.π₂ ∘ π (interp-ctx (A×B-ℐ𝓃𝓉 I J)) i Π-nat₂ = λ i → ⟺ project₂ π₁-tuple : π₁ ≈ tuple (interp-ctx I) (oper-arity f) (λ i → π₁ ∘ (π (interp-ctx I) i ⁂ π (interp-ctx J) i)) π₁-tuple = ⟺ (begin tuple (interp-ctx I) (oper-arity f) (λ i → π₁ ∘ (π (interp-ctx I) i ⁂ π (interp-ctx J) i)) ≈⟨ tuple-cong (interp-ctx I) (λ i → π₁∘⁂) ⟩ tuple (interp-ctx I) (oper-arity f) (λ x → π (interp-ctx I) x ∘ π₁) ≈⟨ ∘-distribʳ-tuple (interp-ctx I) ⟩ (tuple (interp-ctx I) (oper-arity f) (λ x → π (interp-ctx I) x) ∘ π₁) ≈⟨ ∘-resp-≈ˡ (Product.Producted.η (interp-ctx I)) ⟩ (id ∘ π₁) ≈⟨ identityˡ ⟩ π₁ ∎) π₂-tuple : π₂ ≈ tuple (interp-ctx J) (oper-arity f) (λ i → π₂ ∘ (π (interp-ctx I) i ⁂ π (interp-ctx J) i)) π₂-tuple = ⟺ (begin tuple (interp-ctx J) (oper-arity f) (λ i → π₂ ∘ (π (interp-ctx I) i ⁂ π (interp-ctx J) i)) ≈⟨ tuple-cong (interp-ctx J) (λ i → π₂∘⁂) ⟩ tuple (interp-ctx J) (oper-arity f) (λ x → π (interp-ctx J) x ∘ π₂) ≈⟨ ∘-distribʳ-tuple (interp-ctx J) ⟩ (tuple (interp-ctx J) (oper-arity f) (λ x → π (interp-ctx J) x) ∘ π₂) ≈⟨ ∘-resp-≈ˡ (Product.Producted.η (interp-ctx J)) ⟩ (id ∘ π₂) ≈⟨ identityˡ ⟩ π₂ ∎) -- Definition of projections π₁-ℐ𝓃𝓉 : ∀ {I J : Interpretation} → A×B-ℐ𝓃𝓉 I J ⇒I I π₁-ℐ𝓃𝓉 {I} {J} = let open HomReasoning in let open Product.Producted in let open Interpretation in record { hom-morphism = Cartesian.Cartesian.π₁ cartesian-𝒞 ; hom-commute = λ f → begin (π₁ ∘ interp-oper (A×B-ℐ𝓃𝓉 I J) f) ≈⟨ π₁∘⁂ ⟩ (interp-oper I f ∘ π₁) ≈⟨ ∘-resp-≈ʳ (π₁-tuple I J f) ⟩ (interp-oper I f ∘ tuple (interp-ctx I) (oper-arity f) (λ i → π₁ ∘ (π (interp-ctx I) i ⁂ π (interp-ctx J) i))) ∎ } π₂-ℐ𝓃𝓉 : ∀ {I J : Interpretation} → A×B-ℐ𝓃𝓉 I J ⇒I J π₂-ℐ𝓃𝓉 {I} {J} = let open HomReasoning in let open Product.Producted in let open Interpretation in record { hom-morphism = Cartesian.Cartesian.π₂ cartesian-𝒞 ; hom-commute = λ f → begin (π₂ ∘ interp-oper (A×B-ℐ𝓃𝓉 I J) f) ≈⟨ π₂∘⁂ ⟩ (interp-oper J f ∘ π₂) ≈⟨ ∘-resp-≈ʳ (π₂-tuple I J f) ⟩ (interp-oper J f ∘ tuple (interp-ctx J) (oper-arity f) (λ i → π₂ ∘ (π (interp-ctx I) i ⁂ π (interp-ctx J) i))) ∎ } -- Useful properties for the definition of ⟨_,_⟩-ℐ𝓃𝓉 module _ (I J K : Interpretation) f (ϕ : I ⇒I J) (ψ : I ⇒I K) where open Interpretation open HomReasoning open Product.Producted ⟨⟩-left : interp-oper J f ∘ tuple (interp-ctx J) (oper-arity f) (λ x → π₁ ∘ ⟨ _⇒I_.hom-morphism ϕ , _⇒I_.hom-morphism ψ ⟩ ∘ π (interp-ctx I) x) ≈ _⇒I_.hom-morphism ϕ ∘ interp-oper I f ⟨⟩-left = begin (interp-oper J f ∘ tuple (interp-ctx J) (oper-arity f) (λ x → π₁ ∘ ⟨ _⇒I_.hom-morphism ϕ , _⇒I_.hom-morphism ψ ⟩ ∘ π (interp-ctx I) x)) ≈⟨ ∘-resp-≈ʳ (tuple-cong (interp-ctx J) λ i → sym-assoc) ⟩ (interp-oper J f ∘ tuple (interp-ctx J) (oper-arity f) (λ x → (π₁ ∘ ⟨ _⇒I_.hom-morphism ϕ , _⇒I_.hom-morphism ψ ⟩) ∘ π (interp-ctx I) x)) ≈⟨ ∘-resp-≈ʳ (tuple-cong (interp-ctx J) λ i → ∘-resp-≈ˡ project₁) ⟩ (interp-oper J f ∘ tuple (interp-ctx J) (oper-arity f) (λ x → _⇒I_.hom-morphism ϕ ∘ π (interp-ctx I) x)) ≈⟨ ⟺ (_⇒I_.hom-commute ϕ f) ⟩ (_⇒I_.hom-morphism ϕ ∘ interp-oper I f) ∎ ⟨⟩-right : interp-oper K f ∘ tuple (interp-ctx K) (oper-arity f) (λ x → π₂ ∘ ⟨ _⇒I_.hom-morphism ϕ , _⇒I_.hom-morphism ψ ⟩ ∘ π (interp-ctx I) x) ≈ _⇒I_.hom-morphism ψ ∘ interp-oper I f ⟨⟩-right = begin (interp-oper K f ∘ tuple (interp-ctx K) (oper-arity f) (λ x → π₂ ∘ ⟨ _⇒I_.hom-morphism ϕ , _⇒I_.hom-morphism ψ ⟩ ∘ π (interp-ctx I) x)) ≈⟨ ∘-resp-≈ʳ (tuple-cong (interp-ctx K) λ i → sym-assoc) ⟩ (interp-oper K f ∘ tuple (interp-ctx K) (oper-arity f) (λ x → (π₂ ∘ ⟨ _⇒I_.hom-morphism ϕ , _⇒I_.hom-morphism ψ ⟩) ∘ π (interp-ctx I) x)) ≈⟨ ∘-resp-≈ʳ (tuple-cong (interp-ctx K) λ i → ∘-resp-≈ˡ project₂) ⟩ (interp-oper K f ∘ tuple (interp-ctx K) (oper-arity f) (λ x → _⇒I_.hom-morphism ψ ∘ π (interp-ctx I) x)) ≈⟨ ⟺ (_⇒I_.hom-commute ψ f) ⟩ (_⇒I_.hom-morphism ψ ∘ interp-oper I f) ∎ -- Definition of pairing ⟨_,_⟩-ℐ𝓃𝓉 : ∀ {I J K : Interpretation} → I ⇒I J → I ⇒I K → I ⇒I A×B-ℐ𝓃𝓉 J K ⟨_,_⟩-ℐ𝓃𝓉 {I} {J} {K} ϕ ψ = let open HomReasoning in let open Product.Producted in let open Interpretation in record { hom-morphism = λ {A} → ⟨ _⇒I_.hom-morphism ϕ , _⇒I_.hom-morphism ψ ⟩ ; hom-commute = λ f → ⟺ (begin (interp-oper (A×B-ℐ𝓃𝓉 J K) f ∘ tuple (interp-ctx (A×B-ℐ𝓃𝓉 J K)) (oper-arity f) (λ i → ⟨ _⇒I_.hom-morphism ϕ , _⇒I_.hom-morphism ψ ⟩ ∘ π (interp-ctx I) i)) ≈⟨ ⁂∘⟨⟩ ⟩ ⟨ interp-oper J f ∘ tuple (interp-ctx J) (oper-arity f) (λ x → π₁ ∘ ⟨ _⇒I_.hom-morphism ϕ , _⇒I_.hom-morphism ψ ⟩ ∘ π (interp-ctx I) x) , interp-oper K f ∘ tuple (interp-ctx K) (oper-arity f) (λ x → π₂ ∘ ⟨ _⇒I_.hom-morphism ϕ , _⇒I_.hom-morphism ψ ⟩ ∘ π (interp-ctx I) x) ⟩ ≈⟨ ⟨⟩-cong₂ (⟨⟩-left I J K f ϕ ψ) (⟨⟩-right I J K f ϕ ψ) ⟩ product.⟨ _⇒I_.hom-morphism ϕ ∘ interp-oper I f , _⇒I_.hom-morphism ψ ∘ interp-oper I f ⟩ ≈˘⟨ ⟨⟩∘ ⟩ (⟨ _⇒I_.hom-morphism ϕ , _⇒I_.hom-morphism ψ ⟩ ∘ interp-oper I f) ∎) } -- Properties about projections and unicity project₁-ℐ𝓃𝓉 : {I J K : Interpretation} {h : I ⇒I J} {i : I ⇒I K} (A : sort) → π₁ ∘ ⟨ _⇒I_.hom-morphism {I} {J} h {A} , _⇒I_.hom-morphism {I} {K} i ⟩ ≈ _⇒I_.hom-morphism h project₁-ℐ𝓃𝓉 A = project₁ project₂-ℐ𝓃𝓉 : {I J K : Interpretation} {h : I ⇒I J} {i : I ⇒I K} (A : sort) → π₂ ∘ ⟨ _⇒I_.hom-morphism {I} {J} h {A} , _⇒I_.hom-morphism {I} {K} i ⟩ ≈ _⇒I_.hom-morphism i project₂-ℐ𝓃𝓉 A = project₂ unique-ℐ𝓃𝓉 : {I J K : Interpretation} {h : I ⇒I A×B-ℐ𝓃𝓉 J K} {i : I ⇒I J} {j : I ⇒I K} → ((A : sort) → π₁ ∘ _⇒I_.hom-morphism h {A} ≈ _⇒I_.hom-morphism i) → ((A : sort) → π₂ ∘ _⇒I_.hom-morphism h {A} ≈ _⇒I_.hom-morphism j) → (A : sort) → ⟨ _⇒I_.hom-morphism i {A} , _⇒I_.hom-morphism j ⟩ ≈ _⇒I_.hom-morphism h unique-ℐ𝓃𝓉 = λ p₁ p₂ A → unique (p₁ A) (p₂ A) -- Definition of the structure of the product product-ℐ𝓃𝓉 : ∀ {I J} → Product ℐ𝓃𝓉 I J product-ℐ𝓃𝓉 {I} {J} = record { A×B = A×B-ℐ𝓃𝓉 I J ; π₁ = π₁-ℐ𝓃𝓉 {I} {J} ; π₂ = π₂-ℐ𝓃𝓉 {I} {J} ; ⟨_,_⟩ = ⟨_,_⟩-ℐ𝓃𝓉 ; project₁ = λ {K} {h} {i} A → project₁-ℐ𝓃𝓉 {K} {I} {J} {h} {i} A ; project₂ = λ {K} {h} {i} A → project₂-ℐ𝓃𝓉 {K} {I} {J} {h} {i} A ; unique = λ {K} {h} {i} {j} p₁ p₂ A → unique-ℐ𝓃𝓉 {K} {I} {J} {h} {i} {j} p₁ p₂ A } -- The terminal object terminal-ℐ𝓃𝓉 : Terminal ℐ𝓃𝓉 terminal-ℐ𝓃𝓉 = record { ⊤ = Trivial ; ⊤-is-terminal = record { ! = record { hom-morphism = ! ; hom-commute = λ f → !-unique₂ } ; !-unique = λ f A → !-unique₂ } } -- The category of interpretations is cartesian cartesian-ℐ𝓃𝓉 : Cartesian.Cartesian ℐ𝓃𝓉 cartesian-ℐ𝓃𝓉 = record { terminal = terminal-ℐ𝓃𝓉 ; products = record { product = product-ℐ𝓃𝓉 } } -- Each projection is a natural transformation with respect to the interpretation open Interpretation open HomReasoning open Product.Producted natural-π₁ : {I J : Interpretation} {A : sort} {Γ : Context} (t : Term Γ A) → π₁ ∘ (interp-term (A×B-ℐ𝓃𝓉 I J) t) ≈ (interp-term I t) ∘ π₁ natural-π₁ {I} {J} (Signature.tm-var x) = project₁ natural-π₁ {I} {J} (Signature.tm-oper f xs) = begin (π₁ ∘ interp-term (A×B-ℐ𝓃𝓉 I J) (tm-oper f xs)) ≈⟨ ∘-resp-≈ʳ ⁂∘⟨⟩ ⟩ (π₁ ∘ ⟨ interp-oper I f ∘ Product.Producted.tuple (interp-ctx I) (oper-arity f) (λ i → π₁ ∘ interp-term (A×B-ℐ𝓃𝓉 I J) (xs i)) , interp-oper J f ∘ Product.Producted.tuple (interp-ctx J) (oper-arity f) (λ i → π₂ ∘ interp-term (A×B-ℐ𝓃𝓉 I J) (xs i)) ⟩) ≈⟨ project₁ ⟩ (interp-oper I f ∘ Product.Producted.tuple (interp-ctx I) (oper-arity f) (λ i → π₁ ∘ interp-term (A×B-ℐ𝓃𝓉 I J) (xs i))) ≈⟨ ∘-resp-≈ʳ (tuple-cong (interp-ctx I) λ i → natural-π₁ {I} {J} {arg-sort f i} (xs i)) ⟩ (interp-oper I f ∘ tuple (interp-ctx I) (oper-arity f) (λ i → interp-term I (xs i) ∘ π₁)) ≈⟨ ∘-resp-≈ʳ (∘-distribʳ-tuple (interp-ctx I)) ⟩ (interp-oper I f ∘ tuple (interp-ctx I) (oper-arity f) (λ x → interp-term I (xs x)) ∘ π₁) ≈⟨ sym-assoc ⟩ ((interp-oper I f ∘ tuple (interp-ctx I) (oper-arity f) (λ x → interp-term I (xs x))) ∘ π₁) ∎ natural-π₂ : {I J : Interpretation} {A : sort} {Γ : Context} (t : Term Γ A) → π₂ ∘ (interp-term (A×B-ℐ𝓃𝓉 I J) t) ≈ (interp-term J t) ∘ π₂ natural-π₂ {I} {J} (Signature.tm-var x) = project₂ natural-π₂ {I} {J} (Signature.tm-oper f xs) = begin (π₂ ∘ interp-term (A×B-ℐ𝓃𝓉 I J) (tm-oper f xs)) ≈⟨ ∘-resp-≈ʳ ⁂∘⟨⟩ ⟩ (π₂ ∘ ⟨ interp-oper I f ∘ Product.Producted.tuple (interp-ctx I) (oper-arity f) (λ i → π₁ ∘ interp-term (A×B-ℐ𝓃𝓉 I J) (xs i)) , interp-oper J f ∘ Product.Producted.tuple (interp-ctx J) (oper-arity f) (λ i → π₂ ∘ interp-term (A×B-ℐ𝓃𝓉 I J) (xs i)) ⟩) ≈⟨ project₂ ⟩ (interp-oper J f ∘ Product.Producted.tuple (interp-ctx J) (oper-arity f) (λ i → π₂ ∘ interp-term (A×B-ℐ𝓃𝓉 I J) (xs i))) ≈⟨ ∘-resp-≈ʳ (tuple-cong (interp-ctx J) λ i → natural-π₂ {I} {J} {arg-sort f i} (xs i)) ⟩ (interp-oper J f ∘ tuple (interp-ctx J) (oper-arity f) (λ i → interp-term J (xs i) ∘ π₂)) ≈⟨ ∘-resp-≈ʳ (∘-distribʳ-tuple (interp-ctx J)) ⟩ (interp-oper J f ∘ tuple (interp-ctx J) (oper-arity f) (λ x → interp-term J (xs x)) ∘ π₂) ≈⟨ sym-assoc ⟩ ((interp-oper J f ∘ tuple (interp-ctx J) (oper-arity f) (λ x → interp-term J (xs x))) ∘ π₂) ∎
{ "alphanum_fraction": 0.4020467836, "avg_line_length": 55.3526011561, "ext": "agda", "hexsha": "e1f22eed646eee6de438f5b449a8d5ee469882f4", "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/InterpretationCategory.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/InterpretationCategory.agda", "max_line_length": 187, "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/InterpretationCategory.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": 6575, "size": 19152 }
{-# OPTIONS --cubical --safe #-} module Interpreter where open import Function.Base using (_$_) open import FreeReader -- Runs it in the reader monad runFree : ∀ {R A} → R → FreeReader R A → A runFree r (Pure x) = x runFree r (Bind x f) = runFree r $ f $ runFree r x runFree r Ask = r -- Since it's so simple, all these compute nicely runFree r (LeftId a f i) = runFree r $ f a runFree r (RightId x i) = runFree r x runFree r (Assoc x f g i) = runFree r $ g $ runFree r $ f $ runFree r x
{ "alphanum_fraction": 0.6639511202, "avg_line_length": 28.8823529412, "ext": "agda", "hexsha": "711baaeee53e01466c045d3e8d5f8549c1347f81", "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": "13364fa4af25720bf1d73bf960e8c04ebb34762f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mb64/cubical-free-monads", "max_forks_repo_path": "Interpreter.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "13364fa4af25720bf1d73bf960e8c04ebb34762f", "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": "mb64/cubical-free-monads", "max_issues_repo_path": "Interpreter.agda", "max_line_length": 71, "max_stars_count": 1, "max_stars_repo_head_hexsha": "13364fa4af25720bf1d73bf960e8c04ebb34762f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mb64/cubical-free-monads", "max_stars_repo_path": "Interpreter.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-17T17:53:44.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-17T17:53:44.000Z", "num_tokens": 163, "size": 491 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Object.Initial {o ℓ e} (C : Category o ℓ e) where open import Level open import Relation.Binary.PropositionalEquality as ≡ using (_≡_) open Category C open import Categories.Morphism C using (Epi; _≅_) open import Categories.Morphism.IsoEquiv C using (_≃_; ⌞_⌟) open import Categories.Morphism.Reasoning C open HomReasoning record Initial : Set (o ⊔ ℓ ⊔ e) where field ⊥ : Obj ! : {A : Obj} → (⊥ ⇒ A) !-unique : ∀ {A} → (f : ⊥ ⇒ A) → ! ≈ f !-unique₂ : ∀ {A} → (f g : ⊥ ⇒ A) → f ≈ g !-unique₂ f g = begin f ≈˘⟨ !-unique f ⟩ ! ≈⟨ !-unique g ⟩ g ∎ where open HomReasoning ⊥-id : (f : ⊥ ⇒ ⊥) → f ≈ id ⊥-id f = !-unique₂ f id open Initial to-⊥-is-Epi : ∀ {A : Obj} {i : Initial} → (f : A ⇒ ⊥ i) → Epi f to-⊥-is-Epi {_} {i} _ = λ g h _ → !-unique₂ i g h up-to-iso : (i₁ i₂ : Initial) → ⊥ i₁ ≅ ⊥ i₂ up-to-iso i₁ i₂ = record { from = ! i₁ ; to = ! i₂ ; iso = record { isoˡ = ⊥-id i₁ _; isoʳ = ⊥-id i₂ _ } } transport-by-iso : (i : Initial) → ∀ {X} → ⊥ i ≅ X → Initial transport-by-iso i {X} i≅X = record { ⊥ = X ; ! = ! i ∘ to ; !-unique = λ h → begin ! i ∘ to ≈⟨ !-unique i (h ∘ from) ⟩∘⟨refl ⟩ (h ∘ from) ∘ to ≈⟨ cancelʳ isoʳ ⟩ h ∎ } where open _≅_ i≅X up-to-iso-unique : ∀ i i′ → (iso : ⊥ i ≅ ⊥ i′) → up-to-iso i i′ ≃ iso up-to-iso-unique i i′ iso = ⌞ !-unique i _ ⌟ up-to-iso-invˡ : ∀ {t X} {i : ⊥ t ≅ X} → up-to-iso t (transport-by-iso t i) ≃ i up-to-iso-invˡ {t} {i = i} = up-to-iso-unique t (transport-by-iso t i) i up-to-iso-invʳ : ∀ {t t′} → ⊥ (transport-by-iso t (up-to-iso t t′)) ≡ ⊥ t′ up-to-iso-invʳ {t} {t′} = ≡.refl
{ "alphanum_fraction": 0.5240023135, "avg_line_length": 27.4444444444, "ext": "agda", "hexsha": "54cc274fdd2288d0e561c172e421f63bbf995cd9", "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/Object/Initial.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/Object/Initial.agda", "max_line_length": 79, "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/Object/Initial.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 783, "size": 1729 }
module BTA-ken where -- specialize two-level typed terms to untyped lambda calculus open import Data.Nat hiding (_<_) open import Data.Bool open import Data.Fin hiding (_≤_ ; pred; _+_) open import Data.List open import Data.Product open import Function open import Algebra.FunctionProperties using (Commutative; Identity; RightIdentity) open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_; refl; sym; cong; cong₂) open PropEq.≡-Reasoning open import Data.Nat.Properties -- Binding times data BT : Set where S : BT D : BT -- defining a data type [BT],where two members are -- [S] standing for "static" and [D] standing for dynamic. -- ``subsumption'' binding times; static can be treated as dynamic, -- but not vice versa _≼_ : BT → BT → Bool _≼_ D S = false _≼_ _ _ = true record True : Set where data False : Set where isTrue : Bool → Set isTrue true = True isTrue false = False -- More general purpose definitions (should also be in standard library) -- list membership infix 4 _∈_ data _∈_ {A : Set} : A → List A → Set where hd : ∀ {x xs} → x ∈ (x ∷ xs) tl : ∀ {x y xs} → x ∈ xs → x ∈ (y ∷ xs) -- Types of the calculus mutual -- s ^ BT data AType : Set where Ann : BT → SType → AType -- int | t -> t data SType : Set where SInt : SType SFun : AType → AType → SType -- aux definitions ATInt : BT → AType ATInt bt = Ann bt SInt ATFun : BT → AType → AType → AType ATFun bt at1 at2 = Ann bt (SFun at1 at2) -- projection: get the BT from a type btof : AType → BT btof (Ann bt _) = bt -- well-formedness data wft : AType → Set where wf-int : ∀ {bt} → wft (Ann bt SInt) wf-fun : ∀ {bt at1 at2} → wft at1 → wft at2 → isTrue (bt ≼ btof at1) → isTrue (bt ≼ btof at2) → wft (Ann bt (SFun at1 at2)) -- test for dynamic by wellformedness data IsDynamic : AType → Set where is-dyn : ∀ σ → IsDynamic (Ann D σ) lem-IsDynamic-by-wf : ∀ α → isTrue (D ≼ btof α) → IsDynamic α lem-IsDynamic-by-wf (Ann S σ) () lem-IsDynamic-by-wf (Ann D σ) _ = is-dyn σ -- typed annotated expressions ACtx = List AType data AExp (Δ : ACtx) : AType → Set where AVar : ∀ {α} → α ∈ Δ → AExp Δ α AInt : (bt : BT) → ℕ → AExp Δ (ATInt bt) ALam : ∀ {α₁ α₂} (bt : BT) → wft (ATFun bt α₂ α₁) → AExp (α₂ ∷ Δ) α₁ → AExp Δ (ATFun bt α₂ α₁) AApp : ∀ {α₁ α₂} (bt : BT) → wft (ATFun bt α₂ α₁) → AExp Δ (ATFun bt α₂ α₁) → AExp Δ α₂ → AExp Δ α₁ -- Untyped expression, but correctly scoped data Exp' : ℕ → Set where EVar : ∀ {n} → Fin n → Exp' n EInt : ∀ {n} → ℕ → Exp' n ELam : ∀ {n} → Exp' (suc n) → Exp' n EApp : ∀ {n} → Exp' n → Exp' n → Exp' n --- m+1+n≡1+m+n : ∀ m n → m + suc n ≡ suc (m + n) m+1+n≡1+m+n zero n = refl m+1+n≡1+m+n (suc m) n = cong suc (m+1+n≡1+m+n m n) n+0≡n : ∀ n → n + 0 ≡ n n+0≡n zero = refl n+0≡n (suc n) = cong suc $ n+0≡n n +-comm : ∀ m n → m + n ≡ n + m +-comm zero n = sym (n+0≡n n) +-comm (suc m) n = begin suc m + n ≡⟨ refl ⟩ suc (m + n) ≡⟨ cong suc (+-comm m n) ⟩ suc (n + m) ≡⟨ sym (m+1+n≡1+m+n n m) ⟩ n + suc m ∎ ≤-refl : ∀ {n} → n ≤ n ≤-refl {zero} = z≤n ≤-refl {suc n} = s≤s ≤-refl ≤-trans : ∀ {a b c} → a ≤ b → b ≤ c → a ≤ c ≤-trans z≤n q = z≤n ≤-trans (s≤s p) (s≤s q) = s≤s (≤-trans p q) ≤-suc-right : ∀ {m n} → m ≤ n → m ≤ suc n ≤-suc-right z≤n = z≤n ≤-suc-right (s≤s p) = s≤s (≤-suc-right p) ≤-suc-left : ∀ {m n} → suc m ≤ n → m ≤ n ≤-suc-left (s≤s p) = ≤-suc-right p xlate : ∀ {m} {n} → Exp' (m + suc n) → Exp' (suc (n + m)) xlate {m} {n} e rewrite m+1+n≡1+m+n m n | +-comm m n = e shifter1 : ∀ {n} m → Exp' (suc n) → Exp' (suc (n + m)) shifter1 {n} m (EVar x) = xlate {m} (EVar (raise m x)) shifter1 m (EInt x) = EInt x shifter1 m (ELam e) = ELam (shifter1 m e) shifter1 m (EApp e e₁) = EApp (shifter1 m e) (shifter1 m e₁) shifter0 : ∀ m → Exp' zero → Exp' m shifter0 m (EVar ()) shifter0 m (EInt x) = EInt x shifter0 m (ELam e) = ELam (shifter1 m e) shifter0 m (EApp e e₁) = EApp (shifter0 m e) (shifter0 m e₁) shifter : ∀ m d → Exp' m → Exp' (m + d) shifter zero d e = shifter0 d e shifter (suc m) d e = shifter1 d e -- m+n∸m≡n : ∀ {m n} → m ≤ n → m + (n ∸ m) ≡ n -- m+n∸m≡n p helper : ∀ {m n} → n ≤ m → Exp' (n + (m ∸ n)) → Exp' m helper p e rewrite m+n∸m≡n p = e -- index m = nesting level of dynamic definitions Imp : (m : ℕ) → AType → Set Imp m (Ann S SInt) = ℕ Imp m (Ann S (SFun α₁ α₂)) = ∀ n → m ≤ n → (Imp n α₁ → Imp n α₂) Imp m (Ann D σ) = Exp' m -- index = nesting level of dynamic definitions data AEnv1 : ℕ → ACtx → Set where [] : AEnv1 0 [] consS : ∀ {m Δ o} → m ≤ o → (α : AType) → Imp o α → AEnv1 m Δ → AEnv1 o (α ∷ Δ) consD : ∀ {m Δ} → (α : AType) → isTrue (D ≼ btof α) → Imp (suc m) α → AEnv1 m Δ → AEnv1 (suc m) (α ∷ Δ) lift1 : ∀ {m n} α → m ≤ n → Imp m α → Imp n α lift1 (Ann S SInt) p v = v lift1 (Ann S (SFun x x₁)) p v = λ k n≤k → v k (≤-trans p n≤k) lift1 {m} {n} (Ann D σ) p v = helper p (shifter m (n ∸ m) v) lookup1 : ∀ {α Δ m n} → m  ≤ n → AEnv1 m Δ → α ∈ Δ → Imp n α lookup1 {α} p (consS _ .α x env) hd = lift1 α p x lookup1 {α} p (consD .α x x₁ env) hd = lift1 α p x₁ lookup1 p (consS p' .y x env) (tl {_} {y} x₁) = lookup1 (≤-trans p' p) env x₁ lookup1 p (consD .y x x₁ env) (tl {_} {y} x₂) = lookup1 (≤-suc-left p) env x₂ pe1 : ∀ {α Δ} m → AExp Δ α → AEnv1 m Δ → Imp m α pe1 m (AVar x) env = lookup1 ≤-refl env x pe1 m (AInt S x) env = x pe1 m (AInt D x) env = EInt x pe1 m (ALam S x e) env = λ o p → λ v → pe1 o e (consS p _ v env) pe1 m (ALam {α₂} {α₁} D (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) e) env with lem-IsDynamic-by-wf α₁ d≤bt₁ | lem-IsDynamic-by-wf α₂ d≤bt₂ pe1 m (ALam {.(Ann D σ₂)} {.(Ann D σ₁)} D (wf-fun _ _ d≤bt₁ d≤bt₂) e) env | is-dyn σ₁ | is-dyn σ₂ = ELam (pe1 (suc m) e (consD (Ann D σ₁) d≤bt₁ (EVar zero) env)) pe1 m (AApp S x e e₁) env = (pe1 m e env) m ≤-refl (pe1 m e₁ env) pe1 m (AApp {α₂} {α₁} D (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) e e₁) env with lem-IsDynamic-by-wf α₁ d≤bt₁ | lem-IsDynamic-by-wf α₂ d≤bt₂ pe1 m (AApp {.(Ann D σ₂)} {.(Ann D σ₁)} D (wf-fun w₁ w₂ d≤bt₁ d≤bt₂) e e₁) env | is-dyn σ₁ | is-dyn σ₂ = EApp (pe1 m e env) (pe1 m e₁ env)
{ "alphanum_fraction": 0.5720408836, "avg_line_length": 30.4824120603, "ext": "agda", "hexsha": "4755a2cb3f94d9b664e0a8512edebce12187e29c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-10-15T09:01:37.000Z", "max_forks_repo_forks_event_min_datetime": "2019-10-15T09:01:37.000Z", "max_forks_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "luminousfennell/polybta", "max_forks_repo_path": "BTA-ken.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb", "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": "luminousfennell/polybta", "max_issues_repo_path": "BTA-ken.agda", "max_line_length": 105, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ef878f7fa5afa51fb7a14cd8f7f75da0af1b9deb", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "luminousfennell/polybta", "max_stars_repo_path": "BTA-ken.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-15T04:35:29.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-15T04:35:29.000Z", "num_tokens": 2736, "size": 6066 }
{-# OPTIONS --universe-polymorphism #-} module Graphs.GraphMorphism where open import Data.Product open import Level open import Relation.Binary renaming (_⇒_ to _⊆_) open import Relation.Binary.PropositionalEquality using () renaming (_≡_ to _≣_ ; refl to ≣-refl ; sym to ≣-sym ; trans to ≣-trans ; cong to ≣-cong ) open import Graphs.Graph record GraphMorphism {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} (A : Graph o₁ ℓ₁ e₁) (B : Graph o₂ ℓ₂ e₂) : Set (o₁ ⊔ o₂ ⊔ ℓ₁ ⊔ ℓ₂ ⊔ e₁ ⊔ e₂) where module A = Graph A module B = Graph B field F₀ : A.Obj → B.Obj F₁ : ∀ {X Y} → A [ X ↝ Y ] → B [ F₀ X ↝ F₀ Y ] .F-resp-≈ : ∀ {X Y}{f g : A [ X ↝ Y ]} → A [ f ≈ g ] → B [ F₁ f ≈ F₁ g ] infixr 9 _∘_ infix 4 _≈_ id : ∀{o ℓ e}{A : Graph o ℓ e} → GraphMorphism A A id = record { F₀ = λ A → A ; F₁ = λ f → f ; F-resp-≈ = λ f≈g → f≈g } _∘_ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} {A : Graph o₀ ℓ₀ e₀} {B : Graph o₁ ℓ₁ e₁} {C : Graph o₂ ℓ₂ e₂} → GraphMorphism B C → GraphMorphism A B → GraphMorphism A C G ∘ F = record { F₀ = λ A → G₀ (F₀ A) ; F₁ = λ f → G₁ (F₁ f) ; F-resp-≈ = λ f≈g → G-resp-≈ (F-resp-≈ f≈g) } where open GraphMorphism F open GraphMorphism G renaming (F₀ to G₀; F₁ to G₁; F-resp-≈ to G-resp-≈) _≈₀_ : ∀ {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} {A : Graph o₁ ℓ₁ e₁} {B : Graph o₂ ℓ₂ e₂} → (F G : GraphMorphism A B) → Set (o₁ ⊔ o₂) _≈₀_ {A = A}{B} F G = ∀ X → F₀ X ≣ G₀ X where open GraphMorphism F using (F₀) open GraphMorphism G renaming (F₀ to G₀) isEquivalence₀ : ∀{o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} {A : Graph o₁ ℓ₁ e₁} {B : Graph o₂ ℓ₂ e₂} → IsEquivalence (_≈₀_ {A = A}{B}) isEquivalence₀ {A = A}{B} = record { refl = λ x → ≣-refl ; sym = λ p x → ≣-sym (p x) ; trans = λ p q x → ≣-trans (p x) (q x) } _≈₁_ : ∀ {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} {A : Graph o₁ ℓ₁ e₁} {B : Graph o₂ ℓ₂ e₂} → (F G : GraphMorphism A B) → Set (o₁ ⊔ ℓ₁ ⊔ ℓ₂ ⊔ e₂) _≈₁_ {A = A}{B} F G = ∀ {X Y} (f : A [ X ↝ Y ]) → B [ F₁ f ~ G₁ f ] where open GraphMorphism F using (F₁) open GraphMorphism G renaming (F₁ to G₁) isEquivalence₁ : ∀{o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} {A : Graph o₁ ℓ₁ e₁} {B : Graph o₂ ℓ₂ e₂} → IsEquivalence (_≈₁_ {A = A}{B}) isEquivalence₁ {A = A}{B} = record { refl = λ f → refl ; sym = λ p f → sym (p f) ; trans = λ p q f → trans (p f) (q f) } where open Heterogeneous B _≈_ : ∀ {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} {A : Graph o₁ ℓ₁ e₁} {B : Graph o₂ ℓ₂ e₂} → (F G : GraphMorphism A B) → Set (o₁ ⊔ o₂ ⊔ ℓ₁ ⊔ ℓ₂ ⊔ e₂) _≈_ = _≈₀_ -×- _≈₁_ isEquivalence : ∀{o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} {A : Graph o₁ ℓ₁ e₁} {B : Graph o₂ ℓ₂ e₂} → IsEquivalence (_≈_ {A = A}{B}) isEquivalence {A = A}{B} = record { refl = λ {x} → refl₀ {x} , λ f → refl₁ {x} f ; sym = λ {x}{y} → map (sym₀ {x}{y}) (sym₁ {x}{y}) ; trans = λ {x}{y}{z} → zip (trans₀ {x}{y}{z}) (trans₁ {x}{y}{z}) } where open IsEquivalence isEquivalence₀ renaming (refl to refl₀; sym to sym₀; trans to trans₀) open IsEquivalence isEquivalence₁ renaming (refl to refl₁; sym to sym₁; trans to trans₁) .∘-resp-≈ : ∀ {o₀ ℓ₀ e₀ o₁ ℓ₁ e₁ o₂ ℓ₂ e₂} {A : Graph o₀ ℓ₀ e₀} {B : Graph o₁ ℓ₁ e₁} {C : Graph o₂ ℓ₂ e₂} {F H : GraphMorphism B C} {G I : GraphMorphism A B} → F ≈ H → G ≈ I → F ∘ G ≈ H ∘ I ∘-resp-≈ {B = B} {C} {F}{H}{G}{I} F≈H G≈I = (λ x → helper₁ (proj₁ G≈I x) (proj₁ F≈H (GraphMorphism.F₀ I x))) , (λ q → helper₂ (proj₂ G≈I q) (proj₂ F≈H (GraphMorphism.F₁ I q))) where open Heterogeneous C module C = Graph C helper₁ : ∀ {x} → GraphMorphism.F₀ G x ≣ GraphMorphism.F₀ I x → GraphMorphism.F₀ F (GraphMorphism.F₀ I x) ≣ GraphMorphism.F₀ H (GraphMorphism.F₀ I x) → GraphMorphism.F₀ F (GraphMorphism.F₀ G x) ≣ GraphMorphism.F₀ H (GraphMorphism.F₀ I x) helper₁ g≣i f≣h = ≣-trans (≣-cong (GraphMorphism.F₀ F) g≣i) f≣h helper₂ : ∀ {a b c d} {z w} {f : B [ a ↝ b ]} {h : B [ c ↝ d ]} {i : C [ z ↝ w ]} → B [ f ~ h ] → C [ GraphMorphism.F₁ F h ~ i ] → C [ GraphMorphism.F₁ F f ~ i ] helper₂ (≈⇒~ f≈h) (≈⇒~ g≈i) = ≈⇒~ (C.Equiv.trans (GraphMorphism.F-resp-≈ F f≈h) g≈i)
{ "alphanum_fraction": 0.5375121007, "avg_line_length": 34.1487603306, "ext": "agda", "hexsha": "7490586923147543d7e5bc8a661327f387bde6c9", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Graphs/GraphMorphism.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Graphs/GraphMorphism.agda", "max_line_length": 91, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Graphs/GraphMorphism.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 1977, "size": 4132 }
------------------------------------------------------------------------ -- Library stuff data ⊥ : Set where record ⊤ : Set where constructor tt data Bool : Set where true false : Bool if_then_else_ : ∀ {A : Set} → Bool → A → A → A if true then t else f = t if false then t else f = f data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} _∸_ : ℕ → ℕ → ℕ m ∸ zero = m zero ∸ suc n = zero suc m ∸ suc n = m ∸ n _≤_ : ℕ → ℕ → Bool zero ≤ n = true suc m ≤ zero = false suc m ≤ suc n = m ≤ n data _⊎_ (A : Set) (B : Set) : Set where inj₁ : (x : A) → A ⊎ B inj₂ : (y : B) → A ⊎ B [_,_]₁ : ∀ {A : Set} {B : Set} {C : A ⊎ B → Set₁} → ((x : A) → C (inj₁ x)) → ((x : B) → C (inj₂ x)) → ((x : A ⊎ B) → C x) [ f , g ]₁ (inj₁ x) = f x [ f , g ]₁ (inj₂ y) = g y data _≡_ {A : Set}(x : A) : A → Set where refl : x ≡ x record Σ (X : Set) (Y : X → Set) : Set where constructor _,_ field proj₁ : X proj₂ : Y proj₁ _×_ : Set → Set → Set X × Y = Σ X λ _ → Y record Sig : Set₁ where constructor _◃_ field Parameter : Set Arity : Parameter → Set open Sig public ⟦_⟧ : Sig → Set → Set ⟦ P ◃ A ⟧ X = Σ P λ p → A p → X Alg : Sig → Set → Set Alg Σ X = ⟦ Σ ⟧ X → X data μ (C : Sig) : Set where sup : Alg C (μ C) const^C : Set → Sig const^C X = X ◃ λ _ → ⊥ _⊎^C_ : Sig → Sig → Sig (P₁ ◃ A₁) ⊎^C (P₂ ◃ A₂) = (P₁ ⊎ P₂) ◃ [ A₁ , A₂ ]₁ _⋆^C_ : Sig → Set → Sig C ⋆^C X = const^C X ⊎^C C _⋆_ : Sig → Set → Set C ⋆ X = μ (C ⋆^C X) do : ∀ {C X} → Alg C (C ⋆ X) do (p , k) = sup (inj₂ p , k) record Monad (T : Set → Set) : Set₁ where infixl 1 _>>=_ field return : ∀ {X} → X → T X _>>=_ : ∀ {X Y} → T X → (X → T Y) → T Y monad : ∀ {Σ} → Monad (_⋆_ Σ) monad {Σ} = record { return = λ x → sup (inj₁ x , λ ()) ; _>>=_ = _>>=_ } where _>>=_ : ∀ {X Y} → Σ ⋆ X → (X → Σ ⋆ Y) → Σ ⋆ Y sup (inj₁ x , _) >>= f = f x sup (inj₂ p , k) >>= f = do (p , λ a → k a >>= f) generic : ∀ {Σ} (p : Parameter Σ) → Σ ⋆ Arity Σ p generic p = do (p , return) where open Monad monad ------------------------------------------------------------------------ -- Example Π : (X : Set) → (X → Set) → Set Π X Y = (x : X) → (X ◃ Y) ⋆ Y x call : ∀ {X Y} → Π X Y call x = generic x dom : ∀ {X Y} → ∀ {x} → (X ◃ Y) ⋆ Y x → (X → Set) → Set dom (sup (inj₁ _ , _)) R = ⊤ dom {Y = Y} (sup (inj₂ x , k)) R = R x × ((y : Y x) → dom (k y) R) data Dom {X}{Y} (f : (x : X) → (X ◃ Y) ⋆ Y x) : X → Set where ⟨_⟩ : ∀ {x} → dom (f x) (Dom f) → Dom f x dom-map : ∀ {X Y} {R₁ R₂ : X → Set} {x} {w : (X ◃ Y) ⋆ Y x} → (∀ {x} → R₁ x → R₂ x) → dom w R₁ → dom w R₂ dom-map {w = sup (inj₁ _ , _)} f _ = tt dom-map {w = sup (inj₂ _ , _)} f (y₁ , k) = f y₁ , λ y₂ → dom-map f (k y₂) {-# TERMINATING #-} bove-capretta : ∀ {X Y} (f : Π X Y) → (x : X) → Dom f x → Y x bove-capretta {X}{Y} f x ⟨ d ⟩ = helper (f x) (dom-map (λ {x′} → bove-capretta f x′) d) where helper : ∀ {x} (w : (X ◃ Y) ⋆ Y x) → dom w Y → Y x helper (sup (inj₁ y , _)) _ = y helper (sup (inj₂ _ , k)) (d , dk) = helper (k d) (dk d) module _ where open Monad monad gcd : Π (ℕ × ℕ) (λ _ → ℕ) gcd (0 , n) = return n gcd (m , 0) = return m gcd (suc m , suc n) = if m ≤ n then call (suc m , (n ∸ m)) else call ((m ∸ n) , suc n) acc : Dom gcd (8 , 12) acc = ⟨ ⟨ ⟨ ⟨ _ ⟩ , _ ⟩ , _ ⟩ , _ ⟩ -- ⟨ ⟨ ⟨ ⟨ tt ⟩ , (λ _ → tt) ⟩ , (λ _ → tt) ⟩ , (λ _ → tt) ⟩ test-gcd′ : bove-capretta gcd (8 , 12) acc ≡ 4 test-gcd′ = refl
{ "alphanum_fraction": 0.4183588317, "avg_line_length": 23.0448717949, "ext": "agda", "hexsha": "14ecde1b1af4cf9bbbbf493fc70359ec938fc88b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Succeed/Issue1324.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Succeed/Issue1324.agda", "max_line_length": 96, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/Issue1324.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": 1647, "size": 3595 }
module Cats.Category.One where open import Data.Unit using (⊤ ; tt) open import Level open import Cats.Category One : ∀ lo la l≈ → Category lo la l≈ One lo la l≈ = record { Obj = Lift lo ⊤ ; _⇒_ = λ _ _ → Lift la ⊤ ; _≈_ = λ _ _ → Lift l≈ ⊤ ; id = lift tt ; _∘_ = λ _ _ → lift tt ; equiv = record { refl = lift tt ; sym = λ _ → lift tt ; trans = λ _ _ → lift tt } ; ∘-resp = λ _ _ → lift tt ; id-r = lift tt ; id-l = lift tt ; assoc = lift tt }
{ "alphanum_fraction": 0.487804878, "avg_line_length": 19.7407407407, "ext": "agda", "hexsha": "bafaac9b2f04b2300192e2ef4237c154a992e2da", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Category/One.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Category/One.agda", "max_line_length": 36, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Category/One.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 194, "size": 533 }
module regex where data Regex ( Σ : Set) : Set where ε : Regex Σ -- empty φ : Regex Σ -- fail _* : Regex Σ → Regex Σ _&_ : Regex Σ → Regex Σ → Regex Σ _||_ : Regex Σ → Regex Σ → Regex Σ <_> : Σ → Regex Σ infixr 40 _&_ _||_
{ "alphanum_fraction": 0.4463087248, "avg_line_length": 19.8666666667, "ext": "agda", "hexsha": "2873f67cba7ee6a47026db6e95636ed6fae1ae5e", "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/regex.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/regex.agda", "max_line_length": 41, "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/regex.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 121, "size": 298 }