Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --without-K --rewriting #-} open import HoTT module homotopy.WedgeOfCircles {i} where WedgeOfCircles : (I : Type i) → Type i WedgeOfCircles I = BigWedge {A = I} (λ _ → ⊙S¹)
{ "alphanum_fraction": 0.6666666667, "avg_line_length": 18.9, "ext": "agda", "hexsha": "2e705f2ce5f803a42f0900bb37b34d0ca3642ed6", "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": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/WedgeOfCircles.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "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": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/WedgeOfCircles.agda", "max_line_length": 47, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/WedgeOfCircles.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 68, "size": 189 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Groups.Homomorphisms.Definition open import Groups.Definition open import Setoids.Setoids open import Sets.EquivalenceRelations open import Rings.Definition open import Lists.Lists open import Rings.Homomorphisms.Definition module Rings.Polynomial.Evaluation {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) where open Ring R open Setoid S open Equivalence eq open Group additiveGroup open import Groups.Polynomials.Definition additiveGroup open import Groups.Polynomials.Addition additiveGroup open import Rings.Polynomial.Ring R open import Rings.Polynomial.Multiplication R inducedFunction : NaivePoly → A → A inducedFunction [] a = 0R inducedFunction (x :: p) a = x + (a * inducedFunction p a) inducedFunctionMult : (as : NaivePoly) (b c : A) → inducedFunction (map (_*_ b) as) c ∼ (inducedFunction as c) * b inducedFunctionMult [] b c = symmetric (transitive *Commutative timesZero) inducedFunctionMult (x :: as) b c = transitive (transitive (+WellDefined reflexive (transitive (transitive (*WellDefined reflexive (inducedFunctionMult as b c)) *Associative) *Commutative)) (symmetric *DistributesOver+)) *Commutative inducedFunctionWellDefined : {a b : NaivePoly} → polysEqual a b → (c : A) → inducedFunction a c ∼ inducedFunction b c inducedFunctionWellDefined {[]} {[]} a=b c = reflexive inducedFunctionWellDefined {[]} {x :: b} (fst ,, snd) c = symmetric (transitive (+WellDefined fst (transitive (*WellDefined reflexive (symmetric (inducedFunctionWellDefined {[]} {b} snd c))) (timesZero {c}))) identRight) inducedFunctionWellDefined {a :: as} {[]} (fst ,, snd) c = transitive (+WellDefined fst reflexive) (transitive identLeft (transitive (*WellDefined reflexive (inducedFunctionWellDefined {as} {[]} snd c)) (timesZero {c}))) inducedFunctionWellDefined {a :: as} {b :: bs} (fst ,, snd) c = +WellDefined fst (*WellDefined reflexive (inducedFunctionWellDefined {as} {bs} snd c)) inducedFunctionGroupHom : {x y : NaivePoly} → (a : A) → inducedFunction (x +P y) a ∼ (inducedFunction x a + inducedFunction y a) inducedFunctionGroupHom {[]} {[]} a = symmetric identLeft inducedFunctionGroupHom {[]} {x :: y} a rewrite mapId y = symmetric identLeft inducedFunctionGroupHom {x :: xs} {[]} a rewrite mapId xs = symmetric identRight inducedFunctionGroupHom {x :: xs} {y :: ys} a = transitive (symmetric +Associative) (transitive (+WellDefined reflexive (transitive (transitive (+WellDefined reflexive (transitive (*WellDefined reflexive (transitive (inducedFunctionGroupHom {xs} {ys} a) groupIsAbelian)) *DistributesOver+)) +Associative) groupIsAbelian)) +Associative) inducedFunctionRingHom : (r s : NaivePoly) (a : A) → inducedFunction (r *P s) a ∼ (inducedFunction r a * inducedFunction s a) inducedFunctionRingHom [] s a = symmetric (transitive *Commutative timesZero) inducedFunctionRingHom (x :: xs) [] a = symmetric timesZero inducedFunctionRingHom (b :: bs) (c :: cs) a = transitive (+WellDefined reflexive (*WellDefined reflexive (inducedFunctionGroupHom {map (_*_ b) cs +P map (_*_ c) bs} {0G :: (bs *P cs)} a))) (transitive (+WellDefined reflexive (*WellDefined reflexive (+WellDefined (inducedFunctionGroupHom {map (_*_ b) cs} {map (_*_ c) bs} a) identLeft))) (transitive (transitive (transitive (+WellDefined reflexive (transitive (transitive (transitive (*WellDefined reflexive (transitive (+WellDefined (transitive groupIsAbelian (+WellDefined (inducedFunctionMult bs c a) (inducedFunctionMult cs b a))) (transitive (transitive (*WellDefined reflexive (transitive (inducedFunctionRingHom bs cs a) *Commutative)) *Associative) *Commutative)) (symmetric +Associative))) *DistributesOver+) (+WellDefined reflexive *DistributesOver+)) (+WellDefined *Associative (+WellDefined (transitive *Associative *Commutative) *Associative)))) +Associative) (+WellDefined (symmetric *DistributesOver+') (symmetric *DistributesOver+'))) (symmetric *DistributesOver+))) inducedFunctionIsHom : (a : A) → RingHom polyRing R (λ p → inducedFunction p a) RingHom.preserves1 (inducedFunctionIsHom a) = transitive (+WellDefined reflexive (timesZero {a})) identRight RingHom.ringHom (inducedFunctionIsHom a) {r} {s} = inducedFunctionRingHom r s a GroupHom.groupHom (RingHom.groupHom (inducedFunctionIsHom a)) {x} {y} = inducedFunctionGroupHom {x} {y} a GroupHom.wellDefined (RingHom.groupHom (inducedFunctionIsHom a)) x=y = inducedFunctionWellDefined x=y a
{ "alphanum_fraction": 0.7527864467, "avg_line_length": 84.641509434, "ext": "agda", "hexsha": "3353c4836432f95f9e9997b76152b1a3aa1ac4fe", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Rings/Polynomial/Evaluation.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Rings/Polynomial/Evaluation.agda", "max_line_length": 1033, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Rings/Polynomial/Evaluation.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": 1297, "size": 4486 }
module MLib.Fin.Parts.Core where open import MLib.Prelude open Nat using (_*_; _+_; _<_) open Table record Parts {a} (A : Set a) (size : A → ℕ) : Set a where field numParts : ℕ parts : Table A numParts partAt = lookup parts sizeAt = size ∘ partAt totalSize = sum (map size parts) partsizes = tabulate sizeAt constParts : ℕ → ℕ → Parts ℕ id constParts numParts partsize = record { numParts = numParts ; parts = replicate partsize }
{ "alphanum_fraction": 0.6739130435, "avg_line_length": 20, "ext": "agda", "hexsha": "3b0b4ffaa7eb38f61d6ed3e6b038cb69814a1258", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bch29/agda-matrices", "max_forks_repo_path": "src/MLib/Fin/Parts/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bch29/agda-matrices", "max_issues_repo_path": "src/MLib/Fin/Parts/Core.agda", "max_line_length": 57, "max_stars_count": null, "max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bch29/agda-matrices", "max_stars_repo_path": "src/MLib/Fin/Parts/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 146, "size": 460 }
{-# OPTIONS --cubical --safe #-} module Data.Ternary where open import Prelude open import Relation.Nullary.Discrete.FromBoolean infixl 5 _,0 _,1 _,2 data Tri : Type where 0t : Tri _,0 _,1 _,2 : Tri → Tri infix 4 _≡ᴮ_ _≡ᴮ_ : Tri → Tri → Bool 0t ≡ᴮ 0t = true x ,0 ≡ᴮ y ,0 = x ≡ᴮ y x ,1 ≡ᴮ y ,1 = x ≡ᴮ y x ,2 ≡ᴮ y ,2 = x ≡ᴮ y _ ≡ᴮ _ = false sound : ∀ x y → T (x ≡ᴮ y) → x ≡ y sound 0t 0t p = refl sound (x ,0) (y ,0) p = cong _,0 (sound x y p) sound (x ,1) (y ,1) p = cong _,1 (sound x y p) sound (x ,2) (y ,2) p = cong _,2 (sound x y p) complete : ∀ x → T (x ≡ᴮ x) complete 0t = tt complete (x ,0) = complete x complete (x ,1) = complete x complete (x ,2) = complete x _≟_ : (x y : Tri) → Dec (x ≡ y) _≟_ = from-bool-eq _≡ᴮ_ sound complete
{ "alphanum_fraction": 0.5611979167, "avg_line_length": 21.9428571429, "ext": "agda", "hexsha": "2d9ae6beb4b9b2b5aa2ce2a5adb8a4c016d00b6b", "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/Ternary.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/Ternary.agda", "max_line_length": 49, "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/Ternary.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": 371, "size": 768 }
module Sublist where open import Data.List open import Data.List.All open import Data.List.Any open import Level open import Relation.Binary.PropositionalEquality hiding ([_]) open import Function open import Category.Monad open import Data.Product open import Membership-equality hiding (_⊆_; set) infix 3 _⊆_ -- Sublist without re-ordering, to be improved later... data _⊆_ {a}{A : Set a} : List A → List A → Set a where [] : ∀ {ys} → [] ⊆ ys keep : ∀ {x xs ys} → xs ⊆ ys → x ∷ xs ⊆ x ∷ ys skip : ∀ {x xs ys} → xs ⊆ ys → xs ⊆ x ∷ ys singleton-⊆ : ∀ {a} {A : Set a} {x : A} {xs : List A} → x ∈ xs → [ x ] ⊆ xs singleton-⊆ (here refl) = keep [] singleton-⊆ (there mem) = skip (singleton-⊆ mem) reflexive-⊆ : ∀ {a} {A : Set a} {xs : List A} → xs ⊆ xs reflexive-⊆ {xs = []} = [] reflexive-⊆ {xs = x ∷ xs} = keep reflexive-⊆ All-⊆ : ∀ {a p} {A : Set a} {P : A → Set p} {xs ys} → xs ⊆ ys → All P ys → All P xs All-⊆ [] al = [] All-⊆ (keep inc) (px ∷ al) = px ∷ All-⊆ inc al All-⊆ (skip inc) (px ∷ al) = All-⊆ inc al
{ "alphanum_fraction": 0.5856031128, "avg_line_length": 30.2352941176, "ext": "agda", "hexsha": "f2acb32dd86d9ffa6feee4c94d72a32330eb22c3", "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": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Zalastax/singly-typed-actors", "max_forks_repo_path": "unused/Sublist.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "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": "Zalastax/singly-typed-actors", "max_issues_repo_path": "unused/Sublist.agda", "max_line_length": 83, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Zalastax/thesis", "max_stars_repo_path": "unused/Sublist.agda", "max_stars_repo_stars_event_max_datetime": "2018-02-02T16:44:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-02-02T16:44:43.000Z", "num_tokens": 417, "size": 1028 }
{- This file contains: - The reduced version gives the same type as James. -} {-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.HITs.James.Inductive.ColimitEquivalence where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Pointed open import Cubical.HITs.James.Base renaming (James to JamesConstruction) open import Cubical.HITs.James.Inductive.Reduced renaming (𝕁Red to 𝕁RedConstruction ; 𝕁Red∞ to 𝕁amesConstruction) open import Cubical.HITs.James.Inductive.Coherence private variable ℓ : Level module _ ((X , x₀) : Pointed ℓ) where private James = JamesConstruction (X , x₀) 𝕁ames = 𝕁amesConstruction (X , x₀) 𝕁Red = 𝕁RedConstruction (X , x₀) -- Mimicking the constructors in each other unit' : (x : X)(xs : James) → Path James (x₀ ∷ x ∷ xs) (x ∷ x₀ ∷ xs) unit' x xs = sym (unit (x ∷ xs)) ∙∙ refl ∙∙ (λ i → x ∷ unit xs i) coh' : (xs : James) → refl ≡ unit' x₀ xs coh' xs i j = coh-helper {A = James} (unit xs) (unit (x₀ ∷ xs)) (λ i → x₀ ∷ unit xs i) (λ i j → unit (unit xs j) i) i j _∷∞_ : X → 𝕁ames → 𝕁ames _∷∞_ x (inl xs) = inl (x ∷ xs) _∷∞_ x (push xs i) = (push (x ∷ xs) ∙ (λ i → inl (unit x xs i))) i push∞ : (xs : 𝕁ames) → xs ≡ x₀ ∷∞ xs push∞ (inl xs) = push xs push∞ (push xs i) j = push-helper {A = 𝕁ames} (push xs) (push (x₀ ∷ xs)) (λ i → inl (unit x₀ xs i)) (λ i j → inl (coh xs i j)) j i infixr 5 _∷∞_ -- One side map 𝕁→James-inl : 𝕁Red → James 𝕁→James-inl [] = [] 𝕁→James-inl (x ∷ xs) = x ∷ 𝕁→James-inl xs 𝕁→James-inl (unit x xs i) = unit' x (𝕁→James-inl xs) i 𝕁→James-inl (coh xs i j) = coh' (𝕁→James-inl xs) i j 𝕁→James : 𝕁ames → James 𝕁→James (inl xs) = 𝕁→James-inl xs 𝕁→James (push xs i) = unit (𝕁→James-inl xs) i -- Commutativity with pseudo-constructors 𝕁→James-∷ : (x : X)(xs : 𝕁ames) → 𝕁→James (x ∷∞ xs) ≡ x ∷ 𝕁→James xs 𝕁→James-∷ x (inl xs) = refl 𝕁→James-∷ x (push xs i) j = comp-cong-helper 𝕁→James (push (x ∷ xs)) _ (λ i → inl (unit x xs i)) refl j i 𝕁→James-push : (xs : 𝕁ames) → PathP (λ i → 𝕁→James xs ≡ 𝕁→James-∷ x₀ xs i) (cong 𝕁→James (push∞ xs)) (unit (𝕁→James xs)) 𝕁→James-push (inl xs) = refl 𝕁→James-push (push xs i) j k = hcomp (λ l → λ { (i = i0) → unit (𝕁→James-inl xs) k ; (i = i1) → unit (x₀ ∷ 𝕁→James-inl xs) k ; (j = i0) → push-helper-cong 𝕁→James (push xs) (push (x₀ ∷ xs)) (λ i → inl (unit x₀ xs i)) (λ i j → inl (coh xs i j)) k i (~ l) ; (j = i1) → unit (unit (𝕁→James-inl xs) i) k ; (k = i0) → unit (𝕁→James-inl xs) i ; (k = i1) → comp-cong-helper-filler 𝕁→James (push (x₀ ∷ xs)) _ (λ i → inl (unit x₀ xs i)) refl j i l }) (push-coh-helper _ _ _ (λ i j → unit (unit (𝕁→James-inl xs) j) i) k i j) -- The other-side map private push-square : (x : X)(xs : 𝕁Red) → sym (push (x ∷ xs)) ∙∙ refl ∙∙ (λ i → x ∷∞ push xs i) ≡ (λ i → inl (unit x xs i)) push-square x xs i j = push-square-helper (push (x ∷ xs)) (λ i → inl (unit x xs i)) i j coh-cube : (xs : 𝕁Red) → SquareP (λ i j → coh-helper _ _ _ (λ i j → push∞ (push xs j) i) i j ≡ inl (coh xs i j)) (λ i j → inl (x₀ ∷ x₀ ∷ xs)) (λ i j → push-square-helper (push (x₀ ∷ xs)) (λ i → inl (unit x₀ xs i)) j i) (λ i j → inl (x₀ ∷ x₀ ∷ xs)) (λ i j → inl (x₀ ∷ x₀ ∷ xs)) coh-cube xs = coh-cube-helper {A = 𝕁ames} (push xs) (push (x₀ ∷ xs)) (λ i → inl (unit x₀ xs i)) (λ i j → inl (coh xs i j)) J→𝕁ames : James → 𝕁ames J→𝕁ames [] = inl [] J→𝕁ames (x ∷ xs) = x ∷∞ (J→𝕁ames xs) J→𝕁ames (unit xs i) = push∞ (J→𝕁ames xs) i -- The following is the most complicated part. -- It seems horrible but mainly it's due to correction of boudaries. 𝕁→J→𝕁ames-inl : (xs : 𝕁Red) → J→𝕁ames (𝕁→James (inl xs)) ≡ inl xs 𝕁→J→𝕁ames-inl [] = refl 𝕁→J→𝕁ames-inl (x ∷ xs) t = x ∷∞ 𝕁→J→𝕁ames-inl xs t 𝕁→J→𝕁ames-inl (unit x xs i) j = hcomp (λ k → λ { (i = i0) → square-helper (j ∨ ~ k) i0 ; (i = i1) → square-helper (j ∨ ~ k) i1 ; (j = i0) → square-helper (~ k) i ; (j = i1) → inl (unit x xs i) }) (push-square x xs j i) where square-helper : (i j : I) → 𝕁ames square-helper i j = doubleCompPath-cong-filler J→𝕁ames (sym (unit (x ∷ 𝕁→James-inl xs))) refl (λ i → x ∷ unit (𝕁→James-inl xs) i) (λ i j → push∞ (x ∷∞ 𝕁→J→𝕁ames-inl xs i) (~ j)) (λ i j → x ∷∞ 𝕁→J→𝕁ames-inl xs i) (λ i j → x ∷∞ push∞ (𝕁→J→𝕁ames-inl xs i) j) i j i1 𝕁→J→𝕁ames-inl (coh xs i j) k = hcomp (λ l → λ { (i = i0) → cube-helper i0 j (k ∨ ~ l) ; (i = i1) → inl-filler j k l ; (j = i0) → cube-helper i i0 (k ∨ ~ l) ; (j = i1) → cube-helper i i1 (k ∨ ~ l) ; (k = i0) → cube-helper i j (~ l) ; (k = i1) → inl (coh xs i j) }) (coh-cube xs i j k) where cube-helper : (i j k : I) → 𝕁ames cube-helper i j k = coh-helper-cong J→𝕁ames _ _ _ (λ i j → unit (unit (𝕁→James-inl xs) j) i) (λ i j k → push∞ (push∞ (𝕁→J→𝕁ames-inl xs k) j) i) i j k inl-filler : (i j k : I) → 𝕁ames inl-filler i j k = hfill (λ k → λ { (i = i0) → square-helper (j ∨ ~ k) i0 ; (i = i1) → square-helper (j ∨ ~ k) i1 ; (j = i0) → square-helper (~ k) i ; (j = i1) → inl (unit x₀ xs i) }) (inS (push-square x₀ xs j i)) k where square-helper : (i j : I) → 𝕁ames square-helper i j = doubleCompPath-cong-filler J→𝕁ames (sym (unit (x₀ ∷ 𝕁→James-inl xs))) refl (λ i → x₀ ∷ unit (𝕁→James-inl xs) i) (λ i j → push∞ (x₀ ∷∞ 𝕁→J→𝕁ames-inl xs i) (~ j)) (λ i j → x₀ ∷∞ 𝕁→J→𝕁ames-inl xs i) (λ i j → x₀ ∷∞ push∞ (𝕁→J→𝕁ames-inl xs i) j) i j i1 -- The main equivalence 𝕁→J→𝕁ames : (xs : 𝕁ames) → J→𝕁ames (𝕁→James xs) ≡ xs 𝕁→J→𝕁ames (inl xs) = 𝕁→J→𝕁ames-inl xs 𝕁→J→𝕁ames (push xs i) j = push∞ (𝕁→J→𝕁ames-inl xs j) i J→𝕁→James : (xs : James) → 𝕁→James (J→𝕁ames xs) ≡ xs J→𝕁→James [] = refl J→𝕁→James (x ∷ xs) = 𝕁→James-∷ x (J→𝕁ames xs) ∙ (λ i → x ∷ J→𝕁→James xs i) J→𝕁→James (unit xs i) j = hcomp (λ k → λ { (i = i0) → J→𝕁→James xs (j ∧ k) ; (i = i1) → compPath-filler (𝕁→James-∷ x₀ (J→𝕁ames xs)) (λ i → x₀ ∷ J→𝕁→James xs i) k j ; (j = i0) → 𝕁→James (J→𝕁ames (unit xs i)) ; (j = i1) → unit (J→𝕁→James xs k) i }) (𝕁→James-push (J→𝕁ames xs) j i) James≃𝕁Red∞ : James ≃ 𝕁ames James≃𝕁Red∞ = isoToEquiv (iso J→𝕁ames 𝕁→James 𝕁→J→𝕁ames J→𝕁→James)
{ "alphanum_fraction": 0.5225507766, "avg_line_length": 35.807486631, "ext": "agda", "hexsha": "68f359c1db417e4b398fbd5369c7c908463ba962", "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/Inductive/ColimitEquivalence.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/Inductive/ColimitEquivalence.agda", "max_line_length": 107, "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/Inductive/ColimitEquivalence.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": 3085, "size": 6696 }
-- 2017-06-16, reported by Ambrus Kaposi on the Agda mailing list -- WAS: -- β is not a legal rewrite rule, since the left-hand side -- f a reduces to f a -- when checking the pragma REWRITE β -- SHOULD: succeed {-# OPTIONS --rewriting #-} module _ where module a where postulate _~_ : {A : Set} → A → A → Set {-# BUILTIN REWRITE _~_ #-} module m1 (X : Set) where postulate A B : Set a : A b : B f : A → B module m2 (X : Set) where open m1 X postulate β : f a ~ b {-# REWRITE β #-} postulate refl : {A : Set}{a : A} → a ~ a p : f a ~ b p = refl
{ "alphanum_fraction": 0.5638474295, "avg_line_length": 14.023255814, "ext": "agda", "hexsha": "8b59ae6ca94d694c5fbc27a55ad1ad3b0d2bbac4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/Issue2606.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/Issue2606.agda", "max_line_length": 65, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/Issue2606.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 216, "size": 603 }
{-# OPTIONS --show-implicit #-} module Substitution where
{ "alphanum_fraction": 0.7118644068, "avg_line_length": 14.75, "ext": "agda", "hexsha": "e3588d5a2541c645464c226655e238108678b4f1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/Substitution.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/Substitution.agda", "max_line_length": 31, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/Substitution.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 12, "size": 59 }
import Lvl open import Data.Boolean open import Type module Data.List.Sorting {ℓ} {T : Type{ℓ}} (_≤?_ : T → T → Bool) where open import Functional using (_∘₂_) open import Data.Boolean.Stmt open import Data.List import Data.List.Relation.Pairwise open import Data.List.Relation.Permutation open import Logic open Data.List.Relation.Pairwise using (empty ; single ; step) public Sorted = Data.List.Relation.Pairwise.AdjacentlyPairwise(IsTrue ∘₂ (_≤?_)) -- A sorting algorithm is a function that given a list, always return a sorted list which is a permutation of the original one. record SortingAlgorithm (f : List(T) → List(T)) : Stmt{Lvl.𝐒(ℓ)} where constructor intro field ⦃ sorts ⦄ : ∀{l} → Sorted(f(l)) ⦃ permutes ⦄ : ∀{l} → (f(l) permutes l)
{ "alphanum_fraction": 0.7100515464, "avg_line_length": 33.7391304348, "ext": "agda", "hexsha": "1b42f2ffc35b424d03f6fa9dcba1385aec228af6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Data/List/Sorting.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/List/Sorting.agda", "max_line_length": 127, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Data/List/Sorting.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": 236, "size": 776 }
{-# OPTIONS --without-K #-} module NTypes.Sigma where open import NTypes open import PathOperations open import PathStructure.Sigma open import Transport open import Types Σ-isSet : ∀ {a b} {A : Set a} {B : A → Set b} → isSet A → (∀ x → isSet (B x)) → isSet (Σ A B) Σ-isSet {A = A} {B = B} A-set B-set x y p q = split-eq p ⁻¹ · ap₂-dep-eq {B = B} _,_ (ap π₁ p) (ap π₁ q) π₁-eq (tr-∘ π₁ p (π₂ x) ⁻¹ · apd π₂ p) (tr-∘ π₁ q (π₂ x) ⁻¹ · apd π₂ q) π₂-eq · split-eq q where split-eq : (p : x ≡ y) → ap₂-dep {B = B} _,_ (ap π₁ p) (tr-∘ π₁ p (π₂ x) ⁻¹ · apd π₂ p) ≡ p split-eq = π₂ (π₂ (π₂ split-merge-eq)) π₁-eq : ap π₁ p ≡ ap π₁ q π₁-eq = A-set _ _ (ap π₁ p) (ap π₁ q) π₂-eq : tr (λ z → tr B z (π₂ x) ≡ π₂ y) π₁-eq (tr-∘ π₁ p (π₂ x) ⁻¹ · apd π₂ p) ≡ tr-∘ π₁ q (π₂ x) ⁻¹ · apd π₂ q π₂-eq = B-set _ (tr B (ap π₁ q) (π₂ x)) (π₂ y) (tr (λ z → tr B z (π₂ x) ≡ π₂ y) π₁-eq (tr-∘ π₁ p (π₂ x) ⁻¹ · apd π₂ p)) (tr-∘ π₁ q (π₂ x) ⁻¹ · apd π₂ q)
{ "alphanum_fraction": 0.4842406877, "avg_line_length": 26.175, "ext": "agda", "hexsha": "fa674a9cb2c1aaf2c42976f8b321da3a9d0cd677", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vituscze/HoTT-lectures", "max_forks_repo_path": "src/NTypes/Sigma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vituscze/HoTT-lectures", "max_issues_repo_path": "src/NTypes/Sigma.agda", "max_line_length": 48, "max_stars_count": null, "max_stars_repo_head_hexsha": "7730385adfdbdda38ee8b124be3cdeebb7312c65", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vituscze/HoTT-lectures", "max_stars_repo_path": "src/NTypes/Sigma.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 524, "size": 1047 }
{-# OPTIONS --without-K --exact-split --safe #-} module Fragment.Setoid.Morphism.Setoid where open import Fragment.Setoid.Morphism.Base open import Level using (Level; _⊔_) open import Relation.Binary using (Setoid; IsEquivalence; Rel) private variable a b ℓ₁ ℓ₂ : Level module _ {S : Setoid a ℓ₁} {T : Setoid b ℓ₂} where open Setoid T infix 4 _≗_ _≗_ : Rel (S ↝ T) (a ⊔ ℓ₂) f ≗ g = ∀ {x} → ∣ f ∣ x ≈ ∣ g ∣ x ≗-refl : ∀ {f} → f ≗ f ≗-refl = refl ≗-sym : ∀ {f g} → f ≗ g → g ≗ f ≗-sym f≗g {x} = sym (f≗g {x}) ≗-trans : ∀ {f g h} → f ≗ g → g ≗ h → f ≗ h ≗-trans f≗g g≗h {x} = trans (f≗g {x}) (g≗h {x}) ≗-isEquivalence : IsEquivalence _≗_ ≗-isEquivalence = record { refl = λ {f} → ≗-refl {f} ; sym = λ {f g} → ≗-sym {f} {g} ; trans = λ {f g h} → ≗-trans {f} {g} {h} } _↝_/≗ : Setoid a ℓ₁ → Setoid b ℓ₂ → Setoid _ _ S ↝ T /≗ = record { Carrier = S ↝ T ; _≈_ = _≗_ ; isEquivalence = ≗-isEquivalence }
{ "alphanum_fraction": 0.4647758463, "avg_line_length": 25.4186046512, "ext": "agda", "hexsha": "4f3bc60c86fecec88c15fed66f3fe5d35ec3250a", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Setoid/Morphism/Setoid.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Setoid/Morphism/Setoid.agda", "max_line_length": 68, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Setoid/Morphism/Setoid.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "num_tokens": 449, "size": 1093 }
open import Common.Prelude open import Common.Reflect module TermSplicingOutOfScope where f : Set → Set → Set → Set f x y z = unquote (var 3 [])
{ "alphanum_fraction": 0.7278911565, "avg_line_length": 18.375, "ext": "agda", "hexsha": "0dd95a310a091a875ebd311cee7b1420b20464a5", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/TermSplicingOutOfScope.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/TermSplicingOutOfScope.agda", "max_line_length": 35, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/TermSplicingOutOfScope.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": 42, "size": 147 }
module Data.List.First.Membership {ℓ}{A : Set ℓ} where open import Data.Product open import Data.List open import Data.List.Relation.Unary.Any open import Data.List.First hiding (find) open import Relation.Nullary open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Level open import Function open import Data.Empty _∈_ : A → List A → Set _ x ∈ l = first x ∈ l ⇒ (_≡_ x) ¬x∈[] : ∀ {x} → ¬ x ∈ [] ¬x∈[] () find : Decidable (_≡_ {A = A}) → ∀ x l → Dec (x ∈ l) find _≟_ x [] = no (λ ()) find _≟_ x (y ∷ l) with x ≟ y ... | yes refl = yes (here refl) ... | no neq with find _≟_ x l ... | yes p = yes (there y neq p) ... | no ¬p = no (λ{ (here eq) → neq eq ; (there _ _ p) → ¬p p})
{ "alphanum_fraction": 0.6162310867, "avg_line_length": 26.9259259259, "ext": "agda", "hexsha": "0d747b5131c75c3eca915e7a2af279f01e110c72", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/Data/List/First/Membership.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/Data/List/First/Membership.agda", "max_line_length": 67, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/Data/List/First/Membership.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 254, "size": 727 }
------------------------------------------------------------------------ -- Nullary relations (some core definitions) ------------------------------------------------------------------------ -- The definitions in this file are reexported by Relation.Nullary. module Relation.Nullary.Core where open import Data.Empty -- Negation. infix 3 ¬_ ¬_ : Set → Set ¬ P = P → ⊥ -- Decidable relations. data Dec (P : Set) : Set where yes : ( p : P) → Dec P no : (¬p : ¬ P) → Dec P
{ "alphanum_fraction": 0.4453608247, "avg_line_length": 21.0869565217, "ext": "agda", "hexsha": "68a96e29a9a97509dab637d6435094bd93295949", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Relation/Nullary/Core.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Relation/Nullary/Core.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Relation/Nullary/Core.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 109, "size": 485 }
open import Agda.Primitive f : ∀ {a b c} → Set a → Set b → Set c → Set {!!} -- WAS solution: (a ⊔ (b ⊔ c)) f A B C = A → B → C -- NOW: (a ⊔ b ⊔ c)
{ "alphanum_fraction": 0.3709677419, "avg_line_length": 37.2, "ext": "agda", "hexsha": "22b7d4360a8e93b7eb8b78d9f7ba633d0aaa7001", "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/Issue3441.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/Issue3441.agda", "max_line_length": 79, "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/Issue3441.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 66, "size": 186 }
{-# OPTIONS --safe #-} module Cubical.Categories.Instances.Functors where open import Cubical.Categories.Category open import Cubical.Categories.Functor.Base open import Cubical.Categories.NaturalTransformation.Base open import Cubical.Categories.NaturalTransformation.Properties open import Cubical.Categories.Morphism renaming (isIso to isIsoC) open import Cubical.Foundations.Prelude private variable ℓC ℓC' ℓD ℓD' : Level module _ (C : Category ℓC ℓC') (D : Category ℓD ℓD') where open Category open NatTrans open Functor FUNCTOR : Category (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) (ℓ-max (ℓ-max ℓC ℓC') ℓD') ob FUNCTOR = Functor C D Hom[_,_] FUNCTOR = NatTrans id FUNCTOR {F} = idTrans F _⋆_ FUNCTOR = seqTrans ⋆IdL FUNCTOR α = makeNatTransPath λ i x → D .⋆IdL (α .N-ob x) i ⋆IdR FUNCTOR α = makeNatTransPath λ i x → D .⋆IdR (α .N-ob x) i ⋆Assoc FUNCTOR α β γ = makeNatTransPath λ i x → D .⋆Assoc (α .N-ob x) (β .N-ob x) (γ .N-ob x) i isSetHom FUNCTOR = isSetNat open isIsoC renaming (inv to invC) -- componentwise iso is an iso in Functor FUNCTORIso : ∀ {F G : Functor C D} (α : F ⇒ G) → (∀ (c : C .ob) → isIsoC D (α ⟦ c ⟧)) → isIsoC FUNCTOR α FUNCTORIso α is .invC .N-ob c = (is c) .invC FUNCTORIso {F} {G} α is .invC .N-hom {c} {d} f = invMoveL areInv-αc ( α ⟦ c ⟧ ⋆⟨ D ⟩ (G ⟪ f ⟫ ⋆⟨ D ⟩ is d .invC) ≡⟨ sym (D .⋆Assoc _ _ _) ⟩ (α ⟦ c ⟧ ⋆⟨ D ⟩ G ⟪ f ⟫) ⋆⟨ D ⟩ is d .invC ≡⟨ sym (invMoveR areInv-αd (α .N-hom f)) ⟩ F ⟪ f ⟫ ∎ ) where areInv-αc : areInv _ (α ⟦ c ⟧) ((is c) .invC) areInv-αc = isIso→areInv (is c) areInv-αd : areInv _ (α ⟦ d ⟧) ((is d) .invC) areInv-αd = isIso→areInv (is d) FUNCTORIso α is .sec = makeNatTransPath (funExt (λ c → (is c) .sec)) FUNCTORIso α is .ret = makeNatTransPath (funExt (λ c → (is c) .ret))
{ "alphanum_fraction": 0.5793731041, "avg_line_length": 37.320754717, "ext": "agda", "hexsha": "8cc1e5e481bb9824067297909cddff2a386a6096", "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": "63c770b381039c0132c17d7913f4566b35984701", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mzeuner/cubical", "max_forks_repo_path": "Cubical/Categories/Instances/Functors.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "63c770b381039c0132c17d7913f4566b35984701", "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": "mzeuner/cubical", "max_issues_repo_path": "Cubical/Categories/Instances/Functors.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "63c770b381039c0132c17d7913f4566b35984701", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mzeuner/cubical", "max_stars_repo_path": "Cubical/Categories/Instances/Functors.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 778, "size": 1978 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Lemmas relating algebraic definitions (such as associativity and -- commutativity) that don't the equality relation to be a setoid. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Algebra.Consequences.Base {a} {A : Set a} where open import Algebra.Core open import Algebra.Definitions open import Data.Sum.Base open import Relation.Binary.Core sel⇒idem : ∀ {ℓ} {_•_ : Op₂ A} (_≈_ : Rel A ℓ) → Selective _≈_ _•_ → Idempotent _≈_ _•_ sel⇒idem _ sel x with sel x x ... | inj₁ x•x≈x = x•x≈x ... | inj₂ x•x≈x = x•x≈x
{ "alphanum_fraction": 0.5326704545, "avg_line_length": 30.6086956522, "ext": "agda", "hexsha": "914aaf2cecfc66970e3ec3ea19b76c79c4987e9a", "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/Algebra/Consequences/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Algebra/Consequences/Base.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/Algebra/Consequences/Base.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 196, "size": 704 }
------------------------------------------------------------------------ -- Undecidability of subtyping in Fω with interval kinds ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module FOmegaInt.Undecidable where open import Function.Equivalence using (_⇔_; equivalence) open import Relation.Binary.PropositionalEquality open import Relation.Nullary open import Relation.Nullary.Decidable open import FOmegaInt.Syntax open import FOmegaInt.Typing as Declarative open import FOmegaInt.Kinding.Canonical as Canonical open import FOmegaInt.Kinding.Canonical.Equivalence open import FOmegaInt.Undecidable.SK open import FOmegaInt.Undecidable.Encoding open import FOmegaInt.Undecidable.Decoding open Syntax open ContextConversions using (⌞_⌟Ctx) open Canonical.Kinding using (_⊢_<:_⇇_) open Declarative.Typing using (_⊢_<:_∈_) open Encoding module T = TermCtx module E = ElimCtx ------------------------------------------------------------------------ -- SK combinator term equality checking reduces to subtype checking in -- Fω with interval kinds. -- -- We do not proof undecidability of subtyping directly, but give a -- reduction from undecidability of checking the equivalence of two SK -- combinator terms, which is well-known to be undecidable. In other -- words, if we could check subtyping, we could also check the -- equality of two SK combinator terms, which we cannot. -- -- The following types characterize the decision procedures involved. SKEqualityCheck : Set SKEqualityCheck = (s t : SKTerm) → Dec (s ≡SK t) CanoncialSubtypeCheck : Set CanoncialSubtypeCheck = ∀ {n} (Γ : E.Ctx n) a b k → Dec (Γ ⊢ a <: b ⇇ k) DeclarativeSubtypeCheck : Set DeclarativeSubtypeCheck = ∀ {n} (Γ : T.Ctx n) a b k → Dec (Γ ⊢ a <: b ∈ k) -- The reduction from SK equality checking to canoncial subtype checking. module CanoncialReduction (check-<:⇇ : CanoncialSubtypeCheck) where canonicalEquivalence : ∀ s t → Γ-SK? ⊢ encode s <: encode t ⇇ ⌜*⌝ ⇔ s ≡SK t canonicalEquivalence s t = equivalence decode-<:⇇-encode <:⇇-encode check-≡SK : SKEqualityCheck check-≡SK s t = map (canonicalEquivalence s t) (check-<:⇇ Γ-SK? (encode s) (encode t) ⌜*⌝) canonicalReduction : CanoncialSubtypeCheck → SKEqualityCheck canonicalReduction = CanoncialReduction.check-≡SK -- The reduction from SK equality checking to declarative subtype checking. module DeclarativeReduction (check-<:∈ : DeclarativeSubtypeCheck) where declarativeEquivalence : ∀ s t → ⌞Γ-SK?⌟ ⊢ ⌞ encode s ⌟ <: ⌞ encode t ⌟ ∈ * ⇔ s ≡SK t declarativeEquivalence s t = equivalence (λ es<:et∈* → decode-<:⇇-encode (subst₂ (_ ⊢_<:_⇇ _) (nf-encode s) (nf-encode t) (complete-<: es<:et∈*))) (λ s≡t → sound-<:⇇ (<:⇇-encode s≡t)) check-≡SK : SKEqualityCheck check-≡SK s t = map (declarativeEquivalence s t) (check-<:∈ ⌞Γ-SK?⌟ ⌞ encode s ⌟ ⌞ encode t ⌟ *) declarativeReduction : DeclarativeSubtypeCheck → SKEqualityCheck declarativeReduction = DeclarativeReduction.check-≡SK
{ "alphanum_fraction": 0.6774193548, "avg_line_length": 36.1666666667, "ext": "agda", "hexsha": "6535fd942a11f0aa24850f5f3fa230c4e8e753aa", "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": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Blaisorblade/f-omega-int-agda", "max_forks_repo_path": "src/FOmegaInt/Undecidable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "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": "Blaisorblade/f-omega-int-agda", "max_issues_repo_path": "src/FOmegaInt/Undecidable.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Blaisorblade/f-omega-int-agda", "max_stars_repo_path": "src/FOmegaInt/Undecidable.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 911, "size": 3038 }
{-# OPTIONS --cubical --safe #-} module Data.List.Smart where open import Prelude open import Data.Nat.Properties using (_≡ᴮ_; complete-==) infixr 5 _∷′_ _++′_ data List {a} (A : Type a) : Type a where []′ : List A _∷′_ : A → List A → List A _++′_ : List A → List A → List A sz′ : List A → ℕ → ℕ sz′ []′ k = k sz′ (x ∷′ xs) k = k sz′ (xs ++′ ys) k = suc (sz′ xs (sz′ ys k)) sz : List A → ℕ sz []′ = zero sz (x ∷′ xs) = zero sz (xs ++′ ys) = sz′ xs (sz ys) _HasSize_ : List A → ℕ → Type xs HasSize n = T (sz xs ≡ᴮ n) data ListView {a} (A : Type a) : Type a where Nil : ListView A Cons : A → List A → ListView A viewˡ : List A → ListView A viewˡ xs = go xs (sz xs) (complete-== (sz xs)) where go : (xs : List A) → (n : ℕ) → xs HasSize n → ListView A go []′ n p = Nil go (x ∷′ xs) n p = Cons x xs go ((x ∷′ xs) ++′ ys) n p = Cons x (xs ++′ ys) go ([]′ ++′ ys) n p = go ys n p go ((xs ++′ ys) ++′ zs) (suc n) p = go (xs ++′ (ys ++′ zs)) n p
{ "alphanum_fraction": 0.4807692308, "avg_line_length": 23.6363636364, "ext": "agda", "hexsha": "3611700f25a0f853ea94628273d4f1542ad14d57", "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/List/Smart.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/List/Smart.agda", "max_line_length": 66, "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/List/Smart.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": 424, "size": 1040 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Lists made up entirely of unique elements (propositional equality) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Unary.Unique.Propositional {a} {A : Set a} where open import Relation.Binary.PropositionalEquality using (setoid) open import Data.List.Relation.Unary.Unique.Setoid as SetoidUnique ------------------------------------------------------------------------ -- Re-export the contents of setoid uniqueness open SetoidUnique (setoid A) public
{ "alphanum_fraction": 0.5107361963, "avg_line_length": 34.3157894737, "ext": "agda", "hexsha": "4bb5f79aaf064e3746f58d0cf6dadb9cd7a15611", "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/List/Relation/Unary/Unique/Propositional.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/List/Relation/Unary/Unique/Propositional.agda", "max_line_length": 74, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/List/Relation/Unary/Unique/Propositional.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": 108, "size": 652 }
{-# OPTIONS --without-K #-} open import Base open import Homotopy.Pushout open import Homotopy.VanKampen.Guide module Homotopy.VanKampen.Code.LemmaPackB {i} (d : pushout-diag i) (l : legend i (pushout-diag.C d)) where open pushout-diag d open legend l open import Homotopy.Truncation open import Homotopy.PathTruncation open import Homotopy.VanKampen.SplitCode d l abstract trans-q-code-a : ∀ {a₁ a₂} (q : a₁ ≡ a₂) {a₃} (p : _ ≡₀ a₃) → transport (λ x → code-a x a₃) q (a a₁ p) ≡ a a₂ (proj (! q) ∘₀ p) trans-q-code-a refl p = ap (λ x → a _ x) $ ! $ refl₀-left-unit p trans-!q-code-a : ∀ {a₁ a₂} (q : a₂ ≡ a₁) {a₃} (p : _ ≡₀ a₃) → transport (λ x → code-a x a₃) (! q) (a a₁ p) ≡ a a₂ (proj q ∘₀ p) trans-!q-code-a refl p = ap (λ x → a _ x) $ ! $ refl₀-left-unit p trans-q-code-ba : ∀ {a₁ a₂} (q : a₁ ≡ a₂) {a₃} n co (p : _ ≡₀ a₃) → transport (λ x → code-a x a₃) q (ba a₁ n co p) ≡ ba a₂ n (transport (λ x → code-b x (g $ loc n)) q co) p trans-q-code-ba refl n co p = refl trans-q-code-ab : ∀ {a₁ a₂} (q : a₁ ≡ a₂) {b₃} n co (p : _ ≡₀ b₃) → transport (λ x → code-b x b₃) q (ab a₁ n co p) ≡ ab a₂ n (transport (λ x → code-a x (f $ loc n)) q co) p trans-q-code-ab refl n co p = refl
{ "alphanum_fraction": 0.5625, "avg_line_length": 34.5945945946, "ext": "agda", "hexsha": "716f41a704c4f5a2717f39b6c7c24efd8a9f0109", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Homotopy/VanKampen/Code/LemmaPackB.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Homotopy/VanKampen/Code/LemmaPackB.agda", "max_line_length": 69, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/Homotopy/VanKampen/Code/LemmaPackB.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": 542, "size": 1280 }
{-# OPTIONS --rewriting #-} open import Agda.Builtin.Equality {-# BUILTIN REWRITE _≡_ #-} data Bool : Set where true false : Bool op : Bool → Set → Set op false _ = Bool op true A = A postulate id : Bool → Bool id-comp : ∀ y → id y ≡ y {-# REWRITE id-comp #-} postulate A : Set law : (i : Bool) → op (id i) A ≡ Bool {-# REWRITE law #-} ok : (i : Bool) → op i A ≡ Bool ok i = refl
{ "alphanum_fraction": 0.5714285714, "avg_line_length": 16.625, "ext": "agda", "hexsha": "cd9cf22bf3d0ed2e2a9a8c93942da56d65c006d1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/Issue2573.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/Issue2573.agda", "max_line_length": 39, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/Issue2573.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 141, "size": 399 }
-- 2010-09-24 -- example originally stolen from Andrea Vezzosi's post on the Agda list {-# OPTIONS --no-irrelevant-projections #-} module IrrelevantRecordFields where open import Common.Equality record SemiG : Set1 where constructor _,_,_,_,_,_ field M : Set unit : M _+_ : M -> M -> M .assoc : ∀ {x y z} -> x + (y + z) ≡ (x + y) + z .leftUnit : ∀ {x} -> unit + x ≡ x .rightUnit : ∀ {x} -> x + unit ≡ x dual : SemiG -> SemiG dual (M , e , _+_ , assoc , leftUnit , rightUnit) = M , e , (λ x y -> y + x) , sym assoc , rightUnit , leftUnit open SemiG -- trivId : ∀ (M : SemiG) -> M ≡ M -- trivId M = refl dual∘dual≡id : ∀ M -> dual (dual M) ≡ M dual∘dual≡id M = refl {x = M}
{ "alphanum_fraction": 0.5646067416, "avg_line_length": 22.9677419355, "ext": "agda", "hexsha": "c87a8ea7f9c986b9bf4dc6e0e3188342663e2cec", "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/IrrelevantRecordFields.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/IrrelevantRecordFields.agda", "max_line_length": 72, "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/IrrelevantRecordFields.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": 276, "size": 712 }
-- An ATP type must be used with data-types or postulates. -- This error is detected by Syntax.Translation.ConcreteToAbstract. module ATPBadType1 where data Bool : Set where false true : Bool {-# ATP type false #-}
{ "alphanum_fraction": 0.7375565611, "avg_line_length": 20.0909090909, "ext": "agda", "hexsha": "8285076316ddb3a89fc1f7406c924da7dd14a423", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/eagda", "max_forks_repo_path": "test/fail/ATPBadType1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "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": "asr/eagda", "max_issues_repo_path": "test/fail/ATPBadType1.agda", "max_line_length": 67, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/eagda", "max_stars_repo_path": "test/fail/ATPBadType1.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 52, "size": 221 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Machine words: basic type and conversion functions ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Word.Base where open import Level using (zero) import Data.Nat.Base as ℕ open import Function open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------ -- Re-export built-ins publicly open import Agda.Builtin.Word public using (Word64) renaming ( primWord64ToNat to toℕ ; primWord64FromNat to fromℕ ) infix 4 _≈_ _≈_ : Rel Word64 zero _≈_ = _≡_ on toℕ infix 4 _<_ _<_ : Rel Word64 zero _<_ = ℕ._<_ on toℕ
{ "alphanum_fraction": 0.5309405941, "avg_line_length": 23.7647058824, "ext": "agda", "hexsha": "ef287d6edff694f0353b7e54d5386bb686d575d4", "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/Word/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Word/Base.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/Word/Base.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 184, "size": 808 }
{-# OPTIONS --without-K --safe #-} -- The Category of Algebraic Kan Complexes module Categories.Category.Instance.KanComplexes where open import Level open import Function using (_$_) open import Data.Product using (Σ; _,_; proj₁) open import Categories.Category open import Categories.Category.SubCategory open import Categories.Category.Construction.KanComplex open import Categories.Category.Instance.SimplicialSet import Categories.Category.Instance.SimplicialSet.Properties as ΔSetₚ import Categories.Morphism.Reasoning as MR module _ (o ℓ : Level) where open Category (SimplicialSet o ℓ) open ΔSetₚ o ℓ open IsKanComplex open Equiv open MR (SimplicialSet o ℓ) -- As we are working with Algebraic Kan Complexes, maps between two Kan Complexes ought -- to take the chosen filler in 'X' to the chosen filler in 'Y'. PreservesFiller : ∀ {X Y : ΔSet} → IsKanComplex o ℓ X → IsKanComplex o ℓ Y → (X ⇒ Y) → Set (o ⊔ ℓ) PreservesFiller {X} {Y} X-Kan Y-Kan f = ∀ {n} {k} → (i : Λ[ n , k ] ⇒ X) → (f ∘ filler X-Kan {n} i) ≈ filler Y-Kan (f ∘ i) KanComplexes : Category (suc o ⊔ suc ℓ) (o ⊔ ℓ ⊔ (o ⊔ ℓ)) (o ⊔ ℓ) KanComplexes = SubCategory (SimplicialSet o ℓ) {I = Σ ΔSet (IsKanComplex o ℓ)} $ record { U = proj₁ ; R = λ { {_ , X-Kan} {_ , Y-Kan} f → PreservesFiller X-Kan Y-Kan f } ; Rid = λ { {_ , X-Kan} i → begin id ∘ filler X-Kan i ≈⟨ identityˡ {f = filler X-Kan i} ⟩ filler X-Kan i ≈˘⟨ filler-cong X-Kan (identityˡ {f = i}) ⟩ filler X-Kan (id ∘ i) ∎ } ; _∘R_ = λ { {_ , X-Kan} {_ , Y-Kan} {_ , Z-Kan} {f} {g} f-preserves g-preserves i → begin (f ∘ g) ∘ filler X-Kan i ≈⟨ assoc {f = filler X-Kan i} {g = g} {h = f} ⟩ f ∘ (g ∘ filler X-Kan i) ≈⟨ ∘-resp-≈ʳ {f = (g ∘ filler X-Kan i)} {h = filler Y-Kan (g ∘ i)} {g = f} (g-preserves i) ⟩ f ∘ filler Y-Kan (g ∘ i) ≈⟨ f-preserves (g ∘ i) ⟩ filler Z-Kan (f ∘ g ∘ i) ≈˘⟨ filler-cong Z-Kan (assoc {f = i} {g = g} {h = f}) ⟩ filler Z-Kan ((f ∘ g) ∘ i) ∎ } } where open HomReasoning
{ "alphanum_fraction": 0.6020260492, "avg_line_length": 39.8653846154, "ext": "agda", "hexsha": "e95214d937af3af660afd69d487f005efed963fe", "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/Instance/KanComplexes.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/Instance/KanComplexes.agda", "max_line_length": 126, "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/Instance/KanComplexes.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": 790, "size": 2073 }
{-# OPTIONS --without-K #-} open import HoTT module homotopy.PathSetIsInital {i} (A : Type i) -- (A-conn : is-connected 0 A) where open Cover module _ (a₁ : A) -- And an arbitrary covering. {k} (cov : Cover A k) -- (cov-conn : is-connected 0 (Cover.TotalSpace cov)) (a↑₁ : Fiber cov a₁) where private univ-cover = path-set-cover ⊙[ A , a₁ ] -- Weak initiality by transport. quotient-cover : CoverHom univ-cover cov quotient-cover _ p = cover-trace cov a↑₁ p -- Strong initiality by path induction. module Uniqueness (cover-hom : CoverHom univ-cover cov) (pres-a↑₁ : cover-hom a₁ idp₀ == a↑₁) where private lemma₁ : ∀ a p → cover-hom a [ p ] == quotient-cover a [ p ] lemma₁ ._ idp = pres-a↑₁ lemma₂ : ∀ a p → cover-hom a p == quotient-cover a p lemma₂ a = Trunc-elim (λ p → =-preserves-level 0 (Cover.Fiber-level cov a)) (lemma₁ a) theorem : cover-hom == quotient-cover theorem = λ= λ a → λ= $ lemma₂ a
{ "alphanum_fraction": 0.5738476011, "avg_line_length": 24.7209302326, "ext": "agda", "hexsha": "92f3d4fd81ada2fb934079d55f9e635573dcb68d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/PathSetIsInital.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/PathSetIsInital.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/PathSetIsInital.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 329, "size": 1063 }
{-# OPTIONS --copatterns #-} module EmptyInductiveRecord where mutual data E : Set where e : F -> E record F : Set where inductive constructor c field f : E open F data ⊥ : Set where elim : E → ⊥ elim (e (c x)) = elim x mutual empty : E empty = e empty? empty? : F f empty? = empty absurd : ⊥ absurd = elim empty
{ "alphanum_fraction": 0.5942857143, "avg_line_length": 11.6666666667, "ext": "agda", "hexsha": "7c544ce8cc55748f8ce5ea76abc596a66aa472c3", "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/EmptyInductiveRecord.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/EmptyInductiveRecord.agda", "max_line_length": 33, "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/EmptyInductiveRecord.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": 119, "size": 350 }
module Generic.Test.Data.List where module _ where open import Generic.Main as Main hiding ([]; _∷_) renaming (List to StdList) infixr 5 _∷_ _∷′_ List : ∀ {α} -> Set α -> Set α List = readData StdList pattern [] = #₀ lrefl pattern _∷_ x xs = !#₁ (relv x , xs , lrefl) _∷′_ : ∀ {α} {A : Set α} -> A -> List A -> List A _∷′_ = _∷_ elimList : ∀ {α π} {A : Set α} -> (P : List A -> Set π) -> (∀ {xs} x -> P xs -> P (x ∷ xs)) -> P [] -> ∀ xs -> P xs elimList P f z [] = z elimList P f z (x ∷ xs) = f x (elimList P f z xs) toStdList : ∀ {α} {A : Set α} -> List A -> StdList A toStdList xs = guncoerce xs -- The entire content of `Data.List.Base` (modulo `Generic.Test.Data.Maybe` instead of -- `Data.Maybe.Base` and _∷_ was renamed to _∷′_ in some places) open import Data.Nat.Base using (ℕ; zero; suc; _+_; _*_) open import Data.Sum as Sum using (_⊎_; inj₁; inj₂) open import Data.Bool.Base using (Bool; false; true; not; _∧_; _∨_; if_then_else_) open import Generic.Test.Data.Maybe open import Data.Product as Prod using (_×_; _,_) open import Function infixr 5 _++_ [_] : ∀ {a} {A : Set a} → A → List A [ x ] = x ∷ [] _++_ : ∀ {a} {A : Set a} → List A → List A → List A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) -- Snoc. infixl 5 _∷ʳ_ _∷ʳ_ : ∀ {a} {A : Set a} → List A → A → List A xs ∷ʳ x = xs ++ [ x ] null : ∀ {a} {A : Set a} → List A → Bool null [] = true null (x ∷ xs) = false -- * List transformations map : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → List A → List B map f [] = [] map f (x ∷ xs) = f x ∷ map f xs replicate : ∀ {a} {A : Set a} → (n : ℕ) → A → List A replicate zero x = [] replicate (suc n) x = x ∷ replicate n x zipWith : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (A → B → C) → List A → List B → List C zipWith f (x ∷ xs) (y ∷ ys) = f x y ∷ zipWith f xs ys zipWith f _ _ = [] zip : ∀ {a b} {A : Set a} {B : Set b} → List A → List B → List (A × B) zip = zipWith (_,_) intersperse : ∀ {a} {A : Set a} → A → List A → List A intersperse x [] = [] intersperse x (y ∷ []) = [ y ] intersperse x (y ∷ z ∷ zs) = y ∷ x ∷ intersperse x (z ∷ zs) -- * Reducing lists (folds) foldr : ∀ {a b} {A : Set a} {B : Set b} → (A → B → B) → B → List A → B foldr c n [] = n foldr c n (x ∷ xs) = c x (foldr c n xs) foldl : ∀ {a b} {A : Set a} {B : Set b} → (A → B → A) → A → List B → A foldl c n [] = n foldl c n (x ∷ xs) = foldl c (c n x) xs -- ** Special folds concat : ∀ {a} {A : Set a} → List (List A) → List A concat = foldr _++_ [] concatMap : ∀ {a b} {A : Set a} {B : Set b} → (A → List B) → List A → List B concatMap f = concat ∘ map f and : List Bool → Bool and = foldr _∧_ true or : List Bool → Bool or = foldr _∨_ false any : ∀ {a} {A : Set a} → (A → Bool) → List A → Bool any p = or ∘ map p all : ∀ {a} {A : Set a} → (A → Bool) → List A → Bool all p = and ∘ map p sum : List ℕ → ℕ sum = foldr _+_ 0 product : List ℕ → ℕ product = foldr _*_ 1 length : ∀ {a} {A : Set a} → List A → ℕ length = foldr (λ _ → suc) 0 import Data.List.Base reverse : ∀ {a} {A : Set a} → List A → List A reverse = foldl (λ rev x → x ∷′ rev) [] -- * Building lists -- ** Scans scanr : ∀ {a b} {A : Set a} {B : Set b} → (A → B → B) → B → List A → List B scanr f e [] = e ∷ [] scanr f e (x ∷ xs) with scanr f e xs ... | [] = [] -- dead branch ... | y ∷ ys = f x y ∷ y ∷ ys scanl : ∀ {a b} {A : Set a} {B : Set b} → (A → B → A) → A → List B → List A scanl f e [] = e ∷ [] scanl f e (x ∷ xs) = e ∷ scanl f (f e x) xs -- ** Unfolding -- Unfold. Uses a measure (a natural number) to ensure termination. unfold : ∀ {a b} {A : Set a} (B : ℕ → Set b) (f : ∀ {n} → B (suc n) → Maybe (A × B n)) → ∀ {n} → B n → List A unfold B f {n = zero} s = [] unfold B f {n = suc n} s with f s ... | nothing = [] ... | just (x , s') = x ∷ unfold B f s' -- downFrom 3 = 2 ∷ 1 ∷ 0 ∷ []. downFrom : ℕ → List ℕ downFrom n = unfold Singleton f (wrap n) where data Singleton : ℕ → Set where wrap : (n : ℕ) → Singleton n f : ∀ {n} → Singleton (suc n) → Maybe (ℕ × Singleton n) f {n} (wrap .(suc n)) = just (n , wrap n) -- ** Conversions fromMaybe : ∀ {a} {A : Set a} → Maybe A → List A fromMaybe (just x) = [ x ] fromMaybe nothing = [] -- * Sublists -- ** Extracting sublists take : ∀ {a} {A : Set a} → ℕ → List A → List A take zero xs = [] take (suc n) [] = [] take (suc n) (x ∷ xs) = x ∷ take n xs drop : ∀ {a} {A : Set a} → ℕ → List A → List A drop zero xs = xs drop (suc n) [] = [] drop (suc n) (x ∷ xs) = drop n xs splitAt : ∀ {a} {A : Set a} → ℕ → List A → (List A × List A) splitAt zero xs = ([] , xs) splitAt (suc n) [] = ([] , []) splitAt (suc n) (x ∷ xs) with splitAt n xs ... | (ys , zs) = (x ∷ ys , zs) takeWhile : ∀ {a} {A : Set a} → (A → Bool) → List A → List A takeWhile p [] = [] takeWhile p (x ∷ xs) with p x ... | true = x ∷ takeWhile p xs ... | false = [] dropWhile : ∀ {a} {A : Set a} → (A → Bool) → List A → List A dropWhile p [] = [] dropWhile p (x ∷ xs) with p x ... | true = dropWhile p xs ... | false = x ∷ xs span : ∀ {a} {A : Set a} → (A → Bool) → List A → (List A × List A) span p [] = ([] , []) span p (x ∷ xs) with p x ... | true = Prod.map (_∷′_ x) id (span p xs) ... | false = ([] , x ∷ xs) break : ∀ {a} {A : Set a} → (A → Bool) → List A → (List A × List A) break p = span (not ∘ p) inits : ∀ {a} {A : Set a} → List A → List (List A) inits [] = [] ∷ [] inits (x ∷ xs) = [] ∷ map (_∷′_ x) (inits xs) tails : ∀ {a} {A : Set a} → List A → List (List A) tails [] = [] ∷ [] tails (x ∷ xs) = (x ∷ xs) ∷ tails xs infixl 5 _∷ʳ'_ data InitLast {a} {A : Set a} : List A → Set a where []ʳ : InitLast [] _∷ʳ'_ : (xs : List A) (x : A) → InitLast (xs ∷ʳ x) initLast : ∀ {a} {A : Set a} (xs : List A) → InitLast xs initLast [] = []ʳ initLast (x ∷ xs) with initLast xs initLast (x ∷ .[]) | []ʳ = [] ∷ʳ' x initLast (x ∷ .(ys ∷ʳ y)) | ys ∷ʳ' y = (x ∷ ys) ∷ʳ' y -- * Searching lists -- ** Searching with a predicate -- A generalised variant of filter. gfilter : ∀ {a b} {A : Set a} {B : Set b} → (A → Maybe B) → List A → List B gfilter p [] = [] gfilter p (x ∷ xs) with p x ... | just y = y ∷ gfilter p xs ... | nothing = gfilter p xs filter : ∀ {a} {A : Set a} → (A → Bool) → List A → List A filter p = gfilter (λ x → if p x then just′ x else nothing) partition : ∀ {a} {A : Set a} → (A → Bool) → List A → (List A × List A) partition p [] = ([] , []) partition p (x ∷ xs) with p x | partition p xs ... | true | (ys , zs) = (x ∷ ys , zs) ... | false | (ys , zs) = (ys , x ∷ zs)
{ "alphanum_fraction": 0.4850615114, "avg_line_length": 26.8818897638, "ext": "agda", "hexsha": "fdd9d93e923ab90712f828caba3cc42b93d31e08", "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/List.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/List.agda", "max_line_length": 86, "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/List.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": 2723, "size": 6828 }
------------------------------------------------------------------------ -- Code related to the paper "Total Definitional Interpreters for Time -- and Space Complexity" -- -- Nils Anders Danielsson ------------------------------------------------------------------------ -- Note that the code has evolved after the paper was written. For -- code that is closer to the paper, see the version of the code that -- is distributed with the paper. module README where ------------------------------------------------------------------------ -- Pointers to results from the paper -- In order to more easily find code corresponding to results from the -- paper, see the following module. Note that some of the code -- referenced below is not discussed at all in the paper. import README.Pointers-to-results-from-the-paper ------------------------------------------------------------------------ -- Responses to some challenges from Ancona, Dagnino and Zucca -- The syntax of a toy programming language that only supports -- allocation and deallocation of memory. import Only-allocation -- Definitional interpreters can model systems with bounded space. import Bounded-space -- Upper bounds of colists containing natural numbers. import Upper-bounds -- Definitional interpreters can model systems with unbounded space. import Unbounded-space ------------------------------------------------------------------------ -- An example involving a simple λ-calculus -- Some developments based on "Operational Semantics Using the -- Partiality Monad" by Danielsson. -- -- These developments to a large extent mirror developments in -- "Coinductive big-step operational semantics" by Leroy and Grall. -- -- The main differences compared to those two pieces of work are -- perhaps the following ones: -- -- * Sized types are used. -- -- * The infinite set of uninterpreted constants has been replaced by -- booleans, and definitions (named, unary, recursive functions) -- are included. -- -- * The virtual machine and the compiler include support for tail -- calls. -- -- * Stack space usage is analysed. -- The syntax of, and a type system for, an untyped λ-calculus with -- booleans and recursive unary function calls. import Lambda.Syntax -- A delay monad with the possibility of crashing. import Lambda.Delay-crash -- A definitional interpreter. import Lambda.Interpreter -- A type soundness result. import Lambda.Type-soundness -- A combination of the delay monad (with the possibility of crashing) -- and a kind of writer monad yielding colists. import Lambda.Delay-crash-trace -- Virtual machine instructions, state etc. import Lambda.Virtual-machine.Instructions -- A virtual machine. import Lambda.Virtual-machine -- A compiler. import Lambda.Compiler -- Compiler correctness. import Lambda.Compiler-correctness -- A definitional interpreter that is instrumented with information -- about the stack size of the compiled program. import Lambda.Interpreter.Stack-sizes -- The actual maximum stack size of the compiled program matches the -- maximum stack size of the instrumented source-level semantics. import Lambda.Compiler-correctness.Sizes-match -- An example: A non-terminating program that runs in bounded stack -- space. import Lambda.Interpreter.Stack-sizes.Example -- A counterexample: The trace of stack sizes produced by the virtual -- machine is not necessarily bisimilar to that produced by the -- instrumented interpreter. import Lambda.Interpreter.Stack-sizes.Counterexample -- A counterexample: The number of steps taken by the uninstrumented -- interpreter is not, in general, linear in the number of steps taken -- by the virtual machine for the corresponding compiled program. import Lambda.Interpreter.Steps.Counterexample -- A definitional interpreter that is instrumented with information -- about the number of steps required to run the compiled program. import Lambda.Interpreter.Steps -- The "time complexity" of the compiled program matches the one -- obtained from the instrumented interpreter. import Lambda.Compiler-correctness.Steps-match
{ "alphanum_fraction": 0.7089007782, "avg_line_length": 29.3714285714, "ext": "agda", "hexsha": "d5bb49334989f11136d5c1405f3f61a1dd080ddb", "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": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/definitional-interpreters", "max_forks_repo_path": "README.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "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/definitional-interpreters", "max_issues_repo_path": "README.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "dec8cd2d2851340840de25acb0feb78f7b5ffe96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/definitional-interpreters", "max_stars_repo_path": "README.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 794, "size": 4112 }
{-# OPTIONS --type-in-type #-} module Prob where open import DescTT mutual data Sch : Set where ty : (S : Set) -> Sch exPi : (s : Sch)(T : toType s -> Sch) -> Sch imPi : (S : Set)(T : S -> Sch) -> Sch toType : Sch -> Set toType (ty S) = S toType (exPi s T) = (x : toType s) -> toType (T x) toType (imPi S T) = (x : S) -> toType (T x) Args : Sch -> Set Args (ty _) = Unit Args (exPi s T) = Sigma (toType s) \ x -> Args (T x) Args (imPi S T) = Sigma S \ x -> Args (T x) postulate UId : Set Prp : Set Prf : Prp -> Set data Prob : Set where label : (u : UId)(s : Sch)(a : Args s) -> Prob patPi : (u : UId)(S : Set)(p : Prob) -> Prob hypPi : (p : Prp)(T : Prf p -> Prob) -> Prob recPi : (rec : Prob)(p : Prob) -> Prob
{ "alphanum_fraction": 0.5143229167, "avg_line_length": 22.5882352941, "ext": "agda", "hexsha": "5e9462060e2001bb14bc3e54774675319c92efb4", "lang": "Agda", "max_forks_count": 12, "max_forks_repo_forks_event_max_datetime": "2022-02-11T01:57:40.000Z", "max_forks_repo_forks_event_min_datetime": "2016-08-14T21:36:35.000Z", "max_forks_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mietek/epigram", "max_forks_repo_path": "models/Prob.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "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": "mietek/epigram", "max_issues_repo_path": "models/Prob.agda", "max_line_length": 52, "max_stars_count": 48, "max_stars_repo_head_hexsha": "8c46f766bddcec2218ddcaa79996e087699a75f2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mietek/epigram", "max_stars_repo_path": "models/Prob.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-11T01:55:28.000Z", "max_stars_repo_stars_event_min_datetime": "2016-01-09T17:36:19.000Z", "num_tokens": 304, "size": 768 }
{-# OPTIONS --without-K #-} module HoTT.Equivalence.Proposition where open import HoTT.Base open import HoTT.HLevel open import HoTT.Equivalence open variables -- Proven by Theorem 4.3.2 postulate isequiv-prop : {f : A → B} → isProp (isequiv f) {- fib : B → 𝒰 _ fib y = Σ[ x ∶ A ] (f x == y) -- Left inverse with coherence lcoh : linv → 𝒰 _ lcoh (g , η) = Σ[ ε ∶ f ∘ g ~ id ] ap g ∘ ε ~ η ∘ g -- Right inverse with coherence rcoh : rinv → 𝒰 _ rcoh (g , ε) = Σ[ η ∶ g ∘ f ~ id ] ap f ∘ η ~ ε ∘ f -} {- hae-fib-contr : {f : A → B} → ishae f → (y : B) → isContr (fib f y) hae-fib-contr {A = A} {f = f} (g , η , ε , τ) y = (g y , ε y) , contr where contr : (z : fib f y) → (g y , ε y) == z contr (x , p) = pair⁼ (qₓ , qₚ) where qₓ : g y == x qₓ = ap g p ⁻¹ ∙ η x qₚ : transport (λ x → f x == y) qₓ (ε y) == p qₚ = begin transport (λ x → f x == y) qₓ (ε y) =⟨ transport=-constᵣ f y qₓ (ε y) ⟩ ap f qₓ ⁻¹ ∙ ε y =⟨ ap (λ p → p ⁻¹ ∙ ε y) (ap-∙ f (ap g p ⁻¹) (η x)) ⟩ (ap f (ap g p ⁻¹) ∙ ap f (η x)) ⁻¹ ∙ ε y =⟨ ap (λ p → p ⁻¹ ∙ ε y) (ap (ap f) (ap-⁻¹ g p ⁻¹) ⋆ τ x) ⟩ (ap f (ap g (p ⁻¹)) ∙ ε (f x)) ⁻¹ ∙ ε y =⟨ ap (λ p → (p ∙ ε (f x)) ⁻¹ ∙ ε y) (ap-∘ f g (p ⁻¹)) ⟩ (ap (f ∘ g) (p ⁻¹) ∙ ε (f x)) ⁻¹ ∙ ε y =⟨ ap (λ p → p ⁻¹ ∙ ε y) (~-naturality ε (p ⁻¹) ⁻¹) ⟩ (ε y ∙ ap id (p ⁻¹)) ⁻¹ ∙ ε y =⟨ ap (λ p → (ε y ∙ p) ⁻¹ ∙ ε y) (ap-id (p ⁻¹)) ⟩ (ε y ∙ p ⁻¹) ⁻¹ ∙ ε y =⟨ ∙-⁻¹ (ε y) (p ⁻¹) ∙ᵣ ε y ⟩ p ⁻¹ ⁻¹ ∙ ε y ⁻¹ ∙ ε y =⟨ ∙-assoc _ _ _ ⁻¹ ⟩ p ⁻¹ ⁻¹ ∙ (ε y ⁻¹ ∙ ε y) =⟨ invinv p ⋆ ∙-invₗ (ε y) ⟩ p ∙ refl =⟨ ∙-unitᵣ p ⁻¹ ⟩ p ∎ where open =-Reasoning ∙-⁻¹ : {A : 𝒰 i} {x y z : A} (p : x == y) (q : y == z) → (p ∙ q) ⁻¹ == q ⁻¹ ∙ p ⁻¹ ∙-⁻¹ refl refl = refl invinv : {A : 𝒰 i} {x y : A} (p : x == y) → p ⁻¹ ⁻¹ == p invinv refl = refl linv-contr : {f : A → B} → qinv f → isContr (linv f) linv-contr {f = f} (g , η , ε) = {!hae-fib-contr (qinv→ishae e)!} where q' : qinv (_∘ f) q' = _∘ g , (λ x → ap (x ∘_) {!funext ?!}) , {!!} rinv-contr : {f : A → B} → qinv f → isContr (rinv f) rinv-contr = {!!} -}
{ "alphanum_fraction": 0.4001732352, "avg_line_length": 36.078125, "ext": "agda", "hexsha": "719cae575a6d1c6451e6b2986dff684a10268778", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_path": "HoTT/Equivalence/Proposition.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_path": "HoTT/Equivalence/Proposition.agda", "max_line_length": 106, "max_stars_count": null, "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_path": "HoTT/Equivalence/Proposition.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1161, "size": 2309 }
{-# OPTIONS --safe #-} module STLC.Operational.Eager where open import STLC.Syntax open import STLC.Operational.Base open import Data.Empty using (⊥-elim) open import Data.Product using (∃-syntax; _,_) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Fin using (Fin; _≟_) renaming (zero to fzero; suc to fsuc) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong) open import Relation.Nullary using (yes; no; ¬_) private variable m n : ℕ L M M' N N' : Term n A B C : Type Γ Δ : Ctx n v : Fin n data Value {n} : Term n → Set where abs-value ----------------- : Value (abs A M) ⋆-value ----------------- : Value ⋆ pair-value : Value M → Value N ----------------- → Value (pair M N) infix 6 _↦_ data _↦_ : Term n → Term n → Set where red-head : M ↦ M' ------------------ → app M N ↦ app M' N red-arg : Value M → N ↦ N' ------------------ → app M N ↦ app M N' red-β : Value N --------------------------------- → app (abs A M) N ↦ M [ fzero ≔ N ] red-left : M ↦ M' -------------------- → pair M N ↦ pair M' N red-right : Value M → N ↦ N' -------------------- → pair M N ↦ pair M N' red-projₗ-inner : M ↦ M' ------------------ → projₗ M ↦ projₗ M' red-projₗ : Value M → Value N -------------------- → projₗ (pair M N) ↦ M red-projᵣ-inner : M ↦ M' ------------------ → projᵣ M ↦ projᵣ M' red-projᵣ : Value M → Value N -------------------- → projᵣ (pair M N) ↦ N data _↦*_ : Term n → Term n → Set where pure : M ↦ N → M ↦* N id : M ↦* M comp : L ↦* M → M ↦* N → L ↦* N open import STLC.Typing progress : ● ⊢ M ⦂ A → Value M ⊎ (∃[ N ] (M ↦ N)) progress (ty-abs _) = inj₁ abs-value progress (ty-app {f = f} {x = x} t u) with progress u | progress t ... | inj₁ u-value | inj₁ (abs-value {M = M}) = inj₂ (M [ fzero ≔ x ] , red-β u-value) ... | inj₂ (u' , u-step) | inj₁ t-value = inj₂ (app f u' , red-arg t-value u-step) ... | inj₁ _ | inj₂ (t' , t-step) = inj₂ (app t' x , red-head t-step) ... | inj₂ _ | inj₂ (t' , t-step) = inj₂ (app t' x , red-head t-step) progress ty-⋆ = inj₁ ⋆-value progress (ty-pair {a = a} {b = b} t u) with progress t | progress u ... | inj₁ t-value | inj₁ u-value = inj₁ (pair-value t-value u-value) ... | inj₁ t-value | inj₂ (u' , u-step) = inj₂ (pair a u' , red-right t-value u-step) ... | inj₂ (t' , t-step) | _ = inj₂ (pair t' b , red-left t-step) progress (ty-projₗ t) with progress t ... | inj₁ (pair-value {M = M} M-value N-value) = inj₂ (M , red-projₗ M-value N-value) ... | inj₂ (t' , t-step) = inj₂ (projₗ t' , red-projₗ-inner t-step) progress (ty-projᵣ t) with progress t ... | inj₁ (pair-value {N = N} M-value N-value) = inj₂ (N , red-projᵣ M-value N-value) ... | inj₂ (t' , t-step) = inj₂ (projᵣ t' , red-projᵣ-inner t-step) weakening-var : ∀ {Γ : Ctx n} {v' : Fin (suc n)} → Γ ∋ v ⦂ A → liftΓ Γ v' B ∋ Data.Fin.punchIn v' v ⦂ A weakening-var {v' = fzero} vzero = vsuc vzero weakening-var {v' = fsuc n} vzero = vzero weakening-var {v' = fzero} (vsuc v) = vsuc (vsuc v) weakening-var {v' = fsuc n} (vsuc v) = vsuc (weakening-var v) -- | The weakening lemma: A term typeable in a context is typeable in an extended context. -- -- https://www.seas.upenn.edu/~sweirich/dsss17/html/Stlc.Lec2.html weakening : ∀ {Γ : Ctx n} {v : Fin (suc n)} {t : Type} → Γ ⊢ M ⦂ A → liftΓ Γ v t ⊢ lift M v ⦂ A weakening (ty-abs body) = ty-abs (weakening body) weakening (ty-app f x) = ty-app (weakening f) (weakening x) weakening (ty-var v) = ty-var (weakening-var v) weakening ty-⋆ = ty-⋆ weakening (ty-pair l r) = ty-pair (weakening l) (weakening r) weakening (ty-projₗ p) = ty-projₗ (weakening p) weakening (ty-projᵣ p) = ty-projᵣ (weakening p) lemma : ∀ {Γ : Ctx n} → (v : Fin (suc n)) → liftΓ Γ v B ∋ v ⦂ A → A ≡ B lemma fzero vzero = refl lemma {Γ = _ ,- _} (fsuc fin) (vsuc v) = lemma fin v subst-eq : (v : Fin (suc n)) → liftΓ Γ v B ∋ v ⦂ A → Γ ⊢ M ⦂ B → Γ ⊢ var v [ v ≔ M ] ⦂ A subst-eq fzero vzero typing = typing subst-eq {Γ = Γ ,- C} (fsuc fin) (vsuc v) typing with fin ≟ fin ... | yes refl rewrite lemma fin v = typing ... | no neq = ⊥-elim (neq refl) subst-neq : (v v' : Fin (suc n)) → liftΓ Γ v B ∋ v' ⦂ A → (prf : ¬ v ≡ v') → Γ ∋ (Data.Fin.punchOut prf) ⦂ A subst-neq v v' v-typing neq with v ≟ v' ... | yes refl = ⊥-elim (neq refl) subst-neq fzero fzero _ _ | no neq = ⊥-elim (neq refl) subst-neq {Γ = Γ ,- C} fzero (fsuc fin) (vsuc v-typing) _ | no neq = v-typing subst-neq {Γ = Γ ,- C} (fsuc fin) fzero vzero _ | no neq = vzero subst-neq {Γ = Γ ,- C} (fsuc fin) (fsuc fin') (vsuc v-typing) neq | no _ = vsuc (subst-neq fin fin' v-typing λ { assump → neq (cong fsuc assump) }) -- | The substitution lemma: Substitution preserves typing. subst : ∀ {Γ : Ctx n} → liftΓ Γ v B ⊢ M ⦂ A → Γ ⊢ N ⦂ B → Γ ⊢ M [ v ≔ N ] ⦂ A subst (ty-abs body) typing = ty-abs (subst body (weakening typing)) subst (ty-app f x) typing = ty-app (subst f typing) (subst x typing) subst {v = v} {Γ = _} (ty-var {v = v'} v-typing) typing with v' ≟ v ... | yes refl = subst-eq v v-typing typing subst {v = fzero} (ty-var {v = fzero} v-typing) typing | no neq = ⊥-elim (neq refl) subst {v = fzero} (ty-var {v = fsuc v'} (vsuc v-typing)) typing | no neq = ty-var v-typing subst {v = fsuc v} {Γ = Γ ,- C} (ty-var {v = fzero} vzero) typing | no neq = ty-var vzero subst {v = fsuc v} {Γ = Γ ,- C} (ty-var {v = fsuc v'} (vsuc v-typing)) typing | no neq with v ≟ v' ... | yes eq = ⊥-elim (neq (cong fsuc (sym eq))) ... | no neq' = ty-var (vsuc (subst-neq v v' v-typing _)) subst ty-⋆ _ = ty-⋆ subst (ty-pair l r) typing = ty-pair (subst l typing) (subst r typing) subst (ty-projₗ p) typing = ty-projₗ (subst p typing) subst (ty-projᵣ p) typing = ty-projᵣ (subst p typing) preservation : ● ⊢ M ⦂ A → M ↦ N → ● ⊢ N ⦂ A preservation (ty-app M-ty N-ty) (red-head M-step) = ty-app (preservation M-ty M-step) N-ty preservation (ty-app M-ty N-ty) (red-arg M-val N-step) = ty-app M-ty (preservation N-ty N-step) preservation (ty-app (ty-abs body-ty) N-ty) (red-β N-value) = subst body-ty N-ty preservation (ty-pair M-ty N-ty) (red-left M-step) = ty-pair (preservation M-ty M-step) N-ty preservation (ty-pair M-ty N-ty) (red-right _ N-step) = ty-pair M-ty (preservation N-ty N-step) preservation (ty-projₗ M-ty) (red-projₗ-inner M-step) = ty-projₗ (preservation M-ty M-step) preservation (ty-projₗ (ty-pair M-ty _)) (red-projₗ _ _) = M-ty preservation (ty-projᵣ M-ty) (red-projᵣ-inner M-step) = ty-projᵣ (preservation M-ty M-step) preservation (ty-projᵣ (ty-pair _ N-ty)) (red-projᵣ _ _) = N-ty
{ "alphanum_fraction": 0.5675193337, "avg_line_length": 37.3555555556, "ext": "agda", "hexsha": "1b4f8857a629f4124000af51b09e7948bcbf0020", "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": "59bc9648f326b7359801fb31ff6f957a166876fc", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "TrulyNonstrict/STLC", "max_forks_repo_path": "STLC/Operational/Eager.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "59bc9648f326b7359801fb31ff6f957a166876fc", "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": "TrulyNonstrict/STLC", "max_issues_repo_path": "STLC/Operational/Eager.agda", "max_line_length": 92, "max_stars_count": 1, "max_stars_repo_head_hexsha": "59bc9648f326b7359801fb31ff6f957a166876fc", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TypesLogicsCats/STLC", "max_stars_repo_path": "STLC/Operational/Eager.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-16T23:53:48.000Z", "max_stars_repo_stars_event_min_datetime": "2020-03-16T23:53:48.000Z", "num_tokens": 2675, "size": 6724 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Indexed container combinators ------------------------------------------------------------------------ module Data.Container.Indexed.Combinator where open import Level open import Data.Container.Indexed open import Data.Empty using (⊥; ⊥-elim) open import Data.Unit using (⊤) open import Data.Product as Prod hiding (Σ) renaming (_×_ to _⟨×⟩_) open import Data.Sum renaming (_⊎_ to _⟨⊎⟩_) open import Function as F hiding (id; const) renaming (_∘_ to _⟨∘⟩_) open import Function.Inverse using (_↔̇_) open import Relation.Unary using (Pred; _⊆_; _∪_; _∩_; ⋃; ⋂) renaming (_⟨×⟩_ to _⟪×⟫_; _⟨⊙⟩_ to _⟪⊙⟫_; _⟨⊎⟩_ to _⟪⊎⟫_) open import Relation.Binary.PropositionalEquality as P using (_≗_; refl) ------------------------------------------------------------------------ -- Combinators -- Identity. id : ∀ {o c r} {O : Set o} → Container O O c r id = F.const (Lift ⊤) ◃ (λ _ → Lift ⊤) / (λ {o} _ _ → o) -- Constant. const : ∀ {i o c r} {I : Set i} {O : Set o} → Pred O c → Container I O c r const X = X ◃ (λ _ → Lift ⊥) / λ _ → ⊥-elim ⟨∘⟩ lower -- Duality. _^⊥ : ∀ {i o c r} {I : Set i} {O : Set o} → Container I O c r → Container I O (c ⊔ r) c (C ◃ R / n) ^⊥ = record { Command = λ o → (c : C o) → R c ; Response = λ {o} _ → C o ; next = λ f c → n c (f c) } -- Strength. infixl 3 _⋊_ _⋊_ : ∀ {i o c r z} {I : Set i} {O : Set o} (C : Container I O c r) (Z : Set z) → Container (I ⟨×⟩ Z) (O ⟨×⟩ Z) c r C ◃ R / n ⋊ Z = C ⟨∘⟩ proj₁ ◃ R / λ {oz} c r → n c r , proj₂ oz infixr 3 _⋉_ _⋉_ : ∀ {i o z c r} {I : Set i} {O : Set o} (Z : Set z) (C : Container I O c r) → Container (Z ⟨×⟩ I) (Z ⟨×⟩ O) c r Z ⋉ C ◃ R / n = C ⟨∘⟩ proj₂ ◃ R / λ {zo} c r → proj₁ zo , n c r -- Composition. infixr 9 _∘_ _∘_ : ∀ {i j k c r} {I : Set i} {J : Set j} {K : Set k} → Container J K c r → Container I J c r → Container I K _ _ C₁ ∘ C₂ = C ◃ R / n where C : ∀ k → Set _ C = ⟦ C₁ ⟧ (Command C₂) R : ∀ {k} → ⟦ C₁ ⟧ (Command C₂) k → Set _ R (c , k) = ◇ C₁ {X = Command C₂} (Response C₂ ⟨∘⟩ proj₂) (_ , c , k) n : ∀ {k} (c : ⟦ C₁ ⟧ (Command C₂) k) → R c → _ n (_ , f) (r₁ , r₂) = next C₂ (f r₁) r₂ -- Product. (Note that, up to isomorphism, this is a special case of -- indexed product.) infixr 2 _×_ _×_ : ∀ {i o c r} {I : Set i} {O : Set o} → Container I O c r → Container I O c r → Container I O c r (C₁ ◃ R₁ / n₁) × (C₂ ◃ R₂ / n₂) = record { Command = C₁ ∩ C₂ ; Response = R₁ ⟪⊙⟫ R₂ ; next = λ { (c₁ , c₂) → [ n₁ c₁ , n₂ c₂ ] } } -- Indexed product. Π : ∀ {x i o c r} {X : Set x} {I : Set i} {O : Set o} → (X → Container I O c r) → Container I O _ _ Π {X = X} C = record { Command = ⋂ X (Command ⟨∘⟩ C) ; Response = ⋃[ x ∶ X ] λ c → Response (C x) (c x) ; next = λ { c (x , r) → next (C x) (c x) r } } -- Sum. (Note that, up to isomorphism, this is a special case of -- indexed sum.) infixr 1 _⊎_ _⊎_ : ∀ {i o c r} {I : Set i} {O : Set o} → Container I O c r → Container I O c r → Container I O _ _ (C₁ ◃ R₁ / n₁) ⊎ (C₂ ◃ R₂ / n₂) = record { Command = C₁ ∪ C₂ ; Response = R₁ ⟪⊎⟫ R₂ ; next = [ n₁ , n₂ ] } -- Indexed sum. Σ : ∀ {x i o c r} {X : Set x} {I : Set i} {O : Set o} → (X → Container I O c r) → Container I O _ r Σ {X = X} C = record { Command = ⋃ X (Command ⟨∘⟩ C) ; Response = λ { (x , c) → Response (C x) c } ; next = λ { (x , c) r → next (C x) c r } } -- Constant exponentiation. (Note that this is a special case of -- indexed product.) infix 0 const[_]⟶_ const[_]⟶_ : ∀ {i o c r ℓ} {I : Set i} {O : Set o} → Set ℓ → Container I O c r → Container I O _ _ const[ X ]⟶ C = Π {X = X} (F.const C) ------------------------------------------------------------------------ -- Correctness proofs module Identity where correct : ∀ {o ℓ c r} {O : Set o} {X : Pred O ℓ} → ⟦ id {c = c}{r} ⟧ X ↔̇ F.id X correct = record { to = P.→-to-⟶ λ xs → proj₂ xs _ ; from = P.→-to-⟶ λ x → (_ , λ _ → x) ; inverse-of = record { left-inverse-of = λ _ → refl ; right-inverse-of = λ _ → refl } } module Constant (ext : ∀ {ℓ} → P.Extensionality ℓ ℓ) where correct : ∀ {i o ℓ₁ ℓ₂} {I : Set i} {O : Set o} (X : Pred O ℓ₁) {Y : Pred O ℓ₂} → ⟦ const X ⟧ Y ↔̇ F.const X Y correct X {Y} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { right-inverse-of = λ _ → refl ; left-inverse-of = λ xs → P.cong (_,_ (proj₁ xs)) (ext (⊥-elim ⟨∘⟩ lower)) } } where to : ⟦ const X ⟧ Y ⊆ X to = proj₁ from : X ⊆ ⟦ const X ⟧ Y from = < F.id , F.const (⊥-elim ⟨∘⟩ lower) > module Duality where correct : ∀ {i o c r ℓ} {I : Set i} {O : Set o} (C : Container I O c r) (X : Pred I ℓ) → ⟦ C ^⊥ ⟧ X ↔̇ (λ o → (c : Command C o) → ∃ λ r → X (next C c r)) correct C X = record { to = P.→-to-⟶ λ { (f , g) → < f , g > } ; from = P.→-to-⟶ λ f → proj₁ ⟨∘⟩ f , proj₂ ⟨∘⟩ f ; inverse-of = record { left-inverse-of = λ { (_ , _) → refl } ; right-inverse-of = λ _ → refl } } module Composition where correct : ∀ {i j k ℓ c r} {I : Set i} {J : Set j} {K : Set k} (C₁ : Container J K c r) (C₂ : Container I J c r) → {X : Pred I ℓ} → ⟦ C₁ ∘ C₂ ⟧ X ↔̇ (⟦ C₁ ⟧ ⟨∘⟩ ⟦ C₂ ⟧) X correct C₁ C₂ {X} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = λ _ → refl ; right-inverse-of = λ _ → refl } } where to : ⟦ C₁ ∘ C₂ ⟧ X ⊆ ⟦ C₁ ⟧ (⟦ C₂ ⟧ X) to ((c , f) , g) = (c , < f , curry g >) from : ⟦ C₁ ⟧ (⟦ C₂ ⟧ X) ⊆ ⟦ C₁ ∘ C₂ ⟧ X from (c , f) = ((c , proj₁ ⟨∘⟩ f) , uncurry (proj₂ ⟨∘⟩ f)) module Product (ext : ∀ {ℓ} → P.Extensionality ℓ ℓ) where correct : ∀ {i o c r} {I : Set i} {O : Set o} (C₁ C₂ : Container I O c r) {X} → ⟦ C₁ × C₂ ⟧ X ↔̇ (⟦ C₁ ⟧ X ∩ ⟦ C₂ ⟧ X) correct C₁ C₂ {X} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = from∘to ; right-inverse-of = λ _ → refl } } where to : ⟦ C₁ × C₂ ⟧ X ⊆ ⟦ C₁ ⟧ X ∩ ⟦ C₂ ⟧ X to ((c₁ , c₂) , k) = ((c₁ , k ⟨∘⟩ inj₁) , (c₂ , k ⟨∘⟩ inj₂)) from : ⟦ C₁ ⟧ X ∩ ⟦ C₂ ⟧ X ⊆ ⟦ C₁ × C₂ ⟧ X from ((c₁ , k₁) , (c₂ , k₂)) = ((c₁ , c₂) , [ k₁ , k₂ ]) from∘to : from ⟨∘⟩ to ≗ F.id from∘to (c , _) = P.cong (_,_ c) (ext [ (λ _ → refl) , (λ _ → refl) ]) module IndexedProduct where correct : ∀ {x i o c r ℓ} {X : Set x} {I : Set i} {O : Set o} (C : X → Container I O c r) {Y : Pred I ℓ} → ⟦ Π C ⟧ Y ↔̇ ⋂[ x ∶ X ] ⟦ C x ⟧ Y correct {X = X} C {Y} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = λ _ → refl ; right-inverse-of = λ _ → refl } } where to : ⟦ Π C ⟧ Y ⊆ ⋂[ x ∶ X ] ⟦ C x ⟧ Y to (c , k) = λ x → (c x , λ r → k (x , r)) from : ⋂[ x ∶ X ] ⟦ C x ⟧ Y ⊆ ⟦ Π C ⟧ Y from f = (proj₁ ⟨∘⟩ f , uncurry (proj₂ ⟨∘⟩ f)) module Sum where correct : ∀ {i o c r ℓ} {I : Set i} {O : Set o} (C₁ C₂ : Container I O c r) {X : Pred I ℓ} → ⟦ C₁ ⊎ C₂ ⟧ X ↔̇ (⟦ C₁ ⟧ X ∪ ⟦ C₂ ⟧ X) correct C₁ C₂ {X} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = from∘to ; right-inverse-of = [ (λ _ → refl) , (λ _ → refl) ] } } where to : ⟦ C₁ ⊎ C₂ ⟧ X ⊆ ⟦ C₁ ⟧ X ∪ ⟦ C₂ ⟧ X to (inj₁ c₁ , k) = inj₁ (c₁ , k) to (inj₂ c₂ , k) = inj₂ (c₂ , k) from : ⟦ C₁ ⟧ X ∪ ⟦ C₂ ⟧ X ⊆ ⟦ C₁ ⊎ C₂ ⟧ X from = [ Prod.map inj₁ F.id , Prod.map inj₂ F.id ] from∘to : from ⟨∘⟩ to ≗ F.id from∘to (inj₁ _ , _) = refl from∘to (inj₂ _ , _) = refl module IndexedSum where correct : ∀ {x i o c r ℓ} {X : Set x} {I : Set i} {O : Set o} (C : X → Container I O c r) {Y : Pred I ℓ} → ⟦ Σ C ⟧ Y ↔̇ ⋃[ x ∶ X ] ⟦ C x ⟧ Y correct {X = X} C {Y} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = λ _ → refl ; right-inverse-of = λ _ → refl } } where to : ⟦ Σ C ⟧ Y ⊆ ⋃[ x ∶ X ] ⟦ C x ⟧ Y to ((x , c) , k) = (x , (c , k)) from : ⋃[ x ∶ X ] ⟦ C x ⟧ Y ⊆ ⟦ Σ C ⟧ Y from (x , (c , k)) = ((x , c) , k) module ConstantExponentiation where correct : ∀ {x i o c r ℓ} {X : Set x} {I : Set i} {O : Set o} (C : Container I O c r) {Y : Pred I ℓ} → ⟦ const[ X ]⟶ C ⟧ Y ↔̇ (⋂ X (F.const (⟦ C ⟧ Y))) correct C {Y} = IndexedProduct.correct (F.const C) {Y}
{ "alphanum_fraction": 0.4398373065, "avg_line_length": 29.7013422819, "ext": "agda", "hexsha": "426276e81a60fac816498d62e561d0dd1b0052e5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Container/Indexed/Combinator.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Container/Indexed/Combinator.agda", "max_line_length": 76, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Container/Indexed/Combinator.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 3785, "size": 8851 }
{-# OPTIONS --without-K --safe #-} module Data.Binary.Definition where open import Level open import Data.Bits public renaming (Bits to 𝔹; [] to 0ᵇ; 0∷_ to 1ᵇ_; 1∷_ to 2ᵇ_) -- The following causes a performance hit: -- open import Agda.Builtin.List using ([]; _∷_; List) -- open import Agda.Builtin.Bool using (Bool; true; false) -- 𝔹 : Type -- 𝔹 = List Bool -- infixr 8 1ᵇ_ 2ᵇ_ -- pattern 0ᵇ = [] -- pattern 1ᵇ_ xs = false ∷ xs -- pattern 2ᵇ_ xs = true ∷ xs
{ "alphanum_fraction": 0.6587982833, "avg_line_length": 23.3, "ext": "agda", "hexsha": "c372ae72ca270e4e45d8517c4d94e186a32e28b6", "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/Binary/Definition.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/Binary/Definition.agda", "max_line_length": 83, "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/Binary/Definition.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": 179, "size": 466 }
------------------------------------------------------------------------------ -- Conat properties ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Conat.PropertiesATP where open import FOTC.Base open import FOTC.Data.Conat open import FOTC.Data.Nat ------------------------------------------------------------------------------ -- Because a greatest post-fixed point is a fixed-point, then the -- Conat predicate is also a pre-fixed point of the functional NatF, -- i.e. -- -- NatF Conat ≤ Conat (see FOTC.Data.Conat.Type). -- See Issue https://github.com/asr/apia/issues/81 . Conat-inA : D → Set Conat-inA n = n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n') {-# ATP definition Conat-inA #-} Conat-in : ∀ {n} → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat n') → Conat n Conat-in h = Conat-coind Conat-inA h' h where postulate h' : ∀ {n} → Conat-inA n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ Conat-inA n') {-# ATP prove h' #-} -- See Issue https://github.com/asr/apia/issues/81 . 0-ConatA : D → Set 0-ConatA n = n ≡ zero {-# ATP definition 0-ConatA #-} 0-Conat : Conat zero 0-Conat = Conat-coind 0-ConatA h refl where postulate h : ∀ {n} → 0-ConatA n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ 0-ConatA n') {-# ATP prove h #-} ∞-Conat : Conat ∞ ∞-Conat = Conat-coind A h refl where A : D → Set A n = n ≡ ∞ {-# ATP definition A #-} postulate h : ∀ {n} → A n → n ≡ zero ∨ (∃[ n' ] n ≡ succ₁ n' ∧ A n') {-# ATP prove h #-} N→Conat : ∀ {n} → N n → Conat n N→Conat Nn = Conat-coind N h Nn where h : ∀ {m} → N m → m ≡ zero ∨ (∃[ m' ] m ≡ succ₁ m' ∧ N m') h nzero = prf where postulate prf : zero ≡ zero ∨ (∃[ m' ] zero ≡ succ₁ m' ∧ N m') {-# ATP prove prf #-} h (nsucc {m} Nm) = prf where postulate prf : succ₁ m ≡ zero ∨ (∃[ m' ] succ₁ m ≡ succ₁ m' ∧ N m') {-# ATP prove prf #-}
{ "alphanum_fraction": 0.4778887304, "avg_line_length": 30.4782608696, "ext": "agda", "hexsha": "06d20e778b12c5183fb1f16bfee4260217dfd950", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Data/Conat/PropertiesATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Data/Conat/PropertiesATP.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/Conat/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": 703, "size": 2103 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything module Cubical.Algebra.Structures {a} (A : Type a) where -- The file is divided into sections depending on the arities of the -- components of the algebraic structure. open import Cubical.Foundations.Prelude using (isSet; cong; _∙_) open import Cubical.Foundations.HLevels using (hSet) open import Cubical.Algebra.Base open import Cubical.Algebra.Definitions open import Cubical.Algebra.Properties open import Cubical.Data.Sigma using (_,_; fst; snd) open import Cubical.Data.Nat.Base renaming (zero to ℕ-zero; suc to ℕ-suc) open import Cubical.Data.Int.Base open import Cubical.Data.NatPlusOne.Base open import Cubical.Relation.Nullary using (¬_) open import Cubical.Relation.Binary.Reasoning.Equality _NotEqualTo_ : A → Type a _NotEqualTo_ z = Σ[ x ∈ A ] ¬ (x ≡ z) ------------------------------------------------------------------------ -- Algebra with 1 binary operation ------------------------------------------------------------------------ record IsMagma (_•_ : Op₂ A) : Type a where constructor ismagma field is-set : isSet A set : hSet a set = A , is-set record IsSemigroup (_•_ : Op₂ A) : Type a where constructor issemigroup field isMagma : IsMagma _•_ assoc : Associative _•_ open IsMagma isMagma public infixl 10 _^_ _^_ : A → ℕ₊₁ → A x ^ one = x x ^ (2+ n) = x • (x ^ 1+ n) record IsBand (_•_ : Op₂ A) : Type a where constructor isband field isSemigroup : IsSemigroup _•_ idem : Idempotent _•_ open IsSemigroup isSemigroup public record IsCommutativeSemigroup (_•_ : Op₂ A) : Type a where constructor iscommsemigroup field isSemigroup : IsSemigroup _•_ comm : Commutative _•_ open IsSemigroup isSemigroup public record IsSemilattice (_•_ : Op₂ A) : Type a where constructor issemilattice field isBand : IsBand _•_ comm : Commutative _•_ open IsBand isBand public record IsSelectiveMagma (_•_ : Op₂ A) : Type a where constructor isselmagma field isMagma : IsMagma _•_ sel : Selective _•_ open IsMagma isMagma public ------------------------------------------------------------------------ -- Algebra with 1 binary operation & 1 element ------------------------------------------------------------------------ record IsMonoid (_•_ : Op₂ A) (ε : A) : Type a where constructor ismonoid field isSemigroup : IsSemigroup _•_ identity : Identity ε _•_ open IsSemigroup isSemigroup public hiding (_^_) identityˡ : LeftIdentity ε _•_ identityˡ = fst identity identityʳ : RightIdentity ε _•_ identityʳ = snd identity ε-uniqueʳ : ∀ {e} → RightIdentity e _•_ → ε ≡ e ε-uniqueʳ idʳ = id-unique′ identityˡ idʳ ε-uniqueˡ : ∀ {e} → LeftIdentity e _•_ → e ≡ ε ε-uniqueˡ idˡ = id-unique′ idˡ identityʳ infixl 10 _^_ _^_ : A → ℕ → A _ ^ ℕ-zero = ε x ^ (ℕ-suc n) = x • (x ^ n) record IsCommutativeMonoid (_•_ : Op₂ A) (ε : A) : Type a where constructor iscommmonoid field isMonoid : IsMonoid _•_ ε comm : Commutative _•_ open IsMonoid isMonoid public isCommutativeSemigroup : IsCommutativeSemigroup _•_ isCommutativeSemigroup = record { isSemigroup = isSemigroup ; comm = comm } record IsIdempotentCommutativeMonoid (_•_ : Op₂ A) (ε : A) : Type a where constructor isidemcommmonoid field isCommutativeMonoid : IsCommutativeMonoid _•_ ε idem : Idempotent _•_ open IsCommutativeMonoid isCommutativeMonoid public -- Idempotent commutative monoids are also known as bounded lattices. -- Note that the BoundedLattice necessarily uses the notation inherited -- from monoids rather than lattices. IsBoundedLattice = IsIdempotentCommutativeMonoid pattern isboundedlattice = isidemcommmonoid module IsBoundedLattice {_•_ : Op₂ A} {ε : A} (isIdemCommMonoid : IsIdempotentCommutativeMonoid _•_ ε) = IsIdempotentCommutativeMonoid isIdemCommMonoid ------------------------------------------------------------------------ -- Algebra with 1 binary operation, 1 unary operation & 1 element ------------------------------------------------------------------------ record IsGroup (_•_ : Op₂ A) (ε : A) (_⁻¹ : Op₁ A) : Type a where constructor isgroup field isMonoid : IsMonoid _•_ ε inverse : Inverse ε _⁻¹ _•_ open IsMonoid isMonoid public hiding (_^_) infixl 10 _^_ _^_ : A → ℤ → A x ^ pos ℕ-zero = ε x ^ pos (ℕ-suc n) = x • (x ^ pos n) x ^ negsuc ℕ-zero = x ⁻¹ x ^ negsuc (ℕ-suc n) = (x ⁻¹) • (x ^ negsuc n) -- Right division infixl 6 _/_ _/_ : Op₂ A x / y = x • (y ⁻¹) -- Left division infixr 6 _/ˡ_ _/ˡ_ : Op₂ A x /ˡ y = (x ⁻¹) • y inverseˡ : LeftInverse ε _⁻¹ _•_ inverseˡ = fst inverse inverseʳ : RightInverse ε _⁻¹ _•_ inverseʳ = snd inverse inv-uniqueʳ : ∀ x y → (x • y) ≡ ε → x ≡ (y ⁻¹) inv-uniqueʳ = assoc+id+invʳ⇒invʳ-unique assoc identity inverseʳ inv-uniqueˡ : ∀ x y → (x • y) ≡ ε → y ≡ (x ⁻¹) inv-uniqueˡ = assoc+id+invˡ⇒invˡ-unique assoc identity inverseˡ cancelˡ : LeftCancellative _•_ cancelˡ = assoc+idˡ+invˡ⇒cancelˡ assoc identityˡ inverseˡ cancelʳ : RightCancellative _•_ cancelʳ = assoc+idʳ+invʳ⇒cancelʳ assoc identityʳ inverseʳ record IsAbelianGroup (_+_ : Op₂ A) (ε : A) (-_ : Op₁ A) : Type a where constructor isabgroup field isGroup : IsGroup _+_ ε -_ comm : Commutative _+_ open IsGroup isGroup public hiding (_/ˡ_) renaming (_/_ to _-_; _^_ to _*_) isCommutativeMonoid : IsCommutativeMonoid _+_ ε isCommutativeMonoid = record { isMonoid = isMonoid ; comm = comm } open IsCommutativeMonoid isCommutativeMonoid public using (isCommutativeSemigroup) ------------------------------------------------------------------------ -- Algebra with 2 binary operations ------------------------------------------------------------------------ -- Note that `IsLattice` is not defined in terms of `IsSemilattice` -- because the idempotence laws of ⋀ and ⋁ can be derived from the -- absorption laws, which makes the corresponding "idem" fields -- redundant. The derived idempotence laws are stated and proved in -- `Algebra.Properties.Lattice` along with the fact that every lattice -- consists of two semilattices. record IsLattice (_⋀_ _⋁_ : Op₂ A) : Type a where constructor islattice field ⋀-comm : Commutative _⋀_ ⋀-assoc : Associative _⋀_ ⋁-comm : Commutative _⋁_ ⋁-assoc : Associative _⋁_ absorptive : Absorptive _⋀_ _⋁_ ⋀-absorbs-⋁ : _⋀_ Absorbs _⋁_ ⋀-absorbs-⋁ = fst absorptive ⋁-absorbs-⋀ : _⋁_ Absorbs _⋀_ ⋁-absorbs-⋀ = snd absorptive record IsDistributiveLattice (_⋀_ _⋁_ : Op₂ A) : Type a where constructor isdistrlattice field isLattice : IsLattice _⋀_ _⋁_ ⋀-distribʳ-⋁ : _⋀_ DistributesOverʳ _⋁_ open IsLattice isLattice public ------------------------------------------------------------------------ -- Algebra with 2 binary operations & 1 element ------------------------------------------------------------------------ record IsNearSemiring (_+_ _*_ : Op₂ A) (0# : A) : Type a where constructor isnearsemiring field +-isMonoid : IsMonoid _+_ 0# *-isSemigroup : IsSemigroup _*_ distribˡ : _*_ DistributesOverˡ _+_ zeroˡ : LeftZero 0# _*_ open IsMonoid +-isMonoid public renaming ( assoc to +-assoc ; identity to +-identity ; identityˡ to +-identityˡ ; identityʳ to +-identityʳ ; ε-uniqueˡ to 0#-uniqueˡ ; ε-uniqueʳ to 0#-uniqueʳ ; isMagma to +-isMagma ; isSemigroup to +-isSemigroup ; _^_ to _**_ ) open IsSemigroup *-isSemigroup public using (_^_) renaming ( assoc to *-assoc ; isMagma to *-isMagma ) record IsSemiringWithoutOne (_+_ _*_ : Op₂ A) (0# : A) : Type a where constructor issemiringwo1 field +-isCommutativeMonoid : IsCommutativeMonoid _+_ 0# *-isSemigroup : IsSemigroup _*_ distrib : _*_ DistributesOver _+_ zero : Zero 0# _*_ open IsCommutativeMonoid +-isCommutativeMonoid public using () renaming ( comm to +-comm ; isMonoid to +-isMonoid ; isCommutativeSemigroup to +-isCommutativeSemigroup ) zeroˡ : LeftZero 0# _*_ zeroˡ = fst zero zeroʳ : RightZero 0# _*_ zeroʳ = snd zero distribˡ : _*_ DistributesOverˡ _+_ distribˡ = fst distrib distribʳ : _*_ DistributesOverʳ _+_ distribʳ = snd distrib isNearSemiring : IsNearSemiring _+_ _*_ 0# isNearSemiring = record { +-isMonoid = +-isMonoid ; *-isSemigroup = *-isSemigroup ; distribˡ = distribˡ ; zeroˡ = zeroˡ } open IsNearSemiring isNearSemiring public hiding (+-isMonoid; zeroˡ; *-isSemigroup; distribˡ) record IsCommutativeSemiringWithoutOne (_+_ _*_ : Op₂ A) (0# : A) : Type a where constructor iscommsemiringwo1 field isSemiringWithoutOne : IsSemiringWithoutOne _+_ _*_ 0# *-comm : Commutative _*_ open IsSemiringWithoutOne isSemiringWithoutOne public ------------------------------------------------------------------------ -- Algebra with 2 binary operations & 2 elements ------------------------------------------------------------------------ record IsSemiringWithoutAnnihilatingZero (_+_ _*_ : Op₂ A) (0# 1# : A) : Type a where constructor issemiringwoa0 field -- Note that these Algebra do have an additive unit, but this -- unit does not necessarily annihilate multiplication. +-isCommutativeMonoid : IsCommutativeMonoid _+_ 0# *-isMonoid : IsMonoid _*_ 1# distrib : _*_ DistributesOver _+_ distribˡ : _*_ DistributesOverˡ _+_ distribˡ = fst distrib distribʳ : _*_ DistributesOverʳ _+_ distribʳ = snd distrib open IsCommutativeMonoid +-isCommutativeMonoid public renaming ( assoc to +-assoc ; identity to +-identity ; identityˡ to +-identityˡ ; identityʳ to +-identityʳ ; ε-uniqueˡ to 0#-uniqueˡ ; ε-uniqueʳ to 0#-uniqueʳ ; comm to +-comm ; isMagma to +-isMagma ; isSemigroup to +-isSemigroup ; isMonoid to +-isMonoid ; isCommutativeSemigroup to +-isCommutativeSemigroup ; _^_ to _**_ ) open IsMonoid *-isMonoid public using () renaming ( assoc to *-assoc ; identity to *-identity ; identityˡ to *-identityˡ ; identityʳ to *-identityʳ ; ε-uniqueˡ to 1#-uniqueˡ ; ε-uniqueʳ to 1#-uniqueʳ ; isMagma to *-isMagma ; isSemigroup to *-isSemigroup ) record IsSemiring (_+_ _*_ : Op₂ A) (0# 1# : A) : Type a where constructor issemiring field isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _+_ _*_ 0# 1# zero : Zero 0# _*_ open IsSemiringWithoutAnnihilatingZero isSemiringWithoutAnnihilatingZero public isSemiringWithoutOne : IsSemiringWithoutOne _+_ _*_ 0# isSemiringWithoutOne = record { +-isCommutativeMonoid = +-isCommutativeMonoid ; *-isSemigroup = *-isSemigroup ; distrib = distrib ; zero = zero } open IsSemiringWithoutOne isSemiringWithoutOne public using ( isNearSemiring ; zeroˡ ; zeroʳ ) record IsCommutativeSemiring (_+_ _*_ : Op₂ A) (0# 1# : A) : Type a where constructor iscommsemiring field isSemiring : IsSemiring _+_ _*_ 0# 1# *-comm : Commutative _*_ open IsSemiring isSemiring public isCommutativeSemiringWithoutOne : IsCommutativeSemiringWithoutOne _+_ _*_ 0# isCommutativeSemiringWithoutOne = record { isSemiringWithoutOne = isSemiringWithoutOne ; *-comm = *-comm } *-isCommutativeSemigroup : IsCommutativeSemigroup _*_ *-isCommutativeSemigroup = record { isSemigroup = *-isSemigroup ; comm = *-comm } *-isCommutativeMonoid : IsCommutativeMonoid _*_ 1# *-isCommutativeMonoid = record { isMonoid = *-isMonoid ; comm = *-comm } ------------------------------------------------------------------------ -- Algebra with 2 binary operations, 1 unary operation & 2 elements ------------------------------------------------------------------------ record IsRing (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Type a where constructor isring field +-isAbelianGroup : IsAbelianGroup _+_ 0# -_ *-isMonoid : IsMonoid _*_ 1# distrib : _*_ DistributesOver _+_ open IsAbelianGroup +-isAbelianGroup public renaming ( assoc to +-assoc ; identity to +-identity ; identityˡ to +-identityˡ ; identityʳ to +-identityʳ ; ε-uniqueˡ to 0#-uniqueˡ ; ε-uniqueʳ to 0#-uniqueʳ ; inverse to +-inverse ; inverseˡ to +-inverseˡ ; inverseʳ to +-inverseʳ ; inv-uniqueˡ to neg-uniqueˡ ; inv-uniqueʳ to neg-uniqueʳ ; cancelˡ to +-cancelˡ ; cancelʳ to +-cancelʳ ; comm to +-comm ; isMagma to +-isMagma ; isSemigroup to +-isSemigroup ; isMonoid to +-isMonoid ; isCommutativeMonoid to +-isCommutativeMonoid ; isCommutativeSemigroup to +-isCommutativeSemigroup ; isGroup to +-isGroup ; _*_ to _**_ ) open IsMonoid *-isMonoid public using () renaming ( assoc to *-assoc ; identity to *-identity ; identityˡ to *-identityˡ ; identityʳ to *-identityʳ ; ε-uniqueˡ to 1#-uniqueˡ ; ε-uniqueʳ to 1#-uniqueʳ ; isMagma to *-isMagma ; isSemigroup to *-isSemigroup ) distribˡ : _*_ DistributesOverˡ _+_ distribˡ = fst distrib distribʳ : _*_ DistributesOverʳ _+_ distribʳ = snd distrib zeroˡ : LeftZero 0# _*_ zeroˡ = assoc+distribʳ+idʳ+invʳ⇒zeˡ {_+_ = _+_} {_*_ = _*_} { -_} +-assoc distribʳ +-identityʳ +-inverseʳ zeroʳ : RightZero 0# _*_ zeroʳ = assoc+distribˡ+idʳ+invʳ⇒zeʳ {_+_ = _+_} {_*_ = _*_} { -_} +-assoc distribˡ +-identityʳ +-inverseʳ zero : Zero 0# _*_ zero = zeroˡ , zeroʳ isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero _+_ _*_ 0# 1# isSemiringWithoutAnnihilatingZero = record { +-isCommutativeMonoid = +-isCommutativeMonoid ; *-isMonoid = *-isMonoid ; distrib = distrib } isSemiring : IsSemiring _+_ _*_ 0# 1# isSemiring = record { isSemiringWithoutAnnihilatingZero = isSemiringWithoutAnnihilatingZero ; zero = zero } open IsSemiring isSemiring public using (isNearSemiring; isSemiringWithoutOne) record IsCommutativeRing (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Type a where constructor iscommring field isRing : IsRing _+_ _*_ -_ 0# 1# *-comm : Commutative _*_ open IsRing isRing public *-isCommutativeMonoid : IsCommutativeMonoid _*_ 1# *-isCommutativeMonoid = record { isMonoid = *-isMonoid ; comm = *-comm } isCommutativeSemiring : IsCommutativeSemiring _+_ _*_ 0# 1# isCommutativeSemiring = record { isSemiring = isSemiring ; *-comm = *-comm } open IsCommutativeSemiring isCommutativeSemiring public using ( isCommutativeSemiringWithoutOne ) record IsIntegralDomain {ℓ} (Cancellable : A → Type ℓ) (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Type (ℓ-max a ℓ) where constructor isintegraldomain Cancellables : Type (ℓ-max a ℓ) Cancellables = Σ A Cancellable field isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1# *-cancelˡ : ∀ (x : Cancellables) {y z} → (x .fst) * y ≡ (x .fst) * z → y ≡ z open IsCommutativeRing isCommutativeRing public *-cancelʳ : ∀ {x y} (z : Cancellables) → x * (z .fst) ≡ y * (z .fst) → x ≡ y *-cancelʳ {x} {y} zᵖ@(z , _) eq = *-cancelˡ zᵖ ( z * x ≡⟨ *-comm z x ⟩ x * z ≡⟨ eq ⟩ y * z ≡⟨ *-comm y z ⟩ z * y ∎) record IsBooleanAlgebra (_⋀_ _⋁_ : Op₂ A) (¬_ : Op₁ A) (⊤ ⊥ : A) : Type a where constructor isbooleanalgebra field isDistributiveLattice : IsDistributiveLattice _⋀_ _⋁_ ⋀-identityʳ : RightIdentity ⊤ _⋀_ ⋁-identityʳ : RightIdentity ⊥ _⋁_ ⋀-complementʳ : RightInverse ⊥ ¬_ _⋀_ ⋁-complementʳ : RightInverse ⊤ ¬_ _⋁_ open IsDistributiveLattice isDistributiveLattice public ⋀-identityˡ : LeftIdentity ⊤ _⋀_ ⋀-identityˡ x = ⋀-comm _ _ ∙ ⋀-identityʳ x ⋀-identity : Identity ⊤ _⋀_ ⋀-identity = ⋀-identityˡ , ⋀-identityʳ ⋁-identityˡ : LeftIdentity ⊥ _⋁_ ⋁-identityˡ x = ⋁-comm _ _ ∙ ⋁-identityʳ x ⋁-identity : Identity ⊥ _⋁_ ⋁-identity = ⋁-identityˡ , ⋁-identityʳ ⋀-complementˡ : LeftInverse ⊥ ¬_ _⋀_ ⋀-complementˡ = comm+invʳ⇒invˡ ⋀-comm ⋀-complementʳ ⋀-complement : Inverse ⊥ ¬_ _⋀_ ⋀-complement = ⋀-complementˡ , ⋀-complementʳ ⋁-complementˡ : LeftInverse ⊤ ¬_ _⋁_ ⋁-complementˡ = comm+invʳ⇒invˡ ⋁-comm ⋁-complementʳ ⋁-complement : Inverse ⊤ ¬_ _⋁_ ⋁-complement = ⋁-complementˡ , ⋁-complementʳ ------------------------------------------------------------------------ -- Algebra with 2 binary operations, 2 unary operations & 2 elements ------------------------------------------------------------------------ -- The standard definition of division rings excludes the zero ring, but such a restriction is rarely important record IsDivisionRing {ℓ} (Invertible : A → Type ℓ) (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (_⁻¹ : Σ A Invertible → A) (0# 1# : A) : Type (ℓ-max a ℓ) where constructor isdivring Invertibles : Type (ℓ-max a ℓ) Invertibles = Σ A Invertible field isRing : IsRing _+_ _*_ -_ 0# 1# *-inverseˡ : (x : Invertibles) → (x ⁻¹) * (x .fst) ≡ 1# *-inverseʳ : (x : Invertibles) → (x .fst) * (x ⁻¹) ≡ 1# open IsRing isRing public infixl 6 _/_ _/_ : A → Invertibles → A x / y = x * (y ⁻¹) infixr 6 _/ˡ_ _/ˡ_ : Invertibles → A → A x /ˡ y = (x ⁻¹) * y *-cancelˡ : ∀ (x : Invertibles) {y z} → (x .fst) * y ≡ (x .fst) * z → y ≡ z *-cancelˡ xᵖ@(x , _) {y} {z} eq = y ≡˘⟨ *-identityˡ y ⟩ 1# * y ≡˘⟨ cong (_* y) (*-inverseˡ xᵖ) ⟩ ((xᵖ ⁻¹) * x) * y ≡⟨ *-assoc (xᵖ ⁻¹) x y ⟩ (xᵖ ⁻¹) * (x * y) ≡⟨ cong ((xᵖ ⁻¹) *_) eq ⟩ (xᵖ ⁻¹) * (x * z) ≡˘⟨ *-assoc (xᵖ ⁻¹) x z ⟩ ((xᵖ ⁻¹) * x) * z ≡⟨ cong (_* z) (*-inverseˡ xᵖ) ⟩ 1# * z ≡⟨ *-identityˡ z ⟩ z ∎ *-cancelʳ : ∀ {x y} (z : Invertibles) → x * (z .fst) ≡ y * (z .fst) → x ≡ y *-cancelʳ {x} {y} zᵖ@(z , _) eq = x ≡˘⟨ *-identityʳ x ⟩ x * 1# ≡˘⟨ cong (x *_) (*-inverseʳ zᵖ) ⟩ x * (z * (zᵖ ⁻¹)) ≡˘⟨ *-assoc x z (zᵖ ⁻¹) ⟩ (x * z) * (zᵖ ⁻¹) ≡⟨ cong (_* (zᵖ ⁻¹)) eq ⟩ (y * z) * (zᵖ ⁻¹) ≡⟨ *-assoc y z (zᵖ ⁻¹) ⟩ y * (z * (zᵖ ⁻¹)) ≡⟨ cong (y *_) (*-inverseʳ zᵖ) ⟩ y * 1# ≡⟨ *-identityʳ y ⟩ y ∎ record IsField {ℓ} (Invertible : A → Type ℓ) (_+_ _*_ : Op₂ A) (-_ : Op₁ A) (_⁻¹ : Σ A Invertible → A) (0# 1# : A) : Type (ℓ-max a ℓ) where constructor isfield field isDivisionRing : IsDivisionRing Invertible _+_ _*_ -_ _⁻¹ 0# 1# *-comm : Commutative _*_ open IsDivisionRing isDivisionRing public hiding (_/ˡ_) isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1# isCommutativeRing = record { isRing = isRing ; *-comm = *-comm } isIntegralDomain : IsIntegralDomain Invertible _+_ _*_ -_ 0# 1# isIntegralDomain = record { isCommutativeRing = isCommutativeRing ; *-cancelˡ = *-cancelˡ } open IsIntegralDomain isIntegralDomain public using (*-isCommutativeMonoid; isCommutativeSemiring; isCommutativeSemiringWithoutOne)
{ "alphanum_fraction": 0.5817266976, "avg_line_length": 29.6937869822, "ext": "agda", "hexsha": "434efc7c2ca1a94e3fe7e6bf899c4debcbd66d92", "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/Structures.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/Structures.agda", "max_line_length": 146, "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/Structures.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7040, "size": 20073 }
module BBHeap.Order.Properties {A : Set}(_≤_ : A → A → Set) where open import BBHeap _≤_ open import BBHeap.Order _≤_ renaming (Acc to Accₕ ; acc to accₕ) open import Data.Nat open import Induction.Nat open import Induction.WellFounded ii-acc : ∀ {b} {h} → Acc _<′_ (# {b} h) → Accₕ h ii-acc (acc rs) = accₕ (λ h' #h'<′#h → ii-acc (rs (# h') #h'<′#h)) ≺-wf : ∀ {b} h → Accₕ {b} h ≺-wf = λ h → ii-acc (<-well-founded (# h))
{ "alphanum_fraction": 0.5976744186, "avg_line_length": 28.6666666667, "ext": "agda", "hexsha": "71fc67d1359dbab91fee7361510569a75ca117e5", "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/Order/Properties.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/Order/Properties.agda", "max_line_length": 66, "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/Order/Properties.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": 179, "size": 430 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Emptyrec {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped as U hiding (wk) open import Definition.Untyped.Properties open import Definition.Typed import Definition.Typed.Weakening as T open import Definition.Typed.Properties open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Application open import Definition.LogicalRelation.Substitution open import Definition.LogicalRelation.Substitution.Properties import Definition.LogicalRelation.Substitution.Irrelevance as S open import Definition.LogicalRelation.Substitution.Reflexivity open import Definition.LogicalRelation.Substitution.Weakening open import Definition.LogicalRelation.Substitution.Introductions.Empty open import Definition.LogicalRelation.Substitution.Introductions.Pi open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst open import Tools.Product open import Tools.Unit open import Tools.Empty open import Tools.Nat import Tools.PropositionalEquality as PE -- Empty elimination closure reduction (requires reducible terms and equality). Emptyrec-subst* : ∀ {Γ C n n′ l} → Γ ⊢ C → Γ ⊢ n ⇒* n′ ∷ Empty → ([Empty] : Γ ⊩⟨ l ⟩ Empty) → Γ ⊩⟨ l ⟩ n′ ∷ Empty / [Empty] → Γ ⊢ Emptyrec C n ⇒* Emptyrec C n′ ∷ C Emptyrec-subst* C (id x) [Empty] [n′] = id (Emptyrecⱼ C x) Emptyrec-subst* C (x ⇨ n⇒n′) [Empty] [n′] = let q , w = redSubst*Term n⇒n′ [Empty] [n′] a , s = redSubstTerm x [Empty] q in Emptyrec-subst C x ⇨ conv* (Emptyrec-subst* C n⇒n′ [Empty] [n′]) (refl C) -- Reducibility of empty elimination under a valid substitution. EmptyrecTerm : ∀ {F n Γ Δ σ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F / [Γ]) (⊢Δ : ⊢ Δ) ([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ) ([σn] : Δ ⊩⟨ l ⟩ n ∷ Empty / Emptyᵣ (idRed:*: (Emptyⱼ ⊢Δ))) → Δ ⊩⟨ l ⟩ Emptyrec (subst σ F) n ∷ subst σ F / proj₁ ([F] ⊢Δ [σ]) EmptyrecTerm {F} {n} {Γ} {Δ} {σ} {l} [Γ] [F] ⊢Δ [σ] (Emptyₜ m d n≡n (ne (neNfₜ neM ⊢m m≡m))) = let [Empty] = Emptyᵛ {l = l} [Γ] [σEmpty] = proj₁ ([Empty] ⊢Δ [σ]) [σm] = neuTerm [σEmpty] neM ⊢m m≡m [σF] = proj₁ ([F] ⊢Δ [σ]) ⊢F = escape [σF] ⊢F≡F = escapeEq [σF] (reflEq [σF]) EmptyrecM = neuTerm [σF] (Emptyrecₙ neM) (Emptyrecⱼ ⊢F ⊢m) (~-Emptyrec ⊢F≡F m≡m) reduction = Emptyrec-subst* ⊢F (redₜ d) [σEmpty] [σm] in proj₁ (redSubst*Term reduction [σF] EmptyrecM) -- Reducibility of empty elimination congruence under a valid substitution equality. Emptyrec-congTerm : ∀ {F F′ n m Γ Δ σ σ′ l} ([Γ] : ⊩ᵛ Γ) ([F] : Γ ⊩ᵛ⟨ l ⟩ F / [Γ]) ([F′] : Γ ⊩ᵛ⟨ l ⟩ F′ / [Γ]) ([F≡F′] : Γ ⊩ᵛ⟨ l ⟩ F ≡ F′ / [Γ] / [F]) (⊢Δ : ⊢ Δ) ([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ) ([σ′] : Δ ⊩ˢ σ′ ∷ Γ / [Γ] / ⊢Δ) ([σ≡σ′] : Δ ⊩ˢ σ ≡ σ′ ∷ Γ / [Γ] / ⊢Δ / [σ]) ([σn] : Δ ⊩⟨ l ⟩ n ∷ Empty / Emptyᵣ (idRed:*: (Emptyⱼ ⊢Δ))) ([σm] : Δ ⊩⟨ l ⟩ m ∷ Empty / Emptyᵣ (idRed:*: (Emptyⱼ ⊢Δ))) ([σn≡σm] : Δ ⊩⟨ l ⟩ n ≡ m ∷ Empty / Emptyᵣ (idRed:*: (Emptyⱼ ⊢Δ))) → Δ ⊩⟨ l ⟩ Emptyrec (subst σ F) n ≡ Emptyrec (subst σ′ F′) m ∷ subst σ F / proj₁ ([F] ⊢Δ [σ]) Emptyrec-congTerm {F} {F′} {n} {m} {Γ} {Δ} {σ} {σ′} {l} [Γ] [F] [F′] [F≡F′] ⊢Δ [σ] [σ′] [σ≡σ′] (Emptyₜ n′ d n≡n (ne (neNfₜ neN′ ⊢n′ n≡n₁))) (Emptyₜ m′ d′ m≡m (ne (neNfₜ neM′ ⊢m′ m≡m₁))) (Emptyₜ₌ n″ m″ d₁ d₁′ t≡u (ne (neNfₜ₌ x₂ x₃ prop₂))) = let n″≡n′ = whrDet*Term (redₜ d₁ , ne x₂) (redₜ d , ne neN′) m″≡m′ = whrDet*Term (redₜ d₁′ , ne x₃) (redₜ d′ , ne neM′) [Empty] = Emptyᵛ {l = l} [Γ] [σEmpty] = proj₁ ([Empty] ⊢Δ [σ]) [σ′Empty] = proj₁ ([Empty] ⊢Δ [σ′]) [σF] = proj₁ ([F] ⊢Δ [σ]) [σ′F] = proj₁ ([F] ⊢Δ [σ′]) [σ′F′] = proj₁ ([F′] ⊢Δ [σ′]) [σn′] = neuTerm [σEmpty] neN′ ⊢n′ n≡n₁ [σ′m′] = neuTerm [σ′Empty] neM′ ⊢m′ m≡m₁ ⊢F = escape [σF] ⊢F≡F = escapeEq [σF] (reflEq [σF]) ⊢F′ = escape [σ′F′] ⊢F′≡F′ = escapeEq [σ′F′] (reflEq [σ′F′]) ⊢σF≡σ′F = escapeEq [σF] (proj₂ ([F] ⊢Δ [σ]) [σ′] [σ≡σ′]) ⊢σ′F≡σ′F′ = escapeEq [σ′F] ([F≡F′] ⊢Δ [σ′]) ⊢F≡F′ = ≅-trans ⊢σF≡σ′F ⊢σ′F≡σ′F′ [σF≡σ′F] = proj₂ ([F] ⊢Δ [σ]) [σ′] [σ≡σ′] [σ′F≡σ′F′] = [F≡F′] ⊢Δ [σ′] [σF≡σ′F′] = transEq [σF] [σ′F] [σ′F′] [σF≡σ′F] [σ′F≡σ′F′] EmptyrecN = neuTerm [σF] (Emptyrecₙ neN′) (Emptyrecⱼ ⊢F ⊢n′) (~-Emptyrec ⊢F≡F n≡n₁) EmptyrecM = neuTerm [σ′F′] (Emptyrecₙ neM′) (Emptyrecⱼ ⊢F′ ⊢m′) (~-Emptyrec ⊢F′≡F′ m≡m₁) EmptyrecN≡M = (neuEqTerm [σF] (Emptyrecₙ neN′) (Emptyrecₙ neM′) (Emptyrecⱼ ⊢F ⊢n′) (conv (Emptyrecⱼ ⊢F′ ⊢m′) (sym (≅-eq (escapeEq [σF] (transEq [σF] [σ′F] [σ′F′] [σF≡σ′F] [σ′F≡σ′F′]))))) (~-Emptyrec ⊢F≡F′ (PE.subst₂ (λ x y → _ ⊢ x ~ y ∷ _) n″≡n′ m″≡m′ prop₂))) reduction₁ = Emptyrec-subst* ⊢F (redₜ d) [σEmpty] [σn′] reduction₂ = Emptyrec-subst* ⊢F′ (redₜ d′) [σ′Empty] [σ′m′] eq₁ = proj₂ (redSubst*Term reduction₁ [σF] EmptyrecN) eq₂ = proj₂ (redSubst*Term reduction₂ [σ′F′] EmptyrecM) in transEqTerm [σF] eq₁ (transEqTerm [σF] EmptyrecN≡M (convEqTerm₂ [σF] [σ′F′] [σF≡σ′F′] (symEqTerm [σ′F′] eq₂))) -- Validity of empty elimination. Emptyrecᵛ : ∀ {F n Γ l} ([Γ] : ⊩ᵛ Γ) ([Empty] : Γ ⊩ᵛ⟨ l ⟩ Empty / [Γ]) ([F] : Γ ⊩ᵛ⟨ l ⟩ F / [Γ]) → ([n] : Γ ⊩ᵛ⟨ l ⟩ n ∷ Empty / [Γ] / [Empty]) → Γ ⊩ᵛ⟨ l ⟩ Emptyrec F n ∷ F / [Γ] / [F] Emptyrecᵛ {F} {n} {l = l} [Γ] [Empty] [F] [n] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let [σn] = irrelevanceTerm {l′ = l} (proj₁ ([Empty] ⊢Δ [σ])) (Emptyᵣ (idRed:*: (Emptyⱼ ⊢Δ))) (proj₁ ([n] ⊢Δ [σ])) in EmptyrecTerm {F = F} [Γ] [F] ⊢Δ [σ] [σn] , λ {σ'} [σ′] [σ≡σ′] → let [σ′n] = irrelevanceTerm {l′ = l} (proj₁ ([Empty] ⊢Δ [σ′])) (Emptyᵣ (idRed:*: (Emptyⱼ ⊢Δ))) (proj₁ ([n] ⊢Δ [σ′])) [σn≡σ′n] = irrelevanceEqTerm {l′ = l} (proj₁ ([Empty] ⊢Δ [σ])) (Emptyᵣ (idRed:*: (Emptyⱼ ⊢Δ))) (proj₂ ([n] ⊢Δ [σ]) [σ′] [σ≡σ′]) congTerm = Emptyrec-congTerm {F = F} {F′ = F} [Γ] [F] [F] (reflᵛ {F} {l = l} [Γ] [F]) ⊢Δ [σ] [σ′] [σ≡σ′] [σn] [σ′n] [σn≡σ′n] in congTerm -- Validity of empty elimination congruence. Emptyrec-congᵛ : ∀ {F F′ n n′ Γ l} ([Γ] : ⊩ᵛ Γ) ([Empty] : Γ ⊩ᵛ⟨ l ⟩ Empty / [Γ]) ([F] : Γ ⊩ᵛ⟨ l ⟩ F / [Γ]) ([F′] : Γ ⊩ᵛ⟨ l ⟩ F′ / [Γ]) ([F≡F′] : Γ ⊩ᵛ⟨ l ⟩ F ≡ F′ / [Γ] / [F]) ([n] : Γ ⊩ᵛ⟨ l ⟩ n ∷ Empty / [Γ] / [Empty]) ([n′] : Γ ⊩ᵛ⟨ l ⟩ n′ ∷ Empty / [Γ] / [Empty]) ([n≡n′] : Γ ⊩ᵛ⟨ l ⟩ n ≡ n′ ∷ Empty / [Γ] / [Empty]) → Γ ⊩ᵛ⟨ l ⟩ Emptyrec F n ≡ Emptyrec F′ n′ ∷ F / [Γ] / [F] Emptyrec-congᵛ {F} {F′} {n} {n′} {l = l} [Γ] [Empty] [F] [F′] [F≡F′] [n] [n′] [n≡n′] {Δ = Δ} {σ = σ} ⊢Δ [σ] = let [σn] = irrelevanceTerm {l′ = l} (proj₁ ([Empty] ⊢Δ [σ])) (Emptyᵣ (idRed:*: (Emptyⱼ ⊢Δ))) (proj₁ ([n] ⊢Δ [σ])) [σn′] = irrelevanceTerm {l′ = l} (proj₁ ([Empty] ⊢Δ [σ])) (Emptyᵣ (idRed:*: (Emptyⱼ ⊢Δ))) (proj₁ ([n′] ⊢Δ [σ])) [σn≡σn′] = irrelevanceEqTerm {l′ = l} (proj₁ ([Empty] ⊢Δ [σ])) (Emptyᵣ (idRed:*: (Emptyⱼ ⊢Δ))) ([n≡n′] ⊢Δ [σ]) congTerm = Emptyrec-congTerm {F} {F′} [Γ] [F] [F′] [F≡F′] ⊢Δ [σ] [σ] (reflSubst [Γ] ⊢Δ [σ]) [σn] [σn′] [σn≡σn′] in congTerm
{ "alphanum_fraction": 0.4603971963, "avg_line_length": 47.2928176796, "ext": "agda", "hexsha": "60dedc274f9500f25595e8191a3c05c8713ccdaa", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Emptyrec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Emptyrec.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Emptyrec.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3710, "size": 8560 }
module Numeral.Finite.Bound where open import Lang.Instance open import Numeral.Finite open import Numeral.Natural open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Proofs -- For an arbitrary number `n`, `bound-[≤] n` is the same number as `n` semantically but with a different boundary on the type. -- Example: bound-[≤] p (3: 𝕟(10)) = 3: 𝕟(20) where p: (10 ≤ 20) bound-[≤] : ∀{a b} → (a ≤ b) → (𝕟(a) → 𝕟(b)) bound-[≤] {𝐒 a} {𝐒 b} _ 𝟎 = 𝟎 bound-[≤] {𝐒 a} {𝐒 b} (succ p) (𝐒 n) = 𝐒(bound-[≤] p n) bound-𝐒 : ∀{n} → 𝕟(n) → 𝕟(ℕ.𝐒(n)) bound-𝐒 = bound-[≤] [≤]-of-[𝐒] bound-exact : ∀{a b} → (i : 𝕟(a)) → (𝕟-to-ℕ i < b) → 𝕟(b) bound-exact {𝐒 a} {𝐒 b} 𝟎 (succ _) = 𝟎 bound-exact {𝐒 a} {𝐒 b} (𝐒 i) (succ p) = 𝐒(bound-exact i p)
{ "alphanum_fraction": 0.5873221216, "avg_line_length": 36.8095238095, "ext": "agda", "hexsha": "d3bcf16953e0f6bcb36ed8100fdaff38527a3568", "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/Finite/Bound.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/Finite/Bound.agda", "max_line_length": 127, "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/Finite/Bound.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": 374, "size": 773 }
module Avionics.Real where open import Algebra.Definitions using (LeftIdentity; RightIdentity; Commutative) open import Data.Bool using (Bool; _∧_) open import Data.Float using (Float) open import Data.Maybe using (Maybe; just; nothing) open import Data.Nat using (ℕ) open import Level using (0ℓ; _⊔_) renaming (suc to lsuc) open import Relation.Binary using (Decidable; _Preserves_⟶_) open import Relation.Binary.Definitions using (Transitive; Trans) open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import Relation.Nullary using (Dec; yes; no) open import Relation.Nullary.Decidable using (False; ⌊_⌋) open import Relation.Unary using (Pred; _∈_) infix 4 _<_ _≤_ _<ᵇ_ _≤ᵇ_ infixl 6 _+_ _-_ infixl 7 _*_ infix 4 _≟_ postulate ℝ : Set -- TODO: `fromFloat` should return `Maybe ℝ` fromFloat : Float → ℝ toFloat : ℝ → Float fromℕ : ℕ → ℝ _+_ _*_ _^_ : ℝ → ℝ → ℝ -_ abs _^2 : ℝ → ℝ e π 0ℝ 1ℝ -1/2 1/2 2ℝ : ℝ -- This was inspired on how the standard library handles things. -- See: https://plfa.github.io/Decidable/ _<_ _≤_ : ℝ → ℝ → Set _≟_ : Decidable {A = ℝ} _≡_ _≤?_ : (m n : ℝ) → Dec (m ≤ n) _<?_ : (m n : ℝ) → Dec (m < n) _<ᵇ_ _≤ᵇ_ _≡ᵇ_ : ℝ → ℝ → Bool p <ᵇ q = ⌊ p <? q ⌋ p ≤ᵇ q = ⌊ p ≤? q ⌋ p ≡ᵇ q = ⌊ p ≟ q ⌋ _≢0 : ℝ → Set p ≢0 = False (p ≟ 0ℝ) Subset : Set → Set _ Subset A = Pred A 0ℓ -- Dangerous definitions, but necessary! postulate ⟨0,∞⟩ [0,∞⟩ [0,1] : Subset ℝ 1/_ : (p : ℝ) → ℝ √_ : (x : ℝ) → ℝ _÷_ : (p q : ℝ) → ℝ (p ÷ q) = p * (1/ q) -- Dangerous definitions, but necessary! postulate m÷n<o≡m<o*n : ∀ m n o → (m ÷ n <ᵇ o) ≡ (m <ᵇ o * n) m<o÷n≡m*n<o : ∀ m n o → (m <ᵇ o ÷ n) ≡ (m * n <ᵇ o) _-_ : ℝ → ℝ → ℝ p - q = p + (- q) postulate double-neg : ∀ (x y : ℝ) → y - (y - x) ≡ x neg-involutive : ∀ x → -(- x) ≡ x neg-distrib-+ : ∀ m n → - (m + n) ≡ (- m) + (- n) neg-def : ∀ m → 0ℝ - m ≡ - m m-m≡0 : ∀ m → m - m ≡ 0ℝ neg-distribˡ-* : ∀ x y → - (x * y) ≡ (- x) * y √x^2≡absx : ∀ x → √ (x ^2) ≡ abs x >0→≢0 : ∀ {x : ℝ} → x ∈ ⟨0,∞⟩ → x ≢0 >0→≥0 : ∀ {x : ℝ} → x ∈ ⟨0,∞⟩ → x ∈ [0,∞⟩ >0*>0→>0 : ∀ {p q : ℝ} → p ∈ ⟨0,∞⟩ → q ∈ ⟨0,∞⟩ → (p * q) ∈ ⟨0,∞⟩ ≢0*≢0→≢0 : ∀ {p q : ℝ} → p ≢0 → q ≢0 → (p * q) ≢0 2>0 : 2ℝ ∈ ⟨0,∞⟩ π>0 : π ∈ ⟨0,∞⟩ e^x>0 : (x : ℝ) → (e ^ x) ∈ ⟨0,∞⟩ x*x≡x^2 : ∀ x → x * x ≡ x ^2 x^2*y^2≡⟨xy⟩^2 : ∀ x y → (x ^2) * (y ^2) ≡ (x * y)^2 1/x^2≡⟨1/x⟩^2 : ∀ x → 1/ (x ^2) ≡ (1/ x)^2 --√q≥0 : (q : ℝ) → (0≤q : q ∈ [0,∞⟩) → (√ q) {0≤q} ∈ [0,∞⟩ --q>0→√q>0 : {q : ℝ} → (0<q : q ∈ ⟨0,∞⟩) → (√ q) {>0→≥0 0<q} ∈ ⟨0,∞⟩ 0≤→[0,∞⟩ : {n : ℝ} → 0ℝ ≤ n → n ∈ [0,∞⟩ 0<→⟨0,∞⟩ : {n : ℝ} → 0ℝ < n → n ∈ ⟨0,∞⟩ [0,∞⟩→0≤ : {n : ℝ} → n ∈ [0,∞⟩ → 0ℝ ≤ n ⟨0,∞⟩→0< : {n : ℝ} → n ∈ ⟨0,∞⟩ → 0ℝ < n m≤n→m-p≤n-p : {m n p : ℝ} → m ≤ n → m - p ≤ n - p m<n→m-p<n-p : {m n p : ℝ} → m < n → m - p < n - p -- trans-≤ reduces to: {i j k : ℝ} → i ≤ j → j ≤ k → i ≤ k trans-≤ : Transitive _≤_ <-transˡ : Trans _<_ _≤_ _<_ --+-identityˡ : LeftIdentity 0ℝ _+_ --+-identityʳ : RightIdentity 0ℝ _+_ +-identityˡ : ∀ x → 0ℝ + x ≡ x +-identityʳ : ∀ x → x + 0ℝ ≡ x --+-comm : Commutative _+_ +-comm : ∀ m n → m + n ≡ n + m --+-assoc : Associative _+_ +-assoc : ∀ m n o → m + (n + o) ≡ (m + n) + o *-comm : ∀ m n → m * n ≡ n * m *-assoc : ∀ m n o → m * (n * o) ≡ (m * n) * o --0ℝ ≟_ 0≟0≡yes0≡0 : (0ℝ ≟ 0ℝ) ≡ yes refl -- TODO: These properties should be written for _<_ instead of _<ᵇ_ abs<x→<x∧-x< : ∀ {u x} → (abs u <ᵇ x) ≡ ((u <ᵇ x) ∧ (- x <ᵇ u)) --neg-mono-<-> : -_ Preserves _<_ ⟶ (λ a b -> b < a) neg-mono-<-> : ∀ m n → (m <ᵇ n) ≡ (- n <ᵇ - m) --+-monoˡ-< : ∀ n → (_+ n) Preserves _<_ ⟶ _<_ +-monoˡ-< : ∀ n o p → (o <ᵇ p) ≡ (n + o <ᵇ n + p) -- One of the weakest points in the whole library architecture!!! -- This is wrong, really wrong, but useful {-# COMPILE GHC ℝ = type Double #-} {-# COMPILE GHC fromFloat = \x -> x #-} {-# COMPILE GHC toFloat = \x -> x #-} {-# COMPILE GHC fromℕ = fromIntegral #-} {-# COMPILE GHC _<ᵇ_ = (<) #-} {-# COMPILE GHC _≤ᵇ_ = (<=) #-} {-# COMPILE GHC _≡ᵇ_ = (==) #-} {-# COMPILE GHC _+_ = (+) #-} {-# COMPILE GHC _-_ = (-) #-} {-# COMPILE GHC _*_ = (*) #-} {-# COMPILE GHC _^_ = (**) #-} {-# COMPILE GHC _^2 = (**2) #-} {-# COMPILE GHC e = 2.71828182845904523536 #-} {-# COMPILE GHC π = 3.14159265358979323846 #-} {-# COMPILE GHC 0ℝ = 0 #-} {-# COMPILE GHC 1ℝ = 1 #-} {-# COMPILE GHC 2ℝ = 2 #-} {-# COMPILE GHC -1/2 = -1/2 #-} -- REAAALY CAREFUL WITH THIS! -- TODO: Add some runtime checking to this. Fail hard if divisor is zero {-# COMPILE GHC 1/_ = \x -> (1/x) #-} {-# COMPILE GHC _÷_ = \x y -> (x/y) #-} {-# COMPILE GHC √_ = \x -> sqrt x #-}
{ "alphanum_fraction": 0.4822083243, "avg_line_length": 29.3481012658, "ext": "agda", "hexsha": "d2ab4fa978c18638a8ba785cd60edc79dc30fed8", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-09-20T00:36:09.000Z", "max_forks_repo_forks_event_min_datetime": "2020-09-20T00:36:09.000Z", "max_forks_repo_head_hexsha": "bf518286f9d06dc6ea91e111be6ddedb3e2b728f", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "helq/safety-envelopes-sentinels", "max_forks_repo_path": "agda/Avionics/Real.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf518286f9d06dc6ea91e111be6ddedb3e2b728f", "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": "helq/safety-envelopes-sentinels", "max_issues_repo_path": "agda/Avionics/Real.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "bf518286f9d06dc6ea91e111be6ddedb3e2b728f", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "helq/safety-envelopes-sentinels", "max_stars_repo_path": "agda/Avionics/Real.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2294, "size": 4637 }
open import Prelude open import Nat open import List open import Bij -- The contents of this file were originally written in a different codebase, -- which was itself a descendant of a prior codebase that had been using non-standard -- definitions of naturals and other basic definitions. As such this code has -- inherited these non-standard idioms, as seen in Prelude, Nat, and List. Ideally, -- this file would be refactored to use the Agda standard library instead, but beyond -- the significant effort of refactoring, the Agda standard library appears not to be -- packaged with Agda, and must be installed separately. The difficulties inherent in -- attempting to use a "standard library" that is not sufficiently standard as to be -- included with Agda itself, added to the difficulties of refactoring, have led us -- to continue with the the non-standard forms and definitions. We hope that they are -- fairly self-explanatory and intuitive. Below we note some of our idioms that may -- not be obvious: -- * We use "Some" and "None" instead of "Just" and "Nothing" -- * abort is used to prove any goal given ⊥ -- * == is used for reflexive equality -- * Z is zero, 1+ is suc -- * ≤ is defined as data, < is defined as n < m = n ≤ m ∧ n ≠ m -- * l⟦ i ⟧ is used to (maybe) get the ith element of list l -- * ∥ l ∥ is the length of a list -- -- Many of the definitions and theorems are documented to indicate their equivalents -- in the Coq standard libraries Coq.FSets.FMapInterface and Coq.FSets.FMapFacts module Delta (K : Set) {{bij : bij K Nat}} where abstract -- almost everything in the module is abstract open import delta-lemmas K {{bij}} ---- core definitions ---- data dd (V : Set) : Set where DD : dl V → dd V -- nil/empty ∅ : {V : Set} → dd V ∅ = DD [] -- singleton ■_ : {V : Set} → (K ∧ V) → dd V ■_ (k , v) = DD <| (nat k , v) :: [] -- extension/insertion -- Corresponds to FMapInterface.add _,,_ : ∀{V} → dd V → (K ∧ V) → dd V (DD d) ,, (k , v) = DD <| d ,,' (nat k , v) infixl 10 _,,_ -- lookup function -- Corresponds to FMapInterface.find _⟨_⟩ : {V : Set} → dd V → K → Maybe V (DD d) ⟨ k ⟩ = d lkup (nat k) -- There doesn't appear to be a corresponding function in FMapInterface destruct : ∀{V} → dd V → Maybe ((K ∧ V) ∧ dd V) destruct (DD []) = None destruct (DD ((n , v) :: [])) = Some ((key n , v) , DD []) destruct (DD ((n , v) :: ((m , v') :: dd))) = Some ((key n , v) , DD ((m + 1+ n , v') :: dd)) -- size -- Corresponds to FMapInterface.cardinal ||_|| : {V : Set} → dd V → Nat || DD d || = ∥ d ∥ -- membership -- Corresponds to FMapInterface.MapsTo _∈_ : {V : Set} (p : K ∧ V) → (d : dd V) → Set _∈_ {V} (k , v) (DD d) = _∈'_ {V} (nat k , v) d -- domain (not abstract) -- Corresponds to FMapInterface.In dom : {V : Set} → dd V → K → Set dom {V} d k = Σ[ v ∈ V ] ((k , v) ∈ d) -- apartness, i.e. the opposite of dom (not abstract) _#_ : {V : Set} → K → dd V → Set k # d = dom d k → ⊥ abstract -- maps f across the values of the delta dict -- Corresponds to FMapInterface.map dltmap : {A B : Set} → (A → B) → dd A → dd B dltmap f (DD d) = DD <| map (λ {(hn , hv) → (hn , f hv)}) d -- FMapInterface doesn't appear to have a corresponding function list⇒dlt : {V : Set} → List (K ∧ V) → dd V list⇒dlt d = d |> map (λ where (k , v) → (nat k , v)) |> list⇒dlt' |> DD -- converts a delta dict into a list of key-value pairs; the inverse of list⇒dlt -- Corresponds to FMapInterface.elements dlt⇒list : {V : Set} → dd V → List (K ∧ V) dlt⇒list (DD d) = dlt⇒list' d |> map (λ where (n , v) → (key n , v)) -- union merge A B is the union of A and B, -- with (merge a b) being invoked to handle the mappings they have in common union : {V : Set} → (V → V → V) → dd V → dd V → dd V union merge (DD d1) (DD d2) = DD <| union' merge d1 d2 0 ---- core theorems ---- -- The next two theorems show that lookup (_⟨_⟩) is consistent with membership (_∈_) -- As such, future theorems which relate to membership can be taken to appropriately -- comment on lookup as well. -- Corresponds to FMapInterface.find_1 lookup-cons-1 : {V : Set} {d : dd V} {k : K} {v : V} → (k , v) ∈ d → d ⟨ k ⟩ == Some v lookup-cons-1 {V} {DD d} {k} {v} = lookup-cons-1' {V} {d} {nat k} {v} -- Corresponds to FMapInterface.find_2 lookup-cons-2 : {V : Set} {d : dd V} {k : K} {v : V} → d ⟨ k ⟩ == Some v → (k , v) ∈ d lookup-cons-2 {V} {DD d} {k} {v} h = lookup-cons-2' {d = d} {nat k} h -- membership (_∈_) respects insertion (_,,_) -- Corresponds to FMapInterface.add_1 k,v∈d,,k,v : {V : Set} {d : dd V} {k : K} {v : V} → (k , v) ∈ (d ,, (k , v)) k,v∈d,,k,v {V} {d = DD d} {k} = n,v∈'d,,n,v {d = d} {nat k} -- insertion respects membership -- Corresponds to FMapInterface.add_2 k∈d→k∈d+ : {V : Set} {d : dd V} {k k' : K} {v v' : V} → k ≠ k' → (k , v) ∈ d → (k , v) ∈ (d ,, (k' , v')) k∈d→k∈d+ {V} {DD d} {k} {k'} {v} {v'} ne h = n∈d→'n∈d+ {V} {d} {nat k} {nat k'} {v} {v'} (inj-cp ne) h -- insertion can't generate spurious membership -- Corresponds to FMapInterface.add_3 k∈d+→k∈d : {V : Set} {d : dd V} {k k' : K} {v v' : V} → k ≠ k' → (k , v) ∈ (d ,, (k' , v')) → (k , v) ∈ d k∈d+→k∈d {V} {d = DD d} {k} {k'} {v} {v'} ne h = n∈d+→'n∈d {V} {d} {nat k} {nat k'} {v} {v'} (inj-cp ne) h -- Decidability of membership -- This also packages up an appeal to delta dict membership into a form that -- lets us retain more information -- Corresponds to FMapFacts.In_dec mem-dec : {V : Set} (d : dd V) (k : K) → dom d k ∨ k # d mem-dec {V} (DD d) k = mem-dec' {V} d (nat k) -- delta dicts contain at most one binding for each variable -- Corresponds to FMapFacts.MapsTo_fun mem-unicity : {V : Set} {d : dd V} {k : K} {v v' : V} → (k , v) ∈ d → (k , v') ∈ d → v == v' mem-unicity vh v'h with lookup-cons-1 vh | lookup-cons-1 v'h ... | vh' | v'h' = someinj (! vh' · v'h') -- meaning of nil, i.e. nothing is in nil -- Corresponds to FMapFacts.empty_in_iff k#∅ : {V : Set} {k : K} → _#_ {V} k ∅ k#∅ (_ , ()) -- meaning of the singleton ■-def : {V : Set} {k : K} {v : V} → (■ (k , v)) == ∅ ,, (k , v) ■-def = refl -- Theorem 2: Extensionality -- (i.e. if two dicts represent the same mapping from ids to values, -- then they are reflexively equal as judged by _==_) -- Corresponds to FMapFacts.Equal_Equiv extensional : {V : Set} {d1 d2 : dd V} → ((k : K) → d1 ⟨ k ⟩ == d2 ⟨ k ⟩) → d1 == d2 extensional {V} {DD d1} {DD d2} all-bindings-== = ap1 DD <| extensional' {V} {d1} {d2} eqv-nat where eqv-nat : (n : Nat) → (d1 lkup n) == (d2 lkup n) eqv-nat n with bij.surj bij n ... | k , surj with all-bindings-== k ... | eq rewrite surj = eq -- Theorem 3: Decidable Equality -- This doesn't seem to directly correspond to any of the Coq theorems ==-dec : {V : Set} (d1 d2 : dd V) → ((v1 v2 : V) → v1 == v2 ∨ v1 ≠ v2) → d1 == d2 ∨ d1 ≠ d2 ==-dec {V} (DD d1) (DD d2) h with ==-dec' {V} d1 d2 h ... | Inl refl = Inl refl ... | Inr ne = Inr (λ where refl → ne refl) -- The next two theorems specify the behavior of destruct and prove that -- it behaves as intended. The third one combines them to match the paper. destruct-thm-1 : ∀{V} {d : dd V} → destruct d == None → d == ∅ destruct-thm-1 {d = DD []} eq = refl destruct-thm-1 {d = DD (_ :: [])} () destruct-thm-1 {d = DD (_ :: (_ :: _))} () destruct-thm-2 : ∀{V} {d d' : dd V} {k : K} {v : V} → destruct d == Some ((k , v) , d') → k # d' ∧ d == d' ,, (k , v) destruct-thm-2 {d = DD ((n , v) :: [])} refl rewrite convert-bij2 {{bij}} {t = n} = n#'[] , refl destruct-thm-2 {d = DD ((n , v) :: ((m , v') :: t))} refl rewrite convert-bij2 {{bij}} {t = n} with too-small (n<m→n<s+m n<1+n) ... | not-in with <dec n (m + 1+ n) ... | Inl lt rewrite ! (undelta n m lt) = not-in , refl ... | Inr (Inl eq) = abort (n≠n+1+m (eq · (n+1+m==1+n+m · +comm {1+ m}))) ... | Inr (Inr gt) = abort (<antisym gt (n<m→n<s+m n<1+n)) -- Theorem 4: Not-So-Easy Destructibility destruct-thm : ∀{V} {d d' : dd V} {k : K} {v : V} → (destruct d == None → d == ∅) ∧ (destruct d == Some ((k , v) , d') → k # d' ∧ d == d' ,, (k , v)) destruct-thm = destruct-thm-1 , destruct-thm-2 -- When using destruct or delete, this theorem is useful for establishing termination -- Roughly corresponds to FMapFacts.cardinal_2 extend-size : {V : Set} {d : dd V} {k : K} {v : V} → k # d → || d ,, (k , v) || == 1+ || d || extend-size {V} {DD d} {k} {v} n#d = extend-size' {V} {d} {nat k} {v} n#d -- remove a specific mapping from a delta dict -- Roughly corresponds to FMapInterface.remove, and associated theorems delete : {V : Set} {d : dd V} {k : K} {v : V} → (k , v) ∈ d → Σ[ d⁻ ∈ dd V ] ( d == d⁻ ,, (k , v) ∧ k # d⁻) delete {V} {DD d} {k} {v} h with delete' {V} {d} {nat k} {v} h ... | _ , refl , # = _ , refl , # ---- contraction and exchange ---- -- Theorem 5 contraction : {V : Set} {d : dd V} {k : K} {v v' : V} → d ,, (k , v') ,, (k , v) == d ,, (k , v) contraction {V} {DD d} {k} {v} {v'} = ap1 DD <| contraction' {d = d} {nat k} {v} {v'} -- Theorem 6 exchange : {V : Set} {d : dd V} {k1 k2 : K} {v1 v2 : V} → k1 ≠ k2 → d ,, (k1 , v1) ,, (k2 , v2) == d ,, (k2 , v2) ,, (k1 , v1) exchange {V} {DD d} {k1} {k2} {v1} {v2} k1≠k2 = ap1 DD <| exchange' {d = d} <| inj-cp k1≠k2 ---- union theorems ---- k,v∈d1→k∉d2→k,v∈d1∪d2 : {V : Set} {m : V → V → V} {d1 d2 : dd V} {k : K} {v : V} → (k , v) ∈ d1 → k # d2 → (k , v) ∈ union m d1 d2 k,v∈d1→k∉d2→k,v∈d1∪d2 {d1 = DD d1} {DD d2} k∈d1 k#d2 = lemma-union'-1 k∈d1 0≤n (tr (λ y → y #' d2) (! (n+m-n==m 0≤n)) k#d2) k∉d1→k,v∈d2→k,v∈d1∪d2 : {V : Set} {m : V → V → V} {d1 d2 : dd V} {k : K} {v : V} → k # d1 → (k , v) ∈ d2 → (k , v) ∈ union m d1 d2 k∉d1→k,v∈d2→k,v∈d1∪d2 {d1 = DD d1} {DD d2} {k} k#d1 k∈d2 with lemma-union'-2 {n = Z} (tr (λ y → y #' d1) (! n+Z==n) k#d1) k∈d2 ... | rslt rewrite n+Z==n {nat k} = rslt k∈d1→k∈d2→k∈d1∪d2 : {V : Set} {m : V → V → V} {d1 d2 : dd V} {k : K} {v1 v2 : V} → (k , v1) ∈ d1 → (k , v2) ∈ d2 → (k , m v1 v2) ∈ union m d1 d2 k∈d1→k∈d2→k∈d1∪d2 {d1 = DD d1} {DD d2} {k} {v1} k∈d1 k∈d2 with lemma-union'-3 (tr (λ y → (y , v1) ∈' d1) (! n+Z==n) k∈d1) k∈d2 ... | rslt rewrite n+Z==n {nat k} = rslt k∈d1∪d2→k∈d1∨k∈d2 : {V : Set} {m : V → V → V} {d1 d2 : dd V} {k : K} → dom (union m d1 d2) k → dom d1 k ∨ dom d2 k k∈d1∪d2→k∈d1∨k∈d2 {d1 = DD d1} {DD d2} k∈d1∪d2 with lemma-union'-4 {n = Z} k∈d1∪d2 k∈d1∪d2→k∈d1∨k∈d2 k∈d1∪d2 | Inl k'∈d1 = Inl k'∈d1 k∈d1∪d2→k∈d1∨k∈d2 k∈d1∪d2 | Inr (_ , refl , k'∈d2) = Inr k'∈d2 ---- dltmap theorem ---- -- The Coq.FSets library uses different theorems to establish to specify map dltmap-func : {V1 V2 : Set} {d : dd V1} {f : V1 → V2} {k : K} {v : V1} → dltmap f (d ,, (k , v)) == dltmap f d ,, (k , f v) dltmap-func {d = DD d} {f} {k} {v} = ap1 DD (dltmap-func' {d = d}) ---- dlt <=> list theorems ---- -- Corresponds to FMapInterface.cardinal_1 dlt⇒list-size : {V : Set} {d : dd V} → ∥ dlt⇒list d ∥ == || d || dlt⇒list-size {d = DD d} = map-len · dlt⇒list-size' -- Corresponds to FMapInterface.elements_1 dlt⇒list-In-1 : {V : Set} {d : dd V} {k : K} {v : V} → (k , v) ∈ d → (k , v) In dlt⇒list d dlt⇒list-In-1 {d = DD d} {k} in' rewrite ! <| convert-bij1 {f = k} with dlt⇒list-In-1' in' ... | in'' rewrite convert-bij2 {{bij}} {t = bij.convert bij k} = map-In in'' -- Corresponds to FMapInterface.elements_2 dlt⇒list-In-2 : {V : Set} {d : dd V} {k : K} {v : V} → (k , v) In dlt⇒list d → (k , v) ∈ d dlt⇒list-In-2 {V} {d = DD d} {k} {v} in' with map-In {f = λ where (k' , v') → (nat k' , v')} in' ... | in'' rewrite map^2 {f = λ where (k' , v') → (nat k' , v')} {g = λ where (n' , v') → (key n' , v')} {l = dlt⇒list' d} = dlt⇒list-In-2' (tr (λ y → (nat k , v) In y) (map^2 · (map-ext bij-pair-1 · map-id)) (map-In {f = λ where (k , v) → (nat k , v)} in')) list⇒dlt-In : {V : Set} {l : List (K ∧ V)} {k : K} {v : V} → (k , v) ∈ list⇒dlt l → (k , v) In l list⇒dlt-In {l = l} {k} {v} in' with list⇒dlt-In' {l = map (λ { (k , v) → nat k , v }) l} in' |> map-In {f = λ where (n , v) → key n , v} ... | in'' rewrite convert-bij1 {f = k} = tr (λ y → (k , v) In y) (map^2 · (map-ext bij-pair-2 · map-id)) in'' list⇒dlt-key-In : {V : Set} {l : List (K ∧ V)} {k : K} {v : V} → (k , v) In l → dom (list⇒dlt l) k list⇒dlt-key-In {_} {(k , v) :: l} {k} {v} LInH rewrite foldl-++ {l1 = reverse <| map (λ where (k , v) → nat k , v) l} {(nat k , v) :: []} {_,,'_} {[]} = _ , tr (λ y → (nat k , v) ∈' y) (! <| foldl-++ {l1 = reverse <| map (λ where (k , v) → nat k , v) l}) (n,v∈'d,,n,v {d = list⇒dlt' <| map (λ where (k , v) → nat k , v) l}) list⇒dlt-key-In {V} {(k' , v') :: l} {k} {v} (LInT in') with list⇒dlt-key-In in' ... | (_ , in'') = _ , tr (λ y → (nat k , vv) ∈' y) (! <| foldl-++ {l1 = reverse <| map (λ where (k , v) → nat k , v) l}) lem' where nat-inj : ∀{k1 k2} → nat k1 == nat k2 → k1 == k2 nat-inj eq = ! (convert-bij1 {{bij}}) · (ap1 key eq · convert-bij1 {{bij}}) lem : Σ[ vv ∈ V ] ((nat k , vv) ∈' (list⇒dlt' (map (λ { (k , v) → nat k , v }) l) ,,' (nat k' , v'))) lem with natEQ (nat k) (nat k') ... | Inl eq rewrite ! <| nat-inj eq = _ , n,v∈'d,,n,v {d = list⇒dlt' (map (λ { (k , v) → nat k , v }) l)} ... | Inr ne = _ , n∈d→'n∈d+ ne in'' vv = π1 lem lem' = π2 lem -- contrapositives of some previous theorems dlt⇒list-In-1-cp : {V : Set} {d : dd V} {k : K} → (Σ[ v ∈ V ] ((k , v) In dlt⇒list d) → ⊥) → k # d dlt⇒list-In-1-cp {d = DD d} not-in = λ where (_ , in') → not-in (_ , (dlt⇒list-In-1 in')) list⇒dlt-key-In-cp : {V : Set} {l : List (K ∧ V)} {k : K} → k # list⇒dlt l → Σ[ v ∈ V ] ((k , v) In l) → ⊥ list⇒dlt-key-In-cp k#d' (_ , k∈l) = k#d' (list⇒dlt-key-In k∈l) list⇒dlt-order : {V : Set} {l1 l2 : List (K ∧ V)} {k : K} {v1 v2 : V} → (k , v1) ∈ (list⇒dlt ((k , v1) :: l1 ++ ((k , v2) :: l2))) list⇒dlt-order {_} {l1} {l2} {k} {v1} {v2} = tr (λ y → (nat k , v1) ∈' foldl _,,'_ [] (reverse y ++ ((nat k , v1) :: []))) (map-++-comm {a = l1}) (list⇒dlt-order' {l1 = map (λ where (k , v) → nat k , v) l1}) dlt⇒list-inversion : {V : Set} {d : dd V} → list⇒dlt (dlt⇒list d) == d dlt⇒list-inversion {d = DD d} = extensional lem where lem : (k : K) → (list⇒dlt (dlt⇒list <| DD d) ⟨ k ⟩ == DD d ⟨ k ⟩) lem k with mem-dec (list⇒dlt (dlt⇒list <| DD d)) k ... | Inl (_ , k∈d') = lookup-cons-1 k∈d' · (k∈d' |> list⇒dlt-In |> dlt⇒list-In-2 |> lookup-cons-1 {d = DD d} |> !) ... | Inr k#d' = lookup-cp-2' k#d' · (k#d' |> list⇒dlt-key-In-cp |> dlt⇒list-In-1-cp |> lookup-cp-2' {d = d} |> !)
{ "alphanum_fraction": 0.4626579625, "avg_line_length": 41.5348258706, "ext": "agda", "hexsha": "a9f340ca5b0242fcf29795570bd59e476ebe120a", "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": "db857f3e7dc9a4793f68504e6365d93ed75d7f88", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nickcollins/dependent-dicts-agda", "max_forks_repo_path": "Delta.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "db857f3e7dc9a4793f68504e6365d93ed75d7f88", "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": "nickcollins/dependent-dicts-agda", "max_issues_repo_path": "Delta.agda", "max_line_length": 126, "max_stars_count": null, "max_stars_repo_head_hexsha": "db857f3e7dc9a4793f68504e6365d93ed75d7f88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nickcollins/dependent-dicts-agda", "max_stars_repo_path": "Delta.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6622, "size": 16697 }
module FixityOutOfScopeInRecord where postulate _+_ : Set record R : Set where infixl 30 _+_ -- Should complain that _+_ is not in (the same) scope -- in (as) its fixity declaration.
{ "alphanum_fraction": 0.7287234043, "avg_line_length": 18.8, "ext": "agda", "hexsha": "af0f39a883fb90adbc77f9d70a57dfb82cf6daf1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Fail/FixityOutOfScopeInRecord1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Fail/FixityOutOfScopeInRecord1.agda", "max_line_length": 54, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/FixityOutOfScopeInRecord1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 55, "size": 188 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types open import LibraBFT.Impl.Consensus.Liveness.ProposerElection open import LibraBFT.ImplShared.Base.Types open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.LBFT open import Optics.All open import Util.Lemmas open import Util.Prelude module LibraBFT.Impl.Consensus.Liveness.Properties.ProposerElection where -- TUTORIAL module isValidProposalMSpec (b : Block) where pe = _^∙ lProposerElection mAuthor = b ^∙ bAuthor round = b ^∙ bRound contract : ∀ pre Post → (mAuthor ≡ nothing → Post (Left ProposalDoesNotHaveAnAuthor) pre []) → (Maybe-Any (getValidProposer (pe pre) round ≢_) mAuthor → Post (Left ProposerForBlockIsNotValidForThisRound) pre []) → (Maybe-Any (getValidProposer (pe pre) round ≡_) mAuthor → Post (Right unit) pre []) → LBFT-weakestPre (isValidProposalM b) Post pre -- 1. `isValidProposalM` begins with `RWS-maybe`, so we must provide two cases: -- one where `b ^∙ bAuthor` is `nothing` and one where it is `just` -- something -- 2. When it is nothing, we appeal to the assumed proof proj₁ (contract pre Post pfNone pf≢ pfOk) mAuthor≡nothing = pfNone mAuthor≡nothing -- 3. When it is something, we step into `isValidProposerM`. This means: -- - we use the proposer election of the round manager (`pe` and `pe≡`) -- - we apply `isValidProposer` to `pe` (`isvp-pe` and `isvp-pe≡`) -- - we push the pure value `a` into the LBFT monad and apply `isvp-pe` to -- it (`.a`, `isvp-pe-a`, and `isvp-pe-a≡`) -- - we push the pure value `b ^∙ bRound` (`r` and `r≡`) into the LBFT -- monad, and the returned value is the result of applying `isvp-pe-a` to -- this -- - now out of `isValidProposalM`, we are given an alias `r'` for `r` -- > proj₂ (contract Post pre pfNone pf≢ pfOk) a ma≡just-a isvp isvp≡ pe pe≡ isvp-pe isvp-pe≡ .a refl isvp-pe-a isvp-pe-a≡ r r≡ r' r'≡ = {!!} -- 4. Since the returned value we want to reason about is directly related to -- the behavior of these bound functions which are partial applications of -- `isValidProposer`, we perform case-analysis on each of the equality -- proofs (we can't pattern match on `ma≡just-a` directly) -- > proj₂ (contract pre Post pfNone pf≢ pfOk) a ma≡just-a ._ refl ._ refl ._ refl ._ refl ._ refl ._ refl ._ refl = {!!} -- 5. Now we encounter an `ifD`, which means we must provide two cases, one corresponding to each branch. proj₁ (proj₂ (contract pre Post pfNone pf≢ pfOk) a ma≡just-a ._ refl ._ refl ._ refl ._ refl ._ refl ._ refl ._ refl) vp≡true -- 6. The types of `pfOk` and `pf≢` are still "stuck" on the expression -- > b ^∙ bAuthor -- So, in both the `false` and `true` cases we rewrite by `ma≡just-a`, which -- tells us that the result is `just a` rewrite ma≡just-a = -- 7. To finish, we use `toWitnessF` to convert between the two forms of evidence. pfOk (just (toWitnessT vp≡true)) proj₂ (proj₂ (contract pre Post pfNone pf≢ pfOk) a ma≡just-a ._ refl ._ refl ._ refl ._ refl ._ refl ._ refl ._ refl) vp≡false rewrite ma≡just-a = pf≢ (just (toWitnessF vp≡false))
{ "alphanum_fraction": 0.678030303, "avg_line_length": 52.8, "ext": "agda", "hexsha": "2151f7a71bb65efc2c437eb02faace274949dbae", "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/Properties/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/Properties/ProposerElection.agda", "max_line_length": 143, "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/Properties/ProposerElection.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1084, "size": 3432 }
module Logic.Identity where open import Logic.Equivalence open import Logic.Base infix 20 _≡_ _≢_ data _≡_ {A : Set}(x : A) : A -> Set where refl : x ≡ x subst : {A : Set}(P : A -> Set){x y : A} -> x ≡ y -> P y -> P x subst P {x} .{x} refl px = px sym : {A : Set}{x y : A} -> x ≡ y -> y ≡ x sym {A} refl = refl trans : {A : Set}{x y z : A} -> x ≡ y -> y ≡ z -> x ≡ z trans {A} refl xz = xz cong : {A B : Set}(f : A -> B){x y : A} -> x ≡ y -> f x ≡ f y cong {A} f refl = refl cong2 : {A B C : Set}(f : A -> B -> C){x z : A}{y w : B} -> x ≡ z -> y ≡ w -> f x y ≡ f z w cong2 {A}{B} f refl refl = refl Equiv : {A : Set} -> Equivalence A Equiv = record { _==_ = _≡_ ; refl = \x -> refl ; sym = \x y -> sym ; trans = \x y z -> trans } _≢_ : {A : Set} -> A -> A -> Set x ≢ y = ¬ (x ≡ y) sym≢ : {A : Set}{x y : A} -> x ≢ y -> y ≢ x sym≢ np p = np (sym p)
{ "alphanum_fraction": 0.4564220183, "avg_line_length": 21.2682926829, "ext": "agda", "hexsha": "e45cfbbb1083623944c0ce9814651ddd029c2ca4", "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/AIM6/Cat/lib/Logic/Identity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Identity.agda", "max_line_length": 91, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Logic/Identity.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": 407, "size": 872 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.List.Relation.Binary.Lex.NonStrict directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.List.Relation.Lex.NonStrict where open import Data.List.Relation.Binary.Lex.NonStrict public {-# WARNING_ON_IMPORT "Data.List.Relation.Lex.NonStrict was deprecated in v1.0. Use Data.List.Relation.Binary.Lex.NonStrict instead." #-}
{ "alphanum_fraction": 0.559566787, "avg_line_length": 30.7777777778, "ext": "agda", "hexsha": "4e75b5209cd6b120e13fa147b8417e4919475c7c", "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/List/Relation/Lex/NonStrict.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/List/Relation/Lex/NonStrict.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/List/Relation/Lex/NonStrict.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": 103, "size": 554 }
------------------------------------------------------------------------ -- Binomial theorem ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --exact-split #-} module Math.BinomialTheorem.Nat where -- agda-stdlib open import Data.Nat open import Data.Nat.Properties open import Data.Nat.Solver open import Relation.Binary.PropositionalEquality open import Function -- agda-combinatorics open import Math.Combinatorics.Function open import Math.Combinatorics.Function.Properties -- agda-misc open import Math.NumberTheory.Summation.Nat open import Math.NumberTheory.Summation.Nat.Properties open ≤-Reasoning private lemma₁ : ∀ x y n k → x * (C n k * (x ^ k * y ^ (n ∸ k))) ≡ C n k * (x ^ suc k * y ^ (n ∸ k)) lemma₁ x y n k = solve 4 (λ m n o p → m :* (n :* (o :* p)) := n :* (m :* o :* p)) refl x (C n k) (x ^ k) (y ^ (n ∸ k)) where open +-*-Solver lemma₂ : ∀ x y n k → y * (C n k * (x ^ k * y ^ (n ∸ k))) ≡ C n k * (x ^ k * y ^ suc (n ∸ k)) lemma₂ x y n k = solve 4 (λ m n o p → m :* (n :* (o :* p)) := n :* (o :* (m :* p)) ) refl y (C n k) (x ^ k) (y ^ (n ∸ k)) where open +-*-Solver glemma₃ : ∀ x y m n → C m m * (x ^ suc n * y ^ (n ∸ n)) ≡ x ^ suc n glemma₃ x y m n = begin-equality C m m * (x ^ suc n * y ^ (n ∸ n)) ≡⟨ cong₂ (λ u v → u * (x ^ suc n * y ^ v)) (C[n,n]≡1 m) (n∸n≡0 n) ⟩ 1 * (x ^ suc n * 1) ≡⟨ *-identityˡ (x ^ suc n * 1) ⟩ x ^ suc n * 1 ≡⟨ *-identityʳ (x ^ suc n) ⟩ x ^ suc n ∎ lemma₃ : ∀ x y n → C n n * (x ^ suc n * y ^ (n ∸ n)) ≡ x ^ suc n lemma₃ x y n = glemma₃ x y n n lemma₄ : ∀ {k n} → k < n → suc (n ∸ suc k) ≡ suc n ∸ suc k lemma₄ k<n = sym $ +-∸-assoc 1 k<n lemma₅ : ∀ n → 1 * (1 * n) ≡ n lemma₅ n = trans (*-identityˡ (1 * n)) (*-identityˡ n) lemma₆ : ∀ x y n → C (suc n) (suc n) * (x ^ suc n * y ^ (n ∸ n)) ≡ x ^ suc n lemma₆ x y n = glemma₃ x y (suc n) n lemma₇ : ∀ m n o p → m + n + (o + p) ≡ n + o + (m + p) lemma₇ = solve 4 (λ m n o p → m :+ n :+ (o :+ p) := n :+ o :+ (m :+ p) ) refl where open +-*-Solver lemma₈ : ∀ m n o → m + n + o ≡ n + (o + m) lemma₈ = solve 3 (λ m n o → m :+ n :+ o := n :+ (o :+ m)) refl where open +-*-Solver {- (x+y)*(x+y)^n (x+y)*Σ[k≤n][Cnk*x^k*y^(n∸k)] -} theorem : ∀ x y n → (x + y) ^ n ≡ Σ[ k ≤ n ] (C n k * (x ^ k * y ^ (n ∸ k))) theorem x y 0 = begin-equality C 0 0 * ((x ^ 0) * y ^ (0 ∸ 0)) ≡⟨ sym $ Σ≤[0,f]≈f[0] (λ k → C 0 k * (x ^ k * y ^ (0 ∸ k))) ⟩ Σ≤ 0 (λ k → C 0 k * (x ^ k * y ^ (0 ∸ k))) ∎ theorem x y (suc n) = begin-equality (x + y) * (x + y) ^ n ≡⟨ cong ((x + y) *_) $ theorem x y n ⟩ (x + y) * Σ[ k ≤ n ] (C n k * (x ^ k * y ^ (n ∸ k))) ≡⟨ *-distribʳ-+ (Σ[ k ≤ n ] (C n k * (x ^ k * y ^ (n ∸ k)))) x y ⟩ x * Σ[ k ≤ n ] (C n k * (x ^ k * y ^ (n ∸ k))) + y * Σ[ k ≤ n ] (C n k * (x ^ k * y ^ (n ∸ k))) ≡⟨ sym $ cong₂ _+_ (Σ≤-*-commute n x (λ k → C n k * (x ^ k * y ^ (n ∸ k)))) (Σ≤-*-commute n y (λ k → C n k * (x ^ k * y ^ (n ∸ k)))) ⟩ Σ[ k ≤ n ] (x * (C n k * (x ^ k * y ^ (n ∸ k)))) + Σ[ k ≤ n ] (y * (C n k * (x ^ k * y ^ (n ∸ k)))) ≡⟨ cong₂ _+_ (Σ≤-congˡ n (λ k → lemma₁ x y n k)) (Σ≤-congˡ n (λ k → lemma₂ x y n k)) ⟩ Σ[ k ≤ n ] (C n k * ((x ^ suc k) * y ^ (n ∸ k))) + Σ[ k ≤ n ] (C n k * (x ^ k * y ^ suc (n ∸ k))) ≡⟨ cong (Σ[ k ≤ n ] (C n k * (x ^ suc k * y ^ (n ∸ k))) +_) $ Σ<-push-suc n (λ k → C n k * (x ^ k * y ^ suc (n ∸ k))) ⟩ Σ[ k < n ] (C n k * ((x ^ suc k) * y ^ (n ∸ k))) + C n n * ((x ^ suc n) * y ^ (n ∸ n)) + (C n 0 * (x ^ 0 * y ^ (suc (n ∸ 0))) + Σ[ k < n ] (C n (suc k) * (x ^ suc k * y ^ suc (n ∸ suc k)))) ≡⟨⟩ Σ[ k < n ] (C n k * ((x ^ suc k) * y ^ (n ∸ k))) + C n n * ((x ^ suc n) * y ^ (n ∸ n)) + (1 * (1 * y ^ suc n) + Σ[ k < n ] (C n (suc k) * (x ^ suc k * y ^ suc (n ∸ suc k)))) ≡⟨ cong₂ _+_ (cong (Σ[ k < n ] (C n k * (x ^ suc k * y ^ (n ∸ k))) +_) $ lemma₃ x y n) (cong₂ _+_ (lemma₅ (y ^ suc n)) (Σ<-congˡ-with-< n $ λ k k<n → cong (λ v → C n (suc k) * (x ^ suc k * y ^ v)) $ lemma₄ k<n)) ⟩ Σ[ k < n ] (C n k * (x ^ suc k * y ^ (n ∸ k))) + x ^ suc n + (y ^ suc n + Σ[ k < n ] (C n (suc k) * (x ^ suc k * y ^ (n ∸ k)))) ≡⟨ lemma₇ (Σ[ k < n ] (C n k * (x ^ suc k * y ^ (n ∸ k)))) (x ^ suc n) (y ^ suc n) (Σ[ k < n ] (C n (suc k) * (x ^ suc k * y ^ (n ∸ k)))) ⟩ x ^ suc n + y ^ suc n + (Σ[ k < n ] (C n k * (x ^ suc k * y ^ (n ∸ k))) + Σ[ k < n ] (C n (suc k) * (x ^ suc k * y ^ (n ∸ k)))) ≡⟨ cong (λ v → (x ^ suc n + y ^ suc n) + v) $ lemma ⟩ x ^ suc n + y ^ suc n + Σ[ k < n ] (C (suc n) (suc k) * (x ^ suc k * y ^ (n ∸ k))) ≡⟨ lemma₈ (x ^ suc n) (y ^ suc n) (Σ[ k < n ] (C (suc n) (suc k) * (x ^ suc k * y ^ (n ∸ k)))) ⟩ y ^ suc n + (Σ[ k < n ] (C (suc n) (suc k) * (x ^ suc k * y ^ (n ∸ k))) + x ^ suc n) ≡⟨ cong (λ v → y ^ suc n + (Σ[ k < n ] (C (suc n) (suc k) * (x ^ suc k * y ^ (n ∸ k))) + v)) $ sym $ lemma₆ x y n ⟩ y ^ suc n + (Σ[ k < n ] (C (suc n) (suc k) * (x ^ suc k * y ^ (n ∸ k))) + C (suc n) (suc n) * (x ^ suc n * y ^ (n ∸ n))) ≡⟨⟩ y ^ suc n + Σ[ k ≤ n ] (C (suc n) (suc k) * (x ^ suc k * y ^ (n ∸ k))) ≡⟨ cong (_+ Σ[ k ≤ n ] (C (suc n) (suc k) * (x ^ suc k * y ^ (n ∸ k)))) $ sym $ lemma₅ (y ^ suc n) ⟩ 1 * (1 * y ^ suc n) + Σ[ k ≤ n ] (C (suc n) (suc k) * (x ^ suc k * y ^ (n ∸ k))) ≡⟨ sym $ Σ≤-push-suc n (λ k → C (suc n) k * (x ^ k * y ^ (suc n ∸ k))) ⟩ Σ≤ (suc n) (λ k → C (suc n) k * (x ^ k * y ^ (suc n ∸ k))) ∎ where lemma : Σ[ k < n ] (C n k * (x ^ suc k * y ^ (n ∸ k))) + Σ[ k < n ] (C n (suc k) * (x ^ suc k * y ^ (n ∸ k))) ≡ Σ[ k < n ] (C (suc n) (suc k) * (x ^ suc k * y ^ (n ∸ k))) lemma = begin-equality Σ[ k < n ] (C n k * z k) + Σ[ k < n ] (C n (suc k) * z k) ≡⟨ sym $ Σ<-distrib-+ n (λ k → C n k * z k) (λ k → C n (suc k) * z k) ⟩ Σ[ k < n ] (C n k * z k + C n (suc k) * z k) ≡⟨ Σ<-congˡ n (λ k → sym $ *-distribʳ-+ (z k) (C n k) (C n (suc k))) ⟩ Σ[ k < n ] ((C n k + C n (suc k)) * z k) ≡⟨ Σ<-congˡ n (λ k → cong (_* z k) $ sym $ C[1+n,1+k]≡C[n,k]+C[n,1+k] n k) ⟩ Σ[ k < n ] (C (suc n) (suc k) * z k) ∎ where z = λ k → x ^ suc k * y ^ (n ∸ k) Σ[k≤n]C[n,k]≡2^n : ∀ n → Σ[ k ≤ n ] C n k ≡ 2 ^ n Σ[k≤n]C[n,k]≡2^n n = begin-equality Σ[ k ≤ n ] (C n k) ≡⟨ sym $ Σ≤-congˡ n (λ k → begin-equality C n k * (1 ^ k * 1 ^ (n ∸ k)) ≡⟨ cong (C n k *_) $ cong₂ _*_ (^-zeroˡ k) (^-zeroˡ (n ∸ k)) ⟩ C n k * (1 * 1) ≡⟨ *-identityʳ (C n k) ⟩ C n k ∎ ) ⟩ Σ[ k ≤ n ] (C n k * (1 ^ k * 1 ^ (n ∸ k))) ≡⟨ sym $ theorem 1 1 n ⟩ (1 + 1) ^ n ∎
{ "alphanum_fraction": 0.3745179472, "avg_line_length": 44.9466666667, "ext": "agda", "hexsha": "5125e3480c49b85594731021ea9206113ccc0cab", "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": "9fafa35c940ff7b893a80120f6a1f22b0a3917b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-combinatorics", "max_forks_repo_path": "Math/BinomialTheorem/Nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9fafa35c940ff7b893a80120f6a1f22b0a3917b7", "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-combinatorics", "max_issues_repo_path": "Math/BinomialTheorem/Nat.agda", "max_line_length": 143, "max_stars_count": 3, "max_stars_repo_head_hexsha": "9fafa35c940ff7b893a80120f6a1f22b0a3917b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-combinatorics", "max_stars_repo_path": "Math/BinomialTheorem/Nat.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-25T07:25:27.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-25T08:24:15.000Z", "num_tokens": 3356, "size": 6742 }
{- This second-order signature was created from the following second-order syntax description: syntax Combinatory | CL type * : 0-ary term app : * * -> * | _$_ l20 i : * k : * s : * theory (IA) x |> app (i, x) = x (KA) x y |> app (app(k, x), y) = x (SA) x y z |> app (app (app (s, x), y), z) = app (app(x, z), app(y, z)) -} module Combinatory.Signature where open import SOAS.Context open import SOAS.Common open import SOAS.Syntax.Signature *T public open import SOAS.Syntax.Build *T public -- Operator symbols data CLₒ : Set where appₒ iₒ kₒ sₒ : CLₒ -- Term signature CL:Sig : Signature CLₒ CL:Sig = sig λ { appₒ → (⊢₀ *) , (⊢₀ *) ⟼₂ * ; iₒ → ⟼₀ * ; kₒ → ⟼₀ * ; sₒ → ⟼₀ * } open Signature CL:Sig public
{ "alphanum_fraction": 0.5703225806, "avg_line_length": 17.2222222222, "ext": "agda", "hexsha": "96b3792dd5acae6a81118ee27a079b8a4372cae7", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/Combinatory/Signature.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/Combinatory/Signature.agda", "max_line_length": 91, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/Combinatory/Signature.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 302, "size": 775 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Examples of decision procedures and how to use them ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module README.Decidability where -- Reflects and Dec are defined in Relation.Nullary, and operations on them can -- be found in Relation.Nullary.Reflects and Relation.Nullary.Decidable. open import Relation.Nullary as Nullary open import Relation.Nullary.Reflects open import Relation.Nullary.Decidable open import Data.Bool open import Data.List open import Data.List.Properties using (∷-injective) open import Data.Nat open import Data.Nat.Properties using (suc-injective) open import Data.Product open import Data.Unit open import Function open import Relation.Binary.PropositionalEquality open import Relation.Nary open import Relation.Nullary.Product infix 4 _≟₀_ _≟₁_ _≟₂_ -- A proof of `Reflects P b` shows that a proposition `P` has the truth value of -- the boolean `b`. A proof of `Reflects P true` amounts to a proof of `P`, and -- a proof of `Reflects P false` amounts to a refutation of `P`. ex₀ : (n : ℕ) → Reflects (n ≡ n) true ex₀ n = ofʸ refl ex₁ : (n : ℕ) → Reflects (zero ≡ suc n) false ex₁ n = ofⁿ λ () ex₂ : (b : Bool) → Reflects (T b) b ex₂ false = ofⁿ id ex₂ true = ofʸ tt -- A proof of `Dec P` is a proof of `Reflects P b` for some `b`. -- `Dec P` is declared as a record, with fields: -- does : Bool -- proof : Reflects P does ex₃ : (b : Bool) → Dec (T b) does (ex₃ b) = b proof (ex₃ b) = ex₂ b -- We also have pattern synonyms `yes` and `no`, allowing both fields to be -- given at once. ex₄ : (n : ℕ) → Dec (zero ≡ suc n) ex₄ n = no λ () -- It is possible, but not ideal, to define recursive decision procedures using -- only the `yes` and `no` patterns. The following procedure decides whether two -- given natural numbers are equal. _≟₀_ : (m n : ℕ) → Dec (m ≡ n) zero ≟₀ zero = yes refl zero ≟₀ suc n = no λ () suc m ≟₀ zero = no λ () suc m ≟₀ suc n with m ≟₀ n ... | yes p = yes (cong suc p) ... | no ¬p = no (¬p ∘ suc-injective) -- In this case, we can see that `does (suc m ≟ suc n)` should be equal to -- `does (m ≟ n)`, because a `yes` from `m ≟ n` gives rise to a `yes` from the -- result, and similarly for `no`. However, in the above definition, this -- equality does not hold definitionally, because we always do a case split -- before returning a result. To avoid this, we can return the `does` part -- separately, before any pattern matching. _≟₁_ : (m n : ℕ) → Dec (m ≡ n) zero ≟₁ zero = yes refl zero ≟₁ suc n = no λ () suc m ≟₁ zero = no λ () does (suc m ≟₁ suc n) = does (m ≟₁ n) proof (suc m ≟₁ suc n) with m ≟₁ n ... | yes p = ofʸ (cong suc p) ... | no ¬p = ofⁿ (¬p ∘ suc-injective) -- We now get definitional equalities such as the following. _ : (m n : ℕ) → does (5 + m ≟₁ 3 + n) ≡ does (2 + m ≟₁ n) _ = λ m n → refl -- Even better, from a maintainability point of view, is to use `map` or `map′`, -- both of which capture the pattern of the `does` field remaining the same, but -- the `proof` field being updated. _≟₂_ : (m n : ℕ) → Dec (m ≡ n) zero ≟₂ zero = yes refl zero ≟₂ suc n = no λ () suc m ≟₂ zero = no λ () suc m ≟₂ suc n = map′ (cong suc) suc-injective (m ≟₂ n) _ : (m n : ℕ) → does (5 + m ≟₂ 3 + n) ≡ does (2 + m ≟₂ n) _ = λ m n → refl -- `map′` can be used in conjunction with combinators such as `_⊎-dec_` and -- `_×-dec_` to build complex (simply typed) decision procedures. module ListDecEq₀ {a} {A : Set a} (_≟ᴬ_ : (x y : A) → Dec (x ≡ y)) where _≟ᴸᴬ_ : (xs ys : List A) → Dec (xs ≡ ys) [] ≟ᴸᴬ [] = yes refl [] ≟ᴸᴬ (y ∷ ys) = no λ () (x ∷ xs) ≟ᴸᴬ [] = no λ () (x ∷ xs) ≟ᴸᴬ (y ∷ ys) = map′ (uncurry (cong₂ _∷_)) ∷-injective (x ≟ᴬ y ×-dec xs ≟ᴸᴬ ys) -- The final case says that `x ∷ xs ≡ y ∷ ys` exactly when `x ≡ y` *and* -- `xs ≡ ys`. The proofs are updated by the first two arguments to `map′`. -- In the case of ≡-equality tests, the pattern -- `map′ (congₙ c) c-injective (x₀ ≟ y₀ ×-dec ... ×-dec xₙ₋₁ ≟ yₙ₋₁)` -- is captured by `≟-mapₙ n c c-injective (x₀ ≟ y₀) ... (xₙ₋₁ ≟ yₙ₋₁)`. module ListDecEq₁ {a} {A : Set a} (_≟ᴬ_ : (x y : A) → Dec (x ≡ y)) where _≟ᴸᴬ_ : (xs ys : List A) → Dec (xs ≡ ys) [] ≟ᴸᴬ [] = yes refl [] ≟ᴸᴬ (y ∷ ys) = no λ () (x ∷ xs) ≟ᴸᴬ [] = no λ () (x ∷ xs) ≟ᴸᴬ (y ∷ ys) = ≟-mapₙ 2 _∷_ ∷-injective (x ≟ᴬ y) (xs ≟ᴸᴬ ys)
{ "alphanum_fraction": 0.5970215603, "avg_line_length": 33.8270676692, "ext": "agda", "hexsha": "2e6faa9d069f6ab3b31a003950a49d022d62d767", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/README/Decidability.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/README/Decidability.agda", "max_line_length": 80, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/README/Decidability.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": 1669, "size": 4499 }
{-# OPTIONS --cubical-compatible #-} module WithoutK2 where -- Equality defined with two indices. data _≡_ {A : Set} : A → A → Set where refl : ∀ x → x ≡ x K : {A : Set} (P : {x : A} → x ≡ x → Set) → (∀ x → P (refl x)) → ∀ {x} (x≡x : x ≡ x) → P x≡x K P p (refl x) = p x
{ "alphanum_fraction": 0.485915493, "avg_line_length": 20.2857142857, "ext": "agda", "hexsha": "4b5f6690a2af7589675fc8dde407913c58bd4011", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "test/Fail/WithoutK2.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "test/Fail/WithoutK2.agda", "max_line_length": 43, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Fail/WithoutK2.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 123, "size": 284 }
open import SOAS.Common open import SOAS.Families.Core open import Categories.Object.Initial open import SOAS.Coalgebraic.Strength import SOAS.Metatheory.MetaAlgebra -- Substitution structure by initiality module SOAS.Metatheory.Substitution {T : Set} (⅀F : Functor 𝔽amiliesₛ 𝔽amiliesₛ) (⅀:Str : Strength ⅀F) (𝔛 : Familyₛ) (open SOAS.Metatheory.MetaAlgebra ⅀F 𝔛) (𝕋:Init : Initial 𝕄etaAlgebras) where open import SOAS.Context open import SOAS.Variable open import SOAS.Abstract.Hom import SOAS.Abstract.Coalgebra as →□ ; open →□.Sorted import SOAS.Abstract.Box as □ ; open □.Sorted open import SOAS.Abstract.Monoid open import SOAS.Coalgebraic.Map open import SOAS.Coalgebraic.Monoid open import SOAS.Coalgebraic.Lift open import SOAS.Metatheory.Algebra ⅀F open import SOAS.Metatheory.Semantics ⅀F ⅀:Str 𝔛 𝕋:Init open import SOAS.Metatheory.Traversal ⅀F ⅀:Str 𝔛 𝕋:Init open import SOAS.Metatheory.Renaming ⅀F ⅀:Str 𝔛 𝕋:Init open import SOAS.Metatheory.Coalgebraic ⅀F ⅀:Str 𝔛 𝕋:Init open Strength ⅀:Str private variable Γ Δ : Ctx α β : T -- Substitution is a 𝕋-parametrised traversal into 𝕋 module Substitution = Traversal 𝕋ᴮ 𝕒𝕝𝕘 id 𝕞𝕧𝕒𝕣 𝕤𝕦𝕓 : 𝕋 ⇾̣ 〖 𝕋 , 𝕋 〗 𝕤𝕦𝕓 = Substitution.𝕥𝕣𝕒𝕧 -- The renaming and algebra structures on 𝕋 are compatible, so 𝕤𝕦𝕓 is coalgebraic 𝕤𝕦𝕓ᶜ : Coalgebraic 𝕋ᴮ 𝕋ᴮ 𝕋ᴮ 𝕤𝕦𝕓 𝕤𝕦𝕓ᶜ = Travᶜ.𝕥𝕣𝕒𝕧ᶜ 𝕋ᴮ 𝕒𝕝𝕘 id 𝕞𝕧𝕒𝕣 𝕋ᴮ idᴮ⇒ Renaming.𝕤𝕖𝕞ᵃ⇒ module 𝕤𝕦𝕓ᶜ = Coalgebraic 𝕤𝕦𝕓ᶜ -- Compatibility of renaming and substitution compat : {ρ : Γ ↝ Δ} (t : 𝕋 α Γ) → 𝕣𝕖𝕟 t ρ ≡ 𝕤𝕦𝕓 t (𝕧𝕒𝕣 ∘ ρ) compat {ρ = ρ} t = begin 𝕣𝕖𝕟 t ρ ≡˘⟨ 𝕥𝕣𝕒𝕧-η≈id 𝕋ᴮ id refl ⟩ 𝕤𝕦𝕓 (𝕣𝕖𝕟 t ρ) 𝕧𝕒𝕣 ≡⟨ 𝕤𝕦𝕓ᶜ.f∘r ⟩ 𝕤𝕦𝕓 t (𝕧𝕒𝕣 ∘ ρ) ∎ where open ≡-Reasoning -- Substitution associativity law 𝕤𝕦𝕓-comp : MapEq₂ 𝕋ᴮ 𝕋ᴮ 𝕒𝕝𝕘 (λ t σ ς → 𝕤𝕦𝕓 (𝕤𝕦𝕓 t σ) ς) (λ t σ ς → 𝕤𝕦𝕓 t (λ v → 𝕤𝕦𝕓 (σ v) ς)) 𝕤𝕦𝕓-comp = record { φ = id ; ϕ = 𝕤𝕦𝕓 ; χ = 𝕞𝕧𝕒𝕣 ; f⟨𝑣⟩ = 𝕥≈₁ 𝕥⟨𝕧⟩ ; f⟨𝑚⟩ = trans (𝕥≈₁ 𝕥⟨𝕞⟩) 𝕥⟨𝕞⟩ ; f⟨𝑎⟩ = λ{ {σ = σ}{ς}{t} → begin 𝕤𝕦𝕓 (𝕤𝕦𝕓 (𝕒𝕝𝕘 t) σ) ς ≡⟨ 𝕥≈₁ 𝕥⟨𝕒⟩ ⟩ 𝕤𝕦𝕓 (𝕒𝕝𝕘 (str 𝕋ᴮ 𝕋 (⅀₁ 𝕤𝕦𝕓 t) σ)) ς ≡⟨ 𝕥⟨𝕒⟩ ⟩ 𝕒𝕝𝕘 (str 𝕋ᴮ 𝕋 (⅀₁ 𝕤𝕦𝕓 (str 𝕋ᴮ 𝕋 (⅀₁ 𝕤𝕦𝕓 t) σ)) ς) ≡˘⟨ congr (str-nat₂ 𝕤𝕦𝕓 (⅀₁ 𝕤𝕦𝕓 t) σ) (λ - → 𝕒𝕝𝕘 (str 𝕋ᴮ 𝕋 - ς)) ⟩ 𝕒𝕝𝕘 (str 𝕋ᴮ 𝕋 (str 𝕋ᴮ 〖 𝕋 , 𝕋 〗 (⅀.F₁ (λ { h ς → 𝕤𝕦𝕓 (h ς) }) (⅀₁ 𝕤𝕦𝕓 t)) σ) ς) ≡˘⟨ congr ⅀.homomorphism (λ - → 𝕒𝕝𝕘 (str 𝕋ᴮ 𝕋 (str 𝕋ᴮ 〖 𝕋 , 𝕋 〗 - σ) ς)) ⟩ 𝕒𝕝𝕘 (str 𝕋ᴮ 𝕋 (str 𝕋ᴮ 〖 𝕋 , 𝕋 〗 (⅀₁ (λ{ t σ → 𝕤𝕦𝕓 (𝕤𝕦𝕓 t σ)}) t) σ) ς) ∎ } ; g⟨𝑣⟩ = 𝕥⟨𝕧⟩ ; g⟨𝑚⟩ = 𝕥⟨𝕞⟩ ; g⟨𝑎⟩ = λ{ {σ = σ}{ς}{t} → begin 𝕤𝕦𝕓 (𝕒𝕝𝕘 t) (λ v → 𝕤𝕦𝕓 (σ v) ς) ≡⟨ 𝕥⟨𝕒⟩ ⟩ 𝕒𝕝𝕘 (str 𝕋ᴮ 𝕋 (⅀₁ 𝕤𝕦𝕓 t) (λ v → 𝕤𝕦𝕓 (σ v) ς)) ≡⟨ cong 𝕒𝕝𝕘 (str-dist 𝕋 𝕤𝕦𝕓ᶜ (⅀₁ 𝕤𝕦𝕓 t) (λ {τ} z → σ z) ς) ⟩ 𝕒𝕝𝕘 (str 𝕋ᴮ 𝕋 (str 𝕋ᴮ 〖 𝕋 , 𝕋 〗 (⅀.F₁ (precomp 𝕋 𝕤𝕦𝕓) (⅀₁ 𝕤𝕦𝕓 t)) σ) ς) ≡˘⟨ congr ⅀.homomorphism (λ - → 𝕒𝕝𝕘 (str 𝕋ᴮ 𝕋 (str 𝕋ᴮ 〖 𝕋 , 𝕋 〗 - σ) ς)) ⟩ 𝕒𝕝𝕘 (str 𝕋ᴮ 𝕋 (str 𝕋ᴮ 〖 𝕋 , 𝕋 〗 (⅀₁ (λ{ t σ ς → 𝕤𝕦𝕓 t (λ v → 𝕤𝕦𝕓 (σ v) ς)}) t) σ) ς) ∎ } } where open ≡-Reasoning ; open Substitution -- Coalgebraic monoid structure on 𝕋 𝕋ᵐ : Mon 𝕋 𝕋ᵐ = record { η = 𝕧𝕒𝕣 ; μ = 𝕤𝕦𝕓 ; lunit = Substitution.𝕥⟨𝕧⟩ ; runit = λ{ {t = t} → trans (𝕥𝕣𝕒𝕧-η≈𝕤𝕖𝕞 𝕋ᴮ 𝕋ᵃ id refl) 𝕤𝕖𝕞-id } ; assoc = λ{ {t = t} → MapEq₂.≈ 𝕤𝕦𝕓-comp t } } open Mon 𝕋ᵐ using ([_/] ; [_,_/]₂ ; lunit ; runit ; assoc) public 𝕋ᴹ : CoalgMon 𝕋 𝕋ᴹ = record { ᴮ = 𝕋ᴮ ; ᵐ = 𝕋ᵐ ; η-compat = refl ; μ-compat = λ{ {t = t} → compat t } } -- Corollaries: renaming and simultaneous substitution commutes with -- single-variable substitution open import SOAS.ContextMaps.Combinators 𝕣𝕖𝕟[/] : (ρ : Γ ↝ Δ)(b : 𝕋 α (β ∙ Γ))(a : 𝕋 β Γ) → 𝕣𝕖𝕟 ([ a /] b) ρ ≡ [ (𝕣𝕖𝕟 a ρ) /] (𝕣𝕖𝕟 b (rlift _ ρ)) 𝕣𝕖𝕟[/] ρ b a = begin 𝕣𝕖𝕟 ([ a /] b) ρ ≡⟨ 𝕤𝕦𝕓ᶜ.r∘f ⟩ 𝕤𝕦𝕓 b (λ v → 𝕣𝕖𝕟 (add 𝕋 a 𝕧𝕒𝕣 v) ρ) ≡⟨ cong (𝕤𝕦𝕓 b) (dext (λ{ new → refl ; (old y) → Renaming.𝕥⟨𝕧⟩})) ⟩ 𝕤𝕦𝕓 b (λ v → add 𝕋 (𝕣𝕖𝕟 a ρ) 𝕧𝕒𝕣 (rlift _ ρ v)) ≡˘⟨ 𝕤𝕦𝕓ᶜ.f∘r ⟩ [ 𝕣𝕖𝕟 a ρ /] (𝕣𝕖𝕟 b (rlift _ ρ)) ∎ where open ≡-Reasoning 𝕤𝕦𝕓[/] : (σ : Γ ~[ 𝕋 ]↝ Δ)(b : 𝕋 α (β ∙ Γ))(a : 𝕋 β Γ) → 𝕤𝕦𝕓 ([ a /] b) σ ≡ [ 𝕤𝕦𝕓 a σ /] (𝕤𝕦𝕓 b (lift 𝕋ᴮ ⌈ β ⌋ σ)) 𝕤𝕦𝕓[/] {β = β} σ b a = begin 𝕤𝕦𝕓 ([ a /] b) σ ≡⟨ assoc ⟩ 𝕤𝕦𝕓 b (λ v → 𝕤𝕦𝕓 (add 𝕋 a 𝕧𝕒𝕣 v) σ) ≡⟨ cong (𝕤𝕦𝕓 b) (dext (λ{ new → sym lunit ; (old v) → sym (begin 𝕤𝕦𝕓 (𝕣𝕖𝕟 (σ v) old) (add 𝕋 (𝕤𝕦𝕓 a σ) 𝕧𝕒𝕣) ≡⟨ 𝕤𝕦𝕓ᶜ.f∘r ⟩ 𝕤𝕦𝕓 (σ v) (λ v → add 𝕋 (𝕤𝕦𝕓 a σ) 𝕧𝕒𝕣 (old v)) ≡⟨ cong (𝕤𝕦𝕓 (σ v)) (dext (λ{ new → refl ; (old v) → refl})) ⟩ 𝕤𝕦𝕓 (σ v) 𝕧𝕒𝕣 ≡⟨ runit ⟩ σ v ≡˘⟨ lunit ⟩ 𝕤𝕦𝕓 (𝕧𝕒𝕣 v) σ ∎)})) ⟩ 𝕤𝕦𝕓 b (λ v → 𝕤𝕦𝕓 (lift 𝕋ᴮ ⌈ β ⌋ σ v) (add 𝕋 (𝕤𝕦𝕓 a σ) 𝕧𝕒𝕣)) ≡˘⟨ assoc ⟩ [ 𝕤𝕦𝕓 a σ /] (𝕤𝕦𝕓 b (lift 𝕋ᴮ ⌈ β ⌋ σ)) ∎ where open ≡-Reasoning
{ "alphanum_fraction": 0.5447291054, "avg_line_length": 33.3006993007, "ext": "agda", "hexsha": "4c84caa613dfbb3e5387d6ea3ff1ac484b3377e6", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "SOAS/Metatheory/Substitution.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "SOAS/Metatheory/Substitution.agda", "max_line_length": 92, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "SOAS/Metatheory/Substitution.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 3481, "size": 4762 }
module BuiltinConstructorsNeededForLiterals where data Nat : Set where zero : Nat → Nat suc : Nat → Nat {-# BUILTIN NATURAL Nat #-} data ⊥ : Set where empty : Nat → ⊥ empty (zero n) = empty n empty (suc n) = empty n bad : ⊥ bad = empty 0
{ "alphanum_fraction": 0.644, "avg_line_length": 13.8888888889, "ext": "agda", "hexsha": "9dd3bd993c7352f26b1aff0c91f95175d44ab9df", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/fail/BuiltinConstructorsNeededForLiterals.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "np/agda-git-experiment", "max_issues_repo_path": "test/fail/BuiltinConstructorsNeededForLiterals.agda", "max_line_length": 49, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/fail/BuiltinConstructorsNeededForLiterals.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": 84, "size": 250 }
{-# OPTIONS --without-K #-} open import HoTT open import homotopy.HSpace renaming (HSpaceStructure to HSS) open import homotopy.WedgeExtension module homotopy.Pi2HSusp where module Pi2HSusp {i} (A : Type i) (gA : has-level ⟨ 1 ⟩ A) (cA : is-connected ⟨0⟩ A) (A-H : HSS A) (μcoh : HSS.μe- A-H (HSS.e A-H) == HSS.μ-e A-H (HSS.e A-H)) where {- TODO this belongs somewhere else, but where? -} private Type=-ext : ∀ {i} {A B : Type i} (p q : A == B) → ((x : A) → coe p x == coe q x) → p == q Type=-ext p q α = ! (ua-η p) ∙ ap ua (pair= (λ= α) (prop-has-all-paths-↓ (is-equiv-is-prop (coe q)))) ∙ ua-η q open HSpaceStructure A-H open ConnectedHSpace A cA A-H P : Suspension A → Type i P x = Trunc ⟨ 1 ⟩ (north A == x) module Codes = SuspensionRec A A A (λ a → ua (μ-equiv a)) Codes : Suspension A → Type i Codes = Codes.f Codes-level : (x : Suspension A) → has-level ⟨ 1 ⟩ (Codes x) Codes-level = Suspension-elim A gA gA (λ _ → prop-has-all-paths-↓ has-level-is-prop) encode₀ : {x : Suspension A} → (north A == x) → Codes x encode₀ α = transport Codes α e encode : {x : Suspension A} → P x → Codes x encode {x} = Trunc-rec (Codes-level x) encode₀ decode' : A → P (north A) decode' a = [ (merid A a ∙ ! (merid A e)) ] abstract transport-Codes-mer : (a a' : A) → transport Codes (merid A a) a' == μ a a' transport-Codes-mer a a' = coe (ap Codes (merid A a)) a' =⟨ Codes.glue-β a |in-ctx (λ w → coe w a') ⟩ coe (ua (μ-equiv a)) a' =⟨ coe-β (μ-equiv a) a' ⟩ μ a a' ∎ transport-Codes-mer-e-! : (a : A) → transport Codes (! (merid A e)) a == a transport-Codes-mer-e-! a = coe (ap Codes (! (merid A e))) a =⟨ ap-! Codes (merid A e) |in-ctx (λ w → coe w a) ⟩ coe (! (ap Codes (merid A e))) a =⟨ Codes.glue-β e |in-ctx (λ w → coe (! w) a) ⟩ coe (! (ua (μ-equiv e))) a =⟨ Type=-ext (ua (μ-equiv e)) idp (λ x → coe-β _ x ∙ μe- x) |in-ctx (λ w → coe (! w) a) ⟩ coe (! idp) a ∎ abstract encode-decode' : (a : A) → encode (decode' a) == a encode-decode' a = transport Codes (merid A a ∙ ! (merid A e)) e =⟨ trans-∙ {B = Codes} (merid A a) (! (merid A e)) e ⟩ transport Codes (! (merid A e)) (transport Codes (merid A a) e) =⟨ transport-Codes-mer a e ∙ μ-e a |in-ctx (λ w → transport Codes (! (merid A e)) w) ⟩ transport Codes (! (merid A e)) a =⟨ transport-Codes-mer-e-! a ⟩ a ∎ abstract homomorphism : (a a' : A) → Path {A = Trunc ⟨ 1 ⟩ (north A == south A)} [ merid A (μ a a' ) ] [ merid A a' ∙ ! (merid A e) ∙ merid A a ] homomorphism = WedgeExt.ext args where args : WedgeExt.args {a₀ = e} {b₀ = e} args = record {m = ⟨-2⟩; n = ⟨-2⟩; cA = cA; cB = cA; P = λ a a' → (_ , Trunc-level {n = ⟨ 1 ⟩} _ _); f = λ a → ap [_] $ merid A (μ a e) =⟨ ap (merid A) (μ-e a) ⟩ merid A a =⟨ ap (λ w → w ∙ merid A a) (! (!-inv-r (merid A e))) ∙ ∙-assoc (merid A e) (! (merid A e)) (merid A a) ⟩ merid A e ∙ ! (merid A e) ∙ merid A a ∎; g = λ a' → ap [_] $ merid A (μ e a') =⟨ ap (merid A) (μe- a') ⟩ merid A a' =⟨ ! (∙-unit-r (merid A a')) ∙ ap (λ w → merid A a' ∙ w) (! (!-inv-l (merid A e))) ⟩ merid A a' ∙ ! (merid A e) ∙ merid A e ∎ ; p = ap (λ {(p₁ , p₂) → ap [_] $ merid A (μ e e) =⟨ p₁ ⟩ merid A e =⟨ p₂ ⟩ merid A e ∙ ! (merid A e) ∙ merid A e ∎}) (pair×= (ap (λ x → ap (merid A) x) (! μcoh)) (coh (merid A e)))} where coh : {B : Type i} {b b' : B} (p : b == b') → ap (λ w → w ∙ p) (! (!-inv-r p)) ∙ ∙-assoc p (! p) p == ! (∙-unit-r p) ∙ ap (λ w → p ∙ w) (! (!-inv-l p)) coh idp = idp decode : {x : Suspension A} → Codes x → P x decode {x} = Suspension-elim A {P = λ x → Codes x → P x} decode' (λ a → [ merid A a ]) (λ a → ↓-→-from-transp (λ= $ STS a)) x where abstract STS : (a a' : A) → transport P (merid A a) (decode' a') == [ merid A (transport Codes (merid A a) a') ] STS a a' = transport P (merid A a) [ merid A a' ∙ ! (merid A e) ] =⟨ transport-Trunc (λ x → north A == x) (merid A a) _ ⟩ [ transport (λ x → north A == x) (merid A a) (merid A a' ∙ ! (merid A e)) ] =⟨ ap [_] (trans-pathfrom {A = Suspension A} (merid A a) _) ⟩ [ (merid A a' ∙ ! (merid A e)) ∙ merid A a ] =⟨ ap [_] (∙-assoc (merid A a') (! (merid A e)) (merid A a)) ⟩ [ merid A a' ∙ ! (merid A e) ∙ merid A a ] =⟨ ! (homomorphism a a') ⟩ [ merid A (μ a a') ] =⟨ ap ([_] ∘ merid A) (! (transport-Codes-mer a a')) ⟩ [ merid A (transport Codes (merid A a) a') ] ∎ abstract decode-encode : {x : Suspension A} (tα : P x) → decode {x} (encode {x} tα) == tα decode-encode {x} = Trunc-elim {P = λ tα → decode {x} (encode {x} tα) == tα} (λ _ → =-preserves-level ⟨ 1 ⟩ Trunc-level) (J (λ y p → decode {y} (encode {y} [ p ]) == [ p ]) (ap [_] (!-inv-r (merid A e)))) main-lemma-eqv : Trunc ⟨ 1 ⟩ (north A == north A) ≃ A main-lemma-eqv = equiv encode decode' encode-decode' decode-encode ⊙main-lemma : ⊙Trunc ⟨ 1 ⟩ (⊙Ω (⊙Susp (A , e))) == (A , e) ⊙main-lemma = ⊙ua main-lemma-eqv idp abstract main-lemma-iso : (t1 : 1 ≠ 0) → Ω^-Group 1 t1 (⊙Trunc ⟨ 1 ⟩ (⊙Ω (⊙Susp (A , e)))) Trunc-level ≃ᴳ Ω^-Group 1 t1 (⊙Trunc ⟨ 1 ⟩ (A , e)) Trunc-level main-lemma-iso _ = (record {f = f; pres-comp = pres-comp} , ie) where h : fst (⊙Trunc ⟨ 1 ⟩ (⊙Ω (⊙Susp (A , e))) ⊙→ ⊙Trunc ⟨ 1 ⟩ (A , e)) h = (λ x → [ encode x ]) , idp f : Ω (⊙Trunc ⟨ 1 ⟩ (⊙Ω (⊙Susp (A , e)))) → Ω (⊙Trunc ⟨ 1 ⟩ (A , e)) f = fst (ap^ 1 h) pres-comp : (p q : Ω^ 1 (⊙Trunc ⟨ 1 ⟩ (⊙Ω (⊙Susp (A , e))))) → f (conc^ 1 (ℕ-S≠O _) p q) == conc^ 1 (ℕ-S≠O _) (f p) (f q) pres-comp = ap^-conc^ 1 (ℕ-S≠O _) h ie : is-equiv f ie = is-equiv-ap^ 1 h (snd $ ((unTrunc-equiv A gA)⁻¹ ∘e main-lemma-eqv)) abstract π₂-Suspension : (t1 : 1 ≠ 0) (t2 : 2 ≠ 0) → π 2 t2 (⊙Susp (A , e)) == π 1 t1 (A , e) π₂-Suspension t1 t2 = π 2 t2 (⊙Susp (A , e)) =⟨ π-inner-iso 1 t1 t2 (⊙Susp (A , e)) ⟩ π 1 t1 (⊙Ω (⊙Susp (A , e))) =⟨ ! (π-Trunc-shift-iso 1 t1 (⊙Ω (⊙Susp (A , e)))) ⟩ Ω^-Group 1 t1 (⊙Trunc ⟨ 1 ⟩ (⊙Ω (⊙Susp (A , e)))) Trunc-level =⟨ group-ua (main-lemma-iso t1) ⟩ Ω^-Group 1 t1 (⊙Trunc ⟨ 1 ⟩ (A , e)) Trunc-level =⟨ π-Trunc-shift-iso 1 t1 (A , e) ⟩ π 1 t1 (A , e) ∎
{ "alphanum_fraction": 0.454689298, "avg_line_length": 37.5783783784, "ext": "agda", "hexsha": "29a95114a01d9bc91e2e77d2da4357d80dfa6a24", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "homotopy/Pi2HSusp.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "homotopy/Pi2HSusp.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "homotopy/Pi2HSusp.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2886, "size": 6952 }
open import Categories open import Monads open import Level import Monads.CatofAdj module Monads.CatofAdj.TermAdjHom {c d} {C : Cat {c}{d}} (M : Monad C) (A : Cat.Obj (Monads.CatofAdj.CatofAdj M {c ⊔ d}{c ⊔ d})) where open import Library open import Functors open import Adjunctions open import Monads.EM M open Monads.CatofAdj M open import Monads.CatofAdj.TermAdjObj M open Cat open Fun open Adj open Monad open ObjAdj K' : Fun (D A) (D EMObj) K' = record { OMap = λ X → record { acar = OMap (R (adj A)) X; astr = λ Z f → subst (λ Z → Hom C Z (OMap (R (adj A)) X)) (fcong Z (cong OMap (law A))) (HMap (R (adj A)) (right (adj A) f)); alaw1 = λ {Z} {f} → alaw1lem (TFun M) (L (adj A)) (R (adj A)) (law A) (η M) (right (adj A)) (left (adj A)) (ηlaw A) (natleft (adj A) (iden C) (right (adj A) f) (iden (D A))) (lawb (adj A) f); alaw2 = λ {Z} {W} {k} {f} → alaw2lem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (bind M) (natright (adj A)) (bindlaw A {_}{_}{k})}; HMap = λ {X} {Y} f → record { amor = HMap (R (adj A)) f; ahom = λ {Z} {g} → ahomlem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (natright (adj A))}; fid = AlgMorphEq (fid (R (adj A))); fcomp = AlgMorphEq (fcomp (R (adj A)))} Llaw' : K' ○ L (adj A) ≅ L (adj EMObj) Llaw' = FunctorEq _ _ (ext (λ X → AlgEq (fcong X (cong OMap (law A))) ((ext λ Z → dext (λ {f} {f'} p → Llawlem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (bind M) (bindlaw A) p))))) (iext λ X → iext λ Y → ext λ f → AlgMorphEq' (AlgEq (fcong X (cong OMap (law A))) ((ext λ Z → dext (λ {f₁} {f'} p → Llawlem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (bind M) (bindlaw A) p)))) (AlgEq (fcong Y (cong OMap (law A))) ((ext λ Z → dext (λ {f₁} {f'} p → Llawlem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (bind M) (bindlaw A) p)))) (dcong (refl {x = f}) (ext (λ _ → cong₂ (Hom C) (fcong X (cong OMap (law A))) (fcong Y (cong OMap (law A))))) (dicong (refl {x = Y}) (ext (λ z → cong (λ F → Hom C X z → Hom C (F X) (F z)) (cong OMap (law A)))) (dicong (refl {x = X}) (ext (λ z → cong (λ F → ∀ {y} → Hom C z y → Hom C (F z) (F y)) (cong OMap (law A)))) (cong HMap (law A)))))) Rlaw' : R (adj A) ≅ R (adj EMObj) ○ K' Rlaw' = FunctorEq _ _ refl refl rightlaw' : {X : Obj C} {Y : Obj (D A)} {f : Hom C X (OMap (R (adj A)) Y)} → HMap K' (right (adj A) f) ≅ right (adj EMObj) {X} {OMap K' Y} (subst (Hom C X) (fcong Y (cong OMap Rlaw')) f) rightlaw' {X = X}{Y = Y}{f = f} = AlgMorphEq' (AlgEq (fcong X (cong OMap (law A))) (ext λ Z → dext (λ p → Llawlem (TFun M) (L (adj A)) (R (adj A)) (law A) (right (adj A)) (bind M) (bindlaw A) p ))) refl (trans (cong (λ (f₁ : Hom C X (OMap (R (adj A)) Y)) → HMap (R (adj A)) (right (adj A) f₁)) (sym (stripsubst (Hom C X) f (fcong Y (cong OMap Rlaw')))) ) (sym (stripsubst (λ Z → Hom C Z (OMap (R (adj A)) Y)) ( ((HMap (R (adj A)) (right (adj A) (subst (Hom C X) (fcong Y (cong (λ r → OMap r) Rlaw')) f))))) (fcong X (cong OMap (law A)))))) EMHom : Hom CatofAdj A EMObj EMHom = record { K = K'; Llaw = Llaw'; Rlaw = Rlaw'; rightlaw = rightlaw'}
{ "alphanum_fraction": 0.4269524513, "avg_line_length": 26.1870967742, "ext": "agda", "hexsha": "9ad5c24947113936e65368d6cbacb092ba2bd72c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_path": "Monads/CatofAdj/TermAdjHom.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_path": "Monads/CatofAdj/TermAdjHom.agda", "max_line_length": 183, "max_stars_count": 21, "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_path": "Monads/CatofAdj/TermAdjHom.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "num_tokens": 1551, "size": 4059 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Base open import lib.PathFunctor open import lib.PathGroupoid open import lib.Equivalence {- Structural lemmas about paths over paths The lemmas here have the form [↓-something-in] : introduction rule for the something [↓-something-out] : elimination rule for the something [↓-something-β] : β-reduction rule for the something [↓-something-η] : η-reduction rule for the something The possible somethings are: [cst] : constant fibration [cst2] : fibration constant in the second argument [cst2×] : fibration constant and nondependent in the second argument [ap] : the path below is of the form [ap f p] [fst×] : the fibration is [fst] (nondependent product) [snd×] : the fibration is [snd] (nondependent product) The rule of prime: The above lemmas should choose between [_∙_] and [_∙'_] in a way that, if the underlying path is [idp], then the entire lemma reduces to an identity function. Otherwise, the lemma would have the suffix [in'] or [out'], meaning that all the choices of [_∙_] or [_∙'_] are exactly the opposite ones. You can also go back and forth between dependent paths and homogeneous paths with a transport on one side with the functions [to-transp], [from-transp], [to-transp-β] [to-transp!], [from-transp!], [to-transp!-β] More lemmas about paths over paths are present in the lib.types.* modules (depending on the type constructor of the fibration) -} module lib.PathOver where {- Dependent paths in a constant fibration -} module _ {i j} {A : Type i} {B : Type j} where ↓-cst-in : {x y : A} {p : x == y} {u v : B} → u == v → u == v [ (λ _ → B) ↓ p ] ↓-cst-in {p = idp} q = q ↓-cst-out : {x y : A} {p : x == y} {u v : B} → u == v [ (λ _ → B) ↓ p ] → u == v ↓-cst-out {p = idp} q = q ↓-cst-β : {x y : A} (p : x == y) {u v : B} (q : u == v) → (↓-cst-out (↓-cst-in {p = p} q) == q) ↓-cst-β idp q = idp {- Interaction of [↓-cst-in] with [_∙_] -} ↓-cst-in-∙ : {x y z : A} (p : x == y) (q : y == z) {u v w : B} (p' : u == v) (q' : v == w) → ↓-cst-in {p = p ∙ q} (p' ∙ q') == ↓-cst-in {p = p} p' ∙ᵈ ↓-cst-in {p = q} q' ↓-cst-in-∙ idp idp idp idp = idp {- Interaction of [↓-cst-in] with [_∙'_] -} ↓-cst-in-∙' : {x y z : A} (p : x == y) (q : y == z) {u v w : B} (p' : u == v) (q' : v == w) → ↓-cst-in {p = p ∙' q} (p' ∙' q') == ↓-cst-in {p = p} p' ∙'ᵈ ↓-cst-in {p = q} q' ↓-cst-in-∙' idp idp idp idp = idp {- Introduction of an equality between [↓-cst-in]s (used to deduce the recursor from the eliminator in HIT with 2-paths) -} ↓-cst-in2 : {a a' : A} {u v : B} {p₀ : a == a'} {p₁ : a == a'} {q₀ q₁ : u == v} {q : p₀ == p₁} → q₀ == q₁ → (↓-cst-in {p = p₀} q₀ == ↓-cst-in {p = p₁} q₁ [ (λ p → u == v [ (λ _ → B) ↓ p ]) ↓ q ]) ↓-cst-in2 {p₀ = idp} {p₁ = .idp} {q₀} {q₁} {idp} k = k -- Dependent paths in a fibration constant in the second argument module _ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} where ↓-cst2-in : {x y : A} (p : x == y) {b : C x} {c : C y} (q : b == c [ C ↓ p ]) {u : B x} {v : B y} → u == v [ B ↓ p ] → u == v [ (λ xy → B (fst xy)) ↓ (pair= p q) ] ↓-cst2-in idp idp r = r ↓-cst2-out : {x y : A} (p : x == y) {b : C x} {c : C y} (q : b == c [ C ↓ p ]) {u : B x} {v : B y} → u == v [ (λ xy → B (fst xy)) ↓ (pair= p q) ] → u == v [ B ↓ p ] ↓-cst2-out idp idp r = r -- Dependent paths in a fibration constant and non dependent in the -- second argument module _ {i j k} {A : Type i} {B : A → Type j} {C : Type k} where ↓-cst2×-in : {x y : A} (p : x == y) {b c : C} (q : b == c) {u : B x} {v : B y} → u == v [ B ↓ p ] → u == v [ (λ xy → B (fst xy)) ↓ (pair×= p q) ] ↓-cst2×-in idp idp r = r ↓-cst2×-out : {x y : A} (p : x == y) {b c : C} (q : b == c) {u : B x} {v : B y} → u == v [ (λ xy → B (fst xy)) ↓ (pair×= p q) ] → u == v [ B ↓ p ] ↓-cst2×-out idp idp r = r -- Dependent paths in the universal fibration over the universe ↓-idf-out : ∀ {i} {A B : Type i} (p : A == B) {u : A} {v : B} → u == v [ (λ x → x) ↓ p ] → coe p u == v ↓-idf-out idp = idf _ ↓-idf-in : ∀ {i} {A B : Type i} (p : A == B) {u : A} {v : B} → coe p u == v → u == v [ (λ x → x) ↓ p ] ↓-idf-in idp = idf _ -- Dependent paths over [ap f p] module _ {i j k} {A : Type i} {B : Type j} (C : B → Type k) (f : A → B) where ↓-ap-in : {x y : A} {p : x == y} {u : C (f x)} {v : C (f y)} → u == v [ C ∘ f ↓ p ] → u == v [ C ↓ ap f p ] ↓-ap-in {p = idp} idp = idp ↓-ap-out : {x y : A} (p : x == y) {u : C (f x)} {v : C (f y)} → u == v [ C ↓ ap f p ] → u == v [ C ∘ f ↓ p ] ↓-ap-out idp idp = idp -- Dependent paths over [ap2 f p q] module _ {i j k l} {A : Type i} {B : Type j} {C : Type k} (D : C → Type l) (f : A → B → C) where ↓-ap2-in : {x y : A} {p : x == y} {w z : B} {q : w == z} {u : D (f x w)} {v : D (f y z)} → u == v [ D ∘ uncurry f ↓ pair×= p q ] → u == v [ D ↓ ap2 f p q ] ↓-ap2-in {p = idp} {q = idp} α = α ↓-ap2-out : {x y : A} {p : x == y} {w z : B} {q : w == z} {u : D (f x w)} {v : D (f y z)} → u == v [ D ↓ ap2 f p q ] → u == v [ D ∘ uncurry f ↓ pair×= p q ] ↓-ap2-out {p = idp} {q = idp} α = α apd↓ : ∀ {i j k} {A : Type i} {B : A → Type j} {C : (a : A) → B a → Type k} (f : {a : A} (b : B a) → C a b) {x y : A} {p : x == y} {u : B x} {v : B y} (q : u == v [ B ↓ p ]) → f u == f v [ (λ xy → C (fst xy) (snd xy)) ↓ pair= p q ] apd↓ f {p = idp} idp = idp apd↓=apd : ∀ {i j} {A : Type i} {B : A → Type j} (f : (a : A) → B a) {x y : A} (p : x == y) → (apd f p == ↓-ap-out _ _ p (apd↓ {A = Unit} f {p = idp} p)) apd↓=apd f idp = idp -- Paths in the fibrations [fst] and [snd] module _ {i j} where ↓-fst×-out : {A A' : Type i} {B B' : Type j} (p : A == A') (q : B == B') {u : A} {v : A'} → u == v [ fst ↓ pair×= p q ] → u == v [ (λ X → X) ↓ p ] ↓-fst×-out idp idp h = h ↓-snd×-in : {A A' : Type i} {B B' : Type j} (p : A == A') (q : B == B') {u : B} {v : B'} → u == v [ (λ X → X) ↓ q ] → u == v [ snd ↓ pair×= p q ] ↓-snd×-in idp idp h = h -- Mediating dependent paths with the transport version module _ {i j} {A : Type i} where from-transp : (B : A → Type j) {a a' : A} (p : a == a') {u : B a} {v : B a'} → (transport B p u == v) → (u == v [ B ↓ p ]) from-transp B idp idp = idp to-transp : {B : A → Type j} {a a' : A} {p : a == a'} {u : B a} {v : B a'} → (u == v [ B ↓ p ]) → (transport B p u == v) to-transp {p = idp} idp = idp to-transp-β : (B : A → Type j) {a a' : A} (p : a == a') {u : B a} {v : B a'} (q : transport B p u == v) → to-transp (from-transp B p q) == q to-transp-β B idp idp = idp to-transp-η : {B : A → Type j} {a a' : A} {p : a == a'} {u : B a} {v : B a'} (q : u == v [ B ↓ p ]) → from-transp B p (to-transp q) == q to-transp-η {p = idp} idp = idp to-transp-equiv : (B : A → Type j) {a a' : A} (p : a == a') {u : B a} {v : B a'} → (u == v [ B ↓ p ]) ≃ (transport B p u == v) to-transp-equiv B p = equiv to-transp (from-transp B p) (to-transp-β B p) (to-transp-η) from-transp! : (B : A → Type j) {a a' : A} (p : a == a') {u : B a} {v : B a'} → (u == transport! B p v) → (u == v [ B ↓ p ]) from-transp! B idp idp = idp to-transp! : {B : A → Type j} {a a' : A} {p : a == a'} {u : B a} {v : B a'} → (u == v [ B ↓ p ]) → (u == transport! B p v) to-transp! {p = idp} idp = idp to-transp!-β : (B : A → Type j) {a a' : A} (p : a == a') {u : B a} {v : B a'} (q : u == transport! B p v) → to-transp! (from-transp! B p q) == q to-transp!-β B idp idp = idp to-transp!-η : {B : A → Type j} {a a' : A} {p : a == a'} {u : B a} {v : B a'} (q : u == v [ B ↓ p ]) → from-transp! B p (to-transp! q) == q to-transp!-η {p = idp} idp = idp to-transp!-equiv : (B : A → Type j) {a a' : A} (p : a == a') {u : B a} {v : B a'} → (u == v [ B ↓ p ]) ≃ (u == transport! B p v) to-transp!-equiv B p = equiv to-transp! (from-transp! B p) (to-transp!-β B p) (to-transp!-η) {- Various other lemmas -} {- Used for defining the recursor from the eliminator for 1-HIT -} apd=cst-in : ∀ {i j} {A : Type i} {B : Type j} {f : A → B} {a a' : A} {p : a == a'} {q : f a == f a'} → apd f p == ↓-cst-in q → ap f p == q apd=cst-in {p = idp} x = x ↓-apd-out : ∀ {i j k} {A : Type i} {B : A → Type j} (C : (a : A) → B a → Type k) {f : Π A B} {x y : A} {p : x == y} {q : f x == f y [ B ↓ p ]} (r : apd f p == q) {u : C x (f x)} {v : C y (f y)} → u == v [ uncurry C ↓ pair= p q ] → u == v [ (λ z → C z (f z)) ↓ p ] ↓-apd-out C {p = idp} idp idp = idp ↓-ap-out= : ∀ {i j k} {A : Type i} {B : Type j} (C : (b : B) → Type k) (f : A → B) {x y : A} (p : x == y) {q : f x == f y} (r : ap f p == q) {u : C (f x)} {v : C (f y)} → u == v [ C ↓ q ] → u == v [ (λ z → C (f z)) ↓ p ] ↓-ap-out= C f idp idp idp = idp -- No idea what that is to-transp-weird : ∀ {i j} {A : Type i} {B : A → Type j} {u v : A} {d : B u} {d' d'' : B v} {p : u == v} (q : d == d' [ B ↓ p ]) (r : transport B p d == d'') → (from-transp B p r ∙'ᵈ (! r ∙ to-transp q)) == q to-transp-weird {p = idp} idp idp = idp -- Something not really clear yet module _ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : A → C) (g : B → C) where ↓-swap : {a a' : A} {p : a == a'} {b b' : B} {q : b == b'} (r : f a == g b') (s : f a' == g b) → (ap f p ∙' s == r [ (λ x → f a == g x) ↓ q ]) → (r == s ∙ ap g q [ (λ x → f x == g b') ↓ p ]) ↓-swap {p = idp} {q = idp} r s t = (! t) ∙ ∙'-unit-l s ∙ ! (∙-unit-r s) ↓-swap! : {a a' : A} {p : a == a'} {b b' : B} {q : b == b'} (r : f a == g b') (s : f a' == g b) → (r == s ∙ ap g q [ (λ x → f x == g b') ↓ p ]) → (ap f p ∙' s == r [ (λ x → f a == g x) ↓ q ]) ↓-swap! {p = idp} {q = idp} r s t = ∙'-unit-l s ∙ ! (∙-unit-r s) ∙ (! t) ↓-swap-β : {a a' : A} {p : a == a'} {b b' : B} {q : b == b'} (r : f a == g b') (s : f a' == g b) (t : ap f p ∙' s == r [ (λ x → f a == g x) ↓ q ]) → ↓-swap! r s (↓-swap r s t) == t ↓-swap-β {p = idp} {q = idp} r s t = coh (∙'-unit-l s) (∙-unit-r s) t where coh : ∀ {i} {X : Type i} {x y z t : X} (p : x == y) (q : z == y) (r : x == t) → p ∙ ! q ∙ ! (! r ∙ p ∙ ! q) == r coh idp idp idp = idp transp-↓ : ∀ {i j} {A : Type i} (P : A → Type j) {a₁ a₂ : A} (p : a₁ == a₂) (y : P a₂) → transport P (! p) y == y [ P ↓ p ] transp-↓ _ idp _ = idp transp-ap-↓ : ∀ {i j k} {A : Type i} {B : Type j} (P : B → Type k) (h : A → B) {a₁ a₂ : A} (p : a₁ == a₂) (y : P (h a₂)) → transport P (! (ap h p)) y == y [ P ∘ h ↓ p ] transp-ap-↓ _ _ idp _ = idp
{ "alphanum_fraction": 0.4413413039, "avg_line_length": 34.6472491909, "ext": "agda", "hexsha": "1a276be7495fc14b1af17d24bcd328f9920e6f95", "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/PathOver.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/PathOver.agda", "max_line_length": 93, "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/PathOver.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4855, "size": 10706 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The lifting of a strict order to incorporate a new supremum ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- This module is designed to be used with -- Relation.Nullary.Construct.Add.Supremum open import Relation.Binary module Relation.Binary.Construct.Add.Supremum.Strict {a r} {A : Set a} (_<_ : Rel A r) where open import Level using (_⊔_) open import Data.Product open import Function open import Relation.Nullary hiding (Irrelevant) import Relation.Nullary.Decidable as Dec open import Relation.Binary.PropositionalEquality as P using (_≡_; refl) open import Relation.Nullary.Construct.Add.Supremum import Relation.Binary.Construct.Add.Supremum.Equality as Equality import Relation.Binary.Construct.Add.Supremum.NonStrict as NonStrict ------------------------------------------------------------------------ -- Definition infix 4 _<⁺_ data _<⁺_ : Rel (A ⁺) (a ⊔ r) where [_] : {k l : A} → k < l → [ k ] <⁺ [ l ] [_]<⊤⁺ : (k : A) → [ k ] <⁺ ⊤⁺ ------------------------------------------------------------------------ -- Relational properties [<]-injective : ∀ {k l} → [ k ] <⁺ [ l ] → k < l [<]-injective [ p ] = p <⁺-asym : Asymmetric _<_ → Asymmetric _<⁺_ <⁺-asym <-asym [ p ] [ q ] = <-asym p q <⁺-trans : Transitive _<_ → Transitive _<⁺_ <⁺-trans <-trans [ p ] [ q ] = [ <-trans p q ] <⁺-trans <-trans [ p ] [ k ]<⊤⁺ = [ _ ]<⊤⁺ <⁺-dec : Decidable _<_ → Decidable _<⁺_ <⁺-dec _<?_ [ k ] [ l ] = Dec.map′ [_] [<]-injective (k <? l) <⁺-dec _<?_ [ k ] ⊤⁺ = yes [ k ]<⊤⁺ <⁺-dec _<?_ ⊤⁺ [ l ] = no (λ ()) <⁺-dec _<?_ ⊤⁺ ⊤⁺ = no (λ ()) <⁺-irrelevant : Irrelevant _<_ → Irrelevant _<⁺_ <⁺-irrelevant <-irr [ p ] [ q ] = P.cong _ (<-irr p q) <⁺-irrelevant <-irr [ k ]<⊤⁺ [ k ]<⊤⁺ = P.refl module _ {r} {_≤_ : Rel A r} where open NonStrict _≤_ <⁺-transʳ : Trans _≤_ _<_ _<_ → Trans _≤⁺_ _<⁺_ _<⁺_ <⁺-transʳ <-transʳ [ p ] [ q ] = [ <-transʳ p q ] <⁺-transʳ <-transʳ [ p ] [ k ]<⊤⁺ = [ _ ]<⊤⁺ <⁺-transˡ : Trans _<_ _≤_ _<_ → Trans _<⁺_ _≤⁺_ _<⁺_ <⁺-transˡ <-transˡ [ p ] [ q ] = [ <-transˡ p q ] <⁺-transˡ <-transˡ [ p ] ([ _ ] ≤⊤⁺) = [ _ ]<⊤⁺ <⁺-transˡ <-transˡ [ k ]<⊤⁺ (⊤⁺ ≤⊤⁺) = [ k ]<⊤⁺ ------------------------------------------------------------------------ -- Relational properties + propositional equality <⁺-cmp-≡ : Trichotomous _≡_ _<_ → Trichotomous _≡_ _<⁺_ <⁺-cmp-≡ <-cmp ⊤⁺ ⊤⁺ = tri≈ (λ ()) refl (λ ()) <⁺-cmp-≡ <-cmp ⊤⁺ [ l ] = tri> (λ ()) (λ ()) [ l ]<⊤⁺ <⁺-cmp-≡ <-cmp [ k ] ⊤⁺ = tri< [ k ]<⊤⁺ (λ ()) (λ ()) <⁺-cmp-≡ <-cmp [ k ] [ l ] with <-cmp k l ... | tri< a ¬b ¬c = tri< [ a ] (¬b ∘ []-injective) (¬c ∘ [<]-injective) ... | tri≈ ¬a refl ¬c = tri≈ (¬a ∘ [<]-injective) refl (¬c ∘ [<]-injective) ... | tri> ¬a ¬b c = tri> (¬a ∘ [<]-injective) (¬b ∘ []-injective) [ c ] <⁺-irrefl-≡ : Irreflexive _≡_ _<_ → Irreflexive _≡_ _<⁺_ <⁺-irrefl-≡ <-irrefl refl [ x ] = <-irrefl refl x <⁺-respˡ-≡ : _<⁺_ Respectsˡ _≡_ <⁺-respˡ-≡ = P.subst (_<⁺ _) <⁺-respʳ-≡ : _<⁺_ Respectsʳ _≡_ <⁺-respʳ-≡ = P.subst (_ <⁺_) <⁺-resp-≡ : _<⁺_ Respects₂ _≡_ <⁺-resp-≡ = <⁺-respʳ-≡ , <⁺-respˡ-≡ ------------------------------------------------------------------------ -- Relational properties + setoid equality module _ {e} {_≈_ : Rel A e} where open Equality _≈_ <⁺-cmp : Trichotomous _≈_ _<_ → Trichotomous _≈⁺_ _<⁺_ <⁺-cmp <-cmp ⊤⁺ ⊤⁺ = tri≈ (λ ()) ⊤⁺≈⊤⁺ (λ ()) <⁺-cmp <-cmp ⊤⁺ [ l ] = tri> (λ ()) (λ ()) [ l ]<⊤⁺ <⁺-cmp <-cmp [ k ] ⊤⁺ = tri< [ k ]<⊤⁺ (λ ()) (λ ()) <⁺-cmp <-cmp [ k ] [ l ] with <-cmp k l ... | tri< a ¬b ¬c = tri< [ a ] (¬b ∘ [≈]-injective) (¬c ∘ [<]-injective) ... | tri≈ ¬a b ¬c = tri≈ (¬a ∘ [<]-injective) [ b ] (¬c ∘ [<]-injective) ... | tri> ¬a ¬b c = tri> (¬a ∘ [<]-injective) (¬b ∘ [≈]-injective) [ c ] <⁺-irrefl : Irreflexive _≈_ _<_ → Irreflexive _≈⁺_ _<⁺_ <⁺-irrefl <-irrefl [ p ] [ q ] = <-irrefl p q <⁺-respˡ-≈⁺ : _<_ Respectsˡ _≈_ → _<⁺_ Respectsˡ _≈⁺_ <⁺-respˡ-≈⁺ <-respˡ-≈ [ p ] [ q ] = [ <-respˡ-≈ p q ] <⁺-respˡ-≈⁺ <-respˡ-≈ [ p ] ([ l ]<⊤⁺) = [ _ ]<⊤⁺ <⁺-respˡ-≈⁺ <-respˡ-≈ ⊤⁺≈⊤⁺ q = q <⁺-respʳ-≈⁺ : _<_ Respectsʳ _≈_ → _<⁺_ Respectsʳ _≈⁺_ <⁺-respʳ-≈⁺ <-respʳ-≈ [ p ] [ q ] = [ <-respʳ-≈ p q ] <⁺-respʳ-≈⁺ <-respʳ-≈ ⊤⁺≈⊤⁺ q = q <⁺-resp-≈⁺ : _<_ Respects₂ _≈_ → _<⁺_ Respects₂ _≈⁺_ <⁺-resp-≈⁺ = map <⁺-respʳ-≈⁺ <⁺-respˡ-≈⁺ ------------------------------------------------------------------------ -- Structures + propositional equality <⁺-isStrictPartialOrder-≡ : IsStrictPartialOrder _≡_ _<_ → IsStrictPartialOrder _≡_ _<⁺_ <⁺-isStrictPartialOrder-≡ strict = record { isEquivalence = P.isEquivalence ; irrefl = <⁺-irrefl-≡ irrefl ; trans = <⁺-trans trans ; <-resp-≈ = <⁺-resp-≡ } where open IsStrictPartialOrder strict <⁺-isDecStrictPartialOrder-≡ : IsDecStrictPartialOrder _≡_ _<_ → IsDecStrictPartialOrder _≡_ _<⁺_ <⁺-isDecStrictPartialOrder-≡ dectot = record { isStrictPartialOrder = <⁺-isStrictPartialOrder-≡ isStrictPartialOrder ; _≟_ = ≡-dec _≟_ ; _<?_ = <⁺-dec _<?_ } where open IsDecStrictPartialOrder dectot <⁺-isStrictTotalOrder-≡ : IsStrictTotalOrder _≡_ _<_ → IsStrictTotalOrder _≡_ _<⁺_ <⁺-isStrictTotalOrder-≡ strictot = record { isEquivalence = P.isEquivalence ; trans = <⁺-trans trans ; compare = <⁺-cmp-≡ compare } where open IsStrictTotalOrder strictot ------------------------------------------------------------------------ -- Structures + setoid equality module _ {e} {_≈_ : Rel A e} where open Equality _≈_ <⁺-isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_ → IsStrictPartialOrder _≈⁺_ _<⁺_ <⁺-isStrictPartialOrder strict = record { isEquivalence = ≈⁺-isEquivalence isEquivalence ; irrefl = <⁺-irrefl irrefl ; trans = <⁺-trans trans ; <-resp-≈ = <⁺-resp-≈⁺ <-resp-≈ } where open IsStrictPartialOrder strict <⁺-isDecStrictPartialOrder : IsDecStrictPartialOrder _≈_ _<_ → IsDecStrictPartialOrder _≈⁺_ _<⁺_ <⁺-isDecStrictPartialOrder dectot = record { isStrictPartialOrder = <⁺-isStrictPartialOrder isStrictPartialOrder ; _≟_ = ≈⁺-dec _≟_ ; _<?_ = <⁺-dec _<?_ } where open IsDecStrictPartialOrder dectot <⁺-isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_ → IsStrictTotalOrder _≈⁺_ _<⁺_ <⁺-isStrictTotalOrder strictot = record { isEquivalence = ≈⁺-isEquivalence isEquivalence ; trans = <⁺-trans trans ; compare = <⁺-cmp compare } where open IsStrictTotalOrder strictot
{ "alphanum_fraction": 0.4877411867, "avg_line_length": 36.664893617, "ext": "agda", "hexsha": "2fdaf2d2bd74e412cd5dbfaa668ea8607101438f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Relation/Binary/Construct/Add/Supremum/Strict.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Relation/Binary/Construct/Add/Supremum/Strict.agda", "max_line_length": 75, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Relation/Binary/Construct/Add/Supremum/Strict.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": 2857, "size": 6893 }
module _ where module A where infix 2 _↑ infix 1 c data D : Set where ● : D _↑ : D → D c : {x y : D} → D syntax c {x = x} {y = y} = x ↓ y module B where infix 1 c data D : Set where c : {y x : D} → D syntax c {y = y} {x = x} = y ↓ x open A open B rejected : A.D rejected = ● ↑ ↓ ●
{ "alphanum_fraction": 0.4674922601, "avg_line_length": 11.1379310345, "ext": "agda", "hexsha": "a88c6f5faf2ae715b953afaa04c5148af3b2759e", "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/Issue1436-12.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/Issue1436-12.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": "test/Fail/Issue1436-12.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": 138, "size": 323 }
{-# OPTIONS --cubical --safe #-} module Issue4949 where open import Agda.Builtin.Cubical.Path open import Agda.Primitive.Cubical renaming (primIMax to _∨_) open import Agda.Builtin.Unit open import Agda.Builtin.Sigma open import Agda.Builtin.Cubical.Glue renaming (prim^glue to glue) idIsEquiv : ∀ {ℓ} (A : Set ℓ) → isEquiv (\ (x : A) → x) equiv-proof (idIsEquiv A) y = ((y , \ _ → y) , λ z i → z .snd (primINeg i) , λ j → z .snd (primINeg i ∨ j)) idEquiv : ∀ {ℓ} (A : Set ℓ) → Σ _ (isEquiv {A = A} {B = A}) idEquiv A .fst = \ x → x idEquiv A .snd = idIsEquiv A Glue : ∀ {ℓ ℓ'} (A : Set ℓ) {φ : I} → (Te : Partial φ (Σ (Set ℓ') \ T → Σ _ (isEquiv {A = T} {B = A}))) → Set ℓ' Glue A Te = primGlue A (λ x → Te x .fst) (λ x → Te x .snd) ua : ∀ {ℓ} {A B : Set ℓ} → A ≃ B → A ≡ B ua {A = A} {B = B} e i = Glue B (λ { (i = i0) → (A , e) ; (i = i1) → (B , idEquiv B) }) ⊤₀ = ⊤ ⊤₁ = Σ ⊤ \ _ → ⊤ prf : isEquiv {A = ⊤₀} {B = ⊤₁} _ equiv-proof prf y = (_ , \ i → _) , (\ y → \ i → _ , (\ j → _)) u : ⊤₀ ≡ ⊤₁ u = ua ((λ _ → _) , prf) uniq : ∀ i j → u (i ∨ j) uniq i j = glue (λ { (i = i0) (j = i0) → tt ; (i = i1) → tt , tt ; (j = i1) → tt , tt }) _ -- comparing the partial element argument of `glue` should happen at the right type. -- if it does not we get problems with eta. test : ∀ j → uniq i0 j ≡ glue (λ { (i0 = i0) (j = i0) → tt ; (j = i1) → tt , tt }) (tt , tt) test j = \ k → uniq i0 j
{ "alphanum_fraction": 0.5048342541, "avg_line_length": 32.1777777778, "ext": "agda", "hexsha": "56b9e544e55dfd0e2881eda3e1d8c1085a5d3936", "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/Issue4949.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/Issue4949.agda", "max_line_length": 92, "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/Issue4949.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": 628, "size": 1448 }
-- Problem 4: ``50 shades of continuity'' {- C(f) = ∀ c : X. Cat(f,c) Cat(f,c) = ∀ ε > 0. ∃ δ > 0. Q(f,c,ε,δ) Q(f,c,ε,δ) = ∀ x : X. abs(x - c) < δ ⇒ abs(f x - f c) < ε C'(f) = ∃ getδ : X -> RPos -> RPos. ∀ c : X. ∀ ε > 0. Q(f,c,ε,getδ c ε) 4a: Define UC(f): UC(f) = ∀ ε > 0. ∃ δ > 0. ∀ y : X. Q(f,y,ε,δ) 4b: Define UC'(f): UC'(f) = ∃ newδ : RPos -> RPos. ∀ ε > 0. ∀ y : X. Q(f,y,ε,newδ ε) The function |newδ| computes a suitable "global" |δ| from any |ε|, which shows |Q| for any |y|. 4c: Prove |∀ f : X -> ℝ. UC'(f) => C'(f)|. The proof is a function from a pair (newδ, puc) to a pair (getδ, pc). proof f (newδ, puc) = (getδ, pc) where getδ c ε = newδ ε pc c ε = puc ε c -- (1) The type of (1) is Q(f,c,ε,newδ ε) = Q(f,c,ε,getδ c ε) which is the type of |pc c ε|. ---------------- Below is a self-contained proof in Agda just to check the above. It is not part of the exam question. -} postulate R RPos : Set abs : R -> RPos _-_ : R -> R -> R _<_ : RPos -> RPos -> Set X = R -- to avoid trouble with lack of subtyping record Sigma (A : Set) (B : A -> Set) : Set where constructor _,_ field fst : A snd : B fst Q : (X -> R) -> X -> RPos -> RPos -> Set Q f c ε δ = (x : X) -> (abs( x - c) < δ) -> (abs(f x - f c) < ε) Cat : (X -> R) -> X -> Set Cat f c = (ε : RPos) -> Sigma RPos (\δ -> Q f c ε δ) C : (X -> R) -> Set C f = (c : X) -> Cat f c C' : (X -> R) -> Set C' f = Sigma (X -> RPos -> RPos) (\getδ -> (c : X) -> (ε : RPos) -> Q f c ε (getδ c ε)) UC : (X -> R) -> Set UC f = (ε : RPos) -> Sigma RPos (\δ -> (y : X) -> Q f y ε δ) UC' : (X -> R) -> Set UC' f = Sigma (RPos -> RPos) (\newδ -> (ε : RPos) -> (y : X) -> Q f y ε (newδ ε)) proof : (f : X -> R) -> UC' f -> C' f proof f (newδ , puc) = (getδ , pc) where getδ = \c -> newδ pc = \c ε -> puc ε c
{ "alphanum_fraction": 0.4320120421, "avg_line_length": 23.4470588235, "ext": "agda", "hexsha": "eb9e02811a509eff1f63211a6324a194a8087110", "lang": "Agda", "max_forks_count": 47, "max_forks_repo_forks_event_max_datetime": "2022-03-03T23:57:42.000Z", "max_forks_repo_forks_event_min_datetime": "2015-11-16T08:41:04.000Z", "max_forks_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "nicolabotta/DSLsofMath", "max_forks_repo_path": "Exam/2017-08/P4.agda", "max_issues_count": 51, "max_issues_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_issues_repo_issues_event_max_datetime": "2022-03-03T20:06:39.000Z", "max_issues_repo_issues_event_min_datetime": "2016-01-30T15:59:39.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "nicolabotta/DSLsofMath", "max_issues_repo_path": "Exam/2017-08/P4.agda", "max_line_length": 78, "max_stars_count": 248, "max_stars_repo_head_hexsha": "ce764c9bbff5a726d5cf1699a433d9921a1d6a60", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "nicolabotta/DSLsofMath", "max_stars_repo_path": "Exam/2017-08/P4.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-29T11:12:24.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-27T21:04:02.000Z", "num_tokens": 821, "size": 1993 }
-- {-# OPTIONS --show-implicit --show-irrelevant #-} module Data.QuadTree.LensProofs.Valid-LensA where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Lens.Lens open import Data.Logic open import Data.QuadTree.InternalAgda open import Agda.Primitive open import Data.Lens.Proofs.LensLaws open import Data.Lens.Proofs.LensPostulates open import Data.Lens.Proofs.LensComposition open import Data.QuadTree.Implementation.QuadrantLenses open import Data.QuadTree.Implementation.Definition open import Data.QuadTree.Implementation.ValidTypes open import Data.QuadTree.Implementation.SafeFunctions open import Data.QuadTree.Implementation.PublicFunctions open import Data.QuadTree.Implementation.DataLenses --- Lens laws for lensA ValidLens-LensA-ViewSet : {t : Set} {{eqT : Eq t}} {dep : Nat} -> ViewSet (lensA {t} {dep}) ValidLens-LensA-ViewSet (CVQuadrant (Leaf x) {p1}) (CVQuadrant (Leaf v) {p2}) = begin view lensA (set lensA (CVQuadrant (Leaf x) {p1}) (CVQuadrant (Leaf v) {p2})) =⟨⟩ getConst (lensA CConst (ifc (x == v && v == v && v == v) then CVQuadrant (Leaf x) else CVQuadrant (Node (Leaf x) (Leaf v) (Leaf v) (Leaf v)))) =⟨ sym (propFnIfc (x == v && v == v && v == v) (λ x -> getConst (lensA CConst x))) ⟩ (ifc (x == v && v == v && v == v) then (CVQuadrant (Leaf x)) else (CVQuadrant (Leaf x))) =⟨ propIfcBranchesSame {c = (x == v && v == v && v == v)} (CVQuadrant (Leaf x)) ⟩ (CVQuadrant (Leaf x)) end ValidLens-LensA-ViewSet (CVQuadrant (Node a b c d)) (CVQuadrant (Leaf v)) = refl ValidLens-LensA-ViewSet (CVQuadrant (Leaf x) {p1}) (CVQuadrant (Node a b@(Leaf vb) c@(Leaf vc) d@(Leaf vd)) {p2}) = begin view lensA (set lensA (CVQuadrant (Leaf x) {p1}) (CVQuadrant (Node a b c d) {p2})) =⟨⟩ getConst (lensA CConst ( ifc (x == vb && vb == vc && vc == vd) then (CVQuadrant (Leaf x)) else (CVQuadrant (Node (Leaf x) (Leaf vb) (Leaf vc) (Leaf vd))) )) =⟨ sym (propFnIfc (x == vb && vb == vc && vc == vd) (λ x -> getConst (lensA CConst x))) ⟩ (ifc (x == vb && vb == vc && vc == vd) then (CVQuadrant (Leaf x)) else (CVQuadrant (Leaf x))) =⟨ propIfcBranchesSame {c = (x == vb && vb == vc && vc == vd)} (CVQuadrant (Leaf x)) ⟩ (CVQuadrant (Leaf x)) end ValidLens-LensA-ViewSet (CVQuadrant (Leaf x)) (CVQuadrant (Node a (Leaf x₁) (Leaf x₂) (Node d d₁ d₂ d₃))) = refl ValidLens-LensA-ViewSet (CVQuadrant (Leaf x)) (CVQuadrant (Node a (Leaf x₁) (Node c c₁ c₂ c₃) d)) = refl ValidLens-LensA-ViewSet (CVQuadrant (Leaf x)) (CVQuadrant (Node a (Node b b₁ b₂ b₃) c d)) = refl ValidLens-LensA-ViewSet (CVQuadrant (Node toa tob toc tod)) (CVQuadrant (Node a b c d)) = refl ValidLens-LensA-SetView : {t : Set} {{eqT : Eq t}} {dep : Nat} -> SetView (lensA {t} {dep}) ValidLens-LensA-SetView {t} {dep} qd@(CVQuadrant (Leaf x) {p}) = begin set lensA (view lensA qd) qd =⟨⟩ ((ifc (x == x && x == x && x == x) then (CVQuadrant (Leaf x)) else λ {{z}} -> (CVQuadrant (Node (Leaf x) (Leaf x) (Leaf x) (Leaf x))))) =⟨ ifcTrue (x == x && x == x && x == x) (andCombine (eqReflexivity x) (andCombine (eqReflexivity x) (eqReflexivity x))) ⟩ CVQuadrant (Leaf x) end ValidLens-LensA-SetView {t} {dep} cv@(CVQuadrant qd@(Node (Leaf a) (Leaf b) (Leaf c) (Leaf d)) {p}) = begin set lensA (view lensA cv) cv =⟨⟩ (ifc (a == b && b == c && c == d) then (CVQuadrant (Leaf a)) else (CVQuadrant (Node (Leaf a) (Leaf b) (Leaf c) (Leaf d)))) =⟨ ifcFalse (a == b && b == c && c == d) (notTrueToFalse (andSnd {depth qd <= S dep} {isCompressed qd} p)) ⟩ (CVQuadrant (Node (Leaf a) (Leaf b) (Leaf c) (Leaf d))) end ValidLens-LensA-SetView (CVQuadrant (Node (Leaf x) (Leaf x₁) (Leaf x₂) (Node qd₃ qd₄ qd₅ qd₆))) = refl ValidLens-LensA-SetView (CVQuadrant (Node (Leaf x) (Leaf x₁) (Node qd₂ qd₄ qd₅ qd₆) qd₃)) = refl ValidLens-LensA-SetView (CVQuadrant (Node (Leaf x) (Node qd₁ qd₄ qd₅ qd₆) qd₂ qd₃)) = refl ValidLens-LensA-SetView (CVQuadrant (Node (Node qd qd₄ qd₅ qd₆) qd₁ qd₂ qd₃)) = refl ValidLens-LensA-SetSet-Lemma : {t : Set} {{eqT : Eq t}} {dep : Nat} -> (x a b c d : VQuadrant t {dep}) -> set lensA x (combine a b c d) ≡ (combine x b c d) ValidLens-LensA-SetSet-Lemma {t} {dep} (CVQuadrant x@(Leaf xv)) (CVQuadrant a@(Leaf va)) (CVQuadrant b@(Leaf vb)) (CVQuadrant c@(Leaf vc)) (CVQuadrant d@(Leaf vd)) = begin (runIdentity (lensA (λ _ → CIdentity (CVQuadrant (Leaf xv))) (ifc va == vb && vb == vc && vc == vd then CVQuadrant (Leaf va) else CVQuadrant (Node (Leaf va) (Leaf vb) (Leaf vc) (Leaf vd))))) =⟨ sym $ propFnIfc (va == vb && vb == vc && vc == vd) (λ g -> (runIdentity (lensA (λ _ → CIdentity (CVQuadrant (Leaf xv) {andCombine (zeroLteAny dep) IsTrue.itsTrue})) g ) ) ) ⟩ (ifc va == vb && vb == vc && vc == vd then ifc xv == va && va == va && va == va then CVQuadrant (Leaf xv) else CVQuadrant (Node (Leaf xv) (Leaf va) (Leaf va) (Leaf va)) else ifc xv == vb && vb == vc && vc == vd then CVQuadrant (Leaf xv) else CVQuadrant (Node (Leaf xv) (Leaf vb) (Leaf vc) (Leaf vd))) =⟨ ifcTrueMap {c = va == vb && vb == vc && vc == vd} (λ p -> cong (λ q -> ifc xv == q && q == q && q == q then CVQuadrant (Leaf xv) {andCombine (zeroLteAny (S dep)) IsTrue.itsTrue} else (λ {{p}} -> CVQuadrant (Node (Leaf xv) (Leaf q) (Leaf q) (Leaf q)) {andCombine (zeroLteAny (dep)) (falseToNotTrue p)}) ) (eqToEquiv va vb (andFst {va == vb} p)) ) ⟩ (ifc va == vb && vb == vc && vc == vd then ifc xv == vb && vb == vb && vb == vb then CVQuadrant (Leaf xv) {andCombine (zeroLteAny (S dep)) IsTrue.itsTrue} else (λ {{p}} -> CVQuadrant (Node (Leaf xv) (Leaf vb) (Leaf vb) (Leaf vb)) {andCombine (zeroLteAny (dep)) (falseToNotTrue p)}) else ifc xv == vb && vb == vc && vc == vd then CVQuadrant (Leaf xv) else CVQuadrant (Node (Leaf xv) (Leaf vb) (Leaf vc) (Leaf vd))) =⟨ ifcTrueMap {c = va == vb && vb == vc && vc == vd} (λ p -> cong (λ q -> ifc xv == vb && vb == q && q == q then CVQuadrant (Leaf xv) {andCombine (zeroLteAny (S dep)) IsTrue.itsTrue} else (λ {{p}} -> CVQuadrant (Node (Leaf xv) (Leaf vb) (Leaf q) (Leaf q)) {andCombine (zeroLteAny (dep)) (falseToNotTrue p)}) ) (eqToEquiv vb vc (andFst $ andSnd {va == vb} p)) ) ⟩ (ifc va == vb && vb == vc && vc == vd then ifc xv == vb && vb == vc && vc == vc then CVQuadrant (Leaf xv) {andCombine (zeroLteAny (S dep)) IsTrue.itsTrue} else (λ {{p}} -> CVQuadrant (Node (Leaf xv) (Leaf vb) (Leaf vc) (Leaf vc)) {andCombine (zeroLteAny (dep)) (falseToNotTrue p)}) else ifc xv == vb && vb == vc && vc == vd then CVQuadrant (Leaf xv) else CVQuadrant (Node (Leaf xv) (Leaf vb) (Leaf vc) (Leaf vd))) =⟨ ifcTrueMap {c = va == vb && vb == vc && vc == vd} (λ p -> cong (λ q -> ifc xv == vb && vb == vc && vc == q then CVQuadrant (Leaf xv) {andCombine (zeroLteAny (S dep)) IsTrue.itsTrue} else (λ {{p}} -> CVQuadrant (Node (Leaf xv) (Leaf vb) (Leaf vc) (Leaf q)) {andCombine (zeroLteAny (dep)) (falseToNotTrue p)}) ) (eqToEquiv vc vd (andSnd $ andSnd {va == vb} p)) ) ⟩ (ifc va == vb && vb == vc && vc == vd then ifc xv == vb && vb == vc && vc == vd then CVQuadrant (Leaf xv) {andCombine (zeroLteAny (S dep)) IsTrue.itsTrue} else (λ {{p}} -> CVQuadrant (Node (Leaf xv) (Leaf vb) (Leaf vc) (Leaf vd)) {andCombine (zeroLteAny (dep)) (falseToNotTrue p)}) else ifc xv == vb && vb == vc && vc == vd then CVQuadrant (Leaf xv) else CVQuadrant (Node (Leaf xv) (Leaf vb) (Leaf vc) (Leaf vd))) =⟨ propIfcBranchesSame {c = va == vb && vb == vc && vc == vd} (ifc xv == vb && vb == vc && vc == vd then CVQuadrant (Leaf xv) else CVQuadrant (Node (Leaf xv) (Leaf vb) (Leaf vc) (Leaf vd))) ⟩ (ifc xv == vb && vb == vc && vc == vd then CVQuadrant (Leaf xv) else CVQuadrant (Node (Leaf xv) (Leaf vb) (Leaf vc) (Leaf vd))) end ValidLens-LensA-SetSet-Lemma {t} {dep} cvx@(CVQuadrant x@(Node x1 x2 x3 x4) {p}) cva@(CVQuadrant a@(Leaf va)) cvb@(CVQuadrant b@(Leaf vb)) cvc@(CVQuadrant c@(Leaf vc)) cvd@(CVQuadrant d@(Leaf vd)) = begin runIdentity (lensA (λ _ → CIdentity cvx) (ifc va == vb && vb == vc && vc == vd then CVQuadrant (Leaf va) else CVQuadrant (Node (Leaf va) (Leaf vb) (Leaf vc) (Leaf vd)))) =⟨ sym $ propFnIfc (va == vb && vb == vc && vc == vd) (λ g -> (runIdentity (lensA (λ _ → CIdentity cvx) g ) ) ) ⟩ (ifc va == vb && vb == vc && vc == vd then CVQuadrant (Node x (Leaf va) (Leaf va) (Leaf va)) else CVQuadrant (Node x (Leaf vb) (Leaf vc) (Leaf vd))) =⟨ ifcTrueMap {c = va == vb && vb == vc && vc == vd} (λ p -> cong (λ q -> combine cvx (cvq q) (cvq q) (cvq q)) (eqToEquiv va vb (andFst {va == vb} p))) ⟩ (ifc va == vb && vb == vc && vc == vd then CVQuadrant (Node x (Leaf vb) (Leaf vb) (Leaf vb)) else CVQuadrant (Node x (Leaf vb) (Leaf vc) (Leaf vd))) =⟨ ifcTrueMap {c = va == vb && vb == vc && vc == vd} (λ p -> cong (λ q -> combine cvx cvb (cvq q) (cvq q)) (eqToEquiv vb vc (andFst $ andSnd {va == vb} p))) ⟩ (ifc va == vb && vb == vc && vc == vd then CVQuadrant (Node x (Leaf vb) (Leaf vc) (Leaf vc)) else CVQuadrant (Node x (Leaf vb) (Leaf vc) (Leaf vd))) =⟨ ifcTrueMap {c = va == vb && vb == vc && vc == vd} (λ p -> cong (λ q -> combine cvx cvb cvc (cvq q)) (eqToEquiv vc vd (andSnd $ andSnd {va == vb} p))) ⟩ (ifc va == vb && vb == vc && vc == vd then CVQuadrant (Node x (Leaf vb) (Leaf vc) (Leaf vd)) else CVQuadrant (Node x (Leaf vb) (Leaf vc) (Leaf vd))) =⟨ propIfcBranchesSame {c = va == vb && vb == vc && vc == vd} (CVQuadrant (Node x (Leaf vb) (Leaf vc) (Leaf vd))) ⟩ CVQuadrant (Node x (Leaf vb) (Leaf vc) (Leaf vd)) end where -- Construct a valid leaf from a value cvq : t -> VQuadrant t {dep} cvq q = CVQuadrant (Leaf q) {andCombine (zeroLteAny dep) IsTrue.itsTrue} ValidLens-LensA-SetSet-Lemma (CVQuadrant _) (CVQuadrant (Leaf _)) (CVQuadrant (Leaf _)) (CVQuadrant (Leaf _)) (CVQuadrant (Node _ _ _ _)) = refl ValidLens-LensA-SetSet-Lemma (CVQuadrant _) (CVQuadrant (Leaf _)) (CVQuadrant (Leaf _)) (CVQuadrant (Node _ _ _ _)) (CVQuadrant _) = refl ValidLens-LensA-SetSet-Lemma (CVQuadrant _) (CVQuadrant (Leaf _)) (CVQuadrant (Node _ _ _ _)) (CVQuadrant _) (CVQuadrant _) = refl ValidLens-LensA-SetSet-Lemma (CVQuadrant _) (CVQuadrant (Node _ _ _ _)) (CVQuadrant _) (CVQuadrant _) (CVQuadrant _) = refl ValidLens-LensA-SetSet : {t : Set} {{eqT : Eq t}} {dep : Nat} -> SetSet (lensA {t} {dep}) ValidLens-LensA-SetSet a@(CVQuadrant qda) b@(CVQuadrant qdb) x@(CVQuadrant qdx@(Leaf xv)) = begin set lensA (CVQuadrant qdb) (combine (CVQuadrant qda) (CVQuadrant (Leaf xv)) (CVQuadrant (Leaf xv)) (CVQuadrant (Leaf xv))) =⟨ ValidLens-LensA-SetSet-Lemma (CVQuadrant qdb) (CVQuadrant qda) (CVQuadrant (Leaf xv)) (CVQuadrant (Leaf xv)) (CVQuadrant (Leaf xv)) ⟩ combine (CVQuadrant qdb) (CVQuadrant (Leaf xv)) (CVQuadrant (Leaf xv)) (CVQuadrant (Leaf xv)) end ValidLens-LensA-SetSet (CVQuadrant qda) (CVQuadrant qdb) (CVQuadrant qdx@(Node xa xb xc xd)) = begin set lensA (CVQuadrant qdb) (combine (CVQuadrant qda) (CVQuadrant xb) (CVQuadrant xc) (CVQuadrant xd)) =⟨ ValidLens-LensA-SetSet-Lemma (CVQuadrant qdb) (CVQuadrant qda) (CVQuadrant xb) (CVQuadrant xc) (CVQuadrant xd) ⟩ combine (CVQuadrant qdb) (CVQuadrant xb) (CVQuadrant xc) (CVQuadrant xd) end ValidLens-LensA : {t : Set} {{eqT : Eq t}} {dep : Nat} -> ValidLens (VQuadrant t {S dep}) (VQuadrant t {dep}) ValidLens-LensA = CValidLens lensA (ValidLens-LensA-ViewSet) (ValidLens-LensA-SetView) (ValidLens-LensA-SetSet)
{ "alphanum_fraction": 0.5647152529, "avg_line_length": 61.243902439, "ext": "agda", "hexsha": "0f1c34abd8b6470df86d83731294b6eff5d96172", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "JonathanBrouwer/research-project", "max_forks_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensA.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "JonathanBrouwer/research-project", "max_issues_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensA.agda", "max_line_length": 198, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "JonathanBrouwer/research-project", "max_stars_repo_path": "src/Data/QuadTree/LensProofs/Valid-LensA.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:10:20.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:10:20.000Z", "num_tokens": 4547, "size": 12555 }
{- 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.Concrete.System open import LibraBFT.Concrete.System.Parameters import LibraBFT.Impl.Consensus.BlockStorage.BlockStore as BlockStore import LibraBFT.Impl.Consensus.BlockStorage.Properties.BlockStore as BSprops open import LibraBFT.Impl.Consensus.EpochManager as EpochManager open import LibraBFT.Impl.Consensus.EpochManagerTypes import LibraBFT.Impl.Consensus.MetricsSafetyRules as MetricsSafetyRules open import LibraBFT.Impl.Consensus.Properties.MetricsSafetyRules import LibraBFT.Impl.Consensus.RoundManager as RoundManager open import LibraBFT.Impl.Consensus.RoundManager.Properties import LibraBFT.Impl.Consensus.SafetyRules.SafetyRulesManager as SafetyRulesManager open import LibraBFT.Impl.OBM.Logging.Logging open import LibraBFT.Impl.Properties.Util open import LibraBFT.ImplShared.Base.Types open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Consensus.Types.EpochDep open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.Util.Dijkstra.All open import Optics.All open import Util.Hash open import Util.Lemmas open import Util.PKCS open import Util.Prelude open import Yasm.System ℓ-RoundManager ℓ-VSFP ConcSysParms open InitProofDefs open Invariants open EpochManagerInv open SafetyRulesInv open SafetyDataInv module LibraBFT.Impl.Consensus.EpochManager.Properties where module newSpec (nodeConfig : NodeConfig) (stateComp : StateComputer) (persistentLivenessStorage : PersistentLivenessStorage) (obmAuthor : Author) (obmSK : SK) where -- TODO-2: May require refinement (additional requirements and/or properties) Contract : EitherD-Post ErrLog EpochManager Contract (Left _) = ⊤ Contract (Right em) = ∀ {sr} → em ^∙ emSafetyRulesManager ∙ srmInternalSafetyRules ≡ SRWLocal sr → sr ^∙ srPersistentStorage ∙ pssSafetyData ∙ sdLastVote ≡ nothing postulate contract : Contract (EpochManager.new nodeConfig stateComp persistentLivenessStorage obmAuthor obmSK) module startRoundManager'Spec (self0 : EpochManager) (now : Instant) (recoveryData : RecoveryData) (epochState0 : EpochState) (obmNeedFetch : ObmNeedFetch) (obmProposalGenerator : ProposalGenerator) (obmVersion : Version) where open startRoundManager'-ed self0 now recoveryData epochState0 obmNeedFetch obmProposalGenerator obmVersion lastVote = recoveryData ^∙ rdLastVote proposalGenerator = obmProposalGenerator roundState = createRoundState-abs self0 now proposerElection = createProposerElection epochState0 srUpdate : SafetyRules → SafetyRules srUpdate = _& srPersistentStorage ∙ pssSafetyData ∙ sdEpoch ∙~ epochState0 ^∙ esEpoch initProcessor : SafetyRules → BlockStore → RoundManager initProcessor sr bs = RoundManager∙new obmNeedFetch epochState0 bs roundState proposerElection proposalGenerator (srUpdate sr) (self0 ^∙ emConfig ∙ ccSyncOnly) ecInfo = mkECinfo (epochState0 ^∙ esVerifier) (epochState0 ^∙ esEpoch) SRVoteEpoch≡ : SafetyRules → Epoch → Set SRVoteEpoch≡ sr epoch = ∀ {v} → sr ^∙ srPersistentStorage ∙ pssSafetyData ∙ sdLastVote ≡ just v → v ^∙ vEpoch ≡ epoch SRVoteRound≤ : SafetyRules → Set SRVoteRound≤ sr = let sd = sr ^∙ srPersistentStorage ∙ pssSafetyData in Meta.getLastVoteRound sd ≤ sd ^∙ sdLastVotedRound initRMInv : ∀ {sr bs} → ValidatorVerifier-correct (epochState0 ^∙ esVerifier) → SafetyDataInv (sr ^∙ srPersistentStorage ∙ pssSafetyData) → sr ^∙ srPersistentStorage ∙ pssSafetyData ∙ sdLastVote ≡ nothing → BlockStoreInv (bs , ecInfo) → RoundManagerInv (initProcessor sr bs) initRMInv {sr} vvCorr sdInv refl bsInv = mkRoundManagerInv vvCorr refl bsInv (mkSafetyRulesInv (mkSafetyDataInv refl z≤n)) contract-continue2 : ∀ {sr bs} → ValidatorVerifier-correct (epochState0 ^∙ esVerifier) → SafetyRulesInv sr → sr ^∙ srPersistentStorage ∙ pssSafetyData ∙ sdLastVote ≡ nothing → BlockStoreInv (bs , ecInfo) → EitherD-weakestPre (continue2-abs lastVote bs sr) (InitContract lastVote) contract-continue2 {sr} {bs} vvCorr srInv lvNothing bsInv rewrite continue2-abs-≡ with LBFT-contract (RoundManager.start-abs now lastVote) (Contract initRM initRMCorr) (initProcessor sr bs) (contract' initRM initRMCorr) where open startSpec now lastVote initRM = initProcessor sr bs initRMCorr = initRMInv {sr} {bs} vvCorr (sdInv srInv) lvNothing bsInv ...| inj₁ (_ , er≡j ) rewrite er≡j = tt ...| inj₂ (er≡n , ico) rewrite er≡n = LBFT-post (RoundManager.start-abs now lastVote) (initProcessor sr bs) , refl , ico contract-continue1 : ∀ {bs} → BlockStoreInv (bs , ecInfo) → ValidatorVerifier-correct (epochState0 ^∙ esVerifier) → EpochManagerInv self0 → EitherD-weakestPre (continue1-abs lastVote bs) (InitContract lastVote) contract-continue1 {bs} bsInv vvCorr emi rewrite continue1-abs-≡ with self0 ^∙ emSafetyRulesManager ∙ srmInternalSafetyRules | inspect (self0 ^∙_) (emSafetyRulesManager ∙ srmInternalSafetyRules) ...| SRWLocal safetyRules | [ R ] with emiSRI emi R ...| (sri , lvNothing) with performInitializeSpec.contract safetyRules (self0 ^∙ emStorage) sri lvNothing ...| piProp with MetricsSafetyRules.performInitialize-abs safetyRules (self0 ^∙ emStorage) ...| Left _ = tt ...| Right sr = contract-continue2 vvCorr (performInitializeSpec.ContractOk.srPres piProp sri) (performInitializeSpec.ContractOk.lvNothing piProp) bsInv contract' : ValidatorVerifier-correct (epochState0 ^∙ esVerifier) → EpochManagerInv self0 → EitherD-weakestPre (EpochManager.startRoundManager'-ed-abs self0 now recoveryData epochState0 obmNeedFetch obmProposalGenerator obmVersion) (InitContract lastVote) contract' vvCorr emi rewrite startRoundManager'-ed-abs-≡ with BSprops.new.contract (self0 ^∙ emStorage) recoveryData stateComputer (self0 ^∙ emConfig ∙ ccMaxPrunedBlocksInMem) ...| bsprop with BlockStore.new-e-abs (self0 ^∙ emStorage) recoveryData stateComputer (self0 ^∙ emConfig ∙ ccMaxPrunedBlocksInMem) ...| Left _ = tt ...| Right bs = contract-continue1 bsprop vvCorr emi
{ "alphanum_fraction": 0.6901250176, "avg_line_length": 43.1454545455, "ext": "agda", "hexsha": "86f2c04b17ed98a1d4817b53894342c3ad228765", "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/EpochManager/Properties.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/EpochManager/Properties.agda", "max_line_length": 124, "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/EpochManager/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1922, "size": 7119 }
{- https://lists.chalmers.se/pipermail/agda/2013/006033.html http://code.haskell.org/~Saizan/unification/ 18-Nov-2013 Andrea Vezzosi -} module UnifyProof2 where open import Data.Fin using (Fin; suc; zero) open import Data.Nat hiding (_≤_) open import Relation.Binary.PropositionalEquality open import Function open import Relation.Nullary open import Data.Product renaming (map to _***_) open import Data.Empty open import Data.Maybe using (maybe; nothing; just; monad; Maybe) open import Data.Sum open import Unify open import UnifyProof open Σ₁ open import Data.List renaming (_++_ to _++L_) open ≡-Reasoning open import Category.Functor open import Category.Monad import Level open RawMonad (Data.Maybe.monad {Level.zero}) -- We use a view so that we need to handle fewer cases in the main proof data Amgu : {m : ℕ} -> (s t : Term m) -> ∃ (AList m) -> Maybe (∃ (AList m)) -> Set where Flip : ∀ {m s t acc} -> amgu t s acc ≡ amgu s t acc -> Amgu {m} t s acc (amgu t s acc) -> Amgu s t acc (amgu s t acc) leaf-leaf : ∀ {m acc} -> Amgu {m} leaf leaf acc (just acc) leaf-fork : ∀ {m s t acc} -> Amgu {m} leaf (s fork t) acc nothing fork-fork : ∀ {m s1 s2 t1 t2 acc} -> Amgu {m} (s1 fork s2) (t1 fork t2) acc (amgu s2 t2 =<< amgu s1 t1 acc) var-var : ∀ {m x y} -> Amgu (i x) (i y) (m , anil) (just (flexFlex x y)) var-t : ∀ {m x t} -> i x ≢ t -> Amgu (i x) t (m , anil) (flexRigid x t) s-t : ∀{m s t n σ r z} -> Amgu {suc m} s t (n , σ asnoc r / z) ((λ σ -> σ ∃asnoc r / z) <$> amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ)) view : ∀ {m : ℕ} -> (s t : Term m) -> (acc : ∃ (AList m)) -> Amgu s t acc (amgu s t acc) view leaf leaf acc = leaf-leaf view leaf (s fork t) acc = leaf-fork view (s fork t) leaf acc = Flip refl leaf-fork view (s1 fork s2) (t1 fork t2) acc = fork-fork view (i x) (i y) (m , anil) = var-var view (i x) leaf (m , anil) = var-t (λ ()) view (i x) (s fork t) (m , anil) = var-t (λ ()) view leaf (i x) (m , anil) = Flip refl (var-t (λ ())) view (s fork t) (i x) (m , anil) = Flip refl (var-t (λ ())) view (i x) (i x') (n , σ asnoc r / z) = s-t view (i x) leaf (n , σ asnoc r / z) = s-t view (i x) (s fork t) (n , σ asnoc r / z) = s-t view leaf (i x) (n , σ asnoc r / z) = s-t view (s fork t) (i x) (n , σ asnoc r / z) = s-t amgu-Correctness : {m : ℕ} -> (s t : Term m) -> ∃ (AList m) -> Set amgu-Correctness s t (l , ρ) = (∃ λ n → ∃ λ σ → π₁ (Max (Unifies s t [-◇ sub ρ ])) (sub σ) × amgu s t (l , ρ) ≡ just (n , σ ++ ρ )) ⊎ (Nothing ((Unifies s t) [-◇ sub ρ ]) × amgu s t (l , ρ) ≡ nothing) amgu-Ccomm : ∀ {m} s t acc -> amgu {m} s t acc ≡ amgu t s acc -> amgu-Correctness s t acc -> amgu-Correctness t s acc amgu-Ccomm s t (l , ρ) st≡ts = lemma where Unst = (Unifies s t) [-◇ sub ρ ] Unts = (Unifies t s) [-◇ sub ρ ] Unst⇔Unts : ((Unifies s t) [-◇ sub ρ ]) ⇔ ((Unifies t s) [-◇ sub ρ ]) Unst⇔Unts = Properties.fact5 (Unifies s t) (Unifies t s) (sub ρ) (Properties.fact1 {_} {s} {t}) lemma : amgu-Correctness s t (l , ρ) -> amgu-Correctness t s (l , ρ) lemma (inj₁ (n , σ , MaxUnst , amgu≡just)) = inj₁ (n , σ , proj₁ (Max.fact Unst Unts Unst⇔Unts (sub σ)) MaxUnst , trans (sym st≡ts) amgu≡just) lemma (inj₂ (NoUnst , amgu≡nothing)) = inj₂ ((λ {_} → Properties.fact2 Unst Unts Unst⇔Unts NoUnst) , trans (sym st≡ts) amgu≡nothing) amgu-c : ∀ {m s t l ρ} -> Amgu s t (l , ρ) (amgu s t (l , ρ)) -> (∃ λ n → ∃ λ σ → π₁ (Max ((Unifies s t) [-◇ sub ρ ])) (sub σ) × amgu {m} s t (l , ρ) ≡ just (n , σ ++ ρ )) ⊎ (Nothing ((Unifies s t) [-◇ sub ρ ]) × amgu {m} s t (l , ρ) ≡ nothing) amgu-c {m} {s} {t} {l} {ρ} amg with amgu s t (l , ρ) amgu-c {l = l} {ρ} leaf-leaf | ._ = inj₁ (l , anil , trivial-problem {_} {_} {leaf} {sub ρ} , cong (λ x -> just (l , x)) (sym (SubList.anil-id-l ρ)) ) amgu-c leaf-fork | .nothing = inj₂ ((λ _ () ) , refl) amgu-c {m} {s1 fork s2} {t1 fork t2} {l} {ρ} fork-fork | ._ with amgu s1 t1 (l , ρ) | amgu-c $ view s1 t1 (l , ρ) ... | .nothing | inj₂ (nounify , refl) = inj₂ ((λ {_} -> No[Q◇ρ]→No[P◇ρ] No[Q◇ρ]) , refl) where P = Unifies (s1 fork s2) (t1 fork t2) Q = (Unifies s1 t1 ∧ Unifies s2 t2) Q⇔P : Q ⇔ P Q⇔P = switch P Q (Properties.fact1' {_} {s1} {s2} {t1} {t2}) No[Q◇ρ]→No[P◇ρ] : Nothing (Q [-◇ sub ρ ]) -> Nothing (P [-◇ sub ρ ]) No[Q◇ρ]→No[P◇ρ] = Properties.fact2 (Q [-◇ sub ρ ]) (P [-◇ sub ρ ]) (Properties.fact5 Q P (sub ρ) Q⇔P) No[Q◇ρ] : Nothing (Q [-◇ sub ρ ]) No[Q◇ρ] = failure-propagation.first (sub ρ) (Unifies s1 t1) (Unifies s2 t2) nounify ... | .(just (n , σ ++ ρ)) | inj₁ (n , σ , a , refl) with amgu s2 t2 (n , σ ++ ρ) | amgu-c (view s2 t2 (n , (σ ++ ρ))) ... | .nothing | inj₂ (nounify , refl) = inj₂ ( (λ {_} -> No[Q◇ρ]→No[P◇ρ] No[Q◇ρ]) , refl) where P = Unifies (s1 fork s2) (t1 fork t2) Q = (Unifies s1 t1 ∧ Unifies s2 t2) Q⇔P : Q ⇔ P Q⇔P = switch P Q (Properties.fact1' {_} {s1} {s2} {t1} {t2}) No[Q◇ρ]→No[P◇ρ] : Nothing (Q [-◇ sub ρ ]) -> Nothing (P [-◇ sub ρ ]) No[Q◇ρ]→No[P◇ρ] = Properties.fact2 (Q [-◇ sub ρ ]) (P [-◇ sub ρ ]) (Properties.fact5 Q P (sub ρ) Q⇔P) No[Q◇ρ] : Nothing (Q [-◇ sub ρ ]) No[Q◇ρ] = failure-propagation.second (sub ρ) (sub σ) (Unifies s1 t1) (Unifies s2 t2) a (λ f Unifs2t2-f◇σ◇ρ → nounify f (π₂ (Unifies s2 t2) (λ t → cong (f ◃) (sym (SubList.fact1 σ ρ t))) Unifs2t2-f◇σ◇ρ)) ... | .(just (n1 , σ1 ++ (σ ++ ρ))) | inj₁ (n1 , σ1 , b , refl) = inj₁ (n1 , σ1 ++ σ , Max[P∧Q◇ρ][σ1++σ] , cong (λ σ -> just (n1 , σ)) (++-assoc σ1 σ ρ)) where P = Unifies s1 t1 Q = Unifies s2 t2 P∧Q = P ∧ Q C = Unifies (s1 fork s2) (t1 fork t2) Max[C◇ρ]⇔Max[P∧Q◇ρ] : Max (C [-◇ sub ρ ]) ⇔ Max (P∧Q [-◇ sub ρ ]) Max[C◇ρ]⇔Max[P∧Q◇ρ] = Max.fact (C [-◇ sub ρ ]) (P∧Q [-◇ sub ρ ]) (Properties.fact5 C P∧Q (sub ρ) (Properties.fact1' {_} {s1} {s2} {t1} {t2})) Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] : Max (Q [-◇ sub (σ ++ ρ)]) ⇔ Max (Q [-◇ sub σ ◇ sub ρ ]) Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] = Max.fact (Q [-◇ sub (σ ++ ρ)]) (Q [-◇ sub σ ◇ sub ρ ]) (Properties.fact6 Q (SubList.fact1 σ ρ)) Max[P∧Q◇ρ][σ1++σ] : π₁ (Max (C [-◇ sub ρ ])) (sub (σ1 ++ σ)) Max[P∧Q◇ρ][σ1++σ] = π₂ (Max (C [-◇ sub ρ ])) (≐-sym (SubList.fact1 σ1 σ)) (proj₂ (Max[C◇ρ]⇔Max[P∧Q◇ρ] (sub σ1 ◇ sub σ)) (optimist (sub ρ) (sub σ) (sub σ1) P Q (DClosed.fact1 s1 t1) a (proj₁ (Max[Q◇σ++ρ]⇔Max[Q◇σ◇ρ] (sub σ1)) b))) amgu-c {suc l} {i x} {i y} (var-var) | .(just (flexFlex x y)) with thick x y | Thick.fact1 x y (thick x y) refl ... | .(just y') | inj₂ (y' , thinxy'≡y , refl ) = inj₁ (l , anil asnoc i y' / x , var-elim-i-≡ x (i y) (sym (cong i thinxy'≡y)) , refl ) ... | .nothing | inj₁ ( x≡y , refl ) rewrite sym x≡y = inj₁ (suc l , anil , trivial-problem {_} {_} {i x} {sub anil} , refl) amgu-c {suc l} {i x} {t} (var-t ix≢t) | .(flexRigid x t) with check x t | check-prop x t ... | .nothing | inj₂ ( ps , r , refl) = inj₂ ( (λ {_} -> No-Unifier ) , refl) where No-Unifier : {n : ℕ} (f : Fin (suc l) → Term n) → f x ≡ f ◃ t → ⊥ No-Unifier f fx≡f◃t = ix≢t (sym (trans r (cong (λ ps -> ps ⊹ i x) ps≡[]))) where ps≡[] : ps ≡ [] ps≡[] = map-[] f ps (No-Cycle (f x) ((f ◃S) ps) (begin f x ≡⟨ fx≡f◃t ⟩ f ◃ t ≡⟨ cong (f ◃) r ⟩ f ◃ (ps ⊹ i x) ≡⟨ StepM.fact2 f (i x) ps ⟩ (f ◃S) ps ⊹ f x ∎)) ... | .(just t') | inj₁ (t' , r , refl) = inj₁ ( l , anil asnoc t' / x , var-elim-i-≡ x t r , refl ) amgu-c {suc m} {s} {t} {l} {ρ asnoc r / z} s-t | .((λ x' → x' ∃asnoc r / z) <$> (amgu ((r for z) ◃ s) ((r for z) ◃ t) (l , ρ))) with amgu-c (view ((r for z) ◃ s) ((r for z) ◃ t) (l , ρ)) ... | inj₂ (nounify , ra) = inj₂ ( (λ {_} -> NoQ→NoP nounify) , cong (_<$>_ (λ x' → x' ∃asnoc r / z)) ra ) where P = Unifies s t [-◇ sub (ρ asnoc r / z) ] Q = Unifies ((r for z) ◃ s) ((r for z) ◃ t) [-◇ sub ρ ] NoQ→NoP : Nothing Q → Nothing P NoQ→NoP = Properties.fact2 Q P (switch P Q (step-prop s t ρ r z)) ... | inj₁ (n , σ , a , ra) = inj₁ (n , σ , proj₂ (MaxP⇔MaxQ (sub σ)) a , cong (_<$>_ (λ x' → x' ∃asnoc r / z)) ra) where P = Unifies s t [-◇ sub (ρ asnoc r / z) ] Q = Unifies ((r for z) ◃ s) ((r for z) ◃ t) [-◇ sub ρ ] MaxP⇔MaxQ : Max P ⇔ Max Q MaxP⇔MaxQ = Max.fact P Q (step-prop s t ρ r z) amgu-c {m} {s} {t} {l} {ρ} (Flip amguts≡amgust amguts) | ._ = amgu-Ccomm t s (l , ρ) amguts≡amgust (amgu-c amguts) amgu-c {zero} {i ()} _ | _ mgu-c : ∀ {m} (s t : Term m) -> (∃ λ n → ∃ λ σ → π₁ (Max (Unifies s t)) (sub σ) × mgu s t ≡ just (n , σ)) ⊎ (Nothing (Unifies s t) × mgu s t ≡ nothing) mgu-c {m} s t = amgu-c (view s t (m , anil))
{ "alphanum_fraction": 0.4795907492, "avg_line_length": 55.1941176471, "ext": "agda", "hexsha": "7da811aff365c38bc83dc80288bb780203278b63", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/UnifyProof2.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/UnifyProof2.agda", "max_line_length": 146, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/UnifyProof2.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4048, "size": 9383 }
{-# OPTIONS --without-K #-} module sets.fin.ordering where open import equality.core open import function.isomorphism open import sets.core open import sets.fin.core open import sets.fin.properties import sets.nat.ordering as N _<_ : ∀ {n} → Fin n → Fin n → Set i < j = toℕ i N.< toℕ j infixr 4 _<_ ord-from-ℕ : ∀ {n} {i j : Fin n} → Ordering N._<_ (toℕ i) (toℕ j) → Ordering _<_ i j ord-from-ℕ (lt p) = lt p ord-from-ℕ (eq p) = eq (toℕ-inj p) ord-from-ℕ (gt p) = gt p compare : ∀ {n} → (i j : Fin n) → Ordering _<_ i j compare i j = ord-from-ℕ (N.compare (toℕ i) (toℕ j))
{ "alphanum_fraction": 0.6160267112, "avg_line_length": 24.9583333333, "ext": "agda", "hexsha": "ef23abb101720050c395af64ea8bd4cda2e668f6", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/sets/fin/ordering.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/sets/fin/ordering.agda", "max_line_length": 52, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/sets/fin/ordering.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 223, "size": 599 }
module ComplexIMPORT where {-# IMPORT Prelude as P #-}
{ "alphanum_fraction": 0.7142857143, "avg_line_length": 14, "ext": "agda", "hexsha": "7b61f636d809f391c730f228e25e18a1d5231bb0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Fail/ComplexIMPORT.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Fail/ComplexIMPORT.agda", "max_line_length": 27, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Fail/ComplexIMPORT.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 11, "size": 56 }
module AmbiguousModule where module A where module B where module A where open B open A
{ "alphanum_fraction": 0.7741935484, "avg_line_length": 9.3, "ext": "agda", "hexsha": "145993a70aaf357d8ef92333493fa50a5a247178", "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/AmbiguousModule.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/AmbiguousModule.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/Fail/AmbiguousModule.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": 25, "size": 93 }
{-# OPTIONS --cubical --no-import-sorts --safe --guardedness #-} module Cubical.Codata.Stream.Base where open import Cubical.Core.Everything record Stream (A : Type₀) : Type₀ where coinductive constructor _,_ field head : A tail : Stream A
{ "alphanum_fraction": 0.703125, "avg_line_length": 21.3333333333, "ext": "agda", "hexsha": "ade3ad434d519e000814290ccd08b29df607e7b4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Codata/Stream/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Codata/Stream/Base.agda", "max_line_length": 64, "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/Codata/Stream/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 71, "size": 256 }
module Pragmas where -- Check that Haskell code is parsed with the correct language pragmas {-# FOREIGN AGDA2HS {-# LANGUAGE TupleSections #-} {-# LANGUAGE LambdaCase #-} #-} {-# FOREIGN AGDA2HS foo :: Bool -> a -> (a, Int) foo = \ case False -> (, 0) True -> (, 1) #-}
{ "alphanum_fraction": 0.618705036, "avg_line_length": 17.375, "ext": "agda", "hexsha": "5e6bd7cecc022cd241762354fa152b1dc17fa54c", "lang": "Agda", "max_forks_count": 18, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_path": "test/Pragmas.agda", "max_issues_count": 63, "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_path": "test/Pragmas.agda", "max_line_length": 70, "max_stars_count": 55, "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_path": "test/Pragmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "num_tokens": 84, "size": 278 }
postulate F : Set → Set G : Set G = {!F ?!} -- KEEP COMMENTS AT THE END to not mess with the ranges in Issue2174.sh -- Andreas, 2016-09-10, issue #2174 reported by Nisse -- First infer, then give should goalify the questionmark
{ "alphanum_fraction": 0.6923076923, "avg_line_length": 19.5, "ext": "agda", "hexsha": "07830cd08dd434ef4e4d77399100bb0fb5312202", "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/Issue2174.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/Issue2174.agda", "max_line_length": 71, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2174.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": 72, "size": 234 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Group.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function using (id; flip) open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.HLevels open import Cubical.Functions.Embedding open import Cubical.Data.Nat hiding (_+_; _*_) open import Cubical.Data.NatPlusOne using (ℕ₊₁→ℕ) open import Cubical.Data.Int open import Cubical.Data.Sigma hiding (_×_) open import Cubical.Data.Prod open import Cubical.Algebra open import Cubical.Algebra.Properties open import Cubical.Algebra.Group.Morphism open import Cubical.Algebra.Monoid.Properties using (isPropIsMonoid; module MonoidLemmas) open import Cubical.Relation.Unary as Unary hiding (isPropValued) open import Cubical.Relation.Binary as Binary hiding (isPropValued) open import Cubical.HITs.PropositionalTruncation open import Cubical.Relation.Binary.Reasoning.Equality open import Cubical.Algebra.Group.MorphismProperties public using (GroupPath; uaGroup; carac-uaGroup; Group≡; caracGroup≡) private variable ℓ ℓ′ : Level isPropIsGroup : ∀ {G : Type ℓ} {_•_ ε _⁻¹} → isProp (IsGroup G _•_ ε _⁻¹) isPropIsGroup {G = G} {_•_} {ε} {_⁻¹} (isgroup aMon aInv) (isgroup bMon bInv) = cong₂ isgroup (isPropIsMonoid aMon bMon) (isPropInverse (IsMonoid.is-set aMon) _•_ _⁻¹ ε aInv bInv) module GroupLemmas (G : Group ℓ) where open Group G open MonoidLemmas monoid public using (ε-comm) renaming (_^′_ to _^′′_; ^semi≡^ to ^semi≡^mon) invInvo : Involutive _⁻¹ invInvo a = cancelʳ (a ⁻¹) (inverseˡ (a ⁻¹) ∙ sym (inverseʳ a)) invId : ε ⁻¹ ≡ ε invId = cancelʳ ε (inverseˡ ε ∙ sym (identityʳ ε)) invDistr : Homomorphic₂ _⁻¹ _•_ (flip _•_) invDistr x y = sym (inv-uniqueˡ _ _ ( (x • y) • (y ⁻¹ • x ⁻¹) ≡˘⟨ assoc (x • y) (y ⁻¹) (x ⁻¹) ⟩ x • y / y / x ≡⟨ cong (_/ x) (assoc _ _ _ ∙ cong (x •_) (inverseʳ y)) ⟩ x • ε / x ≡⟨ cong (_/ x) (identityʳ x) ∙ inverseʳ x ⟩ ε ∎)) inv-comm : ∀ x → x • x ⁻¹ ≡ x ⁻¹ • x inv-comm x = inverseʳ x ∙ sym (inverseˡ x) isEquiv-•ˡ : ∀ x → isEquiv (x •_) isEquiv-•ˡ x = isoToIsEquiv (iso _ (x ⁻¹ •_) section-• retract-•) where section-• : section (x •_) (x ⁻¹ •_) section-• y = x • (x ⁻¹ • y) ≡˘⟨ assoc x (x ⁻¹) y ⟩ x • x ⁻¹ • y ≡⟨ cong (_• y) (inverseʳ x) ⟩ ε • y ≡⟨ identityˡ y ⟩ y ∎ retract-• : retract (x •_) (x ⁻¹ •_) retract-• y = x ⁻¹ • (x • y) ≡˘⟨ assoc (x ⁻¹) x y ⟩ x ⁻¹ • x • y ≡⟨ cong (_• y) (inverseˡ x) ⟩ ε • y ≡⟨ identityˡ y ⟩ y ∎ isEquiv-•ʳ : ∀ x → isEquiv (_• x) isEquiv-•ʳ x = isoToIsEquiv (iso _ (_• x ⁻¹) section-• retract-•) where section-• : section (_• x) (_• x ⁻¹) section-• y = y • x ⁻¹ • x ≡⟨ assoc y (x ⁻¹) x ⟩ y • (x ⁻¹ • x) ≡⟨ cong (y •_) (inverseˡ x) ⟩ y • ε ≡⟨ identityʳ y ⟩ y ∎ retract-• : retract (_• x) (_• x ⁻¹) retract-• y = y • x • x ⁻¹ ≡⟨ assoc y x (x ⁻¹) ⟩ y • (x • x ⁻¹) ≡⟨ cong (y •_) (inverseʳ x) ⟩ y • ε ≡⟨ identityʳ y ⟩ y ∎ inv-≡ʳ : ∀ {x y} → x • y ⁻¹ ≡ ε → x ≡ y inv-≡ʳ p = inv-uniqueʳ _ _ p ∙ invInvo _ inv-≡ˡ : ∀ {x y} → x ⁻¹ • y ≡ ε → x ≡ y inv-≡ˡ p = sym (invInvo _) ∙ sym (inv-uniqueˡ _ _ p) ≡-invʳ : ∀ {x y} → x ≡ y → x • y ⁻¹ ≡ ε ≡-invʳ p = subst (λ y → _ • y ⁻¹ ≡ ε) p (inverseʳ _) ≡-invˡ : ∀ {x y} → x ≡ y → x ⁻¹ • y ≡ ε ≡-invˡ p = subst (λ y → _ • y ≡ ε) p (inverseˡ _) ^-sucˡ : ∀ x n → x ^ sucInt n ≡ x • x ^ n ^-sucˡ x (pos n) = refl ^-sucˡ x (negsuc zero) = sym (inverseʳ x) ^-sucˡ x (negsuc (suc zero)) = x ^ -1 ≡⟨⟩ x ⁻¹ ≡˘⟨ identityˡ _ ⟩ ε • x ⁻¹ ≡˘⟨ cong (_• x ⁻¹) (inverseʳ x) ⟩ x • x ⁻¹ • x ⁻¹ ≡⟨ assoc _ _ _ ⟩ x • (x ^ -2) ∎ ^-sucˡ x (negsuc (suc (suc n))) = x ^ sucInt (negsuc (suc (suc n))) ≡⟨⟩ x ^ negsuc (suc n) ≡⟨⟩ x ⁻¹ • x ^ negsuc n ≡⟨⟩ x ⁻¹ • x ^ sucInt (negsuc (suc n)) ≡⟨ cong (x ⁻¹ •_) (^-sucˡ x (negsuc (suc n))) ⟩ x ⁻¹ • (x • x ^ negsuc (suc n)) ≡˘⟨ assoc _ _ _ ⟩ x ⁻¹ • x • x ^ negsuc (suc n) ≡˘⟨ cong (_• x ^ negsuc (suc n)) (inv-comm x) ⟩ x • x ⁻¹ • x ^ negsuc (suc n) ≡⟨ assoc _ _ _ ⟩ x • (x ⁻¹ • x ^ negsuc (suc n)) ≡⟨⟩ x • x ^ negsuc (suc (suc n)) ∎ ^-sucʳ : ∀ x n → x ^ sucInt n ≡ x ^ n • x ^-sucʳ x (pos zero) = ε-comm x ^-sucʳ x (pos (suc n)) = x ^ pos (suc (suc n)) ≡⟨⟩ x • x ^ pos (suc n) ≡⟨ cong (x •_) (^-sucʳ x (pos n)) ⟩ x • (x ^ pos n • x) ≡˘⟨ assoc _ _ _ ⟩ x • x ^ pos n • x ≡⟨⟩ x ^ pos (suc n) • x ∎ ^-sucʳ x (negsuc zero) = sym (inverseˡ x) ^-sucʳ x (negsuc (suc zero)) = x ⁻¹ ≡˘⟨ identityʳ _ ⟩ x ⁻¹ • ε ≡˘⟨ cong (x ⁻¹ •_) (inverseˡ x) ⟩ x ⁻¹ • (x ⁻¹ • x) ≡˘⟨ assoc _ _ _ ⟩ x ^ -2 • x ∎ ^-sucʳ x (negsuc (suc (suc n))) = x ^ sucInt (negsuc (suc (suc n))) ≡⟨⟩ x ^ negsuc (suc n) ≡⟨⟩ x ⁻¹ • x ^ negsuc n ≡⟨⟩ x ⁻¹ • x ^ sucInt (negsuc (suc n)) ≡⟨ cong (x ⁻¹ •_) (^-sucʳ x (negsuc (suc n))) ⟩ x ⁻¹ • (x ^ negsuc (suc n) • x) ≡˘⟨ assoc _ _ _ ⟩ x ⁻¹ • x ^ negsuc (suc n) • x ≡⟨⟩ x ^ negsuc (suc (suc n)) • x ∎ ^-predˡ : ∀ x n → x ^ predInt n ≡ x ⁻¹ • x ^ n ^-predˡ x (pos zero) = sym (identityʳ _) ^-predˡ x (pos (suc zero)) = ε ≡˘⟨ inverseˡ x ⟩ x ⁻¹ • x ≡˘⟨ cong (x ⁻¹ •_) (identityʳ x) ⟩ x ⁻¹ • (x • ε) ∎ ^-predˡ x (pos (suc (suc n))) = x ^ predInt (pos (suc (suc n))) ≡⟨⟩ x ^ pos (suc n) ≡⟨⟩ x • x ^ pos n ≡⟨⟩ x • x ^ predInt (pos (suc n)) ≡⟨ cong (x •_) (^-predˡ x (pos (suc n))) ⟩ x • (x ⁻¹ • x ^ pos (suc n)) ≡˘⟨ assoc _ _ _ ⟩ x • x ⁻¹ • x ^ pos (suc n) ≡⟨ cong (_• x ^ pos (suc n)) (inv-comm x) ⟩ x ⁻¹ • x • x ^ pos (suc n) ≡⟨ assoc _ _ _ ⟩ x ⁻¹ • (x • x ^ pos (suc n)) ≡⟨⟩ x ⁻¹ • x ^ pos (suc (suc n)) ∎ ^-predˡ x (negsuc n) = refl ^-predʳ : ∀ x n → x ^ predInt n ≡ x ^ n • x ⁻¹ ^-predʳ x (pos zero) = sym (identityˡ _) ^-predʳ x (pos (suc zero)) = ε ≡˘⟨ identityʳ _ ⟩ ε • ε ≡˘⟨ cong (ε •_) (inverseʳ _) ⟩ ε • (x • x ⁻¹) ≡˘⟨ assoc _ _ _ ⟩ ε • x • x ⁻¹ ≡˘⟨ cong (_• x ⁻¹) (ε-comm _) ⟩ x • ε • x ⁻¹ ∎ ^-predʳ x (pos (suc (suc n))) = x ^ predInt (pos (suc (suc n))) ≡⟨⟩ x ^ pos (suc n) ≡⟨⟩ x • x ^ pos n ≡⟨⟩ x • x ^ predInt (pos (suc n)) ≡⟨ cong (x •_) (^-predʳ x (pos (suc n))) ⟩ x • (x ^ pos (suc n) • x ⁻¹) ≡˘⟨ assoc _ _ _ ⟩ x • x ^ pos (suc n) • x ⁻¹ ≡⟨⟩ x ^ pos (suc (suc n)) • x ⁻¹ ∎ ^-predʳ x (negsuc zero) = refl ^-predʳ x (negsuc (suc n)) = x ^ predInt (negsuc (suc n)) ≡⟨⟩ x ^ negsuc (suc (suc n)) ≡⟨⟩ x ⁻¹ • x ^ negsuc (suc n) ≡⟨⟩ x ⁻¹ • x ^ predInt (negsuc n) ≡⟨ cong (x ⁻¹ •_) (^-predʳ x (negsuc n)) ⟩ x ⁻¹ • (x ^ negsuc n • x ⁻¹) ≡˘⟨ assoc _ _ _ ⟩ x ⁻¹ • x ^ negsuc n • x ⁻¹ ≡⟨⟩ x ^ negsuc (suc n) • x ⁻¹ ∎ ^-plus : ∀ x → Homomorphic₂ (x ^_) _+_ _•_ ^-plus x m (pos zero) = sym (identityʳ (x ^ m)) ^-plus x m (pos (suc n)) = x ^ sucInt (m +pos n) ≡⟨ ^-sucʳ x (m +pos n) ⟩ x ^ (m +pos n) • x ≡⟨ cong (_• x) (^-plus x m (pos n)) ⟩ x ^ m • x ^ pos n • x ≡⟨ assoc _ _ _ ⟩ x ^ m • (x ^ pos n • x) ≡˘⟨ cong (x ^ m •_) (^-sucʳ x (pos n)) ⟩ x ^ m • x ^ pos (suc n) ∎ ^-plus x m (negsuc zero) = ^-predʳ x m ^-plus x m (negsuc (suc n)) = x ^ predInt (m +negsuc n) ≡⟨ ^-predʳ x (m +negsuc n) ⟩ x ^ (m +negsuc n) • x ⁻¹ ≡⟨ cong (_• x ⁻¹) (^-plus x m (negsuc n)) ⟩ x ^ m • x ^ negsuc n • x ⁻¹ ≡⟨ assoc _ _ _ ⟩ x ^ m • (x ^ negsuc n • x ⁻¹) ≡˘⟨ cong (x ^ m •_) (^-predʳ x (negsuc n)) ⟩ x ^ m • x ^ negsuc (suc n) ∎ _^′_ : ⟨ G ⟩ → ℕ → ⟨ G ⟩ _^′_ = IsMonoid._^_ isMonoid ^mon≡^ : ∀ x n → x ^′ n ≡ x ^ pos n ^mon≡^ x zero = refl ^mon≡^ x (suc n) = cong (x •_) (^mon≡^ x n) ^semi≡^ : ∀ x n → x ^′′ n ≡ x ^ pos (ℕ₊₁→ℕ n) ^semi≡^ x n = ^semi≡^mon x n ∙ ^mon≡^ x (ℕ₊₁→ℕ n) module Conjugation (G : Group ℓ) where open Group G open GroupLemmas G using (isEquiv-•ˡ; isEquiv-•ʳ) module _ (g : ⟨ G ⟩) where conjugate : ⟨ G ⟩ → ⟨ G ⟩ conjugate x = g • x • g ⁻¹ conjugate-isEquiv : isEquiv conjugate conjugate-isEquiv = compIsEquiv (isEquiv-•ˡ g) (isEquiv-•ʳ (g ⁻¹)) conjugate-hom : Homomorphic₂ conjugate _•_ _•_ conjugate-hom x y = g • (x • y) • g ⁻¹ ≡˘⟨ cong (λ v → g • (v • y) • g ⁻¹) (identityʳ x) ⟩ g • (x • ε • y) • g ⁻¹ ≡˘⟨ cong (λ v → g • (x • v • y) • g ⁻¹) (inverseˡ g) ⟩ g • (x • (g ⁻¹ • g) • y) • g ⁻¹ ≡˘⟨ cong (λ v → g • (v • y) • g ⁻¹) (assoc _ _ _) ⟩ g • (x • g ⁻¹ • g • y) • g ⁻¹ ≡˘⟨ cong (_• g ⁻¹) (assoc _ _ _) ⟩ g • (x • g ⁻¹ • g) • y • g ⁻¹ ≡˘⟨ cong (λ v → v • y • g ⁻¹) (assoc _ _ _) ⟩ g • (x • g ⁻¹) • g • y • g ⁻¹ ≡˘⟨ cong (λ v → v • g • y • g ⁻¹) (assoc _ _ _) ⟩ g • x • g ⁻¹ • g • y • g ⁻¹ ≡⟨ cong (_• g ⁻¹) (assoc _ _ _) ⟩ g • x • g ⁻¹ • (g • y) • g ⁻¹ ≡⟨ assoc _ _ _ ⟩ g • x • g ⁻¹ • (g • y • g ⁻¹) ∎ conjugate-isHom : IsGroupHom G G conjugate conjugate-isHom = isgrouphom conjugate-hom conjugate-Hom : GroupHom G G conjugate-Hom = record { isHom = conjugate-isHom } conjugate-Equiv : GroupEquiv G G conjugate-Equiv = record { eq = conjugate , conjugate-isEquiv; isHom = conjugate-isHom } conjugate-Path : G ≡ G conjugate-Path = uaGroup conjugate-Equiv Conjugate : Rel ⟨ G ⟩ ℓ Conjugate a b = (∃[ g ∈ ⟨ G ⟩ ] conjugate g a ≡ b) , squash module Kernel {G : Group ℓ} {H : Group ℓ′} (hom : GroupHom G H) where private module G = Group G module H = Group H open GroupHom hom renaming (fun to f) open GroupLemmas Kernel′ : RawPred ⟨ G ⟩ ℓ′ Kernel′ x = f x ≡ H.ε isPropKernel : Unary.isPropValued Kernel′ isPropKernel x = H.is-set (f x) H.ε Kernel : Pred ⟨ G ⟩ ℓ′ Kernel = Unary.fromRaw Kernel′ isPropKernel ker-preservesId : G.ε ∈ Kernel ker-preservesId = preservesId ker-preservesOp : G._•_ Unary.Preserves₂ Kernel ker-preservesOp {x} {y} fx≡ε fy≡ε = f (x G.• y) ≡⟨ preservesOp x y ⟩ f x H.• f y ≡⟨ cong₂ H._•_ fx≡ε fy≡ε ⟩ H.ε H.• H.ε ≡⟨ H.identityʳ H.ε ⟩ H.ε ∎ ker-preservesInv : G._⁻¹ Unary.Preserves Kernel ker-preservesInv {x} fx≡ε = f (x G.⁻¹) ≡⟨ preservesInv _ ⟩ f x H.⁻¹ ≡⟨ cong H._⁻¹ fx≡ε ⟩ H.ε H.⁻¹ ≡⟨ invId H ⟩ H.ε ∎ ker⊆ε→inj : Kernel ⊆ { G.ε } → ∀ {x y} → f x ≡ f y → x ≡ y ker⊆ε→inj sub fx≡fy = inv-≡ʳ G (rec (G.is-set _ _) id (sub (preservesOp+Inv _ _ ∙ ≡-invʳ H fx≡fy))) where preservesOp+Inv : ∀ a b → f (a G.• b G.⁻¹) ≡ f a H.• f b H.⁻¹ preservesOp+Inv a b = preservesOp a (b G.⁻¹) ∙ cong (f a H.•_) (preservesInv b) ker⊆ε→emb : Kernel ⊆ { G.ε } → isEmbedding f ker⊆ε→emb sub = injEmbedding G.is-set H.is-set (ker⊆ε→inj sub) inj→ker⊆ε : (∀ {x y} → f x ≡ f y → x ≡ y) → Kernel ⊆ { G.ε } inj→ker⊆ε inj fx≡ε = ∣ inj (fx≡ε ∙ sym preservesId) ∣ emb→ker⊆ε : isEmbedding f → Kernel ⊆ { G.ε } emb→ker⊆ε emb = inj→ker⊆ε (invIsEq (emb _ _))
{ "alphanum_fraction": 0.484154623, "avg_line_length": 36.1194968553, "ext": "agda", "hexsha": "6bf5ffb2987adbc860f01b462ca52136fe79dc95", "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/Group/Properties.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/Group/Properties.agda", "max_line_length": 101, "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/Group/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5464, "size": 11486 }
------------------------------------------------------------------------ -- The syntax of the untyped λ-calculus ------------------------------------------------------------------------ {-# OPTIONS --safe #-} module Lambda.Simplified.Syntax where open import Equality.Propositional open import Prelude open import Vec.Function equality-with-J ------------------------------------------------------------------------ -- Terms -- Variables are represented using de Bruijn indices. infixl 9 _·_ data Tm (n : ℕ) : Type where var : (x : Fin n) → Tm n ƛ : Tm (suc n) → Tm n _·_ : Tm n → Tm n → Tm n ------------------------------------------------------------------------ -- Closure-based definition of values -- Environments and values. Defined in a module parametrised by the -- type of terms. module Closure (Tm : ℕ → Type) where mutual -- Environments. Env : ℕ → Type Env n = Vec Value n -- Values. Lambdas are represented using closures, so values do -- not contain any free variables. data Value : Type where ƛ : ∀ {n} (t : Tm (suc n)) (ρ : Env n) → Value ------------------------------------------------------------------------ -- Examples -- A non-terminating term. ω : Tm 0 ω = ƛ (var fzero · var fzero) Ω : Tm 0 Ω = ω · ω -- A call-by-value fixpoint combinator. Z : Tm 0 Z = ƛ (t · t) where t = ƛ (var (fsuc fzero) · ƛ (var (fsuc fzero) · var (fsuc fzero) · var fzero))
{ "alphanum_fraction": 0.4692891649, "avg_line_length": 22.2923076923, "ext": "agda", "hexsha": "cd4123aa955e7d3e5a7f81f68c7b3e4dc1c8ecae", "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/Lambda/Simplified/Syntax.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/Lambda/Simplified/Syntax.agda", "max_line_length": 72, "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/Lambda/Simplified/Syntax.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": 377, "size": 1449 }
open import Formalization.PredicateLogic.Signature module Formalization.PredicateLogic.Classical.Semantics.Homomorphism (𝔏 : Signature) where open Signature(𝔏) import Lvl open import Data open import Data.Boolean open import Data.Boolean.Stmt open import Data.ListSized open import Data.ListSized.Functions open import Formalization.PredicateLogic.Classical.Semantics(𝔏) open import Formalization.PredicateLogic.Syntax(𝔏) open import Functional using (_∘_ ; _∘₂_ ; _←_) open import Logic.Propositional as Logic using (_↔_) import Logic.Predicate as Logic open import Numeral.Finite open import Numeral.Finite.Bound open import Numeral.Natural open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Sets.PredicateSet using (PredSet) open Sets.PredicateSet.BoundedQuantifiers open import Structure.Function.Domain open import Syntax.Function open import Type.Dependent renaming (intro to _,_) open import Type.Properties.Decidable open import Type private variable ℓ ℓₘ ℓₘ₁ ℓₘ₂ ℓₑ : Lvl.Level private variable P : Type{ℓₚ} private variable args n vars : ℕ private variable 𝔐 : Model private variable A B C S : Model{ℓₘ} private variable fi : Obj n private variable ri : Prop n private variable xs : List(dom(S))(n) record Homomorphism (A : Model{ℓₘ₁}) (B : Model{ℓₘ₂}) (f : dom(A) → dom(B)) : Type{ℓₚ Lvl.⊔ ℓₒ Lvl.⊔ Lvl.of(Type.of A) Lvl.⊔ Lvl.of(Type.of B)} where field preserve-functions : ∀{xs} → (f(fn(A) fi xs) ≡ fn(B) fi (map f xs)) preserve-relations : ∀{xs} → IsTrue(rel(A) ri xs) → IsTrue(rel(B) ri (map f xs)) _→ₛₜᵣᵤ_ : Model{ℓₘ₁} → Model{ℓₘ₂} → Type A →ₛₜᵣᵤ B = Logic.∃(Homomorphism A B) record Embedding (A : Model{ℓₘ₁}) (B : Model{ℓₘ₂}) (f : dom(A) → dom(B)) : Type{ℓₚ Lvl.⊔ ℓₒ Lvl.⊔ Lvl.of(Type.of A) Lvl.⊔ Lvl.of(Type.of B)} where constructor intro field ⦃ homomorphism ⦄ : Homomorphism(A)(B)(f) ⦃ injection ⦄ : Injective(f) preserve-relations-converse : ∀{xs} → IsTrue(rel(A) ri xs) ← IsTrue(rel(B) ri (map f xs)) open import Data open import Data.Boolean.Stmt open import Data.ListSized.Proofs open import Functional open import Function.Equals open import Function.Proofs open import Lang.Instance open import Logic.Predicate open import Structure.Function open import Structure.Operator open import Structure.Relator.Properties open import Structure.Relator open import Syntax.Transitivity idₛₜᵣᵤ : A →ₛₜᵣᵤ A ∃.witness idₛₜᵣᵤ = id Homomorphism.preserve-functions (∃.proof (idₛₜᵣᵤ {A = A})) {n} {fi} {xs} = congruence₁(fn A fi) (symmetry(_≡_) (_⊜_.proof map-id)) Homomorphism.preserve-relations (∃.proof (idₛₜᵣᵤ {A = A})) {n} {ri} {xs} = substitute₁ₗ(IsTrue ∘ rel A ri) (_⊜_.proof map-id) _∘ₛₜᵣᵤ_ : let _ = A ; _ = B ; _ = C in (B →ₛₜᵣᵤ C) → (A →ₛₜᵣᵤ B) → (A →ₛₜᵣᵤ C) ∃.witness (([∃]-intro f) ∘ₛₜᵣᵤ ([∃]-intro g)) = f ∘ g Homomorphism.preserve-functions (∃.proof (_∘ₛₜᵣᵤ_ {A = A} {B = B} {C = C} ([∃]-intro f ⦃ hom-f ⦄) ([∃]-intro g ⦃ hom-g ⦄))) {fi = fi} {xs} = congruence₁(f) (Homomorphism.preserve-functions hom-g) 🝖 Homomorphism.preserve-functions hom-f 🝖 congruence₁(fn C fi) (symmetry(_≡_) (_⊜_.proof (map-[∘] {f = f}{g = g}) {xs})) Homomorphism.preserve-relations (∃.proof (_∘ₛₜᵣᵤ_ {A = A} {B = B} {C = C} ([∃]-intro f ⦃ hom-f ⦄) ([∃]-intro g ⦃ hom-g ⦄))) {ri = ri} {xs} = substitute₁ₗ(IsTrue ∘ rel C ri) (_⊜_.proof map-[∘] {xs}) ∘ Homomorphism.preserve-relations hom-f ∘ Homomorphism.preserve-relations hom-g import Data.Tuple as Tuple open import Function.Equals open import Function.Equals.Proofs open import Function.Inverse open import Lang.Inspect open import Logic.Predicate.Equiv open import Structure.Category open import Structure.Categorical.Properties open import Structure.Function.Domain.Proofs instance map-function : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → Function ⦃ [⊜]-equiv ⦄ ⦃ [⊜]-equiv ⦄ (map{A = A}{B = B}{n = n}) map-function {A = A}{B = B} = intro proof where proof : ∀{f g : A → B} → (f ⊜ g) → (map{n = n} f ⊜ map g) _⊜_.proof (proof p) {∅} = reflexivity(_≡_) _⊜_.proof (proof p) {x ⊰ l} = congruence₂(_⊰_) (_⊜_.proof p) (_⊜_.proof (proof p) {l}) instance Structure-Homomorphism-category : Category(_→ₛₜᵣᵤ_ {ℓₘ}) Category._∘_ Structure-Homomorphism-category = _∘ₛₜᵣᵤ_ Category.id Structure-Homomorphism-category = idₛₜᵣᵤ BinaryOperator.congruence (Category.binaryOperator Structure-Homomorphism-category) = [⊜][∘]-binaryOperator-raw _⊜_.proof (Morphism.Associativity.proof (Category.associativity Structure-Homomorphism-category) {_} {_} {_} {_} {[∃]-intro f} {[∃]-intro g} {[∃]-intro h}) {x} = reflexivity(_≡_) {f(g(h(x)))} _⊜_.proof (Morphism.Identityₗ.proof (Tuple.left (Category.identity Structure-Homomorphism-category)) {f = [∃]-intro f}) {x} = reflexivity(_≡_) {f(x)} _⊜_.proof (Morphism.Identityᵣ.proof (Tuple.right (Category.identity Structure-Homomorphism-category)) {f = [∃]-intro f}) {x} = reflexivity(_≡_) {f(x)} module _ {F@([∃]-intro f) : _→ₛₜᵣᵤ_ {ℓₘ}{ℓₘ} A B} where isomorphism-surjective-embedding : Morphism.Isomorphism ⦃ [≡∃]-equiv ⦃ [⊜]-equiv ⦄ ⦄ (\{A} → _∘ₛₜᵣᵤ_ {A = A})(idₛₜᵣᵤ)(F) ↔ (Surjective(f) Logic.∧ Embedding(A)(B)(f)) Tuple.left isomorphism-surjective-embedding (Logic.[∧]-intro surj embed) = [∃]-intro ([∃]-intro _ ⦃ hom ⦄) ⦃ Logic.[∧]-intro inverₗ inverᵣ ⦄ where f⁻¹ = invᵣ-surjective f ⦃ surj ⦄ instance inver : Inverse(f)(f⁻¹) inver = Logic.[∧]-elimᵣ ([∃]-proof (bijective-to-invertible ⦃ bij = injective-surjective-to-bijective(f) ⦃ Embedding.injection embed ⦄ ⦃ surj ⦄ ⦄)) instance hom : Homomorphism(B)(A)(f⁻¹) Homomorphism.preserve-functions hom {fi = fi} {xs = xs} = f⁻¹(fn B fi xs) 🝖[ _≡_ ]-[ congruence₁(f⁻¹) (congruence₁(fn B fi) (_⊜_.proof map-id)) ]-sym f⁻¹(fn B fi (map id xs)) 🝖[ _≡_ ]-[ congruence₁(f⁻¹) (congruence₁(fn B fi) (_⊜_.proof (congruence₁(map) (intro (Inverseᵣ.proof(Logic.[∧]-elimᵣ inver)))) {xs})) ]-sym f⁻¹(fn B fi (map (f ∘ f⁻¹) xs)) 🝖[ _≡_ ]-[ congruence₁(f⁻¹) (congruence₁(fn B fi) (_⊜_.proof map-[∘] {xs})) ] f⁻¹(fn B fi (map f (map f⁻¹ xs))) 🝖[ _≡_ ]-[ congruence₁(f⁻¹) (Homomorphism.preserve-functions (Embedding.homomorphism embed)) ]-sym f⁻¹(f(fn A fi (map f⁻¹ xs))) 🝖[ _≡_ ]-[ Inverseₗ.proof(Logic.[∧]-elimₗ inver) ] fn A fi (map f⁻¹ xs) 🝖-end Homomorphism.preserve-relations hom {ri = ri} {xs = xs} p = Embedding.preserve-relations-converse embed {xs = map f⁻¹ xs} (substitute₁(IsTrue ∘ rel B ri) (_⊜_.proof proof {xs}) p) where proof = id 🝖[ _⊜_ ]-[ map-id ]-sym map id 🝖[ _⊜_ ]-[ congruence₁(map) (intro (Inverseᵣ.proof(Logic.[∧]-elimᵣ inver))) ]-sym map(f ∘ f⁻¹) 🝖[ _⊜_ ]-[ map-[∘] ] (map f ∘ map f⁻¹) 🝖-end inverₗ : Morphism.Inverseₗ _ _ F ([∃]-intro f⁻¹) Morphism.Inverseₗ.proof inverₗ = intro(Inverseₗ.proof(Logic.[∧]-elimₗ inver)) inverᵣ : Morphism.Inverseᵣ _ _ F ([∃]-intro f⁻¹) Morphism.Inverseᵣ.proof inverᵣ = intro(Inverseᵣ.proof(Logic.[∧]-elimᵣ inver)) Tuple.right isomorphism-surjective-embedding iso = Logic.[∧]-intro infer (intro (\{n}{ri}{xs} → {!proof!})) where instance bij : Bijective(f) instance inj : Injective(f) inj = bijective-to-injective(f) instance surj : Surjective(f) surj = bijective-to-surjective(f) proof : IsTrue(rel A ri xs) ← IsTrue(rel B ri (map f(xs))) proof p relation x = {!!} proof2 : let _ = (rel A ri xs) in Surjective(f) proof2 = {!!} -- (intro (proof {!!} {!!}))
{ "alphanum_fraction": 0.6537597463, "avg_line_length": 48.8193548387, "ext": "agda", "hexsha": "eebe4b823c736662765ac666d152c33aef4620d7", "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": "Formalization/PredicateLogic/Classical/Semantics/Homomorphism.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": "Formalization/PredicateLogic/Classical/Semantics/Homomorphism.agda", "max_line_length": 193, "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": "Formalization/PredicateLogic/Classical/Semantics/Homomorphism.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": 2977, "size": 7567 }
-- A module which re-exports Type.Category.ExtensionalFunctionsCategory as the default category for types, and defines some shorthand names for categorical stuff. module Type.Category where open import Functional open import Function.Equals open import Logic.Predicate open import Relator.Equals.Proofs.Equiv import Structure.Category.Functor as Category import Structure.Category.Monad.ExtensionSystem as Category import Structure.Category.NaturalTransformation as Category open import Syntax.Transitivity open import Type module _ {ℓ} where open import Type.Category.ExtensionalFunctionsCategory{ℓ} public -- Shorthand for the category-related types in the category of types. Functor = Category.Endofunctor(typeExtensionalFnCategory) -- TODO: Should not be an endofunctor. Let it be parameterized by different levels module Functor {F} ⦃ functor : Functor(F) ⦄ where open Category.Endofunctor(typeExtensionalFnCategory) functor public module HaskellNames where _<$_ : ∀{x y} → y → (F(x) → F(y)) _<$_ = map ∘ const _$>_ : ∀{x y} → F(x) → y → F(y) _$>_ = swap(_<$_) _<$>_ : ∀{x y} → (x → y) → (F(x) → F(y)) _<$>_ = map _<&>_ : ∀{x y} → F(x) → (x → y) → F(y) _<&>_ = swap(_<$>_) -- Applies an unlifted argument to a lifted function, returning a lifted value. -- TODO: When `f` is an instance of `Applicative`, it should be functionally equivalent -- to `f <*> pure x` because: -- f <*$> x -- = fmap ($ x) f //Definition: <*$> -- = pure ($ x) <*> f //Applicative: "As a consequence of these laws, the Functor instance for f will satisfy..." -- = f <*> pure x //Applicative: interchange _<*$>_ : ∀{x y : Type{ℓ}} → F(x → y) → (x → F(y)) f <*$> x = (_$ x) <$> f module _ {F₁} ⦃ functor₁ : Functor(F₁) ⦄ {F₂} ⦃ functor₂ : Functor(F₂) ⦄ where NaturalTransformation : (∀{T} → F₁(T) → F₂(T)) → Type NaturalTransformation η = Category.NaturalTransformation {Cₗ = typeExtensionalFnCategoryObject} {Cᵣ = typeExtensionalFnCategoryObject} ([∃]-intro F₁) ([∃]-intro F₂) (T ↦ η{T}) module NaturalTransformation {η : ∀{T} → F₁(T) → F₂(T)} ⦃ nt : NaturalTransformation(η) ⦄ where open Category.NaturalTransformation {Cₗ = typeExtensionalFnCategoryObject} {Cᵣ = typeExtensionalFnCategoryObject} {[∃]-intro F₁} {[∃]-intro F₂} nt public {- -- All mappings between functors are natural. -- Also called: Theorems for free. -- TODO: Is this correct? Is this provable? Maybe one needs to prove stuff about how types are formed? natural-functor-mapping : ∀{η : ∀{T} → F₁(T) → F₂(T)} → NaturalTransformation(η) Dependent._⊜_.proof (Category.NaturalTransformation.natural (natural-functor-mapping {η}) {X}{Y} {f}) {F₁X} = (η ∘ (Functor.map f)) F₁X 🝖[ _≡_ ]-[] η(Functor.map f(F₁X)) 🝖[ _≡_ ]-[ {!!} ] Functor.map f (η(F₁X)) 🝖[ _≡_ ]-[] ((Functor.map f) ∘ η) F₁X 🝖-end -} Monad = Category.ExtensionSystem{cat = typeExtensionalFnCategoryObject} module Monad {T} ⦃ monad : Monad(T) ⦄ where open Category.ExtensionSystem{cat = typeExtensionalFnCategoryObject} (monad) public -- Do notation for monads. open import Syntax.Do instance doNotation : DoNotation(T) return ⦃ doNotation ⦄ = HaskellNames.return _>>=_ ⦃ doNotation ⦄ = swap(HaskellNames.bind) open Monad using () renaming (doNotation to Monad-doNotation) public
{ "alphanum_fraction": 0.6478711162, "avg_line_length": 46.3466666667, "ext": "agda", "hexsha": "948352aa9b1293410fdc416eddc17b7d065b5caf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Type/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Type/Category.agda", "max_line_length": 179, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Type/Category.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": 1064, "size": 3476 }
module Lib.List where open import Lib.Prelude open import Lib.Id infix 30 _∈_ infixr 40 _::_ _++_ infix 45 _!_ data List (A : Set) : Set where [] : List A _::_ : A -> List A -> List A {-# COMPILED_DATA List [] [] (:) #-} {-# BUILTIN LIST List #-} {-# BUILTIN NIL [] #-} {-# BUILTIN CONS _::_ #-} _++_ : {A : Set} -> List A -> List A -> List A [] ++ ys = ys (x :: xs) ++ ys = x :: (xs ++ ys) foldr : {A B : Set} -> (A -> B -> B) -> B -> List A -> B foldr f z [] = z foldr f z (x :: xs) = f x (foldr f z xs) map : {A B : Set} -> (A -> B) -> List A -> List B map f [] = [] map f (x :: xs) = f x :: map f xs map-id : forall {A}(xs : List A) -> map id xs ≡ xs map-id [] = refl map-id (x :: xs) with map id xs | map-id xs ... | .xs | refl = refl data _∈_ {A : Set} : A -> List A -> Set where hd : forall {x xs} -> x ∈ x :: xs tl : forall {x y xs} -> x ∈ xs -> x ∈ y :: xs data All {A : Set}(P : A -> Set) : List A -> Set where [] : All P [] _::_ : forall {x xs} -> P x -> All P xs -> All P (x :: xs) head : forall {A}{P : A -> Set}{x xs} -> All P (x :: xs) -> P x head (x :: xs) = x tail : forall {A}{P : A -> Set}{x xs} -> All P (x :: xs) -> All P xs tail (x :: xs) = xs _!_ : forall {A}{P : A -> Set}{x xs} -> All P xs -> x ∈ xs -> P x xs ! hd = head xs xs ! tl n = tail xs ! n tabulate : forall {A}{P : A -> Set}{xs} -> ({x : A} -> x ∈ xs -> P x) -> All P xs tabulate {xs = []} f = [] tabulate {xs = x :: xs} f = f hd :: tabulate (f ∘ tl) mapAll : forall {A B}{P : A -> Set}{Q : B -> Set}{xs}(f : A -> B) -> ({x : A} -> P x -> Q (f x)) -> All P xs -> All Q (map f xs) mapAll f h [] = [] mapAll f h (x :: xs) = h x :: mapAll f h xs mapAll- : forall {A}{P Q : A -> Set}{xs} -> ({x : A} -> P x -> Q x) -> All P xs -> All Q xs mapAll- {xs = xs} f zs with map id xs | map-id xs | mapAll id f zs ... | .xs | refl | r = r infix 20 _⊆_ data _⊆_ {A : Set} : List A -> List A -> Set where stop : [] ⊆ [] drop : forall {xs y ys} -> xs ⊆ ys -> xs ⊆ y :: ys keep : forall {x xs ys} -> xs ⊆ ys -> x :: xs ⊆ x :: ys ⊆-refl : forall {A}{xs : List A} -> xs ⊆ xs ⊆-refl {xs = []} = stop ⊆-refl {xs = x :: xs} = keep ⊆-refl _∣_ : forall {A}{P : A -> Set}{xs ys} -> All P ys -> xs ⊆ ys -> All P xs [] ∣ stop = [] (x :: xs) ∣ drop p = xs ∣ p (x :: xs) ∣ keep p = x :: (xs ∣ p)
{ "alphanum_fraction": 0.450572762, "avg_line_length": 28.0595238095, "ext": "agda", "hexsha": "fd2f1a3719d7f4fb59eb0ea129f740a7b26224b3", "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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "examples/simple-lib/Lib/List.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "examples/simple-lib/Lib/List.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "examples/simple-lib/Lib/List.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 952, "size": 2357 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.NaturalTransformation where open import Cubical.Categories.NaturalTransformation.Base public open import Cubical.Categories.NaturalTransformation.Properties public
{ "alphanum_fraction": 0.8312757202, "avg_line_length": 34.7142857143, "ext": "agda", "hexsha": "90a75284afea75c42f86fc7d2cce95d464cf1d96", "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/NaturalTransformation.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/NaturalTransformation.agda", "max_line_length": 70, "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/NaturalTransformation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 45, "size": 243 }
------------------------------------------------------------------------ -- The Agda standard library -- -- AVL trees ------------------------------------------------------------------------ -- AVL trees are balanced binary search trees. -- The search tree invariant is specified using the technique -- described by Conor McBride in his talk "Pivotal pragmatism". {-# OPTIONS --without-K --safe #-} open import Relation.Binary using (StrictTotalOrder) module Data.AVL {a ℓ₁ ℓ₂} (strictTotalOrder : StrictTotalOrder a ℓ₁ ℓ₂) where open import Data.Bool.Base using (Bool) import Data.DifferenceList as DiffList open import Data.List.Base as List using (List) open import Data.Maybe using (Maybe; nothing; just; is-just) open import Data.Nat.Base using (suc) open import Data.Product hiding (map) open import Function as F open import Level using (_⊔_) open import Relation.Unary open StrictTotalOrder strictTotalOrder renaming (Carrier to Key) import Data.AVL.Indexed strictTotalOrder as Indexed open Indexed using (K&_ ; ⊥⁺ ; ⊤⁺; ⊥⁺<⊤⁺; ⊥⁺<[_]<⊤⁺; ⊥⁺<[_]; [_]<⊤⁺) ------------------------------------------------------------------------ -- Re-export some core definitions publically open Indexed using (Value; MkValue; const) public ------------------------------------------------------------------------ -- Types and functions with hidden indices data Tree {v} (V : Value v) : Set (a ⊔ v ⊔ ℓ₂) where tree : ∀ {h} → Indexed.Tree V ⊥⁺ ⊤⁺ h → Tree V module _ {v} {V : Value v} where private Val = Value.family V empty : Tree V empty = tree $′ Indexed.empty ⊥⁺<⊤⁺ singleton : (k : Key) → Val k → Tree V singleton k v = tree (Indexed.singleton k v ⊥⁺<[ k ]<⊤⁺) insert : (k : Key) → Val k → Tree V → Tree V insert k v (tree t) = tree $′ proj₂ $ Indexed.insert k v t ⊥⁺<[ k ]<⊤⁺ insertWith : (k : Key) → (Maybe (Val k) → Val k) → Tree V → Tree V insertWith k f (tree t) = tree $′ proj₂ $ Indexed.insertWith k f t ⊥⁺<[ k ]<⊤⁺ delete : Key → Tree V → Tree V delete k (tree t) = tree $′ proj₂ $ Indexed.delete k t ⊥⁺<[ k ]<⊤⁺ lookup : (k : Key) → Tree V → Maybe (Val k) lookup k (tree t) = Indexed.lookup k t ⊥⁺<[ k ]<⊤⁺ module _ {v w} {V : Value v} {W : Value w} where private Val = Value.family V Wal = Value.family W map : ∀[ Val ⇒ Wal ] → Tree V → Tree W map f (tree t) = tree $ Indexed.map f t module _ {v} {V : Value v} where private Val = Value.family V infix 4 _∈?_ _∈?_ : Key → Tree V → Bool k ∈? t = is-just (lookup k t) headTail : Tree V → Maybe ((K& V) × Tree V) headTail (tree (Indexed.leaf _)) = nothing headTail (tree {h = suc _} t) with Indexed.headTail t ... | (k , _ , _ , t′) = just (k , tree (Indexed.castˡ ⊥⁺<[ _ ] t′)) initLast : Tree V → Maybe (Tree V × (K& V)) initLast (tree (Indexed.leaf _)) = nothing initLast (tree {h = suc _} t) with Indexed.initLast t ... | (k , _ , _ , t′) = just (tree (Indexed.castʳ t′ [ _ ]<⊤⁺) , k) -- The input does not need to be ordered. fromList : List (K& V) → Tree V fromList = List.foldr (uncurry insert) empty -- Returns an ordered list. toList : Tree V → List (K& V) toList (tree t) = DiffList.toList (Indexed.toDiffList t) -- Naive implementations of union. module _ {v w} {V : Value v} {W : Value w} where private Val = Value.family V Wal = Value.family W unionWith : (∀ {k} → Val k → Maybe (Wal k) → Wal k) → -- Left → right → result. Tree V → Tree W → Tree W unionWith f t₁ t₂ = List.foldr (uncurry $ λ k v → insertWith k (f v)) t₂ (toList t₁) -- Left-biased. module _ {v} {V : Value v} where private Val = Value.family V union : Tree V → Tree V → Tree V union = unionWith F.const unionsWith : (∀ {k} → Val k → Maybe (Val k) → Val k) → List (Tree V) → Tree V unionsWith f ts = List.foldr (unionWith f) empty ts -- Left-biased. unions : List (Tree V) → Tree V unions = unionsWith F.const
{ "alphanum_fraction": 0.5687610396, "avg_line_length": 28.7173913043, "ext": "agda", "hexsha": "ae80b5488e56c74d1f6ccf2be2653663578ab2ae", "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/AVL.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/AVL.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/AVL.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1270, "size": 3963 }
{- 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 -} module Dijkstra.EitherLike where open import Haskell.Prelude open import Level renaming (suc to ℓ+1; zero to ℓ0; _⊔_ to _ℓ⊔_) public module _ {ℓ₀ ℓ₁ ℓ₂ : Level} where EL-type = Set ℓ₁ → Set ℓ₂ → Set ℓ₀ EL-level = ℓ₁ ℓ⊔ ℓ₂ ℓ⊔ ℓ₀ -- Utility to make passing between `Either` and `EitherD` more convenient record EitherLike (E : EL-type) : Set (ℓ+1 EL-level) where field fromEither : ∀ {A : Set ℓ₁} {B : Set ℓ₂} → Either A B → E A B toEither : ∀ {A : Set ℓ₁} {B : Set ℓ₂} → E A B → Either A B open EitherLike ⦃ ... ⦄ public EL-func : EL-type → Set (ℓ+1 EL-level) EL-func EL = ⦃ mel : EitherLike EL ⦄ → Set EL-level instance EitherLike-Either : ∀ {ℓ₁ ℓ₂} → EitherLike{ℓ₁ ℓ⊔ ℓ₂}{ℓ₁}{ℓ₂} Either EitherLike.fromEither EitherLike-Either = id EitherLike.toEither EitherLike-Either = id
{ "alphanum_fraction": 0.6710037175, "avg_line_length": 31.6470588235, "ext": "agda", "hexsha": "103095dfae9f042528124d206e87cccb3ee21f2a", "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/Dijkstra/EitherLike.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/Dijkstra/EitherLike.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/Dijkstra/EitherLike.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 401, "size": 1076 }
open import Prelude open import StateMachineModel open StateMachine open System open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary.Core using (Tri) module Behaviors (State : Set) (Event : Set) (sys : System State Event) (_∈Set?_ : (ev : Event) (evSet : EventSet) → Dec (evSet ev)) where open LeadsTo State Event sys StMachine = stateMachine sys -- A Behavior is a coinductive data type, such that it has a head with a given -- state S and a tail that can be next state for an existent transition or can -- be finite, which means that there is no enabled transition -- Question : Would it make more sense the behavior over -- ReachableState instead of State??? record Behavior (S : State) : Set where coinductive field tail : ∃[ ev ] ( Σ[ enEv ∈ enabled StMachine ev S ] Behavior (action StMachine enEv) ) ⊎ ¬ ( ∃[ ev ] enabled StMachine ev S ) open Behavior -- Auxiliary function that allows to do pattern matching on the RHS of an -- expression. -- (ref: https://agda.readthedocs.io/en/v2.5.2/language/with-abstraction.html) case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B case x of f = f x -- Inductive data type to express that Any State ∈ Behavior (AnyS∈B) satisfies -- a given Predicate P at a given index n -- It's similar to the Any for Lists, with the difference that in the 'there' -- contructor we also need to give a proof that the behavior has a tail t. data AnySt {st} (P : Pred State 0ℓ) : ℕ → Pred (Behavior st) 0ℓ where here : ∀ {σ : Behavior st} → P st → AnySt P zero σ there : ∀ {e enEv t} {σ : Behavior st} (n : ℕ) → tail σ ≡ inj₁ (e , enEv , t) → AnySt P n t → AnySt P (suc n) σ -- Syntactic sugar for better reading of lemmas: -- σ satisfies P at i if there is a state ∈ σ that satisfies P at i _satisfies_at_ : ∀ {st} (σ : Behavior st) (P : Pred State 0ℓ) → ℕ → Set σ satisfies P at i = AnySt P i σ -- Gives the tail of the behavior after n transitions. -- If the behavior is finite returns the behavior itself drop : ∀ {st} → ℕ → (σ : Behavior st) → ∃[ s ] Behavior s drop {st} zero σ = st , σ drop {st} (suc n) σ with tail σ ... | inj₁ (e , enEv , t) = drop n t ... | inj₂ ¬enEv = st , σ -- Inductive data type to express that all states in a behavior n satisfy a -- Predicate P up to a given index n -- It's similar to the All for Lists, with the difference that in the '_∷_' -- contructor we also need to give a proof that the behavior has a tail t. data AllSt {st} (P : Pred State 0ℓ) : ℕ → Pred (Behavior st) 0ℓ where last : ∀ {σ : Behavior st} → P st → AllSt P zero σ _∷_∣_ : ∀ {e enEv t n} {σ : Behavior st} → tail σ ≡ inj₁ (e , enEv , t) → P st → AllSt P n t → AllSt P (suc n) σ -- Syntactic sugar for better reading of lemmas AllSt_upTo_satisfy_ : ∀ {st} (σ : Behavior st) → ℕ → (P : Pred State 0ℓ) → Set AllSt σ upTo n satisfy P = AllSt P n σ ------------------------------------------------------------------------------ -- PROOF of SOUNDNESS for LEADS-TO PROOF RULES ------------------------------------------------------------------------------ -- If a behavior σ satisfies P at i then it exists a state s at index i such -- that s is reachable and P s witness : ∀ {st : State} {i} {σ : Behavior st} {P : Pred State 0ℓ} → Reachable {sm = StMachine} st → σ satisfies P at i → ∃[ state ] (Σ[ rSt ∈ Reachable {sm = StMachine} state ] P state) witness {st} rS (here ps) = st , rS , ps witness {st} rS (there {σ = σ} n eq satP) with tail σ | eq ... | inj₁ (e , enEv , t) | refl = witness (step rS enEv) satP -- If a behavior σ satisfies Q ∪ R at a given index i then -- or σ satisfies Q at i or σ satisfies R at i trans2 : ∀ {st} {Q R : Pred State 0ℓ} {i : ℕ} {σ : Behavior st} → σ satisfies (Q ∪ R) at i → σ satisfies Q at i ⊎ σ satisfies R at i trans2 (here (inj₁ qS)) = inj₁ (here qS) trans2 (here (inj₂ rS)) = inj₂ (here rS) trans2 {σ = σ} (there n eq tailQ∨R) with tail σ | eq ... | inj₁ (e , enEv , t) | refl with trans2 tailQ∨R ... | inj₁ anyQ = inj₁ (there n eq anyQ) ... | inj₂ anyR = inj₂ (there n eq anyR) -- If σ satisfies (R ⇒ Q) at a given index i and if R is an invariant then -- σ satisfies Q at i useInv : ∀ {st} {Q R : Pred State 0ℓ} {i : ℕ} {σ : Behavior st} → Invariant StMachine R → Reachable {sm = StMachine} st → σ satisfies (R ⇒ Q) at i → σ satisfies Q at i useInv inv rS (here r→q) = here (r→q (inv rS)) useInv inv rS (there {e} {enEv} n eq sat) = there n eq (useInv inv (step rS enEv) sat) -- If σ satisfies (P ∩ S) at i then σ satisfies P at i and σ satisfies S at i split-Conjunction : ∀ {st} {P S : Pred State 0ℓ} {i : ℕ} {σ : Behavior st} → σ satisfies (P ∩ S) at i → σ satisfies P at i × σ satisfies S at i split-Conjunction (here (p' , s)) = here p' , here s split-Conjunction (there {e} {enEv} n eq satP'∧S) with split-Conjunction satP'∧S ... | tailP' , tailS = (there n eq tailP') , (there n eq tailS) -- If a behavior σ satisfies a stable predicate S at a given index i, and -- satisfies Q at a given k ≥ i then σ satisfies (Q ∩ S) at k stableAux : ∀ {st} {Q S : Pred State 0ℓ} {i k : ℕ} {σ : Behavior st} → Stable StMachine S → σ satisfies S at i → i ≤ k → σ satisfies Q at k → σ satisfies (Q ∩ S) at k stableAux stable (here sS) i<k (here qS) = here (qS , sS) stableAux {σ = σ} stable (here sS) i<k (there {e} {enEv} n eq satQ') = there n eq (stableAux stable (here (stable enEv sS)) z≤n satQ') stableAux stable (there n eq satS) i<k (there n₁ eq₁ satQ') with trans (sym eq₁) eq ... | refl with stableAux stable satS (≤-pred i<k) satQ' ... | satT = there n₁ eq₁ satT -- Let A be a concurrent system. EventSet is a subset of events of A. -- The EventSet evSet is enabled in a state st if: -- ∃[ e ∈ evSet ] enabled e st (see definition of enabledSet) -- A behavior σ satisfies weak fairness for evSet if given that -- evSet is continuously enabled then it will eventually occurs postulate weak-fairness : ∀ {st} → (evSet : EventSet) → weakFairness sys evSet → (σ : Behavior st) → ∃[ n ] (AllSt σ upTo n satisfy (enabledSet StMachine evSet) → case tail (proj₂ (drop n σ)) of λ { (inj₁ (e , enEv , t)) → e ∈ evSet ; (inj₂ ¬enEv) → ⊥ }) -- For all n, given the constraints of the viaEvSet rule of LeadsTo, we know -- that either we reach Q at some point or in all states up to that n the evSet -- will be enabled soundness-WF : ∀ {st} {P Q : Pred State 0ℓ} → Reachable {sm = StMachine} st → (evSet : EventSet) → (σ : Behavior st) → (n : ℕ) → P st → (∀ (e : Event) → evSet e → [ P ] e [ Q ]) → (∀ (e : Event) → ¬ (evSet e) → [ P ] e [ P ∪ Q ]) → Invariant (stateMachine sys) (P ⇒ enabledSet StMachine evSet) → Σ[ j ∈ ℕ ] 0 ≤ j × σ satisfies Q at j ⊎ AllSt σ upTo n satisfy (enabledSet StMachine evSet ∩ P) soundness-WF rS evSet σ zero ps c₁ c₂ c₃ = inj₂ (last ((c₃ rS ps) , ps)) soundness-WF rS evSet σ (suc n) ps c₁ c₂ c₃ with tail σ | inspect tail σ ... | inj₂ ¬enEv | _ = case c₃ rS ps of λ { (ev , _ , enEv) → ⊥-elim (¬enEv (ev , enEv)) } ... | inj₁ (ev , enEv , t) | Reveal[ t≡i₁ ] with ev ∈Set? evSet ... | yes ∈evSet = case c₁ ev ∈evSet of λ { (hoare p→q) → inj₁ (1 , z≤n , (there 0 t≡i₁ (here (p→q ps enEv)))) } ... | no ¬∈evSet with c₂ ev ¬∈evSet ... | hoare p∨q with p∨q ps enEv ... | inj₂ qActionSt = inj₁ (1 , z≤n , (there 0 t≡i₁ (here qActionSt))) ... | inj₁ pActionSt with soundness-WF (step rS enEv) evSet t n pActionSt c₁ c₂ c₃ ... | inj₁ (j , 0<j , anyQT) = inj₁ (suc j , z≤n , there j t≡i₁ anyQT) ... | inj₂ allT = inj₂ ( t≡i₁ ∷ ( c₃ rS ps , ps)∣ allT) -- If all states in a behavior σ up to an index n satisfy (P ∩ Q), then -- all states in σ up to n satisfy P and all states in σ up to n satisfy Q allP∧Q⇒allP∧allQ : ∀ {st} {P Q : Pred State 0ℓ} → (n : ℕ) → (σ : Behavior st) → AllSt σ upTo n satisfy (P ∩ Q) → AllSt σ upTo n satisfy P × AllSt σ upTo n satisfy Q allP∧Q⇒allP∧allQ zero σ (last (p , q)) = (last p) , (last q) allP∧Q⇒allP∧allQ (suc n) σ (eq ∷ (ps , qs) ∣ allPQ) with tail σ | eq ... | inj₁ (ev , enEv , t) | refl with allP∧Q⇒allP∧allQ n t allPQ ... | allP , allQ = (eq ∷ ps ∣ allP) , (eq ∷ qs ∣ allQ) -- If all states up to an index n in a behavior σ satisfy P, the state at the -- nᵗʰ state of σ satisfy P dropNsatP : ∀ {st} {P : Pred State 0ℓ} (n : ℕ) → (σ : Behavior st) → AllSt σ upTo n satisfy P → P (proj₁ (drop n σ)) dropNsatP zero σ (last ps) = ps dropNsatP (suc n) σ (t≡i₁ ∷ ps ∣ allP) with tail σ | t≡i₁ ... | inj₁ (_ , _ , t) | refl = dropNsatP n t allP -- If the nᵗʰ state of σ satisfy P at 1 then σ satisfy Q at (suc n) dropN⇒σsat : ∀ {st} {Q : Pred State 0ℓ} → (n : ℕ) → (σ : Behavior st) → proj₂ (drop n σ) satisfies Q at 1 → σ satisfies Q at (suc n) dropN⇒σsat zero σ satQ = satQ dropN⇒σsat (suc n) σ satQ with tail σ | inspect tail σ ... | inj₂ ¬ev | _ = case satQ of λ { (there {e} {enEv} 0 t≡inj₁ x) → ⊥-elim (¬ev (e , enEv)) } ... | inj₁ (e , enEv , t) | Reveal[ eq ] with dropN⇒σsat n t satQ ... | anyQ = there (suc n) eq anyQ -- If a behavior σ satisfy that it exists a w such that F w at index i then -- it exists a w such that σ satisfy Fw at index i σ⊢Fw : ∀ {st} {F : Z → Pred State 0ℓ} {i : ℕ} {σ : Behavior st} → σ satisfies [∃ w ∶ F w ] at i → Σ[ w ∈ ℕ ] σ satisfies F w at i σ⊢Fw (here (w , fw)) = w , (here fw) σ⊢Fw (there n eq satF) with σ⊢Fw satF ... | w , fw = w , (there n eq fw) -- If a behavior σ satisfy that it exists a w₁ such that w₁ < w and F w₁ -- at an index i then it exists a w₁ such that w₁ < w and -- σ satisfy F w₁ at index i σ⊢Fw< : ∀ {st} {F : Z → Pred State 0ℓ} {j w : ℕ} {σ : Behavior st} → σ satisfies [∃ w₁ ⇒ _< w ∶ F w₁ ] at j → Σ[ w₁ ∈ ℕ ] w₁ < w × σ satisfies F w₁ at j σ⊢Fw< (here (w₁ , w₁<w , fw₁)) = w₁ , w₁<w , (here fw₁) σ⊢Fw< (there n x satF) with σ⊢Fw< satF ... | w , x<w , fw = w , x<w , (there n x fw) -- The following definitions are mutual because the soundness proof use the -- lemma wfr→Q in the viaWFR rule to prove that given the viaWFR rule we reach -- a state that satisfies Q, and the wfr→Q lemma uses the soundness proof to -- prove that progress is made in the well founded ranking, which means that -- either we get to a state that satisfies Q or we reach a state where exists -- a w₁ such that w₁ < w and F w₁. This implies that or we reach Q or w₁ will -- become 0 and Q must hold. mutual wfr→Q : ∀ {w₁ w i : ℕ} {st} {F : Z → Pred State 0ℓ} {Q : Pred State 0ℓ} → w₁ < w → Reachable {sm = StMachine} st → (σ : Behavior st) → σ satisfies F w₁ at i → (∀ (w : Z) → F w l-t (Q ∪ [∃ x ⇒ _< w ∶ F x ])) → Σ[ j ∈ ℕ ] i ≤ j × σ satisfies Q at j wfr→Q {zero} {suc w} w₁<w rS σ satF fw→q∪f with soundness-aux rS σ satF (fw→q∪f 0) ... | n , i≤n , anyQ∨⊥ with trans2 anyQ∨⊥ ... | inj₁ anyQ = n , i≤n , anyQ ... | inj₂ imp with witness rS imp ... | () wfr→Q {suc w₁} {suc w} (s≤s w₁<w) rS σ satF fw→q∪f with soundness-aux rS σ satF (fw→q∪f (suc w₁)) ... | n , i≤n , anyQ∨F with trans2 anyQ∨F ... | inj₁ satQ = n , i≤n , satQ ... | inj₂ satw with σ⊢Fw< satw ... | w₂ , w₂<sw₁ , satw< with wfr→Q {w = w} (≤-trans w₂<sw₁ w₁<w) rS σ satw< fw→q∪f ... | j , n≤j , anyQ = j , ≤-trans i≤n n≤j , anyQ soundness-aux : ∀ {st} {P Q} {i : ℕ} → Reachable {sm = StMachine} st → (σ : Behavior st) → σ satisfies P at i → P l-t Q → Σ[ j ∈ ℕ ] i ≤ j × σ satisfies Q at j soundness-aux rS σ (here ps) (viaEvSet evSet wf c₁ c₂ c₃) with weak-fairness evSet wf σ ... | n , wfa with soundness-WF rS evSet σ n ps c₁ c₂ c₃ ... | inj₁ satQ = satQ ... | inj₂ allE∧P with allP∧Q⇒allP∧allQ n σ allE∧P ... | allE , allP with wfa allE ... | v with tail (proj₂ (drop n σ)) | inspect tail (proj₂ (drop n σ)) ... | inj₂ ¬enEv | _ = ⊥-elim v ... | inj₁ (e , enEv , t) | Reveal[ t≡i₁ ] = case c₁ e v of λ { (hoare p→q) → let pSt = dropNsatP n σ allP q⊢1 = there 0 t≡i₁ (here (p→q pSt enEv)) in (suc n) , z≤n , dropN⇒σsat n σ q⊢1 } soundness-aux rS σ (here ps) (viaInv inv) = 0 , z≤n , here (inv rS ps) soundness-aux rS σ (here ps) (viaTrans p→r r→q) with soundness-aux rS σ (here ps) p→r ... | n , 0<n , anyR with soundness-aux rS σ anyR r→q ... | j , n<j , anyQ = j , ≤-trans 0<n n<j , anyQ soundness-aux rS σ (here ps) (viaTrans2 p→q∨r r→q) with soundness-aux rS σ (here ps) p→q∨r ... | n , 0<n , anyQ∨R with trans2 anyQ∨R ... | inj₁ anyQ = n , z≤n , anyQ ... | inj₂ anyR with soundness-aux rS σ anyR r→q ... | j , n≤j , anyQ = j , ≤-trans 0<n n≤j , anyQ soundness-aux rS σ (here ps) (viaDisj p₁∨p₂ p₁→q p₂→q) with p₁∨p₂ ps ... | inj₁ p₁S = soundness-aux rS σ (here p₁S) p₁→q ... | inj₂ p₂S = soundness-aux rS σ (here p₂S) p₂→q soundness-aux rS σ (here ps) (viaUseInv invR p∧r→r⇒q) with soundness-aux rS σ (here (ps , invR rS)) p∧r→r⇒q ... | n , 0≤n , anyR⇒Q with useInv invR rS anyR⇒Q ... | anyQ = n , 0≤n , anyQ soundness-aux rS σ (here ps) (viaWFR F c₁ c₂) with soundness-aux rS σ (here ps) c₁ ... | n , 0<n , q∪f with trans2 q∪f ... | inj₁ anyQ = n , 0<n , anyQ ... | inj₂ anyF with σ⊢Fw anyF ... | w , satFw with soundness-aux rS σ satFw (c₂ w) ... | j , n<j , anyQ∪F with trans2 anyQ∪F ... | inj₁ anyQw = j , z≤n , anyQw ... | inj₂ anyFw with σ⊢Fw< anyFw ... | w₁ , w₁<w , satFw₁ with wfr→Q w₁<w rS σ satFw₁ c₂ ... | k , j<k , anyQ = k , z≤n , anyQ soundness-aux rS σ (here ps) (viaAllVal invR p∧r→q) with invR rS ... | a , rA = soundness-aux rS σ (here (ps , rA)) (p∧r→q a) soundness-aux rS σ (here ps) (viaStable stableS p→p'∧s p'→q' q'∧s→q) with soundness-aux rS σ (here ps) p→p'∧s ... | n , 0≤n , anyP'∧S with split-Conjunction anyP'∧S ... | anyP' , anyS with soundness-aux rS σ anyP' p'→q' ... | k , n≤k , anyQ' with soundness-aux rS σ (stableAux stableS anyS n≤k anyQ') q'∧s→q ... | j , k≤j , anyQ = j , ≤-trans 0≤n (≤-trans n≤k k≤j) , anyQ soundness-aux rS σ (there {e} {enEv} {t} i t≡i₁ σ⊢P) p→q with soundness-aux (step rS enEv) t σ⊢P p→q ... | j , i≤j , tail⊢Q = suc j , s≤s i≤j , (there j t≡i₁ tail⊢Q) -- Soundness proof for all Behaviors that start in one initial state soundnessLt : ∀ {s₀} {P Q} {i} → initial StMachine s₀ → (σ : Behavior s₀) → σ satisfies P at i → P l-t Q → ∃[ j ] (i ≤ j × σ satisfies Q at j) soundnessLt s₀ σ σ⊢P p→q = soundness-aux (init s₀) σ σ⊢P p→q ------------------------------------------------------------------------------ -- PROOF of SOUNDNESS for INVARIANCE PROOF RULE ------------------------------------------------------------------------------ record AllStates {st} (σ : Behavior st) (P : Pred State 0ℓ) : Set where coinductive field head-Sat : P st tail-Sat : ∀ {e enEv t} → tail σ ≡ inj₁ (e , enEv , t) → AllStates t P open Behavior soundnessInv-rS : ∀ {st} {P} → Reachable {sm = StMachine} st → (σ : Behavior st) → Invariant StMachine P → AllStates σ P AllStates.head-Sat (soundnessInv-rS rS σ invP) = invP rS AllStates.tail-Sat (soundnessInv-rS rS σ invP) {e} {enEv} {t} t≡i₁ = soundnessInv-rS (step rS enEv) t invP soundnessInv : ∀ {st} {P} → initial StMachine st → (σ : Behavior st) → Invariant StMachine P → AllStates σ P soundnessInv s₀ σ invP = soundnessInv-rS (init s₀) σ invP
{ "alphanum_fraction": 0.5149721052, "avg_line_length": 37.4541577825, "ext": "agda", "hexsha": "8279c52f12e4ea388c71fdab2c01e723c98102d3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "lisandrasilva/agda-liveness", "max_forks_repo_path": "src/Behaviors.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "lisandrasilva/agda-liveness", "max_issues_repo_path": "src/Behaviors.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "391e148f391dc2d246249193788a0d203285b38e", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "lisandrasilva/agda-liveness", "max_stars_repo_path": "src/Behaviors.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6311, "size": 17566 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Decidable.Sets open import Lists.Lists open import Numbers.Naturals.Semiring module UnorderedSet.Definition {a : _} {V : Set a} (dec : DecidableSet V) where data UnorderedSetOf : List V → Set a where empty' : UnorderedSetOf [] addCons : (v : V) → (vs : List V) → .(contains vs v → False) → UnorderedSetOf vs → UnorderedSetOf (v :: vs) record UnorderedSet : Set a where field elts : List V set : UnorderedSetOf elts empty : UnorderedSet empty = record { elts = [] ; set = empty' } add : V → UnorderedSet → UnorderedSet add v record { elts = elts ; set = set } with containsDecidable dec elts v ... | inl x = record { elts = elts ; set = set } ... | inr x = record { elts = v :: elts ; set = addCons v elts x set } singleton : V → UnorderedSet singleton v = record { elts = v :: [] ; set = addCons v [] (λ ()) empty' } ofList : (l : List V) → UnorderedSet ofList [] = record { elts = [] ; set = empty' } ofList (x :: l) = add x (ofList l) union : UnorderedSet → UnorderedSet → UnorderedSet union record { elts = eltsA ; set = setA } record { elts = eltsB ; set = setB } = ofList (eltsA ++ eltsB) count : UnorderedSet → ℕ count record { elts = e ; set = _ } = length e setContains : (v : V) → UnorderedSet → Set a setContains v record { elts = elts ; set = set } = contains elts v
{ "alphanum_fraction": 0.6503785272, "avg_line_length": 33.7906976744, "ext": "agda", "hexsha": "64e1b7b21eec5a2424a1a231a0148a4d8313ac26", "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": "UnorderedSet/Definition.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": "UnorderedSet/Definition.agda", "max_line_length": 109, "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": "UnorderedSet/Definition.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": 472, "size": 1453 }
{-# OPTIONS --without-K --safe #-} -- The Everything module of undecidability analysis -- In Agda, we use first order de Bruijn indices to represent variables, that is, the -- natural numbers. module Everything where -- Subtyping problems of all following calculi are undecidable. In this technical -- work, our reduction proofs stop at F<: deterministic (F<:ᵈ), the undecidability of -- which is justified by Pierce92. -- F<: F<:⁻ F<:ᵈ import FsubMinus -- D<: -- -- The examination of D<: is composed of the following files: import DsubDef -- defines the syntax of D<:. import Dsub -- defines the simplified subtyping judgment per Lemma 2 in the paper. import DsubFull -- defines the original definition of D<:. import DsubEquivSimpler -- defines D<: normal form and shows that D<: subtyping is undecidable. import DsubNoTrans -- shows that D<: subtyping without transitivity remains undecidable. import DsubTermUndec -- shows that D<: term typing is also undecidable. -- other things -- properties of F<:⁻ import FsubMinus2
{ "alphanum_fraction": 0.7456479691, "avg_line_length": 35.6551724138, "ext": "agda", "hexsha": "57f603839e09c625c46cc1c92eeeacb30ccb20a0", "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": "48214a55ebb484fd06307df4320813d4a002535b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "HuStmpHrrr/popl20-artifact", "max_forks_repo_path": "agda/Everything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b", "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": "HuStmpHrrr/popl20-artifact", "max_issues_repo_path": "agda/Everything.agda", "max_line_length": 95, "max_stars_count": 1, "max_stars_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "HuStmpHrrr/popl20-artifact", "max_stars_repo_path": "agda/Everything.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-23T08:40:28.000Z", "max_stars_repo_stars_event_min_datetime": "2021-09-23T08:40:28.000Z", "num_tokens": 278, "size": 1034 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Signs ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Sign where ------------------------------------------------------------------------ -- Definition open import Data.Sign.Base public open import Data.Sign.Properties public using (_≟_)
{ "alphanum_fraction": 0.3396226415, "avg_line_length": 24.9411764706, "ext": "agda", "hexsha": "81dbe4b2951ac572a966b35abb084c5ac8fb68af", "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/Sign.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/Sign.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/Sign.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": 53, "size": 424 }
-- We need to look at irrelevant variables in meta instantiation occurs check. -- Here's why. module Issue483 where data _==_ {A : Set}(x : A) : A → Set where refl : x == x data ⊥ : Set where resurrect : .⊥ → ⊥ resurrect () data D : Set where c : (x : ⊥) → (.(y : ⊥) → x == resurrect y) → D d : D d = c _ (λ y → refl) -- this should leave an unsolved meta! An error is too harsh. {- -- Cannot instantiate the metavariable _21 to resurrect _ since it -- contains the variable y which is not in scope of the metavariable -- when checking that the expression refl has type _21 == resurrect _ -} ¬d : D → ⊥ ¬d (c x _) = x oops : ⊥ oops = ¬d d
{ "alphanum_fraction": 0.6298003072, "avg_line_length": 21.7, "ext": "agda", "hexsha": "992af7cd2f57e9da85d54651edd68841028addae", "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/Issue483.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/Issue483.agda", "max_line_length": 78, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue483.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": 208, "size": 651 }
data Greeting : Set where hello : Greeting greet : Greeting greet = hello
{ "alphanum_fraction": 0.7272727273, "avg_line_length": 12.8333333333, "ext": "agda", "hexsha": "772f6351c93ed388f9b5a4f1686197c3ce05e0f7", "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": "c134875eae37d265936199fda278416e2a3c1224", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "supeterlau/bedev", "max_forks_repo_path": "agda/hello.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c134875eae37d265936199fda278416e2a3c1224", "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": "supeterlau/bedev", "max_issues_repo_path": "agda/hello.agda", "max_line_length": 25, "max_stars_count": null, "max_stars_repo_head_hexsha": "c134875eae37d265936199fda278416e2a3c1224", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "supeterlau/bedev", "max_stars_repo_path": "agda/hello.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 24, "size": 77 }
-- Jesper, Andreas, 2018-10-29, issue #3332 -- -- WAS: With-inlining failed in termination checker -- due to a DontCare protecting the clause bodies -- (introduced by Prop). {-# OPTIONS --prop #-} open import Agda.Builtin.Equality open import Agda.Builtin.List postulate A : Set _++_ : List A → List A → List A [] ++ l = l (a ∷ l) ++ l' = a ∷ (l ++ l') module PropEquality where data _≐_ {A : Set} (a : A) : A → Prop where refl : a ≐ a test : (l : List A) → (l ++ []) ≐ l test [] = refl test (x ∷ xs) with xs ++ [] | test xs test (x ∷ xs) | .xs | refl = refl module SquashedEquality where data Squash (A : Set) : Prop where sq : A → Squash A test : (l : List A) → Squash (l ++ [] ≡ l) test [] = sq refl test (x ∷ l) with test l test (x ∷ l) | sq eq with l ++ [] | eq test (x ∷ l) | .(test l) | .l | refl = sq refl -- Both should succeed.
{ "alphanum_fraction": 0.5593220339, "avg_line_length": 21.5853658537, "ext": "agda", "hexsha": "2f6c0f855e4a5b7662847f3f09f29a18166f6ac4", "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/Issue3332.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/Issue3332.agda", "max_line_length": 51, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue3332.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": 320, "size": 885 }
import Relation.Binary.PropositionalEquality as PE module x01 where import Data.Empty.Polymorphic as DEP open import Data.Unit.Polymorphic import Data.Maybe as Maybe {- Dependent Types at Work Ana Bove and Peter Dybjer Chalmers University of Technology, Göteborg, Sweden intro to functional programming with dependent types - simply typed functional programming in style of Haskell and ML - discuss differences between Agda’s type system and Hindley-Milner type system of Haskell/ML - how to use dependent types for programming - explain ideas behind type-checking dependent types - explain Curry-Howard identification of propositions and types - show a method to encode partial/general recursive functions as total functions using dependent types Dependent types are types that depend on elements of other types (e.g., Vec of length n) Invariants can be expressed with dependent type (e.g., sorted list) Agda's dependent type system is an extension of Martin-Löf type theory [20,21,22,25]. Parametrised types - e.g., [A] - usually not called dependent types - they are are families of types indexed by other types - NOT families of types indexed by ELEMENTS of another type - however, in dependent type theories, there is a type of small types (a universe), so that we have a type [A] of lists of elements of a given small type A. - FORTRAN could define arrays of a given dimension, so a form a dependent type on small type - simply typed lambda calculus and the Hindley-Milner type system, (e.g., Haskell/ML) do not include dependent types, only parametrised types - polymorphic lambda calculus System F [15] has types like ∀X.A where X ranges over all types, but no quantification over ELEMENTS of other types development of dependently typed programming languages has origins in Curry-Howard isomorphism between propositions and types 1930’s : Curry noticed similarity between axioms of implicational logic P ⊃ Q ⊃ P (P ⊃ Q ⊃ R) ⊃ (P ⊃ Q) ⊃ P ⊃ R and types of combinators K and S A → B → A (A → B → C) → (A → B) → A → C K can be viewed as a witness (i.e., proof object) of the truth of P ⊃ Q ⊃ P S can be viewed as a withness of the truth of (P ⊃ Q ⊃ R) ⊃ (P ⊃ Q) ⊃ P ⊃ R typing rule for application corresponds to the inference rule modus ponens: from P ⊃ Q and P conclude Q - f : A → B - a : A - f a → B product types correspond to conjunctions sum types (disjoint unions) to disjunctions to extend this correspondence to predicate logic Howard and de Bruijn introduced dependent types A(x) corresponding to predicates P(x). They formed indexed products Π x : D.A(x) : corresponding to universal quantifications ∀x : D.P (x) indexed sums Σ x : D.A(x) : existential quantifications ∃x : D.P (x) this gives a Curry-Howard interpretation of intuitionistic predicate logic one-to-one correspondence between propositions and types in a type system with dependent types one-to-one correspondence between - proofs of a certain proposition in constructive predicate logic, and - terms of the corresponding type To accommodate equality in predicate logic introduce the type a == b of proofs that a and b are equal. Gives a Curry-Howard interpretation of predicate logic with equality. Can go further and add natural numbers with addition and multiplication to obtain a Curry-Howard version of Heyting (intuitionistic) arithmetic. Curry-Howard interpretation was basis for Martin-Löf’s intuitionistic type theory [20,21,22]. - propositions and types are identified - intended to be a foundational system for constructive mathematics - can also be used as a programming language [21] - from 1980’s and onwards, systems implementing variants of Martin-Löf type theory - NuPRL [6] : implementing an extensional version of the theory - Coq [33] : implementing an intensional impredicative version - Agda : implements an intensional predicative extension About these Notes Agda's type-checking algorithm - Section 5 - ideas first presented by Coquand [7] - more information - Norell’s thesis [26] - Abel, Coquand, and Dybjer [1,2] - Coquand, Kinoshita, Nordström, and Takeyama [8]. more complete understanding of dependent type theory - read a book about Martin-Löf type theory and related systems - Martin-Löf’s “Intuitionistic Type Theory” [22] is a classic - be aware that it describes an extensional version of the theory - Nordström, Petersson, and Smith [25] description of the later intensional theory on which Agda is based - variants of dependent type theory are - Thompson [34] - Constable et al [6] : NuPRL - Bertot and Casteran [4] : Coq - lecture notes (Agda wiki [3]) by Norell - collection of advanced examples of how to use Agda for dependently typed programming - Geuvers’ lecture notes : introduction to type theory - including Barendregt’s pure type systems and important meta-theoretic properties - Bertot’s notes : how dependent types (in Coq) can be used for implementing a number of concepts of programming language theory - focus on abstract interpretation - Barthe, Grégoire, and Riba’s notes - method for making termination-checkers Section 2 : ordinary functional programming Section 3 : basic dependent types and shows how to use them Section 4 : Curry-Howard isomorphism Section 5 : aspects of type-checking and pattern matching with dependent types Section 6 : use Agda as a programming logic Section 7 : how to represent general recursion and partial functions as total functions in Agda ------------------------------------------------------------------------------ 2 Simply Typed Functional Programming in Agda 2.1 Truth Values -} data Bool : Set where true : Bool false : Bool {- states - Bool is a data type with the two (no-arg) constructors - “:” denotes type membership - Bool is a member of the type Set - Set - the type of sets (using a terminology introduced by Martin-Löf [22]) or small types (mentioned in the introduction). - Bool is a small type, but Set itself is not, it is a large type. - allowing Set : Set, would make the system inconsistent -} not : Bool -> Bool not true = false not false = true {- Agda cannot generally infer types. Because Agda type-checking done via normalisation (simplification) - without the normality restriction it may not terminate -} equiv : Bool -> Bool -> Bool equiv false false = true equiv true false = false equiv false true = false equiv true true = true _||_ : Bool -> Bool -> Bool true || _ = true false || true = true false || false = false infixl 60 _||_ -- EXERCISE: Define some more truth functions, such as conjunction and implication/TODO. _&&_ : Bool -> Bool -> Bool false && _ = false true && false = false true && true = true -- infixl ?? _&&_ -- 2.2 Natural Numbers -- such data types known as recursive in Haskell -- in constructive type theory, referred to as inductive types or inductively defined types data Nat : Set where zero : Nat succ : Nat -> Nat {-# BUILTIN NATURAL Nat #-} pred : Nat -> Nat pred zero = zero pred (succ n) = n _+_ : Nat -> Nat -> Nat zero + m = m succ n + m = succ (n + m) {-# BUILTIN NATPLUS _+_ #-} _*_ : Nat -> Nat -> Nat zero * n = zero succ n * m = (n * m) + m {-# BUILTIN NATTIMES _*_ #-} infixl 6 _+_ _∸_ infixl 7 _*_ _ : (2 * 3) + 10 PE.≡ 16 _ = PE.refl {- + and * are defined by PRIMITIVE RECURSION in FIRST ARG. - PRIMITIVE RECURSIION : - upper bound of number of iterations of every loop can be determined before entering loop - time complexity of PR functions bounded by the input size - base case for zero - step case for non zero defined recursively Given a first order data type - distinguish between - canonical form - built by constructors only - e.g., true, false, zero, succ zero, succ (succ zero), ... - non-canonical forms - whereas non-canonical elements might contain defined functions - e.g., not true, zero + zero, zero * zero, succ (zero + zero) Martin-Löf [21] instead considers lazy canonical forms - a term begins with a constructor to be considered a canonical form - e.g., succ (zero + zero) is a lazy canonical form, but not a “full” canonical form - Lazy canonical forms are appropriate for lazy functional programming languages (e.g., Haskell) -- EXERCISE: Write the cut-off subtraction function -- the function on natural numbers, which returns 0 -- if the second argument is greater than or equal to the first. -} _∸_ : Nat -> Nat -> Nat zero ∸ _ = zero succ n ∸ zero = succ n succ n ∸ succ m = n ∸ m _ : 0 ∸ 0 PE.≡ 0 _ = PE.refl _ : 0 ∸ 10 PE.≡ 0 _ = PE.refl _ : 10 ∸ 0 PE.≡ 10 _ = PE.refl _ : 10 ∸ 10 PE.≡ 0 _ = PE.refl _ : 10 ∸ 9 PE.≡ 1 _ = PE.refl -- EXERCISE: Also write some more numerical functions like < or <= _<_ : Nat -> Nat -> Bool zero < zero = false zero < succ _ = true succ _ < zero = false succ n < succ m = n < m _ : 9 < 10 PE.≡ true _ = PE.refl _ : 10 < 10 PE.≡ false _ = PE.refl _<=_ : Nat -> Nat -> Bool zero <= zero = true zero <= succ _ = true succ _ <= zero = false succ n <= succ m = n <= m _ : 9 <= 10 PE.≡ true _ = PE.refl _ : 10 <= 10 PE.≡ true _ = PE.refl _>_ : Nat -> Nat -> Bool zero > zero = false zero > succ _ = false succ _ > zero = true succ n > succ m = n > m {- 2.3 Lambda Notation and Polymorphism Agda is based on the typed lambda calculus. APPLICATION is juxtaposition lambda ABSTRACTION written either - Curry-style (without a type label) \x -> e - Church-style (with a type label) \(x : A) -> e a family of identity functions, one for each small type: -} -- idE(xplicit) idE : (A : Set) -> A -> A idE = \(A : Set) -> \(x : A) -> x {- apply this “generic” identity function id to a type argument A to obtain the identity function from A to A 1st use of dependent types: type A -> A depends on variable A : Set - ranging over the small types Agda’s notation for dependent function types - if A is a type and B[x] is a type which depends on (is indexed by) (x : A) then (x : A) -> B[x] is the type of functions f mapping arguments (x : A) to values f x : B[x]. If the type-checker can figure out value of an arg, can use a wild card character: id _ x : A K and S combinators in Agda (uses telescopic notation (A B : Set) -} K : (A B : Set) -> A -> B -> A K _ _ x _ = x S : (A B C : Set) -> (A -> B -> C) -> (A -> B) -> A -> C S _ _ _ f g x = f x (g x) {- 2.4 Implicit Arguments : declared by enclosing typings in curly brackets -} id : {A : Set} -> A -> A id x = x -- implicit arguments are omitted in applications _ : id zero PE.≡ zero _ = PE.refl -- can explicitly write an implicit argument by using curly brackets if needed _ : id {Nat} zero PE.≡ zero _ = PE.refl _ : id {_} zero PE.≡ zero _ = PE.refl {- 2.5 Gödel System T is a subsystem of Agda. System of primitive recursive functionals [16] - important in logic and a precursor to Martin-Löf type theory recursion restricted to primitive recursion : to make sure programs terminate Gödel System T - based on simply typed lambda calculus - with two base types : truth values and natural numbers - (some formulations code truth values as 0 and 1) - constants for constructors true, false, zero - conditional and primitive recursion combinators -} -- conditional if_then_else_ : {C : Set} -> Bool -> C -> C -> C if true then x else _ = x if false then _ else y = y -- primitive recursion combinator for natural numbers -- natrec is a higher-order function defined by primitive recursion with args -- - (implicit) return type -- - c : element returned in base case -- - 𝕟→c→c : step function -- - the Nat on which to perform the recursion natrec : {C : Set} -> C -> (Nat -> C -> C) -> Nat -> C natrec c 𝕟→c→c zero = c natrec c 𝕟→c→c (succ n) = 𝕟→c→c n (natrec c 𝕟→c→c n) -- natrec definitions of addition and multiplication _plus_ : Nat -> Nat -> Nat _plus_ n m = natrec m (\x y -> succ y) n _mult_ : Nat -> Nat -> Nat _mult_ n m = natrec zero (\x y -> y plus m) n -- compare plus/mult to _+_/_*_ _ : succ (succ zero) + 2 PE.≡ succ (succ zero + 2) _ = PE.refl _ : succ (succ zero + 2) PE.≡ succ (succ (zero + 2)) _ = PE.refl _ : succ (succ (zero + 2)) PE.≡ succ (succ 2 ) _ = PE.refl _ : succ (succ zero) plus 2 PE.≡ natrec 2 (\x y -> succ y) (succ (succ zero)) _ = PE.refl _ : natrec 2 (\x y -> succ y) (succ (succ zero)) PE.≡ (\x y -> succ y) (succ zero) (natrec 2 (\x y -> succ y) (succ zero)) _ = PE.refl _ : (\x y -> succ y) (succ zero) (natrec 2 (\x y -> succ y) (succ zero)) PE.≡ (\ y -> succ y) (natrec 2 (\x y -> succ y) (succ zero)) _ = PE.refl _ : (\ y -> succ y) (natrec 2 (\x y -> succ y) (succ zero)) PE.≡ succ (natrec 2 (\x y -> succ y) (succ zero)) _ = PE.refl _ : succ (natrec 2 (\x y -> succ y) (succ zero)) PE.≡ succ ((\x y -> succ y) zero (natrec 2 (\x y -> succ y) zero)) _ = PE.refl _ : succ ((\x y -> succ y) zero (natrec 2 (\x y -> succ y) zero)) PE.≡ succ ((\ y -> succ y) (natrec 2 (\x y -> succ y) zero)) _ = PE.refl _ : succ ((\ y -> succ y) (natrec 2 (\x y -> succ y) zero)) PE.≡ succ ( succ (natrec 2 (\x y -> succ y) zero)) _ = PE.refl _ : succ ( succ (natrec 2 (\x y -> succ y) zero)) PE.≡ succ ( succ 2 ) _ = PE.refl {- to stay entirely in Gödel system T - use terms built up by variables, application, lambda abstraction, - and constants true, false, zero, succ, if_then_else_, natrec Gödel system T has unusual property (for a programming language) - all typable programs terminate not only do terms in base types Bool and Nat terminate whatever reduction is chosen, but also terms of function type terminate reduction rules - β-reduction - defining equations for if_then_else and natrec reductions can be performed anywhere in a term, so there may be several ways to reduce a term therefore, Gödel system T is strongly normalising - any typable term reaches a normal form whatever reduction strategy is chosen Even in this restrictive Gödel system T, possible to define many numerical functions. Can define all primitive recursive functions (in the usual sense without higher-order functions). Can also define functions which are not primitive recursive, such as the Ackermann function. Gödel system T is important in the history of ideas that led to the Curry-Howard isomorphism and Martin-Löf type theory. Gödel system T - is the simply typed kernel of Martin-Löf’s constructive type theory, Martin-Löf type theory - is the foundational system from which Agda grew relationship between Agda and Martin-Löf type theory is much like the relationship between Haskell and the simply typed lambda calculus. Or compare it with the relationship between Haskell and Plotkin’s PCF [30]. Like Gödel system T, PCF is based on the simply typed lambda calculus with truth values and natural numbers. But PCF includes a fixed point combinator - used for encoding arbitrary general recursive definitions - therefore can define non-terminating functions in PCF. -} -- Exercise/TODO: Define all functions previously given in the text in Gödel System T. -- induction principle for booleans (from Mimram) Bool-rec : (P : Bool → Set) → P false → P true → (b : Bool) → P b Bool-rec P Pf Pt false = Pf Bool-rec P Pf Pt true = Pt not' : Bool -> Bool not' b = Bool-rec (λ bool → Bool) true false b _ : not' false PE.≡ not false _ = PE.refl _ : not' true PE.≡ not true _ = PE.refl equiv' : Bool -> Bool -> Bool equiv' b false = Bool-rec (λ bool → Bool) true false b equiv' b true = Bool-rec (λ bool → Bool) false true b _ : equiv' false false PE.≡ equiv false false _ = PE.refl _ : equiv' true false PE.≡ equiv true false _ = PE.refl _ : equiv' false true PE.≡ equiv false true _ = PE.refl _ : equiv' true true PE.≡ equiv true true _ = PE.refl _||'_ : Bool -> Bool -> Bool b ||' false = Bool-rec (λ bool → Bool) b b b b ||' true = Bool-rec (λ bool → Bool) (not b) b b _ : false ||' false PE.≡ false || false _ = PE.refl _ : false ||' true PE.≡ false || true _ = PE.refl _ : true ||' false PE.≡ true || false _ = PE.refl _ : true ||' true PE.≡ true || true _ = PE.refl _&&'_ : Bool -> Bool -> Bool b &&' false = Bool-rec (λ bool → Bool) false false b b &&' true = Bool-rec (λ bool → Bool) b b b _ : false &&' false PE.≡ false && false _ = PE.refl _ : false &&' true PE.≡ false && true _ = PE.refl _ : true &&' false PE.≡ true && false _ = PE.refl _ : true &&' true PE.≡ true && true _ = PE.refl pred' : Nat -> Nat pred' zero = natrec zero (\x y -> zero) zero pred' (succ n) = natrec zero (\_ _ -> n) n -- test after List def {- 2.6 Parametrised Types Haskell parametrised types : [a] -} data List (A : Set) : Set where [] : List A _::_ : A -> List A -> List A infixr 5 _::_ {-# BUILTIN LIST List #-} {- (A : Set) to the left of the colon - tells Agda that A is a parameter - and it becomes an implicit argument to the constructors: [] : {A : Set} -> List A _::_ : {A : Set} -> A -> List A -> List A def only allows defining lists with elements in arbitrary SMALL types - cannot define lists of sets using this definition, since sets form a large type -} -- test for pred' _ : (pred' 0 :: pred' 1 :: pred' 2 :: pred' 101 :: []) PE.≡ (pred 0 :: pred 1 :: pred 2 :: pred 101 :: []) _ = PE.refl mapL : {A B : Set} -> (A -> B) -> List A -> List B mapL f [] = [] mapL f (x :: xs) = f x :: mapL f xs _ : mapL succ (1 :: 2 :: []) PE.≡ (2 :: 3 :: []) _ = PE.refl -- Exercise: Define some more list combinators like for example foldl or filter. filter : {A : Set} -> (A -> Bool) -> List A -> List A filter f [] = [] filter f (x :: xs) = let tail = filter f xs in if f x then x :: tail else tail _ : filter (_< 4) (5 :: 4 :: 3 :: 2 :: 1 :: []) PE.≡ (3 :: 2 :: 1 :: []) _ = PE.refl foldl : {A B : Set} -> (B -> A -> B) -> B -> List A -> B foldl _ b [] = b foldl f b (a :: as) = foldl f (f b a) as foldr : {A B : Set} -> (A -> B -> B) -> B -> List A -> B foldr f b [] = b foldr f b (a :: as) = f a (foldr f b as) _ : foldl _+_ 0 (3 :: 2 :: 1 :: []) PE.≡ 6 _ = PE.refl _ : foldl _∸_ 0 (3 :: 1 :: []) PE.≡ 0 _ = PE.refl _ : foldr _∸_ 0 (3 :: 1 :: []) PE.≡ 2 _ = PE.refl -- Exercise: define list recursion combinator listrec (like natrec, but for lists) -- from Mimram List-rec : {A : Set} → (P : List A → Set) → P [] → ((x : A) → (xs : List A) → P xs → P (x :: xs)) → (xs : List A) → P xs List-rec P Pe Pc [] = Pe List-rec P Pe Pc (x :: xs) = Pc x xs (List-rec P Pe Pc xs) mapL' : {A B : Set} -> (A -> B) -> List A -> List B mapL' {_} {B} f xs = List-rec (λ _ → List B) [] (λ a _ bs → f a :: bs) xs _ : mapL' succ (1 :: 2 :: []) PE.≡ mapL succ (1 :: 2 :: []) _ = PE.refl filter' : {A : Set} -> (A -> Bool) -> List A -> List A filter' {A} f xs = List-rec (λ _ → List A) [] (λ a _ as' → if f a then a :: as' else as') xs _ : filter' (_< 4) (5 :: 4 :: 3 :: 2 :: 1 :: []) PE.≡ filter (_< 4) (5 :: 4 :: 3 :: 2 :: 1 :: []) _ = PE.refl foldl' : {A B : Set} -> (B -> A -> B) -> B -> List A -> B foldl' {_} {B} f b as = List-rec (λ _ → B) b (λ a _ b → f b a) as _ : foldl' _+_ 0 (3 :: 2 :: 1 :: []) PE.≡ foldl _+_ 0 (3 :: 2 :: 1 :: []) _ = PE.refl foldr' : {A B : Set} -> (A -> B -> B) -> B -> List A -> B foldr' {A} {B} f b as = List-rec (λ _ → B) b (λ a as b → f a b) as _ : foldr' _∸_ 0 (3 :: 1 :: []) PE.≡ foldr _∸_ 0 (3 :: 1 :: []) _ = PE.refl -- binary Cartesian product AKA pair data _X_ (A B : Set) : Set where <_,_> : A -> B -> A X B -- prime because these are never used but are redeinfed later fst' : {A B : Set} -> A X B -> A fst' < a , b > = a snd' : {A B : Set} -> A X B -> B snd' < a , b > = b -- Usually want to zip lists of equal length. -- Can fix that with runtime Maybe or compiletime dependent types (later). zipL : {A B : Set} -> List A -> List B -> List (A X B) zipL [] _ = [] zipL (_ :: _) [] = [] zipL (x :: xs) (y :: ys) = < x , y > :: zipL xs ys -- Exercise: Define the sum A + B of two small types with constructors: inl, inr. data Either (A B : Set) : Set where inl : A -> Either A B inr : B -> Either A B -- Exercise: Define a function from A + B to a small type C by cases. toC : {A B C : Set} → (A -> C) -> (B -> C) -> (Either A B) -> C toC ac _ (inl a) = ac a toC _ bc (inr b) = bc b {- 2.7 Termination-checking General recursion allowed in most languages. Therefore possible to define "partial" functions (e.g., divide by 0) How to ensure functions terminate? - one solution : restrict recursion to primitive recursion (like in Gödel system T) - the approach taken in Martin-Löf type theory where primitive recursion as a kind of structural recursion on well-founded data types (see Martin-Löf’s book [22] and Dybjer’s schema for inductive definitions [10]) - but structural recursion (in one argument at a time) is often inconvenient Agda’s termination-checker - generalisation of primitive recursion which is practically useful - enables doing pattern matching on several arguments simultaneously - and having recursive calls to structurally smaller arguments But repeated subtraction is rejected by Agda termination-checker although it is terminating. Because Agda does not recognise the recursive call to (m - n) as structurally smaller. Because subtraction is not a constructor for natural numbers. Further reasoning required to deduce the recursive call is on a smaller argument. Section 7 : describes how partial and general recursive functions can be represented in Agda. Idea is to replace a partial function by a total function with an extra argument: a proof that the function terminates on its arguments. ------------------------------------------------------------------------------ 3 Dependent Types 3.1 Vectors of a Given Length 2 ways to define - Recursive family - by primitive recursion/induction on n - Inductive family - as a family of data types by declaring its constructors and the types of constructors - like def of List, except length info included in types paper mostly uses inductive families -------------------------------------------------- Vectors as a Recursive Family In math : define vectors by induction on n: A 0 = 1 A n+1 = A × An In Agda (and Martin-Löf type theory): -} -- type with only one element data Unit : Set where <> : Unit VecR : Set -> Nat -> Set VecR A zero = Unit VecR A (succ n) = A X VecR A n {- Up till now, only used primitive recursion for defining functions where the range is in a given set (in a given small type). Here, primitive recursion used for defining a family of sets - a family of elements in a given large type. -} zipR : {A B : Set} {n : Nat} -> VecR A n -> VecR B n -> VecR (A X B) n zipR {n = zero} _ _ = <> zipR {n = succ n'} < a , as > < b , bs > = < < a , b > , zipR {n = n'} as bs > {- base case : type-correct since the right hand side has type VecR (A X B) zero = <> step case : type-correct since the right hand side has type VecR (A X B) (succ n) = (A X B) X (VecR (A X B) n) -} -- Exercise. Write the functions head, tail, and map for the recursive vectors. headR : {A : Set} {n : Nat} -> VecR A (succ n) -> A headR < x , _ > = x tailR : {A : Set} {n : Nat} -> VecR A (succ n) -> VecR A n tailR < _ , t > = t mapR : {A B : Set} {n : Nat} -> (A -> B) -> VecR A n -> VecR B n mapR {n = zero} _ _ = <> mapR {n = succ n'} f < a , as > = < f a , mapR {n = n'} f as > _ : mapR succ < 1 , < 2 , < 0 , <> > > > PE.≡ < 2 , < 3 , < 1 , <> > > > _ = PE.refl -------------------------------------------------- -- Vectors as an Inductive Family data Vec (A : Set) : Nat -> Set where [] : Vec A zero _::_ : {n : Nat} -> A -> Vec A n -> Vec A (succ n) {- this time no induction on length instead : constructors generate vectors of different lengths [] : length 0 :: : length (n + 1) Definition style called an inductive family, or an inductively defined family of sets. Terminology comes from constructive type theory, where data types such as Nat and (List A) are called inductive types. Remark: Beware of terminological confusion: - In programming languages one talks about recursive types for such data types defined by declaring the constructors with their types. - May be confusing since the word recursive family was used for a different notion. - Reason for terminological distinction between data types in ordinary functional languages, and data types in languages where all programs terminate. - In terminating languages, there will not be any non-terminating numbers or non-terminating lists. - The set-theoretic meaning of such types is therefore simple: - build the set inductively generated by the constructors, see [9] for details. - In non-terminating language, the semantic domains are more complex. - One typically considers various kinds of Scott domains which are complete partially orders. (Vec A n) has two args: - small type A of the elements - A is a parameter in the sense that it remains the same throughout the definition: for a given A, define the family Vec A : Nat -> Set - length n of type Nat. - n is not a parameter since it varies in the types of the constructors Non-parameters are often called INDICES - say that Vec A is an inductive family indexed by natural numbers In Agda data type definitions - parameters are placed to the left of the colon and become implicit arguments to the constructors - indices are placed to the right -} zip : {A B : Set} {n : Nat} -> Vec A n -> Vec B n -> Vec (A X B) n zip {n = zero} [] [] = [] zip {n = succ n'} (x :: xs) (y :: ys) = < x , y > :: zip {n = n'} xs ys head : {A : Set} {n : Nat} -> Vec A (succ n) -> A head (x :: _) = x tail : {A : Set} {n : Nat} -> Vec A (succ n) -> Vec A n tail (_ :: xs) = xs map : {A B : Set} {n : Nat} -> (A -> B) -> Vec A n -> Vec B n map f [] = [] map f (x :: xs) = f x :: map f xs -------------------------------------------------- -- 3.2 Finite Sets data Fin : Nat -> Set where fzero : {n : Nat} -> Fin (succ n) fsucc : {n : Nat} -> Fin n -> Fin (succ n) {- for each n, Fin n contains n elements e.g., Fin 3 contains fzero, fsucc fzero and fsucc (fsucc fzero) useful to access element in a vector - for Vec A n - position given by (Fin n) - ensures accessing an element inside the vector For empty vector n is zero. So would use (Fin 0) --- which has no elements. There is no such case. Expressed in Agda via "absurd" pattern '()' -} _!_ : {A : Set} {n : Nat} -> Vec A n -> Fin n -> A [] ! () (x :: _) ! fzero = x (_ :: xs) ! fsucc i = xs ! i -- Exercise: Rewrite the function !! so that it has the following type: -- This eliminates the empty vector case, but other cases are needed. _!!_ : {A : Set} {n : Nat} -> Vec A (succ n) -> Fin (succ n) -> A _!!_ {_} {zero} (a :: f_) fzero = a _!!_ {_} {succ n} (a :: _) fzero = a _!!_ {_} {succ n} (_ :: as) (fsucc f) = _!!_ {n = n} as f _!!'_ : {A : Set} {n : Nat} -> Vec A (succ n) -> Fin (succ n) -> A _!!'_ (a :: _) fzero = a _!!'_ {_} {succ n} (_ :: as) (fsucc f) = _!!'_ {n = n} as f _ : (0 :: 1 :: 2 :: []) ! fsucc fzero PE.≡ 1 _ = PE.refl _ : (0 :: 1 :: 2 :: []) !! fsucc fzero PE.≡ 1 _ = PE.refl _ : (0 :: 1 :: 2 :: []) !!' fsucc fzero PE.≡ 1 _ = PE.refl -- Exercise: Give an alternative definition of Fin as a recursive family. -- from Conal Eliot https://raw.githubusercontent.com/conal/agda-play/main/DependentTypesAtWork/RecVec.agda FinR : Nat -> Set FinR zero = DEP.⊥ FinR (succ n) = Maybe.Maybe (FinR n) f5 : FinR 5 f5 = Maybe.nothing f5' : FinR 5 PE.≡ Maybe.Maybe (Maybe.Maybe (Maybe.Maybe (Maybe.Maybe (Maybe.Maybe DEP.⊥)))) f5' = PE.refl f4 : FinR 4 f4 = Maybe.nothing f3 : FinR 3 f3 = Maybe.nothing f2 : FinR 2 f2 = Maybe.nothing f1 : FinR 1 f1 = Maybe.nothing f1' : FinR 1 PE.≡ Maybe.Maybe DEP.⊥ f1' = PE.refl --f0 : FinR 0 --f0 = {!!} -- no solution found f0' : FinR 0 PE.≡ DEP.⊥ f0' = PE.refl _!'_ : {A : Set} {n : Nat} → VecR A n → FinR n → A _!'_ {n = succ m} < a , _ > Maybe.nothing = a _!'_ {n = succ m} < _ , as > (Maybe.just finm) = as !' finm _ : < 0 , < 1 , < 2 , <> > > > !' Maybe.nothing PE.≡ 0 _ = PE.refl _ : < 0 , < 1 , < 2 , <> > > > !' Maybe.just Maybe.nothing PE.≡ 1 _ = PE.refl _ : < 0 , < 1 , < 2 , <> > > > !' Maybe.just (Maybe.just Maybe.nothing) PE.≡ 2 _ = PE.refl -- (Maybe.Maybe _A_645) !=< DEP.⊥ -- _ : < 0 , < 1 , < 2 , <> > > > !' Maybe.just (Maybe.just (Maybe.just Maybe.nothing)) PE.≡ 100 -- _ = PE.refl -------------------------------------------------- -- 3.3 More Inductive Families -- binary trees of a certain height -- any given (t : DBTree A n) is a perfectly balanced tree -- with 2n elements and information in the leaves data DBTree (A : Set) : Nat -> Set where leaf : A -> DBTree A zero node : {n : Nat} -> DBTree A n -> DBTree A n -> DBTree A (succ n) l1 : DBTree Nat 0 l1 = leaf 1 l2 : DBTree Nat 0 l2 = leaf 2 n1-2 : DBTree Nat 1 n1-2 = node l1 l2 l3 : DBTree Nat 0 l3 = leaf 3 l4 : DBTree Nat 0 l4 = leaf 4 n3-4 : DBTree Nat 1 n3-4 = node l3 l4 n1-2-3-4 : DBTree Nat 2 n1-2-3-4 = node n1-2 n3-4 -- Exercise/TODO: Modify DBTree def to define the height balanced binary trees -- i.e., binary trees where difference between heights of left and right subtree is at most one. -- Exercise/TODO: Define lambda terms as an inductive family -- indexed by the maximal number of free variables allowed in the term. -- Exercise/TODO: define typed lambda terms as an inductive family indexed by the type of the term. {- ------------------------------------------------------------------------------ Curry, 1930’s : one-to-one correspondence between propositions in propositional logic and types. 1960’s de Bruijn and Howard introduced dependent types to extend Curry’s correspondence to predicate logic. Scott [31] and Martin-Löf [20], correspondence became building block of foundation for constructive math: - Martin-Löf’s intuitionistic type theory. Will now show how intuitionistic predicate logic with equality is a subsystem of Martin-Löf type theory by realising it as a theory in Agda. 4.1 Propositional Logic isomorphism : each proposition is interpreted as the set of its proofs. To emphazie PROOFS here are FIRST-CLASS mathematical object, say PROOF OBJECTS. aka : CONSTRUCTIONS proposition - is true IFF its set of proofs is inhabited - it is false iff its set of proofs is empty -} -- CONJUNCTION (aka AND) -- A and B are two propositions represented by their sets of proofs. -- A & B is also a set of proofs, representing the conjunction of A and B. -- Note : conjunction is same as Cartesian product of two sets. -- applying & constructor is &-introduction data _&_ (A B : Set) : Set where <_,_> : A -> B -> A & B -- alternate def _&'_ : Set -> Set -> Set A &' B = A X B -- two rules of &-elimination -- rules state that if A & B is true then A and B are also true fst : {A B : Set} -> A & B -> A fst < a , _ > = a snd : {A B : Set} -> A & B -> B snd < _ , b > = b sndP : {A B : Set} -> A &' B -> B sndP < _ , b > = b -- DISJUNCTION (aka OR) -- disjunction corresponds to disjoint union data _\/_ (A B : Set) : Set where inl : A -> A \/ B inr : B -> A \/ B -- alternate def _\/'_ : Set -> Set -> Set A \/' B = Either A B -- rule of \/-elimination is case analysis for a disjoint union case : {A B C : Set} -> A \/ B -> (A -> C) -> (B -> C) -> C case (inl a) d e = d a case (inr b) d e = e b -- proposition which is always true -- corresponds to the unit set (see page 14) according to Curry-Howard: data True : Set where <> : True -- proposition False is the proposition that is false by definition -- corresponds to the the empty set according to Curry-Howard. -- This is the set which is defined by stating that it has no canonical elements. -- sometimes referred as the “absurdity” set and denoted by ⊥ data False : Set where -- rule of ⊥-elimination states that if False has been proved, then can prove any proposition A. -- Can only happen by starting with contradictory assumptions. nocase : {A : Set} -> False -> A nocase () -- tells agda no cases to consider {- Justification of this rule is same as justification of existence of an empty function from the empty set into an arbitrary set. Since the empty set has no elements there is nothing to define; it is definition by no cases. Recall the explanation on page 16 when we used the notation (). -} -- In constructive logic -- - proving negation of a proposition is the same as -- - proving the proposition leads to absurdity: Not : Set -> Set Not A = A -> False {- BHK-interpretation says an implication is proved by providing a method for transforming a proof of A into a proof of B. When Brouwer pioneered this 100 years ago, there were no computers and no models of computation. In contemporary constructive mathematics in general, and in Martin-Löf type theory in particular, a “method” is usually understood as a computable function (or computer program) which transforms proofs. Implication is defined as function space. Emphasized via new notation: -} _==>_ : (A B : Set) -> Set A ==> B = A -> B _ : False ==> False -- T _ = λ () _ : False ==> True -- T _ = λ () _ : True ==> False -- F _ = λ _ → {!!} _ : True ==> True -- T _ = λ _ → <> {- Above def not accepted in Martin-Löf’s version of propositions-as-sets. Because each proposition should be defined by stating what its canonical proofs are. A canonical proof should always begin with a constructor. A function in A -> B does not, unless one considers the lambda-sign as a constructor. Instead, Martin-Löf defines implication as a set with one constructor: Using this, a canonical proof of A ==>' B always begins with the constructor fun. -} data _==>'_ (A B : Set) : Set where fun : (A -> B) -> A ==>' B -- rule of ==>-elimination (modus ponens) apply : {A B : Set} -> A ==>' B -> A -> B apply (fun f) a = f a -- equivalence of propositions _<==>_ : Set -> Set -> Set A <==> B = (A ==> B) & (B ==> A) _ : False <==> False _ = < ( λ () ) , ( λ () ) > _ : False <==> True _ = < (λ () ) , (λ { <> → {!!}}) > _ : True <==> False _ = < (λ { <> → {!!}}) , (λ () ) > _ : True <==> True _ = < (λ _ → <>) , (λ _ → <>) > {- Exercise/TODO: Prove your favourite tautology from propositional logic. Beware that you will not be able to prove the law of the excluded middle A \/ Not A. This is a consequence of the definition of disjunction, can you explain why?. The law of the excluded middle is not available in intuitonistic logic, only in classical logic. -} le : ∀ {P Q : Set} → (P ==> Q) <==> (Not P \/ Q) le {P} {Q} = < (λ {P==>Q → {!!} }) , (λ { (inl NotP) p → {!!} ; (inr q) p → q}) >
{ "alphanum_fraction": 0.6260099181, "avg_line_length": 34.055028463, "ext": "agda", "hexsha": "5814a9b79dd221233e777abc8b5205472d162aa3", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/paper/2009-Dependent_Types_at_Work-Bove_and_Dybjer/x01.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/paper/2009-Dependent_Types_at_Work-Bove_and_Dybjer/x01.agda", "max_line_length": 107, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/paper/2009-Dependent_Types_at_Work-Bove_and_Dybjer/x01.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 10780, "size": 35894 }
{-# OPTIONS --safe --warning=error #-} open import Sets.EquivalenceRelations open import Functions.Definition open import Agda.Primitive using (Level; lzero; lsuc; _⊔_; Setω) open import Setoids.Setoids open import Groups.Definition open import LogicalFormulae open import Orders.WellFounded.Definition open import Numbers.Naturals.Semiring open import Groups.Lemmas module Groups.FreeProduct.Addition {i : _} {I : Set i} (decidableIndex : (x y : I) → ((x ≡ y) || ((x ≡ y) → False))) {a b : _} {A : I → Set a} {S : (i : I) → Setoid {a} {b} (A i)} {_+_ : (i : I) → (A i) → (A i) → A i} (decidableGroups : (i : I) → (x y : A i) → ((Setoid._∼_ (S i) x y)) || ((Setoid._∼_ (S i) x y) → False)) (G : (i : I) → Group (S i) (_+_ i)) where open import Groups.FreeProduct.Definition decidableIndex decidableGroups G open import Groups.FreeProduct.Setoid decidableIndex decidableGroups G prependEqual : (i : I) (g : A i) .(nonZero : (Setoid._∼_ (S i) g (Group.0G (G i))) → False) → (j : I) → i ≡ j → (w : ReducedSequenceBeginningWith j) → ReducedSequence prependEqual i g nonzero .i refl (ofEmpty .i h nonZero) with decidableGroups i (_+_ i g h) (Group.0G (G i)) prependEqual i g nonzero .i refl (ofEmpty .i h nonZero) | inl sumZero = empty prependEqual i g nonzero .i refl (ofEmpty .i h nonZero) | inr sumNotZero = nonempty i (ofEmpty i (_+_ i g h) sumNotZero) prependEqual i g nonzero .i refl (prependLetter .i h nonZero x x₁) with decidableGroups i (_+_ i g h) (Group.0G (G i)) prependEqual i g nonzero .i refl (prependLetter .i h nonZero {j} x x₁) | inl sumZero = nonempty j x prependEqual i g nonzero .i refl (prependLetter .i h nonZero x pr) | inr sumNotZero = nonempty i (prependLetter i (_+_ i g h) sumNotZero x pr) prepend : (i : I) → (g : A i) → .(nonZero : (Setoid._∼_ (S i) g (Group.0G (G i))) → False) → ReducedSequence → ReducedSequence prepend i g nonzero empty = nonempty i (ofEmpty i g nonzero) prepend i g nonzero (nonempty j x) with decidableIndex i j prepend i g nonzero (nonempty j w) | inl i=j = prependEqual i g nonzero j i=j w prepend i g nonzero (nonempty j x) | inr i!=j = nonempty i (prependLetter i g nonzero x i!=j) plus' : {j : _} → (ReducedSequenceBeginningWith j) → ReducedSequence → ReducedSequence plus' (ofEmpty i g nonZero) s = prepend i g nonZero s plus' (prependLetter i g nonZero x pr) s = prepend i g nonZero (plus' x s) _+RP_ : ReducedSequence → ReducedSequence → ReducedSequence empty +RP b = b nonempty i x +RP b = plus' x b abstract prependWD : {i : I} → (g1 g2 : A i) → .(nz1 : _) → .(nz2 : _) → (y : ReducedSequence) (eq : Setoid._∼_ (S i) g1 g2) → prepend i g1 nz1 y =RP prepend i g2 nz2 y prependWD {i} g1 g2 nz1 nz2 empty g1=g2 with decidableIndex i i prependWD {i} g1 g2 nz1 nz2 empty g1=g2 | inl refl = g1=g2 prependWD {i} g1 g2 nz1 nz2 empty g1=g2 | inr x = exFalso (x refl) prependWD {i} g1 g2 nz1 nz2 (nonempty j x) g1=g2 with decidableIndex i j prependWD {.j} g1 g2 nz1 nz2 (nonempty j (ofEmpty .j g nonZero)) g1=g2 | inl refl with decidableGroups j ((j + g1) g) (Group.0G (G j)) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (ofEmpty .j g nonZero)) g1=g2 | inl refl | inl x with decidableGroups j ((j + g2) g) (Group.0G (G j)) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (ofEmpty .j g nonZero)) g1=g2 | inl refl | inl x | inl x₁ = record {} prependWD {.j} g1 g2 nz1 nz2 (nonempty j (ofEmpty .j g nonZero)) g1=g2 | inl refl | inl x | inr bad = exFalso (bad (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) (Equivalence.symmetric (Setoid.eq (S j)) g1=g2) (Equivalence.reflexive (Setoid.eq (S j)))) x)) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (ofEmpty .j g nonZero)) g1=g2 | inl refl | inr x with decidableGroups j ((j + g2) g) (Group.0G (G j)) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (ofEmpty .j g nonZero)) g1=g2 | inl refl | inr bad | inl p = exFalso (bad (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) g1=g2 (Equivalence.reflexive (Setoid.eq (S j)))) p)) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (ofEmpty .j g nonZero)) g1=g2 | inl refl | inr x | inr x₁ with decidableIndex j j prependWD {.j} g1 g2 nz1 nz2 (nonempty j (ofEmpty .j g nonZero)) g1=g2 | inl refl | inr x | inr x₁ | inl refl = Group.+WellDefined (G j) g1=g2 (Equivalence.reflexive (Setoid.eq (S j))) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (ofEmpty .j g nonZero)) g1=g2 | inl refl | inr x | inr x₁ | inr bad = exFalso (bad refl) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (prependLetter .j g nonZero w x₁)) g1=g2 | inl refl with decidableGroups j ((j + g1) g) (Group.0G (G j)) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (prependLetter .j g nonZero w x₁)) g1=g2 | inl refl | inl x with decidableGroups j ((j + g2) g) (Group.0G (G j)) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (prependLetter .j g nonZero w x₁)) g1=g2 | inl refl | inl x | inl x₂ = =RP'reflex w prependWD {.j} g1 g2 nz1 nz2 (nonempty j (prependLetter .j g nonZero w x₁)) g1=g2 | inl refl | inl x | inr bad = exFalso (bad (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) (Equivalence.symmetric (Setoid.eq (S j)) g1=g2) (Equivalence.reflexive (Setoid.eq (S j)))) x)) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (prependLetter .j g nonZero w x₁)) g1=g2 | inl refl | inr neq with decidableGroups j ((j + g2) g) (Group.0G (G j)) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (prependLetter .j g nonZero w x₁)) g1=g2 | inl refl | inr neq | inl x = exFalso (neq (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) g1=g2 (Equivalence.reflexive (Setoid.eq (S j)))) x)) prependWD {.j} g1 g2 nz1 nz2 (nonempty j (prependLetter .j g nonZero w x₁)) g1=g2 | inl refl | inr neq | inr x with decidableIndex j j prependWD {.j} g1 g2 nz1 nz2 (nonempty j (prependLetter .j g nonZero w x₁)) g1=g2 | inl refl | inr neq | inr x | inl refl = Group.+WellDefined (G j) g1=g2 (Equivalence.reflexive (Setoid.eq (S j))) ,, =RP'reflex w prependWD {.j} g1 g2 nz1 nz2 (nonempty j (prependLetter .j g nonZero w x₁)) g1=g2 | inl refl | inr neq | inr x | inr bad = exFalso (bad refl) prependWD {i} g1 g2 nz1 nz2 (nonempty j x) g1=g2 | inr i!=j with decidableIndex i i prependWD {i} g1 g2 nz1 nz2 (nonempty j x) g1=g2 | inr i!=j | inl refl = g1=g2 ,, =RP'reflex x prependWD {i} g1 g2 nz1 nz2 (nonempty j x) g1=g2 | inr i!=j | inr bad = exFalso (bad refl) abstract prependWD' : {i : I} → (g : A i) → .(nz : _) → (y1 y2 : ReducedSequence) (eq : y1 =RP y2) → prepend i g nz y1 =RP prepend i g nz y2 prependWD' {i} g1 nz empty empty eq with decidableIndex i i prependWD' {i} g1 nz empty empty eq | inl refl = Equivalence.reflexive (Setoid.eq (S i)) prependWD' {i} g1 nz empty empty eq | inr x = exFalso (x refl) prependWD' {i} g1 nz (nonempty j x) (nonempty k x₁) eq with decidableIndex i j prependWD' {.j} g1 nz (nonempty j w1) (nonempty k w2) eq | inl refl with decidableIndex j k prependWD' {.j} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty .j (ofEmpty .j h nonZero₁)) eq | inl refl | inl refl with decidableGroups j ((j + g1) g) (Group.0G (G j)) prependWD' {.j} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty .j (ofEmpty .j h nonZero₁)) eq | inl refl | inl refl | inl eq1 with decidableGroups j ((j + g1) h) (Group.0G (G j)) prependWD' {.j} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty .j (ofEmpty .j h nonZero₁)) eq | inl refl | inl refl | inl eq1 | inl x = record {} prependWD' {.j} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty .j (ofEmpty .j h nonZero₁)) eq | inl refl | inl refl | inl eq1 | inr x with decidableIndex j j prependWD' {.j} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty .j (ofEmpty .j h nonZero₁)) eq | inl refl | inl refl | inl eq1 | inr x | inl refl = exFalso (x (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) (Equivalence.symmetric (Setoid.eq (S j)) eq)) eq1)) prependWD' {.j} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty .j (ofEmpty .j h nonZero₁)) eq | inl refl | inl refl | inr neq1 with decidableGroups j ((j + g1) h) (Group.0G (G j)) prependWD' {.j} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty .j (ofEmpty .j h nonZero₁)) eq | inl refl | inl refl | inr neq1 | inl x with decidableIndex j j prependWD' {.j} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty .j (ofEmpty .j h nonZero₁)) eq | inl refl | inl refl | inr neq1 | inl x | inl refl = exFalso (neq1 (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) eq) x)) prependWD' {.j} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty .j (ofEmpty .j h nonZero₁)) eq | inl refl | inl refl | inr neq1 | inr x with decidableIndex j j prependWD' {.j} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty .j (ofEmpty .j h nonZero₁)) eq | inl refl | inl refl | inr neq1 | inr x | inl refl = Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) eq prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty .j (prependLetter .j h nonZero₁ w2 x₁)) eq | inl refl | inl refl with decidableIndex j j prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty .j (prependLetter .j h nonZero₁ w2 x₁)) eq | inl refl | inl refl | inl refl with decidableGroups j ((j + g1) g) (Group.0G (G j)) prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty .j (prependLetter .j h nonZero₁ w2 x₁)) eq | inl refl | inl refl | inl refl | inl eq1 with decidableGroups j ((j + g1) h) (Group.0G (G j)) prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty .j (prependLetter .j h nonZero₁ w2 x₁)) eq | inl refl | inl refl | inl refl | inl eq1 | inl eq2 = _&&_.snd eq prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty .j (prependLetter .j h nonZero₁ w2 x₁)) eq | inl refl | inl refl | inl refl | inl eq1 | inr neq2 = exFalso (neq2 (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) (Equivalence.symmetric (Setoid.eq (S j)) (_&&_.fst eq))) eq1)) prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty .j (prependLetter .j h nonZero₁ w2 x₁)) eq | inl refl | inl refl | inl refl | inr neq1 with decidableGroups j ((j + g1) h) (Group.0G (G j)) prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty .j (prependLetter .j h nonZero₁ w2 x₁)) eq | inl refl | inl refl | inl refl | inr neq1 | inl eq2 = exFalso (neq1 (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) (_&&_.fst eq)) eq2)) prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty .j (prependLetter .j h nonZero₁ w2 x₁)) eq | inl refl | inl refl | inl refl | inr neq1 | inr _ with decidableIndex j j prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty .j (prependLetter .j h nonZero₁ w2 x₁)) eq | inl refl | inl refl | inl refl | inr neq1 | inr _ | inl refl = Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) (_&&_.fst eq) ,, _&&_.snd eq prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty .j (prependLetter .j h nonZero₁ w2 x₁)) eq | inl refl | inl refl | inl refl | inr neq1 | inr _ | inr bad = exFalso (bad refl) prependWD' {.j} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty k (ofEmpty .k g₁ nonZero₁)) eq | inl refl | inr j!=k with decidableIndex j k prependWD' {j} g1 nz (nonempty j (ofEmpty j g nonZero)) (nonempty k (ofEmpty .k g₁ nonZero₁)) eq | inl refl | inr j!=k | inl j=k = exFalso (j!=k j=k) prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty k (prependLetter .k g₁ nonZero₁ w2 x₁)) eq | inl refl | inr j!=k with decidableIndex j k prependWD' {.j} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty k (prependLetter .k g₁ nonZero₁ w2 x₁)) eq | inl refl | inr j!=k | inl j=k = exFalso (j!=k j=k) prependWD' {i} g1 nz (nonempty j w1) (nonempty k w2) eq | inr i!=j with decidableIndex i k prependWD' {.k} g1 nz (nonempty j (ofEmpty .j g nonZero)) (nonempty k (ofEmpty .k g₁ nonZero₁)) eq | inr i!=j | inl refl with decidableIndex j k prependWD' {.k} g1 nz (nonempty .k (ofEmpty .k g nonZero)) (nonempty k (ofEmpty .k g₁ nonZero₁)) eq | inr i!=j | inl refl | inl refl = exFalso (i!=j refl) prependWD' {.k} g1 nz (nonempty j (prependLetter .j g nonZero w1 x)) (nonempty k (prependLetter .k g₁ nonZero₁ w2 x₁)) eq | inr i!=j | inl refl with decidableIndex j k prependWD' {.k} g1 nz (nonempty .k (prependLetter .k g nonZero w1 x)) (nonempty k (prependLetter .k g₁ nonZero₁ w2 x₁)) eq | inr i!=j | inl refl | inl refl = exFalso (i!=j refl) prependWD' {i} g1 nz (nonempty j w1) (nonempty k w2) eq | inr i!=j | inr i!=k with decidableIndex i i prependWD' {i} g1 nz (nonempty j w1) (nonempty k w2) eq | inr i!=j | inr i!=k | inl refl = Equivalence.reflexive (Setoid.eq (S i)) ,, eq prependWD' {i} g1 nz (nonempty j w1) (nonempty k w2) eq | inr i!=j | inr i!=k | inr x = exFalso (x refl) private prependLetterWD : {i : I} {h1 h2 : A i} (h1=h2 : Setoid._∼_ (S i) h1 h2) → .(nonZero1 : _) .(nonZero2 : _) {j1 j2 : I} (w1 : ReducedSequenceBeginningWith j1) (w2 : ReducedSequenceBeginningWith j2) → (eq : =RP' w1 w2) → (x1 : i ≡ _ → False) (x2 : i ≡ _ → False) → nonempty i (prependLetter i h1 nonZero1 w1 x1) =RP nonempty i (prependLetter i h2 nonZero2 w2 x2) prependLetterWD {i} h1=h2 nonZero1 nonZero2 {j1} {j2} w1 w2 eq x1 x2 with decidableIndex i i prependLetterWD {i} h1=h2 nonZero1 nonZero2 {j1} {j2} w1 w2 eq x1 x2 | inl refl = h1=h2 ,, eq prependLetterWD {i} h1=h2 nonZero1 nonZero2 {j1} {j2} w1 w2 eq x1 x2 | inr x = exFalso (x refl) abstract plus'WD' : {i : I} (x : ReducedSequenceBeginningWith i) (y1 y2 : ReducedSequence) → (y1 =RP y2) → plus' x y1 =RP plus' x y2 plus'WD' x empty empty eq = Equivalence.reflexive (Setoid.eq freeProductSetoid) {plus' x empty} plus'WD' {j} (ofEmpty j g nonZero) (nonempty i1 w1) (nonempty i2 w2) eq with decidableIndex j i1 plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j w1) (nonempty i2 w2) eq | inl refl with decidableIndex j i2 plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j g₁ nonZero₁)) (nonempty .j (ofEmpty .j g₂ nonZero₂)) eq | inl refl | inl refl with decidableIndex j j plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j h1 nonZero₁)) (nonempty .j (ofEmpty .j h2 nonZero₂)) eq | inl refl | inl refl | inl refl with decidableGroups j ((j + g) h1) (Group.0G (G j)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j h1 nonZero₁)) (nonempty .j (ofEmpty .j h2 nonZero₂)) eq | inl refl | inl refl | inl refl | inl x with decidableGroups j ((j + g) h2) (Group.0G (G j)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j h1 nonZero₁)) (nonempty .j (ofEmpty .j h2 nonZero₂)) eq | inl refl | inl refl | inl refl | inl x | inl x₁ = record {} plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j h1 nonZero₁)) (nonempty .j (ofEmpty .j h2 nonZero₂)) eq | inl refl | inl refl | inl refl | inl x | inr bad = exFalso (bad (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) (Equivalence.symmetric (Setoid.eq (S j)) eq)) x)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j h1 nonZero₁)) (nonempty .j (ofEmpty .j h2 nonZero₂)) eq | inl refl | inl refl | inl refl | inr x with decidableGroups j ((j + g) h2) (Group.0G (G j)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j h1 nonZero₁)) (nonempty .j (ofEmpty .j h2 nonZero₂)) eq | inl refl | inl refl | inl refl | inr x | inl bad = exFalso (x (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) eq) bad)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j h1 nonZero₁)) (nonempty .j (ofEmpty .j h2 nonZero₂)) eq | inl refl | inl refl | inl refl | inr x | inr x₁ with decidableIndex j j plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j h1 nonZero₁)) (nonempty .j (ofEmpty .j h2 nonZero₂)) eq | inl refl | inl refl | inl refl | inr x | inr x₁ | inl refl = Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) eq plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j h1 nonZero₁)) (nonempty .j (ofEmpty .j h2 nonZero₂)) eq | inl refl | inl refl | inl refl | inr x | inr x₁ | inr bad = exFalso (bad refl) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (prependLetter .j h1 nonZero₁ w1 x)) (nonempty .j (prependLetter .j h2 nonZero₂ w2 x₁)) eq | inl refl | inl refl with decidableGroups j ((j + g) h1) (Group.0G (G j)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (prependLetter .j h1 nonZero₁ w1 x)) (nonempty .j (prependLetter .j h2 nonZero₂ w2 x₁)) eq | inl refl | inl refl | inl eq1 with decidableGroups j ((j + g) h2) (Group.0G (G j)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (prependLetter .j h1 nonZero₁ w1 x)) (nonempty .j (prependLetter .j h2 nonZero₂ w2 x₁)) eq | inl refl | inl refl | inl eq1 | inl x₂ with decidableIndex j j plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (prependLetter .j h1 nonZero₁ w1 x)) (nonempty .j (prependLetter .j h2 nonZero₂ w2 x₁)) eq | inl refl | inl refl | inl eq1 | inl x₂ | inl refl = _&&_.snd eq plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (prependLetter .j h1 nonZero₁ w1 x)) (nonempty .j (prependLetter .j h2 nonZero₂ w2 x₁)) eq | inl refl | inl refl | inl eq1 | inr neq2 with decidableIndex j j ... | inl refl = exFalso (neq2 (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) (Equivalence.symmetric (Setoid.eq (S j)) (_&&_.fst eq))) eq1)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (prependLetter .j h1 nonZero₁ w1 x)) (nonempty .j (prependLetter .j h2 nonZero₂ w2 x₁)) eq | inl refl | inl refl | inr neq1 with decidableGroups j ((j + g) h2) (Group.0G (G j)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (prependLetter .j h1 nonZero₁ w1 x)) (nonempty .j (prependLetter .j h2 nonZero₂ w2 x₁)) eq | inl refl | inl refl | inr neq1 | inl eq2 with decidableIndex j j ... | inl refl = exFalso (neq1 (Equivalence.transitive (Setoid.eq (S j)) (Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) (_&&_.fst eq)) eq2)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (prependLetter .j h1 nonZero₁ w1 x)) (nonempty .j (prependLetter .j h2 nonZero₂ w2 x₁)) eq | inl refl | inl refl | inr neq1 | inr x₂ with decidableIndex j j ... | inl refl = Group.+WellDefined (G j) (Equivalence.reflexive (Setoid.eq (S j))) (_&&_.fst eq) ,, _&&_.snd eq plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j g₁ nonZero₁)) (nonempty i2 (ofEmpty .i2 g₂ nonZero₂)) eq | inl refl | inr x with decidableIndex j i2 plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (ofEmpty .j g₁ nonZero₁)) (nonempty .j (ofEmpty .j g₂ nonZero₂)) eq | inl refl | inr x | inl refl = exFalso (x refl) plus'WD' {j} (ofEmpty j g nonZero) (nonempty .j (prependLetter .j g₁ nonZero₁ w1 x₁)) (nonempty i2 (prependLetter .i2 g₂ nonZero₂ w2 x₂)) eq | inl refl | inr x with decidableIndex j i2 plus'WD' {.i2} (ofEmpty .i2 g nonZero) (nonempty .i2 (prependLetter .i2 g₁ nonZero₁ w1 x₁)) (nonempty i2 (prependLetter .i2 g₂ nonZero₂ w2 x₂)) eq | inl refl | inr x | inl refl = exFalso (x refl) plus'WD' {j} (ofEmpty j g nonZero) (nonempty i1 w1) (nonempty i2 w2) eq | inr j!=i1 with decidableIndex j i2 plus'WD' {j} (ofEmpty j g nonZero) (nonempty i1 (ofEmpty .i1 g₁ nonZero₁)) (nonempty .j (ofEmpty .j g₂ nonZero₂)) eq | inr j!=i1 | inl refl with decidableIndex i1 j plus'WD' {j} (ofEmpty j g nonZero) (nonempty i1 (ofEmpty .i1 g₁ nonZero₁)) (nonempty .j (ofEmpty .j g₂ nonZero₂)) eq | inr j!=i1 | inl refl | inl x = exFalso (j!=i1 (equalityCommutative x)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty i1 (prependLetter .i1 g₁ nonZero₁ w1 x)) (nonempty .j (prependLetter .j g₂ nonZero₂ w2 x₁)) eq | inr j!=i1 | inl refl with decidableIndex i1 j ... | inl bad = exFalso (j!=i1 (equalityCommutative bad)) plus'WD' {j} (ofEmpty j g nonZero) (nonempty i1 w1) (nonempty i2 w2) eq | inr j!=i1 | inr j!=i2 with decidableIndex j j plus'WD' {j} (ofEmpty j g nonZero) (nonempty i1 w1) (nonempty i2 w2) eq | inr j!=i1 | inr j!=i2 | inl refl = Equivalence.reflexive (Setoid.eq (S j)) ,, eq plus'WD' {j} (ofEmpty j g nonZero) (nonempty i1 w1) (nonempty i2 w2) eq | inr j!=i1 | inr j!=i2 | inr x = exFalso (x refl) plus'WD' {j} (prependLetter j g nonZero l x) (nonempty i (ofEmpty .i h1 nonZero1)) (nonempty i2 (ofEmpty .i2 h2 nonZero2)) eq with decidableIndex i i2 ... | inl refl = prependWD' g nonZero (plus' l (nonempty i (ofEmpty i h1 nonZero1))) (plus' l (nonempty i2 (ofEmpty i2 h2 nonZero2))) (plus'WD' l (nonempty i2 (ofEmpty i2 h1 nonZero1)) (nonempty i2 (ofEmpty i2 h2 nonZero2)) t) where t : =RP' (ofEmpty i2 h1 nonZero1) (ofEmpty i2 h2 nonZero2) t with decidableIndex i2 i2 t | inl refl = eq t | inr x = exFalso (x refl) ... | inr i!=i2 = exFalso' eq plus'WD' {j} (prependLetter j g nonZero l x) (nonempty i (prependLetter .i g₁ nonZero₁ w1 x₁)) (nonempty i2 (prependLetter .i2 g₂ nonZero₂ w2 x₂)) eq with decidableIndex i i2 plus'WD' {j} (prependLetter j g nonZero l x) (nonempty i (prependLetter .i h1 nonZero1 w1 x1)) (nonempty .i (prependLetter .i h2 nonZero2 w2 x2)) eq | inl refl = prependWD' g nonZero (plus' l (nonempty i (prependLetter i h1 nonZero1 w1 x1))) (plus' l (nonempty i (prependLetter i h2 nonZero2 w2 x2))) (plus'WD' l (nonempty i (prependLetter i h1 nonZero1 w1 x1)) (nonempty i (prependLetter i h2 nonZero2 w2 x2)) (prependLetterWD (_&&_.fst eq) nonZero1 nonZero2 w1 w2 (_&&_.snd eq) x1 x2)) abstract plusEmptyRight : {i : I} (x : ReducedSequenceBeginningWith i) → _=RP_ (plus' x empty) (nonempty i x) plusEmptyRight (ofEmpty i g nonZero) with decidableIndex i i plusEmptyRight (ofEmpty i g nonZero) | inl refl = Equivalence.reflexive (Setoid.eq (S i)) plusEmptyRight (ofEmpty i g nonZero) | inr x = exFalso (x refl) plusEmptyRight (prependLetter i g nonZero {j} x i!=j) with plusEmptyRight x ... | b with plus' x empty plusEmptyRight (prependLetter i g nonZero {j} x i!=j) | b | nonempty k w with decidableIndex i k plusEmptyRight (prependLetter .k g nonZero {j} x i!=j) | b | nonempty k (ofEmpty .k h nonZero₁) | inl refl with decidableGroups k ((k + g) h) (Group.0G (G k)) plusEmptyRight (prependLetter .k g nonZero {.i} (ofEmpty i g₁ nonZero₂) i!=j) | b | nonempty k (ofEmpty .k h nonZero₁) | inl refl | inl g+k=hinv with decidableIndex k i plusEmptyRight (prependLetter .i g nonZero {.i} (ofEmpty i g₁ nonZero₂) i!=j) | b | nonempty .i (ofEmpty .i h nonZero₁) | inl refl | inl g+k=hinv | inl refl = exFalso (i!=j refl) plusEmptyRight (prependLetter .k g nonZero {.i} (ofEmpty i g₁ nonZero₂) i!=j) | b | nonempty k (ofEmpty .k h nonZero₁) | inl refl | inr x₁ with decidableIndex k i plusEmptyRight (prependLetter .i g nonZero {.i} (ofEmpty i g₁ nonZero₂) i!=j) | b | nonempty .i (ofEmpty .i h nonZero₁) | inl refl | inr x₁ | inl refl = exFalso (i!=j refl) plusEmptyRight (prependLetter .k g nonZero {j} w1 i!=j) | b | nonempty k (prependLetter .k h nonZero₁ w x₁) | inl refl with decidableGroups k ((k + g) h) (Group.0G (G k)) plusEmptyRight (prependLetter .k g nonZero {.i} (prependLetter i g₁ nonZero₂ w1 x) i!=j) | b | nonempty k (prependLetter .k h nonZero₁ w x₁) | inl refl | inl p with decidableIndex k i plusEmptyRight (prependLetter .i g nonZero {.i} (prependLetter i g₁ nonZero₂ w1 x) i!=j) | b | nonempty .i (prependLetter .i h nonZero₁ w x₁) | inl refl | inl p | inl refl = exFalso (i!=j refl) plusEmptyRight (prependLetter .k g nonZero {j} w1 i!=j) | b | nonempty k (prependLetter .k h nonZero₁ w x₁) | inl refl | inr x₂ with decidableIndex k k plusEmptyRight (prependLetter .k g nonZero {.i} (prependLetter i g₁ nonZero₂ w1 x) i!=j) | b | nonempty k (prependLetter .k h nonZero₁ w x₁) | inl refl | inr x₂ | inl refl with decidableIndex k i plusEmptyRight (prependLetter .i g nonZero {.i} (prependLetter i g₁ nonZero₂ w1 x) i!=j) | b | nonempty .i (prependLetter .i h nonZero₁ w x₁) | inl refl | inr x₂ | inl refl | inl refl = exFalso (i!=j refl) plusEmptyRight (prependLetter .k g nonZero {j} w1 i!=j) | b | nonempty k (prependLetter .k h nonZero₁ w x₁) | inl refl | inr x₂ | inr x = exFalso (x refl) plusEmptyRight (prependLetter i g nonZero {j} w1 i!=j) | b | nonempty k w | inr i!=k with decidableIndex i i plusEmptyRight (prependLetter i g nonZero {j} w1 i!=j) | b | nonempty k w | inr i!=k | inl refl = Equivalence.reflexive (Setoid.eq (S i)) ,, b plusEmptyRight (prependLetter i g nonZero {j} w1 i!=j) | b | nonempty k w | inr i!=k | inr x = exFalso (x refl) abstract prependFrom : {i : I} (g1 g2 : A i) (pr : (Setoid._∼_ (S i) (_+_ i g1 g2) (Group.0G (G i))) → False) (c : ReducedSequence) .(p2 : _) .(p3 : _) → prepend i (_+_ i g1 g2) pr c =RP prepend i g1 p2 (prepend i g2 p3 c) prependFrom {i} g1 g2 pr empty _ _ with decidableIndex i i prependFrom {i} g1 g2 pr empty _ _ | inl refl with decidableGroups i ((i + g1) g2) (Group.0G (G i)) prependFrom {i} g1 g2 pr empty _ _ | inl refl | inl bad = exFalso (pr bad) prependFrom {i} g1 g2 pr empty _ _ | inl refl | inr _ with decidableIndex i i prependFrom {i} g1 g2 pr empty _ _ | inl refl | inr _ | inl refl = Equivalence.reflexive (Setoid.eq (S i)) prependFrom {i} g1 g2 pr empty _ _ | inl refl | inr _ | inr bad = exFalso (bad refl) prependFrom {i} g1 g2 pr empty _ _ | inr bad = exFalso (bad refl) prependFrom {i} g1 g2 pr (nonempty j x) _ _ with decidableIndex i j prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl with decidableGroups j ((j + (j + g1) g2) g) (Group.0G (G j)) prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inl eq with decidableGroups j ((j + g2) g) (Group.0G (G j)) prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) g1Nonzero _ | inl refl | inl eq3 | inl eq2 = exFalso (g1Nonzero t) where open Setoid (S j) open Group (G j) open Equivalence eq t : g1 ∼ 0G t = transitive (symmetric identRight) (transitive (+WellDefined reflexive (symmetric eq2)) (transitive +Associative eq3)) prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inl eq | inr neq with decidableIndex j j prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inl eq | inr neq | inl refl with decidableGroups j ((j + g1) ((j + g2) g)) (Group.0G (G j)) prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inl eq | inr neq | inl refl | inl eq2 = record {} prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inl eq | inr neq | inl refl | inr neq2 = exFalso (neq2 (Equivalence.transitive (Setoid.eq (S j)) (Group.+Associative (G j)) eq)) prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inl eq | inr neq | inr bad = exFalso (bad refl) prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inr neq with decidableGroups j ((j + g2) g) (Group.0G (G j)) prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inr neq | inl eq2 with decidableIndex j j prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inr neq | inl eq2 | inl refl = transitive (symmetric +Associative) (transitive (+WellDefined reflexive eq2) identRight) where open Setoid (S j) open Group (G j) open Equivalence eq prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inr neq | inl eq2 | inr bad = exFalso (bad refl) prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inr neq | inr neq2 with decidableIndex j j prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inr neq | inr neq2 | inl refl with decidableGroups j ((j + g1) ((j + g2) g)) (Group.0G (G j)) prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inr neq | inr neq2 | inl refl | inl eq2 = exFalso (neq (Equivalence.transitive (Setoid.eq (S j)) (Equivalence.symmetric (Setoid.eq (S j)) (Group.+Associative (G j))) eq2)) prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inr neq | inr neq2 | inl refl | inr neq3 with decidableIndex j j ... | inl refl = Equivalence.symmetric (Setoid.eq (S j)) (Group.+Associative (G j)) ... | inr bad = exFalso (bad refl) prependFrom {.j} g1 g2 pr (nonempty _ (ofEmpty j g nonZero)) _ _ | inl refl | inr neq | inr neq2 | inr bad = exFalso (bad refl) prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl with decidableGroups j ((j + (j + g1) g2) g) (Group.0G (G j)) prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inl eq1 with decidableGroups j ((j + g2) g) (Group.0G (G j)) prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero {k} x x₁)) p2 _ | inl refl | inl eq1 | inl eq2 = exFalso (p2 (transitive (transitive (symmetric identRight) (transitive (+WellDefined reflexive (symmetric eq2)) +Associative)) eq1)) where open Setoid (S j) open Group (G j) open Equivalence eq prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inl eq1 | inr neq with decidableIndex j j prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inl eq1 | inr neq | inl refl with decidableGroups j ((j + g1) ((j + g2) g)) (Group.0G (G j)) prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inl eq1 | inr neq | inl refl | inl eq2 = =RP'reflex x prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inl eq1 | inr neq | inl refl | inr neq2 = exFalso (neq2 (Equivalence.transitive (Setoid.eq (S j)) (Group.+Associative (G j)) eq1)) prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inl eq1 | inr neq | inr bad = exFalso (bad refl) prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inr neq1 with decidableGroups j ((j + g2) g) (Group.0G (G j)) prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero {k} x x₁)) _ _ | inl refl | inr neq1 | inl eq1 with decidableIndex j k prependFrom {j} g1 g2 pr (nonempty _ (prependLetter _ g nonZero {_} (ofEmpty _ h nonZero₁) bad)) _ _ | inl refl | inr neq1 | inl eq1 | inl refl = exFalso (bad refl) prependFrom {_} g1 g2 pr (nonempty _ (prependLetter _ g nonZero {_} (prependLetter _ g₁ nonZero₁ x x₂) bad)) _ _ | inl refl | inr neq1 | inl eq1 | inl refl = exFalso (bad refl) prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero {k} x x₁)) _ _ | inl refl | inr neq1 | inl eq1 | inr j!=k with decidableIndex j j ... | inl refl = transitive (symmetric +Associative) (transitive (+WellDefined reflexive eq1) identRight) ,, =RP'reflex x where open Setoid (S j) open Group (G j) open Equivalence eq ... | inr bad = exFalso (bad refl) prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inr neq1 | inr neq2 with decidableIndex j j prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inr neq1 | inr neq2 | inl refl with decidableGroups j ((j + g1) ((j + g2) g)) (Group.0G (G j)) prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inr neq1 | inr neq2 | inl refl | inl eq1 = exFalso (neq1 (transitive (symmetric +Associative) eq1)) where open Setoid (S j) open Group (G j) open Equivalence eq prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inr neq1 | inr neq2 | inl refl | inr neq3 with decidableIndex j j ... | inl refl = Equivalence.symmetric (Setoid.eq (S j)) (Group.+Associative (G j)) ,, =RP'reflex x ... | inr bad = exFalso (bad refl) prependFrom {.j} g1 g2 pr (nonempty _ (prependLetter j g nonZero x x₁)) _ _ | inl refl | inr neq1 | inr neq2 | inr bad = exFalso (bad refl) prependFrom {i} g1 g2 pr (nonempty j x) _ _ | inr i!=j with decidableIndex i i prependFrom {i} g1 g2 pr (nonempty j x) _ _ | inr i!=j | inl refl with decidableGroups i ((i + g1) g2) (Group.0G (G i)) prependFrom {i} g1 g2 pr (nonempty j x) _ _ | inr i!=j | inl refl | inl eq1 = exFalso (pr eq1) prependFrom {i} g1 g2 pr (nonempty j x) _ _ | inr i!=j | inl refl | inr neq1 with decidableIndex i i prependFrom {i} g1 g2 pr (nonempty j x) _ _ | inr i!=j | inl refl | inr neq1 | inl refl = Equivalence.reflexive (Setoid.eq (S i)) ,, =RP'reflex x prependFrom {i} g1 g2 pr (nonempty j x) _ _ | inr i!=j | inl refl | inr neq1 | inr bad = exFalso (bad refl) prependFrom {i} g1 g2 pr (nonempty j x) _ _ | inr i!=j | inr bad = exFalso (bad refl) prependFrom' : {i : I} (g h : A i) (pr : (Setoid._∼_ (S i) (_+_ i g h) (Group.0G (G i)))) (c : ReducedSequence) .(p2 : _) .(p3 : _) → prepend i g p2 (prepend i h p3 c) =RP c prependFrom' {i} g h pr empty _ _ with decidableIndex i i prependFrom' {i} g h pr empty _ _ | inl refl with decidableGroups i ((i + g) h) (Group.0G (G i)) ... | inl _ = record {} ... | inr bad = exFalso (bad pr) prependFrom' {i} g h pr empty _ _ | inr bad = exFalso (bad refl) prependFrom' {i} g h pr (nonempty j x) _ _ with decidableIndex i j prependFrom' {.j} g h pr (nonempty j (ofEmpty .j g1 nonZero)) _ _ | inl refl with decidableGroups j ((j + h) g1) (Group.0G (G j)) prependFrom' {.j} g h pr (nonempty j (ofEmpty .j g1 nonZero)) _ _ | inl refl | inl eq1 with decidableIndex j j prependFrom' {.j} g h pr (nonempty j (ofEmpty .j g1 nonZero)) _ _ | inl refl | inl eq1 | inl refl = transitive t (symmetric u) where open Setoid (S j) open Equivalence eq t : Setoid._∼_ (S j) g (Group.inverse (G j) h) t = rightInversesAreUnique (G j) pr u : Setoid._∼_ (S j) g1 (Group.inverse (G j) h) u = leftInversesAreUnique (G j) eq1 prependFrom' {.j} g h pr (nonempty j (ofEmpty .j g1 nonZero)) _ _ | inl refl | inl eq1 | inr bad = exFalso (bad refl) prependFrom' {.j} g h pr (nonempty j (ofEmpty .j g1 nonZero)) _ _ | inl refl | inr neq with decidableIndex j j prependFrom' {.j} g h pr (nonempty j (ofEmpty .j g1 nonZero)) p2 _ | inl refl | inr neq | inl refl with decidableGroups j ((j + g) ((j + h) g1)) (Group.0G (G j)) ... | inl eq1 = exFalso (nonZero t) where open Setoid (S j) open Equivalence eq open Group (G j) t : g1 ∼ 0G t = transitive (transitive (symmetric identLeft) (transitive (+WellDefined (symmetric pr) reflexive) (symmetric +Associative))) eq1 prependFrom' {.j} g h pr (nonempty j (ofEmpty .j g1 nonZero)) _ _ | inl refl | inr neq | inl refl | inr neq2 with decidableIndex j j ... | inl refl = transitive (transitive +Associative (+WellDefined pr reflexive)) identLeft where open Setoid (S j) open Equivalence eq open Group (G j) ... | inr bad = exFalso (bad refl) prependFrom' {.j} g h pr (nonempty j (ofEmpty .j g1 nonZero)) _ _ | inl refl | inr neq | inr bad = exFalso (bad refl) prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero x x₁)) _ _ | inl refl with decidableGroups j ((j + h) g1) (Group.0G (G j)) prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x bad)) _ _ | inl refl | inl eq1 with decidableIndex j k prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x bad)) _ _ | inl refl | inl eq1 | inl j=k = exFalso (bad j=k) prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x bad)) _ _ | inl refl | inl eq1 | inr j!=k with decidableIndex j j prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x bad)) _ _ | inl refl | inl eq1 | inr j!=k | inl refl = transitive {g} {inverse h} (rightInversesAreUnique (G j) pr) (symmetric (leftInversesAreUnique (G j) eq1)) ,, =RP'reflex x where open Setoid (S j) open Equivalence eq open Group (G j) prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x _)) _ _ | inl refl | inl eq1 | inr j!=k | inr bad = exFalso (bad refl) prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x x₁)) _ _ | inl refl | inr neq1 with decidableIndex j j prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x x₁)) _ _ | inl refl | inr neq1 | inl refl with decidableGroups j ((j + g) ((j + h) g1)) (Group.0G (G j)) prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x x₁)) _ _ | inl refl | inr neq1 | inl refl | inl eq1 = exFalso (nonZero (transitive (transitive (symmetric identLeft) (transitive (+WellDefined (symmetric pr) reflexive) (symmetric +Associative))) eq1)) where open Setoid (S j) open Equivalence eq open Group (G j) prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x x₁)) _ _ | inl refl | inr neq1 | inl refl | inr neq2 with decidableIndex j j prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x x₁)) _ _ | inl refl | inr neq1 | inl refl | inr neq2 | inl refl = transitive +Associative (transitive (+WellDefined pr reflexive) identLeft) ,, =RP'reflex x where open Setoid (S j) open Equivalence eq open Group (G j) prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x x₁)) _ _ | inl refl | inr neq1 | inl refl | inr neq2 | inr bad = exFalso (bad refl) prependFrom' {.j} g h pr (nonempty j (prependLetter .j g1 nonZero {k} x x₁)) _ _ | inl refl | inr neq1 | inr bad = exFalso (bad refl) prependFrom' {i} g h pr (nonempty j x) _ _ | inr i!=j with decidableIndex i i prependFrom' {i} g h pr (nonempty j x) _ _ | inr i!=j | inl refl with decidableGroups i ((i + g) h) (Group.0G (G i)) prependFrom' {i} g h pr (nonempty j x) _ _ | inr i!=j | inl refl | inl eq1 = =RP'reflex x prependFrom' {i} g h pr (nonempty j x) _ _ | inr i!=j | inl refl | inr neq1 = exFalso (neq1 pr) prependFrom' {i} g h pr (nonempty j x) _ _ | inr i!=j | inr bad = exFalso (bad refl)
{ "alphanum_fraction": 0.6631415976, "avg_line_length": 114.0958083832, "ext": "agda", "hexsha": "7b88d5f94d79db66b7cde495d5a414808ac324fa", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Groups/FreeProduct/Addition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Groups/FreeProduct/Addition.agda", "max_line_length": 489, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Groups/FreeProduct/Addition.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": 14647, "size": 38108 }
-- Interface to standard library. module Library where open import Function public hiding (_∋_) open import Level public using (Level) renaming (zero to lzero; suc to lsuc) open import Size public open import Category.Monad public using (RawMonad; module RawMonad) open import Data.Empty public using (⊥; ⊥-elim) open import Data.List public using (List; []; _∷_; map) open import Data.Maybe public using (Maybe; just; nothing) renaming (map to fmap) open import Data.Nat public using (ℕ; zero; suc; _+_; _≟_) open import Data.Product public using (∃; _×_; _,_) renaming (proj₁ to fst; proj₂ to snd) --infixr 1 _,_ open import Data.Sum public using (_⊎_; [_,_]′) renaming (inj₁ to inl; inj₂ to inr) open import Data.Unit public using (⊤) open import Function public using (_∘_; flip; case_of_) renaming (id to idf) open import Relation.Nullary public using (Dec; yes; no) open import Relation.Binary public using (Setoid; module Setoid) import Relation.Binary.PreorderReasoning module Pre = Relation.Binary.PreorderReasoning open import Relation.Binary.PropositionalEquality public using ( _≡_; refl; sym; trans; cong; cong₂; subst; module ≡-Reasoning ; inspect; [_]) --open ≡-Reasoning renaming (begin_ to proof_) public open import Relation.Binary.HeterogeneousEquality public using (_≅_; refl; ≡-to-≅; module ≅-Reasoning) renaming (sym to hsym; trans to htrans; cong to hcong; cong₂ to hcong₂; subst to hsubst) {- hcong₃ : {A : Set} {B : A → Set} {C : ∀ a → B a → Set} {D : ∀ a b → C a b → Set} (f : ∀ a b c → D a b c) {a a' : A} → a ≅ a' → {b : B a}{b' : B a'} → b ≅ b' → {c : C a b}{c' : C a' b'} → c ≅ c' → f a b c ≅ f a' b' c' hcong₃ f refl refl refl = refl ≅-to-≡ : ∀ {a} {A : Set a} {x y : A} → x ≅ y → x ≡ y ≅-to-≡ refl = refl record Cat : Set1 where field Obj : Set Hom : Obj → Obj → Set iden : ∀{X} → Hom X X comp : ∀{X Y Z} → Hom Y Z → Hom X Y → Hom X Z idl : ∀{X Y}{f : Hom X Y} → comp iden f ≅ f idr : ∀{X Y}{f : Hom X Y} → comp f iden ≅ f ass : ∀{W X Y Z}{f : Hom Y Z}{g : Hom X Y}{h : Hom W X} → comp (comp f g) h ≅ comp f (comp g h) open Cat public record Fun (C D : Cat) : Set where open Cat field OMap : Obj C → Obj D HMap : ∀{X Y} → Hom C X Y → Hom D (OMap X) (OMap Y) fid : ∀{X} → HMap (iden C {X}) ≅ iden D {OMap X} fcomp : ∀{X Y Z}{f : Hom C Y Z}{g : Hom C X Y} → HMap (comp C f g) ≅ comp D (HMap f) (HMap g) open Fun public postulate ext : {A : Set}{B B' : A → Set}{f : ∀ a → B a}{g : ∀ a → B' a} → (∀ a → f a ≅ g a) → f ≅ g postulate iext : {A : Set}{B B' : A → Set} {f : ∀ {a} → B a}{g : ∀{a} → B' a} → (∀ a → f {a} ≅ g {a}) → _≅_ {_}{ {a : A} → B a} f { {a : A} → B' a} g -}
{ "alphanum_fraction": 0.5469387755, "avg_line_length": 28, "ext": "agda", "hexsha": "91b337f18cce88d8a08f8ebc352460499c65c4d3", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2018-02-23T18:22:17.000Z", "max_forks_repo_forks_event_min_datetime": "2017-11-10T16:44:52.000Z", "max_forks_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "ryanakca/strong-normalization", "max_forks_repo_path": "agda/Library.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_issues_repo_issues_event_max_datetime": "2018-02-20T14:54:18.000Z", "max_issues_repo_issues_event_min_datetime": "2018-02-14T16:42:36.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "ryanakca/strong-normalization", "max_issues_repo_path": "agda/Library.agda", "max_line_length": 74, "max_stars_count": 32, "max_stars_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "ryanakca/strong-normalization", "max_stars_repo_path": "agda/Library.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-05T12:12:03.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-22T14:33:27.000Z", "num_tokens": 1066, "size": 2940 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Universe.Base where
{ "alphanum_fraction": 0.7123287671, "avg_line_length": 24.3333333333, "ext": "agda", "hexsha": "c26fb0811fa4b5979f1a28f6c14f85872e01ba73", "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/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/Data/Universe/Base.agda", "max_line_length": 39, "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/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 18, "size": 73 }
open import Data.Product renaming (_,_ to _,,_) -- just to avoid clash with other commas open import Algebra.Structures using (IsSemigroup) open import Algebra.FunctionProperties using (LeftIdentity; Commutative) module Preliminaries where Rel : Set -> Set₁ Rel A = A -> A -> Set Entire : {A B : Set} -> (_R_ : A -> B -> Set) -> Set Entire _R_ = ∀ a -> ∃ \ b -> a R b fun : {A B : Set} -> {_R_ : A -> B -> Set} -> Entire _R_ -> A -> B fun ent a = proj₁ (ent a) correct : {A B : Set} -> {_R_ : A -> B -> Set} -> (ent : Entire _R_) -> let f = fun ent in ∀ {a : A} -> a R (f a) correct ent {a} = proj₂ (ent a) Entire3 : {A B C D : Set} -> (R : A -> B -> C -> D -> Set) -> Set Entire3 R = ∀ x y z -> ∃ (R x y z) fun3 : {A B C D : Set} -> {R : A -> B -> C -> D -> Set} -> Entire3 R -> A -> B -> C -> D fun3 ent a b c = proj₁ (ent a b c) correct3 : {A B C D : Set} -> {R : A -> B -> C -> D -> Set} -> (e : Entire3 R) -> ∀ {a : A} {b : B} {c : C} -> R a b c (fun3 e a b c) correct3 ent {a} {b} {c} = proj₂ (ent a b c) UniqueSolution : {A : Set} -> Rel A -> (A -> Set) -> Set UniqueSolution _≃_ P = ∀ {x y} -> P x -> P y -> x ≃ y LowerBound : {A : Set} -> Rel A -> (A -> Set) -> (A -> Set) LowerBound _≤_ P a = ∀ z -> (P z -> a ≤ z) Least : {A : Set} -> Rel A -> (A -> Set) -> (A -> Set) Least _≤_ P a = P a × LowerBound _≤_ P a
{ "alphanum_fraction": 0.489146165, "avg_line_length": 36.3684210526, "ext": "agda", "hexsha": "859673747c960e3e10198ba67960ce69c7cb5728", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-29T04:53:48.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-29T04:53:48.000Z", "max_forks_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "DSLsofMath/ValiantAgda", "max_forks_repo_path": "code/Preliminaries.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "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": "DSLsofMath/ValiantAgda", "max_issues_repo_path": "code/Preliminaries.agda", "max_line_length": 88, "max_stars_count": 3, "max_stars_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "DSLsofMath/ValiantAgda", "max_stars_repo_path": "code/Preliminaries.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-15T03:04:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-23T00:41:14.000Z", "num_tokens": 538, "size": 1382 }
------------------------------------------------------------------------------ -- The division specification ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.Division.Specification where open import FOTC.Base open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities ------------------------------------------------------------------------------ -- Specification: The division is total and the result is correct. divSpec : D → D → D → Set divSpec i j q = N q ∧ (∃[ r ] N r ∧ r < j ∧ i ≡ j * q + r) {-# ATP definition divSpec #-}
{ "alphanum_fraction": 0.4265091864, "avg_line_length": 36.2857142857, "ext": "agda", "hexsha": "fae57cd7ce8ae6570d1dad67b898d1a1edaa690c", "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/Division/Specification.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/Division/Specification.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Program/Division/Specification.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": 142, "size": 762 }
-- Andreas, 2016-06-11 postulate Foo : Foo → Set
{ "alphanum_fraction": 0.66, "avg_line_length": 12.5, "ext": "agda", "hexsha": "dd565bd4e0fa71e520deaf2be8076acd28097b10", "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/Issue2024-fun.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/Issue2024-fun.agda", "max_line_length": 25, "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/Issue2024-fun.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": 19, "size": 50 }
---------------------------------------------------------------------------------- -- Types for parse trees ---------------------------------------------------------------------------------- module options-types where open import ial open import parse-tree posinfo = string alpha = string alpha-bar-4 = string alpha-range-2 = string alpha-range-3 = string anychar = string anychar-bar-10 = string anychar-bar-11 = string anychar-bar-12 = string anychar-bar-13 = string anychar-bar-14 = string anychar-bar-15 = string anychar-bar-16 = string anychar-bar-17 = string anychar-bar-18 = string anychar-bar-19 = string anychar-bar-20 = string anychar-bar-21 = string anychar-bar-22 = string anychar-bar-23 = string anychar-bar-24 = string anychar-bar-25 = string anychar-bar-26 = string anychar-bar-27 = string anychar-bar-28 = string anychar-bar-29 = string anychar-bar-9 = string num = string num-plus-6 = string numone = string numone-range-5 = string numpunct = string numpunct-bar-7 = string numpunct-bar-8 = string path = string path-star-1 = string {-# FOREIGN GHC import qualified CedilleOptionsParser #-} {-# FOREIGN GHC import qualified CedilleOptionsLexer #-} data paths : Set where PathsCons : path → paths → paths PathsNil : paths {-# COMPILE GHC paths = data CedilleOptionsLexer.Paths (CedilleOptionsLexer.PathsCons | CedilleOptionsLexer.PathsNil) #-} --data data-encoding : Set where -- Mendler : data-encoding -- Mendler-old : data-encoding --{-# COMPILE GHC data-encoding = data CedilleOptionsLexer.DataEnc (CedilleOptionsLexer.Mendler | CedilleOptionsLexer.MendlerOld) #-} data opt : Set where GenerateLogs : 𝔹 → opt Lib : paths → opt MakeRktFiles : 𝔹 → opt ShowQualifiedVars : 𝔹 → opt UseCedeFiles : 𝔹 → opt EraseTypes : 𝔹 → opt PrettyPrintColumns : string → opt DatatypeEncoding : maybe path → opt {-# COMPILE GHC opt = data CedilleOptionsLexer.Opt (CedilleOptionsLexer.GenerateLogs | CedilleOptionsLexer.Lib | CedilleOptionsLexer.MakeRktFiles | CedilleOptionsLexer.ShowQualifiedVars | CedilleOptionsLexer.UseCedeFiles | CedilleOptionsLexer.EraseTypes | CedilleOptionsLexer.PrintColumns | CedilleOptionsLexer.DatatypeEncoding) #-} data opts : Set where OptsCons : opt → opts → opts OptsNil : opts {-# COMPILE GHC opts = data CedilleOptionsLexer.Opts (CedilleOptionsLexer.OptsCons | CedilleOptionsLexer.OptsNil) #-} data start : Set where File : opts → start {-# COMPILE GHC start = data CedilleOptionsLexer.Start (CedilleOptionsLexer.File) #-} data Either (A : Set)(B : Set) : Set where Left : A → Either A B Right : B → Either A B {-# COMPILE GHC Either = data Either (Left | Right) #-} postulate scanOptions : string → Either string start {-# COMPILE GHC scanOptions = CedilleOptionsParser.parseOptions #-} -- embedded types: data ParseTreeT : Set where parsed-opt : opt → ParseTreeT parsed-opts : opts → ParseTreeT parsed-paths : paths → ParseTreeT parsed-start : start → ParseTreeT parsed-bool : 𝔹 → ParseTreeT parsed-posinfo : posinfo → ParseTreeT parsed-alpha : alpha → ParseTreeT parsed-alpha-bar-4 : alpha-bar-4 → ParseTreeT parsed-alpha-range-2 : alpha-range-2 → ParseTreeT parsed-alpha-range-3 : alpha-range-3 → ParseTreeT parsed-anychar : anychar → ParseTreeT parsed-anychar-bar-10 : anychar-bar-10 → ParseTreeT parsed-anychar-bar-11 : anychar-bar-11 → ParseTreeT parsed-anychar-bar-12 : anychar-bar-12 → ParseTreeT parsed-anychar-bar-13 : anychar-bar-13 → ParseTreeT parsed-anychar-bar-14 : anychar-bar-14 → ParseTreeT parsed-anychar-bar-15 : anychar-bar-15 → ParseTreeT parsed-anychar-bar-16 : anychar-bar-16 → ParseTreeT parsed-anychar-bar-17 : anychar-bar-17 → ParseTreeT parsed-anychar-bar-18 : anychar-bar-18 → ParseTreeT parsed-anychar-bar-19 : anychar-bar-19 → ParseTreeT parsed-anychar-bar-20 : anychar-bar-20 → ParseTreeT parsed-anychar-bar-21 : anychar-bar-21 → ParseTreeT parsed-anychar-bar-22 : anychar-bar-22 → ParseTreeT parsed-anychar-bar-23 : anychar-bar-23 → ParseTreeT parsed-anychar-bar-24 : anychar-bar-24 → ParseTreeT parsed-anychar-bar-25 : anychar-bar-25 → ParseTreeT parsed-anychar-bar-26 : anychar-bar-26 → ParseTreeT parsed-anychar-bar-27 : anychar-bar-27 → ParseTreeT parsed-anychar-bar-28 : anychar-bar-28 → ParseTreeT parsed-anychar-bar-29 : anychar-bar-29 → ParseTreeT parsed-anychar-bar-9 : anychar-bar-9 → ParseTreeT parsed-num : num → ParseTreeT parsed-num-plus-6 : num-plus-6 → ParseTreeT parsed-numone : numone → ParseTreeT parsed-numone-range-5 : numone-range-5 → ParseTreeT parsed-numpunct : numpunct → ParseTreeT parsed-numpunct-bar-7 : numpunct-bar-7 → ParseTreeT parsed-numpunct-bar-8 : numpunct-bar-8 → ParseTreeT parsed-path : path → ParseTreeT parsed-path-star-1 : path-star-1 → ParseTreeT parsed-aws : ParseTreeT parsed-aws-bar-31 : ParseTreeT parsed-aws-bar-32 : ParseTreeT parsed-aws-bar-33 : ParseTreeT parsed-comment : ParseTreeT parsed-comment-star-30 : ParseTreeT parsed-ows : ParseTreeT parsed-ows-star-35 : ParseTreeT parsed-squote : ParseTreeT parsed-ws : ParseTreeT parsed-ws-plus-34 : ParseTreeT ------------------------------------------ -- Parse tree printing functions ------------------------------------------ posinfoToString : posinfo → string posinfoToString x = "(posinfo " ^ x ^ ")" alphaToString : alpha → string alphaToString x = "(alpha " ^ x ^ ")" alpha-bar-4ToString : alpha-bar-4 → string alpha-bar-4ToString x = "(alpha-bar-4 " ^ x ^ ")" alpha-range-2ToString : alpha-range-2 → string alpha-range-2ToString x = "(alpha-range-2 " ^ x ^ ")" alpha-range-3ToString : alpha-range-3 → string alpha-range-3ToString x = "(alpha-range-3 " ^ x ^ ")" anycharToString : anychar → string anycharToString x = "(anychar " ^ x ^ ")" anychar-bar-10ToString : anychar-bar-10 → string anychar-bar-10ToString x = "(anychar-bar-10 " ^ x ^ ")" anychar-bar-11ToString : anychar-bar-11 → string anychar-bar-11ToString x = "(anychar-bar-11 " ^ x ^ ")" anychar-bar-12ToString : anychar-bar-12 → string anychar-bar-12ToString x = "(anychar-bar-12 " ^ x ^ ")" anychar-bar-13ToString : anychar-bar-13 → string anychar-bar-13ToString x = "(anychar-bar-13 " ^ x ^ ")" anychar-bar-14ToString : anychar-bar-14 → string anychar-bar-14ToString x = "(anychar-bar-14 " ^ x ^ ")" anychar-bar-15ToString : anychar-bar-15 → string anychar-bar-15ToString x = "(anychar-bar-15 " ^ x ^ ")" anychar-bar-16ToString : anychar-bar-16 → string anychar-bar-16ToString x = "(anychar-bar-16 " ^ x ^ ")" anychar-bar-17ToString : anychar-bar-17 → string anychar-bar-17ToString x = "(anychar-bar-17 " ^ x ^ ")" anychar-bar-18ToString : anychar-bar-18 → string anychar-bar-18ToString x = "(anychar-bar-18 " ^ x ^ ")" anychar-bar-19ToString : anychar-bar-19 → string anychar-bar-19ToString x = "(anychar-bar-19 " ^ x ^ ")" anychar-bar-20ToString : anychar-bar-20 → string anychar-bar-20ToString x = "(anychar-bar-20 " ^ x ^ ")" anychar-bar-21ToString : anychar-bar-21 → string anychar-bar-21ToString x = "(anychar-bar-21 " ^ x ^ ")" anychar-bar-22ToString : anychar-bar-22 → string anychar-bar-22ToString x = "(anychar-bar-22 " ^ x ^ ")" anychar-bar-23ToString : anychar-bar-23 → string anychar-bar-23ToString x = "(anychar-bar-23 " ^ x ^ ")" anychar-bar-24ToString : anychar-bar-24 → string anychar-bar-24ToString x = "(anychar-bar-24 " ^ x ^ ")" anychar-bar-25ToString : anychar-bar-25 → string anychar-bar-25ToString x = "(anychar-bar-25 " ^ x ^ ")" anychar-bar-26ToString : anychar-bar-26 → string anychar-bar-26ToString x = "(anychar-bar-26 " ^ x ^ ")" anychar-bar-27ToString : anychar-bar-27 → string anychar-bar-27ToString x = "(anychar-bar-27 " ^ x ^ ")" anychar-bar-28ToString : anychar-bar-28 → string anychar-bar-28ToString x = "(anychar-bar-28 " ^ x ^ ")" anychar-bar-29ToString : anychar-bar-29 → string anychar-bar-29ToString x = "(anychar-bar-29 " ^ x ^ ")" anychar-bar-9ToString : anychar-bar-9 → string anychar-bar-9ToString x = "(anychar-bar-9 " ^ x ^ ")" numToString : num → string numToString x = "(num " ^ x ^ ")" num-plus-6ToString : num-plus-6 → string num-plus-6ToString x = "(num-plus-6 " ^ x ^ ")" numoneToString : numone → string numoneToString x = "(numone " ^ x ^ ")" numone-range-5ToString : numone-range-5 → string numone-range-5ToString x = "(numone-range-5 " ^ x ^ ")" numpunctToString : numpunct → string numpunctToString x = "(numpunct " ^ x ^ ")" numpunct-bar-7ToString : numpunct-bar-7 → string numpunct-bar-7ToString x = "(numpunct-bar-7 " ^ x ^ ")" numpunct-bar-8ToString : numpunct-bar-8 → string numpunct-bar-8ToString x = "(numpunct-bar-8 " ^ x ^ ")" pathToString : path → string pathToString x = "(path " ^ x ^ ")" path-star-1ToString : path-star-1 → string path-star-1ToString x = "(path-star-1 " ^ x ^ ")" mutual boolToString : 𝔹 → string boolToString tt = "true" boolToString ff = "false" optToString : opt → string optToString (GenerateLogs x0) = "(GenerateLogs" ^ " " ^ (boolToString x0) ^ ")" optToString (Lib x0) = "(Lib" ^ " " ^ (pathsToString x0) ^ ")" optToString (MakeRktFiles x0) = "(MakeRktFiles" ^ " " ^ (boolToString x0) ^ ")" optToString (ShowQualifiedVars x0) = "(ShowQualifiedVars" ^ " " ^ (boolToString x0) ^ ")" optToString (UseCedeFiles x0) = "(UseCedeFiles" ^ " " ^ (boolToString x0) ^ ")" optToString (EraseTypes x0) = "(EraseTypes" ^ " " ^ (boolToString x0) ^ ")" optToString (PrettyPrintColumns x0) = "PrettyPrintColumns" ^ " " ^ x0 ^ ")" optToString (DatatypeEncoding nothing) = "(DatatypeEncoding nothing)" optToString (DatatypeEncoding (just x0)) = "(DatatypeEncoding (just " ^ x0 ^ "))" optsToString : opts → string optsToString (OptsCons x0 x1) = "(OptsCons" ^ " " ^ (optToString x0) ^ " " ^ (optsToString x1) ^ ")" optsToString (OptsNil) = "OptsNil" ^ "" pathsToString : paths → string pathsToString (PathsCons x0 x1) = "(PathsCons" ^ " " ^ (pathToString x0) ^ " " ^ (pathsToString x1) ^ ")" pathsToString (PathsNil) = "PathsNil" ^ "" -- data-encodingToString : data-encoding → string -- data-encodingToString Mendler = "Mendler" -- data-encodingToString Mendler-old = "Mendler-old" startToString : start → string startToString (File x0) = "(File" ^ " " ^ (optsToString x0) ^ ")" ParseTreeToString : ParseTreeT → string ParseTreeToString (parsed-opt t) = optToString t ParseTreeToString (parsed-opts t) = optsToString t ParseTreeToString (parsed-paths t) = pathsToString t ParseTreeToString (parsed-start t) = startToString t ParseTreeToString (parsed-bool t) = boolToString t ParseTreeToString (parsed-posinfo t) = posinfoToString t ParseTreeToString (parsed-alpha t) = alphaToString t ParseTreeToString (parsed-alpha-bar-4 t) = alpha-bar-4ToString t ParseTreeToString (parsed-alpha-range-2 t) = alpha-range-2ToString t ParseTreeToString (parsed-alpha-range-3 t) = alpha-range-3ToString t ParseTreeToString (parsed-anychar t) = anycharToString t ParseTreeToString (parsed-anychar-bar-10 t) = anychar-bar-10ToString t ParseTreeToString (parsed-anychar-bar-11 t) = anychar-bar-11ToString t ParseTreeToString (parsed-anychar-bar-12 t) = anychar-bar-12ToString t ParseTreeToString (parsed-anychar-bar-13 t) = anychar-bar-13ToString t ParseTreeToString (parsed-anychar-bar-14 t) = anychar-bar-14ToString t ParseTreeToString (parsed-anychar-bar-15 t) = anychar-bar-15ToString t ParseTreeToString (parsed-anychar-bar-16 t) = anychar-bar-16ToString t ParseTreeToString (parsed-anychar-bar-17 t) = anychar-bar-17ToString t ParseTreeToString (parsed-anychar-bar-18 t) = anychar-bar-18ToString t ParseTreeToString (parsed-anychar-bar-19 t) = anychar-bar-19ToString t ParseTreeToString (parsed-anychar-bar-20 t) = anychar-bar-20ToString t ParseTreeToString (parsed-anychar-bar-21 t) = anychar-bar-21ToString t ParseTreeToString (parsed-anychar-bar-22 t) = anychar-bar-22ToString t ParseTreeToString (parsed-anychar-bar-23 t) = anychar-bar-23ToString t ParseTreeToString (parsed-anychar-bar-24 t) = anychar-bar-24ToString t ParseTreeToString (parsed-anychar-bar-25 t) = anychar-bar-25ToString t ParseTreeToString (parsed-anychar-bar-26 t) = anychar-bar-26ToString t ParseTreeToString (parsed-anychar-bar-27 t) = anychar-bar-27ToString t ParseTreeToString (parsed-anychar-bar-28 t) = anychar-bar-28ToString t ParseTreeToString (parsed-anychar-bar-29 t) = anychar-bar-29ToString t ParseTreeToString (parsed-anychar-bar-9 t) = anychar-bar-9ToString t ParseTreeToString (parsed-num t) = numToString t ParseTreeToString (parsed-num-plus-6 t) = num-plus-6ToString t ParseTreeToString (parsed-numone t) = numoneToString t ParseTreeToString (parsed-numone-range-5 t) = numone-range-5ToString t ParseTreeToString (parsed-numpunct t) = numpunctToString t ParseTreeToString (parsed-numpunct-bar-7 t) = numpunct-bar-7ToString t ParseTreeToString (parsed-numpunct-bar-8 t) = numpunct-bar-8ToString t ParseTreeToString (parsed-path t) = pathToString t ParseTreeToString (parsed-path-star-1 t) = path-star-1ToString t ParseTreeToString parsed-aws = "[aws]" ParseTreeToString parsed-aws-bar-31 = "[aws-bar-31]" ParseTreeToString parsed-aws-bar-32 = "[aws-bar-32]" ParseTreeToString parsed-aws-bar-33 = "[aws-bar-33]" ParseTreeToString parsed-comment = "[comment]" ParseTreeToString parsed-comment-star-30 = "[comment-star-30]" ParseTreeToString parsed-ows = "[ows]" ParseTreeToString parsed-ows-star-35 = "[ows-star-35]" ParseTreeToString parsed-squote = "[squote]" ParseTreeToString parsed-ws = "[ws]" ParseTreeToString parsed-ws-plus-34 = "[ws-plus-34]" ------------------------------------------ -- Reorganizing rules ------------------------------------------ mutual {-# TERMINATING #-} norm-bool : (x : bool) → bool norm-bool x = x {-# TERMINATING #-} norm-start : (x : start) → start norm-start x = x {-# TERMINATING #-} norm-posinfo : (x : posinfo) → posinfo norm-posinfo x = x {-# TERMINATING #-} norm-paths : (x : paths) → paths norm-paths x = x {-# TERMINATING #-} norm-opts : (x : opts) → opts norm-opts x = x {-# TERMINATING #-} norm-opt : (x : opt) → opt norm-opt x = x isParseTree : ParseTreeT → 𝕃 char → string → Set isParseTree p l s = ⊤ {- this will be ignored since we are using simply typed runs -} ptr : ParseTreeRec ptr = record { ParseTreeT = ParseTreeT ; isParseTree = isParseTree ; ParseTreeToString = ParseTreeToString }
{ "alphanum_fraction": 0.7013612565, "avg_line_length": 41.6424418605, "ext": "agda", "hexsha": "17c146eef01de99013f6fef263389fdeeee43df4", "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": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ice1k/cedille", "max_forks_repo_path": "src/options-types.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "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": "ice1k/cedille", "max_issues_repo_path": "src/options-types.agda", "max_line_length": 332, "max_stars_count": null, "max_stars_repo_head_hexsha": "bf62d3d338809a30bc21a1affed07936b1ac60ac", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ice1k/cedille", "max_stars_repo_path": "src/options-types.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4306, "size": 14325 }
module reductionSystems1 where data ℕ : Set where Z : ℕ S : ℕ -> ℕ _+_ : ℕ -> ℕ -> ℕ n + Z = n n + S m = S (n + m) _*_ : ℕ -> ℕ -> ℕ n * Z = Z n * S m = (n * m) + n {- {-# BUILTIN NATURAL ℕ #-} {-# BUILTIN ZERO Z #-} {-# BUILTIN SUC S #-} {-# BUILTIN NATPLUS _+_ #-} {-# BUILTIN NATTIMES _*_ #-} -}
{ "alphanum_fraction": 0.4407294833, "avg_line_length": 13.7083333333, "ext": "agda", "hexsha": "926028ea6a62dfd06c1efff264f60fed042511e4", "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": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_path": "tests/covered/reductionSystems1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "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": "andrejtokarcik/agda-semantics", "max_issues_repo_path": "tests/covered/reductionSystems1.agda", "max_line_length": 30, "max_stars_count": 3, "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_path": "tests/covered/reductionSystems1.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "num_tokens": 128, "size": 329 }
{-# OPTIONS --rewriting #-} -- {-# OPTIONS --confluence-check #-} -- Formulæ and hypotheses (contexts) open import Library module Formulas (Base : Set) where -- Propositional formulas data Form : Set where Atom : (P : Base) → Form True False : Form _∨_ _∧_ _⇒_ : (A B : Form) → Form infixl 8 _∧_ infixl 7 _∨_ infixr 6 _⇒_ infixr 5 ¬_ ¬_ : (A : Form) → Form ¬ A = A ⇒ False -- Contexts data Cxt : Set where ε : Cxt _∙_ : (Γ : Cxt) (A : Form) → Cxt infixl 4 _∙_ -- Context extension (thinning) infix 3 _≤_ data _≤_ : (Γ Δ : Cxt) → Set where ε : ε ≤ ε weak : ∀{A Γ Δ} (τ : Γ ≤ Δ) → Γ ∙ A ≤ Δ lift : ∀{A Γ Δ} (τ : Γ ≤ Δ) → Γ ∙ A ≤ Δ ∙ A id≤ : ∀{Γ} → Γ ≤ Γ id≤ {ε} = ε id≤ {Γ ∙ A} = lift id≤ -- Category of thinnings _•_ : ∀{Γ Δ Φ} (τ : Γ ≤ Δ) (σ : Δ ≤ Φ) → Γ ≤ Φ ε • σ = σ weak τ • σ = weak (τ • σ) lift τ • weak σ = weak (τ • σ) lift τ • lift σ = lift (τ • σ) •-id-l : ∀{Γ Δ} (τ : Γ ≤ Δ) → id≤ • τ ≡ τ •-id-l ε = refl •-id-l (weak τ) = cong weak (•-id-l τ) •-id-l (lift τ) = cong lift (•-id-l τ) •-id-r : ∀{Γ Δ} (τ : Γ ≤ Δ) → τ • id≤ ≡ τ •-id-r ε = refl •-id-r (weak τ) = cong weak (•-id-r τ) •-id-r (lift τ) = cong lift (•-id-r τ) •-ε-r : ∀{Γ} (τ : Γ ≤ ε) → τ • ε ≡ τ •-ε-r ε = refl •-ε-r (weak τ) = cong weak (•-ε-r τ) {-# REWRITE •-id-l •-id-r •-ε-r #-} -- Pullbacks record RawPullback {Γ Δ₁ Δ₂} (τ₁ : Δ₁ ≤ Γ) (τ₂ : Δ₂ ≤ Γ) : Set where constructor rawPullback; field {Γ'} : Cxt τ₁' : Γ' ≤ Δ₁ τ₂' : Γ' ≤ Δ₂ comm : τ₁' • τ₁ ≡ τ₂' • τ₂ -- The glb is only unique up to isomorphism: -- for glb (weak τ₁) (weak τ₂) we have two choices how to proceed. glb : ∀ {Γ Δ₁ Δ₂} (τ₁ : Δ₁ ≤ Γ) (τ₂ : Δ₂ ≤ Γ) → RawPullback τ₁ τ₂ glb ε τ₂ = rawPullback τ₂ id≤ refl -- REWRITE (•-id-r τ₂) glb τ₁ ε = rawPullback id≤ τ₁ refl -- REWRITE (•-id-l τ₁) glb (weak τ₁) τ₂ = let rawPullback τ₁' τ₂' comm = glb τ₁ τ₂ in rawPullback (lift τ₁') (weak τ₂') (cong weak comm) glb τ₁ (weak τ₂) = let rawPullback τ₁' τ₂' comm = glb τ₁ τ₂ in rawPullback (weak τ₁') (lift τ₂') (cong weak comm) glb (lift τ₁) (lift τ₂) = let rawPullback τ₁' τ₂' comm = glb τ₁ τ₂ in rawPullback (lift τ₁') (lift τ₂') (cong lift comm) -- glb (weak τ₁) (weak τ₂) = -- let rawPullback τ₁' τ₂' comm = glb τ₁ τ₂ -- in rawPullback (weak (lift τ₁')) (lift (weak τ₂')) (cong (weak ∘ weak) comm) -- -- Here is a choice: it would also work the other way round: -- -- rawPullback (lift (weak τ₁')) (weak (lift τ₂')) (cong (weak ∘ weak) comm) -- glb (weak τ₁) (lift τ₂) = -- let rawPullback τ₁' τ₂' comm = glb τ₁ (lift τ₂) -- in rawPullback (lift τ₁') (weak τ₂') (cong weak comm) record WeakPullback {Γ Δ₁ Δ₂} (τ₁ : Δ₁ ≤ Γ) (τ₂ : Δ₂ ≤ Γ) : Set where constructor weakPullback field rawpullback : RawPullback τ₁ τ₂ open RawPullback rawpullback public -- field -- largest : ∀ (pb : RawPullback τ₁ τ₂) -- There are actually no pullbacks in the OPE category -- Hypotheses data Hyp (A : Form) : (Γ : Cxt) → Set where top : ∀{Γ} → Hyp A (Γ ∙ A) pop : ∀{Γ B} (x : Hyp A Γ) → Hyp A (Γ ∙ B) Mon : (P : Cxt → Set) → Set Mon P = ∀{Γ Δ} (τ : Γ ≤ Δ) → P Δ → P Γ monH : ∀{A} → Mon (Hyp A) monH ε () monH (weak τ) x = pop (monH τ x) monH (lift τ) top = top monH (lift τ) (pop x) = pop (monH τ x) monH-id : ∀{Γ A} (x : Hyp A Γ) → monH id≤ x ≡ x monH-id top = refl monH-id (pop x) = cong pop (monH-id x) monH• : ∀{Γ Δ Φ A} (τ : Γ ≤ Δ) (σ : Δ ≤ Φ) (x : Hyp A Φ) → monH (τ • σ) x ≡ monH τ (monH σ x) monH• ε ε () monH• (weak τ) σ x = cong pop (monH• τ σ x) monH• (lift τ) (weak σ) x = cong pop (monH• τ σ x) monH• (lift τ) (lift σ) top = refl monH• (lift τ) (lift σ) (pop x) = cong pop (monH• τ σ x) {-# REWRITE monH-id monH• #-} □ : (P : Cxt → Set) → Cxt → Set □ P Γ = ∀{Δ} (τ : Δ ≤ Γ) → P Δ mon□ : ∀{P} → Mon (□ P) mon□ τ x τ′ = x (τ′ • τ) infix 1 _→̇_ infixr 2 _⇒̂_ -- Presheaf morphism _→̇_ : (P Q : Cxt → Set) → Set P →̇ Q = ∀{Γ} → P Γ → Q Γ ⟨_⊙_⟩→̇_ : (P Q R : Cxt → Set) → Set ⟨ P ⊙ Q ⟩→̇ R = ∀{Γ} → P Γ → Q Γ → R Γ ⟨_⊙_⊙_⟩→̇_ : (P Q R S : Cxt → Set) → Set ⟨ P ⊙ Q ⊙ R ⟩→̇ S = ∀{Γ} → P Γ → Q Γ → R Γ → S Γ -- Pointwise presheaf arrow (not a presheaf) CFun : (P Q : Cxt → Set) → Cxt → Set CFun P Q Γ = P Γ → Q Γ -- Presheaf exponentional (Kripke function space) KFun : (P Q : Cxt → Set) → Cxt → Set KFun P Q = □ (CFun P Q) -- Again, in expanded form. _⇒̂_ : (P Q : Cxt → Set) → Cxt → Set P ⇒̂ Q = λ Γ → ∀{Δ} (τ : Δ ≤ Γ) → P Δ → Q Δ -- -} -- -} -- -} -- -} -- -}
{ "alphanum_fraction": 0.5242892321, "avg_line_length": 24.543956044, "ext": "agda", "hexsha": "94dd3218ff0d921dd4d402b94786f1384cf87ad3", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z", "max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "andreasabel/ipl", "max_forks_repo_path": "src/Formulas.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "andreasabel/ipl", "max_issues_repo_path": "src/Formulas.agda", "max_line_length": 93, "max_stars_count": 19, "max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "andreasabel/ipl", "max_stars_repo_path": "src/Formulas.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z", "num_tokens": 2066, "size": 4467 }
module Categories.Monad.EilenbergMoore where
{ "alphanum_fraction": 0.8888888889, "avg_line_length": 22.5, "ext": "agda", "hexsha": "ac254eb49d3ab84151fe6fdac6acec806afa8411", "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/Monad/EilenbergMoore.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/Monad/EilenbergMoore.agda", "max_line_length": 44, "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/Monad/EilenbergMoore.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": 10, "size": 45 }
module Issue87 where data I : Set where data D : I -> Set where d : forall {i} (x : D i) -> D i bar : forall {i} -> D i -> D i -> D i bar (d x) (d y) with y bar (d x) (d {i} y) | z = d {i} y -- Panic: unbound variable i -- when checking that the expression i has type I
{ "alphanum_fraction": 0.5607142857, "avg_line_length": 20, "ext": "agda", "hexsha": "97fba1486db2c6293dbfe29e148b501eaab5d900", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/Issue87.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/Issue87.agda", "max_line_length": 49, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Fail/Issue87.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": 105, "size": 280 }
{-# OPTIONS --cubical #-} module LookVsTime where open import Data.Fin using (#_) open import Data.Integer using (+_; -[1+_]) open import Data.List using (List; _∷_; []; map; concat; _++_; replicate; zip; length; take) open import Data.Nat using (_*_; ℕ; suc; _+_) open import Data.Product using (_,_; uncurry) open import Data.Vec using (fromList; Vec; _∷_; []) renaming (replicate to rep; zip to vzip; map to vmap; concat to vconcat; _++_ to _+v_) open import Function using (_∘_) open import Pitch open import Note using (tone; rest; Note; Duration; duration; unduration) open import Music open import Midi open import MidiEvent open import Util using (repeat; repeatV) tempo : ℕ tempo = 84 ---- 8th : ℕ → Duration 8th n = duration (2 * n) whole : ℕ → Duration whole n = duration (16 * n) melodyChannel : Channel-1 melodyChannel = # 0 melodyInstrument : InstrumentNumber-1 melodyInstrument = # 8 -- celesta melodyNotes : List Note melodyNotes = tone (8th 3) (c 5) ∷ tone (8th 5) (d 5) ∷ tone (8th 3) (c 5) ∷ tone (8th 5) (d 5) ∷ tone (8th 1) (g 5) ∷ tone (8th 1) (f 5) ∷ tone (8th 1) (e 5) ∷ tone (8th 5) (d 5) ∷ tone (8th 1) (g 5) ∷ tone (8th 1) (f 5) ∷ tone (8th 1) (e 5) ∷ tone (8th 5) (d 5) ∷ tone (8th 1) (a 5) ∷ tone (8th 1) (g 5) ∷ tone (8th 1) (f 5) ∷ tone (8th 2) (e 5) ∷ tone (8th 1) (c 5) ∷ tone (8th 2) (d 5) ∷ tone (8th 1) (a 5) ∷ tone (8th 1) (g 5) ∷ tone (8th 1) (f 5) ∷ tone (8th 2) (e 5) ∷ tone (8th 1) (c 5) ∷ tone (8th 2) (d 5) ∷ tone (8th 3) (b 4) ∷ tone (8th 5) (c 5) ∷ tone (8th 1) (f 5) ∷ tone (8th 1) (e 5) ∷ tone (8th 1) (d 5) ∷ tone (8th 5) (c 5) ∷ tone (8th 3) (g 5) ∷ tone (8th 3) (e 5) ∷ tone (8th 2) (d 5) ∷ tone (8th 3) (g 5) ∷ tone (8th 3) (e 5) ∷ tone (8th 2) (d 5) ∷ tone (8th 8) (c 5) ∷ tone (8th 8) (b 4) ∷ tone (8th 3) (c 5) ∷ tone (8th 5) (d 5) ∷ tone (8th 3) (c 5) ∷ tone (8th 5) (d 5) ∷ tone (8th 3) (a 5) ∷ tone (8th 5) (f 5) ∷ tone (8th 3) (e 5) ∷ tone (8th 5) (d 5) ∷ tone (8th 8) (c 5) ∷ tone (8th 8) (d 5) ∷ tone (8th 1) (c 5) ∷ tone (8th 1) (c 5) ∷ tone (8th 1) (c 5) ∷ tone (8th 5) (d 5) ∷ tone (8th 1) (c 5) ∷ tone (8th 1) (c 5) ∷ tone (8th 1) (c 5) ∷ tone (8th 5) (d 5) ∷ tone (8th 3) (a 5) ∷ tone (8th 5) (f 5) ∷ tone (8th 3) (a 5) ∷ tone (8th 5) (g 5) ∷ tone (8th 1) (a 5) ∷ tone (8th 1) (g 5) ∷ tone (8th 1) (f 5) ∷ tone (8th 2) (e 5) ∷ tone (8th 1) (c 5) ∷ tone (8th 2) (d 5) ∷ tone (8th 1) (a 5) ∷ tone (8th 1) (g 5) ∷ tone (8th 1) (f 5) ∷ tone (8th 2) (e 5) ∷ tone (8th 1) (c 5) ∷ tone (8th 2) (d 5) ∷ tone (8th 3) (b 4) ∷ tone (8th 5) (c 5) ∷ tone (8th 24) (b 4) ∷ [] melodyTrack : MidiTrack melodyTrack = track "Melody" melodyInstrument melodyChannel tempo (notes→events defaultVelocity melodyNotes) ---- accompChannel : Channel-1 accompChannel = # 1 accompInstrument : InstrumentNumber-1 accompInstrument = # 11 -- vibraphone accompRhythm : Vec Duration 3 accompRhythm = vmap 8th (3 ∷ 3 ∷ 2 ∷ []) accompF accompB2 accompC4 : Vec Pitch 3 accompF = f 4 ∷ a 4 ∷ c 5 ∷ [] accompB2 = f 4 ∷ b 4 ∷ d 4 ∷ [] accompC4 = f 4 ∷ c 5 ∷ e 5 ∷ [] accompFA : Vec Pitch 2 accompFA = f 4 ∷ a 4 ∷ [] accompChords1 : Harmony 3 128 accompChords1 = foldIntoHarmony (repeatV 8 accompRhythm) (repeatV 2 (vconcat (vmap (rep {n = 3}) (accompF ∷ accompB2 ∷ accompC4 ∷ accompB2 ∷ [])))) accompChords2 : Harmony 3 64 accompChords2 = addEmptyVoice (pitches→harmony (whole 4) accompFA) accompChords3 : Harmony 3 64 accompChords3 = foldIntoHarmony (repeatV 4 accompRhythm) (vconcat (vmap (rep {n = 3}) (accompF ∷ accompB2 ∷ accompC4 ∷ [])) +v (accompB2 ∷ accompB2 ∷ accompF ∷ [])) accompChords4 : Harmony 3 16 accompChords4 = addEmptyVoice (foldIntoHarmony accompRhythm (rep accompFA)) accompChords5 : Harmony 3 48 accompChords5 = pitches→harmony (8th (8 + 8 + 6)) accompF +H+ pitches→harmony (8th 2) accompF accompChords6 : Harmony 3 32 accompChords6 = pitches→harmony (8th (8 + 6)) accompB2 +H+ pitches→harmony (8th 2) accompB2 accompChords7 : Harmony 3 32 accompChords7 = pitches→harmony (whole 2) accompF accompChords : Harmony 3 448 accompChords = accompChords1 +H+ accompChords3 +H+ accompChords2 +H+ accompChords3 +H+ accompChords4 +H+ accompChords5 +H+ accompChords6 +H+ accompChords7 accompTrack : MidiTrack accompTrack = track "Accomp" accompInstrument accompChannel tempo (harmony→events defaultVelocity accompChords) ---- bassChannel : Channel-1 bassChannel = # 2 bassInstrument : InstrumentNumber-1 bassInstrument = # 33 -- finger bass bassMelody : List Pitch bassMelody = c 3 ∷ e 3 ∷ f 3 ∷ g 3 ∷ [] bassRhythm : List Duration bassRhythm = map 8th (3 ∷ 1 ∷ 2 ∷ 2 ∷ []) bassNotes : List Note bassNotes = repeat 28 (map (uncurry tone) (zip bassRhythm bassMelody)) bassTrack : MidiTrack bassTrack = track "Bass" bassInstrument bassChannel tempo (notes→events defaultVelocity bassNotes) ---- drumInstrument : InstrumentNumber-1 drumInstrument = # 0 -- SoCal? drumChannel : Channel-1 drumChannel = # 9 drumRhythmA : List Duration drumRhythmA = map duration (2 ∷ []) drumRhythmB : List Duration drumRhythmB = map duration (1 ∷ 1 ∷ 2 ∷ []) drumRhythm : List Duration drumRhythm = drumRhythmA ++ repeat 3 drumRhythmB ++ drumRhythmA drumPitches : List Pitch drumPitches = replicate (length drumRhythm) (b 4) -- Ride In drumNotes : List Note drumNotes = rest (whole 1) ∷ repeat 27 (map (uncurry tone) (zip drumRhythm drumPitches)) drumTrack : MidiTrack drumTrack = track "Drums" drumInstrument drumChannel tempo (notes→events defaultVelocity drumNotes) ---- lookVsTime : List MidiTrack lookVsTime = melodyTrack ∷ accompTrack ∷ bassTrack ∷ drumTrack ∷ []
{ "alphanum_fraction": 0.62489226, "avg_line_length": 23.581300813, "ext": "agda", "hexsha": "83a1909a861f539e268ed69523736469eff46b62", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z", "max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "halfaya/MusicTools", "max_forks_repo_path": "agda/LookVsTime.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z", "max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "halfaya/MusicTools", "max_issues_repo_path": "agda/LookVsTime.agda", "max_line_length": 142, "max_stars_count": 28, "max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "halfaya/MusicTools", "max_stars_repo_path": "agda/LookVsTime.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z", "num_tokens": 2571, "size": 5801 }
{-# OPTIONS --without-K #-} open import Base open import Homotopy.Pointed open import Homotopy.Connected module Homotopy.Cover {i} (A⋆ : pType i) (A⋆-is-conn : is-connected⋆ ⟨0⟩ A⋆) where open pType A⋆ renaming (∣_∣ to A ; ⋆ to a) open import Homotopy.Cover.Def A module Reconstruct where open import Homotopy.Cover.HomotopyGroupSetIsomorphism A⋆ A⋆-is-conn public {- -- The following is still a mess. Don't read it. module _ (uc : universal-covering) where open covering (π₁ uc) {- path⇒deck-is-equiv : ∀ {a₂} (path : a ≡ a₂) → is-equiv (path⇒deck path) path⇒deck-is-equiv path = iso-is-eq (transport fiber path) (transport fiber (! path)) (trans-trans-opposite fiber path) (trans-opposite-trans fiber path) -} is-nature : (fiber a → fiber a) → Set i is-nature f = (p : a ≡ a) → ∀ x → transport fiber p (f x) ≡ f (transport fiber p x) auto : Set i auto = fiber a ≃ fiber a -- This Lemma can be made more general as "(m+1)-connected => has-all-paths_m" uc-has-all-path₀ : ∀ (p q : Σ A fiber) → p ≡₀ q uc-has-all-path₀ p q = inverse τ-path-equiv-path-τ-S $ π₂ (π₂ uc) (proj p) ∘ ! (π₂ (π₂ uc) $ proj q) nature-auto-eq : ∀ (f₁ f₂ : auto) → (f₁-is-nature : is-nature (π₁ f₁)) → (f₂-is-nature : is-nature (π₁ f₂)) → Σ (fiber a) (λ x → f₁ ☆ x ≡ f₂ ☆ x) → f₁ ≡ f₂ nature-auto-eq f₁ f₂ f₁-nat f₂-nat (x , path) = equiv-eq $ funext λ y → π₀-extend ⦃ λ _ → ≡-is-set {x = f₁ ☆ y} {y = f₂ ☆ y} $ fiber-is-set a ⦄ (λ uc-path → f₁ ☆ y ≡⟨ ap (π₁ f₁) $ ! $ fiber-path uc-path ⟩ f₁ ☆ transport fiber (base-path uc-path) x ≡⟨ ! $ f₁-nat (base-path uc-path) x ⟩ transport fiber (base-path uc-path) (f₁ ☆ x) ≡⟨ ap (transport fiber $ base-path uc-path) path ⟩ transport fiber (base-path uc-path) (f₂ ☆ x) ≡⟨ f₂-nat (base-path uc-path) x ⟩ f₂ ☆ transport fiber (base-path uc-path) x ≡⟨ ap (π₁ f₂) $ fiber-path uc-path ⟩∎ f₂ ☆ y ∎) (uc-has-all-path₀ (a , x) (a , y)) -}
{ "alphanum_fraction": 0.5731648031, "avg_line_length": 31.6461538462, "ext": "agda", "hexsha": "610528ff7999725d4a36450bd6244fccdef2daaf", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Homotopy/Cover.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Homotopy/Cover.agda", "max_line_length": 80, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/Homotopy/Cover.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": 780, "size": 2057 }
-- ---------------------------------------------------------------------- -- The Agda Descriptor Library -- -- Natural transformations on indexed families (predicates) -- ---------------------------------------------------------------------- module Relation.Unary.Predicate.Transformation where open import Data.Empty.Polymorphic using (⊥) open import Data.Product using (_×_) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Unit.Polymorphic using (⊤) open import Function using (_∘_) open import Level using (Level; _⊔_; 0ℓ) open import Relation.Unary private variable a b c d ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level A : Set a B : Set b C : Set c D : Set d -- ---------------------------------------------------------------------- -- Definition -- A predicate transformation is a morphism between 2 predicates -- indexed by A and B (w/ levels ℓ₁ ℓ₂ for universe polymorphism) infixr 0 _▷_ _►_ _▷_ : Set a → Set b → (ℓ₁ ℓ₂ : Level) → Set _ (A ▷ B) ℓ₁ ℓ₂ = Pred A ℓ₁ → Pred B ℓ₂ _►_ : Set a → Set b → Set _ (A ► B) = Pred A 0ℓ → Pred B 0ℓ -- ---------------------------------------------------------------------- -- Composition and Identity id : (A ▷ A) ℓ₁ ℓ₁ id = Function.id _○_ : (B ▷ C) ℓ₂ ℓ₃ → (A ▷ B) ℓ₁ ℓ₂ → (A ▷ C) ℓ₁ _ X ○ Y = X ∘ Y -- TODO: Cateogrical view -- ---------------------------------------------------------------------- -- Special transformations empty : (A ▷ B) ℓ₁ ℓ₂ empty = λ _ _ → ⊥ univ : (A ▷ B) ℓ₁ ℓ₂ univ = λ _ _ → ⊤ -- ---------------------------------------------------------------------- -- Operations on transformations infixr 8 _⇉_ infixl 7 _⋏_ infixl 6 _⋎_ -- Negation ∼ : (A ▷ B) ℓ₁ ℓ₂ → (A ▷ B) ℓ₁ ℓ₂ ∼ X = ∁ ∘ X -- Implication _⇉_ : (A ▷ B) ℓ₁ ℓ₂ → (A ▷ B) ℓ₁ ℓ₂ → (A ▷ B) ℓ₁ ℓ₂ X ⇉ Y = λ P → X P ⇒ Y P -- Intersection _⋏_ : (A ▷ B) ℓ₁ ℓ₂ → (A ▷ B) ℓ₁ ℓ₂ → (A ▷ B) ℓ₁ ℓ₂ X ⋏ Y = λ P → X P ∩ Y P -- Union _⋎_ : (A ▷ B) ℓ₁ ℓ₂ → (A ▷ B) ℓ₁ ℓ₂ → (A ▷ B) ℓ₁ ℓ₂ X ⋎ Y = λ P → X P ∪ Y P -- TODO: Infinitary union + intersection -- ---------------------------------------------------------------------- -- Combinators on transformations -- Disjoint sum _∣∣_ : (A ▷ C) ℓ₁ ℓ₂ → (B ▷ D) ℓ₁ ℓ₂ → (A ⊎ B ▷ C ⊎ D) ℓ₁ ℓ₂ (X ∣∣ Y) P (inj₁ x) = X (P ∘ inj₁) x (X ∣∣ Y) P (inj₂ y) = Y (P ∘ inj₂) y -- TODO: Product, etc
{ "alphanum_fraction": 0.4535137495, "avg_line_length": 23.618556701, "ext": "agda", "hexsha": "c9096fd0947ae414fc3d2a3b93eb989fbd165eb2", "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": "27fd49914d5ce1cc90d319089686861b33e8f19f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "johnyob/agda-desc", "max_forks_repo_path": "src/Relation/Unary/Predicate/Transformation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "27fd49914d5ce1cc90d319089686861b33e8f19f", "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": "johnyob/agda-desc", "max_issues_repo_path": "src/Relation/Unary/Predicate/Transformation.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "27fd49914d5ce1cc90d319089686861b33e8f19f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "johnyob/agda-desc", "max_stars_repo_path": "src/Relation/Unary/Predicate/Transformation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 845, "size": 2291 }
{-# OPTIONS --without-K #-} module CauchyProofs where -- Proofs about permutations defined in module Cauchy (everything -- except the multiplicative ones which are defined in CauchyProofsT and -- CauchyProofsS open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; subst; subst₂; cong; cong₂; setoid; proof-irrelevance; module ≡-Reasoning) open import Data.Nat.Properties using (m≤m+n; n≤m+n; n≤1+n; cancel-*-right-≤; ≰⇒>; ¬i+1+j≤i) open import Data.Nat.Properties.Simple using (+-right-identity; +-suc; +-assoc; +-comm; *-assoc; *-comm; *-right-zero; distribʳ-*-+; +-*-suc) open import Data.Nat using (ℕ; suc; _+_; _∸_; _*_; _<_; _≮_; _≤_; _≰_; _≥_; z≤n; s≤s; _≟_; _≤?_; ≤-pred; module ≤-Reasoning) open import Data.Fin using (Fin; zero; suc; toℕ; fromℕ; fromℕ≤; _ℕ-_; _≺_; reduce≥; raise; inject+; inject₁; inject≤; _≻toℕ_) renaming (_+_ to _F+_) open import Data.Fin.Properties using (bounded; inject+-lemma; to-from) open import Data.Vec.Properties using (lookup∘tabulate; tabulate∘lookup; lookup-allFin; tabulate-∘; tabulate-allFin; allFin-map; lookup-++-inject+; lookup-++-≥) open import Data.Vec using (Vec; tabulate; []; _∷_; tail; lookup; zip; zipWith; splitAt; _[_]≔_; allFin; toList) renaming (_++_ to _++V_; map to mapV; concat to concatV) open import Function using (id; _∘_; _$_; _∋_; flip) open import Proofs open import Cauchy ------------------------------------------------------------------------------ -- Proofs about sequential composition -- sequential composition with id on the right is identity scomprid : ∀ {n} → (perm : Cauchy n) → scompcauchy perm (idcauchy n) ≡ perm scomprid {n} perm = begin (scompcauchy perm (idcauchy n) ≡⟨ refl ⟩ tabulate (λ i → lookup (lookup i perm) (allFin n)) ≡⟨ finext (λ i → lookup-allFin (lookup i perm)) ⟩ tabulate (λ i → lookup i perm) ≡⟨ tabulate∘lookup perm ⟩ perm ∎) where open ≡-Reasoning -- sequential composition with id on the left is identity scomplid : ∀ {n} → (perm : Cauchy n) → scompcauchy (idcauchy n) perm ≡ perm scomplid {n} perm = trans (finext (λ i → cong (λ x → lookup x perm) (lookup-allFin i))) (tabulate∘lookup perm) -- sequential composition is associative scompassoc : ∀ {n} → (π₁ π₂ π₃ : Cauchy n) → scompcauchy π₁ (scompcauchy π₂ π₃) ≡ scompcauchy (scompcauchy π₁ π₂) π₃ scompassoc π₁ π₂ π₃ = finext (lookupassoc π₁ π₂ π₃) ------------------------------------------------------------------------------ -- Proofs about additive permutations lookup-subst2 : ∀ {m m'} (i : Fin m) (xs : Vec (Fin m) m) (eq : m ≡ m') → lookup (subst Fin eq i) (subst Cauchy eq xs) ≡ subst Fin eq (lookup i xs) lookup-subst2 i xs refl = refl allFin+ : (m n : ℕ) → allFin (m + n) ≡ mapV (inject+ n) (allFin m) ++V mapV (raise m) (allFin n) allFin+ m n = trans (tabulate-split {m} {n}) (cong₂ _++V_ (tabulate-allFin {m} (inject+ n)) (tabulate-allFin {n} (raise m))) -- swap+ is idempotent -- -- outline of swap+idemp proof -- -- allFin (m + n) ≡ mapV (inject+ n) (allFin m) ++V mapV (raise m) (allFin n) -- zero-m : Vec (Fin (m + n)) m ≡ mapV (inject+ n) (allFin m) -- m-sum : Vec (Fin (m + n)) n ≡ mapV (raise m) (allFin n) -- allFin (n + m) ≡ mapV (inject+ m) (allFin n) ++V mapV (raise n) (allFin m) -- zero-n : Vec (Fin (n + m)) n ≡ mapV (inject+ m) (allFin n) -- n-sum : Vec (Fin (n + m)) m ≡ mapV (raise n) (allFin m) -- -- first swap re-arranges allFin (n + m) to n-sum ++V zero-n -- second swap re-arranges allfin (m + n) to m-sum ++V zero-m -- -- for i = 0, ..., m-1, we have inject+ n i : Fin (m + n) -- lookup (lookup (inject+ n i) (n-sum ++V zero-n)) (m-sum ++V zero-m) ==> -- lookup (lookup i n-sum) (m-sum ++V zero-m) ==> -- lookup (raise n i) (m-sum ++V zero-m) ==> -- lookup i zero-m ==> -- inject+ n i -- -- for i = m, ..., m+n-1, we have raise m i : Fin (m + n) -- lookup (lookup (raise m i) (n-sum ++V zero-n)) (m-sum ++V zero-m) ==> -- lookup (lookup i zero-n) (m-sum ++V zero-m) ==> -- lookup (inject+ m i) (m-sum ++V zero-m) ==> -- lookup i m-sum ==> -- raise m i swap+-left : (m n : ℕ) → ∀ (i : Fin m) → let q = subst Cauchy (+-comm n m) (swap+cauchy n m) in lookup (lookup (inject+ n i) (swap+cauchy m n)) q ≡ inject+ n i swap+-left m n i = let q = subst Cauchy (+-comm n m) (swap+cauchy n m) in begin ( lookup (lookup (inject+ n i) (swap+cauchy m n)) q ≡⟨ cong (flip lookup q) ( (lookup-++-inject+ (tabulate {m} (id+ {m} {n} ∘ raise n)) (tabulate {n} (id+ {m} {n} ∘ inject+ m)) i)) ⟩ lookup (lookup i (tabulate (λ x → subst Fin (+-comm n m) (raise n x)))) q ≡⟨ cong (flip lookup q) (lookup∘tabulate (λ x → subst Fin (+-comm n m) (raise n x)) i) ⟩ lookup (subst Fin (+-comm n m) (raise n i)) q ≡⟨ lookup-subst2 (raise n i) (swap+cauchy n m) (+-comm n m) ⟩ subst Fin (+-comm n m) (lookup (raise n i) (swap+cauchy n m)) ≡⟨ cong (subst Fin (+-comm n m)) (lookup-++-raise (tabulate {n} (id+ {n} ∘ raise m)) (tabulate {m} (id+ {n} ∘ inject+ n)) i) ⟩ subst Fin (+-comm n m) (lookup i (tabulate (λ z → subst Fin (+-comm m n) (inject+ n z)))) ≡⟨ subst-lookup-tabulate-inject+ i ⟩ inject+ n i ∎) where open ≡-Reasoning swap+-right : (m n : ℕ) → (i : Fin n) → let q = subst Cauchy (+-comm n m) (swap+cauchy n m) in lookup (lookup (raise m i) (swap+cauchy m n)) q ≡ raise m i swap+-right m n i = let q = subst Cauchy (+-comm n m) (swap+cauchy n m) in begin ( lookup (lookup (raise m i) (swap+cauchy m n)) q ≡⟨ cong (flip lookup q) ( (lookup-++-raise (tabulate {m} (id+ {m} {n} ∘ raise n)) (tabulate {n} (id+ {m} {n} ∘ inject+ m)) i)) ⟩ lookup (lookup i (tabulate (λ x → subst Fin (+-comm n m) (inject+ m x)))) q ≡⟨ cong (flip lookup q) (lookup∘tabulate (λ x → subst Fin (+-comm n m) (inject+ m x)) i) ⟩ lookup (subst Fin (+-comm n m) (inject+ m i)) q ≡⟨ lookup-subst2 (inject+ m i) (swap+cauchy n m) (+-comm n m) ⟩ subst Fin (+-comm n m) (lookup (inject+ m i) (swap+cauchy n m)) ≡⟨ cong (subst Fin (+-comm n m)) (lookup-++-inject+ (tabulate {n} (id+ {n} ∘ raise m)) (tabulate {m} (id+ {n} ∘ inject+ n)) i) ⟩ subst Fin (+-comm n m) (lookup i (tabulate (λ z → subst Fin (+-comm m n) (raise m z)))) ≡⟨ subst-lookup-tabulate-raise i ⟩ raise m i ∎) where open ≡-Reasoning swap+idemp : (m n : ℕ) → scompcauchy (swap+cauchy m n) (subst Cauchy (+-comm n m) (swap+cauchy n m)) ≡ allFin (m + n) swap+idemp m n = let q = subst Cauchy (+-comm n m) (swap+cauchy n m) in begin (tabulate (λ i → lookup (lookup i (swap+cauchy m n)) q) ≡⟨ tabulate-split {m} {n} ⟩ tabulate {m} (λ i → lookup (lookup (inject+ n i) (swap+cauchy m n)) q) ++V tabulate {n} (λ i → lookup (lookup (raise m i) (swap+cauchy m n)) q) ≡⟨ cong₂ _++V_ (finext (swap+-left m n)) (finext (swap+-right m n)) ⟩ tabulate {m} (inject+ n) ++V tabulate {n} (raise m) ≡⟨ unSplit {m} {n} id ⟩ allFin (m + n) ∎) where open ≡-Reasoning -- Behaviour of parallel additive composition wrt sequential -- a direct proof is hard, but this is really a statement about vectors lookup-left : ∀ {m n} → (i : Fin m) → (pm : Cauchy m) → (pn : Cauchy n) → lookup (inject+ n i) (mapV (inject+ n) pm ++V mapV (raise m) pn) ≡ inject+ n (lookup i pm) lookup-left {m} {n} i pm pn = look-left i (inject+ n) (raise m) pm pn -- as is this lookup-right : ∀ {m n} → (i : Fin n) → (pm : Cauchy m) → (pn : Cauchy n) → lookup (raise m i) (mapV (inject+ n) pm ++V mapV (raise m) pn) ≡ raise m (lookup i pn) lookup-right {m} {n} i pm pn = look-right i (inject+ n) (raise m) pm pn --- find a better name look-left' : ∀ {m n} → (pm qm : Cauchy m) → (pn qn : Cauchy n) → (i : Fin m) → (lookup (lookup (inject+ n i) (pcompcauchy pm pn)) (pcompcauchy qm qn)) ≡ inject+ n (lookup (lookup i pm) qm) look-left' {m} {n} pm qm pn qn i = let pp = pcompcauchy pm pn in let qq = pcompcauchy qm qn in begin ( lookup (lookup (inject+ n i) pp) qq ≡⟨ cong (flip lookup qq) (lookup-++-inject+ (mapV (inject+ n) pm) (mapV (raise m) pn) i) ⟩ lookup (lookup i (mapV (inject+ n) pm)) qq ≡⟨ cong (flip lookup qq) (lookup-map i (inject+ n) pm) ⟩ lookup (inject+ n (lookup i pm)) qq ≡⟨ lookup-left (lookup i pm) qm qn ⟩ inject+ n (lookup (lookup i pm) qm) ∎) where open ≡-Reasoning look-right' : ∀ {m n} → (pm qm : Cauchy m) → (pn qn : Cauchy n) → (i : Fin n) → (lookup (lookup (raise m i) (pcompcauchy pm pn)) (pcompcauchy qm qn)) ≡ raise m (lookup (lookup i pn) qn) look-right' {m} {n} pm qm pn qn i = let pp = pcompcauchy pm pn in let qq = pcompcauchy qm qn in begin ( lookup (lookup (raise m i) pp) qq ≡⟨ cong (flip lookup qq) (lookup-++-raise (mapV (inject+ n) pm) (mapV (raise m) pn) i) ⟩ lookup (lookup i (mapV (raise m) pn)) qq ≡⟨ cong (flip lookup qq) (lookup-map i (raise m) pn) ⟩ lookup (raise m (lookup i pn)) qq ≡⟨ lookup-right (lookup i pn) qm qn ⟩ raise m (lookup (lookup i pn) qn) ∎) where open ≡-Reasoning pcomp-dist : ∀ {m n} → (pm qm : Cauchy m) → (pn qn : Cauchy n) → scompcauchy (pcompcauchy pm pn) (pcompcauchy qm qn) ≡ pcompcauchy (scompcauchy pm qm) (scompcauchy pn qn) pcomp-dist {m} {n} pm qm pn qn = let pp = pcompcauchy pm pn in let qq = pcompcauchy qm qn in let look = λ i → lookup (lookup i pp) qq in begin (scompcauchy pp qq ≡⟨ refl ⟩ tabulate look ≡⟨ tabulate-split {m} {n} ⟩ splitV+ {m} {n} {f = look} ≡⟨ cong₂ _++V_ (finext {m} (look-left' pm qm pn qn)) (finext {n} (look-right' pm qm pn qn)) ⟩ tabulate (λ i → (inject+ n) (lookup (lookup i pm) qm)) ++V tabulate (λ i → (raise m) (lookup (lookup i pn) qn)) ≡⟨ cong₂ _++V_ (tabulate-∘ (inject+ n) (λ i → lookup (lookup i pm) qm)) (tabulate-∘ (raise m) (λ i → lookup (lookup i pn) qn)) ⟩ mapV (inject+ n) (tabulate (λ i → lookup (lookup i pm) qm)) ++V mapV (raise m) (tabulate (λ i → lookup (lookup i pn) qn)) ≡⟨ refl ⟩ pcompcauchy (scompcauchy pm qm) (scompcauchy pn qn) ∎) where open ≡-Reasoning pcomp-id : ∀ {m n} → pcompcauchy (idcauchy m) (idcauchy n) ≡ idcauchy (m + n) pcomp-id {m} {n} = begin (mapV (inject+ n) (idcauchy m) ++V (mapV (raise m) (idcauchy n)) ≡⟨ refl ⟩ mapV (inject+ n) (allFin m) ++V mapV (raise m) (allFin n) ≡⟨ cong₂ _++V_ (sym (tabulate-allFin {m} (inject+ n))) (sym (tabulate-allFin (raise m))) ⟩ tabulate {m} (inject+ n) ++V tabulate {n} (raise m) ≡⟨ unSplit {m} {n} id ⟩ idcauchy (m + n) ∎) where open ≡-Reasoning ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5517860348, "avg_line_length": 42.3650190114, "ext": "agda", "hexsha": "4e5ca69ac85377ebe74c629cc27caa542b5d5ce6", "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/Obsolete/CauchyProofs.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/Obsolete/CauchyProofs.agda", "max_line_length": 120, "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/Obsolete/CauchyProofs.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": 4249, "size": 11142 }
-- Copyright 2019, Xuanrui Qi -- Original algorithm by: Jacques Garrigue, Xuanrui Qi & Kazunari Tanaka open import Data.Nat hiding (compare) open import Data.Nat.Properties open import Relation.Binary import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; subst; sym; inspect; [_]) open Eq.≡-Reasoning open import Data.Product open import Data.Empty using (⊥; ⊥-elim) open import Data.Unit using (⊤; tt) module RedBlack {c r} {A : Set c} {_<_ : Rel A r} (isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_) where open IsStrictTotalOrder isStrictTotalOrder data Color : Set where Red : Color Black : Color incr-Black : ℕ → Color → ℕ incr-Black d Black = suc d incr-Black d Red = d color-valid : Color → Color → Set color-valid Red Red = ⊥ color-valid _ _ = ⊤ inv : Color → Color inv Red = Black inv Black = Red valid-*-Black : ∀ c → color-valid c Black valid-*-Black Red = tt valid-*-Black Black = tt data Tree : ℕ → Color → Set c where Leaf : Tree 0 Black Node : ∀ {d cₗ cᵣ} c → color-valid c cₗ → color-valid c cᵣ → Tree d cₗ → A → Tree d cᵣ → Tree (incr-Black d c) c RNode : ∀ {d} → Tree d Black → A → Tree d Black → Tree d Red RNode = Node Red tt tt BNode : ∀ {d cₗ cᵣ} → Tree d cₗ → A → Tree d cᵣ → Tree (suc d) Black BNode = Node Black tt tt -- Insertion algorithm data InsTree : ℕ → Color → Set c where Fix : ∀ {d} → Tree d Black → A → Tree d Black → A → Tree d Black → InsTree d Red T : ∀ {d c} cₚ → Tree d c → InsTree d cₚ InsTree-color : ∀ {d c} → InsTree d c → Color InsTree-color (Fix _ _ _ _ _) = Red InsTree-color (T _ _) = Black fix-color : ∀ {d c} → InsTree d c → Color fix-color (Fix _ _ _ _ _) = Black fix-color (T {c = c} _ _) = c fix-InsTree : ∀ {d c} → (t : InsTree d c) → Tree (incr-Black d (inv (InsTree-color t))) (fix-color t) fix-InsTree (Fix t₁ x t₂ y t₃) = BNode (RNode t₁ x t₂) y t₃ fix-InsTree (T _ t) = t balanceₗ : ∀ {d cₗ cᵣ} c → (l : InsTree d cₗ) → A → Tree d cᵣ → color-valid c (InsTree-color l) → color-valid c cᵣ → InsTree (incr-Black d c) c balanceₗ Black (Fix t₁ x t₂ y t₃) z t₄ _ _ = T Black (RNode (BNode t₁ x t₂) y (BNode t₃ z t₄)) balanceₗ Black (T _ l) v r _ _ = T Black (BNode l v r) balanceₗ {cᵣ = Black} Red (T _ (Node {cₗ = Black} {cᵣ = Black} Red _ _ t₁ x t₂)) y t₃ _ _ = Fix t₁ x t₂ y t₃ balanceₗ {cᵣ = Black} Red (T {c = Black} _ l) v r _ _ = T Red (RNode l v r) balanceᵣ : ∀ {d cₗ cᵣ} c → Tree d cₗ → A → (r : InsTree d cᵣ) → color-valid c cₗ → color-valid c (InsTree-color r) → InsTree (incr-Black d c) c balanceᵣ Black t₁ x (Fix t₂ y t₃ z t₄) _ _ = T Black (RNode (BNode t₁ x t₂) y (BNode t₃ z t₄)) balanceᵣ Black l v (T _ r) _ _ = T Black (BNode l v r) balanceᵣ {cₗ = Black} Red t₁ x (T _ (Node {cₗ = Black} {cᵣ = Black} Red _ _ t₂ y t₃)) _ _ = Fix t₁ x t₂ y t₃ balanceᵣ {cₗ = Black} Red l v (T {c = Black} _ r) _ _ = T Red (RNode l v r) ins : ∀ {d c} → A → Tree d c → InsTree d c ins x Leaf = T Black (RNode Leaf x Leaf) ins x (Node c _ _ l v r) with (compare x v) ins x (Node c _ _ l v r) | tri< x<v _ _ with ins x l | inspect (ins x) l ins x (Node Black _ validᵣ l v r) | _ | Fix _ _ _ _ _ | [ insₗ ] = balanceₗ Black (ins x l) v r tt tt ins x (Node c _ validᵣ l v r) | _ | T _ _ | [ insₗ ] = balanceₗ c (ins x l) v r validₗ validᵣ where validₗ = subst (λ t → color-valid c (InsTree-color t)) (sym insₗ) (valid-*-Black c) ins x t@(Node c _ _ l v r) | tri≈ _ x≡v _ = T _ t ins x (Node c _ _ l v r) | tri> _ _ x>v with ins x r | inspect (ins x) r ins x (Node Black validₗ _ l v r) | _ | Fix _ _ _ _ _ | [ insᵣ ] = balanceᵣ Black l v (ins x r) tt tt ins x (Node c validₗ _ l v r) | _ | T _ _ | [ insᵣ ] = balanceᵣ c l v (ins x r) validₗ validᵣ where validᵣ = subst (λ t → color-valid c (InsTree-color t)) (sym insᵣ) (valid-*-Black c) blacken : ∀ {d c} → Tree d c → Tree (incr-Black d (inv c)) Black blacken Leaf = Leaf blacken (Node Black _ _ l v r) = BNode l v r blacken (Node Red _ _ l v r) = BNode l v r insert : ∀ {d} → A → Tree d Black → ∃ (λ d' → Tree d' Black) insert {d = d} x t with ins x t ... | T {c = c} _ t' = (incr-Black d (inv c) , blacken t') -- Deletion algorithm data DelTree : ℕ → Color → Set c where Stay : ∀ {d c} cₚ → color-valid c (inv cₚ) → Tree d c → DelTree d cₚ Down : ∀ {d} → Tree d Black → DelTree (suc d) Black bal-right : ∀ {d cₗ cᵣ} c → Tree d cₗ → A → DelTree d cᵣ → color-valid c cₗ → color-valid c cᵣ → DelTree (incr-Black d c) c bal-right {cₗ = Black} Red l v (Stay {c = Black} _ _ r) _ _ = Stay Red tt (RNode l v r) bal-right {cₗ = Black} Red l v (Stay {c = Red} Red _ _) _ () bal-right Red (Node {cᵣ = Black} Black _ _ t₁ x t₂) y (Down t₃) _ _ = Stay Red tt (BNode t₁ x (RNode t₂ y t₃)) bal-right Red (Node {cᵣ = Red} Black _ _ t₁ x (Node _ _ _ t₂ y t₃)) z (Down t₄) _ _ = Stay Red tt (RNode (BNode t₁ x t₂) y (BNode t₃ z t₄)) bal-right Black l v (Stay _ _ r) _ _ = Stay Black tt (BNode l v r) bal-right Black (Node {cᵣ = Red} Black _ _ t₁ x (Node _ _ _ t₂ y t₃)) z (Down t₄) _ _ = Stay Black tt (BNode (BNode t₁ x t₂) y (BNode t₃ z t₄)) bal-right Black (Node {cₗ = Black} {cᵣ = Black} Red _ _ t₁ x (Node {cᵣ = Black} _ _ _ t₂ y t₃)) z (Down t₄) _ _ = Stay Black tt (BNode t₁ x (BNode t₂ y (RNode t₃ z t₄))) bal-right Black (Node {cₗ = Black} {cᵣ = Black} Red _ _ t₁ x (Node {cᵣ = Red} _ _ _ t₂ y (Node {cₗ = Black} {cᵣ = Black} _ _ _ t₃ z t₄))) w (Down t₅) _ _ = Stay Black tt (BNode t₁ x (RNode (BNode t₂ y t₃) z (BNode t₄ w t₅))) bal-right Black (Node {cᵣ = Black} Black _ _ t₁ x t₂) y (Down t₃) _ _ = Down (BNode t₁ x (RNode t₂ y t₃)) bal-left : ∀ {d cₗ cᵣ} c → DelTree d cₗ → A → Tree d cᵣ → color-valid c cₗ → color-valid c cᵣ → DelTree (incr-Black d c) c bal-left {cₗ = Black} {cᵣ = Black} Red (Stay {c = Black} _ _ l) v r _ _ = Stay Red tt (RNode l v r) bal-left {cₗ = Black} {cᵣ = Black} Red (Stay {c = Red} _ () l) v r _ _ bal-left {cₗ = Black} {cᵣ = Black} Red (Down t₁) x (Node {cₗ = Red} _ _ _ (Node {cₗ = Black} {cᵣ = Black} _ _ _ t₂ y t₃) z t₄) _ _ = Stay Red tt (RNode (BNode t₁ x t₂) y (BNode t₃ z t₄)) bal-left {cₗ = Black} {cᵣ = Black} Red (Down t₁) x (Node {cₗ = Black} _ _ _ t₂ y t₃) _ _ = Stay Red tt (BNode (RNode t₁ x t₂) y t₃) bal-left Black (Stay _ _ l) v r _ _ = Stay Black tt (BNode l v r) bal-left {cᵣ = Black} Black (Down t₁) x (Node {cₗ = Red} Black _ _ (Node {cₗ = Black} {cᵣ = Black} _ _ _ t₂ y t₃) z t₄) _ _ = Stay Black tt (BNode (BNode t₁ x t₂) y (BNode t₃ z t₄)) bal-left {cᵣ = Red} Black (Down t₁) x (Node {cₗ = Black} {cᵣ = Black} _ _ _ (Node {cₗ = Red} Black _ _ (Node {cₗ = Black} {cᵣ = Black} _ _ _ t₂ y t₃) z t₄) w t₅) _ _ = Stay Black tt (BNode (BNode t₁ x t₂) y (RNode (BNode t₃ z t₄) w t₅)) bal-left {cᵣ = Red} Black (Down t₁) x (Node {cₗ = Black} {cᵣ = Black} _ _ _ (Node {cₗ = Black} _ _ _ t₂ y t₃) z t₄) _ _ = Stay Black tt (BNode (BNode (RNode t₁ x t₂) y t₃) z t₄) bal-left {cᵣ = Black} Black (Down t₁) x (Node {cₗ = Black} _ _ _ t₂ y t₃) _ _ = Down (BNode (RNode t₁ x t₂) y t₃)
{ "alphanum_fraction": 0.5912897822, "avg_line_length": 52.2919708029, "ext": "agda", "hexsha": "434f91df79e539328d325681ef3bb239db31da1b", "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": "c0c33dff4b114381561c011df4d5cf5da7a083f0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "xuanruiqi/dtp", "max_forks_repo_path": "RedBlack.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0c33dff4b114381561c011df4d5cf5da7a083f0", "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": "xuanruiqi/dtp", "max_issues_repo_path": "RedBlack.agda", "max_line_length": 169, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0c33dff4b114381561c011df4d5cf5da7a083f0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "xuanruiqi/dtp", "max_stars_repo_path": "RedBlack.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3091, "size": 7164 }