Search is not available for this dataset
text
string
meta
dict
------------------------------------------------------------------------ -- The Agda standard library -- -- Convenient syntax for reasoning with a setoid ------------------------------------------------------------------------ -- Example use: -- n*0≡0 : ∀ n → n * 0 ≡ 0 -- n*0≡0 zero = refl -- n*0≡0 (suc n) = begin -- suc n * 0 ≈⟨ refl ⟩ -- n * 0 + 0 ≈⟨ ... ⟩ -- n * 0 ≈⟨ n*0≡0 n ⟩ -- 0 ∎ -- Module `≡-Reasoning` in `Relation.Binary.PropositionalEquality` -- is recommended for equational reasoning when the underlying equality is -- `_≡_`. {-# OPTIONS --without-K --safe #-} open import Relation.Binary module Relation.Binary.Reasoning.Setoid {s₁ s₂} (S : Setoid s₁ s₂) where open Setoid S ------------------------------------------------------------------------ -- Reasoning combinators open import Relation.Binary.Reasoning.PartialSetoid partialSetoid public open import Relation.Binary.Reasoning.Base.Single _≈_ refl trans public using (_∎)
{ "alphanum_fraction": 0.506122449, "avg_line_length": 28, "ext": "agda", "hexsha": "9bdd00a09cc574b1cba4221a5db6bba17e9e40fe", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/Setoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/Setoid.agda", "max_line_length": 74, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Reasoning/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": 262, "size": 980 }
{-# OPTIONS --without-K #-} open import Base open import Integers module Spaces.FlatteningLoopSpaceWedgeCircles {i} (A : Set i) (set : is-set A) where import Spaces.WedgeCircles import Algebra.FreeGroup import Algebra.FreeGroupProps import Algebra.FreeGroupAsReducedWords open Spaces.WedgeCircles A renaming (wedge-circles to WA; base to baseWA) open Algebra.FreeGroup A renaming (freegroup to FA) open Algebra.FreeGroupProps A -- Path fibration path-fib : WA → Set (suc i) path-fib t = (t ≡ baseWA) tot-path-fib : Set (suc i) tot-path-fib = Σ (WA) path-fib abstract tot-path-fib-is-contr : is-contr tot-path-fib tot-path-fib-is-contr = pathto-is-contr baseWA -- Universal cover x·-path : A → FA ≡ FA x·-path x = eq-to-path (_ , x·-is-equiv x) universal-cover : WA → Set i universal-cover = wedge-circles-rec-nondep (Set _) FA x·-path tot-cover : Set _ tot-cover = Σ WA universal-cover trans-universal-cover : {u v : WA} (p : u ≡ v) (q : universal-cover u) → transport universal-cover p q ≡ transport (λ A → A) (ap universal-cover p) q trans-universal-cover refl _ = refl abstract loops-to-x· : (t : A) (u : FA) → transport universal-cover (loops t) u ≡ t · u loops-to-x· t u = trans-universal-cover (loops t) u ∘ (ap (λ t' → transport (λ B → B) t' u) (β-nondep (Set _) FA x·-path t) ∘ trans-id-eq-to-path (_ , x·-is-equiv t) u) {- Here is an HIT declaration for the Cayley graph of the free group over A: data cayley : Set where z : FA → cayley e : (t : A) (u : FA) → z u ≡ z (t · u) We will see that [cayley] is contractible. We want to show that [tot-cover] has the same introduction and elimination rules, so that we can prove that [tot-cover] is contractible too. We do not need to actually have the type [cayley], it is enough to show that [tot-cover] has the same rules and then we can copy the proof of the contractibility using the new rules. -} -- Introduction rules CA-z : FA → tot-cover CA-z u = (baseWA , u) CA-e : (t : A) (u : FA) → CA-z u ≡ CA-z (t · u) CA-e t u = Σ-eq (loops t) (loops-to-x· t u) -- Elimination rule module equivCA {i} (P : tot-cover → Set i) (z : (u : FA) → P (CA-z u)) (e : (t : A) (u : FA) → transport P (CA-e t u) (z u) ≡ z (t · u)) where CA-e' : (t : A) (u : FA) → CA-z u ≡ CA-z (transport universal-cover (loops t) u) CA-e' t u = Σ-eq (loops t) refl abstract e' : (t : A) (u : FA) → transport P (CA-e' t u) (z u) ≡ z (transport universal-cover (loops t) u) e' t u = (trans-totalpath universal-cover P {x = (baseWA , u)} {y = (baseWA , transport universal-cover (loops t) u)} (loops t) refl z ∘ move!-transp-left (λ z → P (baseWA , z)) _ (loops-to-x· t u) (z (t · u)) (! (trans-totalpath universal-cover P {x = (baseWA , u)} {y = (baseWA , (t · u))} (loops t) (loops-to-x· t u) z) ∘ e t u)) ∘ apd z (! (loops-to-x· t u)) P-base : (u : universal-cover (baseWA)) → P (baseWA , u) P-base u = z u abstract P-loops : (t : A) (u : universal-cover (baseWA)) → transport (λ x → (t : universal-cover x) → P (x , t)) (loops t) P-base u ≡ P-base u P-loops t u = transport (λ u → transport (λ x → (t : universal-cover x) → P (x , t)) (loops t) P-base u ≡ P-base u) (trans-trans-opposite universal-cover (loops t) u) (! (trans-totalpath universal-cover P {x = (baseWA , transport universal-cover (! (loops t)) u)} {y = (baseWA , transport universal-cover (loops t) (transport universal-cover (! (loops t)) u))} (loops t) refl z) ∘ e' t (transport universal-cover (! (loops t)) u)) P-CA-rec : (x : WA) → (t : universal-cover x) → P (x , t) P-CA-rec = wedge-circles-rec (λ x → (t : universal-cover x) → P (x , t)) P-base (λ t → funext (P-loops t)) -- Here is the conclusion of the elimination rule abstract CA-rec : (t : tot-cover) → P t CA-rec (x , y) = P-CA-rec x y
{ "alphanum_fraction": 0.5766811805, "avg_line_length": 32.5511811024, "ext": "agda", "hexsha": "571f5275b6648b445910301a66474619bd744237", "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/Spaces/FlatteningLoopSpaceWedgeCircles.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/Spaces/FlatteningLoopSpaceWedgeCircles.agda", "max_line_length": 80, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/Spaces/FlatteningLoopSpaceWedgeCircles.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": 1334, "size": 4134 }
{-# OPTIONS --without-K #-} --open import HoTT open import homotopy.3x3.PushoutPushout open import homotopy.3x3.Transpose import homotopy.3x3.To as To import homotopy.3x3.From as From open import homotopy.3x3.Common module homotopy.3x3.FromTo {i} (d : Span^2 {i}) where open Span^2 d open M d hiding (Pushout^2) open M (transpose d) using () renaming (module F₁∙ to F∙₁; f₁∙ to f∙₁; module F₃∙ to F∙₃; f₃∙ to f∙₃; v-h-span to h-v-span) open M using (Pushout^2) open To d open From d open import homotopy.3x3.FromToInit d open import homotopy.3x3.FromTo2 d open import homotopy.3x3.FromTo3 d from-to-g-g : (c : A₂₂) → (from-to-g-l (f₂₁ c) , ↓-='-out (apd (from-to-r ∘ f₃∙) (glue c)) , ↓-='-out (apd (ap from ∘ ap to ∘ glue) (glue c)) =□□ ↓-='-out (apd glue (glue c)) , ↓-='-out (apd (from-to-l ∘ f₁∙) (glue c)) , from-to-g-r (f₂₃ c)) from-to-g-g c = coh _ lemma1 lemma3 _ _ (↓-='-out (apd glue (glue c))) lemma2 where open M2 c open M3 c from-to-g-g' : (c : A₂₂) → from-to-g-l (f₂₁ c) == from-to-g-r (f₂₃ c) [ (λ c → (from-to-l (f₁∙ c) , glue c =□ ap from (ap to (glue c)) , from-to-r (f₃∙ c))) ↓ glue c ] from-to-g-g' c = ↓-=□-in (from-to-g-g c) module FromToG = PushoutElim {d = span _ _ _ f₂₁ f₂₃} {P = λ c → (from-to-l (f₁∙ c) , glue c =□ ap from (ap to (glue c)) , from-to-r (f₃∙ c))} from-to-g-l from-to-g-r from-to-g-g' from-to-g : (c : A₂∙) → (from-to-l (f₁∙ c) , glue c =□ ap from (ap to (glue c)) , from-to-r (f₃∙ c)) from-to-g = FromToG.f from-to-g' : (c : A₂∙) → from-to-l (f₁∙ c) == from-to-r (f₃∙ c) [ (λ z → from (to z) == z) ↓ glue c ] from-to-g' c = ↓-∘=idf-in from to (from-to-g c) from-to : (x : Pushout^2 d) → from (to x) == x from-to = Pushout-elim from-to-l from-to-r from-to-g'
{ "alphanum_fraction": 0.5458885942, "avg_line_length": 39.2708333333, "ext": "agda", "hexsha": "289af1db007bc62c737ced87e642e4e9680386b0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "homotopy/3x3/FromTo.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "homotopy/3x3/FromTo.agda", "max_line_length": 167, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda", "max_stars_repo_path": "homotopy/3x3/FromTo.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 771, "size": 1885 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.SumFin.Properties where open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Prelude open import Cubical.Foundations.Univalence open import Cubical.Data.Empty as ⊥ import Cubical.Data.Fin as Fin open import Cubical.Data.Nat open import Cubical.Data.SumFin.Base as SumFin private variable ℓ : Level k : ℕ SumFin→Fin : Fin k → Fin.Fin k SumFin→Fin = SumFin.elim (λ {k} _ → Fin.Fin k) Fin.fzero Fin.fsuc Fin→SumFin : Fin.Fin k → Fin k Fin→SumFin = Fin.elim (λ {k} _ → Fin k) fzero fsuc Fin→SumFin-fsuc : (fk : Fin.Fin k) → Fin→SumFin (Fin.fsuc fk) ≡ fsuc (Fin→SumFin fk) Fin→SumFin-fsuc = Fin.elim-fsuc (λ {k} _ → Fin k) fzero fsuc SumFin→Fin→SumFin : (fk : Fin k) → Fin→SumFin (SumFin→Fin fk) ≡ fk SumFin→Fin→SumFin = SumFin.elim (λ fk → Fin→SumFin (SumFin→Fin fk) ≡ fk) refl λ {k} {fk} eq → Fin→SumFin (Fin.fsuc (SumFin→Fin fk)) ≡⟨ Fin→SumFin-fsuc (SumFin→Fin fk) ⟩ fsuc (Fin→SumFin (SumFin→Fin fk)) ≡⟨ cong fsuc eq ⟩ fsuc fk ∎ Fin→SumFin→Fin : (fk : Fin.Fin k) → SumFin→Fin (Fin→SumFin fk) ≡ fk Fin→SumFin→Fin = Fin.elim (λ fk → SumFin→Fin (Fin→SumFin fk) ≡ fk) refl λ {k} {fk} eq → SumFin→Fin (Fin→SumFin (Fin.fsuc fk)) ≡⟨ cong SumFin→Fin (Fin→SumFin-fsuc fk) ⟩ Fin.fsuc (SumFin→Fin (Fin→SumFin fk)) ≡⟨ cong Fin.fsuc eq ⟩ Fin.fsuc fk ∎ SumFin≃Fin : ∀ k → Fin k ≃ Fin.Fin k SumFin≃Fin _ = isoToEquiv (iso SumFin→Fin Fin→SumFin Fin→SumFin→Fin SumFin→Fin→SumFin) SumFin≡Fin : ∀ k → Fin k ≡ Fin.Fin k SumFin≡Fin k = ua (SumFin≃Fin k)
{ "alphanum_fraction": 0.6357808858, "avg_line_length": 35.0204081633, "ext": "agda", "hexsha": "3ff9218173357d25042e1a4bde58bcfee17fddfd", "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/Data/SumFin/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/SumFin/Properties.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/SumFin/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 643, "size": 1716 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Group.EilenbergMacLane1 where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.GroupoidLaws renaming (assoc to ∙assoc) open import Cubical.Foundations.Path open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Foundations.SIP open import Cubical.Data.Unit open import Cubical.Data.Sigma open import Cubical.Relation.Binary.Base open import Cubical.Structures.Axioms open import Cubical.Structures.Auto open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Homotopy.Connected open import Cubical.HITs.Nullification as Null hiding (rec; elim) open import Cubical.HITs.Truncation.FromNegOne as Trunc renaming (rec to trRec; elim to trElim) open import Cubical.HITs.EilenbergMacLane1 private variable ℓ : Level module _ (G : Group {ℓ}) where open Group G emloop-id : emloop 0g ≡ refl emloop-id = -- emloop 0g ≡⟨ rUnit (emloop 0g) ⟩ emloop 0g ≡⟨ rUnit (emloop 0g) ⟩ emloop 0g ∙ refl ≡⟨ cong (emloop 0g ∙_) (rCancel (emloop 0g) ⁻¹) ⟩ emloop 0g ∙ (emloop 0g ∙ (emloop 0g) ⁻¹) ≡⟨ ∙assoc _ _ _ ⟩ (emloop 0g ∙ emloop 0g) ∙ (emloop 0g) ⁻¹ ≡⟨ cong (_∙ emloop 0g ⁻¹) ((emloop-comp G 0g 0g) ⁻¹) ⟩ emloop (0g + 0g) ∙ (emloop 0g) ⁻¹ ≡⟨ cong (λ g → emloop {G = G} g ∙ (emloop 0g) ⁻¹) (rid 0g) ⟩ emloop 0g ∙ (emloop 0g) ⁻¹ ≡⟨ rCancel (emloop 0g) ⟩ refl ∎ emloop-inv : (g : Carrier) → emloop (- g) ≡ (emloop g) ⁻¹ emloop-inv g = emloop (- g) ≡⟨ rUnit (emloop (- g)) ⟩ emloop (- g) ∙ refl ≡⟨ cong (emloop (- g) ∙_) (rCancel (emloop g) ⁻¹) ⟩ emloop (- g) ∙ (emloop g ∙ (emloop g) ⁻¹) ≡⟨ ∙assoc _ _ _ ⟩ (emloop (- g) ∙ emloop g) ∙ (emloop g) ⁻¹ ≡⟨ cong (_∙ emloop g ⁻¹) ((emloop-comp G (- g) g) ⁻¹) ⟩ emloop (- g + g) ∙ (emloop g) ⁻¹ ≡⟨ cong (λ h → emloop {G = G} h ∙ (emloop g) ⁻¹) (invl g) ⟩ emloop 0g ∙ (emloop g) ⁻¹ ≡⟨ cong (_∙ (emloop g) ⁻¹) emloop-id ⟩ refl ∙ (emloop g) ⁻¹ ≡⟨ (lUnit ((emloop g) ⁻¹)) ⁻¹ ⟩ (emloop g) ⁻¹ ∎ EM₁Groupoid : isGroupoid (EM₁ G) EM₁Groupoid = emsquash EM₁Connected : isConnected 2 (EM₁ G) EM₁Connected = ∣ embase ∣ , h where h : (y : hLevelTrunc 2 (EM₁ G)) → ∣ embase ∣ ≡ y h = trElim (λ y → isOfHLevelSuc 1 (isOfHLevelTrunc 2 ∣ embase ∣ y)) (elimProp G (λ x → isOfHLevelTrunc 2 ∣ embase ∣ ∣ x ∣) refl) {- since we write composition in diagrammatic order, and function composition in the other order, we need right multiplication here -} rightEquiv : (g : Carrier) → Carrier ≃ Carrier rightEquiv g = isoToEquiv (iso (_+ g) (_+ - g) (λ h → (h + - g) + g ≡⟨ (assoc h (- g) g) ⁻¹ ⟩ h + - g + g ≡⟨ cong (h +_) (invl g) ⟩ h + 0g ≡⟨ rid h ⟩ h ∎) λ h → (h + g) + - g ≡⟨ (assoc h g (- g)) ⁻¹ ⟩ h + g + - g ≡⟨ cong (h +_) (invr g) ⟩ h + 0g ≡⟨ rid h ⟩ h ∎) compRightEquiv : (g h : Carrier) → compEquiv (rightEquiv g) (rightEquiv h) ≡ rightEquiv (g + h) compRightEquiv g h = equivEq _ _ (funExt (λ x → (assoc x g h) ⁻¹)) CodesSet : EM₁ G → hSet ℓ CodesSet = rec G (isOfHLevelTypeOfHLevel 2) (Carrier , is-set) RE REComp where RE : (g : Carrier) → Path (hSet ℓ) (Carrier , is-set) (Carrier , is-set) RE g = Σ≡Prop (λ X → isPropIsOfHLevel {A = X} 2) (ua (rightEquiv g)) lemma₁ : (g h : Carrier) → Square (ua (rightEquiv g)) (ua (rightEquiv (g + h))) refl (ua (rightEquiv h)) lemma₁ g h = invEq (Square≃doubleComp (ua (rightEquiv g)) (ua (rightEquiv (g + h))) refl (ua (rightEquiv h))) (ua (rightEquiv g) ∙ ua (rightEquiv h) ≡⟨ (uaCompEquiv (rightEquiv g) (rightEquiv h)) ⁻¹ ⟩ ua (compEquiv (rightEquiv g) (rightEquiv h)) ≡⟨ cong ua (compRightEquiv g h) ⟩ ua (rightEquiv (g + h)) ∎) lemma₂ : {A₀₀ A₀₁ : hSet ℓ} (p₀₋ : A₀₀ ≡ A₀₁) {A₁₀ A₁₁ : hSet ℓ} (p₁₋ : A₁₀ ≡ A₁₁) (p₋₀ : A₀₀ ≡ A₁₀) (p₋₁ : A₀₁ ≡ A₁₁) (s : Square (cong fst p₀₋) (cong fst p₁₋) (cong fst p₋₀) (cong fst p₋₁)) → Square p₀₋ p₁₋ p₋₀ p₋₁ fst (lemma₂ p₀₋ p₁₋ p₋₀ p₋₁ s i j) = s i j snd (lemma₂ p₀₋ p₁₋ p₋₀ p₋₁ s i j) = isSet→isSetDep (λ X → isProp→isSet (isPropIsOfHLevel {A = X} 2)) (cong fst p₀₋) (cong fst p₁₋) (cong fst p₋₀) (cong fst p₋₁) s (cong snd p₀₋) (cong snd p₁₋) (cong snd p₋₀) (cong snd p₋₁) i j REComp : (g h : Carrier) → Square (RE g) (RE (g + h)) refl (RE h) REComp g h = lemma₂ (RE g) (RE (g + h)) refl (RE h) (lemma₁ g h) Codes : EM₁ G → Type ℓ Codes x = CodesSet x .fst encode : (x : EM₁ G) → embase ≡ x → Codes x encode x p = subst Codes p 0g decode : (x : EM₁ G) → Codes x → embase ≡ x decode = elimSet G (λ x → isOfHLevelΠ 2 (λ c → EM₁Groupoid (embase) x)) emloop lem₂ where module _ (g : Carrier) where lem₁ : (h : Carrier) → PathP (λ i → embase ≡ emloop g i) (emloop h) (emloop (h + g)) lem₁ h = emcomp h g lem₂ : PathP (λ i → Codes (emloop g i) → embase ≡ emloop g i) emloop emloop lem₂ = ua→ {A₀ = Carrier} {A₁ = Carrier} {e = rightEquiv g} lem₁ decode-encode : (x : EM₁ G) (p : embase ≡ x) → decode x (encode x p) ≡ p decode-encode x p = J (λ y q → decode y (encode y q) ≡ q) (emloop (transport refl 0g) ≡⟨ cong emloop (transportRefl 0g) ⟩ emloop 0g ≡⟨ emloop-id ⟩ refl ∎) p encode-decode : (x : EM₁ G) (c : Codes x) → encode x (decode x c) ≡ c encode-decode = elimProp G (λ x → isOfHLevelΠ 1 (λ c → CodesSet x .snd _ _)) λ g → encode embase (decode embase g) ≡⟨ refl ⟩ encode embase (emloop g) ≡⟨ refl ⟩ transport (ua (rightEquiv g)) 0g ≡⟨ uaβ (rightEquiv g) 0g ⟩ 0g + g ≡⟨ lid g ⟩ g ∎ ΩEM₁Iso : Iso (Path (EM₁ G) embase embase) Carrier Iso.fun ΩEM₁Iso = encode embase Iso.inv ΩEM₁Iso = emloop Iso.rightInv ΩEM₁Iso = encode-decode embase Iso.leftInv ΩEM₁Iso = decode-encode embase ΩEM₁≡ : (Path (EM₁ G) embase embase) ≡ Carrier ΩEM₁≡ = isoToPath ΩEM₁Iso
{ "alphanum_fraction": 0.5825501253, "avg_line_length": 42, "ext": "agda", "hexsha": "0e562ebc662e5ccd02c12a3c649a2dff37803af8", "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": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/EilenbergMacLane1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "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": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/EilenbergMacLane1.agda", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/EilenbergMacLane1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2629, "size": 6384 }
{-# OPTIONS --without-K #-} open import library.Basics hiding (Type ; Σ) open import library.types.Sigma open import library.NType2 open import Sec2preliminaries open import Sec3hedberg module Sec4hasConstToSplit where -- Auxiliary Lemma 4.2 transport-is-comp : {X Y : Type} → {x₁ x₂ : X} → (h k : X → Y) → (t : x₁ == x₂) → (p : h x₁ == k x₁) → (transport _ t p) == ! (ap h t) ∙ p ∙ ap k t transport-is-comp h k idp p = ! (∙-unit-r _) -- Auxiliary Lemma 4.3, part 1 wconstant-implies-path-wconstant : {X Y : Type} → (f : X → Y) → (const f) → (x₁ x₂ : X) → const (ap f {x = x₁} {y = x₂}) wconstant-implies-path-wconstant {X} f c x₁ x₂ p₁ p₂ = claim-cor where claim : {x₃ x₄ : X} → {p : x₃ == x₄} → (ap f p) == ! (c x₃ x₃) ∙ (c x₃ x₄) claim {x₃} {p = idp} = ! (!-inv-l (c x₃ x₃)) claim-cor : ap f p₁ == ap f p₂ claim-cor = ap f p₁ =⟨ claim ⟩ ! (c x₁ x₁) ∙ (c x₁ x₂) =⟨ ! claim ⟩ ap f p₂ ∎ -- Auxiliary Lemma 4.3, part 2 wconstant-refl : {X Y : Type} → (f : X → Y) → (const f) → (x : X) → (p : x == x) → ap f p == idp wconstant-refl f c x p = wconstant-implies-path-wconstant f c x x p idp -- We also need the following very simple lemma: ap-id-trivial : {X : Type} → {x₁ x₂ : X} → (p : x₁ == x₂) → ap (idf X) p == p ap-id-trivial idp = idp -- Lemma 4.1 needs a bit of preparation. fix : {X : Type} → (f : X → X) → Type fix {X} f = Σ X λ x → x == f x -- let us give a name to the map X → fix f: to-fix : {X : Type} → (f : X → X) → (const f) → X → fix f to-fix f c x₀ = f x₀ , c _ _ -- the other direction is just projection: from-fix : {X : Type} → (f : X → X) → fix f → X from-fix f (x₀ , p₀) = x₀ -- let us structure the proof of the fixed point lemma a bit: module fixedpoint {X : Type} (f : X → X) (c : const f) where -- let us show that (x , p) == (x , q) first module _ (x : X) (p q : x == f x) where t : x == x t = p ∙ ! q r : f x == f x r = ap f t r-is-triv : r == idp r-is-triv = wconstant-refl f c x t t' : x == x t' = ap (idf X) t t'-is-t : t' == t t'-is-t = ap-id-trivial t trans-t-p-is-q : transport (λ y → y == f y) t p == q trans-t-p-is-q = transport (λ y → y == f y) t p =⟨ transport-is-comp (idf X) f t p ⟩ ! t' ∙ p ∙ r =⟨ ap (λ s → ! s ∙ p ∙ r) t'-is-t ⟩ ! t ∙ p ∙ r =⟨ ! (∙-assoc (! t) _ _) ⟩ (! t ∙ p) ∙ r =⟨ ap (λ s → (! t ∙ p) ∙ s) r-is-triv ⟩ (! t ∙ p) ∙ idp =⟨ ∙-unit-r _ ⟩ ! t ∙ p =⟨ ap (λ s → s ∙ p) (!-∙ p (! q)) ⟩ (! (! q) ∙ ! p) ∙ p =⟨ ∙-assoc (! (! q)) _ _ ⟩ ! (! q) ∙ ! p ∙ p =⟨ ap (λ s → ! (! q) ∙ s) (!-inv-l p) ⟩ ! (! q) ∙ idp =⟨ ∙-unit-r _ ⟩ ! (! q) =⟨ !-! _ ⟩ q ∎ single-x-claim : (x , p) == (x , q) single-x-claim = pair= t (from-transp _ _ trans-t-p-is-q) -- Now, we can prove that (x₁ , p₁) and (x₂ , p₂) are always equal: fix-paths : has-all-paths (fix f) fix-paths (x₁ , p₁) (x₂ , p₂) = (x₁ , p₁) =⟨ pair= (p₁ ∙ c x₁ x₂ ∙ ! p₂) (from-transp _ (p₁ ∙ c x₁ x₂ ∙ ! p₂) idp) ⟩ (x₂ , _) =⟨ single-x-claim x₂ _ _ ⟩ (x₂ , p₂) ∎ -- finally, the proof of the fixed point lemma fixed-point : {X : Type} → (f : X → X) → (const f) → is-prop (fix f) fixed-point {X} f c = all-paths-is-prop (fixedpoint.fix-paths f c) -- Sattler's argument fixed-point-alt : {X : Type} → (f : X → X) → (const f) → is-prop (fix f) fixed-point-alt {X} f c = inhab-to-contr-is-prop inh→contr where inh→contr : fix f → is-contr (fix f) inh→contr (x₀ , p₀) = equiv-preserves-level {A = Σ X λ x → x == f x₀} {B = fix f} claim-Σ (pathto-is-contr _) where claim : (x : X) → (x == f x₀) ≃ (x == f x) claim x = (λ p → p ∙ c x₀ x) , post∙-is-equiv _ claim-Σ : (Σ X λ x → x == f x₀) ≃ fix f claim-Σ = equiv-Σ-snd claim -- Corollary 4.4 -- let us define the following map: trunc-to-fix : {X : Type} → (fc : hasConst X) → Trunc X → fix (fst fc) trunc-to-fix (f , c) z = rec (fixed-point f c) (to-fix f c) z hasConst→splitSup : {X : Type} → hasConst X → splitSup X hasConst→splitSup (f , c) = (from-fix f) ∘ trunc-to-fix (f , c) -- Theorem 4.5 hasConst↔splitSup : {X : Type} → hasConst X ↔ splitSup X hasConst↔splitSup {X} = hasConst→splitSup , splitSup→hasConst where splitSup→hasConst : splitSup X → hasConst X splitSup→hasConst hst = f , c where f = hst ∘ ∣_∣ c : const f c x₁ x₂ = f x₁ =⟨ idp ⟩ hst ∣ x₁ ∣ =⟨ ap hst (prop-has-all-paths (h-tr _) _ _) ⟩ hst ∣ x₂ ∣ =⟨ idp ⟩ f x₂ ∎ -- preparation for Theorem 4.6 - we need to prove that -- f : X → X with an inhabitant of Trunc (wconst f) is enough -- to show that fix f is propositional. fixed-point-strong : {X : Type} → (f : X → X) → (Trunc (const f)) → is-prop (fix f) fixed-point-strong {X} f = rec {X = const f} {P = is-prop(fix f)} is-prop-is-prop (fixed-point f) -- Theorem 4.6 (we exclude the part which is already included in 4.5) -- to get an easy proof of the addendum, we structure it in the following way: module thm46 {X : Type} where module _ (fhc : Σ (X → X) (Trunc ∘ const)) where f = fst fhc hc = snd fhc trunc-wconst-fix : Trunc X → Trunc(const f) → fix f trunc-wconst-fix z = rec {X = const f} {P = fix f} (fixed-point-strong f hc) (λ c → trunc-to-fix (f , c) z) trunc-fix : Trunc X → fix f trunc-fix z = trunc-wconst-fix z hc g : X → X g = fst ∘ trunc-fix ∘ ∣_∣ g-wconst : const g g-wconst x₁ x₂ = ap (fst ∘ trunc-fix) (prop-has-all-paths (h-tr _) _ _) hasConst↔hideProof : {X : Type} → hasConst X ↔ Σ (X → X) (Trunc ∘ const) hasConst↔hideProof {X} = one , two where one : hasConst X → Σ (X → X) (Trunc ∘ const) one (f , c) = f , ∣ c ∣ two : (Σ (X → X) (Trunc ∘ const)) → hasConst X two fhc = thm46.g fhc , thm46.g-wconst fhc -- Theorem 4.6 addendum merely-equal : {X : Type} → (fhc : Σ (X → X) (Trunc ∘ const)) → Trunc ((x : X) → fst fhc x == thm46.g fhc x) merely-equal {X} (f , hc) = rec (h-tr _) (∣_∣ ∘ wconst-equal) hc where open thm46 hiding (f ; hc) wconst-equal : const f → (x : X) → f x == thm46.g (f , hc) x wconst-equal c x = f x =⟨ idp ⟩ fst (to-fix f c x) =⟨ ap fst (! (trunc-β _ _ x)) ⟩ fst (trunc-to-fix (f , c) ∣ x ∣) =⟨ ap fst (! (trunc-β _ _ c)) ⟩ fst (trunc-wconst-fix (f , hc) ∣ x ∣ ∣ c ∣) =⟨ ap (λ hc' → fst (trunc-wconst-fix (f , hc) ∣ x ∣ hc')) (prop-has-all-paths (h-tr _) _ _) ⟩ fst (trunc-wconst-fix (f , hc) ∣ x ∣ hc) =⟨ idp ⟩ fst (trunc-fix (f , hc) ∣ x ∣) =⟨ idp ⟩ g (f , hc) x ∎
{ "alphanum_fraction": 0.5038235294, "avg_line_length": 39.7660818713, "ext": "agda", "hexsha": "563aa9c37f0f690973f616048dcc76d47e89ae4c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "nicolai/anonymousExistence/Sec4hasConstToSplit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "nicolai/anonymousExistence/Sec4hasConstToSplit.agda", "max_line_length": 142, "max_stars_count": 1, "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_path": "nicolai/anonymousExistence/Sec4hasConstToSplit.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 2766, "size": 6800 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Monoid.Morphism where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Functions.Embedding open import Cubical.Algebra open import Cubical.Algebra.Semigroup.Morphism private variable m n : Level record IsMonoidHom (M : Monoid m) (N : Monoid n) (f : ⟨ M ⟩ → ⟨ N ⟩) : Type (ℓ-max m n) where constructor ismonoidhom field preservesOp : Homomorphic₂ f (Monoid._•_ M) (Monoid._•_ N) preservesId : Homomorphic₀ f (Monoid.ε M) (Monoid.ε N) record MonoidHom (M : Monoid m) (N : Monoid n) : Type (ℓ-max m n) where constructor monoidhom field fun : ⟨ M ⟩ → ⟨ N ⟩ isHom : IsMonoidHom M N fun open IsMonoidHom isHom public record MonoidEquiv (M : Monoid m) (N : Monoid n) : Type (ℓ-max m n) where constructor monoidequiv field eq : ⟨ M ⟩ ≃ ⟨ N ⟩ isHom : IsMonoidHom M N (equivFun eq) open IsMonoidHom isHom public hom : MonoidHom M N hom = record { isHom = isHom } instance MonoidHomOperators : HomOperators (Monoid m) (Monoid n) (ℓ-max m n) MonoidHomOperators = record { _⟶ᴴ_ = MonoidHom; _≃ᴴ_ = MonoidEquiv } private variable M : Monoid m N : Monoid n IsMonoidHom→IsSemigroupHom : {f : ⟨ M ⟩ → ⟨ N ⟩} → IsMonoidHom M N f → IsSemigroupHom (Monoid.semigroup M) (Monoid.semigroup N) f IsMonoidHom→IsSemigroupHom = IsMonoidHom.preservesOp MonoidHom→SemigroupHom : (M ⟶ᴴ N) → (Monoid.semigroup M ⟶ᴴ Monoid.semigroup N) MonoidHom→SemigroupHom hom .SemigroupHom.fun = hom .MonoidHom.fun MonoidHom→SemigroupHom hom .SemigroupHom.isHom = IsMonoidHom→IsSemigroupHom (hom .MonoidHom.isHom) MonoidEquiv→SemigroupEquiv : M ≃ᴴ N → Monoid.semigroup M ≃ᴴ Monoid.semigroup N MonoidEquiv→SemigroupEquiv eq .SemigroupEquiv.eq = eq .MonoidEquiv.eq MonoidEquiv→SemigroupEquiv eq .SemigroupEquiv.isHom = IsMonoidHom→IsSemigroupHom (eq .MonoidEquiv.isHom)
{ "alphanum_fraction": 0.718879668, "avg_line_length": 31.606557377, "ext": "agda", "hexsha": "9186f80150c470f78cb24e11f6edf972af0d97ff", "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/Morphism.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/Morphism.agda", "max_line_length": 129, "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/Morphism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 689, "size": 1928 }
open import bool module braun-tree{ℓ} (A : Set ℓ) (_<A_ : A → A → 𝔹) where open import bool-thms open import eq open import list open import nat open import nat-thms open import product open import sum -- the index n is the size of the tree (number of elements of type A) data braun-tree : (n : ℕ) → Set ℓ where bt-empty : braun-tree 0 bt-node : ∀ {n m : ℕ} → A → braun-tree n → braun-tree m → n ≡ m ∨ n ≡ suc m → braun-tree (suc (n + m)) {- we will keep smaller (_<A_) elements closer to the root of the Braun tree as we insert -} bt-insert : ∀ {n : ℕ} → A → braun-tree n → braun-tree (suc n) bt-insert a bt-empty = bt-node a bt-empty bt-empty (inj₁ refl) bt-insert a (bt-node{n}{m} a' l r p) rewrite +comm n m with p | if a <A a' then (a , a') else (a' , a) bt-insert a (bt-node{n}{m} a' l r _) | inj₁ p | (a1 , a2) rewrite p = (bt-node a1 (bt-insert a2 r) l (inj₂ refl)) bt-insert a (bt-node{n}{m} a' l r _) | inj₂ p | (a1 , a2) = (bt-node a1 (bt-insert a2 r) l (inj₁ (sym p))) bt-replace-min : ∀{n : ℕ} → A → braun-tree (suc n) → braun-tree (suc n) bt-replace-min a (bt-node _ bt-empty bt-empty u) = (bt-node a bt-empty bt-empty u) bt-replace-min a (bt-node _ bt-empty (bt-node _ _ _ _) (inj₁ ())) bt-replace-min a (bt-node _ bt-empty (bt-node _ _ _ _) (inj₂ ())) bt-replace-min a (bt-node _ (bt-node _ _ _ _) bt-empty (inj₁ ())) bt-replace-min a (bt-node a' (bt-node x l r u) bt-empty (inj₂ y)) with a <A x bt-replace-min a (bt-node a' (bt-node x l r u) bt-empty (inj₂ y)) | tt = (bt-node a (bt-node x l r u) bt-empty (inj₂ y)) bt-replace-min a (bt-node a' (bt-node x l r u) bt-empty (inj₂ y)) | ff = (bt-node x (bt-replace-min a (bt-node x l r u)) bt-empty (inj₂ y)) bt-replace-min a (bt-node a' (bt-node x l r u) (bt-node x' l' r' u') v) with a <A x && a <A x' bt-replace-min a (bt-node a' (bt-node x l r u) (bt-node x' l' r' u') v) | tt = (bt-node a (bt-node x l r u) (bt-node x' l' r' u') v) bt-replace-min a (bt-node a' (bt-node x l r u) (bt-node x' l' r' u') v) | ff with x <A x' bt-replace-min a (bt-node a' (bt-node x l r u) (bt-node x' l' r' u') v) | ff | tt = (bt-node x (bt-replace-min a (bt-node x l r u)) (bt-node x' l' r' u') v) bt-replace-min a (bt-node a' (bt-node x l r u) (bt-node x' l' r' u') v) | ff | ff = (bt-node x' (bt-node x l r u) (bt-replace-min a (bt-node x' l' r' u')) v) {- thanks to Matías Giovannini for the excellent post http://alaska-kamtchatka.blogspot.com/2010/02/braun-trees.html explaining how to do delete -} bt-delete-min : ∀ {p : ℕ} → braun-tree (suc p) → braun-tree p bt-delete-min (bt-node a bt-empty bt-empty u) = bt-empty bt-delete-min (bt-node a bt-empty (bt-node _ _ _ _) (inj₁ ())) bt-delete-min (bt-node a bt-empty (bt-node _ _ _ _) (inj₂ ())) bt-delete-min (bt-node a (bt-node{n'}{m'} a' l' r' u') bt-empty u) rewrite +0 (n' + m') = bt-node a' l' r' u' bt-delete-min (bt-node a (bt-node{n}{m} x l1 r1 u1) (bt-node{n'}{m'} x' l2 r2 u2) u) rewrite +suc(n + m)(n' + m') | +suc n (m + (n' + m')) | +comm(n + m)(n' + m') = if (x <A x') then (bt-node x (bt-node x' l2 r2 u2) (bt-delete-min (bt-node x l1 r1 u1)) (lem{n}{m}{n'}{m'} u)) else (bt-node x' (bt-replace-min x (bt-node x' l2 r2 u2)) (bt-delete-min (bt-node x l1 r1 u1)) (lem{n}{m}{n'}{m'} u)) where lem : {n m n' m' : ℕ} → suc (n + m) ≡ suc (n' + m') ∨ suc (n + m) ≡ suc (suc (n' + m')) → suc (n' + m') ≡ n + m ∨ suc (n' + m') ≡ suc (n + m) lem{n}{m}{n'}{m'} (inj₁ x) = inj₂ (sym x) lem (inj₂ y) = inj₁ (sym (suc-inj y)) bt-remove-min : ∀ {p : ℕ} → braun-tree (suc p) → A × braun-tree p bt-remove-min (bt-node a l r u) = a , bt-delete-min (bt-node a l r u) ---------------------------------------------------------------------- -- this version stores data at the leaves instead of at the nodes ---------------------------------------------------------------------- data braun-tree' : (n : ℕ) → Set ℓ where bt'-leaf : A → braun-tree' 1 bt'-node : ∀ {n m : ℕ} → braun-tree' n → braun-tree' m → n =ℕ m ≡ tt ⊎ n =ℕ m + 1 ≡ tt → braun-tree' (n + m) bt'-insert : ∀ {n : ℕ} → A → braun-tree' n → braun-tree' (suc n) bt'-insert a (bt'-leaf a') = bt'-node (bt'-leaf a) (bt'-leaf a') (inj₁ refl) bt'-insert a (bt'-node{n}{m} l r p) rewrite +comm n m with p bt'-insert a (bt'-node{n}{m} l r p) | inj₁ p' rewrite =ℕ-to-≡{n} p' = (bt'-node (bt'-insert a r) l (inj₂ lem)) where lem : suc m =ℕ m + 1 ≡ tt lem rewrite +comm m 1 = =ℕ-refl m bt'-insert a (bt'-node{n}{m} l r p) | inj₂ p' = (bt'-node (bt'-insert a r) l (inj₁ (lem n m p'))) where lem : ∀ n m → n =ℕ m + 1 ≡ tt → suc m =ℕ n ≡ tt lem n m p' rewrite =ℕ-to-≡{n} p' | +comm m 1 = =ℕ-refl m 𝕃-to-braun-tree' : A → (l : 𝕃 A) → braun-tree' (suc (length l)) 𝕃-to-braun-tree' a [] = bt'-leaf a 𝕃-to-braun-tree' a (a' :: as) = bt'-insert a (𝕃-to-braun-tree' a' as)
{ "alphanum_fraction": 0.5363544814, "avg_line_length": 48.6764705882, "ext": "agda", "hexsha": "dfe66f556d425d1efaebc85a51135359670aff0c", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "braun-tree.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "braun-tree.agda", "max_line_length": 120, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "braun-tree.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 1949, "size": 4965 }
open import Silica open import HeapProperties import Context open TypeEnvContext open import Data.Nat open import Relation.Nullary using (¬_; Dec; yes; no) open import Data.Empty import Relation.Binary.PropositionalEquality as Eq data Preservation : Expr → Set where pres : ∀ {e e' : Expr} → ∀ {T T' : Type} → ∀ {Δ Δ'' Δ''' : StaticEnv} → ∀ {Σ Σ' : RuntimeEnv } → Δ ⊢ e ⦂ T ⊣ Δ'' → Σ & Δ ok -- TODO: hdref(e) → Σ , e ⟶ Σ' , e' → (Δ' : StaticEnv) → (Δ' ⊢ e' ⦂ T' ⊣ Δ''') → (Σ' & Δ' ok) -- → (Δ''' <* Δ'') ----------------- → Preservation e splitIdempotent : ∀ {Γ T₁ T₂ T₃} → Γ ⊢ T₁ ⇛ T₂ / T₃ → Γ ⊢ T₂ ⇛ T₂ / T₃ splitIdempotent {Γ} {.(base Void)} {.(base Void)} {.(base Void)} voidSplit = voidSplit splitIdempotent {Γ} {.(base Boolean)} {.(base Boolean)} {.(base Boolean)} booleanSplit = booleanSplit splitIdempotent {Γ} {.(contractType _)} {.(contractType _)} {.(contractType _)} (unownedSplit namesEq1 namesEq2 permsEq permUnowned) = unownedSplit refl (Eq.trans (Eq.sym namesEq1) namesEq2) refl permUnowned splitIdempotent {Γ} {.(contractType _)} {.(contractType _)} {.(contractType _)} (shared-shared-shared x) = shared-shared-shared x splitIdempotent {Γ} {.(contractType (tc _ Owned))} {.(contractType (tc _ Shared))} {.(contractType (tc _ Shared))} (owned-shared x) = shared-shared-shared refl splitIdempotent {Γ} {.(contractType (record { contractName = _ ; perm = S _ }))} {.(contractType (record { contractName = _ ; perm = Shared }))} {.(contractType (record { contractName = _ ; perm = Shared }))} (states-shared x) = shared-shared-shared refl preservation : ∀ {e e' : Expr} → {Γ : ContractEnv.ctx} → ∀ {T : Type} → ∀ {Δ Δ'' : StaticEnv} → ∀ {Σ Σ' : RuntimeEnv} → Δ ⊢ e ⦂ T ⊣ Δ'' → Σ & Δ ok → Σ , e ⟶ Σ' , e' ----------------------- → Preservation e -- Proof proceeds by induction on the dynamic semantics. preservation ty@(locTy {Γ} {Δ₀} l voidSplit) consis st@(SElookup {l = l} {v = voidVal} _ lookupL) = let Δ = (Δ₀ ,ₗ l ⦂ base Void) Δ' = Δ e'TypingJudgment = voidTy {Γ} {Δ = Δ'} in pres ty consis st Δ' e'TypingJudgment consis <*-refl preservation ty@(locTy {Γ} {Δ₀} l booleanSplit) consis st@(SElookup {l = l} {v = boolVal b} _ lookupL) = let Δ = (Δ₀ ,ₗ l ⦂ base Boolean) Δ' = Δ e'TypingJudgment = boolTy {Γ} {Δ = Δ'} b in pres {Δ = Δ} ty consis st Δ' e'TypingJudgment consis <*-refl -- The code duplication below is very sad, but I haven't figured out a way that doesn't require refactoring the split judgment to be two-level. preservation ty@(locTy {Γ} {Δ₀} {T₁ = contractType t₁} {T₂ = contractType t₂} {T₃ = contractType t₃} l spl@(unownedSplit _ _ _ _)) consis@(ok Δ voidLookup boolLookup objLookup refConsistencyFunc) st@(SElookup {Σ} {l = l} {v = objVal o} _ lookupL) = let spl' = splitIdempotent spl e'TypingJudgment = objTy {Γ} {Δ = Δ''} {T₁ = contractType t₂} {T₂ = contractType t₂} {T₃ = contractType t₃} o spl' consis' = ok {Σ} Δ' voidLookup' boolLookup' objLookup' refConsistency' in pres {_} {_} {_} {_} {Δ = Δ} {Δ'' = Δ''} {_} {_} {_} ty consis st Δ' e'TypingJudgment consis' <*-o-extension where splT = splitType spl Δ'' = Δ₀ ,ₗ l ⦂ (SplitType.t₃ splT) -- This is the result of checking e. Δ' = Δ'' ,ₒ o ⦂ (SplitType.t₂ splT) -- This is the typing context in which we need to typecheck e'. --Δ = Δ₀ ,ₗ l ⦂ (SplitType.t₁ splT) -- Show that if you look up l in the new context, you get the same type as before. voidLookup' : (∀ (l' : IndirectRef) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ base Void → (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ voidVal))) voidLookup' l' l'InΔ' with l' Data.Nat.≟ l voidLookup' l' (Context.S l'NeqL l'VoidType) | yes eq = ⊥-elim (l'NeqL eq) voidLookup' l' l'InΔ' | no nEq = voidLookup l' (S nEq (irrelevantReductionsOK l'InΔ' nEq)) boolLookup' : (∀ (l' : IndirectRef) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ base Boolean → ∃[ b ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ boolVal b))) boolLookup' l' l'InΔ' with l' Data.Nat.≟ l boolLookup' l' (Context.S l'NeqL l'BoolType) | yes eq = ⊥-elim (l'NeqL eq) boolLookup' l' l'InΔ' | no nEq = boolLookup l' (S nEq (irrelevantReductionsOK l'InΔ' nEq)) objLookup' : (l' : IndirectRef) → (T : Tc) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ (contractType T) → ∃[ o ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ objVal o × (o ObjectRefContext.∈dom (RuntimeEnv.μ Σ)))) objLookup' l' _ l'InΔ' with l' Data.Nat.≟ l objLookup' l' _ (Context.S l'NeqL l'ObjType) | yes eq = ⊥-elim (l'NeqL eq) objLookup' l' t l'InΔ'@(Z {a = contractType t₃}) | yes eq = objLookup l' t₁ Z objLookup' l' t l'InΔ' | no nEq = objLookup l' t (S nEq (irrelevantReductionsOK l'InΔ' nEq)) lookupUnique : objVal o ≡ objVal ( proj₁ (objLookup l t₁ Z)) lookupUnique = IndirectRefContext.contextLookupUnique {RuntimeEnv.ρ Σ} lookupL (proj₁ (proj₂ (objLookup l t₁ Z))) oLookupUnique = objValInjectiveContrapositive lookupUnique -- Show that all location-based aliases from the previous environment are compatible with the new alias. -- Note that Σ is unchanged, so we use Σ instead of defining a separate Σ'. refConsistency' : (o' : ObjectRef) → o' ObjectRefContext.∈dom (RuntimeEnv.μ Σ) → ReferenceConsistency Σ Δ' o' refConsistency' o' o'Inμ = let origRefConsistency = refConsistencyFunc o' o'Inμ origConnected = referencesConsistentImpliesConnectivity origRefConsistency newConnected = splitReplacementOK {Γ} {Σ} {Δ₀} {o} {o'} {l} {t₁} {t₂} {SplitType.t₁ splT} {SplitType.t₂ splT} {SplitType.t₃ splT} refl refl consis oLookupUnique (proj₁ origConnected) (proj₂ origConnected) spl in referencesConsistent {_} {_} {o'} newConnected preservation ty@(locTy {Γ} {Δ₀} {T₁ = contractType t₁} {T₂ = contractType t₂} {T₃ = contractType t₃} l spl@(shared-shared-shared _)) consis@(ok Δ voidLookup boolLookup objLookup refConsistencyFunc) st@(SElookup {Σ} {l = l} {v = objVal o} _ lookupL) = let spl' = splitIdempotent spl e'TypingJudgment = objTy {Γ} {Δ = Δ''} {T₁ = contractType t₂} {T₂ = contractType t₂} {T₃ = contractType t₃} o spl' consis' = ok {Σ} Δ' voidLookup' boolLookup' objLookup' refConsistency' in pres {_} {_} {_} {_} {Δ = Δ} {Δ'' = Δ''} {_} {_} {_} ty consis st Δ' e'TypingJudgment consis' <*-o-extension where splT = splitType spl Δ'' = Δ₀ ,ₗ l ⦂ (SplitType.t₃ splT) -- This is the result of checking e. Δ' = Δ'' ,ₒ o ⦂ (SplitType.t₂ splT) -- This is the typing context in which we need to typecheck e'. --Δ = Δ₀ ,ₗ l ⦂ (SplitType.t₁ splT) -- Show that if you look up l in the new context, you get the same type as before. voidLookup' : (∀ (l' : IndirectRef) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ base Void → (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ voidVal))) voidLookup' l' l'InΔ' with l' Data.Nat.≟ l voidLookup' l' (Context.S l'NeqL l'VoidType) | yes eq = ⊥-elim (l'NeqL eq) voidLookup' l' l'InΔ' | no nEq = voidLookup l' (S nEq (irrelevantReductionsOK l'InΔ' nEq)) boolLookup' : (∀ (l' : IndirectRef) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ base Boolean → ∃[ b ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ boolVal b))) boolLookup' l' l'InΔ' with l' Data.Nat.≟ l boolLookup' l' (Context.S l'NeqL l'BoolType) | yes eq = ⊥-elim (l'NeqL eq) boolLookup' l' l'InΔ' | no nEq = boolLookup l' (S nEq (irrelevantReductionsOK l'InΔ' nEq)) objLookup' : (l' : IndirectRef) → (T : Tc) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ (contractType T) → ∃[ o ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ objVal o × (o ObjectRefContext.∈dom (RuntimeEnv.μ Σ)))) objLookup' l' _ l'InΔ' with l' Data.Nat.≟ l objLookup' l' _ (Context.S l'NeqL l'ObjType) | yes eq = ⊥-elim (l'NeqL eq) objLookup' l' t l'InΔ'@(Z {a = contractType t₃}) | yes eq = objLookup l' t₁ Z objLookup' l' t l'InΔ' | no nEq = objLookup l' t (S nEq (irrelevantReductionsOK l'InΔ' nEq)) lookupUnique : objVal o ≡ objVal ( proj₁ (objLookup l t₁ Z)) lookupUnique = IndirectRefContext.contextLookupUnique {RuntimeEnv.ρ Σ} lookupL (proj₁ (proj₂ (objLookup l t₁ Z))) oLookupUnique = objValInjectiveContrapositive lookupUnique -- Show that all location-based aliases from the previous environment are compatible with the new alias. -- Note that Σ is unchanged, so we use Σ instead of defining a separate Σ'. refConsistency' : (o' : ObjectRef) → o' ObjectRefContext.∈dom (RuntimeEnv.μ Σ) → ReferenceConsistency Σ Δ' o' refConsistency' o' o'Inμ = let origRefConsistency = refConsistencyFunc o' o'Inμ origConnected = referencesConsistentImpliesConnectivity origRefConsistency newConnected = splitReplacementOK {Γ} {Σ} {Δ₀} {o} {o'} {l} {t₁} {t₂} {SplitType.t₁ splT} {SplitType.t₂ splT} {SplitType.t₃ splT} refl refl consis oLookupUnique (proj₁ origConnected) (proj₂ origConnected) spl in referencesConsistent {_} {_} {o'} newConnected preservation ty@(locTy {Γ} {Δ₀} {T₁ = contractType t₁} {T₂ = contractType t₂} {T₃ = contractType t₃} l spl@(owned-shared _)) consis@(ok Δ voidLookup boolLookup objLookup refConsistencyFunc) st@(SElookup {Σ} {l = l} {v = objVal o} _ lookupL) = let spl' = splitIdempotent spl e'TypingJudgment = objTy {Γ} {Δ = Δ''} {T₁ = contractType t₂} {T₂ = contractType t₂} {T₃ = contractType t₃} o spl' consis' = ok {Σ} Δ' voidLookup' boolLookup' objLookup' refConsistency' in pres {_} {_} {_} {_} {Δ = Δ} {Δ'' = Δ''} {_} {_} {_} ty consis st Δ' e'TypingJudgment consis' <*-o-extension where splT = splitType spl Δ'' = Δ₀ ,ₗ l ⦂ (SplitType.t₃ splT) -- This is the result of checking e. Δ' = Δ'' ,ₒ o ⦂ (SplitType.t₂ splT) -- This is the typing context in which we need to typecheck e'. --Δ = Δ₀ ,ₗ l ⦂ (SplitType.t₁ splT) -- Show that if you look up l in the new context, you get the same type as before. voidLookup' : (∀ (l' : IndirectRef) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ base Void → (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ voidVal))) voidLookup' l' l'InΔ' with l' Data.Nat.≟ l voidLookup' l' (Context.S l'NeqL l'VoidType) | yes eq = ⊥-elim (l'NeqL eq) voidLookup' l' l'InΔ' | no nEq = voidLookup l' (S nEq (irrelevantReductionsOK l'InΔ' nEq)) boolLookup' : (∀ (l' : IndirectRef) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ base Boolean → ∃[ b ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ boolVal b))) boolLookup' l' l'InΔ' with l' Data.Nat.≟ l boolLookup' l' (Context.S l'NeqL l'BoolType) | yes eq = ⊥-elim (l'NeqL eq) boolLookup' l' l'InΔ' | no nEq = boolLookup l' (S nEq (irrelevantReductionsOK l'InΔ' nEq)) objLookup' : (l' : IndirectRef) → (T : Tc) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ (contractType T) → ∃[ o ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ objVal o × (o ObjectRefContext.∈dom (RuntimeEnv.μ Σ)))) objLookup' l' _ l'InΔ' with l' Data.Nat.≟ l objLookup' l' _ (Context.S l'NeqL l'ObjType) | yes eq = ⊥-elim (l'NeqL eq) objLookup' l' t l'InΔ'@(Z {a = contractType t₃}) | yes eq = objLookup l' t₁ Z objLookup' l' t l'InΔ' | no nEq = objLookup l' t (S nEq (irrelevantReductionsOK l'InΔ' nEq)) lookupUnique : objVal o ≡ objVal ( proj₁ (objLookup l t₁ Z)) lookupUnique = IndirectRefContext.contextLookupUnique {RuntimeEnv.ρ Σ} lookupL (proj₁ (proj₂ (objLookup l t₁ Z))) oLookupUnique = objValInjectiveContrapositive lookupUnique -- Show that all location-based aliases from the previous environment are compatible with the new alias. -- Note that Σ is unchanged, so we use Σ instead of defining a separate Σ'. refConsistency' : (o' : ObjectRef) → o' ObjectRefContext.∈dom (RuntimeEnv.μ Σ) → ReferenceConsistency Σ Δ' o' refConsistency' o' o'Inμ = let origRefConsistency = refConsistencyFunc o' o'Inμ origConnected = referencesConsistentImpliesConnectivity origRefConsistency newConnected = splitReplacementOK {Γ} {Σ} {Δ₀} {o} {o'} {l} {t₁} {t₂} {SplitType.t₁ splT} {SplitType.t₂ splT} {SplitType.t₃ splT} refl refl consis oLookupUnique (proj₁ origConnected) (proj₂ origConnected) spl in referencesConsistent {_} {_} {o'} newConnected preservation ty@(locTy {Γ} {Δ₀} {T₁ = contractType t₁} {T₂ = contractType t₂} {T₃ = contractType t₃} l spl@(states-shared _)) consis@(ok Δ voidLookup boolLookup objLookup refConsistencyFunc) st@(SElookup {Σ} {l = l} {v = objVal o} _ lookupL) = let spl' = splitIdempotent spl e'TypingJudgment = objTy {Γ} {Δ = Δ''} {T₁ = contractType t₂} {T₂ = contractType t₂} {T₃ = contractType t₃} o spl' consis' = ok {Σ} Δ' voidLookup' boolLookup' objLookup' refConsistency' in pres {_} {_} {_} {_} {Δ = Δ} {Δ'' = Δ''} {_} {_} {_} ty consis st Δ' e'TypingJudgment consis' <*-o-extension where splT = splitType spl Δ'' = Δ₀ ,ₗ l ⦂ (SplitType.t₃ splT) -- This is the result of checking e. Δ' = Δ'' ,ₒ o ⦂ (SplitType.t₂ splT) -- This is the typing context in which we need to typecheck e'. --Δ = Δ₀ ,ₗ l ⦂ (SplitType.t₁ splT) -- Show that if you look up l in the new context, you get the same type as before. voidLookup' : (∀ (l' : IndirectRef) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ base Void → (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ voidVal))) voidLookup' l' l'InΔ' with l' Data.Nat.≟ l voidLookup' l' (Context.S l'NeqL l'VoidType) | yes eq = ⊥-elim (l'NeqL eq) voidLookup' l' l'InΔ' | no nEq = voidLookup l' (S nEq (irrelevantReductionsOK l'InΔ' nEq)) boolLookup' : (∀ (l' : IndirectRef) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ base Boolean → ∃[ b ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ boolVal b))) boolLookup' l' l'InΔ' with l' Data.Nat.≟ l boolLookup' l' (Context.S l'NeqL l'BoolType) | yes eq = ⊥-elim (l'NeqL eq) boolLookup' l' l'InΔ' | no nEq = boolLookup l' (S nEq (irrelevantReductionsOK l'InΔ' nEq)) objLookup' : (l' : IndirectRef) → (T : Tc) → ((StaticEnv.locEnv Δ') ∋ l' ⦂ (contractType T) → ∃[ o ] (RuntimeEnv.ρ Σ IndirectRefContext.∋ l' ⦂ objVal o × (o ObjectRefContext.∈dom (RuntimeEnv.μ Σ)))) objLookup' l' _ l'InΔ' with l' Data.Nat.≟ l objLookup' l' _ (Context.S l'NeqL l'ObjType) | yes eq = ⊥-elim (l'NeqL eq) objLookup' l' t l'InΔ'@(Z {a = contractType t₃}) | yes eq = objLookup l' t₁ Z objLookup' l' t l'InΔ' | no nEq = objLookup l' t (S nEq (irrelevantReductionsOK l'InΔ' nEq)) lookupUnique : objVal o ≡ objVal ( proj₁ (objLookup l t₁ Z)) lookupUnique = IndirectRefContext.contextLookupUnique {RuntimeEnv.ρ Σ} lookupL (proj₁ (proj₂ (objLookup l t₁ Z))) oLookupUnique = objValInjectiveContrapositive lookupUnique -- Show that all location-based aliases from the previous environment are compatible with the new alias. -- Note that Σ is unchanged, so we use Σ instead of defining a separate Σ'. refConsistency' : (o' : ObjectRef) → o' ObjectRefContext.∈dom (RuntimeEnv.μ Σ) → ReferenceConsistency Σ Δ' o' refConsistency' o' o'Inμ = let origRefConsistency = refConsistencyFunc o' o'Inμ origConnected = referencesConsistentImpliesConnectivity origRefConsistency newConnected = splitReplacementOK {Γ} {Σ} {Δ₀} {o} {o'} {l} {t₁} {t₂} {SplitType.t₁ splT} {SplitType.t₂ splT} {SplitType.t₃ splT} refl refl consis oLookupUnique (proj₁ origConnected) (proj₂ origConnected) spl in referencesConsistent {_} {_} {o'} newConnected preservation {T = contractType t₂} (locTy {Γ} {Δ₀} {contractType t₁} {.(contractType t₂)} {contractType t₃} l spl) (ok .(Δ₀ ,ₗ l ⦂ contractType t₁) voidLookup boolLookup objLookup refConsistencyFunc) (SElookup {Σ} {l = l} {boolVal b} _ lookupL) = -- The context says the location refers to a contract, but also a boolean value?? Inconsistent. ⊥-elim (lookupNeq lookupUnique) where objLookupResult = objLookup l t₁ Z o = proj₁ objLookupResult lHasObjType = proj₁ (proj₂ objLookupResult) lookupUnique = IndirectRefContext.contextLookupUnique lHasObjType lookupL lookupNeq : (objVal o) ≢ boolVal b lookupNeq () preservation {T = contractType t₂} (locTy {Γ} {Δ₀} {contractType t₁} {.(contractType t₂)} {contractType t₃} l spl) (ok .(Δ₀ ,ₗ l ⦂ contractType t₁) voidLookup boolLookup objLookup refConsistencyFunc) (SElookup {Σ} {l = l} {voidVal} _ lookupL) = -- The context says the location refers to a contract, but also a boolean value?? Inconsistent. ⊥-elim (lookupNeq lookupUnique) where objLookupResult = objLookup l t₁ Z o = proj₁ objLookupResult lHasObjType = proj₁ (proj₂ objLookupResult) lookupUnique = IndirectRefContext.contextLookupUnique lHasObjType lookupL lookupNeq : (objVal o) ≢ voidVal lookupNeq () preservation (locTy {Γ} {Δ₀} {.(base Void)} l voidSplit) (ok .(Δ₀ ,ₗ l ⦂ base Void) voidLookup boolLookup objLookup refConsistencyFunc) (SElookup {Σ} {Δ} {T = T} {l = l} {boolVal b} lookupLType lookupL) = ⊥-elim (lookupNeq lookupUnique) where lLookupResult = voidLookup l Z lookupUnique = IndirectRefContext.contextLookupUnique lLookupResult lookupL lookupNeq : voidVal ≢ boolVal b lookupNeq () preservation (locTy {Γ} {Δ₀} {.(base Void)} l voidSplit) (ok .(Δ₀ ,ₗ l ⦂ base Void) voidLookup boolLookup objLookup refConsistencyFunc) (SElookup {Σ} {Δ} {T = T} {l = l} {objVal o} lookupLType lookupL) = ⊥-elim (lookupNeq lookupUnique) where lLookupResult = voidLookup l Z lookupUnique = IndirectRefContext.contextLookupUnique lLookupResult lookupL lookupNeq : voidVal ≢ objVal o lookupNeq () preservation (locTy {Γ} {Δ₀} {.(base Boolean)} l booleanSplit) (ok .(Δ₀ ,ₗ l ⦂ base Boolean) voidLookup boolLookup objLookup refConsistencyFunc) (SElookup {Σ} {Δ} {T = T} {l = l} {voidVal} lookupLType lookupL) = ⊥-elim (lookupNeq lookupUnique) where lLookupResult = boolLookup l Z lookupUnique = IndirectRefContext.contextLookupUnique (proj₂ lLookupResult) lookupL lookupNeq : boolVal (proj₁ lLookupResult) ≢ voidVal lookupNeq () preservation (locTy {Γ} {Δ₀} {.(base Boolean)} l booleanSplit) (ok .(Δ₀ ,ₗ l ⦂ base Boolean) voidLookup boolLookup objLookup refConsistencyFunc) (SElookup {Σ} {Δ} {T = T} {l = l} {objVal o} lookupLType lookupL) = ⊥-elim (lookupNeq lookupUnique) where lLookupResult = boolLookup l Z lookupUnique = IndirectRefContext.contextLookupUnique (proj₂ lLookupResult) lookupL lookupNeq : boolVal (proj₁ lLookupResult) ≢ objVal o lookupNeq () preservation {Γ = Γ} {Δ = Δ} {Δ'' = Δ''} ty@(assertTyₓ _ _) consis st@(SEassertₓ x s) = pres ty consis st Δ (voidTy {Γ = Γ} {Δ = Δ}) consis <*-refl preservation {Γ = Γ} {Δ = Δ} {Δ'' = Δ''} ty@(assertTyₗ _ _) consis st@(SEassertₗ x s) = pres ty consis st Δ (voidTy {Γ = Γ} {Δ = Δ}) consis <*-refl preservation {Γ = Γ} {Δ = Δ} {Δ'' = Δ''} ty@(newTy {C = C} {st = st} stOK ty₁ ty₂ CInΓ refl) consis step@(SEnew {Σ} {o = o} oFresh refl refl) = pres ty consis step Δ' newTypeJudgment {!!} {!!} where T = contractType (tc C (S [ st ]) ) Δ' = Δ ,ₒ o ⦂ T spl = unownedSplit {Γ} refl refl refl refl newTypeJudgment = objTy o spl
{ "alphanum_fraction": 0.6150401102, "avg_line_length": 53.753968254, "ext": "agda", "hexsha": "d5d422567d6953b3cd9081cbe981d5a4cabc5efd", "lang": "Agda", "max_forks_count": 11, "max_forks_repo_forks_event_max_datetime": "2021-06-09T18:40:19.000Z", "max_forks_repo_forks_event_min_datetime": "2018-05-24T08:20:52.000Z", "max_forks_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "ivoysey/Obsidian", "max_forks_repo_path": "formalization/preservation.agda", "max_issues_count": 259, "max_issues_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6", "max_issues_repo_issues_event_max_datetime": "2022-03-29T18:20:05.000Z", "max_issues_repo_issues_event_min_datetime": "2017-08-18T19:50:41.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "ivoysey/Obsidian", "max_issues_repo_path": "formalization/preservation.agda", "max_line_length": 143, "max_stars_count": 79, "max_stars_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "ivoysey/Obsidian", "max_stars_repo_path": "formalization/preservation.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-27T10:34:28.000Z", "max_stars_repo_stars_event_min_datetime": "2017-08-19T16:24:10.000Z", "num_tokens": 7056, "size": 20319 }
{- Set quotients: -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.SetQuotients.Properties where open import Cubical.HITs.SetQuotients.Base open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.Univalence open import Cubical.Data.Sigma open import Cubical.Relation.Nullary open import Cubical.Relation.Binary.Base open import Cubical.HITs.PropositionalTruncation as PropTrunc using (∥_∥; ∣_∣; squash) open import Cubical.HITs.SetTruncation as SetTrunc using (∥_∥₂; ∣_∣₂; squash₂) -- Type quotients private variable ℓ : Level A : Type ℓ R : A → A → Type ℓ B : A / R → Type ℓ C : A / R → A / R → Type ℓ D : A / R → A / R → A / R → Type ℓ elimEq/ : (Bprop : (x : A / R ) → isProp (B x)) {x y : A / R} (eq : x ≡ y) (bx : B x) (by : B y) → PathP (λ i → B (eq i)) bx by elimEq/ {B = B} Bprop {x = x} = J (λ y eq → ∀ bx by → PathP (λ i → B (eq i)) bx by) (λ bx by → Bprop x bx by) elimProp : ((x : A / R ) → isProp (B x)) → ((a : A) → B ( [ a ])) → (x : A / R) → B x elimProp Bprop f [ x ] = f x elimProp Bprop f (squash/ x y p q i j) = isOfHLevel→isOfHLevelDep 2 (λ x → isProp→isSet (Bprop x)) (g x) (g y) (cong g p) (cong g q) (squash/ x y p q) i j where g = elimProp Bprop f elimProp Bprop f (eq/ a b r i) = elimEq/ Bprop (eq/ a b r) (f a) (f b) i elimProp2 : ((x y : A / R ) → isProp (C x y)) → ((a b : A) → C [ a ] [ b ]) → (x y : A / R) → C x y elimProp2 Cprop f = elimProp (λ x → isPropΠ (λ y → Cprop x y)) (λ x → elimProp (λ y → Cprop [ x ] y) (f x)) elimProp3 : ((x y z : A / R ) → isProp (D x y z)) → ((a b c : A) → D [ a ] [ b ] [ c ]) → (x y z : A / R) → D x y z elimProp3 Dprop f = elimProp (λ x → isPropΠ2 (λ y z → Dprop x y z)) (λ x → elimProp2 (λ y z → Dprop [ x ] y z) (f x)) -- lemma 6.10.2 in hott book []surjective : (x : A / R) → ∃[ a ∈ A ] [ a ] ≡ x []surjective = elimProp (λ x → squash) (λ a → ∣ a , refl ∣) elim : {B : A / R → Type ℓ} → ((x : A / R) → isSet (B x)) → (f : (a : A) → (B [ a ])) → ((a b : A) (r : R a b) → PathP (λ i → B (eq/ a b r i)) (f a) (f b)) → (x : A / R) → B x elim Bset f feq [ a ] = f a elim Bset f feq (eq/ a b r i) = feq a b r i elim Bset f feq (squash/ x y p q i j) = isOfHLevel→isOfHLevelDep 2 Bset (g x) (g y) (cong g p) (cong g q) (squash/ x y p q) i j where g = elim Bset f feq rec : {B : Type ℓ} (Bset : isSet B) (f : A → B) (feq : (a b : A) (r : R a b) → f a ≡ f b) → A / R → B rec Bset f feq [ a ] = f a rec Bset f feq (eq/ a b r i) = feq a b r i rec Bset f feq (squash/ x y p q i j) = Bset (g x) (g y) (cong g p) (cong g q) i j where g = rec Bset f feq rec2 : {B : Type ℓ} (Bset : isSet B) (f : A → A → B) (feql : (a b c : A) (r : R a b) → f a c ≡ f b c) (feqr : (a b c : A) (r : R b c) → f a b ≡ f a c) → A / R → A / R → B rec2 Bset f feql feqr = rec (isSetΠ (λ _ → Bset)) (λ a → rec Bset (f a) (feqr a)) (λ a b r → funExt (elimProp (λ _ → Bset _ _) (λ c → feql a b c r))) setQuotUniversal : {B : Type ℓ} (Bset : isSet B) → (A / R → B) ≃ (Σ[ f ∈ (A → B) ] ((a b : A) → R a b → f a ≡ f b)) setQuotUniversal Bset = isoToEquiv (iso intro out outRightInv outLeftInv) where intro = λ g → (λ a → g [ a ]) , λ a b r i → g (eq/ a b r i) out = λ h → elim (λ x → Bset) (fst h) (snd h) outRightInv : ∀ h → intro (out h) ≡ h outRightInv h = refl outLeftInv : ∀ g → out (intro g) ≡ g outLeftInv = λ g → funExt (λ x → PropTrunc.elim {P = λ sur → out (intro g) x ≡ g x} (λ sur → Bset (out (intro g) x) (g x)) (λ sur → cong (out (intro g)) (sym (snd sur)) ∙ (cong g (snd sur))) ([]surjective x) ) open BinaryRelation effective : (Rprop : isPropValued R) (Requiv : isEquivRel R) (a b : A) → [ a ] ≡ [ b ] → R a b effective {A = A} {R = R} Rprop (equivRel R/refl R/sym R/trans) a b p = transport aa≡ab (R/refl _) where helper : A / R → hProp _ helper = rec isSetHProp (λ c → (R a c , Rprop a c)) (λ c d cd → Σ≡Prop (λ _ → isPropIsProp) (hPropExt (Rprop a c) (Rprop a d) (λ ac → R/trans _ _ _ ac cd) (λ ad → R/trans _ _ _ ad (R/sym _ _ cd)))) aa≡ab : R a a ≡ R a b aa≡ab i = helper (p i) .fst isEquivRel→isEffective : isPropValued R → isEquivRel R → isEffective R isEquivRel→isEffective {R = R} Rprop Req a b = isoToIsEquiv (iso out intro out-intro intro-out) where intro : [ a ] ≡ [ b ] → R a b intro = effective Rprop Req a b out : R a b → [ a ] ≡ [ b ] out = eq/ a b intro-out : ∀ x → intro (out x) ≡ x intro-out ab = Rprop a b _ _ out-intro : ∀ x → out (intro x) ≡ x out-intro eq = squash/ _ _ _ _ discreteSetQuotients : Discrete A → isPropValued R → isEquivRel R → (∀ a₀ a₁ → Dec (R a₀ a₁)) → Discrete (A / R) discreteSetQuotients {A = A} {R = R} Adis Rprop Req Rdec = elim (λ a₀ → isSetΠ (λ a₁ → isProp→isSet (isPropDec (squash/ a₀ a₁)))) discreteSetQuotients' discreteSetQuotients'-eq where discreteSetQuotients' : (a : A) (y : A / R) → Dec ([ a ] ≡ y) discreteSetQuotients' a₀ = elim (λ a₁ → isProp→isSet (isPropDec (squash/ [ a₀ ] a₁))) dis dis-eq where dis : (a₁ : A) → Dec ([ a₀ ] ≡ [ a₁ ]) dis a₁ with Rdec a₀ a₁ ... | (yes p) = yes (eq/ a₀ a₁ p) ... | (no ¬p) = no λ eq → ¬p (effective Rprop Req a₀ a₁ eq ) dis-eq : (a b : A) (r : R a b) → PathP (λ i → Dec ([ a₀ ] ≡ eq/ a b r i)) (dis a) (dis b) dis-eq a b ab = J (λ b ab → ∀ k → PathP (λ i → Dec ([ a₀ ] ≡ ab i)) (dis a) k) (λ k → isPropDec (squash/ _ _) _ _) (eq/ a b ab) (dis b) discreteSetQuotients'-eq : (a b : A) (r : R a b) → PathP (λ i → (y : A / R) → Dec (eq/ a b r i ≡ y)) (discreteSetQuotients' a) (discreteSetQuotients' b) discreteSetQuotients'-eq a b ab = J (λ b ab → ∀ k → PathP (λ i → (y : A / R) → Dec (ab i ≡ y)) (discreteSetQuotients' a) k) (λ k → funExt (λ x → isPropDec (squash/ _ _) _ _)) (eq/ a b ab) (discreteSetQuotients' b)
{ "alphanum_fraction": 0.5014236475, "avg_line_length": 36.2663043478, "ext": "agda", "hexsha": "910419a4e30788bd39724f729d2d491e2db35524", "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": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ayberkt/cubical", "max_forks_repo_path": "Cubical/HITs/SetQuotients/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ayberkt/cubical", "max_issues_repo_path": "Cubical/HITs/SetQuotients/Properties.agda", "max_line_length": 121, "max_stars_count": null, "max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ayberkt/cubical", "max_stars_repo_path": "Cubical/HITs/SetQuotients/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2623, "size": 6673 }
{-# OPTIONS --sized-types #-} open import Common.Size data Heap : (i j : Size) → Set where node : (i j : Size) → Heap (↑ i) (↑ j) postulate _∪_ : Heap ∞ ∞ → Heap ∞ ∞ → Heap ∞ ∞ mkH : ∀ i j → Heap i j merge : (i j : Size) → Heap i j → Heap ∞ ∞ merge .(↑ i) .(↑ j) (node i j) with Set merge .(↑ i) .(↑ j) (node i j) | _ = merge i (↑ j) (mkH i (↑ j)) ∪ merge (↑ i) j (mkH (↑ i) j)
{ "alphanum_fraction": 0.4795918367, "avg_line_length": 23.0588235294, "ext": "agda", "hexsha": "8a138a488f6f777917454b5873db286af664fd01", "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/Issue59b.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/Issue59b.agda", "max_line_length": 42, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue59b.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": 174, "size": 392 }
postulate A : Set module _ {{a : A}} (f : A → A) where g : {{a : A}} → A g {{a}} = a t : A t = g
{ "alphanum_fraction": 0.3796296296, "avg_line_length": 10.8, "ext": "agda", "hexsha": "d4292e4a537ce889fa125ba98bc59b57ad8c3ca0", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/InstanceSearchExplicitArgumentNoLooping.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/InstanceSearchExplicitArgumentNoLooping.agda", "max_line_length": 36, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/InstanceSearchExplicitArgumentNoLooping.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": 51, "size": 108 }
{-# OPTIONS --cubical --no-import-sorts #-} module Module where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Structures.Ring open import Cubical.Structures.Group open import Cubical.Structures.AbGroup open import NumberBundles2 record IsLeftRModule {ℓ ℓᴿ : Level} {R : Type ℓᴿ} ( 1ᴿ : R) (_+ᴿ_ _·ᴿ_ : R → R → R) {X : Type ℓ} (0ᴹ : X) (_+ᴹ_ : X → X → X) (_·ᴹ_ : R → X → X) (-ᴹ_ : X → X) : Type (ℓ-max ℓ ℓᴿ) where field isAbGroupᴹ : IsAbGroup 0ᴹ _+ᴹ_ -ᴹ_ ·ᴹ-dist-+ᴹ : ∀ r x y → r ·ᴹ (x +ᴹ y) ≡ (r ·ᴹ x) +ᴹ (r ·ᴹ y) ·ᴹ-dist-+ᴿ : ∀ r s x → (r +ᴿ s) ·ᴹ x ≡ (r ·ᴹ x) +ᴹ (s ·ᴹ x) ·ᴹ-assoc-·ᴿ : ∀ r s x → (r ·ᴿ s) ·ᴹ x ≡ r ·ᴹ (s ·ᴹ x) ·ᴹ-identity : ∀ x → 1ᴿ ·ᴹ x ≡ x open IsAbGroup isAbGroupᴹ renaming ( _-_ to _-ᴹ_ ; assoc to +ᴹ-assoc ; identity to +ᴹ-identity ; lid to +ᴹ-lid ; rid to +ᴹ-rid ; inverse to +ᴹ-inv ; invl to +ᴹ-linv ; invr to +ᴹ-rinv ; comm to +ᴹ-comm ; isSemigroup to +ᴹ-isSemigroup ; isMonoid to +ᴹ-isMonoid ; isGroup to +ᴹ-isGroup ) public ApartnessRingWithAbs = Ring -- TODO define `ApartnessRingWithAbs` record LeftRModule {ℓ ℓᴿ : Level} (ring : ApartnessRingWithAbs {ℓᴿ}) : Type (ℓ-suc (ℓ-max ℓ ℓᴿ)) where open Ring ring renaming ( Carrier to Carrierᴿ ; 0r to 0ᴿ ; 1r to 1ᴿ ; _+_ to _+ᴿ_ ; _·_ to _·ᴿ_ ; -_ to -ᴿ_ ; is-set to is-setᴿ ; +-assoc to +ᴿ-assoc ; +-identity to +ᴿ-identity ; +-lid to +ᴿ-lid ; +-rid to +ᴿ-rid ; +-inv to +ᴿ-inv ; +-linv to +ᴿ-linv ; +-rinv to +ᴿ-rinv ; +-comm to +ᴿ-comm ; +-isSemigroup to +ᴿ-isSemigroup ; +-isMonoid to +ᴿ-isMonoid ; +-isGroup to +ᴿ-isGroup ; ·-assoc to ·ᴿ-assoc ; ·-identity to ·ᴿ-identity ; ·-lid to ·ᴿ-lid ; ·-rid to ·ᴿ-rid ; ·-isSemigroup to ·ᴿ-isSemigroup ; ·-rdist-+ to ·ᴿ-rdist-+ᴿ ; ·-ldist-+ to ·ᴿ-ldist-+ᴿ ) public field Carrier : Type ℓ 0ᴹ : Carrier _+ᴹ_ : Carrier → Carrier → Carrier _·ᴹ_ : Carrierᴿ → Carrier → Carrier -ᴹ_ : Carrier → Carrier isLeftRModule : IsLeftRModule 1ᴿ _+ᴿ_ _·ᴿ_ 0ᴹ _+ᴹ_ _·ᴹ_ -ᴹ_ open IsLeftRModule isLeftRModule public infix 8 -ᴹ_ infixl 7 _·ᴹ_ infixl 6 _+ᴹ_ record LeftKModule {ℓ ℓᴷ : Level} (ffield : CompleteApartnessFieldWithAbs {ℓᴷ}) : Type (ℓ-suc (ℓ-max ℓ ℓᴷ)) where open CompleteApartnessFieldWithAbs ffield renaming ( Carrier to Carrierᴷ ; 0f to 0ᴷ ; 1f to 1ᴷ ; _+_ to _+ᴷ_ ; _·_ to _·ᴷ_ ; -_ to -ᴷ_ ) public field Carrier : Type ℓ 0ᴹ : Carrier _+ᴹ_ : Carrier → Carrier → Carrier _·ᴹ_ : Carrierᴷ → Carrier → Carrier -ᴹ_ : Carrier → Carrier isLeftRModule : IsLeftRModule 1ᴷ _+ᴷ_ _·ᴷ_ 0ᴹ _+ᴹ_ _·ᴹ_ -ᴹ_
{ "alphanum_fraction": 0.5246313147, "avg_line_length": 32.1919191919, "ext": "agda", "hexsha": "f29b258af254cce87a3b2a25011bcc07a0d8e9a5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/Module.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/Module.agda", "max_line_length": 113, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/Module.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 1458, "size": 3187 }
{-# OPTIONS --cubical --safe #-} module Data.Tuple.UniverseMonomorphic where open import Prelude open import Data.Fin Tuple : ∀ n → (Fin n → Type) → Type Tuple zero f = ⊤ Tuple (suc n) f = f f0 × Tuple n (f ∘ fs) private variable n : ℕ U : Fin n → Type ind : Tuple n U → (i : Fin n) → U i ind {n = suc n} (x , xs) f0 = x ind {n = suc n} (x , xs) (fs i) = ind xs i tab : ((i : Fin n) → U i) → Tuple n U tab {n = zero} f = tt tab {n = suc n} f = f f0 , tab (f ∘ fs) Π→Tuple→Π : ∀ {n} {U : Fin n → Type} (xs : (i : Fin n) → U i) i → ind (tab xs) i ≡ xs i Π→Tuple→Π {n = suc n} f f0 = refl Π→Tuple→Π {n = suc n} f (fs i) = Π→Tuple→Π (f ∘ fs) i Tuple→Π→Tuple : ∀ {n} {U : Fin n → Type} (xs : Tuple n U) → tab (ind xs) ≡ xs Tuple→Π→Tuple {n = zero} tt = refl Tuple→Π→Tuple {n = suc n} (x , xs) i .fst = x Tuple→Π→Tuple {n = suc n} (x , xs) i .snd = Tuple→Π→Tuple xs i Tuple⇔ΠFin : Tuple n U ⇔ ((i : Fin n) → U i) Tuple⇔ΠFin .fun = ind Tuple⇔ΠFin .inv = tab Tuple⇔ΠFin .leftInv = Tuple→Π→Tuple Tuple⇔ΠFin .rightInv x = funExt (Π→Tuple→Π x)
{ "alphanum_fraction": 0.549905838, "avg_line_length": 27.2307692308, "ext": "agda", "hexsha": "33aa4defd479e5862e2a2b3d7603c4e5bcb6cbb8", "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/Tuple/UniverseMonomorphic.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/Tuple/UniverseMonomorphic.agda", "max_line_length": 87, "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/Tuple/UniverseMonomorphic.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": 485, "size": 1062 }
{- This file contains cospans, cones, pullbacks and maps of cones in precategories. -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Pullback where open import Cubical.Foundations.Prelude open import Cubical.Data.Sigma open import Cubical.Categories.Category private variable ℓ ℓ' : Level record Cospan (𝒞 : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where constructor cospan field S₁ S₂ vertex : Precategory.ob 𝒞 s₁ : hom 𝒞 S₁ vertex s₂ : hom 𝒞 S₂ vertex record Cone {𝒞 : Precategory ℓ ℓ'} (cspn : Cospan 𝒞) (c : ob 𝒞) : Type (ℓ-max ℓ ℓ') where constructor cone field p₁ : hom 𝒞 c (Cospan.S₁ cspn) p₂ : hom 𝒞 c (Cospan.S₂ cspn) sq : seq 𝒞 p₁ (Cospan.s₁ cspn) ≡ seq 𝒞 p₂ (Cospan.s₂ cspn) record Pullback {𝒞 : Precategory ℓ ℓ'} (cspn : Cospan 𝒞) : Type (ℓ-max ℓ ℓ') where constructor pullback field c : ob 𝒞 cn : Cone cspn c universal : {c' : ob 𝒞} (cn' : Cone cspn c') → ∃![ f ∈ 𝒞 .hom c' c ] Σ[ q ∈ Cone.p₁ cn' ≡ 𝒞 .seq f (Cone.p₁ cn) ] (Cone.p₂ cn' ≡ 𝒞 .seq f (Cone.p₂ cn)) -- whisker the parallel morphisms g and g' with f lPrecatWhisker : {𝒞 : Precategory ℓ ℓ'} {x y z : 𝒞 .ob} (f : 𝒞 .hom x y) (g g' : 𝒞 .hom y z) (p : g ≡ g') → 𝒞 .seq f g ≡ 𝒞 .seq f g' lPrecatWhisker {𝒞 = 𝒞} f _ _ p = cong (𝒞 .seq f) p -- extend a cone on c by a morphism c'→c using precomposition coneMap : {𝒞 : Precategory ℓ ℓ'} {cspn : Cospan 𝒞} {c c' : ob 𝒞} (cn : Cone cspn c) (f : hom 𝒞 c' c) → Cone cspn c' coneMap {𝒞 = 𝒞} {cospan _ _ _ s₁ s₂} (cone p₁ p₂ sq) f = cone (𝒞 .seq f p₁) (𝒞 .seq f p₂) ((𝒞 .seq-α f p₁ s₁) ∙∙ lPrecatWhisker {𝒞 = 𝒞} f (𝒞 .seq p₁ s₁) (𝒞 .seq p₂ s₂) sq ∙∙ sym (𝒞 .seq-α f p₂ s₂))
{ "alphanum_fraction": 0.6158427635, "avg_line_length": 37.3111111111, "ext": "agda", "hexsha": "242e742d04158ee1ff58d72809012be1f6525ba8", "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": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/Categories/Pullback.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "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": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/Categories/Pullback.agda", "max_line_length": 155, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/Categories/Pullback.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 769, "size": 1679 }
module Common.Semantics where open import Common.Context public -- Special products for glueing. infix 5 _⅋_ record Glue (Syn : Set) (Sem : Set) : Set where constructor _⅋_ field syn : Syn sem : Sem open Glue public -- Contexts as concrete worlds. module ConcreteWorlds (U : Set) where record World : Set where constructor wrap field Γ : Cx U unwrap : World → Cx U unwrap (wrap Γ) = Γ data _≤_ : World → World → Set where wrap : ∀ {Γ Γ′} → Γ ⊆ Γ′ → wrap Γ ≤ wrap Γ′ unwrap≤ : ∀ {Γ Γ′} → wrap Γ ≤ wrap Γ′ → Γ ⊆ Γ′ unwrap≤ (wrap η) = η refl≤ : ∀ {w} → w ≤ w refl≤ = wrap refl⊆ trans≤ : ∀ {w w′ w″} → w ≤ w′ → w′ ≤ w″ → w ≤ w″ trans≤ (wrap η) (wrap η′) = wrap (trans⊆ η η′) weak≤ : ∀ {A w} → w ≤ wrap (unwrap w , A) weak≤ = wrap weak⊆
{ "alphanum_fraction": 0.56, "avg_line_length": 18.6046511628, "ext": "agda", "hexsha": "3665ef34e52261fc1baf71b6d975baa479ca7441", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "Common/Semantics.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "Common/Semantics.agda", "max_line_length": 50, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "Common/Semantics.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 317, "size": 800 }
data ℕ : Set where zero : ℕ succ : ℕ → ℕ data D : Set foo : ℕ → ℕ foo n = n data D where lam : (D → D) → D
{ "alphanum_fraction": 0.5, "avg_line_length": 9.6666666667, "ext": "agda", "hexsha": "feceaceefa2ffbdaed2595034feec19b81782558", "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/Issue1614b.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/Issue1614b.agda", "max_line_length": 19, "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/Issue1614b.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": 49, "size": 116 }
module SystemF.BigStep.Intrinsic where open import Prelude hiding (⊥) open import SystemF.BigStep.Types open import Data.List hiding ([_]) open import Data.List.Any.Membership open import Data.List.Any hiding (map) open import Data.Fin.Substitution -- intrinsically typed syntax for System F infix 100 _[_] data Term {n}(Γ : Ctx n) : Type n → Set where unit : Term Γ Unit ƛ : ∀ {b} (a : Type n) → Term (Γ +tm a) b → Term Γ (a ⇒ b) Λ : ∀ {a} → Term (Γ +ty) a → Term Γ (∀' a) _·_ : ∀ {a b} → Term Γ (a ⇒ b) → Term Γ a → Term Γ b _[_] : ∀ {a} → Term Γ (∀' a) → ∀ b → Term Γ (a / sub b) var : ∀ {a} → Var Γ a → Term Γ a _tm/_ : ∀ {n m}{Γ : Ctx n}{a} → Term Γ a → (ρ : Sub Type n m) → Term (Γ ctx/ ρ) (a / ρ) unit tm/ ρ = unit ƛ a t tm/ ρ = ƛ (a / ρ) (t tm/ ρ) Λ t tm/ ρ = Λ (subst (λ Γ → Term Γ _) (sym $ CtxLemmas.ctx/-wk-comm _ ρ) (t tm/ (ρ ↑))) (f · e) tm/ ρ = (f tm/ ρ) · (e tm/ ρ) (_[_] {a = a} t b) tm/ ρ = subst (λ a → Term _ a) (sym $ Lemmas.sub-commutes a) ((t tm/ ρ) [ b / ρ ]) var x tm/ ρ = var (Inverse.to map-∈↔ ⟨$⟩ (, (x , refl))) where open import Function.Equality open import Function.Inverse module Semantics where Env : ∀ {n} → Ctx n → Set data Val {n} : Type n → Set where unit : Val {n} Unit clos : ∀ {a b Γ} → Env Γ → Term (Γ +tm a) b → Val (a ⇒ b) tclos : ∀ {a Γ} → Env Γ → Term (Γ +ty) a → Val (∀' a) open import Data.List open import Data.List.All as All hiding (map) Env Γ = All Val Γ open import Category.Monad.Partiality open import Coinduction private open Workaround _⊢_⇓P : ∀ {n}{Γ : Ctx n}{a} → Env Γ → Term Γ a → (Val a) ⊥P C ⊢ unit ⇓P = now unit C ⊢ ƛ a t ⇓P = now (clos C t) C ⊢ Λ t ⇓P = now (tclos C t) C ⊢ t [ ty ] ⇓P = (C ⊢ t ⇓P >>= λ{ -- We have to substitute a type into the body here -- and proof that weakening + substitution disappears on the context. -- The context lemma is computationally irrelevant, but the -- type-in-term substitution is not as trivially irrelevant (tclos C' b) → later (♯ ( (subst Env (sym $ CtxLemmas.ctx/-wk-sub≡id _ ty) C') ⊢ b tm/ sub ty ⇓P )) }) C ⊢ f · e ⇓P = (C ⊢ f ⇓P) >>= λ{ (clos C' fb) → (C ⊢ e ⇓P) >>= λ v → later (♯ ((v ∷ C') ⊢ fb ⇓P)) } C ⊢ var x ⇓P = now (lookup C x) -- definitional interpreter in the partiality monad _⊢_⇓ : ∀ {n}{Γ : Ctx n}{a} → Env Γ → Term Γ a → (Val a) ⊥ C ⊢ t ⇓ = ⟦ C ⊢ t ⇓P ⟧P module Example where open import Data.Fin renaming (zero to z; suc to s) open import Data.List hiding ([_]) open import Data.List.Any open import Data.List.All open import Category.Monad.Partiality open Semantics id' : Term {0} [] (∀' (ν zero ⇒ ν zero)) id' = Λ (ƛ (ν z) (var (here refl))) test = run ([] ⊢ ((id' [ Unit ]) · unit) ⇓) for 10 steps
{ "alphanum_fraction": 0.5475017593, "avg_line_length": 31.5777777778, "ext": "agda", "hexsha": "526f03ace6b04f3aa9a2da4be711584f6acea275", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/SystemF/BigStep/Intrinsic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/SystemF/BigStep/Intrinsic.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/SystemF/BigStep/Intrinsic.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1110, "size": 2842 }
-- Andreas, 2019-08-18, issue #1346 -- Allow fixity in renaming directive, but not for modules. module _ where open import Agda.Builtin.Equality using () renaming (module _≡_ to infix 4 _~_) -- Expected warning: -- Modules do not have fixity -- when scope checking the declaration -- open import Agda.Builtin.Equality -- using () -- renaming (module _≡_ to infix 4 _~_)
{ "alphanum_fraction": 0.6976744186, "avg_line_length": 22.7647058824, "ext": "agda", "hexsha": "8ff06142878171d34d63ce3428246e5b51200c37", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue1346ModuleFixity.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue1346ModuleFixity.agda", "max_line_length": 59, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue1346ModuleFixity.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": 109, "size": 387 }
{- Copyright 2019 Lisandra Silva Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -} open import Prelude module StateMachineModel where ----------------------------------------------------------------------------- -- State Machine ----------------------------------------------------------------------------- record StateMachine (State : Set) (Event : Set) : Set₁ where field initial : Pred State 0ℓ enabled : Event → State → Set action : ∀ {preState} {event} → enabled event preState → State open StateMachine data Reachable {State Event} {sm : StateMachine State Event} : State → Set where init : ∀ {s₀} → initial sm s₀ → Reachable s₀ step : ∀ {st event} → Reachable {sm = sm} st → (enEv : enabled sm event st) → Reachable (action sm enEv) Invariant : ∀ {State Event} (sm : StateMachine State Event) (P : Pred State 0ℓ) → Set Invariant sm P = ∀ {state} (rs : Reachable {sm = sm} state) → P state Stable : ∀ {State Event} (sm : StateMachine State Event) (P : Pred State 0ℓ) → Set Stable sm P = ∀ {st ev} (enEv : enabled sm ev st) → P st → P (action sm enEv) EventSet : ∀ {Event : Set} → Set₁ EventSet {Event} = Pred Event 0ℓ record System State Event : Set₁ where field stateMachine : StateMachine State Event weakFairness : Pred (EventSet {Event}) 0ℓ open System enabledSet : ∀ {State Event} → StateMachine State Event → EventSet {Event} → State → Set enabledSet sm evSet state = ∃[ event ] (event ∈ evSet × enabled sm event state) module LeadsTo (State : Set) (Event : Set) (sys : System State Event) where ----------------------------------------------------------------------------- -- HOARE Triple ----------------------------------------------------------------------------- data [_]_[_] (P : Pred State 0ℓ) (event : Event) (Q : Pred State 0ℓ) : Set where hoare : (∀ {st} → P st → (enEv : enabled (stateMachine sys) event st) → Q (action (stateMachine sys) enEv )) → [ P ] event [ Q ] Z : Set Z = ℕ -- Auxiliary properties with syntax renaming for better compliance with paper -- TODO : Try to make this more generic ⋃₁ : ∀ {ℓ ℓ'} {A : Set ℓ'} → (A → Pred State ℓ) → Pred State (ℓ ⊔ ℓ') ⋃₁ {A = A} P = λ x → Σ[ i ∈ A ] P i x syntax ⋃₁ (λ i → P) = [∃ i ∶ P ] ⋃₂ : ∀ {ℓ₁ ℓ₂ ℓ'} {A : Set ℓ'} → (C : Pred A ℓ₁) → (F : A → Pred State ℓ₂) → Pred State _ ⋃₂ {A = A} C F = λ s → Σ[ i ∈ A ] ( C i × F i s ) syntax ⋃₂ C (λ x → P) = [∃ x ⇒ C ∶ P ] ----------------------------------------------------------------------------- -- PROOF RULES for liveness ----------------------------------------------------------------------------- infix 1 _l-t_ data _l-t_ (P : Pred State 0ℓ) (Q : Pred State 0ℓ) : Set₁ where viaEvSet : (evSet : EventSet) → (weakFairness sys evSet) → (∀ (e : Event) → e ∈ evSet → [ P ] e [ Q ]) → (∀ (e : Event) → ¬ (e ∈ evSet) → [ P ] e [ P ∪ Q ]) → Invariant (stateMachine sys) (P ⇒ enabledSet (stateMachine sys) evSet) → P l-t Q viaInv : Invariant (stateMachine sys) (P ⇒ Q) → P l-t Q viaTrans : ∀ {R} → P l-t R → R l-t Q → P l-t Q viaTrans2 : ∀ {R} → P l-t (Q ∪ R) → R l-t Q → P l-t Q viaDisj : ∀ {P₁ P₂} → P ⊆ (P₁ ∪ P₂) → P₁ l-t Q → P₂ l-t Q → P l-t Q viaUseInv : ∀ {R} → Invariant (stateMachine sys) R → (P ∩ R) l-t (R ⇒ Q) → P l-t Q viaWFR : ∀ (F : Z → Pred State 0ℓ) → P l-t (Q ∪ [∃ x ∶ F x ]) → (∀ (w : Z) → F w l-t (Q ∪ [∃ x ⇒ _< w ∶ F x ])) → P l-t Q viaAllVal : ∀ {A : Set} → {R : A → Pred State 0ℓ} → Invariant (stateMachine sys) [∃ x ∶ R x ] → (∀ (a : A) → (P ∩ R a) l-t Q ) → P l-t Q viaStable : ∀ {P' Q' S} → Stable (stateMachine sys) S → P l-t P' ∩ S → P' l-t Q' → Q' ∩ S l-t Q → P l-t Q P⊆QQ→Inv[P⇒Q] : ∀ {P Q} {sm : StateMachine State Event} → P ⊆ Q → Invariant sm (P ⇒ Q) P⊆QQ→Inv[P⇒Q] p⊆q rs pS with p⊆q pS ... | qS = qS invR⇒P-l-t-P∧R : ∀ {P R} {sm : StateMachine State Event} → Invariant (stateMachine sys) R → P l-t P ∩ R invR⇒P-l-t-P∧R invR = viaInv (λ rs ps → ps , (invR rs))
{ "alphanum_fraction": 0.4652709842, "avg_line_length": 32.9741935484, "ext": "agda", "hexsha": "dc2dfda41688283f879e81906de30283e7540933", "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": "391e148f391dc2d246249193788a0d203285b38e", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "lisandrasilva/agda-liveness", "max_forks_repo_path": "src/StateMachineModel.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "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": "lisandrasilva/agda-liveness", "max_issues_repo_path": "src/StateMachineModel.agda", "max_line_length": 92, "max_stars_count": null, "max_stars_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "lisandrasilva/agda-liveness", "max_stars_repo_path": "src/StateMachineModel.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1573, "size": 5111 }
------------------------------------------------------------------------------ -- FOTC version of the domain predicate of quicksort given by the -- Bove-Capretta method ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Program.QuickSort.DomainPredicate where open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.Nat.Inequalities hiding ( le ; gt ) open import FOTC.Data.Nat.List.Type open import FOTC.Data.Nat.Type open import FOTC.Data.List ------------------------------------------------------------------------------ -- We need to define monadic inequalities. postulate le gt : D le-00 : le · zero · zero ≡ false le-0S : ∀ d → le · zero · succ₁ d ≡ true le-S0 : ∀ d → le · succ₁ d · zero ≡ false le-SS : ∀ d e → le · succ₁ d · succ₁ e ≡ lt d e postulate filter : D → D → D filter-[] : ∀ f → filter f [] ≡ [] filter-∷ : ∀ f d ds → filter f (d ∷ ds) ≡ (if f · d then d ∷ filter f (d ∷ ds) else filter f (d ∷ ds)) postulate filter-List : ∀ f {xs} → List xs → List (filter f xs) postulate qs : D → D qs-[] : qs [] ≡ [] qs-∷ : ∀ x xs → qs (x ∷ xs) ≡ qs (filter (gt · x) xs) ++ x ∷ qs (filter (le · x) xs) -- Domain predicate for quicksort. data Dqs : {xs : D} → List xs → Set where dnil : Dqs lnil dcons : ∀ {x xs} → (Lxs : List xs) → Dqs (filter-List (gt · x) Lxs) → Dqs (filter-List (le · x) Lxs) → Dqs (lcons x Lxs) -- Induction principle associated to the domain predicate of quicksort. Dqs-ind : (P : {xs : D} → List xs → Set) → P lnil → (∀ {x xs} → (Lxs : List xs) → Dqs (filter-List (gt · x) Lxs) → P (filter-List (gt · x) Lxs) → Dqs (filter-List (le · x) Lxs) → P (filter-List (le · x) Lxs) → P (lcons x Lxs)) → (∀ {xs} → {Lxs : List xs} → Dqs Lxs → P Lxs) Dqs-ind P P[] ih dnil = P[] Dqs-ind P P[] ih (dcons Lxs h₁ h₂) = ih Lxs h₁ (Dqs-ind P P[] ih h₁) h₂ (Dqs-ind P P[] ih h₂)
{ "alphanum_fraction": 0.4510135135, "avg_line_length": 36.4307692308, "ext": "agda", "hexsha": "5839ecd5108fdff6aca249d53f09425803168a5f", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/QuickSort/DomainPredicate.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/QuickSort/DomainPredicate.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/QuickSort/DomainPredicate.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": 716, "size": 2368 }
{-# OPTIONS --without-K --safe #-} module Categories.2-Functor where open import Level open import Categories.Category.Monoidal.Instance.StrictCats using (module Product) open import Categories.2-Category using (2-Category) open import Categories.Enriched.Functor using (Functor) 2-Functor : ∀ {o ℓ e c d} → 2-Category o ℓ e c → 2-Category o ℓ e d → Set (o ⊔ ℓ ⊔ e ⊔ c ⊔ d) 2-Functor C D = Functor (Product.Cats-Monoidal) C D
{ "alphanum_fraction": 0.7013574661, "avg_line_length": 31.5714285714, "ext": "agda", "hexsha": "f3a8fd7256dd9d3a41db3d05e74a9a2254b0aab7", "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/2-Functor.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/2-Functor.agda", "max_line_length": 83, "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/2-Functor.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": 136, "size": 442 }
{-# OPTIONS --cubical --safe #-} module Cubical.Structures.Rng where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Foundations.SIP renaming (SNS-PathP to SNS) open import Cubical.Structures.NAryOp open import Cubical.Structures.Semigroup hiding (⟨_⟩) open import Cubical.Structures.AbGroup private variable ℓ ℓ' : Level raw-rng-structure : Type ℓ → Type ℓ raw-rng-structure X = (X → X → X) × (X → X → X) raw-rng-is-SNS : SNS {ℓ} raw-rng-structure _ raw-rng-is-SNS = join-SNS (nAryFunIso 2) (nAryFunSNS 2) (nAryFunIso 2) (nAryFunSNS 2) rng-axioms : (X : Type ℓ) (s : raw-rng-structure X) → Type ℓ rng-axioms X (_·_ , _+_) = abelian-group-axioms X _·_ × semigroup-axioms X _+_ × ((x y z : X) → x · (y + z) ≡ (x · y) + (x · z)) × ((x y z : X) → (x + y) · z ≡ (x · z) + (y · z)) rng-structure : Type ℓ → Type ℓ rng-structure = add-to-structure raw-rng-structure rng-axioms Rngs : Type (ℓ-suc ℓ) Rngs {ℓ} = TypeWithStr ℓ rng-structure rng-iso : StrIso rng-structure ℓ rng-iso = add-to-iso (join-iso (nAryFunIso 2) (nAryFunIso 2)) rng-axioms rng-axioms-isProp : (X : Type ℓ) (s : raw-rng-structure X) → isProp (rng-axioms X s) rng-axioms-isProp X (_·_ , _+_) = isPropΣ (abelian-group-axioms-isProp X _·_) λ _ → isPropΣ (semigroup-axiom-isProp X _+_) λ { (isSetX , _) → isPropΣ (isPropΠ3 (λ _ _ _ → isSetX _ _)) λ _ → isPropΠ3 (λ _ _ _ → isSetX _ _)} rng-is-SNS : SNS {ℓ} rng-structure rng-iso rng-is-SNS = add-axioms-SNS _ rng-axioms-isProp raw-rng-is-SNS RngPath : (M N : Rngs {ℓ}) → (M ≃[ rng-iso ] N) ≃ (M ≡ N) RngPath = SIP rng-is-SNS
{ "alphanum_fraction": 0.6032258065, "avg_line_length": 35.0943396226, "ext": "agda", "hexsha": "283c8981fa2ca14fa8a98789a62c55de754f92e9", "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/Structures/Rng.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/Structures/Rng.agda", "max_line_length": 94, "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/Structures/Rng.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": 687, "size": 1860 }
module Extensionality where open import Relation.Binary.PropositionalEquality hiding (Extensionality) postulate f-ext : {A : Set}{B : A → Set}{f : (x : A) → B x} {g : (x : A) → B x} → (∀ x → f x ≡ g x) → f ≡ g
{ "alphanum_fraction": 0.5917431193, "avg_line_length": 27.25, "ext": "agda", "hexsha": "67c9cde9f135111d590a14efe187ec682f4e7324", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "kcaliban/ldlc", "max_forks_repo_path": "src/llc/Extensionality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "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": "kcaliban/ldlc", "max_issues_repo_path": "src/llc/Extensionality.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "kcaliban/ldlc", "max_stars_repo_path": "src/llc/Extensionality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 79, "size": 218 }
_ : Set _ : Set → Set
{ "alphanum_fraction": 0.5, "avg_line_length": 7.3333333333, "ext": "agda", "hexsha": "6b0c1ece87c0f10812b905121ea3d3cc4f3dc571", "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/Issue4881b.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/Issue4881b.agda", "max_line_length": 13, "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/Issue4881b.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": 10, "size": 22 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Heterogeneous N-ary Functions: basic types and operations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Function.Nary.NonDependent.Base where ------------------------------------------------------------------------ -- Concrete examples can be found in README.Nary. This file's comments -- are more focused on the implementation details and the motivations -- behind the design decisions. ------------------------------------------------------------------------ open import Level using (Level; 0ℓ; _⊔_; Lift) open import Data.Nat.Base using (ℕ; zero; suc) open import Data.Product using (_×_; _,_) open import Data.Unit.Base open import Function using (_∘′_; _$′_; const; flip) private variable a b c : Level A : Set a B : Set b C : Set c ------------------------------------------------------------------------ -- Type Definitions -- We want to define n-ary function spaces and generic n-ary operations on -- them such as (un)currying, zipWith, alignWith, etc. -- We want users to be able to use these seamlessly whenever n is concrete. -- In other words, we want Agda to infer the sets `A₁, ⋯, Aₙ` when we write -- `uncurryₙ n f` where `f` has type `A₁ → ⋯ → Aₙ → B`. For this to happen, -- we need the structure in which these Sets are stored to effectively -- η-expand to `A₁, ⋯, Aₙ` when the parameter `n` is known. -- Hence the following definitions: ------------------------------------------------------------------------ -- First, a "vector" of `n` Levels (defined by induction on n so that it -- may be built by η-expansion and unification). Each Level will be that -- of one of the Sets we want to take the n-ary product of. Levels : ℕ → Set Levels zero = ⊤ Levels (suc n) = Level × Levels n -- The overall Level of a `n` Sets of respective levels `l₁, ⋯, lₙ` will -- be the least upper bound `l₁ ⊔ ⋯ ⊔ lₙ` of all of the Levels involved. -- Hence the following definition of n-ary least upper bound: ⨆ : ∀ n → Levels n → Level ⨆ zero _ = Level.zero ⨆ (suc n) (l , ls) = l ⊔ (⨆ n ls) -- Second, a "vector" of `n` Sets whose respective Levels are determined -- by the `Levels n` input. Sets : ∀ n (ls : Levels n) → Set (Level.suc (⨆ n ls)) Sets zero _ = Lift _ ⊤ Sets (suc n) (l , ls) = Set l × Sets n ls -- Third, a function type whose domains are given by a "vector" of `n` Sets -- `A₁, ⋯, Aₙ` and whose codomain is `B`. `Arrows` forms such a type of -- shape `A₁ → ⋯ → Aₙ → B` by induction on `n`. Arrows : ∀ n {r ls} → Sets n ls → Set r → Set (r ⊔ (⨆ n ls)) Arrows zero _ b = b Arrows (suc n) (a , as) b = a → Arrows n as b -- We introduce a notation for this definition infixr 0 _⇉_ _⇉_ : ∀ {n ls r} → Sets n ls → Set r → Set (r ⊔ (⨆ n ls)) _⇉_ = Arrows _ ------------------------------------------------------------------------ -- Operations on Sets -- Level-respecting map _<$>_ : (∀ {l} → Set l → Set l) → ∀ {n ls} → Sets n ls → Sets n ls _<$>_ f {zero} as = _ _<$>_ f {suc n} (a , as) = f a , f <$> as -- Level-modifying generalised map lmap : (Level → Level) → ∀ n → Levels n → Levels n lmap f zero ls = _ lmap f (suc n) (l , ls) = f l , lmap f n ls smap : ∀ f → (∀ {l} → Set l → Set (f l)) → ∀ n {ls} → Sets n ls → Sets n (lmap f n ls) smap f F zero as = _ smap f F (suc n) (a , as) = F a , smap f F n as ------------------------------------------------------------------------ -- Operations on Functions -- mapping under n arguments mapₙ : ∀ n {ls} {as : Sets n ls} → (B → C) → as ⇉ B → as ⇉ C mapₙ zero f v = f v mapₙ (suc n) f g = mapₙ n f ∘′ g -- compose function at the n-th position _%=_⊢_ : ∀ n {ls} {as : Sets n ls} → (A → B) → as ⇉ (B → C) → as ⇉ (A → C) n %= f ⊢ g = mapₙ n (_∘′ f) g -- partially apply function at the n-th position _∷=_⊢_ : ∀ n {ls} {as : Sets n ls} → A → as ⇉ (A → B) → as ⇉ B n ∷= x ⊢ g = mapₙ n (_$′ x) g -- hole at the n-th position holeₙ : ∀ n {ls} {as : Sets n ls} → (A → as ⇉ B) → as ⇉ (A → B) holeₙ zero f = f holeₙ (suc n) f = holeₙ n ∘′ flip f -- function constant in its n first arguments -- Note that its type will only be inferred if it is used in a context -- specifying what the type of the function ought to be. Just like the -- usual const: there is no way to infer its domain from its argument. constₙ : ∀ n {ls r} {as : Sets n ls} {b : Set r} → b → as ⇉ b constₙ zero v = v constₙ (suc n) v = const (constₙ n v)
{ "alphanum_fraction": 0.5313179643, "avg_line_length": 33.0791366906, "ext": "agda", "hexsha": "6fb098e62c5f9ac1e835cb8c217f4ff362139fe8", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Function/Nary/NonDependent/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Function/Nary/NonDependent/Base.agda", "max_line_length": 75, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Function/Nary/NonDependent/Base.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": 1440, "size": 4598 }
module par-swap.confluent where open import par-swap open import par-swap.properties open import Data.Nat using (_+_ ; _≤′_ ; _<′_ ; suc ; zero ; ≤′-refl) open import Esterel.Lang.CanFunction open import utility open import Esterel.Lang open import Esterel.Context open import Data.Product open import Data.Sum open import Data.List using ([] ; [_] ; _∷_ ; List ; _++_) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; sym ; subst ; cong ; trans ; module ≡-Reasoning ; cong₂ ; subst₂ ; inspect) open import sn-calculus open import context-properties -- get view, E-views open import Esterel.Lang.Binding open import binding-preserve using (sn⟶-maintains-binding ; sn⟶*-maintains-binding) open import sn-calculus-props ∥R-confluent : CB-CONFLUENT _∥R_ ∥R-confluent CBp (∥Rstep dchole) (∥Rstep dchole) = _ , ∥Rstep dchole , ∥Rstep dchole ∥R-confluent CBp (∥Rstep dchole) (∥Rstep (dcpar₁ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcpar₂ d≐C⟦p∥q⟧c₂) , ∥Rstep dchole ∥R-confluent CBp (∥Rstep dchole) (∥Rstep (dcpar₂ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcpar₁ d≐C⟦p∥q⟧c₂) , ∥Rstep dchole ∥R-confluent CBp (∥Rstep (dcpar₁ d≐C⟦p∥q⟧c₁)) (∥Rstep dchole) = _ , ∥Rstep dchole , ∥Rstep (dcpar₂ d≐C⟦p∥q⟧c₁) ∥R-confluent (CBpar CBs _ _ _ _ _) (∥Rstep {c₁ ∷ C₁} (dcpar₁ d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcpar₁ d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent CBp (∥Rstep (dcpar₁ d≐C⟦p∥q⟧c₁)) (∥Rstep (dcpar₂ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcpar₂ d≐C⟦p∥q⟧c₂) , ∥Rstep (dcpar₁ d≐C⟦p∥q⟧c₁) ∥R-confluent CBp (∥Rstep (dcpar₂ d≐C⟦p∥q⟧c₁)) (∥Rstep dchole) = _ , ∥Rstep dchole , ∥Rstep (dcpar₁ d≐C⟦p∥q⟧c₁) ∥R-confluent CBp (∥Rstep (dcpar₂ d≐C⟦p∥q⟧c₁)) (∥Rstep (dcpar₁ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcpar₁ d≐C⟦p∥q⟧c₂) , ∥Rstep (dcpar₂ d≐C⟦p∥q⟧c₁) ∥R-confluent (CBpar _ CBs _ _ _ _) (∥Rstep {c₁ ∷ C₁} (dcpar₂ d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcpar₂ d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent (CBseq CBs _ _) (∥Rstep {c₁ ∷ C₁} (dcseq₁ d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcseq₁ d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent CBp (∥Rstep (dcseq₁ d≐C⟦p∥q⟧c₁)) (∥Rstep (dcseq₂ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcseq₂ d≐C⟦p∥q⟧c₂) , ∥Rstep (dcseq₁ d≐C⟦p∥q⟧c₁) ∥R-confluent CBp (∥Rstep (dcseq₂ d≐C⟦p∥q⟧c₁)) (∥Rstep (dcseq₁ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcseq₁ d≐C⟦p∥q⟧c₂) , ∥Rstep (dcseq₂ d≐C⟦p∥q⟧c₁) ∥R-confluent (CBseq _ CBs _) (∥Rstep {c₁ ∷ C₁} (dcseq₂ d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcseq₂ d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent (CBsusp CBs _) (∥Rstep {c₁ ∷ C₁} (dcsuspend d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcsuspend d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent (CBtrap CBs) (∥Rstep {c₁ ∷ C₁} (dctrap d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dctrap d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent (CBsig CBs) (∥Rstep {c₁ ∷ C₁} (dcsignl d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcsignl d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent (CBpresent CBs _) (∥Rstep {c₁ ∷ C₁} (dcpresent₁ d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcpresent₁ d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent CBp (∥Rstep (dcpresent₁ d≐C⟦p∥q⟧c₁)) (∥Rstep (dcpresent₂ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcpresent₂ d≐C⟦p∥q⟧c₂) , ∥Rstep (dcpresent₁ d≐C⟦p∥q⟧c₁) ∥R-confluent CBp (∥Rstep (dcpresent₂ d≐C⟦p∥q⟧c₁)) (∥Rstep (dcpresent₁ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcpresent₁ d≐C⟦p∥q⟧c₂) , ∥Rstep (dcpresent₂ d≐C⟦p∥q⟧c₁) ∥R-confluent (CBpresent _ CBs) (∥Rstep {c₁ ∷ C₁} (dcpresent₂ d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcpresent₂ d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent (CBloop CBs _) (∥Rstep {c₁ ∷ C₁} (dcloop d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcloop d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent (CBloopˢ CBs _ _ _) (∥Rstep {c₁ ∷ C₁} (dcloopˢ₁ d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcloopˢ₁ d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent CBp (∥Rstep (dcloopˢ₁ d≐C⟦p∥q⟧c₁)) (∥Rstep (dcloopˢ₂ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcloopˢ₂ d≐C⟦p∥q⟧c₂) , ∥Rstep (dcloopˢ₁ d≐C⟦p∥q⟧c₁) ∥R-confluent CBp (∥Rstep (dcloopˢ₂ d≐C⟦p∥q⟧c₁)) (∥Rstep (dcloopˢ₁ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcloopˢ₁ d≐C⟦p∥q⟧c₂) , ∥Rstep (dcloopˢ₂ d≐C⟦p∥q⟧c₁) ∥R-confluent (CBloopˢ _ CBs _ _) (∥Rstep {c₁ ∷ C₁} (dcloopˢ₂ d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcloopˢ₂ d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent (CBshared CBs) (∥Rstep {c₁ ∷ C₁} (dcshared d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcshared d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent (CBvar CBs) (∥Rstep {c₁ ∷ C₁} (dcvar d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcvar d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent (CBif CBs _) (∥Rstep {c₁ ∷ C₁} (dcif₁ d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcif₁ d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent _ (∥Rstep (dcif₁ d≐C⟦p∥q⟧c₁)) (∥Rstep (dcif₂ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcif₂ d≐C⟦p∥q⟧c₂) , ∥Rstep (dcif₁ d≐C⟦p∥q⟧c₁) ∥R-confluent CBp (∥Rstep (dcif₂ d≐C⟦p∥q⟧c₁)) (∥Rstep (dcif₁ d≐C⟦p∥q⟧c₂)) = _ , ∥Rstep (dcif₁ d≐C⟦p∥q⟧c₂) , ∥Rstep (dcif₂ d≐C⟦p∥q⟧c₁) ∥R-confluent (CBif _ CBs) (∥Rstep {c₁ ∷ C₁} (dcif₂ d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcif₂ d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-confluent (CBρ CBs) (∥Rstep {c₁ ∷ C₁} (dcenv d≐C⟦p∥q⟧c₁)) (∥Rstep {c₂ ∷ C₂} (dcenv d≐C⟦p∥q⟧c₂)) with ∥R-confluent CBs (∥Rstep d≐C⟦p∥q⟧c₁) (∥Rstep d≐C⟦p∥q⟧c₂) ... | z , C₁⟦q₁∥p₁⟧c∥Rz , C₂⟦q₂∥p₂⟧c∥Rz = _ , Context1-∥R c₁ C₁⟦q₁∥p₁⟧c∥Rz , Context1-∥R c₂ C₂⟦q₂∥p₂⟧c∥Rz ∥R-maintains-binding : ∀ {p BV FV q} → CorrectBinding p BV FV → p ∥R q → CorrectBinding q (BVars q) (FVars q) ∥R-maintains-binding = thm where thm : ∀ {p BV FV q} → CorrectBinding p BV FV → p ∥R q → CorrectBinding q (BVars q) (FVars q) thm{p}{BVp}{FVp}{q} CBp (∥Rstep{C}{r₁}{r₂}{d} d≐C⟦p∥q⟧c) with binding-extractc' CBp d≐C⟦p∥q⟧c ... | (BVr₁∥r₂ , FVr₁∥r₂) , CBpar{.r₁}{.r₂}{BVr₁}{FVr₁}{BVr₂}{FVr₂} CBr₁ CBr₂ BVr₁≠BVr₂ FVr₁≠BVr₂ BVr₁≠FVr₂ Xr₁≠Xr₂ with CBpar{r₂}{r₁}{BVr₂}{FVr₂}{BVr₁}{FVr₁} CBr₂ CBr₁ (distinct-sym BVr₁≠BVr₂) (distinct-sym BVr₁≠FVr₂) (distinct-sym FVr₁≠BVr₂) (dist'-sym Xr₁≠Xr₂) ... | CBr₂∥r₁ with binding-substc' CBp d≐C⟦p∥q⟧c (CBpar CBr₁ CBr₂ BVr₁≠BVr₂ FVr₁≠BVr₂ BVr₁≠FVr₂ Xr₁≠Xr₂) (∪-comm-⊆-right BVr₁ ⊆-refl) (∪-comm-⊆-right FVr₁ ⊆-refl) CBr₂∥r₁ ... | (BVq , FVq) , (_ , CBq) with BVFVcorrect _ BVq FVq CBq ... | (refl , refl) = CBq ∥R*-maintains-binding : ∀ {p BV FV q} → CorrectBinding p BV FV → p ∥R* q → CorrectBinding q (BVars q) (FVars q) ∥R*-maintains-binding = thm where thm : ∀ {p BV FV q} → CorrectBinding p BV FV → p ∥R* q → CorrectBinding q (BVars q) (FVars q) thm CBp ∥R0 with BVFVcorrect _ _ _ CBp ... | refl , refl = CBp thm CBp (∥Rn p∥Rq₁ q₁∥R*q) with ∥R-maintains-binding CBp p∥Rq₁ ... | CBq₁ = thm CBq₁ q₁∥R*q ∥R*-semi-confluent : ∀ {p q r BV FV} -> CorrectBinding p BV FV -> p ∥R q -> p ∥R* r -> ∃ λ {z → (q ∥R* z × r ∥R* z)} ∥R*-semi-confluent CBp p∥Rq ∥R0 = _ , ∥R0 , (∥Rn p∥Rq ∥R0) ∥R*-semi-confluent CBp p∥Rq (∥Rn p∥Rq₁ q₁∥R*r) with ∥R-confluent CBp p∥Rq p∥Rq₁ ... | z , q∥Rz , q₁∥Rz with ∥R*-semi-confluent (∥R-maintains-binding CBp p∥Rq₁) q₁∥Rz q₁∥R*r ... | z₁ , z∥R*z₁ , r∥R*z₁ = z₁ , ∥Rn q∥Rz z∥R*z₁ , r∥R*z₁ ∥R*-confluent : CB-CONFLUENT _∥R*_ ∥R*-confluent CBp ∥R0 p∥R*r = _ , p∥R*r , ∥R0 ∥R*-confluent CBp (∥Rn p∥Rp₁ p₁∥R*q) p∥R*r with ∥R*-semi-confluent CBp p∥Rp₁ p∥R*r ... | z₁ , p₁∥R*z₁ , r∥R*z₁ with ∥R*-confluent (∥R-maintains-binding CBp p∥Rp₁) p₁∥R*q p₁∥R*z₁ ... | z , q∥R*z , z₁∥R*z = z , q∥R*z , ∥R*-concat r∥R*z₁ z₁∥R*z
{ "alphanum_fraction": 0.5830385121, "avg_line_length": 38.64453125, "ext": "agda", "hexsha": "32c6ca63d810cc016f5eae4322931bd8eb0bea2c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/par-swap/confluent.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/par-swap/confluent.agda", "max_line_length": 83, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/par-swap/confluent.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 6670, "size": 9893 }
------------------------------------------------------------------------ -- Support for sized types ------------------------------------------------------------------------ {-# OPTIONS --without-K --sized-types #-} module Prelude.Size where open import Prelude -- Size primitives. open import Agda.Builtin.Size public using (Size; ∞) renaming (Size<_ to Size<; SizeUniv to Size-universe; ↑_ to ssuc) -- If S is a type in the size universe, then S in-type is a type in -- Type. record _in-type (S : Size-universe) : Type where field size : S open _in-type public
{ "alphanum_fraction": 0.5155172414, "avg_line_length": 23.2, "ext": "agda", "hexsha": "6bd337191e99288e7cc28e79471189c7443e53c1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Prelude/Size.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Prelude/Size.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": "src/Prelude/Size.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": 126, "size": 580 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.CommRing.Instances.Polynomials.UnivariatePolyHIT where open import Cubical.Foundations.Prelude open import Cubical.Data.Empty as ⊥ open import Cubical.Data.Nat hiding (_·_) renaming (_+_ to _+n_) open import Cubical.Data.Nat.Order open import Cubical.Data.Sigma open import Cubical.Algebra.Monoid open import Cubical.Algebra.Monoid.Instances.Nat open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing open import Cubical.Algebra.GradedRing.DirectSumHIT private variable ℓ : Level open GradedRing-⊕HIT-index open GradedRing-⊕HIT-⋆ open ExtensionCommRing module _ (ACommRing@(A , Astr) : CommRing ℓ) where open CommRingStr Astr open RingTheory (CommRing→Ring ACommRing) UnivariatePolyHIT-CommRing : CommRing ℓ UnivariatePolyHIT-CommRing = ⊕HITgradedRing-CommRing NatMonoid (λ _ → A) (λ _ → snd (Ring→AbGroup (CommRing→Ring ACommRing))) 1r _·_ 0LeftAnnihilates 0RightAnnihilates (λ a b c → ΣPathP ((+-assoc _ _ _) , (·Assoc _ _ _))) (λ a → ΣPathP ((+-zero _) , (·IdR _))) (λ a → ΣPathP (refl , (·IdL _))) ·DistR+ ·DistL+ λ x y → ΣPathP ((+-comm _ _) , (·Comm _ _)) nUnivariatePolyHIT : (A' : CommRing ℓ) → (n : ℕ) → CommRing ℓ nUnivariatePolyHIT A' zero = A' nUnivariatePolyHIT A' (suc n) = UnivariatePolyHIT-CommRing (nUnivariatePolyHIT A' n)
{ "alphanum_fraction": 0.6518087855, "avg_line_length": 32.9361702128, "ext": "agda", "hexsha": "49d4a48d9a265d82a457030288b637beaf59f8f0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyHIT.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyHIT.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRing/Instances/Polynomials/UnivariatePolyHIT.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 478, "size": 1548 }
module Data.Num.Sandbox.WF where open import Data.Nat -- open import Relation.Binary -- -- open DecTotalOrder decTotalOrder -- using (trans) -- -- data Acc (n : ℕ) : Set where -- acc : (∀ m → m < n → Acc m) → Acc n -- -- go0 : (m : ℕ) → m < 0 → Acc m -- go0 m () -- -- <-wf : ∀ n → Acc n -- <-wf n = acc (go n) -- where go : (n m : ℕ) → m < n → Acc m -- go zero m () -- go (suc n₁) zero m<n = acc (λ _ → λ ()) -- go (suc n₁) (suc m) (s≤s m<n₁) = acc (λ m₁ m₁<m+1 → go n₁ m₁ (trans m₁<m+1 m<n₁)) pp : ℕ → ℕ pp zero = zero pp (suc zero) = zero pp (suc (suc n)) = n -- -- f : ℕ → ℕ -- f n = go n (<-wf n) -- where -- go : ∀ n → Acc n → ℕ -- go zero _ = zero -- go (suc n) (acc a) = go (pp (suc n)) (a (pp (suc n)) {! !}) open import Induction.Nat half : ℕ → ℕ half = <-rec _ go where go : (x : ℕ) → ((y : ℕ) → suc y ≤′ x → ℕ) → ℕ go zero acc = zero go (suc zero) acc = zero go (suc (suc n)) acc = suc (acc n (≤′-step ≤′-refl))
{ "alphanum_fraction": 0.4424357755, "avg_line_length": 25.0238095238, "ext": "agda", "hexsha": "5d32a36ec17df45a2f0568f873829aff8cbba584", "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": "Data/Num/Sandbox/WF.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": "Data/Num/Sandbox/WF.agda", "max_line_length": 96, "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": "Data/Num/Sandbox/WF.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": 415, "size": 1051 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Boring lemmas used in Data.Nat.GCD and Data.Nat.Coprimality ------------------------------------------------------------------------ module Data.Nat.GCD.Lemmas where open import Data.Nat import Data.Nat.Properties as NatProp open NatProp.SemiringSolver open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Function lem₀ = solve 2 (λ n k → n :+ (con 1 :+ k) := con 1 :+ n :+ k) refl lem₁ : ∀ i j → 2 + i ≤′ 2 + j + i lem₁ i j = NatProp.≤⇒≤′ $ s≤s $ s≤s $ NatProp.n≤m+n j i lem₂ : ∀ d x {k n} → d + x * k ≡ x * n → d + x * (n + k) ≡ 2 * x * n lem₂ d x {k} {n} eq = begin d + x * (n + k) ≡⟨ solve 4 (λ d x n k → d :+ x :* (n :+ k) := d :+ x :* k :+ x :* n) refl d x n k ⟩ d + x * k + x * n ≡⟨ cong₂ _+_ eq refl ⟩ x * n + x * n ≡⟨ solve 3 (λ x n k → x :* n :+ x :* n := con 2 :* x :* n) refl x n k ⟩ 2 * x * n ∎ lem₃ : ∀ d x {i k n} → d + (1 + x + i) * k ≡ x * n → d + (1 + x + i) * (n + k) ≡ (1 + 2 * x + i) * n lem₃ d x {i} {k} {n} eq = begin d + y * (n + k) ≡⟨ solve 4 (λ d y n k → d :+ y :* (n :+ k) := (d :+ y :* k) :+ y :* n) refl d y n k ⟩ (d + y * k) + y * n ≡⟨ cong₂ _+_ eq refl ⟩ x * n + y * n ≡⟨ solve 3 (λ x n i → x :* n :+ (con 1 :+ x :+ i) :* n := (con 1 :+ con 2 :* x :+ i) :* n) refl x n i ⟩ (1 + 2 * x + i) * n ∎ where y = 1 + x + i lem₄ : ∀ d y {k i} n → d + y * k ≡ (1 + y + i) * n → d + y * (n + k) ≡ (1 + 2 * y + i) * n lem₄ d y {k} {i} n eq = begin d + y * (n + k) ≡⟨ solve 4 (λ d y n k → d :+ y :* (n :+ k) := d :+ y :* k :+ y :* n) refl d y n k ⟩ d + y * k + y * n ≡⟨ cong₂ _+_ eq refl ⟩ (1 + y + i) * n + y * n ≡⟨ solve 3 (λ y i n → (con 1 :+ y :+ i) :* n :+ y :* n := (con 1 :+ con 2 :* y :+ i) :* n) refl y i n ⟩ (1 + 2 * y + i) * n ∎ private distrib-comm = solve 3 (λ x k n → x :* k :+ x :* n := x :* (n :+ k)) refl lem₅ : ∀ d x {n k} → d + x * n ≡ x * k → d + 2 * x * n ≡ x * (n + k) lem₅ d x {n} {k} eq = begin d + 2 * x * n ≡⟨ solve 3 (λ d x n → d :+ con 2 :* x :* n := d :+ x :* n :+ x :* n) refl d x n ⟩ d + x * n + x * n ≡⟨ cong₂ _+_ eq refl ⟩ x * k + x * n ≡⟨ distrib-comm x k n ⟩ x * (n + k) ∎ lem₆ : ∀ d x {n i k} → d + x * n ≡ (1 + x + i) * k → d + (1 + 2 * x + i) * n ≡ (1 + x + i) * (n + k) lem₆ d x {n} {i} {k} eq = begin d + (1 + 2 * x + i) * n ≡⟨ solve 4 (λ d x i n → d :+ (con 1 :+ con 2 :* x :+ i) :* n := d :+ x :* n :+ (con 1 :+ x :+ i) :* n) refl d x i n ⟩ d + x * n + y * n ≡⟨ cong₂ _+_ eq refl ⟩ y * k + y * n ≡⟨ distrib-comm y k n ⟩ y * (n + k) ∎ where y = 1 + x + i lem₇ : ∀ d y {i} n {k} → d + (1 + y + i) * n ≡ y * k → d + (1 + 2 * y + i) * n ≡ y * (n + k) lem₇ d y {i} n {k} eq = begin d + (1 + 2 * y + i) * n ≡⟨ solve 4 (λ d y i n → d :+ (con 1 :+ con 2 :* y :+ i) :* n := d :+ (con 1 :+ y :+ i) :* n :+ y :* n) refl d y i n ⟩ d + (1 + y + i) * n + y * n ≡⟨ cong₂ _+_ eq refl ⟩ y * k + y * n ≡⟨ distrib-comm y k n ⟩ y * (n + k) ∎ lem₈ : ∀ {i j k q} x y → 1 + y * j ≡ x * i → j * k ≡ q * i → k ≡ (x * k ∸ y * q) * i lem₈ {i} {j} {k} {q} x y eq eq′ = sym (NatProp.im≡jm+n⇒[i∸j]m≡n (x * k) (y * q) i k lemma) where lemma = begin x * k * i ≡⟨ solve 3 (λ x k i → x :* k :* i := x :* i :* k) refl x k i ⟩ x * i * k ≡⟨ cong (λ n → n * k) (sym eq) ⟩ (1 + y * j) * k ≡⟨ solve 3 (λ y j k → (con 1 :+ y :* j) :* k := y :* (j :* k) :+ k) refl y j k ⟩ y * (j * k) + k ≡⟨ cong (λ n → y * n + k) eq′ ⟩ y * (q * i) + k ≡⟨ solve 4 (λ y q i k → y :* (q :* i) :+ k := y :* q :* i :+ k) refl y q i k ⟩ y * q * i + k ∎ lem₉ : ∀ {i j k q} x y → 1 + x * i ≡ y * j → j * k ≡ q * i → k ≡ (y * q ∸ x * k) * i lem₉ {i} {j} {k} {q} x y eq eq′ = sym (NatProp.im≡jm+n⇒[i∸j]m≡n (y * q) (x * k) i k lemma) where lem = solve 3 (λ a b c → a :* b :* c := b :* c :* a) refl lemma = begin y * q * i ≡⟨ lem y q i ⟩ q * i * y ≡⟨ cong (λ n → n * y) (sym eq′) ⟩ j * k * y ≡⟨ sym (lem y j k) ⟩ y * j * k ≡⟨ cong (λ n → n * k) (sym eq) ⟩ (1 + x * i) * k ≡⟨ solve 3 (λ x i k → (con 1 :+ x :* i) :* k := x :* k :* i :+ k) refl x i k ⟩ x * k * i + k ∎ lem₁₀ : ∀ {a′} b c {d} e f → let a = suc a′ in a + b * (c * d * a) ≡ e * (f * d * a) → d ≡ 1 lem₁₀ {a′} b c {d} e f eq = NatProp.i*j≡1⇒j≡1 (e * f ∸ b * c) d (NatProp.im≡jm+n⇒[i∸j]m≡n (e * f) (b * c) d 1 (NatProp.cancel-*-right (e * f * d) (b * c * d + 1) (begin e * f * d * a ≡⟨ solve 4 (λ e f d a → e :* f :* d :* a := e :* (f :* d :* a)) refl e f d a ⟩ e * (f * d * a) ≡⟨ sym eq ⟩ a + b * (c * d * a) ≡⟨ solve 4 (λ a b c d → a :+ b :* (c :* d :* a) := (b :* c :* d :+ con 1) :* a) refl a b c d ⟩ (b * c * d + 1) * a ∎))) where a = suc a′ lem₁₁ : ∀ {i j m n k d} x y → 1 + y * j ≡ x * i → i * k ≡ m * d → j * k ≡ n * d → k ≡ (x * m ∸ y * n) * d lem₁₁ {i} {j} {m} {n} {k} {d} x y eq eq₁ eq₂ = sym (NatProp.im≡jm+n⇒[i∸j]m≡n (x * m) (y * n) d k lemma) where assoc = solve 3 (λ x y z → x :* y :* z := x :* (y :* z)) refl lemma = begin x * m * d ≡⟨ assoc x m d ⟩ x * (m * d) ≡⟨ cong (_*_ x) (sym eq₁) ⟩ x * (i * k) ≡⟨ sym (assoc x i k) ⟩ x * i * k ≡⟨ cong₂ _*_ (sym eq) refl ⟩ (1 + y * j) * k ≡⟨ solve 3 (λ y j k → (con 1 :+ y :* j) :* k := y :* (j :* k) :+ k) refl y j k ⟩ y * (j * k) + k ≡⟨ cong (λ p → y * p + k) eq₂ ⟩ y * (n * d) + k ≡⟨ cong₂ _+_ (sym $ assoc y n d) refl ⟩ y * n * d + k ∎
{ "alphanum_fraction": 0.283835384, "avg_line_length": 41.350877193, "ext": "agda", "hexsha": "8b5a6c0424db0007bc7435f1310ebcd7b638632d", "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/Nat/GCD/Lemmas.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/Nat/GCD/Lemmas.agda", "max_line_length": 93, "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/Nat/GCD/Lemmas.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": 3029, "size": 7071 }
{-# OPTIONS --safe #-} module Cubical.Displayed.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence using (pathToEquiv; univalence; ua-ungluePath-Equiv) open import Cubical.Data.Unit open import Cubical.Data.Sigma open import Cubical.Relation.Binary open BinaryRelation open import Cubical.Displayed.Base private variable ℓ ℓA ℓA' ℓP ℓ≅A ℓ≅A' ℓB ℓB' ℓ≅B ℓ≅B' ℓC ℓ≅C : Level -- induction principles module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) where open UARel 𝒮-A 𝒮-J : {a : A} (P : (a' : A) → (p : a ≡ a') → Type ℓ) (d : P a refl) {a' : A} (p : a ≅ a') → P a' (≅→≡ p) 𝒮-J {a} P d {a'} p = J (λ y q → P y q) d (≅→≡ p) 𝒮-J-2 : {a : A} (P : (a' : A) → (p : a ≅ a') → Type ℓ) (d : P a (ρ a)) {a' : A} (p : a ≅ a') → P a' p 𝒮-J-2 {a = a} P d {a'} p = subst (λ r → P a' r) (Iso.leftInv (uaIso a a') p) g where g : P a' (≡→≅ (≅→≡ p)) g = 𝒮-J (λ y q → P y (≡→≅ q)) d p -- constructors module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A} {B : A → Type ℓB} (_≅ᴰ⟨_⟩_ : {a a' : A} → B a → UARel._≅_ 𝒮-A a a' → B a' → Type ℓ≅B) where open UARel 𝒮-A -- constructor that reduces ua to the case where p = ρ a by induction on p private 𝒮ᴰ-make-aux : (uni : {a : A} (b b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ (b ≡ b')) → ({a a' : A} (b : B a) (p : a ≅ a') (b' : B a') → (b ≅ᴰ⟨ p ⟩ b') ≃ PathP (λ i → B (≅→≡ p i)) b b') 𝒮ᴰ-make-aux uni {a} {a'} b p = 𝒮-J-2 𝒮-A (λ y q → (b' : B y) → (b ≅ᴰ⟨ q ⟩ b') ≃ PathP (λ i → B (≅→≡ q i)) b b') (λ b' → uni' b') p where g : (b' : B a) → (b ≡ b') ≡ PathP (λ i → B (≅→≡ (ρ a) i)) b b' g b' = subst (λ r → (b ≡ b') ≡ PathP (λ i → B (r i)) b b') (sym (Iso.rightInv (uaIso a a) refl)) refl uni' : (b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ PathP (λ i → B (≅→≡ (ρ a) i)) b b' uni' b' = compEquiv (uni b b') (pathToEquiv (g b')) 𝒮ᴰ-make-1 : (uni : {a : A} (b b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ (b ≡ b')) → DUARel 𝒮-A B ℓ≅B DUARel._≅ᴰ⟨_⟩_ (𝒮ᴰ-make-1 uni) = _≅ᴰ⟨_⟩_ DUARel.uaᴰ (𝒮ᴰ-make-1 uni) = 𝒮ᴰ-make-aux uni -- constructor that reduces univalence further to contractibility of relational singletons 𝒮ᴰ-make-2 : (ρᴰ : {a : A} → isRefl _≅ᴰ⟨ ρ a ⟩_) (contrTotal : (a : A) → contrRelSingl _≅ᴰ⟨ ρ a ⟩_) → DUARel 𝒮-A B ℓ≅B 𝒮ᴰ-make-2 ρᴰ contrTotal = 𝒮ᴰ-make-1 (contrRelSingl→isUnivalent _ ρᴰ (contrTotal _)) -- relational isomorphisms 𝒮-iso→iso : {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) {B : Type ℓB} (𝒮-B : UARel B ℓ≅B) (F : RelIso (UARel._≅_ 𝒮-A) (UARel._≅_ 𝒮-B)) → Iso A B 𝒮-iso→iso 𝒮-A 𝒮-B F = RelIso→Iso (UARel._≅_ 𝒮-A) (UARel._≅_ 𝒮-B) (UARel.≅→≡ 𝒮-A) (UARel.≅→≡ 𝒮-B) F -- fiberwise relational isomorphisms module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A} {A' : Type ℓA'} {𝒮-A' : UARel A' ℓ≅A'} (F : Iso A A') {B : A → Type ℓB} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B) {B' : A' → Type ℓB'} (𝒮ᴰ-B' : DUARel 𝒮-A' B' ℓ≅B') where open UARel 𝒮-A open DUARel 𝒮ᴰ-B renaming (_≅ᴰ⟨_⟩_ to _≅B⟨_⟩_ ; uaᴰ to uaB ; fiberRel to fiberRelB ; uaᴰρ to uaᴰρB) open DUARel 𝒮ᴰ-B' renaming (_≅ᴰ⟨_⟩_ to _≅B'⟨_⟩_ ; uaᴰ to uaB' ; fiberRel to fiberRelB' ; uaᴰρ to uaᴰρB') private f = Iso.fun F -- the following can of course be done slightly more generally -- for fiberwise binary relations F*fiberRelB' : (a : A) → Rel (B' (f a)) (B' (f a)) ℓ≅B' F*fiberRelB' a = fiberRelB' (f a) module _ (G : (a : A) → RelIso (fiberRelB a) (F*fiberRelB' a)) where private fiberIsoOver : (a : A) → Iso (B a) (B' (f a)) fiberIsoOver a = RelIso→Iso (fiberRelB a) (F*fiberRelB' a) (equivFun (uaᴰρB _ _)) (equivFun (uaᴰρB' _ _)) (G a) -- DUARelFiberIsoOver→TotalIso produces an isomorphism of total spaces -- from a relational isomorphism between B a and (F * B) a 𝒮ᴰ-fiberIsoOver→totalIso : Iso (Σ A B) (Σ A' B') 𝒮ᴰ-fiberIsoOver→totalIso = Σ-cong-iso F fiberIsoOver
{ "alphanum_fraction": 0.4729584141, "avg_line_length": 32.6830985915, "ext": "agda", "hexsha": "8d59bf8dd1976dee4a912c9537231db2ab1e171c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Seanpm2001-web/cubical", "max_forks_repo_path": "Cubical/Displayed/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Seanpm2001-web/cubical", "max_issues_repo_path": "Cubical/Displayed/Properties.agda", "max_line_length": 119, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FernandoLarrain/cubical", "max_stars_repo_path": "Cubical/Displayed/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z", "num_tokens": 2061, "size": 4641 }
open import Oscar.Prelude module Oscar.Class.Map where module _ {𝔬₁} {𝔒₁ : Ø 𝔬₁} {ℓ₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø ℓ₁) {ℓ₂} (_∼₂_ : 𝔒₁ → 𝔒₁ → Ø ℓ₂) where 𝓶ap = ∀ {x y} → x ∼₁ y → x ∼₂ y record 𝓜ap : Ø 𝔬₁ ∙̂ ℓ₁ ∙̂ ℓ₂ where field map : 𝓶ap open 𝓜ap ⦃ … ⦄ public
{ "alphanum_fraction": 0.545112782, "avg_line_length": 19, "ext": "agda", "hexsha": "6b39b37cf63e7a9df4d9ac60e8f1c3bc6358a39a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Map.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Map.agda", "max_line_length": 53, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Map.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 164, "size": 266 }
-- Andreas, 2016-05-04, issue 1954 module _ where module P (A : Set) where record R : Set where field f : A open module Q A = P A module M (A : Set) (r : R A) where open R A r public -- Parameter A should be hidden in R.f works : ∀{A} → R A → A works r = R.f r -- Record value should not be hidden in M.f test : ∀{A} → R A → A test r = M.f r
{ "alphanum_fraction": 0.6011235955, "avg_line_length": 16.9523809524, "ext": "agda", "hexsha": "4d7a74e49829f5f5f17b69a7960cc4fac8cb5197", "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/Issue1954b.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/Issue1954b.agda", "max_line_length": 43, "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/Issue1954b.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": 131, "size": 356 }
-- Andreas, 2017-12-16, issue #2868. -- Printing record fields correctly inside the record definition -- in the presence of --postfix-projections. {-# OPTIONS --postfix-projections #-} open import Agda.Builtin.Equality postulate A : Set record R : Set where field a : A same : a ≡ a test : A test = same -- (We are reifying Var 0 [Proj ProjSystem Issue2868.R.a]) -- WAS: .a ≡ .a !=< A of type Set -- Note the extra dots! -- Expected: a ≡ a !=< A of type Set
{ "alphanum_fraction": 0.6393442623, "avg_line_length": 20.3333333333, "ext": "agda", "hexsha": "8f39afe6b254e249fddaa158a01e0b60ca43073c", "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/Issue2868.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/Issue2868.agda", "max_line_length": 64, "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/Issue2868.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": 488 }
module _ where open import Data.Nat using (_+_) open import Data.Nat.Properties.Simple using ( +-comm ; +-assoc) open import utility open import Esterel.Lang open import Esterel.Lang.Properties open import Esterel.Environment as Env open import Esterel.Context open import Data.Product open import Data.Sum open import Data.Bool open import Data.List open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Data.Empty open import sn-calculus open import context-properties open import Esterel.Lang.Binding open import Data.Maybe using ( just ) open import Function using (_$_) open import Data.FiniteMap import Data.OrderedListMap as OMap open import Data.Nat as Nat using (ℕ) open import Esterel.Variable.Signal as Signal using (Signal) open import Esterel.Variable.Shared as SharedVar using (SharedVar) open import Esterel.Variable.Sequential as SeqVar open import sn-calculus-confluence.helper open import sn-calculus-confluence.rec open import sn-calculus-confluence.potrec open import sn-calculus-confluence.potpot ρ-conf : ∀{p FV BV ql qr θ qi A} → CorrectBinding p FV BV → p sn⟶₁ ql → p sn⟶₁ qr → p ≡ (ρ⟨ θ , A ⟩· qi) → ql ≡ qr ⊎ (∃ (λ o → ql sn⟶₁ o × qr sn⟶₁ o)) ⊎ ql sn⟶₁ qr ⊎ qr sn⟶₁ ql ρ-conf {(ρ⟨ θ , .A ⟩· qi)}{ql = ql}{qr = qr}{A = A} cb redl redr refl with ρ-stays-ρ-sn⟶₁ redl | ρ-stays-ρ-sn⟶₁ redr ... | (θl , qlin , Al , refl) | (θr , qrin , Ar , refl) with get-view redl | get-view redr ρ-conf {(ρ⟨ θ , .A ⟩· qi)}{ql = ql}{qr = qr}{A = A} cb redl redr refl | (θl , qlin , Al , refl) | (θr , qrin , Ar , refl) | inj₁ (_ , _ , _ , _ , _ , viewl) | inj₁ (_ , _ , _ , _ , _ , viewr) with E-view-main-bind viewl viewr ... | inj₁ (e= , q= , θ= , A=) rewrite e= | q= | θ= | A= = inj₁ refl ... | inj₂ ~a with ρ-conf-rec cb _ _ ~a redl redr _ _ viewl viewr ... | (θo , Ao , so , _ , _ , _ , _ , _ , _ , redol , redor , _) = inj₂ $ inj₁ ((ρ⟨ θo , Ao ⟩· so) , redol , redor) ρ-conf {(ρ⟨ θ , .A ⟩· qi)}{ql = ql}{qr = qr}{A = A} cb redl redr refl | (θl , qlin , Al , refl) | (θr , qrin , Ar , refl) | inj₁ (_ , _ , _ , _ , _ , viewl) | inj₂ (_ , _ , viewr) with ρ-pot-conf-rec cb viewr viewl ... | inj₁ redo = inj₂ (inj₂ (inj₂ redo)) ... | inj₂ (s , env , Ao , redol , redor) = inj₂ $ inj₁ (ρ⟨ env , Ao ⟩· s , redor , redol) ρ-conf {(ρ⟨ θ , .A ⟩· qi)}{ql = ql}{qr = qr}{A = A} cb redl redr refl | (θl , qlin , Al , refl) | (θr , qrin , Ar , refl) | inj₂ (_ , _ , viewl) | inj₁ (_ , _ , _ , _ , _ , viewr) with ρ-pot-conf-rec cb viewl viewr ... | inj₁ redo = inj₂ (inj₂ (inj₁ redo)) ... | inj₂ (s , env , Ao , redol , redor) = inj₂ $ inj₁ ((ρ⟨ env , Ao ⟩· s) , redol , redor) ρ-conf {(ρ⟨ θ , .A ⟩· qi)}{ql = ql}{qr = qr}{A = A} cb redl redr refl | (θl , qlin , Al , refl) | (θr , qrin , Ar , refl) | inj₂ (_ , _ , viewl) | inj₂ (_ , _ , viewr) with pot-pot-conf-rec viewl viewr ... | inj₁ eq = inj₁ eq ... | inj₂ (env , redol , redor) = inj₂ $ inj₁ (ρ⟨ env , A ⟩· qi , redol , redor) R-confluent : ∀{p q r BV FV} → CorrectBinding p BV FV → p sn⟶₁ q → p sn⟶₁ r → q ≡ r ⊎ (∃ (λ s → q sn⟶₁ s × r sn⟶₁ s)) ⊎ q sn⟶₁ r ⊎ r sn⟶₁ q R-confluent {.(_ ∥ _)} cb (rpar-done-right p'' q'') (rpar-done-right p' q') = inj₁ ( value-max-unique{d1 = (dhalted p'')}{d2 = q''}{d3 = (dhalted p')}{d4 = q'} ) R-confluent {.(_ ∥ _)} cb (rpar-done-right p'' q'') (rpar-done-left p' q') = inj₁ ( value-max-unique{d1 = (dhalted p'')}{d2 = q''}{d3 = p'}{d4 = (dhalted q')} ) R-confluent {.(_ ∥ _)} cb (rpar-done-left p'' q'') (rpar-done-right p' q') = inj₁ (value-max-unique{d1 = (p'')}{d2 =(dhalted q'')}{d3 = (dhalted p')}{d4 = (q')}) R-confluent {.(_ ∥ _)} cb (rpar-done-left p'' q'') (rpar-done-left p' q') = inj₁ (value-max-unique{d1 = p''}{d2 = (dhalted q'')}{d3 = p'}{d4 = (dhalted q')}) R-confluent {.(loop _)} cb rloop-unroll rloop-unroll = inj₁ refl R-confluent {.(nothin >> _)} cb rseq-done rseq-done = inj₁ refl R-confluent {.(exit _ >> _)} cb rseq-exit rseq-exit = inj₁ refl R-confluent {.(loopˢ (exit _) _)} cb rloopˢ-exit rloopˢ-exit = inj₁ refl R-confluent {.(suspend nothin _)} cb (rsuspend-done hnothin) (rsuspend-done hnothin) = inj₁ refl R-confluent {.(suspend (exit n) _)} cb (rsuspend-done (hexit n)) (rsuspend-done (hexit .n)) = inj₁ refl R-confluent {.(trap nothin)} cb (rtrap-done hnothin) (rtrap-done hnothin) = inj₁ refl R-confluent {.(trap (exit n))} cb (rtrap-done (hexit n)) (rtrap-done (hexit .n)) = inj₁ refl R-confluent {.(signl _ _)} cb rraise-signal rraise-signal = inj₁ refl R-confluent {p@(ρ⟨ _ , _ ⟩· _)} cb redl redr = ρ-conf cb redl redr refl
{ "alphanum_fraction": 0.5923322684, "avg_line_length": 57.962962963, "ext": "agda", "hexsha": "dfa8f69e4fa80281f406f53bd4f7e7dd6a6bfd7a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/sn-calculus-confluence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/sn-calculus-confluence.agda", "max_line_length": 191, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/sn-calculus-confluence.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 1799, "size": 4695 }
module Categories.Functor.Construction.Exponential where open import Categories.Category open import Categories.Category.Product using (Product) open import Categories.Category.CartesianClosed open import Categories.Category.Cartesian open import Categories.Category.BinaryProducts open import Categories.Object.Exponential open import Categories.Functor.Bifunctor open import Data.Product using (_,_; proj₁; proj₂) module _ {o ℓ e} (𝒞 : Category o ℓ e) (cartesianClosed : CartesianClosed 𝒞) where open import Categories.Morphism.Reasoning 𝒞 open CartesianClosed cartesianClosed open Cartesian cartesian open BinaryProducts products open Category 𝒞 open Equiv private P : Category _ _ _ P = Product 𝒞 op Exp : Bifunctor 𝒞 (Category.op 𝒞) 𝒞 Exp = record { F₀ = λ (x , y) → x ^ y ; F₁ = λ (f , g) → λg (f ∘ eval′ ∘ (id ⁂ g)) ; identity = λ {A} → begin λg (id ∘ eval′ ∘ (id ⁂ id)) ≈⟨ λ-cong identityˡ ⟩ λg (eval′ ∘ (id ⁂ id)) ≈⟨ λ-cong (elimʳ (Equiv.trans (⟨⟩-cong₂ identityˡ identityˡ) η)) ⟩ λg eval′ ≈⟨ η-id′ ⟩ id ∎ ; homomorphism = λ {X} {Y} {Z} {f} {g} → begin λg ((proj₁ g ∘ proj₁ f) ∘ eval′ ∘ (id ⁂ (proj₂ f ∘ proj₂ g))) ≈⟨ λ-cong assoc ⟩ λg (proj₁ g ∘ proj₁ f ∘ eval′ ∘ (id ⁂ proj₂ f ∘ proj₂ g)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (∘-resp-≈ʳ (trans ⁂∘⁂ (⁂-cong₂ identity² refl))))) ⟩ λg (proj₁ g ∘ proj₁ f ∘ eval′ ∘ (id ⁂ proj₂ f) ∘ (id ⁂ proj₂ g)) ≈˘⟨ λ-cong (∘-resp-≈ʳ assoc²') ⟩ λg (proj₁ g ∘ (proj₁ f ∘ eval′ ∘ (id ⁂ proj₂ f)) ∘ (id ⁂ proj₂ g)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (pullˡ β′)) ⟩ λg (proj₁ g ∘ eval′ ∘ (λg (proj₁ f ∘ eval′ ∘ (id ⁂ proj₂ f)) ⁂ id) ∘ (id ⁂ proj₂ g)) ≈⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ ⁂∘⁂)) ⟩ λg (proj₁ g ∘ eval′ ∘ (λg (proj₁ f ∘ eval′ ∘ (id ⁂ proj₂ f)) ∘ id ⁂ id ∘ proj₂ g)) ≈⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (⁂-cong₂ (trans identityʳ (sym identityˡ)) (trans identityˡ (sym identityʳ))))) ⟩ λg (proj₁ g ∘ eval′ ∘ (id ∘ λg (proj₁ f ∘ eval′ ∘ (id ⁂ proj₂ f)) ⁂ proj₂ g ∘ id)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ ⁂∘⁂)) ⟩ λg (proj₁ g ∘ eval′ ∘ (id ⁂ proj₂ g) ∘ (λg (proj₁ f ∘ eval′ ∘ (id ⁂ proj₂ f)) ⁂ id)) ≈˘⟨ λ-cong assoc²' ⟩ λg ((proj₁ g ∘ eval′ ∘ (id ⁂ proj₂ g)) ∘ (λg (proj₁ f ∘ eval′ ∘ (id ⁂ proj₂ f)) ⁂ id)) ≈˘⟨ exp.subst product product ⟩ λg (proj₁ g ∘ eval′ ∘ (id ⁂ proj₂ g)) ∘ λg (proj₁ f ∘ eval′ ∘ (id ⁂ proj₂ f)) ∎ ; F-resp-≈ = λ (x , y) → λ-cong (∘-resp-≈ x (∘-resp-≈ʳ (⁂-cong₂ Equiv.refl y))) } where open HomReasoning
{ "alphanum_fraction": 0.4731289153, "avg_line_length": 45.9545454545, "ext": "agda", "hexsha": "e0d92de6735e0034267c988aea3cea679286c9ac", "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": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "elpinal/exsub-ccc", "max_forks_repo_path": "Categories/Functor/Construction/Exponential.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "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": "elpinal/exsub-ccc", "max_issues_repo_path": "Categories/Functor/Construction/Exponential.agda", "max_line_length": 131, "max_stars_count": 3, "max_stars_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "elpinal/exsub-ccc", "max_stars_repo_path": "Categories/Functor/Construction/Exponential.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T13:30:48.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-05T06:16:32.000Z", "num_tokens": 1171, "size": 3033 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Dagger where open import Level using (_⊔_; suc) open import Relation.Unary using (Pred) open import Categories.Category.Core using (Category) open import Categories.Functor.Core using (Functor) open import Categories.Morphism using (Iso) record HasDagger {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where open Category C infix 10 _† field _† : ∀ {A B} → A ⇒ B → B ⇒ A †-identity : ∀ {A} → id {A} † ≈ id †-homomorphism : ∀ {A B C} {f : A ⇒ B} {g : B ⇒ C} → (g ∘ f) † ≈ f † ∘ g † †-resp-≈ : ∀ {A B} {f g : A ⇒ B} → f ≈ g → f † ≈ g † †-involutive : ∀ {A B} (f : A ⇒ B) → f † † ≈ f †-Functor : Functor op C †-Functor = record { F₀ = λ A → A ; F₁ = _† ; identity = †-identity ; homomorphism = †-homomorphism ; F-resp-≈ = †-resp-≈ } isUnitary : ∀ {A B} → Pred (A ⇒ B) e isUnitary f = Iso C f (f †) isSelfAdjoint : ∀ {A} → Pred (A ⇒ A) e isSelfAdjoint f = f † ≈ f record DaggerCategory o ℓ e : Set (suc (o ⊔ ℓ ⊔ e)) where field C : Category o ℓ e hasDagger : HasDagger C open Category C public open HasDagger hasDagger public
{ "alphanum_fraction": 0.5620188195, "avg_line_length": 26.5681818182, "ext": "agda", "hexsha": "bdd8ef843121e6674ad0c43a76b92ab3832a2b5d", "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/Dagger.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/Dagger.agda", "max_line_length": 78, "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/Dagger.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": 474, "size": 1169 }
-- Andreas, 2017-01-12, issue #2386 postulate A : Set -- Should be rejected: data Eq : (B : Set) (x y : B) → Set where refl : (x : A) → Eq A x x {-# BUILTIN EQUALITY Eq #-} -- Expected error: -- Wrong type of constructor of BUILTIN EQUALITY -- when checking the pragma BUILTIN EQUALITY Eq
{ "alphanum_fraction": 0.6464646465, "avg_line_length": 19.8, "ext": "agda", "hexsha": "d80bb43b4084cbc8d1cc9e0b4578568158765b2c", "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/Issue2386-a.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/Issue2386-a.agda", "max_line_length": 48, "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/Issue2386-a.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": 94, "size": 297 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.ProdBetaEta {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped as U hiding (wk) open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Weakening as T hiding (wk; wkTerm; wkEqTerm) open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Weakening open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Application open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Properties open import Definition.LogicalRelation.Substitution.Reduction open import Definition.LogicalRelation.Substitution.Conversion open import Definition.LogicalRelation.Substitution.Reflexivity open import Definition.LogicalRelation.Substitution.Introductions.Pi open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst open import Definition.LogicalRelation.Substitution.Introductions.Prod open import Definition.LogicalRelation.Substitution.Introductions.Fst open import Definition.LogicalRelation.Substitution.Introductions.Snd open import Tools.Product import Tools.PropositionalEquality as PE Σ-β₁ᵛ : ∀ {F G t u Γ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F / [Γ]) ([G] : Γ ∙ F ⊩ᵛ⟨ l ⟩ G / [Γ] ∙ [F]) ([t] : Γ ⊩ᵛ⟨ l ⟩ t ∷ F / [Γ] / [F]) ([u] : Γ ⊩ᵛ⟨ l ⟩ u ∷ G [ t ] / [Γ] / substS {F} {G} [Γ] [F] [G] [t]) → Γ ⊩ᵛ⟨ l ⟩ fst (prod t u) ≡ t ∷ F / [Γ] / [F] Σ-β₁ᵛ {F} {G} {t} {u} {Γ} {l} [Γ] [F] [G] [t] [u] = let [Gt] = substS {F} {G} {t} [Γ] [F] [G] [t] fst⇒t : Γ ⊩ᵛ fst (prod t u) ⇒ t ∷ F / [Γ] fst⇒t = (λ {Δ} {σ} ⊢Δ [σ] → let ⊩σF = proj₁ ([F] ⊢Δ [σ]) ⊢σF = escape ⊩σF [Fσ] = liftSubstS {F = F} {σ = σ} [Γ] ⊢Δ [F] [σ] ⊩σG : Δ ∙ subst σ F ⊩⟨ l ⟩ subst (liftSubst σ) G ⊩σG = proj₁ ([G] (⊢Δ ∙ ⊢σF) [Fσ]) ⊢σG = escape ⊩σG ⊩σt = proj₁ ([t] ⊢Δ [σ]) ⊢σt = escapeTerm ⊩σF ⊩σt ⊩σGt₁ = proj₁ ([Gt] ⊢Δ [σ]) ⊩σGt = irrelevance′ (singleSubstLift G t) ⊩σGt₁ ⊩σu₁ = proj₁ ([u] ⊢Δ [σ]) ⊩σu = irrelevanceTerm′ (singleSubstLift G t) ⊩σGt₁ ⊩σGt ⊩σu₁ ⊢σu = escapeTerm ⊩σGt ⊩σu in Σ-β₁ ⊢σF ⊢σG ⊢σt ⊢σu) in proj₂ (redSubstTermᵛ {F} {fst (prod t u)} {t} [Γ] fst⇒t [F] [t]) Σ-β₂ᵛ : ∀ {F G t u Γ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F / [Γ]) ([G] : Γ ∙ F ⊩ᵛ⟨ l ⟩ G / [Γ] ∙ [F]) ([t] : Γ ⊩ᵛ⟨ l ⟩ t ∷ F / [Γ] / [F]) ([u] : Γ ⊩ᵛ⟨ l ⟩ u ∷ G [ t ] / [Γ] / substS {F} {G} [Γ] [F] [G] [t]) → Γ ⊩ᵛ⟨ l ⟩ snd (prod t u) ≡ u ∷ G [ fst (prod t u) ] / [Γ] / substS {F} {G} [Γ] [F] [G] (fstᵛ {F} {G} {prod t u} [Γ] [F] [G] (prodᵛ {F} {G} {t} {u} [Γ] [F] [G] [t] [u])) Σ-β₂ᵛ {F} {G} {t} {u} {Γ} {l} [Γ] [F] [G] [t] [u] = let [Gt] = substS {F} {G} {t} [Γ] [F] [G] [t] [prod] = prodᵛ {F} {G} {t} {u} [Γ] [F] [G] [t] [u] [fst] = fstᵛ {F} {G} {prod t u} [Γ] [F] [G] [prod] [Gfst] = substS {F} {G} {fst (prod t u)} [Γ] [F] [G] [fst] [fst≡t] = Σ-β₁ᵛ {F} {G} {t} {u} [Γ] [F] [G] [t] [u] [Gfst≡Gt] = substSEq {F} {F} {G} {G} {fst (prod t u)} {t} [Γ] [F] [F] (reflᵛ {F} [Γ] [F]) [G] [G] (reflᵛ {G} {Γ ∙ F} ([Γ] ∙ [F]) [G]) [fst] [t] [fst≡t] [u]Gfst = conv₂ᵛ {u} {G [ fst (prod t u) ]} {G [ t ]} [Γ] [Gfst] [Gt] [Gfst≡Gt] [u] snd⇒t : Γ ⊩ᵛ snd (prod t u) ⇒ u ∷ G [ fst (prod t u) ] / [Γ] snd⇒t = (λ {Δ} {σ} ⊢Δ [σ] → let ⊩σF = proj₁ ([F] ⊢Δ [σ]) ⊢σF = escape ⊩σF [Fσ] = liftSubstS {F = F} {σ = σ} [Γ] ⊢Δ [F] [σ] ⊩σG : Δ ∙ subst σ F ⊩⟨ l ⟩ subst (liftSubst σ) G ⊩σG = proj₁ ([G] (⊢Δ ∙ ⊢σF) [Fσ]) ⊢σG = escape ⊩σG ⊩σt = proj₁ ([t] ⊢Δ [σ]) ⊢σt = escapeTerm ⊩σF ⊩σt ⊩σGt₁ = proj₁ ([Gt] ⊢Δ [σ]) ⊩σGt = irrelevance′ (singleSubstLift G t) ⊩σGt₁ ⊩σu₁ = proj₁ ([u] ⊢Δ [σ]) ⊩σu = irrelevanceTerm′ (singleSubstLift G t) ⊩σGt₁ ⊩σGt ⊩σu₁ ⊢σu = escapeTerm ⊩σGt ⊩σu snd⇒t : Δ ⊢ _ ⇒ _ ∷ _ snd⇒t = Σ-β₂ ⊢σF ⊢σG ⊢σt ⊢σu σGfst≡σGfst = PE.subst (λ x → Δ ⊢ x ≡ subst σ (G [ fst (prod t u) ])) (singleSubstLift G (fst (prod t u))) (refl (escape (proj₁ ([Gfst] ⊢Δ [σ])))) in conv snd⇒t σGfst≡σGfst) in proj₂ (redSubstTermᵛ {G [ fst (prod t u) ]} {snd (prod t u)} {u} [Γ] snd⇒t [Gfst] [u]Gfst) Σ-η′ : ∀ {F G p r Γ l l′} ([F] : Γ ⊩⟨ l′ ⟩ F) ([Gfstp] : Γ ⊩⟨ l′ ⟩ G [ fst p ]) ([ΣFG]₁ : Γ ⊩⟨ l ⟩B⟨ BΣ ⟩ Σ F ▹ G ) ([p] : Γ ⊩⟨ l ⟩ p ∷ Σ F ▹ G / B-intr BΣ [ΣFG]₁) ([r] : Γ ⊩⟨ l ⟩ r ∷ Σ F ▹ G / B-intr BΣ [ΣFG]₁) ([fst≡] : Γ ⊩⟨ l′ ⟩ fst p ≡ fst r ∷ F / [F]) ([snd≡] : Γ ⊩⟨ l′ ⟩ snd p ≡ snd r ∷ G [ fst p ] / [Gfstp]) → Γ ⊩⟨ l ⟩ p ≡ r ∷ Σ F ▹ G / B-intr BΣ [ΣFG]₁ Σ-η′ {F} {G} {p} {r} {Γ} {l} {l′} [F] [Gfstp] [ΣFG]₁@(noemb (Bᵣ F₁ G₁ D ⊢F ⊢G A≡A [F]₁ [G]₁ G-ext)) [p]@(Σₜ p′ dₚ p′Prod p′≅p′ wk[fstp′] wk[sndp′]) [r]@(Σₜ r′ dᵣ r′Prod r′≅r′ wk[fstr′] wk[sndr′]) [fst≡] [snd≡] with B-PE-injectivity BΣ (whnfRed* (red D) Σₙ) ... | PE.refl , PE.refl = let [ΣFG] = B-intr BΣ [ΣFG]₁ ⊢Γ = wf ⊢F wk[F] = [F]₁ id ⊢Γ wk[Gfstp′] = [G]₁ id ⊢Γ wk[fstp′] fstp⇒* : Γ ⊢ fst p ⇒* fst p′ ∷ U.wk id F fstp⇒* = PE.subst (λ x → Γ ⊢ _ ⇒* _ ∷ x) (PE.sym (wk-id F)) (fst-subst* ⊢F ⊢G (redₜ dₚ)) fstr⇒* = PE.subst (λ x → Γ ⊢ _ ⇒* _ ∷ x) (PE.sym (wk-id F)) (fst-subst* ⊢F ⊢G (redₜ dᵣ)) --wk[fstp≡] : Γ ⊩⟨ l ⟩ fst p ≡ fst p′ ∷ U.wk id F / wk[F] wk[fstp] , wk[fstp≡] = redSubst*Term fstp⇒* wk[F] wk[fstp′] wk[fstr] , wk[fstr≡] = redSubst*Term fstr⇒* wk[F] wk[fstr′] wk[fst≡] = irrelevanceEqTerm′ (PE.sym (wk-id F)) [F] wk[F] [fst≡] wk[fst′≡] : Γ ⊩⟨ l ⟩ fst p′ ≡ fst r′ ∷ U.wk id F / wk[F] wk[fst′≡] = transEqTerm wk[F] (symEqTerm wk[F] wk[fstp≡]) (transEqTerm wk[F] wk[fst≡] wk[fstr≡]) [p′] : Γ ⊩⟨ l ⟩ p′ ∷ Σ F ▹ G / [ΣFG] [p′] = Σₜ p′ (idRedTerm:*: (⊢u-redₜ dₚ)) p′Prod p′≅p′ wk[fstp′] wk[sndp′] [r′] = Σₜ r′ (idRedTerm:*: (⊢u-redₜ dᵣ)) r′Prod r′≅r′ wk[fstr′] wk[sndr′] sndp⇒*₁ : Γ ⊢ snd p ⇒* snd p′ ∷ G [ fst p ] sndp⇒*₁ = snd-subst* [F] [ΣFG] [p′] (redₜ dₚ) sndr⇒*₁ = snd-subst* [F] [ΣFG] [r′] (redₜ dᵣ) wk[Gfstp] = [G]₁ id ⊢Γ wk[fstp] wk[Gfstr] = [G]₁ id ⊢Γ wk[fstr] [Gfstr] = irrelevance′ (PE.cong (λ x → x [ fst r ]) (wk-lift-id G)) wk[Gfstr] wk[Gfstr′] = [G]₁ id ⊢Γ wk[fstr′] [Gfstp≡wkGfstp′] : Γ ⊩⟨ l′ ⟩ G [ fst p ] ≡ U.wk (lift id) G [ fst p′ ] / [Gfstp] [Gfstp≡wkGfstp′] = irrelevanceEq′ (PE.cong (λ x → x [ fst p ]) (wk-lift-id G)) ([G]₁ id ⊢Γ wk[fstp]) [Gfstp] (G-ext id ⊢Γ wk[fstp] wk[fstp′] wk[fstp≡]) [Gfstr≡Gfstp] : Γ ⊩⟨ _ ⟩ G [ fst r ] ≡ G [ fst p ] / [Gfstr] [Gfstr≡Gfstp] = irrelevanceEq″ (PE.cong (λ x → x [ fst r ]) (wk-lift-id G)) (PE.cong (λ x → x [ fst p ]) (wk-lift-id G)) wk[Gfstr] [Gfstr] (symEq wk[Gfstp] wk[Gfstr] (G-ext id ⊢Γ wk[fstp] wk[fstr] wk[fst≡])) [Gfstr≡wkGfstp′] : Γ ⊩⟨ l ⟩ G [ fst r ] ≡ U.wk (lift id) G [ fst p′ ] / [Gfstr] [Gfstr≡wkGfstp′] = transEq [Gfstr] [Gfstp] wk[Gfstp′] [Gfstr≡Gfstp] [Gfstp≡wkGfstp′] [wkGfstr′≡wkGfstp′] : Γ ⊩⟨ l ⟩ U.wk (lift id) G [ fst r′ ] ≡ U.wk (lift id) G [ fst p′ ] / wk[Gfstr′] [wkGfstr′≡wkGfstp′] = G-ext id ⊢Γ wk[fstr′] wk[fstp′] (symEqTerm wk[F] wk[fst′≡]) sndp⇒* : Γ ⊢ snd p ⇒* snd p′ ∷ U.wk (lift id) G [ fst p′ ] sndp⇒* = conv* sndp⇒*₁ (≅-eq (escapeEq [Gfstp] [Gfstp≡wkGfstp′])) sndr⇒* = conv* sndr⇒*₁ (≅-eq (escapeEq [Gfstr] [Gfstr≡wkGfstp′])) wk[sndp≡] : Γ ⊩⟨ l ⟩ snd p ≡ snd p′ ∷ U.wk (lift id) G [ fst p′ ] / wk[Gfstp′] wk[sndp≡] = proj₂ (redSubst*Term sndp⇒* wk[Gfstp′] wk[sndp′]) wk[sndr≡] = proj₂ (redSubst*Term sndr⇒* wk[Gfstp′] (convTerm₁ wk[Gfstr′] wk[Gfstp′] [wkGfstr′≡wkGfstp′] wk[sndr′])) wk[snd≡] : Γ ⊩⟨ l ⟩ snd p ≡ snd r ∷ U.wk (lift id) G [ fst p′ ] / wk[Gfstp′] wk[snd≡] = convEqTerm₁ [Gfstp] wk[Gfstp′] [Gfstp≡wkGfstp′] [snd≡] wk[snd′≡] : Γ ⊩⟨ l ⟩ snd p′ ≡ snd r′ ∷ U.wk (lift id) G [ fst p′ ] / wk[Gfstp′] wk[snd′≡] = transEqTerm wk[Gfstp′] (symEqTerm wk[Gfstp′] wk[sndp≡]) (transEqTerm wk[Gfstp′] wk[snd≡] wk[sndr≡]) p′≅r′ : Γ ⊢ p′ ≅ r′ ∷ Σ F ▹ G p′≅r′ = ≅-Σ-η ⊢F ⊢G (⊢u-redₜ dₚ) (⊢u-redₜ dᵣ) p′Prod r′Prod (PE.subst (λ x → Γ ⊢ _ ≅ _ ∷ x) (wk-id F) (escapeTermEq wk[F] wk[fst′≡])) (PE.subst (λ x → Γ ⊢ _ ≅ _ ∷ x [ fst p′ ]) (wk-lift-id G) (escapeTermEq wk[Gfstp′] wk[snd′≡])) in Σₜ₌ p′ r′ dₚ dᵣ p′Prod r′Prod p′≅r′ [p] [r] wk[fstp′] wk[fstr′] wk[fst′≡] wk[snd′≡] Σ-η′ [F] [Gfst] (emb 0<1 x) = Σ-η′ [F] [Gfst] x Σ-η″ : ∀ {F G p r Γ l} ([F] : Γ ⊩⟨ l ⟩ F) ([Gfst] : Γ ⊩⟨ l ⟩ G [ fst p ]) ([ΣFG] : Γ ⊩⟨ l ⟩ Σ F ▹ G) ([p] : Γ ⊩⟨ l ⟩ p ∷ Σ F ▹ G / [ΣFG]) ([r] : Γ ⊩⟨ l ⟩ r ∷ Σ F ▹ G / [ΣFG]) ([fst≡] : Γ ⊩⟨ l ⟩ fst p ≡ fst r ∷ F / [F]) ([snd≡] : Γ ⊩⟨ l ⟩ snd p ≡ snd r ∷ G [ fst p ] / [Gfst]) → Γ ⊩⟨ l ⟩ p ≡ r ∷ Σ F ▹ G / [ΣFG] Σ-η″ {F} {G} {t} {Γ} {l} [F] [Gfst] [ΣFG] [p] [r] [fst≡] [snd≡] = let [ΣFG]′ = B-intr BΣ (B-elim BΣ [ΣFG]) [p]′ = irrelevanceTerm [ΣFG] [ΣFG]′ [p] [r]′ = irrelevanceTerm [ΣFG] [ΣFG]′ [r] [p≡]′ = Σ-η′ [F] [Gfst] (B-elim BΣ [ΣFG]) [p]′ [r]′ [fst≡] [snd≡] in irrelevanceEqTerm [ΣFG]′ [ΣFG] [p≡]′ Σ-ηᵛ : ∀ {F G p r Γ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F / [Γ]) ([G] : Γ ∙ F ⊩ᵛ⟨ l ⟩ G / [Γ] ∙ [F]) → let [ΣFG] = Σᵛ {F} {G} [Γ] [F] [G] in ([p] : Γ ⊩ᵛ⟨ l ⟩ p ∷ Σ F ▹ G / [Γ] / [ΣFG]) ([r] : Γ ⊩ᵛ⟨ l ⟩ r ∷ Σ F ▹ G / [Γ] / [ΣFG]) ([fst≡] : Γ ⊩ᵛ⟨ l ⟩ fst p ≡ fst r ∷ F / [Γ] / [F]) → let [Gfst] = substS {F} {G} [Γ] [F] [G] (fstᵛ {F} {G} {p} [Γ] [F] [G] [p]) in ([snd≡] : Γ ⊩ᵛ⟨ l ⟩ snd p ≡ snd r ∷ G [ fst p ] / [Γ] / [Gfst]) → Γ ⊩ᵛ⟨ l ⟩ p ≡ r ∷ Σ F ▹ G / [Γ] / [ΣFG] Σ-ηᵛ {F} {G} {p} {r} {Γ} {l} [Γ] [F] [G] [p] [r] [fst≡] [snd≡] {Δ} {σ} ⊢Δ [σ] = let [ΣFG] = Σᵛ {F} {G} [Γ] [F] [G] [Gfst] = substS {F} {G} [Γ] [F] [G] (fstᵛ {F} {G} {p} [Γ] [F] [G] [p]) ⊩σF = proj₁ ([F] ⊢Δ [σ]) ⊩σGfst₁ = proj₁ ([Gfst] ⊢Δ [σ]) ⊩σGfst = irrelevance′ (singleSubstLift G (fst p)) ⊩σGfst₁ ⊩σΣFG = proj₁ ([ΣFG] ⊢Δ [σ]) ⊩σp = proj₁ ([p] ⊢Δ [σ]) ⊩σr = proj₁ ([r] ⊢Δ [σ]) σfst≡ = [fst≡] ⊢Δ [σ] σsnd≡₁ = [snd≡] ⊢Δ [σ] σsnd≡ = irrelevanceEqTerm′ (singleSubstLift G (fst p)) ⊩σGfst₁ ⊩σGfst σsnd≡₁ in Σ-η″ ⊩σF ⊩σGfst ⊩σΣFG ⊩σp ⊩σr σfst≡ σsnd≡
{ "alphanum_fraction": 0.4228888164, "avg_line_length": 46.1203007519, "ext": "agda", "hexsha": "aee8aa4936df9dadf3a168edf100d274c6bb2304", "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/ProdBetaEta.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/ProdBetaEta.agda", "max_line_length": 107, "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/ProdBetaEta.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5745, "size": 12268 }
Finite : Domain → Formula Finite(s) = ∃ₛ(ℕ)(n ↦ s ≼ 𝕟(n)) -- TODO: Now this means that there is an injection (s → 𝕟(n)), which is equivalent to the existance of an surjection (𝕟(n) → s) because stuff that follows from excluded middle (more specifically ((s ≼ 𝕟(n)) ↔ (𝕟(n) ≽ s))). Define ∑ (summation over finite sets) by using the existance of a finite sequence -- reduce : (_▫_ : Domain → Domain → Domain) → ⦃ _ : Commutativity(_▫_) ⦄ → ⦃ _ : Associativity(_▫_) ⦄ → ⦃ _ : Identity(_▫_) ⦄ → (s : Domain) → ⦃ _ : Finite(s) ⦄ → Domain -- reduce₀ : (_▫_ : Domain → Domain → Domain) → ⦃ _ : Commutativity(_▫_) ⦄ → ⦃ _ : Associativity(_▫_) ⦄ → (s : Domain) → ⦃ _ : Finite(s) ⦄ → Domain → Domain
{ "alphanum_fraction": 0.6132756133, "avg_line_length": 99, "ext": "agda", "hexsha": "220deb7d7d11cc35f29c7787ee41821e43da0002", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/Finite.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/Finite.agda", "max_line_length": 336, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC/Finite.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": 268, "size": 693 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Semigroup where open import Cubical.Algebra.Base public open import Cubical.Algebra.Definitions public open import Cubical.Algebra.Structures public using (IsSemigroup; issemigroup) open import Cubical.Algebra.Bundles public using (Semigroup; mksemigroup; SemigroupCarrier) open import Cubical.Structures.Carrier public open import Cubical.Algebra.Semigroup.Properties public open import Cubical.Algebra.Semigroup.Morphism public open import Cubical.Algebra.Semigroup.MorphismProperties public hiding (isPropIsSemigroup)
{ "alphanum_fraction": 0.8377926421, "avg_line_length": 42.7142857143, "ext": "agda", "hexsha": "5555a95e0c36cef8c2fedbeb00290f9114121216", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Semigroup.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Semigroup.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Semigroup.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 141, "size": 598 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Numbers.Naturals.Order.Lemmas open import Semirings.Definition open import Orders.Total.Definition open import Lists.Lists module Vectors where data Vec {a : _} (X : Set a) : ℕ -> Set a where [] : Vec X zero _,-_ : {n : ℕ} -> X -> Vec X n -> Vec X (succ n) infixr 10 _,-_ vecLen : {a : _} {X : Set a} {n : ℕ} → Vec X n → ℕ vecLen {a} {X} {n} v = n vecHead : {a : _} {X : Set a} {n : ℕ} → Vec X (succ n) → X vecHead (x ,- xs) = x vecTail : {a : _} {X : Set a} {n : ℕ} → Vec X (succ n) → Vec X n vecTail (x ,- xs) = xs vecIsHeadPlusTail : {a : _} {X : Set a} {n : ℕ} → (xs : Vec X (succ n)) → (vecHead xs ,- vecTail xs) ≡ xs vecIsHeadPlusTail (x ,- xs) = refl _+V_ : {a : _} {X : Set a} {m n : ℕ} → Vec X m → Vec X n → Vec X (m +N n) [] +V ys = ys (x ,- xs) +V ys = (x ,- (xs +V ys)) vecIndex : {a : _} {X : Set a} {m : ℕ} → Vec X m → (i : ℕ) → .(i <N m) → X vecIndex [] zero () vecIndex (x ,- vec) zero i<m = x vecIndex [] (succ i) () vecIndex (x ,- vec) (succ i) i<m = vecIndex vec i (canRemoveSuccFrom<N i<m) vecLast : {a : _} {X : Set a} {m : ℕ} → Vec X m → (0 <N m) → X vecLast {a} {X} {zero} v () vecLast {a} {X} {succ zero} (x ,- []) _ = x vecLast {a} {X} {succ (succ m)} (x ,- v) _ = vecLast v (succIsPositive m) vecLast' : {a : _} {X : Set a} {m : ℕ} → Vec X (succ m) → X vecLast' {m = m} v = vecLast v (le m (applyEquality succ (Semiring.sumZeroRight ℕSemiring m))) vecAppend : {a : _} {X : Set a} {m : ℕ} → Vec X m → (x : X) → Vec X (succ m) vecAppend {a} {X} {zero} [] x = x ,- [] vecAppend {a} {X} {succ m} (y ,- v) x = y ,- vecAppend v x vecAppendIsNowLast : {a : _} {X : Set a} {m : ℕ} → (x : X) → (v : Vec X m) → (vecLast (vecAppend v x) (succIsPositive m)) ≡ x vecAppendIsNowLast {a} {X} {zero} x [] = refl vecAppendIsNowLast {a} {X} {succ m} x (y ,- v) = vecAppendIsNowLast x v vecRev : {a : _} {X : Set a} {m : ℕ} → Vec X m → Vec X m vecRev {a} {X} {zero} [] = [] vecRev {a} {X} {succ m} (x ,- v) = vecAppend (vecRev v) x vecMoveAppend : {a : _} {X : Set a} {m : ℕ} → (x : X) → (v : Vec X m) → vecRev (vecAppend v x) ≡ x ,- vecRev v vecMoveAppend {a} {X} {.0} x [] = refl vecMoveAppend {a} {X} {.(succ _)} x (y ,- v) rewrite vecMoveAppend x v = refl vecRevRevIsId : {a : _} {X : Set a} {m : ℕ} → (v : Vec X m) → (vecRev (vecRev v)) ≡ v vecRevRevIsId {a} {X} {zero} [] = refl vecRevRevIsId {a} {X} {succ m} (x ,- v) rewrite vecMoveAppend x (vecRev v) = applyEquality (λ i → x ,- i) (vecRevRevIsId v) record vecContains {a : _} {X : Set a} {m : ℕ} (vec : Vec X m) (x : X) : Set a where field index : ℕ index<m : index <N m isHere : vecIndex vec index index<m ≡ x vecSolelyContains : {a : _} {X : Set a} → {m : X} → (n : X) → (vecContains (m ,- []) n) → m ≡ n vecSolelyContains {m} n record { index = zero ; index<m = _ ; isHere = isHere } = isHere vecSolelyContains {m} n record { index = (succ index) ; index<m = (le x proof) ; isHere = isHere } = exFalso (f {x} {index} proof) where f : {x index : ℕ} → succ (x +N succ index) ≡ 1 → False f {x} {index} pr rewrite Semiring.commutative ℕSemiring x (succ index) = naughtE (equalityCommutative (succInjective pr)) vecChop : {a : _} {X : Set a} (m : ℕ) {n : ℕ} → Vec X (m +N n) → Vec X m && Vec X n _&&_.fst (vecChop zero xs) = [] _&&_.fst (vecChop (succ m) (x ,- xs)) = (x ,- _&&_.fst (vecChop m xs)) _&&_.snd (vecChop zero xs) = xs _&&_.snd (vecChop (succ m) (x ,- xs)) = _&&_.snd (vecChop m xs) {- vecIsChopThenAppend : {a : _} {X : Set a} {m n : ℕ} (xs : Vec X m) (ys : Vec X n) → vecChop m (xs +V ys) ≡ record { fst = xs ; snd = ys } vecIsChopThenAppend {a} {X} {m} xs ys with vecChop m (xs +V ys) vecIsChopThenAppend {a} {X} {zero} [] ys | record { fst = [] ; snd = snd } = {!!} vecIsChopThenAppend {a} {X} {succ m} xs ys | bl = {!!} -} vecMap : {a b : _} {X : Set a} {Y : Set b} → (X → Y) → {n : ℕ} → Vec X n → Vec Y n vecMap f [] = [] vecMap f (x ,- vec) = f x ,- (vecMap f vec) vecMapCommutesWithAppend : {a b : _} {X : Set a} {Y : Set b} → (f : X → Y) → {n : ℕ} → (x : X) → (v : Vec X n) → (vecMap f (vecAppend v x) ≡ vecAppend (vecMap f v) (f x)) vecMapCommutesWithAppend f {.0} x [] = refl vecMapCommutesWithAppend f {.(succ _)} x (y ,- v) = applyEquality (λ i → (f y ,- i)) (vecMapCommutesWithAppend f x v) vecMapCommutesWithRev : {a b : _} {X : Set a} {Y : Set b} → (f : X → Y) → {n : ℕ} → (v : Vec X n) → (vecMap f (vecRev v) ≡ vecRev (vecMap f v)) vecMapCommutesWithRev {a} {b} {X} {Y} f {.0} [] = refl vecMapCommutesWithRev {a} {b} {X} {Y} f {.(succ _)} (x ,- v) rewrite vecMapCommutesWithAppend f x (vecRev v) = applyEquality (λ i → vecAppend i (f x)) (vecMapCommutesWithRev f v) vecIndex0AndAppend : {a : _} {X : Set a} {n : ℕ} → (v : Vec X n) → (0<n : 0 <N n) → (x : X) → vecIndex (vecAppend v x) 0 (succIsPositive n) ≡ vecIndex v 0 0<n vecIndex0AndAppend [] () x vecIndex0AndAppend (a ,- v) 0<n x = refl vecIndexMAndAppend : {a : _} {X : Set a} {n : ℕ} → (v : Vec X n) → (x : X) → (m : ℕ) → (m<n : m <N n) → (pr : m <N succ n) → vecIndex (vecAppend v x) m pr ≡ vecIndex v m m<n vecIndexMAndAppend {n = .(succ _)} (v ,- vs) x zero m<n pr = refl vecIndexMAndAppend [] x (succ m) () vecIndexMAndAppend {n = n} (y ,- v) x (succ m) m<n pr = vecIndexMAndAppend v x m (canRemoveSuccFrom<N m<n) (canRemoveSuccFrom<N pr) vecMapCompose : {a b c : _} {X : Set a} {Y : Set b} {Z : Set c} → (f : X → Y) → (g : Y → Z) → {n : ℕ} → (v : Vec X n) → (vecMap g (vecMap f v)) ≡ vecMap (λ i → g (f i)) v vecMapCompose f g [] = refl vecMapCompose f g (x ,- v) = applyEquality (λ w → (g (f x) ,- w)) (vecMapCompose f g v) vecMapIdFact : {a : _} {X : Set a} {f : X → X} (feq : (x : X) → f x ≡ x) {n : ℕ} (xs : Vec X n) → vecMap f xs ≡ xs vecMapIdFact feq [] = refl vecMapIdFact feq (x ,- xs) rewrite (feq x) | vecMapIdFact feq xs = refl vecMapCompositionFact : {a b c : _} {X : Set a} {Y : Set b} {Z : Set c} {f : Y → Z} {g : X → Y} {h : X → Z} (heq : (x : X) → f (g x) ≡ h x) → {n : ℕ} (xs : Vec X n) → vecMap f (vecMap g xs) ≡ vecMap h xs vecMapCompositionFact heq [] = refl vecMapCompositionFact {a} {b} {c} {X} {Y} {Z} {f} {g} {h} heq (x ,- xs) rewrite heq x | vecMapCompositionFact {a} {b} {c} {X} {Y} {Z} {f} {g} {h} heq xs = refl vecMapIsNatural : {a b : _} {X : Set a} {Y : Set b} (f : X → Y) → {m n : ℕ} (xs : Vec X m) (xs' : Vec X n) → vecMap f (xs +V xs') ≡ (vecMap f xs +V vecMap f xs') vecMapIsNatural f [] xs' = refl vecMapIsNatural f (x ,- xs) xs' rewrite vecMapIsNatural f xs xs' = refl vecMapAndIndex : {n : ℕ} {a b : _} {A : Set a} {B : Set b} (v : Vec A n) (f : A → B) → {a : ℕ} → (a<n : a <N n) → vecIndex (vecMap f v) a a<n ≡ f (vecIndex v a a<n) vecMapAndIndex (x ,- v) f {zero} a<n = refl vecMapAndIndex (x ,- v) f {succ a} a<n = vecMapAndIndex v f (canRemoveSuccFrom<N a<n) vecPure : {a : _} {X : Set a} → X → {n : ℕ} → Vec X n vecPure x {zero} = [] vecPure x {succ n} = x ,- vecPure x {n} vecAllTrue : {a b : _} {X : Set a} (f : X → Set b) → {n : ℕ} (v : Vec X n) → Set b vecAllTrue f [] = True' vecAllTrue f (x ,- v) = f x && vecAllTrue f v vecFold : {a b : _} {X : Set a} {S : Set b} (f : X → S → S) (s : S) {n : ℕ} (v : Vec X n) → S vecFold f s [] = s vecFold f s (x ,- v) = vecFold f (f x s) v private succLess1 : (i : ℕ) → .(succ i <N 1) → False succLess1 zero pr with <NProp pr ... | le zero () ... | le (succ x) () succLess1 (succ i) pr with <NProp pr ... | le zero () ... | le (succ x) () vecDelete : {a : _} {X : Set a} {n : ℕ} (index : ℕ) .(pr : index <N succ n) → Vec X (succ n) → Vec X n vecDelete zero _ (x ,- v) = v vecDelete (succ i) p (x ,- []) = exFalso (succLess1 i p) vecDelete (succ i) pr (x ,- (y ,- v)) = x ,- vecDelete i (canRemoveSuccFrom<N pr) (y ,- v) _$V_ : {a b : _} {X : Set a} {Y : Set b} {n : ℕ} → Vec (X → Y) n → Vec X n → Vec Y n [] $V [] = [] (f ,- fs) $V (x ,- xs) = f x ,- (fs $V xs) infixl 3 _$V_ vec : {a b : _} {X : Set a} {Y : Set b} → (X → Y) → {n : ℕ} → Vec X n → Vec Y n vec f xs = (vecPure f) $V xs vecZip : {a b : _} {X : Set a} {Y : Set b} {n : ℕ} → Vec X n → Vec Y n → Vec (X && Y) n vecZip [] [] = [] vecZip (x ,- xs) (x₁ ,- ys) = record { fst = x ; snd = x₁ } ,- vecZip xs ys vecIdentity : {a : _} {X : Set a} {f : X → X} (feq : (x : X) → f x ≡ x) → {n : ℕ} (xs : Vec X n) → (vecPure f $V xs) ≡ xs vecIdentity feq [] = refl vecIdentity feq (x ,- xs) rewrite feq x | vecIdentity feq xs = refl vecHom : {a b : _} {X : Set a} {Y : Set b} (f : X → Y) (x : X) → {n : ℕ} → (vecPure f $V vecPure x) ≡ vecPure (f x) {n} vecHom f x {zero} = refl vecHom f x {succ n} rewrite vecHom f x {n} = refl vecInterchange : {a b : _} {X : Set a} {Y : Set b} {n : ℕ} (fs : Vec (X → Y) n) (x : X) → (fs $V vecPure x) ≡ (vecPure (λ f → f x) $V fs) vecInterchange [] x = refl vecInterchange (f ,- fs) x rewrite vecInterchange fs x = refl vecComposition : {a b c : _} {X : Set a} {Y : Set b} {Z : Set c} {n : ℕ} (fs : Vec (Y → Z) n) (gs : Vec (X → Y) n) (xs : Vec X n) → (vecPure (λ i j x → i (j x)) $V fs $V gs $V xs) ≡ (fs $V (gs $V xs)) vecComposition [] [] [] = refl vecComposition (f ,- fs) (g ,- gs) (x ,- xs) rewrite vecComposition fs gs xs = refl vecToList : {a : _} {A : Set a} {n : ℕ} → (v : Vec A n) → List A vecToList [] = [] vecToList (x ,- v) = x :: vecToList v listToVec : {a : _} {A : Set a} (l : List A) → Vec A (length l) listToVec [] = [] listToVec (x :: l) = x ,- listToVec l ------------ data _<=_ : ℕ → ℕ → Set where oz : zero <= zero os : {n m : ℕ} → n <= m → succ n <= succ m o' : {n m : ℕ} → n <= m → n <= succ m all0<=4 : Vec (0 <= 4) 1 all0<=4 = o' (o' (o' (o' oz))) ,- [] all1<=4 : Vec (1 <= 4) 4 all1<=4 = (o' ((o' (o' (os oz))))) ,- ((o' (o' (os (o' oz)))) ,- ((o' (os (o' (o' oz)))) ,- ((os (o' (o' (o' oz)))) ,- []))) all2<=4 : Vec (2 <= 4) 6 all2<=4 = os (os (o' (o' oz))) ,- (os (o' (os (o' oz))) ,- (os (o' (o' (os oz))) ,- (o' (o' (os (os oz))) ,- (o' (os (o' (os oz))) ,- (o' (os (os (o' oz))) ,- []))))) all3<=4 : Vec (3 <= 4) 4 all3<=4 = os (os (os (o' oz))) ,- (os (os (o' (os oz))) ,- (os (o' (os (os oz))) ,- (o' (os (os (os oz))) ,- []))) all4<=4 : Vec (4 <= 4) 1 all4<=4 = os (os (os (os oz))) ,- [] <=Is≤N : {n m : ℕ} → (n <= m) → n ≤N m <=Is≤N {n} {m} thm with TotalOrder.totality ℕTotalOrder n m <=Is≤N {n} {m} thm | inl (inl n<m) = inl n<m <=Is≤N {n} {.n} thm | inr refl = inr refl <=Is≤N {zero} {zero} thm | inl (inr m<n) = inl m<n <=Is≤N {zero} {succ m} thm | inl (inr m<n) = inl (succIsPositive m) <=Is≤N {succ n} {zero} () | inl (inr m<n) <=Is≤N {succ n} {succ m} (os thm) | inl (inr m<n) with <=Is≤N thm <=Is≤N {succ n} {succ m} (os thm) | inl (inr m<n) | inl x = inl (succPreservesInequality x) <=Is≤N {succ n} {succ m} (os thm) | inl (inr m<n) | inr x rewrite x = inr refl <=Is≤N {succ n} {succ m} (o' thm) | inl (inr m<n) with <=Is≤N thm <=Is≤N {succ n} {succ m} (o' thm) | inl (inr m<n) | inl x with a<SuccA m ... | m<sm = inl (lessTransitive x m<sm) <=Is≤N {succ n} {succ m} (o' thm) | inl (inr m<n) | inr x rewrite x = inl (a<SuccA m) succIsNotEqual : {n : ℕ} → (succ n ≡ n) → False succIsNotEqual {zero} pr = naughtE (equalityCommutative pr) succIsNotEqual {succ n} pr = succIsNotEqual (succInjective pr) succIsNotLess : {n : ℕ} → (succ n <N n) → False succIsNotLess {zero} (le x proof) = naughtE (equalityCommutative proof) succIsNotLess {succ n} pr = succIsNotLess (canRemoveSuccFrom<N pr) noSN<=N : {n : ℕ} → (succ n) <= n → False noSN<=N {n} thm with <=Is≤N thm noSN<=N {n} thm | inl x = succIsNotLess x noSN<=N {n} thm | inr x = succIsNotEqual x no5<=4 : 5 <= 4 → False no5<=4 th = noSN<=N {4} th _<?=_ : {a : _} {X : Set a} {n m : ℕ} → (n <= m) → Vec X m → Vec X n oz <?= xs = xs os th <?= (x ,- xs) = x ,- (th <?= xs) o' th <?= (x ,- xs) = th <?= xs vMap<?=Fact : {a b : _} {X : Set a} {Y : Set b} (f : X → Y) {n m : ℕ} (th : n <= m) (xs : Vec X m) → vecMap f (th <?= xs) ≡ (th <?= vecMap f xs) vMap<?=Fact f oz xs = refl vMap<?=Fact f (os th) (x ,- xs) rewrite vMap<?=Fact f th xs = refl vMap<?=Fact f (o' th) (x ,- xs) rewrite vMap<?=Fact f th xs = refl oi : {n : ℕ} → n <= n oi {zero} = oz oi {succ n} = os oi oe : {n : ℕ} → 0 <= n oe {zero} = oz oe {succ n} = o' oe oeUnique : {n : ℕ} (th : 0 <= n) → th ≡ oe oeUnique oz = refl oeUnique (o' i) rewrite oeUnique i = refl oTooBig : {n m : ℕ} → m ≤N n → succ n <= m → False oTooBig {n} {m} m<=n th with <=Is≤N th oTooBig {n} {m} (inl m<n) th | inl x = succIsNotLess (lessTransitive x m<n) oTooBig {n} {m} (inr m=n) th | inl x rewrite m=n = succIsNotLess x oTooBig {n} {m} (inl m<n) th | inr x rewrite (equalityCommutative x) = succIsNotLess m<n oTooBig {n} {m} (inr m=n) th | inr x rewrite m=n = succIsNotEqual x oiUnique : {n : ℕ} (th : n <= n) → (th ≡ oi) oiUnique oz = refl oiUnique (os th) rewrite oiUnique th = refl oiUnique {succ n} (o' th) with oTooBig {n} {n} (inr refl) th ... | bl = exFalso bl id-<?= : {a : _} {X : Set a} {n : ℕ} (xs : Vec X n) → (oi <?= xs) ≡ xs id-<?= [] = refl id-<?= (x ,- xs) rewrite id-<?= xs = refl _o>>_ : {p n m : ℕ} → p <= n → n <= m → p <= m oz o>> th' = th' os th o>> os th' = os (th o>> th') os th o>> o' th' = os (o' th o>> th') o' th o>> os th' = o' (th o>> th') o' th o>> o' th' = o' (o' th o>> th') eqHelper : {a : _} {X : Set a} (x : X) {n : ℕ} {r s : Vec X n} (pr : r ≡ s) → (x ,- r) ≡ (x ,- s) eqHelper x pr rewrite pr = refl
{ "alphanum_fraction": 0.5304581807, "avg_line_length": 44.745819398, "ext": "agda", "hexsha": "2f50bed5137b5d0dfd1a7b2d82967e711d1d3a12", "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": "Vectors.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": "Vectors.agda", "max_line_length": 203, "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": "Vectors.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": 5845, "size": 13379 }
module Printf where import AlonzoPrelude import PreludeList import PreludeShow import PreludeString import PreludeNat open AlonzoPrelude open PreludeList hiding (_++_) open PreludeShow open PreludeString open PreludeNat data Unit : Set where unit : Unit data Format : Set where stringArg : Format natArg : Format intArg : Format floatArg : Format charArg : Format litChar : Char -> Format badFormat : Char -> Format data BadFormat (c : Char) : Set where format : String -> List Format format s = format' (toList s) where format' : List Char -> List Format format' ('%' :: 's' :: fmt) = stringArg :: format' fmt format' ('%' :: 'n' :: fmt) = natArg :: format' fmt format' ('%' :: 'd' :: fmt) = intArg :: format' fmt format' ('%' :: 'f' :: fmt) = floatArg :: format' fmt format' ('%' :: 'c' :: fmt) = charArg :: format' fmt format' ('%' :: '%' :: fmt) = litChar '%' :: format' fmt format' ('%' :: c :: fmt) = badFormat c :: format' fmt format' (c :: fmt) = litChar c :: format' fmt format' [] = [] Printf' : List Format -> Set Printf' (stringArg :: fmt) = String × Printf' fmt Printf' (natArg :: fmt) = Nat × Printf' fmt Printf' (intArg :: fmt) = Int × Printf' fmt Printf' (floatArg :: fmt) = Float × Printf' fmt Printf' (charArg :: fmt) = Char × Printf' fmt Printf' (badFormat c :: fmt) = BadFormat c Printf' (litChar _ :: fmt) = Printf' fmt Printf' [] = Unit Printf : String -> Set Printf fmt = Printf' (format fmt) {- printf' : (fmt : List Format) -> Printf' fmt -> String printf' (stringArg :: fmt) < s , args > = s ++ printf' fmt args printf' (natArg :: fmt) < n , args > = showNat n ++ printf' fmt args printf' (intArg :: fmt) < n , args > = showInt n ++ printf' fmt args printf' (floatArg :: fmt) < x , args > = showFloat x ++ printf' fmt args printf' (charArg :: fmt) < c , args > = showChar c ++ printf' fmt args printf' (litChar c :: fmt) args = fromList (c :: []) ++ printf' fmt args printf' (badFormat _ :: fmt) () printf' [] unit = "" -} printf : (fmt : String) -> Printf fmt -> String printf fmt = printf' (format fmt) where printf' : (fmt : List Format) -> Printf' fmt -> String printf' (stringArg :: fmt) < s , args > = s ++ printf' fmt args printf' (natArg :: fmt) < n , args > = showNat n ++ printf' fmt args printf' (intArg :: fmt) < n , args > = showInt n ++ printf' fmt args printf' (floatArg :: fmt) < x , args > = showFloat x ++ printf' fmt args printf' (charArg :: fmt) < c , args > = showChar c ++ printf' fmt args printf' (litChar c :: fmt) args = fromList (c :: []) ++ printf' fmt args printf' (badFormat _ :: fmt) () printf' [] unit = "" mainS : String -- mainS = printf "pi = %f" < 3.14 , unit > mainS = printf "Answer is %n, pi = %f %% %s" < 42 , < 3.14159 , < "Alonzo" , unit > > >
{ "alphanum_fraction": 0.5645595158, "avg_line_length": 35.4047619048, "ext": "agda", "hexsha": "ac35a3ab91585bfeed4f178ec50fba81ac17bcb7", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/Alonzo/Printf.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/Alonzo/Printf.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/Alonzo/Printf.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 951, "size": 2974 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.List.Relation.Unary.Any.Properties directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Any.Properties where open import Data.List.Relation.Unary.Any.Properties public
{ "alphanum_fraction": 0.4815724816, "avg_line_length": 31.3076923077, "ext": "agda", "hexsha": "d5d655df797b94019122c2b52b9d7d3273e53358", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Any/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Any/Properties.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Any/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 60, "size": 407 }
open import Function using (case_of_; _∘_) open import Data.List using (List; _++_; map) renaming (_∷_ to _,_; _∷ʳ_ to _,′_; [] to ∅) open import Data.List.Properties using (map-++-commute) open import Data.Product using () renaming (_×_ to _x'_) open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl; sym; cong) module LinearLogic (U : Set) (R : U) (⟦_⟧ᵁ : U → Set) where infixr 40 ¬_ infix 30 _⊗_ infixr 20 _⊸_ infix 4 _⊢_ data Type : Set where el : (A : U) → Type ⊥ : Type _⊗_ : Type → Type → Type _⊸_ : Type → Type → Type data _⊢_ : ∀ (X : List Type) (A : Type) → Set where var : ∀ {A} → A , ∅ ⊢ A abs : ∀ {X A B} → A , X ⊢ B → X ⊢ A ⊸ B app : ∀ {X Y A B} → X ⊢ A ⊸ B → Y ⊢ A → X ++ Y ⊢ B pair : ∀ {X Y A B} → X ⊢ A → Y ⊢ B → X ++ Y ⊢ A ⊗ B case : ∀ {X Y A B C } → X ⊢ A ⊗ B → A , B , Y ⊢ C → X ++ Y ⊢ C exch : ∀ {X Y Z W A} → (X ++ Z) ++ (Y ++ W) ⊢ A → (X ++ Y) ++ (Z ++ W) ⊢ A ¬_ : Type → Type ¬ A = A ⊸ ⊥ exch₀ : ∀ {A B C X} → A , B , X ⊢ C → B , A , X ⊢ C exch₀ {A} {B} {X = X} t = exch {∅} {B , ∅} {A , ∅} {X} t swap : ∀ {A B} → ∅ ⊢ A ⊗ B ⊸ B ⊗ A swap {A} {B} = abs (case var (exch₀ (pair var var))) raise : ∀ {A B X} → X ⊢ A → X ⊢ (A ⊸ B) ⊸ B raise t = abs (app var t) ++-assoc : ∀ {a} {A : Set a} (X Y Z : List A) → X ++ (Y ++ Z) ≡ (X ++ Y) ++ Z ++-assoc ∅ Y Z = refl ++-assoc (x , X) Y Z = cong (_,_ x) (++-assoc X Y Z) xs++[]=xs : ∀ {a} {A : Set a} (xs : List A) → xs ++ ∅ ≡ xs xs++[]=xs ∅ = refl xs++[]=xs (x , xs) = cong (_,_ x) (xs++[]=xs xs) to-front : ∀ {X A B} → A , X ⊢ B → X ,′ A ⊢ B to-front {X} {A} {B} t = lem1 lem2 where lem1 : A , (X ++ ∅) ⊢ B → X ,′ A ⊢ B lem1 = exch {∅} {X} {A , ∅} {∅} lem2 : A , (X ++ ∅) ⊢ B lem2 rewrite xs++[]=xs X = t to-back : ∀ {X A B} → X ,′ A ⊢ B → A , X ⊢ B to-back {X} {A} {B} t = lem2 where lem1 : A , X ++ ∅ ⊢ B lem1 = exch {∅} {A , ∅} {X} {∅} t lem2 : A , X ⊢ B lem2 rewrite sym (xs++[]=xs (A , X)) = lem1 YX↝XY : ∀ {A} X Y → Y ++ X ⊢ A → X ++ Y ⊢ A YX↝XY {A} X Y t = lem₃ where lem₁ : Y ++ X ++ ∅ ⊢ A lem₁ rewrite xs++[]=xs X = t lem₂ : X ++ Y ++ ∅ ⊢ A lem₂ = exch {∅} {X} {Y} {∅} lem₁ lem₃ : X ++ Y ⊢ A lem₃ = PropEq.subst (λ Y → X ++ Y ⊢ A) (xs++[]=xs Y) lem₂ Y[XZ]↝X[YZ] : ∀ {A} X Y Z → Y ++ (X ++ Z) ⊢ A → X ++ (Y ++ Z) ⊢ A Y[XZ]↝X[YZ] {A} X Y Z t = exch {∅} {X} {Y} {Z} t [YX]Z↝[XY]Z : ∀ {A} X Y Z → (Y ++ X) ++ Z ⊢ A → (X ++ Y) ++ Z ⊢ A [YX]Z↝[XY]Z {A} X Y Z t = lem₃ where lem₁ : Y ++ (X ++ Z) ⊢ A lem₁ rewrite ++-assoc Y X Z = t lem₂ : X ++ (Y ++ Z) ⊢ A lem₂ = Y[XZ]↝X[YZ] X Y Z lem₁ lem₃ : (X ++ Y) ++ Z ⊢ A lem₃ rewrite sym (++-assoc X Y Z) = lem₂ [XZ]Y↝[XY]Z : ∀ {A} X Y Z → (X ++ Z) ++ Y ⊢ A → (X ++ Y) ++ Z ⊢ A [XZ]Y↝[XY]Z {A} X Y Z t = lem₃ where lem₁ : (X ++ Z) ++ Y ++ ∅ ⊢ A lem₁ rewrite xs++[]=xs Y = t lem₂ : (X ++ Y) ++ Z ++ ∅ ⊢ A lem₂ = exch {X} {Y} {Z} {∅} lem₁ lem₃ : (X ++ Y) ++ Z ⊢ A lem₃ = PropEq.subst (λ Z → (X ++ Y) ++ Z ⊢ A) (xs++[]=xs Z) lem₂ X[ZY]↝X[YZ] : ∀ {A} X Y Z → X ++ (Z ++ Y) ⊢ A → X ++ (Y ++ Z) ⊢ A X[ZY]↝X[YZ] {A} X Y Z t = lem₃ where lem₁ : (X ++ Z) ++ Y ⊢ A lem₁ rewrite sym (++-assoc X Z Y) = t lem₂ : (X ++ Y) ++ Z ⊢ A lem₂ = [XZ]Y↝[XY]Z X Y Z lem₁ lem₃ : X ++ Y ++ Z ⊢ A lem₃ rewrite ++-assoc X Y Z = lem₂ XYZW↝XWZY : ∀ {A} X Y Z W → (X ++ Y) ++ (Z ++ W) ⊢ A → (X ++ W) ++ (Z ++ Y) ⊢ A XYZW↝XWZY {A} X Y Z W t = lem₃ where lem₁ : (X ++ Y) ++ (W ++ Z) ⊢ A lem₁ = X[ZY]↝X[YZ] (X ++ Y) W Z t lem₂ : (X ++ W) ++ (Y ++ Z) ⊢ A lem₂ = exch {X} {W} {Y} {Z} lem₁ lem₃ : (X ++ W) ++ (Z ++ Y) ⊢ A lem₃ = X[ZY]↝X[YZ] (X ++ W) Z Y lem₂ XYZW↝YWXZ : ∀ {A} X Y Z W → (X ++ Y) ++ (Z ++ W) ⊢ A → (Y ++ W) ++ (X ++ Z) ⊢ A XYZW↝YWXZ {A} X Y Z W t = lem₃ where lem₁ : (Y ++ X) ++ (Z ++ W) ⊢ A lem₁ = [YX]Z↝[XY]Z Y X (Z ++ W) t lem₂ : (Y ++ X) ++ (W ++ Z) ⊢ A lem₂ = X[ZY]↝X[YZ] (Y ++ X) W Z lem₁ lem₃ : (Y ++ W) ++ (X ++ Z) ⊢ A lem₃ = exch {Y} {W} {X} {Z} lem₂ XYZW↝ZXWY : ∀ {A} X Y Z W → (X ++ Y) ++ (Z ++ W) ⊢ A → (Z ++ X) ++ (W ++ Y) ⊢ A XYZW↝ZXWY {A} X Y Z W t = lem₃ where lem₁ : (X ++ Z) ++ (Y ++ W) ⊢ A lem₁ = exch {X} {Z} {Y} {W} t lem₂ : (Z ++ X) ++ (Y ++ W) ⊢ A lem₂ = [YX]Z↝[XY]Z Z X (Y ++ W) lem₁ lem₃ : (Z ++ X) ++ (W ++ Y) ⊢ A lem₃ = X[ZY]↝X[YZ] (Z ++ X) W Y lem₂ XYZW↝ZYXW : ∀ {A} X Y Z W → (X ++ Y) ++ (Z ++ W) ⊢ A → (Z ++ Y) ++ (X ++ W) ⊢ A XYZW↝ZYXW {A} X Y Z W t = lem₃ where lem₁ : (Y ++ X) ++ (Z ++ W) ⊢ A lem₁ = [YX]Z↝[XY]Z Y X (Z ++ W) t lem₂ : (Y ++ Z) ++ (X ++ W) ⊢ A lem₂ = exch {Y} {Z} {X} {W} lem₁ lem₃ : (Z ++ Y) ++ (X ++ W) ⊢ A lem₃ = [YX]Z↝[XY]Z Z Y (X ++ W) lem₂ pair-left : ∀ {X A B C} → A , B , X ⊢ C → A ⊗ B , X ⊢ C pair-left t = case var t pair-left′ : ∀ {X A B C} → X ++ (A , B , ∅) ⊢ C → X ,′ A ⊗ B ⊢ C pair-left′ {X} {A} {B} {C} = lem₃ where lem₁ : X ,′ A ,′ B ⊢ C → X ,′ A ⊗ B ⊢ C lem₁ t = to-front (pair-left (to-back {B , X} {A} (to-back {X ,′ A} {B} t))) lem₂ : ∀ {a} {A : Set a} xs (y z : A) → xs ,′ y ,′ z ≡ xs ++ (y , z , ∅) lem₂ ∅ y z = refl lem₂ (x , xs) y z = cong (_,_ x) (lem₂ xs y z) lem₃ : X ++ (A , B , ∅) ⊢ C → X ,′ A ⊗ B ⊢ C lem₃ rewrite sym (lem₂ X A B) = lem₁ open import IntuitionisticLogic U ⟦_⟧ᵁ as IL renaming (Type to TypeIL; _⊗_ to _×_) open IL.Explicit hiding (swap; swap′) renaming (_⊢_ to _⊢IL_; ReifyType to ReifyTypeIL; ReifyCtxt to ReiftCtxtIL; [_] to reifyIL) instance ReifyType : Reify Type TypeIL ReifyType = record { ⟦_⟧ = ⟦_⟧ } where ⟦_⟧ : Type → TypeIL ⟦ ⊥ ⟧ = el R ⟦ el A ⟧ = el A ⟦ A ⊗ B ⟧ = ⟦ A ⟧ × ⟦ B ⟧ ⟦ A ⊸ B ⟧ = ⟦ A ⟧ ⇒ ⟦ B ⟧ open Reify {{...}} using (⟦_⟧) instance ReifyCtxt : Reify (List Type) (List TypeIL) ReifyCtxt = record { ⟦_⟧ = map ⟦_⟧ } ⟦X++Y⟧=⟦X⟧++⟦Y⟧ : (X Y : List Type) → ⟦ X ++ Y ⟧ ≡ ⟦ X ⟧ ++ ⟦ Y ⟧ ⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Y = map-++-commute ⟦_⟧ X Y toIL : ∀ {X A} → X ⊢ A → ⟦ X ⟧ ⊢IL ⟦ A ⟧ toIL var = var toIL (abs t) = abs (toIL t) toIL (app {X} {Y} s t) rewrite ⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Y = app (toIL s) (toIL t) toIL (pair {X} {Y} s t) rewrite ⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Y = pair (toIL s) (toIL t) toIL (case {X} {Y} s t) rewrite ⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Y = case (toIL s) (toIL t) toIL (exch {X} {Y} {Z} {W} {A} t) = lem4 where lem1 : ⟦ (X ++ Z) ++ (Y ++ W) ⟧ ⊢IL ⟦ A ⟧ lem1 = toIL t lem2 : (⟦ X ⟧ ++ ⟦ Z ⟧) ++ (⟦ Y ⟧ ++ ⟦ W ⟧) ⊢IL ⟦ A ⟧ lem2 rewrite sym (⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Z) | sym (⟦X++Y⟧=⟦X⟧++⟦Y⟧ Y W) | sym (⟦X++Y⟧=⟦X⟧++⟦Y⟧ (X ++ Z) (Y ++ W)) = lem1 lem3 : (⟦ X ⟧ ++ ⟦ Y ⟧) ++ (⟦ Z ⟧ ++ ⟦ W ⟧) ⊢IL ⟦ A ⟧ lem3 = exch {⟦ X ⟧} {⟦ Y ⟧} {⟦ Z ⟧} {⟦ W ⟧} lem2 lem4 : ⟦ (X ++ Y) ++ (Z ++ W) ⟧ ⊢IL ⟦ A ⟧ lem4 rewrite ⟦X++Y⟧=⟦X⟧++⟦Y⟧ (X ++ Y) (Z ++ W) | ⟦X++Y⟧=⟦X⟧++⟦Y⟧ X Y | ⟦X++Y⟧=⟦X⟧++⟦Y⟧ Z W = lem3 [_] : {A : Type} {X : List Type} → X ⊢ A → (Ctxt ⟦ ⟦ X ⟧ ⟧ → ⟦ ⟦ A ⟧ ⟧) [_] = reifyIL ∘ toIL swap′ : {A B : Type} → ⟦ ⟦ A ⟧ ⟧ x' ⟦ ⟦ B ⟧ ⟧ → ⟦ ⟦ B ⟧ ⟧ x' ⟦ ⟦ A ⟧ ⟧ swap′ {A} {B} = [ swap {A} {B} ] ∅
{ "alphanum_fraction": 0.4012102449, "avg_line_length": 33.2056074766, "ext": "agda", "hexsha": "0e3e8265200a5b4def54f58a7667f0a8c7078c3d", "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": "b880cf25ed8e81b9a965ea9aad18377008d68a9f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "wenkokke/msla2014", "max_forks_repo_path": "src/LinearLogic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b880cf25ed8e81b9a965ea9aad18377008d68a9f", "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": "wenkokke/msla2014", "max_issues_repo_path": "src/LinearLogic.agda", "max_line_length": 93, "max_stars_count": 5, "max_stars_repo_head_hexsha": "b880cf25ed8e81b9a965ea9aad18377008d68a9f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/msla2014", "max_stars_repo_path": "src/LinearLogic.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-29T09:07:45.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-17T23:04:39.000Z", "num_tokens": 3834, "size": 7106 }
module Issue564 where postulate Level : Set zero : Level {-# BUILTIN LEVEL Level #-} {-# BUILTIN LEVELZERO zero #-} postulate A : Level → Set module M ℓ where postulate a : A ℓ postulate P : A zero → Set open M zero p : P a p = {!!}
{ "alphanum_fraction": 0.609375, "avg_line_length": 11.1304347826, "ext": "agda", "hexsha": "ae731d8696f42da717b6d6d633762a37b2d78f5a", "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/interaction/Issue564.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/interaction/Issue564.agda", "max_line_length": 31, "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/interaction/Issue564.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": 83, "size": 256 }
{-# OPTIONS --without-K --safe #-} -- This module primarily deals with expressions for pretty-printing, -- for the step-by-step output from the solver. open import Algebra open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Data.String using (String) open import EqBool open import Data.Bool module Polynomial.Expr.Normalising {c ℓ} (ring : RawRing c ℓ) (show : RawRing.Carrier ring → String) ⦃ _ : HasEqBool (RawRing.Carrier ring) ⦄ where open RawRing ring -- An expressions which contains some free variables. infixl 6 _⊕_ infixl 7 _⊗_ data Open : Set c where V : String → Open K : Carrier → Open _⊕_ : Open → Open → Open _⊗_ : Open → Open → Open ⊝_ : Open → Open _==O_ : Open → Open → Bool _==O_ (V v) (V y) = v == y _==O_ (K k) (K y) = k == y _==O_ (x₁ ⊕ y₁) (x₂ ⊕ y₂) = x₁ ==O x₂ ∧ y₁ ==O y₂ _==O_ (x₁ ⊗ y₁) (x₂ ⊗ y₂) = x₁ ==O x₂ ∧ y₁ ==O y₂ _==O_ (⊝ x) (⊝ y) = x ==O y _==O_ _ _ = false instance eqOpen : HasEqBool Open _==_ ⦃ eqOpen ⦄ = _==O_ -- An expression which might not have any free variables data Expr : Set c where C : Carrier → Expr O : Open → Expr instance eqExpr : HasEqBool Expr _==_ ⦃ eqExpr ⦄ (C x₁) (C x₂) = x₁ == x₂ _==_ ⦃ eqExpr ⦄ (C x₁) (O x₂) = false _==_ ⦃ eqExpr ⦄ (O x₁) (C x₂) = false _==_ ⦃ eqExpr ⦄ (O x₁) (O x₂) = x₁ == x₂ normalise : Expr → Expr normalise (C x) = C x normalise (O x) = go x where go : Open → Expr go (V v) = O (V v) go (K k) = C k go (x ⊕ y) with go x | go y go (x ⊕ y) | C x₁ | C x₂ = C (x₁ + x₂) go (x ⊕ y) | C x₁ | O x₂ = if x₁ == 0# then O x₂ else O (K x₁ ⊕ x₂) go (x ⊕ y) | O x₁ | C x₂ = if x₂ == 0# then O x₁ else O (x₁ ⊕ K x₂) go (x ⊕ y) | O x₁ | O x₂ = O (x₁ ⊕ x₂) go (x ⊗ y) with go x | go y go (x ⊗ y) | C x₁ | C x₂ = C (x₁ * x₂) go (x ⊗ y) | C x₁ | O x₂ = if x₁ == 0# then C 0# else if x₁ == 1# then O x₂ else O (K x₁ ⊗ x₂) go (x ⊗ y) | O x₁ | C x₂ = if x₂ == 0# then C 0# else if x₂ == 1# then O x₁ else O (x₁ ⊗ K x₂) go (x ⊗ y) | O x₁ | O x₂ = O (x₁ ⊗ x₂) go (⊝ x) with go x go (⊝ x) | C x₁ = C (- x₁) go (⊝ x) | O x₁ = O (⊝ x₁) open import Data.List.Kleene open import Data.Product open import Data.Nat data Flat : Set c where sum : Flat + → Flat prd : (Flat × ℕ) + → Flat neg : Flat → Flat V′ : String → Flat K′ : Carrier → Flat mutual _==F*_ : Flat * → Flat * → Bool [] ==F* [] = true [] ==F* (∹ x₁) = false (∹ x₁) ==F* [] = false (∹ x & xs) ==F* (∹ y & ys) = x ==F y ∧ xs ==F* ys _==F×*_ : (Flat × ℕ) * → (Flat × ℕ) * → Bool [] ==F×* [] = true [] ==F×* (∹ x₁) = false (∹ x₁) ==F×* [] = false (∹ (x , i) & xs) ==F×* (∹ (y , j) & ys) = i == j ∧ x ==F y ∧ xs ==F×* ys _==F_ : Flat → Flat → Bool _==F_ (sum (x & xs)) (sum (y & ys)) = x ==F y ∧ xs ==F* ys _==F_ (prd ((x , i) & xs)) (prd ((y , j) & ys)) = i == j ∧ x ==F y ∧ xs ==F×* ys _==F_ (neg xs) (neg ys) = xs ==F ys _==F_ (V′ x) (V′ y) = x == y _==F_ (K′ x) (K′ y) = x == y _==F_ _ _ = false instance eqFlat : HasEqBool Flat _==_ ⦃ eqFlat ⦄ = _==F_ prodCons : Flat → (Flat × ℕ) * → (Flat × ℕ) + prodCons x [] = (x , 0) & [] prodCons x (∹ (y , n) & xs ) with x == y prodCons x xs@((∹ (y , n) & ys )) | false = (x , 0) & xs prodCons x (∹ (y , n) & xs ) | true = (y , suc n) & xs flatten : Open → Flat flatten (V x) = V′ x flatten (K x) = K′ x flatten (x ⊕ y) = sum (x ⊕* (∹ y ⊕* [] )) where _⊕*_ : Open → Flat * → Flat + (x ⊕ y) ⊕* xs = x ⊕* (∹ y ⊕* xs ) x ⊕* xs = flatten x & xs flatten (x ⊗ y) = prd (x ⊗* (∹ y ⊗* [] )) where _⊗*_ : Open → (Flat × ℕ) * → (Flat × ℕ) + (x ⊗ y) ⊗* xs = x ⊗* (∹ y ⊗* xs ) x ⊗* xs = prodCons (flatten x) xs flatten (⊝ x) = neg (flatten x) ⟨_⟩ₑ : Expr → String ⟨ C x ⟩ₑ = show x ⟨ O x ⟩ₑ = Data.String.fromList (go add (flatten x) List.[]) where import Data.String open import Data.Char using (Char) open import Data.List.Kleene open import Data.List as List using (List; _∷_) import Data.Nat.Show data PrecLevel : Set where mul add neg′ : PrecLevel go : PrecLevel → Flat → List Char → List Char gop : (Flat × ℕ) → List Char → List Char gop (x , zero) = go mul x gop (x , suc i) xs = go neg′ x (' ' ∷ '^' ∷ ' ' ∷ Data.String.toList (Data.Nat.Show.show (suc (suc i))) List.++ (' ' ∷ xs)) f-+ : List Char → Flat * → List Char f-+ xs (∹ x & zs ) = ' ' ∷ '+' ∷ ' ' ∷ go add x (f-+ xs zs) f-+ xs [] = xs f-× : List Char → (Flat × ℕ) * → List Char f-× xs (∹ x & zs ) = ' ' ∷ '*' ∷ ' ' ∷ gop x (f-× xs zs) f-× xs [] = xs go _ (V′ x) xs = Data.String.toList x List.++ xs go _ (K′ x) xs = Data.String.toList (show x) List.++ xs go neg′ (neg x) xs = '(' ∷ '-' ∷ ' ' ∷ go neg′ x (')' ∷ xs) go _ (neg x) xs = '-' ∷ ' ' ∷ go neg′ x xs go add (sum (z & zs)) xs = go add z (f-+ xs zs) go _ (sum (z & zs)) xs = '(' ∷ go add z (f-+ (')' ∷ xs) zs) go neg′ (prd (z & zs)) xs = '(' ∷ gop z (f-× (')' ∷ xs) zs) go _ (prd (z & zs)) xs = gop z (f-× xs zs)
{ "alphanum_fraction": 0.5006060606, "avg_line_length": 29.2899408284, "ext": "agda", "hexsha": "321d132059f661f9e288bd4736256b506cb64a4e", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_path": "src/Polynomial/Expr/Normalising.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_path": "src/Polynomial/Expr/Normalising.agda", "max_line_length": 125, "max_stars_count": 36, "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_path": "src/Polynomial/Expr/Normalising.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "num_tokens": 2232, "size": 4950 }
module Data.Lens.Lens where open import Haskell.Prelude {-# FOREIGN AGDA2HS {-# LANGUAGE Rank2Types #-} #-} ---- Functors -- The const functor, for which fmap does not change its value data Const (a : Set) (b : Set) : Set where CConst : a -> Const a b getConst : {a : Set} {b : Set} -> Const a b -> a getConst (CConst a) = a instance constFunctor : {a : Set} -> Functor (Const a) constFunctor .fmap f (CConst v) = CConst v {-# COMPILE AGDA2HS Const #-} {-# COMPILE AGDA2HS getConst #-} {-# COMPILE AGDA2HS constFunctor #-} -- The identity functor, which just wraps the object data Identity (a : Set) : Set where CIdentity : a -> Identity a runIdentity : {a : Set} -> Identity a -> a runIdentity (CIdentity a) = a instance identityFunctor : Functor Identity identityFunctor .fmap f (CIdentity v) = CIdentity (f v) {-# COMPILE AGDA2HS Identity #-} {-# COMPILE AGDA2HS runIdentity #-} {-# COMPILE AGDA2HS identityFunctor #-} ---- Lens -- van Laarhoven style implementation Lens : Set -> Set -> Set₁ Lens s a = {f : Set -> Set} -> {{ff : Functor f}} -> (a -> f a) -> s -> f s {-# FOREIGN AGDA2HS type Lens s a = forall f. Functor f => (a -> f a) -> s -> f s #-} view : {a b : Set} -> Lens a b -> a -> b view lens v = getConst $ lens CConst v {-# COMPILE AGDA2HS view #-} set : {a b : Set} -> Lens a b -> b -> a -> a set lens to v = runIdentity $ lens (λ _ -> CIdentity to) v {-# COMPILE AGDA2HS set #-} over : {a b : Set} -> Lens a b -> (b -> b) -> a -> a over lens f v = runIdentity $ lens (CIdentity ∘ f) v {-# COMPILE AGDA2HS over #-}
{ "alphanum_fraction": 0.6186820218, "avg_line_length": 26.05, "ext": "agda", "hexsha": "a5eaea05b35d4f061f1e0ff12d2d99dfb0c96653", "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/Lens/Lens.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/Lens/Lens.agda", "max_line_length": 85, "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/Lens/Lens.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": 502, "size": 1563 }
module Postulate where postulate f : {A : Set} → A → A g : {A : Set} → A → A h : {A : Set} → A → A h x = f x
{ "alphanum_fraction": 0.3552631579, "avg_line_length": 6.9090909091, "ext": "agda", "hexsha": "c3ab3e6a469b6adcfe30dd43b98fe47bd0e2b996", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z", "max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msuperdock/agda-unused", "max_forks_repo_path": "data/declaration/Postulate.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "msuperdock/agda-unused", "max_issues_repo_path": "data/declaration/Postulate.agda", "max_line_length": 22, "max_stars_count": 6, "max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msuperdock/agda-unused", "max_stars_repo_path": "data/declaration/Postulate.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z", "num_tokens": 69, "size": 152 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Variable.Other {ℓ} (𝕒 : Set ℓ) where variable a b c d e f g h i j k l m : 𝕒 variable n o p q r s t u v w x y z : 𝕒
{ "alphanum_fraction": 0.6476190476, "avg_line_length": 30, "ext": "agda", "hexsha": "adfac348750e3222e81b4d79b732328414474565", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "Light/Variable/Other.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "Light/Variable/Other.agda", "max_line_length": 79, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "Light/Variable/Other.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 75, "size": 210 }
open import slots.imports open import slots.defs module slots.packed {cfg : config}(g : game cfg) where open config cfg open game g LineCombinations = Vec ℕ n ReelCombinations = Vec LineCombinations m PackedLine = Fruit × ReelNo PackedReel = Vec ℕ m PackedReels = Vec PackedReel n packReel : Reel → PackedReel packReel = L.foldl (λ r f → V.zipWith _+_ r (z V.[ f ]≔ 1)) z where z = V.replicate 0 packReels : Reels → PackedReels packReels = V.map packReel packedLength : PackedReel → ℕ packedLength = V.foldl _ _+_ 0 packedTotal : PackedReels → ℕ packedTotal = V.foldl _ (λ i r → i * packedLength r) 1 packedLineWin : PackedLine → WinTable → ℕ packedLineWin (f , r) = V.lookup r ∘ V.lookup f rproducts : ∀ {n} → Vec ℕ n → Vec ℕ n rproducts = V.foldr (Vec ℕ) (λ k ks → k ∷ V.map (k N.*_) ks) [] lproducts : ∀ {n} → Vec ℕ n → Vec ℕ n lproducts = V.foldl (Vec ℕ) (λ ks k → k ∷ V.map (k N.*_) ks) [] fruitLineCombinations : PackedReels → Fruit → LineCombinations fruitLineCombinations rs f = {!!} where g′ : PackedReel → ℕ × ℕ g′ r = #f , #f̅ where #f : ℕ #f = V.lookup f r #f̅ : ℕ #f̅ = V.sum r N.∸ #f fs,f̅s = V.unzip (V.map g′ rs) fs : Vec ℕ n fs = rproducts (proj₁ fs,f̅s) -- ts = lproducts f̅s : Vec ℕ n f̅s = proj₂ fs,f̅s -- f₀ f₁ f₂ f₃ -- f̅₀ f̅₁ f̅₂ f̅₃ -- t₀ t₁ t₂ t₃ -- f₀ f̅₁ t₂ t₃ | 1 -- f₀ f₁ f̅₂ t₃ | 2 -- f₀ f₁ f₂ f̅₃ | 3 -- f₀ f₁ f₂ f₃ | 4 fruitReelCombinations : PackedReels → ReelCombinations fruitReelCombinations rs = V.tabulate (fruitLineCombinations rs) sum2 : ∀ {n}{A : Set}{B : Set} → (A → B → ℕ) → Vec A n → Vec B n → ℕ sum2 f as bs = V.sum (V.zipWith f as bs) rtp : WinTable → ReelCombinations → ℕ rtp = sum2 (sum2 _*_)
{ "alphanum_fraction": 0.6258064516, "avg_line_length": 25.0735294118, "ext": "agda", "hexsha": "798163f8be70abcd71755f1cc49d0ae0376a2fe0", "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": "86d777ade14f63032c46bd168b76ac60d6bdf9b9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "semenov-vladyslav/slots-agda", "max_forks_repo_path": "src/slots/packed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "86d777ade14f63032c46bd168b76ac60d6bdf9b9", "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/slots-agda", "max_issues_repo_path": "src/slots/packed.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "86d777ade14f63032c46bd168b76ac60d6bdf9b9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "semenov-vladyslav/slots-agda", "max_stars_repo_path": "src/slots/packed.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 712, "size": 1705 }
module plfa.part1.Equality where data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x infix 4 _≡_ sym : ∀ {A : Set} {x y : A} → x ≡ y → y ≡ x sym refl = refl trans : ∀ {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z trans refl refl = refl cong : ∀ {A B : Set} (f : A → B) {x y : A} → x ≡ y → f x ≡ f y cong f refl = refl cong₂ : ∀ {A B C : Set} (f : A → B → C) {u x : A} {v y : B} → u ≡ x → v ≡ y → f u v ≡ f x y cong₂ f refl refl = refl cong-app : ∀ {A B : Set} {f g : A → B} → f ≡ g → ∀ (x : A) → f x ≡ g x cong-app refl x = refl subst : ∀ {A : Set} {x y : A} (P : A → Set) → x ≡ y → P x → P y subst P refl px = px data ℕ : Set where zero : ℕ suc : ℕ → ℕ _+_ : ℕ → ℕ → ℕ zero + n = n (suc m) + n = suc (m + n) postulate +-identity : ∀ (m : ℕ) → m + zero ≡ m +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n)
{ "alphanum_fraction": 0.4413875598, "avg_line_length": 22.5945945946, "ext": "agda", "hexsha": "7140ac8940f22cfbab8bd1a16cfffb570c2f1d03", "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": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "helq/old_code", "max_forks_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Equality.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "helq/old_code", "max_issues_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Equality.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "helq/old_code", "max_stars_repo_path": "proglangs-learning/Agda/plfa-exercises/part1/Equality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 403, "size": 836 }
module Class.Monad.Writer where open import Class.Monad open import Data.Product open import Data.Unit.Polymorphic open import Level open import Function private variable a : Level A : Set a record MonadWriter (M : Set a → Set a) {{_ : Monad M}} (W : Set a) : Set (suc a) where field tell : W → M ⊤ listen : M A → M (A × W) pass : M (A × (W → W)) → M A listens : {B : Set a} → (W → B) → M A → M (A × B) listens f x = do (a , w) ← listen x return (a , f w) censor : (W → W) → M A → M A censor f x = pass $ do a ← x return (a , f) open MonadWriter {{...}} public
{ "alphanum_fraction": 0.5577235772, "avg_line_length": 19.8387096774, "ext": "agda", "hexsha": "ae75aa4bd42bb0aa4e992c39555e076de831c5c5", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Class/Monad/Writer.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Class/Monad/Writer.agda", "max_line_length": 86, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Class/Monad/Writer.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 216, "size": 615 }
{-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Snd {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped as U hiding (wk) open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Weakening as T hiding (wk; wkTerm; wkEqTerm) open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Weakening open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Application open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Properties open import Definition.LogicalRelation.Substitution.Reflexivity open import Definition.LogicalRelation.Substitution.Introductions.Sigma open import Definition.LogicalRelation.Substitution.Introductions.Fst open import Definition.LogicalRelation.Substitution.Introductions.Pi open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst open import Definition.LogicalRelation.Substitution.MaybeEmbed open import Definition.LogicalRelation.Substitution.Introductions.Universe open import Tools.Product import Tools.PropositionalEquality as PE -- Valid snd term construction. sndᵛ : ∀ {F G l∃ tu Γ} ([Γ] : ⊩ᵛ Γ) → let l = ∞ [UF] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) [U∃] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) in ([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ % , ι l∃ ] / [Γ]) ([G] : Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ G ^ [ % , ι l∃ ] / [Γ] ∙ [F]) ([UG] : Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] ∙ [F]) ([Fₜ] : Γ ⊩ᵛ⟨ l ⟩ F ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] / [UF]) ([Gₜ] : Γ ∙ F ^ [ % , ι l∃ ] ⊩ᵛ⟨ l ⟩ G ∷ Univ % l∃ ^ [ ! , next l∃ ] / [Γ] ∙ [F] / (λ {Δ} {σ} → [UG] {Δ} {σ})) ([tu] : Γ ⊩ᵛ⟨ l ⟩ tu ∷ ∃ F ▹ G ^ [ % , ι l∃ ] / [Γ] / ∃ᵛ {F} {G} [Γ] [F] [G]) → Γ ⊩ᵛ⟨ l ⟩ snd tu ∷ G [ fst tu ] ^ [ % , ι l∃ ] / [Γ] / substS {F} {G} {fst tu} [Γ] [F] [G] (fstᵛ {F} {G} {l∃} {tu} {Γ} [Γ] [F] [G] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] [tu]) sndᵛ {F} {G} {l∃} {tu} {Γ} [Γ] [F] [G] [UG] [Fₜ] [Gₜ] [tu] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let [fst] = fstᵛ {F} {G} {l∃} {tu} {Γ} [Γ] [F] [G] (λ {Δ} {σ} → [UG] {Δ} {σ}) [Fₜ] [Gₜ] [tu] [G[fsttu]] = substS {F} {G} {fst tu} [Γ] [F] [G] [fst] [UF] = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) [σUF] = proj₁ ([UF] ⊢Δ [σ]) [σF] = proj₁ ([F] ⊢Δ [σ]) ⊢F = escape [σF] [σF]ₜ = proj₁ ([Fₜ] ⊢Δ [σ]) ⊢Fₜ = escapeTerm [σUF] [σF]ₜ [σUG] = proj₁ ([UG] {σ = liftSubst σ} (⊢Δ ∙ ⊢F) (liftSubstS {F = F} [Γ] ⊢Δ [F] [σ])) [σG]ₜ = proj₁ ([Gₜ] (⊢Δ ∙ ⊢F) (liftSubstS {F = F} [Γ] ⊢Δ [F] [σ])) ⊢Gₜ = escapeTerm [σUG] [σG]ₜ [σtu] = proj₁ ([tu] (⊢Δ) [σ]) [∃FG] = ∃ᵛ {F} {G} {Γ} [Γ] [F] [G] [σ∃FG] = proj₁ ([∃FG] ⊢Δ [σ]) ⊢tu = escapeTerm [σ∃FG] [σtu] ⊢snd = sndⱼ {F = subst σ F} {G = subst (liftSubst σ) G} {t = subst σ tu} ⊢Fₜ ⊢Gₜ ⊢tu [σG[fsttu]] = proj₁ ([G[fsttu]] ⊢Δ [σ]) ⊢sndSubst = PE.subst (λ x → _ ⊢ _ ∷ x ^ _) (PE.sym (singleSubstLift G (fst tu))) ⊢snd in logRelIrr [σG[fsttu]] ⊢sndSubst , (λ {σ′} [σ]′ [σ≡σ′] → logRelIrrEq [σG[fsttu]] ⊢sndSubst let [UF]′ = maybeEmbᵛ {A = Univ % _} [Γ] (Uᵛ (proj₂ (levelBounded l∃)) [Γ]) [σUF]′ = proj₁ ([UF] ⊢Δ [σ]′) [σF]′ = proj₁ ([F] ⊢Δ [σ]′) ⊢F′ = escape [σF]′ [σF]ₜ′ = proj₁ ([Fₜ] ⊢Δ [σ]′) ⊢Fₜ′ = escapeTerm [σUF]′ [σF]ₜ′ [σUG]′ = proj₁ ([UG] {σ = liftSubst σ′} (⊢Δ ∙ ⊢F′) (liftSubstS {F = F} [Γ] ⊢Δ [F] [σ]′)) [σG]ₜ′ = proj₁ ([Gₜ] (⊢Δ ∙ ⊢F′) (liftSubstS {F = F} [Γ] ⊢Δ [F] [σ]′)) ⊢Gₜ′ = escapeTerm [σUG]′ [σG]ₜ′ [σtu]′ = proj₁ ([tu] (⊢Δ) [σ]′) [σ∃FG]′ = proj₁ ([∃FG] ⊢Δ [σ]′) ⊢tu′ = escapeTerm [σ∃FG]′ [σtu]′ ⊢snd′ = sndⱼ {F = subst σ′ F} {G = subst (liftSubst σ′) G} {t = subst σ′ tu} ⊢Fₜ′ ⊢Gₜ′ ⊢tu′ [σG[fsttu]′] = proj₁ ([G[fsttu]] ⊢Δ [σ]′) ⊢sndSubst′ = PE.subst (λ x → _ ⊢ _ ∷ x ^ _) (PE.sym (singleSubstLift G (fst tu))) ⊢snd′ [σG[fsttu]≡σG[fsttu]′] = proj₂ ([G[fsttu]] ⊢Δ [σ]) [σ]′ [σ≡σ′] ⊢σG[fsttu]≡σG[fsttu]′ = escapeEq [σG[fsttu]] [σG[fsttu]≡σG[fsttu]′] in conv ⊢sndSubst′ (≅-eq (≅-sym ⊢σG[fsttu]≡σG[fsttu]′)) )
{ "alphanum_fraction": 0.5199325037, "avg_line_length": 51.5326086957, "ext": "agda", "hexsha": "87e2a41b0d5c9ff62d38d0136fc17199920e8660", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Snd.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Snd.agda", "max_line_length": 183, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Snd.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": 2162, "size": 4741 }
module plfa.part1.Naturals where import Relation.Binary.PropositionalEquality as Eq -- import Data.Nat using (ℕ; zero; suc; _+_; _*_; _^_; _∸_) open Eq using (_≡_; refl) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) -- 'refl' - the name for evidence that two terms are equal -- Agda uses underbars to indicate where terms appear in -- infix or mixfix operators: -- -- * _≡_ and _≡⟨⟩_ -- infix -- * begin_ -- prefix -- * _∎ -- postfix data ℕ : Set where zero : ℕ suc : ℕ → ℕ -- The following pragma tells Agda that ℕ corresponds to the -- natural numbers, and hence one is permitted to type 0 as -- shorthand for 'zero,' 1 as shorthand for 'suc zero'. It also -- enables a more efficient internal representation of naturals -- using the Haskell type for arbitrary-precision integers. {-# BUILTIN NATURAL ℕ #-} -- Operations on naturals are recursive functions -- The empty braces are called a hole, -- and 0 is a number used for referring to the hole ------------------------------------------------------------- -- Workflow & hotkeys: ------------------------------------------------------------- -- C-c C-l - load the current file -- C-c C-f - moves to the next hole -- C-c C-b - moves to the previous hole -- C-c C-, - displays information on the required -- type of the hole and available free vars -- C-c C-c - case split on a variable -- C-c C-SPC - give to the hole at point an expression in it -- C-c C-r - solve the case trivially (refine) -- gd - go to definition (custom key binding) ------------------------------------------------------------- _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc (m + n) -- It works because addition of larger numbers is defined in -- terms of addition of smaller numbers. Such a definition is -- called well founded. -- 0 + n ≡ n -- (1 + m) + n ≡ 1 + (m + n) -- We write '=' for definitions, while we write '≡' for -- assertions that two already defined things are the same. _ : 2 + 3 ≡ 5 _ = begin 2 + 3 ≡⟨⟩ (suc (suc zero)) + (suc (suc (suc zero))) ≡⟨⟩ suc ((suc zero) + (suc (suc (suc zero)))) ≡⟨⟩ suc (suc (zero + (suc (suc (suc zero))))) ≡⟨⟩ suc (suc (suc (suc (suc zero)))) ≡⟨⟩ 5 ∎ _ : 2 + 3 ≡ 5 _ = begin 2 + 3 ≡⟨⟩ suc (1 + 3) ≡⟨⟩ suc (suc (0 + 3)) ≡⟨⟩ suc (suc 3) ≡⟨⟩ 5 ∎ -- In fact, both proofs are longer than need be, and Agda is -- satisfied with the following: _ : 2 + 3 ≡ 5 _ = refl -- Agda knows how to compute the value of 2 + 3, and so can -- immediately check it is the same as 5. A binary relation is -- said to be reflexive if every value relates to itself. -- Evidence that a value is equal to itself is written 'refl'. -- ^ 'refl' is defined almost the -- same way as 'eq_relf' in Coq -- Excercise: _ : 3 + 4 ≡ 7 _ = begin 3 + 4 ≡⟨⟩ suc (2 + 4) ≡⟨⟩ suc (suc (1 + 4)) ≡⟨⟩ suc (suc (suc (0 + 4))) ≡⟨⟩ 7 ∎ -- Multiplication _*_ : ℕ → ℕ → ℕ zero * n = zero (suc m) * n = n + (m * n) _ = begin 2 * 3 ≡⟨⟩ -- inductive case 3 + (1 * 3) ≡⟨⟩ -- inductive case 3 + (3 + (0 * 3)) ≡⟨⟩ -- base case 3 + (3 + 0) ≡⟨⟩ -- simplify 6 ∎ -- Exercise: _^_ : ℕ → ℕ → ℕ m ^ zero = suc zero m ^ (suc n) = m * (m ^ n) _ : 3 ^ 4 ≡ 81 _ = begin 3 ^ 4 ≡⟨⟩ 3 * (3 ^ 3) ≡⟨⟩ 3 * (3 * (3 ^ 2)) ≡⟨⟩ 3 * (3 * (3 * (3 ^ 1))) ≡⟨⟩ 81 ∎ _∸_ : ℕ → ℕ → ℕ m ∸ zero = m zero ∸ suc n = zero suc m ∸ suc n = m ∸ n _ = begin 3 ∸ 2 ≡⟨⟩ 2 ∸ 1 ≡⟨⟩ 1 ∸ 0 ≡⟨⟩ 1 ∎ _ = begin 2 ∸ 3 ≡⟨⟩ 1 ∸ 2 ≡⟨⟩ 0 ∸ 1 ≡⟨⟩ 0 ∎ -- Precedence infixl 6 _+_ _∸_ infixl 7 _*_ -- Application binds more tightly than -- (or has precedence over) any operator -- Currying _ -- ℕ → ℕ → ℕ stands for ℕ → (ℕ → ℕ) -- and -- _+_ 2 3 stands for (_+_ 2) 3. -- Writing definitions interactively _+₁_ : ℕ → ℕ → ℕ zero +₁ n = n suc m +₁ n = suc (m +₁ n) -- Exercise data Bin : Set where ⟨⟩ : Bin _O : Bin → Bin _I : Bin → Bin inc : Bin → Bin inc ⟨⟩ = ⟨⟩ O inc (x O) = x I inc (x I) = inc x O _ : inc (⟨⟩ I O I I) ≡ ⟨⟩ I I O O _ = {!!} to : ℕ → Bin to zero = ⟨⟩ O to (suc m) = (to m) I _ : to 12 ≡ ⟨⟩ I O I I _ = {!!} from : Bin → ℕ from ⟨⟩ = 0 from (x O) = from x from (x I) = suc (from x) _ : from (⟨⟩ I O I I) ≡ 12 _ = {!!}
{ "alphanum_fraction": 0.5117714286, "avg_line_length": 18.0785123967, "ext": "agda", "hexsha": "fcd04406bd070647f361fdace840178825457cd6", "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": "3429c5ef0a2636330f2d4e5e77b22605102a2247", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "vyorkin/plfa", "max_forks_repo_path": "part1/Naturals.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3429c5ef0a2636330f2d4e5e77b22605102a2247", "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": "vyorkin/plfa", "max_issues_repo_path": "part1/Naturals.agda", "max_line_length": 63, "max_stars_count": null, "max_stars_repo_head_hexsha": "3429c5ef0a2636330f2d4e5e77b22605102a2247", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "vyorkin/plfa", "max_stars_repo_path": "part1/Naturals.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1723, "size": 4375 }
module FunctionsInIndices where open import Prelude open import Eq data Tree (a : Set) : ℕ -> Set where leaf : a -> Tree a 1 node : forall n₁ n₂ -> Tree a n₁ -> Tree a n₂ -> Tree a (n₁ + n₂) -- This does not work: -- leftmost : forall {a} n -> Tree a (suc n) -> a -- leftmost .0 (leaf x) = x -- leftmost .n₂ (node zero (suc n₂) l r) = leftmost l -- leftmost .(n₁ + n₂) (node (suc n₁) n₂ l r) = leftmost l module Workaround1 where private T : Set -> ℕ -> Set T a zero = ⊤ T a (suc n) = a leftmost' : forall {a n} -> Tree a n -> T a n leftmost' (leaf x) = x leftmost' (node zero zero l r) = tt leftmost' (node zero (suc n₂) l r) = leftmost' r leftmost' (node (suc n₁) n₂ l r) = leftmost' l leftmost : forall {a n} -> Tree a (suc n) -> a leftmost = leftmost' module Workaround2 where private leftmost' : forall {a n m} -> Tree a m -> m ≡ suc n -> a leftmost' (leaf x) _ = x leftmost' (node zero (suc n₂) l r) _ = leftmost' r refl leftmost' (node (suc n₁) n₂ l r) _ = leftmost' l refl leftmost : forall {a n} -> Tree a (suc n) -> a leftmost t = leftmost' t refl
{ "alphanum_fraction": 0.5271132376, "avg_line_length": 27.8666666667, "ext": "agda", "hexsha": "2c8291247ec11f75cb5861aed5778ab3e4ff4625", "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/FunctionsInIndices.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/FunctionsInIndices.agda", "max_line_length": 67, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/FunctionsInIndices.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": 450, "size": 1254 }
{-# OPTIONS --experimental-irrelevance #-} -- {-# OPTIONS -v tc.lhs:20 #-} module ShapeIrrelevantIndex where data Nat : Set where Z : Nat S : Nat → Nat data Good : ..(_ : Nat) → Set where goo : .(n : Nat) → Good (S n) bad : .(n : Nat) → Good n → Nat bad .(S n) (goo n) = n
{ "alphanum_fraction": 0.5653710247, "avg_line_length": 20.2142857143, "ext": "agda", "hexsha": "2776b27e954fc29822a6533654f65e3fcd856914", "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/ShapeIrrelevantIndex.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/ShapeIrrelevantIndex.agda", "max_line_length": 42, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/ShapeIrrelevantIndex.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": 101, "size": 283 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- From: Peter Dybjer. Comparing integrated and external logics of -- functional programs. Science of Computer Programming, 14:59–79, -- 1990 module Norm where postulate Char : Set data Atom : Set where True False : Atom Var : Char → Atom data Exp : Set where at : Atom → Exp if : Exp → Exp → Exp → Exp -- Agda doesn't recognize the termination of the function. {-# TERMINATING #-} norm : Exp → Exp norm (at a) = at a norm (if (at a) y z) = if (at a) (norm y) (norm z) norm (if (if u v w) y z) = norm (if u (if v y z) (if w y z))
{ "alphanum_fraction": 0.5824324324, "avg_line_length": 26.4285714286, "ext": "agda", "hexsha": "6b97b0b220c3b37e483ce4543a0839aa49383323", "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/Norm.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/Norm.agda", "max_line_length": 66, "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/Norm.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": 210, "size": 740 }
module Ferros.Resource.CNode where open import Ferros.Resource.CNode.Base public
{ "alphanum_fraction": 0.8313253012, "avg_line_length": 20.75, "ext": "agda", "hexsha": "2f60c8d7bf72d8198da23f31ef4345d378570c29", "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": "8759d36ac9ec24c53f226a60fa3811eb1d4e5d93", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "auxoncorp/ferros-spec", "max_forks_repo_path": "Ferros/Resource/CNode.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8759d36ac9ec24c53f226a60fa3811eb1d4e5d93", "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": "auxoncorp/ferros-spec", "max_issues_repo_path": "Ferros/Resource/CNode.agda", "max_line_length": 46, "max_stars_count": 3, "max_stars_repo_head_hexsha": "8759d36ac9ec24c53f226a60fa3811eb1d4e5d93", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "auxoncorp/ferros-spec", "max_stars_repo_path": "Ferros/Resource/CNode.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-27T23:18:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-09-11T01:06:56.000Z", "num_tokens": 18, "size": 83 }
{-# OPTIONS --without-K --rewriting #-} module Basics where open import Base public open import PropT public open import hSet public open import lib.Basics public
{ "alphanum_fraction": 0.765060241, "avg_line_length": 16.6, "ext": "agda", "hexsha": "22b2436fc0bc1880ca0543ca0048696cf538c464", "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/Basics.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/Basics.agda", "max_line_length": 39, "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/Basics.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": 37, "size": 166 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Monoidal.Structure using (SymmetricMonoidalCategory) module Categories.Functor.Monoidal.Symmetric {o o′ ℓ ℓ′ e e′} (C : SymmetricMonoidalCategory o ℓ e) (D : SymmetricMonoidalCategory o′ ℓ′ e′) where open import Level open import Data.Product using (_,_) open import Categories.Category using (module Commutation) open import Categories.Functor using (Functor) open import Categories.Functor.Monoidal open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism) open NaturalIsomorphism private module C = SymmetricMonoidalCategory C module D = SymmetricMonoidalCategory D module Lax where -- Lax symmetric monoidal functors. record IsSymmetricMonoidalFunctor (F : Functor C.U D.U) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where open Functor F field isMonoidal : IsMonoidalFunctor C.monoidalCategory D.monoidalCategory F open IsMonoidalFunctor isMonoidal public open D open Commutation D.U -- coherence condition field braiding-compat : ∀ {X Y} → [ F₀ X ⊗₀ F₀ Y ⇒ F₀ (Y C.⊗₀ X) ]⟨ ⊗-homo.η (X , Y) ⇒⟨ F₀ (X C.⊗₀ Y) ⟩ F₁ (C.braiding.⇒.η (X , Y)) ≈ D.braiding.⇒.η (F₀ X , F₀ Y) ⇒⟨ F₀ Y ⊗₀ F₀ X ⟩ ⊗-homo.η (Y , X) ⟩ record SymmetricMonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where field F : Functor C.U D.U isSymmetricMonoidal : IsSymmetricMonoidalFunctor F open Functor F public open IsSymmetricMonoidalFunctor isSymmetricMonoidal public monoidalFunctor : MonoidalFunctor C.monoidalCategory D.monoidalCategory monoidalFunctor = record { F = F ; isMonoidal = isMonoidal } module Strong where -- Strong symmetric monoidal functors. record IsSymmetricMonoidalFunctor (F : Functor C.U D.U) : Set (o ⊔ ℓ ⊔ ℓ′ ⊔ e′) where open Functor F field isStrongMonoidal : IsStrongMonoidalFunctor C.monoidalCategory D.monoidalCategory F open IsStrongMonoidalFunctor isStrongMonoidal public open D open Commutation D.U -- coherence condition field braiding-compat : ∀ {X Y} → [ F₀ X ⊗₀ F₀ Y ⇒ F₀ (Y C.⊗₀ X) ]⟨ ⊗-homo.⇒.η (X , Y) ⇒⟨ F₀ (X C.⊗₀ Y) ⟩ F₁ (C.braiding.⇒.η (X , Y)) ≈ D.braiding.⇒.η (F₀ X , F₀ Y) ⇒⟨ F₀ Y ⊗₀ F₀ X ⟩ ⊗-homo.⇒.η (Y , X) ⟩ isLaxSymmetricMonoidal : Lax.IsSymmetricMonoidalFunctor F isLaxSymmetricMonoidal = record { isMonoidal = isMonoidal ; braiding-compat = braiding-compat } record SymmetricMonoidalFunctor : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where field F : Functor C.U D.U isSymmetricMonoidal : IsSymmetricMonoidalFunctor F open Functor F public open IsSymmetricMonoidalFunctor isSymmetricMonoidal public monoidalFunctor : StrongMonoidalFunctor C.monoidalCategory D.monoidalCategory monoidalFunctor = record { F = F ; isStrongMonoidal = isStrongMonoidal }
{ "alphanum_fraction": 0.5882178804, "avg_line_length": 31.8679245283, "ext": "agda", "hexsha": "033c4bd9c34ef79d2e436c19ad81fef9860f3e9e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "d07746023503cc8f49670e309a6170dc4b404b95", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Monoidal/Symmetric.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d07746023503cc8f49670e309a6170dc4b404b95", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Monoidal/Symmetric.agda", "max_line_length": 80, "max_stars_count": 1, "max_stars_repo_head_hexsha": "3ef03f73bce18f1efba2890df9ddf3d76ed2de32", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "FintanH/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Monoidal/Symmetric.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-18T18:21:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-18T18:21:47.000Z", "num_tokens": 1018, "size": 3378 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Finite sets ------------------------------------------------------------------------ -- Note that elements of Fin n can be seen as natural numbers in the -- set {m | m < n}. The notation "m" in comments below refers to this -- natural number view. {-# OPTIONS --without-K --safe #-} module Data.Fin.Base where open import Data.Empty using (⊥-elim) open import Data.Nat as ℕ using (ℕ; zero; suc; z≤n; s≤s) open import Function using (_∘_; _on_) open import Level using () renaming (zero to ℓ₀) open import Relation.Nullary using (yes; no) open import Relation.Nullary.Decidable using (True; toWitness) open import Relation.Binary open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; cong) ------------------------------------------------------------------------ -- Types -- Fin n is a type with n elements. data Fin : ℕ → Set where zero : {n : ℕ} → Fin (suc n) suc : {n : ℕ} (i : Fin n) → Fin (suc n) -- A conversion: toℕ "i" = i. toℕ : ∀ {n} → Fin n → ℕ toℕ zero = 0 toℕ (suc i) = suc (toℕ i) -- A Fin-indexed variant of Fin. Fin′ : ∀ {n} → Fin n → Set Fin′ i = Fin (toℕ i) ------------------------------------------------------------------------ -- A cast that actually computes on constructors (as opposed to subst) cast : ∀ {m n} → .(_ : m ≡ n) → Fin m → Fin n cast {zero} {zero} eq k = k cast {suc m} {suc n} eq zero = zero cast {suc m} {suc n} eq (suc k) = suc (cast (cong ℕ.pred eq) k) cast {zero} {suc n} () cast {suc m} {zero} () ------------------------------------------------------------------------ -- Conversions -- toℕ is defined above. -- fromℕ n = "n". fromℕ : (n : ℕ) → Fin (suc n) fromℕ zero = zero fromℕ (suc n) = suc (fromℕ n) -- fromℕ≤ {m} _ = "m". fromℕ≤ : ∀ {m n} → m ℕ.< n → Fin n fromℕ≤ (s≤s z≤n) = zero fromℕ≤ (s≤s (s≤s m≤n)) = suc (fromℕ≤ (s≤s m≤n)) -- fromℕ≤″ m _ = "m". fromℕ≤″ : ∀ m {n} → m ℕ.<″ n → Fin n fromℕ≤″ zero (ℕ.less-than-or-equal refl) = zero fromℕ≤″ (suc m) (ℕ.less-than-or-equal refl) = suc (fromℕ≤″ m (ℕ.less-than-or-equal refl)) -- # m = "m". infix 10 #_ #_ : ∀ m {n} {m<n : True (suc m ℕ.≤? n)} → Fin n #_ _ {m<n = m<n} = fromℕ≤ (toWitness m<n) -- raise m "i" = "m + i". raise : ∀ {m} n → Fin m → Fin (n ℕ.+ m) raise zero i = i raise (suc n) i = suc (raise n i) -- reduce≥ "m + i" _ = "i". reduce≥ : ∀ {m n} (i : Fin (m ℕ.+ n)) (i≥m : toℕ i ℕ.≥ m) → Fin n reduce≥ {zero} i i≥m = i reduce≥ {suc m} zero () reduce≥ {suc m} (suc i) (s≤s i≥m) = reduce≥ i i≥m -- inject⋆ m "i" = "i". inject : ∀ {n} {i : Fin n} → Fin′ i → Fin n inject {i = zero} () inject {i = suc i} zero = zero inject {i = suc i} (suc j) = suc (inject j) inject! : ∀ {n} {i : Fin (suc n)} → Fin′ i → Fin n inject! {n = zero} {i = suc ()} _ inject! {i = zero} () inject! {n = suc _} {i = suc _} zero = zero inject! {n = suc _} {i = suc _} (suc j) = suc (inject! j) inject+ : ∀ {m} n → Fin m → Fin (m ℕ.+ n) inject+ n zero = zero inject+ n (suc i) = suc (inject+ n i) inject₁ : ∀ {m} → Fin m → Fin (suc m) inject₁ zero = zero inject₁ (suc i) = suc (inject₁ i) inject≤ : ∀ {m n} → Fin m → m ℕ.≤ n → Fin n inject≤ zero (s≤s le) = zero inject≤ (suc i) (s≤s le) = suc (inject≤ i le) -- lower₁ "i" _ = "i". lower₁ : ∀ {n} → (i : Fin (suc n)) → (n ≢ toℕ i) → Fin n lower₁ {zero} zero ne = ⊥-elim (ne refl) lower₁ {zero} (suc ()) _ lower₁ {suc n} zero _ = zero lower₁ {suc n} (suc i) ne = suc (lower₁ i λ x → ne (cong suc x)) -- A strengthening injection into the minimal Fin fibre. strengthen : ∀ {n} (i : Fin n) → Fin′ (suc i) strengthen zero = zero strengthen (suc i) = suc (strengthen i) ------------------------------------------------------------------------ -- Operations -- Folds. fold : ∀ {t} (T : ℕ → Set t) {m} → (∀ {n} → T n → T (suc n)) → (∀ {n} → T (suc n)) → Fin m → T m fold T f x zero = x fold T f x (suc i) = f (fold T f x i) fold′ : ∀ {n t} (T : Fin (suc n) → Set t) → (∀ i → T (inject₁ i) → T (suc i)) → T zero → ∀ i → T i fold′ T f x zero = x fold′ {n = zero} T f x (suc ()) fold′ {n = suc n} T f x (suc i) = f i (fold′ (T ∘ inject₁) (f ∘ inject₁) x i) -- Lifts functions. lift : ∀ {m n} k → (Fin m → Fin n) → Fin (k ℕ.+ m) → Fin (k ℕ.+ n) lift zero f i = f i lift (suc k) f zero = zero lift (suc k) f (suc i) = suc (lift k f i) -- "i" + "j" = "i + j". infixl 6 _+_ _+_ : ∀ {m n} (i : Fin m) (j : Fin n) → Fin (toℕ i ℕ.+ n) zero + j = j suc i + j = suc (i + j) -- "i" - "j" = "i ∸ j". infixl 6 _-_ _-_ : ∀ {m} (i : Fin m) (j : Fin′ (suc i)) → Fin (m ℕ.∸ toℕ j) i - zero = i zero - suc () suc i - suc j = i - j -- m ℕ- "i" = "m ∸ i". infixl 6 _ℕ-_ _ℕ-_ : (n : ℕ) (j : Fin (suc n)) → Fin (suc n ℕ.∸ toℕ j) n ℕ- zero = fromℕ n zero ℕ- suc () suc n ℕ- suc i = n ℕ- i -- m ℕ-ℕ "i" = m ∸ i. infixl 6 _ℕ-ℕ_ _ℕ-ℕ_ : (n : ℕ) → Fin (suc n) → ℕ n ℕ-ℕ zero = n zero ℕ-ℕ suc () suc n ℕ-ℕ suc i = n ℕ-ℕ i -- pred "i" = "pred i". pred : ∀ {n} → Fin n → Fin n pred zero = zero pred (suc i) = inject₁ i -- The function f(i,j) = if j>i then j-1 else j -- This is a variant of the thick function from Conor -- McBride's "First-order unification by structural recursion". punchOut : ∀ {m} {i j : Fin (suc m)} → i ≢ j → Fin m punchOut {_} {zero} {zero} i≢j = ⊥-elim (i≢j refl) punchOut {_} {zero} {suc j} _ = j punchOut {zero} {suc ()} punchOut {suc m} {suc i} {zero} _ = zero punchOut {suc m} {suc i} {suc j} i≢j = suc (punchOut (i≢j ∘ cong suc)) -- The function f(i,j) = if j≥i then j+1 else j punchIn : ∀ {m} → Fin (suc m) → Fin m → Fin (suc m) punchIn zero j = suc j punchIn (suc i) zero = zero punchIn (suc i) (suc j) = suc (punchIn i j) ------------------------------------------------------------------------ -- Order relations infix 4 _≤_ _<_ _≤_ : ∀ {n} → Rel (Fin n) ℓ₀ _≤_ = ℕ._≤_ on toℕ _<_ : ∀ {n} → Rel (Fin n) ℓ₀ _<_ = ℕ._<_ on toℕ data _≺_ : ℕ → ℕ → Set where _≻toℕ_ : ∀ n (i : Fin n) → toℕ i ≺ n ------------------------------------------------------------------------ -- An ordering view. data Ordering {n : ℕ} : Fin n → Fin n → Set where less : ∀ greatest (least : Fin′ greatest) → Ordering (inject least) greatest equal : ∀ i → Ordering i i greater : ∀ greatest (least : Fin′ greatest) → Ordering greatest (inject least) compare : ∀ {n} (i j : Fin n) → Ordering i j compare zero zero = equal zero compare zero (suc j) = less (suc j) zero compare (suc i) zero = greater (suc i) zero compare (suc i) (suc j) with compare i j compare (suc .(inject least)) (suc .greatest) | less greatest least = less (suc greatest) (suc least) compare (suc .greatest) (suc .(inject least)) | greater greatest least = greater (suc greatest) (suc least) compare (suc .i) (suc .i) | equal i = equal (suc i)
{ "alphanum_fraction": 0.4897494305, "avg_line_length": 27.0153846154, "ext": "agda", "hexsha": "581611d1662519059668fdc93d65d5e1acf8eb5c", "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/Fin/Base.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/Fin/Base.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Fin/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2732, "size": 7024 }
{-# OPTIONS --allow-unsolved-metas #-} postulate A : Set data Unit : Set where unit : Unit F : Unit → Set F unit = A postulate P : {A : Set} → A → Set Q : ∀ {x} → F x → Set f : ∀ {x} {y : F x} (z : Q y) → P z variable x : Unit y : F x g : (z : Q y) → P z g z with f z ... | p = p
{ "alphanum_fraction": 0.4766666667, "avg_line_length": 12.5, "ext": "agda", "hexsha": "b4dfd4750e5d1041478ba673a2dc838b8f7e3897", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue3673.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue3673.agda", "max_line_length": 38, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue3673.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": 300 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Categories.Instances.EilenbergMoore where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism renaming (Iso to _≅_) open import Cubical.Foundations.Univalence open import Cubical.Categories.Category open import Cubical.Categories.Functor renaming (𝟙⟨_⟩ to funcId) open import Cubical.Categories.NaturalTransformation.Base open import Cubical.Categories.Monad.Base open import Cubical.Categories.Instances.FunctorAlgebras open import Cubical.Categories.Constructions.FullSubcategory open import Cubical.Categories.Adjoint private variable ℓC ℓC' : Level module _ {C : Category ℓC ℓC'} (monadM : Monad C) where private M : Functor C C M = fst monadM --open Category private module C = Category C open Functor open NatTrans open IsMonad (snd monadM) record IsEMAlgebra (algA : Algebra M) : Type ℓC' where constructor proveEMAlgebra open Algebra algA field str-η : str C.∘ N-ob η carrier ≡ C.id str-μ : str C.∘ N-ob μ carrier ≡ str C.∘ F-hom M str open IsEMAlgebra isPropIsEMAlgebra : ∀ {algA} → isProp (IsEMAlgebra algA) isPropIsEMAlgebra {algA} isalg isalg' = cong₂ proveEMAlgebra (C.isSetHom _ _ (str-η isalg) (str-η isalg')) (C.isSetHom _ _ (str-μ isalg) (str-μ isalg')) EMAlgebra : Type (ℓ-max ℓC ℓC') EMAlgebra = Σ[ algA ∈ Algebra M ] IsEMAlgebra algA EMCategory : Category (ℓ-max (ℓ-max ℓC ℓC') ℓC') ℓC' -- cannot simplify level: --experimental-lossy-unification won't allow it. EMCategory = FullSubcategory (AlgebrasCategory M) IsEMAlgebra ForgetEM : Functor EMCategory (AlgebrasCategory M) ForgetEM = FullInclusion (AlgebrasCategory M) IsEMAlgebra ForgetEMAlgebra : Functor EMCategory C ForgetEMAlgebra = funcComp (ForgetAlgebra M) ForgetEM open Algebra freeEMAlgebra : C.ob → EMAlgebra carrier (fst (freeEMAlgebra x)) = F-ob M x str (fst (freeEMAlgebra x)) = N-ob μ x str-η (snd (freeEMAlgebra x)) = lemma where lemma : N-ob η (F-ob M x) C.⋆ N-ob μ x ≡ C.id lemma = funExt⁻ (congP (λ i → N-ob) idl-μ) x str-μ (snd (freeEMAlgebra x)) = lemma where lemma : N-ob μ (F-ob M x) C.⋆ N-ob μ x ≡ F-hom M (N-ob μ x) C.⋆ N-ob μ x lemma = funExt⁻ (congP (λ i → N-ob) (symP-fromGoal assoc-μ)) x open AlgebraHom FreeEMAlgebra : Functor C EMCategory F-ob FreeEMAlgebra x = freeEMAlgebra x carrierHom (F-hom FreeEMAlgebra {x} {y} φ) = F-hom M φ strHom (F-hom FreeEMAlgebra {x} {y} φ) = sym (N-hom μ φ) F-id FreeEMAlgebra = AlgebraHom≡ M (F-id M) F-seq FreeEMAlgebra {x} {y} {z} φ ψ = AlgebraHom≡ M (F-seq M φ ψ) ForgetFreeEMAlgebra : funcComp ForgetEMAlgebra FreeEMAlgebra ≡ M ForgetFreeEMAlgebra = Functor≡ (λ x → refl) (λ f → refl) emCounit : NatTrans (funcComp FreeEMAlgebra ForgetEMAlgebra) (funcId EMCategory) carrierHom (N-ob emCounit (algebra A α , isEMA)) = α strHom (N-ob emCounit (algebra A α , isEMA)) = str-μ isEMA N-hom emCounit {algebra A α , isEMA} {algebra B β , isEMB} (algebraHom f isalgF) = AlgebraHom≡ M (sym (isalgF)) open NaturalBijection open _⊣_ open _≅_ emBijection : ∀ a emB → (EMCategory [ FreeEMAlgebra ⟅ a ⟆ , emB ]) ≅ (C [ a , ForgetEMAlgebra ⟅ emB ⟆ ]) fun (emBijection a (algebra b β , isEMB)) (algebraHom f isalgF) = f C.∘ N-ob η a carrierHom (inv (emBijection a (algebra b β , isEMB)) f) = β C.∘ F-hom M f strHom (inv (emBijection a (algebra b β , isEMB)) f) = (N-ob μ a C.⋆ (F-hom M f C.⋆ β)) ≡⟨ sym (C.⋆Assoc _ _ _) ⟩ ((N-ob μ a C.⋆ F-hom M f) C.⋆ β) ≡⟨ cong (C._⋆ β) (sym (N-hom μ f)) ⟩ ((F-hom M (F-hom M f) C.⋆ N-ob μ b) C.⋆ β) ≡⟨ C.⋆Assoc _ _ _ ⟩ (F-hom M (F-hom M f) C.⋆ (N-ob μ b C.⋆ β)) ≡⟨ cong (F-hom M (F-hom M f) C.⋆_) (str-μ isEMB) ⟩ (F-hom M (F-hom M f) C.⋆ (F-hom M β C.⋆ β)) ≡⟨ sym (C.⋆Assoc _ _ _) ⟩ ((F-hom M (F-hom M f) C.⋆ F-hom M β) C.⋆ β) ≡⟨ cong (C._⋆ β) (sym (F-seq M _ _)) ⟩ (F-hom M (F-hom M f C.⋆ β) C.⋆ β) ∎ rightInv (emBijection a (algebra b β , isEMB)) f = (N-ob η a C.⋆ (F-hom M f C.⋆ β)) ≡⟨ sym (C.⋆Assoc _ _ _) ⟩ ((N-ob η a C.⋆ F-hom M f) C.⋆ β) ≡⟨ cong (C._⋆ β) (sym (N-hom η f)) ⟩ ((f C.⋆ N-ob η b) C.⋆ β) ≡⟨ C.⋆Assoc _ _ _ ⟩ (f C.⋆ (N-ob η b C.⋆ β)) ≡⟨ cong (f C.⋆_) (str-η isEMB) ⟩ (f C.⋆ C.id) ≡⟨ C.⋆IdR _ ⟩ f ∎ leftInv (emBijection a (algebra b β , isEMB)) (algebraHom f isalgF) = AlgebraHom≡ M ( (F-hom M (N-ob η a C.⋆ f) C.⋆ β) ≡⟨ cong (C._⋆ β) (F-seq M _ _) ⟩ ((F-hom M (N-ob η a) C.⋆ F-hom M f) C.⋆ β) ≡⟨ C.⋆Assoc _ _ _ ⟩ (F-hom M (N-ob η a) C.⋆ (F-hom M f C.⋆ β)) ≡⟨ cong (F-hom M (N-ob η a) C.⋆_) (sym isalgF) ⟩ (F-hom M (N-ob η a) C.⋆ (N-ob μ a C.⋆ f)) ≡⟨ sym (C.⋆Assoc _ _ _) ⟩ ((F-hom M (N-ob η a) C.⋆ N-ob μ a) C.⋆ f) ≡⟨ cong (C._⋆ f) (funExt⁻ (congP (λ i → N-ob) idr-μ) a) ⟩ (C.id C.⋆ f) ≡⟨ C.⋆IdL f ⟩ f ∎ ) emAdjunction : FreeEMAlgebra ⊣ ForgetEMAlgebra adjIso emAdjunction {a} {algebra b β , isEMB} = emBijection a (algebra b β , isEMB) adjNatInD emAdjunction {a} {algebra b β , isEMB} {algebra c γ , isEMC} (algebraHom f isalgF) (algebraHom g isalgG) = sym (C.⋆Assoc _ _ _) adjNatInC emAdjunction {a} {b} {algebra c γ , isEMC} f g = AlgebraHom≡ M ( (F-hom M (g C.⋆ f) C.⋆ γ) ≡⟨ cong (C._⋆ γ) (F-seq M _ _) ⟩ ((F-hom M g C.⋆ F-hom M f) C.⋆ γ) ≡⟨ C.⋆Assoc _ _ _ ⟩ (F-hom M g C.⋆ (F-hom M f C.⋆ γ)) ∎ ) module _ {C : Category ℓC ℓC'} {monadM monadN : Monad C} (monadν : MonadHom monadM monadN) where open Category C open Functor open IsEMAlgebra open NatTrans private M N : Functor C C M = fst monadM N = fst monadN module M = IsMonad (snd monadM) module N = IsMonad (snd monadN) ν : NatTrans M N ν = fst monadν module ν = IsMonadHom (snd monadν) mapIsEMAlgebra : (algA : Algebra N) → IsEMAlgebra monadN algA → IsEMAlgebra monadM (F-ob (AlgebrasFunctor ν) algA) str-η (mapIsEMAlgebra (algebra a αN) isEMA) = N-ob M.η a ⋆ (N-ob ν a ⋆ αN) ≡⟨ sym (⋆Assoc _ _ _) ⟩ (N-ob M.η a ⋆ N-ob ν a) ⋆ αN ≡⟨ cong (_⋆ αN) (cong (λ θ → N-ob θ a) ν.N-η) ⟩ N-ob N.η a ⋆ αN ≡⟨ isEMA .str-η ⟩ id ∎ str-μ (mapIsEMAlgebra (algebra a αN) isEMA) = N-ob M.μ a ⋆ (N-ob ν a ⋆ αN) ≡⟨ sym (⋆Assoc _ _ _) ⟩ (N-ob M.μ a ⋆ N-ob ν a) ⋆ αN ≡⟨ cong (_⋆ αN) (cong (λ θ → N-ob θ a) ν.N-μ) ⟩ ((F-hom M (N-ob ν a) ⋆ N-ob ν (F-ob N a)) ⋆ N-ob N.μ a) ⋆ αN ≡⟨ ⋆Assoc _ _ _ ⟩ (F-hom M (N-ob ν a) ⋆ N-ob ν (F-ob N a)) ⋆ (N-ob N.μ a ⋆ αN) ≡⟨ cong ((F-hom M (N-ob ν a) ⋆ N-ob ν (F-ob N a)) ⋆_) (isEMA .str-μ) ⟩ (F-hom M (N-ob ν a) ⋆ N-ob ν (F-ob N a)) ⋆ (F-hom N αN ⋆ αN) ≡⟨ sym (⋆Assoc _ _ _) ⟩ ((F-hom M (N-ob ν a) ⋆ N-ob ν (F-ob N a)) ⋆ F-hom N αN) ⋆ αN ≡⟨ cong (_⋆ αN) (⋆Assoc _ _ _) ⟩ (F-hom M (N-ob ν a) ⋆ (N-ob ν (F-ob N a) ⋆ F-hom N αN)) ⋆ αN ≡⟨ cong (_⋆ αN) (cong (F-hom M (N-ob ν a) ⋆_) (sym (N-hom ν αN))) ⟩ (F-hom M (N-ob ν a) ⋆ (F-hom M αN ⋆ N-ob ν a)) ⋆ αN ≡⟨ cong (_⋆ αN) (sym (⋆Assoc _ _ _)) ⟩ ((F-hom M (N-ob ν a) ⋆ F-hom M αN) ⋆ N-ob ν a) ⋆ αN ≡⟨ cong (_⋆ αN) (cong (_⋆ N-ob ν a) (sym (F-seq M _ _))) ⟩ (F-hom M (N-ob ν a ⋆ αN) ⋆ N-ob ν a) ⋆ αN ≡⟨ ⋆Assoc _ _ _ ⟩ F-hom M (N-ob ν a ⋆ αN) ⋆ (N-ob ν a ⋆ αN) ∎ EMFunctor : Functor (EMCategory monadN) (EMCategory monadM) EMFunctor = MapFullSubcategory (AlgebrasCategory N) (IsEMAlgebra monadN) (AlgebrasCategory M) (IsEMAlgebra monadM) (AlgebrasFunctor ν) mapIsEMAlgebra
{ "alphanum_fraction": 0.5837127618, "avg_line_length": 36.9567307692, "ext": "agda", "hexsha": "bbb09d11aa27a137ba1741b2280a42d9b0e19a1e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Categories/Instances/EilenbergMoore.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Categories/Instances/EilenbergMoore.agda", "max_line_length": 116, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Categories/Instances/EilenbergMoore.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 3559, "size": 7687 }
module _ where open import Issue1839.A open import Issue1839.B X : DontPrintThis -- should display as PrintThis X = {!!}
{ "alphanum_fraction": 0.7165354331, "avg_line_length": 14.1111111111, "ext": "agda", "hexsha": "13ab5dca1cabc513a7e04a4497d72ba4351965c2", "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/Issue1839.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/Issue1839.agda", "max_line_length": 51, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue1839.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 36, "size": 127 }
------------------------------------------------------------------------ -- Some code suggesting that types used in "programs" might not -- necessarily be sets ------------------------------------------------------------------------ -- If lenses are only used in programs, and types used in programs are -- always sets, then higher lenses might be pointless. -- This module uses univalence without tracking such uses in the types -- of functions. {-# OPTIONS --cubical #-} open import Equality.Path as P hiding (Is-proposition; Is-set) module README.Not-a-set {e⁺} (eq : ∀ {a p} → Equality-with-paths a p e⁺) where private open module D = Derived-definitions-and-properties eq using (Is-proposition; Is-set) open import Equality.Path.Univalence open import Prelude open import Bijection equality-with-J as Bijection using (_↔_) import Bijection D.equality-with-J as DB import Bool equality-with-J as B open import Equality.Decision-procedures equality-with-J import Equality.Path.Isomorphisms eq as I open import Equivalence equality-with-J as Eq using (_≃_) open import Function-universe equality-with-J as F hiding (id; _∘_) import H-level D.equality-with-J as H-level open import H-level.Closure D.equality-with-J open import Surjection D.equality-with-J using (_↠_) private variable A B C : Type ------------------------------------------------------------------------ -- Dynamic types -- Values of arbitrary type that can be turned into strings. Printable : Type₁ Printable = ∃ λ (A : Type) → A × (A → String) -- Printable is not a set. ¬-Printable-set : ¬ Is-set Printable ¬-Printable-set = Is-set Printable ↝⟨ DB._↔_.to (I.H-level↔H-level 2) ⟩ P.Is-set Printable ↝⟨ (λ h → h _ _) ⟩ refl ≡ q ↝⟨ cong (cong proj₁) ⟩ refl ≡ cong proj₁ q ↝⟨ flip trans (proj₁-Σ-≡,≡→≡ {B = λ A → A × (A → String)} {y₁ = proj₂ x} _ refl) ⟩ refl ≡ q′ ↝⟨ cong (λ eq → subst id eq (just true)) ⟩ just true ≡ just false ↝⟨ Bool.true≢false ∘ ⊎.cancel-inj₂ ⟩□ ⊥ □ where x : Printable x = Maybe Bool , nothing , λ _ → "" q′ : Maybe Bool ≡ Maybe Bool q′ = ≃⇒≡ (F.id ⊎-cong Eq.↔⇒≃ B.swap) q : x ≡ x q = Σ-≡,≡→≡ q′ refl ------------------------------------------------------------------------ -- Streams -- Streams, based on the definition given by Coutts et al. in "Stream -- Fusion: From Lists to Streams to Nothing at All". data Step (A S : Type) : Type where done : Step A S yield : A → S → Step A S skip : S → Step A S Stream : Type → Type₁ Stream A = ∃ λ (S : Type) → (S → Step A S) × S -- Stream A is not a set. ¬-Stream-set : ¬ Is-set (Stream A) ¬-Stream-set {A = A} = Is-set (Stream A) ↝⟨ DB._↔_.to (I.H-level↔H-level 2) ⟩ P.Is-set (Stream A) ↝⟨ (λ h → h _ _) ⟩ refl ≡ p ↝⟨ cong (cong proj₁) ⟩ refl ≡ cong proj₁ p ↝⟨ flip trans (proj₁-Σ-≡,≡→≡ {B = F} {y₁ = proj₂ t} _ refl) ⟩ refl ≡ q ↝⟨ cong (λ eq → subst id eq (just true)) ⟩ just true ≡ just false ↝⟨ Bool.true≢false ∘ ⊎.cancel-inj₂ ⟩□ ⊥ □ where F : Type → Type F S = (S → Step A S) × S t : Stream A t = Maybe Bool , const done , nothing q : Maybe Bool ≡ Maybe Bool q = ≃⇒≡ (F.id ⊎-cong Eq.↔⇒≃ B.swap) p : t ≡ t p = Σ-≡,≡→≡ q refl -- Streams, with the added requirement that the state type must be a -- set. Streamˢ : Type → Type₁ Streamˢ A = ∃ λ (S : Type) → Is-set S × (S → Step A S) × S -- Streamˢ A is not a set. ¬-Streamˢ-set : ¬ Is-set (Streamˢ A) ¬-Streamˢ-set {A = A} = Is-set (Streamˢ A) ↝⟨ DB._↔_.to (I.H-level↔H-level 2) ⟩ P.Is-set (Streamˢ A) ↝⟨ (λ h → h _ _) ⟩ refl ≡ p ↝⟨ cong (cong proj₁) ⟩ refl ≡ cong proj₁ p ↝⟨ flip trans (proj₁-Σ-≡,≡→≡ {B = F} {y₁ = proj₂ t} _ refl) ⟩ refl ≡ q ↝⟨ cong (λ eq → subst id eq (inj₂ true)) ⟩ just true ≡ just false ↝⟨ Bool.true≢false ∘ ⊎.cancel-inj₂ ⟩□ ⊥ □ where F : Type → Type F S = Is-set S × (S → Step A S) × S t : Streamˢ A t = Maybe Bool , Maybe-closure 0 Bool-set , const done , nothing q : Maybe Bool ≡ Maybe Bool q = ≃⇒≡ (F.id ⊎-cong Eq.↔⇒≃ B.swap) p : t ≡ t p = Σ-≡,≡→≡ q $ cong₂ _,_ (DB._↔_.to D.≡↔≡ (H-level-propositional I.ext 2 _ _)) refl ------------------------------------------------------------------------ -- Some deep embeddings -- The module is parametrised by a predicate P that satisfies some -- properties. module Tm-with-predicate (P : Type → Type) (P-Maybe-Bool : P (Maybe Bool)) (P-Maybe-Bool-propositional : Is-proposition (P (Maybe Bool))) where -- A deep embedding of a simple programming language. Note the -- requirement that P B must hold. data Tm (A : Type) : Type₁ where literal : A → Tm A map : {B : Type} → P B → Tm (B → A) → Tm B → Tm A -- An unfolding lemma. Tm≃ : Tm A ≃ (A ⊎ ∃ λ (B : Type) → P B × Tm (B → A) × Tm B) Tm≃ = Eq.↔→≃ (λ where (literal x) → inj₁ x (map p f t) → inj₂ (_ , p , f , t)) [ literal , (λ (_ , p , f , t) → map p f t) ] [ (λ _ → refl) , (λ _ → refl) ] (λ where (literal _) → refl (map _ _ _) → refl) -- If A is inhabited, then Tm A is not a set. ¬-Tm-set : A → ¬ Is-set (Tm A) ¬-Tm-set {A = A} a = Is-set (Tm A) ↝⟨ DB._↔_.to (I.H-level↔H-level 2) ⟩ P.Is-set (Tm A) ↝⟨ (λ h → h _ _) ⟩ refl ≡ p ↝⟨ cong map-injective ⟩ refl ≡ map-injective p ↝⟨ flip trans lemma ⟩ refl ≡ p₁ ↝⟨ cong (λ eq → subst id eq (just true)) ⟩ just true ≡ just false ↝⟨ Bool.true≢false ∘ ⊎.cancel-inj₂ ⟩□ ⊥ □ where F : Type → Type₁ F B = P B × Tm (B → A) × Tm B t : Tm A t = map P-Maybe-Bool (literal λ _ → a) (literal nothing) t′ : F (Maybe Bool) t′ = P-Maybe-Bool , literal (const a) , literal nothing p₁ : Maybe Bool ≡ Maybe Bool p₁ = ≃⇒≡ (F.id ⊎-cong Eq.↔⇒≃ B.swap) p₂ : subst F p₁ t′ ≡ t′ p₂ = cong₂ _,_ (DB._↔_.to (I.H-level↔H-level 1) P-Maybe-Bool-propositional _ _) (cong (_, literal nothing) (subst (λ B → Tm (B → A)) p₁ (literal (const a)) ≡⟨⟩ literal (subst (λ B → B → A) p₁ (const a)) ≡⟨ (cong literal $ ⟨ext⟩ λ b → subst-→-domain id p₁ {u = b}) ⟩∎ literal (const a) ∎)) p : t ≡ t p = _≃_.to (Eq.≃-≡ Tm≃) $ cong inj₂ $ Σ-≡,≡→≡ p₁ p₂ map-injective : {p : P B} {f : Tm (B → C)} {t : Tm B} → map p f t ≡ map p f t → B ≡ B map-injective {B = B} {p = p} {f = f} {t = t} = map p f t ≡ map p f t ↔⟨ inverse $ Eq.≃-≡ Tm≃ ⟩ _≃_.to Tm≃ (map p f t) ≡ _≃_.to Tm≃ (map p f t) ↔⟨⟩ inj₂ (B , p , f , t) ≡ inj₂ (B , p , f , t) ↔⟨ inverse Bijection.≡↔inj₂≡inj₂ ⟩ (B , p , f , t) ≡ (B , p , f , t) ↝⟨ cong proj₁ ⟩□ B ≡ B □ lemma : map-injective p ≡ p₁ lemma = map-injective p ≡⟨⟩ cong proj₁ (⊎.cancel-inj₂ (_≃_.from (Eq.≃-≡ Tm≃) (_≃_.to (Eq.≃-≡ Tm≃) (cong inj₂ (Σ-≡,≡→≡ p₁ p₂))))) ≡⟨ cong (cong proj₁ ∘ ⊎.cancel-inj₂) $ _≃_.left-inverse-of (Eq.≃-≡ Tm≃) (cong inj₂ (Σ-≡,≡→≡ p₁ p₂)) ⟩ cong (proj₁ {B = F}) (⊎.cancel-inj₂ {A = ⊤ ⊎ ⊤} (cong inj₂ (Σ-≡,≡→≡ {p₁ = _ , t′} p₁ p₂))) ≡⟨ cong (cong (proj₁ {B = F})) $ _↔_.left-inverse-of (Bijection.≡↔inj₂≡inj₂ {A = ⊤ ⊎ ⊤}) (Σ-≡,≡→≡ {p₁ = _ , t′} _ refl) ⟩ cong (proj₁ {B = F}) (Σ-≡,≡→≡ {p₁ = _ , t′} p₁ p₂) ≡⟨ proj₁-Σ-≡,≡→≡ {B = F} {y₁ = t′} _ refl ⟩∎ p₁ ∎ -- A deep embedding of a simple programming language. data Tm (A : Type) : Type₁ where literal : A → Tm A map : {B : Type} → Tm (B → A) → Tm B → Tm A -- If A is inhabited, then Tm A is not a set. ¬-Tm-set : A → ¬ Is-set (Tm A) ¬-Tm-set {A = A} a = Is-set (Tm A) ↝⟨ H-level.respects-surjection Tm↠Tm 2 ⟩ Is-set (T.Tm A) ↝⟨ T.¬-Tm-set a ⟩□ ⊥ □ where module T = Tm-with-predicate (λ _ → ⊤) _ (λ _ _ → D.refl _) to : Tm B → T.Tm B to (literal x) = T.literal x to (map f t) = T.map _ (to f) (to t) from : T.Tm B → Tm B from (T.literal x) = literal x from (T.map _ f t) = map (from f) (from t) to-from : (t : T.Tm B) → to (from t) D.≡ t to-from (T.literal x) = D.refl _ to-from (T.map _ f t) = D.cong₂ (T.map _) (to-from f) (to-from t) Tm↠Tm : Tm B ↠ T.Tm B Tm↠Tm = record { logical-equivalence = record { to = to ; from = from } ; right-inverse-of = to-from } -- A deep embedding of a simple programming language. Note the -- requirement that "B" must be a set. data Tmˢ (A : Type) : Type₁ where literal : A → Tmˢ A map : {B : Type} → Is-set B → Tmˢ (B → A) → Tmˢ B → Tmˢ A -- If A is inhabited, then Tmˢ A is not a set. ¬-Tmˢ-set : A → ¬ Is-set (Tmˢ A) ¬-Tmˢ-set {A = A} a = Is-set (Tmˢ A) ↝⟨ H-level.respects-surjection Tmˢ↠Tm 2 ⟩ Is-set (T.Tm A) ↝⟨ T.¬-Tm-set a ⟩□ ⊥ □ where module T = Tm-with-predicate Is-set (Maybe-closure 0 Bool-set) (H-level-propositional I.ext 2) to : Tmˢ B → T.Tm B to (literal x) = T.literal x to (map s f t) = T.map s (to f) (to t) from : T.Tm B → Tmˢ B from (T.literal x) = literal x from (T.map s f t) = map s (from f) (from t) to-from : (t : T.Tm B) → to (from t) D.≡ t to-from (T.literal x) = D.refl _ to-from (T.map s f t) = D.cong₂ (T.map s) (to-from f) (to-from t) Tmˢ↠Tm : Tmˢ B ↠ T.Tm B Tmˢ↠Tm = record { logical-equivalence = record { to = to ; from = from } ; right-inverse-of = to-from }
{ "alphanum_fraction": 0.4906932287, "avg_line_length": 30.9626168224, "ext": "agda", "hexsha": "99d968cf79ebae43ac9ce33718d2b332a74e4c7e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_forks_event_min_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependent-lenses", "max_forks_repo_path": "README/Not-a-set.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/dependent-lenses", "max_issues_repo_path": "README/Not-a-set.agda", "max_line_length": 144, "max_stars_count": 3, "max_stars_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependent-lenses", "max_stars_repo_path": "README/Not-a-set.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:55:52.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:10:46.000Z", "num_tokens": 3872, "size": 9939 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Examples showing how the generic n-ary operations the stdlib provides -- can be used ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module README.Nary where open import Level using (Level) open import Data.Nat.Base open import Data.Nat.Properties open import Data.Fin using (Fin; fromℕ; #_; inject₁) open import Data.List open import Data.List.Properties open import Data.Product using (_×_; _,_) open import Data.Sum using (inj₁; inj₂) open import Function open import Relation.Nullary open import Relation.Binary using (module Tri); open Tri open import Relation.Binary.PropositionalEquality private variable a b c d e : Level A : Set a B : Set b C : Set c D : Set d E : Set e ------------------------------------------------------------------------ -- Introduction ------------------------------------------------------------------------ -- Function.Nary.NonDependent and Data.Product.N-ary.Heterogeneous provide -- a generic representation of n-ary heterogeneous (non dependent) products -- and the corresponding types of (non-dependent) n-ary functions. The -- representation works well with inference thus allowing us to use generic -- combinators to manipulate such functions. open import Data.Product.Nary.NonDependent open import Function.Nary.NonDependent open import Relation.Nary ------------------------------------------------------------------------ -- Generalised equality-manipulating combinators ------------------------------------------------------------------------ -- By default the standard library provides users with (we are leaving out -- the implicit arguments here): -- -- cong : (f : A₁ → B) → a₁ ≡ b₁ → f a₁ ≡ f b₁ -- cong₂ : (f : A₁ → A₂ → B) → a₁ ≡ b₁ → a₂ ≡ b₂ → f a₁ a₂ ≡ f b₁ b₂ -- -- and -- -- subst : (P : A₁ → Set p) → a₁ ≡ b₁ → P a₁ → P b₁ -- subst₂ : (P : A₁ → A₂ → Set p) → a₁ ≡ b₁ → a₂ ≡ b₂ → P a₁ a₂ → P b₁ b₂ -- -- This pattern can be generalised to any natural number `n`. Thanks to our -- library for n-ary functions, we can write the types and implementations -- of `congₙ` and `substₙ`. ------------------------------------------------------------------------ -- congₙ : ∀ n (f : A₁ → ⋯ → Aₙ → B) → -- a₁ ≡ b₁ → ⋯ aₙ ≡ bₙ → f a₁ ⋯ aₙ ≡ f b₁ ⋯ bₙ -- It may be used directly to prove something: _ : ∀ (as bs cs : List ℕ) → zip (zip (as ++ []) (map id cs)) (reverse (reverse bs)) ≡ zip (zip as cs) bs _ = λ as bs cs → congₙ 3 (λ as bs → zip (zip as bs)) (++-identityʳ as) (map-id cs) (reverse-involutive bs) -- Or as part of a longer derivation: _ : ∀ m n p q → suc (m + (p * n) + (q ^ (m + n))) ≡ (m + 0) + (n * p) + (q ^ m * q ^ n) + 1 _ = λ m n p q → begin suc (m + (p * n) + (q ^ (m + n))) ≡⟨ +-comm 1 _ ⟩ m + (p * n) + (q ^ (m + n)) + 1 ≡⟨ congₙ 3 (λ m n p → m + n + p + 1) (+-comm 0 m) (*-comm p n) (^-distribˡ-+-* q m n) ⟩ m + 0 + n * p + (q ^ m) * (q ^ n) + 1 ∎ where open ≡-Reasoning -- Partial application of the functional argument is fine: the number of arguments -- `congₙ` is going to take is determined by its first argument (a natural number) -- and not by the type of the function it works on. _ : ∀ m → (m +_) ≡ ((m + 0) +_) _ = λ m → congₙ 1 _+_ (+-comm 0 m) -- We don't have to work on the function's first argument either: we can just as -- easily use `congₙ` to act on the second one by `flip`ping it. See `holeₙ` for -- a generalisation of this idea allowing to target *any* of the function's -- arguments and not just the first or second one. _ : ∀ m → (_+ m) ≡ (_+ (m + 0)) _ = λ m → congₙ 1 (flip _+_) (+-comm 0 m) ------------------------------------------------------------------------ -- substₙ : (P : A₁ → ⋯ → Aₙ → Set p) → -- a₁ ≡ b₁ → ⋯ aₙ ≡ bₙ → P a₁ ⋯ aₙ → P b₁ ⋯ bₙ -- We can play the same type of game with subst open import Agda.Builtin.Nat using (mod-helper) -- Because we know from the definition `mod-helper` that this equation holds: -- mod-helper k m (suc n) (suc j) = mod-helper (suc k) m n j -- we should be able to prove the slightly modified statement by transforming -- all the `x + 1` into `suc x`. We can do so using `substₙ`. _ : ∀ k m n j → mod-helper k m (n + 1) (j + 1) ≡ mod-helper (k + 1) m n j _ = λ k m n j → let P sk sn sj = mod-helper k m sn sj ≡ mod-helper sk m n j in substₙ P (+-comm 1 k) (+-comm 1 n) (+-comm 1 j) refl ----------------------------------------------------------------------- -- Generic programs working on n-ary products & functions ----------------------------------------------------------------------- ----------------------------------------------------------------------- -- curryₙ : ∀ n → (A₁ × ⋯ × Aₙ → B) → A₁ → ⋯ → Aₙ → B -- uncurryₙ : ∀ n → (A₁ → ⋯ → Aₙ → B) → A₁ × ⋯ × Aₙ → B -- The first thing we may want to do generically is convert between -- curried function types and uncurried ones. We can do this by using: -- They both work the same way so we will focus on curryₙ only here. -- If we pass to `curryₙ` the arity of its argument then we obtain a -- fully curried function. curry₁ : (A × B × C × D → E) → A → B → C → D → E curry₁ = curryₙ 4 -- Note that here we are not flattening arbitrary nestings: products have -- to be right nested. Which means that if you have a deeply-nested product -- then it won't be affected by the procedure. curry₁' : (A × (B × C) × D → E) → A → (B × C) → D → E curry₁' = curryₙ 3 -- When we are currying a function, we have no obligation to pass its exact -- arity as the parameter: we can decide to only curry part of it like so: -- Indeed (A₁ × ⋯ × Aₙ → B) can also be seen as (A₁ × ⋯ × (Aₖ × ⋯ × Aₙ) → B) curry₂ : (A × B × C × D → E) → A → B → (C × D) → E curry₂ = curryₙ 3 ----------------------------------------------------------------------- -- projₙ : ∀ n (k : Fin n) → (A₁ × ⋯ × Aₙ) → Aₖ₊₁ -- Another useful class of functions to manipulate n-ary product is a -- generic projection function. Note the (k + 1) in the return index: -- Fin counts from 0 up. -- It behaves as one expects (Data.Fin's #_ comes in handy to write down -- Fin literals): proj₃ : (A × B × C × D × E) → C proj₃ = projₙ 5 (# 2) -- Of course we can once more project the "tail" of the n-ary product by -- passing `projₙ` a natural number which is smaller than the size of the -- n-ary product, seeing (A₁ × ⋯ × Aₙ) as (A₁ × ⋯ × (Aₖ × ⋯ × Aₙ)). proj₃' : (A × B × C × D × E) → C × D × E proj₃' = projₙ 3 (# 2) ----------------------------------------------------------------------- -- insertₙ : ∀ n (k : Fin (suc n)) → -- B → (A₁ × ⋯ Aₙ) → (A₁ × ⋯ × Aₖ × B × Aₖ₊₁ × ⋯ Aₙ) insert₁ : C → (A × B × D × E) → (A × B × C × D × E) insert₁ = insertₙ 4 (# 2) insert₁' : C → (A × B × D × E) → (A × B × C × D × E) insert₁' = insertₙ 3 (# 2) -- Note that `insertₙ` takes a `Fin (suc n)`. Indeed in an n-ary product -- there are (suc n) positions at which one may insert a value. We may -- insert at the front or the back of the product: insert-front : A → (B × C × D × E) → (A × B × C × D × E) insert-front = insertₙ 4 (# 0) insert-back : E → (A × B × C × D) → (A × B × C × D × E) insert-back = insertₙ 4 (# 4) ----------------------------------------------------------------------- -- removeₙ : ∀ n (k : Fin n) → (A₁ × ⋯ Aₙ) → (A₁ × ⋯ × Aₖ × Aₖ₊₂ × ⋯ Aₙ) -- Dual to `insertₙ`, we may remove a value. remove₁ : (A × B × C × D × E) → (A × B × D × E) remove₁ = removeₙ 5 (# 2) -- Inserting at `k` and then removing at `inject₁ k` should yield the identity remove-insert : C → (A × B × D × E) → (A × B × D × E) remove-insert c = removeₙ 5 (inject₁ k) ∘′ insertₙ 4 k c where k = # 2 ----------------------------------------------------------------------- -- updateₙ : ∀ n (k : Fin n) (f : (a : Aₖ₊₁) → B a) → -- (p : A₁ × ⋯ Aₙ) → (A₁ × ⋯ × Aₖ × B (projₙ n k p) × Aₖ₊₂ × ⋯ Aₙ) -- We can not only project out, insert or remove values: we can update them -- in place. The type (and value) of the replacement at position k may depend -- upon the current value at position k. update₁ : (p : A × B × ℕ × C × D) → (A × B × Fin _ × C × D) update₁ = updateₙ 5 (# 2) fromℕ -- We can explicitly use the primed version of `updateₙ` to make it known to -- Agda that the update function is non dependent. This type of information -- is useful for inference: the tighter the constraints, the easier it is to -- find a solution (if possible). update₂ : (p : A × B × ℕ × C × D) → (A × B × List D × C × D) update₂ = λ p → updateₙ′ 5 (# 2) (λ n → replicate n (projₙ 5 (# 4) p)) p ----------------------------------------------------------------------- -- _%=_⊢_ : ∀ n → (C → D) → (A₁ → ⋯ Aₙ → D → B) → A₁ → ⋯ → Aₙ → C → B -- Traditional composition (also known as the index update operator `_⊢_` -- in `Relation.Unary`) focuses solely on the first argument of an n-ary -- function. `_%=_⊢_` on the other hand allows us to touch any one of the -- arguments. -- In the following example we have a function `f : A → B` and `replicate` -- of type `ℕ → B → List B`. We want ̀f` to act on the second argument of -- replicate. Which we can do like so. compose₁ : (A → B) → ℕ → A → List B compose₁ f = 1 %= f ⊢ replicate -- Here we spell out the equivalent explicit variable-manipulation and -- prove the two functions equal. compose₁' : (A → B) → ℕ → A → List B compose₁' f n a = replicate n (f a) compose₁-eq : compose₁ {a} {A} {b} {B} ≡ compose₁' compose₁-eq = refl ----------------------------------------------------------------------- -- _∷=_⊢_ : ∀ n → A → (A₁ → ⋯ Aₙ → A → B) → A₁ → ⋯ → Aₙ → B -- Partial application usually focuses on the first argument of a function. -- We can now partially apply a function in any of its arguments using -- `_∷=_⊢_`. Reusing our example involving replicate: we can specialise it -- to only output finite lists of `0`: apply₁ : ℕ → List ℕ apply₁ = 1 ∷= 0 ⊢ replicate apply₁-eq : apply₁ 3 ≡ 0 ∷ 0 ∷ 0 ∷ [] apply₁-eq = refl ------------------------------------------------------------------------ -- holeₙ : ∀ n → (A → (A₁ → ⋯ Aₙ → B)) → A₁ → ⋯ → Aₙ → (A → B) -- As we have seen earlier, `cong` acts on a function's first variable. -- If we want to access the second one, we can use `flip`. But what about -- the fourth one? We typically use an explicit λ-abstraction shuffling -- variables. Not anymore. -- Reusing mod-helper just because it takes a lot of arguments: hole₁ : ∀ k m n j → mod-helper k (m + 1) n j ≡ mod-helper k (suc m) n j hole₁ = λ k m n j → cong (holeₙ 2 (mod-helper k) n j) (+-comm m 1) ----------------------------------------------------------------------- -- mapₙ : ∀ n → (B → C) → (A₁ → ⋯ Aₙ → B) → (A₁ → ⋯ → Aₙ → C) -- (R →_) gives us the reader monad (and, a fortiori, functor). That is to -- say that given a function (A → B) and an (R → A) we can get an (R → B) -- This generalises to n-ary functions. -- Reusing our `composeₙ` example: instead of applying `f` to the replicated -- element, we can map it on the resulting list. Giving us: map₁ : (A → B) → ℕ → A → List B map₁ f = mapₙ 2 (map f) replicate ------------------------------------------------------------------------ -- constₙ : ∀ n → B → A₁ → ⋯ → Aₙ → B -- `const` is basically `pure` for the reader monad discussed above. Just -- like we can generalise the functorial action corresponding to the reader -- functor to n-ary functions, we can do the same for `pure`. const₁ : A → B → C → D → E → A const₁ = constₙ 4 -- Together with `holeₙ`, this means we can make a constant function out -- of any of the arguments. The fourth for instance: const₂ : A → B → C → D → E → D const₂ = holeₙ 3 (constₙ 4) ------------------------------------------------------------------------ -- Generalised quantifiers ------------------------------------------------------------------------ -- As we have seen multiple times already, one of the advantages of working -- with non-dependent products is that they can be easily inferred. This is -- a prime opportunity to define generic quantifiers. -- And because n-ary relations are Set-terminated, there is no ambiguity -- where to split between arguments & codomain. As a consequence Agda can -- infer even `n`, the number of arguments. We can use notations which are -- just like the ones defined in `Relation.Unary`. ------------------------------------------------------------------------ -- ∃⟨_⟩ : (A₁ → ⋯ → Aₙ → Set r) → Set _ -- ∃⟨ P ⟩ = ∃ λ a₁ → ⋯ → ∃ λ aₙ → P a₁ ⋯ aₙ -- Returning to our favourite function taking a lot of arguments: we can -- find a set of input for which it evaluates to 666 exist₁ : ∃⟨ (λ k m n j → mod-helper k m n j ≡ 666) ⟩ exist₁ = 19 , 793 , 3059 , 10 , refl ------------------------------------------------------------------------ -- ∀[_] : (A₁ → ⋯ → Aₙ → Set r) → Set _ -- ∀[_] P = ∀ {a₁} → ⋯ → ∀ {aₙ} → P a₁ ⋯ aₙ all₁ : ∀[ (λ (a₁ a₂ : ℕ) → Dec (a₁ ≡ a₂)) ] all₁ {a₁} {a₂} = a₁ ≟ a₂ ------------------------------------------------------------------------ -- Π : (A₁ → ⋯ → Aₙ → Set r) → Set _ -- Π P = ∀ a₁ → ⋯ → ∀ aₙ → P a₁ ⋯ aₙ all₂ : Π[ (λ (a₁ a₂ : ℕ) → Dec (a₁ ≡ a₂)) ] all₂ = _≟_ ------------------------------------------------------------------------ -- _⇒_ : (A₁ → ⋯ → Aₙ → Set r) → (A₁ → ⋯ → Aₙ → Set s) → (A₁ → ⋯ → Aₙ → Set _) -- P ⇒ Q = λ a₁ → ⋯ → λ aₙ → P a₁ ⋯ aₙ → Q a₁ ⋯ aₙ antisym : ∀[ _≤_ ⇒ _≥_ ⇒ _≡_ ] antisym = ≤-antisym ------------------------------------------------------------------------ -- _∪_ : (A₁ → ⋯ → Aₙ → Set r) → (A₁ → ⋯ → Aₙ → Set s) → (A₁ → ⋯ → Aₙ → Set _) -- P ∪ Q = λ a₁ → ⋯ → λ aₙ → P a₁ ⋯ aₙ ⊎ Q a₁ ⋯ aₙ ≤->-connex : Π[ _≤_ ∪ _>_ ] ≤->-connex m n with <-cmp m n ... | tri< a ¬b ¬c = inj₁ (<⇒≤ a) ... | tri≈ ¬a b ¬c = inj₁ (≤-reflexive b) ... | tri> ¬a ¬b c = inj₂ c ------------------------------------------------------------------------ -- _∩_ : (A₁ → ⋯ → Aₙ → Set r) → (A₁ → ⋯ → Aₙ → Set s) → (A₁ → ⋯ → Aₙ → Set _) -- P ∩ Q = λ a₁ → ⋯ → λ aₙ → P a₁ ⋯ aₙ × Q a₁ ⋯ aₙ <-inversion : ∀[ _<_ ⇒ _≤_ ∩ _≢_ ] <-inversion m<n = <⇒≤ m<n , <⇒≢ m<n ------------------------------------------------------------------------ -- ∁ : (A₁ → ⋯ → Aₙ → Set r) → (A₁ → ⋯ → Aₙ → Set _) -- ∁ P = λ a₁ → ⋯ → λ aₙ → ¬ (P a₁ ⋯ aₙ) m<n⇒m≱n : ∀[ _>_ ⇒ ∁ _≤_ ] m<n⇒m≱n m>n m≤n = <⇒≱ m>n m≤n
{ "alphanum_fraction": 0.4950657895, "avg_line_length": 38.4, "ext": "agda", "hexsha": "3ea619e7462551579ef5a7fef5c448dd7c8ad731", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/README/Nary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/README/Nary.agda", "max_line_length": 82, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/README/Nary.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": 4790, "size": 14592 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category using (Category) -- A "canonical" presentation of cartesian closed categories. -- -- This presentation is equivalent to the one in -- Categories.Category.CartesianClosed but it is easier to work with -- in some circumstances. -- -- Here, exponentials are not defined in terms of arbitrary products, -- but in terms of a family of "canonical" products. Since products -- are defined only up to isomorphism the choice of product does not -- matter for the property of being cartesian closed, but working with -- a fixed choice of representatives simplifies the constructions of -- some instances of CCCs (e.g. Cats). module Categories.Category.CartesianClosed.Canonical {o ℓ e} (𝒞 : Category o ℓ e) where open import Level using (levelOfTerm) open import Function using (flip) open import Categories.Category.Cartesian 𝒞 using (Cartesian) import Categories.Category.CartesianClosed 𝒞 as 𝒞-CC open import Categories.Object.Exponential 𝒞 using (Exponential) open import Categories.Object.Product 𝒞 open import Categories.Object.Terminal 𝒞 using (Terminal) open import Categories.Morphism.Reasoning 𝒞 private module 𝒞 = Category 𝒞 open Category 𝒞 open HomReasoning variable A B C : Obj f g h f₁ f₂ g₁ g₂ : A ⇒ B -- A (canonical) cartesian closed category is a category with all -- (canonical) products and exponentials -- -- This presentation is equivalent to the one in -- Categories.Category.CartesianClosed.CartesianClosed. record CartesianClosed : Set (levelOfTerm 𝒞) where infixr 7 _×_ infixr 9 _^_ infix 10 ⟨_,_⟩ field -- Canonical products ⊤ : Obj _×_ : Obj → Obj → Obj ! : A ⇒ ⊤ π₁ : A × B ⇒ A π₂ : A × B ⇒ B ⟨_,_⟩ : C ⇒ A → C ⇒ B → C ⇒ A × B !-unique : (f : A ⇒ ⊤) → ! ≈ f π₁-comp : π₁ ∘ ⟨ f , g ⟩ ≈ f π₂-comp : π₂ ∘ ⟨ f , g ⟩ ≈ g ⟨,⟩-unique : π₁ ∘ h ≈ f → π₂ ∘ h ≈ g → ⟨ f , g ⟩ ≈ h -- The above defines canonical finite products, making 𝒞 cartesian. ⊤-terminal : Terminal ⊤-terminal = record { !-unique = !-unique } ×-product : ∀ {A B} → Product A B ×-product {A} {B} = record { project₁ = π₁-comp; project₂ = π₂-comp; unique = ⟨,⟩-unique } isCartesian : Cartesian isCartesian = record { terminal = ⊤-terminal ; products = record { product = ×-product } } module cartesian = Cartesian isCartesian open cartesian public hiding (_×_; π₁; π₂; ⟨_,_⟩) renaming (⟨⟩-cong₂ to ⟨,⟩-resp-≈) field -- Canonical exponentials (w.r.t. the canonical products) _^_ : Obj → Obj → Obj eval : B ^ A × A ⇒ B curry : C × A ⇒ B → C ⇒ B ^ A eval-comp : eval ∘ (curry f ⁂ id) ≈ f curry-resp-≈ : f ≈ g → curry f ≈ curry g curry-unique : eval ∘ (f ⁂ id) ≈ g → f ≈ curry g -- The above defines canonical exponentials, making 𝒞 cartesian closed. -- -- NOTE: below we use "⊗" to indicate "non-canonical" products. ^-exponential : ∀ {A B} → Exponential A B ^-exponential {A} {B} = record { B^A = B ^ A ; product = ×-product ; eval = eval ; λg = λ C⊗A f → curry (f ∘ repack ×-product C⊗A) ; β = λ {C} C⊗A {g} → begin eval ∘ [ C⊗A ⇒ ×-product ] curry (g ∘ repack ×-product C⊗A) ×id ≈˘⟨ pullʳ [ ×-product ⇒ ×-product ]×∘⟨⟩ ⟩ (eval ∘ (curry (g ∘ repack ×-product C⊗A) ⁂ id)) ∘ repack C⊗A ×-product ≈⟨ eval-comp ⟩∘⟨refl ⟩ (g ∘ repack ×-product C⊗A) ∘ repack C⊗A ×-product ≈⟨ cancelʳ (repack∘repack≈id ×-product C⊗A) ⟩ g ∎ ; λ-unique = λ {C} C⊗A {g} {f} hyp → curry-unique (begin eval ∘ (f ⁂ id) ≈˘⟨ pullʳ [ C⊗A ⇒ ×-product ]×∘⟨⟩ ⟩ (eval ∘ [ C⊗A ⇒ ×-product ] f ×id) ∘ repack ×-product C⊗A ≈⟨ hyp ⟩∘⟨refl ⟩ g ∘ repack ×-product C⊗A ∎) } module Equivalence where open 𝒞-CC using () renaming (CartesianClosed to CartesianClosed′) -- The two presentations of CCCs are equivalent fromCanonical : CartesianClosed → CartesianClosed′ fromCanonical cc = record { cartesian = CartesianClosed.isCartesian cc ; exp = CartesianClosed.^-exponential cc } toCanonical : CartesianClosed′ → CartesianClosed toCanonical cc = record { ⊤ = ⊤ ; _×_ = _×_ ; ! = ! ; π₁ = π₁ ; π₂ = π₂ ; ⟨_,_⟩ = ⟨_,_⟩ ; !-unique = !-unique ; π₁-comp = project₁ ; π₂-comp = project₂ ; ⟨,⟩-unique = unique ; _^_ = _^_ ; eval = eval′ ; curry = λg ; eval-comp = β′ ; curry-resp-≈ = λ-cong ; curry-unique = λ-unique′ } where open CartesianClosed′ cc
{ "alphanum_fraction": 0.5973689886, "avg_line_length": 28.6234567901, "ext": "agda", "hexsha": "93cd846e8a7634522e2efc1c71dd7976d2a52e5b", "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": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_path": "Categories/Category/CartesianClosed/Canonical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "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": "Taneb/agda-categories", "max_issues_repo_path": "Categories/Category/CartesianClosed/Canonical.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_path": "Categories/Category/CartesianClosed/Canonical.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1608, "size": 4637 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Empty.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude private variable ℓ : Level data ⊥ : Type₀ where ⊥* : Type ℓ ⊥* = Lift ⊥ rec : {A : Type ℓ} → ⊥ → A rec () elim : {A : ⊥ → Type ℓ} → (x : ⊥) → A x elim ()
{ "alphanum_fraction": 0.6121212121, "avg_line_length": 15.7142857143, "ext": "agda", "hexsha": "023d975c8aae715dc21ae619903be1d5768c6acc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Empty/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "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": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/Empty/Base.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Empty/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 120, "size": 330 }
------------------------------------------------------------------------ -- A memoising backend for RecursiveDescent.Hybrid ------------------------------------------------------------------------ -- Following Frost/Szydlowski and Frost/Hafiz/Callaghan (but without -- the left recursion fix). An improvement has been made: The user -- does not have to insert memoisation annotations manually. Instead -- all grammar nonterminals are memoised. This is perhaps a bit less -- flexible, but less error-prone, since there is no need to guarantee -- that all "keys" (arguments to the memoise combinator) are unique -- (assuming that the nonterminal equality is strong enough). open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Relation.Binary.PropositionalEquality1 open import RecursiveDescent.Index open import Data.Product module RecursiveDescent.Hybrid.Memoised -- In order to be able to store results in a memo table (and avoid -- having to lift the table code to Set1) the result types have to -- come from the following universe: {Result : Set} (⟦_⟧ : Result -> Set) -- Nonterminals also have to be small enough: {NT : Index -> Result -> Set} {LargeNT : ParserType} (resultType : forall {i r} -> LargeNT i r -> Result) (resultTypeCorrect : forall {i r} (x : LargeNT i r) -> ⟦ resultType x ⟧ ≡₁ r) (notTooLarge : forall {i r} (x : LargeNT i r) -> NT i (resultType x)) -- Furthermore nonterminals need to be ordered, so that they can be -- used as memo table keys: {_≈_ _<_ : Rel (∃₂ NT)} (ntOrdered : IsStrictTotalOrder _≈_ _<_) -- And the underlying equality needs to be strong enough: (indicesEqual : _≈_ =[ (\irx -> (proj₁ irx , proj₁ (proj₂ irx))) ]⇒ _≡_ {Index × Result}) -- Token type: {Tok : Set} where open import Data.Bool renaming (true to ⊤; false to ⊥) import Data.Nat as Nat open Nat using (ℕ; zero; suc; pred; z≤n; s≤s) import Data.Nat.Properties as NatProp open import Data.Function hiding (_∘′_) import Data.Product.Record as PR open PR using () renaming (_,_ to _◇_) import Data.Vec as Vec; open Vec using (Vec; []; _∷_) import Data.List as List; open List using (List; []; _∷_) open import Data.Sum open import Data.Maybe open import Relation.Binary.OrderMorphism open _⇒-Poset_ import Relation.Binary.On as On import Relation.Binary.Props.StrictTotalOrder as STOProps open STOProps NatProp.strictTotalOrder import RecursiveDescent.Hybrid.Memoised.Monad as Monad open import RecursiveDescent.Hybrid.Type renaming (return to ret) open import Utilities ------------------------------------------------------------------------ -- Some monotone functions MonoFun : Set MonoFun = poset ⇒-Poset poset suc-mono : _≤_ =[ suc ]⇒ _≤_ suc-mono (inj₁ i<j) = inj₁ (s≤s i<j) suc-mono (inj₂ ≡-refl) = inj₂ ≡-refl pred-mono : _≤_ =[ pred ]⇒ _≤_ pred-mono (inj₁ (s≤s (z≤n {zero}))) = inj₂ ≡-refl pred-mono (inj₁ (s≤s (z≤n {suc j}))) = inj₁ (s≤s z≤n) pred-mono (inj₁ (s≤s (s≤s i<j))) = inj₁ (s≤s i<j) pred-mono (inj₂ ≡-refl) = inj₂ ≡-refl sucM : MonoFun sucM = record { fun = suc ; monotone = suc-mono } predM : MonoFun predM = record { fun = pred ; monotone = pred-mono } maybePredM : Empty -> MonoFun maybePredM e = if e then idM else predM lemma : forall e pos -> fun (maybePredM e) pos ≤ pos lemma ⊤ pos = refl lemma ⊥ zero = refl lemma ⊥ (suc pos) = inj₁ (Poset.refl Nat.poset) ------------------------------------------------------------------------ -- Parser monad data Key : MonoFun -> Result -> Set where key : forall {e c r} (nt : NT (e ◇ c) r) -> Key (maybePredM e) r shuffle : ∃₂ Key -> ∃₂ NT shuffle (._ , _ , key x) = (, , x) _≈K_ : Rel (∃₂ Key) _≈K_ = _≈_ on₁ shuffle _<K_ : Rel (∃₂ Key) _<K_ = _<_ on₁ shuffle ordered : IsStrictTotalOrder _≈K_ _<K_ ordered = On.isStrictTotalOrder shuffle ntOrdered funsEqual : _≈K_ =[ proj₁ ]⇒ _≡_ funsEqual {(._ , _ , key _)} {(._ , _ , key _)} eq = ≡-cong (maybePredM ∘ PR.proj₁ ∘ proj₁) (indicesEqual eq) resultsEqual : _≈K_ =[ (\rfk -> proj₁ (proj₂ rfk)) ]⇒ _≡_ resultsEqual {(._ , _ , key _)} {(._ , _ , key _)} eq = ≡-cong proj₂ (indicesEqual eq) open Monad (StrictTotalOrder.isStrictTotalOrder NatProp.strictTotalOrder) (Vec Tok) ⟦_⟧ ordered (\{k₁} {k₂} -> funsEqual {k₁} {k₂}) (\{k₁} {k₂} -> resultsEqual {k₁} {k₂}) open PM cast : forall {bnd f A₁ A₂} -> A₁ ≡₁ A₂ -> P bnd f A₁ -> P bnd f A₂ cast ≡₁-refl p = p ------------------------------------------------------------------------ -- Run function for the parsers -- Some helper functions. private -- Extracts the first element from the input, if any. eat : forall {bnd} (inp : Input≤ bnd) -> Maybe Tok × Input≤ (pred (position inp)) eat {bnd} xs = helper (bounded xs) (string xs) where helper : forall {pos} -> pos ≤ bnd -> Vec Tok pos -> Maybe Tok × Input≤ (pred pos) helper _ [] = (nothing , [] isBounded∶ refl) helper le (c ∷ cs) = (just c , cs isBounded∶ refl) -- Fails if it encounters nothing. fromJust : forall {bnd} -> Maybe Tok -> P bnd idM Tok fromJust nothing = ∅ fromJust (just c) = return c -- For every successful parse the run function returns the remaining -- string. (Since there can be several successful parses a list of -- strings is returned.) -- This function is structurally recursive with respect to the -- following lexicographic measure: -- -- 1) The upper bound of the length of the input string. -- 2) The parser's proper left corner tree. private module Dummy (g : Grammar Tok LargeNT) where mutual parse : forall n {e c r} -> Parser Tok LargeNT (e ◇ c) r -> P n (if e then idM else predM) r parse n (! x) = memoParse n x parse n symbol = fromJust =<< gmodify predM eat parse n (ret x) = return x parse n fail = ∅ parse n (p₁ ?>>= p₂) = parse n p₁ >>= parse n ∘′ p₂ parse zero (p₁ !>>= p₂) = ∅ parse (suc n) (p₁ !>>= p₂) = parse (suc n) p₁ >>= parse↑ n ∘′ p₂ parse n (alt ⊤ _ p₁ p₂) = parse n p₁ ∣ parse↑ n p₂ parse n (alt ⊥ ⊤ p₁ p₂) = parse↑ n p₁ ∣ parse n p₂ parse n (alt ⊥ ⊥ p₁ p₂) = parse n p₁ ∣ parse n p₂ parse↑ : forall n {e c r} -> Parser Tok LargeNT (e ◇ c) r -> P n idM r parse↑ n {e} p = adjustBound (lemma e) (parse n p) memoParse : forall n {r e c} -> LargeNT (e ◇ c) r -> P n (if e then idM else predM) r memoParse n x = cast₁ (memoise k (cast₂ (parse n (g x)))) where k = key (notTooLarge x) cast₁ = cast (resultTypeCorrect x) cast₂ = cast (≡₁-sym (resultTypeCorrect x)) -- Exported run function. parse : forall {i r} -> Parser Tok LargeNT i r -> Grammar Tok LargeNT -> List Tok -> List (r × List Tok) parse p g toks = List.map (map-× id (\xs -> Vec.toList (string xs))) $ run (Vec.fromList toks) (Dummy.parse g _ p) -- A variant which only returns parses which leave no remaining input. parse-complete : forall {i r} -> Parser Tok LargeNT i r -> Grammar Tok LargeNT -> List Tok -> List r parse-complete p g s = List.map proj₁ (List.filter (List.null ∘ proj₂) (parse p g s))
{ "alphanum_fraction": 0.588860487, "avg_line_length": 32.3173913043, "ext": "agda", "hexsha": "8007495bfa0e9b0eb7b5098a3365c925087c081e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "misc/RecursiveDescent/Hybrid/Memoised.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "misc/RecursiveDescent/Hybrid/Memoised.agda", "max_line_length": 72, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "misc/RecursiveDescent/Hybrid/Memoised.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 2312, "size": 7433 }
module Data.Rational where import Data.Bool as Bool import Data.Nat as Nat import Data.Integer as Int open Int renaming ( _*_ to _*'_ ; _+_ to _+'_ ; -_ to -'_ ; _-_ to _-'_ ; !_! to !_!' ; _==_ to _=='_ ; _≤_ to _≤'_ ; _≥_ to _≥'_ ; _>_ to _>'_ ; _<_ to _<'_ ) open Nat using (Nat; zero; suc) open Bool infix 40 _==_ _<_ _>_ _≤_ _≥_ infixl 60 _+_ _-_ infixl 70 _%'_ _%_ _/_ _*_ infixr 80 _^_ infix 90 -_ data Rational : Set where _%'_ : Int -> Int -> Rational numerator : Rational -> Int numerator (n %' d) = n denominator : Rational -> Int denominator (n %' d) = d _%_ : Int -> Int -> Rational neg n % neg m = pos (suc n) % pos (suc m) pos 0 % neg m = pos 0 %' pos 1 pos (suc n) % neg m = neg n % pos (suc m) x % y = div x z %' div y z where z = gcd x y fromInt : Int -> Rational fromInt x = x %' pos 1 fromNat : Nat -> Rational fromNat x = fromInt (pos x) _+_ : Rational -> Rational -> Rational (a %' b) + (c %' d) = (a *' d +' c *' b) % (b *' d) -_ : Rational -> Rational - (a %' b) = -' a %' b _-_ : Rational -> Rational -> Rational a - b = a + (- b) _/_ : Rational -> Rational -> Rational (a %' b) / (c %' d) = (a *' d) % (b *' c) _*_ : Rational -> Rational -> Rational (a %' b) * (c %' d) = (a *' c) % (b *' d) recip : Rational -> Rational recip (a %' b) = b %' a _^_ : Rational -> Int -> Rational q ^ neg n = recip q ^ pos (suc n) q ^ pos zero = fromNat 1 q ^ pos (suc n) = q * q ^ pos n !_! : Rational -> Rational ! a %' b ! = pos ! a !' %' pos ! b !' round : Rational -> Int round (a %' b) = div (a +' div b (pos 2)) b _==_ : Rational -> Rational -> Bool (a %' b) == (c %' d) = a *' d ==' b *' c _<_ : Rational -> Rational -> Bool (a %' b) < (c %' d) = a *' d <' b *' c _>_ : Rational -> Rational -> Bool (a %' b) > (c %' d) = a *' d >' b *' c _≤_ : Rational -> Rational -> Bool (a %' b) ≤ (c %' d) = a *' d ≤' b *' c _≥_ : Rational -> Rational -> Bool (a %' b) ≥ (c %' d) = a *' d ≥' b *' c max : Rational -> Rational -> Rational max a b = if a < b then b else a min : Rational -> Rational -> Rational min a b = if a < b then a else b
{ "alphanum_fraction": 0.476127321, "avg_line_length": 22.1764705882, "ext": "agda", "hexsha": "bbb24f70f13e83e2368a5f784f16bfe0477cfade", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Rational.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Rational.agda", "max_line_length": 51, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Rational.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": 868, "size": 2262 }
{- This second-order signature was created from the following second-order syntax description: syntax Empty | E type 𝟘 : 0-ary term abort : 𝟘 -> α theory (𝟘η) e : 𝟘 c : α |> abort(e) = c -} module Empty.Signature where open import SOAS.Context -- Type declaration data ET : Set where 𝟘 : ET open import SOAS.Syntax.Signature ET public open import SOAS.Syntax.Build ET public -- Operator symbols data Eₒ : Set where abortₒ : {α : ET} → Eₒ -- Term signature E:Sig : Signature Eₒ E:Sig = sig λ { (abortₒ {α}) → (⊢₀ 𝟘) ⟼₁ α } open Signature E:Sig public
{ "alphanum_fraction": 0.6672413793, "avg_line_length": 14.5, "ext": "agda", "hexsha": "22c98666f8c3dc390041636fec687fbc9c552380", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/Empty/Signature.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/Empty/Signature.agda", "max_line_length": 91, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/Empty/Signature.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 206, "size": 580 }
module Issue1245 where postulate A B : Set [_] : A -> B module M (_ : B) where module N (a : A) = M [ a ]
{ "alphanum_fraction": 0.5486725664, "avg_line_length": 11.3, "ext": "agda", "hexsha": "7394cd983742a7ac6d7659bff909193d1362088c", "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/Issue1245.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/Issue1245.agda", "max_line_length": 26, "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/Issue1245.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": 43, "size": 113 }
-- This file is the source Agda file -- Edit this file not Type.hs -- The warning below will be written to Type.hs module PlutusCore.Generators.NEAT.Type where -- warning to be written to Haskell file: {-# FOREIGN AGDA2HS {- !!! THIS FILE IS GENERATED FROM Type.agda !!! DO NOT EDIT THIS FILE. EDIT Type.agda !!! AND THEN RUN agda2hs ON IT. -} #-} {-# FOREIGN AGDA2HS {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE StandaloneDeriving #-} import Control.Enumerable import Control.Monad.Except import PlutusCore import PlutusCore.Generators.NEAT.Common #-} open import Relation.Binary.PropositionalEquality open import Haskell.Prelude hiding (m) open import PlutusCore.Generators.NEAT.Common {-# FOREIGN AGDA2HS newtype Neutral a = Neutral { unNeutral :: a } #-} -- * Enumeration -- ** Enumerating types data TypeBuiltinG : Set where TyByteStringG : TypeBuiltinG TyIntegerG : TypeBuiltinG TyBoolG : TypeBuiltinG TyUnitG : TypeBuiltinG TyStringG : TypeBuiltinG TyListG : TypeBuiltinG TyDataG : TypeBuiltinG {-# COMPILE AGDA2HS TypeBuiltinG deriving (Show, Eq, Ord) #-} {-# FOREIGN AGDA2HS deriveEnumerable ''TypeBuiltinG #-} -- NOTE: Unusually, the application case is annotated with a kind. -- The reason is eagerness and efficiency. If we have the kind -- information at the application site, we can check the two -- subterms in parallel, while evaluating as little as possible. variable n m o : Set postulate Kind : Set → Set data TypeG (n : Set) : Set where TyVarG : n → TypeG n TyFunG : TypeG n → TypeG n → TypeG n TyIFixG : TypeG n → Kind ⊤ → TypeG n → TypeG n TyForallG : Kind ⊤ → TypeG (S n) → TypeG n TyBuiltinG : TypeBuiltinG → TypeG n TyLamG : TypeG (S n) → TypeG n TyAppG : TypeG n → TypeG n → Kind ⊤ → TypeG n {-# COMPILE AGDA2HS TypeG deriving (Eq, Ord, Show) #-} {-# FOREIGN AGDA2HS deriving instance Ord (Kind ()) deriveEnumerable ''Kind deriveEnumerable ''TypeG type ClosedTypeG = TypeG Z instance Functor TypeG where fmap = ren #-} ext : (m → n) → S m → S n ext _ FZ = FZ ext f (FS x) = FS (f x) {-# COMPILE AGDA2HS ext #-} ren : (m → n) → TypeG m → TypeG n ren f (TyVarG x) = TyVarG (f x) ren f (TyFunG ty1 ty2) = TyFunG (ren f ty1) (ren f ty2) ren f (TyIFixG ty1 k ty2) = TyIFixG (ren f ty1) k (ren f ty2) ren f (TyForallG k ty) = TyForallG k (ren (ext f) ty) ren _ (TyBuiltinG b) = TyBuiltinG b ren f (TyLamG ty) = TyLamG (ren (ext f) ty) ren f (TyAppG ty1 ty2 k) = TyAppG (ren f ty1) (ren f ty2) k {-# COMPILE AGDA2HS ren #-} ext-cong : {ρ ρ' : m → n} → (∀ x → ρ x ≡ ρ' x) → ∀ x → ext ρ x ≡ ext ρ' x ext-cong p FZ = refl ext-cong p (FS x) = cong FS (p x) ren-cong : {ρ ρ' : m → n} → (∀ x → ρ x ≡ ρ' x) → ∀ t → ren ρ t ≡ ren ρ' t ren-cong p (TyVarG x) = cong TyVarG (p x) ren-cong p (TyFunG ty1 ty2) = cong₂ TyFunG (ren-cong p ty1) (ren-cong p ty2) ren-cong p (TyIFixG ty1 k ty2) = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (ren-cong p ty1) (ren-cong p ty2) ren-cong p (TyForallG k ty) = cong (TyForallG k) (ren-cong (ext-cong p) ty) ren-cong p (TyBuiltinG b) = refl ren-cong p (TyLamG ty) = cong TyLamG (ren-cong (ext-cong p) ty) ren-cong p (TyAppG ty1 ty2 k) = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (ren-cong p ty1) (ren-cong p ty2) -- ext (map for S) satisfies the functor laws ext-id : (x : S m) → ext id x ≡ x ext-id FZ = refl ext-id (FS x) = refl ext-comp : (x : S m)(ρ : m → n)(ρ' : n → o) → ext (ρ' ∘ ρ) x ≡ ext ρ' (ext ρ x) ext-comp FZ ρ ρ' = refl ext-comp (FS x) ρ ρ' = refl -- ren (map for TypeG) satisfies the functor laws ren-id : (ty : TypeG m) → ren id ty ≡ ty ren-id (TyVarG _) = refl ren-id (TyFunG ty1 ty2) = cong₂ TyFunG (ren-id ty1) (ren-id ty2) ren-id (TyIFixG ty1 k ty2) = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (ren-id ty1) (ren-id ty2) ren-id (TyForallG k ty) = cong (TyForallG k) (trans (ren-cong ext-id ty) (ren-id ty)) ren-id (TyBuiltinG _) = refl ren-id (TyLamG ty) = cong TyLamG (trans (ren-cong ext-id ty) (ren-id ty)) ren-id (TyAppG ty1 ty2 k) = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (ren-id ty1) (ren-id ty2) ren-comp : (ty : TypeG m)(ρ : m → n)(ρ' : n → o) → ren (ρ' ∘ ρ) ty ≡ ren ρ' (ren ρ ty) ren-comp (TyVarG x) ρ ρ' = refl ren-comp (TyFunG ty1 ty2) ρ ρ' = cong₂ TyFunG (ren-comp ty1 ρ ρ') (ren-comp ty2 ρ ρ') ren-comp (TyIFixG ty1 k ty2) ρ ρ' = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (ren-comp ty1 ρ ρ') (ren-comp ty2 ρ ρ') ren-comp (TyForallG k ty) ρ ρ' = cong (TyForallG k) (trans (ren-cong (λ x → ext-comp x ρ ρ') ty) (ren-comp ty (ext ρ) (ext ρ'))) ren-comp (TyBuiltinG b) ρ ρ' = refl ren-comp (TyLamG ty) ρ ρ' = cong TyLamG (trans (ren-cong (λ x → ext-comp x ρ ρ') ty) (ren-comp ty (ext ρ) (ext ρ'))) ren-comp (TyAppG ty1 ty2 k) ρ ρ' = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (ren-comp ty1 ρ ρ') (ren-comp ty2 ρ ρ') -- ** Type reduction -- |Extend type substitutions. exts : (n → TypeG m) -> S n → TypeG (S m) exts _ FZ = TyVarG FZ exts s (FS i) = ren FS (s i) -- FS <$> s i {-# COMPILE AGDA2HS exts #-} -- |Simultaneous substitution of type variables. sub : (n -> TypeG m) -> TypeG n -> TypeG m sub s (TyVarG i) = s i sub s (TyFunG ty1 ty2) = TyFunG (sub s ty1) (sub s ty2) sub s (TyIFixG ty1 k ty2) = TyIFixG (sub s ty1) k (sub s ty2) sub s (TyForallG k ty) = TyForallG k (sub (exts s) ty) sub _ (TyBuiltinG tyBuiltin) = TyBuiltinG tyBuiltin sub s (TyLamG ty) = TyLamG (sub (exts s) ty) sub s (TyAppG ty1 ty2 k) = TyAppG (sub s ty1) (sub s ty2) k {-# COMPILE AGDA2HS sub #-} {-# FOREIGN AGDA2HS instance Monad TypeG where a >>= f = sub f a -- return = pure instance Applicative TypeG where (<*>) = ap pure = TyVarG #-} -- sub ((=<<) for TypeG) satisfies the monad laws exts-cong : {σ σ' : m → TypeG n} → (∀ x → σ x ≡ σ' x) → ∀ x → exts σ x ≡ exts σ' x exts-cong p FZ = refl exts-cong p (FS x) = cong (ren FS) (p x) sub-cong : {σ σ' : m → TypeG n} → (∀ x → σ x ≡ σ' x) → ∀ ty → sub σ ty ≡ sub σ' ty sub-cong p (TyVarG x) = p x sub-cong p (TyFunG ty1 ty2) = cong₂ TyFunG (sub-cong p ty1) (sub-cong p ty2) sub-cong p (TyIFixG ty1 k ty2) = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (sub-cong p ty1) (sub-cong p ty2) sub-cong p (TyForallG k ty) = cong (TyForallG k) (sub-cong (exts-cong p) ty) sub-cong p (TyBuiltinG b) = refl sub-cong p (TyLamG ty) = cong TyLamG (sub-cong (exts-cong p) ty) sub-cong p (TyAppG ty1 ty2 k) = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (sub-cong p ty1) (sub-cong p ty2) exts-id : (x : S m) → exts TyVarG x ≡ TyVarG x exts-id FZ = refl exts-id (FS x) = refl sub-id : (t : TypeG m) → sub TyVarG t ≡ t sub-id (TyVarG x) = refl sub-id (TyFunG ty1 ty2) = cong₂ TyFunG (sub-id ty1) (sub-id ty2) sub-id (TyIFixG ty1 k ty2) = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (sub-id ty1) (sub-id ty2) sub-id (TyForallG k ty) = cong (TyForallG k) (trans (sub-cong exts-id ty) (sub-id ty)) sub-id (TyBuiltinG b) = refl sub-id (TyLamG ty) = cong TyLamG (trans (sub-cong exts-id ty) (sub-id ty)) sub-id (TyAppG ty1 ty2 k) = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (sub-id ty1) (sub-id ty2) exts-ext : (x : S m)(ρ : m → n)(σ : n → TypeG o) → exts (σ ∘ ρ) x ≡ exts σ (ext ρ x) exts-ext FZ σ ρ = refl exts-ext (FS x) σ ρ = refl sub-ren : (t : TypeG m)(ρ : m → n)(σ : n → TypeG o) → sub (σ ∘ ρ) t ≡ sub σ (ren ρ t) sub-ren (TyVarG x) ρ σ = refl sub-ren (TyFunG ty1 ty2) ρ σ = cong₂ TyFunG (sub-ren ty1 ρ σ) (sub-ren ty2 ρ σ) sub-ren (TyIFixG ty1 k ty2) ρ σ = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (sub-ren ty1 ρ σ) (sub-ren ty2 ρ σ) sub-ren (TyForallG k ty) ρ σ = cong (TyForallG k) (trans (sub-cong (λ x → exts-ext x ρ σ) ty) (sub-ren ty (ext ρ) (exts σ))) sub-ren (TyBuiltinG b) ρ σ = refl sub-ren (TyLamG ty) ρ σ = cong TyLamG (trans (sub-cong (λ x → exts-ext x ρ σ) ty) (sub-ren ty (ext ρ) (exts σ))) sub-ren (TyAppG ty1 ty2 k) ρ σ = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (sub-ren ty1 ρ σ) (sub-ren ty2 ρ σ) ext-exts : (x : S m)(σ : m → TypeG n)(ρ : n → o) → exts (ren ρ ∘ σ) x ≡ ren (ext ρ) (exts σ x) ext-exts FZ σ ρ = refl ext-exts (FS x) σ ρ = trans (sym (ren-comp (σ x) ρ FS)) (ren-comp (σ x) FS (ext ρ)) ren-sub : (t : TypeG m)(σ : m → TypeG n)(ρ : n → o) → sub (ren ρ ∘ σ) t ≡ ren ρ (sub σ t) ren-sub (TyVarG x) σ ρ = refl ren-sub (TyFunG ty1 ty2) σ ρ = cong₂ TyFunG (ren-sub ty1 σ ρ) (ren-sub ty2 σ ρ) ren-sub (TyIFixG ty1 k ty2) σ ρ = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (ren-sub ty1 σ ρ) (ren-sub ty2 σ ρ) ren-sub (TyForallG k ty) σ ρ = cong (TyForallG k) (trans (sub-cong (λ x → ext-exts x σ ρ) ty) (ren-sub ty (exts σ) (ext ρ))) ren-sub (TyBuiltinG b) σ ρ = refl ren-sub (TyLamG ty) σ ρ = cong TyLamG (trans (sub-cong (λ x → ext-exts x σ ρ) ty) (ren-sub ty (exts σ) (ext ρ))) ren-sub (TyAppG ty1 ty2 k) σ ρ = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (ren-sub ty1 σ ρ) (ren-sub ty2 σ ρ) exts-comp : (x : S m)(σ : m → TypeG n)(σ' : n → TypeG o) → exts (sub σ' ∘ σ) x ≡ sub (exts σ') (exts σ x) exts-comp FZ σ σ' = refl exts-comp (FS x) σ σ' = trans (sym (ren-sub (σ x) σ' FS)) (sub-ren (σ x) FS (exts σ')) sub-comp : (ty : TypeG m)(σ : m → TypeG n)(σ' : n → TypeG o) → sub (sub σ' ∘ σ) ty ≡ sub σ' (sub σ ty) sub-comp (TyVarG x) σ σ' = refl sub-comp (TyFunG ty1 ty2) σ σ' = cong₂ TyFunG (sub-comp ty1 σ σ') (sub-comp ty2 σ σ') sub-comp (TyIFixG ty1 k ty2) σ σ' = cong₂ (λ ty1 ty2 → TyIFixG ty1 k ty2) (sub-comp ty1 σ σ') (sub-comp ty2 σ σ') sub-comp (TyForallG k ty) σ σ' = cong (TyForallG k) (trans (sub-cong (λ x → exts-comp x σ σ') ty) (sub-comp ty (exts σ) (exts σ'))) sub-comp (TyBuiltinG b) σ σ' = refl sub-comp (TyLamG ty) σ σ' = cong TyLamG (trans (sub-cong (λ x → exts-comp x σ σ') ty) (sub-comp ty (exts σ) (exts σ'))) sub-comp (TyAppG ty1 ty2 k) σ σ' = cong₂ (λ ty1 ty2 → TyAppG ty1 ty2 k) (sub-comp ty1 σ σ') (sub-comp ty2 σ σ')
{ "alphanum_fraction": 0.5874481719, "avg_line_length": 32.7530864198, "ext": "agda", "hexsha": "8a5bc1528dac341423e7fd999ac66feab96abcdd", "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": "77e80e0f286494cac29e46b5ed6a7e5ea409f7ef", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "kk-anlm/plutus", "max_forks_repo_path": "plutus-core/generators/PlutusCore/Generators/NEAT/Type.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "77e80e0f286494cac29e46b5ed6a7e5ea409f7ef", "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": "kk-anlm/plutus", "max_issues_repo_path": "plutus-core/generators/PlutusCore/Generators/NEAT/Type.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "77e80e0f286494cac29e46b5ed6a7e5ea409f7ef", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "kk-anlm/plutus", "max_stars_repo_path": "plutus-core/generators/PlutusCore/Generators/NEAT/Type.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4318, "size": 10612 }
module Fail.MultiArgumentPatternLambda where open import Agda.Builtin.Bool tooManyPats : Bool → Bool → Bool tooManyPats = λ where false false → false true true → false _ _ → true {-# COMPILE AGDA2HS tooManyPats #-}
{ "alphanum_fraction": 0.6066176471, "avg_line_length": 24.7272727273, "ext": "agda", "hexsha": "64282886385589d5c1e545bf47316a4ba39bbf9e", "lang": "Agda", "max_forks_count": 18, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_path": "test/Fail/MultiArgumentPatternLambda.agda", "max_issues_count": 63, "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_path": "test/Fail/MultiArgumentPatternLambda.agda", "max_line_length": 44, "max_stars_count": 55, "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_path": "test/Fail/MultiArgumentPatternLambda.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "num_tokens": 68, "size": 272 }
-- Andreas, 2018-03-23: issue #3007, reported by Fabian -- An broken identifier followed by a comment and then the end of the file -- caused an internal error during error reporting. -- -- Should fail without internal error. postulate _-- This is the end of the file!
{ "alphanum_fraction": 0.7407407407, "avg_line_length": 30, "ext": "agda", "hexsha": "174f09bec2fa481ce55e1d514876c1a8c5969fa8", "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/Issue3007.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/Issue3007.agda", "max_line_length": 74, "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/Issue3007.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 66, "size": 270 }
module Relator.Equals.Proofs where open import Relator.Equals open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Structure.Setoid renaming (_≡_ to _≡ₛ_) instance [≡]-reflexivity : ∀{ℓ}{A : Type{ℓ}} → Reflexivity(_≡_ {P = A}) Reflexivity.proof([≡]-reflexivity) = constant-path instance [≡]-symmetry : ∀{ℓ}{A : Type{ℓ}} → Symmetry(_≡_ {P = A}) Symmetry.proof([≡]-symmetry) = reversed-path
{ "alphanum_fraction": 0.7104072398, "avg_line_length": 29.4666666667, "ext": "agda", "hexsha": "f0e4a9d9f45c06e500402c9200970b8811dfc7d6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "old/Mathematical/Relator/Equals/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Mathematical/Relator/Equals/Proofs.agda", "max_line_length": 64, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "old/Mathematical/Relator/Equals/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": 150, "size": 442 }
module New.NewNew where open import New.Changes open import New.LangChanges open import New.Lang open import New.Derive open import Data.Empty [_]τ_from_to_ : ∀ (τ : Type) → (dv : Chτ τ) → (v1 v2 : ⟦ τ ⟧Type) → Set -- This can't be a datatype, since it wouldn't be strictly positive as it -- appears on the left of an arrow in the function case, which then can be -- contained in nested "fromto-validity" proofs. sumfromto : ∀ (σ τ : Type) → (dv : SumChange2 {A = ⟦ σ ⟧Type} {B = ⟦ τ ⟧Type}) → (v1 v2 : ⟦ sum σ τ ⟧Type) → Set sumfromto σ τ (ch₁ da) (inj₁ a1) (inj₁ a2) = [ σ ]τ da from a1 to a2 -- These fallback equations unfortunately don't hold definitionally, they're -- split on multiple cases, so the pattern match is a mess. -- -- To "case split" on validity, I typically copy-paste the pattern match from -- fromto→⊕ and change the function name :-(. sumfromto σ τ (ch₁ da) _ _ = ⊥ sumfromto σ τ (ch₂ db) (inj₂ b1) (inj₂ b2) = [ τ ]τ db from b1 to b2 sumfromto σ τ (ch₂ db) _ _ = ⊥ sumfromto σ τ (rp (inj₂ b2)) (inj₁ a1) (inj₂ b2') = b2 ≡ b2' sumfromto σ τ (rp (inj₁ a2)) (inj₂ b1) (inj₁ a2') = a2 ≡ a2' sumfromto σ τ (rp s) _ _ = ⊥ [ σ ⇒ τ ]τ df from f1 to f2 = ∀ (da : Chτ σ) (a1 a2 : ⟦ σ ⟧Type) → [ σ ]τ da from a1 to a2 → [ τ ]τ df a1 da from f1 a1 to f2 a2 [ int ]τ dv from v1 to v2 = v2 ≡ v1 + dv [ pair σ τ ]τ (da , db) from (a1 , b1) to (a2 , b2) = [ σ ]τ da from a1 to a2 × [ τ ]τ db from b1 to b2 [ sum σ τ ]τ dv from v1 to v2 = sumfromto σ τ (convert dv) v1 v2 data [_]Γ_from_to_ : ∀ Γ → ChΓ Γ → (ρ1 ρ2 : ⟦ Γ ⟧Context) → Set where v∅ : [ ∅ ]Γ ∅ from ∅ to ∅ _v•_ : ∀ {τ Γ dv v1 v2 dρ ρ1 ρ2} → (dvv : [ τ ]τ dv from v1 to v2) → (dρρ : [ Γ ]Γ dρ from ρ1 to ρ2) → [ τ • Γ ]Γ (dv • v1 • dρ) from (v1 • ρ1) to (v2 • ρ2) ⟦Γ≼ΔΓ⟧ : ∀ {Γ ρ1 ρ2 dρ} → (dρρ : [ Γ ]Γ dρ from ρ1 to ρ2) → ρ1 ≡ ⟦ Γ≼ΔΓ ⟧≼ dρ ⟦Γ≼ΔΓ⟧ v∅ = refl ⟦Γ≼ΔΓ⟧ (dvv v• dρρ) = cong₂ _•_ refl (⟦Γ≼ΔΓ⟧ dρρ) fit-sound : ∀ {Γ τ} → (t : Term Γ τ) → ∀ {dρ ρ1 ρ2} → [ Γ ]Γ dρ from ρ1 to ρ2 → ⟦ t ⟧Term ρ1 ≡ ⟦ fit t ⟧Term dρ fit-sound t dρρ = trans (cong ⟦ t ⟧Term (⟦Γ≼ΔΓ⟧ dρρ)) (sym (weaken-sound t _)) -- Now relate this validity with ⊕. To know that nil and so on are valid, also -- relate it to the other definition. fromto→⊕ : ∀ {τ} dv v1 v2 → [ τ ]τ dv from v1 to v2 → v1 ⊕ dv ≡ v2 ⊝-fromto : ∀ {τ} (v1 v2 : ⟦ τ ⟧Type) → [ τ ]τ v2 ⊝ v1 from v1 to v2 ⊝-fromto {σ ⇒ τ} f1 f2 da a1 a2 daa rewrite sym (fromto→⊕ da a1 a2 daa) = ⊝-fromto (f1 a1) (f2 (a1 ⊕ da)) ⊝-fromto {int} v1 v2 = sym (update-diff v2 v1) ⊝-fromto {pair σ τ} (a1 , b1) (a2 , b2) = ⊝-fromto a1 a2 , ⊝-fromto b1 b2 ⊝-fromto {sum σ τ} (inj₁ a1) (inj₁ a2) = ⊝-fromto a1 a2 ⊝-fromto {sum σ τ} (inj₁ a1) (inj₂ b2) = refl ⊝-fromto {sum σ τ} (inj₂ b1) (inj₁ a2) = refl ⊝-fromto {sum σ τ} (inj₂ b1) (inj₂ b2) = ⊝-fromto b1 b2 nil-fromto : ∀ {τ} (v : ⟦ τ ⟧Type) → [ τ ]τ nil v from v to v nil-fromto v = ⊝-fromto v v fromto→⊕ {σ ⇒ τ} df f1 f2 dff = ext (λ v → fromto→⊕ {τ} (df v (nil v)) (f1 v) (f2 v) (dff (nil v) v v (nil-fromto v))) fromto→⊕ {int} dn n1 n2 refl = refl fromto→⊕ {pair σ τ} (da , db) (a1 , b1) (a2 , b2) (daa , dbb) = cong₂ _,_ (fromto→⊕ _ _ _ daa) (fromto→⊕ _ _ _ dbb) fromto→⊕ {sum σ τ} (inj₁ (inj₁ da)) (inj₁ a1) (inj₁ a2) daa rewrite fromto→⊕ da a1 a2 daa = refl fromto→⊕ {sum σ τ} (inj₁ (inj₁ da)) (inj₁ _) (inj₂ _) () fromto→⊕ {sum σ τ} (inj₁ (inj₁ da)) (inj₂ _) (inj₁ _) () fromto→⊕ {sum σ τ} (inj₁ (inj₁ da)) (inj₂ _) (inj₂ _) () fromto→⊕ {sum σ τ} (inj₁ (inj₂ db)) (inj₂ b1) (inj₂ b2) dbb rewrite fromto→⊕ db b1 b2 dbb = refl fromto→⊕ {sum σ τ} (inj₁ (inj₂ db)) (inj₁ _) (inj₁ _) () fromto→⊕ {sum σ τ} (inj₁ (inj₂ db)) (inj₁ _) (inj₂ _) () fromto→⊕ {sum σ τ} (inj₁ (inj₂ db)) (inj₂ _) (inj₁ _) () fromto→⊕ {sum σ τ} (inj₂ (inj₁ a2)) (inj₂ b1) (inj₁ .a2) refl = refl fromto→⊕ {sum σ τ} (inj₂ (inj₁ a2)) (inj₁ _) (inj₁ _) () fromto→⊕ {sum σ τ} (inj₂ (inj₁ a2)) (inj₁ _) (inj₂ _) () fromto→⊕ {sum σ τ} (inj₂ (inj₁ a2)) (inj₂ _) (inj₂ _) () fromto→⊕ {sum σ τ} (inj₂ (inj₂ b2)) (inj₁ a1) (inj₂ .b2) refl = refl fromto→⊕ {sum σ τ} (inj₂ (inj₂ b2)) (inj₁ _) (inj₁ _) () fromto→⊕ {sum σ τ} (inj₂ (inj₂ b2)) (inj₂ _) (inj₁ _) () fromto→⊕ {sum σ τ} (inj₂ (inj₂ b2)) (inj₂ _) (inj₂ _) () fromtoDeriveConst : ∀ {τ} c → [ τ ]τ ⟦ deriveConst c ⟧Term ∅ from ⟦ c ⟧Const to ⟦ c ⟧Const fromtoDeriveConst (lit n) = sym (right-id-int n) fromtoDeriveConst plus da a1 a2 daa db b1 b2 dbb rewrite daa | dbb = mn·pq=mp·nq {a1} {da} {b1} {db} fromtoDeriveConst minus da a1 a2 daa db b1 b2 dbb rewrite daa | dbb | sym (-m·-n=-mn {b1} {db}) = mn·pq=mp·nq {a1} {da} { - b1} { - db} fromtoDeriveConst cons da a1 a2 daa db b1 b2 dbb = daa , dbb fromtoDeriveConst fst (da , db) (a1 , b1) (a2 , b2) (daa , dbb) = daa fromtoDeriveConst snd (da , db) (a1 , b1) (a2 , b2) (daa , dbb) = dbb fromtoDeriveConst linj da a1 a2 daa = daa fromtoDeriveConst rinj db b1 b2 dbb = dbb fromtoDeriveConst match (inj₁ (inj₁ da)) (inj₁ a1) (inj₁ a2) daa df f1 f2 dff dg g1 g2 dgg = dff da a1 a2 daa fromtoDeriveConst match (inj₁ (inj₁ da)) (inj₁ _) (inj₂ _) () fromtoDeriveConst match (inj₁ (inj₁ da)) (inj₂ _) (inj₁ _) () fromtoDeriveConst match (inj₁ (inj₁ da)) (inj₂ _) (inj₂ _) () fromtoDeriveConst match (inj₁ (inj₂ db)) (inj₂ b1) (inj₂ b2) dbb df f1 f2 dff dg g1 g2 dgg = dgg db b1 b2 dbb fromtoDeriveConst match (inj₁ (inj₂ db)) (inj₁ _) (inj₁ _) () fromtoDeriveConst match (inj₁ (inj₂ db)) (inj₁ _) (inj₂ _) () fromtoDeriveConst match (inj₁ (inj₂ db)) (inj₂ _) (inj₁ _) () fromtoDeriveConst match (inj₂ (inj₁ a2)) (inj₂ b1) (inj₁ .a2) refl df f1 f2 dff dg g1 g2 dgg rewrite changeMatchSem-lem2 f1 df g1 dg b1 a2 | sym (fromto→⊕ df _ _ dff) | sym (fromto→⊕ dg _ _ dgg) = ⊝-fromto (g1 b1) ((f1 ⊕ df) a2) fromtoDeriveConst match (inj₂ (inj₁ a2)) (inj₁ _) (inj₁ _) () fromtoDeriveConst match (inj₂ (inj₁ a2)) (inj₁ _) (inj₂ _) () fromtoDeriveConst match (inj₂ (inj₁ a2)) (inj₂ _) (inj₂ _) () fromtoDeriveConst match (inj₂ (inj₂ b2)) (inj₁ a1) (inj₂ .b2) refl df f1 f2 dff dg g1 g2 dgg rewrite changeMatchSem-lem1 f1 df g1 dg a1 b2 | sym (fromto→⊕ df _ _ dff) | sym (fromto→⊕ dg _ _ dgg) = ⊝-fromto (f1 a1) ((g1 ⊕ dg) b2) fromtoDeriveConst match (inj₂ (inj₂ b2)) (inj₁ _) (inj₁ _) () fromtoDeriveConst match (inj₂ (inj₂ b2)) (inj₂ _) (inj₁ _) () fromtoDeriveConst match (inj₂ (inj₂ b2)) (inj₂ _) (inj₂ _) () fromtoDeriveVar : ∀ {Γ τ} → (x : Var Γ τ) → ∀ {dρ ρ1 ρ2} → [ Γ ]Γ dρ from ρ1 to ρ2 → [ τ ]τ (⟦ x ⟧ΔVar ρ1 dρ) from (⟦ x ⟧Var ρ1) to (⟦ x ⟧Var ρ2) fromtoDeriveVar this (dvv v• dρρ) = dvv fromtoDeriveVar (that x) (dvv v• dρρ) = fromtoDeriveVar x dρρ fromtoDerive : ∀ {Γ} τ → (t : Term Γ τ) → {dρ : ChΓ Γ} {ρ1 ρ2 : ⟦ Γ ⟧Context} → [ Γ ]Γ dρ from ρ1 to ρ2 → [ τ ]τ (⟦ t ⟧ΔTerm ρ1 dρ) from (⟦ t ⟧Term ρ1) to (⟦ t ⟧Term ρ2) fromtoDerive τ (const c) {dρ} {ρ1} dρρ rewrite ⟦ c ⟧ΔConst-rewrite ρ1 dρ = fromtoDeriveConst c fromtoDerive τ (var x) dρρ = fromtoDeriveVar x dρρ fromtoDerive τ (app {σ} s t) dρρ rewrite sym (fit-sound t dρρ) = let fromToF = fromtoDerive (σ ⇒ τ) s dρρ in let fromToB = fromtoDerive σ t dρρ in fromToF _ _ _ fromToB fromtoDerive (σ ⇒ τ) (abs t) dρρ = λ dv v1 v2 dvv → fromtoDerive τ t (dvv v• dρρ) open import Postulate.Extensionality open ≡-Reasoning -- If df is valid, prove (f1 ⊕ df) (a ⊕ da) ≡ f1 a ⊕ df a da. -- This statement uses a ⊕ da instead of a2, which is not the style of this formalization but fits better with the other one. -- Instead, WellDefinedFunChangeFromTo (without prime) fits this formalization. WellDefinedFunChangeFromTo′ : ∀ {σ τ} (f1 : ⟦ σ ⇒ τ ⟧Type) → (df : Chτ (σ ⇒ τ)) → Set WellDefinedFunChangeFromTo′ f1 df = ∀ da a → [ _ ]τ da from a to (a ⊕ da) → WellDefinedFunChangePoint f1 df a da fromto→WellDefined′ : ∀ {σ τ f1 f2 df} → [ σ ⇒ τ ]τ df from f1 to f2 → WellDefinedFunChangeFromTo′ f1 df fromto→WellDefined′ {f1 = f1} {f2} {df} dff da a daa = begin (f1 ⊕ df) (a ⊕ da) ≡⟨ cong (λ □ → □ (a ⊕ da)) (fromto→⊕ df f1 f2 dff)⟩ f2 (a ⊕ da) ≡⟨ sym (fromto→⊕ _ _ _ (dff da _ _ daa)) ⟩ f1 a ⊕ df a da ∎ WellDefinedFunChangeFromTo : ∀ {σ τ} (f1 : ⟦ σ ⇒ τ ⟧Type) → (df : Chτ (σ ⇒ τ)) → Set WellDefinedFunChangeFromTo f1 df = ∀ da a1 a2 → [ _ ]τ da from a1 to a2 → WellDefinedFunChangePoint f1 df a1 da fromto→WellDefined : ∀ {σ τ f1 f2 df} → [ σ ⇒ τ ]τ df from f1 to f2 → WellDefinedFunChangeFromTo f1 df fromto→WellDefined {f1 = f1} {f2} {df} dff da a1 a2 daa = fromto→WellDefined′ dff da a1 daa′ where daa′ : [ _ ]τ da from a1 to (a1 ⊕ da) daa′ rewrite fromto→⊕ da _ _ daa = daa -- Recursive isomorphism between the two validities. -- -- Among other things, valid→fromto proves that a validity-preserving function, -- with validity defined via (f1 ⊕ df) (a ⊕ da) ≡ f1 a ⊕ df a da, is also valid -- in the "fromto" sense. -- -- We can't hope for a better statement, since we need the equation to be -- satisfied also by returned or argument functions. fromto→valid : ∀ {τ} → ∀ dv v1 v2 → [ τ ]τ dv from v1 to v2 → valid v1 dv valid→fromto : ∀ {τ} v (dv : Chτ τ) → valid v dv → [ τ ]τ dv from v to (v ⊕ dv) fromto→valid {int} = λ dv v1 v2 x → tt fromto→valid {pair σ τ} (da , db) (a1 , b1) (a2 , b2) (daa , dbb) = (fromto→valid da _ _ daa) , (fromto→valid db _ _ dbb) fromto→valid {σ ⇒ τ} df f1 f2 dff = λ a da ada → fromto→valid (df a da) (f1 a) (f2 (a ⊕ da)) (dff da a (a ⊕ da) (valid→fromto a da ada)) , fromto→WellDefined′ dff da a (valid→fromto a da ada) fromto→valid {sum σ τ} (inj₁ (inj₁ da)) (inj₁ a1) (inj₁ a2) daa = sv₁ a1 da (fromto→valid da a1 a2 daa) fromto→valid {sum σ τ} (inj₁ (inj₁ da)) (inj₁ _) (inj₂ _) () fromto→valid {sum σ τ} (inj₁ (inj₁ da)) (inj₂ _) (inj₁ _) () fromto→valid {sum σ τ} (inj₁ (inj₁ da)) (inj₂ _) (inj₂ _) () fromto→valid {sum σ τ} (inj₁ (inj₂ db)) (inj₂ b1) (inj₂ b2) dbb = sv₂ b1 db (fromto→valid db b1 b2 dbb) fromto→valid {sum σ τ} (inj₁ (inj₂ db)) (inj₁ _) (inj₁ _) () fromto→valid {sum σ τ} (inj₁ (inj₂ db)) (inj₁ _) (inj₂ _) () fromto→valid {sum σ τ} (inj₁ (inj₂ db)) (inj₂ _) (inj₁ _) () fromto→valid {sum σ τ} (inj₂ (inj₁ a2)) (inj₂ b1) (inj₁ .a2) refl = svrp₂ b1 a2 fromto→valid {sum σ τ} (inj₂ (inj₁ a2)) (inj₁ _) (inj₁ _) () fromto→valid {sum σ τ} (inj₂ (inj₁ a2)) (inj₁ _) (inj₂ _) () fromto→valid {sum σ τ} (inj₂ (inj₁ a2)) (inj₂ _) (inj₂ _) () fromto→valid {sum σ τ} (inj₂ (inj₂ b2)) (inj₁ a1) (inj₂ .b2) refl = svrp₁ a1 b2 fromto→valid {sum σ τ} (inj₂ (inj₂ b2)) (inj₁ _) (inj₁ _) () fromto→valid {sum σ τ} (inj₂ (inj₂ b2)) (inj₂ _) (inj₁ _) () fromto→valid {sum σ τ} (inj₂ (inj₂ b2)) (inj₂ _) (inj₂ _) () valid→fromto {int} v dv tt = refl valid→fromto {pair σ τ} (a , b) (da , db) (ada , bdb) = valid→fromto a da ada , valid→fromto b db bdb valid→fromto {σ ⇒ τ} f df fdf da a1 a2 daa = body where fa1da-valid : valid (f a1) (df a1 da) × WellDefinedFunChangePoint f df a1 da fa1da-valid = fdf a1 da (fromto→valid da _ _ daa) body : [ τ ]τ df a1 da from f a1 to (f ⊕ df) a2 body rewrite sym (fromto→⊕ da _ _ daa) | proj₂ fa1da-valid = valid→fromto (f a1) (df a1 da) (proj₁ fa1da-valid) valid→fromto {sum σ τ} .(inj₁ a) .(inj₁ (inj₁ da)) (sv₁ a da ada) = valid→fromto a da ada valid→fromto {sum σ τ} .(inj₂ b) .(inj₁ (inj₂ db)) (sv₂ b db bdb) = valid→fromto b db bdb valid→fromto {sum σ τ} .(inj₁ a1) .(inj₂ (inj₂ b2)) (svrp₁ a1 b2) = refl valid→fromto {sum σ τ} .(inj₂ b1) .(inj₂ (inj₁ a2)) (svrp₂ b1 a2) = refl correctDeriveOplus : ∀ {Γ} τ → (t : Term Γ τ) → {dρ : ChΓ Γ} {ρ1 ρ2 : ⟦ Γ ⟧Context} → [ Γ ]Γ dρ from ρ1 to ρ2 → (⟦ t ⟧Term ρ1) ⊕ (⟦ t ⟧ΔTerm ρ1 dρ) ≡ (⟦ t ⟧Term ρ2) correctDeriveOplus τ t dρρ = fromto→⊕ _ _ _ (fromtoDerive τ t dρρ) -- Getting to the original equation 1 from PLDI'14. open import New.LangOps correctDeriveOplusτ : ∀ {Γ} τ → (t : Term Γ τ) {dρ : ChΓ Γ} {ρ1 ρ2 : ⟦ Γ ⟧Context} → [ Γ ]Γ dρ from ρ1 to ρ2 → (⟦ app₂ (oplusτo τ) (fit t) (derive t) ⟧Term dρ) ≡ (⟦ t ⟧Term ρ2) correctDeriveOplusτ τ t {dρ = dρ} {ρ1 = ρ1} dρρ rewrite oplusτ-equiv _ dρ _ (⟦ fit t ⟧Term dρ) (⟦ derive t ⟧Term dρ) | sym (fit-sound t dρρ) = correctDeriveOplus τ t dρρ deriveGivesDerivative : ∀ {Γ} σ τ → (f : Term Γ (σ ⇒ τ)) (a : Term Γ σ)→ {dρ : ChΓ Γ} {ρ1 ρ2 : ⟦ Γ ⟧Context} → [ Γ ]Γ dρ from ρ1 to ρ2 → (⟦ app f a ⟧Term ρ1) ⊕ (⟦ app f a ⟧ΔTerm ρ1 dρ) ≡ (⟦ app f a ⟧Term ρ2) deriveGivesDerivative σ τ f a dρρ = correctDeriveOplus τ (app f a) dρρ deriveGivesDerivative₂ : ∀ {Γ} σ τ → (f : Term Γ (σ ⇒ τ)) (a : Term Γ σ) → {dρ : ChΓ Γ} {ρ1 ρ2 : ⟦ Γ ⟧Context} → [ Γ ]Γ dρ from ρ1 to ρ2 → (⟦ app₂ (oplusτo τ) (fit (app f a)) (app₂ (derive f) (fit a) (derive a)) ⟧Term dρ) ≡ (⟦ app f a ⟧Term ρ2) deriveGivesDerivative₂ σ τ f a dρρ = correctDeriveOplusτ τ (app f a) dρρ -- Proof of the original equation 1 from PLDI'14. eq1 : ∀ {Γ} σ τ → {nilρ : ChΓ Γ} {ρ : ⟦ Γ ⟧Context} → [ Γ ]Γ nilρ from ρ to ρ → ∀ (f : Term Γ (σ ⇒ τ)) (a : Term Γ σ) (da : Term (ΔΓ Γ) (Δt σ)) → (daa : [ σ ]τ (⟦ da ⟧Term nilρ) from (⟦ a ⟧Term ρ) to (⟦ a ⟧Term ρ ⊕ ⟦ da ⟧Term nilρ)) → ⟦ app₂ (oplusτo τ) (fit (app f a)) (app₂ (derive f) (fit a) da) ⟧Term nilρ ≡ ⟦ app (fit f) (app₂ (oplusτo σ) (fit a) da) ⟧Term nilρ eq1 σ τ {nilρ} {ρ} dρρ f a da daa rewrite oplusτ-equiv _ nilρ _ (⟦ fit (app f a) ⟧Term nilρ) (⟦ (app₂ (derive f) (fit a) da) ⟧Term nilρ) | sym (fit-sound f dρρ) | oplusτ-equiv _ nilρ _ (⟦ fit a ⟧Term nilρ) (⟦ da ⟧Term nilρ) | sym (fit-sound a dρρ) = fromto→⊕ (⟦ f ⟧ΔTerm ρ nilρ (⟦ a ⟧Term ρ) (⟦ da ⟧Term nilρ)) _ _ (fromtoDerive _ f dρρ (⟦ da ⟧Term nilρ) (⟦ a ⟧Term ρ) (⟦ a ⟧Term ρ ⊕ ⟦ da ⟧Term nilρ) daa)
{ "alphanum_fraction": 0.6055708647, "avg_line_length": 50.6679245283, "ext": "agda", "hexsha": "626ae260dbc93ba4f1736e2b922eee72c9a0fe40", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "New/NewNew.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "New/NewNew.agda", "max_line_length": 228, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "New/NewNew.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 6531, "size": 13427 }
module Data.ListSized.Functions where import Lvl open import Data.ListSized open import Functional open import Numeral.Finite open import Numeral.Natural open import Numeral.Natural.Function open import Numeral.Natural.Oper open import Numeral.Natural.Oper.Proofs open import Type private variable ℓ ℓ₁ ℓ₂ : Lvl.Level private variable T A A₁ A₂ B B₁ B₂ Result : Type{ℓ} private variable a b n n₁ n₂ : ℕ -- List concatenation _++_ : List(T)(a) → List(T)(b) → List(T)(a + b) _++_ x y = elim _ (\{a} → const(List _ (a + _))) y (const ∘ (_⊰_)) x infixl 1000 _++_ -- The first element of the list head : List(T)(𝐒(n)) → T head (x ⊰ _) = x -- The list without its first element tail : List(T)(𝐒(n)) → List(T)(n) tail (_ ⊰ l) = l tail₀ : List(T)(n) → List(T)(𝐏(n)) tail₀ ∅ = ∅ tail₀ (_ ⊰ l) = l -- The nth element in the list index : 𝕟(n) → List(T)(n) → T index 𝟎 (x ⊰ _) = x index (𝐒(n)) (_ ⊰ l) = index n l -- The sublist with the first n elements in the list first : (k : 𝕟₌(n)) → List(T)(n) → List(T)(𝕟-to-ℕ k) first 𝟎 _ = ∅ first (𝐒(n)) (x ⊰ l) = x ⊰ (first n l) -- skip : ∀{n} → (k : 𝕟₌(n)) → List(T)(n) → List(T)(n − k) -- last : ∀{n} → (k : 𝕟₌(n)) → List(T)(n) → List(T)(𝕟-to-ℕ k) -- Length of the list (number of elements in the list) length : List(T)(n) → ℕ length {n = n} _ = n -- The list with an element repeated n times repeat : T → (n : ℕ) → List(T)(n) repeat _ 𝟎 = ∅ repeat x (𝐒(n)) = x ⊰ (repeat x n) -- A list constructed from a function fromFn : (𝕟(n) → T) → List(T)(n) fromFn {n = 𝟎} _ = ∅ fromFn {n = 𝐒(n)} f = f(𝟎) ⊰ fromFn {n = n} (f ∘ 𝐒) -- The list with a list concatenated (repeated) n times _++^_ : List(T)(n) → (k : ℕ) → List(T)(n ⋅ k) _++^_ _ 𝟎 = ∅ _++^_ l (𝐒(k)) = l ++ (l ++^ k) -- Applies a function to each element in the list map : (A → B) → List(A)(n) → List(B)(n) map f = elim _ (\{n} _ → List(_)(n)) ∅ (const ∘ (_⊰_) ∘ f) -- Applies a binary operator to each element in the list starting with the initial element. -- Example: -- foldₗ(▫)(init)[] = init -- foldₗ(▫)(init)[a] = init▫a -- foldₗ(▫)(init)[a,b] = (init▫a)▫b -- foldₗ(▫)(init)[a,b,c,d,e] = ((((init▫a)▫b)▫c)▫d)▫e foldₗ : (Result → T → Result) → Result → List(T)(n) → Result foldₗ _ result ∅ = result foldₗ(_▫_) result (elem ⊰ l) = foldₗ(_▫_) (result ▫ elem) l -- Applies a binary operator to each element in the list starting with the initial element. -- Example: -- foldᵣ(▫)(init)[] = init -- foldᵣ(▫)(init)[a] = a▫init -- foldᵣ(▫)(init)[a,b] = a▫(b▫init) -- foldᵣ(▫)(init)[a,b,c,d,e] = a▫(b▫(c▫(d▫(e▫init)))) foldᵣ : (T → Result → Result) → Result → List(T)(n) → Result foldᵣ(_▫_) init = elim _ _ init (const ∘ (_▫_)) -- Example: -- reduceₗ(▫)[a] = a -- reduceₗ(▫)[a,b] = a▫b -- reduceₗ(▫)[a,b,c] = (a▫b)▫c -- reduceₗ(▫)[a,b,c,d,e] = (((a▫b)▫c)▫d)▫e reduceₗ : (T → T → T) → List(T)(𝐒(n)) → T reduceₗ(_▫_) (elem ⊰ l) = foldₗ(_▫_) elem l -- Example: -- reduceᵣ(▫)[a] = a -- reduceᵣ(▫)[a,b] = a▫b -- reduceᵣ(▫)[a,b,c] = a▫(b▫c) -- reduceᵣ(▫)[a,b,c,d,e] = a▫(b▫(c▫(d▫e))) reduceᵣ : (T → T → T) → List(T)(𝐒(n)) → T reduceᵣ(_▫_) (elem ⊰ l) = foldᵣ(_▫_) elem l map₂ : (A₁ → A₂ → B) → (List(A₁)(n₁) → List(B)(n₁)) → (List(A₂)(n₂) → List(B)(n₂)) → (List(A₁)(n₁) → List(A₂)(n₂) → List(B)(max n₁ n₂)) map₂ f g₁ g₂ ∅ ∅ = ∅ map₂ f g₁ g₂ ∅ l₂@(_ ⊰ _) = g₂ l₂ map₂ f g₁ g₂ l₁@(_ ⊰ _) ∅ = g₁ l₁ map₂ f g₁ g₂ (x₁ ⊰ l₁) (x₂ ⊰ l₂) = f x₁ x₂ ⊰ map₂ f (tail ∘ g₁ ∘ (x₁ ⊰_)) ((tail ∘ g₂ ∘ (x₂ ⊰_))) l₁ l₂ map₂₌ : (A₁ → A₂ → B) → (List(A₁)(n) → List(A₂)(n) → List(B)(n)) map₂₌ f ∅ ∅ = ∅ map₂₌ f (x₁ ⊰ l₁) (x₂ ⊰ l₂) = f x₁ x₂ ⊰ map₂₌ f l₁ l₂ -- Accumulates the results of every step in `_^_` into a list. -- Example: -- accumulateIterate₀ 0 f(x) = [] -- accumulateIterate₀ 1 f(x) = [x] -- accumulateIterate₀ 2 f(x) = [x , f(x)] -- accumulateIterate₀ 3 f(x) = [x , f(x) , f(f(x))] -- accumulateIterate₀ 4 f(x) = [x , f(x) , f(f(x)) , f(f(f(x)))] accumulateIterate₀ : (n : ℕ) → (T → T) → (T → List(T)(n)) accumulateIterate₀ 𝟎 f(x) = ∅ accumulateIterate₀ (𝐒(n)) f(x) = x ⊰ accumulateIterate₀ n f (f(x)) -- Accumulates the results of every step in `_^_` into a list. -- Example: -- accumulateIterate 0 f(x) = [x] -- accumulateIterate 1 f(x) = [x , f(x)] -- accumulateIterate 2 f(x) = [x , f(x) , f(f(x))] -- accumulateIterate 3 f(x) = [x , f(x) , f(f(x)) , f(f(f(x)))] -- accumulateIterate 4 f(x) = [x , f(x) , f(f(x)) , f(f(f(x))) , f(f(f(f(x))))] accumulateIterate : (n : ℕ) → (T → T) → (T → List(T)(𝐒(n))) accumulateIterate n = accumulateIterate₀(𝐒(n))
{ "alphanum_fraction": 0.5322511747, "avg_line_length": 34.6814814815, "ext": "agda", "hexsha": "46660575cc8ee23fea43d425bcb3b46545037974", "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/ListSized/Functions.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/ListSized/Functions.agda", "max_line_length": 135, "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/ListSized/Functions.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": 2099, "size": 4682 }
{-# OPTIONS --type-in-type #-} id : ∀ {A : Set} → A → A;id = λ x → x Pair : Set → Set → Set;Pair = λ A B → (P : Set) → (A → B → P) → P dup : ∀ {A : Set} → A → Pair A A;dup = λ a P p → p a a Nat : Set;Nat = (n : Set) → (n → n) → n → n zero : Nat;zero = λ n s z → z suc : Nat → Nat;suc = λ a n s z → s (a n s z) Vec : Set → Nat → Set;Vec = λ A n → (V : Nat → Set) → (∀{n} → A → V n → V (suc n)) → V zero → V n nil : ∀ {A : Set} → Vec A zero;nil = λ V c n → n cons : ∀ {A : Set}{n : Nat} → A → Vec A n → Vec A (suc n);cons = λ a as V c n → c a (as V c n) -------------------------------------------------------------------------------- -- Fails -- idTest : ∀ {A} → A → A;idTest -- = id id id id id id id id id id id id id id id id id id id id -- id id id id id id id id id id id id id id id id id id id id -- Fails -- pairTest = -- let x0 = dup Set -- x1 = dup x0 -- x2 = dup x1 -- x3 = dup x2 -- x4 = dup x3 -- x5 = dup x4 -- x6 = dup x5 -- x7 = dup x6 -- x8 = dup x7 -- x9 = dup x8 -- x10 = dup x9 -- x11 = dup x10 -- x12 = dup x11 -- x13 = dup x12 -- x14 = dup x13 -- x15 = dup x14 -- x16 = dup x15 -- x17 = dup x16 -- x18 = dup x17 -- x19 = dup x18 -- x20 = dup x19 -- in x20 vecTest = (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set (cons Set nil )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))) ))))))))))))))))))))))))))))))
{ "alphanum_fraction": 0.579854737, "avg_line_length": 48.3745173745, "ext": "agda", "hexsha": "b492147caf5039bbcdfc2bf0fd9bd92abe6761b4", "lang": "Agda", "max_forks_count": 19, "max_forks_repo_forks_event_max_datetime": "2022-03-03T19:46:54.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-05T21:11:34.000Z", "max_forks_repo_head_hexsha": "6a87f295148bd753d2519d50c2e1011b64c859ff", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "int-index/smalltt", "max_forks_repo_path": "bench/asymptotics.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "6a87f295148bd753d2519d50c2e1011b64c859ff", "max_issues_repo_issues_event_max_datetime": "2022-02-28T21:51:10.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-16T09:14:57.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "int-index/smalltt", "max_issues_repo_path": "bench/asymptotics.agda", "max_line_length": 80, "max_stars_count": 377, "max_stars_repo_head_hexsha": "6a87f295148bd753d2519d50c2e1011b64c859ff", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "int-index/smalltt", "max_stars_repo_path": "bench/asymptotics.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T21:31:01.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-26T16:57:16.000Z", "num_tokens": 4039, "size": 12529 }
module MLib.Prelude.TransitiveProver.Test where open import MLib.Prelude.FromStdlib open import Data.Nat open import Data.Nat.Properties open import MLib.Prelude.TransitiveProver _≤_ ≤-trans open Search <-isStrictTotalOrder 1≤3 : 1 ≤ 3 1≤3 = s≤s z≤n 3≤5 : 3 ≤ 5 3≤5 = s≤s (s≤s (s≤s z≤n)) 5≤9 : 5 ≤ 9 5≤9 = s≤s (s≤s (s≤s (s≤s (s≤s z≤n)))) 3≤6 : 3 ≤ 6 3≤6 = s≤s (s≤s (s≤s z≤n)) 9≤13 : 9 ≤ 13 9≤13 = s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s z≤n)))))))) 5≤13 : 5 ≤ 13 5≤13 = s≤s (s≤s (s≤s (s≤s (s≤s z≤n)))) 3≤3 : 3 ≤ 3 3≤3 = s≤s (s≤s (s≤s z≤n)) db : Database db = (_ , _ , 1≤3) ∷ (_ , _ , 3≤3) ∷ (_ , _ , 3≤6) ∷ (_ , _ , 9≤13) ∷ (_ , _ , 3≤5) ∷ (_ , _ , 3≤5) ∷ (_ , _ , 5≤13) ∷ (_ , _ , 5≤9) ∷ [] res : 3 ≤ 9 res = s≤s (s≤s (s≤s z≤n)) test1 : tryProve db 3 9 ≡ just res test1 = ≡.refl test2 = findTransTargets db 1
{ "alphanum_fraction": 0.5041224971, "avg_line_length": 15.7222222222, "ext": "agda", "hexsha": "fe4d31dd891e1e733a1b9cf93f66a88cee8723b2", "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/TransitiveProver/Test.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/TransitiveProver/Test.agda", "max_line_length": 62, "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/TransitiveProver/Test.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 524, "size": 849 }
------------------------------------------------------------------------ -- The Agda standard library -- -- A categorical view of Vec ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.Categorical {a n} where open import Category.Applicative using (RawApplicative) open import Category.Applicative.Indexed using (Morphism) open import Category.Functor as Fun using (RawFunctor) import Function.Identity.Categorical as Id open import Category.Monad using (RawMonad) open import Data.Fin.Base using (Fin) open import Data.Vec.Base as Vec hiding (_⊛_) open import Data.Vec.Properties open import Function ------------------------------------------------------------------------ -- Functor and applicative functor : RawFunctor (λ (A : Set a) → Vec A n) functor = record { _<$>_ = map } applicative : RawApplicative (λ (A : Set a) → Vec A n) applicative = record { pure = replicate ; _⊛_ = Vec._⊛_ } ------------------------------------------------------------------------ -- Get access to other monadic functions module TraversableA {f F} (App : RawApplicative {f} F) where open RawApplicative App sequenceA : ∀ {A n} → Vec (F A) n → F (Vec A n) sequenceA [] = pure [] sequenceA (x ∷ xs) = _∷_ <$> x ⊛ sequenceA xs mapA : ∀ {a} {A : Set a} {B n} → (A → F B) → Vec A n → F (Vec B n) mapA f = sequenceA ∘ map f forA : ∀ {a} {A : Set a} {B n} → Vec A n → (A → F B) → F (Vec B n) forA = flip mapA module TraversableM {m M} (Mon : RawMonad {m} M) where open RawMonad Mon open TraversableA rawIApplicative public renaming ( sequenceA to sequenceM ; mapA to mapM ; forA to forM ) ------------------------------------------------------------------------ -- Other -- lookup is a functor morphism from Vec to Identity. lookup-functor-morphism : (i : Fin n) → Fun.Morphism functor Id.functor lookup-functor-morphism i = record { op = flip lookup i ; op-<$> = lookup-map i } -- lookup is an applicative functor morphism. lookup-morphism : (i : Fin n) → Morphism applicative Id.applicative lookup-morphism i = record { op = flip lookup i ; op-pure = lookup-replicate i ; op-⊛ = lookup-⊛ i }
{ "alphanum_fraction": 0.5482300885, "avg_line_length": 27.5609756098, "ext": "agda", "hexsha": "ba5f1669c0e7347a2cc1be9f14cd8202bd2a63ce", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Vec/Categorical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Vec/Categorical.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Vec/Categorical.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": 615, "size": 2260 }
{- This second-order signature was created from the following second-order syntax description: syntax Monad | M type T : 1-ary term ret : α -> T α bind : T α α.(T β) -> T β | _>>=_ r10 theory (LU) a : α b : α.(T β) |> bind (ret(a), x. b[x]) = b[a] (RU) t : T α |> bind (t, x. ret(x)) = t (AS) t : T α b : α.(T β) c : β.(T γ) |> bind (bind (t, x.b[x]), y.c[y]) = bind (t, x. bind (b[x], y.c[y])) -} module Monad.Signature where open import SOAS.Context -- Type declaration data MT : Set where T : MT → MT open import SOAS.Syntax.Signature MT public open import SOAS.Syntax.Build MT public -- Operator symbols data Mₒ : Set where retₒ : {α : MT} → Mₒ bindₒ : {α β : MT} → Mₒ -- Term signature M:Sig : Signature Mₒ M:Sig = sig λ { (retₒ {α}) → (⊢₀ α) ⟼₁ T α ; (bindₒ {α}{β}) → (⊢₀ T α) , (α ⊢₁ T β) ⟼₂ T β } open Signature M:Sig public
{ "alphanum_fraction": 0.5604519774, "avg_line_length": 19.6666666667, "ext": "agda", "hexsha": "bbd3911873bd61cbeccc4a1f6397960581347aaa", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/Monad/Signature.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/Monad/Signature.agda", "max_line_length": 110, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/Monad/Signature.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 358, "size": 885 }
-- Andreas, 2016-12-31, issue #1976 raised by nad -- Check for correct parameters in projection pattern -- {-# OPTIONS -v tc.lhs.split:40 #-} postulate A B : Set module M (_ : Set) where record R : Set₂ where field F : Set₁ open R public open M A wrong : M.R B F wrong = Set -- Expected error: -- A != B of type Set -- when checking that the clause F wrong = Set has type M.R B
{ "alphanum_fraction": 0.6393034826, "avg_line_length": 16.08, "ext": "agda", "hexsha": "1cdb93a454c94804223ccc66ec278e301323c23c", "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/Issue1976.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/Issue1976.agda", "max_line_length": 61, "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/Issue1976.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": 123, "size": 402 }
{-# OPTIONS --allow-unsolved-metas #-} open import Agda.Builtin.Nat data Tick : Nat → Set where tick : ∀ {n} → Tick (suc n) data Tensor : ∀ n → Tick n → Set where ss : ∀ {n} → Tensor (1 + n) tick tensor→a : ∀ {n s} → Tensor n s → Set tensor→a x = {!!}
{ "alphanum_fraction": 0.5692307692, "avg_line_length": 20, "ext": "agda", "hexsha": "9ed2d8ae11943ee7e02d878ec382ef628c6d7962", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue4116.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue4116.agda", "max_line_length": 38, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue4116.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 92, "size": 260 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of sums (disjoint unions) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Sum.Properties where open import Data.Sum open import Function open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality open import Relation.Nullary using (yes; no) module _ {a b} {A : Set a} {B : Set b} where inj₁-injective : ∀ {x y} → (A ⊎ B ∋ inj₁ x) ≡ inj₁ y → x ≡ y inj₁-injective refl = refl inj₂-injective : ∀ {x y} → (A ⊎ B ∋ inj₂ x) ≡ inj₂ y → x ≡ y inj₂-injective refl = refl ≡-dec : Decidable _≡_ → Decidable _≡_ → Decidable {A = A ⊎ B} _≡_ ≡-dec dec₁ dec₂ (inj₁ x) (inj₁ y) with dec₁ x y ... | yes refl = yes refl ... | no x≢y = no (x≢y ∘ inj₁-injective) ≡-dec dec₁ dec₂ (inj₁ x) (inj₂ y) = no λ() ≡-dec dec₁ dec₂ (inj₂ x) (inj₁ y) = no λ() ≡-dec dec₁ dec₂ (inj₂ x) (inj₂ y) with dec₂ x y ... | yes refl = yes refl ... | no x≢y = no (x≢y ∘ inj₂-injective) swap-involutive : swap {A = A} {B} ∘ swap ≗ id swap-involutive = [ (λ _ → refl) , (λ _ → refl) ]
{ "alphanum_fraction": 0.5350949628, "avg_line_length": 32.7297297297, "ext": "agda", "hexsha": "0b1644efecf2ce86c8fda916cdf633ebe87d966f", "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/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/Properties.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 426, "size": 1211 }
------------------------------------------------------------------------ -- The universe used to define breadth-first manipulations of trees ------------------------------------------------------------------------ module BreadthFirst.Universe where open import Codata.Musical.Colist using (Colist; []; _∷_) open import Codata.Musical.Notation open import Data.Product using (_×_; _,_) open import Relation.Binary.PropositionalEquality using (_≡_) open import Stream using (Stream; _≺_) open import Tree using (Tree; node; leaf) infixr 5 _≺_ _∷_ infixr 4 _,_ infixr 2 _⊗_ data U : Set₁ where tree : (a : U) → U stream : (a : U) → U colist : (a : U) → U _⊗_ : (a b : U) → U ⌈_⌉ : (A : Set) → U El : U → Set El (tree a) = Tree.Tree (El a) El (stream a) = Stream (El a) El (colist a) = Colist (El a) El (a ⊗ b) = El a × El b El ⌈ A ⌉ = A -- Equality. data Eq : ∀ a → El a → El a → Set₁ where leaf : ∀ {a} → Eq (tree a) leaf leaf node : ∀ {a x x′ l l′ r r′} (l≈l′ : ∞ (Eq (tree a) (♭ l) (♭ l′))) (x≈x′ : Eq a x x′ ) (r≈r′ : ∞ (Eq (tree a) (♭ r) (♭ r′))) → Eq (tree a) (node l x r) (node l′ x′ r′) _≺_ : ∀ {a x x′ xs xs′} (x≈x′ : Eq a x x′ ) (xs≈xs′ : ∞ (Eq (stream a) (♭ xs) (♭ xs′))) → Eq (stream a) (x ≺ xs) (x′ ≺ xs′) [] : ∀ {a} → Eq (colist a) [] [] _∷_ : ∀ {a x x′ xs xs′} (x≈x′ : Eq a x x′ ) (xs≈xs′ : ∞ (Eq (colist a) (♭ xs) (♭ xs′))) → Eq (colist a) (x ∷ xs) (x′ ∷ xs′) _,_ : ∀ {a b x x′ y y′} (x≈x′ : Eq a x x′) (y≈y′ : Eq b y y′) → Eq (a ⊗ b) (x , y) (x′ , y′) ⌈_⌉ : ∀ {A} {x x′} (x≡x′ : x ≡ x′) → Eq ⌈ A ⌉ x x′ -- PrefixOf a xs ys is inhabited iff xs is a prefix of ys. data PrefixOf (a : U) : Colist (El a) → Stream (El a) → Set₁ where [] : ∀ {ys} → PrefixOf a [] ys _∷_ : ∀ {x y xs ys} (x≈y : Eq a x y) (p : ∞ (PrefixOf a (♭ xs) (♭ ys))) → PrefixOf a (x ∷ xs) (y ≺ ys)
{ "alphanum_fraction": 0.421182266, "avg_line_length": 32.2222222222, "ext": "agda", "hexsha": "fec65922dcbaf31fa07a5bee1797b0058e6a3d52", "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": "BreadthFirst/Universe.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": "BreadthFirst/Universe.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": "BreadthFirst/Universe.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": 841, "size": 2030 }
module StateSizedIO.GUI.VariableList where open import Data.Product hiding (map) open import Data.List open import NativeIO open import StateSizedIO.GUI.WxBindingsFFI data VarList : Set₁ where [] : VarList addVar : (A : Set) → Var A → VarList → VarList addVar' : {A : Set} → Var A → VarList → VarList addVar' {A} = addVar A [_]var : ∀ {A : Set} → Var A → VarList [_]var{A} x = addVar A x [] prod : VarList → Set prod [] = Unit prod (addVar A v []) = A prod (addVar A v l) = A × prod l varListProj₁ : (l : VarList){A : Set}{v : Var A}(p : prod (addVar A v l)) → A varListProj₁ [] {A} {v} a = a varListProj₁ (addVar A₁ x l) {A} {v} (a , rest) = a varListUpdateProj₁ : (l : VarList){A : Set}{v : Var A}(a : A) (p : prod (addVar A v l)) → prod (addVar A v l) varListUpdateProj₁ [] {A} {v} a p = a varListUpdateProj₁ (addVar A₁ x l) {A} {v} a' (a , rest) = ( a' , rest ) takeVar : (l : VarList) → NativeIO (prod l) takeVar [] = nativeReturn _ takeVar (addVar A v []) = nativeTakeVar {A} v native>>= λ a → nativeReturn a takeVar (addVar A v (addVar B v' l)) = nativeTakeVar {A} v native>>= λ a → takeVar (addVar B v' l) native>>= λ rest → nativeReturn ( a , rest ) putVar : (l : VarList) → prod l → NativeIO Unit putVar [] _ = nativeReturn _ putVar (addVar A v []) a = nativePutVar {A} v a putVar (addVar A v (addVar B v' l)) (a , rest) = nativePutVar {A} v a native>>= λ _ → putVar (addVar B v' l) rest native>>= nativeReturn dispatch : (l : VarList) → (prod l → NativeIO (prod l)) → NativeIO Unit dispatch l f = takeVar l native>>= λ a → f a native>>= λ a₁ → putVar l a₁ dispatchList : (l : VarList) → List (prod l → NativeIO (prod l)) → NativeIO Unit dispatchList l [] = nativeReturn _ dispatchList l (p ∷ rest) = dispatch l p native>>= λ _ → dispatchList l rest
{ "alphanum_fraction": 0.5244072524, "avg_line_length": 32.5909090909, "ext": "agda", "hexsha": "9e8e8d108bf33419e024702a5a5f7e780fa81392", "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": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "stephanadls/state-dependent-gui", "max_forks_repo_path": "src/StateSizedIO/GUI/VariableList.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "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": "stephanadls/state-dependent-gui", "max_issues_repo_path": "src/StateSizedIO/GUI/VariableList.agda", "max_line_length": 84, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "stephanadls/state-dependent-gui", "max_stars_repo_path": "src/StateSizedIO/GUI/VariableList.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z", "num_tokens": 681, "size": 2151 }
module Measure where import Data.Nat as ℕ import Data.Nat.Coprimality as Coprimality import Data.Nat.GCD as GCD import Data.Nat.Show as ℕshow import Data.Nat.Divisibility as Divisibility open ℕ using (ℕ; suc; zero) open Coprimality using (Coprime) open Divisibility using (divides) open import Relation.Nullary.Decidable using (True; False; toWitness; fromWitness) open import Data.Product using (_,_; ∃; proj₁; proj₂) open import Data.String as String using (String) open import Relation.Binary.PropositionalEquality as ≡ using (_≡_; _≢_; cong; sym; refl) open import Data.Empty as ⊥ using (⊥) record ℙ : Set where field numerator : ℕ denominator-1 : ℕ .coprime : Coprime numerator (suc denominator-1) denominator : ℕ denominator = suc denominator-1 open ℙ infixl 7 _÷₌_ _÷₌_ : (n : ℕ) → (d : ℕ) → .{coprime : Coprime n d} → .{≢0 : False (d ℕ.≟ 0)} → ∃ (λ p → denominator p ≡ d) numerator (proj₁ (n ÷₌ _)) = n denominator-1 (proj₁ ((_ ÷₌ zero) {≢0 = ()})) denominator-1 (proj₁ (_ ÷₌ suc d)) = d coprime (proj₁ ((_ ÷₌ zero) {≢0 = ()})) coprime (proj₁ ((_ ÷₌ suc d) {coprime})) = coprime proj₂ ((n ÷₌ zero) {≢0 = ()}) proj₂ (n ÷₌ suc d) = refl infixl 7 _÷_ _÷_ : (n d : ℕ) → .{coprime : Coprime n d} → .{≢0 : False (d ℕ.≟ 0)} → ℙ numerator (n ÷ d) = n denominator-1 ((n ÷ zero) {≢0 = ()}) denominator-1 (n ÷ suc d-1) = d-1 coprime ((n ÷ zero) {≢0 = ()}) coprime ((n ÷ suc d-1) {coprime}) = coprime fromNat : ℕ → ℙ numerator (fromNat n) = n denominator-1 (fromNat _) = 0 coprime (fromNat n) = Coprimality.sym (Coprimality.1-coprimeTo n) private 1+≢*0 : ∀ x y → suc x ≢ y ℕ.* 0 1+≢*0 x zero () 1+≢*0 x (suc y) = 1+≢*0 x y infixl 7 _?÷₌_ _?÷₌_ : ∀ x y → .{≢0 : False (y ℕ.≟ 0)} → ∃ (λ p → x ℕ.* denominator p ≡ numerator p ℕ.* y) _?÷₌_ x zero {≢0 = ()} _?÷₌_ x (suc y-1) with GCD.Bézout.lemma x (suc y-1) _?÷₌_ x (suc y-1) | GCD.Bézout.result 0 (GCD.GCD.is (_ , divides y′ y-eq) _) _ = ⊥.⊥-elim (1+≢*0 y-1 y′ y-eq) _?÷₌_ x (suc y-1) | GCD.Bézout.result (suc d-1) (GCD.GCD.is (divides x′ x-eq , divides y′ y-eq) _) bézout = proj₁ frac , eq-prf where open import Data.Nat using (_*_) y = suc y-1 d = suc d-1 bézout′ : GCD.Bézout.Identity d (x′ * d) (y′ * d) bézout′ = ≡.subst₂ (GCD.Bézout.Identity d) x-eq y-eq bézout coprime-prf : Coprime x′ y′ coprime-prf = Coprimality.Bézout-coprime bézout′ open ≡.≡-Reasoning open import Data.Nat.Properties.Simple y′≢0 : False (y′ ℕ.≟ 0) y′≢0 = Relation.Nullary.Decidable.fromWitnessFalse wtns where suc-≢0 : {n : ℕ} → (suc n ≡ 0) → ⊥ suc-≢0 {n} () open import Relation.Nullary using (¬_) wtns : ¬ (y′ ≡ 0) wtns refl = suc-≢0 {y-1} y-eq frac : ∃ (λ p → denominator p ≡ y′) frac = (x′ ÷₌ y′) {coprime = coprime-prf} {≢0 = y′≢0} eq-prf : x * denominator (proj₁ frac) ≡ numerator (proj₁ frac) * suc y-1 eq-prf = begin x * denominator (proj₁ frac) ≡⟨ cong (λ z → x * z) (proj₂ frac) ⟩ x * y′ ≡⟨ cong (λ z → z * y′) x-eq ⟩ x′ * d * y′ ≡⟨ *-assoc x′ d y′ ⟩ x′ * (d * y′) ≡⟨ sym (cong (_*_ x′) (*-comm y′ d)) ⟩ x′ * (y′ * d) ≡⟨ sym (cong (_*_ x′) y-eq) ⟩ x′ * y ∎ infixl 7 _?÷_ _?÷_ : (x y : ℕ) → .{≢0 : False (y ℕ.≟ 0)} → ℙ (x ?÷ zero) {≢0 = ()} x ?÷ suc y-1 with GCD.Bézout.lemma x (suc y-1) (n ?÷ suc y-1) | GCD.Bézout.result 0 (GCD.GCD.is (_ , divides y′ y-eq) _) _ = ⊥.⊥-elim (1+≢*0 y-1 y′ y-eq) (n ?÷ suc y-1) | GCD.Bézout.result (suc d-1) (GCD.GCD.is (divides x′ x-eq , divides y′ y-eq) _) bézout = (x′ ÷ y′) {coprime = coprime-prf} {≢0 = y′≢0} where open import Data.Nat using (_*_) y = suc y-1 d = suc d-1 bézout′ : GCD.Bézout.Identity d (x′ * d) (y′ * d) bézout′ = ≡.subst₂ (GCD.Bézout.Identity d) x-eq y-eq bézout coprime-prf : Coprime x′ y′ coprime-prf = Coprimality.Bézout-coprime bézout′ y′≢0 : False (y′ ℕ.≟ 0) y′≢0 = Relation.Nullary.Decidable.fromWitnessFalse wtns where suc-≢0 : {n : ℕ} → (suc n ≡ 0) → ⊥ suc-≢0 {n} () open import Relation.Nullary using (¬_) wtns : ¬ (y′ ≡ 0) wtns refl = suc-≢0 {y-1} y-eq _+_ : ℙ → ℙ → ℙ x + y = ((numerator x ℕ.* denominator y) ℕ.+ (numerator y ℕ.* denominator x)) ?÷ (denominator x ℕ.* denominator y) _*_ : ℙ → ℙ → ℙ x * y = (numerator x ℕ.* numerator y) ?÷ (denominator x ℕ.* denominator y) show : ℙ → String show p = ℕshow (numerator p) ++ "÷" ++ ℕshow (denominator p) where open String using (_++_) open import Data.Nat.Show renaming (show to ℕshow)
{ "alphanum_fraction": 0.5589899869, "avg_line_length": 32.8142857143, "ext": "agda", "hexsha": "8e11da2db0409cde0ff3d2b3efc5394ce40c6417", "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": "880217ca51ab62f6feee58ccacdb39bfade43101", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/prob-presentation", "max_forks_repo_path": "probability/Measure.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "880217ca51ab62f6feee58ccacdb39bfade43101", "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/prob-presentation", "max_issues_repo_path": "probability/Measure.agda", "max_line_length": 150, "max_stars_count": null, "max_stars_repo_head_hexsha": "880217ca51ab62f6feee58ccacdb39bfade43101", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/prob-presentation", "max_stars_repo_path": "probability/Measure.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2041, "size": 4594 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Sets.EquivalenceRelations open import Setoids.Setoids module Setoids.Product {m n o p : _} {A : Set m} {B : Set n} (R : Setoid {m} {o} A) (S : Setoid {n} {p} B) where open Setoid productSetoid : Setoid (A && B) _∼_ (productSetoid) (a ,, b) (c ,, d) = (Setoid._∼_ R a c) && (Setoid._∼_ S b d) Equivalence.reflexive (eq (productSetoid)) {(a ,, b)} = Equivalence.reflexive (Setoid.eq R) ,, Equivalence.reflexive (Setoid.eq S) Equivalence.symmetric (eq (productSetoid)) {(a ,, b)} {(c ,, d)} (fst ,, snd) = Equivalence.symmetric (Setoid.eq R) fst ,, Equivalence.symmetric (Setoid.eq S) snd Equivalence.transitive (eq (productSetoid)) {a ,, b} {c ,, d} {e ,, f} (fst1 ,, snd1) (fst2 ,, snd2) = Equivalence.transitive (Setoid.eq R) fst1 fst2 ,, Equivalence.transitive (Setoid.eq S) snd1 snd2 productLift : {r s : A} {t u : B} → (Setoid._∼_ R r s) → (Setoid._∼_ S t u) → Setoid._∼_ productSetoid (r ,, t) (s ,, u) _&&_.fst (productLift r=s t=u) = r=s _&&_.snd (productLift r=s t=u) = t=u
{ "alphanum_fraction": 0.6425255339, "avg_line_length": 53.85, "ext": "agda", "hexsha": "09a9e50f324e54848e837605534f2aa7e86ddd5a", "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": "Setoids/Product.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": "Setoids/Product.agda", "max_line_length": 199, "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": "Setoids/Product.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": 397, "size": 1077 }
module Issue4435-1 where record ⊤ : Set where -- Declarations. data Foo (a : Set) : Set Bar : {a : Set} → Foo a → Set -- Definitions. data Foo a : Set where c1 : Foo a c2 : (x : Foo a) (y : Bar x → Foo a) → Foo a Bar c1 = ⊤ Bar (c2 a b) = (x : Bar a) → Bar (b x)
{ "alphanum_fraction": 0.5535055351, "avg_line_length": 16.9375, "ext": "agda", "hexsha": "676368c2464e3644e32697d6e2a00b5cbbf49968", "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/Issue4435-1.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/Issue4435-1.agda", "max_line_length": 46, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue4435-1.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 108, "size": 271 }
{-# OPTIONS --cubical --safe #-} module Equality where open import Cubical.Core.Everything using (_≡_; Level; Type; Σ; _,_; fst; snd; _≃_; ~_) open import Cubical.Foundations.Prelude using (refl; sym; cong; transport; subst; funExt; transp; I; i0; i1) open import Cubical.Foundations.Function using (_∘_) open import Cubical.Foundations.Univalence using (ua) open import Cubical.Foundations.Isomorphism using (iso; Iso; isoToPath; section; retract) open import Data.Bool.Base using (Bool; true; false; _∧_) open import Data.Nat.Base using (ℕ; zero; suc; _+_) open import Data.Fin using (Fin; toℕ; fromℕ; #_; opposite) renaming (zero to fz; suc to fs) open import Data.Product using (_×_; proj₁; proj₂) -- mutual recursion data Γ : ℕ → Type data U : {n : ℕ} → Γ n → Type -- context (snoc list of dependent types) data Γ where ε : Γ 0 _∙_ : {n : ℕ} → (γ : Γ n) → U γ → Γ (suc n) tail : {n : ℕ} → Γ (suc n) → Γ n tail (γ ∙ _) = γ drop : {n : ℕ} → (k : ℕ) → Γ (k + n) → Γ n drop zero γ = γ drop (suc k) (γ ∙ x) = drop k γ head : {n : ℕ} → (γ : Γ (suc n)) → U (tail γ) head (_ ∙ A) = A -- lookup a type in a context at position k lookup : {n : ℕ} → (k : ℕ) → (γ : Γ (k + suc n)) → U (tail (drop k γ)) lookup k γ = head (drop k γ) -- type universe data U where nat : {n : ℕ} → {γ : Γ n} → U γ pi : {n : ℕ} → {γ : Γ n} → (A : U γ) → U (γ ∙ A) → U γ data Term : {n : ℕ} → (γ : Γ n) → U γ → Type where -- v : {n : ℕ} → (k : ℕ) → {γ : Γ (k + suc n)} → {A : U (tail (drop k γ))} → Term (tail (drop k γ)) A v : {n : ℕ} → (k : ℕ) → {γ : Γ (k + suc n)} → {A : U (tail (drop k γ))} → Term (tail (drop k γ)) A tz : {n : ℕ} → {γ : Γ n} → Term γ nat -- zero ts : {n : ℕ} → {γ : Γ n} → Term γ nat → Term γ nat -- suc -- tn : (P : Term nat → U) → Term (P tz) → ((n : Term nat) → Term (P n) → Term (P (ts n))) → (n : Term nat) → Term (P n) -- natrec tλ : {n : ℕ} → {γ : Γ n} → {A : U γ} → {B : U (γ ∙ A)} → Term (γ ∙ A) B → Term γ (pi A B) ta : {n : ℕ} → {γ : Γ n} → {A : U γ} → {B : U (γ ∙ A)} → Term γ (pi A B) → Term γ A → Term (γ ∙ A) B --+1 : Term ε (pi nat nat) --+1 = tλ {!!} --(v {n = 0} 0) data Eq : Type where eq : Eq -- equal ne : Eq -- not equal data Maybe (a : Type) : Type where nothing : Maybe a just : a → Maybe a ℕeq : ℕ → ℕ → Eq ℕeq zero zero = eq ℕeq zero (suc n) = ne ℕeq (suc m) zero = ne ℕeq (suc m) (suc n) = ℕeq m n natrec : (P : ℕ → Type) → P 0 → ((n : ℕ) → P n → P (suc n)) → (n : ℕ) → P n natrec P z s zero = z natrec P z s (suc n) = s n (natrec P z s n) _+'_ : ℕ → ℕ → ℕ _+'_ = λ m → λ n → natrec (λ _ → ℕ) n (λ _ → suc) m 0=0 : 0 ≡ 0 0=0 = refl suc=suc : (m n : ℕ) → m ≡ n → suc m ≡ suc n suc=suc m n e = cong suc e 0+n=n : (n : ℕ) → 0 + n ≡ n 0+n=n = natrec (λ k → 0 + k ≡ k) 0=0 (λ n e → suc=suc n n e) n=0+n : (n : ℕ) → n + 0 ≡ n n=0+n = natrec (λ k → k + 0 ≡ k) 0=0 λ n e → suc=suc (n + 0) n e
{ "alphanum_fraction": 0.5028960818, "avg_line_length": 32.2527472527, "ext": "agda", "hexsha": "ba470138ab8f5da7b668fb29a263293fcb52cc0f", "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": "5b22f5cb073dc2508ad158959a096df7763c57c4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "halfaya/Alae", "max_forks_repo_path": "agda/Equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5b22f5cb073dc2508ad158959a096df7763c57c4", "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": "halfaya/Alae", "max_issues_repo_path": "agda/Equality.agda", "max_line_length": 131, "max_stars_count": null, "max_stars_repo_head_hexsha": "5b22f5cb073dc2508ad158959a096df7763c57c4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "halfaya/Alae", "max_stars_repo_path": "agda/Equality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1260, "size": 2935 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Setoids.Setoids open import Functions open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Numbers.Naturals.Naturals open import Sets.FinSet open import Groups.Definition open import Groups.Lemmas open import Groups.Groups open import Groups.Actions.Definition open import Groups.Actions.Stabiliser open import Groups.Groups2 open import Sets.EquivalenceRelations module Groups.Actions.OrbitStabiliser where orbitStabiliserEquivRel1 : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → Rel A orbitStabiliserEquivRel1 {T = T} action x g1 g2 = Setoid._∼_ T (GroupAction.action action g1 x) (GroupAction.action action g2 x) orbitStabiliserEquivRel2 : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → Rel A orbitStabiliserEquivRel2 {T = T} {_+_ = _+_} {G = G} action x g1 g2 = Setoid._∼_ T (GroupAction.action action ((Group.inverse G g2) + g1) x) x osEquivRel1Equiv : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → Equivalence (orbitStabiliserEquivRel1 action x) Equivalence.reflexive (osEquivRel1Equiv {T = T} action x) {a} = Equivalence.reflexive (Setoid.eq T) Equivalence.symmetric (osEquivRel1Equiv {T = T} action x) {a} {b} = Equivalence.symmetric (Setoid.eq T) Equivalence.transitive (osEquivRel1Equiv {T = T} action x) {a} {b} {c} = Equivalence.transitive (Setoid.eq T) osEquivRel2Equiv : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → Equivalence (orbitStabiliserEquivRel2 action x) Equivalence.reflexive (osEquivRel2Equiv {T = T} {G = G} action x) = transitive (GroupAction.actionWellDefined1 action (Group.invLeft G)) (GroupAction.identityAction action) where open Equivalence (Setoid.eq T) Equivalence.symmetric (osEquivRel2Equiv {S = S} {T = T} {_+_ = _+_} {G = G} gAction x) {b} {c} b=c = need where open Equivalence (Setoid.eq T) open Equivalence (Setoid.eq S) renaming (symmetric to symmetricS ; transitive to transitiveS ; reflexive to reflexiveS) open Setoid T open GroupAction gAction open Group G have : action ((inverse c) + b) x ∼ x have = b=c p : action (inverse (inverse b + c)) x ∼ x p = transitive (actionWellDefined1 (transitiveS (invContravariant G) (Group.+WellDefined G reflexiveS (invInv G)))) have q : action ((inverse b) + c) (action (inverse (inverse b + c)) x) ∼ action ((inverse b) + c) x q = actionWellDefined2 p r : action (((inverse b) + c) + (inverse (inverse b + c))) x ∼ action ((inverse b) + c) x r = transitive associativeAction q s : action identity x ∼ action ((inverse b) + c) x s = transitive (actionWellDefined1 (symmetricS invRight)) r need : action ((inverse b) + c) x ∼ x need = symmetric (transitive (symmetric identityAction) s) Equivalence.transitive (osEquivRel2Equiv {S = S} {T = T} {_+_ = _+_} {G = G} gAction x) {a} {b} {c} a=b b=c = need where open Equivalence (Setoid.eq T) open Equivalence (Setoid.eq S) renaming (symmetric to symmetricS ; reflexive to reflexiveS ; transitive to transitiveS) open Setoid T open GroupAction gAction open Group G have1 : action ((inverse c) + b) x ∼ x have1 = b=c have2 : action ((inverse b) + a) x ∼ x have2 = a=b p : action ((inverse c) + b) (action (inverse b + a) x) ∼ x p = transitive (actionWellDefined2 have2) have1 q : action ((inverse c + b) + (inverse b + a)) x ∼ x q = transitive associativeAction p need : action ((inverse c) + a) x ∼ x need = transitive (actionWellDefined1 (transitiveS (+WellDefined reflexiveS (transitiveS (symmetricS identLeft) (+WellDefined (symmetricS invRight) reflexiveS))) (fourWayAssoc G))) q osEquivRelsEqual' : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) {g h : A} → (orbitStabiliserEquivRel2 action x) g h → (orbitStabiliserEquivRel1 action x) g h osEquivRelsEqual' {S = S} {T = T} {_+_ = _+_} {G = G} action x {g} {h} g=h = need where open Setoid T open Group G open Equivalence eq open Equivalence (Setoid.eq S) renaming (symmetric to symmetricS ; transitive to transitiveS) have : (GroupAction.action action ((inverse h) + g) x) ∼ x have = g=h p : (GroupAction.action action (inverse h) (GroupAction.action action g x)) ∼ x p = transitive (symmetric (GroupAction.associativeAction action)) have q : (GroupAction.action action h (GroupAction.action action (inverse h) (GroupAction.action action g x))) ∼ GroupAction.action action h x q = GroupAction.actionWellDefined2 action p r : (GroupAction.action action (h + inverse h) (GroupAction.action action g x)) ∼ GroupAction.action action h x r = transitive (GroupAction.associativeAction action) q s : (GroupAction.action action identity (GroupAction.action action g x)) ∼ GroupAction.action action h x s = transitive (GroupAction.actionWellDefined1 action (symmetricS (Group.invRight G))) r need : (GroupAction.action action g x) ∼ (GroupAction.action action h x) need = transitive (symmetric (GroupAction.identityAction action)) s osEquivRelsEqual : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) {g h : A} → (orbitStabiliserEquivRel1 action x) g h → (orbitStabiliserEquivRel2 action x) g h osEquivRelsEqual {T = T} {_+_ = _+_} {G = G} action x {g} {h} g=h = need where open Setoid T open Group G open Equivalence eq have : (GroupAction.action action g x) ∼ (GroupAction.action action h x) have = g=h p : GroupAction.action action (inverse h) (GroupAction.action action g x) ∼ GroupAction.action action (inverse h) (GroupAction.action action h x) p = GroupAction.actionWellDefined2 action have need : (GroupAction.action action ((inverse h) + g) x) ∼ x need = transitive (GroupAction.associativeAction action) (transitive p (transitive (symmetric (GroupAction.associativeAction action)) (transitive (GroupAction.actionWellDefined1 action (Group.invLeft G)) (GroupAction.identityAction action)))) orbitStabiliserBijection : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → A → ((Stabiliser action x) && Orbit action x) orbitStabiliserBijection action x g = stab {!GroupAction.action action ? ?!} {!!} ,, orbitElt g where osBijWellDefined : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → {r s : A} → (Setoid._∼_ S r s) → Setoid._∼_ (directSumSetoid (stabiliserSetoid action x) (orbitSetoid action x)) (orbitStabiliserBijection action x r) (orbitStabiliserBijection action x s) _&&_.fst (osBijWellDefined action x r~s) = {!!} _&&_.snd (osBijWellDefined action x r~s) = GroupAction.actionWellDefined1 action r~s orbitStabiliserTheorem : {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (action : GroupAction G T) (x : B) → SetoidBijection S (directSumSetoid (stabiliserSetoid action x) (orbitSetoid action x)) (orbitStabiliserBijection action x) SetoidInjection.+WellDefined (SetoidBijection.inj (orbitStabiliserTheorem {S = S} action x)) = osBijWellDefined action x SetoidInjection.injective (SetoidBijection.inj (orbitStabiliserTheorem {S = S} action x)) {g} {h} (fst ,, gx=hx) = {!!} SetoidSurjection.+WellDefined (SetoidBijection.surj (orbitStabiliserTheorem action x)) = osBijWellDefined action x SetoidSurjection.surjective (SetoidBijection.surj (orbitStabiliserTheorem action x)) {stab g gx=x ,, orbitElt h} = h , ({!!} ,, {!!})
{ "alphanum_fraction": 0.6710430343, "avg_line_length": 70.3076923077, "ext": "agda", "hexsha": "a13d289d0f5e798882535afc7d1ee0079ba26988", "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": "Groups/Actions/OrbitStabiliser.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": "Groups/Actions/OrbitStabiliser.agda", "max_line_length": 364, "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": "Groups/Actions/OrbitStabiliser.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": 2828, "size": 8226 }
open import Data.Nat using ( ℕ ; fold ) renaming ( zero to zero' ; suc to suc' ) open import Data.String using ( String ) module Data.Natural.Primitive where infixl 6 _+_ postulate Natural : Set zero : Natural suc : Natural → Natural _+_ : Natural → Natural → Natural show : Natural → String foldl : {A : Set} → (A → A) → A → Natural → A foldl' : {A : Set} → (A → A) → A → Natural → A foldr : {A : Set} → (A → A) → A → Natural → A {-# IMPORT Data.Natural.AgdaFFI #-} {-# COMPILED_TYPE Natural Data.Natural.AgdaFFI.Natural #-} {-# COMPILED zero 0 #-} {-# COMPILED suc succ #-} {-# COMPILED _+_ (+) #-} {-# COMPILED show show #-} {-# COMPILED foldl (\ _ -> Data.Natural.AgdaFFI.nfoldl) #-} {-# COMPILED foldl' (\ _ -> Data.Natural.AgdaFFI.nfoldl') #-} {-# COMPILED foldr (\ _ -> Data.Natural.AgdaFFI.nfoldr) #-} private postulate # : ∀ {l} {A : Set l} → A → Natural {-# COMPILED # (\ _ -> Data.Natural.AgdaFFI.convert MAlonzo.Data.Nat.mazNatToInteger) #-} fromℕ : ℕ → Natural fromℕ = #
{ "alphanum_fraction": 0.6110562685, "avg_line_length": 29.7941176471, "ext": "agda", "hexsha": "65028b7712904956c1823777e272c2a161baf0c5", "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": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/Data/Natural/Primitive.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/Data/Natural/Primitive.agda", "max_line_length": 89, "max_stars_count": null, "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/Data/Natural/Primitive.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 339, "size": 1013 }
------------------------------------------------------------------------ -- Unary relations (variant for Set₁) ------------------------------------------------------------------------ -- I want universe polymorphism. module Relation.Unary1 where ------------------------------------------------------------------------ -- Unary relations Pred : Set → Set₂ Pred a = a → Set₁ ------------------------------------------------------------------------ -- Unary relations can be seen as sets -- I.e., they can be seen as subsets of the universe of discourse. private module Dummy {a : Set} -- The universe of discourse. where -- Set membership. infix 4 _∈_ _∈_ : a → Pred a → Set₁ x ∈ P = P x -- The property of being universal. Universal : Pred a → Set₁ Universal P = ∀ x → x ∈ P -- P ⊆ Q means that P is a subset of Q. _⊆′_ is a variant of _⊆_. infix 4 _⊆_ _⊇_ _⊆′_ _⊇′_ _⊆_ : Pred a → Pred a → Set₁ P ⊆ Q = ∀ {x} → x ∈ P → x ∈ Q _⊆′_ : Pred a → Pred a → Set₁ P ⊆′ Q = ∀ x → x ∈ P → x ∈ Q _⊇_ : Pred a → Pred a → Set₁ Q ⊇ P = P ⊆ Q _⊇′_ : Pred a → Pred a → Set₁ Q ⊇′ P = P ⊆′ Q open Dummy public
{ "alphanum_fraction": 0.4230103806, "avg_line_length": 21.8113207547, "ext": "agda", "hexsha": "3339ecaf5eceb27d2fa77267e4ba9896b7784d86", "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/Relation/Unary1.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/Relation/Unary1.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/Relation/Unary1.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": 347, "size": 1156 }
-- Andreas, 2012-02-25 reported by edgmnt on behalf of xplat. module Issue574 where open import Common.Level wah : ∀ o a → Set (lsuc lzero ⊔ (lsuc a ⊔ o)) → Set ((lsuc lzero ⊔ lsuc a) ⊔ o) wah o a x = x -- should succeed -- Error message was: -- Set (suc zero ⊔ (suc a ⊔ o)) != Set (suc a ⊔ o) -- when checking that the expression x has type Set (suc a ⊔ o)
{ "alphanum_fraction": 0.6388888889, "avg_line_length": 32.7272727273, "ext": "agda", "hexsha": "e20a0a14fd8dbb20b0eb52470b170ae2c8e47bbb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue574.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/Issue574.agda", "max_line_length": 79, "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/Issue574.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": 360 }
module Data.Either.Setoid where import Lvl open import Data.Either as Either open import Data.Either.Equiv open import Logic open import Logic.Propositional open import Structure.Function.Domain open import Structure.Function open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Structure.Setoid open import Type private variable ℓ ℓₑ ℓₑ₁ ℓₑ₂ : Lvl.Level private variable A B : Type{ℓ} module _ ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ where data EitherEquality : (A ‖ B) → (A ‖ B) → Stmt{Lvl.of(A) Lvl.⊔ Lvl.of(B) Lvl.⊔ ℓₑ₁ Lvl.⊔ ℓₑ₂} where Left : ∀{x y} → (x ≡ y) → EitherEquality(Left x)(Left y) Right : ∀{x y} → (x ≡ y) → EitherEquality(Right x)(Right y) EitherEquality-elim : ∀{ℓ}{P : ∀{ab₁ ab₂ : (A ‖ B)} → EitherEquality ab₁ ab₂ → Type{ℓ}} → (∀{x y : A} → (xy : (x ≡ y)) → P(Left xy)) → (∀{x y : B} → (xy : (x ≡ y)) → P(Right xy)) → ∀{ab₁ ab₂ : (A ‖ B)} → (eq : EitherEquality ab₁ ab₂) → P(eq) EitherEquality-elim l r (Left p) = l p EitherEquality-elim l r (Right p) = r p EitherEquality-not-Left-Right : ∀{a : A}{b : B} → ¬(EitherEquality (Left a) (Right b)) EitherEquality-not-Left-Right () instance Either-equiv : Equiv(A ‖ B) Equiv._≡_ Either-equiv = EitherEquality Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence Either-equiv)) {Left _} = Left (reflexivity(_≡_)) Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence Either-equiv)) {Right _} = Right (reflexivity(_≡_)) Symmetry.proof (Equivalence.symmetry (Equiv.equivalence Either-equiv)) {.(Left _)} {.(Left _)} (Left p) = Left (symmetry(_≡_) p) Symmetry.proof (Equivalence.symmetry (Equiv.equivalence Either-equiv)) {.(Right _)} {.(Right _)} (Right p) = Right (symmetry(_≡_) p) Transitivity.proof (Equivalence.transitivity (Equiv.equivalence Either-equiv)) {.(Left _)} {.(Left _)} {.(Left _)} (Left xy) (Left yz) = Left (transitivity(_≡_) xy yz) Transitivity.proof (Equivalence.transitivity (Equiv.equivalence Either-equiv)) {.(Right _)} {.(Right _)} {.(Right _)} (Right xy) (Right yz) = Right (transitivity(_≡_) xy yz) instance Left-function : Function ⦃ equiv-A ⦄ ⦃ Either-equiv ⦄ (Left) Function.congruence Left-function = Left instance Right-function : Function ⦃ equiv-B ⦄ ⦃ Either-equiv ⦄ (Right) Function.congruence Right-function = Right instance Left-injectivity : Injective(Left {A = A}{B = B}) Injective.proof Left-injectivity (Left p) = p instance Right-injectivity : Injective(Right {A = A}{B = B}) Injective.proof Right-injectivity (Right p) = p instance EitherEquality-extensionality : Extensionality(Either-equiv) Extensionality.Left-Right-inequality EitherEquality-extensionality ()
{ "alphanum_fraction": 0.6775009029, "avg_line_length": 46.9322033898, "ext": "agda", "hexsha": "ce87bd068dc3e71a092df6421690f4fe1a240d74", "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/Either/Setoid.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/Either/Setoid.agda", "max_line_length": 243, "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/Either/Setoid.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": 932, "size": 2769 }
------------------------------------------------------------------------ -- Functional semantics for a non-deterministic untyped λ-calculus -- with constants ------------------------------------------------------------------------ module Lambda.Closure.Functional.Non-deterministic where open import Category.Monad.Partiality as Pa using (_⊥; now; later) open import Codata.Musical.Notation open import Data.Fin using (Fin; zero; suc; #_) open import Data.List hiding (lookup) open import Data.Maybe hiding (_>>=_) open import Data.Nat open import Data.Vec using ([]; _∷_; lookup) open import Function open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Relation.Nullary open import Relation.Nullary.Decidable open import Lambda.Syntax using (Ty; Ctxt) open Lambda.Syntax.Closure using (con; ƛ) open Lambda.Syntax.Ty open import Lambda.VirtualMachine hiding (comp; comp-val; comp-env; lookup-hom) open Functional private module VM = Lambda.Syntax.Closure Code ------------------------------------------------------------------------ -- A monad with partiality, failure and non-determinism module D where -- This is basically the maybe monad transformer applied to the -- partiality monad transformer applied to the non-determinism monad -- N A = μX. A ⊎ X × X. Unfortunately it is somewhat awkward to -- implement the partiality monad transformer in Agda: the -- definition -- -- data Partiality′ (M : Set → Set) (A : Set) : Set where -- now-or-later : M (A ⊎ Partiality′ M A) → Partiality′ M A -- -- is rejected, because M might use its argument negatively. infixr 6 _∣_ data D (A : Set) : Set where fail : D A return : (x : A) → D A _∣_ : (x y : D A) → D A later : (x : ∞ (D A)) → D A -- The function force n removes (up to) n layers of later -- constructors. force : {A : Set} → ℕ → D A → D A force (suc n) (later x) = force n (♭ x) force n (x₁ ∣ x₂) = force n x₁ ∣ force n x₂ force _ x = x -- Bind. infixl 5 _>>=_ _>>=_ : {A B : Set} → D A → (A → D B) → D B fail >>= f = fail return x >>= f = f x (x₁ ∣ x₂) >>= f = (x₁ >>= f) ∣ (x₂ >>= f) later x >>= f = later (♯ (♭ x >>= f)) -- A deterministic non-terminating computation. never : {A : Set} → D A never = later (♯ never) -- Strong bisimilarity. infix 4 _≅_ data _≅_ {A : Set} : D A → D A → Set where fail : fail ≅ fail return : ∀ {x} → return x ≅ return x _∣_ : ∀ {x₁ x₂ y₁ y₂} (x₁≅y₁ : x₁ ≅ y₁) (x₂≅y₂ : x₂ ≅ y₂) → x₁ ∣ x₂ ≅ y₁ ∣ y₂ later : ∀ {x y} (x≅y : ∞ (♭ x ≅ ♭ y)) → later x ≅ later y -- Strong bisimilarity is reflexive. infixr 3 _∎ _∎ : {A : Set} (x : D A) → x ≅ x fail ∎ = fail return x ∎ = return x₁ ∣ x₂ ∎ = (x₁ ∎) ∣ (x₂ ∎) later x ∎ = later (♯ (♭ x ∎)) -- Strong bisimilarity is symmetric. sym : {A : Set} {x y : D A} → x ≅ y → y ≅ x sym fail = fail sym return = return sym (x₁≅y₁ ∣ x₂≅y₂) = sym x₁≅y₁ ∣ sym x₂≅y₂ sym (later x≅y) = later (♯ sym (♭ x≅y)) -- Strong bisimilarity is transitive. infixr 2 _≅⟨_⟩_ _≅⟨_⟩_ : ∀ {A : Set} (x : D A) {y z} → x ≅ y → y ≅ z → x ≅ z ._ ≅⟨ fail ⟩ fail = fail ._ ≅⟨ return ⟩ return = return ._ ≅⟨ x₁≅y₁ ∣ x₂≅y₂ ⟩ y₁≅z₁ ∣ y₂≅z₂ = (_ ≅⟨ x₁≅y₁ ⟩ y₁≅z₁) ∣ (_ ≅⟨ x₂≅y₂ ⟩ y₂≅z₂) ._ ≅⟨ later x≅y ⟩ later y≅z = later (♯ (_ ≅⟨ ♭ x≅y ⟩ ♭ y≅z)) -- The monad laws hold up to strong bisimilarity. left-identity : {A B : Set} {x : A} {f : A → D B} → return x >>= f ≅ f x left-identity {x = x} {f} = f x ∎ right-identity : {A : Set} (x : D A) → x >>= return ≅ x right-identity fail = fail right-identity (return x) = return right-identity (x₁ ∣ x₂) = right-identity x₁ ∣ right-identity x₂ right-identity (later x) = later (♯ right-identity (♭ x)) associative : {A B C : Set} (x : D A) {f : A → D B} {g : B → D C} → x >>= f >>= g ≅ x >>= λ y → f y >>= g associative fail = fail associative (return x) {f} {g} = f x >>= g ∎ associative (x₁ ∣ x₂) = associative x₁ ∣ associative x₂ associative (later x) = later (♯ associative (♭ x)) -- Bind respects strong bisimilarity. infixl 5 _>>=-cong_ _>>=-cong_ : {A B : Set} {x₁ x₂ : D A} {f₁ f₂ : A → D B} → x₁ ≅ x₂ → (∀ y → f₁ y ≅ f₂ y) → x₁ >>= f₁ ≅ x₂ >>= f₂ fail >>=-cong f₁≅f₂ = fail return >>=-cong f₁≅f₂ = f₁≅f₂ _ later x≅y >>=-cong f₁≅f₂ = later (♯ (♭ x≅y >>=-cong f₁≅f₂)) x₁≅x₂ ∣ y₁≅y₂ >>=-cong f₁≅f₂ = (x₁≅x₂ >>=-cong f₁≅f₂) ∣ (y₁≅y₂ >>=-cong f₁≅f₂) -- More laws. never-left-zero : {A B : Set} {f : A → D B} → never >>= f ≅ never never-left-zero = later (♯ never-left-zero) fail-left-zero : {A B : Set} {f : A → D B} → fail >>= f ≅ fail fail-left-zero = fail ∎ open D using (D; _≅_; _≅⟨_⟩_; _∎; _>>=-cong_) hiding (module D) open D.D open D._≅_ ------------------------------------------------------------------------ -- Syntax infixl 9 _·_ infixr 6 _∣_ data Tm (n : ℕ) : Set where con : (i : ℕ) → Tm n var : (x : Fin n) → Tm n ƛ : (t : Tm (suc n)) → Tm n _·_ : (t₁ t₂ : Tm n) → Tm n _∣_ : (t₁ t₂ : Tm n) → Tm n -- Convenient helper. vr : ∀ m {n} {m<n : True (suc m ≤? n)} → Tm n vr _ {m<n = m<n} = var (#_ _ {m<n = m<n}) open Lambda.Syntax.Closure Tm hiding (con; ƛ) ------------------------------------------------------------------------ -- A workaround for the limitations of guardedness module Workaround where infixr 6 _∣_ infixl 5 _>>=_ data DP : Set → Set₁ where fail : ∀ {A} → DP A return : ∀ {A} (x : A) → DP A _∣_ : ∀ {A} (x y : DP A) → DP A later : ∀ {A} (x : ∞ (DP A)) → DP A _>>=_ : ∀ {A B} (x : DP A) (f : A → DP B) → DP B private data DW : Set → Set₁ where fail : ∀ {A} → DW A return : ∀ {A} (x : A) → DW A _∣_ : ∀ {A} (x y : DW A) → DW A later : ∀ {A} (x : DP A) → DW A mutual _>>=W_ : ∀ {A B} → DW A → (A → DP B) → DW B fail >>=W f = fail return x >>=W f = whnf (f x) (x ∣ y) >>=W f = (x >>=W f) ∣ (y >>=W f) later x >>=W f = later (x >>= f) whnf : ∀ {A} → DP A → DW A whnf fail = fail whnf (return x) = return x whnf (later x) = later (♭ x) whnf (x ∣ y) = whnf x ∣ whnf y whnf (x >>= f) = whnf x >>=W f mutual private ⟪_⟫W : ∀ {A} → DW A → D A ⟪ fail ⟫W = fail ⟪ return x ⟫W = return x ⟪ x ∣ y ⟫W = ⟪ x ⟫W ∣ ⟪ y ⟫W ⟪ later x ⟫W = later (♯ ⟪ x ⟫P) ⟪_⟫P : ∀ {A} → DP A → D A ⟪ p ⟫P = ⟪ whnf p ⟫W -- The definitions above make sense. ⟪_⟫P is homomorphic with respect -- to fail, return, _∣_, later and _>>=_. fail-hom : ∀ {A} → ⟪ fail {A = A} ⟫P ≅ fail fail-hom = fail ∎ return-hom : ∀ {A} (x : A) → ⟪ return x ⟫P ≅ return x return-hom x = return x ∎ ∣-hom : ∀ {A} (x y : DP A) → ⟪ x ∣ y ⟫P ≅ ⟪ x ⟫P ∣ ⟪ y ⟫P ∣-hom x y = ⟪ x ⟫P ∣ ⟪ y ⟫P ∎ later-hom : ∀ {A} (x : ∞ (DP A)) → ⟪ later x ⟫P ≅ later (♯ ⟪ ♭ x ⟫P) later-hom x = later (♯ (⟪ ♭ x ⟫P ∎)) mutual private >>=-homW : ∀ {A B} (x : DW A) (f : A → DP B) → ⟪ x >>=W f ⟫W ≅ D._>>=_ ⟪ x ⟫W (λ y → ⟪ f y ⟫P) >>=-homW fail f = fail ∎ >>=-homW (return x) f = ⟪ f x ⟫P ∎ >>=-homW (x ∣ y) f = >>=-homW x f ∣ >>=-homW y f >>=-homW (later x) f = later (♯ >>=-hom x f) >>=-hom : ∀ {A B} (x : DP A) (f : A → DP B) → ⟪ x >>= f ⟫P ≅ D._>>=_ ⟪ x ⟫P (λ y → ⟪ f y ⟫P) >>=-hom x f = >>=-homW (whnf x) f open Workaround hiding (_>>=_) ------------------------------------------------------------------------ -- Semantics infix 9 _∙_ mutual ⟦_⟧′ : ∀ {n} → Tm n → Env n → DP Value ⟦ con i ⟧′ ρ = return (con i) ⟦ var x ⟧′ ρ = return (lookup ρ x) ⟦ ƛ t ⟧′ ρ = return (ƛ t ρ) ⟦ t₁ · t₂ ⟧′ ρ = ⟦ t₁ ⟧′ ρ >>= λ v₁ → ⟦ t₂ ⟧′ ρ >>= λ v₂ → v₁ ∙ v₂ where open Workaround ⟦ t₁ ∣ t₂ ⟧′ ρ = ⟦ t₁ ⟧′ ρ ∣ ⟦ t₂ ⟧′ ρ _∙_ : Value → Value → DP Value con i ∙ v₂ = fail ƛ t₁ ρ ∙ v₂ = later (♯ (⟦ t₁ ⟧′ (v₂ ∷ ρ))) ⟦_⟧ : ∀ {n} → Tm n → Env n → D Value ⟦ t ⟧ ρ = ⟪ ⟦ t ⟧′ ρ ⟫P -- An abbreviation. infix 9 _⟦·⟧_ _⟦·⟧_ : D Value → D Value → D Value v₁ ⟦·⟧ v₂ = v₁ >>= λ v₁ → v₂ >>= λ v₂ → ⟪ v₁ ∙ v₂ ⟫P where open D -- The semantics of application is compositional (with respect to the -- syntactic equality which is used). ·-comp : ∀ {n} (t₁ t₂ : Tm n) {ρ} → ⟦ t₁ · t₂ ⟧ ρ ≅ ⟦ t₁ ⟧ ρ ⟦·⟧ ⟦ t₂ ⟧ ρ ·-comp t₁ t₂ {ρ} = ⟦ t₁ · t₂ ⟧ ρ ≅⟨ >>=-hom (⟦ t₁ ⟧′ ρ) _ ⟩ D._>>=_ (⟦ t₁ ⟧ ρ) (λ v₁ → ⟪ Workaround._>>=_ (⟦ t₂ ⟧′ ρ) (λ v₂ → v₁ ∙ v₂) ⟫P) ≅⟨ ((⟦ t₁ ⟧ ρ ∎) >>=-cong λ _ → >>=-hom (⟦ t₂ ⟧′ ρ) _) ⟩ ⟦ t₁ ⟧ ρ ⟦·⟧ ⟦ t₂ ⟧ ρ ∎ open D ------------------------------------------------------------------------ -- Compiler -- The compiler takes a code continuation. -- -- Non-determinism is resolved by always picking the left choice. comp : ∀ {n} → Tm n → Code n → Code n comp (con i) c = con i ∷ c comp (var x) c = var x ∷ c comp (ƛ t) c = clo (comp t [ ret ]) ∷ c comp (t₁ · t₂) c = comp t₁ (comp t₂ (app ∷ c)) comp (t₁ ∣ t₂) c = comp t₁ c -- Environments and values can also be compiled. mutual comp-env : ∀ {n} → Env n → VM.Env n comp-env [] = [] comp-env (v ∷ ρ) = comp-val v ∷ comp-env ρ comp-val : Value → VM.Value comp-val (con i) = con i comp-val (ƛ t ρ) = ƛ (comp t [ ret ]) (comp-env ρ) -- lookup x is homomorphic with respect to comp-env/comp-val. lookup-hom : ∀ {n} (x : Fin n) ρ → lookup (comp-env ρ) x ≡ comp-val (lookup ρ x) lookup-hom zero (v ∷ ρ) = P.refl lookup-hom (suc x) (v ∷ ρ) = lookup-hom x ρ ------------------------------------------------------------------------ -- Examples -- A non-terminating term. Ω : Tm 0 Ω = ω · ω where ω = ƛ (vr 0 · vr 0) Ω-loops : ⟦ Ω ⟧ [] ≅ never Ω-loops = later (♯ Ω-loops) -- A call-by-value fix-point combinator. Z : {n : ℕ} → Tm n Z = ƛ (t · t) where t = ƛ (vr 1 · ƛ (vr 1 · vr 1 · vr 0)) -- A non-deterministically non-terminating term. ! : Tm 0 ! = Z · ƛ (ƛ (vr 1 · vr 0 ∣ vr 1 · vr 0)) · con 0 -- Its semantics. !-sem : D Value !-sem = later (♯ later (♯ later (♯ later (♯ (!-sem ∣ !-sem))))) ⟦!⟧≅!-sem : ⟦ ! ⟧ [] ≅ !-sem ⟦!⟧≅!-sem = later (♯ lem) where lem : force 1 (⟦ ! ⟧ []) ≅ force 1 !-sem lem = later (♯ later (♯ later (♯ (later (♯ lem) ∣ later (♯ lem))))) -- How did I come up with this proof term? Through a manual -- calculation... -- -- Let us first define some abbreviations: -- -- t₀ = vr 1 · vr 1 · vr 0 -- t₁ = ƛ t₀ -- t₂ = vr 1 · t₁ -- t₃ = ƛ t₂ -- -- u₀ = vr 1 · vr 0 -- u₁ = u₀ ∣ u₀ -- u₂ = ƛ u₁ -- u₃ = ƛ u₂ -- -- c₀ = ƛ u₂ [] -- c₁ = ƛ t₂ (c₀ ∷ []) -- c₂ = ƛ t₀ (c₁ ∷ c₀ ∷ []) -- -- Now we can calculate as follows (ignoring ♯): -- -- ⟦ Z · u₃ · con 0 ⟧ [] -- = ⟦ Z · u₃ ⟧ [] ⟦·⟧ return (con 0) -- = ƛ (t₃ · t₃) [] ∙ c₀ ⟦·⟧ return (con 0) -- = later (⟦ t₃ · t₃ ⟧ (c₀ ∷ []) ⟦·⟧ return (con 0)) -- = later (c₁ ∙ c₁ ⟦·⟧ return (con 0)) -- -- = c₁ ∙ c₁ ⟦·⟧ return (con 0) -- = later (⟦ t₂ ⟧ (c₁ ∷ c₀ ∷ []) ⟦·⟧ return (con 0)) -- = later (c₀ ∙ c₂ ⟦·⟧ return (con 0)) -- = later (later (⟦ u₂ ⟧ (c₂ ∷ []) ⟦·⟧ return (con 0))) -- = later (later (ƛ u₁ (c₂ ∷ []) ∙ con 0)) -- = later (later (later (⟦ u₁ ⟧ (con 0 ∷ c₂ ∷ [])))) -- = later (later (later (⟦ u₀ ⟧ (con 0 ∷ c₂ ∷ []) ∣ -- ⟦ u₀ ⟧ (con 0 ∷ c₂ ∷ [])))) -- = later (later (later (c₂ ∙ con 0 ∣ c₂ ∙ con 0))) -- = later (later (later (⟦ t₀ ⟧ (con 0 ∷ c₁ ∷ c₀ ∷ []) ∣ -- ⟦ t₀ ⟧ (con 0 ∷ c₁ ∷ c₀ ∷ [])))) -- = later (later (later (later (c₁ ∙ c₁ ⟦·⟧ return (con 0)) ∣ -- later (c₁ ∙ c₁ ⟦·⟧ return (con 0))))) ------------------------------------------------------------------------ -- A relation relating deterministic and non-deterministic -- computations -- x ≈∈ y means that x implements /one/ possible semantics of y (up to -- weak bisimilarity). infix 4 _≈∈_ data _≈∈_ {A : Set} : Maybe A ⊥ → D A → Set where fail : now nothing ≈∈ fail return : ∀ {x} → now (just x) ≈∈ return x ∣ˡ : ∀ {x y₁ y₂} (x≈∈y₁ : x ≈∈ y₁) → x ≈∈ y₁ ∣ y₂ ∣ʳ : ∀ {x y₁ y₂} (x≈∈y₂ : x ≈∈ y₂) → x ≈∈ y₁ ∣ y₂ later : ∀ {x y} (x≈∈y : ∞ (♭ x ≈∈ ♭ y)) → later x ≈∈ later y laterˡ : ∀ {x y} (x≈∈y : ♭ x ≈∈ y ) → later x ≈∈ y laterʳ : ∀ {x y} (x≈∈y : x ≈∈ ♭ y ) → x ≈∈ later y -- A transitivity-like result for _≡_ and _≈∈_. infixr 2 _≡⟨_⟩_ _≡⟨_⟩_ : ∀ {A : Set} (x : Maybe A ⊥) {y z} → x ≡ y → y ≈∈ z → x ≈∈ z _ ≡⟨ P.refl ⟩ y≈z = y≈z -- A transitivity-like result for _≈∈_ and _≅_. infixr 2 _≈∈⟨_⟩_ _≈∈⟨_⟩_ : ∀ {A : Set} (x : Maybe A ⊥) {y z} → x ≈∈ y → y ≅ z → x ≈∈ z ._ ≈∈⟨ fail ⟩ fail = fail ._ ≈∈⟨ return ⟩ return = return _ ≈∈⟨ ∣ˡ x₁≈∈y₁ ⟩ y₁≅z₁ ∣ y₂≅z₂ = ∣ˡ (_ ≈∈⟨ x₁≈∈y₁ ⟩ y₁≅z₁) _ ≈∈⟨ ∣ʳ x₂≈∈y₂ ⟩ y₁≅z₁ ∣ y₂≅z₂ = ∣ʳ (_ ≈∈⟨ x₂≈∈y₂ ⟩ y₂≅z₂) ._ ≈∈⟨ later x≈∈y ⟩ later y≅z = later (♯ (_ ≈∈⟨ ♭ x≈∈y ⟩ ♭ y≅z)) ._ ≈∈⟨ laterˡ x≈∈y ⟩ y≅z = laterˡ (_ ≈∈⟨ x≈∈y ⟩ y≅z) _ ≈∈⟨ laterʳ x≈∈y ⟩ later y≅z = laterʳ (_ ≈∈⟨ x≈∈y ⟩ ♭ y≅z) -- An example. lemma : Pa.never ≈∈ !-sem lemma = later (♯ later (♯ later (♯ later (♯ ∣ˡ lemma)))) ------------------------------------------------------------------------ -- Compiler correctness module Correctness where infix 4 _≈∈P_ _≈∈W_ infixr 2 _≡⟨_⟩W_ _≈∈⟨_⟩P_ _≈∈⟨_⟩W_ mutual data _≈∈P_ : Maybe VM.Value ⊥ → D VM.Value → Set where _≈∈⟨_⟩P_ : ∀ x {y z} (x≈y : x ≈∈P y) (y≅z : y ≅ z) → x ≈∈P z correct : ∀ {n} t {ρ : Env n} {c s} {k : Value → D VM.Value} → (hyp : ∀ v → exec ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≈∈W k v) → exec ⟨ comp t c , s , comp-env ρ ⟩ ≈∈P (⟦ t ⟧ ρ >>= k) data _≈∈W_ : Maybe VM.Value ⊥ → D VM.Value → Set where ⌈_⌉ : ∀ {x y} (x≈y : x ≈∈ y) → x ≈∈W y ∣ˡ : ∀ {x y₁ y₂} (x≈y₁ : x ≈∈W y₁) → x ≈∈W y₁ ∣ y₂ later : ∀ {x y} (x≈y : ♭ x ≈∈P ♭ y) → later x ≈∈W later y laterˡ : ∀ {x y} (x≈y : ♭ x ≈∈W y) → later x ≈∈W y _≡⟨_⟩W_ : ∀ x {y z} → x ≡ y → y ≈∈W z → x ≈∈W z _ ≡⟨ P.refl ⟩W y≈z = y≈z _≈∈⟨_⟩W_ : ∀ x {y z} → x ≈∈W y → y ≅ z → x ≈∈W z _ ≈∈⟨ ⌈ x≈y ⌉ ⟩W y≅z = ⌈ _ ≈∈⟨ x≈y ⟩ y≅z ⌉ _ ≈∈⟨ ∣ˡ x≈y₁ ⟩W y₁≅z₁ ∣ y₂≅z₂ = ∣ˡ (_ ≈∈⟨ x≈y₁ ⟩W y₁≅z₁) ._ ≈∈⟨ later x≈y ⟩W later y≅z = later (_ ≈∈⟨ x≈y ⟩P ♭ y≅z) ._ ≈∈⟨ laterˡ x≈y ⟩W y≅z = laterˡ (_ ≈∈⟨ x≈y ⟩W y≅z) mutual correctW : ∀ {n} t {ρ : Env n} {c s} {k : Value → D VM.Value} → (∀ v → exec ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≈∈W k v) → exec ⟨ comp t c , s , comp-env ρ ⟩ ≈∈W (⟦ t ⟧ ρ >>= k) correctW (con i) {ρ} {c} {s} {k} hyp = laterˡ ( exec ⟨ c , val (con i) ∷ s , comp-env ρ ⟩ ≈∈⟨ hyp (con i) ⟩W k (con i) ∎) correctW (var x) {ρ} {c} {s} {k} hyp = laterˡ ( exec ⟨ c , val (lookup (comp-env ρ) x) ∷ s , comp-env ρ ⟩ ≡⟨ P.cong (λ v → exec ⟨ c , val v ∷ s , comp-env ρ ⟩) (lookup-hom x ρ) ⟩W exec ⟨ c , val (comp-val (lookup ρ x)) ∷ s , comp-env ρ ⟩ ≈∈⟨ hyp (lookup ρ x) ⟩W k (lookup ρ x) ∎) correctW (ƛ t) {ρ} {c} {s} {k} hyp = laterˡ ( exec ⟨ c , val (comp-val (ƛ t ρ)) ∷ s , comp-env ρ ⟩ ≈∈⟨ hyp (ƛ t ρ) ⟩W k (ƛ t ρ) ∎) correctW (t₁ · t₂) {ρ} {c} {s} {k} hyp = exec ⟨ comp t₁ (comp t₂ (app ∷ c)) , s , comp-env ρ ⟩ ≈∈⟨ correctW t₁ (λ v₁ → correctW t₂ (λ v₂ → ∙-correctW v₁ v₂ hyp)) ⟩W (⟦ t₁ ⟧ ρ >>= λ v₁ → ⟦ t₂ ⟧ ρ >>= λ v₂ → ⟪ v₁ ∙ v₂ ⟫P >>= k) ≅⟨ ((⟦ t₁ ⟧ ρ ∎) >>=-cong λ _ → sym $ associative (⟦ t₂ ⟧ ρ)) ⟩ (⟦ t₁ ⟧ ρ >>= λ v₁ → (⟦ t₂ ⟧ ρ >>= λ v₂ → ⟪ v₁ ∙ v₂ ⟫P) >>= k) ≅⟨ sym $ associative (⟦ t₁ ⟧ ρ) ⟩ (⟦ t₁ ⟧ ρ ⟦·⟧ ⟦ t₂ ⟧ ρ >>= k) ≅⟨ sym (·-comp t₁ t₂ >>=-cong λ v → k v ∎) ⟩ (⟦ t₁ · t₂ ⟧ ρ >>= k) ∎ correctW (t₁ ∣ t₂) {ρ} {c} {s} {k} hyp = exec ⟨ comp t₁ c , s , comp-env ρ ⟩ ≈∈⟨ ∣ˡ (correctW t₁ hyp) ⟩W (⟦ t₁ ⟧ ρ >>= k) ∣ (⟦ t₂ ⟧ ρ >>= k) ∎ ∙-correctW : ∀ {n} v₁ v₂ {ρ : Env n} {c s} {k : Value → D VM.Value} → (∀ v → exec ⟨ c , val (comp-val v) ∷ s , comp-env ρ ⟩ ≈∈W k v) → exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val v₁) ∷ s , comp-env ρ ⟩ ≈∈W ⟪ v₁ ∙ v₂ ⟫P >>= k ∙-correctW (con i) v₂ _ = ⌈ fail ⌉ ∙-correctW (ƛ t₁ ρ₁) v₂ {ρ} {c} {s} {k} hyp = exec ⟨ app ∷ c , val (comp-val v₂) ∷ val (comp-val (ƛ t₁ ρ₁)) ∷ s , comp-env ρ ⟩ ≈∈⟨ later ( exec ⟨ comp t₁ [ ret ] , ret c (comp-env ρ) ∷ s , comp-env (v₂ ∷ ρ₁) ⟩ ≈∈⟨ correct t₁ (λ v → laterˡ (hyp v)) ⟩P (⟦ t₁ ⟧ (v₂ ∷ ρ₁) >>= k) ∎) ⟩W (⟪ ƛ t₁ ρ₁ ∙ v₂ ⟫P >>= k) ∎ whnf : ∀ {x y} → x ≈∈P y → x ≈∈W y whnf (x ≈∈⟨ x≈y ⟩P y≅z) = x ≈∈⟨ whnf x≈y ⟩W y≅z whnf (correct t hyp) = correctW t hyp mutual soundW : ∀ {x y} → x ≈∈W y → x ≈∈ y soundW ⌈ x≈y ⌉ = x≈y soundW (∣ˡ x≈y₁) = ∣ˡ (soundW x≈y₁) soundW (later x≈y) = later (♯ soundP x≈y) soundW (laterˡ x≈y) = laterˡ (soundW x≈y) soundP : ∀ {x y} → x ≈∈P y → x ≈∈ y soundP x≈y = soundW (whnf x≈y) correct : ∀ t → exec ⟨ comp t [] , [] , [] ⟩ ≈∈ ⟦ t ⟧ [] >>= λ v → return (comp-val v) correct t = soundP $ Correctness.correct t (λ _ → ⌈ return ⌉) where open Correctness ------------------------------------------------------------------------ -- Type system (following Leroy and Grall) infix 4 _⊢_∈_ data _⊢_∈_ {n} (Γ : Ctxt n) : Tm n → Ty → Set where con : ∀ {i} → Γ ⊢ con i ∈ nat var : ∀ {x} → Γ ⊢ var x ∈ lookup Γ x ƛ : ∀ {t σ τ} (t∈ : ♭ σ ∷ Γ ⊢ t ∈ ♭ τ) → Γ ⊢ ƛ t ∈ σ ⇾ τ _·_ : ∀ {t₁ t₂ σ τ} (t₁∈ : Γ ⊢ t₁ ∈ σ ⇾ τ) (t₂∈ : Γ ⊢ t₂ ∈ ♭ σ) → Γ ⊢ t₁ · t₂ ∈ ♭ τ _∣_ : ∀ {t₁ t₂ σ} (t₁∈ : Γ ⊢ t₁ ∈ σ) (t₂∈ : Γ ⊢ t₂ ∈ σ) → Γ ⊢ t₁ ∣ t₂ ∈ σ -- Ω is well-typed. Ω-well-typed : (τ : Ty) → [] ⊢ Ω ∈ τ Ω-well-typed τ = _·_ {σ = ♯ σ} {τ = ♯ τ} (ƛ (var · var)) (ƛ (var · var)) where σ = ♯ σ ⇾ ♯ τ -- The call-by-value fix-point combinator is also well-typed. fix-well-typed : ∀ {σ τ} → [] ⊢ Z ∈ ♯ (♯ (σ ⇾ τ) ⇾ ♯ (σ ⇾ τ)) ⇾ ♯ (σ ⇾ τ) fix-well-typed = ƛ (_·_ {σ = υ} {τ = ♯ _} (ƛ (var · ƛ (var · var · var))) (ƛ (var · ƛ (var · var · var)))) where υ : ∞ Ty υ = ♯ (υ ⇾ ♯ _) ------------------------------------------------------------------------ -- Type soundness -- WF-Value, WF-Env and WF-DV specify when a -- value/environment/computation is well-formed with respect to a -- given context (and type). mutual data WF-Value : Ty → Value → Set where con : ∀ {i} → WF-Value nat (con i) ƛ : ∀ {n Γ σ τ} {t : Tm (1 + n)} {ρ} (t∈ : ♭ σ ∷ Γ ⊢ t ∈ ♭ τ) (ρ-wf : WF-Env Γ ρ) → WF-Value (σ ⇾ τ) (ƛ t ρ) infixr 5 _∷_ data WF-Env : ∀ {n} → Ctxt n → Env n → Set where [] : WF-Env [] [] _∷_ : ∀ {n} {Γ : Ctxt n} {ρ σ v} (v-wf : WF-Value σ v) (ρ-wf : WF-Env Γ ρ) → WF-Env (σ ∷ Γ) (v ∷ ρ) data WF-DV (σ : Ty) : D Value → Set where return : ∀ {v} (v-wf : WF-Value σ v) → WF-DV σ (return v) _∣_ : ∀ {x y} (x-wf : WF-DV σ x) (y-wf : WF-DV σ y) → WF-DV σ (x ∣ y) later : ∀ {x} (x-wf : ∞ (WF-DV σ (♭ x))) → WF-DV σ (later x) -- Variables pointing into a well-formed environment refer to -- well-formed values. lookup-wf : ∀ {n Γ ρ} (x : Fin n) → WF-Env Γ ρ → WF-Value (lookup Γ x) (lookup ρ x) lookup-wf zero (v-wf ∷ ρ-wf) = v-wf lookup-wf (suc x) (v-wf ∷ ρ-wf) = lookup-wf x ρ-wf -- If we can prove WF-DV σ x, then x does not "go wrong". does-not-go-wrong : ∀ {σ x} → WF-DV σ x → ¬ now nothing ≈∈ x does-not-go-wrong (return v-wf) () does-not-go-wrong (x-wf ∣ y-wf) (∣ˡ x↯) = does-not-go-wrong x-wf x↯ does-not-go-wrong (x-wf ∣ y-wf) (∣ʳ y↯) = does-not-go-wrong y-wf y↯ does-not-go-wrong (later x-wf) (laterʳ x↯) = does-not-go-wrong (♭ x-wf) x↯ -- A variant of WF-DV, used to please the productivity checker. infix 3 _⟨_⟩P infixr 2 _≅⟨_⟩P_ data WF-DVP (σ : Ty) : D Value → Set where return : ∀ {v} (v-wf : WF-Value σ v) → WF-DVP σ (return v) _∣_ : ∀ {x y} (x-wf : WF-DVP σ x) (y-wf : WF-DVP σ y) → WF-DVP σ (x ∣ y) later : ∀ {x} (x-wf : ∞ (WF-DVP σ (♭ x))) → WF-DVP σ (later x) _>>=-congP_ : ∀ {τ x f} (x-wf : WF-DVP τ x) (f-wf : ∀ {v} → WF-Value τ v → WF-DVP σ (f v)) → WF-DVP σ (x >>= f) _≅⟨_⟩P_ : ∀ x {y} (x≅y : x ≅ y) (y-wf : WF-DVP σ y) → WF-DVP σ x _⟨_⟩P : ∀ x (x-wf : WF-DVP σ x) → WF-DVP σ x -- WF-DVP is sound with respect to WF-DV. private -- WHNFs. data WF-DVW (σ : Ty) : D Value → Set where return : ∀ {v} (v-wf : WF-Value σ v) → WF-DVW σ (return v) _∣_ : ∀ {x y} (x-wf : WF-DVW σ x) (y-wf : WF-DVW σ y) → WF-DVW σ (x ∣ y) later : ∀ {x} (x-wf : WF-DVP σ (♭ x)) → WF-DVW σ (later x) -- Functions which turn programs into WHNFs. trans-≅ : ∀ {σ x y} → x ≅ y → WF-DVW σ y → WF-DVW σ x trans-≅ fail () trans-≅ return (return v-wf) = return v-wf trans-≅ (x₁≅y₁ ∣ x₂≅y₂) (y₁-wf ∣ y₂-wf) = trans-≅ x₁≅y₁ y₁-wf ∣ trans-≅ x₂≅y₂ y₂-wf trans-≅ (later x≅y) (later y-wf) = later (_ ≅⟨ ♭ x≅y ⟩P y-wf) mutual _>>=-congW_ : ∀ {σ τ x f} → WF-DVW σ x → (∀ {v} → WF-Value σ v → WF-DVP τ (f v)) → WF-DVW τ (x >>= f) return v-wf >>=-congW f-wf = whnf (f-wf v-wf) (x-wf ∣ y-wf) >>=-congW f-wf = (x-wf >>=-congW f-wf) ∣ (y-wf >>=-congW f-wf) later x-wf >>=-congW f-wf = later (x-wf >>=-congP f-wf) whnf : ∀ {σ x} → WF-DVP σ x → WF-DVW σ x whnf (return v-wf) = return v-wf whnf (x-wf ∣ y-wf) = whnf x-wf ∣ whnf y-wf whnf (later x-wf) = later (♭ x-wf) whnf (x-wf >>=-congP f-wf) = whnf x-wf >>=-congW f-wf whnf (_ ≅⟨ x≅y ⟩P y-wf) = trans-≅ x≅y (whnf y-wf) whnf (_ ⟨ x-wf ⟩P) = whnf x-wf sound : ∀ {σ x} → WF-DVP σ x → WF-DV σ x sound = λ p → soundW (whnf p) where soundW : ∀ {σ x} → WF-DVW σ x → WF-DV σ x soundW (return v-wf) = return v-wf soundW (x-wf ∣ y-wf) = soundW x-wf ∣ soundW y-wf soundW (later x-wf) = later (♯ sound x-wf) -- Well-typed programs do not "go wrong". mutual ⟦⟧-wf : ∀ {n Γ} (t : Tm n) {σ} → Γ ⊢ t ∈ σ → ∀ {ρ} → WF-Env Γ ρ → WF-DVP σ (⟦ t ⟧ ρ) ⟦⟧-wf (con i) con ρ-wf = return con ⟦⟧-wf (var x) var ρ-wf = return (lookup-wf x ρ-wf) ⟦⟧-wf (ƛ t) (ƛ t∈) ρ-wf = return (ƛ t∈ ρ-wf) ⟦⟧-wf (t₁ ∣ t₂) (t₁∈ ∣ t₂∈) ρ-wf = ⟦⟧-wf t₁ t₁∈ ρ-wf ∣ ⟦⟧-wf t₂ t₂∈ ρ-wf ⟦⟧-wf (t₁ · t₂) (t₁∈ · t₂∈) {ρ} ρ-wf = ⟦ t₁ · t₂ ⟧ ρ ≅⟨ ·-comp t₁ t₂ ⟩P ⟦ t₁ ⟧ ρ ⟦·⟧ ⟦ t₂ ⟧ ρ ⟨ (⟦⟧-wf t₁ t₁∈ ρ-wf >>=-congP λ f-wf → ⟦⟧-wf t₂ t₂∈ ρ-wf >>=-congP λ v-wf → ∙-wf f-wf v-wf) ⟩P ∙-wf : ∀ {σ τ f v} → WF-Value (σ ⇾ τ) f → WF-Value (♭ σ) v → WF-DVP (♭ τ) ⟪ f ∙ v ⟫P ∙-wf (ƛ t₁∈ ρ₁-wf) v₂-wf = later (♯ ⟦⟧-wf _ t₁∈ (v₂-wf ∷ ρ₁-wf)) type-soundness : ∀ {t : Tm 0} {σ} → [] ⊢ t ∈ σ → ¬ now nothing ≈∈ ⟦ t ⟧ [] type-soundness t∈ = does-not-go-wrong (sound (⟦⟧-wf _ t∈ []))
{ "alphanum_fraction": 0.4323803943, "avg_line_length": 32.8173076923, "ext": "agda", "hexsha": "26cb0aef2d58ff3619bd804bc7bff8e5a7ac1240", "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": "Lambda/Closure/Functional/Non-deterministic.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": "Lambda/Closure/Functional/Non-deterministic.agda", "max_line_length": 138, "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": "Lambda/Closure/Functional/Non-deterministic.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": 10909, "size": 23891 }
module plfa.Induction where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; sym) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _≡⟨_⟩_; _∎) open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_) -- associativity of addition: (m + n) + p ≡ m + (n + p) +-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p) +-assoc zero n p = begin (zero + n) + p ≡⟨⟩ zero + (n + p) ∎ +-assoc (suc m) n p = begin (suc m + n) + p ≡⟨⟩ suc (m + n) + p ≡⟨⟩ suc ((m + n) + p) ≡⟨ cong suc (+-assoc m n p) ⟩ suc (m + (n + p)) ≡⟨⟩ suc m + (n + p) ∎ +-assoc′ : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p) +-assoc′ zero n p = refl +-assoc′ (suc m) n p rewrite +-assoc′ m n p = refl {- identity: m + 0 ≡ m, analogous to 0 + m ≡ m, which is the base case of addition -} +-identityʳ : ∀ (m : ℕ) → m + zero ≡ m +-identityʳ zero = begin zero + zero ≡⟨⟩ zero ∎ +-identityʳ (suc m) = begin suc m + zero ≡⟨⟩ suc (m + zero) ≡⟨ cong suc (+-identityʳ m) ⟩ suc m ∎ +-identity′ : ∀ (m : ℕ) → m + zero ≡ m +-identity′ zero = refl +-identity′ (suc m) rewrite +-identity′ m = refl {- m + suc n ≡ suc (m + n), analogous to suc m + n ≡ suc (m + n), which is the inductive case of addition for ∀ (m n :ℕ) -} +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n) +-suc zero n = begin zero + suc n ≡⟨⟩ suc (zero + n) ∎ +-suc (suc m) n = begin suc m + suc n ≡⟨⟩ suc (m + suc n) ≡⟨ cong suc (+-suc m n) ⟩ suc (suc (m + n)) ≡⟨⟩ suc (suc m + n) ∎ +-suc′ : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n) +-suc′ zero n = refl +-suc′ (suc m) n rewrite +-suc′ m n = refl -- commutativity: m + n ≡ n + m +-comm : ∀ (m n : ℕ) → m + n ≡ n + m +-comm m zero = begin m + zero ≡⟨ +-identityʳ m ⟩ zero + m ∎ +-comm m (suc n) = begin m + suc n ≡⟨ +-suc m n ⟩ suc (m + n) ≡⟨ cong suc (+-comm m n) ⟩ suc (n + m) ≡⟨⟩ suc n + m ∎ +-comm′ : ∀ (m n : ℕ) → m + n ≡ n + m +-comm′ m zero rewrite +-identity′ m = refl +-comm′ m (suc n) rewrite +-suc′ m n | +-comm′ m n = refl -- rearrange: (m + n) + (p + q) ≡ m + (n + p) + q +-rearrange : ∀ (m n p q : ℕ) → (m + n) + (p + q) ≡ m + (n + p) + q +-rearrange m n p q = begin (m + n) + (p + q) ≡⟨ +-assoc m n (p + q) ⟩ m + (n + (p + q)) ≡⟨ cong (m +_) (sym (+-assoc n p q)) ⟩ m + ((n + p) + q) ≡⟨ sym (+-assoc m (n + p) q) ⟩ m + (n + p) + q ∎ -- swap: m + (n + p) ≡ n + (m + p) +-swap : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p) +-swap m n p = begin m + (n + p) ≡⟨ +-comm m (n + p) ⟩ (n + p) + m ≡⟨ +-assoc n p m ⟩ n + (p + m) ≡⟨ cong (n +_) (+-comm p m) ⟩ n + (m + p) ∎ +-swap′ : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p) +-swap′ m n p rewrite +-comm′ m (n + p) | +-assoc′ n p m | +-comm′ p m = refl -- distributivity of multiplication over addition: (m + n) * p ≡ m * p + n * p *-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p *-distrib-+ zero n p = begin (zero + n) * p ≡⟨⟩ zero * p + n * p ∎ *-distrib-+ (suc m) n p = begin (suc m + n) * p ≡⟨⟩ suc (m + n) * p ≡⟨⟩ p + (m + n) * p ≡⟨ cong (p +_) (*-distrib-+ m n p) ⟩ p + (m * p + n * p) ≡⟨ sym (+-assoc p (m * p) (n * p)) ⟩ p + m * p + n * p ≡⟨⟩ suc m * p + n * p ∎ *-distrib-+′ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p *-distrib-+′ zero n p = refl *-distrib-+′ (suc m) n p rewrite *-distrib-+′ m n p | sym (+-assoc′ p (m * p) (n * p)) = refl -- associativity of multiplication: (m * n) * p ≡ m * (n * p) *-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p) *-assoc zero n p = begin (zero * n) * p ≡⟨⟩ zero * (n * p) ∎ *-assoc (suc m) n p = begin (suc m * n) * p ≡⟨⟩ (n + m * n) * p ≡⟨ *-distrib-+ n (m * n) p ⟩ n * p + (m * n) * p ≡⟨ cong ((n * p) +_) (*-assoc m n p) ⟩ n * p + m * (n * p) ≡⟨⟩ suc m * (n * p) ∎ *-assoc′ : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p) *-assoc′ zero n p = refl *-assoc′ (suc m) n p rewrite *-distrib-+′ n (m * n) p | *-assoc′ m n p = refl -- multiplication by zero, analogous to the base case of multiplication. n*0≡0 : ∀ (n : ℕ) → n * zero ≡ zero n*0≡0 zero = begin zero * zero ≡⟨⟩ zero ∎ n*0≡0 (suc n) = begin suc n * zero ≡⟨ n*0≡0 n ⟩ zero ∎ n*0≡0′ : ∀ (n : ℕ) → n * zero ≡ zero n*0≡0′ zero = refl n*0≡0′ (suc n) rewrite n*0≡0′ n = refl -- multiplication, analogous to the inductive case of multiplication. *-suc : ∀ (m n : ℕ) → m * suc n ≡ m + m * n *-suc zero n = begin zero * suc n ≡⟨⟩ zero + zero * n ∎ *-suc (suc m) n = begin suc m * suc n ≡⟨⟩ suc n + m * suc n ≡⟨ cong (suc n +_) (*-suc m n) ⟩ suc (n + (m + m * n)) ≡⟨ cong suc (sym (+-assoc n m (m * n))) ⟩ suc (n + m + m * n) ≡⟨ cong suc (cong (_+ (m * n)) (+-comm n m)) ⟩ suc (m + n + m * n) ≡⟨ cong suc (+-assoc m n (m * n)) ⟩ suc m + (n + m * n) ≡⟨⟩ suc m + suc m * n ∎ *-suc′ : ∀ (m n : ℕ) → m * suc n ≡ m + m * n *-suc′ zero n = refl *-suc′ (suc m) n rewrite *-suc′ m n | sym (+-assoc′ n m (m * n)) | +-comm n m | +-assoc m n (m * n)= refl -- commutitavity of multiplication: m * n ≡ n * m *-comm : ∀ (m n : ℕ) → m * n ≡ n * m *-comm m zero = begin m * zero ≡⟨ n*0≡0 m ⟩ zero * m ∎ *-comm m (suc n) = begin m * suc n ≡⟨ *-suc m n ⟩ m + m * n ≡⟨ cong (m +_) (*-comm m n) ⟩ m + n * m ≡⟨⟩ suc n * m ∎ *-comm′ : ∀ (m n : ℕ) → m * n ≡ n * m *-comm′ m zero rewrite n*0≡0′ m = refl *-comm′ m (suc n) rewrite *-suc′ m n | *-comm′ m n = refl -- zero monus (n : ℕ) 0∸n≡0 : ∀ (n : ℕ) → zero ∸ n ≡ zero 0∸n≡0 zero = begin zero ∸ zero ≡⟨⟩ zero ∎ 0∸n≡0 (suc n) = begin zero ∸ suc n ≡⟨⟩ zero ∎ 0∸n≡0′ : ∀ (n : ℕ) → zero ∸ n ≡ zero 0∸n≡0′ zero = refl 0∸n≡0′ (suc n) = refl -- associativity of monus: m ∸ n ∸ p ≡ m ∸ (n + p) ∸-+-assoc : ∀ (m n p : ℕ) → m ∸ n ∸ p ≡ m ∸ (n + p) ∸-+-assoc zero n p = begin zero ∸ n ∸ p ≡⟨ cong (_∸ p) (0∸n≡0 n) ⟩ zero ∸ p ≡⟨ 0∸n≡0 p ⟩ zero ≡⟨ sym (0∸n≡0 (n + p)) ⟩ zero ∸ (n + p) ∎ ∸-+-assoc (suc m) zero p = begin suc m ∸ zero ∸ p ≡⟨⟩ suc m ∸ p ≡⟨⟩ suc m ∸ (zero + p) ∎ ∸-+-assoc (suc m) (suc n) p = begin suc m ∸ suc n ∸ p ≡⟨⟩ m ∸ n ∸ p ≡⟨ ∸-+-assoc m n p ⟩ m ∸ (n + p) ≡⟨⟩ suc m ∸ suc (n + p) ≡⟨⟩ suc m ∸ (suc n + p) ∎ ∸-+-assoc′ : ∀ (m n p : ℕ) → m ∸ n ∸ p ≡ m ∸ (n + p) ∸-+-assoc′ zero zero p = refl ∸-+-assoc′ zero (suc n) p rewrite 0∸n≡0 p = refl ∸-+-assoc′ (suc m) zero p = refl ∸-+-assoc′ (suc m) (suc n) p rewrite ∸-+-assoc m n p = refl
{ "alphanum_fraction": 0.4314634523, "avg_line_length": 25.0813953488, "ext": "agda", "hexsha": "8d9312a3df513cadec6a10c2ab08ee5cda1f15f0", "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": "d6ca8fb32c4fe02c96f6e5eef82c2f24b7206e1b", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "tobal/plfa", "max_forks_repo_path": "logical_foundations/Induction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d6ca8fb32c4fe02c96f6e5eef82c2f24b7206e1b", "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": "tobal/plfa", "max_issues_repo_path": "logical_foundations/Induction.agda", "max_line_length": 105, "max_stars_count": null, "max_stars_repo_head_hexsha": "d6ca8fb32c4fe02c96f6e5eef82c2f24b7206e1b", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "tobal/plfa", "max_stars_repo_path": "logical_foundations/Induction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3225, "size": 6471 }