Search is not available for this dataset
text
string
meta
dict
open import Nat open import Prelude open import core open import contexts open import lemmas-disjointness open import exchange -- this module contains all the proofs of different weakening structural -- properties that we use for the hypothetical judgements module weakening where mutual weaken-subst-Δ : ∀{Δ1 Δ2 Γ σ Γ'} → Δ1 ## Δ2 → Δ1 , Γ ⊢ σ :s: Γ' → (Δ1 ∪ Δ2) , Γ ⊢ σ :s: Γ' weaken-subst-Δ disj (STAId x) = STAId x weaken-subst-Δ disj (STASubst subst x) = STASubst (weaken-subst-Δ disj subst) (weaken-ta-Δ1 disj x) weaken-ta-Δ1 : ∀{Δ1 Δ2 Γ d τ} → Δ1 ## Δ2 → Δ1 , Γ ⊢ d :: τ → (Δ1 ∪ Δ2) , Γ ⊢ d :: τ weaken-ta-Δ1 disj TAConst = TAConst weaken-ta-Δ1 disj (TAVar x₁) = TAVar x₁ weaken-ta-Δ1 disj (TALam x₁ wt) = TALam x₁ (weaken-ta-Δ1 disj wt) weaken-ta-Δ1 disj (TAAp wt wt₁) = TAAp (weaken-ta-Δ1 disj wt) (weaken-ta-Δ1 disj wt₁) weaken-ta-Δ1 {Δ1} {Δ2} {Γ} disj (TAEHole {u = u} {Γ' = Γ'} x x₁) = TAEHole (x∈∪l Δ1 Δ2 u _ x ) (weaken-subst-Δ disj x₁) weaken-ta-Δ1 {Δ1} {Δ2} {Γ} disj (TANEHole {Γ' = Γ'} {u = u} x wt x₁) = TANEHole (x∈∪l Δ1 Δ2 u _ x) (weaken-ta-Δ1 disj wt) (weaken-subst-Δ disj x₁) weaken-ta-Δ1 disj (TACast wt x) = TACast (weaken-ta-Δ1 disj wt) x weaken-ta-Δ1 disj (TAFailedCast wt x x₁ x₂) = TAFailedCast (weaken-ta-Δ1 disj wt) x x₁ x₂ -- this is a little bit of a time saver. since ∪ is commutative on -- disjoint contexts, and we need that premise anyway in both positions, -- there's no real reason to repeat the inductive argument above weaken-ta-Δ2 : ∀{Δ1 Δ2 Γ d τ} → Δ1 ## Δ2 → Δ2 , Γ ⊢ d :: τ → (Δ1 ∪ Δ2) , Γ ⊢ d :: τ weaken-ta-Δ2 {Δ1} {Δ2} {Γ} {d} {τ} disj D = tr (λ q → q , Γ ⊢ d :: τ) (∪comm Δ2 Δ1 (##-comm disj)) (weaken-ta-Δ1 (##-comm disj) D) -- note that these statements are somewhat stronger than usual. this is -- because we don't have implcit α-conversion. this reifies the -- often-silent on paper assumption that if you collide with a bound -- variable you can just α-convert it away and not worry. mutual weaken-synth : ∀{ x Γ e τ τ'} → freshh x e → Γ ⊢ e => τ → (Γ ,, (x , τ')) ⊢ e => τ weaken-synth FRHConst SConst = SConst weaken-synth (FRHAsc frsh) (SAsc x₁) = SAsc (weaken-ana frsh x₁) weaken-synth {Γ = Γ} (FRHVar {x = x} x₁) (SVar {x = y} x₂) = SVar (x∈∪l Γ (■(x , _)) y _ x₂) weaken-synth {Γ = Γ} (FRHLam2 x₁ frsh) (SLam x₂ wt) = SLam (apart-extend1 Γ (flip x₁) x₂) (exchange-synth {Γ = Γ} (flip x₁) ((weaken-synth frsh wt))) weaken-synth FRHEHole SEHole = SEHole weaken-synth (FRHNEHole frsh) (SNEHole x₁ wt) = SNEHole x₁ (weaken-synth frsh wt) weaken-synth (FRHAp frsh frsh₁) (SAp x₁ wt x₂ x₃) = SAp x₁ (weaken-synth frsh wt) x₂ (weaken-ana frsh₁ x₃) weaken-ana : ∀{x Γ e τ τ'} → freshh x e → Γ ⊢ e <= τ → (Γ ,, (x , τ')) ⊢ e <= τ weaken-ana frsh (ASubsume x₁ x₂) = ASubsume (weaken-synth frsh x₁) x₂ weaken-ana {Γ = Γ} (FRHLam1 neq frsh) (ALam x₂ x₃ wt) = ALam (apart-extend1 Γ (flip neq) x₂) x₃ (exchange-ana {Γ = Γ} (flip neq) (weaken-ana frsh wt)) mutual weaken-subst-Γ : ∀{ x Γ Δ σ Γ' τ} → envfresh x σ → Δ , Γ ⊢ σ :s: Γ' → Δ , (Γ ,, (x , τ)) ⊢ σ :s: Γ' weaken-subst-Γ {Γ = Γ} (EFId x₁) (STAId x₂) = STAId (λ x τ x₃ → x∈∪l Γ _ x τ (x₂ x τ x₃) ) weaken-subst-Γ {x = x} {Γ = Γ} (EFSubst x₁ efrsh x₂) (STASubst {y = y} {τ = τ'} subst x₃) = STASubst (exchange-subst-Γ {Γ = Γ} (flip x₂) (weaken-subst-Γ {Γ = Γ ,, (y , τ')} efrsh subst)) (weaken-ta x₁ x₃) weaken-ta : ∀{x Γ Δ d τ τ'} → fresh x d → Δ , Γ ⊢ d :: τ → Δ , Γ ,, (x , τ') ⊢ d :: τ weaken-ta _ TAConst = TAConst weaken-ta {x} {Γ} {_} {_} {τ} {τ'} (FVar x₂) (TAVar x₃) = TAVar (x∈∪l Γ (■ (x , τ')) _ _ x₃) weaken-ta {x = x} frsh (TALam {x = y} x₂ wt) with natEQ x y weaken-ta (FLam x₁ x₂) (TALam x₃ wt) | Inl refl = abort (x₁ refl) weaken-ta {Γ = Γ} {τ' = τ'} (FLam x₁ x₃) (TALam {x = y} x₄ wt) | Inr x₂ = TALam (apart-extend1 Γ (flip x₁) x₄) (exchange-ta-Γ {Γ = Γ} (flip x₁) (weaken-ta x₃ wt)) weaken-ta (FAp frsh frsh₁) (TAAp wt wt₁) = TAAp (weaken-ta frsh wt) (weaken-ta frsh₁ wt₁) weaken-ta (FHole x₁) (TAEHole x₂ x₃) = TAEHole x₂ (weaken-subst-Γ x₁ x₃) weaken-ta (FNEHole x₁ frsh) (TANEHole x₂ wt x₃) = TANEHole x₂ (weaken-ta frsh wt) (weaken-subst-Γ x₁ x₃) weaken-ta (FCast frsh) (TACast wt x₁) = TACast (weaken-ta frsh wt) x₁ weaken-ta (FFailedCast frsh) (TAFailedCast wt x₁ x₂ x₃) = TAFailedCast (weaken-ta frsh wt) x₁ x₂ x₃
{ "alphanum_fraction": 0.5384461754, "avg_line_length": 55.6333333333, "ext": "agda", "hexsha": "e7c275afb89e011da718866d3c3e5a600a3ce7e2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_forks_repo_path": "weakening.agda", "max_issues_count": 54, "max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_issues_repo_path": "weakening.agda", "max_line_length": 166, "max_stars_count": 16, "max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_stars_repo_path": "weakening.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z", "max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z", "num_tokens": 2079, "size": 5007 }
{-# OPTIONS --without-K --rewriting #-} module lib.Basics where open import lib.Base public open import lib.Equivalence public open import lib.Function public open import lib.Funext public open import lib.NType public open import lib.PathFunctor public open import lib.PathGroupoid public open import lib.PathOver public open import lib.Relation public open import lib.Univalence public
{ "alphanum_fraction": 0.8128205128, "avg_line_length": 24.375, "ext": "agda", "hexsha": "fa3f942898a3e236a452bec07c6b290841e27f60", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/Basics.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/Basics.agda", "max_line_length": 39, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/Basics.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 87, "size": 390 }
open import Data.Product using ( ∃ ; _×_ ; _,_ ; proj₁ ; proj₂ ) open import Relation.Unary using ( _∈_ ) open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; cong ) open import Web.Semantic.DL.ABox.Interp using ( Interp ; _,_ ; ⌊_⌋ ; ind ; _*_ ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox.Interp using ( Δ ; _⊨_≈_ ; ≈-refl ; ≈-sym ; ≈-trans ) renaming ( Interp to Interp′ ) open import Web.Semantic.DL.TBox.Interp.Morphism using ( ≲-image ; ≃-image ; ≃-image⁻¹ ; ≲-resp-≈ ; ≃-resp-≈ ; ≃-iso ) renaming ( _≲_ to _≲′_ ; _≃_ to _≃′_ ; ≲-refl to ≲′-refl ; ≲-trans to ≲′-trans ; ≃-refl to ≃′-refl ; ≃-sym to ≃′-sym ; ≃-trans to ≃′-trans ; ≃-impl-≲ to ≃-impl-≲′ ) open import Web.Semantic.Util using ( _∘_ ; _⊕_⊕_ ; inode ; bnode ; enode ; →-dist-⊕ ) module Web.Semantic.DL.ABox.Interp.Morphism {Σ : Signature} where infix 2 _≲_ _≃_ _≋_ infixr 4 _,_ infix 5 _**_ data _≲_ {X} (I J : Interp Σ X) : Set where _,_ : ∀ (I≲J : ⌊ I ⌋ ≲′ ⌊ J ⌋) → (i≲j : ∀ x → (⌊ J ⌋ ⊨ ≲-image I≲J (ind I x) ≈ ind J x)) → (I ≲ J) ≲⌊_⌋ : ∀ {X} {I J : Interp Σ X} → (I ≲ J) → (⌊ I ⌋ ≲′ ⌊ J ⌋) ≲⌊_⌋ (I≲J , i≲j) = I≲J ≲-resp-ind : ∀ {X} {I J : Interp Σ X} → (I≲J : I ≲ J) → ∀ x → (⌊ J ⌋ ⊨ ≲-image ≲⌊ I≲J ⌋ (ind I x) ≈ ind J x) ≲-resp-ind (I≲J , i≲j) = i≲j ≲-refl : ∀ {X} (I : Interp Σ X) → (I ≲ I) ≲-refl I = (≲′-refl ⌊ I ⌋ , λ x → ≈-refl ⌊ I ⌋) ≲-trans : ∀ {X} {I J K : Interp Σ X} → (I ≲ J) → (J ≲ K) → (I ≲ K) ≲-trans {X} {I} {J} {K} I≲J J≲K = (≲′-trans ≲⌊ I≲J ⌋ ≲⌊ J≲K ⌋ , λ x → ≈-trans ⌊ K ⌋ (≲-resp-≈ ≲⌊ J≲K ⌋ (≲-resp-ind I≲J x)) (≲-resp-ind J≲K x)) ≡-impl-≈ : ∀ {X : Set} (I : Interp′ Σ) {i j : X → Δ I} → (i ≡ j) → (∀ x → I ⊨ i x ≈ j x) ≡-impl-≈ I refl x = ≈-refl I ≡³-impl-≈ : ∀ {V X Y : Set} (I : Interp′ Σ) (i j : (X ⊕ V ⊕ Y) → Δ I) → (→-dist-⊕ i ≡ →-dist-⊕ j) → (∀ x → I ⊨ i x ≈ j x) ≡³-impl-≈ I i j i≡j (inode x) = ≡-impl-≈ I (cong proj₁ i≡j) x ≡³-impl-≈ I i j i≡j (bnode v) = ≡-impl-≈ I (cong proj₁ (cong proj₂ i≡j)) v ≡³-impl-≈ I i j i≡j (enode y) = ≡-impl-≈ I (cong proj₂ (cong proj₂ i≡j)) y ≡-impl-≲ : ∀ {X : Set} (I : Interp Σ X) j → (ind I ≡ j) → (I ≲ (⌊ I ⌋ , j)) ≡-impl-≲ (I , i) .i refl = ≲-refl (I , i) ≡³-impl-≲ : ∀ {V X Y : Set} (I : Interp Σ (X ⊕ V ⊕ Y)) j → (→-dist-⊕ (ind I) ≡ →-dist-⊕ j) → (I ≲ (⌊ I ⌋ , j)) ≡³-impl-≲ (I , i) j i≡j = (≲′-refl I , ≡³-impl-≈ I i j i≡j) _**_ : ∀ {X Y I J} (f : Y → X) → (I ≲ J) → (f * I ≲ f * J) f ** I≲J = (≲⌊ I≲J ⌋ , λ x → ≲-resp-ind I≲J (f x)) _≋_ : ∀ {X} {I J : Interp Σ X} → (I ≲ J) → (I ≲ J) → Set _≋_ {X} {I} {J} I≲₁J I≲₂J = ∀ x → (⌊ J ⌋ ⊨ ≲-image ≲⌊ I≲₁J ⌋ x ≈ ≲-image ≲⌊ I≲₂J ⌋ x) data _≃_ {X} (I J : Interp Σ X) : Set₁ where _,_ : (I≃J : ⌊ I ⌋ ≃′ ⌊ J ⌋) → (∀ x → (⌊ J ⌋ ⊨ ≃-image I≃J (ind I x) ≈ ind J x)) → (I ≃ J) ≃⌊_⌋ : ∀ {X} {I J : Interp Σ X} → (I ≃ J) → (⌊ I ⌋ ≃′ ⌊ J ⌋) ≃⌊_⌋ (I≃J , i≃j) = I≃J ≃-impl-≲ : ∀ {X} {I J : Interp Σ X} → (I ≃ J) → (I ≲ J) ≃-impl-≲ (I≃J , i≃j) = (≃-impl-≲′ I≃J , i≃j) ≃-resp-ind : ∀ {X} {I J : Interp Σ X} → (I≃J : I ≃ J) → ∀ x → (⌊ J ⌋ ⊨ ≃-image ≃⌊ I≃J ⌋ (ind I x) ≈ ind J x) ≃-resp-ind (I≃J , i≃j) = i≃j ≃-resp-ind⁻¹ : ∀ {X} {I J : Interp Σ X} → (I≃J : I ≃ J) → ∀ x → (⌊ I ⌋ ⊨ ≃-image⁻¹ ≃⌊ I≃J ⌋ (ind J x) ≈ ind I x) ≃-resp-ind⁻¹ {X} {I , i} {J , j} (I≃J , i≃j) x = ≈-trans I (≃-resp-≈ (≃′-sym I≃J) (≈-sym J (i≃j x))) (≃-iso I≃J (i x)) ≃-refl : ∀ {X} (I : Interp Σ X) → (I ≃ I) ≃-refl (I , i) = (≃′-refl I , λ x → ≈-refl I) ≃-symm : ∀ {X} {I J : Interp Σ X} → (I ≃ J) → (J ≃ I) ≃-symm {X} {I , i} {J , j} (I≃J , i≃j) = (≃′-sym I≃J , ≃-resp-ind⁻¹ {X} {I , i} {J , j} (I≃J , i≃j)) ≃-trans : ∀ {X} {I J K : Interp Σ X} → (I ≃ J) → (J ≃ K) → (I ≃ K) ≃-trans {X} {I , i} {J , j} {K , k} (I≃J , i≃j) (J≃K , j≃k) = (≃′-trans I≃J J≃K , λ x → ≈-trans K (≃-resp-≈ J≃K (i≃j x)) (j≃k x))
{ "alphanum_fraction": 0.4321344185, "avg_line_length": 38.8673469388, "ext": "agda", "hexsha": "945bf224457e61c63382c05e77bd57b72866e583", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/ABox/Interp/Morphism.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/ABox/Interp/Morphism.agda", "max_line_length": 110, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/ABox/Interp/Morphism.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 2387, "size": 3809 }
module _ where record R : Set₁ where field overlap A : Set
{ "alphanum_fraction": 0.6470588235, "avg_line_length": 9.7142857143, "ext": "agda", "hexsha": "fa638016c4e6f5109b8377ad329c18f2dd246cec", "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/UselessOverlap.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/UselessOverlap.agda", "max_line_length": 21, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/UselessOverlap.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 22, "size": 68 }
{-# OPTIONS --without-K #-} open import HoTT.Base open import HoTT.Identity open import HoTT.Equivalence module HoTT.Identity.Sigma where open variables _=Σ_ : Σ A P → Σ A P → 𝒰 _ _=Σ_ {P = P} x y = Σ[ p ∶ x₁ == y₁ ] transport P p x₂ == y₂ where open Σ x renaming (pr₁ to x₁ ; pr₂ to x₂) open Σ y renaming (pr₁ to y₁ ; pr₂ to y₂) pair⁼' : {x y : Σ A P} → Σ[ p ∶ pr₁ x == pr₁ y ] pr₂ x == transport P (p ⁻¹) (pr₂ y) → x == y pair⁼' {x = _ , _} {y = _ , _} (refl , refl) = refl =Σ-equiv : {x y : Σ A P} → (x == y) ≃ x =Σ y =Σ-equiv {x = _ , _} {y = _ , _} = let open Iso in iso→eqv λ where .f refl → (refl , refl) .g (refl , refl) → refl .η refl → refl .ε (refl , refl) → refl pair⁼ : {x y : Σ A P} → x =Σ y → x == y pair⁼ = Iso.g (eqv→iso =Σ-equiv)
{ "alphanum_fraction": 0.5442708333, "avg_line_length": 27.4285714286, "ext": "agda", "hexsha": "fa846ccae39d8e1f30317c527659a4c6fe0d959d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_path": "HoTT/Identity/Sigma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_path": "HoTT/Identity/Sigma.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_path": "HoTT/Identity/Sigma.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 348, "size": 768 }
{-# OPTIONS --without-K #-} -- Some basic theorems on paths and path compositions. module hott.core.equality.theorems where open import hott.core -- The path refl is the left identity under path concatnation. refl∙p≡p : ∀ {ℓ} {A : Type ℓ} {x y : A} → ∀ (p : x ≡ y) → refl ∙ p ≡ p refl∙p≡p refl = refl -- Alternate form of refl being left identity. p≡refl∙p : ∀ {ℓ} {A : Type ℓ} {x y : A} → ∀ (p : x ≡ y) → p ≡ refl ∙ p p≡refl∙p p = refl∙p≡p p ⁻¹ -- The path refl is the right identity under path concatnation. p∙refl≡p : ∀ {ℓ} {A : Type ℓ} {x y : A} → ∀ (p : x ≡ y) → p ∙ refl ≡ p p∙refl≡p refl = refl -- Alternate form of refl being the right identity. p≡p∙refl : ∀ {ℓ} {A : Type ℓ} {x y : A} → ∀ (p : x ≡ y) → p ≡ p ∙ refl p≡p∙refl p = p∙refl≡p p ⁻¹ -- The inverse of inverse is identity p⁻¹⁻¹≡p : ∀ {ℓ} {A : Type ℓ} {x y : A} → ∀ (p : x ≡ y) → (p ⁻¹)⁻¹ ≡ p p⁻¹⁻¹≡p refl = refl -- Alternate form of the theorem inverse of inverse is identity. p≡p⁻¹⁻¹ : ∀ {ℓ} {A : Type ℓ} {x y : A} → ∀ (p : x ≡ y) → p ≡ (p ⁻¹)⁻¹ p≡p⁻¹⁻¹ p = p⁻¹⁻¹≡p p ⁻¹ -- Inverse is actually right inverse. p∙p⁻¹≡refl : ∀ {ℓ} {A : Type ℓ} {x y : A} → ∀ (p : x ≡ y) → p ∙ p ⁻¹ ≡ refl p∙p⁻¹≡refl refl = refl -- Inverse is actually left inverse. p⁻¹∙p≡refl : ∀ {ℓ} {A : Type ℓ} {x y : A} → ∀ (p : x ≡ y) → p ⁻¹ ∙ p ≡ refl p⁻¹∙p≡refl refl = refl -- The associativity of path composition. assoc : ∀ {ℓ} {A : Type ℓ} {u v w x : A} → (p : u ≡ v) → (q : v ≡ w) → (r : w ≡ x) → (p ∙ q) ∙ r ≡ p ∙ (q ∙ r) assoc refl refl refl = refl
{ "alphanum_fraction": 0.4746945899, "avg_line_length": 25.6567164179, "ext": "agda", "hexsha": "7a344dbf4100d13bd6c123057b33945d4cd1e0a4", "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": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_path": "agda/hott/core/equality/theorems.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "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": "piyush-kurur/hott", "max_issues_repo_path": "agda/hott/core/equality/theorems.agda", "max_line_length": 64, "max_stars_count": null, "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_path": "agda/hott/core/equality/theorems.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 765, "size": 1719 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020 Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Abstract.Types open import LibraBFT.Impl.NetworkMsg open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Yasm.System ConcSysParms open import LibraBFT.Yasm.Properties ConcSysParms -- This module collects the implementation obligations for our (fake/simple, for now) -- "implementation" into the structure required by Concrete.Properties. open import LibraBFT.Concrete.Obligations module LibraBFT.Impl.Properties where open import LibraBFT.Impl.Properties.Aux open import LibraBFT.Concrete.System impl-sps-avp import LibraBFT.Impl.Properties.VotesOnce as VO import LibraBFT.Impl.Properties.LockedRound as LR theImplObligations : ImplObligations theImplObligations = record { sps-cor = impl-sps-avp ; vo₁ = VO.vo₁ ; vo₂ = VO.vo₂ ; lr₁ = LR.lr₁ }
{ "alphanum_fraction": 0.7192242833, "avg_line_length": 39.5333333333, "ext": "agda", "hexsha": "8e04932f85221fc68649449c98f98b321e54ac91", "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": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "lisandrasilva/bft-consensus-agda-1", "max_forks_repo_path": "LibraBFT/Impl/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "lisandrasilva/bft-consensus-agda-1", "max_issues_repo_path": "LibraBFT/Impl/Properties.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "lisandrasilva/bft-consensus-agda-1", "max_stars_repo_path": "LibraBFT/Impl/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 307, "size": 1186 }
module LC.Subst where open import LC.Base open import LC.Subst.Var open import LC.Subst.Term open import LC.Subst.Term public using (lift) open import Data.Nat open import Data.Nat.Properties open import Relation.Nullary -------------------------------------------------------------------------------- -- substitution infixl 10 _[_/_] _[_/_] : Term → Term → ℕ → Term (var x) [ N / i ] = subst-var (match x i) N (ƛ M) [ N / i ] = ƛ (M [ N / suc i ]) (L ∙ M) [ N / i ] = L [ N / i ] ∙ M [ N / i ] -- substitute the 0th var in M for N infixl 10 _[_] _[_] : Term → Term → Term M [ N ] = M [ N / 0 ] -------------------------------------------------------------------------------- -- properties regarding substitution open import Relation.Binary.PropositionalEquality hiding ([_]) open import Relation.Nullary.Negation using (contradiction) open ≡-Reasoning subst-< : ∀ x i N → x < i → (var x) [ N / i ] ≡ var x subst-< x i N x<i with match x i ... | Under x<i' = refl ... | Exact x≡i = contradiction x≡i (<⇒≢ x<i) ... | Above v x≥i = contradiction (≤-step (≤-pred x≥i)) (<⇒≱ x<i) subst-≡ : ∀ x i N → x ≡ i → (var x) [ N / i ] ≡ lift 0 i N subst-≡ x i N x≡i with match x i ... | Under x<i = contradiction x≡i (<⇒≢ x<i) ... | Exact x≡i' = refl ... | Above v x≥i = contradiction (sym x≡i) (<⇒≢ x≥i) subst-> : ∀ x i N → suc x > i → (var suc x) [ N / i ] ≡ var x subst-> x i N x≥i with match (suc x) i ... | Under x<i = contradiction (≤-pred (≤-step x<i)) (<⇒≱ x≥i) ... | Exact x≡i = contradiction (sym x≡i) (<⇒≢ x≥i) ... | Above v x≥i' = refl subst-[]-var : ∀ m n i x N → subst-var (match (lift-var n m x) (n + m + i)) N ≡ lift n m (subst-var (match x (n + i)) N) subst-[]-var m n i x N with inspectBinding n x subst-[]-var m n i x N | Free n≤x with match x (n + i) subst-[]-var m n i x N | Free n≤x | Under x<n+i = begin subst-var (match (m + x) (n + m + i)) N ≡⟨ subst-var-match-< {m + x} {n + m + i} N (LC.Subst.Var.INEQ.l+m+n>m+x n m i x x<n+i) ⟩ var (m + x) ≡⟨ cong var_ (sym (LC.Subst.Var.lift-var-≤ n≤x)) ⟩ var lift-var n m x ∎ subst-[]-var m n i x N | Free n≤x | Exact x≡n+i = begin subst-var (match (m + x) (n + m + i)) N ≡⟨ subst-var-match-≡ {m + x} {n + m + i} N (sym (LC.Subst.Var.EQ.l+m+n≡m+x n m i x (sym x≡n+i))) ⟩ lift 0 (n + m + i) N ≡⟨ lift-lemma 0 m n i N ⟩ lift n m (lift 0 (n + i) N) ∎ subst-[]-var m n i .(suc v) N | Free n≤x | Above v x≥n+i = begin subst-var (match (m + suc v) (n + m + i)) N ≡⟨ cong (λ w → subst-var (match w (n + m + i)) N) (+-suc m v) ⟩ subst-var (match (suc m + v) (n + m + i)) N ≡⟨ subst-var-match-> {m + v} {n + m + i} N (s≤s (LC.Subst.Var.INEQ.l+m+n≤m+x n m i v (≤-pred x≥n+i))) ⟩ var (m + v) ≡⟨ cong var_ (sym (LC.Subst.Var.lift-var-≤ {n} {m} {v} (≤-trans (m≤m+n n i) (≤-pred x≥n+i)))) ⟩ var lift-var n m v ∎ subst-[]-var m n i x N | Bound n>x = begin subst-var (match x (n + m + i)) N ≡⟨ subst-var-match-< N (≤-trans n>x (≤-trans (m≤m+n n m) (m≤m+n (n + m) i))) ⟩ var x ≡⟨ cong var_ (sym (LC.Subst.Var.lift-var-> n>x)) ⟩ var lift-var n m x ≡⟨⟩ lift n m (var x) ≡⟨ cong (lift n m) (sym (subst-var-match-< N (≤-trans n>x (m≤m+n n i)))) ⟩ lift n m (subst-var (match x (n + i)) N) ∎ lemma : ∀ {m n i} M N → lift (suc ((m + n))) i M [ lift n i N / m ] ≡ lift (m + n) i (M [ N / m ]) lemma {m} {n} {i} (var x) N = LC.Subst.Term.subst-var-lift _ _ _ x N lemma (ƛ M) N = cong ƛ_ (lemma M N) lemma (K ∙ M) N = cong₂ _∙_ (lemma K N) (lemma M N) lift-[] : ∀ n m i M N → lift n m (M [ N / n + i ]) ≡ lift n m M [ N / n + m + i ] lift-[] n m i (var x) N = sym (subst-[]-var m n i x N) lift-[] n m i (ƛ M) N = cong ƛ_ (lift-[] (suc n) m i M N) lift-[] n m i (M ∙ M') N = cong₂ _∙_ (lift-[] n m i M N) (lift-[] n m i M' N) lift-subst-var : ∀ l m n i x N → n ≥ i → i ≥ m → lift (l + m) (suc n) (var x) [ N / l + i ] ≡ lift (l + m) n (var x) lift-subst-var l m n i x N n≥i i≥m with inspectBinding (l + m) x ... | Free l+m≤x = begin subst-var (match (suc (n + x)) (l + i)) N ≡⟨ subst-var-match-> {n + x} {l + i} N (s≤s prop) ⟩ var (n + x) ∎ where prop : l + i ≤ n + x prop = ≤-trans (≤-reflexive (+-comm l i)) (+-mono-≤ n≥i (≤-trans (m≤m+n l m) l+m≤x)) ... | Bound l+m>x = begin subst-var (match x (l + i)) N ≡⟨ subst-var-match-< {x} {l + i} N prop ⟩ var x ∎ where prop : x < l + i prop = ≤-trans l+m>x (+-monoʳ-≤ l i≥m) lift-subst : ∀ l m n i M N → n ≥ i → i ≥ m → lift (l + m) (suc n) M [ N / l + i ] ≡ lift (l + m) n M lift-subst l m n i (var x) N n≥i i≥m = lift-subst-var l m n i x N n≥i i≥m lift-subst l m n i (ƛ M) N n≥i i≥m = cong ƛ_ (lift-subst (suc l) m n i M N n≥i i≥m) lift-subst l m n i (L ∙ M) N n≥i i≥m = cong₂ _∙_ (lift-subst l m n i L N n≥i i≥m) (lift-subst l m n i M N n≥i i≥m) subst-var-match-[] : ∀ {m i} x M N → subst-var (match x (suc (m + i))) N [ M [ N / i ] / m ] ≡ subst-var (match x m ) M [ N / m + i ] subst-var-match-[] {m} {i} x M N with match x m ... | Under x<m = begin subst-var (match x (suc (m + i))) N [ M [ N / i ] / m ] ≡⟨ (cong (_[ M [ N / i ] / m ])) (LC.Subst.Term.subst-var-match-< N (≤-trans x<m (≤-step (m≤m+n m i)))) ⟩ (var x) [ M [ N / i ] / m ] ≡⟨ subst-< x m (M [ N / i ]) x<m ⟩ var x ≡⟨ sym (LC.Subst.Term.subst-var-match-< N (≤-trans x<m (m≤m+n m i))) ⟩ subst-var (match x (m + i)) N ∎ ... | Exact x≡m = begin subst-var (match x (suc (m + i))) N [ M [ N / i ] / m ] ≡⟨ cong (_[ M [ N / i ] / m ]) (LC.Subst.Term.subst-var-match-< N (≤-trans (s≤s (≤-reflexive x≡m)) (s≤s (m≤m+n m i)))) ⟩ (var x) [ M [ N / i ] / m ] ≡⟨ subst-≡ x m (M [ N / i ]) x≡m ⟩ lift 0 m (M [ N / i ]) ≡⟨ lift-[] 0 m i M N ⟩ lift 0 m M [ N / m + i ] ∎ ... | Above v v≥m with match v (m + i) ... | Under v<m+i = begin subst-var (match (suc v) (suc (m + i))) N [ M [ N / i ] / m ] ≡⟨ cong (_[ M [ N / i ] / m ]) (LC.Subst.Term.subst-var-match-< {suc v} {suc m + i} N (s≤s v<m+i)) ⟩ (var suc v) [ M [ N / i ] / m ] ≡⟨ subst-> v m (M [ N / i ]) v≥m ⟩ var v ∎ ... | Exact v≡m+i = begin subst-var (match (suc v) (suc (m + i))) N [ M [ N / i ] / m ] ≡⟨ cong (_[ M [ N / i ] / m ]) (LC.Subst.Term.subst-var-match-≡ {suc v} {suc m + i} N (cong suc v≡m+i)) ⟩ lift 0 (suc m + i) N [ M [ N / i ] / m ] ≡⟨ lift-subst 0 0 (m + i) m N (M [ N / i ]) (m≤m+n m i) z≤n ⟩ lift 0 (m + i) N ∎ ... | Above v' v>m+i = begin subst-var (match (suc (suc v')) (suc (m + i))) N [ M [ N / i ] / m ] ≡⟨ cong (_[ M [ N / i ] / m ]) (LC.Subst.Term.subst-var-match-> {suc v'} {suc m + i} N (s≤s v>m+i)) ⟩ (var (suc v')) [ M [ N / i ] / m ] ≡⟨ subst-> v' m (M [ N / i ]) (≤-trans (s≤s (m≤m+n m i)) v>m+i) ⟩ var v' ∎ subst-lemma : ∀ {m i} M N O → M [ O / suc m + i ] [ N [ O / i ] / m ] ≡ M [ N / m ] [ O / m + i ] subst-lemma (var x) N O = subst-var-match-[] x N O subst-lemma (ƛ M) N O = cong ƛ_ (subst-lemma M N O) subst-lemma (M ∙ L) N O = cong₂ _∙_ (subst-lemma M N O) (subst-lemma L N O)
{ "alphanum_fraction": 0.451014885, "avg_line_length": 36.95, "ext": "agda", "hexsha": "e6ebf91cb04afeb079360bf27ffdae1ed5d59adc", "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": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/bidirectional", "max_forks_repo_path": "LC/Subst.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "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/bidirectional", "max_issues_repo_path": "LC/Subst.agda", "max_line_length": 125, "max_stars_count": 2, "max_stars_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/bidirectional", "max_stars_repo_path": "LC/Subst.agda", "max_stars_repo_stars_event_max_datetime": "2020-08-25T14:05:01.000Z", "max_stars_repo_stars_event_min_datetime": "2020-08-25T07:34:40.000Z", "num_tokens": 3253, "size": 7390 }
open import Level hiding ( suc ; zero ) open import Algebra module Solvable {n m : Level} (G : Group n m ) where open import Data.Unit open import Function.Inverse as Inverse using (_↔_; Inverse; _InverseOf_) open import Function open import Data.Nat hiding (_⊔_) -- using (ℕ; suc; zero) open import Relation.Nullary open import Data.Empty open import Data.Product open import Relation.Binary.PropositionalEquality hiding ( [_] ; sym ) open Group G open import Gutil G [_,_] : Carrier → Carrier → Carrier [ g , h ] = g ⁻¹ ∙ h ⁻¹ ∙ g ∙ h data Commutator (P : Carrier → Set (Level.suc n ⊔ m)) : (f : Carrier) → Set (Level.suc n ⊔ m) where comm : {g h : Carrier} → P g → P h → Commutator P [ g , h ] ccong : {f g : Carrier} → f ≈ g → Commutator P f → Commutator P g deriving : ( i : ℕ ) → Carrier → Set (Level.suc n ⊔ m) deriving 0 x = Lift (Level.suc n ⊔ m) ⊤ deriving (suc i) x = Commutator (deriving i) x open import Relation.Binary.HeterogeneousEquality as HE using (_≅_ ) deriving-subst : { i : ℕ } → {x y : Carrier } → x ≈ y → (dx : deriving i x ) → deriving i y deriving-subst {zero} {x} {y} x=y dx = lift tt deriving-subst {suc i} {x} {y} x=y dx = ccong x=y dx record solvable : Set (Level.suc n ⊔ m) where field dervied-length : ℕ end : (x : Carrier ) → deriving dervied-length x → x ≈ ε -- deriving stage is closed on multiplication and inversion import Relation.Binary.Reasoning.Setoid as EqReasoning open EqReasoning (Algebra.Group.setoid G) lemma4 : (g h : Carrier ) → [ h , g ] ≈ [ g , h ] ⁻¹ lemma4 g h = begin [ h , g ] ≈⟨ grefl ⟩ (h ⁻¹ ∙ g ⁻¹ ∙ h ) ∙ g ≈⟨ assoc _ _ _ ⟩ h ⁻¹ ∙ g ⁻¹ ∙ (h ∙ g) ≈⟨ ∙-cong grefl (gsym (∙-cong lemma6 lemma6)) ⟩ h ⁻¹ ∙ g ⁻¹ ∙ ((h ⁻¹) ⁻¹ ∙ (g ⁻¹) ⁻¹) ≈⟨ ∙-cong grefl (lemma5 _ _ ) ⟩ h ⁻¹ ∙ g ⁻¹ ∙ (g ⁻¹ ∙ h ⁻¹) ⁻¹ ≈⟨ assoc _ _ _ ⟩ h ⁻¹ ∙ (g ⁻¹ ∙ (g ⁻¹ ∙ h ⁻¹) ⁻¹) ≈⟨ ∙-cong grefl (lemma5 (g ⁻¹ ∙ h ⁻¹ ) g ) ⟩ h ⁻¹ ∙ (g ⁻¹ ∙ h ⁻¹ ∙ g) ⁻¹ ≈⟨ lemma5 (g ⁻¹ ∙ h ⁻¹ ∙ g) h ⟩ (g ⁻¹ ∙ h ⁻¹ ∙ g ∙ h) ⁻¹ ≈⟨ grefl ⟩ [ g , h ] ⁻¹ ∎ deriving-inv : { i : ℕ } → { x : Carrier } → deriving i x → deriving i ( x ⁻¹ ) deriving-inv {zero} {x} (lift tt) = lift tt deriving-inv {suc i} {_} (comm x x₁ ) = ccong (lemma4 _ _) (comm x₁ x) deriving-inv {suc i} {x} (ccong eq ix ) = ccong (⁻¹-cong eq) ( deriving-inv ix ) idcomtr : (g : Carrier ) → [ g , ε ] ≈ ε idcomtr g = begin (g ⁻¹ ∙ ε ⁻¹ ∙ g ∙ ε ) ≈⟨ ∙-cong (∙-cong (∙-cong grefl (sym lemma3 )) grefl ) grefl ⟩ (g ⁻¹ ∙ ε ∙ g ∙ ε ) ≈⟨ ∙-cong (∙-cong (proj₂ identity _) grefl) grefl ⟩ (g ⁻¹ ∙ g ∙ ε ) ≈⟨ ∙-cong (proj₁ inverse _ ) grefl ⟩ ( ε ∙ ε ) ≈⟨ proj₂ identity _ ⟩ ε ∎ idcomtl : (g : Carrier ) → [ ε , g ] ≈ ε idcomtl g = begin (ε ⁻¹ ∙ g ⁻¹ ∙ ε ∙ g ) ≈⟨ ∙-cong (proj₂ identity _) grefl ⟩ (ε ⁻¹ ∙ g ⁻¹ ∙ g ) ≈⟨ ∙-cong (∙-cong (sym lemma3 ) grefl ) grefl ⟩ (ε ∙ g ⁻¹ ∙ g ) ≈⟨ ∙-cong (proj₁ identity _) grefl ⟩ (g ⁻¹ ∙ g ) ≈⟨ proj₁ inverse _ ⟩ ε ∎ deriving-ε : { i : ℕ } → deriving i ε deriving-ε {zero} = lift tt deriving-ε {suc i} = ccong (idcomtr ε) (comm deriving-ε deriving-ε) comm-refl : {f g : Carrier } → f ≈ g → [ f , g ] ≈ ε comm-refl {f} {g} f=g = begin f ⁻¹ ∙ g ⁻¹ ∙ f ∙ g ≈⟨ ∙-cong (∙-cong (∙-cong (⁻¹-cong f=g ) grefl ) f=g ) grefl ⟩ g ⁻¹ ∙ g ⁻¹ ∙ g ∙ g ≈⟨ ∙-cong (assoc _ _ _ ) grefl ⟩ g ⁻¹ ∙ (g ⁻¹ ∙ g ) ∙ g ≈⟨ ∙-cong (∙-cong grefl (proj₁ inverse _) ) grefl ⟩ g ⁻¹ ∙ ε ∙ g ≈⟨ ∙-cong (proj₂ identity _) grefl ⟩ g ⁻¹ ∙ g ≈⟨ proj₁ inverse _ ⟩ ε ∎ comm-resp : {g h g1 h1 : Carrier } → g ≈ g1 → h ≈ h1 → [ g , h ] ≈ [ g1 , h1 ] comm-resp {g} {h} {g1} {h1} g=g1 h=h1 = ∙-cong (∙-cong (∙-cong (⁻¹-cong g=g1 ) (⁻¹-cong h=h1 )) g=g1 ) h=h1
{ "alphanum_fraction": 0.4816336394, "avg_line_length": 39.7884615385, "ext": "agda", "hexsha": "5b9674984714099e5fb51496774e8f6a0824684f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/Galois", "max_forks_repo_path": "src/Solvable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "shinji-kono/Galois", "max_issues_repo_path": "src/Solvable.agda", "max_line_length": 109, "max_stars_count": 1, "max_stars_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/Galois", "max_stars_repo_path": "src/Solvable.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-16T03:37:05.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-16T03:37:05.000Z", "num_tokens": 1830, "size": 4138 }
{- This file contains: - The equivalence "James X ≃ Ω Σ X" for any connected pointed type X. (KANG Rongji, Feb. 2022) -} {-# OPTIONS --safe #-} module Cubical.HITs.James.LoopSuspEquiv where open import Cubical.Foundations.Prelude open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.Fiberwise open import Cubical.Foundations.Univalence open import Cubical.Foundations.HLevels open import Cubical.Foundations.Pointed open import Cubical.Data.Unit open import Cubical.Data.Sigma open import Cubical.HITs.Pushout open import Cubical.HITs.Pushout.Flattening open import Cubical.HITs.Susp open import Cubical.HITs.James.Base renaming (James to JamesContruction ; James∙ to JamesContruction∙) open import Cubical.HITs.Truncation open import Cubical.Homotopy.Connected open import Cubical.Homotopy.Loopspace private variable ℓ : Level module _ ((X , x₀) : Pointed ℓ) where private James = JamesContruction (X , x₀) James∙ = JamesContruction∙ (X , x₀) Total : Type ℓ Total = Pushout {A = X × James} snd (λ (x , xs) → x ∷ xs) private flipSquare : (xs : James)(i j : I) → James flipSquare xs i j = hcomp (λ k → λ { (i = i0) → unit xs (j ∨ k) ; (i = i1) → unit (x₀ ∷ xs) j ; (j = i0) → unit xs (i ∨ k) ; (j = i1) → x₀ ∷ (unit xs i) }) (unit (unit xs i) j) square1 : (x : X)(xs : James)(i j : I) → Total square1 x xs i j = hfill (λ j → λ { (i = i0) → push (x , xs) (~ j) ; (i = i1) → push (x₀ , x ∷ xs) (~ j) }) (inS (inr (unit (x ∷ xs) i))) j square2 : (xs : James)(i j : I) → Total square2 xs i j = hcomp (λ k → λ { (i = i0) → push (x₀ , xs) (~ k) ; (i = i1) → square1 x₀ xs j k ; (j = i0) → push (x₀ , xs) (~ k) ; (j = i1) → push (x₀ , unit xs i) (~ k) }) (inr (flipSquare xs i j)) center : Total center = inl [] pathL : (xs : James) → center ≡ inl xs pathL [] = refl pathL (x ∷ xs) = pathL xs ∙ (λ i → square1 x xs i i1) pathL (unit xs i) j = hcomp (λ k → λ { (i = i0) → pathL xs j ; (i = i1) → compPath-filler (pathL xs) (λ i → square1 x₀ xs i i1) k j ; (j = i0) → inl [] ; (j = i1) → square2 xs i k }) (pathL xs j) isContrTotal : isContr Total isContrTotal .fst = center isContrTotal .snd (inl xs) = pathL xs isContrTotal .snd (inr xs) = pathL xs ∙∙ push (x₀ , xs) ∙∙ (λ i → inr (unit xs (~ i))) isContrTotal .snd (push (x , xs) i) j = hcomp (λ k → λ { (i = i0) → compPath-filler' (pathL xs) (λ i → square1 x xs i i1) (~ j) (~ k) ; (i = i1) → doubleCompPath-filler (pathL (x ∷ xs)) (push (x₀ , x ∷ xs)) (λ i → inr (unit (x ∷ xs) (~ i))) k j ; (j = i0) → pathL (x ∷ xs) (~ k) ; (j = i1) → square1 x xs (~ k) (~ i) }) (push (x₀ , x ∷ xs) (i ∧ j)) module _ (conn : isConnected 2 X) where private isEquivx₀∷ : isEquiv {A = James} (x₀ ∷_) isEquivx₀∷ = subst isEquiv (λ i xs → unit xs i) (idIsEquiv _) ∣isEquiv∣ : hLevelTrunc 2 X → Type ℓ ∣isEquiv∣ x = rec isSetHProp (λ x → isEquiv {A = James} (x ∷_) , isPropIsEquiv _) x .fst isEquiv∷ : (x : X) → isEquiv {A = James} (x ∷_) isEquiv∷ x = subst ∣isEquiv∣ (sym (conn .snd ∣ x₀ ∣) ∙ (conn .snd ∣ x ∣)) isEquivx₀∷ Code : Susp X → Type ℓ Code north = James Code south = James Code (merid x i) = ua (_ , isEquiv∷ x) i private open FlatteningLemma (λ _ → tt) (λ _ → tt) (λ tt → James) (λ tt → James) (λ x → _ , isEquiv∷ x) Total≃ : Pushout Σf Σg ≃ Total Total≃ = pushoutEquiv _ _ _ _ (idEquiv _) (ΣUnit _) (ΣUnit _) refl refl PushoutSuspCode : (x : PushoutSusp X) → E x ≃ Code (PushoutSusp→Susp x) PushoutSuspCode (inl tt) = idEquiv _ PushoutSuspCode (inr tt) = idEquiv _ PushoutSuspCode (push x i) = idEquiv _ ΣCode≃' : _ ≃ Σ _ Code ΣCode≃' = Σ-cong-equiv PushoutSusp≃Susp PushoutSuspCode ΣCode≃ : Total ≃ Σ _ Code ΣCode≃ = compEquiv (invEquiv Total≃) (compEquiv (invEquiv flatten) ΣCode≃') isContrΣCode : isContr (Σ _ Code) isContrΣCode = isOfHLevelRespectEquiv _ ΣCode≃ isContrTotal ΩΣ≃J : Ω (Susp∙ X) .fst ≃ James ΩΣ≃J = recognizeId Code [] isContrΣCode _ ΩΣ≃∙J : Ω (Susp∙ X) ≃∙ James∙ ΩΣ≃∙J = ΩΣ≃J , refl J≃ΩΣ : James ≃ Ω (Susp∙ X) .fst J≃ΩΣ = invEquiv ΩΣ≃J J≃∙ΩΣ : James∙ ≃∙ Ω (Susp∙ X) J≃∙ΩΣ = invEquiv∙ ΩΣ≃∙J
{ "alphanum_fraction": 0.5690460307, "avg_line_length": 30.801369863, "ext": "agda", "hexsha": "e2b6ea08f720fd11210e03891507d904ebb3b76a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/James/LoopSuspEquiv.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/HITs/James/LoopSuspEquiv.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/HITs/James/LoopSuspEquiv.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": 1829, "size": 4497 }
module _ (P : Set) where data ⊤ : Set where tt : ⊤ foo : ⊤ → Set foo tt = ⊤ bar : {{_ : ⊤}} → ⊤ bar {{tt}} = tt error : foo bar → ⊤ error tt = tt
{ "alphanum_fraction": 0.4768211921, "avg_line_length": 10.7857142857, "ext": "agda", "hexsha": "51f1c0c9555ed4c716141db92d56734e5ac181d4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue999.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/Issue999.agda", "max_line_length": 25, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/Issue999.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 66, "size": 151 }
{-# OPTIONS --sized-types --show-implicit #-} module SizedNat where open import Size data Nat : {size : Size} -> Set where zero : {size : Size} -> Nat {↑ size} suc : {size : Size} -> Nat {size} -> Nat {↑ size} -- subtraction is non size increasing sub : {size : Size} -> Nat {size} -> Nat {∞} -> Nat {size} sub zero n = zero sub (suc m) zero = suc m sub (suc m) (suc n) = sub m n -- div' m n computes ceiling(m/(n+1)) div' : {size : Size} -> Nat {size} -> Nat -> Nat {size} div' zero n = zero div' (suc m) n = suc (div' (sub m n) n) -- one can use sized types as if they were not sized -- sizes default to ∞ add : Nat -> Nat -> Nat add (zero ) n = n add (suc m) n = suc (add m n) nisse : {i : Size} -> Nat {i} -> Nat {i} nisse zero = zero nisse (suc zero) = suc zero nisse (suc (suc n)) = suc zero {- Agda complains about duplicate binding NatInfty = Nat {∞} {-# BUILTIN NATURAL NatInfty #-} {-# BUILTIN PLUS add #-} -}
{ "alphanum_fraction": 0.5784518828, "avg_line_length": 22.2325581395, "ext": "agda", "hexsha": "a97d74cbb50d2bad6a114183838aa4c3f5549b4d", "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/Termination/Sized/SizedNat.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/Termination/Sized/SizedNat.agda", "max_line_length": 58, "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/Termination/Sized/SizedNat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 330, "size": 956 }
module _ where open import Common.Prelude open import Common.Equality primitive primForce : ∀ {a b} {A : Set a} {B : A → Set b} (x : A) → (∀ x → B x) → B x primForceLemma : ∀ {a b} {A : Set a} {B : A → Set b} (x : A) (f : ∀ x → B x) → primForce x f ≡ f x force = primForce forceLemma = primForceLemma seq : ∀ {a b} {A : Set a} {B : Set b} → A → B → B seq x y = force x λ _ → y foo : (a b : Nat) → seq a b ≡ b foo zero _ = refl foo (suc n) _ = refl seqLit : (n : Nat) → seq "literal" n ≡ n seqLit n = refl seqType : (n : Nat) → seq Nat n ≡ n seqType n = refl seqPi : {A B : Set} {n : Nat} → seq (A → B) n ≡ n seqPi = refl seqLam : {n : Nat} → seq (λ (x : Nat) → x) n ≡ n seqLam = refl seqLemma : (a b : Nat) → seq a b ≡ b seqLemma a b = forceLemma a _ evalLemma : (n : Nat) → seqLemma (suc n) n ≡ refl evalLemma n = refl infixr 0 _$!_ _$!_ : ∀ {a b} {A : Set a} {B : A → Set b} → (∀ x → B x) → ∀ x → B x f $! x = force x f -- Without seq, this would be exponential -- pow2 : Nat → Nat → Nat pow2 zero acc = acc pow2 (suc n) acc = pow2 n $! acc + acc lem : pow2 32 1 ≡ 4294967296 lem = refl
{ "alphanum_fraction": 0.5428571429, "avg_line_length": 21.9607843137, "ext": "agda", "hexsha": "bba4b1f53fa855390e5d38ed47e35203dccf52ef", "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/PrimSeq.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/PrimSeq.agda", "max_line_length": 100, "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/PrimSeq.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": 471, "size": 1120 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Foundations.HLevels module Cubical.Algebra.Semigroup.Construct.Right {ℓ} (Aˢ : hSet ℓ) where open import Cubical.Foundations.Prelude open import Cubical.Algebra.Semigroup import Cubical.Algebra.Magma.Construct.Right Aˢ as RMagma open RMagma public hiding (Right-isMagma; RightMagma) private A = ⟨ Aˢ ⟩ isSetA = Aˢ .snd ▸-assoc : Associative _▸_ ▸-assoc _ _ _ = refl Right-isSemigroup : IsSemigroup A _▸_ Right-isSemigroup = record { isMagma = RMagma.Right-isMagma ; assoc = ▸-assoc } RightSemigroup : Semigroup ℓ RightSemigroup = record { isSemigroup = Right-isSemigroup }
{ "alphanum_fraction": 0.7460770328, "avg_line_length": 23.3666666667, "ext": "agda", "hexsha": "a311c5662eabed22b2e8d086eb330c589c7e5dee", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Semigroup/Construct/Right.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Semigroup/Construct/Right.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Semigroup/Construct/Right.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 225, "size": 701 }
module _ where abstract data Nat : Set where Zero : Nat Succ : Nat → Nat countDown : Nat → Nat countDown x with x ... | Zero = Zero ... | Succ n = countDown n
{ "alphanum_fraction": 0.5801104972, "avg_line_length": 15.0833333333, "ext": "agda", "hexsha": "30ed477ee6026383b9a780150bb09e59ed98b025", "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/Issue4833.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/Issue4833.agda", "max_line_length": 28, "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/Issue4833.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": 58, "size": 181 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Sigma open import lib.types.Group open import lib.types.CommutingSquare open import lib.groups.Homomorphism open import lib.groups.Isomorphism module lib.groups.CommutingSquare where -- A new type to keep the parameters. record CommSquareᴳ {i₀ i₁ j₀ j₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} (φ₀ : G₀ →ᴳ H₀) (φ₁ : G₁ →ᴳ H₁) (ξG : G₀ →ᴳ G₁) (ξH : H₀ →ᴳ H₁) : Type (lmax (lmax i₀ i₁) (lmax j₀ j₁)) where constructor comm-sqrᴳ field commutesᴳ : ∀ g₀ → GroupHom.f (ξH ∘ᴳ φ₀) g₀ == GroupHom.f (φ₁ ∘ᴳ ξG) g₀ infixr 0 _□$ᴳ_ _□$ᴳ_ = CommSquareᴳ.commutesᴳ is-csᴳ-equiv : ∀ {i₀ i₁ j₀ j₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} {φ₀ : G₀ →ᴳ H₀} {φ₁ : G₁ →ᴳ H₁} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} → CommSquareᴳ φ₀ φ₁ ξG ξH → Type (lmax (lmax i₀ i₁) (lmax j₀ j₁)) is-csᴳ-equiv {ξG = ξG} {ξH} _ = is-equiv (GroupHom.f ξG) × is-equiv (GroupHom.f ξH) CommSquareEquivᴳ : ∀ {i₀ i₁ j₀ j₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} (φ₀ : G₀ →ᴳ H₀) (φ₁ : G₁ →ᴳ H₁) (ξG : G₀ →ᴳ G₁) (ξH : H₀ →ᴳ H₁) → Type (lmax (lmax i₀ i₁) (lmax j₀ j₁)) CommSquareEquivᴳ φ₀ φ₁ ξG ξH = Σ (CommSquareᴳ φ₀ φ₁ ξG ξH) is-csᴳ-equiv abstract CommSquareᴳ-∘v : ∀ {i₀ i₁ i₂ j₀ j₁ j₂} {G₀ : Group i₀} {G₁ : Group i₁} {G₂ : Group i₂} {H₀ : Group j₀} {H₁ : Group j₁} {H₂ : Group j₂} {φ : G₀ →ᴳ H₀} {ψ : G₁ →ᴳ H₁} {χ : G₂ →ᴳ H₂} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} {μA : G₁ →ᴳ G₂} {μB : H₁ →ᴳ H₂} → CommSquareᴳ ψ χ μA μB → CommSquareᴳ φ ψ ξG ξH → CommSquareᴳ φ χ (μA ∘ᴳ ξG) (μB ∘ᴳ ξH) CommSquareᴳ-∘v {ξG = ξG} {μB = μB} (comm-sqrᴳ □₁₂) (comm-sqrᴳ □₀₁) = comm-sqrᴳ λ g₀ → ap (GroupHom.f μB) (□₀₁ g₀) ∙ □₁₂ (GroupHom.f ξG g₀) CommSquareEquivᴳ-inverse-v : ∀ {i₀ i₁ j₀ j₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} {φ₀ : G₀ →ᴳ H₀} {φ₁ : G₁ →ᴳ H₁} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} → (cse : CommSquareEquivᴳ φ₀ φ₁ ξG ξH) → CommSquareEquivᴳ φ₁ φ₀ (GroupIso.g-hom (ξG , fst (snd cse))) (GroupIso.g-hom (ξH , snd (snd cse))) CommSquareEquivᴳ-inverse-v (comm-sqrᴳ cs , ise) with CommSquareEquiv-inverse-v (comm-sqr cs , ise) ... | (comm-sqr cs' , ise') = cs'' , ise' where abstract cs'' = comm-sqrᴳ cs' CommSquareᴳ-inverse-v : ∀ {i₀ i₁ j₀ j₁} {G₀ : Group i₀} {G₁ : Group i₁} {H₀ : Group j₀} {H₁ : Group j₁} {φ₀ : G₀ →ᴳ H₀} {φ₁ : G₁ →ᴳ H₁} {ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} → CommSquareᴳ φ₀ φ₁ ξG ξH → (ξG-ise : is-equiv (GroupHom.f ξG)) (ξH-ise : is-equiv (GroupHom.f ξH)) → CommSquareᴳ φ₁ φ₀ (GroupIso.g-hom (ξG , ξG-ise)) (GroupIso.g-hom (ξH , ξH-ise)) CommSquareᴳ-inverse-v cs ξG-ise ξH-ise = fst (CommSquareEquivᴳ-inverse-v (cs , ξG-ise , ξH-ise)) -- basic facts nicely represented in commuting squares inv-hom-natural-comm-sqr : ∀ {i j} (G : AbGroup i) (H : AbGroup j) (φ : AbGroup.grp G →ᴳ AbGroup.grp H) → CommSquareᴳ φ φ (inv-hom G) (inv-hom H) inv-hom-natural-comm-sqr _ _ φ = comm-sqrᴳ λ g → ! (GroupHom.pres-inv φ g)
{ "alphanum_fraction": 0.6094830425, "avg_line_length": 42.1805555556, "ext": "agda", "hexsha": "5ea33d09d727cb53460e9178794fe92df7e84cce", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/groups/CommutingSquare.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/groups/CommutingSquare.agda", "max_line_length": 102, "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": "core/lib/groups/CommutingSquare.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": 1591, "size": 3037 }
-- this is effectively a CM make file. it just includes all the files that -- exist in the directory in the right order so that one can check that -- everything compiles cleanly and has no unfilled holes -- data structures open import List open import Nat open import Prelude -- basic stuff: core definitions, etc open import core open import checks open import judgemental-erase open import judgemental-inconsistency open import moveerase open import examples open import structural -- first wave theorems open import sensibility open import aasubsume-min open import determinism -- second wave theorems (checksums) open import reachability open import constructability
{ "alphanum_fraction": 0.8103703704, "avg_line_length": 25, "ext": "agda", "hexsha": "2a0155229cb5bc93189eb0ad16b24d6c815fc662", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-07-03T03:45:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-07-03T03:45:07.000Z", "max_forks_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/agda-popl17", "max_forks_repo_path": "all.agda", "max_issues_count": 37, "max_issues_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_issues_repo_issues_event_max_datetime": "2016-11-09T18:13:55.000Z", "max_issues_repo_issues_event_min_datetime": "2016-07-07T16:23:11.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/agda-popl17", "max_issues_repo_path": "all.agda", "max_line_length": 74, "max_stars_count": 14, "max_stars_repo_head_hexsha": "db3d21a1e3f17ef77ad557ed12374979f381b6b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/agda-popl17", "max_stars_repo_path": "all.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-11T12:30:50.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-01T22:44:11.000Z", "num_tokens": 151, "size": 675 }
module consoleExamples.passwordCheckSimple where open import ConsoleLib open import Data.Bool.Base open import Data.Bool open import Data.String renaming (_==_ to _==str_) open import SizedIO.Base main : ConsoleProg main = run (GetLine >>= λ s → if s ==str "passwd" then WriteString "Success" else WriteString "Error")
{ "alphanum_fraction": 0.6888888889, "avg_line_length": 25.7142857143, "ext": "agda", "hexsha": "56cadb31d9b46cccf34c8043eb232ea6625bd3bf", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/consoleExamples/passwordCheckSimple.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/consoleExamples/passwordCheckSimple.agda", "max_line_length": 50, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/consoleExamples/passwordCheckSimple.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 84, "size": 360 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Universe where open import Cubical.Data.Universe.Base public open import Cubical.Data.Universe.Properties public
{ "alphanum_fraction": 0.7857142857, "avg_line_length": 24, "ext": "agda", "hexsha": "185cd6517d16c95343a080b3b4818b9a86429c7d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Data/Universe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/Data/Universe.agda", "max_line_length": 51, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Data/Universe.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 37, "size": 168 }
{-# OPTIONS --without-K --safe #-} open import Categories.Bicategory using (Bicategory) -- A Pseudofunctor is a homomorphism of Bicategories -- Follow Bénabou's definition, which is basically that of a Functor -- Note that what is in nLab is an "exploded" version of the simpler version below module Categories.Pseudofunctor where open import Level open import Data.Product using (_,_) import Categories.Category as Category open Category.Category using (Obj; module Commutation) open Category using (Category; _[_,_]) open import Categories.Functor using (Functor; _∘F_) renaming (id to idF) open import Categories.Category.Product using (_⁂_) open import Categories.NaturalTransformation using (NaturalTransformation) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; _≃_) open import Categories.Category.Instance.One using (shift) open NaturalIsomorphism using (F⇒G; F⇐G) record Pseudofunctor {o ℓ e t o′ ℓ′ e′ t′ : Level} (C : Bicategory o ℓ e t) (D : Bicategory o′ ℓ′ e′ t′) : Set (o ⊔ ℓ ⊔ e ⊔ t ⊔ o′ ⊔ ℓ′ ⊔ e′ ⊔ t′) where private module C = Bicategory C module D = Bicategory D field P₀ : C.Obj → D.Obj P₁ : {x y : C.Obj} → Functor (C.hom x y) (D.hom (P₀ x) (P₀ y)) -- For maximal generality, shift the levels of One. P preserves id P-identity : {A : C.Obj} → D.id {P₀ A} ∘F shift o′ ℓ′ e′ ≃ P₁ ∘F (C.id {A}) -- P preserves composition P-homomorphism : {x y z : C.Obj} → D.⊚ ∘F (P₁ ⁂ P₁) ≃ P₁ ∘F C.⊚ {x} {y} {z} -- P preserves ≃ module unitˡ {A} = NaturalTransformation (F⇒G (P-identity {A})) module unitʳ {A} = NaturalTransformation (F⇐G (P-identity {A})) module Hom {x} {y} {z} = NaturalTransformation (F⇒G (P-homomorphism {x} {y} {z})) -- For notational convenience, shorten some functor applications private F₀ = λ {x y} X → Functor.F₀ (P₁ {x} {y}) X field unitaryˡ : {x y : C.Obj} → let open Commutation (D.hom (P₀ x) (P₀ y)) in {f : Obj (C.hom x y)} → [ D.id₁ D.⊚₀ (F₀ f) ⇒ F₀ f ]⟨ unitˡ.η _ D.⊚₁ D.id₂ ⇒⟨ F₀ C.id₁ D.⊚₀ F₀ f ⟩ Hom.η ( C.id₁ , f) ⇒⟨ F₀ (C.id₁ C.⊚₀ f) ⟩ Functor.F₁ P₁ C.unitorˡ.from ≈ D.unitorˡ.from ⟩ unitaryʳ : {x y : C.Obj} → let open Commutation (D.hom (P₀ x) (P₀ y)) in {f : Obj (C.hom x y)} → [ (F₀ f) D.⊚₀ D.id₁ ⇒ F₀ f ]⟨ D.id₂ D.⊚₁ unitˡ.η _ ⇒⟨ F₀ f D.⊚₀ F₀ C.id₁ ⟩ Hom.η ( f , C.id₁ ) ⇒⟨ F₀ (f C.⊚₀ C.id₁) ⟩ Functor.F₁ P₁ (C.unitorʳ.from) ≈ D.unitorʳ.from ⟩ assoc : {x y z w : C.Obj} → let open Commutation (D.hom (P₀ x) (P₀ w)) in {f : Obj (C.hom x y)} {g : Obj (C.hom y z)} {h : Obj (C.hom z w)} → [ (F₀ h D.⊚₀ F₀ g) D.⊚₀ F₀ f ⇒ F₀ (h C.⊚₀ (g C.⊚₀ f)) ]⟨ Hom.η (h , g) D.⊚₁ D.id₂ ⇒⟨ F₀ (h C.⊚₀ g) D.⊚₀ F₀ f ⟩ Hom.η (_ , f) ⇒⟨ F₀ ((h C.⊚₀ g) C.⊚₀ f) ⟩ Functor.F₁ P₁ C.associator.from ≈ D.associator.from ⇒⟨ F₀ h D.⊚₀ (F₀ g D.⊚₀ F₀ f) ⟩ D.id₂ D.⊚₁ Hom.η (g , f) ⇒⟨ F₀ h D.⊚₀ F₀ (g C.⊚₀ f) ⟩ Hom.η (h , _) ⟩
{ "alphanum_fraction": 0.53125, "avg_line_length": 43.0769230769, "ext": "agda", "hexsha": "69b7e3e08a571be3889966c84b089a65ce9ea403", "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/Pseudofunctor.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/Pseudofunctor.agda", "max_line_length": 105, "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/Pseudofunctor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1274, "size": 3360 }
module Tactic.Reflection.Replace where open import Prelude open import Container.Traversable open import Tactic.Reflection open import Tactic.Reflection.Equality {-# TERMINATING #-} _r[_/_] : Term → Term → Term → Term p r[ r / l ] = ifYes p == l then r else case p of λ { (var x args) → var x $ args r₂[ r / l ] ; (con c args) → con c $ args r₂[ r / l ] ; (def f args) → def f $ args r₂[ r / l ] ; (lam v t) → lam v $ t r₁[ weaken 1 r / weaken 1 l ] -- lam v <$> t r₁[ weaken 1 r / weaken 1 l ] ; (pat-lam cs args) → let w = length args in pat-lam (replaceClause (weaken w l) (weaken w r) <$> cs) $ args r₂[ r / l ] ; (pi a b) → pi (a r₁[ r / l ]) (b r₁[ weaken 1 r / weaken 1 l ]) ; (agda-sort s) → agda-sort $ replaceSort l r s ; (lit l) → lit l ; (meta x args) → meta x $ args r₂[ r / l ] ; unknown → unknown } where replaceClause : Term → Term → Clause → Clause replaceClause l r (clause pats x) = clause pats $ x r[ r / l ] replaceClause l r (absurd-clause pats) = absurd-clause pats replaceSort : Term → Term → Sort → Sort replaceSort l r (set t) = set $ t r[ r / l ] replaceSort l r (lit n) = lit n replaceSort l r unknown = unknown _r₁[_/_] : {T₀ : Set → Set} {{_ : Traversable T₀}} → T₀ Term → Term → Term → T₀ Term p r₁[ r / l ] = _r[ r / l ] <$> p _r₂[_/_] : {T₀ T₁ : Set → Set} {{_ : Traversable T₀}} {{_ : Traversable T₁}} → T₁ (T₀ Term) → Term → Term → T₁ (T₀ Term) p r₂[ r / l ] = fmap _r[ r / l ] <$> p _R[_/_] : List (Arg Type) → Type → Type → List (Arg Type) Γ R[ L / R ] = go Γ (strengthen 1 L) (strengthen 1 R) where go : List (Arg Type) → Maybe Term → Maybe Term → List (Arg Type) go (γ ∷ Γ) (just L) (just R) = (caseF γ of _r[ L / R ]) ∷ go Γ (strengthen 1 L) (strengthen 1 R) go Γ _ _ = Γ
{ "alphanum_fraction": 0.5195729537, "avg_line_length": 38.568627451, "ext": "agda", "hexsha": "8f341a3b2856765eedd7c53478aef2eeb5478440", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Tactic/Reflection/Replace.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Tactic/Reflection/Replace.agda", "max_line_length": 106, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Tactic/Reflection/Replace.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 691, "size": 1967 }
module Numeral.Natural.Relation.Order.Decidable where open import Functional open import Logic.IntroInstances open import Logic.Propositional.Theorems open import Numeral.Natural open import Numeral.Natural.Oper.Comparisons open import Numeral.Natural.Oper.Proofs open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs open import Structure.Function.Domain open import Type.Properties.Decidable instance [≡]-decider : Decider(2)(_≡_)(_≡?_) [≡]-decider {𝟎} {𝟎} = true [≡]-intro [≡]-decider {𝟎} {𝐒 y} = false \() [≡]-decider {𝐒 x}{𝟎} = false \() [≡]-decider {𝐒 x}{𝐒 y} = step{f = id} (true ∘ [≡]-with(𝐒)) (false ∘ contrapositiveᵣ (injective(𝐒))) ([≡]-decider {x}{y}) instance [≤]-decider : Decider(2)(_≤_)(_≤?_) [≤]-decider {𝟎} {𝟎} = true [≤]-minimum [≤]-decider {𝟎} {𝐒 y} = true [≤]-minimum [≤]-decider {𝐒 x} {𝟎} = false \() [≤]-decider {𝐒 x} {𝐒 y} = step{f = id} (true ∘ \p → [≤]-with-[𝐒] ⦃ p ⦄) (false ∘ contrapositiveᵣ [≤]-without-[𝐒]) ([≤]-decider {x}{y}) [<]-decider : Decider(2)(_<_)(_<?_) [<]-decider {𝟎} {𝟎} = false (λ ()) [<]-decider {𝟎} {𝐒 y} = true (succ min) [<]-decider {𝐒 x} {𝟎} = false (λ ()) [<]-decider {𝐒 x} {𝐒 y} = step{f = id} (true ∘ succ) (false ∘ contrapositiveᵣ [≤]-without-[𝐒]) ([<]-decider {x} {y})
{ "alphanum_fraction": 0.6289726534, "avg_line_length": 38.6571428571, "ext": "agda", "hexsha": "84dadb439550be5567f1b183706c0bf244ad5d0a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Natural/Relation/Order/Decidable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Natural/Relation/Order/Decidable.agda", "max_line_length": 136, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Natural/Relation/Order/Decidable.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": 592, "size": 1353 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Numbers.Naturals.Order.WellFounded open import Numbers.Naturals.Order.Lemmas open import Numbers.Integers.Definition open import Numbers.Integers.Integers open import Numbers.Integers.Order open import Groups.Groups open import Groups.Definition open import Rings.Definition open import Rings.Orders.Partial.Definition open import Rings.Orders.Total.Definition open import Fields.Fields open import Numbers.Primes.PrimeNumbers open import Setoids.Setoids open import Functions.Definition open import Sets.EquivalenceRelations open import Numbers.Rationals.Definition open import Semirings.Definition open import Orders.Total.Definition open import Orders.WellFounded.Induction open import Setoids.Orders.Total.Definition module Numbers.Rationals.Lemmas where open import Semirings.Lemmas ℕSemiring open PartiallyOrderedRing ℤPOrderedRing open import Rings.Orders.Total.Lemmas ℤOrderedRing open import Rings.Orders.Total.AbsoluteValue ℤOrderedRing open SetoidTotalOrder (totalOrderToSetoidTotalOrder ℤOrder) evenOrOdd : (a : ℕ) → (Sg ℕ (λ i → i *N 2 ≡ a)) || (Sg ℕ (λ i → succ (i *N 2) ≡ a)) evenOrOdd zero = inl (zero , refl) evenOrOdd (succ zero) = inr (zero , refl) evenOrOdd (succ (succ a)) with evenOrOdd a evenOrOdd (succ (succ a)) | inl (a/2 , even) = inl (succ a/2 , applyEquality (λ i → succ (succ i)) even) evenOrOdd (succ (succ a)) | inr (a/2-1 , odd) = inr (succ a/2-1 , applyEquality (λ i → succ (succ i)) odd) parity : (a b : ℕ) → succ (2 *N a) ≡ 2 *N b → False parity zero (succ b) pr rewrite Semiring.commutative ℕSemiring b (succ (b +N 0)) = bad pr where bad : (1 ≡ succ (succ ((b +N 0) +N b))) → False bad () parity (succ a) (succ b) pr rewrite Semiring.commutative ℕSemiring b (succ (b +N 0)) | Semiring.commutative ℕSemiring a (succ (a +N 0)) | Semiring.commutative ℕSemiring (a +N 0) a | Semiring.commutative ℕSemiring (b +N 0) b = parity a b (succInjective (succInjective pr)) sqrt0 : (p : ℕ) → p *N p ≡ 0 → p ≡ 0 sqrt0 zero pr = refl sqrt0 (succ p) () -- So as to give us something easy to induct down, introduce a silly extra variable evil' : (k : ℕ) → ((a b : ℕ) → (0 <N a) → (pr : k ≡ a +N b) → a *N a ≡ (b *N b) *N 2 → False) evil' = rec <NWellfounded (λ z → (x x₁ : ℕ) (pr' : 0 <N x) (x₂ : z ≡ x +N x₁) (x₃ : x *N x ≡ (x₁ *N x₁) *N 2) → False) go where go : (k : ℕ) (indHyp : (k' : ℕ) (k'<k : k' <N k) (r s : ℕ) (0<r : 0 <N r) (r+s : k' ≡ r +N s) (x₇ : r *N r ≡ (s *N s) *N 2) → False) (a b : ℕ) (0<a : 0 <N a) (a+b : k ≡ a +N b) (pr : a *N a ≡ (b *N b) *N 2) → False go k indHyp a b 0<a a+b pr = contr where open import Semirings.Solver ℕSemiring multiplicationNIsCommutative aEven : Sg ℕ (λ i → i *N 2 ≡ a) aEven with evenOrOdd a aEven | inl x = x aEven | inr (a/2-1 , odd) rewrite equalityCommutative odd = -- Derive a pretty mechanical contradiction using the automatic solver. -- This line looks hellish, but it was almost completely mechanical. exFalso (parity (a/2-1 +N (a/2-1 *N succ (a/2-1 *N 2))) (b *N b) (transitivity ( -- truly mechanical bit starts here from (succ (plus (plus (const a/2-1) (times (const a/2-1) (succ (times (const a/2-1) (succ (succ zero)))))) (plus (plus (const a/2-1) (times (const a/2-1) (succ (times (const a/2-1) (succ (succ zero)))))) (times zero (plus (const a/2-1) (times (const a/2-1) (succ (times (const a/2-1) (succ (succ zero)))))))))) to succ (plus (times (const a/2-1) (succ (succ zero))) (times (times (const a/2-1) (succ (succ zero))) (succ (times (const a/2-1) (succ (succ zero)))))) -- truly mechanical bit ends here by applyEquality (λ i → succ (a/2-1 +N i)) ( -- Grinding out some manipulations transitivity (equalityCommutative (Semiring.+Associative ℕSemiring a/2-1 _ _)) (applyEquality (a/2-1 +N_) (transitivity (Semiring.commutative ℕSemiring (a/2-1 *N (a/2-1 +N a/2-1)) _) (transitivity (equalityCommutative (Semiring.+Associative ℕSemiring a/2-1 _ _)) (applyEquality (a/2-1 +N_) (transitivity (equalityCommutative (Semiring.+Associative ℕSemiring a/2-1 _ _)) (applyEquality (a/2-1 +N_) (transitivity (equalityCommutative (Semiring.+DistributesOver* ℕSemiring a/2-1 _ _)) (applyEquality (a/2-1 *N_) (equalityCommutative (Semiring.+Associative ℕSemiring a/2-1 _ _)))))))))) )) (transitivity pr (multiplicationNIsCommutative (b *N b) 2)))) next : (underlying aEven *N 2) *N (underlying aEven *N 2) ≡ (b *N b) *N 2 next with aEven ... | a/2 , even rewrite even = pr next2 : (underlying aEven *N 2) *N underlying aEven ≡ b *N b next2 = productCancelsRight 2 _ _ (le 1 refl) (transitivity (equalityCommutative (Semiring.*Associative ℕSemiring (underlying aEven *N 2) _ _)) next) next3 : b *N b ≡ (underlying aEven *N underlying aEven) *N 2 next3 = equalityCommutative (transitivity (transitivity (equalityCommutative (Semiring.*Associative ℕSemiring (underlying aEven) _ _)) (multiplicationNIsCommutative (underlying aEven) _)) next2) halveDecreased : underlying aEven <N a halveDecreased with aEven halveDecreased | zero , even rewrite equalityCommutative even = exFalso (TotalOrder.irreflexive ℕTotalOrder 0<a) halveDecreased | succ a/2 , even = le a/2 (transitivity (applyEquality succ (transitivity (Semiring.commutative ℕSemiring a/2 _) (applyEquality succ (transitivity (doubleIsAddTwo a/2) (multiplicationNIsCommutative 2 a/2))))) even) reduced : b +N underlying aEven <N k reduced with lessRespectsAddition b halveDecreased ... | bl rewrite a+b = identityOfIndiscernablesLeft _<N_ bl (Semiring.commutative ℕSemiring _ b) 0<b : 0 <N b 0<b with TotalOrder.totality ℕTotalOrder 0 b 0<b | inl (inl 0<b) = 0<b 0<b | inl (inr ()) 0<b | inr 0=b rewrite equalityCommutative 0=b = exFalso (TotalOrder.irreflexive ℕTotalOrder {0} (identityOfIndiscernablesRight _<N_ 0<a (sqrt0 a pr))) contr : False contr = indHyp (b +N underlying aEven) reduced b (underlying aEven) 0<b refl next3 evil : (a b : ℕ) → (0 <N a) → a *N a ≡ (b *N b) *N 2 → False evil a b 0<a = evil' (a +N b) a b 0<a refl absNonneg : (x : ℕ) → abs (nonneg x) ≡ nonneg x absNonneg x with totality (nonneg 0) (nonneg x) absNonneg x | inl (inl 0<x) = refl absNonneg x | inr 0=x = refl absNegsucc : (x : ℕ) → abs (negSucc x) ≡ nonneg (succ x) absNegsucc x with totality (nonneg 0) (negSucc x) absNegsucc x | inl (inr _) = refl toNats : (numerator denominator : ℤ) → .(denominator ≡ nonneg 0 → False) → (abs numerator) *Z (abs numerator) ≡ ((abs denominator) *Z (abs denominator)) *Z nonneg 2 → Sg (ℕ && ℕ) (λ nats → ((_&&_.fst nats *N _&&_.fst nats) ≡ (_&&_.snd nats *N _&&_.snd nats) *N 2) && (_&&_.snd nats ≡ 0 → False)) toNats (nonneg num) (nonneg 0) pr _ = exFalso (pr refl) toNats (nonneg num) (nonneg (succ denom)) _ pr = (num ,, (succ denom)) , (nonnegInjective (transitivity (transitivity (equalityCommutative (absNonneg (num *N num))) (absRespectsTimes (nonneg num) (nonneg num))) pr) ,, λ ()) toNats (nonneg num) (negSucc denom) _ pr = (num ,, succ denom) , (nonnegInjective (transitivity (transitivity (equalityCommutative (absNonneg (num *N num))) (absRespectsTimes (nonneg num) (nonneg num))) pr) ,, λ ()) toNats (negSucc num) (nonneg (succ denom)) _ pr = (succ num ,, succ denom) , (nonnegInjective pr ,, λ ()) toNats (negSucc num) (negSucc denom) _ pr = (succ num ,, succ denom) , (nonnegInjective pr ,, λ ()) sqrt2Irrational : (a : ℚ) → (a *Q a) =Q (injectionQ (nonneg 2)) → False sqrt2Irrational (record { num = numerator ; denom = denominator ; denomNonzero = denom!=0 }) pr = bad where -- We have in hand `pr`, which is the following (almost by definition): pr' : (numerator *Z numerator) ≡ (denominator *Z denominator) *Z nonneg 2 pr' = transitivity (equalityCommutative (transitivity (Ring.*Commutative ℤRing) (Ring.identIsIdent ℤRing))) pr -- Move into the naturals so that we can do nice divisibility things. lemma1 : abs ((denominator *Z denominator) *Z nonneg 2) ≡ (abs denominator *Z abs denominator) *Z nonneg 2 lemma1 = transitivity (absRespectsTimes (denominator *Z denominator) (nonneg 2)) (applyEquality (_*Z nonneg 2) (absRespectsTimes denominator denominator)) amenableToNaturals : (abs numerator) *Z (abs numerator) ≡ ((abs denominator) *Z (abs denominator)) *Z nonneg 2 amenableToNaturals = transitivity (equalityCommutative (absRespectsTimes numerator numerator)) (transitivity (applyEquality abs pr') lemma1) naturalsStatement : Sg (ℕ && ℕ) (λ nats → ((_&&_.fst nats *N _&&_.fst nats) ≡ (_&&_.snd nats *N _&&_.snd nats) *N 2) && (_&&_.snd nats ≡ 0 → False)) naturalsStatement = toNats numerator denominator denom!=0 amenableToNaturals bad : False bad with naturalsStatement bad | (num ,, 0) , (pr1 ,, pr2) = exFalso (pr2 refl) bad | (num ,, succ denom) , (pr1 ,, pr2) = evil num (succ denom) 0<num pr1 where 0<num : 0 <N num 0<num with TotalOrder.totality ℕTotalOrder 0 num 0<num | inl (inl 0<num) = 0<num 0<num | inr 0=num rewrite equalityCommutative 0=num = exFalso (naughtE pr1)
{ "alphanum_fraction": 0.6646814846, "avg_line_length": 62.6866666667, "ext": "agda", "hexsha": "cb2c43edbf53a1d31ee371a030fefb8b7d1a5f7e", "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": "Numbers/Rationals/Lemmas.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Numbers/Rationals/Lemmas.agda", "max_line_length": 596, "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": "Numbers/Rationals/Lemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 3225, "size": 9403 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.DStructures.Equivalences.PeifferGraphS2G where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Function open import Cubical.Foundations.Structure open import Cubical.Functions.FunExtEquiv open import Cubical.Homotopy.Base open import Cubical.Data.Sigma open import Cubical.Data.Unit open import Cubical.Relation.Binary open import Cubical.Structures.Subtype open import Cubical.Algebra.Group open import Cubical.Structures.LeftAction open import Cubical.Algebra.Group.Semidirect open import Cubical.DStructures.Base open import Cubical.DStructures.Meta.Properties open import Cubical.DStructures.Meta.Isomorphism open import Cubical.DStructures.Structures.Constant open import Cubical.DStructures.Structures.Type open import Cubical.DStructures.Structures.Group open import Cubical.DStructures.Structures.Action open import Cubical.DStructures.Structures.XModule open import Cubical.DStructures.Structures.ReflGraph open import Cubical.DStructures.Structures.VertComp open import Cubical.DStructures.Structures.PeifferGraph open import Cubical.DStructures.Structures.Strict2Group open import Cubical.DStructures.Equivalences.GroupSplitEpiAction open import Cubical.DStructures.Equivalences.PreXModReflGraph private variable ℓ ℓ' ℓ'' ℓ₁ ℓ₁' ℓ₁'' ℓ₂ ℓA ℓA' ℓ≅A ℓ≅A' ℓB ℓB' ℓ≅B ℓC ℓ≅C ℓ≅ᴰ ℓ≅ᴰ' ℓ≅B' : Level open Kernel open GroupHom -- such .fun! open GroupLemmas open MorphismLemmas open ActionLemmas module _ (ℓ ℓ' : Level) where ℓℓ' = ℓ-max ℓ ℓ' 𝒮ᴰ-♭PIso-PeifferGraph-Strict2Group : 𝒮ᴰ-♭PIso (idfun (ReflGraph ℓ ℓℓ')) (𝒮ᴰ-ReflGraph\Peiffer ℓ ℓℓ') (𝒮ᴰ-Strict2Group ℓ ℓℓ') RelIso.fun (𝒮ᴰ-♭PIso-PeifferGraph-Strict2Group 𝒢) isPeifferGraph = 𝒱 where open ReflGraphNotation 𝒢 open ReflGraphLemmas 𝒢 open VertComp _⊙_ = λ (g f : ⟨ G₁ ⟩) → (g -₁ (𝒾s g)) +₁ f 𝒱 : VertComp 𝒢 vcomp 𝒱 g f _ = g ⊙ f σ-∘ 𝒱 g f c = r where isg = 𝒾s g abstract r = s ((g -₁ isg) +₁ f) ≡⟨ (σ .isHom (g -₁ isg) f) ⟩ s (g -₁ isg) +₀ s f ≡⟨ cong (_+₀ s f) (σ-g--isg g) ⟩ 0₀ +₀ s f ≡⟨ lId₀ (s f) ⟩ s f ∎ τ-∘ 𝒱 g f c = r where isg = 𝒾s g -isg = -₁ (𝒾s g) abstract r = t ((g -₁ isg) +₁ f) ≡⟨ τ .isHom (g -₁ isg) f ⟩ t (g -₁ isg) +₀ t f ≡⟨ cong (_+₀ t f) (τ .isHom g (-₁ isg)) ⟩ (t g +₀ t -isg) +₀ t f ≡⟨ cong ((t g +₀ t -isg) +₀_) (sym c) ⟩ (t g +₀ t -isg) +₀ s g ≡⟨ cong (λ z → (t g +₀ z) +₀ s g) (mapInv τ isg) ⟩ (t g -₀ (t isg)) +₀ s g ≡⟨ cong (λ z → (t g -₀ z) +₀ s g) (τι-≡-fun (s g)) ⟩ (t g -₀ (s g)) +₀ s g ≡⟨ (sym (assoc₀ (t g) (-₀ s g) (s g))) ∙ (cong (t g +₀_) (lCancel₀ (s g))) ⟩ t g +₀ 0₀ ≡⟨ rId₀ (t g) ⟩ t g ∎ isHom-∘ 𝒱 g f c-gf g' f' _ _ = r where isg = 𝒾s g -isg = -₁ (𝒾s g) isg' = 𝒾s g' -isg' = -₁ (𝒾s g') itf = 𝒾t f -itf = -₁ (𝒾t f) abstract r = (g +₁ g') ⊙ (f +₁ f') ≡⟨ assoc₁ ((g +₁ g') -₁ 𝒾s (g +₁ g')) f f' ⟩ (((g +₁ g') -₁ 𝒾s (g +₁ g')) +₁ f) +₁ f' ≡⟨ cong (λ z → (z +₁ f) +₁ f') (sym (assoc₁ g g' (-₁ (𝒾s (g +₁ g'))))) ⟩ ((g +₁ (g' -₁ (𝒾s (g +₁ g')))) +₁ f) +₁ f' ≡⟨ cong (_+₁ f') (sym (assoc₁ g (g' -₁ (𝒾s (g +₁ g'))) f)) ⟩ (g +₁ ((g' -₁ (𝒾s (g +₁ g'))) +₁ f)) +₁ f' ≡⟨ cong (λ z → (g +₁ z) +₁ f') ((g' -₁ (𝒾s (g +₁ g'))) +₁ f ≡⟨ cong (λ z → (g' -₁ z) +₁ f) (ι∘σ .isHom g g') ⟩ (g' -₁ (isg +₁ isg')) +₁ f ≡⟨ cong (λ z → (g' +₁ z) +₁ f) (invDistr G₁ isg isg') ⟩ (g' +₁ (-isg' +₁ -isg)) +₁ f ≡⟨ assoc-c--r- G₁ g' -isg' -isg f ⟩ g' +₁ (-isg' +₁ (-isg +₁ f)) ≡⟨ cong (λ z → g' +₁ (-isg' +₁ ((-₁ (𝒾 z)) +₁ f))) c-gf ⟩ g' +₁ (-isg' +₁ (-itf +₁ f)) ≡⟨ isPeifferGraph4 𝒢 isPeifferGraph f g' ⟩ -itf +₁ (f +₁ (g' +₁ -isg')) ≡⟨ cong (λ z → (-₁ (𝒾 z)) +₁ (f +₁ (g' +₁ -isg'))) (sym c-gf) ⟩ -isg +₁ (f +₁ (g' +₁ -isg')) ∎) ⟩ (g +₁ (-isg +₁ (f +₁ (g' +₁ -isg')))) +₁ f' ≡⟨ cong (_+₁ f') (assoc₁ g -isg (f +₁ (g' -₁ isg'))) ⟩ ((g +₁ -isg) +₁ (f +₁ (g' +₁ -isg'))) +₁ f' ≡⟨ cong (_+₁ f') (assoc₁ (g -₁ isg) f (g' -₁ isg')) ⟩ (((g -₁ isg) +₁ f) +₁ (g' -₁ isg')) +₁ f' ≡⟨ sym (assoc₁ ((g -₁ isg) +₁ f) (g' -₁ isg') f') ⟩ ((g -₁ isg) +₁ f) +₁ ((g' -₁ isg') +₁ f') ≡⟨ refl ⟩ (g ⊙ f) +₁ (g' ⊙ f') ∎ -- behold! use of symmetry is lurking around the corner -- (in stark contrast to composability proofs) assoc-∘ 𝒱 h g f _ _ _ _ = sym r where isg = 𝒾s g ish = 𝒾s h -ish = -₁ 𝒾s h abstract r = (h ⊙ g) ⊙ f ≡⟨ cong (λ z → (((h -₁ ish) +₁ g) -₁ z) +₁ f) (ι∘σ .isHom (h -₁ ish) g) ⟩ (((h -₁ ish) +₁ g) -₁ (𝒾s (h -₁ ish) +₁ 𝒾s g)) +₁ f ≡⟨ cong (λ z → (((h -₁ ish) +₁ g) -₁ (z +₁ 𝒾s g)) +₁ f) (ι∘σ .isHom h (-₁ ish)) ⟩ (((h -₁ ish) +₁ g) -₁ ((𝒾s h +₁ (𝒾s -ish)) +₁ 𝒾s g)) +₁ f ≡⟨ cong (λ z → (((h -₁ ish) +₁ g) -₁ ((𝒾s h +₁ z) +₁ 𝒾s g)) +₁ f) (ισ-ι (s h)) ⟩ (((h -₁ ish) +₁ g) -₁ ((ish -₁ ish) +₁ isg)) +₁ f ≡⟨ cong (λ z → (((h -₁ ish) +₁ g) -₁ z) +₁ f) (rCancel-lId G₁ ish isg) ⟩ (((h -₁ ish) +₁ g) -₁ isg) +₁ f ≡⟨ (cong (_+₁ f) (sym (assoc₁ (h -₁ ish) g (-₁ isg)))) ∙ (sym (assoc₁ (h -₁ ish) (g -₁ isg) f)) ⟩ h ⊙ (g ⊙ f) ∎ lid-∘ 𝒱 f _ = r where itf = 𝒾t f abstract r = itf ⊙ f ≡⟨ cong (λ z → (itf -₁ (𝒾 z)) +₁ f) (σι-≡-fun (t f)) ⟩ (itf -₁ itf) +₁ f ≡⟨ rCancel-lId G₁ itf f ⟩ f ∎ rid-∘ 𝒱 g _ = r where isg = 𝒾s g -isg = -₁ (𝒾s g) abstract r = g ⊙ isg ≡⟨ sym (assoc₁ g -isg isg) ⟩ g +₁ (-isg +₁ isg) ≡⟨ lCancel-rId G₁ g isg ⟩ g ∎ RelIso.inv (𝒮ᴰ-♭PIso-PeifferGraph-Strict2Group 𝒢) 𝒞 = isPf where open ReflGraphNotation 𝒢 open VertComp 𝒞 abstract isPf : isPeifferGraph 𝒢 isPf f g = ((isg +₁ (f -₁ itf)) +₁ (-isg +₁ g)) +₁ itf ≡⟨ cong (_+₁ itf) (sym (assoc₁ isg (f -₁ itf) (-isg +₁ g))) ⟩ (isg +₁ ((f -₁ itf) +₁ (-isg +₁ g))) +₁ itf ≡⟨ cong (λ z → (isg +₁ z) +₁ itf) (sym (assoc₁ f -itf (-isg +₁ g))) ⟩ (isg +₁ (f +₁ (-itf +₁ (-isg +₁ g)))) +₁ itf ≡⟨ cong (λ z → (isg +₁ (f +₁ z)) +₁ itf) (assoc₁ -itf -isg g) ⟩ (isg +₁ (f +₁ ((-itf -₁ isg) +₁ g))) +₁ itf ≡⟨ cong (λ z → (isg +₁ z) +₁ itf) (IC5 𝒞 g f) ⟩ (isg +₁ ((-isg +₁ g) +₁ (f -₁ itf))) +₁ itf ≡⟨ cong (_+₁ itf) (assoc₁ isg (-isg +₁ g) (f -₁ itf)) ⟩ ((isg +₁ (-isg +₁ g)) +₁ (f -₁ itf)) +₁ itf ≡⟨ cong (λ z → (z +₁ (f -₁ itf)) +₁ itf) (assoc₁ isg -isg g ∙ rCancel-lId G₁ isg g) ⟩ (g +₁ (f -₁ itf)) +₁ itf ≡⟨ sym (assoc₁ g (f -₁ itf) itf) ⟩ g +₁ ((f -₁ itf) +₁ itf) ≡⟨ cong (g +₁_) ((sym (assoc₁ _ _ _)) ∙ (lCancel-rId G₁ f itf)) ⟩ g +₁ f ∎ where isg = 𝒾s g -isg = -₁ (𝒾s g) itf = 𝒾t f -itf = -it f RelIso.leftInv (𝒮ᴰ-♭PIso-PeifferGraph-Strict2Group _) _ = tt RelIso.rightInv (𝒮ᴰ-♭PIso-PeifferGraph-Strict2Group _) _ = tt Iso-PeifferGraph-Strict2Group : Iso (PeifferGraph ℓ ℓℓ') (Strict2Group ℓ ℓℓ') Iso-PeifferGraph-Strict2Group = 𝒮ᴰ-♭PIso-Over→TotalIso idIso (𝒮ᴰ-ReflGraph\Peiffer ℓ ℓℓ') (𝒮ᴰ-Strict2Group ℓ ℓℓ') 𝒮ᴰ-♭PIso-PeifferGraph-Strict2Group open import Cubical.DStructures.Equivalences.XModPeifferGraph Iso-XModule-Strict2Group : Iso (XModule ℓ ℓℓ') (Strict2Group ℓ ℓℓ') Iso-XModule-Strict2Group = compIso (Iso-XModule-PeifferGraph ℓ ℓℓ') Iso-PeifferGraph-Strict2Group
{ "alphanum_fraction": 0.4261882279, "avg_line_length": 40.0462184874, "ext": "agda", "hexsha": "f3f08f6b0739a9d8f1583d2f051c0756962de629", "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/DStructures/Equivalences/PeifferGraphS2G.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/DStructures/Equivalences/PeifferGraphS2G.agda", "max_line_length": 150, "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/DStructures/Equivalences/PeifferGraphS2G.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3748, "size": 9531 }
------------------------------------------------------------------------------ -- Arithmetic properties (added for the Collatz function example) ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.Collatz.Data.Nat.PropertiesATP where open import FOTC.Base open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Inequalities.PropertiesATP using ( x≤x ; 2*SSx≥2 ) open import FOTC.Data.Nat.PropertiesATP using ( *-N ; *-rightZero ; *-rightIdentity ; x∸x≡0 ; +-rightIdentity ; +-comm ; +-N ; xy≡0→x≡0∨y≡0 ; Sx≢x ; xy≡1→x≡1 ; 0∸x ; S∸S ) open import FOTC.Data.Nat.UnaryNumbers open import FOTC.Program.Collatz.Data.Nat ------------------------------------------------------------------------------ ^-N : ∀ {m n} → N m → N n → N (m ^ n) ^-N {m} Nm nzero = prf where postulate prf : N (m ^ zero) {-# ATP prove prf #-} ^-N {m} Nm (nsucc {n} Nn) = prf (^-N Nm Nn) where postulate prf : N (m ^ n) → N (m ^ succ₁ n) {-# ATP prove prf *-N #-} div-2x-2≡x : ∀ {n} → N n → div (2' * n) 2' ≡ n div-2x-2≡x nzero = prf where postulate prf : div (2' * zero) 2' ≡ zero {-# ATP prove prf *-rightZero #-} div-2x-2≡x (nsucc nzero) = prf where postulate prf : div (2' * (succ₁ zero)) 2' ≡ succ₁ zero {-# ATP prove prf *-rightIdentity x≤x x∸x≡0 #-} div-2x-2≡x (nsucc (nsucc {n} Nn)) = prf (div-2x-2≡x (nsucc Nn)) where postulate prf : div (2' * succ₁ n) 2' ≡ succ₁ n → div (2' * (succ₁ (succ₁ n))) 2' ≡ succ₁ (succ₁ n) {-# ATP prove prf 2*SSx≥2 +-rightIdentity +-comm +-N #-} postulate div-2^[x+1]-2≡2^x : ∀ {n} → N n → div (2' ^ succ₁ n) 2' ≡ 2' ^ n {-# ATP prove div-2^[x+1]-2≡2^x ^-N div-2x-2≡x #-} +∸2 : ∀ {n} → N n → n ≢ zero → n ≢ 1' → n ≡ succ₁ (succ₁ (n ∸ 2')) +∸2 nzero n≢0 n≢1 = ⊥-elim (n≢0 refl) +∸2 (nsucc nzero) n≢0 n≢1 = ⊥-elim (n≢1 refl) +∸2 (nsucc (nsucc {n} Nn)) n≢0 n≢1 = prf where -- TODO (06 December 2012). We do not use the ATPs because we do not -- how to erase a term. -- -- See the interactive proof. postulate prf : succ₁ (succ₁ n) ≡ succ₁ (succ₁ (succ₁ (succ₁ n) ∸ 2')) -- {-# ATP prove prf S∸S #-} 2^x≢0 : ∀ {n} → N n → 2' ^ n ≢ zero 2^x≢0 nzero h = ⊥-elim (0≢S (trans (sym h) (^-0 2'))) 2^x≢0 (nsucc {n} Nn) h = prf (2^x≢0 Nn) where postulate prf : 2' ^ n ≢ zero → ⊥ {-# ATP prove prf xy≡0→x≡0∨y≡0 ^-N #-} postulate 2^[x+1]≢1 : ∀ {n} → N n → 2' ^ succ₁ n ≢ 1' {-# ATP prove 2^[x+1]≢1 Sx≢x xy≡1→x≡1 ^-N #-} Sx-Even→x-Odd : ∀ {n} → N n → Even (succ₁ n) → Odd n Sx-Even→x-Odd nzero h = ⊥-elim prf where postulate prf : ⊥ {-# ATP prove prf #-} Sx-Even→x-Odd (nsucc {n} Nn) h = prf where postulate prf : odd (succ₁ n) ≡ true {-# ATP prove prf #-} Sx-Odd→x-Even : ∀ {n} → N n → Odd (succ₁ n) → Even n Sx-Odd→x-Even nzero _ = even-0 Sx-Odd→x-Even (nsucc {n} Nn) h = trans (sym (odd-S (succ₁ n))) h postulate 2-Even : Even 2' {-# ATP prove 2-Even #-} ∸-Even : ∀ {m n} → N m → N n → Even m → Even n → Even (m ∸ n) ∸-Odd : ∀ {m n} → N m → N n → Odd m → Odd n → Even (m ∸ n) ∸-Even {m} Nm nzero h₁ _ = subst Even (sym (∸-x0 m)) h₁ ∸-Even nzero (nsucc {n} Nn) h₁ _ = subst Even (sym (0∸x (nsucc Nn))) h₁ ∸-Even (nsucc {m} Nm) (nsucc {n} Nn) h₁ h₂ = prf where postulate prf : Even (succ₁ m ∸ succ₁ n) {-# ATP prove prf ∸-Odd Sx-Even→x-Odd S∸S #-} ∸-Odd nzero Nn h₁ _ = ⊥-elim (t≢f (trans (sym h₁) odd-0)) ∸-Odd (nsucc Nm) nzero _ h₂ = ⊥-elim (t≢f (trans (sym h₂) odd-0)) ∸-Odd (nsucc {m} Nm) (nsucc {n} Nn) h₁ h₂ = prf where postulate prf : Even (succ₁ m ∸ succ₁ n) {-# ATP prove prf ∸-Even Sx-Odd→x-Even S∸S #-} x-Even→SSx-Even : ∀ {n} → N n → Even n → Even (succ₁ (succ₁ n)) x-Even→SSx-Even nzero h = prf where postulate prf : Even (succ₁ (succ₁ zero)) {-# ATP prove prf #-} x-Even→SSx-Even (nsucc {n} Nn) h = prf where postulate prf : Even (succ₁ (succ₁ (succ₁ n))) {-# ATP prove prf #-} x+x-Even : ∀ {n} → N n → Even (n + n) x+x-Even nzero = prf where postulate prf : even (zero + zero) ≡ true {-# ATP prove prf #-} x+x-Even (nsucc {n} Nn) = prf (x+x-Even Nn) where postulate prf : Even (n + n) → Even (succ₁ n + succ₁ n) {-# ATP prove prf x-Even→SSx-Even +-N +-comm #-} 2x-Even : ∀ {n} → N n → Even (2' * n) 2x-Even nzero = prf where postulate prf : Even (2' * zero) {-# ATP prove prf #-} 2x-Even (nsucc {n} Nn) = prf where postulate prf : Even (2' * succ₁ n) {-# ATP prove prf x-Even→SSx-Even x+x-Even +-N +-comm +-rightIdentity #-} postulate 2^[x+1]-Even : ∀ {n} → N n → Even (2' ^ succ₁ n) {-# ATP prove 2^[x+1]-Even ^-N 2x-Even #-}
{ "alphanum_fraction": 0.49970244, "avg_line_length": 36.0071428571, "ext": "agda", "hexsha": "e59ef4c782b8ba4630a2400979a27c16e89b8aa4", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Program/Collatz/Data/Nat/PropertiesATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Program/Collatz/Data/Nat/PropertiesATP.agda", "max_line_length": 85, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Program/Collatz/Data/Nat/PropertiesATP.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 2089, "size": 5041 }
module OlderBasicILP.Direct.Translation where open import Common.Context public -- import OlderBasicILP.Direct.Hilbert.Sequential as HS import OlderBasicILP.Direct.Hilbert.Nested as HN import OlderBasicILP.Direct.Gentzen as G -- open HS using () renaming (_⊢×_ to HS⟨_⊢×_⟩ ; _⊢_ to HS⟨_⊢_⟩) public open HN using () renaming (_⊢_ to HN⟨_⊢_⟩ ; _⊢⋆_ to HN⟨_⊢⋆_⟩) public open G using () renaming (_⊢_ to G⟨_⊢_⟩ ; _⊢⋆_ to G⟨_⊢⋆_⟩) public -- Translation from sequential Hilbert-style to nested. -- hs→hn : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → HN⟨ Γ ⊢ A ⟩ -- hs→hn = ? -- Translation from nested Hilbert-style to sequential. -- hn→hs : ∀ {A Γ} → HN⟨ Γ ⊢ A ⟩ → HS⟨ Γ ⊢ A ⟩ -- hn→hs = ? -- Deduction theorem for sequential Hilbert-style. -- hs-lam : ∀ {A B Γ} → HS⟨ Γ , A ⊢ B ⟩ → HS⟨ Γ ⊢ A ▻ B ⟩ -- hs-lam = hn→hs ∘ HN.lam ∘ hs→hn -- Translation from Hilbert-style to Gentzen-style. mutual hn→gᵇᵒˣ : HN.Box → G.Box hn→gᵇᵒˣ HN.[ t ] = {!G.[ hn→g t ]!} hn→gᵀ : HN.Ty → G.Ty hn→gᵀ (HN.α P) = G.α P hn→gᵀ (A HN.▻ B) = hn→gᵀ A G.▻ hn→gᵀ B hn→gᵀ (T HN.⦂ A) = hn→gᵇᵒˣ T G.⦂ hn→gᵀ A hn→gᵀ (A HN.∧ B) = hn→gᵀ A G.∧ hn→gᵀ B hn→gᵀ HN.⊤ = G.⊤ hn→gᵀ⋆ : Cx HN.Ty → Cx G.Ty hn→gᵀ⋆ ∅ = ∅ hn→gᵀ⋆ (Γ , A) = hn→gᵀ⋆ Γ , hn→gᵀ A hn→gⁱ : ∀ {A Γ} → A ∈ Γ → hn→gᵀ A ∈ hn→gᵀ⋆ Γ hn→gⁱ top = top hn→gⁱ (pop i) = pop (hn→gⁱ i) hn→g : ∀ {A Γ} → HN⟨ Γ ⊢ A ⟩ → G⟨ hn→gᵀ⋆ Γ ⊢ hn→gᵀ A ⟩ hn→g (HN.var i) = G.var (hn→gⁱ i) hn→g (HN.app t u) = G.app (hn→g t) (hn→g u) hn→g HN.ci = G.ci hn→g HN.ck = G.ck hn→g HN.cs = G.cs hn→g (HN.box t) = {!G.box (hn→g t)!} hn→g HN.cdist = {!G.cdist!} hn→g HN.cup = {!G.cup!} hn→g HN.cdown = G.cdown hn→g HN.cpair = G.cpair hn→g HN.cfst = G.cfst hn→g HN.csnd = G.csnd hn→g HN.unit = G.unit -- hs→g : ∀ {A Γ} → HS⟨ Γ ⊢ A ⟩ → G⟨ Γ ⊢ A ⟩ -- hs→g = hn→g ∘ hs→hn -- Translation from Gentzen-style to Hilbert-style. mutual g→hnᵇᵒˣ : G.Box → HN.Box g→hnᵇᵒˣ G.[ t ] = {!HN.[ g→hn t ]!} g→hnᵀ : G.Ty → HN.Ty g→hnᵀ (G.α P) = HN.α P g→hnᵀ (A G.▻ B) = g→hnᵀ A HN.▻ g→hnᵀ B g→hnᵀ (T G.⦂ A) = g→hnᵇᵒˣ T HN.⦂ g→hnᵀ A g→hnᵀ (A G.∧ B) = g→hnᵀ A HN.∧ g→hnᵀ B g→hnᵀ G.⊤ = HN.⊤ g→hnᵀ⋆ : Cx G.Ty → Cx HN.Ty g→hnᵀ⋆ ∅ = ∅ g→hnᵀ⋆ (Γ , A) = g→hnᵀ⋆ Γ , g→hnᵀ A g→hnⁱ : ∀ {A Γ} → A ∈ Γ → g→hnᵀ A ∈ g→hnᵀ⋆ Γ g→hnⁱ top = top g→hnⁱ (pop i) = pop (g→hnⁱ i) g→hn : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → HN⟨ g→hnᵀ⋆ Γ ⊢ g→hnᵀ A ⟩ g→hn (G.var i) = HN.var (g→hnⁱ i) g→hn (G.lam t) = HN.lam (g→hn t) g→hn (G.app t u) = HN.app (g→hn t) (g→hn u) -- g→hn (G.multibox ts u) = {!HN.multibox (g→hn⋆ ts) (g→hn u)!} g→hn (G.down t) = HN.down (g→hn t) g→hn (G.pair t u) = HN.pair (g→hn t) (g→hn u) g→hn (G.fst t) = HN.fst (g→hn t) g→hn (G.snd t) = HN.snd (g→hn t) g→hn G.unit = HN.unit g→hn⋆ : ∀ {Ξ Γ} → G⟨ Γ ⊢⋆ Ξ ⟩ → HN⟨ g→hnᵀ⋆ Γ ⊢⋆ g→hnᵀ⋆ Ξ ⟩ g→hn⋆ {∅} ∙ = ∙ g→hn⋆ {Ξ , A} (ts , t) = g→hn⋆ ts , g→hn t -- g→hs : ∀ {A Γ} → G⟨ Γ ⊢ A ⟩ → HS⟨ Γ ⊢ A ⟩ -- g→hs = hn→hs ∘ g→hn
{ "alphanum_fraction": 0.484309285, "avg_line_length": 28.1, "ext": "agda", "hexsha": "18edd7f3f8de07c4efdcd52c84f3356c105cfafa", "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": "OlderBasicILP/Direct/Translation.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": "OlderBasicILP/Direct/Translation.agda", "max_line_length": 71, "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": "OlderBasicILP/Direct/Translation.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": 1821, "size": 3091 }
module Oscar.Class.Semifunctor where open import Oscar.Class.Semigroup open import Oscar.Class.Extensionality open import Oscar.Class.Preservativity open import Oscar.Function open import Oscar.Level open import Oscar.Relation record Semifunctor {𝔞₁} {𝔄₁ : Set 𝔞₁} {𝔰₁} {_►₁_ : 𝔄₁ → 𝔄₁ → Set 𝔰₁} (_◅₁_ : ∀ {m n} → m ►₁ n → ∀ {l} → m ⟨ l ►₁_ ⟩→ n) {ℓ₁} (_≋₁_ : ∀ {m n} → m ►₁ n → m ►₁ n → Set ℓ₁) {𝔞₂} {𝔄₂ : Set 𝔞₂} {𝔰₂} {_►₂_ : 𝔄₂ → 𝔄₂ → Set 𝔰₂} (_◅₂_ : ∀ {m n} → m ►₂ n → ∀ {l} → m ⟨ l ►₂_ ⟩→ n) {ℓ₂} (_≋₂_ : ∀ {m n} → m ►₂ n → m ►₂ n → Set ℓ₂) (μ : 𝔄₁ → 𝔄₂) (□ : ∀ {m n} → m ►₁ n → μ m ►₂ μ n) : Set (𝔞₁ ⊔ 𝔰₁ ⊔ ℓ₁ ⊔ 𝔞₂ ⊔ 𝔰₂ ⊔ ℓ₂) where field ⦃ ′semigroup₁ ⦄ : Semigroup _◅₁_ _≋₁_ ⦃ ′semigroup₂ ⦄ : Semigroup _◅₂_ _≋₂_ ⦃ ′extensionality ⦄ : ∀ {m n} → Extensionality (_≋₁_ {m} {n}) (λ ⋆ → _≋₂_ {μ m} {μ n} ⋆) □ □ ⦃ ′preservativity ⦄ : ∀ {l m n} → Preservativity (λ ⋆ → _◅₁_ {m = m} {n = n} ⋆ {l = l}) (λ ⋆ → _◅₂_ ⋆) _≋₂_ □ □ □ instance Semifunctor⋆ : ∀ {𝔞₁} {𝔄₁ : Set 𝔞₁} {𝔰₁} {_►₁_ : 𝔄₁ → 𝔄₁ → Set 𝔰₁} {_◅₁_ : ∀ {m n} → m ►₁ n → ∀ {l} → m ⟨ l ►₁_ ⟩→ n} {ℓ₁} {_≋₁_ : ∀ {m n} → m ►₁ n → m ►₁ n → Set ℓ₁} {𝔞₂} {𝔄₂ : Set 𝔞₂} {𝔰₂} {_►₂_ : 𝔄₂ → 𝔄₂ → Set 𝔰₂} {_◅₂_ : ∀ {m n} → m ►₂ n → ∀ {l} → m ⟨ l ►₂_ ⟩→ n} {ℓ₂} {_≋₂_ : ∀ {m n} → m ►₂ n → m ►₂ n → Set ℓ₂} {μ : 𝔄₁ → 𝔄₂} {□ : ∀ {m n} → m ►₁ n → μ m ►₂ μ n} ⦃ _ : Semigroup _◅₁_ _≋₁_ ⦄ ⦃ _ : Semigroup _◅₂_ _≋₂_ ⦄ ⦃ _ : ∀ {m n} → Extensionality (_≋₁_ {m} {n}) (λ ⋆ → _≋₂_ {μ m} {μ n} ⋆) □ □ ⦄ ⦃ _ : ∀ {l m n} → Preservativity (λ ⋆ → _◅₁_ {m = m} {n = n} ⋆ {l = l}) (λ ⋆ → _◅₂_ ⋆) _≋₂_ □ □ □ ⦄ → Semifunctor _◅₁_ _≋₁_ _◅₂_ _≋₂_ μ □ Semifunctor.′semigroup₁ Semifunctor⋆ = it Semifunctor.′semigroup₂ Semifunctor⋆ = it Semifunctor.′extensionality Semifunctor⋆ = it Semifunctor.′preservativity Semifunctor⋆ = it -- record Semifunctor' -- {𝔞} {𝔄 : Set 𝔞} {𝔰} {_►_ : 𝔄 → 𝔄 → Set 𝔰} -- (_◅_ : ∀ {m n} → m ► n → ∀ {l} → m ⟨ l ►_ ⟩→ n) -- {ℓ₁} -- (_≋₁_ : ∀ {m n} → m ► n → m ► n → Set ℓ₁) -- {𝔱} {▸ : 𝔄 → Set 𝔱} -- (_◃_ : ∀ {m n} → m ► n → m ⟨ ▸ ⟩→ n) -- {ℓ₂} -- (_≋₂_ : ∀ {n} → ▸ n → ▸ n → Set ℓ₂) -- (□ : ∀ {m n} → m ► n → m ► n) -- : Set (𝔞 ⊔ 𝔰 ⊔ ℓ₁ ⊔ 𝔱 ⊔ ℓ₂) where -- field -- ⦃ ′semigroup₁ ⦄ : Semigroup _◅_ (λ ⋆ → _◅_ ⋆) _≋₁_ -- ⦃ ′semigroup₂ ⦄ : Semigroup _◅_ _◃_ _≋₂_ -- ⦃ ′extensionality ⦄ : ∀ {m} {t : ▸ m} {n} → Extensionality (_≋₁_ {m} {n}) (λ ⋆ → _≋₂_ {n} ⋆) (_◃ t) (_◃ t) -- ⦃ ′preservativity ⦄ : Preservativity _►₁_ _◃₁_ _►₂_ _◃₂_ _≋₂_ ◽ □ -- record Semifunctor -- {𝔞₁} {𝔄₁ : Set 𝔞₁} {𝔰₁} {_►₁_ : 𝔄₁ → 𝔄₁ → Set 𝔰₁} -- (_◅₁_ : ∀ {m n} → m ►₁ n → ∀ {l} → m ⟨ l ►₁_ ⟩→ n) -- {𝔱₁} {▸₁ : 𝔄₁ → Set 𝔱₁} -- (_◃₁_ : ∀ {m n} → m ►₁ n → m ⟨ ▸₁ ⟩→ n) -- {ℓ₁} -- (_≋₁_ : ∀ {n} → ▸₁ n → ▸₁ n → Set ℓ₁) -- {𝔞₂} {𝔄₂ : Set 𝔞₂} {𝔰₂} {_►₂_ : 𝔄₂ → 𝔄₂ → Set 𝔰₂} -- (_◅₂_ : ∀ {m n} → m ►₂ n → ∀ {l} → m ⟨ l ►₂_ ⟩→ n) -- {𝔱₂} {▸₂ : 𝔄₂ → Set 𝔱₂} -- (_◃₂_ : ∀ {m n} → m ►₂ n → m ⟨ ▸₂ ⟩→ n) -- {ℓ₂} -- (_≋₂_ : ∀ {n} → ▸₂ n → ▸₂ n → Set ℓ₂) -- (μ : 𝔄₁ → 𝔄₂) -- (◽ : ∀ {n} → ▸₁ n → ▸₂ (μ n)) -- (□ : ∀ {m n} → m ►₁ n → μ m ►₂ μ n) -- : Set (𝔞₁ ⊔ 𝔰₁ ⊔ 𝔱₁ ⊔ ℓ₁ ⊔ 𝔞₂ ⊔ 𝔰₂ ⊔ 𝔱₂ ⊔ ℓ₂) where -- field -- ⦃ ′semigroup₁ ⦄ : Semigroup _◅₁_ _◃₁_ _≋₁_ -- ⦃ ′semigroup₂ ⦄ : Semigroup _◅₂_ _◃₂_ _≋₂_ -- ⦃ ′extensionality ⦄ : ∀ {n} → Extensionality (_≋₁_ {n}) (λ ⋆ → _≋₂_ {μ n} ⋆) ◽ ◽ -- ⦃ ′preservativity ⦄ : Preservativity _►₁_ _◃₁_ _►₂_ _◃₂_ _≋₂_ ◽ □ -- open Semifunctor ⦃ … ⦄ public hiding (′semigroup₁; ′semigroup₂; ′extensionality; ′preservativity) -- instance -- Semifunctor⋆ : ∀ -- {𝔞₁} {𝔄₁ : Set 𝔞₁} {𝔰₁} {_►₁_ : 𝔄₁ → 𝔄₁ → Set 𝔰₁} -- {_◅₁_ : ∀ {m n} → m ►₁ n → ∀ {l} → m ⟨ l ►₁_ ⟩→ n} -- {𝔱₁} {▸₁ : 𝔄₁ → Set 𝔱₁} -- {_◃₁_ : ∀ {m n} → m ►₁ n → m ⟨ ▸₁ ⟩→ n} -- {ℓ₁} -- {_≋₁_ : ∀ {n} → ▸₁ n → ▸₁ n → Set ℓ₁} -- {𝔞₂} {𝔄₂ : Set 𝔞₂} {𝔰₂} {_►₂_ : 𝔄₂ → 𝔄₂ → Set 𝔰₂} -- {_◅₂_ : ∀ {m n} → m ►₂ n → ∀ {l} → m ⟨ l ►₂_ ⟩→ n} -- {𝔱₂} {▸₂ : 𝔄₂ → Set 𝔱₂} -- {_◃₂_ : ∀ {m n} → m ►₂ n → m ⟨ ▸₂ ⟩→ n} -- {ℓ₂} -- {_≋₂_ : ∀ {n} → ▸₂ n → ▸₂ n → Set ℓ₂} -- {μ : 𝔄₁ → 𝔄₂} -- {◽ : ∀ {n} → ▸₁ n → ▸₂ (μ n)} -- {□ : ∀ {m n} → m ►₁ n → μ m ►₂ μ n} -- ⦃ _ : Semigroup _◅₁_ _◃₁_ _≋₁_ ⦄ -- ⦃ _ : Semigroup _◅₂_ _◃₂_ _≋₂_ ⦄ -- ⦃ _ : ∀ {n} → Extensionality (_≋₁_ {n}) (λ ⋆ → _≋₂_ {μ n} ⋆) ◽ ◽ ⦄ -- ⦃ _ : Preservativity _►₁_ _◃₁_ _►₂_ _◃₂_ _≋₂_ ◽ □ ⦄ -- → Semifunctor _◅₁_ _◃₁_ _≋₁_ _◅₂_ _◃₂_ _≋₂_ μ ◽ □ -- Semifunctor.′semigroup₁ Semifunctor⋆ = it -- Semifunctor.′semigroup₂ Semifunctor⋆ = it -- Semifunctor.′extensionality Semifunctor⋆ = it -- Semifunctor.′preservativity Semifunctor⋆ = it
{ "alphanum_fraction": 0.4334745763, "avg_line_length": 39.0082644628, "ext": "agda", "hexsha": "e2b065812c3008a1d4a18733e1979bdce0dc0558", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Class/Semifunctor.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Class/Semifunctor.agda", "max_line_length": 117, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Class/Semifunctor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2853, "size": 4720 }
module nform where open import Data.PropFormula (3) public open import Data.PropFormula.NormalForms 3 public open import Relation.Binary.PropositionalEquality using (_≡_; refl) p : PropFormula p = Var (# 0) q : PropFormula q = Var (# 1) r : PropFormula r = Var (# 2) φ : PropFormula φ = ¬ ((p ∧ (p ⊃ q)) ⊃ q) -- (p ∧ q) ∨ (¬ r) cnfφ : PropFormula cnfφ = ¬ q ∧ (p ∧ (¬ p ∨ q)) postulate p1 : ∅ ⊢ φ p2 : ∅ ⊢ cnfφ p2 = cnf-lem p1 -- thm-cnf p1 {- p3 : cnf φ ≡ cnfφ p3 = refl ψ : PropFormula ψ = (¬ r) ∨ (p ∧ q) cnfψ : PropFormula cnfψ = (¬ r ∨ p) ∧ (¬ r ∨ q) p5 : cnf ψ ≡ cnfψ p5 = refl -} to5 = (¬ p) ∨ ((¬ q) ∨ r) from5 = (¬ p) ∨ (r ∨ ((¬ q) ∧ p)) test : ⌊ eq (cnf from5) to5 ⌋ ≡ false test = refl
{ "alphanum_fraction": 0.5504201681, "avg_line_length": 15.1914893617, "ext": "agda", "hexsha": "582f6bf57d952459dfd8f960179e9cd8962eddbc", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_path": "test/nform.agda", "max_issues_count": 18, "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_path": "test/nform.agda", "max_line_length": 67, "max_stars_count": 13, "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_path": "test/nform.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "num_tokens": 325, "size": 714 }
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category hiding (module Heterogeneous) open import Categories.Congruence module Categories.Arrow {o ℓ e} (C : Category o ℓ e) where open import Level open import Relation.Binary using (Rel) open import Data.Product using (_×_; _,_; map; zip) open Category C open Category.Equiv C record ArrowObj : Set (o ⊔ ℓ) where constructor arrobj field {A} : Obj {B} : Obj arr : A ⇒ B record Arrow⇒ (X Y : ArrowObj) : Set (ℓ ⊔ e) where constructor arrarr module X = ArrowObj X module Y = ArrowObj Y field {f} : X.A ⇒ Y.A {g} : X.B ⇒ Y.B .square : CommutativeSquare X.arr f g Y.arr arrow : Category _ _ _ arrow = record { Obj = Obj′ ; _⇒_ = _⇒′_ ; _≡_ = _≡′_ ; _∘_ = _∘′_ ; id = id′ ; assoc = λ {_} {_} {_} {_} {f} {g} {h} → assoc′ {f = f} {g} {h} ; identityˡ = identityˡ , identityˡ ; identityʳ = identityʳ , identityʳ ; equiv = record { refl = refl , refl ; sym = map sym sym ; trans = zip trans trans } ; ∘-resp-≡ = zip ∘-resp-≡ ∘-resp-≡ } where Obj′ = ArrowObj _⇒′_ : Rel Obj′ _ _⇒′_ = Arrow⇒ infixr 9 _∘′_ infix 4 _≡′_ _≡′_ : ∀ {A B} → (f g : A ⇒′ B) → Set _ (arrarr {f} {h} _) ≡′ (arrarr {i} {g} _) = f ≡ i × h ≡ g _∘′_ : ∀ {A B C} → (B ⇒′ C) → (A ⇒′ B) → (A ⇒′ C) _∘′_ {arrobj x} {arrobj y} {arrobj z} (arrarr {f} {h} pf₁) (arrarr {i} {g} pf₂) = arrarr pf where .pf : (h ∘ g) ∘ x ≡ z ∘ (f ∘ i) pf = begin (h ∘ g) ∘ x ↓⟨ assoc ⟩ h ∘ (g ∘ x) ↓⟨ ∘-resp-≡ʳ pf₂ ⟩ h ∘ (y ∘ i) ↑⟨ assoc ⟩ (h ∘ y) ∘ i ↓⟨ ∘-resp-≡ˡ pf₁ ⟩ (z ∘ f) ∘ i ↓⟨ assoc ⟩ z ∘ (f ∘ i) ∎ where open HomReasoning id′ : ∀ {A} → A ⇒′ A id′ = arrarr (sym id-comm) .assoc′ : ∀ {A B C D} {f : A ⇒′ B} {g : B ⇒′ C} {h : C ⇒′ D} → (h ∘′ g) ∘′ f ≡′ h ∘′ (g ∘′ f) assoc′ = assoc , assoc module Congruent {q} (Q : Congruence C q) where open Congruence Q open Heterogeneous Q renaming (refl to ⇉-refl; sym to ⇉-sym; trans to ⇉-trans) ArrowEq : Rel ArrowObj _ ArrowEq (arrobj f) (arrobj g) = f ∼ g private _⇉_ : Rel ArrowObj _ _⇉_ = ArrowEq open Category arrow using () renaming (_≡_ to _≡′_; _∘_ to _∘′_) force : ∀ {X₁ X₂ Y₁ Y₂} (pfX : X₁ ⇉ X₂) (pfY : Y₁ ⇉ Y₂) → (f : Arrow⇒ X₁ Y₁) → Arrow⇒ X₂ Y₂ force {arrobj h₁} {arrobj h₂} {arrobj k₁} {arrobj k₂} (≡⇒∼ sh th ah) (≡⇒∼ sk tk ak) (arrarr {f} {g} square) = arrarr ( begin coerce th tk g ∘ h₂ ↑⟨ ∘-resp-≡ʳ ah ⟩ coerce th tk g ∘ coerce sh th h₁ ↑⟨ coerce-∘ _ _ _ _ _ ⟩ coerce sh tk (g ∘ h₁) ↓⟨ coerce-resp-≡ _ _ square ⟩ coerce sh tk (k₁ ∘ f) ↓⟨ coerce-∘ _ _ _ _ _ ⟩ coerce sk tk k₁ ∘ coerce sh sk f ↓⟨ ∘-resp-≡ˡ ak ⟩ k₂ ∘ coerce sh sk f ∎) where open HomReasoning .force-resp-≡′ : ∀ {X₁ X₂ Y₁ Y₂} (pfX : X₁ ⇉ X₂) (pfY : Y₁ ⇉ Y₂) → {f₁ f₂ : Arrow⇒ X₁ Y₁} → f₁ ≡′ f₂ → force pfX pfY f₁ ≡′ force pfX pfY f₂ force-resp-≡′ (≡⇒∼ _ _ _) (≡⇒∼ _ _ _) (eq₁ , eq₂) = coerce-resp-≡ _ _ eq₁ , coerce-resp-≡ _ _ eq₂ .force-refl : ∀ {X Y} (f : Arrow⇒ X Y) → force ⇉-refl ⇉-refl f ≡′ f force-refl f = coerce-refl _ , coerce-refl _ .force-inv : ∀ {X₁ X₂ Y₁ Y₂} (pfX₁ pfX₂ : X₁ ⇉ X₂) (pfY₁ pfY₂ : Y₁ ⇉ Y₂) → (f : Arrow⇒ X₁ Y₁) → force pfX₁ pfY₁ f ≡′ force pfX₂ pfY₂ f force-inv (≡⇒∼ _ _ _) (≡⇒∼ _ _ _) (≡⇒∼ _ _ _) (≡⇒∼ _ _ _) f = coerce-invariant _ _ _ _ _ , coerce-invariant _ _ _ _ _ .force-trans : ∀ {X₁ X₂ X₃ Y₁ Y₂ Y₃} (pfX₁ : X₁ ⇉ X₂) (pfX₂ : X₂ ⇉ X₃) (pfY₁ : Y₁ ⇉ Y₂) (pfY₂ : Y₂ ⇉ Y₃) → (f : Arrow⇒ X₁ Y₁) → force (⇉-trans pfX₁ pfX₂) (⇉-trans pfY₁ pfY₂) f ≡′ force pfX₂ pfY₂ (force pfX₁ pfY₁ f) force-trans (≡⇒∼ _ _ _) (≡⇒∼ _ _ _) (≡⇒∼ _ _ _) (≡⇒∼ _ _ _) f = coerce-trans _ _ _ _ _ , coerce-trans _ _ _ _ _ .force-∘′ : ∀ {X₁ X₂ Y₁ Y₂ Z₁ Z₂} → (pfX : X₁ ⇉ X₂) (pfY : Y₁ ⇉ Y₂) (pfZ : Z₁ ⇉ Z₂) → (g : Arrow⇒ Y₁ Z₁) (f : Arrow⇒ X₁ Y₁) → force pfX pfZ (g ∘′ f) ≡′ force pfY pfZ g ∘′ force pfX pfY f force-∘′ (≡⇒∼ _ _ _) (≡⇒∼ _ _ _) (≡⇒∼ _ _ _) g f = coerce-∘ _ _ _ _ _ , coerce-∘ _ _ _ _ _ arrowQ : Congruence arrow _ arrowQ = record { _≡₀_ = ArrowEq ; equiv₀ = record { refl = ⇉-refl ; sym = ⇉-sym ; trans = ⇉-trans } ; coerce = force ; coerce-resp-≡ = force-resp-≡′ ; coerce-refl = force-refl ; coerce-invariant = force-inv ; coerce-trans = force-trans ; coerce-∘ = force-∘′ } open Congruent (TrivialCongruence C) public using () renaming (arrowQ to arrow∼)
{ "alphanum_fraction": 0.4826946848, "avg_line_length": 29.5975609756, "ext": "agda", "hexsha": "f5c46dd1728fce670efa17c9956943b58b32dca5", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Arrow.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Arrow.agda", "max_line_length": 95, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Arrow.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 2185, "size": 4854 }
{-# OPTIONS --without-K --safe #-} module Data.Fin.Indexed.Base where open import Data.Nat using (ℕ; suc; zero) open import Agda.Builtin.Nat using (_<_) open import Level open import Data.Bool.Truth private variable n m : ℕ -- This is the more traditional definition of Fin, -- that you would usually find in Agda code. -- I tend to use the other one because cubical -- Agda doesn't yet support transport along -- equalities of indexed types. data Fin : ℕ → Type where f0 : Fin (suc n) fs : Fin n → Fin (suc n) FinToℕ : Fin n → ℕ FinToℕ f0 = zero FinToℕ (fs i) = suc (FinToℕ i) {-# DISPLAY f0 = zero #-} {-# DISPLAY fs n = suc n #-} FinFromℕ : ∀ {m} → (n : ℕ) → T (n < m) → Fin m FinFromℕ {m = suc m} zero p = f0 FinFromℕ {m = suc m} (suc n) p = fs (FinFromℕ n p)
{ "alphanum_fraction": 0.6503856041, "avg_line_length": 25.0967741935, "ext": "agda", "hexsha": "404e15c458d8ef1cd89b0b7d71efbad39eb3db93", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Fin/Indexed/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/Fin/Indexed/Base.agda", "max_line_length": 50, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Fin/Indexed/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 261, "size": 778 }
module Data.Fin.Instance where open import Class.Equality open import Class.Traversable open import Data.Fin renaming (_≟_ to _≟F_) open import Data.Fin.Map instance Eq-Fin : ∀ {n} -> Eq (Fin n) Eq-Fin = record { _≟_ = _≟F_ } Traversable-Fin-Map : ∀ {a} {n} -> Traversable {a} (FinMap n) Traversable-Fin-Map = record { sequence = sequenceDepFinMap }
{ "alphanum_fraction": 0.6897506925, "avg_line_length": 25.7857142857, "ext": "agda", "hexsha": "27f117138dc09a73c51d36d97786418973e36d49", "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/Data/Fin/Instance.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/Data/Fin/Instance.agda", "max_line_length": 63, "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/Data/Fin/Instance.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": 120, "size": 361 }
------------------------------------------------------------------------ -- Various properties ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} module Delay-monad.Alternative.Properties where open import Equality.Propositional.Cubical open import Logical-equivalence using (_⇔_) open import Prelude hiding (↑) open import Bijection equality-with-J as Bijection using (_↔_) open import Embedding equality-with-J as Embedding using (Embedding) open import Equality.Decision-procedures equality-with-J import Equality.Groupoid equality-with-J as EG open import Equivalence equality-with-J as Eq using (_≃_) open import Function-universe equality-with-J hiding (id; _∘_) open import Groupoid equality-with-J open import H-level equality-with-J as H-level open import H-level.Closure equality-with-J open import Injection equality-with-J using (Injective) import Nat equality-with-J as N open import Delay-monad.Alternative ------------------------------------------------------------------------ -- Lemmas related to h-levels module _ {a} {A : Type a} where -- _↑ is a family of propositions. ↑-propositional : (x : Maybe A) → Is-proposition (x ↑) ↑-propositional nothing = $⟨ mono (N.zero≤ 2) ⊤-contractible ⟩ Is-proposition (tt ≡ tt) ↝⟨ H-level.respects-surjection (_↔_.surjection Bijection.≡↔inj₁≡inj₁) 1 ⟩□ Is-proposition (nothing ≡ nothing) □ ↑-propositional (just x) = [inhabited⇒+]⇒+ 0 ( just x ≡ nothing ↝⟨ ⊎.inj₁≢inj₂ ∘ sym ⟩ ⊥₀ ↝⟨ ⊥-elim ⟩□ Is-proposition (just x ↑) □) -- LE nothing is a family of contractible types. LE-nothing-contractible : {x : Maybe A} → Contractible (LE nothing x) LE-nothing-contractible {x = x} = propositional⇒inhabited⇒contractible (λ where (inj₁ x↑) (inj₂ (_ , ¬x↑)) → ⊥-elim (¬x↑ (sym x↑)) (inj₂ (_ , ¬x↑)) (inj₁ x↑) → ⊥-elim (¬x↑ (sym x↑)) (inj₁ p) (inj₁ q) → $⟨ ↑-propositional _ ⟩ Is-proposition (x ↑) ↝⟨ (λ hyp → hyp _ _) ⦂ (_ → _) ⟩ sym p ≡ sym q ↔⟨ Eq.≃-≡ $ from-bijection $ Groupoid.⁻¹-bijection (EG.groupoid _) ⟩ p ≡ q ↔⟨ Bijection.≡↔inj₁≡inj₁ ⟩□ inj₁ p ≡ inj₁ q □ (inj₂ p) (inj₂ q) → $⟨ ×-closure 1 (↑-propositional _) (¬-propositional ext) ⟩ Is-proposition (nothing ↑ × ¬ x ↑) ↝⟨ (λ hyp → hyp _ _) ⦂ (_ → _) ⟩ p ≡ q ↔⟨ Bijection.≡↔inj₂≡inj₂ ⟩□ inj₂ p ≡ inj₂ q □) (case x return LE nothing of λ where nothing → inj₁ refl (just x) → inj₂ (refl , ⊎.inj₁≢inj₂ ∘ sym)) -- If A is a set, then LE is a family of propositions. LE-propositional : Is-set A → {x y : Maybe A} → Is-proposition (LE x y) LE-propositional A-set = irr _ _ where irr : ∀ x y → Is-proposition (LE x y) irr nothing _ = mono₁ 0 LE-nothing-contractible irr (just x) (just y) (inj₁ p) (inj₁ q) = cong inj₁ $ Maybe-closure 0 A-set p q irr (just _) (just _) (inj₂ (() , _)) irr (just _) (just _) _ (inj₂ (() , _)) irr (just _) nothing (inj₁ ()) irr (just _) nothing (inj₂ (() , _)) -- If A is a set, then Increasing is a family of propositions. Increasing-propositional : Is-set A → {f : ℕ → Maybe A} → Is-proposition (Increasing f) Increasing-propositional A-set = Π-closure ext 1 λ _ → LE-propositional A-set -- An equality characterisation lemma which applies when A is a set. equality-characterisation : Is-set A → {x y : Delay A} → proj₁ x ≡ proj₁ y ↔ x ≡ y equality-characterisation A-set = ignore-propositional-component (Increasing-propositional A-set) -- If A has h-level 2 + n, then LE {A = A} x y has h-level 2 + n. LE-closure : ∀ {x y} n → H-level (2 + n) A → H-level (2 + n) (LE x y) LE-closure n h = ⊎-closure n (mono₁ (1 + n) (Maybe-closure n h)) (mono (N.suc≤suc (N.zero≤ (1 + n))) (×-closure 1 (↑-propositional _) (¬-propositional ext))) -- If A has h-level 2 + n, then Increasing {A = A} f has h-level -- 2 + n. Increasing-closure : ∀ {f} n → H-level (2 + n) A → H-level (2 + n) (Increasing f) Increasing-closure n h = Π-closure ext (2 + n) λ _ → LE-closure n h -- If A has h-level 2 + n, then Delay A has h-level 2 + n. Delay-closure : ∀ n → H-level (2 + n) A → H-level (2 + n) (Delay A) Delay-closure n h = Σ-closure (2 + n) (Π-closure ext (2 + n) λ _ → Maybe-closure n h) (λ _ → Increasing-closure n h) ------------------------------------------------------------------------ -- Various properties relating _↓_, _↑ and the usual ordering of the -- natural numbers module _ {a} {A : Type a} where -- If f is increasing and f n has a value, then f (suc n) has the -- same value. ↓-step : ∀ {f} {x : A} {n} → Increasing f → f n ↓ x → f (suc n) ↓ x ↓-step {f = f} {x} {n} inc fn↓x = step (inc n) module ↓ where step : LE (f n) (f (suc n)) → f (suc n) ↓ x step (inj₁ fn≡f1+n) = f (suc n) ≡⟨ sym fn≡f1+n ⟩ f n ≡⟨ fn↓x ⟩∎ just x ∎ step (inj₂ (fn↑ , _)) = ⊥-elim $ ⊎.inj₁≢inj₂ ( nothing ≡⟨ sym fn↑ ⟩ f n ≡⟨ fn↓x ⟩∎ just x ∎) -- If f is increasing and f (suc n) does not have a value, then -- f n does not have a value. ↑-step : ∀ {f : ℕ → Maybe A} {n} → Increasing f → f (suc n) ↑ → f n ↑ ↑-step {f} {n} inc f1+n↑ with inc n ... | inj₁ fn≡f1+n = f n ≡⟨ fn≡f1+n ⟩ f (suc n) ≡⟨ f1+n↑ ⟩∎ nothing ∎ ... | inj₂ (fn↑ , _) = fn↑ -- If f is increasing and f 0 has a value, then f n has the same -- value. ↓-upwards-closed₀ : ∀ {f} {x : A} → Increasing f → f 0 ↓ x → ∀ n → f n ↓ x ↓-upwards-closed₀ _ f0↓ zero = f0↓ ↓-upwards-closed₀ inc f0↓ (suc n) = ↓-upwards-closed₀ (inc ∘ suc) (↓-step inc f0↓) n -- If f is increasing, then (λ n → f n ↓ x) is upwards closed. ↓-upwards-closed : ∀ {f : ℕ → Maybe A} {m n x} → Increasing f → m N.≤ n → f m ↓ x → f n ↓ x ↓-upwards-closed _ (N.≤-refl′ refl) = id ↓-upwards-closed inc (N.≤-step′ m≤n refl) = ↓-step inc ∘ ↓-upwards-closed inc m≤n -- If f is increasing, then (λ n → f n ↑) is downwards closed. ↑-downwards-closed : ∀ {f : ℕ → Maybe A} {m n} → Increasing f → m N.≤ n → f n ↑ → f m ↑ ↑-downwards-closed inc (N.≤-refl′ refl) = id ↑-downwards-closed inc (N.≤-step′ m≤n refl) = ↑-downwards-closed inc m≤n ∘ ↑-step inc -- If f is increasing and f m does not have a value, but f n does -- have a value, then m < n. ↑<↓ : ∀ {f : ℕ → Maybe A} {x m n} → Increasing f → f m ↑ → f n ↓ x → m N.< n ↑<↓ {f} {x} {m} {n} inc fm↑ fn↓x with n N.≤⊎> m ... | inj₂ m<n = m<n ... | inj₁ n≤m = ⊥-elim $ ⊎.inj₁≢inj₂ (nothing ≡⟨ sym $ ↑-downwards-closed inc n≤m fm↑ ⟩ f n ≡⟨ fn↓x ⟩∎ just x ∎) ------------------------------------------------------------------------ -- An unused lemma private -- If the embedding g maps nothing to nothing and just to just, then -- there is an isomorphism between Increasing f and -- Increasing (g ∘ f). Increasing-∘ : ∀ {a b} {A : Type a} {B : Type b} {f : ℕ → Maybe A} → (g : Embedding (Maybe A) (Maybe B)) → Embedding.to g nothing ≡ nothing → (∀ {x} → Embedding.to g (just x) ≢ nothing) → Increasing f ↔ Increasing (Embedding.to g ∘ f) Increasing-∘ {A = A} {B} {f} g g↑ g↓ = record { surjection = record { logical-equivalence = record { to = to ∘_ ; from = from ∘_ } ; right-inverse-of = ⟨ext⟩ ∘ (to∘from ∘_) } ; left-inverse-of = ⟨ext⟩ ∘ (from∘to ∘_) } where g′ : Maybe A → Maybe B g′ = Embedding.to g g-injective : Injective g′ g-injective = Embedding.injective (Embedding.is-embedding g) lemma₁ : ∀ {x} → x ↑ → g′ x ↑ lemma₁ refl = g↑ lemma₂ : ∀ x → ¬ x ↑ → ¬ g′ x ↑ lemma₂ nothing x↓ _ = x↓ refl lemma₂ (just _) _ = g↓ lemma₃ : ∀ x → g′ x ↑ → x ↑ lemma₃ nothing _ = refl lemma₃ (just _) g↓↑ = ⊥-elim (lemma₂ _ (λ ()) g↓↑) lemma₄ : ∀ x → g′ x ≢ nothing → x ≢ nothing lemma₄ nothing g↑↓ _ = g↑↓ g↑ lemma₄ (just _) _ () to : ∀ {n} → Increasing-at n f → Increasing-at n (g′ ∘ f) to = ⊎-map (cong g′) (Σ-map lemma₁ (lemma₂ _)) from : ∀ {n} → Increasing-at n (g′ ∘ f) → Increasing-at n f from = ⊎-map g-injective (Σ-map (lemma₃ _) (lemma₄ _)) to∘from : ∀ {n} (x : Increasing-at n (g′ ∘ f)) → to (from x) ≡ x to∘from (inj₁ p) = cong inj₁ ( cong g′ (g-injective p) ≡⟨ _≃_.right-inverse-of (Embedding.equivalence g) _ ⟩∎ p ∎) to∘from (inj₂ _) = cong inj₂ $ ×-closure 1 (↑-propositional _) (¬-propositional ext) _ _ from∘to : ∀ {n} (x : Increasing-at n f) → from (to x) ≡ x from∘to (inj₁ p) = cong inj₁ ( g-injective (cong g′ p) ≡⟨ _≃_.left-inverse-of (Embedding.equivalence g) _ ⟩∎ p ∎) from∘to (inj₂ _) = cong inj₂ $ ×-closure 1 (↑-propositional _) (¬-propositional ext) _ _
{ "alphanum_fraction": 0.5089871009, "avg_line_length": 34.0215827338, "ext": "agda", "hexsha": "4e53a8ec6197e7e3b5da38f921337d79ede42592", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Delay-monad/Alternative/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Delay-monad/Alternative/Properties.agda", "max_line_length": 114, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Delay-monad/Alternative/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 3395, "size": 9458 }
module BasicIPC.Metatheory.Hilbert-KripkeConcreteGluedImplicit where open import BasicIPC.Syntax.Hilbert public open import BasicIPC.Semantics.KripkeConcreteGluedImplicit public open ImplicitSyntax (_⊢_) (mono⊢) public -- Completeness with respect to a particular model. module _ {{_ : Model}} where reify : ∀ {A w} → w ⊩ A → unwrap w ⊢ A reify {α P} s = syn s reify {A ▻ B} s = syn s reify {A ∧ B} s = pair (reify (π₁ s)) (reify (π₂ s)) reify {⊤} s = unit reify⋆ : ∀ {Ξ w} → w ⊩⋆ Ξ → unwrap w ⊢⋆ Ξ reify⋆ {∅} ∙ = ∙ reify⋆ {Ξ , A} (ts , t) = reify⋆ ts , reify t -- Additional useful equipment. module _ {{_ : Model}} where ⟪K⟫ : ∀ {A B w} → w ⊩ A → w ⊩ B ▻ A ⟪K⟫ {A} a = app ck (reify a) ⅋ λ ξ → K (mono⊩ {A} ξ a) ⟪S⟫′ : ∀ {A B C w} → w ⊩ A ▻ B ▻ C → w ⊩ (A ▻ B) ▻ A ▻ C ⟪S⟫′ {A} {B} {C} s₁ = app cs (syn s₁) ⅋ λ ξ s₂ → app (app cs (mono⊢ (unwrap≤ ξ) (syn s₁))) (syn s₂) ⅋ λ ξ′ → ⟪S⟫ (mono⊩ {A ▻ B ▻ C} (trans≤ ξ ξ′) s₁) (mono⊩ {A ▻ B} ξ′ s₂) _⟪,⟫′_ : ∀ {A B w} → w ⊩ A → w ⊩ B ▻ A ∧ B _⟪,⟫′_ {A} a = app cpair (reify a) ⅋ λ ξ → _,_ (mono⊩ {A} ξ a) -- Soundness with respect to all models, or evaluation. eval : ∀ {A Γ} → Γ ⊢ A → Γ ⊨ A eval (var i) γ = lookup i γ eval (app t u) γ = eval t γ ⟪$⟫ eval u γ eval ci γ = ci ⅋ K I eval ck γ = ck ⅋ K ⟪K⟫ eval cs γ = cs ⅋ K ⟪S⟫′ eval cpair γ = cpair ⅋ K _⟪,⟫′_ eval cfst γ = cfst ⅋ K π₁ eval csnd γ = csnd ⅋ K π₂ eval unit γ = ∙ -- TODO: Correctness of evaluation with respect to conversion. -- The canonical model. private instance canon : Model canon = record { _⊩ᵅ_ = λ w P → unwrap w ⊢ α P ; mono⊩ᵅ = λ ξ t → mono⊢ (unwrap≤ ξ) t } -- Soundness with respect to the canonical model. reflectᶜ : ∀ {A w} → unwrap w ⊢ A → w ⊩ A reflectᶜ {α P} t = t ⅋ t reflectᶜ {A ▻ B} t = t ⅋ λ ξ a → reflectᶜ (app (mono⊢ (unwrap≤ ξ) t) (reify a)) reflectᶜ {A ∧ B} t = reflectᶜ (fst t) , reflectᶜ (snd t) reflectᶜ {⊤} t = ∙ reflectᶜ⋆ : ∀ {Ξ w} → unwrap w ⊢⋆ Ξ → w ⊩⋆ Ξ reflectᶜ⋆ {∅} ∙ = ∙ reflectᶜ⋆ {Ξ , A} (ts , t) = reflectᶜ⋆ ts , reflectᶜ t -- Reflexivity and transitivity. refl⊩⋆ : ∀ {w} → w ⊩⋆ unwrap w refl⊩⋆ = reflectᶜ⋆ refl⊢⋆ trans⊩⋆ : ∀ {w w′ w″} → w ⊩⋆ unwrap w′ → w′ ⊩⋆ unwrap w″ → w ⊩⋆ unwrap w″ trans⊩⋆ ts us = reflectᶜ⋆ (trans⊢⋆ (reify⋆ ts) (reify⋆ us)) -- Completeness with respect to all models, or quotation. quot : ∀ {A Γ} → Γ ⊨ A → Γ ⊢ A quot s = reify (s refl⊩⋆) -- Normalisation by evaluation. norm : ∀ {A Γ} → Γ ⊢ A → Γ ⊢ A norm = quot ∘ eval -- TODO: Correctness of normalisation with respect to conversion.
{ "alphanum_fraction": 0.5211786372, "avg_line_length": 26.359223301, "ext": "agda", "hexsha": "adb0e29f937233230ff084f035e0edc607cd0007", "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": "BasicIPC/Metatheory/Hilbert-KripkeConcreteGluedImplicit.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": "BasicIPC/Metatheory/Hilbert-KripkeConcreteGluedImplicit.agda", "max_line_length": 90, "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": "BasicIPC/Metatheory/Hilbert-KripkeConcreteGluedImplicit.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": 1278, "size": 2715 }
{-# OPTIONS --allow-unsolved-metas #-} {- This is a copy of Sane, but building upon a rather different notion of permutation -} module Sane2 where import Data.Fin as F -- open import Data.Unit open import Data.Nat using (ℕ ; zero ; suc ; _+_ ; _>_ ) open import Data.Sum using (inj₁ ; inj₂ ; _⊎_) open import Data.Vec open import Function using ( id ) renaming (_∘_ to _○_) open import Relation.Binary -- to make certain goals look nicer open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym ; cong ; trans ; subst ; module ≡-Reasoning ) open ≡-Reasoning -- start re-splitting things up, as this is getting out of hand open import FT -- Finite Types open import VecHelpers open import NatSimple open import Eval open import Permutations open import CombPerm -- Suppose we have some combinator c, its output vector v, and the corresponding -- permutation p. We construct p by looking at how many places each element is -- displaced from its index in v *to the right* (if it's where it "should" be or -- to the left, just return 0). -- In other words, if v[i] = j, then p[j] = j - i. That is, if j is in location -- i, j - i is how many spaces to the right (if any) j appears from its own -- index. Note that if v[i] = j, then c(i) = j, and inv(c)(j) = i. This suggests -- that if I can write a tabulate function for permutations, the permutation for -- a combinator c will be "tabulate (∩ -> i - (evalCombB c i))", modulo type -- coercions. -- -- JC: I think an even easier way is to use LeftCancellation and build it -- recursively! By this I mean something which gives a -- (fromℕ n ⇛ fromℕ n) given a (fromℕ (suc n) ⇛ fromℕ (suc n)) combToPerm : {n : ℕ} → (fromℕ n ⇛ fromℕ n) → Permutation n combToPerm {zero} c = [] combToPerm {suc n} c = valToFin (evalComb c (inj₁ tt)) ∷ {!!} -- This is just nasty, prove it 'directly' key-lemma : {n : ℕ} (i : F.Fin (suc n)) (j : F.Fin (suc (suc n))) → (lookup (lookup ((F.inject₁ i ∷ remove (F.inject₁ i) vId) !! j) (insert (remove (F.inject₁ i) vId) (F.suc i) (F.inject₁ i))) (insert vS (F.inject₁ i) F.zero)) ≡ (F.suc i ∷ insert (remove i vS) i F.zero) !! j key-lemma {zero} F.zero F.zero = refl key-lemma {zero} F.zero (F.suc F.zero) = refl key-lemma {zero} F.zero (F.suc (F.suc ())) key-lemma {zero} (F.suc ()) j key-lemma {suc n} F.zero F.zero = refl key-lemma {suc n} F.zero (F.suc j) = begin lookup (lookup (vS !! j) swap01vec) vId ≡⟨ lookupTab {f = id} (lookup (vS !! j) swap01vec) ⟩ lookup (vS !! j) swap01vec ≡⟨ cong (λ z → lookup z swap01vec) (lookupTab {f = F.suc} j) ⟩ lookup (F.suc j) swap01vec ≡⟨ refl ⟩ lookup j (F.zero ∷ vSS) ∎ key-lemma {suc n} (F.suc i) F.zero = begin lookup (lookup (F.inject₁ i) (insert (remove (F.inject₁ i) (tabulate F.suc)) (F.suc i) (F.suc (F.inject₁ i)))) (F.suc F.zero ∷ insert (tabulate (F.suc ○ F.suc)) (F.inject₁ i) F.zero) ≡⟨ cong (λ z → lookup z (F.suc F.zero ∷ insert (tabulate (F.suc ○ F.suc)) (F.inject₁ i) F.zero)) (lookup+1-insert-remove i (tabulate F.suc)) ⟩ lookup (lookup (F.suc i) (tabulate F.suc)) (F.suc F.zero ∷ insert (tabulate (F.suc ○ F.suc)) (F.inject₁ i) F.zero) ≡⟨ cong (λ z → lookup z (F.suc F.zero ∷ insert (tabulate (F.suc ○ F.suc)) (F.inject₁ i) F.zero)) (lookupTab {f = F.suc} (F.suc i)) ⟩ lookup (F.suc (F.suc i)) (F.suc F.zero ∷ insert (tabulate (F.suc ○ F.suc)) (F.inject₁ i) F.zero) ≡⟨ refl ⟩ lookup (F.suc i) (insert (tabulate (F.suc ○ F.suc)) (F.inject₁ i) F.zero) ≡⟨ sym (lookup-insert3 i (tabulate (F.suc ○ F.suc))) ⟩ lookup i (tabulate (F.suc ○ F.suc)) ≡⟨ lookupTab {f = F.suc ○ F.suc} i ⟩ F.suc (F.suc i) ∎ key-lemma {suc n} (F.suc i) (F.suc j) = begin (lookup (lookup (lookup j (remove (F.inject₁ (F.suc i)) vId)) (insert (remove (F.inject₁ (F.suc i)) vId) (F.suc (F.suc i)) (F.inject₁ (F.suc i)))) (insert vS (F.inject₁ (F.suc i)) F.zero)) ≡⟨ refl ⟩ -- lots of β (lookup (lookup ((F.zero ∷ remove (F.inject₁ i) vS) !! j) (F.zero ∷ insert (remove (F.inject₁ i) vS) (F.suc i) (F.inject₁ (F.suc i)))) (F.suc F.zero ∷ insert vSS (F.inject₁ i) F.zero)) ≡⟨ {!!} ⟩ (F.suc F.zero ∷ insert (remove i vSS) i F.zero) !! j ≡⟨ refl ⟩ (insert (remove (F.suc i) vS) (F.suc i) F.zero) !! j ∎ {- (lookup (lookup ((F.inject₁ i ∷ remove (F.inject₁ i) vId) !! j) (insert (remove (F.inject₁ i) vId) (F.suc i) (F.inject₁ i))) (insert vS (F.inject₁ i) F.zero)) ≡ (F.suc i ∷ insert (remove i vS) i F.zero) !! j -} -------------------------------------------------------------------------------------------------------------- -- shuffle is like permute, but takes a combinator rather than a permutation as input shuffle : {n : ℕ} {A : Set} → (fromℕ n ⇛ fromℕ n) → Vec A n → Vec A n shuffle c v = tabulate (λ x → v !! valToFin (evalComb c (finToVal x))) -------------------------------------------------------------------------------------------------------------- swapUpCorrect : {n : ℕ} → (i : F.Fin n) → (j : F.Fin (1 + n)) → evalComb (swapUpTo i) (finToVal j) ≡ finToVal (evalPerm (swapUpToPerm i) j) swapUpCorrect {zero} () j swapUpCorrect {suc zero} F.zero F.zero = refl swapUpCorrect {suc zero} F.zero (F.suc F.zero) = refl swapUpCorrect {suc zero} F.zero (F.suc (F.suc ())) swapUpCorrect {suc zero} (F.suc ()) j swapUpCorrect {suc (suc n)} F.zero j = cong finToVal ( begin j ≡⟨ sym (lookupTab {f = id} j) ⟩ lookup j (tabulate id) ≡⟨ cong (λ x → lookup j (F.zero ∷ F.suc F.zero ∷ F.suc (F.suc F.zero) ∷ x)) (sym (idP-id (tabulate (F.suc ○ F.suc ○ F.suc)))) ⟩ evalPerm (swapUpToPerm F.zero) j ∎ ) swapUpCorrect {suc (suc n)} (F.suc i) F.zero = refl swapUpCorrect {suc (suc n)} (F.suc i) (F.suc j) = begin evalComb (assocl₊⇛ ◎ (swap₊⇛ ⊕ id⇛) ◎ assocr₊⇛) (inj₂ (evalComb (swapUpTo i) (finToVal j))) ≡⟨ cong (λ x → evalComb (assocl₊⇛ ◎ (swap₊⇛ ⊕ id⇛) ◎ assocr₊⇛) (inj₂ x)) (swapUpCorrect i j) ⟩ evalComb (assocl₊⇛ ◎ (swap₊⇛ ⊕ id⇛) ◎ assocr₊⇛) (inj₂ (finToVal (evalPerm (swapUpToPerm i) j))) ≡⟨ swapi≡swap01 (F.suc (evalPerm (swapUpToPerm i) j)) ⟩ finToVal (evalPerm (swap01 (suc (suc (suc n)))) (F.suc (evalPerm (swapUpToPerm i) j))) ≡⟨ cong finToVal ( begin evalPerm (swap01 (suc (suc (suc n)))) (F.suc (evalPerm (swapUpToPerm i) j)) ≡⟨ cong (λ x → evalPerm (swap01 (suc (suc (suc n)))) (F.suc (lookup j x))) (swapUpToAct i (tabulate id)) ⟩ lookup (F.suc (lookup j (insert (tabulate (λ z → F.suc z)) (F.inject₁ i) F.zero))) (F.suc F.zero ∷ F.zero ∷ F.suc (F.suc F.zero) ∷ permute idP (tabulate (λ z → F.suc (F.suc (F.suc z))))) ≡⟨ cong (λ x → (lookup (F.suc (lookup j (insert (tabulate F.suc) (F.inject₁ i) F.zero))) (F.suc F.zero ∷ F.zero ∷ F.suc (F.suc F.zero) ∷ x))) (idP-id _) ⟩ (swap01vec !! (F.suc ((insert (tabulate F.suc) (F.inject₁ i) F.zero) !! j))) ≡⟨ cong (λ x → swap01vec !! x) (sym (map!! F.suc _ j)) ⟩ (swap01vec !! (vmap F.suc (insert (tabulate F.suc) (F.inject₁ i) F.zero) !! j)) ≡⟨ sym (lookupTab {f = (λ j → (swap01vec !! (vmap F.suc (insert (tabulate F.suc) (F.inject₁ i) F.zero) !! j)))} j) ⟩ (tabulate (λ k → (swap01vec !! (vmap F.suc (insert (tabulate F.suc) (F.inject₁ i) F.zero) !! k))) !! j) ≡⟨ refl ⟩ (((vmap F.suc (insert (tabulate F.suc) (F.inject₁ i) F.zero)) ∘̬ swap01vec) !! j) ≡⟨ cong (λ x → x !! j) (∘̬≡∘̬′ _ _) ⟩ (((vmap F.suc (insert (tabulate F.suc) (F.inject₁ i) F.zero)) ∘̬′ swap01vec) !! j) ≡⟨ cong (λ x → ((vmap F.suc (insert x (F.inject₁ i) F.zero) ∘̬′ swap01vec) !! j)) (sym (mapTab F.suc id)) ⟩ {-- For reference: newlemma6 : {m n : ℕ} → (i : F.Fin n) → (v : Vec (F.Fin m) n) → (vmap F.suc (insert (vmap F.suc v) (F.inject₁ i) F.zero)) ∘̬′ swap01vec ≡ insert (vmap F.suc (vmap F.suc v)) (F.inject₁ i) F.zero --} (((vmap F.suc (insert (vmap F.suc (tabulate id)) (F.inject₁ i) F.zero)) ∘̬′ swap01vec) !! j) ≡⟨ cong (λ x → x !! j) (newlemma6 i (tabulate id)) ⟩ (insert (vmap F.suc (vmap F.suc (tabulate id))) (F.inject₁ i) F.zero !! j) ≡⟨ cong (λ x → insert (vmap F.suc x) (F.inject₁ i) F.zero !! j) (mapTab F.suc id) ⟩ (insert (vmap F.suc (tabulate F.suc)) (F.inject₁ i) F.zero !! j) ≡⟨ cong (λ x → insert x (F.inject₁ i) F.zero !! j) (mapTab F.suc F.suc) ⟩ (insert (tabulate (λ x → F.suc (F.suc x))) (F.inject₁ i) F.zero !! j) ≡⟨ cong (λ x → lookup j (insert x (F.inject₁ i) F.zero)) (sym (idP-id _)) ⟩ (lookup j (insert (permute idP (tabulate (λ x → F.suc (F.suc x)))) (F.inject₁ i) F.zero)) ≡⟨ refl ⟩ evalPerm (swapUpToPerm (F.suc i)) (F.suc j) ∎ ) ⟩ finToVal (evalPerm (swapUpToPerm (F.suc i)) (F.suc j)) ∎ swapDownCorrect : {n : ℕ} → (i : F.Fin n) → (j : F.Fin (1 + n)) → evalComb (swapDownFrom i) (finToVal j) ≡ finToVal (evalPerm (swapDownFromPerm i) j) swapDownCorrect F.zero j = begin evalComb (swapDownFrom F.zero) (finToVal j) ≡⟨ refl ⟩ finToVal j ≡⟨ cong finToVal (sym (lookupTab {f = id} j)) ⟩ finToVal ((tabulate id) !! j) ≡⟨ cong (λ x → finToVal (x !! j)) (sym (idP-id (tabulate id))) ⟩ finToVal (permute idP (tabulate id) !! j) ≡⟨ refl ⟩ finToVal (evalPerm (swapDownFromPerm F.zero) j) ∎ swapDownCorrect (F.suc i) F.zero = begin evalComb (swapDownFrom (F.suc i)) (finToVal F.zero) ≡⟨ refl ⟩ evalComb (swapi F.zero ◎ (id⇛ ⊕ swapDownFrom i)) (finToVal F.zero) ≡⟨ refl ⟩ evalComb (id⇛ ⊕ swapDownFrom i) (evalComb (swapi F.zero) (finToVal F.zero)) ≡⟨ refl ⟩ evalComb (id⇛ ⊕ swapDownFrom i) (finToVal (F.suc F.zero)) ≡⟨ refl ⟩ inj₂ (evalComb (swapDownFrom i) (finToVal F.zero)) ≡⟨ cong inj₂ (swapDownCorrect i F.zero) ⟩ inj₂ (finToVal (evalPerm (swapDownFromPerm i) F.zero)) ≡⟨ refl ⟩ finToVal (F.suc (evalPerm (swapDownFromPerm i) F.zero)) ≡⟨ refl ⟩ -- beta finToVal (F.suc (permute (swapDownFromPerm i) (tabulate id) !! F.zero)) ≡⟨ cong finToVal (push-f-through F.suc F.zero (swapDownFromPerm i) id ) ⟩ finToVal (lookup F.zero (permute (swapDownFromPerm i) (tabulate F.suc))) ≡⟨ cong finToVal (sym (lookup-insert (permute (swapDownFromPerm i) (tabulate F.suc)))) ⟩ finToVal (evalPerm (swapDownFromPerm (F.suc i)) F.zero) ∎ swapDownCorrect (F.suc i) (F.suc F.zero) = begin evalComb (swapDownFrom (F.suc i)) (finToVal (F.suc F.zero)) ≡⟨ refl ⟩ evalComb (swapi F.zero ◎ (id⇛ ⊕ swapDownFrom i)) (finToVal (F.suc F.zero)) ≡⟨ refl ⟩ evalComb (id⇛ ⊕ swapDownFrom i) (evalComb (swapi F.zero) (finToVal (F.suc F.zero))) ≡⟨ refl ⟩ evalComb (id⇛ ⊕ swapDownFrom i) (inj₁ tt) ≡⟨ refl ⟩ inj₁ tt ≡⟨ refl ⟩ finToVal (F.zero) ≡⟨ cong finToVal (sym (lookup-insert′ (F.suc F.zero) (permute (swapDownFromPerm i) (tabulate F.suc)))) ⟩ finToVal (evalPerm (swapDownFromPerm (F.suc i)) (F.suc F.zero)) ∎ swapDownCorrect (F.suc i) (F.suc (F.suc j)) = begin evalComb (swapDownFrom (F.suc i)) (finToVal (F.suc (F.suc j))) ≡⟨ refl ⟩ evalComb (swapi F.zero ◎ (id⇛ ⊕ swapDownFrom i)) (finToVal (F.suc (F.suc j))) ≡⟨ refl ⟩ evalComb (id⇛ ⊕ swapDownFrom i) (evalComb (swapi F.zero) (finToVal (F.suc (F.suc j)))) ≡⟨ refl ⟩ evalComb (id⇛ ⊕ swapDownFrom i) (finToVal (F.suc (F.suc j))) ≡⟨ refl ⟩ evalComb (id⇛ ⊕ swapDownFrom i) (inj₂ (finToVal (F.suc j))) ≡⟨ refl ⟩ inj₂ (evalComb (swapDownFrom i) (finToVal (F.suc j))) ≡⟨ cong inj₂ (swapDownCorrect i (F.suc j)) ⟩ inj₂ (finToVal (evalPerm (swapDownFromPerm i) (F.suc j))) ≡⟨ refl ⟩ finToVal (F.suc (evalPerm (swapDownFromPerm i) (F.suc j))) ≡⟨ cong finToVal (push-f-through F.suc (F.suc j) (swapDownFromPerm i) id) ⟩ -- need to do a little β-expansion to see this finToVal (lookup (F.suc j) (permute (1iP i) (tabulate F.suc))) ≡⟨ cong finToVal (lookup-insert′′ j (permute (1iP i) (tabulate F.suc))) ⟩ finToVal (evalPerm (swapDownFromPerm (F.suc i)) (F.suc (F.suc j))) ∎ swapmCorrect : {n : ℕ} → (i j : F.Fin n) → evalComb (swapm i) (finToVal j) ≡ finToVal (evalPerm (swapmPerm i) j) swapmCorrect {zero} () _ swapmCorrect {suc n} F.zero j = begin finToVal j ≡⟨ cong finToVal (sym (lookupTab {f = id} j)) ⟩ finToVal (lookup j (tabulate id)) ≡⟨ cong (λ x → finToVal (lookup j x)) (sym (idP-id (tabulate id))) ⟩ finToVal (lookup j (permute idP (tabulate id))) ∎ swapmCorrect {suc zero} (F.suc ()) _ swapmCorrect {suc (suc n)} (F.suc i) j = -- requires the breakdown of swapm ? begin evalComb (swapm (F.suc i)) (finToVal j) ≡⟨ refl ⟩ evalComb (swapDownFrom i ◎ swapi i ◎ swapUpTo i) (finToVal j) ≡⟨ refl ⟩ evalComb (swapUpTo i) (evalComb (swapi i) (evalComb (swapDownFrom i) (finToVal j))) ≡⟨ cong (λ x → evalComb (swapUpTo i) (evalComb (swapi i) x)) (swapDownCorrect i j) ⟩ evalComb (swapUpTo i) (evalComb (swapi i) (finToVal (permute (swapDownFromPerm i) (tabulate id) !! j))) ≡⟨ cong (λ x → evalComb (swapUpTo i) x) (swapiCorrect i (permute (swapDownFromPerm i) (tabulate id) !! j)) ⟩ evalComb (swapUpTo i) (finToVal (permute (swapiPerm i) (tabulate id) !! (permute (swapDownFromPerm i) (tabulate id) !! j))) ≡⟨ (swapUpCorrect i ) (permute (swapiPerm i) (tabulate id) !! (permute (swapDownFromPerm i) (tabulate id) !! j))⟩ finToVal (permute (swapUpToPerm i) (tabulate id) !! (permute (swapiPerm i) (tabulate id) !! (permute (swapDownFromPerm i) (tabulate id) !! j))) ≡⟨ cong (λ x → finToVal (x !! (permute (swapiPerm i) (tabulate id) !! (permute (swapDownFromPerm i) (tabulate id) !! j)))) (swapUpToAct i (tabulate id)) ⟩ finToVal (insert (tabulate F.suc) (F.inject₁ i) F.zero !! (permute (swapiPerm i) (tabulate id) !! (permute (swapDownFromPerm i) (tabulate id) !! j))) ≡⟨ cong (λ z → finToVal (insert (tabulate F.suc) (F.inject₁ i) F.zero !! (z !! (permute (swapDownFromPerm i) (tabulate id) !! j)))) (swapiAct i (tabulate id)) ⟩ finToVal (insert (tabulate F.suc) (F.inject₁ i) F.zero !! (insert (remove (F.inject₁ i) (tabulate id)) (F.suc i) ((tabulate id) !! (F.inject₁ i)) !! (permute (swapDownFromPerm i) (tabulate id) !! j))) ≡⟨ cong (λ z → finToVal (insert (tabulate F.suc) (F.inject₁ i) F.zero !! (insert (remove (F.inject₁ i) (tabulate id)) (F.suc i) ((tabulate id) !! (F.inject₁ i)) !! (z !! j)))) (swapDownFromAct i (tabulate id)) ⟩ finToVal (insert (tabulate F.suc) (F.inject₁ i) F.zero !! (insert (remove (F.inject₁ i) (tabulate id)) (F.suc i) ((tabulate id) !! (F.inject₁ i)) !! ( swapDownFromVec (F.inject₁ i) (tabulate id) !! j))) ≡⟨ cong (λ z → finToVal (insert (tabulate F.suc) (F.inject₁ i) F.zero !! (insert (remove (F.inject₁ i) (tabulate id)) (F.suc i) z !! ( swapDownFromVec (F.inject₁ i) (tabulate id) !! j)))) (lookupTab {f = id} (F.inject₁ i)) ⟩ finToVal (insert (tabulate F.suc) (F.inject₁ i) F.zero !! (insert (remove (F.inject₁ i) (tabulate id)) (F.suc i) (F.inject₁ i) !! ( swapDownFromVec (F.inject₁ i) (tabulate id) !! j))) ≡⟨ refl ⟩ finToVal (insert (tabulate F.suc) (F.inject₁ i) F.zero !! (insert (remove (F.inject₁ i) (tabulate id)) (F.suc i) (F.inject₁ i) !! ( (((tabulate id) !! (F.inject₁ i)) ∷ (remove (F.inject₁ i) (tabulate id))) !! j))) ≡⟨ cong (λ z → finToVal (insert (tabulate F.suc) (F.inject₁ i) F.zero !! (insert (remove (F.inject₁ i) (tabulate id)) (F.suc i) (F.inject₁ i) !! ( (z ∷ (remove (F.inject₁ i) (tabulate id))) !! j)))) (lookupTab {f = id} (F.inject₁ i)) ⟩ finToVal (insert (tabulate F.suc) (F.inject₁ i) F.zero !! (insert (remove (F.inject₁ i) (tabulate id)) (F.suc i) (F.inject₁ i) !! ( ((F.inject₁ i) ∷ (remove (F.inject₁ i) (tabulate id))) !! j))) ≡⟨ cong finToVal (key-lemma i j) ⟩ finToVal ( ((F.suc i) ∷ (insert (remove i (tabulate F.suc)) i F.zero)) !! j) ≡⟨ cong (λ z → finToVal ((z ∷ (insert (remove i (tabulate F.suc)) i F.zero)) !! j)) (sym (lookupTab {f = F.suc} i)) ⟩ finToVal ( (((tabulate F.suc) !! i) ∷ (insert (remove i (tabulate F.suc)) i F.zero)) !! j) ≡⟨ refl ⟩ finToVal (swapmVec (F.suc i) (tabulate id) !! j) ≡⟨ cong (λ z → finToVal (z !! j)) (sym (swapmAct (F.suc i) (tabulate id))) ⟩ finToVal (permute (swapmPerm (F.suc i)) (tabulate id) !! j) ≡⟨ refl ⟩ finToVal (evalPerm (swapmPerm (F.suc i)) j) ∎ lemma1 : {n : ℕ} (p : Permutation n) → (i : F.Fin n) → evalComb (permToComb p) (finToVal i) ≡ finToVal (evalPerm p i) lemma1 {zero} [] () lemma1 {suc n} (F.zero ∷ p) F.zero = refl lemma1 {suc zero} (F.zero ∷ p) (F.suc ()) lemma1 {suc (suc n)} (F.zero ∷ p) (F.suc i) = begin inj₂ (evalComb (permToComb p) (finToVal i)) ≡⟨ cong inj₂ (lemma1 p i) ⟩ inj₂ (finToVal (evalPerm p i)) ≡⟨ refl ⟩ finToVal (F.suc (evalPerm p i)) ≡⟨ cong finToVal (push-f-through F.suc i p id) ⟩ finToVal (evalPerm (F.zero ∷ p) (F.suc i)) ∎ lemma1 {suc n} (F.suc j ∷ p) i = {!!} -- needs all the previous ones first. {- This is cleaner as a proof, but is not headed the right way as the cases are not the 'right' ones swapmCorrect2 : {n : ℕ} → (i j : F.Fin n) → evalComb (swapm i) (finToVal j) ≡ finToVal (evalPerm (swapmPerm i) j) swapmCorrect2 {zero} () _ swapmCorrect2 {suc zero} F.zero F.zero = refl swapmCorrect2 {suc zero} F.zero (F.suc ()) swapmCorrect2 {suc zero} (F.suc ()) _ swapmCorrect2 {suc (suc n)} F.zero j = sym ( trans (cong (λ x → finToVal (lookup j (F.zero ∷ F.suc F.zero ∷ x))) (idP-id (tabulate (F.suc ○ F.suc)))) (cong finToVal (lookupTab {f = id} j))) swapmCorrect2 {suc (suc n)} (F.suc F.zero) F.zero = refl swapmCorrect2 {suc (suc n)} (F.suc (F.suc i)) F.zero = let up = λ x → evalComb (swapUpTo (F.suc i)) x swap = λ x → evalComb (swapi (F.suc i)) x down = λ x → evalComb (swapDownFrom (F.suc i)) x in begin evalComb (swapm (F.suc (F.suc i))) (inj₁ tt) ≡⟨ refl ⟩ evalComb (swapDownFrom (F.suc i) ◎ swapi (F.suc i) ◎ swapUpTo (F.suc i)) (inj₁ tt) ≡⟨ refl ⟩ up (swap (down (inj₁ tt))) ≡⟨ cong (up ○ swap) (swapDownCorrect (F.suc i) F.zero) ⟩ up (swap ( finToVal (evalPerm (swapDownFromPerm (F.suc i)) F.zero) )) ≡⟨ refl ⟩ up (swap (finToVal (permute (swapDownFromPerm (F.suc i)) (tabulate id) !! F.zero))) ≡⟨ cong (λ x → up (swap (finToVal (x !! F.zero )))) (swapDownFromAct (F.suc i) (tabulate id)) ⟩ up (swap (finToVal (swapDownFromVec (F.inject₁ (F.suc i)) (tabulate id) !! F.zero))) ≡⟨ refl ⟩ up (swap (finToVal ( (((tabulate id) !! (F.inject₁ (F.suc i))) ∷ remove (F.inject₁ (F.suc i)) (tabulate id)) !! F.zero ))) ≡⟨ refl ⟩ up (swap (finToVal ((tabulate id) !! (F.inject₁ (F.suc i))))) ≡⟨ cong (up ○ swap ○ finToVal) (lookupTab {f = id} (F.inject₁ (F.suc i))) ⟩ up (swap (finToVal (F.inject₁ (F.suc i)))) ≡⟨ cong up (swapiCorrect (F.suc i) (F.inject₁ (F.suc i))) ⟩ up (finToVal (evalPerm (swapiPerm (F.suc i)) (F.inject₁ (F.suc i)))) ≡⟨ refl ⟩ up (finToVal (permute (swapiPerm (F.suc i)) (tabulate id) !! (F.inject₁ (F.suc i)))) ≡⟨ cong (λ x → up (finToVal( x !! (F.inject₁ (F.suc i))))) (swapiAct (F.suc i) (tabulate id)) ⟩ up (finToVal (insert (remove (F.inject₁ (F.suc i)) (tabulate id)) (F.suc (F.suc i)) ((tabulate id) !! (F.inject₁ (F.suc i))) !! (F.inject₁ (F.suc i)))) ≡⟨ cong (λ x → up (finToVal (insert (remove (F.inject₁ (F.suc i)) (tabulate id)) (F.suc (F.suc i)) x !! (F.inject₁ (F.suc i))))) (lookupTab {f = id} (F.inject₁ (F.suc i))) ⟩ up (finToVal (insert (remove (F.inject₁ (F.suc i)) (tabulate id)) (F.suc (F.suc i)) (F.inject₁ (F.suc i)) !! (F.inject₁ (F.suc i)))) ≡⟨ cong (up ○ finToVal) (lookup+1-insert-remove (F.suc i) (tabulate id)) ⟩ up (finToVal (lookup (F.suc (F.suc i)) (tabulate id))) ≡⟨ cong (up ○ finToVal) (lookupTab {f = id} (F.suc (F.suc i))) ⟩ up (finToVal (F.suc (F.suc i))) ≡⟨ swapUpCorrect (F.suc i) (F.suc (F.suc i)) ⟩ finToVal (evalPerm (swapUpToPerm (F.suc i)) (F.suc (F.suc i))) ≡⟨ cong (λ x → finToVal (x !! (F.suc (F.suc i)))) (swapUpToAct (F.suc i) (tabulate id)) ⟩ finToVal ( insert (tabulate F.suc) (F.inject₁ (F.suc i)) (F.zero) !! (F.suc (F.suc i))) ≡⟨ cong finToVal (sym (lookup-insert3 (F.suc i) (tabulate F.suc))) ⟩ finToVal ((tabulate F.suc) !! (F.suc i)) ≡⟨ cong finToVal (lookupTab {f = F.suc} (F.suc i)) ⟩ finToVal (F.suc (F.suc i)) ≡⟨ cong finToVal (sym (lookupTab {f = F.suc ○ F.suc} i)) ⟩ finToVal (lookup i (tabulate (F.suc ○ F.suc))) ≡⟨ refl ⟩ finToVal (lookup F.zero (swapmVec (F.suc (F.suc i)) (tabulate id))) ≡⟨ cong (λ x → finToVal (x !! F.zero)) (sym (swapmAct (F.suc (F.suc i)) (tabulate id))) ⟩ finToVal (evalPerm (swapmPerm (F.suc (F.suc i))) F.zero) ∎ swapmCorrect2 {suc (suc n)} (F.suc F.zero) (F.suc j) = begin evalComb (swapi F.zero) (inj₂ (finToVal j)) ≡⟨ swapi≡swap01 (F.suc j) ⟩ finToVal (lookup j (F.zero ∷ permute idP (tabulate (λ z → F.suc (F.suc z))))) ≡⟨ refl ⟩ finToVal (permute (F.suc F.zero ∷ idP) (tabulate id) !! (F.suc j)) ∎ swapmCorrect2 {suc (suc n)} (F.suc (F.suc i)) (F.suc j) = {!!} -} {- -- this alternate version of lemma1 might, in the long term, but a better -- way to go? lemma1′ : {n : ℕ} → (i : F.Fin n) → vmap (evalComb (swapm i)) (tabulate finToVal) ≡ vmap finToVal (permute (swapmPerm i) (tabulate id)) lemma1′ {zero} () lemma1′ {suc n} F.zero = cong (_∷_ (inj₁ tt)) ( begin vmap id (tabulate (inj₂ ○ finToVal)) ≡⟨ mapTab id (inj₂ ○ finToVal) ⟩ tabulate (inj₂ ○ finToVal) ≡⟨ cong tabulate refl ⟩ tabulate (finToVal ○ F.suc) ≡⟨ sym (mapTab finToVal F.suc) ⟩ vmap finToVal (tabulate F.suc) ≡⟨ cong (vmap finToVal) (sym (idP-id _)) ⟩ vmap finToVal (permute idP (tabulate F.suc)) ∎ ) lemma1′ {suc n} (F.suc i) = begin vmap (evalComb (swapm (F.suc i))) (tabulate finToVal) ≡⟨ refl ⟩ evalComb (swapm (F.suc i)) (inj₁ tt) ∷ vmap (evalComb (swapm (F.suc i))) (tabulate (inj₂ ○ finToVal)) ≡⟨ cong (λ x → x ∷ vmap (evalComb (swapm (F.suc i))) (tabulate (inj₂ ○ finToVal))) (swapmCorrect {suc n} (F.suc i) F.zero) ⟩ (finToVal (evalPerm (swapmPerm (F.suc i)) F.zero)) ∷ vmap (evalComb (swapm (F.suc i))) (tabulate (inj₂ ○ finToVal)) ≡⟨ cong (λ x → (finToVal (evalPerm (swapmPerm (F.suc i)) F.zero)) ∷ x ) {!!} ⟩ -- need to generalize the inductive hyp. for this to work {!!} ≡⟨ {!!} ⟩ vmap finToVal (insert (permute (swapOne i) (tabulate F.suc)) (F.suc i) F.zero) ∎ lemma2 : {n : ℕ} (c : (fromℕ n) ⇛ (fromℕ n)) → (i : F.Fin n) → (evalComb c (finToVal i)) ≡ finToVal (evalPerm (combToPerm c) i) lemma2 c i = {!!} -}
{ "alphanum_fraction": 0.5536873647, "avg_line_length": 50.4789915966, "ext": "agda", "hexsha": "b0b927770562b4d8fca21f21c1d45443575faf8a", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/OldUnivalence/Sane2.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/OldUnivalence/Sane2.agda", "max_line_length": 182, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/OldUnivalence/Sane2.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 9251, "size": 24028 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Functor.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function renaming (_∘_ to _◍_) open import Cubical.Foundations.GroupoidLaws using (lUnit; rUnit; assoc; cong-∙) open import Cubical.Categories.Category open import Cubical.Categories.Functor.Base private variable ℓ ℓ' ℓ'' : Level B C D E : Precategory ℓ ℓ' open Precategory open Functor {- x ---p--- x' ⇓ᵍ g x' ---q--- y ⇓ʰ h y ---r--- z The path from `h (g x) ≡ z` obtained by 1. first applying cong to p and composing with q; then applying cong again and composing with r 2. first applying cong to q and composing with r; then applying a double cong to p and precomposing are path equal. -} congAssoc : ∀ {X : Type ℓ} {Y : Type ℓ'} {Z : Type ℓ''} (g : X → Y) (h : Y → Z) {x x' : X} {y : Y} {z : Z} → (p : x ≡ x') (q : g x' ≡ y) (r : h y ≡ z) → cong (h ◍ g) p ∙ (cong h q ∙ r) ≡ cong h (cong g p ∙ q) ∙ r congAssoc g h p q r = cong (h ◍ g) p ∙ (cong h q ∙ r) ≡⟨ assoc _ _ _ ⟩ ((cong (h ◍ g) p) ∙ (cong h q)) ∙ r ≡⟨ refl ⟩ (cong h (cong g p) ∙ (cong h q)) ∙ r ≡⟨ cong (_∙ r) (sym (cong-∙ h _ _)) ⟩ cong h (cong g p ∙ q) ∙ r ∎ -- composition is associative F-assoc : {F : Functor B C} {G : Functor C D} {H : Functor D E} → H ∘F (G ∘F F) ≡ (H ∘F G) ∘F F F-assoc {F = F} {G} {H} i .F-ob x = H ⟅ G ⟅ F ⟅ x ⟆ ⟆ ⟆ F-assoc {F = F} {G} {H} i .F-hom f = H ⟪ G ⟪ F ⟪ f ⟫ ⟫ ⟫ F-assoc {F = F} {G} {H} i .F-id {x} = congAssoc (G ⟪_⟫) (H ⟪_⟫) (F .F-id {x}) (G .F-id {F ⟅ x ⟆}) (H .F-id) (~ i) F-assoc {F = F} {G} {H} i .F-seq f g = congAssoc (G ⟪_⟫) (H ⟪_⟫) (F .F-seq f g) (G .F-seq _ _) (H .F-seq _ _) (~ i) -- Results about functors module _ {F : Functor C D} where -- the identity is the identity F-lUnit : F ∘F 𝟙⟨ C ⟩ ≡ F F-lUnit i .F-ob x = F ⟅ x ⟆ F-lUnit i .F-hom f = F ⟪ f ⟫ F-lUnit i .F-id {x} = lUnit (F .F-id) (~ i) F-lUnit i .F-seq f g = lUnit (F .F-seq f g) (~ i) F-rUnit : 𝟙⟨ D ⟩ ∘F F ≡ F F-rUnit i .F-ob x = F ⟅ x ⟆ F-rUnit i .F-hom f = F ⟪ f ⟫ F-rUnit i .F-id {x} = rUnit (F .F-id) (~ i) F-rUnit i .F-seq f g = rUnit (F .F-seq f g) (~ i) -- functors preserve commutative diagrams (specificallysqures here) preserveCommF : ∀ {x y z w} {f : C [ x , y ]} {g : C [ y , w ]} {h : C [ x , z ]} {k : C [ z , w ]} → f ⋆⟨ C ⟩ g ≡ h ⋆⟨ C ⟩ k → (F ⟪ f ⟫) ⋆⟨ D ⟩ (F ⟪ g ⟫) ≡ (F ⟪ h ⟫) ⋆⟨ D ⟩ (F ⟪ k ⟫) preserveCommF {f = f} {g = g} {h = h} {k = k} eq = (F ⟪ f ⟫) ⋆⟨ D ⟩ (F ⟪ g ⟫) ≡⟨ sym (F .F-seq _ _) ⟩ F ⟪ f ⋆⟨ C ⟩ g ⟫ ≡⟨ cong (F ⟪_⟫) eq ⟩ F ⟪ h ⋆⟨ C ⟩ k ⟫ ≡⟨ F .F-seq _ _ ⟩ (F ⟪ h ⟫) ⋆⟨ D ⟩ (F ⟪ k ⟫) ∎ -- functors preserve isomorphisms preserveIsosF : ∀ {x y} → CatIso {C = C} x y → CatIso {C = D} (F ⟅ x ⟆) (F ⟅ y ⟆) preserveIsosF {x} {y} (catiso f f⁻¹ sec' ret') = catiso g g⁻¹ -- sec ( (g⁻¹ ⋆⟨ D ⟩ g) ≡⟨ sym (F .F-seq f⁻¹ f) ⟩ F ⟪ f⁻¹ ⋆⟨ C ⟩ f ⟫ ≡⟨ cong (F .F-hom) sec' ⟩ F ⟪ C .id y ⟫ ≡⟨ F .F-id ⟩ D .id y' ∎ ) -- ret ( (g ⋆⟨ D ⟩ g⁻¹) ≡⟨ sym (F .F-seq f f⁻¹) ⟩ F ⟪ f ⋆⟨ C ⟩ f⁻¹ ⟫ ≡⟨ cong (F .F-hom) ret' ⟩ F ⟪ C .id x ⟫ ≡⟨ F .F-id ⟩ D .id x' ∎ ) where x' : D .ob x' = F ⟅ x ⟆ y' : D .ob y' = F ⟅ y ⟆ g : D [ x' , y' ] g = F ⟪ f ⟫ g⁻¹ : D [ y' , x' ] g⁻¹ = F ⟪ f⁻¹ ⟫
{ "alphanum_fraction": 0.4465883669, "avg_line_length": 30.5641025641, "ext": "agda", "hexsha": "5a29f4307a830e2bca5ca96ad36780bfe511b8c0", "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/Categories/Functor/Properties.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/Categories/Functor/Properties.agda", "max_line_length": 116, "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/Categories/Functor/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1739, "size": 3576 }
------------------------------------------------------------------------ -- A comparison of the two alternative definitions of weak -- bisimilarity ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} module Bisimilarity.Weak.Alternative.Comparison where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude open import H-level equality-with-J open import Surjection equality-with-J using (_↠_) open import Univalence-axiom equality-with-J import Bisimilarity import Bisimilarity.Classical import Bisimilarity.Comparison as Comp import Bisimilarity.Weak.Alternative import Bisimilarity.Weak.Alternative.Classical open import Labelled-transition-system module _ {ℓ} {lts : LTS ℓ} where open LTS lts private module Co = Bisimilarity.Weak.Alternative lts module Cl = Bisimilarity.Weak.Alternative.Classical lts -- Classically weakly bisimilar processes are coinductively weakly -- bisimilar. cl⇒co : ∀ {i p q} → p Cl.≈ q → Co.[ i ] p ≈ q cl⇒co = Comp.cl⇒co -- Coinductively weakly bisimilar processes are classically weakly -- bisimilar. co⇒cl : ∀ {p q} → p Co.≈ q → p Cl.≈ q co⇒cl = Comp.co⇒cl -- The function cl⇒co is a left inverse of co⇒cl (up to pointwise -- bisimilarity). cl⇒co∘co⇒cl : ∀ {i p q} (p≈q : p Co.≈ q) → Co.[ i ] cl⇒co (co⇒cl p≈q) ≡ p≈q cl⇒co∘co⇒cl = Comp.cl⇒co∘co⇒cl -- If there are two processes that are not equal, but weakly -- bisimilar, then co⇒cl is not a left inverse of cl⇒co. co⇒cl∘cl⇒co : ∀ {p q} → p ≢ q → p Co.≈ q → ∃ λ (p≈p : p Cl.≈ p) → co⇒cl (cl⇒co p≈p) ≢ p≈p co⇒cl∘cl⇒co = Comp.co⇒cl∘cl⇒co -- The two definitions of weak bisimilarity are logically -- equivalent. classical⇔coinductive : ∀ {p q} → p Cl.≈ q ⇔ p Co.≈ q classical⇔coinductive = Comp.classical⇔coinductive -- There is a split surjection from the classical definition of -- bisimilarity to the coinductive one (assuming two kinds of -- extensionality). classical↠coinductive : Extensionality ℓ ℓ → Co.Extensionality → ∀ {p q} → p Cl.≈ q ↠ p Co.≈ q classical↠coinductive = Comp.classical↠coinductive -- There is at least one LTS for which there is a split surjection -- from the coinductive definition of weak bisimilarity to the -- classical one. coinductive↠classical : ∀ {p q} → Bisimilarity.Weak.Alternative._≈_ empty p q ↠ Bisimilarity.Weak.Alternative.Classical._≈_ empty p q coinductive↠classical {p = ()} -- There is an LTS for which coinductive weak bisimilarity is -- pointwise propositional (assuming two kinds of extensionality and -- univalence). coinductive-weak-bisimilarity-is-sometimes-propositional : Extensionality lzero (lsuc lzero) → Univalence lzero → let module Co = Bisimilarity.Weak.Alternative one-loop in Co.Extensionality → Is-proposition (tt Co.≈ tt) coinductive-weak-bisimilarity-is-sometimes-propositional ext univ = subst (λ lts → let module Co = Bisimilarity lts in ∀ p → Co.Extensionality → Is-proposition (p Co.∼ p)) (sym $ weak≡id ext univ one-loop (λ _ ())) (λ _ → Comp.coinductive-bisimilarity-is-sometimes-propositional (lower-extensionality _ _ ext)) _ -- However, classical weak bisimilarity (of any size) is, for the same -- LTS, not pointwise propositional (assuming extensionality and -- univalence). classical-weak-bisimilarity-is-not-propositional : Extensionality lzero (lsuc lzero) → Univalence lzero → let module Cl = Bisimilarity.Weak.Alternative.Classical one-loop in ∀ {ℓ} → ¬ Is-proposition (Cl.Weak-bisimilarity′ ℓ (tt , tt)) classical-weak-bisimilarity-is-not-propositional ext univ {ℓ} = subst (λ lts → let module Cl = Bisimilarity.Classical lts in ∀ p → ¬ Is-proposition (Cl.Bisimilarity′ ℓ (p , p))) (sym $ weak≡id ext univ one-loop (λ _ ())) (λ _ → Comp.classical-bisimilarity-is-not-propositional) _ -- Thus, assuming two kinds of extensionality and univalence, there is -- in general no split surjection from the coinductive definition of -- weak bisimilarity to the classical one (of any size). ¬coinductive↠classical : Extensionality lzero (lsuc lzero) → Univalence lzero → Bisimilarity.Weak.Alternative.Extensionality one-loop → ∀ {ℓ} → ¬ (∀ {p q} → Bisimilarity.Weak.Alternative._≈_ one-loop p q ↠ Bisimilarity.Weak.Alternative.Classical.Weak-bisimilarity′ one-loop ℓ (p , q)) ¬coinductive↠classical ext univ ext′ {ℓ} = subst (λ lts → Bisimilarity.Extensionality lts → ¬ (∀ {p q} → Bisimilarity._∼_ lts p q ↠ Bisimilarity.Classical.Bisimilarity′ lts ℓ (p , q))) (sym $ weak≡id ext univ one-loop (λ _ ())) (λ ext′ → Comp.¬coinductive↠classical (lower-extensionality _ _ ext) ext′) ext′ -- Note also that coinductive weak bisimilarity is not always -- propositional (assuming extensionality and univalence). coinductive-weak-bisimilarity-is-not-propositional : Extensionality lzero (lsuc lzero) → Univalence lzero → let open Bisimilarity.Weak.Alternative two-bisimilar-processes in ¬ (∀ {p q} → Is-proposition (p ≈ q)) coinductive-weak-bisimilarity-is-not-propositional ext univ = subst (λ lts → let open Bisimilarity lts in ¬ (∀ {p q} → Is-proposition (p ∼ q))) (sym $ weak≡id ext univ two-bisimilar-processes (λ _ ())) Comp.coinductive-bisimilarity-is-not-propositional -- In fact, for every type A there is a pointwise split surjection -- from a certain instance of weak bisimilarity to equality on A -- (assuming extensionality and univalence). weak-bisimilarity↠equality : ∀ {a} → Extensionality a (lsuc a) → Univalence a → {A : Type a} → let open Bisimilarity.Weak.Alternative (bisimilarity⇔equality A) in {p q : A} → p ≈ q ↠ p ≡ q weak-bisimilarity↠equality ext univ {A} = subst (λ lts → let open Bisimilarity lts in ∀ {p q} → p ∼ q ↠ p ≡ q) (sym $ weak≡id ext univ (bisimilarity⇔equality A) (λ _ ())) (Comp.bisimilarity↠equality {A = A})
{ "alphanum_fraction": 0.654676259, "avg_line_length": 36.1560693642, "ext": "agda", "hexsha": "5b0d29367a38dd9d95d4cc31d93fbb9332d74f4a", "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": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/up-to", "max_forks_repo_path": "src/Bisimilarity/Weak/Alternative/Comparison.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "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/up-to", "max_issues_repo_path": "src/Bisimilarity/Weak/Alternative/Comparison.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/up-to", "max_stars_repo_path": "src/Bisimilarity/Weak/Alternative/Comparison.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1976, "size": 6255 }
module Examples.Type where open import Agda.Builtin.Equality using (_≡_; refl) open import FFI.Data.String using (_++_) open import Luau.Type using (nil; _∪_; _∩_; _⇒_) open import Luau.Type.ToString using (typeToString) ex1 : typeToString(nil) ≡ "nil" ex1 = refl ex2 : typeToString(nil ⇒ nil) ≡ "(nil) -> nil" ex2 = refl ex3 : typeToString(nil ⇒ (nil ⇒ nil)) ≡ "(nil) -> (nil) -> nil" ex3 = refl ex4 : typeToString(nil ∪ (nil ⇒ (nil ⇒ nil))) ≡ "((nil) -> (nil) -> nil)?" ex4 = refl ex5 : typeToString(nil ⇒ ((nil ⇒ nil) ∪ nil)) ≡ "(nil) -> ((nil) -> nil)?" ex5 = refl ex6 : typeToString((nil ⇒ nil) ∪ (nil ⇒ (nil ⇒ nil))) ≡ "((nil) -> nil | (nil) -> (nil) -> nil)" ex6 = refl ex7 : typeToString((nil ⇒ nil) ∪ ((nil ⇒ (nil ⇒ nil)) ∪ nil)) ≡ "((nil) -> nil | (nil) -> (nil) -> nil)?" ex7 = refl
{ "alphanum_fraction": 0.5773067332, "avg_line_length": 28.6428571429, "ext": "agda", "hexsha": "859227ee3eb5a27da044abcf3d2154591fed7b48", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_path": "prototyping/Examples/Type.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Tr4shh/Roblox-Luau", "max_issues_repo_path": "prototyping/Examples/Type.agda", "max_line_length": 105, "max_stars_count": null, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/Examples/Type.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 293, "size": 802 }
module Sets.BoolSet {ℓ ℓₑ} where import Lvl open import Data.Boolean import Data.Boolean.Operators open Data.Boolean.Operators.Logic using (_⟶_ ; _⟵_) open Data.Boolean.Operators.Programming hiding (_==_) open import Data.Boolean.Stmt open import Data.Boolean.Proofs import Data.List as List import Data.List.Functions as List open import Logic open import Functional open import Operator.Equals open import Structure.Setoid open import Type -- A function from a type T to a boolean value. -- This can be interpreted as a computable set over T (a set with a computable containment relation). BoolSet : ∀{ℓ} → Type{ℓ} → Type{ℓ} BoolSet(T) = (T → Bool) module _ {T : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where 𝐔 : BoolSet(T) 𝐔 = const(𝑇) ∅ : BoolSet(T) ∅ = const(𝐹) singleton : ⦃ _ : DecidableEquiv(T) ⦄ → T → BoolSet(T) singleton(t) = (_== t) enumeration : ⦃ _ : DecidableEquiv(T) ⦄ → List.List(T) → BoolSet(T) enumeration(l) = (x ↦ List.satisfiesAny(_== x)(l)) _∈?_ : T → BoolSet(T) → Bool _∈?_ = apply _∉?_ : T → BoolSet(T) → Bool _∉?_ a set = !(a ∈? set) {- TODO: Define a FinitelyEnumerable relation _⊆?_ : BoolSet(T) → BoolSet(T) → Bool _⊆?_ A B = all(elem ↦ (elem ∈? A) ⟶ (elem ∈? B)) _⊇?_ : BoolSet(T) → BoolSet(T) → Bool _⊇?_ A B = all(elem ↦ (elem ∈? A) ⟵ (elem ∈? B)) -} _∈_ : T → BoolSet(T) → Stmt _∈_ a set = IsTrue(a ∈? set) _∉_ : T → BoolSet(T) → Stmt _∉_ a set = IsTrue(a ∉? set) _⊆_ : BoolSet(T) → BoolSet(T) → Stmt _⊆_ set₁ set₂ = (∀{a} → (a ∈ set₁) → (a ∈ set₂)) _⊇_ : BoolSet(T) → BoolSet(T) → Stmt _⊇_ set₁ set₂ = _⊆_ set₂ set₁ _∪_ : BoolSet(T) → BoolSet(T) → BoolSet(T) _∪_ A B = (elem ↦ (elem ∈? A) || (elem ∈? B)) _∩_ : BoolSet(T) → BoolSet(T) → BoolSet(T) _∩_ A B = (elem ↦ (elem ∈? A) && (elem ∈? B)) _∖_ : BoolSet(T) → BoolSet(T) → BoolSet(T) _∖_ A B = (elem ↦ (elem ∈? A) && !(elem ∈? B)) ∁_ : BoolSet(T) → BoolSet(T) ∁_ A = (elem ↦ !(elem ∈? A)) ℘_ : BoolSet(T) → BoolSet(BoolSet(T)) ℘_ _ = const(𝑇)
{ "alphanum_fraction": 0.5841874085, "avg_line_length": 26.9605263158, "ext": "agda", "hexsha": "48dc10f924a3865e7d116b2f1deed6e15870f068", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Sets/BoolSet.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Sets/BoolSet.agda", "max_line_length": 101, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Sets/BoolSet.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": 835, "size": 2049 }
-- MIT License -- Copyright (c) 2021 Luca Ciccone and Luca Padovani -- Permission is hereby granted, free of charge, to any person -- obtaining a copy of this software and associated documentation -- files (the "Software"), to deal in the Software without -- restriction, including without limitation the rights to use, -- copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following -- conditions: -- The above copyright notice and this permission notice shall be -- included in all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- OTHER DEALINGS IN THE SOFTWARE. {-# OPTIONS --guardedness #-} open import Data.Empty open import Data.Maybe open import Data.Product open import Data.Sum open import Data.List using ([]; _∷_; _++_) open import Relation.Nullary open import Relation.Unary using (_∪_; _∩_; Satisfiable) open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (Star; ε; _◅_) open import Common module Session {ℙ : Set} (message : Message ℙ) where open import Trace message open import SessionType message open import Transitions message open import HasTrace message data Session : Set where _#_ : (T : SessionType) (S : SessionType) -> Session data Reduction : Session -> Session -> Set where sync : ∀{α R R' T T'} (r : Transition R (co-action α) R') (t : Transition T α T') -> Reduction (R # T) (R' # T') Reductions : Session -> Session -> Set Reductions = Star Reduction Reduce : Session -> Set Reduce S = Satisfiable (Reduction S) data Success : Session -> Set where win#def : ∀{T S} (w : Win T) (def : Defined S) -> Success (T # S) ProgressS : Session -> Set ProgressS = Success ∪ Reduce MaySucceed : Session -> Set MaySucceed S = Satisfiable (Reductions S ∩ Success) InvariantS : (Session -> Set) -> Session -> Set InvariantS P S = ∀{S'} -> Reductions S S' -> P S' ImplyS : (Session -> Set) -> SessionType -> SessionType -> Set ImplyS P T S = ∀{R} -> P (R # T) -> P (R # S) ComplianceS : Session -> Set ComplianceS = InvariantS ProgressS FairComplianceS : Session -> Set FairComplianceS = InvariantS MaySucceed SubtypingS : SessionType -> SessionType -> Set SubtypingS = ImplyS ComplianceS FairSubtypingS : SessionType -> SessionType -> Set FairSubtypingS = ImplyS FairComplianceS ConvergenceS : SessionType -> SessionType -> Set ConvergenceS T S = ∀{R} -> FairComplianceS (R # T) -> MaySucceed (R # S) unzip-red* : ∀{T T' S S'} -> Reductions (T # S) (T' # S') -> ∃[ φ ] (Transitions T (co-trace φ) T' × Transitions S φ S') unzip-red* ε = _ , refl , refl unzip-red* (sync r t ◅ reds) = let _ , tr , sr = unzip-red* reds in _ , step r tr , step t sr zip-red* : ∀{φ T T' S S'} -> Transitions T (co-trace φ) T' -> Transitions S φ S' -> Reductions (T # S) (T' # S') zip-red* refl refl = ε zip-red* (step t tr) (step s sr) = sync t s ◅ zip-red* tr sr zip-traces : ∀{R T φ} (rφ : R HasTrace (co-trace φ)) (tφ : T HasTrace φ) -> Reductions (R # T) (after rφ # after tφ) zip-traces (_ , _ , rr) (_ , _ , tr) = zip-red* rr tr success-not-reduce : ∀{S S'} → Success S → ¬ (Reduction S S') success-not-reduce (win#def win _) (sync r _) = win-reduces-⊥ win r
{ "alphanum_fraction": 0.6814064997, "avg_line_length": 33.2212389381, "ext": "agda", "hexsha": "eb503688e7ac1a368409563724bf91e8b5a25f8f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "boystrange/FairSubtypingAgda", "max_forks_repo_path": "src/Session.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "boystrange/FairSubtypingAgda", "max_issues_repo_path": "src/Session.agda", "max_line_length": 114, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "boystrange/FairSubtypingAgda", "max_stars_repo_path": "src/Session.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-24T14:38:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-29T14:32:30.000Z", "num_tokens": 1079, "size": 3754 }
module _ where open import Prelude open import Numeric.Nat.Prime 2^44+7 2^46+15 2^48+21 : Nat 2^44+7 = 17592186044423 2^46+15 = 70368744177679 2^48+21 = 281474976710677 main : IO ⊤ main = print $ isPrime! 2^48+21
{ "alphanum_fraction": 0.7045454545, "avg_line_length": 15.7142857143, "ext": "agda", "hexsha": "f4bb1dab67679f8d041955340081ef027db26612", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_path": "test/PrimeTest.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "t-more/agda-prelude", "max_issues_repo_path": "test/PrimeTest.agda", "max_line_length": 31, "max_stars_count": 111, "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_path": "test/PrimeTest.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 99, "size": 220 }
{-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Setoid) -- Lifts a setoid into a 1-groupoid module Categories.Category.Construction.0-Groupoid {c ℓ} e (S : Setoid c ℓ) where open import Level using (Lift) open import Data.Unit using (⊤) open import Function using (flip) open import Categories.Category.Groupoid using (Groupoid) open Setoid S 0-Groupoid : Groupoid c ℓ e 0-Groupoid = record { category = record { Obj = Carrier ; _⇒_ = _≈_ ; _≈_ = λ _ _ → Lift e ⊤ ; id = refl ; _∘_ = flip trans } ; isGroupoid = record { _⁻¹ = sym } }
{ "alphanum_fraction": 0.648241206, "avg_line_length": 20.5862068966, "ext": "agda", "hexsha": "d9ccfab7af85fc286763cf8d0ed4123d2b12621d", "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/Construction/0-Groupoid.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/Construction/0-Groupoid.agda", "max_line_length": 57, "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/Construction/0-Groupoid.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": 195, "size": 597 }
module MapTm where open import Prelude open import Star open import Modal open import Examples open import Lambda open Term eq⟶ : {ty : Set}(T : TyAlg ty){σ₁ σ₂ τ₁ τ₂ : ty} -> σ₁ == σ₂ -> τ₁ == τ₂ -> TyAlg._⟶_ T σ₁ τ₁ == TyAlg._⟶_ T σ₂ τ₂ eq⟶ T refl refl = refl mapTm : {ty₁ ty₂ : Set}{T₁ : TyAlg ty₁}{T₂ : TyAlg ty₂} {Γ : List ty₁}{τ : ty₁}(F : T₁ =Ty=> T₂) -> Tm T₁ Γ τ -> Tm T₂ (map _ (TyArrow.apply F) Γ) (TyArrow.apply F τ) mapTm {T₁ = T₁}{T₂}{Γ} F (var x) = var (mapAny (cong (TyArrow.apply F)) x) mapTm {T₁ = T₁}{T₂}{Γ} F zz = subst (\τ -> Tm T₂ (map _ (TyArrow.apply F) Γ) τ) (TyArrow.respNat F) zz mapTm {T₁ = T₁}{T₂}{Γ} F ss = subst Tm₂ (trans (TyArrow.resp⟶ F) (TyArrow.respNat F -eq⟶ TyArrow.respNat F)) ss where _-eq⟶_ = eq⟶ T₂ Tm₂ = Tm T₂ (map _ (TyArrow.apply F) Γ) mapTm {T₂ = T₂}{Γ} F (ƛ t) = subst Tm₂ (TyArrow.resp⟶ F) (ƛ (mapTm F t)) where Tm₂ = Tm T₂ (map _ (TyArrow.apply F) Γ) mapTm {T₂ = T₂}{Γ} F (s $ t) = subst Tm₂ (sym (TyArrow.resp⟶ F)) (mapTm F s) $ mapTm F t where Tm₂ = Tm T₂ (map _ (TyArrow.apply F) Γ)
{ "alphanum_fraction": 0.5605263158, "avg_line_length": 28.5, "ext": "agda", "hexsha": "94abffa8fa5fd849fb1ec2b11750be051bbc91b7", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/AIM6/Path/MapTm.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/AIM6/Path/MapTm.agda", "max_line_length": 74, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/AIM6/Path/MapTm.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": 505, "size": 1140 }
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_) open import Agda.Builtin.Sigma open import Agda.Builtin.List open import Agda.Builtin.Unit open import Agda.Builtin.Nat map : {A B : Set} → (A → B) → List A → List B map f [] = [] map f (x ∷ xs) = f x ∷ map f xs reverseAcc : {A : Set} → List A → List A → List A reverseAcc [] ys = ys reverseAcc (x ∷ xs) ys = reverseAcc xs (x ∷ ys) reverse : {A : Set} → List A → List A reverse xs = reverseAcc xs [] data Vec (A : Set) : Nat → Set where _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n) postulate replicate : ∀ {A : Set} {n} → A → Vec A n zipWith : ∀ {A B C : Set} {n} → (A → B → C) → Vec A n → Vec B n → Vec C n macro rtest : Name → Term → TC ⊤ rtest f a = do (function (clause tel _ t ∷ [])) ← withReconstructed (getDefinition f) where _ → typeError (strErr "ERROR" ∷ []) t ← inContext (reverse tel) (normalise t) quoteTC t >>= unify a transp : ∀ m n → Vec (Vec Nat n) m → Vec (Vec Nat m) n transp .(suc m) n (_∷_ {m} x xs) = zipWith {Nat} {Vec Nat m} {Vec Nat (suc m)} {n} (_∷_ {Nat} {m}) x (transp _ n xs) test : Term test = rtest transp
{ "alphanum_fraction": 0.5841325196, "avg_line_length": 30.1842105263, "ext": "agda", "hexsha": "063fc54551fc842bfb86123ee862607ad8fa9b10", "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": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "Seanpm2001-Agda-lang/agda", "max_forks_repo_path": "test/Succeed/Issue5075.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "Seanpm2001-Agda-lang/agda", "max_issues_repo_path": "test/Succeed/Issue5075.agda", "max_line_length": 116, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6b13364d36eeb60d8ec15eaf8effe23c73401900", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "sseefried/agda", "max_stars_repo_path": "test/Succeed/Issue5075.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z", "num_tokens": 433, "size": 1147 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020 Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import Optics.All open import LibraBFT.Prelude open import LibraBFT.Hash open import LibraBFT.Lemmas open import LibraBFT.Base.KVMap open import LibraBFT.Base.PKCS open import LibraBFT.Abstract.Types open EpochConfig open import LibraBFT.Impl.NetworkMsg open import LibraBFT.Impl.Consensus.Types open import LibraBFT.Impl.Util.Crypto open import LibraBFT.Impl.Handle sha256 sha256-cr open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Yasm.Base open import LibraBFT.Yasm.AvailableEpochs using (AvailableEpochs ; lookup'; lookup'') open import LibraBFT.Yasm.System ConcSysParms open import LibraBFT.Yasm.Properties ConcSysParms -- This module contains placeholders for the future analog of the -- corresponding VotesOnce property. Defining the implementation -- obligation and proving that it is an invariant of an implementation -- is a substantial undertaking. We are working first on proving the -- simpler VotesOnce property to settle down the structural aspects -- before tackling the harder semantic issues. module LibraBFT.Concrete.Properties.LockedRound where -- TODO-3: define the implementation obligation ImplObligation₁ : Set ImplObligation₁ = Unit -- Next, we prove that given the necessary obligations, module Proof (sps-corr : StepPeerState-AllValidParts) (Impl-LR1 : ImplObligation₁) where -- Any reachable state satisfies the LR rule for any epoch in the system. module _ {e}(st : SystemState e)(r : ReachableSystemState st)(eid : Fin e) where -- Bring in 'unwind', 'ext-unforgeability' and friends open Structural sps-corr -- Bring in ConcSystemState open import LibraBFT.Concrete.System sps-corr open PerState st r open PerEpoch eid open import LibraBFT.Abstract.Obligations.LockedRound 𝓔 Hash _≟Hash_ (ConcreteVoteEvidence 𝓔) as LR postulate -- TODO-3: prove it lrr : LR.Type ConcSystemState
{ "alphanum_fraction": 0.7855140187, "avg_line_length": 35.6666666667, "ext": "agda", "hexsha": "e70d4cd491ba17775af72f56e051adbbc9aee122", "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": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "lisandrasilva/bft-consensus-agda-1", "max_forks_repo_path": "LibraBFT/Concrete/Properties/LockedRound.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "lisandrasilva/bft-consensus-agda-1", "max_issues_repo_path": "LibraBFT/Concrete/Properties/LockedRound.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "lisandrasilva/bft-consensus-agda-1", "max_stars_repo_path": "LibraBFT/Concrete/Properties/LockedRound.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 567, "size": 2140 }
module Cats.Trans.Iso where open import Level using (_⊔_) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl) open import Cats.Category.Base open import Cats.Functor using (Functor) open import Cats.Util.Simp using (simp!) open import Cats.Trans using (Trans ; component ; natural) import Cats.Category.Constructions.Iso as Iso open Functor open Iso.Build._≅_ module _ {lo la l≈ lo′ la′ l≈′} {C : Category lo la l≈} {D : Category lo′ la′ l≈′} where private module C = Category C module D = Category D open module D≅ = Iso.Build D using (_≅_) module ≅ = D≅.≅ open D.≈-Reasoning record NatIso (F G : Functor C D) : Set (lo ⊔ la ⊔ lo′ ⊔ la′ ⊔ l≈′) where field iso : ∀ {c} → fobj F c ≅ fobj G c forth-natural : ∀ {c d} {f : c C.⇒ d} → forth iso D.∘ fmap F f D.≈ fmap G f D.∘ forth iso back-natural : ∀ {c d} {f : c C.⇒ d} → back iso D.∘ fmap G f D.≈ fmap F f D.∘ back iso back-natural {f = f} = begin back iso D.∘ fmap G f ≈⟨ D.∘-resp-r (D.≈.sym D.id-r) ⟩ back iso D.∘ fmap G f D.∘ D.id ≈⟨ D.∘-resp-r (D.∘-resp-r (D.≈.sym (forth-back iso))) ⟩ back iso D.∘ fmap G f D.∘ forth iso D.∘ back iso ≈⟨ simp! D ⟩ back iso D.∘ (fmap G f D.∘ forth iso) D.∘ back iso ≈⟨ D.∘-resp-r (D.∘-resp-l (D.≈.sym forth-natural)) ⟩ back iso D.∘ (forth iso D.∘ fmap F f) D.∘ back iso ≈⟨ simp! D ⟩ (back iso D.∘ (forth iso)) D.∘ fmap F f D.∘ back iso ≈⟨ D.∘-resp-l (back-forth iso) ⟩ D.id D.∘ fmap F f D.∘ back iso ≈⟨ D.id-l ⟩ fmap F f D.∘ back iso ∎ Forth : Trans F G Forth = record { component = λ _ → forth iso ; natural = forth-natural } Back : Trans G F Back = record { component = λ _ → back iso ; natural = back-natural } open NatIso public id : ∀ {F} → NatIso F F id = record { iso = ≅.refl ; forth-natural = D.≈.trans D.id-l (D.≈.sym D.id-r) } sym : ∀ {F G} → NatIso F G → NatIso G F sym θ = record { iso = ≅.sym (iso θ) ; forth-natural = back-natural θ } _∘_ : ∀ {F G H} → NatIso G H → NatIso F G → NatIso F H _∘_ {F} {G} {H} θ ι = record { iso = ≅.trans (iso ι) (iso θ) ; forth-natural = λ {_} {_} {f} → begin (forth (iso θ) D.∘ forth (iso ι)) D.∘ fmap F f ≈⟨ D.assoc ⟩ forth (iso θ) D.∘ forth (iso ι) D.∘ fmap F f ≈⟨ D.∘-resp-r (forth-natural ι) ⟩ forth (iso θ) D.∘ fmap G f D.∘ forth (iso ι) ≈⟨ D.unassoc ⟩ (forth (iso θ) D.∘ fmap G f) D.∘ forth (iso ι) ≈⟨ D.∘-resp-l (forth-natural θ) ⟩ (fmap H f D.∘ forth (iso θ)) D.∘ forth (iso ι) ≈⟨ D.assoc ⟩ fmap H f D.∘ forth (iso θ) D.∘ forth (iso ι) ∎ }
{ "alphanum_fraction": 0.4965729952, "avg_line_length": 26.7706422018, "ext": "agda", "hexsha": "43469d92f69a739af0d76a327909961e445ffa7a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Trans/Iso.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Trans/Iso.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Trans/Iso.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1164, "size": 2918 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Sums (disjoint unions) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Sum.Base where open import Function using (_∘_; _-[_]-_ ; id) open import Relation.Nullary using (Dec; yes; no; ¬_) open import Level using (_⊔_) ------------------------------------------------------------------------ -- Definition infixr 1 _⊎_ data _⊎_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where inj₁ : (x : A) → A ⊎ B inj₂ : (y : B) → A ⊎ B ------------------------------------------------------------------------ -- Functions [_,_] : ∀ {a b c} {A : Set a} {B : Set b} {C : A ⊎ B → Set c} → ((x : A) → C (inj₁ x)) → ((x : B) → C (inj₂ x)) → ((x : A ⊎ B) → C x) [ f , g ] (inj₁ x) = f x [ f , g ] (inj₂ y) = g y [_,_]′ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (A → C) → (B → C) → (A ⊎ B → C) [_,_]′ = [_,_] swap : ∀ {a b} {A : Set a} {B : Set b} → A ⊎ B → B ⊎ A swap (inj₁ x) = inj₂ x swap (inj₂ x) = inj₁ x map : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} → (A → C) → (B → D) → (A ⊎ B → C ⊎ D) map f g = [ inj₁ ∘ f , inj₂ ∘ g ] map₁ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}→ (A → C) → (A ⊎ B → C ⊎ B) map₁ f = map f id map₂ : ∀ {a b d} {A : Set a} {B : Set b} {D : Set d} → (B → D) → (A ⊎ B → A ⊎ D) map₂ = map id infixr 1 _-⊎-_ _-⊎-_ : ∀ {a b c d} {A : Set a} {B : Set b} → (A → B → Set c) → (A → B → Set d) → (A → B → Set (c ⊔ d)) f -⊎- g = f -[ _⊎_ ]- g module _ {p} {P : Set p} where -- Conversion back and forth with Dec fromDec : Dec P → P ⊎ ¬ P fromDec (yes p) = inj₁ p fromDec (no ¬p) = inj₂ ¬p toDec : P ⊎ ¬ P → Dec P toDec (inj₁ p) = yes p toDec (inj₂ ¬p) = no ¬p
{ "alphanum_fraction": 0.3712284483, "avg_line_length": 26.8985507246, "ext": "agda", "hexsha": "ee1dbc118d8ca55f2ade33df436a39e06bf21b69", "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/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/Sum/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/Sum/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 756, "size": 1856 }
------------------------------------------------------------------------------ -- Common FOL definitions ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Common.FOL where infix 6 ∃ infix 4 _≡_ infixr 4 _,_ postulate D : Set -- The existential quantifier type on D. data ∃ (A : D → Set) : Set where _,_ : (t : D) → A t → ∃ A -- The identity type on D. data _≡_ (x : D) : D → Set where refl : x ≡ x
{ "alphanum_fraction": 0.4077669903, "avg_line_length": 24.72, "ext": "agda", "hexsha": "a42995b7c3e24575eb84a22e50ad2dbe4858087a", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Succeed/fol-theorems/Common/FOL.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Succeed/fol-theorems/Common/FOL.agda", "max_line_length": 78, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Succeed/fol-theorems/Common/FOL.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 149, "size": 618 }
------------------------------------------------------------------------ -- "Equational" reasoning combinator setup ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Prelude.Size open import Labelled-transition-system module Similarity.Equational-reasoning-instances {ℓ} {lts : LTS ℓ} {i : Size} where open import Prelude open import Bisimilarity lts open import Equational-reasoning open import Similarity lts instance reflexive≤ : Reflexive [ i ]_≤_ reflexive≤ = is-reflexive reflexive-≤ reflexive≤′ : Reflexive [ i ]_≤′_ reflexive≤′ = is-reflexive reflexive-≤′ convert≤≤ : Convertible [ i ]_≤_ [ i ]_≤_ convert≤≤ = is-convertible id convert≤′≤ : Convertible _≤′_ [ i ]_≤_ convert≤′≤ = is-convertible λ p≤′q → force p≤′q convert≤≤′ : Convertible [ i ]_≤_ [ i ]_≤′_ convert≤≤′ = is-convertible lemma where lemma : ∀ {p q} → [ i ] p ≤ q → [ i ] p ≤′ q force (lemma p≤q) = p≤q convert≤′≤′ : Convertible [ i ]_≤′_ [ i ]_≤′_ convert≤′≤′ = is-convertible id convert∼≤ : Convertible [ i ]_∼_ [ i ]_≤_ convert∼≤ = is-convertible ∼⇒≤ convert∼′≤ : Convertible _∼′_ [ i ]_≤_ convert∼′≤ = is-convertible (convert ∘ ∼⇒≤′) convert∼≤′ : ∀ {i} → Convertible [ i ]_∼_ [ i ]_≤′_ convert∼≤′ {i} = is-convertible lemma where lemma : ∀ {p q} → [ i ] p ∼ q → [ i ] p ≤′ q force (lemma p∼q) = ∼⇒≤ p∼q convert∼′≤′ : ∀ {i} → Convertible [ i ]_∼′_ [ i ]_≤′_ convert∼′≤′ = is-convertible ∼⇒≤′ trans≤≤ : Transitive [ i ]_≤_ [ i ]_≤_ trans≤≤ = is-transitive transitive-≤ trans≤′≤ : Transitive _≤′_ [ i ]_≤_ trans≤′≤ = is-transitive λ p≤′q → transitive (force p≤′q) trans≤′≤′ : Transitive [ i ]_≤′_ [ i ]_≤′_ trans≤′≤′ = is-transitive transitive-≤′ trans≤≤′ : Transitive [ i ]_≤_ [ i ]_≤′_ trans≤≤′ = is-transitive lemma where lemma : ∀ {p q r} → [ i ] p ≤ q → [ i ] q ≤′ r → [ i ] p ≤′ r force (lemma p≤q q≤′r) = transitive-≤ p≤q (force q≤′r)
{ "alphanum_fraction": 0.5336994508, "avg_line_length": 27.8194444444, "ext": "agda", "hexsha": "dcb7eaaa01f5b2e84e78ec50127ee0b84bc04f30", "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": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/up-to", "max_forks_repo_path": "src/Similarity/Equational-reasoning-instances.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "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/up-to", "max_issues_repo_path": "src/Similarity/Equational-reasoning-instances.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/up-to", "max_stars_repo_path": "src/Similarity/Equational-reasoning-instances.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 848, "size": 2003 }
{-# OPTIONS --without-K --safe #-} module Dodo.Binary.Precedes where -- Stdlib imports open import Level using (Level; _⊔_) open import Data.Product using (_×_; _,_) open import Relation.Nullary using (¬_) open import Relation.Unary using (Pred) open import Relation.Binary using (REL; Rel) open import Relation.Binary.Construct.Closure.Transitive using (TransClosure; [_]; _∷_) -- Local imports open import Dodo.Binary.Transitive open import Dodo.Binary.Immediate -- # Definitions # -- `¬ P x` before `¬ P y` -- `P x` before `¬ P y` -- `P x` before `P y` ⊤-Precedes-⊥ : {a ℓ₁ ℓ₂ : Level} {A : Set a} → Pred A ℓ₁ → Rel A ℓ₂ → Set _ ⊤-Precedes-⊥ P R = ∀ {x y} → R x y → (P y → P x) -- We could generalize `⊤-Precedes-⊥` to `Precedes` below: -- -- Precedes : {a ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} → Pred A ℓ₁ → Pred A ℓ₂ → Rel A ℓ₃ → Set _ -- Precedes P Q R = ∀ {x y} → R x y → (P y → P x) × (Q x → Q y) -- -- However, this is semantically a bit cumbersome, as P and Q are /not/ mutually exclusive. -- Which means both P and Q may hold for an element. -- # Helpers # private identity : {a : Level} → {A : Set a} → A → A identity x = x contrapositive : ∀ {a b : Level} {A : Set a} {B : Set b} → ( A → B ) → ( ¬ B → ¬ A ) contrapositive f ¬b a = ¬b (f a) -- # Operations # module _ {a ℓ₁ ℓ₂ : Level} {A : Set a} {P : Pred A ℓ₁} (R : Rel A ℓ₂) where ⊤prec⊥-invert : ⊤-Precedes-⊥ P R → {x y : A} → R x y → ¬ P x → ¬ P y ⊤prec⊥-invert ⊤prec⊥ Rxy ¬Px Py = contrapositive ¬Px identity (⊤prec⊥ Rxy Py) -- # Properties # module _ {a ℓ₁ ℓ₂ : Level} {A : Set a} {P : Pred A ℓ₁} {R : Rel A ℓ₂} where ⊤prec⊥-⁺ : ⊤-Precedes-⊥ P R → ⊤-Precedes-⊥ P (TransClosure R) ⊤prec⊥-⁺ Pprec¬P [ x∼y ] Py = Pprec¬P x∼y Py ⊤prec⊥-⁺ Pprec¬P (x∼y ∷ y~⁺z) Py = Pprec¬P x∼y (⊤prec⊥-⁺ Pprec¬P y~⁺z Py) ⊤prec⊥-imm : ⊤-Precedes-⊥ P R → ⊤-Precedes-⊥ P (immediate R) ⊤prec⊥-imm Pprec¬P (x~y , ¬∃z) Py = Pprec¬P x~y Py
{ "alphanum_fraction": 0.5839378238, "avg_line_length": 30.6349206349, "ext": "agda", "hexsha": "b23413a03f9ce64dde75222d6b2ef2b5f6e83ca1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "sourcedennis/agda-dodo", "max_forks_repo_path": "src/Dodo/Binary/Precedes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "sourcedennis/agda-dodo", "max_issues_repo_path": "src/Dodo/Binary/Precedes.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "sourcedennis/agda-dodo", "max_stars_repo_path": "src/Dodo/Binary/Precedes.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 816, "size": 1930 }
-- Copyright 2020 Frederik Zipp. All rights reserved. -- Use of this source code is governed by a BSD-style -- license that can be found in the LICENSE file. module GameOfLife where open import Data.Bool using (Bool; _∨_; if_then_else_) open import Data.Nat using (ℕ; suc; _+_; _<ᵇ_; _≡ᵇ_) open import Data.List using (List; []; _∷_; length; zipWith; upTo; sum; map) open import Data.Maybe using (Maybe; just; nothing; fromMaybe) open import Data.String using (String; intersperse) open import Function using (_∘_; id; _$_) open import IO using (run; putStrLn) ---- Utility functions ---- mapWithIndex : ∀ {A B : Set} → (ℕ → A → B) → List A → List B mapWithIndex f xs = zipWith f (upTo (length xs)) xs _element_ : ∀ {A : Set} → List A → ℕ → Maybe A [] element n = nothing (x ∷ xs) element 0 = just x (x ∷ xs) element suc n = xs element n _-_ : ℕ → ℕ → Maybe ℕ m - 0 = just m 0 - (suc n) = nothing suc m - suc n = m - n catMaybes : ∀ {A : Set} → List (Maybe A) → List A catMaybes [] = [] catMaybes (nothing ∷ xs) = catMaybes xs catMaybes (just x ∷ xs) = x ∷ catMaybes xs ---- Domain ---- data Cell : Set where □ : Cell ■ : Cell aliveCount : Cell → ℕ aliveCount □ = 0 aliveCount ■ = 1 Row : Set Row = List Cell Board : Set Board = List Row data Pos : Set where ⟨_,_⟩ : ℕ → ℕ → Pos ⟨_,_⟩? : Maybe ℕ → Maybe ℕ → Maybe Pos ⟨ just colᵢ , just rowᵢ ⟩? = just ⟨ colᵢ , rowᵢ ⟩ ⟨ just colᵢ , nothing ⟩? = nothing ⟨ nothing , just rowᵢ ⟩? = nothing ⟨ nothing , nothing ⟩? = nothing neighbourPositions : Pos → List Pos neighbourPositions ⟨ colᵢ , rowᵢ ⟩ = catMaybes ( ⟨ (colᵢ - 1) , (rowᵢ - 1) ⟩? ∷ ⟨ (colᵢ - 1) , just (rowᵢ + 0) ⟩? ∷ ⟨ (colᵢ - 1) , just (rowᵢ + 1) ⟩? ∷ ⟨ just (colᵢ + 0) , (rowᵢ - 1) ⟩? ∷ ⟨ just (colᵢ + 0) , just (rowᵢ + 1) ⟩? ∷ ⟨ just (colᵢ + 1) , (rowᵢ - 1) ⟩? ∷ ⟨ just (colᵢ + 1) , just (rowᵢ + 0) ⟩? ∷ ⟨ just (colᵢ + 1) , just (rowᵢ + 1) ⟩? ∷ []) cellAt : Board → Pos → Cell cellAt board ⟨ colᵢ , rowᵢ ⟩ = fromMaybe □ ((fromMaybe [] (board element rowᵢ)) element colᵢ) aliveCountAt : Board → Pos → ℕ aliveCountAt board = aliveCount ∘ cellAt board neighbourCount : Board → Pos → ℕ neighbourCount board pos = sum $ map (aliveCountAt board) (neighbourPositions pos) nextCell : Cell → ℕ → Cell nextCell ■ neighbours = if (neighbours <ᵇ 2) ∨ (3 <ᵇ neighbours) then □ else ■ nextCell □ neighbours = if (neighbours ≡ᵇ 3) then ■ else □ nextRow : Board → ℕ → Row → Row nextRow board rowᵢ = mapWithIndex (λ colᵢ cell → nextCell cell (neighbourCount board ⟨ colᵢ , rowᵢ ⟩)) nextGen : Board → Board nextGen board = mapWithIndex (nextRow board) board nthGen : ℕ → Board → Board nthGen 0 = id nthGen (suc n) = nextGen ∘ nthGen n ---- "Tests" ---- import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) -- Glider gliderBoard : Board gliderBoard = ( (□ ∷ ■ ∷ □ ∷ □ ∷ []) ∷ (□ ∷ □ ∷ ■ ∷ □ ∷ []) ∷ (■ ∷ ■ ∷ ■ ∷ □ ∷ []) ∷ (□ ∷ □ ∷ □ ∷ □ ∷ []) ∷ (□ ∷ □ ∷ □ ∷ □ ∷ []) ∷ []) assertGliderGen4 : nthGen 4 gliderBoard ≡ ( (□ ∷ □ ∷ □ ∷ □ ∷ []) ∷ (□ ∷ □ ∷ ■ ∷ □ ∷ []) ∷ (□ ∷ □ ∷ □ ∷ ■ ∷ []) ∷ (□ ∷ ■ ∷ ■ ∷ ■ ∷ []) ∷ (□ ∷ □ ∷ □ ∷ □ ∷ []) ∷ []) assertGliderGen4 = refl -- Blinker blinker_v : Board blinker_v = ( (□ ∷ ■ ∷ □ ∷ []) ∷ (□ ∷ ■ ∷ □ ∷ []) ∷ (□ ∷ ■ ∷ □ ∷ []) ∷ []) blinker_h : Board blinker_h = ( (□ ∷ □ ∷ □ ∷ []) ∷ (■ ∷ ■ ∷ ■ ∷ []) ∷ (□ ∷ □ ∷ □ ∷ []) ∷ []) assertBlinkerGen0 : nthGen 0 blinker_v ≡ blinker_v assertBlinkerGen0 = refl assertBlinkerGen1 : nthGen 1 blinker_v ≡ blinker_h assertBlinkerGen1 = refl assertBlinkerGen2 : nthGen 2 blinker_v ≡ blinker_v assertBlinkerGen2 = refl assertBlinkerGen3 : nthGen 3 blinker_v ≡ blinker_h assertBlinkerGen3 = refl gen0-ident : ∀ {b : Board} → nthGen 0 b ≡ b gen0-ident = refl ---- Main ---- showCell : Cell → String showCell □ = "□" showCell ■ = "■" showRow : Row → String showRow = intersperse " " ∘ map showCell showBoard : Board → String showBoard = intersperse "\n" ∘ map showRow main = run $ putStrLn ∘ showBoard ∘ nthGen 3 $ blinker_h
{ "alphanum_fraction": 0.5806132542, "avg_line_length": 24.6585365854, "ext": "agda", "hexsha": "ce7fabea57e2c93b062e5b9d5668082fb0080fe6", "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": "18dda7f45541d2e8f47c351d72a20a25d3bfb4be", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "fzipp/agda-life", "max_forks_repo_path": "GameOfLife.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "18dda7f45541d2e8f47c351d72a20a25d3bfb4be", "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": "fzipp/agda-life", "max_issues_repo_path": "GameOfLife.agda", "max_line_length": 102, "max_stars_count": null, "max_stars_repo_head_hexsha": "18dda7f45541d2e8f47c351d72a20a25d3bfb4be", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "fzipp/agda-life", "max_stars_repo_path": "GameOfLife.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1705, "size": 4044 }
module Structure.Function.Names where open import Function.Names open import Functional open import Logic open import Logic.Propositional open import Logic.Predicate import Lvl open import Structure.Setoid.Uniqueness open import Structure.Setoid open import Type private variable ℓₒ ℓₒ₁ ℓₒ₂ ℓₒ₃ ℓₒ₄ ℓₗ ℓₗ₁ ℓₗ₂ ℓₗ₃ ℓₗ₄ : Lvl.Level module _ {A : Type{ℓₒ₁}} ⦃ equiv-A : Equiv{ℓₗ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₗ₂}(B) ⦄ where Injective : (A → B) → Stmt Injective(f) = (∀{x y : A} → (f(x) ≡ f(y)) → (x ≡ y)) module _ {A : Type{ℓₒ₁}} {B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₗ₂}(B) ⦄ where Surjective : (A → B) → Stmt Surjective(f) = (∀{y : B} → ∃(x ↦ f(x) ≡ y)) module _ {A : Type{ℓₒ₁}} ⦃ equiv-A : Equiv{ℓₗ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₗ₂}(B) ⦄ where Bijective : (A → B) → Stmt Bijective(f) = (∀{y : B} → ∃!(x ↦ f(x) ≡ y)) module _ {A : Type{ℓₒ₁}} {B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₗ₂}(B) ⦄ where InversesOn : (A → B) → (B → A) → B → Stmt InversesOn f g x = ((f ∘ g)(x) ≡ x) Inverses : (A → B) → (B → A) → Stmt Inverses f g = ∀¹(InversesOn f g) Constant : (A → B) → Stmt Constant(f) = (∀{x y : A} → (f(x) ≡ f(y))) module _ {A : Type{ℓₒ}} ⦃ equiv : Equiv{ℓₗ}(A) ⦄ where Fixpoint : (A → A) → A → Stmt Fixpoint f(x) = (f(x) ≡ x) InvolutionOn : (A → A) → A → Stmt InvolutionOn f(x) = InversesOn f f x -- (f ∘ f)(x) ≡ x -- f(f(x)) ≡ x Involution : (A → A) → Stmt Involution(f) = Inverses f f IdempotentOn : (A → A) → A → Stmt IdempotentOn f(x) = Fixpoint f(f(x)) -- (f ∘ f)(x) ≡ f(x) -- f(f(x)) ≡ f(x) Idempotent : (A → A) → Stmt Idempotent(f) = ∀ₗ(IdempotentOn f) module _ {A : Type{ℓₒ₁}} ⦃ equiv-A : Equiv{ℓₗ₁}(A) ⦄ {B : Type{ℓₒ₂}} ⦃ equiv-B : Equiv{ℓₗ₂}(B) ⦄ where Congruence₁ : (A → B) → Stmt Congruence₁(f) = (∀{x y : A} → (x ≡ y) → (f(x) ≡ f(y))) module _ {C : Type{ℓₒ₃}} ⦃ _ : Equiv{ℓₗ₃}(C) ⦄ where Congruence₂ : (A → B → C) → Stmt Congruence₂(f) = (∀{x₁ y₁ : A}{x₂ y₂ : B} → (x₁ ≡ y₁) → (x₂ ≡ y₂) → (f x₁ x₂ ≡ f y₁ y₂)) module _ {D : Type{ℓₒ₄}} ⦃ _ : Equiv{ℓₗ₄}(D) ⦄ where Congruence₃ : (A → B → C → D) → Stmt Congruence₃(f) = (∀{x₁ y₁ : A}{x₂ y₂ : B}{x₃ y₃ : C} → (x₁ ≡ y₁) → (x₂ ≡ y₂) → (x₃ ≡ y₃) → (f x₁ x₂ x₃ ≡ f y₁ y₂ y₃)) module _ {A : Type{ℓₒ₁}} {B : Type{ℓₒ₂}} ⦃ _ : Equiv{ℓₗ₂}(B) ⦄ ⦃ _ : Equiv{ℓₗ₃}(A → B) ⦄ where FunctionExtensionalityOn : (A → B) → (A → B) → Stmt FunctionExtensionalityOn(f)(g) = ((f ⊜ g) → (f ≡ g)) FunctionApplicationOn : (A → B) → (A → B) → Stmt FunctionApplicationOn(f)(g) = ((f ≡ g) → (f ⊜ g)) module _ (A : Type{ℓₒ₁}) (B : Type{ℓₒ₂}) ⦃ _ : Equiv{ℓₗ₂}(B) ⦄ ⦃ _ : Equiv{ℓₗ₃}(A → B) ⦄ where FunctionExtensionality : Stmt FunctionExtensionality = ∀²(FunctionExtensionalityOn{ℓₒ₁}{ℓₒ₂}{ℓₗ₂}{ℓₗ₃}{A}{B}) FunctionApplication : Stmt FunctionApplication = ∀²(FunctionApplicationOn{ℓₒ₁}{ℓₒ₂}{ℓₗ₂}{ℓₗ₃}{A}{B}) module _ {A : Type{ℓₒ₁}} {B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄ ⦃ _ : Equiv{ℓₗ₃}((a : A) → B(a)) ⦄ where DependentFunctionExtensionalityOn : ((a : A) → B(a)) → ((a : A) → B(a)) → Stmt DependentFunctionExtensionalityOn(f)(g) = ((f ⊜ g) → (f ≡ g)) module _ (A : Type{ℓₒ₁}) (B : A → Type{ℓₒ₂}) ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄ ⦃ _ : Equiv{ℓₗ₃}((a : A) → B(a)) ⦄ where DependentFunctionExtensionality : Stmt DependentFunctionExtensionality = ∀²(DependentFunctionExtensionalityOn{ℓₒ₁}{ℓₒ₂}{ℓₗ₂}{ℓₗ₃}{A}{B}) module _ {A : Type{ℓₒ₁}} {B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄ ⦃ _ : Equiv{ℓₗ₃}({a : A} → B(a)) ⦄ where DependentImplicitFunctionExtensionalityOn : ({a : A} → B(a)) → ({a : A} → B(a)) → Stmt DependentImplicitFunctionExtensionalityOn(f)(g) = (((\{a} → f{a}) ⊜ᵢ (\{a} → g{a})) → ((\{a} → f{a}) ≡ (\{a} → g{a}))) module _ (A : Type{ℓₒ₁}) (B : A → Type{ℓₒ₂}) ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄ ⦃ _ : Equiv{ℓₗ₃}({a : A} → B(a)) ⦄ where DependentImplicitFunctionExtensionality : Stmt DependentImplicitFunctionExtensionality = ∀²(DependentImplicitFunctionExtensionalityOn{ℓₒ₁}{ℓₒ₂}{ℓₗ₂}{ℓₗ₃}{A}{B}) module _ {A : Type{ℓₒ₁}} {B : A → Type{ℓₒ₂}} ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄ ⦃ _ : Equiv{ℓₗ₃}(⦃ a : A ⦄ → B(a)) ⦄ where DependentInstanceFunctionExtensionalityOn : (⦃ a : A ⦄ → B(a)) → (⦃ a : A ⦄ → B(a)) → Stmt DependentInstanceFunctionExtensionalityOn(f)(g) = (((\ ⦃ a ⦄ → f ⦃ a ⦄) ⦃⊜⦄ (\ ⦃ a ⦄ → g ⦃ a ⦄)) → ((\ ⦃ a ⦄ → f ⦃ a ⦄) ≡ (\ ⦃ a ⦄ → g ⦃ a ⦄))) module _ (A : Type{ℓₒ₁}) (B : A → Type{ℓₒ₂}) ⦃ _ : ∀{a} → Equiv{ℓₗ₂}(B(a)) ⦄ ⦃ _ : Equiv{ℓₗ₃}(⦃ a : A ⦄ → B(a)) ⦄ where DependentInstanceFunctionExtensionality : Stmt DependentInstanceFunctionExtensionality = ∀²(DependentInstanceFunctionExtensionalityOn{ℓₒ₁}{ℓₒ₂}{ℓₗ₂}{ℓₗ₃}{A}{B})
{ "alphanum_fraction": 0.5604466395, "avg_line_length": 43.9339622642, "ext": "agda", "hexsha": "5a4eeeb7d778f4f64a21868b1bf9a0652b2f9e68", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Structure/Function/Names.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Function/Names.agda", "max_line_length": 145, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Structure/Function/Names.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 2418, "size": 4657 }
module Acc where data Acc ( A : Set ) ( Lt : A -> A -> Set) : A -> Set where acc : ( b : A ) -> ( ( a : A ) -> Lt a b -> Acc A Lt a ) -> ( Acc A Lt b ) data Nat : Set where zero : Nat succ : Nat -> Nat data Lt : Nat -> Nat -> Set where ltzero : ( x : Nat ) -> Lt zero (succ x) ltsucc : ( x : Nat ) -> (y : Nat) -> Lt x y -> Lt (succ x) (succ y) notLt0 : ( x : Nat ) -> Lt x zero -> (C : Set) -> C notLt0 x () accLt : ( x : Nat ) -> Acc Nat Lt x accLt zero = acc zero (\a -> \p -> notLt0 a p (Acc Nat Lt a) ) accLt (succ x) = acc (succ x) (\a -> \p -> (accLt a)) ---- data WO ( A : Set ) ( Lt : A -> A -> Set ) : Set where wo : ((x : A) -> Acc A Lt x) -> WO A Lt woLt : WO Nat Lt woLt = wo accLt
{ "alphanum_fraction": 0.4582210243, "avg_line_length": 23.1875, "ext": "agda", "hexsha": "827eda55bd346aec632b568f53796256aa2394ce", "lang": "Agda", "max_forks_count": 5, "max_forks_repo_forks_event_max_datetime": "2021-08-16T07:47:36.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-30T00:17:04.000Z", "max_forks_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andreasabel/miniagda", "max_forks_repo_path": "examples/Acc.agda", "max_issues_count": 7, "max_issues_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08", "max_issues_repo_issues_event_max_datetime": "2020-03-17T08:09:01.000Z", "max_issues_repo_issues_event_min_datetime": "2016-12-16T15:48:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andreasabel/miniagda", "max_issues_repo_path": "examples/Acc.agda", "max_line_length": 69, "max_stars_count": 85, "max_stars_repo_head_hexsha": "4a674eddcc8950f37fcc723b26f81d5164b05f08", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andreasabel/miniagda", "max_stars_repo_path": "examples/Acc.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-12T16:54:56.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-16T15:53:24.000Z", "num_tokens": 284, "size": 742 }
{-# OPTIONS --safe #-} module JVM.Printer.Jasmin where open import Function open import Data.Nat open import Data.Integer open import Data.Nat.Show as NatShow open import Data.String as S using (String) open import Data.List as List open import JVM.Types open import JVM.Builtins sep : List (List String) → List String sep = List.concat ∘ List.intersperse [ " " ] Words = List String abstract Line = String Lines = List String unwords : Words → Line unwords = S.unwords line : String → Line line = id lines : List Line → Lines lines = id unlines : Lines → String unlines = S.unlines infixr 4 _<+_ _<+_ : Line → Lines → Lines l <+ ls = l ∷ ls infixl 6 _+>_ _+>_ : Lines → Line → Lines ls +> l = ls ∷ʳ l infixl 4 _<>_ _<>_ : Lines → Lines → Lines ls <> js = ls ++ js pars : List Lines → Lines pars = concat ident : Line → Line ident = "\t" S.++_ indent : Lines → Lines indent = List.map ident record ClassSpec : Set where constructor class field class_name : String out : Line out = unwords $ ".class" ∷ "public" ∷ class_name ∷ [] record SuperSpec : Set where constructor super field class_name : String out : Line out = unwords $ ".super" ∷ class_name ∷ [] record Header : Set where field class_spec : ClassSpec super_spec : SuperSpec out : Lines out = lines $ ClassSpec.out class_spec ∷ SuperSpec.out super_spec ∷ [] module Descriptor where type-desc : Ty → String type-desc boolean = "Z" type-desc byte = "B" type-desc short = "S" type-desc int = "I" type-desc long = "J" type-desc char = "C" type-desc (array t) = "[" S.++ type-desc t type-desc (ref cls) = S.concat $ "L" ∷ cls ∷ ";" ∷ [] ret-desc : Ret → String ret-desc void = "V" ret-desc (ty t) = type-desc t out : List Ty → Ret → String out as r = args as S.++ ret-desc r where args : List Ty → String args d = "(" S.++ (S.intersperse ";" (List.map type-desc d)) S.++ ")" data Comparator : Set where eq ne lt ge gt le : Comparator icmpge icmpgt icmpeq icmpne icmplt icmple : Comparator open import JVM.Types using (Fun) module Comp where out : Comparator → String out eq = "eq" out ne = "ne" out lt = "lt" out ge = "ge" out gt = "gt" out le = "le" out icmpge = "_icmpge" out icmpgt = "_icmpgt" out icmpeq = "_icmpeq" out icmpne = "_icmpne" out icmplt = "_icmplt" out icmple = "_icmple" data Instr : Set where nop pop dup swap ret : Instr aconst_null : Instr bipush sipush : ℤ → Instr iconstm1 iconst0 iconst1 iconst2 : Instr aaload aload iload : ℕ → Instr aastore astore istore : ℕ → Instr new : String → Instr goto : String → Instr if : Comparator → String → Instr iadd isub imul idiv ixor : Instr invokevirtual invokespecial invokestatic : Fun → Instr module Funs where out : Fun → String out (c / m :⟨ as ⟩ r) = c S.++ "/" S.++ m S.++ Descriptor.out as r module Instruction where lbl : String → String lbl x = "label_" S.++ x showInt : ℤ → String showInt (+ n) = NatShow.show n showInt (-[1+ n ]) = "-" S.++ NatShow.show (ℕ.suc n) out : Instr → Line out nop = line "nop" out pop = line "pop" out dup = line "dup" out swap = line "swap" out ret = line "return" out aconst_null = line "aconst_null" out (bipush n) = unwords $ "sipush" ∷ showInt n ∷ [] out (sipush n) = unwords $ "bipush" ∷ showInt n ∷ [] out (aload n) = unwords $ "aload" ∷ NatShow.show n ∷ [] out (astore n) = unwords $ "astore" ∷ NatShow.show n ∷ [] out (iload n) = unwords $ "iload" ∷ NatShow.show n ∷ [] out (istore n) = unwords $ "istore" ∷ NatShow.show n ∷ [] out (aaload n) = unwords $ "aaload" ∷ NatShow.show n ∷ [] out (aastore n) = unwords $ "astore" ∷ NatShow.show n ∷ [] out iconstm1 = line "iconstm1" out iconst0 = line "iconst_0" out iconst1 = line "iconst_1" out iconst2 = line "iconst_2" out (goto l) = unwords $ "goto" ∷ lbl l ∷ [] out (if c l) = unwords $ ("if" S.++ Comp.out c) ∷ lbl l ∷ [] out iadd = line "iadd" out isub = line "isub" out imul = line "imul" out idiv = line "idiv" out ixor = line "ixor" out (new c) = unwords $ "new" ∷ c ∷ [] out (invokespecial sf) = unwords $ "invokespecial" ∷ Funs.out sf ∷ [] out (invokestatic sf) = unwords $ "invokestatic" ∷ Funs.out sf ∷ [] out (invokevirtual sf) = unwords $ "invokevirtual" ∷ Funs.out sf ∷ [] data Stat : Set where label : String → Stat instr : Instr → Stat module Statement where out : Stat → Line out (label x) = line $ Instruction.lbl x S.++ ":" out (instr x) = Instruction.out x record ClassField : Set where constructor clsfield field name : String access : List String f_ty : Ty out : Line out = unwords $ ".field" ∷ access ++ name ∷ Descriptor.type-desc f_ty ∷ [] record Method : Set where constructor method field name : String access : List String locals : ℕ stacksize : ℕ m_args : List Ty m_ret : Ret body : List Stat out : Lines out = (unwords $ ".method" ∷ (S.unwords access) ∷ (name S.++ Descriptor.out m_args m_ret) ∷ []) <+ (ident $ unwords $ ".limit locals" ∷ NatShow.show locals ∷ []) <+ (ident $ unwords $ ".limit stack" ∷ NatShow.show stacksize ∷ []) <+ (lines $ List.map (ident ∘ Statement.out) body) +> (line $ ".end method") record Jasmin : Set where constructor jasmin field header : Header fields : List ClassField methods : List Method out : Lines out = Header.out header <> lines (List.map ClassField.out fields) <> pars (List.map Method.out methods) module _ where defaultInit : Method defaultInit = method "<init>" [ "public" ] 1 1 [] void ( instr (aload 0) ∷ instr (invokespecial (Object / "<init>" :⟨ [] ⟩ void)) ∷ instr ret ∷ [] ) procedure : (name : String) → ℕ → ℕ → List Stat → Jasmin procedure name locals stack st = jasmin (record { class_spec = class name ; super_spec = super Object }) [] ( method "apply" ("public" ∷ "static" ∷ []) locals stack [] void (st ∷ʳ instr ret) ∷ defaultInit ∷ method "main" ("public" ∷ "static" ∷ []) 1 0 [ array (ref "java/lang/String") ] void ( instr (invokestatic (name / "apply" :⟨ [] ⟩ void)) ∷ instr ret ∷ [] ) ∷ [] )
{ "alphanum_fraction": 0.5655182568, "avg_line_length": 24.6981818182, "ext": "agda", "hexsha": "205707c4e9d237fa6a7cf17eba9555f550c3eb47", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ajrouvoet/jvm.agda", "max_forks_repo_path": "src/JVM/Printer/Jasmin.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "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": "ajrouvoet/jvm.agda", "max_issues_repo_path": "src/JVM/Printer/Jasmin.agda", "max_line_length": 98, "max_stars_count": 6, "max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ajrouvoet/jvm.agda", "max_stars_repo_path": "src/JVM/Printer/Jasmin.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z", "num_tokens": 2185, "size": 6792 }
{-# OPTIONS --safe --no-guardedness #-} record Stream (A : Set) : Set where coinductive field head : A tail : Stream A open Stream repeat : ∀ {A} → A → Stream A repeat x .head = x repeat x .tail = repeat x
{ "alphanum_fraction": 0.6108597285, "avg_line_length": 15.7857142857, "ext": "agda", "hexsha": "4d99231a09ca9b1ac7cca718167da4f36010ede5", "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/Issue1209-5.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue1209-5.agda", "max_line_length": 39, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue1209-5.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 70, "size": 221 }
------------------------------------------------------------------------ -- An alternative backend ------------------------------------------------------------------------ -- Acknowledgements: -- -- • The use of parsing "processes" is based on implementation C from -- Koen Claessen's paper Parallel parsing processes. -- -- • The idea to use toProc is due to Jean-Philippe Bernardy. -- It is not obvious how to adapt this backend so that it can handle -- parsers which are simultaneously left and right recursive, like -- TotalRecognisers.LeftRecursion.leftRight. open import Relation.Binary open import Relation.Binary.PropositionalEquality module TotalRecognisers.Simple.AlternativeBackend (Tok : Set) (_≟_ : Decidable (_≡_ {A = Tok})) -- The tokens must come with decidable equality. where open import Codata.Musical.Notation open import Data.Bool hiding (_≟_) open import Data.List open import Relation.Nullary.Decidable import TotalRecognisers.Simple as S open S Tok _≟_ hiding (_∈?_) ------------------------------------------------------------------------ -- Parsing "processes" data Proc : Set where tokenBind : (p : Tok → ∞ Proc) → Proc emptyOr : (p : Proc) → Proc fail : Proc -- The semantics of Proc is given by run: run p s is true iff s is a -- member of the language defined by p. run : Proc → List Tok → Bool run (tokenBind p) (c ∷ s) = run (♭ (p c)) s run (emptyOr p) s = null s ∨ run p s run _ _ = false ------------------------------------------------------------------------ -- Parsers can be turned into processes -- Here I use my technique for "beating the productivity checker". -- Process "programs". infixl 5 _∣_ data ProcP : Set where -- Process primitives. tokenBind : (p : Tok → ∞ ProcP) → ProcP emptyOr : (p : ProcP) → ProcP fail : ProcP -- Symmetric choice. _∣_ : (p₁ p₂ : ProcP) → ProcP -- Embedding of parsers. toProc : ∀ {n} (p : P n) (κ : ProcP) → ProcP -- WHNFs. data ProcW : Set where tokenBind : (p : Tok → ∞ ProcP) → ProcW emptyOr : (p : ProcW) → ProcW fail : ProcW -- WHNFs can be turned into programs. program : ProcW → ProcP program (tokenBind p) = tokenBind p program (emptyOr p) = emptyOr (program p) program fail = fail -- Symmetric choice for WHNFs. _∣W_ : ProcW → ProcW → ProcW tokenBind p₁ ∣W tokenBind p₂ = tokenBind (λ c → ♯ (♭ (p₁ c) ∣ ♭ (p₂ c))) emptyOr p₁ ∣W emptyOr p₂ = emptyOr (p₁ ∣W p₂) emptyOr p₁ ∣W p₂ = emptyOr (p₁ ∣W p₂) p₁ ∣W emptyOr p₂ = emptyOr (p₁ ∣W p₂) fail ∣W p₂ = p₂ p₁ ∣W fail = p₁ -- Interpretation of toProc. mutual toProcW′ : ∀ {n} → P n → if n then ProcW else ProcP → ProcW toProcW′ fail κ = fail toProcW′ empty κ = κ toProcW′ (tok t) κ = tokenBind (λ t′ → if ⌊ t ≟ t′ ⌋ then ♯ κ else ♯ fail) toProcW′ (_∣_ {n₁ = true } {n₂ = true } p₁ p₂) κ = toProcW′ p₁ κ ∣W toProcW′ p₂ κ toProcW′ (_∣_ {n₁ = true } {n₂ = false} p₁ p₂) κ = toProcW′ p₁ κ ∣W toProcW p₂ κ toProcW′ (_∣_ {n₁ = false} {n₂ = true } p₁ p₂) κ = toProcW p₁ κ ∣W toProcW′ p₂ κ toProcW′ (_∣_ {n₁ = false} {n₂ = false} p₁ p₂) κ = toProcW′ p₁ κ ∣W toProcW′ p₂ κ toProcW′ (_·_ {n₁ = true } p₁ p₂) κ = toProcW′ p₁ (toProcW′ p₂ κ) toProcW′ (_·_ {n₁ = false} p₁ p₂) κ = toProcW′ p₁ (toProc (♭ p₂) κ) toProcW : ∀ {n} → P n → ProcW → ProcW toProcW {true } p κ = toProcW′ p κ toProcW {false} p κ = toProcW′ p (program κ) -- Programs can be turned into WHNFs. whnf : ProcP → ProcW whnf (tokenBind p) = tokenBind p whnf (emptyOr p) = emptyOr (whnf p) whnf fail = fail whnf (p₁ ∣ p₂) = whnf p₁ ∣W whnf p₂ whnf (toProc p κ) = toProcW p (whnf κ) -- Programs can be turned into processes. mutual ⟦_⟧W : ProcW → Proc ⟦ tokenBind p ⟧W = tokenBind (λ c → ♯ ⟦ ♭ (p c) ⟧P) ⟦ emptyOr p ⟧W = emptyOr ⟦ p ⟧W ⟦ fail ⟧W = fail ⟦_⟧P : ProcP → Proc ⟦ p ⟧P = ⟦ whnf p ⟧W ------------------------------------------------------------------------ -- Alternative backend -- I have not proved that this implementation is correct. infix 4 _∈?_ _∈?_ : ∀ {n} → List Tok → P n → Bool s ∈? p = run ⟦ toProc p (emptyOr fail) ⟧P s
{ "alphanum_fraction": 0.5371169126, "avg_line_length": 30.5902777778, "ext": "agda", "hexsha": "ce18b5fd012f3a89ed785f601bfcb34f3c179a33", "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": "TotalRecognisers/Simple/AlternativeBackend.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "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/parser-combinators", "max_issues_repo_path": "TotalRecognisers/Simple/AlternativeBackend.agda", "max_line_length": 90, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalRecognisers/Simple/AlternativeBackend.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 1456, "size": 4405 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Hash open import LibraBFT.Base.PKCS open import LibraBFT.Base.Encode -- The ground types that are common across Abstract, Concrete and Impl -- and some utility types module LibraBFT.Base.Types where Epoch : Set Epoch = ℕ Round : Set Round = ℕ -- This was intended to be a simple way to flag meta-information without having it -- getting in the way. It's important to ensure that an implementation does not -- use various information, such as who is honest. However, we found this got in -- the way too much during development, so for now we get a similar effect by using -- a naming convention and enforcement via grep and eyeballs. Maybe one day... Meta : ∀{ℓ} → Set ℓ → Set ℓ Meta x = x -- An EPRound is a 'compound round'; that is, -- is a round coupled with an epoch id. As most of our -- proofs are per-epoch so far, these are not used, but -- they may be in future. EpRound : Set EpRound = Epoch × Round sucr : EpRound → EpRound sucr (e , r) = (e , suc r) epr-epoch : EpRound → Epoch epr-epoch = proj₁ epr-round : EpRound → Round epr-round = proj₂ epr₀ : EpRound epr₀ = (0 , 0) -- Compound rounds admit a total order data _<ER_ : EpRound → EpRound → Set where ince : ∀{e₀ e₁ r₀ r₁} → e₀ < e₁ → (e₀ , r₀) <ER (e₁ , r₁) incr : ∀{e r₀ r₁} → r₀ < r₁ → (e , r₀) <ER (e , r₁) <ER-irrelevant : Irrelevant _<ER_ <ER-irrelevant (ince x) (ince x₁) = cong ince (<-irrelevant x x₁) <ER-irrelevant (ince x) (incr x₁) = ⊥-elim (<-irrefl refl x) <ER-irrelevant (incr x) (ince x₁) = ⊥-elim (<-irrefl refl x₁) <ER-irrelevant (incr x) (incr x₁) = cong incr (<-irrelevant x x₁) <ER-asym : Asymmetric _<ER_ <ER-asym (ince x) (ince x₁) = <-asym x x₁ <ER-asym (ince x) (incr x₁) = <-irrefl refl x <ER-asym (incr x) (ince x₁) = <-irrefl refl x₁ <ER-asym (incr x) (incr x₁) = <-asym x x₁ <ER-trans : Transitive _<ER_ <ER-trans (ince x) (ince x₁) = ince (<-trans x x₁) <ER-trans (ince x) (incr x₁) = ince x <ER-trans (incr x) (ince x₁) = ince x₁ <ER-trans (incr x) (incr x₁) = incr (<-trans x x₁) <ER-irrefl : Irreflexive _≡_ _<ER_ <ER-irrefl refl (ince x) = <-irrefl refl x <ER-irrefl refl (incr x) = <-irrefl refl x postulate -- prove, if needed/used <ER-cmp : Trichotomous _≡_ _<ER_ {- This <ER relation is not currently used. If it turns out to be used: TODO-1: finish this proof <ER-cmp (e₀ , r₀) (e₁ , r₁) with <-cmp e₀ e₁ ...| tri≈ e₀≮e₁ refl e₁≮e₀ = {!!} {!!} {!!} ...| tri< e₀<e₁ e₀≢e₁ e₁≮e₀ = tri< (ince e₀<e₁) {!!} {!!} ...| tri> e₀≮e₁ e₀≢e₁ e₁<e₀ = {!!} -} ep≮epr₀ : ∀{ep} → ¬ (ep <ER epr₀) ep≮epr₀ (ince ()) ep≮epr₀ (incr ()) _≤ER_ : EpRound → EpRound → Set er₀ ≤ER er₁ = er₀ ≡ er₁ ⊎ er₀ <ER er₁ ≤ER⇒epoch≤ : ∀{er₀ er₁} → er₀ ≤ER er₁ → epr-epoch er₀ ≤ epr-epoch er₁ ≤ER⇒epoch≤ (inj₁ refl) = ≤-refl ≤ER⇒epoch≤ (inj₂ (ince x)) = <⇒≤ x ≤ER⇒epoch≤ (inj₂ (incr x)) = ≤-refl ≤ER⇒round≤ : ∀{er₀ er₁} → er₀ ≤ER er₁ → epr-epoch er₀ ≡ epr-epoch er₁ → epr-round er₀ ≤ epr-round er₁ ≤ER⇒round≤ (inj₁ refl) hyp1 = ≤-refl ≤ER⇒round≤ (inj₂ (ince x)) refl = ⊥-elim (<-irrefl refl x) ≤ER⇒round≤ (inj₂ (incr x)) hyp1 = <⇒≤ x ≤ER-intro : ∀{e₀ e₁ r₀ r₁} → e₀ ≤ e₁ → r₀ ≤ r₁ → (e₀ , r₀) ≤ER (e₁ , r₁) ≤ER-intro {e0} {e1} {r0} {r1} e r with e0 ≟ℕ e1 ...| no le = inj₂ (ince (≤∧≢⇒< e le)) ...| yes refl with r0 ≟ℕ r1 ...| no le = inj₂ (incr (≤∧≢⇒< r le)) ...| yes refl = inj₁ refl er≤0⇒er≡0 : ∀{er} → er ≤ER epr₀ → er ≡ epr₀ er≤0⇒er≡0 (inj₁ x) = x er≤0⇒er≡0 (inj₂ (ince ())) er≤0⇒er≡0 (inj₂ (incr ())) <⇒≤ER : ∀{er₀ er₁} → er₀ <ER er₁ → er₀ ≤ER er₁ <⇒≤ER = inj₂ ≤ER-refl : Reflexive _≤ER_ ≤ER-refl = inj₁ refl postulate -- prove, if needed/used ≤ER-trans : Transitive _≤ER_
{ "alphanum_fraction": 0.6049079755, "avg_line_length": 32.8629032258, "ext": "agda", "hexsha": "f71443caceb51b124c1a77a7ebfc8627a44bcf49", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Base/Types.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "cwjnkins/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Base/Types.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "cwjnkins/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Base/Types.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1739, "size": 4075 }
{-# OPTIONS --without-K --exact-split #-} module free-group where import 15-groups open 15-groups public {- We state the universal property of the free group on a set X -} precomp-universal-property-free-group : {l1 l2 l3 : Level} (X : UU-Set l1) (F : Group l2) (G : Group l3) (f : type-hom-Set X (set-Group F)) → hom-Group F G → type-hom-Set X (set-Group G) precomp-universal-property-free-group X F G f g = (map-hom-Group F G g) ∘ f universal-property-free-group : (l : Level) {l1 l2 : Level} (X : UU-Set l1) (F : Group l2) (f : type-hom-Set X (set-Group F)) → UU (lsuc l ⊔ l1 ⊔ l2) universal-property-free-group l X F f = (G : Group l) → is-equiv (precomp-universal-property-free-group X F G f) {- We state the universal property of the initial set equipped with a point and an automorphism for each x : X. -} universal-property-initial-pset-with-automorphisms : (l : Level) {l1 l2 : Level} (X : UU-Set l1) (Y : UU-Set l2) (pt-Y : type-Set Y) (f : type-Set X → (type-Set Y ≃ type-Set Y)) → UU (lsuc l ⊔ l1 ⊔ l2) universal-property-initial-pset-with-automorphisms l X Y pt-Y f = (Z : UU-Set l) (pt-Z : type-Set Z) (g : type-Set X → (type-Set Z ≃ type-Set Z)) → is-contr ( Σ ( type-hom-Set Y Z) ( λ h → ( Id (h pt-Y) pt-Z) × ( (x : type-Set X) (y : type-Set Y) → Id (h (map-equiv (f x) y)) (map-equiv (g x) (h y))))) map-initial-pset-with-automorphisms : { l1 l2 l3 : Level} (X : UU-Set l1) (Y : UU-Set l2) (pt-Y : type-Set Y) ( f : type-Set X → (type-Set Y ≃ type-Set Y)) → ( {l : Level} → universal-property-initial-pset-with-automorphisms l X Y pt-Y f) → ( Z : UU-Set l3) (pt-Z : type-Set Z) ( g : type-Set X → (type-Set Z ≃ type-Set Z)) → type-hom-Set Y Z map-initial-pset-with-automorphisms X Y pt-Y f up-Y Z pt-Z g = pr1 (center (up-Y Z pt-Z g)) preserves-point-map-initial-pset-with-automorphisms : { l1 l2 l3 : Level} (X : UU-Set l1) (Y : UU-Set l2) (pt-Y : type-Set Y) ( f : type-Set X → (type-Set Y ≃ type-Set Y)) → ( up-Y : {l : Level} → universal-property-initial-pset-with-automorphisms l X Y pt-Y f) → ( Z : UU-Set l3) (pt-Z : type-Set Z) ( g : type-Set X → (type-Set Z ≃ type-Set Z)) → Id (map-initial-pset-with-automorphisms X Y pt-Y f up-Y Z pt-Z g pt-Y) pt-Z preserves-point-map-initial-pset-with-automorphisms X Y pt-Y f up-Y Z pt-Z g = pr1 (pr2 (center (up-Y Z pt-Z g))) htpy-map-initial-pset-with-automorphisms : { l1 l2 l3 : Level} (X : UU-Set l1) (Y : UU-Set l2) (pt-Y : type-Set Y) ( f : type-Set X → (type-Set Y ≃ type-Set Y)) → ( up-Y : {l : Level} → universal-property-initial-pset-with-automorphisms l X Y pt-Y f) → ( Z : UU-Set l3) (pt-Z : type-Set Z) ( g : type-Set X → (type-Set Z ≃ type-Set Z)) → ( x : type-Set X) (y : type-Set Y) → Id ( map-initial-pset-with-automorphisms X Y pt-Y f up-Y Z pt-Z g ( map-equiv (f x) y)) ( map-equiv (g x) ( map-initial-pset-with-automorphisms X Y pt-Y f up-Y Z pt-Z g y)) htpy-map-initial-pset-with-automorphisms X Y pt-Y f up-Y Z pt-Z g = pr2 (pr2 (center (up-Y Z pt-Z g))) {- We show a dependent elimination property for the initial pointed set with an automorphism for each x : X. -} dependent-up-initial-pset-with-automorphisms : { l1 l2 l3 l4 : Level} (X : UU-Set l1) (Y : UU-Set l2) (pt-Y : type-Set Y) ( f : type-Set X → (type-Set Y ≃ type-Set Y)) → ( up-Y : {l : Level} → universal-property-initial-pset-with-automorphisms l X Y pt-Y f) → ( Z : UU-Set l3) (pt-Z : type-Set Z) ( g : type-Set X → (type-Set Z ≃ type-Set Z)) → ( P : type-Set Z → UU-Set l4) ( p : type-Set (P pt-Z)) ( e : (x : type-Set X) (z : type-Set Z) → type-Set (P z) ≃ type-Set (P (map-equiv (g x) z))) → ( y : type-Set Y) → type-Set (P (map-initial-pset-with-automorphisms X Y pt-Y f up-Y Z pt-Z g y)) dependent-up-initial-pset-with-automorphisms X Y pt-Y f up-Y Z pt-Z g P p e = {!!} {- We show that the initial set equipped with a point and an automorphism for each x : X is a group. -} mul-initial-pset-with-automorphisms : {l1 l2 : Level} (X : UU-Set l1) (Y : UU-Set l2) (pt-Y : type-Set Y) (f : type-Set X → (type-Set Y ≃ type-Set Y)) → ( {l : Level} → universal-property-initial-pset-with-automorphisms l X Y pt-Y f) → type-Set Y → type-Set Y → type-Set Y mul-initial-pset-with-automorphisms {l1} {l2} X Y pt-Y f up-Y = map-initial-pset-with-automorphisms X Y pt-Y f up-Y (hom-Set Y Y) id ( λ x → equiv-postcomp (type-Set Y) (f x)) associative-mul-initial-pset-with-automorphisms : {l1 l2 : Level} (X : UU-Set l1) (Y : UU-Set l2) (pt-Y : type-Set Y) (f : type-Set X → (type-Set Y ≃ type-Set Y)) → ( up-Y : {l : Level} → universal-property-initial-pset-with-automorphisms l X Y pt-Y f) → ( x y z : type-Set Y) → Id ( mul-initial-pset-with-automorphisms X Y pt-Y f up-Y ( mul-initial-pset-with-automorphisms X Y pt-Y f up-Y x y) z) ( mul-initial-pset-with-automorphisms X Y pt-Y f up-Y x ( mul-initial-pset-with-automorphisms X Y pt-Y f up-Y y z)) associative-mul-initial-pset-with-automorphisms X Y pt-Y f up-Y x y z = {!refl!}
{ "alphanum_fraction": 0.6069206843, "avg_line_length": 42.8666666667, "ext": "agda", "hexsha": "1d3b53b038626f851b43c2dbbd8b2c21db6764af", "lang": "Agda", "max_forks_count": 30, "max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z", "max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_path": "Agda/free-group.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_path": "Agda/free-group.agda", "max_line_length": 83, "max_stars_count": 333, "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_path": "Agda/free-group.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z", "num_tokens": 1961, "size": 5144 }
------------------------------------------------------------------------------ -- Propositional logic theorems ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- This module contains some examples showing the use of the ATPs to -- prove theorems from propositional logic. module FOL.PropositionalLogic.TheoremsATP where open import FOL.Base ------------------------------------------------------------------------------ -- We postulate some propositional formulae (which are translated as -- 0-ary predicates). postulate P Q R : Set ------------------------------------------------------------------------------ -- The introduction and elimination rules for the intuitionist -- propositional connectives are theorems. postulate →I : (P → Q) → P → Q →E : (P → Q) → P → Q →I' : (P → Q) → P → Q →E' : (P ⇒ Q) ⇒ P ⇒ Q {-# ATP prove →I #-} {-# ATP prove →E #-} {-# ATP prove →I' #-} {-# ATP prove →E' #-} postulate ∧I : P → Q → P ∧ Q ∧E₁ : P ∧ Q → P ∧E₂ : P ∧ Q → Q ∧I' : P ⇒ Q ⇒ P ∧ Q ∧E₂' : P ∧ Q ⇒ Q ∧E₁' : P ∧ Q ⇒ P {-# ATP prove ∧I #-} {-# ATP prove ∧E₁ #-} {-# ATP prove ∧E₂ #-} {-# ATP prove ∧I' #-} {-# ATP prove ∧E₁' #-} {-# ATP prove ∧E₂' #-} postulate ∨I₁ : P → P ∨ Q ∨I₂ : Q → P ∨ Q ∨E : (P → R) → (Q → R) → P ∨ Q → R ∨I₁' : P ⇒ P ∨ Q ∨I₂' : Q ⇒ P ∨ Q ∨E' : (P ⇒ R) ⇒ (Q ⇒ R) ⇒ P ∨ Q ⇒ R {-# ATP prove ∨I₁ #-} {-# ATP prove ∨I₂ #-} {-# ATP prove ∨E #-} {-# ATP prove ∨I₁' #-} {-# ATP prove ∨I₂' #-} {-# ATP prove ∨E' #-} postulate ⊥E : ⊥ → P ⊥E' : ⊥ ⇒ P {-# ATP prove ⊥E #-} {-# ATP prove ⊥E' #-} ------------------------------------------------------------------------------ -- Boolean laws (there are some non-intuitionistic laws) postulate ∧-ident : P ∧ ⊤ ↔ P ∨-ident : P ∨ ⊥ ↔ P ∧-dom : P ∧ ⊥ ↔ ⊥ ∨-dom : P ∨ ⊤ ↔ ⊤ ∧-idemp : P ∧ P ↔ P ∨-idemp : P ∨ P ↔ P dn : ¬ ¬ P ↔ P ∧-comm : P ∧ Q → Q ∧ P ∨-comm : P ∨ Q → Q ∨ P ∧-assoc : (P ∧ Q) ∧ R ↔ P ∧ Q ∧ R ∨-assoc : (P ∨ Q) ∨ R ↔ P ∨ Q ∨ R ∧∨-dist : P ∧ (Q ∨ R) ↔ P ∧ Q ∨ P ∧ R ∨∧-dist : P ∨ Q ∧ R ↔ (P ∨ Q) ∧ (P ∨ R) DM₁ : ¬ (P ∨ Q) ↔ ¬ P ∧ ¬ Q DM₂ : ¬ (P ∧ Q) ↔ ¬ P ∨ ¬ Q abs₁ : P ∨ P ∧ Q ↔ P abs₂ : P ∧ (P ∨ Q) ↔ P ∧-neg : P ∧ ¬ P ↔ ⊥ ∨-neg : P ∨ ¬ P ↔ ⊤ {-# ATP prove ∧-ident #-} {-# ATP prove ∨-ident #-} {-# ATP prove ∧-dom #-} {-# ATP prove ∨-dom #-} {-# ATP prove ∧-idemp #-} {-# ATP prove ∨-idemp #-} {-# ATP prove dn #-} {-# ATP prove ∧-comm #-} {-# ATP prove ∨-comm #-} {-# ATP prove ∧-assoc #-} {-# ATP prove ∨-assoc #-} {-# ATP prove ∧∨-dist #-} {-# ATP prove ∨∧-dist #-} {-# ATP prove DM₁ #-} {-# ATP prove DM₂ #-} {-# ATP prove abs₁ #-} {-# ATP prove abs₂ #-} {-# ATP prove ∧-neg #-} {-# ATP prove ∨-neg #-} ------------------------------------------------------------------------------ -- Theorems related with the definition of logical connectives in -- terms of others postulate ↔-def : (P ↔ Q) ↔ (P → Q) ∧ (Q → P) →-def : P → Q ↔ ¬ P ∨ Q ∨₁-def : P ∨ Q ↔ ¬ P → Q ∨₂-def : P ∨ Q ↔ ¬ (¬ P ∧ ¬ Q) ∧-def : P ∧ Q ↔ ¬ (¬ P ∨ ¬ Q) ¬-def : ¬ P ↔ P → ⊥ ⊥-def : ⊥ ↔ P ∧ ¬ P ⊤-def : ⊤ ↔ ¬ ⊥ {-# ATP prove ↔-def #-} {-# ATP prove →-def #-} {-# ATP prove ∨₁-def #-} {-# ATP prove ∨₂-def #-} {-# ATP prove ∧-def #-} {-# ATP prove ¬-def #-} {-# ATP prove ⊥-def #-} {-# ATP prove ⊤-def #-} ------------------------------------------------------------------------------ -- Some intuitionistic theorems postulate →-transposition : (P → Q) → ¬ Q → ¬ P {-# ATP prove →-transposition #-} postulate i₁ : P → Q → P i₂ : (P → Q → R) → (P → Q) → P → R i₃ : P → ¬ ¬ P i₄ : ¬ ¬ ¬ P → ¬ P i₅ : ((P ∧ Q) → R) ↔ (P → (Q → R)) i₆ : ¬ ¬ (P ∨ ¬ P) i₇ : (P ∨ ¬ P) → ¬ ¬ P → P {-# ATP prove i₁ #-} {-# ATP prove i₂ #-} {-# ATP prove i₃ #-} {-# ATP prove i₄ #-} {-# ATP prove i₅ #-} {-# ATP prove i₆ #-} {-# ATP prove i₇ #-} ------------------------------------------------------------------------------ -- Some non-intuitionistic theorems postulate ←-transposition : (¬ Q → ¬ P) → P → Q {-# ATP prove ←-transposition #-} postulate ni₁ : ((P → Q) → P) → P ni₂ : P ∨ ¬ P ni₃ : ¬ ¬ P → P ni₄ : (P → Q) → (¬ P → Q) → Q ni₅ : (P ∨ Q → P) ∨ (P ∨ Q → Q) ni₆ : (¬ ¬ P → P) → P ∨ ¬ P {-# ATP prove ni₁ #-} {-# ATP prove ni₂ #-} {-# ATP prove ni₃ #-} {-# ATP prove ni₄ #-} {-# ATP prove ni₅ #-} {-# ATP prove ni₆ #-} ------------------------------------------------------------------------------ -- The principle of the excluded middle implies the double negation -- elimination postulate pem→¬¬-elim : (P ∨ ¬ P) → ¬ ¬ P → P {-# ATP prove pem→¬¬-elim #-}
{ "alphanum_fraction": 0.3794165982, "avg_line_length": 26.6010928962, "ext": "agda", "hexsha": "44f95c46db93a39b6cc2d2dfadb618cb7cc190da", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOL/PropositionalLogic/TheoremsATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOL/PropositionalLogic/TheoremsATP.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOL/PropositionalLogic/TheoremsATP.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": 1701, "size": 4868 }
module Product where open import Base open import Category open import Unique open import Dual module Prod (ℂ : Cat) where private ℂ' = η-Cat ℂ open module C = Cat ℂ' open module U = Uniq ℂ' data _×_ (A B : Obj) : Set1 where prod : (AB : Obj) (π₀ : AB ─→ A) (π₁ : AB ─→ B) -> ((X : Obj)(f : X ─→ A)(g : X ─→ B) -> ∃! \(h : X ─→ AB) -> π₀ ∘ h == f /\ π₁ ∘ h == g ) -> A × B Product : {A B : Obj} -> A × B -> Obj Product (prod AB _ _ _) = AB π₀ : {A B : Obj}(p : A × B) -> Product p ─→ A π₀ (prod _ p _ _) = p π₁ : {A B : Obj}(p : A × B) -> Product p ─→ B π₁ (prod _ _ q _) = q module Sum (ℂ : Cat) = Prod (η-Cat ℂ op) renaming ( _×_ to _+_ ; prod to sum ; Product to Sum ; π₀ to inl ; π₁ to inr )
{ "alphanum_fraction": 0.4617283951, "avg_line_length": 19.756097561, "ext": "agda", "hexsha": "216685119fee4c540020c7a8da72d038c0e51e15", "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/cat/Product.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/cat/Product.agda", "max_line_length": 52, "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/cat/Product.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 333, "size": 810 }
{-# OPTIONS --without-K #-} module FinEquivPlusTimes where open import Data.Empty using (⊥; ⊥-elim) open import Data.Unit using (⊤; tt) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Product using (_,_; _×_; proj₁; proj₂) open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _<_; _≤_; ≤-pred; _≥_; _≤?_; module ≤-Reasoning) open import Data.Nat.DivMod using (_divMod_; result) open import Data.Nat.Properties using (≰⇒>; 1+n≰n; m≤m+n; ¬i+1+j≤i) open import Data.Nat.Properties.Simple using (+-assoc; +-suc; +-comm; *-right-zero) open import Data.Fin using (Fin; zero; suc; inject+; raise; toℕ; fromℕ≤; reduce≥) open import Data.Fin.Properties using (bounded; inject+-lemma; toℕ-raise; toℕ-injective; toℕ-fromℕ≤) open import Function using (_∘_; id; case_of_) open import Relation.Nullary using (yes; no) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; cong₂; subst; module ≡-Reasoning; inspect; [_]) -- open import Equiv using (_∼_; _≃_; qinv; id≃; sym≃; _●_; _⊎≃_) open import Proofs using ( -- LeqLemmas _<?_; cong+r≤; cong+l≤; cong*r≤; -- FinNatLemmas inj₁-≡; inj₂-≡; inject+-injective; raise-injective; addMul-lemma ) ------------------------------------------------------------------------------ -- Additive unit and multiplicative unit are Fin 0 and Fin 1 which are -- equivalent to ⊥ and ⊤ abstract Fin0-⊥ : Fin 0 → ⊥ Fin0-⊥ () F0≃⊥ : Fin 0 ≃ ⊥ F0≃⊥ = f , qinv g α β where f : Fin 0 → ⊥ f () g : ⊥ → Fin 0 g () α : f ∘ g ∼ id α () β : g ∘ f ∼ id β () Fin1≃⊤ : Fin 1 ≃ ⊤ Fin1≃⊤ = f , qinv g α β where f : Fin 1 → ⊤ f zero = tt f (suc ()) g : ⊤ → Fin 1 g tt = zero α : f ∘ g ∼ id α tt = refl β : g ∘ f ∼ id β zero = refl β (suc ()) ------------------------------------------------------------------------------ -- Additive monoid module Plus where -- Main goal is to show (Fin m ⊎ Fin n) ≃ Fin (m + n) It is then -- fairly easy to show that ⊎ satisfies the commutative monoid -- axioms private fwd : {m n : ℕ} → (Fin m ⊎ Fin n) → Fin (m + n) fwd {m} {n} (inj₁ x) = inject+ n x fwd {m} {n} (inj₂ y) = raise m y bwd : {m n : ℕ} → Fin (m + n) → (Fin m ⊎ Fin n) bwd {m} {n} = λ i → case (toℕ i <? m) of λ { (yes p) → inj₁ (fromℕ≤ p) ; (no ¬p) → inj₂ (reduce≥ i (≤-pred (≰⇒> ¬p))) } fwd∘bwd~id : {m n : ℕ} → fwd {m} {n} ∘ bwd ∼ id fwd∘bwd~id {m} i with toℕ i <? m fwd∘bwd~id i | yes p = sym (inj₁-≡ i p) fwd∘bwd~id i | no ¬p = sym (inj₂-≡ i (≤-pred (≰⇒> ¬p))) bwd∘fwd~id : {m n : ℕ} → bwd {m} {n} ∘ fwd ∼ id bwd∘fwd~id {m} {n} (inj₁ x) with toℕ (inject+ n x) <? m bwd∘fwd~id {n = n} (inj₁ x) | yes p = cong inj₁ (inject+-injective (fromℕ≤ p) x (sym (inj₁-≡ (inject+ n x) p))) bwd∘fwd~id {m} {n} (inj₁ x) | no ¬p = ⊥-elim (1+n≰n pf) where open ≤-Reasoning pf : suc (toℕ x) ≤ toℕ x pf = let q = (≤-pred (≰⇒> ¬p)) in begin ( suc (toℕ x) ≤⟨ bounded x ⟩ m ≤⟨ q ⟩ toℕ (inject+ n x) ≡⟨ sym (inject+-lemma n x) ⟩ toℕ x ∎ ) bwd∘fwd~id {m} {n} (inj₂ y) with toℕ (raise m y) <? m bwd∘fwd~id {m} {n} (inj₂ y) | yes p = ⊥-elim (1+n≰n pf) where open ≤-Reasoning pf : suc m ≤ m pf = begin ( suc m ≤⟨ m≤m+n (suc m) (toℕ y) ⟩ suc (m + toℕ y) ≡⟨ cong suc (sym (toℕ-raise m y)) ⟩ suc (toℕ (raise m y)) ≤⟨ p ⟩ m ∎) bwd∘fwd~id {m} {n} (inj₂ y) | no ¬p = cong inj₂ (raise-injective {m} (reduce≥ (raise m y) (≤-pred (≰⇒> ¬p))) y (sym (inj₂-≡ (raise m y) (≤-pred (≰⇒> ¬p))))) -- the main equivalence abstract fwd-iso : {m n : ℕ} → (Fin m ⊎ Fin n) ≃ Fin (m + n) fwd-iso {m} {n} = fwd , qinv bwd (fwd∘bwd~id {m}) (bwd∘fwd~id {m}) -- aliases for the above which are more convenient ⊎≃+ : {m n : ℕ} → (Fin m ⊎ Fin n) ≃ Fin (m + n) ⊎≃+ = fwd-iso +≃⊎ : {m n : ℕ} → Fin (m + n) ≃ (Fin m ⊎ Fin n) +≃⊎ = sym≃ fwd-iso ----------------------------------------------------------------------------- -- Multiplicative monoid module Times where -- main goal is to show (Fin m × Fin n) ≃ Fin (m * n) It is then -- fairly easy to show that × satisfies the commutative monoid -- axioms private fwd : {m n : ℕ} → (Fin m × Fin n) → Fin (m * n) fwd {suc m} {n} (zero , k) = inject+ (m * n) k fwd {n = n} (suc i , k) = raise n (fwd (i , k)) soundness : ∀ {m n} (i : Fin m) (j : Fin n) → toℕ (fwd (i , j)) ≡ toℕ i * n + toℕ j soundness {suc m} {n} zero j = sym (inject+-lemma (m * n) j) soundness {n = n} (suc i) j rewrite toℕ-raise n (fwd (i , j)) | soundness i j = sym (+-assoc n (toℕ i * n) (toℕ j)) absurd-quotient : (m n q : ℕ) (r : Fin (suc n)) (k : Fin (m * suc n)) (k≡r+q*sn : toℕ k ≡ toℕ r + q * suc n) (p : m ≤ q) → ⊥ absurd-quotient m n q r k k≡r+q*sn p = ¬i+1+j≤i (toℕ k) {toℕ r} k≥k+sr where k≥k+sr : toℕ k ≥ toℕ k + suc (toℕ r) k≥k+sr = begin (toℕ k + suc (toℕ r) ≡⟨ +-suc (toℕ k) (toℕ r) ⟩ suc (toℕ k) + toℕ r ≤⟨ cong+r≤ (bounded k) (toℕ r) ⟩ (m * suc n) + toℕ r ≡⟨ +-comm (m * suc n) (toℕ r) ⟩ toℕ r + (m * suc n) ≡⟨ refl ⟩ toℕ r + m * suc n ≤⟨ cong+l≤ (cong*r≤ p (suc n)) (toℕ r) ⟩ toℕ r + q * suc n ≡⟨ sym k≡r+q*sn ⟩ toℕ k ∎) where open ≤-Reasoning elim-right-zero : ∀ {ℓ} {Whatever : Set ℓ} (m : ℕ) → Fin (m * 0) → Whatever elim-right-zero m i = ⊥-elim (Fin0-⊥ (subst Fin (*-right-zero m) i)) bwd : {m n : ℕ} → Fin (m * n) → (Fin m × Fin n) bwd {m} {0} k = elim-right-zero m k bwd {m} {suc n} k with toℕ k | inspect toℕ k | (toℕ k) divMod (suc n) bwd {m} {suc n} k | .(toℕ r + q * suc n) | [ pf ] | result q r refl = (fromℕ≤ {q} {m} q<m , r) where q<m : q < m q<m with suc q ≤? m ... | no ¬p = ⊥-elim (absurd-quotient m n q r k pf (≤-pred (≰⇒> ¬p))) ... | yes p = p fwd∘bwd~id : {m n : ℕ} → fwd {m} {n} ∘ bwd ∼ id fwd∘bwd~id {m} {zero} i = elim-right-zero m i fwd∘bwd~id {m} {suc n} i with toℕ i | inspect toℕ i | (toℕ i) divMod (suc n) fwd∘bwd~id {m} {suc n} i | .(toℕ r + q * suc n) | [ eq ] | result q r refl with suc q ≤? m ... | no ¬p = ⊥-elim (absurd-quotient m n q r i eq (≤-pred (≰⇒> ¬p))) ... | yes p = toℕ-injective ( begin ( toℕ (fwd (fromℕ≤ {q} {m} p , r)) ≡⟨ soundness (fromℕ≤ p) r ⟩ toℕ (fromℕ≤ p) * (suc n) + toℕ r ≡⟨ cong (λ x → x * (suc n) + toℕ r) (toℕ-fromℕ≤ p) ⟩ q * (suc n) + toℕ r ≡⟨ +-comm _ (toℕ r) ⟩ toℕ r + q * (suc n) ≡⟨ sym eq ⟩ toℕ i ∎)) where open ≡-Reasoning bwd∘fwd~id : {m n : ℕ} → (x : Fin m × Fin n) → bwd {m} {n} (fwd x) ≡ id x bwd∘fwd~id {m} {zero} (b , ()) bwd∘fwd~id {m} {suc n} (b , d) with toℕ (fwd (b , d)) | inspect toℕ (fwd (b , d)) | (toℕ (fwd (b , d)) divMod (suc n)) bwd∘fwd~id {m} {suc n} (b , d) | .(toℕ r + q * suc n) | [ eqk ] | result q r refl with q <? m ... | no ¬p = ⊥-elim (absurd-quotient m n q r (fwd (b , d)) eqk (≤-pred (≰⇒> ¬p))) ... | yes p = begin ( (fromℕ≤ {q} {m} p , r) ≡⟨ cong₂ _,_ pf₁ (proj₁ same-quot) ⟩ (b , d) ∎) where open ≡-Reasoning eq' : toℕ d + toℕ b * suc n ≡ toℕ r + q * suc n eq' = begin ( toℕ d + toℕ b * suc n ≡⟨ +-comm (toℕ d) _ ⟩ toℕ b * suc n + toℕ d ≡⟨ sym (soundness b d) ⟩ toℕ (fwd (b , d)) ≡⟨ eqk ⟩ toℕ r + q * suc n ∎ ) same-quot : (r ≡ d) × (q ≡ toℕ b) same-quot = addMul-lemma q (toℕ b) n r d ( sym eq' ) pf₁ = toℕ-injective (trans (toℕ-fromℕ≤ p) (proj₂ same-quot)) abstract fwd-iso : {m n : ℕ} → (Fin m × Fin n) ≃ Fin (m * n) fwd-iso {m} {n} = fwd , qinv bwd (fwd∘bwd~id {m}) (bwd∘fwd~id {m}) -- convenient aliases ×≃* : {m n : ℕ} → (Fin m × Fin n) ≃ Fin (m * n) ×≃* = fwd-iso *≃× : {m n : ℕ} → Fin (m * n) ≃ (Fin m × Fin n) *≃× = sym≃ ×≃* ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.4305208096, "avg_line_length": 33.4372623574, "ext": "agda", "hexsha": "f7cba1d8c682c0a8ba8d0533c9a6d0488e1b566d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/FinEquivPlusTimes.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/FinEquivPlusTimes.agda", "max_line_length": 123, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/FinEquivPlusTimes.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 3701, "size": 8794 }
open import Data.Product using ( _×_ ; _,_ ; swap ) open import Relation.Nullary using ( ¬_ ) open import Web.Semantic.DL.ABox using ( ABox ; ε ; _,_ ; _∼_ ; _∈₁_ ; _∈₂_ ) open import Web.Semantic.DL.ABox.Model using ( _⊨a_ ) open import Web.Semantic.DL.Concept using ( Concept ; ⟨_⟩ ; ¬⟨_⟩ ; ⊤ ; ⊥ ; _⊔_ ; _⊓_ ; ∀[_]_ ; ∃⟨_⟩_ ; ≤1 ; >1 ; neg ) open import Web.Semantic.DL.KB using ( KB ; tbox ; abox ) open import Web.Semantic.DL.KB.Model using ( _⊨_ ) open import Web.Semantic.DL.Role using ( Role ; ⟨_⟩ ; ⟨_⟩⁻¹ ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ; ε ; _,_ ; _⊑₁_ ; _⊑₂_ ; Dis ; Ref ; Irr ; Tra ) module Web.Semantic.DL.Integrity.Closed.Alternate {Σ : Signature} {X : Set} where -- An alternate definition of closed-world integrity. infixr 4 _,_ infix 2 _⊫_∈₂_ _⊫_∈₁_ _⊫a_ _⊫t_ data _⊫_∼_ (K : KB Σ X) (x y : X) : Set₁ where eq : (∀ I → (I ⊨ K) → (I ⊨a x ∼ y)) → (K ⊫ x ∼ y) data _⊫_∈₂_ (K : KB Σ X) (xy : X × X) : Role Σ → Set₁ where rel : ∀ {r} → (∀ I → (I ⊨ K) → (I ⊨a xy ∈₂ r)) → (K ⊫ xy ∈₂ ⟨ r ⟩) rev : ∀ {r} → (∀ I → (I ⊨ K) → (I ⊨a swap xy ∈₂ r)) → (K ⊫ xy ∈₂ ⟨ r ⟩⁻¹) data _⊫_∈₁_ (K : KB Σ X) (x : X) : Concept Σ → Set₁ where +atom : ∀ {c} → (∀ I → (I ⊨ K) → (I ⊨a x ∈₁ c)) → (K ⊫ x ∈₁ ⟨ c ⟩) -atom : ∀ {c} → ¬(∀ I → (I ⊨ K) → (I ⊨a x ∈₁ c)) → (K ⊫ x ∈₁ ¬⟨ c ⟩) top : (K ⊫ x ∈₁ ⊤) inj₁ : ∀ {C D} → (K ⊫ x ∈₁ C) → (K ⊫ x ∈₁ C ⊔ D) inj₂ : ∀ {C D} → (K ⊫ x ∈₁ D) → (K ⊫ x ∈₁ C ⊔ D) _,_ : ∀ {C D} → (K ⊫ x ∈₁ C) → (K ⊫ x ∈₁ D) → (K ⊫ x ∈₁ C ⊓ D) all : ∀ {R C} → (∀ y → (K ⊫ (x , y) ∈₂ R) → (K ⊫ y ∈₁ C)) → (K ⊫ x ∈₁ ∀[ R ] C) ex : ∀ {R C} y → (K ⊫ (x , y) ∈₂ R) → (K ⊫ y ∈₁ C) → (K ⊫ x ∈₁ ∃⟨ R ⟩ C) uniq : ∀ {R} → (∀ y z → (K ⊫ (x , y) ∈₂ R) → (K ⊫ (x , z) ∈₂ R) → (K ⊫ y ∼ z)) → (K ⊫ x ∈₁ ≤1 R) ¬uniq : ∀ {R} y z → (K ⊫ (x , y) ∈₂ R) → (K ⊫ (x , z) ∈₂ R) → ¬(K ⊫ y ∼ z) → (K ⊫ x ∈₁ >1 R) data _⊫a_ (K : KB Σ X) : ABox Σ X → Set₁ where ε : (K ⊫a ε) _,_ : ∀ {A B} → (K ⊫a A) → (K ⊫a B) → (K ⊫a A , B) eq : ∀ x y → (K ⊫ x ∼ y) → (K ⊫a x ∼ y) rl : ∀ xy r → (K ⊫ xy ∈₂ ⟨ r ⟩) → (K ⊫a xy ∈₂ r) cn : ∀ x c → (K ⊫ x ∈₁ ⟨ c ⟩) → (K ⊫a x ∈₁ c) data _⊫t_ (K : KB Σ X) : TBox Σ → Set₁ where ε : (K ⊫t ε) _,_ : ∀ {T U} → (K ⊫t T) → (K ⊫t U) → (K ⊫t T , U) rl : ∀ Q R → (∀ xy → (K ⊫ xy ∈₂ Q) → (K ⊫ xy ∈₂ R)) → (K ⊫t Q ⊑₂ R) cn : ∀ C D → (∀ x → (K ⊫ x ∈₁ neg C ⊔ D)) → (K ⊫t C ⊑₁ D) dis : ∀ Q R → (∀ xy → (K ⊫ xy ∈₂ Q) → ¬(K ⊫ xy ∈₂ R)) → (K ⊫t Dis Q R) ref : ∀ R → (∀ x → (K ⊫ (x , x) ∈₂ R)) → (K ⊫t Ref R) irr : ∀ R → (∀ x → ¬(K ⊫ (x , x) ∈₂ R)) → (K ⊫t Irr R) tra : ∀ R → (∀ x y z → (K ⊫ (x , y) ∈₂ R) → (K ⊫ (y , z) ∈₂ R) → (K ⊫ (x , z) ∈₂ R)) → (K ⊫t Tra R) data _⊫k_ (K L : KB Σ X) : Set₁ where _,_ : (K ⊫t tbox L) → (K ⊫a abox L) → (K ⊫k L)
{ "alphanum_fraction": 0.4209202013, "avg_line_length": 46.3666666667, "ext": "agda", "hexsha": "b17bb570687e742ab8987e86d784a27c7240c2e9", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/Integrity/Closed/Alternate.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/Integrity/Closed/Alternate.agda", "max_line_length": 101, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/Integrity/Closed/Alternate.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 1520, "size": 2782 }
module Ag02 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; _+_; _*_; _∸_; _^_) +-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p) +-assoc zero n p = begin (zero + n) + p ≡⟨⟩ 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) ∎ +-identityʳ : ∀ (m : ℕ) → m + 0 ≡ m +-identityʳ zero = begin zero + 0 ≡⟨⟩ zero ∎ +-identityʳ (suc m) = begin suc m + zero ≡⟨⟩ suc (m + zero) ≡⟨ cong suc (+-identityʳ m) ⟩ suc m ∎ +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n) +-suc zero n = begin zero + suc n ≡⟨⟩ 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) ∎ +-comm : ∀ (m n : ℕ) → m + n ≡ n + m +-comm m zero = begin m + zero ≡⟨ +-identityʳ m ⟩ 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 ∎ +-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 ∎ +-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 +-swap : ∀ (m n p : ℕ) → m + (n + p) ≡ n + (m + p) +-swap m n p rewrite sym (+-assoc m n p) | +-comm m n | +-assoc n m p = refl *-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p *-distrib-+ 0 n p = refl *-distrib-+ (suc m) n p rewrite *-distrib-+ m n p | +-assoc p (m * p) (n * p) = refl *-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p) *-assoc 0 n p = refl *-assoc (suc m) n p rewrite *-distrib-+ n (m * n) p | *-assoc m n p = refl *-identityʳ : ∀ (n : ℕ) → n * 0 ≡ 0 *-identityʳ 0 = refl *-identityʳ (suc n) rewrite *-identityʳ n = refl *-suc : ∀ (m n : ℕ) → m * (suc n) ≡ m + m * n *-suc 0 n = refl *-suc (suc m) n rewrite *-suc m n | +-swap n m (m * n) = refl *-comm : ∀ (m n : ℕ) → m * n ≡ n * m *-comm 0 n rewrite *-identityʳ n = refl *-comm (suc m) n rewrite *-comm m n | *-suc n m = refl ∸-n : ∀ (n : ℕ) → 0 ∸ n ≡ 0 ∸-n zero = refl ∸-n (suc n) = refl ∸-+-assoc : ∀ (m n p : ℕ) → m ∸ n ∸ p ≡ m ∸ (n + p) ∸-+-assoc zero n p rewrite ∸-n n | ∸-n p | ∸-n (n + p) = refl ∸-+-assoc (suc m) zero p = refl ∸-+-assoc (suc m) (suc n) p rewrite ∸-+-assoc m n p = refl ^-distrib-+ : ∀ (m n p : ℕ) → m ^ (n + p) ≡ (m ^ n) * (m ^ p) ^-distrib-+ m 0 p rewrite +-identityʳ (m ^ p) = refl ^-distrib-+ m (suc n) p rewrite ^-distrib-+ m n p | *-assoc m (m ^ n) (m ^ p) = refl ^-distrib-* : ∀ (m n p : ℕ) → (m * n) ^ p ≡ (m ^ p) * (n ^ p) ^-distrib-* m n zero = refl ^-distrib-* m n (suc p) rewrite ^-distrib-* m n p | sym (*-assoc (m * n) (m ^ p) (n ^ p)) | *-assoc m n (m ^ p) | *-comm n (m ^ p) | *-assoc m ((m ^ p) * n) (n ^ p) | *-assoc (m ^ p) n (n ^ p) | *-assoc m (m ^ p) (n * (n ^ p)) = refl ^-identity : ∀ (p : ℕ) → 1 ^ p ≡ 1 ^-identity zero = refl ^-identity (suc p) rewrite ^-identity p = refl ^-*-plus : ∀ (m n p : ℕ) → m ^ (n * p) ≡ (m ^ n) ^ p ^-*-plus m zero p rewrite ^-identity p = refl ^-*-plus m (suc n) p rewrite ^-distrib-+ m p (n * p) | ^-*-plus m n p | sym (^-distrib-* m (m ^ n) p) = refl data Bin : Set where nil : Bin x0_ : Bin → Bin x1_ : Bin → Bin inc : Bin → Bin inc nil = x1 nil inc (x1 b) = x0 (inc b) inc (x0 b) = x1 b to : ℕ → Bin to zero = nil to (suc m) = inc (to m) from : Bin → ℕ from nil = zero from (x1 b) = suc (2 * (from b)) from (x0 b) = 2 * (from b) inc-suc : ∀ (x : Bin) → from (inc x) ≡ suc (from x) inc-suc nil = refl inc-suc (x0 x) = refl inc-suc (x1 x) rewrite inc-suc x | +-suc (from x) (from x + 0) = refl
{ "alphanum_fraction": 0.4446312755, "avg_line_length": 23.3876404494, "ext": "agda", "hexsha": "72824ed3012a9753c24b91c107f5d6cf498905b1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_path": "Agda/Ag02.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "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": "Brethland/LEARNING-STUFF", "max_issues_repo_path": "Agda/Ag02.agda", "max_line_length": 108, "max_stars_count": 2, "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_path": "Agda/Ag02.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "num_tokens": 2015, "size": 4163 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category.Core -- Kernel Pair - a Pullback of a morphism along itself -- https://ncatlab.org/nlab/show/kernel+pair module Categories.Diagram.KernelPair {o ℓ e} (𝒞 : Category o ℓ e) where open import Level open import Categories.Diagram.Pullback 𝒞 open Category 𝒞 private variable A B : Obj -- Make it a pure synonym KernelPair : (f : A ⇒ B) → Set (o ⊔ ℓ ⊔ e) KernelPair f = Pullback f f
{ "alphanum_fraction": 0.7002188184, "avg_line_length": 20.7727272727, "ext": "agda", "hexsha": "5fa4d7daf103f72d4ffa6edc35763566ac6bab91", "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/Diagram/KernelPair.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/Diagram/KernelPair.agda", "max_line_length": 71, "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/Diagram/KernelPair.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": 138, "size": 457 }
------------------------------------------------------------------------ -- Total recognisers based on the same principles as the parsers in -- TotalParserCombinators.Parser -- -- Nils Anders Danielsson ------------------------------------------------------------------------ -- Recognisers are less complicated than parsers, and the following -- code should (generally) be easier to follow than the code under -- TotalParserCombinators. module TotalRecognisers where ------------------------------------------------------------------------ -- Recognisers which do not support left recursion -- Very simple recognisers, including a formal semantics and a proof -- of decidability. import TotalRecognisers.Simple -- Proof showing that the set of languages accepted by these -- recognisers is exactly the set of languages which can be decided by -- Agda programs (when the alphabet is {true, false}). import TotalRecognisers.Simple.ExpressiveStrength -- An example: a right recursive expression grammar. import TotalRecognisers.Simple.Expression -- An alternative backend (without correctness proof). import TotalRecognisers.Simple.AlternativeBackend ------------------------------------------------------------------------ -- Recognisers which do support left recursion -- More complicated recognisers, which can handle left recursion. (The -- set of basic combinators is also different: tok has been replaced -- by sat, and nonempty and cast have been added.) import TotalRecognisers.LeftRecursion -- These recognisers have the same (maximal) expressive strength as -- the simple ones, as long as the alphabet is finite. For infinite -- alphabets it is shown that the expressive strength is not maximal. import TotalRecognisers.LeftRecursion.ExpressiveStrength -- A tiny library of derived combinators. import TotalRecognisers.LeftRecursion.Lib -- An example: a left recursive expression grammar. import TotalRecognisers.LeftRecursion.Expression -- An example of how nonempty can be used: parsing of matching -- parentheses, along with a correctness proof. import TotalRecognisers.LeftRecursion.MatchingParentheses -- The recognisers form a *-continuous Kleene algebra. import TotalRecognisers.LeftRecursion.KleeneAlgebra -- A direct proof which shows that the context-sensitive language -- { aⁿbⁿcⁿ | n ∈ ℕ } can be decided. import TotalRecognisers.LeftRecursion.NotOnlyContextFree
{ "alphanum_fraction": 0.702781237, "avg_line_length": 33.4583333333, "ext": "agda", "hexsha": "ba6f5ac25a19f10600d0075f5bf010098e1bbe6b", "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": "TotalRecognisers.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": "TotalRecognisers.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": "TotalRecognisers.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": 471, "size": 2409 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Concrete.Records open import LibraBFT.Concrete.System open import LibraBFT.Concrete.System.Parameters import LibraBFT.Concrete.Properties.Common as Common import LibraBFT.Concrete.Properties.VotesOnce as VO open import LibraBFT.Impl.Consensus.Network as Network open import LibraBFT.Impl.Consensus.Network.Properties as NetworkProps open import LibraBFT.Impl.Consensus.RoundManager import LibraBFT.Impl.Handle as Handle open import LibraBFT.Impl.Handle.Properties open import LibraBFT.Impl.IO.OBM.InputOutputHandlers open import LibraBFT.Impl.IO.OBM.Properties.InputOutputHandlers open import LibraBFT.Impl.Properties.Common open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Consensus.Types.EpochDep open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.Util.Crypto open import LibraBFT.ImplShared.Util.Dijkstra.All open ReachableSystemStateProps open import LibraBFT.Impl.Properties.Util open import Optics.All open import Util.Lemmas open import Util.PKCS open import Util.Prelude open Invariants open RoundManagerTransProps open import LibraBFT.Abstract.Types.EpochConfig UID NodeId open ParamsWithInitAndHandlers Handle.InitHandler.initAndHandlers open import LibraBFT.ImplShared.Util.HashCollisions Handle.InitHandler.initAndHandlers open import Yasm.Yasm ℓ-RoundManager ℓ-VSFP ConcSysParms Handle.InitHandler.initAndHandlers PeerCanSignForPK PeerCanSignForPK-stable open Structural impl-sps-avp open import LibraBFT.Impl.Handle.InitProperties open initHandlerSpec -- This module proves the two "VotesOnce" proof obligations for our handler. module LibraBFT.Impl.Properties.VotesOnce (𝓔 : EpochConfig) where ------------------------------------------------------------------------------ newVote⇒lv≡ : ∀ {pre : SystemState}{pid s' acts v m pk} → ReachableSystemState pre → StepPeerState pid (msgPool pre) (initialised pre) (peerStates pre pid) (s' , acts) → v ⊂Msg m → send m ∈ acts → (sig : WithVerSig pk v) → Meta-Honest-PK pk → ¬ (∈BootstrapInfo-impl fakeBootstrapInfo (ver-signature sig)) → ¬ MsgWithSig∈ pk (ver-signature sig) (msgPool pre) → LastVoteIs s' v newVote⇒lv≡ {pid = pid} preach (step-init rm×acts uni) v⊂m send∈acts sig hpk ¬bootstrap ¬mws∈pool with initHandlerSpec.contract pid fakeBootstrapInfo rm×acts ...| init-contract with initHandlerSpec.ContractOk.isInitPM init-contract send∈acts ...| (_ , refl , noSigs) with v⊂m ...| vote∈qc vs∈qc v≈rbld qc∈pm = ⊥-elim (noSigs vs∈qc qc∈pm) newVote⇒lv≡{pre}{pid}{s'}{v = v}{m}{pk} preach sps@(step-msg{sndr , nm} m∈pool ini) (vote∈qc{vs}{qc} vs∈qc v≈rbld qc∈m) m∈acts sig hpk ¬bootstrap ¬msb4 with cong _vSignature v≈rbld ...| refl = ⊥-elim ∘′ ¬msb4 $ qcVoteSigsSentB4-handle pid preach sps m∈acts qc∈m sig vs∈qc v≈rbld ¬bootstrap newVote⇒lv≡{pre}{pid}{v = v} preach (step-msg{sndr , P pm} m∈pool ini) vote∈vm m∈acts sig hpk ¬bootstrap ¬msb4 with handleProposalSpec.contract! 0 pm (msgPool pre) (peerStates pre pid) ...| handleProposalSpec.mkContract _ invalidProposal _ vac _ _ -- TODO-2: DRY fail. This pattern arises several times in this file, where we need to know that -- the proposal being processed is valid, and to use handleProposalSpec to derive a contradiction -- if is not. Some are identical, some are not. with BlockId-correct? (pm ^∙ pmProposal) ...| no ¬validProposal = ⊥-elim (sendVote∉actions {outs = handleOuts} {st = handlePre} (sym (proj₂ $ invalidProposal ¬validProposal)) m∈acts) where handlePre = peerStates pre pid handleOuts = LBFT-outs (handle pid (P pm) 0) (peerStates pre pid) ...| yes refl with vac refl (nohc preach m∈pool pid ini (invariantsCorrect pid pre ini preach) refl refl) ...| Voting.mkVoteAttemptCorrectWithEpochReq (inj₁ (_ , voteUnsent)) sdEpoch≡? = ⊥-elim (¬voteUnsent voteUnsent) where handleOuts = LBFT-outs (handle pid (P pm) 0) (peerStates pre pid) ¬voteUnsent : ¬ Voting.VoteUnsentCorrect (peerStates pre pid) _ _ _ _ ¬voteUnsent (Voting.mkVoteUnsentCorrect noVoteMsgOuts _) = sendVote∉actions{outs = handleOuts}{st = peerStates pre pid} (sym noVoteMsgOuts) m∈acts ...| Voting.mkVoteAttemptCorrectWithEpochReq (inj₂ (Voting.mkVoteSentCorrect (VoteMsg∙new v' _) rcvr voteMsgOuts vgCorrect)) sdEpoch≡? = sentVoteIsPostLV where handlePost = LBFT-post (handle pid (P pm) 0) (peerStates pre pid) handleOuts = LBFT-outs (handle pid (P pm) 0) (peerStates pre pid) sentVoteIsPostLV : LastVoteIs handlePost v sentVoteIsPostLV with Voting.VoteGeneratedCorrect.state vgCorrect ...| RoundManagerTransProps.mkVoteGenerated lv≡v _ rewrite sym lv≡v = cong (just ∘ _^∙ vmVote) (sendVote∈actions{outs = handleOuts}{st = peerStates pre pid} (sym voteMsgOuts) m∈acts) newVote⇒lv≡{pre}{pid}{s' = s'}{v = v} preach (step-msg{sndr , V vm} m∈pool ini) vote∈vm m∈outs sig hpk ¬bootstrap ¬msb4 = ⊥-elim (sendVote∉actions{outs = hvOut}{st = hvPre} (sym noVotes) m∈outs) where hvPre = peerStates pre pid hvOut = LBFT-outs (handleVote 0 vm) hvPre open handleVoteSpec.Contract (handleVoteSpec.contract! 0 vm (msgPool pre) hvPre) ------------------------------------------------------------------------------ oldVoteRound≤lvr : ∀ {pid pk v}{pre : SystemState} → (r : ReachableSystemState pre) → Meta-Honest-PK pk → (sig : WithVerSig pk v) → ¬ (∈BootstrapInfo-impl fakeBootstrapInfo (ver-signature sig)) → MsgWithSig∈ pk (ver-signature sig) (msgPool pre) → PeerCanSignForPK pre v pid pk → (peerStates pre pid) ^∙ rmEpoch ≡ (v ^∙ vEpoch) → v ^∙ vRound ≤ Meta.getLastVoteRound ((peerStates pre pid) ^∙ pssSafetyData-rm) oldVoteRound≤lvr{pid} (step-s preach step@(step-peer{pid'} sp@(step-cheat cmc))) hpk sig ¬bootstrap mws∈pool pcsfpk epoch≡ -- `pid`'s state is untouched by this step rewrite cheatStepDNMPeerStates₁{pid = pid'}{pid' = pid} sp unit = oldVoteRound≤lvr preach hpk sig ¬bootstrap mws∈prePool pcsfpkPre epoch≡ where -- The cheat step could not have been where the signed message was introduced, -- so there must be a signed message in the pool prior to this mws∈prePool = ¬cheatForgeNew sp refl unit hpk mws∈pool (¬subst ¬bootstrap (msgSameSig mws∈pool)) -- `pid` can sign for the message in the previous system state pcsfpkPre = PeerCanSignForPKProps.msb4 preach step pcsfpk hpk sig mws∈prePool oldVoteRound≤lvr{pid}{v = v} step*@(step-s{pre = pre}{post = post@._} preach step@(step-peer{pid'} sp@(step-honest{st = ppost}{outs} sps))) hpk sig ¬bootstrap mws∈pool pcsfpk epoch≡ with msgSameSig mws∈pool ...| refl with newMsg⊎msgSentB4 preach sps hpk (msgSigned mws∈pool) ¬bootstrap (msg⊆ mws∈pool) (msg∈pool mws∈pool) ...| Right msb4 = helpSentB4 where pcsfpkPre : PeerCanSignForPK pre v pid _ pcsfpkPre = PeerCanSignForPKProps.msb4 preach step pcsfpk hpk sig msb4 ovrHyp : peerStates pre pid ^∙ rmEpoch ≡ v ^∙ vEpoch → v ^∙ vRound ≤ Meta.getLastVoteRound ((peerStates pre pid) ^∙ pssSafetyData-rm) ovrHyp ep≡ = oldVoteRound≤lvr{pre = pre} preach hpk sig ¬bootstrap msb4 pcsfpkPre ep≡ helpSentB4 : v ^∙ vRound ≤ Meta.getLastVoteRound ((peerStates post pid) ^∙ pssSafetyData-rm) helpSentB4 with pid ≟ pid' -- A step by `pid'` step cannot affect `pid`'s state ...| no pid≢ rewrite sym (pids≢StepDNMPeerStates{pre = pre} sps pid≢) = ovrHyp epoch≡ ...| yes refl = ≤-trans (ovrHyp epochPre≡) lvr≤ where -- If a vote signed by a peer exists in the past, and that vote has an -- epoch id associated to it that is the same as the peer's post-state -- epoch, then the peer has that same epoch id in its immediately preceding -- pre-state. epochPre≡ : peerStates pre pid ^∙ rmEpoch ≡ v ^∙ vEpoch epochPre≡ = ReachableSystemStateProps.mws∈pool⇒epoch≡{v = v}{ppost}{outs} preach sps pcsfpkPre hpk sig ¬bootstrap msb4 epoch≡' where open ≡-Reasoning epoch≡' : ppost ^∙ rmEpoch ≡ v ^∙ vEpoch epoch≡' = begin ppost ^∙ rmEpoch ≡⟨ cong (_^∙ rmEpoch) (StepPeer-post-lemma sp) ⟩ peerStates (StepPeer-post{pre = pre} sp) pid' ^∙ rmEpoch ≡⟨ epoch≡ ⟩ v ^∙ vEpoch ∎ ini : initialised pre pid' ≡ initd ini = ReachableSystemStateProps.mws∈pool⇒initd preach pcsfpkPre hpk sig ¬bootstrap msb4 lvr≤ : Meta.getLastVoteRound ((peerStates pre pid) ^∙ pssSafetyData-rm) ≤ Meta.getLastVoteRound ((peerStates post pid) ^∙ pssSafetyData-rm) lvr≤ rewrite sym (StepPeer-post-lemma{pre = pre} sp) = lastVotedRound-mono pid' pre preach ini sps (trans epochPre≡ (sym epoch≡)) -- The vote was newly sent this round ...| Left (m∈outs , pcsfpkPost , ¬msb4) -- ... and it really is the same vote, because there has not been a hash collision with sameSig⇒sameVoteData (msgSigned mws∈pool) sig (msgSameSig mws∈pool) ...| Left nonInjSHA256 = ⊥-elim (PerReachableState.meta-no-collision step* nonInjSHA256) ...| Right refl with PeerCanSignForPKProps.pidInjective pcsfpk pcsfpkPost refl ...| refl = ≡⇒≤ vr≡lvrPost where vr≡lvrPost : v ^∙ vRound ≡ Meta.getLastVoteRound ((peerStates (StepPeer-post sp) pid) ^∙ pssSafetyData-rm) vr≡lvrPost rewrite sym (StepPeer-post-lemma sp) with newVote⇒lv≡{pre = pre}{pid = pid} preach sps (msg⊆ mws∈pool) m∈outs (msgSigned mws∈pool) hpk ¬bootstrap ¬msb4 ...| lastVoteIsJust with ppost ^∙ pssSafetyData-rm ∙ sdLastVote ...| nothing = absurd (just _ ≡ nothing) case lastVoteIsJust of λ () ...| just _ rewrite just-injective (sym lastVoteIsJust) = refl ------------------------------------------------------------------------------ sameERasLV⇒sameId-lem₁ : ∀ {pid pid' pk s acts}{pre : SystemState} → ReachableSystemState pre → (sp : StepPeer pre pid' s acts) → ∀ {v v'} → Meta-Honest-PK pk → PeerCanSignForPK (StepPeer-post sp) v pid pk → (sig' : WithVerSig pk v') → ¬ (∈BootstrapInfo-impl fakeBootstrapInfo (ver-signature sig')) → (mws : MsgWithSig∈ pk (ver-signature sig') (msgPool pre)) → v ≡L v' at vEpoch → v ≡L v' at vRound → Σ[ mws ∈ MsgWithSig∈ pk (ver-signature sig') (msgPool pre) ] (¬ ∈BootstrapInfo-impl fakeBootstrapInfo (ver-signature ∘ msgSigned $ mws) × PeerCanSignForPK pre v pid pk × v ≡L msgPart mws at vEpoch × v ≡L msgPart mws at vRound × msgPart mws ≡L v' at vProposedId) sameERasLV⇒sameId-lem₁{pid}{pid'}{pk}{pre = pre} rss sp {v}{v'} hpk pcsfpk sig' ¬bootstrap mws ≡epoch ≡round = mws , ¬bootstrap' , pcsfpkPre , trans ≡epoch (cong (_^∙ vdProposed ∙ biEpoch) (sym ≡voteData)) , trans ≡round (cong (_^∙ vdProposed ∙ biRound) (sym ≡voteData)) , cong (_^∙ vdProposed ∙ biId) ( ≡voteData) where -- That message has the same signature as `v'`, so it has the same vote data -- (unless there was a collision, which we currently assume does not occur). ≡voteData : msgPart mws ≡L v' at vVoteData ≡voteData = ⊎-elimˡ (PerReachableState.meta-no-collision rss) (sameSig⇒sameVoteData sig' (msgSigned mws) (sym ∘ msgSameSig $ mws)) ¬bootstrap' : ¬ ∈BootstrapInfo-impl fakeBootstrapInfo (ver-signature ∘ msgSigned $ mws) ¬bootstrap' rewrite msgSameSig mws = ¬bootstrap -- The peer can sign for `v` now, so it can sign for `v` in the preceeding -- step, because there is an honestly signed message part for the peer's pubkey in the -- current epoch already in the pool. pcsfpkPre : PeerCanSignForPK pre v pid pk pcsfpkPre = PeerCanSignForPKProps.msb4-eid≡ rss (step-peer sp) hpk pcsfpk ≡epoch sig' mws sameERasLV⇒sameId : ∀ {pid pid' pk}{st : SystemState} → ReachableSystemState st → ∀{v v' m'} → Meta-Honest-PK pk → just v ≡ peerStates st pid ^∙ pssSafetyData-rm ∙ sdLastVote → PeerCanSignForPK st v pid pk → v' ⊂Msg m' → (pid' , m') ∈ (msgPool st) → (sig' : WithVerSig pk v') → ¬ (∈BootstrapInfo-impl fakeBootstrapInfo (ver-signature sig')) → v ≡L v' at vEpoch → v ≡L v' at vRound → v ≡L v' at vProposedId -- Cheat steps cannot be where an honestly signed message originated. sameERasLV⇒sameId{pid}{pid'}{pk} (step-s{pre = pre} rss (step-peer sp@(step-cheat cmc))) {v}{v'}{m'} hpk ≡pidLV pcsfpk v'⊂m' m'∈pool sig' ¬bootstrap ≡epoch ≡round with sameERasLV⇒sameId-lem₁ rss sp hpk pcsfpk sig' ¬bootstrap mws ≡epoch ≡round where -- Track down the honestly signed message which existed before. mws : MsgWithSig∈ pk (ver-signature sig') (msgPool pre) mws = ¬cheatForgeNew sp refl unit hpk (mkMsgWithSig∈ m' v' v'⊂m' pid' m'∈pool sig' refl) ¬bootstrap ...| mws , ¬bootstrap' , pcsfpkPre , ≡epoch' , ≡round' , v'id≡ = trans (sameERasLV⇒sameId rss hpk ≡pidLVPre pcsfpkPre (msg⊆ mws) (msg∈pool mws) (msgSigned mws) ¬bootstrap' ≡epoch' ≡round') v'id≡ where -- The state of `pid` is unchanged ≡pidLVPre : just v ≡ peerStates pre pid ^∙ pssSafetyData-rm ∙ sdLastVote ≡pidLVPre = trans ≡pidLV (cong (_^∙ pssSafetyData-rm ∙ sdLastVote) (cheatStepDNMPeerStates₁ sp unit)) -- Initialization steps cannot be where an honestly signed message originated sameERasLV⇒sameId {pid} {pid'} {pk} (step-s rss step@(step-peer{pre = pre} sp@(step-honest{pid“} sps@(step-init {rm} rm×acts uni)))) {v} {v'} {m'} hpk ≡pidLV pcsfpk v'⊂m' m'∈pool sig' ¬bootstrap ≡epoch ≡round with pid ≟ pid“ -- If this isn't `pid`, the step does not affect `pid`'s state ...| no pid≢ rewrite sym $ pids≢StepDNMPeerStates{pre = pre} sps pid≢ = sameERasLV⇒sameId rss hpk ≡pidLV pcsfpkPre v'⊂m' (m'∈poolb4 v'⊂m') sig' ¬bootstrap ≡epoch ≡round where m'∈poolb4 : v' ⊂Msg m' → (pid' , m') ∈ (msgPool pre) m'∈poolb4 v'⊂m' with Any-++⁻ _ m'∈pool ...| inj₂ x = x ...| inj₁ x with initHandlerSpec.contract pid“ fakeBootstrapInfo rm×acts ...| init-contract with initHandlerSpec.ContractOk.isInitPM init-contract (proj₁ (senderMsgPair∈⇒send∈ _ x)) ...| (pm , refl , noSigs) with v'⊂m' ...| vote∈qc vs∈qc v≈rbld qc∈nm = ⊥-elim (noSigs vs∈qc qc∈nm) mws : MsgWithSig∈ pk (ver-signature sig') (msgPool pre) mws = mkMsgWithSig∈ _ _ v'⊂m' _ (m'∈poolb4 v'⊂m') sig' refl pcsfpkPre : PeerCanSignForPK pre v pid pk pcsfpkPre = PeerCanSignForPKProps.msb4-eid≡ rss step hpk pcsfpk ≡epoch sig' mws -- If this is `pid`, the last vote cannot be a `just`! ...| yes refl rewrite sym (StepPeer-post-lemma sp) with initHandlerSpec.contract pid fakeBootstrapInfo rm×acts ...| init-contract with initHandlerSpec.ContractOk.sdLVnothing init-contract ...| lv≡nothing = absurd just v ≡ nothing case trans ≡pidLV lv≡nothing of λ () sameERasLV⇒sameId{pid}{pid'}{pk} (step-s rss (step-peer{pre = pre} sp@(step-honest{pid“} sps@(step-msg{sndr , m} m∈pool ini)))) {v}{v'} hpk ≡pidLV pcsfpk v'⊂m' m'∈pool sig' ¬bootstrap ≡epoch ≡round with newMsg⊎msgSentB4 rss sps hpk sig' ¬bootstrap v'⊂m' m'∈pool -- The message has been sent before ...| Right mws' with sameERasLV⇒sameId-lem₁ rss sp hpk pcsfpk sig' ¬bootstrap mws' ≡epoch ≡round ...| mws , ¬bootstrap' , pcsfpkPre , ≡epoch' , ≡round' , v'id≡ with pid ≟ pid“ -- If this isn't `pid`, the step does not affect `pid`'s state ...| no pid≢ rewrite sym $ pids≢StepDNMPeerStates{pre = pre} sps pid≢ = trans (sameERasLV⇒sameId rss hpk ≡pidLV pcsfpkPre (msg⊆ mws) (msg∈pool mws) (msgSigned mws) ¬bootstrap' ≡epoch' ≡round') v'id≡ -- This is `pid`, so we need to know what message it was processing ...| yes refl rewrite sym $ StepPeer-post-lemma{pre = pre} sp = trans (sameERasLV⇒sameId rss hpk (≡pidLVPre m m∈pool ≡pidLV) pcsfpkPre (msg⊆ mws) (msg∈pool mws) (msgSigned mws) ¬bootstrap' ≡epoch' ≡round') v'id≡ where ≡pidLVPre : (m : NetworkMsg) → (sndr , m) ∈ msgPool pre → just v ≡ LBFT-post (handle pid m 0) (peerStates pre pid) ^∙ pssSafetyData-rm ∙ sdLastVote → just v ≡ peerStates pre pid ^∙ pssSafetyData-rm ∙ sdLastVote -- Last vote doesn't change when processing a vote message ≡pidLVPre (V vm) m∈pool ≡pidLV = begin just v ≡⟨ ≡pidLV ⟩ hvPos ^∙ pssSafetyData-rm ∙ sdLastVote ≡⟨ cong (_^∙ sdLastVote) (sym noSDChange) ⟩ hvPre ^∙ pssSafetyData-rm ∙ sdLastVote ∎ where open ≡-Reasoning hvPre = peerStates pre pid hvPos = LBFT-post (handleVote 0 vm) hvPre hvOut = LBFT-outs (handleVote 0 vm) hvPre open handleVoteSpec.Contract (handleVoteSpec.contract! 0 vm (msgPool pre) hvPre) -- Commit messages are only for reasoning about correctness ≡pidLVPre (C cm) m∈pool ≡pidLV = ≡pidLV ≡pidLVPre (P pm) m∈pool ≡pidLV = analyzeVoteAttempt where hpPre = peerStates pre pid“ hpPos = LBFT-post (handleProposal 0 pm) hpPre open handleProposalSpec.Contract (handleProposalSpec.contract! 0 pm (msgPool pre) hpPre) renaming (rmInv to rmInvP) open Invariants.RoundManagerInv (invariantsCorrect pid“ pre ini rss) -- when the last vote is the same in pre and post states module OldVote (lv≡ : hpPre ≡L hpPos at pssSafetyData-rm ∙ sdLastVote) where open ≡-Reasoning ≡pidLVPre₁ : just v ≡ hpPre ^∙ pssSafetyData-rm ∙ sdLastVote ≡pidLVPre₁ = begin just v ≡⟨ ≡pidLV ⟩ hpPos ^∙ pssSafetyData-rm ∙ sdLastVote ≡⟨ sym lv≡ ⟩ hpPre ^∙ pssSafetyData-rm ∙ sdLastVote ∎ -- When a new vote is generated, its round is strictly greater than that of the previous vote we attempted to send. module NewVote (vote : Vote) (lv≡v : just vote ≡ hpPos ^∙ pssSafetyData-rm ∙ sdLastVote) (lvr< : hpPre [ _<_ ]L hpPos at pssSafetyData-rm ∙ sdLastVotedRound) (lvr≡ : vote ^∙ vRound ≡ hpPos ^∙ pssSafetyData-rm ∙ sdLastVotedRound) (sdEpoch≡ : hpPre ^∙ pssSafetyData-rm ∙ sdEpoch ≡ pm ^∙ pmProposal ∙ bEpoch) (blockTriggered : Voting.VoteMadeFromBlock vote (pm ^∙ pmProposal)) where -- `vote` comes from the peer handler contract v≡vote : v ≡ vote v≡vote = just-injective $ begin just v ≡⟨ ≡pidLV ⟩ hpPos ^∙ pssSafetyData-rm ∙ sdLastVote ≡⟨ sym lv≡v ⟩ just vote ∎ where open ≡-Reasoning -- The round of `v'` must be less than the round of the vote stored in `sdLastVote` rv'≤lvrPre : v' ^∙ vRound ≤ Meta.getLastVoteRound (hpPre ^∙ pssSafetyData-rm) rv'≤lvrPre = oldVoteRound≤lvr rss hpk sig' ¬bootstrap mws pcsfpkPre' (ReachableSystemStateProps.mws∈pool⇒epoch≡ rss (step-msg m∈pool ini) pcsfpkPre' hpk sig' ¬bootstrap mws ≡epoch“) where pcsfpkPre' = peerCanSignEp≡ pcsfpkPre ≡epoch open ≡-Reasoning ≡epoch“ : hpPos ^∙ rmEpoch ≡ v' ^∙ vEpoch ≡epoch“ = begin hpPos ^∙ rmEpoch ≡⟨ sym noEpochChange ⟩ hpPre ^∙ rmEpoch ≡⟨ rmEpochsMatch ⟩ hpPre ^∙ pssSafetyData-rm ∙ sdEpoch ≡⟨ sdEpoch≡ ⟩ pm ^∙ pmProposal ∙ bEpoch ≡⟨ sym $ Voting.VoteMadeFromBlock.epoch≡ blockTriggered ⟩ vote ^∙ vEpoch ≡⟨ cong (_^∙ vEpoch) (sym v≡vote) ⟩ v ^∙ vEpoch ≡⟨ ≡epoch ⟩ v' ^∙ vEpoch ∎ rv'<rv : v' [ _<_ ]L v at vRound rv'<rv = begin (suc $ v' ^∙ vRound) ≤⟨ s≤s rv'≤lvrPre ⟩ (suc $ Meta.getLastVoteRound (hpPre ^∙ pssSafetyData-rm)) ≤⟨ s≤s lvRound≤ ⟩ (suc $ hpPre ^∙ pssSafetyData-rm ∙ sdLastVotedRound) ≤⟨ lvr< ⟩ hpPos ^∙ pssSafetyData-rm ∙ sdLastVotedRound ≡⟨ sym lvr≡ ⟩ vote ^∙ vRound ≡⟨ sym (cong (_^∙ vRound) v≡vote) ⟩ v ^∙ vRound ∎ where open ≤-Reasoning open SafetyDataInv (SafetyRulesInv.sdInv rmSafetyRulesInv) analyzeVoteAttempt : just v ≡ peerStates pre pid ^∙ pssSafetyData-rm ∙ sdLastVote analyzeVoteAttempt with BlockId-correct? (pm ^∙ pmProposal) ...| no ¬validProposal rewrite sym (proj₁ (invalidProposal ¬validProposal)) = ≡pidLV ...| yes refl with voteAttemptCorrect refl (nohc rss m∈pool pid ini (invariantsCorrect pid pre ini rss) refl refl) ...| Voting.mkVoteAttemptCorrectWithEpochReq (Left (_ , Voting.mkVoteUnsentCorrect noVoteMsgOuts nvg⊎vgusc)) sdEpoch≡? with nvg⊎vgusc ...| Left (mkVoteNotGenerated lv≡ lvr≤) = OldVote.≡pidLVPre₁ lv≡ ...| Right (Voting.mkVoteGeneratedUnsavedCorrect vote (Voting.mkVoteGeneratedCorrect (mkVoteGenerated lv≡v voteSrc) blockTriggered)) with voteSrc ...| Left (mkVoteOldGenerated lvr≡ lv≡) = OldVote.≡pidLVPre₁ lv≡ ...| Right (mkVoteNewGenerated lvr< lvr≡) = ⊥-elim (<⇒≢ (NewVote.rv'<rv vote lv≡v lvr< lvr≡ sdEpoch≡? blockTriggered) (sym ≡round)) analyzeVoteAttempt | yes refl | Voting.mkVoteAttemptCorrectWithEpochReq (Right (Voting.mkVoteSentCorrect vm pid voteMsgOuts vgCorrect)) sdEpoch≡? with vgCorrect ...| Voting.mkVoteGeneratedCorrect (mkVoteGenerated lv≡v voteSrc) blockTriggered with voteSrc ...| Left (mkVoteOldGenerated lvr≡ lv≡) = OldVote.≡pidLVPre₁ lv≡ ...| Right (mkVoteNewGenerated lvr< lvr≡) = ⊥-elim (<⇒≢ (NewVote.rv'<rv (vm ^∙ vmVote) lv≡v lvr< lvr≡ sdEpoch≡? blockTriggered) (sym ≡round)) -- This is the origin of the message sameERasLV⇒sameId{pid}{pid'}{pk} (step-s rss (step-peer{pre = pre} sp@(step-honest{pid“} sps@(step-msg{sndr , m} m∈pool ini)))) {v}{v'} hpk ≡pidLV pcsfpk v'⊂m' m'∈pool sig' ¬bootstrap ≡epoch ≡round | Left (m'∈acts , pcsfpk' , ¬msb4) -- So `pid“` must be `pid` with PeerCanSignForPKProps.pidInjective pcsfpk pcsfpk' ≡epoch ...| refl with v'⊂m' -- QC vote signatures have been sent before ...| vote∈qc{qc = qc} vs∈qc v≈ qc∈m' rewrite cong _vSignature v≈ = ⊥-elim ∘′ ¬msb4 $ qcVoteSigsSentB4-handle pid rss sps m'∈acts qc∈m' sig' vs∈qc v≈ ¬bootstrap ...| vote∈vm rewrite sym $ StepPeer-post-lemma{pre = pre} sp = sameId m m∈pool m'∈acts ≡pidLV where handlePre = peerStates pre pid handleOuts : NetworkMsg → List Output handleOuts m = LBFT-outs (handle sndr m 0) handlePre handlePst : NetworkMsg → RoundManager handlePst m = LBFT-post (handle sndr m 0) handlePre sameId : ∀ {sndr} m → (sndr , m) ∈ msgPool pre → send (V (VoteMsg∙new v' _)) ∈ outputsToActions{State = handlePre} (handleOuts m) → just v ≡ handlePst m ^∙ pssSafetyData-rm ∙ sdLastVote → v ≡L v' at vProposedId sameId (P pm) m∈pool m'∈acts ≡pidLV = analyzeVoteAttempt where open handleProposalSpec.Contract (handleProposalSpec.contract! 0 pm (msgPool pre) handlePre) analyzeVoteAttempt : v ≡L v' at vProposedId analyzeVoteAttempt with BlockId-correct? (pm ^∙ pmProposal) ...| no ¬validProposal = ⊥-elim (sendVote∉actions {outs = handleOuts (P pm)} {st = handlePre} (sym (proj₂ $ invalidProposal ¬validProposal)) m'∈acts) ...| yes refl with voteAttemptCorrect refl (nohc rss m∈pool pid ini (invariantsCorrect pid pre ini rss) refl refl) ...| Voting.mkVoteAttemptCorrectWithEpochReq (Left (_ , vuc)) sdEpoch≡? = ⊥-elim (sendVote∉actions {outs = handleOuts (P pm)} {st = handlePre} (sym $ Voting.VoteUnsentCorrect.noVoteMsgOuts vuc) m'∈acts) ...| Voting.mkVoteAttemptCorrectWithEpochReq (Right (Voting.mkVoteSentCorrect vm pid voteMsgOuts vgCorrect)) sdEpoch≡? with vgCorrect ...| Voting.mkVoteGeneratedCorrect (mkVoteGenerated lv≡v voteSrc) blockTriggered = cong (_^∙ vProposedId) v≡v' where open ≡-Reasoning v≡v' : v ≡ v' v≡v' = just-injective $ begin just v ≡⟨ ≡pidLV ⟩ (handlePst (P pm) ^∙ pssSafetyData-rm ∙ sdLastVote) ≡⟨ sym lv≡v ⟩ just (vm ^∙ vmVote) ≡⟨ cong (just ∘ _^∙ vmVote) (sym $ sendVote∈actions{outs = handleOuts (P pm)}{st = handlePre} (sym voteMsgOuts) m'∈acts) ⟩ just v' ∎ sameId (V vm) _ m'∈acts ≡pidLV = ⊥-elim (sendVote∉actions {outs = hvOuts} {st = peerStates pre pid} (sym noVotes) m'∈acts) where hvOuts = LBFT-outs (handleVote 0 vm) (peerStates pre pid) open handleVoteSpec.Contract (handleVoteSpec.contract! 0 vm (msgPool pre) handlePre) sameId (C x) _ () ------------------------------------------------------------------------------ votesOnce₁ : Common.IncreasingRoundObligation Handle.InitHandler.initAndHandlers 𝓔 votesOnce₁ {pid = pid} {pid'} {pk = pk} {pre = pre} preach (step-init {rm} rm×acts uni) {v} {m} {v'} {m'} hpk v⊂MsgPpm m∈acts sig ¬bootstrap ¬msb pcspkv v'⊂m' m'∈pool sig' ¬bootstrap' eid≡ with initHandlerSpec.contract pid fakeBootstrapInfo rm×acts ...| init-contract with initHandlerSpec.ContractOk.isInitPM init-contract m∈acts ...| (_ , _ , noSigs) with v⊂MsgPpm ...| vote∈qc vs∈qc v≈rbld qc∈nm = ⊥-elim (noSigs vs∈qc qc∈nm) votesOnce₁ {pid = pid} {pid'} {pk = pk} {pre = pre} preach sps@(step-msg {sndr , P pm} m∈pool ini) {v} {m} {v'} {m'} hpk (vote∈qc {vs} {qc} vs∈qc v≈rbld qc∈m) m∈acts sig ¬bootstrap ¬msb pcspkv v'⊂m' m'∈pool sig' ¬bootstrap' eid≡ with cong _vSignature v≈rbld ...| refl = ⊥-elim ∘′ ¬msb $ qcVoteSigsSentB4-handle pid preach sps m∈acts qc∈m sig vs∈qc v≈rbld ¬bootstrap votesOnce₁ {pid = pid} {pid'} {pk = pk} {pre = pre} preach sps@(step-msg {sndr , P pm} m∈pool ini) {v} {.(V (VoteMsg∙new v _))} {v'} {m'} hpk vote∈vm m∈acts sig ¬bootstrap ¬msb pcspkv v'⊂m' m'∈pool sig' ¬bootstrap' eid≡ with handleProposalSpec.contract! 0 pm (msgPool pre) (peerStates pre pid) ...| handleProposalSpec.mkContract _ invProp noEpochChange vac _ _ with BlockId-correct? (pm ^∙ pmProposal) ...| no ¬validProposal = ⊥-elim (sendVote∉actions {outs = hpOut} {st = hpPre} (sym (proj₂ $ invProp ¬validProposal)) m∈acts ) where hpPre = peerStates pre pid hpOut = LBFT-outs (handleProposal 0 pm) hpPre ...| yes refl with vac refl (nohc preach m∈pool pid ini (invariantsCorrect pid pre ini preach) refl refl) ...| Voting.mkVoteAttemptCorrectWithEpochReq (inj₁ (_ , Voting.mkVoteUnsentCorrect noVoteMsgOuts nvg⊎vgusc)) sdEpoch≡? = ⊥-elim (sendVote∉actions{outs = LBFT-outs (handleProposal 0 pm) (peerStates pre pid)}{st = peerStates pre pid} (sym noVoteMsgOuts) m∈acts) ...| Voting.mkVoteAttemptCorrectWithEpochReq (inj₂ (Voting.mkVoteSentCorrect vm pid₁ voteMsgOuts vgCorrect)) sdEpoch≡? with sendVote∈actions{outs = LBFT-outs (handleProposal 0 pm) (peerStates pre pid)}{st = peerStates pre pid} (sym voteMsgOuts) m∈acts ...| refl = ret where -- Some definitions step = step-peer (step-honest sps) rmPre = peerStates pre pid rmPost = peerStates (StepPeer-post{pre = pre} (step-honest sps)) pid -- State invariants rmInvs = invariantsCorrect pid pre ini preach open RoundManagerInv rmInvs -- Properties of `handleProposal` postLV≡ : just v ≡ (rmPost ^∙ pssSafetyData-rm ∙ sdLastVote) postLV≡ = trans (RoundManagerTransProps.VoteGenerated.lv≡v ∘ Voting.VoteGeneratedCorrect.state $ vgCorrect) (cong (_^∙ pssSafetyData-rm ∙ sdLastVote) (StepPeer-post-lemma (step-honest sps))) -- The proof m'mwsb : MsgWithSig∈ pk (ver-signature sig') (msgPool pre) m'mwsb = mkMsgWithSig∈ m' v' v'⊂m' pid' m'∈pool sig' refl pcspkv'-pre : PeerCanSignForPK pre v' pid pk pcspkv'-pre = PeerCanSignForPKProps.msb4 preach step (peerCanSignEp≡{v' = v'} pcspkv eid≡) hpk sig' m'mwsb rv'≤rv : v' ^∙ vRound ≤ v ^∙ vRound rv'≤rv = ≤-trans (oldVoteRound≤lvr preach hpk sig' ¬bootstrap' m'mwsb pcspkv'-pre (trans rmPreEsEpoch≡ eid≡)) realLVR≤rv where open ≡-Reasoning -- TODO-1 : `rmPreSdEpoch≡` can be factored out into a lemma. -- Something like: for any reachable state where a peer sends a vote, the -- epoch for that vote is the peer's sdEpoch / esEpoch. rmPreSdEpoch≡ : rmPre ^∙ pssSafetyData-rm ∙ sdEpoch ≡ v ^∙ vEpoch rmPreSdEpoch≡ with Voting.VoteGeneratedCorrect.state vgCorrect | Voting.VoteGeneratedCorrect.blockTriggered vgCorrect ...| RoundManagerTransProps.mkVoteGenerated lv≡v (Left (RoundManagerTransProps.mkVoteOldGenerated lvr≡ lv≡)) | _ with SafetyDataInv.lvEpoch≡ ∘ SafetyRulesInv.sdInv $ rmSafetyRulesInv ...| sdEpochInv rewrite trans lv≡ (sym lv≡v) = sym sdEpochInv rmPreSdEpoch≡ | RoundManagerTransProps.mkVoteGenerated lv≡v (Right (RoundManagerTransProps.mkVoteNewGenerated lvr< lvr≡)) | bt = trans sdEpoch≡? (sym ∘ proj₁ ∘ Voting.VoteMadeFromBlock⇒VoteEpochRoundIs $ bt) rmPreEsEpoch≡ : rmPre ^∙ rmEpochState ∙ esEpoch ≡ v ^∙ vEpoch rmPreEsEpoch≡ = begin rmPre ^∙ rmEpochState ∙ esEpoch ≡⟨ rmEpochsMatch ⟩ rmPre ^∙ pssSafetyData-rm ∙ sdEpoch ≡⟨ rmPreSdEpoch≡ ⟩ v ^∙ vEpoch ∎ realLVR≤rv : Meta.getLastVoteRound (rmPre ^∙ pssSafetyData-rm) ≤ v ^∙ vRound realLVR≤rv with Voting.VoteGeneratedCorrect.state vgCorrect ...| RoundManagerTransProps.mkVoteGenerated lv≡v (inj₁ (RoundManagerTransProps.mkVoteOldGenerated lvr≡ lv≡)) rewrite trans lv≡ (sym lv≡v) = ≤-refl ...| RoundManagerTransProps.mkVoteGenerated lv≡v (inj₂ (RoundManagerTransProps.mkVoteNewGenerated lvr< lvr≡)) with rmPre ^∙ pssSafetyData-rm ∙ sdLastVote | SafetyDataInv.lvRound≤ ∘ SafetyRulesInv.sdInv $ rmSafetyRulesInv ...| nothing | _ = z≤n ...| just lv | round≤ = ≤-trans (≤-trans round≤ (<⇒≤ lvr<)) (≡⇒≤ (sym lvr≡)) ret : v' [ _<_ ]L v at vRound ⊎ Common.VoteForRound∈ Handle.InitHandler.initAndHandlers 𝓔 pk (v ^∙ vRound) (v ^∙ vEpoch) (v ^∙ vProposedId) (msgPool pre) ret with <-cmp (v' ^∙ vRound) (v ^∙ vRound) ...| tri< rv'<rv _ _ = Left rv'<rv ...| tri≈ _ rv'≡rv _ = Right (Common.mkVoteForRound∈ _ v' v'⊂m' pid' m'∈pool sig' (sym eid≡) rv'≡rv (sym (sameERasLV⇒sameId (step-s preach step) hpk postLV≡ pcspkv v'⊂m' (Any-++ʳ _ m'∈pool) sig' ¬bootstrap' eid≡ (sym rv'≡rv) ))) ...| tri> _ _ rv'>rv = ⊥-elim (≤⇒≯ rv'≤rv rv'>rv) votesOnce₁{pid = pid}{pid'}{pk = pk}{pre = pre} preach sps@(step-msg{sndr , V vm} m∈pool ini){v}{m}{v'}{m'} hpk v⊂m m∈acts sig ¬bootstrap ¬msb vspk v'⊂m' m'∈pool sig' ¬bootstrap' eid≡ with v⊂m ...| vote∈qc vs∈qc v≈rbld qc∈m rewrite cong _vSignature v≈rbld = ⊥-elim ∘′ ¬msb $ qcVoteSigsSentB4-handle pid preach sps m∈acts qc∈m sig vs∈qc v≈rbld ¬bootstrap ...| vote∈vm = ⊥-elim (sendVote∉actions{outs = hvOut}{st = hvPre} (sym noVotes) m∈acts) where hvPre = peerStates pre pid hvOut = LBFT-outs (handleVote 0 vm) hvPre open handleVoteSpec.Contract (handleVoteSpec.contract! 0 vm (msgPool pre) hvPre) ------------------------------------------------------------------------------ votesOnce₂ : VO.ImplObligation₂ Handle.InitHandler.initAndHandlers 𝓔 votesOnce₂ {pid} {pk = pk} {pre} rss (step-init {rm} rm×acts uni) hpk v⊂m m∈acts sig ¬bootstrap ¬msb4 pcsfpk v'⊂m' m'∈acts sig' ¬bootstrap' ¬msb4' pcsfpk' ≡epoch ≡round with initHandlerSpec.contract pid fakeBootstrapInfo rm×acts ...| init-contract with initHandlerSpec.ContractOk.isInitPM init-contract m∈acts ...| (_ , refl , noSigs) with v⊂m ...| vote∈qc vs∈qc v≈rbld qc∈pm = ⊥-elim (noSigs vs∈qc qc∈pm) votesOnce₂{pid}{pk = pk}{pre} rss (step-msg{sndr , m“} m“∈pool ini){v}{v' = v'} hpk v⊂m m∈acts sig ¬bootstrap ¬msb4 pcsfpk v'⊂m' m'∈acts sig' ¬bootstrap' ¬msb4' pcsfpk' ≡epoch ≡round with v⊂m ...| vote∈qc vs∈qc v≈rbld qc∈m rewrite cong _vSignature v≈rbld = ⊥-elim ∘′ ¬msb4 $ qcVoteSigsSentB4-handle pid rss (step-msg m“∈pool ini) m∈acts qc∈m sig vs∈qc v≈rbld ¬bootstrap ...| vote∈vm with v'⊂m' ...| vote∈qc vs∈qc' v≈rbld' qc∈m' rewrite cong _vSignature v≈rbld' = ⊥-elim ∘′ ¬msb4' $ qcVoteSigsSentB4-handle pid rss (step-msg m“∈pool ini) m'∈acts qc∈m' sig' vs∈qc' v≈rbld' ¬bootstrap' ...| vote∈vm with m“ ...| P pm = cong (_^∙ vProposedId) v≡v' where hpPool = msgPool pre hpPre = peerStates pre pid hpOut = LBFT-outs (handleProposal 0 pm) hpPre open handleProposalSpec.Contract (handleProposalSpec.contract! 0 pm hpPool hpPre) v≡v' : v ≡ v' v≡v' with BlockId-correct? (pm ^∙ pmProposal) ...| no ¬validProposal = ⊥-elim (sendVote∉actions {outs = hpOut} {st = hpPre} (sym (proj₂ $ invalidProposal ¬validProposal)) m∈acts) ...| yes refl with voteAttemptCorrect refl (nohc rss m“∈pool pid ini (invariantsCorrect pid pre ini rss) refl refl ) ...| Voting.mkVoteAttemptCorrectWithEpochReq (Left (_ , Voting.mkVoteUnsentCorrect noVoteMsgOuts _)) _ = ⊥-elim (sendVote∉actions{outs = hpOut}{st = hpPre} (sym noVoteMsgOuts) m∈acts) ...| Voting.mkVoteAttemptCorrectWithEpochReq (Right (Voting.mkVoteSentCorrect vm pid voteMsgOuts _)) _ = begin v ≡⟨ cong (_^∙ vmVote) (sendVote∈actions{outs = hpOut}{st = hpPre} (sym voteMsgOuts) m∈acts) ⟩ vm ^∙ vmVote ≡⟨ (sym $ cong (_^∙ vmVote) (sendVote∈actions{outs = hpOut}{st = hpPre} (sym voteMsgOuts) m'∈acts)) ⟩ v' ∎ where open ≡-Reasoning ...| V vm = ⊥-elim (sendVote∉actions{outs = hvOut}{st = hvPre} (sym noVotes) m∈acts) where hvPre = peerStates pre pid hvOut = LBFT-outs (handle pid (V vm) 0) hvPre open handleVoteSpec.Contract (handleVoteSpec.contract! 0 vm (msgPool pre) hvPre)
{ "alphanum_fraction": 0.6522072484, "avg_line_length": 51.3803030303, "ext": "agda", "hexsha": "8e071ba4b8532447d7491e3c8f57d7223e714738", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/Properties/VotesOnce.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/Properties/VotesOnce.agda", "max_line_length": 228, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/Properties/VotesOnce.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11909, "size": 33911 }
-- Andreas, 2016-07-28, issue #779 record R : Set1 where Bla : Set1 Bla with Set ... | _ = Set field F : Set -- Current error: -- Missing definition for Bla -- Expected: -- Success, or error outlawing pattern matching definition before last field.
{ "alphanum_fraction": 0.6603773585, "avg_line_length": 15.5882352941, "ext": "agda", "hexsha": "2612ac5caae0a1815b6b350dd75c4a5d10941fd7", "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/Issue779with.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/Issue779with.agda", "max_line_length": 77, "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/Issue779with.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": 78, "size": 265 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.Vec.Relation.Unary.All.Properties directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.All.Properties where open import Data.Vec.Relation.Unary.All.Properties public {-# WARNING_ON_IMPORT "Data.Vec.All.Properties was deprecated in v1.0. Use Data.Vec.Relation.Unary.All.Properties instead." #-}
{ "alphanum_fraction": 0.5459662289, "avg_line_length": 29.6111111111, "ext": "agda", "hexsha": "04e6bbd610bb29a7d72dda52fb06c38ec16bac54", "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/All/Properties.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/All/Properties.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/All/Properties.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": 97, "size": 533 }
{-# OPTIONS --prop --without-K --rewriting #-} -- Theorems about noninterference. open import Calf.CostMonoid module Calf.Noninterference (costMonoid : CostMonoid) where open import Calf.Prelude open import Calf.Metalanguage open import Calf.Step costMonoid open import Calf.PhaseDistinction open import Calf.Types.Eq open import Data.Product open import Relation.Binary.PropositionalEquality as P oblivious : ∀ {A B} (f : cmp (F A) → val (◯⁺ B)) → ∀ c e → f (step (F A) c e) ≡ f e oblivious {A} {B} f c e = funext/Ω (λ u → begin f (step (F A) c e) u ≡⟨ cong (λ e → f e u) (step/ext (F A) e c u) ⟩ f e u ∎ ) where open ≡-Reasoning unique : ∀ {A} → (a : val (● A)) → (u : ext) → a ≡ ∗ u unique {A} a u = eq/ref (●/ind {A} a (λ a → F (eq (● A) a (∗ u))) (λ a → ret (eq/intro (η≡∗ a u))) (λ u → ret (eq/intro refl)) (λ a u → eq/uni _ _ u)) constant : ∀ {A B} (f : val (● A) → val (◯⁺ B)) → Σ (val (◯⁺ B)) λ b → f ≡ λ _ → b constant f = (λ u → f (∗ u) u) , funext (λ a → funext/Ω (λ u → P.cong (λ a → f a u) (unique a u))) optimization : ∀ {C B : tp pos} {A : val C → tp pos} (f : val (Σ++ C λ c → ● (A c)) → val (◯⁺ B)) → Σ (val C → val (◯⁺ B)) λ f' → ∀ c a → f (c , a) ≡ f' c optimization {C} {B} {A} f = (λ c → let g : val (● (A c)) → val (◯⁺ B) g a = f (c , a) in let (b , h) = constant {A c} {B} g in b) , λ c a → let g : val (● (A c)) → val (◯⁺ B) g a = f (c , a) in let (b , h) = constant {A c} {B} g in P.cong-app h a
{ "alphanum_fraction": 0.5115359262, "avg_line_length": 27.0892857143, "ext": "agda", "hexsha": "a74bc2eb6f68f24c4b69a9f5e724f35193b5a787", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z", "max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "jonsterling/agda-calf", "max_forks_repo_path": "src/Calf/Noninterference.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "jonsterling/agda-calf", "max_issues_repo_path": "src/Calf/Noninterference.agda", "max_line_length": 69, "max_stars_count": 29, "max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "jonsterling/agda-calf", "max_stars_repo_path": "src/Calf/Noninterference.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z", "num_tokens": 666, "size": 1517 }
module Punctaffy.Hypersnippet.Hyperstack where open import Level using (Level; _⊔_) open import Punctaffy.Hypersnippet.Dim using (DimSys; dimLte) data DimList {n l : Level} : DimSys {n} {l} → Set (n ⊔ l) → Set (n ⊔ l) where makeDimList : {ds : DimSys} → {a : Set (n ⊔ l)} → (len : DimSys.Carrier ds) → ((i : DimSys.Carrier ds) → dimLte {n} {l} {ds} i len → a) → DimList ds a
{ "alphanum_fraction": 0.6447368421, "avg_line_length": 42.2222222222, "ext": "agda", "hexsha": "609c5773468702a39730fae1e698c712c0da4969", "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": "b5a981ce0158c3c8e1296da4a71e83de23ed52ef", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "lathe/punctaffy-for-racket", "max_forks_repo_path": "notes/code-sketches/agda/src/Punctaffy/Hypersnippet/Hyperstack.agda", "max_issues_count": 13, "max_issues_repo_head_hexsha": "2a958bf3987459e9197eb5963fe5107ea2e2e912", "max_issues_repo_issues_event_max_datetime": "2022-03-06T14:40:21.000Z", "max_issues_repo_issues_event_min_datetime": "2021-03-12T03:11:01.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "rocketnia/lexmeta", "max_issues_repo_path": "notes/code-sketches/agda/src/Punctaffy/Hypersnippet/Hyperstack.agda", "max_line_length": 152, "max_stars_count": 1, "max_stars_repo_head_hexsha": "2a958bf3987459e9197eb5963fe5107ea2e2e912", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "rocketnia/lexmeta", "max_stars_repo_path": "notes/code-sketches/agda/src/Punctaffy/Hypersnippet/Hyperstack.agda", "max_stars_repo_stars_event_max_datetime": "2020-02-03T21:26:07.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-03T21:26:07.000Z", "num_tokens": 152, "size": 380 }
module Tests where open import BasicFunctions open import TransportLemmas open import EquivalenceType open import QuasiinverseType open import QuasiinverseLemmas open import HLevelTypes open import HLevelLemmas open import UnivalenceAxiom open import CoproductIdentities equiv-is-inj : {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{B : Type ℓ₂} → (f : A → B) → isEquiv f → ∀ {x y : A} → (f x ≡ f y) → x ≡ y equiv-is-inj {A = A}{B} f f-is-equiv fx≡fy = ! cr · (ap f^-1 fx≡fy · cr) where f^-1 : B → A f^-1 = remap (f , f-is-equiv) cr : ∀ {x : A} → f^-1 (f x) ≡ x cr = rlmap-inverse (f , f-is-equiv) module _ {ℓ : Level} {A : Type ℓ} where equiv-induction : (P : (C : Type ℓ) → (A ≃ C) → Type ℓ) → P A idEqv → (C : Type ℓ) → (e : A ≃ C) ----------------------------- → P C e equiv-induction P p-refl C e = tr (P C) (ua-β e) g where open import HLevelLemmas P' : (C : Type ℓ) → A ≡ C → Type ℓ P' C p = P C (idtoeqv p) b' : P A (idtoeqv idp) b' = tr (P A) (sameEqv idp) p-refl f' : (C : Type ℓ) → (p : A ≡ C) → P C (idtoeqv p) f' C idp = b' g : P C (idtoeqv (ua e)) g = f' C (ua e) postcomp-is-equiv : (B : Type ℓ) → (e : A ≃ B) → ∀ {C : Type ℓ} → isEquiv {A = C → A} {B = C → B} (_:> (e ∙→)) postcomp-is-equiv B e = equiv-induction (λ C A≃C → isEquiv (_:> (A≃C ∙→) )) base-case B e where base-case : isEquiv (λ f x → π₁ idEqv (f x)) base-case = π₂ idEqv postcomp-≃ : (B : Type ℓ) → (e : A ≃ B) → (X : Type ℓ) → (X → A) ≃ (X → B) postcomp-≃ B e X = (_:> (e ∙→)) , postcomp-is-equiv B e postcomp-is-inj : (B : Type ℓ) → (e : A ≃ B) → {C : Type ℓ} → (f g : C → A) → f :> (e ∙→) ≡ g :> (e ∙→) → f ≡ g postcomp-is-inj B e f g p = equiv-is-inj (_:> (e ∙→)) (postcomp-is-equiv B e) p -- The naive non-dependent function extensionality axiom funext' : {ℓ : Level} {A : Type ℓ}{B : Type ℓ} → (f g : A → B) → (h : ∏[ x ∶ A ] (f x ≡ g x)) → f ≡ g funext' {A = A}{B} f g h = ap (_:> p₁) d≡e where d e : A → ∑[ (x , y ) ∶ (B × B) ] (x ≡ y) d = λ x → ((f x , f x)) , refl (f x) e = λ x → ((f x , g x)) , h x p₀ : ∑[ (x , y ) ∶ (B × B) ] (x ≡ y) → B p₀ ((x , y) , p) = x p₁ : ∑[ (x , y ) ∶ (B × B) ] (x ≡ y) → B p₁ ((x , y) , p) = y p₀-is-equiv : isEquiv p₀ p₀-is-equiv = π₂ (qinv-≃ p₀ ((λ x → ((x , x) , (refl x) )) , (λ {p → idp}) , (λ {((x , .x) , idp) → idp}))) d:>p₀≡e:>p₀ : (d :> p₀) ≡ (e :> p₀) d:>p₀≡e:>p₀ = idp d≡e : d ≡ e d≡e = postcomp-is-inj B (p₀ , p₀-is-equiv) d e d:>p₀≡e:>p₀ -- naive-funext implies weak extensionality: open import FibreType open import EquivalenceReasoning left-universal-property-of-idenity-type : {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{B : A → Type ℓ₂} → (a x : A) → (∑[ p ∶ a ≡ x ] B a) ≃ (∑[ b ∶ B a ] a ≡ x) left-universal-property-of-idenity-type a x = qinv-≃ f (g , ((λ {(_ , idp) → idp}) , λ { (idp , π₄) → idp})) where f = λ {(idp , b) → (b , idp)} g = λ {(b , p) → (p , b)} universal-property-of-identity-type : {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{B : A → Type ℓ₂} → (x : A) → B x ≃ (∑[ a ∶ A ] ∑[ p ∶ a ≡ x ] B a) universal-property-of-identity-type x = qinv-≃ f (g , (λ { (a , idp , π₄) → idp}) , λ {p → idp}) where f = λ b → (x , (refl x , b)) g = λ {(a , (idp , b)) → b} contr-fibers-gives-pr₁-equiv : {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{B : A → Type ℓ₂} → ((x : A) → isContr (B x)) → (pr₁ {A = A}{B}) is-equiv contr-fibers-gives-pr₁-equiv {A = A}{B} Bx-is-contr = λ x → equiv-preserves-contr (calculation x) (Bx-is-contr x) where open import SigmaEquivalence open import SigmaPreserves open import HLevelLemmas calculation : (x : A) → (B x) ≃ fib (pr₁ {A = A}{B}) x calculation x = begin≃ B x ≃⟨ universal-property-of-identity-type {A = A}{B} x ⟩ ∑[ a ∶ A ] (∑[ p ∶ a ≡ x ] B a) ≃⟨ sigma-preserves (λ a → left-universal-property-of-idenity-type {A = A}{B} a x) ⟩ ∑[ a ∶ A ] (∑[ b ∶ B a ] a ≡ x) ≃⟨⟩ ∑[ a ∶ A ] (∑[ b ∶ B a ] (pr₁ {A = A}{B} (a , b) ≡ x) ) ≃⟨ ∑-assoc ⟩ (∑[ p ∶ ∑ A B ] (pr₁ p ≡ x)) ≃⟨⟩ fib (pr₁ {A = A}{B}) x ≃∎ happly : ∀ {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{B : A → Type ℓ₂} → {f g : ∏ A B} → (f ≡ g) → (x : A) → (f x ≡ g x) happly idp x = idp weak-extensionality pi-is-contr : {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{B : A → Type ℓ₂} → ((x : A) → isContr (B x)) → isContr (Π A B) weak-extensionality {ℓ₁}{ℓ₂}{A}{B} Bx-is-contr = retract-of-singleton Π-is-retract fib-α-id-is-contr where open import SectionsAndRetractions α≃ : ((↑ ℓ₂ A) → ∑ (↑ ℓ₂ A) λ { (Lift a) → B a}) ≃ ((↑ ℓ₂ A) → ↑ ℓ₂ A) α≃ = postcomp-≃ (↑ ℓ₂ A) (pr₁ , contr-fibers-gives-pr₁-equiv (λ { (Lift a) → Bx-is-contr a})) (↑ ℓ₂ A) α = α≃ ∙→ fib-α-id = fib α (id-on (↑ ℓ₂ A)) fib-α-id-is-contr : isContr (fib-α-id) fib-α-id-is-contr = pr₂ α≃ (id-on (↑ ℓ₂ A)) φ : fib-α-id → Π A B φ (g , p) = λ x → tr (λ { (Lift a) → B a}) (happly p (Lift x)) (pr₂ (g (Lift x))) ψ : (f : Π A B) → fib-α-id ψ f = ((λ {(Lift a) → (Lift a) , f a}) , refl (id-on (↑ ℓ₂ A))) Π-is-retract : retract (Π A B) of fib-α-id Π-is-retract = (φ , (ψ , λ f → idp)) pi-is-contr = weak-extensionality funext : {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{B : A → Type ℓ₂} → (f g : ∏ A B) → (h : ∏[ x ∶ A ] (f x ≡ g x)) → f ≡ g funext {ℓ₁}{ℓ₂}{A}{B} f g h = ap (_!-inv) p where hat : (∏ A B) → (↑ ℓ₂ A) → ∑ A B hat f (Lift a) = (a , f a) hat-f≡hat-g : (hat f) ≡ (hat g) hat-f≡hat-g = funext' (hat f) (hat g) (λ { (Lift a) → pair= (idp , h a)}) _! : ∏ A B → ∑[ h ∶ ((↑ ℓ₂ A) → ∑ A B) ] (∏[ x ∶ (↑ ℓ₂ A) ] (π₁ (h x) ≡ lower x) ) f ! = ( hat f , λ { (Lift a) → refl a}) _!-inv : ∑[ h ∶ ((↑ ℓ₂ A) → ∑ A B) ] (∏[ x ∶ (↑ ℓ₂ A) ] (π₁ (h x) ≡ (lower x)) ) → ∏ A B _!-inv (h , p) = λ x → tr B (p (Lift x)) (π₂ (h (Lift x))) -- see that, the round trip gives. _ : ((f !) !-inv) ≡ f _ = idp p : (f !) ≡ (g !) p = pair= (hat-f≡hat-g , q) where open import HLevelLemmas q : PathOver (λ h₁ → ∏ (↑ ℓ₂ A) (λ x → π₁ (h₁ x) ≡ lower x)) (π₂ (f !)) hat-f≡hat-g (π₂ (g !)) q = contr-is-prop (weak-extensionality (λ {(Lift a) → idp , λ { idp → idp}})) (tr (λ h → ∏ (↑ ℓ₂ A) λ x → π₁ (h x) ≡ lower x) hat-f≡hat-g (π₂ (f !))) (π₂ (g !)) fiberwise-transformation fiberwise-map-from_to_ : ∀ {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁} → (P Q : A → Type ℓ₂) → Type (ℓ₁ ⊔ ℓ₂) fiberwise-transformation P Q = ∏[ x ] (P x → Q x) fiberwise-map-from_to_ = fiberwise-transformation total : ∀ {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{P Q : A → Type ℓ₂} → (f : fiberwise-map-from P to Q) → ((∑ A P) → (∑ A Q)) total f (a , p) = ( a , f a p) fib-total-≃fib-fiberwise : ∀ {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{P Q : A → Type ℓ₂} → (f : fiberwise-map-from P to Q) → (x : A) (v : Q x) → fib (total f) (( x , v)) ≃ fib (f x) v fib-total-≃fib-fiberwise {P = P}{Q} f x v = qinv-≃ f' (g' , (λ {(p , idp) → idp}) , λ { (a , idp) → idp}) where private f' = λ { ((a , p) , idp) → (p , idp)} g' = λ { (p , idp) → ( (x , p) , idp)} fib-total-equiv-from-fiberwise-equiv : ∀ {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{P Q : A → Type ℓ₂} → (f : fiberwise-map-from P to Q) → ((x : A) → (f x) is-equiv) -- this says f is fiberwise equivalence. → ((total f) is-equiv) fib-total-equiv-from-fiberwise-equiv f f-fiberwise-equiv = λ x → equiv-preserves-contr (≃-sym (fib-total-≃fib-fiberwise f (π₁ x) (π₂ x))) (f-fiberwise-equiv (π₁ x) (π₂ x)) fib-total-equiv-to-fiberwise-equiv : ∀ {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{P Q : A → Type ℓ₂} → (f : fiberwise-map-from P to Q) → ((total f) is-equiv) → ((x : A) → (f x) is-equiv) fib-total-equiv-to-fiberwise-equiv f total-is-equiv = λ x → λ p → equiv-preserves-contr (fib-total-≃fib-fiberwise f x p) (total-is-equiv ((x , p))) happly-is-equiv : ∀ {ℓ₁ ℓ₂ : Level} {A : Type ℓ₁}{B : A → Type ℓ₂} → {f g : ∏ A B} → (happly {f = f} {g}) is-equiv happly-is-equiv {A = A}{B}{f = f}{g} h = fib-total-equiv-to-fiberwise-equiv s total-happly-is-equiv g h where open import SigmaEquivalence calculation : (∏[ x ∶ A ] (∑[ u ∶ B x ] (f x ≡ u))) ≃ (∑[ g ∶ ∏ A B ] (∏[ x ∶ A ] (f x ≡ g x))) calculation = choice α-codomain-is-contr : isContr ((∑[ g ∶ ∏ A B ] (∏[ x ∶ A ] (f x ≡ g x)))) α-codomain-is-contr = equiv-preserves-contr choice (pi-is-contr (λ x → pathfrom-is-contr _ _)) s : (g : (∏ A B)) → (f ≡ g) → (∏[ x ∶ A ] (f x ≡ g x)) s g p = happly p α : (∑[ g ∶ (∏ A B) ] (f ≡ g)) → (∑[ g ∶ ∏ A B ] ∏[ x ∶ A ] (f x ≡ g x)) α (g , p) = (g , happly p) total-happly-is-equiv : α is-equiv total-happly-is-equiv (g , p) = map-domain-and-codomain-contr-is-equiv α-domain-is-contr α-codomain-is-contr _ _ where open import SectionsAndRetractions α-domain-is-contr : isContr (domain α) α-domain-is-contr = pathfrom-is-contr _ _ map-domain-and-codomain-contr-is-equiv : ∀ {ℓ₁ ℓ₂ : Level}{X : Type ℓ₁}{Y : Type ℓ₂} → X is-contr → Y is-contr → (f : X → Y) → f is-equiv map-domain-and-codomain-contr-is-equiv {X = X}{Y} X-is-contr Y-is-contr f = λ y → ((center-of X-is-contr , contr-is-prop Y-is-contr _ _)) , λ x → pair= (contr-is-prop X-is-contr _ _ , prop-is-set (contr-is-prop Y-is-contr) _ _ _ _)
{ "alphanum_fraction": 0.4624987416, "avg_line_length": 31.2358490566, "ext": "agda", "hexsha": "f4780ed739f285494ada6f27c340d4e00bfa8dd3", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-26T15:16:01.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-26T15:16:01.000Z", "max_forks_repo_head_hexsha": "9e81415f0276ee42b4a57816c1dcd3aaa6d9ea60", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "jonaprieto/mini-hott", "max_forks_repo_path": "src/Tests.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9e81415f0276ee42b4a57816c1dcd3aaa6d9ea60", "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": "jonaprieto/mini-hott", "max_issues_repo_path": "src/Tests.agda", "max_line_length": 99, "max_stars_count": 3, "max_stars_repo_head_hexsha": "9e81415f0276ee42b4a57816c1dcd3aaa6d9ea60", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "jonaprieto/mini-hott", "max_stars_repo_path": "src/Tests.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-17T10:28:06.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-12T14:19:04.000Z", "num_tokens": 4336, "size": 9933 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Library.Relation.Decidable where open import Light.Level using (Setω ; Level) open import Light.Variable.Levels open import Light.Variable.Sets open import Light.Library.Relation using (Base ; Kind ; Style) open import Light.Indexed using (Indexed ; thing ; indexed) open import Light.Package using (Package) record Dependencies : Setω where record Library (dependencies : Dependencies) : Setω where field base : Base open Style (base .Base.style) using (True ; False) open Kind (base .Base.kind) using (Index ; Proposition) field ℓf : Index → Level Decidable : ∀ {i} → Proposition i → Set (ℓf i) kind : Kind kind = record { Index = Indexed Index Proposition ; Proposition = λ i → Decidable (thing i) } field instance style : Style kind if′_then_else_ : ∀ {i} {𝕒 : Proposition i} → Decidable 𝕒 → 𝕓 → 𝕓 → 𝕓 if_then_else_ : ∀ {i} {𝕒 : Proposition i} → Decidable 𝕒 → (∀ ⦃ witness : True 𝕒 ⦄ → 𝕓) → (∀ ⦃ witness : False 𝕒 ⦄ → 𝕓) → 𝕓 to‐witness : ∀ {i} {𝕒 : Proposition i} {a? : Decidable 𝕒} ⦃ truth : Style.True style a? ⦄ → True 𝕒 to‐false‐witness : ∀ {i} {𝕒 : Proposition i} {a? : Decidable 𝕒} ⦃ falsehood : Style.False style a? ⦄ → False 𝕒 ⦃ from‐witness ⦄ : ∀ {i} {𝕒 : Proposition i} {a? : Decidable 𝕒} ⦃ witness : True 𝕒 ⦄ → Style.True style a? ⦃ from‐false‐witness ⦄ : ∀ {i} {𝕒 : Proposition i} {a? : Decidable 𝕒} ⦃ witness : False 𝕒 ⦄ → Style.False style a? yes : ∀ {i} {𝕒 : Proposition i} → True 𝕒 → Decidable 𝕒 no : ∀ {i} {𝕒 : Proposition i} → False 𝕒 → Decidable 𝕒 instance base′ = record { kind = kind ; style = style } open Library ⦃ ... ⦄ public
{ "alphanum_fraction": 0.5607287449, "avg_line_length": 42.9565217391, "ext": "agda", "hexsha": "a86e59a44bf546d17b37c2c7aa4975f159dfa7f1", "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/Library/Relation/Decidable.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/Library/Relation/Decidable.agda", "max_line_length": 126, "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/Library/Relation/Decidable.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": 609, "size": 1976 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types open import LibraBFT.ImplShared.Base.Types open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Util.Dijkstra.All open import Optics.All open import Util.Prelude module LibraBFT.Impl.Consensus.Liveness.ProposerElection where postulate -- TODO-1: Implement getValidProposer getValidProposer : ProposerElection → Round → Author isValidProposerM : Author → Round → LBFT Bool isValidProposer : ProposerElection → Author → Round → Bool isValidProposalM : Block → LBFT (Either ObmNotValidProposerReason Unit) isValidProposalM b = maybeSD (b ^∙ bAuthor) (bail ProposalDoesNotHaveAnAuthor) $ λ a → do -- IMPL-DIFF: `ifM` in Haskell means something else vp ← isValidProposerM a (b ^∙ bRound) ifD vp then ok unit else bail ProposerForBlockIsNotValidForThisRound isValidProposerM a r = isValidProposer <$> use lProposerElection <*> pure a <*> pure r isValidProposer pe a r = getValidProposer pe r == a
{ "alphanum_fraction": 0.771801141, "avg_line_length": 36.0882352941, "ext": "agda", "hexsha": "1148f9f1cd02769333469ca43e7959c79d134c0c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/Consensus/Liveness/ProposerElection.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/Consensus/Liveness/ProposerElection.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/Consensus/Liveness/ProposerElection.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 343, "size": 1227 }
{-# OPTIONS --without-K #-} module Pi0Cat where -- Proving that Pi at level 0 symmetric rig groupoid open import Level using () renaming (zero to lzero) open import Data.Unit using (tt) open import Data.Product using (_,_) open import Categories.Category using (Category) open import Categories.Groupoid using (Groupoid) open import Categories.Monoidal using (Monoidal) open import Categories.Monoidal.Helpers using (module MonoidalHelperFunctors) open import Categories.Bifunctor using (Bifunctor) open import Categories.NaturalIsomorphism using (NaturalIsomorphism) open import Categories.Monoidal.Braided using (Braided) open import Categories.Monoidal.Symmetric using (Symmetric) open import Categories.RigCategory using (RigCategory; module BimonoidalHelperFunctors) open import PiU using (U; PLUS; ZERO; TIMES; ONE) open import PiLevel0 using (_⟷_; !; triv≡; triv≡Equiv; id⟷; _◎_; _⊕_; unite₊l; uniti₊l; unite₊r; uniti₊r; swap₊; assocr₊; assocl₊; _⊗_; unite⋆l; uniti⋆l; unite⋆r; uniti⋆r; swap⋆; assocr⋆; assocl⋆; absorbl; absorbr; factorzl; factorzr; dist; factor; distl; factorl) ------------------------------------------------------------------------------ -- It is a category... PiCat : Category lzero lzero lzero PiCat = record { Obj = U ; _⇒_ = _⟷_ ; _≡_ = triv≡ ; id = id⟷ ; _∘_ = λ y⟷z x⟷y → x⟷y ◎ y⟷z ; assoc = tt ; identityˡ = tt ; identityʳ = tt ; equiv = triv≡Equiv ; ∘-resp-≡ = λ _ _ → tt } -- and a groupoid PiGroupoid : Groupoid PiCat PiGroupoid = record { _⁻¹ = ! ; iso = record { isoˡ = tt ; isoʳ = tt } } -- additive bifunctor and monoidal structure ⊕-bifunctor : Bifunctor PiCat PiCat PiCat ⊕-bifunctor = record { F₀ = λ {(u , v) → PLUS u v} ; F₁ = λ {(x⟷y , z⟷w) → x⟷y ⊕ z⟷w } ; identity = tt ; homomorphism = tt ; F-resp-≡ = λ _ → tt } module ⊎h = MonoidalHelperFunctors PiCat ⊕-bifunctor ZERO 0⊕x≡x : NaturalIsomorphism ⊎h.id⊗x ⊎h.x 0⊕x≡x = record { F⇒G = record { η = λ X → unite₊l ; commute = λ _ → tt } ; F⇐G = record { η = λ X → uniti₊l ; commute = λ _ → tt } ; iso = λ X → record { isoˡ = tt; isoʳ = tt } } x⊕0≡x : NaturalIsomorphism ⊎h.x⊗id ⊎h.x x⊕0≡x = record { F⇒G = record { η = λ X → unite₊r ; commute = λ _ → tt } ; F⇐G = record { η = λ X → uniti₊r ; commute = λ _ → tt } ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } } [x⊕y]⊕z≡x⊕[y⊕z] : NaturalIsomorphism ⊎h.[x⊗y]⊗z ⊎h.x⊗[y⊗z] [x⊕y]⊕z≡x⊕[y⊕z] = record { F⇒G = record { η = λ X → assocr₊ ; commute = λ f → tt } ; F⇐G = record { η = λ X → assocl₊ ; commute = λ _ → tt } ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } } M⊕ : Monoidal PiCat M⊕ = record { ⊗ = ⊕-bifunctor ; id = ZERO ; identityˡ = 0⊕x≡x ; identityʳ = x⊕0≡x ; assoc = [x⊕y]⊕z≡x⊕[y⊕z] ; triangle = tt ; pentagon = tt } -- multiplicative bifunctor and monoidal structure ⊗-bifunctor : Bifunctor PiCat PiCat PiCat ⊗-bifunctor = record { F₀ = λ {(u , v) → TIMES u v} ; F₁ = λ {(x⟷y , z⟷w) → x⟷y ⊗ z⟷w } ; identity = tt ; homomorphism = tt ; F-resp-≡ = λ _ → tt } module ⊗h = MonoidalHelperFunctors PiCat ⊗-bifunctor ONE 1⊗x≡x : NaturalIsomorphism ⊗h.id⊗x ⊗h.x 1⊗x≡x = record { F⇒G = record { η = λ X → unite⋆l ; commute = λ _ → tt } ; F⇐G = record { η = λ X → uniti⋆l ; commute = λ _ → tt } ; iso = λ X → record { isoˡ = tt; isoʳ = tt } } x⊗1≡x : NaturalIsomorphism ⊗h.x⊗id ⊗h.x x⊗1≡x = record { F⇒G = record { η = λ X → unite⋆r ; commute = λ _ → tt } ; F⇐G = record { η = λ X → uniti⋆r ; commute = λ _ → tt } ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } } [x⊗y]⊗z≡x⊗[y⊗z] : NaturalIsomorphism ⊗h.[x⊗y]⊗z ⊗h.x⊗[y⊗z] [x⊗y]⊗z≡x⊗[y⊗z] = record { F⇒G = record { η = λ X → assocr⋆ ; commute = λ f → tt } ; F⇐G = record { η = λ X → assocl⋆ ; commute = λ _ → tt } ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } } M⊗ : Monoidal PiCat M⊗ = record { ⊗ = ⊗-bifunctor ; id = ONE ; identityˡ = 1⊗x≡x ; identityʳ = x⊗1≡x ; assoc = [x⊗y]⊗z≡x⊗[y⊗z] ; triangle = tt ; pentagon = tt } x⊕y≡y⊕x : NaturalIsomorphism ⊎h.x⊗y ⊎h.y⊗x x⊕y≡y⊕x = record { F⇒G = record { η = λ X → swap₊ ; commute = λ f → tt } ; F⇐G = record { η = λ X → swap₊ ; commute = λ f → tt } ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } } BM⊕ : Braided M⊕ BM⊕ = record { braid = x⊕y≡y⊕x ; unit-coh = tt; hexagon₁ = tt ; hexagon₂ = tt } x⊗y≡y⊗x : NaturalIsomorphism ⊗h.x⊗y ⊗h.y⊗x x⊗y≡y⊗x = record { F⇒G = record { η = λ X → swap⋆ ; commute = λ f → tt } ; F⇐G = record { η = λ X → swap⋆ ; commute = λ f → tt } ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } } BM⊗ : Braided M⊗ BM⊗ = record { braid = x⊗y≡y⊗x ; unit-coh = tt; hexagon₁ = tt ; hexagon₂ = tt } SBM⊕ : Symmetric BM⊕ SBM⊕ = record { symmetry = tt } SBM⊗ : Symmetric BM⊗ SBM⊗ = record { symmetry = tt } module r = BimonoidalHelperFunctors BM⊕ BM⊗ x⊗0≡0 : NaturalIsomorphism r.x⊗0 r.0↑ x⊗0≡0 = record { F⇒G = record { η = λ X → absorbl ; commute = λ f → tt } ; F⇐G = record { η = λ X → factorzr ; commute = λ f → tt } ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } } 0⊗x≡0 : NaturalIsomorphism r.0⊗x r.0↑ 0⊗x≡0 = record { F⇒G = record { η = λ X → absorbr ; commute = λ f → tt } ; F⇐G = record { η = λ X → factorzl ; commute = λ f → tt } ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } } x⊗[y⊕z]≡[x⊗y]⊕[x⊗z] : NaturalIsomorphism r.x⊗[y⊕z] r.[x⊗y]⊕[x⊗z] x⊗[y⊕z]≡[x⊗y]⊕[x⊗z] = record -- this probably says we need distl/distr { F⇒G = record { η = λ X → distl ; commute = λ f → tt } ; F⇐G = record { η = λ X → factorl ; commute = λ f → tt } ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } } [x⊕y]⊗z≡[x⊗z]⊕[y⊗z] : NaturalIsomorphism r.[x⊕y]⊗z r.[x⊗z]⊕[y⊗z] [x⊕y]⊗z≡[x⊗z]⊕[y⊗z] = record { F⇒G = record { η = λ X → dist ; commute = λ f → tt } ; F⇐G = record { η = λ X → factor ; commute = λ f → tt } ; iso = λ X → record { isoˡ = tt ; isoʳ = tt } } Pi0Rig : RigCategory SBM⊕ SBM⊗ Pi0Rig = record { distribₗ = x⊗[y⊕z]≡[x⊗y]⊕[x⊗z] ; distribᵣ = [x⊕y]⊗z≡[x⊗z]⊕[y⊗z] ; annₗ = 0⊗x≡0 ; annᵣ = x⊗0≡0 ; laplazaI = tt ; laplazaII = tt ; laplazaIV = tt ; laplazaVI = tt ; laplazaIX = tt ; laplazaX = tt ; laplazaXI = tt ; laplazaXIII = tt ; laplazaXV = tt ; laplazaXVI = tt ; laplazaXVII = tt ; laplazaXIX = tt ; laplazaXXIII = tt } ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5378950598, "avg_line_length": 24.5037593985, "ext": "agda", "hexsha": "c18fbe2bdaacf818fcf7696b83b84f74beae1df0", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Pi0Cat.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Pi0Cat.agda", "max_line_length": 79, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Pi0Cat.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 3182, "size": 6518 }
open import Coinduction using ( ∞ ; ♭ ; ♯_ ) open import Relation.Binary.PropositionalEquality using ( _≡_ ; _≢_ ; refl ) open import Relation.Nullary using ( Dec ; yes ; no ) open import System.IO.Transducers.Session using ( Session ; I ; Σ ; Γ ; _/_ ; IsI ) module System.IO.Transducers.Trace where infixr 4 _≤_ _⊑_ _⊨_⊑_ _⊨_✓ _✓ infixr 5 _∷_ _++_ -- The semantics of a session is its set of traces. -- The name "trace" comes from process algebra, -- it's called a play in games semantics, or a word of an automaton. data Trace (S : Session) : Set where [] : Trace S _∷_ : (a : Γ S) (as : Trace (S / a)) → (Trace S) -- Traces ending in [] at type I are completed traces data _⊨_✓ : ∀ S → (Trace S) → Set₁ where [] : I ⊨ [] ✓ _∷_ : ∀ {S} a {as} → (S / a ⊨ as ✓) → (S ⊨ a ∷ as ✓) _✓ : ∀ {S} → (Trace S) → Set₁ _✓ {S} as = S ⊨ as ✓ -- Prefix order on traces data _⊨_⊑_ : ∀ S → (Trace S) → (Trace S) → Set₁ where [] : ∀ {S as} → (S ⊨ [] ⊑ as) _∷_ : ∀ {S} a {as bs} → (S / a ⊨ as ⊑ bs) → (S ⊨ a ∷ as ⊑ a ∷ bs) _⊑_ : ∀ {S} → (Trace S) → (Trace S) → Set₁ _⊑_ {S} as bs = S ⊨ as ⊑ bs -- For building buffers, it is useful to provide -- snoc traces as well as cons traces. data _≤_ : Session → Session → Set₁ where [] : ∀ {S} → (S ≤ S) _∷_ : ∀ {S T} a (as : S ≤ T) → (S / a ≤ T) -- Snoc traces form categories, where composition is concatenation. _++_ : ∀ {S T U} → (S ≤ T) → (T ≤ U) → (S ≤ U) [] ++ bs = bs (a ∷ as) ++ bs = a ∷ (as ++ bs) -- snoc traces can be reversed to form cons traces revApp : ∀ {S T} → (S ≤ T) → (Trace S) → (Trace T) revApp [] bs = bs revApp (a ∷ as) bs = revApp as (a ∷ bs) reverse : ∀ {S T} → (S ≤ T) → (Trace T) reverse as = revApp as []
{ "alphanum_fraction": 0.5475352113, "avg_line_length": 29.3793103448, "ext": "agda", "hexsha": "d9ca88d7774b376fe95030c25b8ea76d859a0bc6", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z", "max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z", "max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/System/IO/Transducers/Trace.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ilya-fiveisky/agda-system-io", "max_issues_repo_path": "src/System/IO/Transducers/Trace.agda", "max_line_length": 83, "max_stars_count": 10, "max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ilya-fiveisky/agda-system-io", "max_stars_repo_path": "src/System/IO/Transducers/Trace.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z", "num_tokens": 688, "size": 1704 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category {- Definition of SubCategory of a given Category C. Here a SubCategory is defined via - an index set I - a mapping I → Obj (not necessarily injective) - a proof (as a unary relation) that for all a, b : A, all arrows U a ⇒ U b belong to the SubCategory (note that this is 'backwards' from SubCategory at https://ncatlab.org/nlab/show/subcategory which would be (∀ {x y : Obj} (f : x ⇒ y) → R f → ∃ (A × B) (λ (a , b) → U a × U b)) and that would be awkward to work with. - a proof that all objects pointed to by I have identity arrows that belong - a proof that composable arrows in the SubCategory are closed under composition It is simpler to package up all of that into a single record. -} module Categories.Category.SubCategory {o ℓ e} (C : Category o ℓ e) where open Category C open HomReasoning using (refl; sym; trans) open import Level open import Data.Product private variable i : Level record SubCat {ℓ′} (I : Set i) : Set (o ⊔ ℓ ⊔ i ⊔ suc ℓ′) where field U : I → Obj R : {a b : I} → U a ⇒ U b → Set ℓ′ Rid : {a : I} → R (id {U a}) _∘R_ : {a b c : I} {f : U b ⇒ U c} {g : U a ⇒ U b} → R f → R g → R (f ∘ g) SubCategory : {ℓ′ : Level} {I : Set i} → SubCat {ℓ′ = ℓ′} I → Category _ _ _ SubCategory {I = I} sc = let open SubCat sc in record { Obj = I ; _⇒_ = λ a b → Σ (U a ⇒ U b) R ; _≈_ = λ f g → proj₁ f ≈ proj₁ g ; id = id , Rid ; _∘_ = zip _∘_ _∘R_ ; assoc = assoc ; sym-assoc = sym-assoc ; identityˡ = identityˡ ; identityʳ = identityʳ ; identity² = identity² ; equiv = record -- need to expand this out, else the levels don't work out { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≈ = ∘-resp-≈ } FullSubCategory : ∀ {I : Set i} → (U : I → Obj) → Category _ _ _ FullSubCategory {I = I} U = record { Obj = I ; _⇒_ = λ x y → U x ⇒ U y ; _≈_ = _≈_ ; id = id ; _∘_ = _∘_ ; assoc = assoc ; sym-assoc = sym-assoc ; identityˡ = identityˡ ; identityʳ = identityʳ ; identity² = identity² ; equiv = equiv ; ∘-resp-≈ = ∘-resp-≈ }
{ "alphanum_fraction": 0.5699505173, "avg_line_length": 30.4520547945, "ext": "agda", "hexsha": "b858415acc2f9856d966a3d1cc9d45bc5930e148", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/SubCategory.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/SubCategory.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/SubCategory.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 808, "size": 2223 }
import Structure.Logic.Classical.NaturalDeduction module Structure.Logic.Classical.SetTheory.Relation {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic : _ ⦄ (_∈_ : Domain → Domain → Formula) where open Structure.Logic.Classical.NaturalDeduction.ClassicalLogic {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (classicLogic) open import Syntax.Function open import Structure.Logic.Classical.SetTheory.SetBoundedQuantification {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic ⦄ (_∈_) UnaryRelator : Set(_) UnaryRelator = (Domain → Formula) BinaryRelator : Set(_) BinaryRelator = (Domain → Domain → Formula) -- Containment -- (a ∋ x) means that the set a contains the set x. _∋_ : BinaryRelator _∋_ a x = (x ∈ a) -- Non-containment _∌_ : BinaryRelator _∌_ a x = ¬(x ∈ a) -- Not element of _∉_ : BinaryRelator _∉_ x a = ¬(x ∈ a) -- Subset of _⊆_ : BinaryRelator _⊆_ a b = ∀ₗ(x ↦ (x ∈ a) ⟶ (x ∈ b)) -- Superset of _⊇_ : BinaryRelator _⊇_ a b = ∀ₗ(x ↦ (x ∈ a) ⟵ (x ∈ b)) -- Equality of _≡ₛ_ : BinaryRelator _≡ₛ_ a b = ∀ₗ(x ↦ (x ∈ a) ⟷ (x ∈ b)) -- The statement that the set s is empty Empty : UnaryRelator Empty(s) = ∀ₗ(x ↦ ¬(x ∈ s)) -- The statement that the set s is non-empty NonEmpty : UnaryRelator NonEmpty(s) = ∃ₗ(x ↦ (x ∈ s)) -- The statement that the set s is a set that contains all sets Universal : UnaryRelator Universal(s) = ∀ₗ(x ↦ (x ∈ s)) -- The statement that the sets s₁ and s₂ are disjoint Disjoint : BinaryRelator Disjoint(s₁)(s₂) = ∀ₗ(x ↦ ¬((x ∈ s₁)∧(x ∈ s₂))) -- ¬ ∃ₗ(x ↦ (x ∈ s₁)∧(x ∈ s₂)) -- The statement that the sets in ss are all pairwise disjoint PairwiseDisjoint : UnaryRelator PairwiseDisjoint(ss) = ∀ₛ(ss)(s₁ ↦ ∀ₛ(ss)(s₂ ↦ ∀ₗ(x ↦ (x ∈ s₁)∧(x ∈ s₂) ⟶ (s₁ ≡ s₂)))) -- ∀ₛ(ss)(s₁ ↦ ∀ₛ(ss)(s₂ ↦ (s₁ ≢ s₂) → Disjoint(s₁)(s₂))) -- The statement that the relation predicate F can be interpreted as a partial function PartialFunction : BinaryRelator → Domain → Formula PartialFunction(F) (dom) = ∀ₛ(dom)(x ↦ Unique(y ↦ F(x)(y))) -- The statement that the relation predicate F can be interpreted as a total function TotalFunction : BinaryRelator → Domain → Formula TotalFunction(F) (dom) = ∀ₛ(dom)(x ↦ ∃ₗ!(y ↦ F(x)(y))) -- A binary relator modifier which makes the binary relator to a statement about all distinct pairs in a set. -- Note: This is specifically for irreflexive binary relations. Pairwise : BinaryRelator → UnaryRelator Pairwise Related (S) = ∀ₛ(S)(a ↦ ∀ₛ(S)(b ↦ (a ≢ b) ⟶ Related(a)(b)))
{ "alphanum_fraction": 0.6661217818, "avg_line_length": 33.0675675676, "ext": "agda", "hexsha": "b0411cc9668ffebe977f8eb676103db6e0bde7c7", "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/Relation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Structure/Logic/Classical/SetTheory/Relation.agda", "max_line_length": 155, "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/Relation.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 913, "size": 2447 }
{-# OPTIONS --sized-types #-} module FormalLanguage.Equals{ℓ} where import Lvl open import FormalLanguage open import Lang.Size open import Logic.Propositional open import Relator.Equals using ([≡]-intro) renaming (_≡_ to _≡ₑ_) open import Relator.Equals.Proofs import Structure.Relator.Names as Names open import Structure.Setoid open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Type private variable s : Size module _ {Σ : Alphabet{ℓ}} where record _≅[_]≅_ (A : Language(Σ){∞ˢⁱᶻᵉ}) (s : Size) (B : Language(Σ){∞ˢⁱᶻᵉ}) : Type{ℓ} where constructor intro coinductive field accepts-ε : Language.accepts-ε(A) ≡ₑ Language.accepts-ε(B) suffix-lang : ∀{c : Σ}{sₛ : <ˢⁱᶻᵉ s} → (Language.suffix-lang A c ≅[ sₛ ]≅ Language.suffix-lang B c) _≅_ : ∀{s : Size} → Language(Σ){∞ˢⁱᶻᵉ} → Language(Σ){∞ˢⁱᶻᵉ} → Type _≅_ {s} = _≅[ s ]≅_ [≅]-reflexivity-raw : Names.Reflexivity(_≅[ s ]≅_) _≅[_]≅_.accepts-ε ([≅]-reflexivity-raw) = [≡]-intro _≅[_]≅_.suffix-lang ([≅]-reflexivity-raw) = [≅]-reflexivity-raw [≅]-symmetry-raw : Names.Symmetry(_≅[ s ]≅_) _≅[_]≅_.accepts-ε ([≅]-symmetry-raw ab) = symmetry(_≡ₑ_) (_≅[_]≅_.accepts-ε ab) _≅[_]≅_.suffix-lang ([≅]-symmetry-raw ab) = [≅]-symmetry-raw (_≅[_]≅_.suffix-lang ab) [≅]-transitivity-raw : Names.Transitivity(_≅[ s ]≅_) _≅[_]≅_.accepts-ε ([≅]-transitivity-raw ab bc) = transitivity(_≡ₑ_) (_≅[_]≅_.accepts-ε ab) (_≅[_]≅_.accepts-ε bc) _≅[_]≅_.suffix-lang ([≅]-transitivity-raw ab bc) = [≅]-transitivity-raw (_≅[_]≅_.suffix-lang ab) (_≅[_]≅_.suffix-lang bc) instance [≅]-reflexivity : Reflexivity(_≅[ s ]≅_) Reflexivity.proof([≅]-reflexivity) = [≅]-reflexivity-raw instance [≅]-symmetry : Symmetry(_≅[ s ]≅_) Symmetry.proof([≅]-symmetry) = [≅]-symmetry-raw instance [≅]-transitivity : Transitivity(_≅[ s ]≅_) Transitivity.proof([≅]-transitivity) = [≅]-transitivity-raw instance [≅]-equivalence : Equivalence(_≅[ s ]≅_) [≅]-equivalence = record{} instance [≅]-equiv : let _ = s in Equiv(Language(Σ)) [≅]-equiv {s = s} = intro(_≅[ s ]≅_) ⦃ [≅]-equivalence ⦄
{ "alphanum_fraction": 0.6302131603, "avg_line_length": 35.3770491803, "ext": "agda", "hexsha": "1635b8e1eb82ecd438b7b60392ec71717d7ee38f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "FormalLanguage/Equals.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "FormalLanguage/Equals.agda", "max_line_length": 123, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "FormalLanguage/Equals.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": 910, "size": 2158 }
open import Agda.Primitive module Experimental.Equality where data _≡_ {ℓ} {A : Set ℓ} : A → A → Set ℓ where refl : ∀ {x : A} → x ≡ x sym : ∀ {ℓ} {A : Set ℓ} {x y : A} → x ≡ y → y ≡ x sym refl = refl tran : ∀ {ℓ} {A : Set ℓ} {x y z : A} → x ≡ y → y ≡ z → x ≡ z tran refl q = q ap : ∀ {ℓ k} {A : Set ℓ} {B : Set k} {x y : A} {f : A → B} → x ≡ y → f x ≡ f y ap refl = refl transport : ∀ {ℓ k} {A : Set ℓ} (B : A → Set k) {x y : A} → x ≡ y → B x → B y transport _ refl u = u
{ "alphanum_fraction": 0.45, "avg_line_length": 26.3157894737, "ext": "agda", "hexsha": "a3c8de24b935ed91a7b6fa65d7a526c956adf58b", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/Experimental/Equality.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/Experimental/Equality.agda", "max_line_length": 80, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/Experimental/Equality.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 242, "size": 500 }
module Generic.Test.Data.Maybe where open import Generic.Main as Main hiding (Maybe; just; nothing) Maybe : ∀ {α} -> Set α -> Set α Maybe = readData Main.Maybe pattern nothing = #₀ lrefl pattern just x = !#₁ (relv x , lrefl) just′ : ∀ {α} {A : Set α} -> A -> Maybe A just′ = just nothing′ : ∀ {α} {A : Set α} -> Maybe A nothing′ = nothing
{ "alphanum_fraction": 0.6289855072, "avg_line_length": 21.5625, "ext": "agda", "hexsha": "707c47d2fbbd8fc0c239a2139be051b29ea5312f", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z", "max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z", "max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "turion/Generic", "max_forks_repo_path": "src/Generic/Test/Data/Maybe.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z", "max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "turion/Generic", "max_issues_repo_path": "src/Generic/Test/Data/Maybe.agda", "max_line_length": 62, "max_stars_count": 30, "max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "turion/Generic", "max_stars_repo_path": "src/Generic/Test/Data/Maybe.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z", "num_tokens": 113, "size": 345 }
-- -- Formalize correctness of differentiation for the source calculus in the -- static caching paper (typed version). -- module Thesis.ANormal where open import Thesis.Types public open import Thesis.Contexts public open import Relation.Binary.PropositionalEquality data Term (Γ : Context) (τ : Type) : Set where var : (x : Var Γ τ) → Term Γ τ lett : ∀ {σ τ₁} → (f : Var Γ (σ ⇒ τ₁)) → (x : Var Γ σ) → Term (τ₁ • Γ) τ → Term Γ τ -- Also represent top-level definitions, so that we can somehow create functions -- via syntax. Made up on the moment. -- WARNING: this allows nested lambdas. That's more powerful than allowing only -- closures whose bodies can't contain lambdas, like in the paper. data Fun (Γ : Context) : (τ : Type) → Set where term : ∀ {τ} → Term Γ τ → Fun Γ τ abs : ∀ {σ τ} → Fun (σ • Γ) τ → Fun Γ (σ ⇒ τ) -- Indeed, caching doesn't work there with Fun. It works on FunR. Eventually -- should adapt definitions to FunR. data FunR (Γ : Context) : (τ : Type) → Set where cabsterm : ∀ {σ τ} → Term (σ • Γ) τ → FunR Γ (σ ⇒ τ) open import Thesis.Environments public ⟦_⟧Term : ∀ {Γ τ} → Term Γ τ → ⟦ Γ ⟧Context → ⟦ τ ⟧Type ⟦ var x ⟧Term ρ = ⟦ x ⟧Var ρ ⟦ lett f x t ⟧Term ρ = ⟦ t ⟧Term (⟦ f ⟧Var ρ (⟦ x ⟧Var ρ) • ρ) ⟦_⟧Fun : ∀ {Γ τ} → Fun Γ τ → ⟦ Γ ⟧Context → ⟦ τ ⟧Type ⟦ term t ⟧Fun ρ = ⟦ t ⟧Term ρ ⟦ abs f ⟧Fun ρ = λ v → ⟦ f ⟧Fun (v • ρ) -- Next steps: -- 1. Add a functional big-step semantics for this language: DONE. -- 2. Prove it sound wrt. the denotational semantics: DONE. -- 3. Add an erasure to a uni-typed language. DONE. -- 4. Redo 1 with an *untyped* functional big-step semantics. -- 5. Prove that evaluation and erasure commute: -- -- erasure-commute-term : ∀ {Γ τ} (t : T.Term Γ τ) ρ n → -- -- erase-errVal (T.eval-term t ρ n) ≡ eval-term (erase-term t) (erase-env ρ) n -- 6. Define new caching transformation into untyped language. -- -- 7. Prove the new transformation correct in the untyped language, by reusing -- evaluation on the source language.
{ "alphanum_fraction": 0.6487294469, "avg_line_length": 37.1666666667, "ext": "agda", "hexsha": "043ec2ef579250c549da632cc6386d4815276228", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Thesis/ANormal.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Thesis/ANormal.agda", "max_line_length": 85, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Thesis/ANormal.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": 680, "size": 2007 }
{-# OPTIONS --safe --without-K #-} -- The category of group objects with a cartesian category open import Categories.Category open import Categories.Category.Cartesian module Categories.Category.Construction.Groups {o ℓ e} {𝒞 : Category o ℓ e} (C : Cartesian 𝒞) where open import Level open import Categories.Category.BinaryProducts 𝒞 open import Categories.Morphism.Reasoning 𝒞 open import Categories.Object.Group C open import Categories.Object.Product.Morphisms 𝒞 open Category 𝒞 open Cartesian C open BinaryProducts products open Equiv open HomReasoning open Group using (μ) open Group⇒ Groups : Category (o ⊔ ℓ ⊔ e) (ℓ ⊔ e) e Groups = record { Obj = Group ; _⇒_ = Group⇒ ; _≈_ = λ f g → arr f ≈ arr g ; id = record { arr = id ; preserves-μ = identityˡ ○ introʳ (id×id product) ; preserves-η = identityˡ ; preserves-ι = id-comm-sym } ; _∘_ = λ f g → record { arr = arr f ∘ arr g ; preserves-μ = glue (preserves-μ f) (preserves-μ g) ○ ∘-resp-≈ʳ ⁂∘⁂ ; preserves-η = glueTrianglesˡ (preserves-η f) (preserves-η g) ; preserves-ι = glue (preserves-ι f) (preserves-ι g) } ; assoc = assoc ; sym-assoc = sym-assoc ; identityˡ = identityˡ ; identityʳ = identityʳ ; identity² = identity² ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≈ = ∘-resp-≈ }
{ "alphanum_fraction": 0.6578171091, "avg_line_length": 25.1111111111, "ext": "agda", "hexsha": "a58e281c7ab43ddfdb9d885984eebb79ff37e30a", "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": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Construction/Groups.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "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": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Construction/Groups.agda", "max_line_length": 99, "max_stars_count": 5, "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/Construction/Groups.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z", "num_tokens": 463, "size": 1356 }
------------------------------------------------------------------------ -- Parallel reduction in pure type systems (PTS) ------------------------------------------------------------------------ module Pts.Reduction.Parallel where open import Data.Fin using (Fin) open import Data.Fin.Substitution open import Data.Fin.Substitution.ExtraLemmas open import Data.Fin.Substitution.Relation open import Data.Star using (Star; ε; _◅_; _◅◅_) open import Data.Product using (_,_; ∃; _×_) open import Data.Nat using (ℕ; _+_) open import Data.Vec.All using (lookup₂) import Function as Fun open import Relation.Binary open import Relation.Binary.EquivalenceClosure using (EqClosure) open import Relation.Binary.SymmetricClosure using (fwd; bwd) open import Relation.Binary.Reduction import Relation.Binary.PropositionalEquality as P open import Pts.Syntax -- All remaining submodules are parametrized by a given set of sorts. module _ {Sort : Set} where open Syntax Sort open Substitution Sort using (_[_]) ---------------------------------------------------------------------- -- Parallel reduction infixl 9 _·_ infix 5 _⇛_ -- One-step parallel reduction. data _⇛_ {n : ℕ} : Term n → Term n → Set where refl : ∀ {a} → a ⇛ a Π : ∀ {a₁ a₂ b₁ b₂} → a₁ ⇛ a₂ → b₁ ⇛ b₂ → Π a₁ b₁ ⇛ Π a₂ b₂ ƛ : ∀ {a₁ a₂ b₁ b₂} → a₁ ⇛ a₂ → b₁ ⇛ b₂ → ƛ a₁ b₁ ⇛ ƛ a₂ b₂ _·_ : ∀ {a₁ a₂ b₁ b₂} → a₁ ⇛ a₂ → b₁ ⇛ b₂ → a₁ · b₁ ⇛ a₂ · b₂ cont : ∀ {a b₁ b₂ c₁ c₂} → b₁ ⇛ b₂ → c₁ ⇛ c₂ → (ƛ a b₁) · c₁ ⇛ b₂ [ c₂ ] reduction : Reduction Term reduction = record { _→1_ = _⇛_ } -- Parallel reduction and equivalence. open Reduction reduction public renaming (_→*_ to _⇛*_; _↔_ to _≡p_) ---------------------------------------------------------------------- -- Simple properties of parallel reduction -- Inclusions. ⇛⇒⇛* = →1⇒→* reduction ⇛*⇒≡p = →*⇒↔ reduction ⇛⇒≡p = →1⇒↔ reduction -- parallel reduction is a preorder. ⇛*-predorder = →*-predorder reduction -- Terms together with parallel equivalence form a setoid. ≡p-setoid = ↔-setoid reduction open P using (_≡_) -- Shapes are preserved by one-step parallel reduction. sort-⇛ : ∀ {n s} {a : Term n} → sort s ⇛ a → sort s ≡ a sort-⇛ refl = P.refl ƛ-⇛ : ∀ {n} {a : Term n} {b c} → ƛ a b ⇛ c → ∃ λ a′ → ∃ λ b′ → a ⇛ a′ × b ⇛ b′ × ƛ a′ b′ ≡ c ƛ-⇛ refl = _ , _ , refl , refl , P.refl ƛ-⇛ (ƛ a⇛a′ b⇛b′) = _ , _ , a⇛a′ , b⇛b′ , P.refl Π-⇛ : ∀ {n} {a : Term n} {b c} → Π a b ⇛ c → ∃ λ a′ → ∃ λ b′ → a ⇛ a′ × b ⇛ b′ × Π a′ b′ ≡ c Π-⇛ refl = _ , _ , refl , refl , P.refl Π-⇛ (Π a⇛a′ b⇛b′) = _ , _ , a⇛a′ , b⇛b′ , P.refl -- Shapes are preserved by parallel reduction. sort-⇛* : ∀ {n s} {a : Term n} → sort s ⇛* a → sort s ≡ a sort-⇛* ε = P.refl sort-⇛* (refl ◅ s⇛*b) = sort-⇛* s⇛*b ƛ-⇛* : ∀ {n} {a : Term n} {b c} → ƛ a b ⇛* c → ∃ λ a′ → ∃ λ b′ → a ⇛* a′ × b ⇛* b′ × ƛ a′ b′ ≡ c ƛ-⇛* ε = _ , _ , ε , ε , P.refl ƛ-⇛* (refl ◅ λab⇛*d) = ƛ-⇛* λab⇛*d ƛ-⇛* (ƛ a⇛a₁ b⇛b₁ ◅ λa₁b₁⇛*d) = let a₂ , b₂ , a₁⇛*a₂ , b₁⇛*b₂ , λa₂b₂≡d = ƛ-⇛* λa₁b₁⇛*d in a₂ , b₂ , a⇛a₁ ◅ a₁⇛*a₂ , b⇛b₁ ◅ b₁⇛*b₂ , λa₂b₂≡d Π-⇛* : ∀ {n} {a : Term n} {b c} → Π a b ⇛* c → ∃ λ a′ → ∃ λ b′ → a ⇛* a′ × b ⇛* b′ × Π a′ b′ ≡ c Π-⇛* ε = _ , _ , ε , ε , P.refl Π-⇛* (refl ◅ Πab⇛*d) = Π-⇛* Πab⇛*d Π-⇛* (Π a⇛a₁ b⇛b₁ ◅ Πa₁b₁⇛*d) = let a₂ , b₂ , a₁⇛*a₂ , b₁⇛*b₂ , Πa₂b₂≡d = Π-⇛* Πa₁b₁⇛*d in a₂ , b₂ , a⇛a₁ ◅ a₁⇛*a₂ , b⇛b₁ ◅ b₁⇛*b₂ , Πa₂b₂≡d ---------------------------------------------------------------------- -- Substitutions lifted to parallel reduction -- -- The application _/⇛_ below may be considered a substitution -- lemma, i.e. it establishes that substitutions of terms preserve -- parallel reduction: -- -- ⇛ -- a ------→ b -- | | -- -/σ | | -/σ -- ↓ ⇛ ↓ -- a/σ ····→ b/σ -- -- ∀ (a b : Term n) (σ : Sub Term m n). -- Application of generic substitutions lifted to reduction. record ParSubstApp {T₁ T₂} (R : TermRel T₁ T₂) (l₁ : Lift T₁ Term) (l₂ : Lift T₂ Term) (rl : RelLift R _⇛_ l₁ l₂) : Set where infix 10 _↑₂ infixl 8 _/₁_ _/₂_ _/_ _/⇛_ open Substitution Sort using (termSubst) private _/₁_ = TermSubst.app termSubst l₁ _/₂_ = TermSubst.app termSubst l₂ _↑₂ = Lift._↑ l₂ open LiftTermRel T₁ T₂ using (_⟨_⟩_) open RelLift rl open P using (sym; subst) -- T₂-substitutions commute. field /₂-sub-↑ : ∀ {m n b} {σ : Sub T₂ m n} a → (a [ b ]) /₂ σ ≡ (a /₂ (σ ↑₂)) [ b /₂ σ ] _/_ : ∀ {m n} {σ₁ : Sub T₁ m n} {σ₂ : Sub T₂ m n} → ∀ a → σ₁ ⟨ R ⟩ σ₂ → a /₁ σ₁ ⇛ a /₂ σ₂ var x / σ₁∼σ₂ = lift (lookup₂ x σ₁∼σ₂) sort s / σ₁∼σ₂ = refl Π a b / σ₁∼σ₂ = Π (a / σ₁∼σ₂) (b / σ₁∼σ₂ ↑) ƛ a b / σ₁∼σ₂ = ƛ (a / σ₁∼σ₂) (b / σ₁∼σ₂ ↑) (a · b) / σ₁∼σ₂ = (a / σ₁∼σ₂) · (b / σ₁∼σ₂) _/⇛_ : ∀ {m n a₁ a₂} {σ₁ : Sub T₁ m n} {σ₂ : Sub T₂ m n} → a₁ ⇛ a₂ → σ₁ ⟨ R ⟩ σ₂ → a₁ /₁ σ₁ ⇛ a₂ /₂ σ₂ refl {a} /⇛ σ₁∼σ₂ = a / σ₁∼σ₂ Π a₁⇛a₂ b₁⇛b₂ /⇛ σ₁∼σ₂ = Π (a₁⇛a₂ /⇛ σ₁∼σ₂) (b₁⇛b₂ /⇛ σ₁∼σ₂ ↑) ƛ a₁⇛a₂ b₁⇛b₂ /⇛ σ₁∼σ₂ = ƛ (a₁⇛a₂ /⇛ σ₁∼σ₂) (b₁⇛b₂ /⇛ σ₁∼σ₂ ↑) a₁⇛a₂ · b₁⇛b₂ /⇛ σ₁∼σ₂ = (a₁⇛a₂ /⇛ σ₁∼σ₂) · (b₁⇛b₂ /⇛ σ₁∼σ₂) cont {b₂ = b₂} a₁⇛a₂ b₁⇛b₂ /⇛ σ₁∼σ₂ = P.subst (_⇛_ _) (sym (/₂-sub-↑ b₂)) (cont (a₁⇛a₂ /⇛ σ₁∼σ₂ ↑) (b₁⇛b₂ /⇛ σ₁∼σ₂)) -- Term substitutions lifted to parallel reduction. module ParSubstitution where open Substitution Sort using (termSubst; sub-commutes; varLiftSubLemmas) open P using (_≡_; refl) private module S = TermSubst termSubst module V = VarEqSubst varLift : RelLift _≡_ _⇛_ S.varLift S.varLift varLift = record { simple = V.simple; lift = lift } where lift : ∀ {n} {x₁ x₂ : Fin n} → x₁ ≡ x₂ → S.var x₁ ⇛ S.var x₂ lift {x₁ = x} refl = refl varSubstApp : ParSubstApp _≡_ S.varLift S.varLift varLift varSubstApp = record { /₂-sub-↑ = λ a → /-sub-↑ a _ _ } where open LiftSubLemmas varLiftSubLemmas infix 8 _/Var-⇛_ _/Var-⇛_ : ∀ {m n a₁ a₂} {σ₁ σ₂ : Sub Fin m n} → a₁ ⇛ a₂ → σ₁ V.⟨≡⟩ σ₂ → (a₁ S./Var σ₁) ⇛ (a₂ S./Var σ₂) _/Var-⇛_ = ParSubstApp._/⇛_ varSubstApp simple : RelSimple _⇛_ S.simple S.simple simple = record { extension = record { weaken = λ t₁⇛t₂ → t₁⇛t₂ /Var-⇛ V.wk } ; var = λ x → refl {a = var x} } termLift : RelLift _⇛_ _⇛_ S.termLift S.termLift termLift = record { simple = simple; lift = Fun.id } termSubstApp : ParSubstApp _⇛_ S.termLift S.termLift termLift termSubstApp = record { /₂-sub-↑ = sub-commutes } open ParSubstApp termSubstApp public subst : RelSubst _⇛_ S.subst S.subst subst = record { simple = simple ; application = record { _/_ = _/⇛_ } } open LiftTermRel Term Term public using (_⟨_⟩_) open RelSubst subst public hiding (var; simple; _/_) infix 10 _[⇛_] -- Shorthand for single-variable substitutions lifted to redcution. _[⇛_] : ∀ {n} {a₁ : Term (1 + n)} {a₂} {b₁ : Term n} {b₂} → a₁ ⇛ a₂ → b₁ ⇛ b₂ → a₁ S./ S.sub b₁ ⇛ a₂ S./ S.sub b₂ a₁⇛a₂ [⇛ b₁⇛b₂ ] = a₁⇛a₂ /⇛ sub b₁⇛b₂ open ParSubstitution ---------------------------------------------------------------------- -- Confluence of parallel reduction -- -- Parallel reduction enjoys the single-step diamond property, -- i.e. for any pair a ⇛ b₁, a ⇛ b₂ of parallel reductions, there is -- a term c, such that -- -- ⇛ -- a ------→ b₂ -- | : -- ⇛ | : ⇛ -- ↓ ⇛ ↓ -- b₁ ·····→ c -- -- commutes. Confluence (aka the Church-Rosser property) then -- follows by pasting of diagrams. infixl 4 _⋄_ -- Diamond property of one-step reduction. _⋄_ : ∀ {n} {a b₁ b₂ : Term n} → a ⇛ b₁ → a ⇛ b₂ → ∃ λ c → b₁ ⇛ c × b₂ ⇛ c refl ⋄ a⇛b = _ , a⇛b , refl a⇛b ⋄ refl = _ , refl , a⇛b Π a₁⇛b₁₁ a₂⇛b₁₂ ⋄ Π a₁⇛b₂₁ a₂⇛b₂₂ = let c₁ , b₁₁⇛c₁ , b₂₁⇛c₁ = a₁⇛b₁₁ ⋄ a₁⇛b₂₁ c₂ , b₁₂⇛c₂ , b₂₂⇛c₂ = a₂⇛b₁₂ ⋄ a₂⇛b₂₂ in Π c₁ c₂ , Π b₁₁⇛c₁ b₁₂⇛c₂ , Π b₂₁⇛c₁ b₂₂⇛c₂ ƛ a₁⇛b₁₁ a₂⇛b₁₂ ⋄ ƛ a₁⇛b₂₁ a₂⇛b₂₂ = let c₁ , b₁₁⇛c₁ , b₂₁⇛c₁ = a₁⇛b₁₁ ⋄ a₁⇛b₂₁ c₂ , b₁₂⇛c₂ , b₂₂⇛c₂ = a₂⇛b₁₂ ⋄ a₂⇛b₂₂ in ƛ c₁ c₂ , ƛ b₁₁⇛c₁ b₁₂⇛c₂ , ƛ b₂₁⇛c₁ b₂₂⇛c₂ a₁⇛b₁₁ · a₂⇛b₁₂ ⋄ a₁⇛b₂₁ · a₂⇛b₂₂ = let c₁ , b₁₁⇛c₁ , b₂₁⇛c₁ = a₁⇛b₁₁ ⋄ a₁⇛b₂₁ c₂ , b₁₂⇛c₂ , b₂₂⇛c₂ = a₂⇛b₁₂ ⋄ a₂⇛b₂₂ in c₁ · c₂ , b₁₁⇛c₁ · b₁₂⇛c₂ , b₂₁⇛c₁ · b₂₂⇛c₂ refl · a₂⇛b₁₂ ⋄ cont {b₂ = b₂₁} a₁⇛b₂₁ a₂⇛b₂₂ = let c₂ , b₁₂⇛c₂ , b₂₂⇛c₂ = a₂⇛b₁₂ ⋄ a₂⇛b₂₂ in b₂₁ [ c₂ ] , cont a₁⇛b₂₁ b₁₂⇛c₂ , refl {a = b₂₁} [⇛ b₂₂⇛c₂ ] ƛ _ a₁⇛b₁₁ · a₂⇛b₁₂ ⋄ cont a₁⇛b₂₁ a₂⇛b₂₂ = let c₁ , b₁₁⇛c₁ , b₂₁⇛c₁ = a₁⇛b₁₁ ⋄ a₁⇛b₂₁ c₂ , b₁₂⇛c₂ , b₂₂⇛c₂ = a₂⇛b₁₂ ⋄ a₂⇛b₂₂ in c₁ [ c₂ ] , cont b₁₁⇛c₁ b₁₂⇛c₂ , b₂₁⇛c₁ [⇛ b₂₂⇛c₂ ] cont {b₂ = b₁₁} a₁⇛b₁₁ a₂⇛b₁₂ ⋄ refl · a₂⇛b₂₂ = let c₂ , b₁₂⇛c₂ , b₂₂⇛c₂ = a₂⇛b₁₂ ⋄ a₂⇛b₂₂ in b₁₁ [ c₂ ] , refl {a = b₁₁} [⇛ b₁₂⇛c₂ ] , cont a₁⇛b₁₁ b₂₂⇛c₂ cont a₁⇛b₁₁ a₂⇛b₁₂ ⋄ ƛ _ a₁⇛b₂₁ · a₂⇛b₂₂ = let c₁ , b₁₁⇛c₁ , b₂₁⇛c₁ = a₁⇛b₁₁ ⋄ a₁⇛b₂₁ c₂ , b₁₂⇛c₂ , b₂₂⇛c₂ = a₂⇛b₁₂ ⋄ a₂⇛b₂₂ in c₁ [ c₂ ] , b₁₁⇛c₁ [⇛ b₁₂⇛c₂ ] , cont b₂₁⇛c₁ b₂₂⇛c₂ cont a₁⇛b₁₁ a₂⇛b₁₂ ⋄ cont a₁⇛b₂₁ a₂⇛b₂₂ = let c₁ , b₁₁⇛c₁ , b₂₁⇛c₁ = a₁⇛b₁₁ ⋄ a₁⇛b₂₁ c₂ , b₁₂⇛c₂ , b₂₂⇛c₂ = a₂⇛b₁₂ ⋄ a₂⇛b₂₂ in c₁ [ c₂ ] , b₁₁⇛c₁ [⇛ b₁₂⇛c₂ ] , b₂₁⇛c₁ [⇛ b₂₂⇛c₂ ] -- A strip lemma. _⋄′_ : ∀ {n} {a b₁ b₂ : Term n} → a ⇛ b₁ → a ⇛* b₂ → ∃ λ c → b₁ ⇛* c × b₂ ⇛ c a⇛b ⋄′ ε = _ , ε , a⇛b a⇛b₁ ⋄′ (a⇛b₂ ◅ b₂⇛*c₂) = let c₁ , b₁⇛c₁ , b₂⇛c₁ = a⇛b₁ ⋄ a⇛b₂ d , c₁⇛*d , c₂⇛d = b₂⇛c₁ ⋄′ b₂⇛*c₂ in d , b₁⇛c₁ ◅ c₁⇛*d , c₂⇛d -- Confluence (aka the Church-Rosser property) of _⇛*_ _⋄*_ : ∀ {n} {a b₁ b₂ : Term n} → a ⇛* b₁ → a ⇛* b₂ → ∃ λ c → b₁ ⇛* c × b₂ ⇛* c ε ⋄* a⇛*b = _ , a⇛*b , ε (a⇛b₁ ◅ b₁⇛*c₁) ⋄* a⇛*b₂ = let c₂ , b₁⇛*c₂ , b₂⇛c₂ = a⇛b₁ ⋄′ a⇛*b₂ d , c₁⇛*d , c₂⇛*d = b₁⇛*c₁ ⋄* b₁⇛*c₂ in d , c₁⇛*d , b₂⇛c₂ ◅ c₂⇛*d -- Factorization of equivalence into parallel reductions. ≡p⇒⇛* : ∀ {n} {a b : Term n} → a ≡p b → ∃ λ c → a ⇛* c × b ⇛* c ≡p⇒⇛* ε = _ , ε , ε ≡p⇒⇛* (fwd a⇛b ◅ b≡c) = let d , b⇛*d , c⇛*d = ≡p⇒⇛* b≡c in d , a⇛b ◅ b⇛*d , c⇛*d ≡p⇒⇛* (bwd a⇚b ◅ b≡c) = let d , b⇛*d , c⇛*d = ≡p⇒⇛* b≡c e , a⇛*e , d⇛e = a⇚b ⋄′ b⇛*d in e , a⇛*e , c⇛*d ◅◅ (d⇛e ◅ ε) -- Π-injectivity (with respect to ≡p). Π-inj : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → Π a₁ b₁ ≡p Π a₂ b₂ → a₁ ≡p a₂ × b₁ ≡p b₂ Π-inj Πa₁b₁≡Πa₂b₂ with ≡p⇒⇛* Πa₁b₁≡Πa₂b₂ Π-inj Πa₁b₁≡Πa₂b₂ | c , Πa₁b₁⇛*c , Πa₂b₂⇛*c with Π-⇛* Πa₁b₁⇛*c | Π-⇛* Πa₂b₂⇛*c Π-inj Πa₁b₁≡Πa₂b₂ | Π a₃ b₃ , Πa₁b₁⇛*c , Πa₂b₂⇛*c | ._ , ._ , a₁⇛*a₃ , b₁⇛*b₃ , P.refl | ._ , ._ , a₂⇛*a₃ , b₂⇛*b₃ , P.refl = ⇛*⇒≡p a₁⇛*a₃ ◅◅ sym (⇛*⇒≡p a₂⇛*a₃) , ⇛*⇒≡p b₁⇛*b₃ ◅◅ sym (⇛*⇒≡p b₂⇛*b₃) where module ParSetoid {n} where open Setoid (≡p-setoid {n}) public open ParSetoid -- Parallel equivalence on sorts implies syntactic equivalence. sort-≡p : ∀ {n s₁ s₂} → sort {n} s₁ ≡p sort s₂ → s₁ ≡ s₂ sort-≡p s₁≡s₂ with ≡p⇒⇛* s₁≡s₂ sort-≡p s₁≡s₂ | c , s₁⇛*c , s₂⇛*c with sort-⇛* s₁⇛*c | sort-⇛* s₂⇛*c sort-≡p s₁≡s₂ | ._ , s₁⇛*c , s₂⇛*c | P.refl | P.refl = P.refl
{ "alphanum_fraction": 0.4762307562, "avg_line_length": 37.2933753943, "ext": "agda", "hexsha": "05bad7dfe5d7b612e8f9299dd6c67307c2d78f73", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-08-11T23:28:33.000Z", "max_forks_repo_forks_event_min_datetime": "2017-08-20T10:29:44.000Z", "max_forks_repo_head_hexsha": "d701c2688e4a88eb81bdd9d458f9a2fcf81d5a43", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/pts-agda", "max_forks_repo_path": "src/Pts/Reduction/Parallel.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "d701c2688e4a88eb81bdd9d458f9a2fcf81d5a43", "max_issues_repo_issues_event_max_datetime": "2017-08-21T16:01:50.000Z", "max_issues_repo_issues_event_min_datetime": "2017-08-21T14:48:09.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "asr/pts-agda", "max_issues_repo_path": "src/Pts/Reduction/Parallel.agda", "max_line_length": 77, "max_stars_count": 21, "max_stars_repo_head_hexsha": "d701c2688e4a88eb81bdd9d458f9a2fcf81d5a43", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/pts-agda", "max_stars_repo_path": "src/Pts/Reduction/Parallel.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-31T10:47:57.000Z", "max_stars_repo_stars_event_min_datetime": "2016-05-13T12:11:10.000Z", "num_tokens": 6318, "size": 11822 }
------------------------------------------------------------------------ -- Safe modules that use --with-K ------------------------------------------------------------------------ {-# OPTIONS --safe --with-K #-} module README.Safe.With-K where -- Some theory of Erased, developed using the K rule and propositional -- equality. import Erased.With-K
{ "alphanum_fraction": 0.4135977337, "avg_line_length": 27.1538461538, "ext": "agda", "hexsha": "5b2b97b47cb83df78a5fc49851bc8edb16d5916e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "README/Safe/With-K.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "README/Safe/With-K.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "README/Safe/With-K.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": 53, "size": 353 }
------------------------------------------------------------------------ -- Full β-reduction in pure type systems (PTS) ------------------------------------------------------------------------ module Pts.Reduction.Full where open import Data.Fin.Substitution open import Data.Fin.Substitution.ExtraLemmas open import Data.Star using (ε; _◅_; map; gmap; _⋆) open import Data.Sum using ([_,_]) open import Data.Product using (_,_; ∃; _×_) open import Function using (_∘_) open import Relation.Binary import Relation.Binary.EquivalenceClosure as EqClos import Relation.Binary.PropositionalEquality as P import Relation.Binary.SymmetricClosure as SymClos open import Relation.Binary.Reduction import Function.Equivalence as Equiv open import Pts.Syntax open import Pts.Reduction.Parallel as Par hiding (reduction; _⋄*_; Π-inj) -- All remaining submodules are parametrized by a given set of sorts. module _ {Sort : Set} where open Syntax Sort open Substitution Sort using (_[_]) ---------------------------------------------------------------------- -- Full β-reduction and equivalence relations infixl 9 _·₁_ _·₂_ infix 5 _→β_ -- One-step β-reduction. data _→β_ {n} : Term n → Term n → Set where cont : ∀ a b c → (ƛ a b) · c →β b [ c ] Π₁ : ∀ {a₁ a₂} → a₁ →β a₂ → ∀ b → Π a₁ b →β Π a₂ b Π₂ : ∀ {b₁ b₂} a → b₁ →β b₂ → Π a b₁ →β Π a b₂ ƛ₁ : ∀ {a₁ a₂} → a₁ →β a₂ → ∀ b → ƛ a₁ b →β ƛ a₂ b ƛ₂ : ∀ {b₁ b₂} a → b₁ →β b₂ → ƛ a b₁ →β ƛ a b₂ _·₁_ : ∀ {a₁ a₂} → a₁ →β a₂ → ∀ b → a₁ · b →β a₂ · b _·₂_ : ∀ {b₁ b₂} a → b₁ →β b₂ → a · b₁ →β a · b₂ reduction : Reduction Term reduction = record { _→1_ = _→β_ } -- Full beta reduction and equivalence. open Reduction reduction public renaming (_→*_ to _→β*_; _↔_ to _≡β_) ---------------------------------------------------------------------- -- Substitutions in full β-reductions/equivalence -- -- The applications _/→β_, _/→β*_ and _/≡β_ below may be considered -- substitution lemmas, i.e. they establish the commutativity of the -- respective reductions/equivalence with substitutions. -- Application of generic substitutions to the -- reductions/equivalence. record BetaSubstApp {T} (l : Lift T Term) : Set where open Lift l open SubstApp Sort l open P hiding ([_]) -- Substitutions commute. field /-sub-↑ : ∀ {m n} a b (σ : Sub T m n) → a [ b ] / σ ≡ (a / σ ↑) [ b / σ ] infixl 8 _/→β_ -- Substitution commutes with one-step β-reduction. _/→β_ : ∀ {m n a b} → a →β b → (σ : Sub T m n) → a / σ →β b / σ cont a b c /→β σ = subst (_→β_ _) (sym (/-sub-↑ b c σ)) (cont (a / σ) (b / σ ↑) (c / σ)) Π₁ a₁→a₂ b /→β σ = Π₁ (a₁→a₂ /→β σ) (b / σ ↑) Π₂ a b₁→b₂ /→β σ = Π₂ (a / σ) (b₁→b₂ /→β σ ↑) ƛ₁ a₁→a₂ b /→β σ = ƛ₁ (a₁→a₂ /→β σ) (b / σ ↑) ƛ₂ a b₁→b₂ /→β σ = ƛ₂ (a / σ) (b₁→b₂ /→β σ ↑) a₁→a₂ ·₁ b /→β σ = (a₁→a₂ /→β σ) ·₁ (b / σ) a ·₂ b₁→b₂ /→β σ = (a / σ) ·₂ (b₁→b₂ /→β σ) redSubstApp : RedSubstApp reduction (record { _/_ = _/_ }) redSubstApp = record { _/→1_ = _/→β_ } open RedSubstApp redSubstApp public hiding (_/→1_) renaming (_/→*_ to _/→β*_; _/↔_ to _/≡β_) -- Term substitutions in reductions/equivalences. module BetaSubstitution where open Substitution Sort using (termSubst; weaken; sub-commutes; varLiftSubLemmas) -- Application of renamings to reductions/equivalences. varSubstApp : BetaSubstApp (TermSubst.varLift termSubst) varSubstApp = record { /-sub-↑ = /-sub-↑ } where open LiftSubLemmas varLiftSubLemmas private module V = BetaSubstApp varSubstApp -- Weakening of one-step β-reductions. weaken-→β : ∀ {n} {a b : Term n} → a →β b → weaken a →β weaken b weaken-→β a→b = a→b V./→β VarSubst.wk -- Weakening of β-reductions. weaken-→β* : ∀ {n} {a b : Term n} → a →β* b → weaken a →β* weaken b weaken-→β* = gmap weaken weaken-→β -- Weakening of β-equivalences. weaken-≡β : ∀ {n} {a b : Term n} → a ≡β b → weaken a ≡β weaken b weaken-≡β = EqClos.gmap weaken weaken-→β -- Application of term substitutions to reductions/equivalences. termSubstApp : BetaSubstApp (TermSubst.termLift termSubst) termSubstApp = record { /-sub-↑ = λ a _ _ → sub-commutes a } open BetaSubstApp termSubstApp public ---------------------------------------------------------------------- -- Simple properties of the β-reductions/equivalence -- Inclusions. →β⇒→β* = →1⇒→* reduction →β*⇒≡β = →*⇒↔ reduction →β⇒≡β = →1⇒↔ reduction -- β-reduction is a preorder. →β*-predorder = →*-predorder reduction -- Preorder reasoning for β-reduction. module →β*-Reasoning = →*-Reasoning reduction -- Terms together with β-equivalence form a setoid. ≡β-setoid = ↔-setoid reduction -- Equational reasoning for β-equivalence. module ≡β-Reasoning = ↔-Reasoning reduction ---------------------------------------------------------------------- -- Relationships between β-reduction and parallel reduction -- One-step β-reduction implies one-step parallel reduction. →β⇒⇛ : ∀ {n} {a b : Term n} → a →β b → a ⇛ b →β⇒⇛ (cont a b c) = cont refl refl →β⇒⇛ (Π₁ a₁→a₂ b) = Π (→β⇒⇛ a₁→a₂) refl →β⇒⇛ (Π₂ a b₁→b₂) = Π refl (→β⇒⇛ b₁→b₂) →β⇒⇛ (ƛ₁ a₁→a₂ b) = ƛ (→β⇒⇛ a₁→a₂) refl →β⇒⇛ (ƛ₂ a b₁→b₂) = ƛ refl (→β⇒⇛ b₁→b₂) →β⇒⇛ (a₁→a₂ ·₁ b) = →β⇒⇛ a₁→a₂ · refl →β⇒⇛ (a ·₂ b₁→b₂) = refl · →β⇒⇛ b₁→b₂ -- β-reduction implies parallel reduction. →β*⇒⇛* : ∀ {n} {a b : Term n} → a →β* b → a ⇛* b →β*⇒⇛* = map →β⇒⇛ -- β-equivalence implies parallel equivalence. ≡β⇒≡p : ∀ {n} {a b : Term n} → a ≡β b → a ≡p b ≡β⇒≡p = EqClos.map →β⇒⇛ open →*-Reasoning reduction -- One-step parallel reduction implies β-reduction. ⇛⇒→β* : ∀ {n} {a b : Term n} → a ⇛ b → a →β* b ⇛⇒→β* refl = ε ⇛⇒→β* (Π {a₁} {a₂} {b₁} {b₂} a₁⇛a₂ b₁⇛b₂) = begin Π a₁ b₁ ⟶⋆⟨ gmap (λ a → Π a _) (λ a₁→a₂ → Π₁ a₁→a₂ _) (⇛⇒→β* a₁⇛a₂) ⟩ Π a₂ b₁ ⟶⋆⟨ gmap (Π _) (Π₂ _) (⇛⇒→β* b₁⇛b₂) ⟩ Π a₂ b₂ ∎ ⇛⇒→β* (ƛ {a₁} {a₂} {b₁} {b₂} a₁⇛a₂ b₁⇛b₂) = begin ƛ a₁ b₁ ⟶⋆⟨ gmap (λ a → ƛ a _) (λ a₁→a₂ → ƛ₁ a₁→a₂ _) (⇛⇒→β* a₁⇛a₂) ⟩ ƛ a₂ b₁ ⟶⋆⟨ gmap (ƛ _) (ƛ₂ _) (⇛⇒→β* b₁⇛b₂) ⟩ ƛ a₂ b₂ ∎ ⇛⇒→β* (_·_ {a₁} {a₂} {b₁} {b₂} a₁⇛a₂ b₁⇛b₂) = begin a₁ · b₁ ⟶⋆⟨ gmap (λ a → a · _) (λ a₁→a₂ → a₁→a₂ ·₁ _) (⇛⇒→β* a₁⇛a₂) ⟩ a₂ · b₁ ⟶⋆⟨ gmap (_·_ _) (_·₂_ _) (⇛⇒→β* b₁⇛b₂) ⟩ a₂ · b₂ ∎ ⇛⇒→β* (cont {a} {b₁} {b₂} {c₁} {c₂} b₁⇛b₂ c₁⇛c₂) = begin (ƛ a b₁) · c₁ ⟶⋆⟨ gmap (λ b → (ƛ _ b) · _) (λ b₁→b₂ → (ƛ₂ _ b₁→b₂) ·₁ _) (⇛⇒→β* b₁⇛b₂) ⟩ (ƛ a b₂) · c₁ ⟶⋆⟨ gmap (_·_ _) (_·₂_ _) (⇛⇒→β* c₁⇛c₂) ⟩ (ƛ a b₂) · c₂ ⟶⟨ cont a b₂ c₂ ⟩ b₂ [ c₂ ] ∎ -- Parallel reduction implies β-reduction. ⇛*⇒→β* : ∀ {n} {a b : Term n} → a ⇛* b → a →β* b ⇛*⇒→β* a⇛*b = (⇛⇒→β* ⋆) a⇛*b -- Parallel equivalence implies β-equivalence. ≡p⇒≡β : ∀ {n} {a b : Term n} → a ≡p b → a ≡β b ≡p⇒≡β a≡b = ([ ⇛⇒≡β , sym ∘ ⇛⇒≡β ] ⋆) a≡b where open Setoid ≡β-setoid using (sym) ⇛⇒≡β : ∀ {n} {a b : Term n} → a ⇛ b → a ≡β b ⇛⇒≡β = →*⇒↔ reduction ∘ ⇛⇒→β* open Equiv using (_⇔_; equivalence) -- Full β-reduction is equivalent to parallel reduction. →β*-⇛*-equivalence : ∀ {n} {a b : Term n} → a →β* b ⇔ a ⇛* b →β*-⇛*-equivalence = equivalence →β*⇒⇛* ⇛*⇒→β* -- β-equivalence is equivalent to parallel equivalence. ≡β-≡p-equivalence : ∀ {n} {a b : Term n} → a ≡β b ⇔ a ≡p b ≡β-≡p-equivalence = equivalence ≡β⇒≡p ≡p⇒≡β -- Shorthand for single-variable substitutions lifted to β-redcution. _[→β_] : ∀ {n} a {b₁ b₂ : Term n} → b₁ →β b₂ → a [ b₁ ] →β* a [ b₂ ] a [→β b₁→b₂ ] = ⇛⇒→β* (a / sub (→β⇒⇛ b₁→b₂)) where open ParSubstitution using (_/_; sub) open P using (_≡_) -- Shapes are preserved by full β-reduction. sort-→β* : ∀ {n s} {a : Term n} → sort s →β* a → sort s ≡ a sort-→β* ε = P.refl sort-→β* (() ◅ _) ƛ-→β* : ∀ {n} {a : Term n} {b c} → ƛ a b →β* c → ∃ λ a′ → ∃ λ b′ → a →β* a′ × b →β* b′ × ƛ a′ b′ ≡ c ƛ-→β* λab→*c = let a′ , b′ , a⇛a′ , b⇛b′ , λa′b′≡c = ƛ-⇛* (→β*⇒⇛* λab→*c) in a′ , b′ , ⇛*⇒→β* a⇛a′ , ⇛*⇒→β* b⇛b′ , λa′b′≡c Π-→β* : ∀ {n} {a : Term n} {b c} → Π a b →β* c → ∃ λ a′ → ∃ λ b′ → a →β* a′ × b →β* b′ × Π a′ b′ ≡ c Π-→β* Πab→*c = let a′ , b′ , a⇛a′ , b⇛b′ , Πa′b′≡c = Π-⇛* (→β*⇒⇛* Πab→*c) in a′ , b′ , ⇛*⇒→β* a⇛a′ , ⇛*⇒→β* b⇛b′ , Πa′b′≡c ---------------------------------------------------------------------- -- Confluence (aka the Church-Rosser property) of full β-reduction -- -- Full β-reduction is confluent, i.e. i.e. for any pair a →β* b₁, -- a →β* b₂ of parallel reductions, there is a term c, such that -- -- →β* -- a ------→ b₂ -- | : -- →β* | : →β* -- ↓ →β* ↓ -- b₁ ·····→ c -- -- commutes. -- Confluence of _→β*_ (aka the Church-Rosser property). _⋄*_ : ∀ {n} {a b₁ b₂ : Term n} → a →β* b₁ → a →β* b₂ → ∃ λ c → b₁ →β* c × b₂ →β* c a→*b₁ ⋄* a→*b₂ = let c , b₁⇛*c , b₂⇛*c = (→β*⇒⇛* a→*b₁) Par.⋄* (→β*⇒⇛* a→*b₂) in c , ⇛*⇒→β* b₁⇛*c , ⇛*⇒→β* b₂⇛*c -- Factorization of β-equivalence into β-reductions. ≡β⇒→β* : ∀ {n} {a b : Term n} → a ≡β b → ∃ λ c → a →β* c × b →β* c ≡β⇒→β* a≡b = let c , a⇛*c , b⇛*c = ≡p⇒⇛* (≡β⇒≡p a≡b) in c , ⇛*⇒→β* a⇛*c , ⇛*⇒→β* b⇛*c -- Π-injectivity (with respect to ≡β). Π-inj : ∀ {n} {a₁ a₂ : Term n} {b₁ b₂} → Π a₁ b₁ ≡β Π a₂ b₂ → a₁ ≡β a₂ × b₁ ≡β b₂ Π-inj Πa₁b₁≡Πa₂b₂ = let a₁≡a₂ , b₁≡b₂ = Par.Π-inj (≡β⇒≡p Πa₁b₁≡Πa₂b₂) in ≡p⇒≡β a₁≡a₂ , ≡p⇒≡β b₁≡b₂ -- β-equivalence on sorts implies syntactic equivalence. sort-≡β : ∀ {n s₁ s₂} → sort {n} s₁ ≡β sort s₂ → s₁ ≡ s₂ sort-≡β s₁≡βs₂ = Par.sort-≡p (≡β⇒≡p s₁≡βs₂)
{ "alphanum_fraction": 0.494136514, "avg_line_length": 36.6801470588, "ext": "agda", "hexsha": "577fa5e17342743a2c8ea3007964bb9f217b7c56", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-08-11T23:28:33.000Z", "max_forks_repo_forks_event_min_datetime": "2017-08-20T10:29:44.000Z", "max_forks_repo_head_hexsha": "d701c2688e4a88eb81bdd9d458f9a2fcf81d5a43", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/pts-agda", "max_forks_repo_path": "src/Pts/Reduction/Full.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "d701c2688e4a88eb81bdd9d458f9a2fcf81d5a43", "max_issues_repo_issues_event_max_datetime": "2017-08-21T16:01:50.000Z", "max_issues_repo_issues_event_min_datetime": "2017-08-21T14:48:09.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "asr/pts-agda", "max_issues_repo_path": "src/Pts/Reduction/Full.agda", "max_line_length": 75, "max_stars_count": 21, "max_stars_repo_head_hexsha": "d701c2688e4a88eb81bdd9d458f9a2fcf81d5a43", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/pts-agda", "max_stars_repo_path": "src/Pts/Reduction/Full.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-31T10:47:57.000Z", "max_stars_repo_stars_event_min_datetime": "2016-05-13T12:11:10.000Z", "num_tokens": 4682, "size": 9977 }
module Issue2447.Operator-error where import Issue2447.M _+_ : Set → Set → Set A + _ = A F : Set → Set F A = A + A + A
{ "alphanum_fraction": 0.6147540984, "avg_line_length": 12.2, "ext": "agda", "hexsha": "1a1710042ed4982d3fa3dc25a8ca41a4a42fde6a", "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/Issue2447/Operator-error.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/Issue2447/Operator-error.agda", "max_line_length": 37, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2447/Operator-error.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 44, "size": 122 }
open import Agda.Builtin.Unit open import Agda.Builtin.Bool open import Agda.Builtin.Nat renaming (_<_ to natLessThan) open import Agda.Builtin.Int _<_ : Int -> Int -> Bool _<_ = \ where (pos m) (pos n) -> natLessThan m n (negsuc m) (negsuc n) -> natLessThan n m (negsuc _) (pos _) -> true (pos _) (negsuc _) -> false {-# INLINE _<_ #-} check : Int -> Bool check n = pos 0 < n
{ "alphanum_fraction": 0.6443298969, "avg_line_length": 22.8235294118, "ext": "agda", "hexsha": "cda1131a5087033cc6e4f084421d6cd144a46ec7", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Succeed/Issue4967.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/Issue4967.agda", "max_line_length": 58, "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/Issue4967.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": 136, "size": 388 }
-- Verify that issue 3415 has been fixed by checking that the -- computation rule for univalence holds up to a trivial transport (it -- used to only hold up to a more complicated argument). {-# OPTIONS --cubical #-} module Issue3415 where open import Agda.Primitive.Cubical public open import Agda.Builtin.Cubical.Path public open import Agda.Builtin.Cubical.Glue public open import Agda.Builtin.Sigma public idIsEquiv : ∀ {ℓ} (A : Set ℓ) → isEquiv (λ (x : A) → x) equiv-proof (idIsEquiv A) y = ((y , λ _ → y) , λ z i → z .snd (primINeg i) , λ j → z .snd (primIMax (primINeg i) j)) idEquiv : ∀ {ℓ} (A : Set ℓ) → A ≃ A idEquiv A = ((λ x → x) , idIsEquiv A) ua : ∀ {ℓ} {A B : Set ℓ} → A ≃ B → A ≡ B ua {A = A} {B = B} e i = primGlue B (λ { (i = i0) → A ; (i = i1) → B }) (λ { (i = i0) → e ; (i = i1) → (idEquiv B) }) transport : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → A → B transport p a = primTransp (λ i → p i) i0 a transportRefl : ∀ {ℓ} {A : Set ℓ} → (x : A) → transport (λ _ → A) x ≡ x transportRefl {A = A} x i = primTransp (λ _ → A) i x uaβ : ∀ {ℓ} {A B : Set ℓ} (e : A ≃ B) (x : A) → transport (ua e) x ≡ e .fst x uaβ e x = transportRefl (e .fst x)
{ "alphanum_fraction": 0.5776450512, "avg_line_length": 35.5151515152, "ext": "agda", "hexsha": "3ca0a7a8825bb474bb61d74c9026ef4bbfa70608", "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/Issue3415.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/Issue3415.agda", "max_line_length": 77, "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/Issue3415.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": 479, "size": 1172 }
module BasicIS4.Metatheory.ClosedHilbert-TarskiClosedOvergluedImplicit where open import BasicIS4.Syntax.ClosedHilbert public open import BasicIS4.Semantics.TarskiClosedOvergluedImplicit public open ImplicitSyntax (⊢_) public -- Completeness with respect to a particular model. module _ {{_ : Model}} where reify : ∀ {A} → ⊩ A → ⊢ A reify {α P} s = syn s reify {A ▻ B} s = syn s reify {□ A} s = syn s reify {A ∧ B} s = pair (reify (π₁ s)) (reify (π₂ s)) reify {⊤} s = unit -- Additional useful equipment. module _ {{_ : Model}} where ⟪K⟫ : ∀ {A B} → ⊩ A → ⊩ B ▻ A ⟪K⟫ a = app ck (reify a) ⅋ K a ⟪S⟫′ : ∀ {A B C} → ⊩ A ▻ B ▻ C → ⊩ (A ▻ B) ▻ A ▻ C ⟪S⟫′ s₁ = app cs (reify s₁) ⅋ λ s₂ → app (app cs (reify s₁)) (reify s₂) ⅋ ⟪S⟫ s₁ s₂ _⟪D⟫_ : ∀ {A B} → ⊩ □ (A ▻ B) → ⊩ □ A → ⊩ □ B (t ⅋ s) ⟪D⟫ (u ⅋ a) = app (app cdist t) u ⅋ s ⟪$⟫ a _⟪D⟫′_ : ∀ {A B} → ⊩ □ (A ▻ B) → ⊩ □ A ▻ □ B _⟪D⟫′_ s = app cdist (reify s) ⅋ _⟪D⟫_ s ⟪↑⟫ : ∀ {A} → ⊩ □ A → ⊩ □ □ A ⟪↑⟫ s = box (syn s) ⅋ s _⟪,⟫′_ : ∀ {A B} → ⊩ A → ⊩ B ▻ A ∧ B _⟪,⟫′_ a = app cpair (reify a) ⅋ _,_ a -- Soundness with respect to all models, or evaluation, for closed terms only. eval₀ : ∀ {A} → ⊢ A → ⊨ A eval₀ (app t u) = eval₀ t ⟪$⟫ eval₀ u eval₀ ci = ci ⅋ I eval₀ ck = ck ⅋ ⟪K⟫ eval₀ cs = cs ⅋ ⟪S⟫′ eval₀ (box t) = box t ⅋ eval₀ t eval₀ cdist = cdist ⅋ _⟪D⟫′_ eval₀ cup = cup ⅋ ⟪↑⟫ eval₀ cdown = cdown ⅋ ⟪↓⟫ eval₀ cpair = cpair ⅋ _⟪,⟫′_ eval₀ cfst = cfst ⅋ π₁ eval₀ csnd = csnd ⅋ π₂ eval₀ unit = ∙ -- Correctness of evaluation with respect to conversion. eval₀✓ : ∀ {{_ : Model}} {A} {t t′ : ⊢ A} → t ⋙ t′ → eval₀ t ≡ eval₀ t′ eval₀✓ refl⋙ = refl eval₀✓ (trans⋙ p q) = trans (eval₀✓ p) (eval₀✓ q) eval₀✓ (sym⋙ p) = sym (eval₀✓ p) eval₀✓ (congapp⋙ p q) = cong² _⟪$⟫_ (eval₀✓ p) (eval₀✓ q) eval₀✓ (congi⋙ p) = cong I (eval₀✓ p) eval₀✓ (congk⋙ p q) = cong² K (eval₀✓ p) (eval₀✓ q) eval₀✓ (congs⋙ p q r) = cong³ ⟪S⟫ (eval₀✓ p) (eval₀✓ q) (eval₀✓ r) eval₀✓ (congdist⋙ p q) = cong² _⟪D⟫_ (eval₀✓ p) (eval₀✓ q) eval₀✓ (congup⋙ p) = cong ⟪↑⟫ (eval₀✓ p) eval₀✓ (congdown⋙ p) = cong ⟪↓⟫ (eval₀✓ p) eval₀✓ (congpair⋙ p q) = cong² _,_ (eval₀✓ p) (eval₀✓ q) eval₀✓ (congfst⋙ p) = cong π₁ (eval₀✓ p) eval₀✓ (congsnd⋙ p) = cong π₂ (eval₀✓ p) eval₀✓ beta▻ₖ⋙ = refl eval₀✓ beta▻ₛ⋙ = refl eval₀✓ beta□⋙ = refl eval₀✓ eta□⋙ = refl eval₀✓ beta∧₁⋙ = refl eval₀✓ beta∧₂⋙ = refl eval₀✓ eta∧⋙ = refl eval₀✓ eta⊤⋙ = refl -- The canonical model. private instance canon : Model canon = record { ⊩ᵅ_ = λ P → ⊢ α P } -- Completeness with respect to all models, or quotation, for closed terms only. quot₀ : ∀ {A} → ⊨ A → ⊢ A quot₀ s = reify s -- Normalisation by evaluation, for closed terms only. norm₀ : ∀ {A} → ⊢ A → ⊢ A norm₀ = quot₀ ∘ eval₀ -- Correctness of normalisation with respect to conversion. norm₀✓ : ∀ {{_ : Model}} {A} {t t′ : ⊢ A} → t ⋙ t′ → norm₀ t ≡ norm₀ t′ norm₀✓ p = cong reify (eval₀✓ p)
{ "alphanum_fraction": 0.5264005151, "avg_line_length": 27.7321428571, "ext": "agda", "hexsha": "f50066da791efc2f525d2546043f4286ca6a98ad", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIS4/Metatheory/ClosedHilbert-TarskiClosedOvergluedImplicit.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIS4/Metatheory/ClosedHilbert-TarskiClosedOvergluedImplicit.agda", "max_line_length": 80, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIS4/Metatheory/ClosedHilbert-TarskiClosedOvergluedImplicit.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": 1531, "size": 3106 }
module MonoidTactic where open import Prelude open import Container.Traversable open import Tactic.Monoid open import Tactic.Reflection SemigroupAnd : Semigroup Bool _<>_ {{SemigroupAnd}} = _&&_ MonoidAnd : Monoid Bool Monoid.super MonoidAnd = SemigroupAnd mempty {{MonoidAnd}} = true Monoid/LawsAnd : Monoid/Laws Bool Monoid/Laws.super Monoid/LawsAnd = MonoidAnd left-identity {{Monoid/LawsAnd}} x = refl right-identity {{Monoid/LawsAnd}} true = refl right-identity {{Monoid/LawsAnd}} false = refl monoid-assoc {{Monoid/LawsAnd}} true y z = refl monoid-assoc {{Monoid/LawsAnd}} false y z = refl test₁ : (a b : Bool) → (a && (b && a && true)) ≡ ((a && b) && a) test₁ a b = auto-monoid {{Laws = Monoid/LawsAnd}} test₂ : ∀ {a} {A : Set a} {{Laws : Monoid/Laws A}} → (x y : A) → x <> (y <> x <> mempty) ≡ (x <> y) <> x test₂ x y = auto-monoid test₃ : ∀ {a} {A : Set a} (xs ys zs : List A) → xs ++ ys ++ zs ≡ (xs ++ []) ++ (ys ++ []) ++ zs test₃ xs ys zs = runT monoidTactic
{ "alphanum_fraction": 0.6401209677, "avg_line_length": 29.1764705882, "ext": "agda", "hexsha": "1161ebdaaa9fdb3e6f69eded7239020b70ff615c", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "test/MonoidTactic.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "test/MonoidTactic.agda", "max_line_length": 95, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "test/MonoidTactic.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 349, "size": 992 }
-- The type checker was a little too eager to prune metavariables in -- order to get the occurs check to pass. In this particular case it -- got the constraint -- _41 A B x == B (_42 A B (x , y)) -- and tried to make it work by pruning the third argument to _42. The -- correct solution _42 A B p := fst p was thus lost. module Issue458 where data Σ (A : Set) (B : A -> Set) : Set where _,_ : (x : A) (y : B x) → Σ A B uncurry : {A : Set} {B : A → Set} {P : Σ A B → Set} → ((x : A) (y : B x) → P (x , y)) → (p : Σ A B) → P p uncurry f (x , y) = f x y fst : {A : Set} {B : A → Set} → Σ A B → A fst = uncurry λ x y → x snd : {A : Set} {B : A → Set} (p : Σ A B) → B (fst p) snd = uncurry λ x y → y -- Bug.agda:15,7-24 -- Cannot instantiate the metavariable _50 to .B x since it contains -- the variable x which is not in scope of the metavariable -- when checking that the expression uncurry (λ x y → y) has type -- (p : Σ .A .B) → .B (fst p)
{ "alphanum_fraction": 0.5774793388, "avg_line_length": 35.8518518519, "ext": "agda", "hexsha": "a1d38ed5eaba6fbfdc5770f9b843ddcaafa424ce", "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/Issue458.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/Issue458.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue458.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": 357, "size": 968 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The state monad ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Category.Monad.State where open import Category.Applicative.Indexed open import Category.Monad open import Function.Identity.Categorical as Id using (Identity) open import Category.Monad.Indexed open import Data.Product open import Data.Unit open import Function open import Level ------------------------------------------------------------------------ -- Indexed state IStateT : ∀ {i f} {I : Set i} → (I → Set f) → (Set f → Set f) → IFun I f IStateT S M i j A = S i → M (A × S j) ------------------------------------------------------------------------ -- Indexed state applicative StateTIApplicative : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonad M → RawIApplicative (IStateT S M) StateTIApplicative S Mon = record { pure = λ a s → return (a , s) ; _⊛_ = λ f t s → do (f′ , s′) ← f s (t′ , s′′) ← t s′ return (f′ t′ , s′′) } where open RawMonad Mon StateTIApplicativeZero : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonadZero M → RawIApplicativeZero (IStateT S M) StateTIApplicativeZero S Mon = record { applicative = StateTIApplicative S monad ; ∅ = const ∅ } where open RawMonadZero Mon StateTIAlternative : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonadPlus M → RawIAlternative (IStateT S M) StateTIAlternative S Mon = record { applicativeZero = StateTIApplicativeZero S monadZero ; _∣_ = λ m n s → m s ∣ n s } where open RawMonadPlus Mon ------------------------------------------------------------------------ -- Indexed state monad StateTIMonad : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonad M → RawIMonad (IStateT S M) StateTIMonad S Mon = record { return = λ x s → return (x , s) ; _>>=_ = λ m f s → m s >>= uncurry f } where open RawMonad Mon StateTIMonadZero : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonadZero M → RawIMonadZero (IStateT S M) StateTIMonadZero S Mon = record { monad = StateTIMonad S (RawMonadZero.monad Mon) ; applicativeZero = StateTIApplicativeZero S Mon } where open RawMonadZero Mon StateTIMonadPlus : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonadPlus M → RawIMonadPlus (IStateT S M) StateTIMonadPlus S Mon = record { monad = StateTIMonad S monad ; alternative = StateTIAlternative S Mon } where open RawMonadPlus Mon ------------------------------------------------------------------------ -- State monad operations record RawIMonadState {i f} {I : Set i} (S : I → Set f) (M : IFun I f) : Set (i ⊔ suc f) where field monad : RawIMonad M get : ∀ {i} → M i i (S i) put : ∀ {i j} → S j → M i j (Lift f ⊤) open RawIMonad monad public modify : ∀ {i j} → (S i → S j) → M i j (Lift f ⊤) modify f = get >>= put ∘ f StateTIMonadState : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonad M → RawIMonadState S (IStateT S M) StateTIMonadState S Mon = record { monad = StateTIMonad S Mon ; get = λ s → return (s , s) ; put = λ s _ → return (_ , s) } where open RawIMonad Mon ------------------------------------------------------------------------ -- Ordinary state monads RawMonadState : ∀ {f} → Set f → (Set f → Set f) → Set _ RawMonadState S M = RawIMonadState {I = ⊤} (λ _ → S) (λ _ _ → M) module RawMonadState {f} {S : Set f} {M : Set f → Set f} (Mon : RawMonadState S M) where open RawIMonadState Mon public StateT : ∀ {f} → Set f → (Set f → Set f) → Set f → Set f StateT S M = IStateT {I = ⊤} (λ _ → S) M _ _ StateTMonad : ∀ {f} (S : Set f) {M} → RawMonad M → RawMonad (StateT S M) StateTMonad S = StateTIMonad (λ _ → S) StateTMonadZero : ∀ {f} (S : Set f) {M} → RawMonadZero M → RawMonadZero (StateT S M) StateTMonadZero S = StateTIMonadZero (λ _ → S) StateTMonadPlus : ∀ {f} (S : Set f) {M} → RawMonadPlus M → RawMonadPlus (StateT S M) StateTMonadPlus S = StateTIMonadPlus (λ _ → S) StateTMonadState : ∀ {f} (S : Set f) {M} → RawMonad M → RawMonadState S (StateT S M) StateTMonadState S = StateTIMonadState (λ _ → S) State : ∀ {f} → Set f → Set f → Set f State S = StateT S Identity StateMonad : ∀ {f} (S : Set f) → RawMonad (State S) StateMonad S = StateTMonad S Id.monad StateMonadState : ∀ {f} (S : Set f) → RawMonadState S (State S) StateMonadState S = StateTMonadState S Id.monad LiftMonadState : ∀ {f S₁} (S₂ : Set f) {M} → RawMonadState S₁ M → RawMonadState S₁ (StateT S₂ M) LiftMonadState S₂ Mon = record { monad = StateTIMonad (λ _ → S₂) monad ; get = λ s → get >>= λ x → return (x , s) ; put = λ s′ s → put s′ >> return (_ , s) } where open RawIMonadState Mon
{ "alphanum_fraction": 0.5279936242, "avg_line_length": 34.1428571429, "ext": "agda", "hexsha": "c0035b1cd3c1400a668ff2266729a82d4fbadefd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Category/Monad/State.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Category/Monad/State.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Category/Monad/State.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1596, "size": 5019 }
{-# OPTIONS --without-K --safe #-} module Experiment.EvenOdd where open import Data.List open import Data.List.Relation.Unary.All open import Data.Product hiding (map) open import Data.Sum as Sum hiding (map) open import Data.Nat open import Data.Nat.GeneralisedArithmetic import Data.Nat.Properties as ℕₚ open import Function.Base open import Relation.Binary.PropositionalEquality data RoseTree {a} (A : Set a) : Set a where node : A → List (RoseTree A) → RoseTree A unnode : ∀ {a} {A : Set a} → RoseTree A → A × List (RoseTree A) unnode (node x rs) = x , rs foldRoseTree : ∀ {a b} {A : Set a} {B : Set b} → (A → List B → B) → RoseTree A → B foldRoseTrees : ∀ {a b} {A : Set a} {B : Set b} → (A → List B → B) → List (RoseTree A) → List B foldRoseTree f (node x rs) = f x (foldRoseTrees f rs) foldRoseTrees f [] = [] foldRoseTrees f (x ∷ rs) = foldRoseTree f x ∷ foldRoseTrees f rs mapRoseTree : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → RoseTree A → RoseTree B mapRoseTree f r = foldRoseTree (λ x rs → node (f x) rs) r data Parity : Set where even odd : Parity data Pos : Set where one : Pos node : Parity → Pos → List Pos → Pos op : Parity → Parity op even = odd op odd = even induction : ∀ {p} {P : Pos → Set p} → P one → (∀ pa x xs → P x → All P xs → P (node pa x xs)) → ∀ n → P n induction-node : ∀ {p} {P : Pos → Set p} → P one → (∀ pa x xs → P x → All P xs → P (node pa x xs)) → ∀ ns → All P ns induction P1 Pn one = P1 induction P1 Pn (node pa n ns) = Pn pa n ns (induction P1 Pn n) (induction-node P1 Pn ns) induction-node P1 Pn [] = [] induction-node P1 Pn (x ∷ ns) = induction P1 Pn x ∷ induction-node P1 Pn ns recursion : ∀ {a} {A : Set a} → A → (Parity → A → List A → A) → Pos → A recursion o n p = induction o (λ pa _ _ x AllAxs → n pa x (reduce id AllAxs)) p ℕ⁺ : Set ℕ⁺ = Σ ℕ (λ n → n ≢ 0) 1ℕ⁺ : ℕ⁺ 1ℕ⁺ = 1 , (λ ()) 2ℕ⁺ : ℕ⁺ 2ℕ⁺ = 2 , (λ ()) sucℕ⁺ : ℕ⁺ → ℕ⁺ sucℕ⁺ (n , _) = suc n , λ () _+ℕ⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺ (m , m≢0) +ℕ⁺ (n , n≢0) = (m + n) , (λ m+n≡0 → m≢0 (ℕₚ.m+n≡0⇒m≡0 m m+n≡0) ) private m*n≡0⇒m≡0∨n≡0 : ∀ m {n} → m * n ≡ 0 → m ≡ 0 ⊎ n ≡ 0 m*n≡0⇒m≡0∨n≡0 zero {zero} m+n≡0 = inj₁ refl m*n≡0⇒m≡0∨n≡0 zero {suc n} m+n≡0 = inj₁ refl m*n≡0⇒m≡0∨n≡0 (suc m) {zero} m+n≡0 = inj₂ refl _*ℕ⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺ (m , m≢0) *ℕ⁺ (n , n≢0) = (m * n) , λ m*n≡0 → Sum.[ m≢0 , n≢0 ] (m*n≡0⇒m≡0∨n≡0 m m*n≡0) private m^n≡0⇒m≡0 : ∀ m n → m ^ n ≡ 0 → m ≡ 0 m^n≡0⇒m≡0 zero (suc n) m^n≡0 = refl m^n≡0⇒m≡0 (suc m) (suc n) m^n≡0 with m*n≡0⇒m≡0∨n≡0 (suc m) m^n≡0 ... | inj₂ sm^n≡0 = m^n≡0⇒m≡0 (suc m) n sm^n≡0 _^ℕ⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺ (m , m≢0) ^ℕ⁺ (n , n≢0) = (m ^ n) , λ m^n≡0 → m≢0 (m^n≡0⇒m≡0 m n m^n≡0) _⊓ℕ⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺ (m , m≢0) ⊓ℕ⁺ (n , n≢0) = (m ⊓ n) , {! !} oℕ : ℕ → ℕ oℕ n = 2 * n iℕ : ℕ → ℕ iℕ n = 1 + 2 * n oℕ⁺ : ℕ⁺ → ℕ⁺ oℕ⁺ n = 2ℕ⁺ *ℕ⁺ n iℕ⁺ : ℕ⁺ → ℕ⁺ iℕ⁺ n = sucℕ⁺ (2ℕ⁺ *ℕ⁺ n) o^ℕ⁺ : ℕ⁺ → ℕ⁺ → ℕ⁺ o^ℕ⁺ (m , _) x = fold x oℕ⁺ m i^ℕ⁺ : ℕ⁺ → ℕ⁺ → ℕ⁺ i^ℕ⁺ (m , _) x = fold x iℕ⁺ m toℕ⁺ : Pos → ℕ⁺ toℕ⁺ = recursion 1ℕ⁺ f where f : Parity → ℕ⁺ → List ℕ⁺ → ℕ⁺ f even x [] = o^ℕ⁺ x 1ℕ⁺ f even x (y ∷ xs) = o^ℕ⁺ x (f odd y xs) f odd x [] = i^ℕ⁺ x 1ℕ⁺ f odd x (y ∷ xs) = i^ℕ⁺ x (f even y xs)
{ "alphanum_fraction": 0.499850075, "avg_line_length": 27.3360655738, "ext": "agda", "hexsha": "798947264d2ddf7329ba02b96ce814b250b2b5c9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Experiment/EvenOdd.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Experiment/EvenOdd.agda", "max_line_length": 89, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Experiment/EvenOdd.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 1726, "size": 3335 }
module BBHeap.Compound {A : Set}(_≤_ : A → A → Set) where open import BBHeap _≤_ open import Bound.Lower A open import Bound.Lower.Order _≤_ data Compound {b : Bound} : BBHeap b → Set where cl : {x : A}{l r : BBHeap (val x)}(b≤x : LeB b (val x))(l⋘r : l ⋘ r) → Compound (left b≤x l⋘r) cr : {x : A}{l r : BBHeap (val x)}(b≤x : LeB b (val x))(l⋙r : l ⋙ r) → Compound (right b≤x l⋙r)
{ "alphanum_fraction": 0.587628866, "avg_line_length": 38.8, "ext": "agda", "hexsha": "f431d5663863555cda476ab5049825188513dc6e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/BBHeap/Compound.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/BBHeap/Compound.agda", "max_line_length": 97, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/BBHeap/Compound.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 175, "size": 388 }
module Test where import Data.Bits import Data.Bool import Data.Char import Data.Fin import Data.Integer import Data.Interval import Data.List import Data.Map import Data.Maybe import Data.Nat import Data.Nat.Properties import Data.Permutation import Data.PigeonHole import Data.Rational import Data.Real.Base import Data.Real.CReal import Data.Real.Complete import Data.Real.Gauge import Data.Show import Data.String import Data.Tuple import Data.Vec import Logic.Base import Logic.ChainReasoning import Logic.Congruence import Logic.Equivalence import Logic.Identity import Logic.Leibniz import Logic.Operations import Logic.Relations import Logic.Structure.Applicative import Logic.Structure.Monoid import Prelude
{ "alphanum_fraction": 0.8458333333, "avg_line_length": 18.9473684211, "ext": "agda", "hexsha": "ca8e05cbfc822b0420c3fa8702bf40f8677da087", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/lib/Test.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/lib/Test.agda", "max_line_length": 34, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/lib/Test.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": 720 }
{- Please do not move this file. Changes should only be made if necessary. This file contains pointers to the code examples and main results from the paper: Synthetic Cohomology Theory in Cubical Agda -} -- The "--safe" flag ensures that there are no postulates or -- unfinished goals {-# OPTIONS --safe #-} module Cubical.Papers.ZCohomology where -- Misc. open import Cubical.Data.Int hiding (_+_) open import Cubical.Data.Nat open import Cubical.Foundations.Everything open import Cubical.HITs.S1 open import Cubical.Data.Sum open import Cubical.Data.Sigma -- 2 open import Cubical.Core.Glue as Glue import Cubical.Foundations.Prelude as Prelude import Cubical.Foundations.GroupoidLaws as GroupoidLaws import Cubical.Foundations.Path as Path import Cubical.Foundations.Pointed as Pointed renaming (Pointed to Type∙) open import Cubical.HITs.S1 as S1 open import Cubical.HITs.Susp as Suspension open import Cubical.HITs.Sn as Sn open import Cubical.Homotopy.Loopspace as Loop open import Cubical.Foundations.HLevels as n-types open import Cubical.HITs.Truncation as Trunc open import Cubical.Homotopy.Connected as Connected import Cubical.HITs.Pushout as Push import Cubical.HITs.Wedge as ⋁ import Cubical.Foundations.Univalence as Unival import Cubical.Foundations.SIP as StructIdPrinc import Cubical.Algebra.Group as Gr import Cubical.Algebra.Group.GroupPath as GrPath -- 3 import Cubical.ZCohomology.Base as coHom renaming (coHomK to K ; coHomK-ptd to K∙) import Cubical.HITs.Sn.Properties as S import Cubical.ZCohomology.GroupStructure as GroupStructure import Cubical.ZCohomology.Properties as Properties renaming (Kn→ΩKn+1 to σ ; ΩKn+1→Kn to σ⁻¹) import Cubical.Experiments.ZCohomologyOld.Properties as oldCohom -- 4 import Cubical.ZCohomology.RingStructure.CupProduct as Cup import Cubical.ZCohomology.RingStructure.RingLaws as ⌣Ring import Cubical.ZCohomology.RingStructure.GradedCommutativity as ⌣Comm import Cubical.Foundations.Pointed.Homogeneous as Homogen -- 5 import Cubical.HITs.Torus as 𝕋² renaming (Torus to 𝕋²) import Cubical.HITs.KleinBottle as 𝕂² renaming (KleinBottle to 𝕂²) import Cubical.HITs.RPn as ℝP renaming (RP² to ℝP²) import Cubical.ZCohomology.Groups.Sn as HⁿSⁿ renaming (Hⁿ-Sᵐ≅0 to Hⁿ-Sᵐ≅1) import Cubical.ZCohomology.Groups.Torus as HⁿT² import Cubical.ZCohomology.Groups.Wedge as Hⁿ-wedge import Cubical.ZCohomology.Groups.KleinBottle as Hⁿ𝕂² import Cubical.ZCohomology.Groups.RP2 as HⁿℝP² renaming (H¹-RP²≅0 to H¹-RP²≅1) import Cubical.ZCohomology.Groups.CP2 as HⁿℂP² renaming (CP² to ℂP² ; ℤ→HⁿCP²→ℤ to g) {- Remark: ℂP² is defined as the pushout S² ← TotalHopf → 1 in the formalisation. TotalHopf is just the total space from the Hopf fibration. We have TotalHopf ≃ S³, and the map TotalHopf → S² is given by taking the first projection. This is equivalent to the description given in the paper, since h : S³ → S² is given by S³ ≃ TotalHopf → S² -} -- Appendix import Cubical.Homotopy.EilenbergSteenrod as ES-axioms import Cubical.ZCohomology.EilenbergSteenrodZ as satisfies-ES-axioms renaming (coHomFunctor to H^~ ; coHomFunctor' to Ĥ) import Cubical.ZCohomology.MayerVietorisUnreduced as MayerVietoris ----- 2. HOMOTOPY TYPE THEORY IN CUBICAL AGDA ----- -- 2.1 Important notions in Cubical Agda open Prelude using ( PathP ; _≡_ ; refl ; cong ; cong₂ ; funExt) open GroupoidLaws using (_⁻¹) open Prelude using ( transport ; subst ; hcomp) --- 2.2 Important concepts from HoTT/UF in Cubical Agda -- Pointed Types open Pointed using (Type∙) -- The circle, 𝕊¹ open S1 using (S¹) -- Suspensions open Suspension using (Susp) -- (Pointed) n-spheres, 𝕊ⁿ open Sn using (S₊∙) -- Loop spaces open Loop using (Ω^_) -- Eckmann-Hilton argument open Loop using (Eckmann-Hilton) -- n-types Note that we start indexing from 0 in the Cubical Library -- (so (-2)-types as referred to as 0-types, (-1) as 1-types, and so -- on) open n-types using (isOfHLevel) -- truncations open Trunc using (hLevelTrunc) -- elimination principle open Trunc using (elim) -- elimination principle for paths truncPathElim : ∀ {ℓ ℓ'} {A : Type ℓ} {x y : A} (n : ℕ) → {B : Path (hLevelTrunc (suc n) A) ∣ x ∣ ∣ y ∣ → Type ℓ'} → ((q : _) → isOfHLevel n (B q)) → ((p : x ≡ y) → B (cong ∣_∣ p)) → (q : _) → B q truncPathElim zero hlev ind q = hlev q .fst truncPathElim (suc n) {B = B} hlev ind q = subst B (Iso.leftInv (Trunc.PathIdTruncIso _) q) (help (ΩTrunc.encode-fun ∣ _ ∣ ∣ _ ∣ q)) where help : (q : _) → B (ΩTrunc.decode-fun ∣ _ ∣ ∣ _ ∣ q) help = Trunc.elim (λ _ → hlev _) ind -- Connectedness open Connected using (isConnected) -- Pushouts open Push using (Pushout) -- Wedge sum open ⋁ using (_⋁_) -- 2.3 Univalence -- Univalence and the ua function respectively open Unival using (univalence ; ua) -- Glue types open Glue using (Glue) -- The structure identity principle and the sip function -- respectively open StructIdPrinc using (SIP ; sip) -- Groups open Gr using (Group) -- Isomorphic groups are path equal open GrPath using (GroupPath) ----- 3. ℤ-COHOMOLOGY IN CUBICAL AGDA ----- -- 3.1 Eilenberg-MacLane spaces -- Eilenberg-MacLane spaces Kₙ (unpointed and pointed respectively) open coHom using (K ; K∙) -- Proposition 7 open S using (sphereConnected) -- Lemma 8 open S using (wedgeconFun; wedgeconLeft ; wedgeconRight) -- restated to match the formulation in the paper wedgeConSn' : ∀ {ℓ} (n m : ℕ) {A : (S₊ (suc n)) → (S₊ (suc m)) → Type ℓ} → ((x : S₊ (suc n)) (y : S₊ (suc m)) → isOfHLevel ((suc n) + (suc m)) (A x y)) → (fₗ : (x : _) → A x (ptSn (suc m))) → (fᵣ : (x : _) → A (ptSn (suc n)) x) → (p : fₗ (ptSn (suc n)) ≡ fᵣ (ptSn (suc m))) → Σ[ F ∈ ((x : S₊ (suc n)) (y : S₊ (suc m)) → A x y) ] (Σ[ (left , right) ∈ ((x : S₊ (suc n)) → fₗ x ≡ F x (ptSn (suc m))) × ((x : S₊ (suc m)) → fᵣ x ≡ F (ptSn (suc n)) x) ] p ≡ left (ptSn (suc n)) ∙ (right (ptSn (suc m))) ⁻¹) wedgeConSn' zero zero hlev fₗ fᵣ p = (wedgeconFun 0 0 hlev fᵣ fₗ p) , ((λ x → sym (wedgeconRight 0 0 hlev fᵣ fₗ p x)) , λ _ → refl) -- right holds by refl , rUnit _ wedgeConSn' zero (suc m) hlev fₗ fᵣ p = (wedgeconFun 0 (suc m) hlev fᵣ fₗ p) , ((λ _ → refl) -- left holds by refl , (λ x → sym (wedgeconLeft 0 (suc m) hlev fᵣ fₗ p x))) , lUnit _ wedgeConSn' (suc n) m hlev fₗ fᵣ p = (wedgeconFun (suc n) m hlev fᵣ fₗ p) , ((λ x → sym (wedgeconRight (suc n) m hlev fᵣ fₗ p x)) , λ _ → refl) -- right holds by refl , rUnit _ -- +ₖ (addition) and 0ₖ open GroupStructure using (_+ₖ_ ; 0ₖ) -- The function σ : Kₙ → ΩKₙ₊₁ open Properties using (σ) -- -ₖ (subtraction) open GroupStructure using (-ₖ_) -- Group laws for +ₖ open GroupStructure using ( rUnitₖ ; lUnitₖ ; rCancelₖ ; lCancelₖ ; commₖ ; assocₖ) -- All group laws are equal to refl at 0ₖ -- rUnitₖ (definitional) 0-rUnit≡refl : rUnitₖ 0 (0ₖ 0) ≡ refl 1-rUnit≡refl : rUnitₖ 1 (0ₖ 1) ≡ refl 0-rUnit≡refl = refl 1-rUnit≡refl = refl n≥2-rUnit≡refl : {n : ℕ} → rUnitₖ (2 + n) (0ₖ (2 + n)) ≡ refl n≥2-rUnit≡refl = refl -- lUnitₖ (definitional) 0-lUnit≡refl : lUnitₖ 0 (0ₖ 0) ≡ refl 1-lUnit≡refl : lUnitₖ 1 (0ₖ 1) ≡ refl n≥2-lUnit≡refl : {n : ℕ} → lUnitₖ (2 + n) (0ₖ (2 + n)) ≡ refl 0-lUnit≡refl = refl 1-lUnit≡refl = refl n≥2-lUnit≡refl = refl -- assocₖ (definitional) 0-assoc≡refl : assocₖ 0 (0ₖ 0) (0ₖ 0) (0ₖ 0) ≡ refl 1-assoc≡refl : assocₖ 1 (0ₖ 1) (0ₖ 1) (0ₖ 1) ≡ refl n≥2-assoc≡refl : {n : ℕ} → assocₖ (2 + n) (0ₖ (2 + n)) (0ₖ (2 + n)) (0ₖ (2 + n)) ≡ refl 0-assoc≡refl = refl 1-assoc≡refl = refl n≥2-assoc≡refl = refl -- commₖ (≡ refl ∙ refl for n ≥ 2) 0-comm≡refl : commₖ 0 (0ₖ 0) (0ₖ 0) ≡ refl 1-comm≡refl : commₖ 1 (0ₖ 1) (0ₖ 1) ≡ refl n≥2-comm≡refl : {n : ℕ} → commₖ (2 + n) (0ₖ (2 + n)) (0ₖ (2 + n)) ≡ refl 0-comm≡refl = refl 1-comm≡refl = refl n≥2-comm≡refl = sym (rUnit refl) -- lCancelₖ (definitional) 0-lCancel≡refl : lCancelₖ 0 (0ₖ 0) ≡ refl 1-lCancel≡refl : lCancelₖ 1 (0ₖ 1) ≡ refl n≥2-lCancel≡refl : {n : ℕ} → lCancelₖ (2 + n) (0ₖ (2 + n)) ≡ refl 0-lCancel≡refl = refl 1-lCancel≡refl = refl n≥2-lCancel≡refl = refl -- rCancelₖ (≡ (refl ∙ refl) ∙ refl for n ≥ 1) 0-rCancel≡refl : rCancelₖ 0 (0ₖ 0) ≡ refl 1-rCancel≡refl : rCancelₖ 1 (0ₖ 1) ≡ refl n≥2-rCancel≡refl : {n : ℕ} → rCancelₖ (2 + n) (0ₖ (2 + n)) ≡ refl 0-rCancel≡refl = refl 1-rCancel≡refl = refl n≥2-rCancel≡refl i = rUnit (rUnit refl (~ i)) (~ i) -- Proof that there is a unique h-structure on Kₙ -- +ₖ defines an h-Structure on Kₙ open GroupStructure using (_+ₖ_ ; 0ₖ ; rUnitₖ ; lUnitₖ ; lUnitₖ≡rUnitₖ) -- and so does Brunerie's addition open oldCohom using (_+ₖ_ ; 0ₖ ; rUnitₖ ; lUnitₖ ; rUnitlUnit0) -- consequently both additions agree open GroupStructure using (+ₖ-unique) open oldCohom using (addLemma) additionsAgree : (n : ℕ) → GroupStructure._+ₖ_ {n = n} ≡ oldCohom._+ₖ_ {n = n} additionsAgree zero i x y = oldCohom.addLemma x y (~ i) additionsAgree (suc n) i x y = +ₖ-unique n (GroupStructure._+ₖ_) (oldCohom._+ₖ_) (GroupStructure.rUnitₖ (suc n)) (GroupStructure.lUnitₖ (suc n)) (oldCohom.rUnitₖ (suc n)) (oldCohom.lUnitₖ (suc n)) (sym (lUnitₖ≡rUnitₖ (suc n))) (rUnitlUnit0 (suc n)) x y i -- Theorem 9 (Kₙ ≃ ΩKₙ₊₁) open Properties using (Kn≃ΩKn+1) -- σ and σ⁻¹ are morphisms -- (for σ⁻¹ this is proved directly without using the fact that σ is a morphism) open Properties using (Kn→ΩKn+1-hom ; ΩKn+1→Kn-hom) -- Lemma 10 (p ∙ q ≡ cong²₊(p,q)) for n = 1 and n ≥ 2 respectively open GroupStructure using (∙≡+₁ ; ∙≡+₂) -- Lemma 11 (cong²₊ is commutative) and Theorem 12 respectively open GroupStructure using (cong+ₖ-comm ; isCommΩK) -- 3.2 Group structure on Hⁿ(A) -- +ₕ (addition), -ₕ and 0ₕ open GroupStructure using (_+ₕ_ ; -ₕ_ ; 0ₕ) -- Cohomology group structure open GroupStructure using ( rUnitₕ ; lUnitₕ ; rCancelₕ ; lCancelₕ ; commₕ ; assocₕ) -------------------------------------------------------------------- MOVE? -- Reduced cohomology, group structure open GroupStructure using (coHomRedGroupDir) -- Equality of unreduced and reduced cohmology open Properties using (coHomGroup≡coHomRedGroup) -------------------------------------------------------------------- ----- 4. The Cup Product and Cohomology Ring ----- -- 4.1 -- Lemma 13 open Properties using (isOfHLevel↑∙) -- ⌣ₖ open Cup using (_⌣ₖ_) -- ⌣ₖ is pointed in both arguments open ⌣Ring using (0ₖ-⌣ₖ ; ⌣ₖ-0ₖ) -- The cup product open Cup using (_⌣_) -- 4.2 -- Lemma 14 Lem14 : ∀ {ℓ} {A : Type∙ ℓ} (n : ℕ) (f g : A →∙ K∙ n) → fst f ≡ fst g → f ≡ g Lem14 n f g p = Homogen.→∙Homogeneous≡ (Properties.isHomogeneousKn n) p -- Proposition 15 open ⌣Ring using (leftDistr-⌣ₖ ; rightDistr-⌣ₖ) -- Lemma 16 open ⌣Ring using (assocer-helpFun≡) -- Proposition 17 open ⌣Ring using (assoc-⌣ₖ) -- Proposition 18 open ⌣Comm using (gradedComm-⌣ₖ) -- Ring structure on ⌣ open ⌣Ring using (leftDistr-⌣ ; rightDistr-⌣ ; assoc-⌣ ; 1⌣ ; rUnit⌣ ; lUnit⌣ ; ⌣0 ; 0⌣) open ⌣Comm using (gradedComm-⌣) ----- 5. CHARACTERIZING ℤ-COHOMOLOGY GROUPS ----- -- 5.1 -- Proposition 19 open HⁿSⁿ using (Hⁿ-Sⁿ≅ℤ) -- 5.2 -- The torus open 𝕋² using (𝕋²) -- Propositions 20 and 21 respectively open HⁿT² using (H¹-T²≅ℤ×ℤ ; H²-T²≅ℤ) -- 5.3 -- The Klein bottle open 𝕂² using (𝕂²) -- The real projective plane open ℝP using (ℝP²) -- Proposition 22 and 23 respectively -- ℤ/2ℤ is represented by Bool with the unique group structure -- Lemma 23 is used implicitly in H²-𝕂²≅Bool open Hⁿ𝕂² using (H¹-𝕂²≅ℤ ; H²-𝕂²≅Bool) -- First and second cohomology groups of ℝP² respectively open HⁿℝP² using (H¹-RP²≅1 ; H²-RP²≅Bool) -- 5.4 -- The complex projective plane open HⁿℂP² using (ℂP²) -- Second and fourth cohomology groups ℂP² respectively open HⁿℂP² using (H²CP²≅ℤ ; H⁴CP²≅ℤ) -- 6 Proving by computations in Cubical Agda -- Proof of m = n = 1 case of graded commutativity (post truncation elimination): -- Uncomment and give it a minute. The proof is currently not running very fast. {- open ⌣Comm using (-ₖ^_·_ ) n=m=1 : (a b : S¹) → _⌣ₖ_ {n = 1} {m = 1} ∣ a ∣ ∣ b ∣ ≡ (-ₖ (_⌣ₖ_ {n = 1} {m = 1} ∣ b ∣ ∣ a ∣)) n=m=1 base base = refl n=m=1 base (loop i) k = -ₖ (Properties.Kn→ΩKn+10ₖ _ (~ k) i) n=m=1 (loop i) base k = Properties.Kn→ΩKn+10ₖ _ k i n=m=1 (loop i) (loop j) k = -- This hcomp is just a simple rewriting to get paths in Ω²K₂ hcomp (λ r → λ { (i = i0) → -ₖ Properties.Kn→ΩKn+10ₖ _ (~ k ∨ ~ r) j ; (i = i1) → -ₖ Properties.Kn→ΩKn+10ₖ _ (~ k ∨ ~ r) j ; (j = i0) → Properties.Kn→ΩKn+10ₖ _ (k ∨ ~ r) i ; (j = i1) → Properties.Kn→ΩKn+10ₖ _ (k ∨ ~ r) i ; (k = i0) → doubleCompPath-filler (sym (Properties.Kn→ΩKn+10ₖ _)) (λ j i → _⌣ₖ_ {n = 1} {m = 1} ∣ loop i ∣ ∣ loop j ∣) (Properties.Kn→ΩKn+10ₖ _) (~ r) j i ; (k = i1) → -ₖ doubleCompPath-filler (sym (Properties.Kn→ΩKn+10ₖ _)) (λ j i → _⌣ₖ_ {n = 1} {m = 1} ∣ loop i ∣ ∣ loop j ∣) (Properties.Kn→ΩKn+10ₖ _) (~ r) i j}) ((main ∙ sym (cong-∙∙ (cong (-ₖ_)) (sym (Properties.Kn→ΩKn+10ₖ _)) (λ j i → (_⌣ₖ_ {n = 1} {m = 1} ∣ loop i ∣ ∣ loop j ∣)) (Properties.Kn→ΩKn+10ₖ _))) k i j) where open import Cubical.Foundations.Equiv.HalfAdjoint t : Iso (typ ((Ω^ 2) (K∙ 2))) ℤ t = compIso (congIso (invIso (Properties.Iso-Kn-ΩKn+1 1))) (invIso (Properties.Iso-Kn-ΩKn+1 0)) p₁ = flipSquare ((sym (Properties.Kn→ΩKn+10ₖ _)) ∙∙ (λ j i → _⌣ₖ_ {n = 1} {m = 1} ∣ loop i ∣ ∣ loop j ∣) ∙∙ (Properties.Kn→ΩKn+10ₖ _)) p₂ = (cong (cong (-ₖ_)) ((sym (Properties.Kn→ΩKn+10ₖ _)))) ∙∙ (λ j i → -ₖ (_⌣ₖ_ {n = 1} {m = 1} ∣ loop i ∣ ∣ loop j ∣)) ∙∙ (cong (cong (-ₖ_)) (Properties.Kn→ΩKn+10ₖ _)) computation : Iso.fun t p₁ ≡ Iso.fun t p₂ computation = refl main : p₁ ≡ p₂ main = p₁ ≡⟨ sym (Iso.leftInv t p₁) ⟩ (Iso.inv t (Iso.fun t p₁)) ≡⟨ cong (Iso.inv t) computation ⟩ Iso.inv t (Iso.fun t p₂) ≡⟨ Iso.leftInv t p₂ ⟩ p₂ ∎ -} -- 𝕋² ≠ S² ∨ S¹ ∨ S¹ open HⁿT² using (T²≠S²⋁S¹⋁S¹) -- Second "Brunerie number" open HⁿℂP² using (g) brunerie2 : ℤ brunerie2 = g 1 ----- A. Proofs ----- -- A.2 Proofs for Section 4 -- Lemma 27 open Homogen using (→∙Homogeneous≡) -- Lemma 28 open Homogen using (isHomogeneous→∙) -- Lemma 29 open Properties using (isHomogeneousKn) -- Lemma 30, parts 1-3 respectively open Path using (sym≡flipSquare ; sym-cong-sym≡id ; sym≡cong-sym) -- Lemma 31 open ⌣Comm using (cong-ₖ-gen-inr) -- A.3 Proofs for Section 5 -- Proposition 32 open HⁿSⁿ using (Hⁿ-Sᵐ≅1) ----- B. THE EILENBERG-STEENROD AXIOMS ----- -- B.1 The axioms in HoTT/UF -- The axioms are defined as a record type open ES-axioms.coHomTheory -- Proof of the claim that the alternative reduced cohomology functor -- Ĥ is the same as the usual reduced cohomology functor _ : ∀ {ℓ} → satisfies-ES-axioms.H^~ {ℓ} ≡ satisfies-ES-axioms.Ĥ _ = satisfies-ES-axioms.coHomFunctor≡coHomFunctor' -- B.2 Verifying the axioms -- Propositions 35 and 36. _ : ∀ {ℓ} → ES-axioms.coHomTheory {ℓ} satisfies-ES-axioms.H^~ _ = satisfies-ES-axioms.isCohomTheoryZ -- B.3 Characterizing Z-cohomology groups using the axioms -- Theorem 37 open MayerVietoris.MV using ( Ker-i⊂Im-d ; Im-d⊂Ker-i ; Ker-Δ⊂Im-i ; Im-i⊂Ker-Δ ; Ker-d⊂Im-Δ ; Im-Δ⊂Ker-d) ----- C. BENCHMARKING COMPUTATIONS WITH THE COHOMOLOGY GROUPS ----- import Cubical.Experiments.ZCohomology.Benchmarks
{ "alphanum_fraction": 0.5860713448, "avg_line_length": 32.2192816635, "ext": "agda", "hexsha": "89b7c43c8fd6a1d23bf6a17921fd46867274339c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "707825882556937ebcf15a53eac63f0afc4d0cfe", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "XiaohuWang0921/cubical", "max_forks_repo_path": "Cubical/Papers/ZCohomology.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "707825882556937ebcf15a53eac63f0afc4d0cfe", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "XiaohuWang0921/cubical", "max_issues_repo_path": "Cubical/Papers/ZCohomology.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "707825882556937ebcf15a53eac63f0afc4d0cfe", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "XiaohuWang0921/cubical", "max_stars_repo_path": "Cubical/Papers/ZCohomology.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6419, "size": 17044 }
{-# OPTIONS --without-K #-} module tests.compileCoreLibrary where open import hott.core open import hott.core.theorems open import hott.topology open import hott.topology.theorems open import io.placeholder main : IO Unit main = dummyMain
{ "alphanum_fraction": 0.7925311203, "avg_line_length": 20.0833333333, "ext": "agda", "hexsha": "4c5344dbadfe36e3692eb31f322955cfceed4d77", "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": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_path": "agda/tests/compileCoreLibrary.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "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": "piyush-kurur/hott", "max_issues_repo_path": "agda/tests/compileCoreLibrary.agda", "max_line_length": 37, "max_stars_count": null, "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_path": "agda/tests/compileCoreLibrary.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 56, "size": 241 }
-- NBE for Gödel System T module NBE where module Prelude where -- Zero and One ----------------------------------------------------------- data Zero : Set where data One : Set where unit : One -- Natural numbers -------------------------------------------------------- data Nat : Set where zero : Nat suc : Nat -> Nat (+) : Nat -> Nat -> Nat zero + m = m suc n + m = suc (n + m) -- Props ------------------------------------------------------------------ data True : Prop where tt : True data False : Prop where postulate falseE : (A:Set) -> False -> A infix 3 /\ data (/\)(P Q:Prop) : Prop where andI : P -> Q -> P /\ Q module Fin where open Prelude -- Finite sets ------------------------------------------------------------ data Suc (A:Set) : Set where fzero_ : Suc A fsuc_ : A -> Suc A mutual data Fin (n:Nat) : Set where finI : Fin_ n -> Fin n Fin_ : Nat -> Set Fin_ zero = Zero Fin_ (suc n) = Suc (Fin n) fzero : {n:Nat} -> Fin (suc n) fzero = finI fzero_ fsuc : {n:Nat} -> Fin n -> Fin (suc n) fsuc i = finI (fsuc_ i) finE : {n:Nat} -> Fin n -> Fin_ n finE (finI i) = i module Vec where open Prelude open Fin infixr 15 :: -- Vectors ---------------------------------------------------------------- data Nil : Set where nil_ : Nil data Cons (A As:Set) : Set where cons_ : A -> As -> Cons A As mutual data Vec (A:Set)(n:Nat) : Set where vecI : Vec_ A n -> Vec A n Vec_ : Set -> Nat -> Set Vec_ A zero = Nil Vec_ A (suc n) = Cons A (Vec A n) nil : {A:Set} -> Vec A zero nil = vecI nil_ (::) : {A:Set} -> {n:Nat} -> A -> Vec A n -> Vec A (suc n) x :: xs = vecI (cons_ x xs) vecE : {A:Set} -> {n:Nat} -> Vec A n -> Vec_ A n vecE (vecI xs) = xs vec : {A:Set} -> (n:Nat) -> A -> Vec A n vec zero _ = nil vec (suc n) x = x :: vec n x map : {n:Nat} -> {A B:Set} -> (A -> B) -> Vec A n -> Vec B n map {zero} f (vecI nil_) = nil map {suc n} f (vecI (cons_ x xs)) = f x :: map f xs (!) : {n:Nat} -> {A:Set} -> Vec A n -> Fin n -> A (!) {suc n} (vecI (cons_ x _ )) (finI fzero_) = x (!) {suc n} (vecI (cons_ _ xs)) (finI (fsuc_ i)) = xs ! i tabulate : {n:Nat} -> {A:Set} -> (Fin n -> A) -> Vec A n tabulate {zero} f = nil tabulate {suc n} f = f fzero :: tabulate (\x -> f (fsuc x)) module Syntax where open Prelude open Fin -- Types ------------------------------------------------------------------ infixr 8 => data Type : Set where nat : Type (=>) : Type -> Type -> Type -- Terms ------------------------------------------------------------------ data Term (n:Nat) : Set where eZero : Term n eSuc : Term n eApp : Term n -> Term n -> Term n eLam : Term (suc n) -> Term n eVar : Fin n -> Term n module NormalForms where open Prelude open Syntax open Fin mutual -- Normal terms ----------------------------------------------------------- data Normal (n:Nat) : Set where nZero : Normal n nSuc : Normal n -> Normal n nLam : Normal (suc n) -> Normal n nNeutral : Neutral n -> Normal n nStuck : Normal n -- type error -- Neutral terms ---------------------------------------------------------- data Neutral (n:Nat) : Set where uVar : Fin n -> Neutral n uApp : Neutral n -> Normal n -> Neutral n nVar : {n:Nat} -> Fin n -> Normal n nVar i = nNeutral (uVar i) nApp : {n:Nat} -> Neutral n -> Normal n -> Normal n nApp u n = nNeutral (uApp u n) module Rename where open Prelude open Fin open Vec open NormalForms -- Renamings -------------------------------------------------------------- Ren : Nat -> Nat -> Set Ren m n = Vec (Fin n) m id : {n:Nat} -> Ren n n id = tabulate (\i -> i) compose : {l m n:Nat} -> Ren m n -> Ren l m -> Ren l n compose {l}{m}{n} ρ γ = map (\i -> ρ ! i) γ lift : {m n:Nat} -> Ren m n -> Ren (suc m) (suc n) lift ρ = fzero :: map fsuc ρ mutual rename : {m n:Nat} -> Ren m n -> Normal m -> Normal n rename ρ nZero = nZero rename ρ (nSuc n) = nSuc (rename ρ n) rename ρ (nLam n) = nLam (rename (lift ρ) n) rename ρ (nNeutral u) = nNeutral (renameNe ρ u) rename ρ nStuck = nStuck renameNe : {m n:Nat} -> Ren m n -> Neutral m -> Neutral n renameNe ρ (uVar i) = uVar (ρ ! i) renameNe ρ (uApp u n) = uApp (renameNe ρ u) (rename ρ n) up : {n:Nat} -> Ren n (suc n) up = map fsuc id module Subst where open Prelude open Fin open Vec open NormalForms open Rename using (Ren; rename; up) -- Substitutions ---------------------------------------------------------- Sub : Nat -> Nat -> Set Sub m n = Vec (Normal n) m id : {n:Nat} -> Sub n n id = tabulate nVar ren2sub : {m n:Nat} -> Ren m n -> Sub m n ren2sub ρ = map nVar ρ lift : {m n:Nat} -> Sub m n -> Sub (suc m) (suc n) lift σ = nVar fzero :: map (rename up) σ mutual app : {n:Nat} -> Normal n -> Normal n -> Normal n app nZero _ = nStuck app (nSuc _) _ = nStuck app nStuck _ = nStuck app (nLam u) v = subst (v :: id) u app (nNeutral n) v = nApp n v subst : {m n:Nat} -> Sub m n -> Normal m -> Normal n subst σ nZero = nZero subst σ (nSuc v) = nSuc (subst σ v) subst σ (nLam v) = nLam (subst (lift σ) v) subst σ (nNeutral n) = substNe σ n subst σ nStuck = nStuck substNe : {m n:Nat} -> Sub m n -> Neutral m -> Normal n substNe σ (uVar i) = σ ! i substNe σ (uApp n v) = substNe σ n `app` subst σ v compose : {l m n:Nat} -> Sub m n -> Sub l m -> Sub l n compose σ δ = map (subst σ) δ module TypeSystem where open Prelude open Fin open Vec open Syntax mutual EqType : Type -> Type -> Prop EqType nat nat = True EqType (τ => τ') (σ => σ') = τ == σ /\ τ' == σ' EqType _ _ = False infix 5 == data (==) (τ0 τ1:Type) : Prop where eqTypeI : EqType τ0 τ1 -> τ0 == τ1 eqSubst : {σ τ:Type} -> (C:Type -> Set) -> σ == τ -> C τ -> C σ eqSubst {nat}{nat} C _ x = x eqSubst {σ => τ}{σ' => τ'} C (eqTypeI (andI eqσ eqτ)) x = eqSubst (\μ -> C (μ => τ)) eqσ ( eqSubst (\η -> C (σ' => η)) eqτ x ) Context : Nat -> Set Context n = Vec Type n mutual HasType : {n:Nat} -> Context n -> Term n -> Type -> Set HasType Γ eZero τ = ZeroType Γ τ HasType Γ eSuc τ = SucType Γ τ HasType Γ (eVar i) τ = VarType Γ i τ HasType Γ (eApp e1 e2) τ = AppType Γ e1 e2 τ HasType Γ (eLam e) τ = LamType Γ e τ data ZeroType {n:Nat}(Γ:Context n)(τ:Type) : Set where zeroType : τ == nat -> HasType Γ eZero τ data SucType {n:Nat}(Γ:Context n)(τ:Type) : Set where sucType : τ == (nat => nat) -> HasType Γ eSuc τ data VarType {n:Nat}(Γ:Context n)(i:Fin n)(τ:Type) : Set where varType : τ == (Γ ! i) -> HasType Γ (eVar i) τ data AppType {n:Nat}(Γ:Context n)(e1 e2:Term n)(τ:Type) : Set where appType : (σ:Type) -> HasType Γ e1 (σ => τ) -> HasType Γ e2 σ -> HasType Γ (eApp e1 e2) τ data LamType {n:Nat}(Γ:Context n)(e:Term (suc n))(τ:Type) : Set where lamType : (τ0 τ1:Type) -> τ == (τ0 => τ1) -> HasType (τ0 :: Γ) e τ1 -> HasType Γ (eLam e) τ module NBE where open Prelude open Syntax open Fin open Vec open TypeSystem mutual D_ : Nat -> Type -> Set D_ n nat = NatD n D_ n (σ => τ) = FunD n σ τ data D (n:Nat)(τ:Type) : Set where dI : D_ n τ -> D n τ data NatD (n:Nat) : Set where zeroD_ : D_ n nat sucD_ : D n nat -> D_ n nat neD_ : Term n -> D_ n nat -- Will this pass the positivity check? data FunD (n:Nat)(σ τ:Type) : Set where lamD_ : (D n σ -> D n τ) -> D_ n (σ => τ) zeroD : {n:Nat} -> D n nat zeroD = dI zeroD_ sucD : {n:Nat} -> D n nat -> D n nat sucD d = dI (sucD_ d) neD : {n:Nat} -> Term n -> D n nat neD t = dI (neD_ t) lamD : {n:Nat} -> {σ τ:Type} -> (D n σ -> D n τ) -> D n (σ => τ) lamD f = dI (lamD_ f) coerce : {n:Nat} -> {τ0 τ1:Type} -> τ0 == τ1 -> D n τ1 -> D n τ0 coerce {n} = eqSubst (D n) mutual down : {τ:Type} -> {n:Nat} -> D n τ -> Term n down {σ => τ} (dI (lamD_ f)) = eLam (down {τ} ?) -- doesn't work! down {nat} (dI zeroD_) = eZero down {nat} (dI (sucD_ d)) = eSuc `eApp` down d down {nat} (dI (neD_ t)) = t up : {n:Nat} -> (τ:Type) -> Term n -> D n τ up (σ => τ) t = lamD (\d -> up τ (t `eApp` down d)) up nat t = neD t Valuation : {m:Nat} -> Nat -> Context m -> Set Valuation {zero} n _ = Nil Valuation {suc m} n (vecI (cons_ τ Γ)) = Cons (D n τ) (Valuation n Γ) (!!) : {m n:Nat} -> {Γ:Context m} -> Valuation n Γ -> (i:Fin m) -> D n (Γ ! i) (!!) {suc _} {_} {vecI (cons_ _ _)} (cons_ v ξ) (finI fzero_) = v (!!) {suc _} {_} {vecI (cons_ _ _)} (cons_ v ξ) (finI (fsuc_ i)) = ξ !! i ext : {m n:Nat} -> {τ:Type} -> {Γ:Context m} -> Valuation n Γ -> D n τ -> Valuation n (τ :: Γ) ext ξ v = cons_ v ξ app : {σ τ:Type} -> {n:Nat} -> D n (σ => τ) -> D n σ -> D n τ --app (dI (lamD_ f)) d = f d app (lamD f) d = f d eval : {n:Nat} -> {Γ:Context n} -> (e:Term n) -> (τ:Type) -> HasType Γ e τ -> Valuation n Γ -> D n τ eval (eVar i) τ (varType eq) ξ = coerce eq (ξ !! i) eval (eApp r s) τ (appType σ dr ds) ξ = eval r (σ => τ) dr ξ `app` eval s σ ds ξ eval (eLam r) τ (lamType τ0 τ1 eq dr) ξ = coerce eq (lamD (\d -> ?)) -- doesn't work either eval eZero τ (zeroType eq) ξ = coerce eq zeroD eval eSuc τ (sucType eq) ξ = coerce eq (lamD sucD) module Eval where open Prelude open Fin open Vec open Syntax open NormalForms open Rename using (up; rename) open Subst open TypeSystem eval : {n:Nat} -> (Γ:Context n) -> (e:Term n) -> (τ:Type) -> HasType Γ e τ -> Normal n eval Γ eZero τ _ = nZero eval Γ eSuc τ _ = nLam (nSuc (nVar fzero)) eval Γ (eVar i) τ _ = nVar i eval Γ (eApp e1 e2) τ (appType σ d1 d2) = eval Γ e1 (σ => τ) d1 `app` eval Γ e2 σ d2 eval Γ (eLam e) τ (lamType τ0 τ1 _ d) = nLam (eval (τ0 :: Γ) e τ1 d) open Prelude open Fin open Vec open Syntax
{ "alphanum_fraction": 0.4896096329, "avg_line_length": 25.8743718593, "ext": "agda", "hexsha": "7f2012cdca2b7882dc725d0624648ccf4e2908db", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/NBE.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/NBE.agda", "max_line_length": 102, "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/NBE.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": 3875, "size": 10298 }
{-# OPTIONS --without-K #-} open import M-types.Base.Core open import M-types.Base.Sum open import M-types.Base.Prod open import M-types.Base.Eq module M-types.Base.Equi where Qinv : {X : Ty ℓ₀} {Y : Ty ℓ₁} → ∏[ f ∈ (X → Y)] Ty (ℓ-max ℓ₀ ℓ₁) Qinv {_} {_} {X} {Y} f = ∑[ g ∈ (Y → X) ] (∏[ x ∈ X ] g (f x) ≡ x) × (∏[ y ∈ Y ] f (g y) ≡ y) IsEqui : {X : Ty ℓ₀} {Y : Ty ℓ₁} → ∏[ f ∈ (X → Y) ] Ty (ℓ-max ℓ₀ ℓ₁) IsEqui {_} {_} {X} {Y} f = (∑[ g ∈ (Y → X) ] ∏[ x ∈ X ] g (f x) ≡ x) × (∑[ g ∈ (Y → X) ] ∏[ y ∈ Y ] f (g y) ≡ y) infixr 8 _≃_ _≃_ : ∏[ X ∈ Ty ℓ₀ ] ∏[ Y ∈ Ty ℓ₁ ] Ty (ℓ-max ℓ₀ ℓ₁) X ≃ Y = ∑[ f ∈ (X → Y) ] IsEqui f Qinv→IsEqui : {X : Ty ℓ₀} {Y : Ty ℓ₁} {f : X → Y} → Qinv f → IsEqui f Qinv→IsEqui (g , hom₀ , hom₁) = ((g , hom₀) , (g , hom₁)) IsEqui→Qinv : {X : Ty ℓ₀} {Y : Ty ℓ₁} {f : X → Y} → IsEqui f → Qinv f IsEqui→Qinv {_} {_} {_} {_} {f} ((g₀ , hom₀) , (g₁ , hom₁)) = ( g₀ , hom₀ , λ y → ap f (ap g₀ (hom₁ y)⁻¹ · hom₀ (g₁ y)) · hom₁ y ) inv : {X : Ty ℓ₀} {Y : Ty ℓ₁} → ∏[ equi ∈ X ≃ Y ] (Y → X) inv (fun , isEqui) = pr₀ (IsEqui→Qinv isEqui) hom₀ : {X : Ty ℓ₀} {Y : Ty ℓ₁} → ∏[ equi ∈ X ≃ Y ] ∏[ x ∈ X ] inv equi (fun equi x) ≡ x hom₀ (fun , isEqui) = pr₀ (pr₁ (IsEqui→Qinv isEqui)) hom₁ : {X : Ty ℓ₀} {Y : Ty ℓ₁} → ∏[ equi ∈ X ≃ Y ] ∏[ y ∈ Y ] fun equi (inv equi y) ≡ y hom₁ (fun , isEqui) = pr₁ (pr₁ (IsEqui→Qinv isEqui))
{ "alphanum_fraction": 0.4131274131, "avg_line_length": 29.320754717, "ext": "agda", "hexsha": "2e43e1a375be7de453cce857b8f8936ce2732597", "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": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DDOtten/M-types", "max_forks_repo_path": "Base/Equi.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369", "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": "DDOtten/M-types", "max_issues_repo_path": "Base/Equi.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "5b70f4b3dc3e50365ad7a3a80b0cd14efbfa4369", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DDOtten/M-types", "max_stars_repo_path": "Base/Equi.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 758, "size": 1554 }
{-# OPTIONS --safe #-} module Cubical.HITs.James where open import Cubical.HITs.James.Base public open import Cubical.HITs.James.Properties public
{ "alphanum_fraction": 0.7837837838, "avg_line_length": 24.6666666667, "ext": "agda", "hexsha": "1722cf49261ac98ef2b56048ab10d5a71bf03ba3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/HITs/James.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/HITs/James.agda", "max_line_length": 48, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/James.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": 39, "size": 148 }
{-# OPTIONS --allow-unsolved-metas #-} module _ where open import Agda.Primitive open import Agda.Builtin.Nat module Test₁ where record ⊤ {a} : Set a where constructor tt data G : (A : Set) → ⊤ {_} → Set where d : (x : ⊤) → G ⊤ x test : (g : G ⊤ tt) → Set test (d x) = ⊤ module Test₂ where postulate A : Set a : A record R {a} : Set a where constructor mkR field x : A data G : (A : Set) → R {_} → Set where d : (x : R) → G R x test : (g : G R (mkR a)) → R test (d x) = x module Test₃ where postulate A : Set a : A record R {a} : Set a where constructor mkR field x y : A data G : (A : Set) → R {_} → Set where d : (x : R) → G R x -- Forced: mkR x y test₁ : ∀ x y → (g : G R (mkR x y)) → Set test₁ x y (d (mkR x y)) = A -- .(mkR x y) turns into z with x = .(R.x z) and y = .(R.y z) test₂ : ∀ x y → (g : G R (mkR x y)) → Set test₂ x y (d .(mkR x y)) = A test₃ : ∀ x y → (g : G R (mkR x y)) → Set test₃ .(R.x z) .(R.y z) (d z) = A
{ "alphanum_fraction": 0.4923224568, "avg_line_length": 18.9454545455, "ext": "agda", "hexsha": "ce675b80ccbcb81ecafd50282e61d10f9c08f463", "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/Issue2888.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/Issue2888.agda", "max_line_length": 63, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2888.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": 435, "size": 1042 }