Search is not available for this dataset
text
string
meta
dict
------------------------------------------------------------------------ -- The Agda standard library -- -- Some properties about subsets ------------------------------------------------------------------------ module Data.Fin.Subset.Properties where open import Algebra import Algebra.Properties.BooleanAlgebra as BoolProp open import Data.Empty using (⊥-elim) open import Data.Fin using (Fin); open Data.Fin.Fin open import Data.Fin.Subset open import Data.Nat using (ℕ) open import Data.Product open import Data.Sum as Sum open import Data.Vec hiding (_∈_) open import Function open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence using (_⇔_; equivalence; module Equivalence) open import Relation.Binary open import Relation.Binary.PropositionalEquality as P using (_≡_) ------------------------------------------------------------------------ -- Constructor mangling drop-there : ∀ {s n x} {p : Subset n} → suc x ∈ s ∷ p → x ∈ p drop-there (there x∈p) = x∈p drop-∷-⊆ : ∀ {n s₁ s₂} {p₁ p₂ : Subset n} → s₁ ∷ p₁ ⊆ s₂ ∷ p₂ → p₁ ⊆ p₂ drop-∷-⊆ p₁s₁⊆p₂s₂ x∈p₁ = drop-there $ p₁s₁⊆p₂s₂ (there x∈p₁) drop-∷-Empty : ∀ {n s} {p : Subset n} → Empty (s ∷ p) → Empty p drop-∷-Empty ¬∃∈ (x , x∈p) = ¬∃∈ (suc x , there x∈p) ------------------------------------------------------------------------ -- Properties involving ⊥ ∉⊥ : ∀ {n} {x : Fin n} → x ∉ ⊥ ∉⊥ (there p) = ∉⊥ p ⊥⊆ : ∀ {n} {p : Subset n} → ⊥ ⊆ p ⊥⊆ x∈⊥ with ∉⊥ x∈⊥ ... | () Empty-unique : ∀ {n} {p : Subset n} → Empty p → p ≡ ⊥ Empty-unique {p = []} ¬∃∈ = P.refl Empty-unique {p = s ∷ p} ¬∃∈ with Empty-unique (drop-∷-Empty ¬∃∈) Empty-unique {p = outside ∷ .⊥} ¬∃∈ | P.refl = P.refl Empty-unique {p = inside ∷ .⊥} ¬∃∈ | P.refl = ⊥-elim (¬∃∈ (zero , here)) ------------------------------------------------------------------------ -- Properties involving ⊤ ∈⊤ : ∀ {n} {x : Fin n} → x ∈ ⊤ ∈⊤ {x = zero} = here ∈⊤ {x = suc x} = there ∈⊤ ⊆⊤ : ∀ {n} {p : Subset n} → p ⊆ ⊤ ⊆⊤ = const ∈⊤ ------------------------------------------------------------------------ -- A property involving ⁅_⁆ x∈⁅y⁆⇔x≡y : ∀ {n} {x y : Fin n} → x ∈ ⁅ y ⁆ ⇔ x ≡ y x∈⁅y⁆⇔x≡y {x = x} {y} = equivalence (to y) (λ x≡y → P.subst (λ y → x ∈ ⁅ y ⁆) x≡y (x∈⁅x⁆ x)) where to : ∀ {n x} (y : Fin n) → x ∈ ⁅ y ⁆ → x ≡ y to (suc y) (there p) = P.cong suc (to y p) to zero here = P.refl to zero (there p) with ∉⊥ p ... | () x∈⁅x⁆ : ∀ {n} (x : Fin n) → x ∈ ⁅ x ⁆ x∈⁅x⁆ zero = here x∈⁅x⁆ (suc x) = there (x∈⁅x⁆ x) ------------------------------------------------------------------------ -- A property involving _∪_ ∪⇔⊎ : ∀ {n} {p₁ p₂ : Subset n} {x} → x ∈ p₁ ∪ p₂ ⇔ (x ∈ p₁ ⊎ x ∈ p₂) ∪⇔⊎ = equivalence (to _ _) from where to : ∀ {n} (p₁ p₂ : Subset n) {x} → x ∈ p₁ ∪ p₂ → x ∈ p₁ ⊎ x ∈ p₂ to [] [] () to (inside ∷ p₁) (s₂ ∷ p₂) here = inj₁ here to (outside ∷ p₁) (inside ∷ p₂) here = inj₂ here to (s₁ ∷ p₁) (s₂ ∷ p₂) (there x∈p₁∪p₂) = Sum.map there there (to p₁ p₂ x∈p₁∪p₂) ⊆∪ˡ : ∀ {n p₁} (p₂ : Subset n) → p₁ ⊆ p₁ ∪ p₂ ⊆∪ˡ [] () ⊆∪ˡ (s ∷ p₂) here = here ⊆∪ˡ (s ∷ p₂) (there x∈p₁) = there (⊆∪ˡ p₂ x∈p₁) ⊆∪ʳ : ∀ {n} (p₁ p₂ : Subset n) → p₂ ⊆ p₁ ∪ p₂ ⊆∪ʳ p₁ p₂ rewrite BooleanAlgebra.∨-comm (booleanAlgebra _) p₁ p₂ = ⊆∪ˡ p₁ from : ∀ {n} {p₁ p₂ : Subset n} {x} → x ∈ p₁ ⊎ x ∈ p₂ → x ∈ p₁ ∪ p₂ from (inj₁ x∈p₁) = ⊆∪ˡ _ x∈p₁ from (inj₂ x∈p₂) = ⊆∪ʳ _ _ x∈p₂ ------------------------------------------------------------------------ -- _⊆_ is a partial order -- The "natural poset" associated with the boolean algebra. module NaturalPoset where private open module BA {n} = BoolProp (booleanAlgebra n) public using (poset) open module Po {n} = Poset (poset {n = n}) public -- _⊆_ is equivalent to the natural lattice order. orders-equivalent : ∀ {n} {p₁ p₂ : Subset n} → p₁ ⊆ p₂ ⇔ p₁ ≤ p₂ orders-equivalent = equivalence (to _ _) (from _ _) where to : ∀ {n} (p₁ p₂ : Subset n) → p₁ ⊆ p₂ → p₁ ≤ p₂ to [] [] p₁⊆p₂ = P.refl to (inside ∷ p₁) (_ ∷ p₂) p₁⊆p₂ with p₁⊆p₂ here to (inside ∷ p₁) (.inside ∷ p₂) p₁⊆p₂ | here = P.cong (_∷_ inside) (to p₁ p₂ (drop-∷-⊆ p₁⊆p₂)) to (outside ∷ p₁) (_ ∷ p₂) p₁⊆p₂ = P.cong (_∷_ outside) (to p₁ p₂ (drop-∷-⊆ p₁⊆p₂)) from : ∀ {n} (p₁ p₂ : Subset n) → p₁ ≤ p₂ → p₁ ⊆ p₂ from [] [] p₁≤p₂ x = x from (.inside ∷ _) (_ ∷ _) p₁≤p₂ here rewrite P.cong head p₁≤p₂ = here from (_ ∷ p₁) (_ ∷ p₂) p₁≤p₂ (there xs[i]=x) = there (from p₁ p₂ (P.cong tail p₁≤p₂) xs[i]=x) -- _⊆_ is a partial order. poset : ℕ → Poset _ _ _ poset n = record { Carrier = Subset n ; _≈_ = _≡_ ; _≤_ = _⊆_ ; isPartialOrder = record { isPreorder = record { isEquivalence = P.isEquivalence ; reflexive = λ i≡j → from ⟨$⟩ reflexive i≡j ; trans = λ x⊆y y⊆z → from ⟨$⟩ trans (to ⟨$⟩ x⊆y) (to ⟨$⟩ y⊆z) } ; antisym = λ x⊆y y⊆x → antisym (to ⟨$⟩ x⊆y) (to ⟨$⟩ y⊆x) } } where open NaturalPoset open module E {p₁ p₂} = Equivalence (orders-equivalent {n = n} {p₁ = p₁} {p₂ = p₂})
{ "alphanum_fraction": 0.4564102564, "avg_line_length": 33.5350318471, "ext": "agda", "hexsha": "722a0767a0fa15bad8487eb9de07922695cc4cb7", "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/Fin/Subset/Properties.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/Fin/Subset/Properties.agda", "max_line_length": 100, "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/Fin/Subset/Properties.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": 2227, "size": 5265 }
{- - UARel given by a universe and equivalences - SubstRel and DUARel for the element family over the universe -} {-# OPTIONS --no-exact-split --safe #-} module Cubical.Displayed.Universe where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Displayed.Base open import Cubical.Displayed.Subst private variable ℓA ℓ≅A ℓB ℓ≅B ℓP : Level 𝒮-Univ : ∀ ℓ → UARel (Type ℓ) ℓ 𝒮-Univ ℓ .UARel._≅_ = _≃_ 𝒮-Univ ℓ .UARel.ua _ _ = isoToEquiv (invIso univalenceIso) 𝒮ˢ-El : ∀ ℓ → SubstRel (𝒮-Univ ℓ) (λ X → X) 𝒮ˢ-El ℓ .SubstRel.act e = e 𝒮ˢ-El ℓ .SubstRel.uaˢ e a = uaβ e a 𝒮ᴰ-El : ∀ ℓ → DUARel (𝒮-Univ ℓ) (λ X → X) ℓ 𝒮ᴰ-El ℓ .DUARel._≅ᴰ⟨_⟩_ a e a' = e .fst a ≡ a' 𝒮ᴰ-El ℓ .DUARel.uaᴰ a e a' = invEquiv (ua-ungluePath-Equiv e)
{ "alphanum_fraction": 0.6996547756, "avg_line_length": 26.3333333333, "ext": "agda", "hexsha": "5a2da6f0ee54dd3f696f38df5493f7935231fe36", "lang": "Agda", "max_forks_count": 134, "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_path": "Cubical/Displayed/Universe.agda", "max_issues_count": 584, "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_path": "Cubical/Displayed/Universe.agda", "max_line_length": 64, "max_stars_count": 301, "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_path": "Cubical/Displayed/Universe.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "num_tokens": 388, "size": 869 }
module nodcap.Show where open import Coinduction open import Category.Monad.State using (State; StateMonadState; module RawMonadState) open import Data.Nat as ℕ using (ℕ; suc; zero) open import Data.Nat.Show as ℕS using () open import Data.Fin as F using (Fin; suc; zero) open import Data.Pos as ℕ⁺ open import Data.List as L using (List; []; _∷_; length) open import Data.List.Any as LA using (Any; here; there) open import Data.List.Any.Properties as LAP using (++ˡ; ++ʳ) open import Data.Product as PR using (proj₁) open import Data.String as S using (String; _++_) open import Data.Stream as X using (Stream; _∷_; lookup) open import Data.Vec as V using (Vec) open import Function using (_∘_) open import Function.Equality using (_⟨$⟩_) open import Function.Inverse as I using () open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_) open import Data.Environment open import nodcap.Base open import nodcap.Typing open I.Inverse using (to; from) showTerm : {Γ : Environment} → ⊢ Γ → String showTerm {Γ} x = proj₁ (go bound x state) where open RawMonadState (StateMonadState (Stream String)) names : Stream String names = X.map (("x" S.++_) ∘ ℕS.show) (naturals 0) where naturals : ℕ → Stream ℕ naturals n = n ∷ ♯ naturals (suc n) fresh : State (Stream String) String fresh = get >>= λ{(x ∷ xs) → put (♭ xs) >> return x} go : {Γ : Environment} (bound : {w : Type} → w ∈ Γ → String) → ⊢ Γ → State (Stream String) String go bound ax = return (boundˣ ++ "<->" ++ boundʸ) where boundˣ = bound (here P.refl) boundʸ = bound (there (here P.refl)) go bound (cut {Γ} {Δ} {A} x y) = fresh >>= withFresh where withFresh : String → State (Stream String) String withFresh boundˣ = go bound₁ x >>= λ x' → go bound₂ y >>= λ y' → return ("new " ++ boundˣ ++ ".(" ++ x' ++ "|" ++ y' ++ ")") where bound₁ : {w : Type} → w ∈ A ∷ Γ → String bound₁ (here px) = boundˣ bound₁ (there i) = bound (++ˡ i) bound₂ : {w : Type} → w ∈ A ^ ∷ Δ → String bound₂ (here px) = boundˣ bound₂ (there i) = bound (++ʳ Γ i) go bound (send {Γ} {Δ} {A} {B} x y) = fresh >>= withFresh where withFresh : String → State (Stream String) String withFresh boundʸ = go bound₁ x >>= λ x' → go bound₂ y >>= λ y' → return (boundˣ ++ "[" ++ boundʸ ++ "].(" ++ x' ++ "|" ++ y' ++ ")") where boundˣ = bound (here P.refl) bound₁ : {w : Type} → w ∈ A ∷ Γ → String bound₁ (here px) = boundʸ bound₁ (there i) = bound (there (++ˡ i)) bound₂ : {w : Type} → w ∈ B ∷ Δ → String bound₂ (here px) = bound (here P.refl) bound₂ (there i) = bound (there (++ʳ Γ i)) go bound (recv {Γ} {A} {B} x) = fresh >>= withFresh where withFresh : String → State (Stream String) String withFresh boundʸ = go bound₁ x >>= λ x' → return (boundˣ ++ "(" ++ boundʸ ++ ")." ++ x') where boundˣ = bound (here P.refl) bound₁ : {w : Type} → w ∈ A ∷ B ∷ Γ → String bound₁ (here px) = boundʸ bound₁ (there (here px)) = boundˣ bound₁ (there (there i)) = bound (there i) go bound (sel₁ {Γ} {A} {B} x) = go bound₁ x >>= λ x' → return (boundˣ ++ "[inl]." ++ x') where boundˣ = bound (here P.refl) bound₁ : {w : Type} → w ∈ A ∷ Γ → String bound₁ (here px) = boundˣ bound₁ (there i) = bound (there i) go bound (sel₂ {Γ} {A} {B} x) = go bound₁ x >>= λ x' → return (boundˣ ++ "[inr]." ++ x') where boundˣ = bound (here P.refl) bound₁ : {w : Type} → w ∈ B ∷ Γ → String bound₁ (here px) = boundˣ bound₁ (there i) = bound (there i) go bound (case {Γ} {A} {B} x y) = go bound₁ x >>= λ x' → go bound₂ y >>= λ y' → return ("case " ++ boundˣ ++ " {" ++ x' ++ ";" ++ y' ++ "}") where boundˣ = bound (here P.refl) bound₁ : {w : Type} → w ∈ A ∷ Γ → String bound₁ (here px) = boundˣ bound₁ (there i) = bound (there i) bound₂ : {w : Type} → w ∈ B ∷ Γ → String bound₂ (here px) = boundˣ bound₂ (there i) = bound (there i) go bound halt = return (boundˣ ++ "[].0") where boundˣ = bound (here P.refl) go bound (wait x) = go (bound ∘ there) x >>= λ x' → return (boundˣ ++ "()." ++ x') where boundˣ = bound (here P.refl) go bound loop = return ("case " ++ boundˣ ++ " {;}") where boundˣ = bound (here P.refl) go bound (mk?₁ {Γ} {A} x) = fresh >>= withFresh where withFresh : String → State (Stream String) String withFresh boundʸ = go bound₁ x >>= λ x' → return ("?" ++ boundˣ ++ "[" ++ boundʸ ++ "]." ++ x') where boundˣ = bound (here P.refl) bound₁ : {w : Type} → w ∈ A ∷ Γ → String bound₁ (here px) = boundʸ bound₁ (there i) = bound (there i) go bound (mk!₁ {Γ} {A} x) = fresh >>= withFresh where withFresh : String → State (Stream String) String withFresh boundʸ = go bound₁ x >>= λ x' → return ("!" ++ boundˣ ++ "(" ++ boundʸ ++ ")." ++ x') where boundˣ = bound (here P.refl) bound₁ : {w : Type} → w ∈ A ∷ Γ → String bound₁ (here px) = boundʸ bound₁ (there i) = bound (there i) go bound (cont {Γ} {A} {m} {n} x) = go bound₁ x where boundˣ = bound (here P.refl) bound₁ : {w : Type} → w ∈ ?[ m ] A ∷ ?[ n ] A ∷ Γ → String bound₁ (here px) = boundˣ bound₁ (there (here px)) = boundˣ bound₁ (there (there i)) = bound (there i) go bound (pool {Γ} {Δ} {A} {m} {n} x y) = go bound₁ x >>= λ x' → go bound₂ y >>= λ y' → return ("(" ++ x' ++ "|" ++ y' ++ ")") where boundˣ = bound (here P.refl) bound₁ : {w : Type} → w ∈ ![ m ] A ∷ Γ → String bound₁ (here px) = boundˣ bound₁ (there i) = bound (there (++ˡ i)) bound₂ : {w : Type} → w ∈ ![ n ] A ∷ Δ → String bound₂ (here px) = boundˣ bound₂ (there i) = bound (there (++ʳ Γ i)) go bound (exch b x) = go (bound ∘ (to b ⟨$⟩_)) x bound : {w : Type} → w ∈ Γ → String bound i = V.lookup (toFin i) (X.take (length Γ) names) where toFin : {Γ : Environment} {w : Type} → w ∈ Γ → Fin (length Γ) toFin (here px) = zero toFin (there i) = suc (toFin i) state : Stream String state = X.drop (length Γ) names
{ "alphanum_fraction": 0.5052910053, "avg_line_length": 37.3846153846, "ext": "agda", "hexsha": "899b812e302c13f7f807a950fa38730c70e0de18", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-05T08:58:13.000Z", "max_forks_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "pepijnkokke/nodcap", "max_forks_repo_path": "src/cpnd1/nodcap/Show.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "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": "pepijnkokke/nodcap", "max_issues_repo_path": "src/cpnd1/nodcap/Show.agda", "max_line_length": 101, "max_stars_count": 4, "max_stars_repo_head_hexsha": "fb5e78d6182276e4d93c4c0e0d563b6b027bc5c2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "wenkokke/nodcap", "max_stars_repo_path": "src/cpnd1/nodcap/Show.agda", "max_stars_repo_stars_event_max_datetime": "2019-09-24T20:16:35.000Z", "max_stars_repo_stars_event_min_datetime": "2018-09-05T08:58:11.000Z", "num_tokens": 2213, "size": 6804 }
-- Andreas, 2016-12-20, issue #2348 -- {-# OPTIONS -v tc.proj.like:100 #-} {-# OPTIONS --show-implicit #-} -- NEEDED -- something projection like record Wrap (A : Set) : Set where field out : A proj-like : {{A : Set}} {{r : Wrap A}} → A proj-like {{r = r}} = Wrap.out r -- display term with projection like thing postulate B : Set b : B P : B → Set p : P b instance w : Wrap B ok = proj-like {{B}} {{r = w}} test : P (proj-like {{B}}) test = p -- triggers error message -- EXPECTED ERROR: -- b != Wrap.out w of type B -- when checking that the expression p has type P (proj-like {{r = w}})
{ "alphanum_fraction": 0.585089141, "avg_line_length": 18.696969697, "ext": "agda", "hexsha": "fe133efa88a7d92ede1fab715656dfa102e6a8ce", "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/Issue2348.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/Issue2348.agda", "max_line_length": 71, "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/Issue2348.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 197, "size": 617 }
module Syntax.Function where import Lvl open import Type open import Syntax.Type private variable ℓ : Lvl.Level private variable T A B C : Type{ℓ} infix 2 [↦] [⤠] [⤇] -- Custom syntax for an anonymous function -- Example: -- f : A → A -- f = a ↦ a -- -- g : (A → A → A) → (A → A → A) -- g(_▫_) = a₁ ↦ a₂ ↦ (a₁ ▫ a₂) [↦] : T → T [↦] x = x syntax [↦](\x → y) = x ↦ y {-# DISPLAY [↦] x = x #-} -- Custom syntax for an anonymous function with an implicit argument -- Example: -- f : A → A -- f = a ↦ a [⤠] : (A → B) → ({A} → B) [⤠] f{x} = f(x) syntax [⤠](\x → y) = x ⤠ y {-# DISPLAY [⤠] x = x #-} -- Custom syntax for an anonymous function with an instance argument [⤇] : (A → B) → (⦃ _ : A ⦄ → B) [⤇] f ⦃ x ⦄ = f(x) syntax [⤇](\x → y) = x ⤇ y {-# DISPLAY [⤇] x = x #-} -- Functions with two parameters as an infix binary operator _⦗_⦘_ : A → (A → B → C) → B → C a ⦗ op ⦘ b = op a b infix 10000 _⦗_⦘_ infixl 10000 _⦗_⦘ₗ_ infixr 10000 _⦗_⦘ᵣ_ _⦗_⦘ₗ_ = _⦗_⦘_ _⦗_⦘ᵣ_ = _⦗_⦘_ {- TODO: Fix these with stuff in Lang.Function f : {a : A} → A f = (a ⤠ a) g : ⦃ a₁ : A ⦄ ⦃ a₂ : A ⦄ → A g = (a₁ ⤇ a₂ ⤇ a₁) -}
{ "alphanum_fraction": 0.5075690116, "avg_line_length": 19.701754386, "ext": "agda", "hexsha": "7d339801ac14b471f97e36959be71ddbb037f211", "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": "Syntax/Function.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": "Syntax/Function.agda", "max_line_length": 68, "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": "Syntax/Function.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": 562, "size": 1123 }
open import Agda.Builtin.Nat open import Agda.Builtin.Unit open import Agda.Builtin.Reflection renaming (bindTC to _>>=_) open import Agda.Builtin.List open import Agda.Builtin.Sigma open import Agda.Builtin.Equality infixr -1 _$_ _$_ : ∀ {a b}{A : Set a}{B : Set b} → (A → B) → A → B f $ x = f x 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 reverse : ∀ {a}{A : Set a} → List A → List A reverse {A = A} xs = reverseAcc xs [] where reverseAcc : List A → List A → List A reverseAcc [] a = a reverseAcc (x ∷ xs) a = reverseAcc xs (x ∷ a) data Fin : Nat → Set where zero : ∀ {n} → Fin (suc n) suc : ∀ {n} → Fin n → Fin (suc n) infixr 5 _∷_ data Vec {a} (A : Set a) : Nat → Set a where [] : Vec A zero _∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n) data Ix : (d : Nat) → (s : Vec Nat d) → Set where [] : Ix 0 [] _∷_ : ∀ {d s x} → Fin x → (ix : Ix d s) → Ix (suc d) (x ∷ s) record Ar {a} (X : Set a) (d : Nat) (s : Vec Nat d) : Set a where constructor imap field sel : Ix d s → X open Ar public foo : Nat → Nat foo x = 1 + x test-ar : ∀ {n} → (a : Ar Nat 1 (n ∷ [])) → Ar Nat 1 (n ∷ []) test-ar (imap f) = imap λ iv → foo $ foo $ f iv -- Make sure that the telescope is also reconstructed when -- calling getDefinition with withReconstructed. macro z : Name → Term → TC ⊤ z n hole = do (function (clause tel ps t ∷ [])) ← withReconstructed $ getDefinition n where _ → quoteTC "ERROR" >>= unify hole t ← withReconstructed $ inContext (reverse tel) $ normalise t quoteTC t >>= unify hole test₁ : z test-ar ≡ con (quote imap) (_ ∷ _ ∷ _ ∷ _ ∷ arg _ (lam _ (abs "iv" (con (quote Nat.suc) _))) ∷ []) test₁ = refl -- Make sure that getType behaves correctly under withReconstructed. macro q : Name → Term → TC ⊤ q n hole = do t ← withReconstructed $ getType n t ← withReconstructed $ normalise t quoteTC t >>= unify hole test₂ : Term test₂ = q test-ar
{ "alphanum_fraction": 0.5440487348, "avg_line_length": 26.0243902439, "ext": "agda", "hexsha": "8f6ef819f9f21e126545495de01f62e01c8ec271", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "Seanpm2001-Agda-lang/agda", "max_forks_repo_path": "test/Succeed/recons-tele.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "Seanpm2001-Agda-lang/agda", "max_issues_repo_path": "test/Succeed/recons-tele.agda", "max_line_length": 68, "max_stars_count": 1, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "test/Succeed/recons-tele.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z", "num_tokens": 751, "size": 2134 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of constructions over unary relations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Unary.Properties where open import Data.Product using (_×_; _,_; swap; proj₁) open import Data.Sum.Base using (inj₁; inj₂) open import Data.Unit using (tt) open import Relation.Binary.Core hiding (Decidable) open import Relation.Unary open import Relation.Nullary using (yes; no) open import Relation.Nullary.Product using (_×-dec_) open import Relation.Nullary.Sum using (_⊎-dec_) open import Relation.Nullary.Negation using (¬?) open import Function using (_$_; _∘_) ---------------------------------------------------------------------- -- The empty set module _ {a} {A : Set a} where ∅? : Decidable {A = A} ∅ ∅? _ = no λ() ∅-Empty : Empty {A = A} ∅ ∅-Empty x () ∁∅-Universal : Universal {A = A} (∁ ∅) ∁∅-Universal = λ x x∈∅ → x∈∅ ---------------------------------------------------------------------- -- The universe module _ {a} {A : Set a} where U? : Decidable {A = A} U U? _ = yes tt U-Universal : Universal {A = A} U U-Universal = λ _ → _ ∁U-Empty : Empty {A = A} (∁ U) ∁U-Empty = λ x x∈∁U → x∈∁U _ ---------------------------------------------------------------------- -- Subset properties module _ {a ℓ} {A : Set a} where ∅-⊆ : (P : Pred A ℓ) → ∅ ⊆ P ∅-⊆ P () ⊆-U : (P : Pred A ℓ) → P ⊆ U ⊆-U P _ = _ ⊆-refl : Reflexive (_⊆_ {A = A} {ℓ}) ⊆-refl x∈P = x∈P ⊆-trans : Transitive (_⊆_ {A = A} {ℓ}) ⊆-trans P⊆Q Q⊆R x∈P = Q⊆R (P⊆Q x∈P) ⊂-asym : Asymmetric (_⊂_ {A = A} {ℓ}) ⊂-asym (_ , Q⊈P) = Q⊈P ∘ proj₁ ---------------------------------------------------------------------- -- Decidability properties module _ {a} {A : Set a} where ∁? : ∀ {ℓ} {P : Pred A ℓ} → Decidable P → Decidable (∁ P) ∁? P? x = ¬? (P? x) _∪?_ : ∀ {ℓ₁ ℓ₂} {P : Pred A ℓ₁} {Q : Pred A ℓ₂} → Decidable P → Decidable Q → Decidable (P ∪ Q) _∪?_ P? Q? x = (P? x) ⊎-dec (Q? x) _∩?_ : ∀ {ℓ₁ ℓ₂} {P : Pred A ℓ₁} {Q : Pred A ℓ₂} → Decidable P → Decidable Q → Decidable (P ∩ Q) _∩?_ P? Q? x = (P? x) ×-dec (Q? x) module _ {a b} {A : Set a} {B : Set b} where _×?_ : ∀ {ℓ₁ ℓ₂} {P : Pred A ℓ₁} {Q : Pred B ℓ₂} → Decidable P → Decidable Q → Decidable (P ⟨×⟩ Q) _×?_ P? Q? (a , b) = (P? a) ×-dec (Q? b) _⊙?_ : ∀ {ℓ₁ ℓ₂} {P : Pred A ℓ₁} {Q : Pred B ℓ₂} → Decidable P → Decidable Q → Decidable (P ⟨⊙⟩ Q) _⊙?_ P? Q? (a , b) = (P? a) ⊎-dec (Q? b) _⊎?_ : ∀ {ℓ} {P : Pred A ℓ} {Q : Pred B ℓ} → Decidable P → Decidable Q → Decidable (P ⟨⊎⟩ Q) _⊎?_ P? Q? (inj₁ a) = P? a _⊎?_ P? Q? (inj₂ b) = Q? b _~? : ∀ {ℓ} {P : Pred (A × B) ℓ} → Decidable P → Decidable (P ~) _~? P? = P? ∘ swap
{ "alphanum_fraction": 0.4478079332, "avg_line_length": 27.6346153846, "ext": "agda", "hexsha": "8d1d0e642aa396b7a040c34de418746f66cb609e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Properties.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1135, "size": 2874 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Truncation.Base where open import Cubical.Data.NatMinusOne open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.HITs.Sn data ∥_∥_ {ℓ} (A : Type ℓ) (n : ℕ₋₁) : Type ℓ where ∣_∣ : A → ∥ A ∥ n hub : (f : S (1+ n) → ∥ A ∥ n) → ∥ A ∥ n spoke : (f : S (1+ n) → ∥ A ∥ n) (x : S (1+ n)) → hub f ≡ f x
{ "alphanum_fraction": 0.5965346535, "avg_line_length": 28.8571428571, "ext": "agda", "hexsha": "3995c525e88e6de9e3abb8acffe3a2fba707a220", "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/HITs/Truncation/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/HITs/Truncation/Base.agda", "max_line_length": 63, "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/HITs/Truncation/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 175, "size": 404 }
module _ where open import Agda.Builtin.Bool open import Agda.Builtin.Nat renaming (_==_ to _==N_; _<_ to _<N_) record Eq (A : Set) : Set where field _==_ : A → A → Bool open Eq {{...}} record Ord (A : Set) : Set where constructor mkOrd field _<_ : A → A → Bool overlap {{eqA}} : Eq A open Ord {{...}} hiding (eqA) record Num (A : Set) : Set where constructor mkNum field fromNat : Nat → A overlap {{eqA}} : Eq A open Num {{...}} hiding (eqA) instance EqNat : Eq Nat _==_ {{EqNat}} = _==N_ OrdNat : Ord Nat _<_ {{OrdNat}} = _<N_ Ord.eqA OrdNat = EqNat NumNat : Num Nat fromNat {{NumNat}} n = n Num.eqA NumNat = EqNat infixr 3 _||_ _||_ : Bool → Bool → Bool true || x = true false || x = x -- Here it will pick the eq dictionary from the Ord leq3 : {A : Set} {{OrdA : Ord A}} {{NumA : Num A}} → A → Bool leq3 x = x == fromNat 3 || x < fromNat 3 open import Agda.Builtin.Equality 2<3 : true ≡ leq3 2 2<3 = refl it : ∀ {a} {A : Set a} {{_ : A}} → A it {{x}} = x -- Check that you get the first shared dictionary getShared : {A : Set} {{OrdA : Ord A}} {{NumA : Num A}} → Eq A getShared = it itsOrd : {A : Set} {{OrdA : Ord A}} {{NumA : Num A}} → getShared ≡ Ord.eqA OrdA itsOrd = refl -- Check that it also works if you pattern match on the dictionaries leq3' : {A : Set} {{OrdA : Ord A}} {{NumA : Num A}} → A → Bool leq3' {{mkOrd _<_}} {{mkNum fromNat}} x = x == fromNat 3 || x < fromNat 3
{ "alphanum_fraction": 0.5828178694, "avg_line_length": 20.7857142857, "ext": "agda", "hexsha": "58ac8e80c349fefd82b82efd032ab59710e8233b", "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/SharedSuperclasses.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/SharedSuperclasses.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/Succeed/SharedSuperclasses.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": 542, "size": 1455 }
{-# OPTIONS --rewriting #-} module GSeTT.GSeTT where open import GSeTT.Syntax open import GSeTT.Rules import GSeTT.CwF-structure import GSeTT.Dec-Type-Checking import GSeTT.Uniqueness-Derivations open import GSeTT.Typed-Syntax
{ "alphanum_fraction": 0.7613168724, "avg_line_length": 18.6923076923, "ext": "agda", "hexsha": "8f9af49737310ab3a96d9eb042104abbc73be87a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thibautbenjamin/catt-formalization", "max_forks_repo_path": "GSeTT/GSeTT.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thibautbenjamin/catt-formalization", "max_issues_repo_path": "GSeTT/GSeTT.agda", "max_line_length": 37, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thibautbenjamin/catt-formalization", "max_stars_repo_path": "GSeTT/GSeTT.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 76, "size": 243 }
------------------------------------------------------------------------ -- Code related to the paper "Isomorphism Is Equality" by Thierry -- Coquand and Nils Anders Danielsson -- -- The code is written by Nils Anders Danielsson ------------------------------------------------------------------------ -- Note that the code has been changed after the paper was published. {-# OPTIONS --without-K --safe #-} module README.Isomorphism-is-equality where ---===================================================================== -- 2: Preliminaries ------------------------------------------------------------------------ -- 2.1: Hierarchy of Types -- The lifting operator ↑. (Note that Agda is universe-polymorphic.) import Prelude ------------------------------------------------------------------------ -- 2.2: Quantifiers -- Σ, ∃ and _×_. (The code sometimes uses ∃ instead of Σ.) import Prelude ------------------------------------------------------------------------ -- 2.3: Equality -- Axiomatisations of equality, used in order to ensure that the -- elimination rule (J) does not compute. J is called elim in the -- code. import Equality -- Bijections (_↔_), the key property of equality of Σ-types -- (Σ-≡,≡↔≡). import Bijection -- Extensionality. import Equality -- "∀ x. f x ≡ g x is in bijective correspondence with f ≡ g" -- (extensionality-isomorphism). import Equivalence ------------------------------------------------------------------------ -- 2.4: More Types -- ⊤, ⊥, _+_ (called _⊎_ in the code), ℕ. import Prelude -- Logical equivalences (_⇔_). import Logical-equivalence ------------------------------------------------------------------------ -- 2.5: Univalent Foundations -- Contractible. import Equality -- H-level, Is-proposition, Is-set. import H-level -- Results that can be used to establish that a type has a certain -- h-level. import H-level import H-level.Closure import Equality.Decidable-UIP -- Propositional second components of pairs can be dropped -- (ignore-propositional-component). import Function-universe -- Is-equivalence, subst P eq is an equivalence -- (subst-is-equivalence), _≃_, _≃_ is logically equivalent to _↔_ and -- related properties (_≃_.bijection, ↔⇒≃, ↔↔≃, ⇔↔≃), Σ and Π preserve -- equivalences (Σ-preserves, Π-preserves). import Equivalence -- More congruence properties (including _⊎-cong_ and →-cong). import Function-universe -- ≡⇒≃, Univalence, ≃⇒≡, the univalence axiom implies extensionality -- (dependent-extensionality), the transport theorem -- (transport-theorem), resp eq is an equivalence -- (resp-is-equivalence), resp eq preserves compositions -- (resp-preserves-compositions). import Univalence-axiom ---===================================================================== -- 3: Isomorphism Is Equality ------------------------------------------------------------------------ -- 3.1: Parameters -- The parameters are represented using a record type called Universe. import Univalence-axiom.Isomorphism-is-equality.Simple ------------------------------------------------------------------------ -- 3.2: Codes for Structures -- Code, Instance, Is-isomorphism, Isomorphic, Carrier, element, -- equality-pair-lemma. import Univalence-axiom.Isomorphism-is-equality.Simple ------------------------------------------------------------------------ -- 3.3: Main Theorem -- The main result (isomorphism-is-equality), isomorphism is equal to -- equality (isomorphic≡≡), the right-to-left direction of the -- bijection is equal to a simple function -- (from-isomorphism-is-equality). import Univalence-axiom.Isomorphism-is-equality.Simple ------------------------------------------------------------------------ -- 3.4: A Universe -- U, El, cast, resp, resp-id, Is-isomorphism′, -- isomorphism-definitions-isomorphic. import Univalence-axiom.Isomorphism-is-equality.Simple -- The operators _→-eq_ (→-cong-⇔), _×-eq_ (_×-cong_) and _+-eq_ -- (_⊎-cong_). import Function-universe -- The operators _→-rel_, _×-rel_ and _+-rel_ (_⊎-rel_). import Prelude ------------------------------------------------------------------------ -- 3.5: Examples -- Monoids, posets, discrete fields, fixpoint operators. import Univalence-axiom.Isomorphism-is-equality.Simple ---===================================================================== -- 4: Related Work -- Aczel's structure identity principle (structure-identity-principle). import Structure-identity-principle -- The structure identity principle can be used to prove a slightly -- restricted variant of our main theorem (isomorphism-is-equality′, -- from-isomorphism-is-equality′). import Univalence-axiom.Isomorphism-is-equality.Structure-identity-principle
{ "alphanum_fraction": 0.5629363232, "avg_line_length": 27.4825581395, "ext": "agda", "hexsha": "013704c2505f8ea75106840763ced62646591c04", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "README/Isomorphism-is-equality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "README/Isomorphism-is-equality.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "README/Isomorphism-is-equality.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 1073, "size": 4727 }
{-# OPTIONS --copattern --safe --no-sized-types --guardedness #-} module Copattern where open import Data.Nat open import Relation.Binary.PropositionalEquality record Stream (A : Set) : Set where coinductive field head : A tail : Stream A open Stream public -- | Bisimulation as equality record _==_ {A : Set} (x : Stream A) (y : Stream A) : Set where coinductive field refl-head : head x ≡ head y refl-tail : tail x == tail y open _==_ public module Introduction where ones : Stream ℕ head ones = suc zero tail ones = ones repeat : {A : Set} -> A -> Stream A repeat {A} a = P where P : Stream A head P = a tail P = repeat a even : ∀ {A} -> Stream A -> Stream A even {A} a = P where P : Stream A head P = head a tail P = even (tail (tail a)) odd : ∀ {A} -> Stream A -> Stream A odd {A} a = P where P : Stream A head P = head (tail a) tail P = odd (tail (tail a)) module Bisimulation where open Introduction refl′ : ∀ {A} -> (a : Stream A) -> a == a refl′ a = f where f : a == a refl-head f = refl refl-tail f = refl′ (tail a) oddEven : ∀ {A} -> (a : Stream A) -> odd a == even (tail a) oddEven a = f where f : odd a == even (tail a) refl-head f = refl refl-tail f = oddEven ((tail (tail a))) module Merge where open Bisimulation open Introduction merge : ∀ {A} -> Stream A -> Stream A -> Stream A merge {A} a b = ma where ma : Stream A head ma = head a tail ma = merge b (tail a) -- Merge! Even! Odd! moe : ∀ {A} -> (a : Stream A) -> (merge (even a) (odd a) == a) moe a = f where f : merge (even a) (odd a) == a refl-head f = refl refl-head (refl-tail f) = refl refl-tail (refl-tail f) = moe (tail (tail a))
{ "alphanum_fraction": 0.5655783066, "avg_line_length": 21.2588235294, "ext": "agda", "hexsha": "ec7f32ffd6c731c12668acf06c271cb9eeaef7ae", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_forks_event_min_datetime": "2019-12-13T04:50:46.000Z", "max_forks_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Brethland/LEARNING-STUFF", "max_forks_repo_path": "Agda/Copattern.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Brethland/LEARNING-STUFF", "max_issues_repo_path": "Agda/Copattern.agda", "max_line_length": 65, "max_stars_count": 2, "max_stars_repo_head_hexsha": "eb2cef0556efb9a4ce11783f8516789ea48cc344", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Brethland/LEARNING-STUFF", "max_stars_repo_path": "Agda/Copattern.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-11T10:35:42.000Z", "max_stars_repo_stars_event_min_datetime": "2020-02-03T05:05:52.000Z", "num_tokens": 606, "size": 1807 }
module safe where -- Note that if every module listed here is safe in isolation, it does -- not mean that they are using compatible options. As a consequence, -- importing a combination of some of the modules listed may lead to -- an unsafe result.
{ "alphanum_fraction": 0.764, "avg_line_length": 35.7142857143, "ext": "agda", "hexsha": "bede43fc6cd41ab296bcb7511b4b3f8a58db0c9f", "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/travis/safe.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/travis/safe.agda", "max_line_length": 70, "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/travis/safe.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": 250 }
module sv20.assign2.Second where open import sv20.assign2.SetTheory.Logic using (_⇔_; ¬_; _∧_; _∨_) renaming (_,_ to ⟨_,_⟩) open import sv20.assign2.SetTheory.ZAxioms using (𝓢; _⊆_; _∈_; _∉_; _≡_; _⊂_; sym; cong; subs; trans; proj₁; proj₂; empt; ext; union; pair; pow; sub; pem; sum) open import sv20.assign2.SetTheory.Algebra using (_∪_; _-_; _∩_) ∪-dist : (A B C : 𝓢) → A ∪ (B ∪ C) ≡ (A ∪ B) ∪ C ∪-dist = ? -- I could try going this route. This would prove certain things using -- ZFC and would be really neat but requires too much work.
{ "alphanum_fraction": 0.5612403101, "avg_line_length": 46.0714285714, "ext": "agda", "hexsha": "094031750cd0d7494587e8f5a37d70a6eb74aae6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "helq/old_code", "max_forks_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old3.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_issues_repo_issues_event_max_datetime": "2021-06-07T15:39:48.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-10T19:20:21.000Z", "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "helq/old_code", "max_issues_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old3.agda", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "a432faf1b340cb379190a2f2b11b997b02d1cd8d", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "helq/old_code", "max_stars_repo_path": "proglangs-learning/Agda/sv20/assign2/Second_old3.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 209, "size": 645 }
{-# OPTIONS --without-K #-} module FiniteTypeEquiv where open import Level open import Data.Nat using (ℕ) open import Data.Fin using (Fin) open import Data.Product open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Function.Equality using (_∘_; _⟶_; _⟨$⟩_) open ≡-Reasoning open import Function renaming (_∘_ to _○_) open import FinVec ------------------------------------------------------------------------------ -- Permutations record CPerm {ℓ : Level} (values : ℕ) (size : ℕ) : Set ℓ where constructor cp field π : FinVec values size πᵒ : FinVec size values αp : π ∘̂ πᵒ ≡ 1C βp : πᵒ ∘̂ π ≡ 1C -- Permutations are compared by ≡ -- The setoid of permutations under ≡ SCPerm : ∀ {ℓ} → ℕ → ℕ → Setoid ℓ ℓ SCPerm m n = setoid (CPerm m n) ------------------------------------------------------------------------------ -- Equivalences _∼_ : ∀ {ℓ ℓ'} → {A : Set ℓ} {P : A → Set ℓ'} → (f g : (x : A) → P x) → Set (ℓ ⊔ ℓ') _∼_ {ℓ} {ℓ'} {A} {P} f g = (x : A) → f x ≡ g x record qinv {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} (f : A → B) : Set (ℓ ⊔ ℓ') where constructor mkqinv field g : B → A α : (f ○ g) ∼ id β : (g ○ f) ∼ id _≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ') A ≃ B = Σ (A → B) qinv sym≃ : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → (A ≃ B) → (B ≃ A) sym≃ (A→B , equiv) = e.g , mkqinv A→B e.β e.α where module e = qinv equiv -- Equivalences are compared by ≋ which reduces to extensional -- equality of the underlying back and forth functions _⋆_ : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} → (A ≃ B) → (x : A) → B (f , _) ⋆ x = f x record _≋_ {ℓ ℓ' : Level} {A : Set ℓ} {B : Set ℓ'} (eq₁ eq₂ : A ≃ B) : Set (ℓ ⊔ ℓ') where constructor eq field f≡ : ∀ x → eq₁ ⋆ x ≡ eq₂ ⋆ x g≡ : ∀ x → (sym≃ eq₁) ⋆ x ≡ (sym≃ eq₂) ⋆ x id≋ : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} {x : A ≃ B} → x ≋ x id≋ = record { f≡ = λ x → refl ; g≡ = λ x → refl } sym≋ : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} {x y : A ≃ B} → x ≋ y → y ≋ x sym≋ (eq f≡ g≡) = eq (λ a → sym (f≡ a)) (λ b → sym (g≡ b)) trans≋ : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} {x y z : A ≃ B} → x ≋ y → y ≋ z → x ≋ z trans≋ (eq f≡ g≡) (eq h≡ i≡) = eq (λ a → trans (f≡ a) (h≡ a)) (λ b → trans (g≡ b) (i≡ b)) -- The setoid of equivalences under ≋ _S≃_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Setoid (ℓ ⊔ ℓ') (ℓ ⊔ ℓ') _S≃_ A B = record { Carrier = A ≃ B ; _≈_ = _≋_ ; isEquivalence = record { refl = id≋ ; sym = sym≋ ; trans = trans≋ } } ------------------------------------------------------------------------------ -- Univalence... -- On one side we have permutations under ≡ -- On the other we have equivalences under ≋ -- -- The equivalence of these two sides uses a version of ≃ (called ≃S) -- that relates setoids each with its own equivalence relation infix 4 _≃S_ record _≃S_ {ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level} (A : Setoid ℓ₁ ℓ₂) (B : Setoid ℓ₃ ℓ₄) : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) where constructor equiv field f : A ⟶ B g : B ⟶ A α : ∀ {x y} → Setoid._≈_ B x y → Setoid._≈_ B ((f ∘ g) ⟨$⟩ x) y β : ∀ {x y} → Setoid._≈_ A x y → Setoid._≈_ A ((g ∘ f) ⟨$⟩ x) y univalence : {m n : ℕ} → _≃S_ {zero} {zero} {zero} {zero} (SCPerm m n) (Fin m S≃ Fin n) univalence {m} {n} = equiv {!!} {!!} {!!} {!!} ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.4720812183, "avg_line_length": 28.8706896552, "ext": "agda", "hexsha": "15bfceacad5df92ee88a7e24d2756ee80269b3ae", "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/FiniteTypeEquiv.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/FiniteTypeEquiv.agda", "max_line_length": 82, "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/FiniteTypeEquiv.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": 1435, "size": 3349 }
module Issue857 where data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x data ⊤ : Set where tt : ⊤ data ⊥ : Set where ⊥-elim : {A : Set} → ⊥ → A ⊥-elim = λ () bad : (x : ⊥) → ⊥-elim x ≡ tt bad x = {!!} -- Goal type: x ≡ tt, with x : ⊥.
{ "alphanum_fraction": 0.4661354582, "avg_line_length": 15.6875, "ext": "agda", "hexsha": "f0a506e5d21172c3240925535a049ca8c063bcd9", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue857.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue857.agda", "max_line_length": 47, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue857.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": 118, "size": 251 }
module Oscar.Property where open import Oscar.Builtin.Numbatural open import Oscar.Builtin.Objectevel 𝑴 : ℕ → ∀ {𝔬} → Ø 𝔬 → ∀ 𝔪 → Ø 𝔬 ∙̂ ↑̂ 𝔪 𝑴 ∅ 𝔒 𝔪 = 𝔒 → Ø 𝔪 𝑴 (↑ n) 𝔒 𝔪 = 𝔒 → 𝑴 n 𝔒 𝔪 𝑴² : ∀ (m : ℕ) n {𝔬} {𝔒 : Ø 𝔬} {𝔪} → 𝑴 n 𝔒 𝔪 → ∀ 𝔮 → Ø 𝔬 ∙̂ 𝔪 ∙̂ ↑̂ 𝔮 𝑴² m ∅ 𝔒 𝔮 = ∀ {o} → 𝑴 m (𝔒 o) 𝔮 𝑴² m (↑ n) 𝔒 𝔮 = ∀ {o} → 𝑴² m n (𝔒 o) 𝔮
{ "alphanum_fraction": 0.4684684685, "avg_line_length": 23.7857142857, "ext": "agda", "hexsha": "653a32096a64661f1a9216822094c5f2324f73df", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-2/Oscar/Property.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-2/Oscar/Property.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-2/Oscar/Property.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 253, "size": 333 }
-- Andreas, 2015-06-29 fixed handling of projections in positivity checker -- {-# OPTIONS -v tc.polarity:20 -v tc.proj.like:10 -v tc.pos:10 --show-implicit #-} -- {-# OPTIONS -v tc.pos.occ:70 #-} open import Common.Prelude open import Common.Product dup : (b : Bool) (X : Set) → Set × Set dup true X = (X → X) , X dup false X = (X → X) , X postulate b : Bool data D : Set where c : proj₁ (dup b D) → D -- ERROR WAS: -- D is not strictly positive, because it occurs -- in the second argument to dup -- in the type of the constructor c -- in the definition of D. -- EXPECTED ERROR: -- D is not strictly positive, because it occurs -- in the second argument to dup -- in the first argument to proj₁ -- in the type of the constructor c -- in the definition of D.
{ "alphanum_fraction": 0.6653696498, "avg_line_length": 25.7, "ext": "agda", "hexsha": "f6ff5e11e3f149bb7cdb1e8fa971acbd45cc4cfa", "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/Issue1592c.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/Issue1592c.agda", "max_line_length": 85, "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/Issue1592c.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": 228, "size": 771 }
------------------------------------------------------------------------------ -- Agda-Prop Library. -- Normal Forms. ------------------------------------------------------------------------------ open import Data.Nat using (suc; zero; _+_;_*_) renaming (_⊔_ to max; ℕ to Nat ) module Data.PropFormula.NormalForms (n : Nat) where ------------------------------------------------------------------------------ open import Data.Bool.Base using ( Bool; true; false; if_then_else_; not) renaming (_∧_ to _and_; _∨_ to _or_) open import Data.Fin using ( Fin; #_ ) open import Data.List using ( List; [_]; []; _++_; _∷_ ; concatMap; map ) open import Data.PropFormula.Properties n using ( subst ) open import Data.PropFormula.Syntax n open import Data.PropFormula.Views n open import Relation.Nullary using (yes; no) open import Data.PropFormula.Theorems n open import Function using ( _∘_; _$_ ) open import Relation.Binary.PropositionalEquality using ( _≡_; sym ) ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Negation Normal Form (NNF) ------------------------------------------------------------------------------ -- Def. nnf₁ : Nat → PropFormula → PropFormula nnf₁ (suc n) φ with n-view φ ... | conj φ₁ φ₂ = nnf₁ n φ₁ ∧ nnf₁ n φ₂ ... | disj φ₁ φ₂ = nnf₁ n φ₁ ∨ nnf₁ n φ₂ ... | impl φ₁ φ₂ = nnf₁ n ((¬ φ₁) ∨ φ₂) ... | biimpl φ₁ φ₂ = nnf₁ n ((φ₁ ⊃ φ₂) ∧ (φ₂ ⊃ φ₁)) ... | nconj φ₁ φ₂ = nnf₁ n ((¬ φ₁) ∨ (¬ φ₂)) ... | ndisj φ₁ φ₂ = nnf₁ n ((¬ φ₁) ∧ (¬ φ₂)) ... | nneg φ₁ = nnf₁ n φ₁ ... | nimpl φ₁ φ₂ = nnf₁ n (¬ (φ₂ ∨ (¬ φ₁))) ... | nbiim φ₁ φ₂ = nnf₁ n (¬ ((φ₁ ⊃ φ₂) ∧ (φ₂ ⊃ φ₁))) ... | ntop = ⊥ ... | nbot = ⊤ ... | other .φ = φ nnf₁ zero φ = φ -- Theorem. nnf₁-lem : ∀ {Γ} {φ} → (n : Nat) → Γ ⊢ φ → Γ ⊢ nnf₁ n φ -- Proof. nnf₁-lem {Γ} {φ} (suc n) Γ⊢φ with n-view φ ... | conj φ₁ φ₂ = ∧-intro (nnf₁-lem n (∧-proj₁ Γ⊢φ)) (nnf₁-lem n (∧-proj₂ Γ⊢φ)) ... | disj φ₁ φ₂ = (⊃-elim (⊃-intro (∨-elim (∨-intro₁ (nnf₁ n φ₂) (nnf₁-lem n (assume φ₁))) (∨-intro₂ (nnf₁ n φ₁) (nnf₁-lem n (assume φ₂))))) Γ⊢φ) ... | impl φ₁ φ₂ = nnf₁-lem n (⊃-to-¬∨ Γ⊢φ) ... | biimpl φ₁ φ₂ = nnf₁-lem n (⇔-equiv₁ Γ⊢φ) ... | nconj φ₁ φ₂ = nnf₁-lem n (¬∧-to-¬∨¬ Γ⊢φ) ... | ndisj φ₁ φ₂ = nnf₁-lem n (¬∨-to-¬∧¬ Γ⊢φ) ... | nneg φ₁ = nnf₁-lem n (¬¬-equiv₁ Γ⊢φ) ... | nimpl φ₁ φ₂ = nnf₁-lem n (subst⊢¬ helper Γ⊢φ) where helper : Γ ⊢ φ₂ ∨ ¬ φ₁ ⊃ (φ₁ ⊃ φ₂) helper = ⊃-intro (¬∨-to-⊃ (∨-comm (assume (φ₂ ∨ ¬ φ₁)))) ... | nbiim φ₁ φ₂ = nnf₁-lem n (subst⊢¬ (⊃-intro (⇔-equiv₂ (assume ((φ₁ ⊃ φ₂) ∧ (φ₂ ⊃ φ₁))))) Γ⊢φ) ... | ntop = ¬-elim Γ⊢φ ⊤-intro ... | nbot = ⊤-intro ... | other .φ = Γ⊢φ nnf₁-lem {Γ} {φ} zero Γ⊢φ = Γ⊢φ --------------------------------------------------------------------------- ∎ -- Complexity measure. nnf-cm : PropFormula → Nat nnf-cm φ with n-view φ ... | conj φ₁ φ₂ = nnf-cm φ₁ + nnf-cm φ₂ + 1 ... | disj φ₁ φ₂ = nnf-cm φ₁ + nnf-cm φ₂ + 1 ... | impl φ₁ φ₂ = 2 * nnf-cm φ₁ + nnf-cm φ₂ + 1 ... | biimpl φ₁ φ₂ = 2 * (nnf-cm φ₁ + nnf-cm φ₂) + 3 ... | nconj φ₁ φ₂ = nnf-cm (¬ φ₁) + nnf-cm (¬ φ₂) + 1 ... | ndisj φ₁ φ₂ = nnf-cm (¬ φ₁) + nnf-cm (¬ φ₂) + 1 ... | nneg φ₁ = nnf-cm (¬ φ₁) + 1 ... | nimpl φ₁ φ₂ = nnf-cm φ₁ + nnf-cm (¬ φ₂) + 3 ... | nbiim φ₁ φ₂ = nnf-cm φ₁ + nnf-cm φ₂ + nnf-cm (¬ φ₁) + nnf-cm (¬ φ₂) + 8 ... | ntop = 1 ... | nbot = 1 ... | other .φ = 1 -- Def. nnf : PropFormula → PropFormula nnf φ = nnf₁ (nnf-cm φ) φ -- Theorem. nnf-lem : ∀ {Γ} {φ} → Γ ⊢ φ → Γ ⊢ nnf φ -- Proof. nnf-lem {Γ} {φ} Γ⊢φ = nnf₁-lem (nnf-cm φ) Γ⊢φ --------------------------------------------------------------------------- ∎ ------------------------------------------------------------------------------ -- Disjunctive Normal Form (DNF) ------------------------------------------------------------------------------ -- Def. dist-∧ : PropFormula → PropFormula dist-∧ φ with d-view-aux φ ... | case₁ φ₁ φ₂ φ₃ = dist-∧ (φ₁ ∧ φ₃) ∨ dist-∧ (φ₂ ∧ φ₃) ... | case₂ φ₁ φ₂ φ₃ = dist-∧ (φ₁ ∧ φ₂) ∨ dist-∧ (φ₁ ∧ φ₃) ... | other .φ = φ -- Theorem. dist-∧-lem : ∀ {Γ} {φ} → Γ ⊢ φ → Γ ⊢ dist-∧ φ -- Proof. dist-∧-lem {Γ} {φ} Γ⊢φ with d-view-aux φ dist-∧-lem {Γ} {.((φ ∨ ψ) ∧ γ)} Γ⊢⟨φ∨ψ⟩∧γ | case₁ φ ψ γ = ⊃-elim (⊃-intro (∨-elim (∨-intro₁ (dist-∧ (ψ ∧ γ)) (dist-∧-lem (∧-intro (assume φ) (weaken φ (∧-proj₂ Γ⊢⟨φ∨ψ⟩∧γ))))) (∨-intro₂ (dist-∧ (φ ∧ γ)) (dist-∧-lem (∧-intro (assume ψ) (weaken ψ (∧-proj₂ Γ⊢⟨φ∨ψ⟩∧γ))))))) (∧-proj₁ Γ⊢⟨φ∨ψ⟩∧γ) dist-∧-lem {Γ} {.(φ ∧ (ψ ∨ γ))} Γ⊢φ∧⟨ψ∨γ⟩ | case₂ φ ψ γ = ⊃-elim (⊃-intro (∨-elim (∨-intro₁ (dist-∧ (φ ∧ γ)) (dist-∧-lem (∧-intro (weaken ψ (∧-proj₁ Γ⊢φ∧⟨ψ∨γ⟩)) (assume ψ)))) (∨-intro₂ (dist-∧ (φ ∧ ψ)) (dist-∧-lem (∧-intro (weaken γ (∧-proj₁ Γ⊢φ∧⟨ψ∨γ⟩)) (assume γ)))))) (∧-proj₂ Γ⊢φ∧⟨ψ∨γ⟩) dist-∧-lem {Γ} {.φ} Γ⊢φ | other φ = Γ⊢φ --------------------------------------------------------------------------- ∎ -- Theorem. from-dist-∧-lem : ∀ {Γ} {φ} → Γ ⊢ dist-∧ φ → Γ ⊢ φ -- Proof. from-dist-∧-lem {Γ} {φ} Γ⊢φ with d-view-aux φ from-dist-∧-lem {Γ} {.((φ ∨ ψ) ∧ γ)} Γ⊢⟨φ∨ψ⟩∧γ | case₁ φ ψ γ = ∧-comm (∧-dist₂ (⊃-elim (⊃-intro (∨-elim (∨-intro₁ (γ ∧ ψ) (∧-comm (from-dist-∧-lem (assume (dist-∧ (φ ∧ γ)))))) (∨-intro₂ (γ ∧ φ) (∧-comm (from-dist-∧-lem (assume (dist-∧ (ψ ∧ γ)))))))) Γ⊢⟨φ∨ψ⟩∧γ)) from-dist-∧-lem {Γ} {.(φ ∧ (ψ ∨ γ))} Γ⊢φ∧⟨ψ∨γ⟩ | case₂ φ ψ γ = ∧-dist₂ (⊃-elim (⊃-intro (∨-elim (∨-intro₁ (φ ∧ γ) (from-dist-∧-lem (assume (dist-∧ (φ ∧ ψ))))) (∨-intro₂ (φ ∧ ψ) (from-dist-∧-lem (assume (dist-∧ (φ ∧ γ))))))) Γ⊢φ∧⟨ψ∨γ⟩) from-dist-∧-lem {Γ} {.φ} Γ⊢φ | other φ = Γ⊢φ --------------------------------------------------------------------------- ∎ -- Def. dnf-dist : PropFormula → PropFormula dnf-dist φ with d-view φ dnf-dist .(φ ∧ ψ) | conj φ ψ = dist-∧ (dnf-dist φ ∧ dnf-dist ψ) dnf-dist .(φ ∨ ψ) | disj φ ψ = dnf-dist φ ∨ dnf-dist ψ dnf-dist φ | other .φ = φ -- Theorem. dnf-dist-lem : ∀ {Γ} {φ} → Γ ⊢ φ → Γ ⊢ dnf-dist φ -- Proof. dnf-dist-lem {Γ} {φ} Γ⊢φ with d-view φ dnf-dist-lem {Γ} {φ ∧ ψ} Γ⊢φ∧ψ | conj .φ .ψ = dist-∧-lem (∧-intro (dnf-dist-lem (∧-proj₁ Γ⊢φ∧ψ)) (dnf-dist-lem (∧-proj₂ Γ⊢φ∧ψ))) dnf-dist-lem {Γ} {φ ∨ ψ} Γ⊢φ∨ψ | disj .φ .ψ = ⊃-elim (⊃-intro (∨-elim (∨-intro₁ (dnf-dist ψ) (dnf-dist-lem (assume φ))) (∨-intro₂ (dnf-dist φ) (dnf-dist-lem (assume ψ))))) Γ⊢φ∨ψ dnf-dist-lem {Γ} {φ} Γ⊢φ | other .φ = Γ⊢φ --------------------------------------------------------------------------- ∎ -- Theorem. from-dnf-dist-lem : ∀ {Γ} {φ} → Γ ⊢ dnf-dist φ → Γ ⊢ φ -- Proof. from-dnf-dist-lem {_} {φ} Γ⊢φ with d-view φ from-dnf-dist-lem {_} {φ ∧ ψ} Γ⊢φ∧ψ | conj .φ .ψ = ∧-intro (from-dnf-dist-lem {φ = φ} (∧-proj₁ (from-dist-∧-lem Γ⊢φ∧ψ))) (from-dnf-dist-lem {φ = ψ} (∧-proj₂ {φ = dnf-dist φ} (from-dist-∧-lem Γ⊢φ∧ψ))) from-dnf-dist-lem {_} {φ ∨ ψ} Γ⊢φ∨ψ | disj .φ .ψ = ⊃-elim (⊃-intro (∨-elim (∨-intro₁ ψ (from-dnf-dist-lem (assume (dnf-dist φ)))) (∨-intro₂ φ (from-dnf-dist-lem (assume (dnf-dist ψ)))))) Γ⊢φ∨ψ from-dnf-dist-lem {_} {φ} Γ⊢φ | other .φ = Γ⊢φ --------------------------------------------------------------------------- ∎ -- Def. dnf : PropFormula → PropFormula dnf = dnf-dist ∘ nnf -- Theorem. dnf-lem : ∀ {Γ} {φ} → Γ ⊢ φ → Γ ⊢ dnf φ -- Proof. dnf-lem = dnf-dist-lem ∘ nnf-lem --------------------------------------------------------------------------- ∎ ------------------------------------------------------------------------------ -- Conjunctive Normal Forms (CNF) ------------------------------------------------------------------------------ -- Def. dist-∨ : PropFormula → PropFormula dist-∨ φ with c-view-aux φ dist-∨ .((φ₁ ∧ φ₂) ∨ φ₃) | case₁ φ₁ φ₂ φ₃ = dist-∨ (φ₁ ∨ φ₃) ∧ dist-∨ (φ₂ ∨ φ₃) dist-∨ .(φ₁ ∨ (φ₂ ∧ φ₃)) | case₂ φ₁ φ₂ φ₃ = dist-∨ (φ₁ ∨ φ₂) ∧ dist-∨ (φ₁ ∨ φ₃) dist-∨ φ | other .φ = φ -- Theorem. dist-∨-lem : ∀ {Γ} {φ} → Γ ⊢ φ → Γ ⊢ dist-∨ φ -- Proof. dist-∨-lem {Γ} {φ} Γ⊢φ with c-view-aux φ dist-∨-lem {Γ} {.((φ ∧ ψ) ∨ γ)} Γ⊢φ | case₁ φ ψ γ = ∧-intro (dist-∨-lem (∧-proj₁ helper)) (dist-∨-lem (∧-proj₂ helper)) where helper : Γ ⊢ (φ ∨ γ) ∧ (ψ ∨ γ) helper = ∧-intro (∨-comm (∧-proj₁ (∨-dist₁ (∨-comm Γ⊢φ)))) (∨-comm (∧-proj₂ (∨-dist₁ (∨-comm Γ⊢φ)))) dist-∨-lem {Γ} {.(φ ∨ (ψ ∧ γ))} Γ⊢φ | case₂ φ ψ γ = ∧-intro (dist-∨-lem (∧-proj₁ (∨-dist₁ Γ⊢φ))) (dist-∨-lem (∧-proj₂ (∨-dist₁ Γ⊢φ))) dist-∨-lem {Γ} {.φ} Γ⊢φ | other φ = Γ⊢φ --------------------------------------------------------------------------- ∎ -- Theorem. from-dist-∨-lem : ∀ {Γ} {φ} → Γ ⊢ dist-∨ φ → Γ ⊢ φ -- Proof. from-dist-∨-lem {Γ} {φ} Γ⊢φ with c-view-aux φ from-dist-∨-lem {Γ} {.((φ ∧ ψ) ∨ γ)} Γ⊢φ | case₁ φ ψ γ = ∨-comm (∨-dist₂ (∧-intro (∨-comm (from-dist-∨-lem (∧-proj₁ Γ⊢φ))) (∨-comm (from-dist-∨-lem (∧-proj₂ Γ⊢φ))))) from-dist-∨-lem {Γ} {.(φ ∨ (ψ ∧ γ))} Γ⊢φ | case₂ φ ψ γ = ∨-dist₂ (∧-intro (from-dist-∨-lem (∧-proj₁ Γ⊢φ)) (from-dist-∨-lem (∧-proj₂ Γ⊢φ))) from-dist-∨-lem {Γ} {.φ} Γ⊢φ | other φ = Γ⊢φ --------------------------------------------------------------------------- ∎ -- Def. cnf-dist : PropFormula → PropFormula cnf-dist φ with d-view φ cnf-dist .(φ ∧ ψ) | conj φ ψ = cnf-dist φ ∧ cnf-dist ψ cnf-dist .(φ ∨ ψ) | disj φ ψ = dist-∨ ((cnf-dist φ) ∨ (cnf-dist ψ)) cnf-dist φ | other .φ = φ -- Theorem. cnf-dist-lem : ∀ {Γ} {φ} → Γ ⊢ φ → Γ ⊢ cnf-dist φ -- Proof. cnf-dist-lem {_} {φ} Γ⊢φ with d-view φ cnf-dist-lem {_} {.(φ ∧ ψ)} Γ⊢φ∧ψ | conj φ ψ = ∧-intro (cnf-dist-lem (∧-proj₁ Γ⊢φ∧ψ)) (cnf-dist-lem (∧-proj₂ Γ⊢φ∧ψ)) cnf-dist-lem {_} {.(φ ∨ ψ)} Γ⊢φ∨ψ | disj φ ψ = dist-∨-lem (⊃-elim (⊃-intro (∨-elim (∨-intro₁ (cnf-dist ψ) (cnf-dist-lem (assume φ))) (∨-intro₂ (cnf-dist φ) (cnf-dist-lem (assume ψ))))) Γ⊢φ∨ψ) cnf-dist-lem {_} {.φ} Γ⊢φ | other φ = Γ⊢φ --------------------------------------------------------------------------- ∎ -- Theorem. from-cnf-dist-lem : ∀ {Γ} {φ} → Γ ⊢ cnf-dist φ → Γ ⊢ φ -- Proof. from-cnf-dist-lem {_} {φ} Γ⊢cnfdist with d-view φ from-cnf-dist-lem {_} {.(φ ∧ ψ)} Γ⊢cnfdistφ∧ψ | conj φ ψ = ∧-intro (from-cnf-dist-lem (∧-proj₁ Γ⊢cnfdistφ∧ψ)) (from-cnf-dist-lem (∧-proj₂ Γ⊢cnfdistφ∧ψ)) from-cnf-dist-lem {_} {.(φ ∨ ψ)} Γ⊢cnfdistφ∨ψ | disj φ ψ = ⊃-elim (⊃-intro (∨-elim (∨-intro₁ ψ (from-cnf-dist-lem (assume (cnf-dist φ)))) (∨-intro₂ φ (from-cnf-dist-lem (assume (cnf-dist ψ)))))) (from-dist-∨-lem Γ⊢cnfdistφ∨ψ) from-cnf-dist-lem {_} {.φ} Γ⊢φ | other φ = Γ⊢φ --------------------------------------------------------------------------- ∎ -- Def. cnf : PropFormula → PropFormula cnf = cnf-dist ∘ nnf -- Theorem. cnf-lem : ∀ {Γ} {φ} → Γ ⊢ φ → Γ ⊢ cnf φ -- Proof. cnf-lem = cnf-dist-lem ∘ nnf-lem -- ▪ ---------------------------------------------------------------------------- -- Testing for a normal form. is∨ : PropFormula → Bool is∨ φ with d-view φ is∨ .(φ₁ ∧ φ₂) | conj φ₁ φ₂ = false is∨ .(φ₁ ∨ φ₂) | disj φ₁ φ₂ = is∨ φ₁ and is∨ φ₂ is∨ φ | other .φ = true is∧∨ : PropFormula → Bool is∧∨ φ with d-view φ is∧∨ .(φ₁ ∧ φ₂) | conj φ₁ φ₂ = is∧∨ φ₁ and is∧∨ φ₂ is∧∨ .(φ₁ ∨ φ₂) | disj φ₁ φ₂ = is∨ φ₁ and is∨ φ₂ is∧∨ φ | other .φ = true is∧ : PropFormula → Bool is∧ φ with d-view φ is∧ .(φ₁ ∧ φ₂) | conj φ₁ φ₂ = is∧ φ₁ and is∧ φ₂ is∧ .(φ₁ ∨ φ₂) | disj φ₁ φ₂ = false is∧ φ | other .φ = true is∨∧ : PropFormula → Bool is∨∧ φ with d-view φ is∨∧ .(φ₁ ∧ φ₂) | conj φ₁ φ₂ = is∧ φ₁ and is∧ φ₂ is∨∧ .(φ₁ ∨ φ₂) | disj φ₁ φ₂ = is∨∧ φ₁ and is∨∧ φ₂ is∨∧ φ | other .φ = true isNNF : PropFormula → Bool isNNF φ with push-neg-view φ isNNF φ | yes .φ = false isNNF .(φ₁ ∧ φ₂) | no-∧ φ₁ φ₂ = isNNF φ₁ and isNNF φ₂ isNNF .(φ₁ ∨ φ₂) | no-∨ φ₁ φ₂ = isNNF φ₁ and isNNF φ₂ isNNF φ | no .φ = true isCNF : PropFormula → Bool isCNF φ = isNNF φ and is∧∨ φ isDNF : PropFormula → Bool isDNF φ = isNNF φ and is∨∧ φ
{ "alphanum_fraction": 0.4123462556, "avg_line_length": 27.6258064516, "ext": "agda", "hexsha": "c3028f512c33542af2f891fa4013fae2273a0f90", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_path": "src/Data/PropFormula/NormalForms.agda", "max_issues_count": 18, "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_path": "src/Data/PropFormula/NormalForms.agda", "max_line_length": 78, "max_stars_count": 13, "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_path": "src/Data/PropFormula/NormalForms.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "num_tokens": 5650, "size": 12846 }
module Tactic.Nat.Simpl.Lemmas where open import Prelude open import Tactic.Nat.NF open import Tactic.Nat.Exp open import Container.Bag open import Tactic.Nat.Auto open import Prelude.Nat.Properties open import Container.List.Properties open import Tactic.Nat.Auto.Lemmas product1-sound : ∀ xs → product1 xs ≡ productR xs product1-sound [] = refl product1-sound (x ∷ xs) rewrite sym (cong (λ x → foldl _*_ x xs) (mul-one-r x)) | foldl-assoc _*_ mul-assoc x 1 xs | foldl-foldr _*_ 1 mul-assoc add-zero-r mul-one-r xs = refl map-eq : ∀ {c b} {A : Set c} {B : Set b} (f g : A → B) → (∀ x → f x ≡ g x) → ∀ xs → map f xs ≡ map g xs map-eq f g f=g [] = refl map-eq f g f=g (x ∷ xs) rewrite f=g x | map-eq f g f=g xs = refl fst-*** : ∀ {a b} {A₁ A₂ : Set a} {B₁ B₂ : Set b} (f : A₁ → B₁) (g : A₂ → B₂) (p : A₁ × A₂) → fst ((f *** g) p) ≡ f (fst p) fst-*** f g (x , y) = refl snd-*** : ∀ {a b} {A₁ A₂ : Set a} {B₁ B₂ : Set b} (f : A₁ → B₁) (g : A₂ → B₂) (p : A₁ × A₂) → snd ((f *** g) p) ≡ g (snd p) snd-*** f g (x , y) = refl eta : ∀ {a b} {A : Set a} {B : Set b} (p : A × B) → p ≡ (fst p , snd p) eta (x , y) = refl private shuffle₁ : (a b c : Nat) → a + (b + c) ≡ b + (a + c) shuffle₁ a b c = auto module _ {Atom : Set} {{_ : Ord Atom}} where NFEqS : NF Atom × NF Atom → Env Atom → Set NFEqS (nf₁ , nf₂) ρ = ⟦ nf₁ ⟧ns ρ ≡ ⟦ nf₂ ⟧ns ρ NFEq : NF Atom × NF Atom → Env Atom → Set NFEq (nf₁ , nf₂) ρ = ⟦ nf₁ ⟧n ρ ≡ ⟦ nf₂ ⟧n ρ ts-sound : ∀ x (ρ : Env Atom) → ⟦ x ⟧ts ρ ≡ ⟦ x ⟧t ρ ts-sound (0 , x) ρ = mul-zero-r (product1 (map ρ x)) ts-sound (1 , x) ρ = product1-sound (map ρ x) ⟨≡⟩ʳ add-zero-r _ ts-sound (suc (suc i) , x) ρ rewrite sym (product1-sound (map ρ x)) = auto private et : Env Atom → Nat × Tm Atom → Nat et = flip ⟦_⟧t ets : Env Atom → Nat × Tm Atom → Nat ets = flip ⟦_⟧ts plus-nf : Nat → Env Atom → NF Atom → Nat plus-nf = λ a ρ xs → a + ⟦ xs ⟧n ρ ns-sound : ∀ nf (ρ : Env Atom) → ⟦ nf ⟧ns ρ ≡ ⟦ nf ⟧n ρ ns-sound [] ρ = refl ns-sound (x ∷ nf) ρ rewrite sym (foldl-map-fusion _+_ (ets ρ) (ets ρ x) nf) | ts-sound x ρ | map-eq (ets ρ) (et ρ) (flip ts-sound ρ) nf | sym (foldl-foldr _+_ 0 add-assoc (λ _ → refl) add-zero-r (map (et ρ) nf)) | sym (foldl-assoc _+_ add-assoc (et ρ x) 0 (map (et ρ) nf)) | add-zero-r (et ρ x) = refl private lem-sound : ∀ a b ρ f g (xs : NF Atom × NF Atom) → a + ⟦ fst ((f *** g) xs) ⟧n ρ ≡ b + ⟦ snd ((f *** g) xs) ⟧n ρ → a + ⟦ f (fst xs) ⟧n ρ ≡ b + ⟦ g (snd xs) ⟧n ρ lem-sound a b ρ f g xs H = cong (plus-nf a ρ) (fst-*** f g xs) ʳ⟨≡⟩ H ⟨≡⟩ cong (plus-nf b ρ) (snd-*** f g xs) cancel-sound′ : ∀ a b nf₁ nf₂ (ρ : Env Atom) → a + ⟦ fst (cancel nf₁ nf₂) ⟧n ρ ≡ b + ⟦ snd (cancel nf₁ nf₂) ⟧n ρ → a + ⟦ nf₁ ⟧n ρ ≡ b + ⟦ nf₂ ⟧n ρ cancel-sound′ a b [] [] ρ H = H cancel-sound′ a b [] (x ∷ nf₂) ρ H = H cancel-sound′ a b (x ∷ nf₁) [] ρ H = H cancel-sound′ a b ((i , x) ∷ nf₁) ((j , y) ∷ nf₂) ρ H with compare x y ... | less _ = add-assoc a _ _ ⟨≡⟩ cancel-sound′ (a + et ρ (i , x)) b nf₁ ((j , y) ∷ nf₂) ρ (add-assoc a _ _ ʳ⟨≡⟩ lem-sound a b ρ (_∷_ (i , x)) id (cancel nf₁ ((j , y) ∷ nf₂)) H) ... | greater _ = cancel-sound′ a (b + et ρ (j , y)) ((i , x) ∷ nf₁) nf₂ ρ (lem-sound a b ρ id (_∷_ (j , y)) (cancel ((i , x) ∷ nf₁) nf₂) H ⟨≡⟩ add-assoc b _ _) ⟨≡⟩ʳ add-assoc b _ _ cancel-sound′ a b ((i , x) ∷ nf₁) ((j , .x) ∷ nf₂) ρ H | equal refl with compare i j cancel-sound′ a b ((i , x) ∷ nf₁) ((.(suc k + i) , .x) ∷ nf₂) ρ H | equal refl | less (diff! k) = shuffle₁ a (et ρ (i , x)) _ ⟨≡⟩ cong (et ρ (i , x) +_) (cancel-sound′ a (b + et ρ (suc k , x)) nf₁ nf₂ ρ (lem-sound a b ρ id (_∷_ (suc k , x)) (cancel nf₁ nf₂) H ⟨≡⟩ add-assoc b _ _)) ⟨≡⟩ auto cancel-sound′ a b ((.(suc k + j) , x) ∷ nf₁) ((j , .x) ∷ nf₂) ρ H | equal refl | greater (diff! k) = sym (shuffle₁ b (et ρ (j , x)) _ ⟨≡⟩ cong (et ρ (j , x) +_) (sym (cancel-sound′ (a + et ρ (suc k , x)) b nf₁ nf₂ ρ (add-assoc a _ _ ʳ⟨≡⟩ lem-sound a b ρ (_∷_ (suc k , x)) id (cancel nf₁ nf₂) H))) ⟨≡⟩ auto) cancel-sound′ a b ((i , x) ∷ nf₁) ((.i , .x) ∷ nf₂) ρ H | equal refl | equal refl = shuffle₁ a (et ρ (i , x)) _ ⟨≡⟩ cong (et ρ (i , x) +_) (cancel-sound′ a b nf₁ nf₂ ρ H) ⟨≡⟩ shuffle₁ (et ρ (i , x)) b _ cancel-sound-s′ : ∀ a b nf₁ nf₂ (ρ : Env Atom) → a + ⟦ fst (cancel nf₁ nf₂) ⟧ns ρ ≡ b + ⟦ snd (cancel nf₁ nf₂) ⟧ns ρ → a + ⟦ nf₁ ⟧ns ρ ≡ b + ⟦ nf₂ ⟧ns ρ cancel-sound-s′ a b nf₁ nf₂ ρ eq = (a +_) $≡ ns-sound nf₁ ρ ⟨≡⟩ cancel-sound′ a b nf₁ nf₂ ρ ((a +_) $≡ ns-sound (fst (cancel nf₁ nf₂)) ρ ʳ⟨≡⟩ eq ⟨≡⟩ (b +_) $≡ ns-sound (snd (cancel nf₁ nf₂)) ρ) ⟨≡⟩ʳ (b +_) $≡ ns-sound nf₂ ρ cancel-sound : ∀ nf₁ nf₂ ρ → NFEqS (cancel nf₁ nf₂) ρ → NFEq (nf₁ , nf₂) ρ cancel-sound nf₁ nf₂ ρ H rewrite cong (λ p → NFEqS p ρ) (eta (cancel nf₁ nf₂)) = (cancel-sound′ 0 0 nf₁ nf₂ ρ (ns-sound (fst (cancel nf₁ nf₂)) ρ ʳ⟨≡⟩ H ⟨≡⟩ ns-sound (snd (cancel nf₁ nf₂)) ρ)) private prod : Env Atom → List Atom → Nat prod ρ x = productR (map ρ x) private lem-complete : ∀ a b ρ f g (xs : NF Atom × NF Atom) → a + ⟦ f (fst xs) ⟧n ρ ≡ b + ⟦ g (snd xs) ⟧n ρ → a + ⟦ fst ((f *** g) xs) ⟧n ρ ≡ b + ⟦ snd ((f *** g) xs) ⟧n ρ lem-complete a b ρ f g xs H = cong (plus-nf a ρ) (fst-*** f g xs) ⟨≡⟩ H ⟨≡⟩ʳ cong (plus-nf b ρ) (snd-*** f g xs) cancel-complete′ : ∀ a b nf₁ nf₂ (ρ : Env Atom) → a + ⟦ nf₁ ⟧n ρ ≡ b + ⟦ nf₂ ⟧n ρ → a + ⟦ fst (cancel nf₁ nf₂) ⟧n ρ ≡ b + ⟦ snd (cancel nf₁ nf₂) ⟧n ρ cancel-complete′ a b [] [] ρ H = H cancel-complete′ a b [] (x ∷ nf₂) ρ H = H cancel-complete′ a b (x ∷ nf₁) [] ρ H = H cancel-complete′ a b ((i , x) ∷ nf₁) ((j , y) ∷ nf₂) ρ H with compare x y ... | less lt = lem-complete a b ρ (_∷_ (i , x)) id (cancel nf₁ ((j , y) ∷ nf₂)) (add-assoc a _ _ ⟨≡⟩ cancel-complete′ (a + et ρ (i , x)) b nf₁ ((j , y) ∷ nf₂) ρ (add-assoc a _ _ ʳ⟨≡⟩ H)) ... | greater _ = lem-complete a b ρ id (_∷_ (j , y)) (cancel ((i , x) ∷ nf₁) nf₂) (cancel-complete′ a (b + et ρ (j , y)) ((i , x) ∷ nf₁) nf₂ ρ (H ⟨≡⟩ add-assoc b _ _) ⟨≡⟩ʳ add-assoc b _ _) cancel-complete′ a b ((i , x) ∷ nf₁) ((j , .x) ∷ nf₂) ρ H | equal refl with compare i j cancel-complete′ a b ((i , x) ∷ nf₁) ((.(suc (k + i)) , .x) ∷ nf₂) ρ H | equal refl | less (diff! k) = lem-complete a b ρ id (_∷_ (suc k , x)) (cancel nf₁ nf₂) (cancel-complete′ a (b + suc k * prod ρ x) nf₁ nf₂ ρ (add-inj₂ (i * prod ρ x) _ _ (shuffle₁ (i * prod ρ x) a _ ⟨≡⟩ H ⟨≡⟩ auto)) ⟨≡⟩ʳ add-assoc b _ _) cancel-complete′ a b ((.(suc (k + j)) , x) ∷ nf₁) ((j , .x) ∷ nf₂) ρ H | equal refl | greater (diff! k) = lem-complete a b ρ (_∷_ (suc k , x)) id (cancel nf₁ nf₂) (add-assoc a _ _ ⟨≡⟩ cancel-complete′ (a + suc k * prod ρ x) b nf₁ nf₂ ρ (add-inj₂ (j * prod ρ x) _ _ (sym (shuffle₁ (j * prod ρ x) b _ ⟨≡⟩ʳ auto ʳ⟨≡⟩ H)))) cancel-complete′ a b ((i , x) ∷ nf₁) ((.i , .x) ∷ nf₂) ρ H | equal refl | equal refl = cancel-complete′ a b nf₁ nf₂ ρ (add-inj₂ (i * prod ρ x) _ _ (shuffle₁ a (i * prod ρ x) _ ʳ⟨≡⟩ H ⟨≡⟩ shuffle₁ b (i * prod ρ x) _)) cancel-complete-s′ : ∀ a b nf₁ nf₂ (ρ : Env Atom) → a + ⟦ nf₁ ⟧ns ρ ≡ b + ⟦ nf₂ ⟧ns ρ → a + ⟦ fst (cancel nf₁ nf₂) ⟧ns ρ ≡ b + ⟦ snd (cancel nf₁ nf₂) ⟧ns ρ cancel-complete-s′ a b nf₁ nf₂ ρ eq = (a +_) $≡ ns-sound (fst (cancel nf₁ nf₂)) ρ ⟨≡⟩ cancel-complete′ a b nf₁ nf₂ ρ ((a +_) $≡ ns-sound nf₁ ρ ʳ⟨≡⟩ eq ⟨≡⟩ (b +_) $≡ ns-sound nf₂ ρ) ⟨≡⟩ʳ (b +_) $≡ ns-sound (snd (cancel nf₁ nf₂)) ρ cancel-complete : ∀ nf₁ nf₂ ρ → NFEq (nf₁ , nf₂) ρ → NFEqS (cancel nf₁ nf₂) ρ cancel-complete nf₁ nf₂ ρ H rewrite cong (λ p → NFEqS p ρ) (eta (cancel nf₁ nf₂)) = ns-sound (fst (cancel nf₁ nf₂)) ρ ⟨≡⟩ cancel-complete′ 0 0 nf₁ nf₂ ρ H ⟨≡⟩ʳ ns-sound (snd (cancel nf₁ nf₂)) ρ
{ "alphanum_fraction": 0.4791641933, "avg_line_length": 41.9054726368, "ext": "agda", "hexsha": "30a47727b863603f919568406be5e91197a88056", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Tactic/Nat/Simpl/Lemmas.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Tactic/Nat/Simpl/Lemmas.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Tactic/Nat/Simpl/Lemmas.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3768, "size": 8423 }
------------------------------------------------------------------------------ -- Agda-Prop Library. -- Extension Theorems of the Syntax definitions. ------------------------------------------------------------------------------ open import Data.Nat using ( ℕ ) module Data.PropFormula.Theorems.Weakening ( n : ℕ ) where ------------------------------------------------------------------------------ open import Data.PropFormula.Syntax n open import Data.PropFormula.Properties n using ( substΓ ) open import Data.List using ( List ; [] ; _∷_ ; _++_ ; [_] ) open import Relation.Binary.PropositionalEquality using ( _≡_; refl; cong; trans; sym) ------------------------------------------------------------------------------ -- Theorem. weaken-Δ₁ : ∀ {Γ} {φ} → (Δ : Ctxt) → Γ ⊢ φ → Γ ⨆ Δ ⊢ φ -- Proof. weaken-Δ₁ {[]} {φ} [] Γ⊢φ = Γ⊢φ weaken-Δ₁ {x ∷ Γ} {φ} [] Γ⊢φ = substΓ (sym helper) Γ⊢φ where helper : ∀ {Γ} → Γ ⨆ [] ≡ Γ helper {[]} = refl helper {x ∷ Γ} rewrite helper {Γ = Γ} = refl weaken-Δ₁ {Γ} {φ} (x ∷ []) Γ⊢φ = weaken x Γ⊢φ weaken-Δ₁ {Γ} {φ} (x₁ ∷ Δ) Γ⊢φ = substΓ helper (weaken-Δ₁ Δ (weaken x₁ Γ⊢φ)) where helper : ∀ {Γ Δ} {x} → (Γ , x ) ⨆ Δ ≡ Γ ⨆ (x ∷ Δ) helper {[]} {Δ} = refl helper {y ∷ Γ} {Δ} {x} rewrite helper {Γ = Γ} {Δ = Δ} {x = x} = refl -------------------------------------------------------------------------- ∎ -- Theorem. weaken-Δ₂ : ∀ {Γ} {φ} → (Δ : Ctxt) → Γ ⊢ φ → Δ ⨆ Γ ⊢ φ -- Proof. weaken-Δ₂ {_} [] Γ⊢φ = Γ⊢φ weaken-Δ₂ {[]} (hyp ∷ []) Γ⊢φ = weaken₂ hyp Γ⊢φ weaken-Δ₂ {_} (hyp ∷ []) Γ⊢φ = weaken₂ hyp Γ⊢φ weaken-Δ₂ {_} (hyp ∷ hyps) Γ⊢φ = weaken₂ hyp (weaken-Δ₂ hyps Γ⊢φ) -------------------------------------------------------------------------- ∎
{ "alphanum_fraction": 0.3935629588, "avg_line_length": 29.0327868852, "ext": "agda", "hexsha": "af33ca3dca9e79ededfb1330c90f9f5fc58c4ea4", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z", "max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z", "max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jonaprieto/agda-prop", "max_forks_repo_path": "src/Data/PropFormula/Theorems/Weakening.agda", "max_issues_count": 18, "max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jonaprieto/agda-prop", "max_issues_repo_path": "src/Data/PropFormula/Theorems/Weakening.agda", "max_line_length": 78, "max_stars_count": 13, "max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jonaprieto/agda-prop", "max_stars_repo_path": "src/Data/PropFormula/Theorems/Weakening.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z", "num_tokens": 634, "size": 1771 }
-- Andreas, 2016-07-08, issue reported by Nisse module Issue2081 where module M where private Private : Set₁ Private = Set -- The local module should be private as well! module Public where -- The definitions inside this module should not be private -- unless declared so explicitly! Public : Set₁ Public = Set private Bla = Public -- should work! -- This `where` should not give a 'useless private' error: where open Public module Pu = M.Public -- should fail!
{ "alphanum_fraction": 0.6432532348, "avg_line_length": 21.64, "ext": "agda", "hexsha": "300e38dd809ed000f50b672102eaca9121d8bf0e", "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/Issue2081.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/Issue2081.agda", "max_line_length": 67, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue2081.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 131, "size": 541 }
{- Macros (autoDesc, AutoStructure, AutoEquivStr, autoUnivalentStr) for automatically generating structure definitions. For example: autoDesc (λ (X : Type₀) → X → X × ℕ) ↦ function+ var (var , constant ℕ) We prefer to use the constant structure whenever possible, e.g., [autoDesc (λ (X : Type₀) → ℕ → ℕ)] is [constant (ℕ → ℕ)] rather than [function (constant ℕ) (constant ℕ)]. Writing [auto* (λ X → ⋯)] doesn't seem to work, but [auto* (λ (X : Type ℓ) → ⋯)] does. -} {-# OPTIONS --cubical --no-exact-split --safe #-} module Cubical.Structures.Relational.Auto where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Data.Nat open import Cubical.Data.List open import Cubical.Data.Bool open import Cubical.Data.Maybe open import Cubical.Structures.Relational.Macro as Macro import Agda.Builtin.Reflection as R -- Magic number private FUEL = 10000 -- Mark a constant type with a proof it is a set abstract Const[_] : ∀ {ℓ} → hSet ℓ → Type ℓ Const[ A ] = A .fst -- Some reflection utilities private _>>=_ = R.bindTC _<|>_ = R.catchTC _>>_ : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → R.TC A → R.TC B → R.TC B f >> g = f >>= λ _ → g infixl 4 _>>=_ _>>_ _<|>_ varg : ∀ {ℓ} {A : Type ℓ} → A → R.Arg A varg = R.arg (R.arg-info R.visible R.relevant) tLevel = R.def (quote Level) [] tType : R.Term → R.Term tType ℓ = R.def (quote Type) [ varg ℓ ] thSet : R.Term → R.Term thSet ℓ = R.def (quote hSet) [ varg ℓ ] tPosRelDesc : R.Term → R.Term tPosRelDesc ℓ = R.def (quote PosRelDesc) [ varg ℓ ] tRelDesc : R.Term → R.Term tRelDesc ℓ = R.def (quote RelDesc) [ varg ℓ ] func : (ℓ ℓ' : Level) → Type (ℓ-suc (ℓ-max ℓ ℓ')) func ℓ ℓ' = Type ℓ → Type ℓ' tStruct : R.Term → R.Term → R.Term tStruct ℓ ℓ' = R.def (quote func) (varg ℓ ∷ varg ℓ' ∷ []) newMeta = R.checkType R.unknown -- We try to build a descriptor by unifying the provided structure with combinators we're aware of. We -- redefine the structure combinators as the *Shape terms below so that we don't depend on the specific way -- these are defined in other files (order of implicit arguments and so on); the syntactic analysis that goes -- on here means that we would get mysterious errors if those changed. private constantShape : ∀ {ℓ'} (ℓ : Level) (A : hSet ℓ') → (Type ℓ → Type ℓ') constantShape _ A _ = Const[ A ] pointedShape : (ℓ : Level) → Type ℓ → Type ℓ pointedShape _ X = X productShape : ∀ {ℓ₀ ℓ₁} (ℓ : Level) → (Type ℓ → Type ℓ₀) → (Type ℓ → Type ℓ₁) → Type ℓ → Type (ℓ-max ℓ₀ ℓ₁) productShape _ A₀ A₁ X = A₀ X × A₁ X paramShape : ∀ {ℓ₀ ℓ'} (ℓ : Level) → Type ℓ' → (Type ℓ → Type ℓ₀) → Type ℓ → Type (ℓ-max ℓ' ℓ₀) paramShape _ A A₀ X = A → A₀ X functionShape : ∀ {ℓ₀ ℓ₁} (ℓ : Level) → (Type ℓ → Type ℓ₀) → (Type ℓ → Type ℓ₁) → Type ℓ → Type (ℓ-max ℓ₀ ℓ₁) functionShape _ A₀ A₁ X = A₀ X → A₁ X maybeShape : ∀ {ℓ₀} (ℓ : Level) → (Type ℓ → Type ℓ₀) → Type ℓ → Type ℓ₀ maybeShape _ A₀ X = Maybe (A₀ X) private -- Build transport structure descriptor from a function [t : Type ℓ → Type ℓ'] buildPosRelDesc : ℕ → R.Term → R.Term → R.Term → R.TC R.Term buildPosRelDesc zero ℓ ℓ' t = R.typeError (R.strErr "Ran out of fuel! at \n" ∷ R.termErr t ∷ []) buildPosRelDesc (suc fuel) ℓ ℓ' t = tryConstant t <|> tryPointed t <|> tryProduct t <|> tryMaybe t <|> R.typeError (R.strErr "Can't automatically generate a positive structure for\n" ∷ R.termErr t ∷ []) where tryConstant : R.Term → R.TC R.Term tryConstant t = newMeta (thSet ℓ') >>= λ A → R.unify t (R.def (quote constantShape) (varg ℓ ∷ varg A ∷ [])) >> R.returnTC (R.con (quote PosRelDesc.constant) (varg A ∷ [])) tryPointed : R.Term → R.TC R.Term tryPointed t = R.unify t (R.def (quote pointedShape) (varg ℓ ∷ [])) >> R.returnTC (R.con (quote PosRelDesc.var) []) tryProduct : R.Term → R.TC R.Term tryProduct t = newMeta tLevel >>= λ ℓ₀ → newMeta tLevel >>= λ ℓ₁ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → newMeta (tStruct ℓ ℓ₁) >>= λ A₁ → R.unify t (R.def (quote productShape) (varg ℓ ∷ varg A₀ ∷ varg A₁ ∷ [])) >> buildPosRelDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → buildPosRelDesc fuel ℓ ℓ₁ A₁ >>= λ d₁ → R.returnTC (R.con (quote PosRelDesc._,_) (varg d₀ ∷ varg d₁ ∷ [])) tryMaybe : R.Term → R.TC R.Term tryMaybe t = newMeta tLevel >>= λ ℓ₀ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → R.unify t (R.def (quote maybeShape) (varg ℓ ∷ varg A₀ ∷ [])) >> buildPosRelDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → R.returnTC (R.con (quote PosRelDesc.maybe) (varg d₀ ∷ [])) autoPosRelDesc' : R.Term → R.Term → R.TC Unit autoPosRelDesc' t hole = R.inferType hole >>= λ H → newMeta tLevel >>= λ ℓ → newMeta tLevel >>= λ ℓ' → R.unify (tPosRelDesc ℓ) H >> R.checkType t (tStruct ℓ ℓ') >> buildPosRelDesc FUEL ℓ ℓ' t >>= R.unify hole -- Build structure descriptor from a function [t : Type ℓ → Type ℓ'] buildRelDesc : ℕ → R.Term → R.Term → R.Term → R.TC R.Term buildRelDesc zero ℓ ℓ' t = R.typeError (R.strErr "Ran out of fuel! at \n" ∷ R.termErr t ∷ []) buildRelDesc (suc fuel) ℓ ℓ' t = tryConstant t <|> tryPointed t <|> tryProduct t <|> tryParam t <|> tryFunction t <|> tryMaybe t <|> R.typeError (R.strErr "Can't automatically generate a structure for\n" ∷ R.termErr t ∷ []) where tryConstant : R.Term → R.TC R.Term tryConstant t = newMeta (thSet ℓ') >>= λ A → R.unify t (R.def (quote constantShape) (varg ℓ ∷ varg A ∷ [])) >> R.returnTC (R.con (quote RelDesc.constant) (varg A ∷ [])) tryPointed : R.Term → R.TC R.Term tryPointed t = R.unify t (R.def (quote pointedShape) (varg ℓ ∷ [])) >> R.returnTC (R.con (quote RelDesc.var) []) tryProduct : R.Term → R.TC R.Term tryProduct t = newMeta tLevel >>= λ ℓ₀ → newMeta tLevel >>= λ ℓ₁ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → newMeta (tStruct ℓ ℓ₁) >>= λ A₁ → R.unify t (R.def (quote productShape) (varg ℓ ∷ varg A₀ ∷ varg A₁ ∷ [])) >> buildRelDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → buildRelDesc fuel ℓ ℓ₁ A₁ >>= λ d₁ → R.returnTC (R.con (quote RelDesc._,_) (varg d₀ ∷ varg d₁ ∷ [])) tryParam : R.Term → R.TC R.Term tryParam t = newMeta (tType R.unknown) >>= λ A → newMeta tLevel >>= λ ℓ₀ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → R.unify t (R.def (quote paramShape) (varg ℓ ∷ varg A ∷ varg A₀ ∷ [])) >> buildRelDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → R.returnTC (R.con (quote RelDesc.param) (varg A ∷ varg d₀ ∷ [])) tryFunction : R.Term → R.TC R.Term tryFunction t = newMeta tLevel >>= λ ℓ₀ → newMeta tLevel >>= λ ℓ₁ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → newMeta (tStruct ℓ ℓ₁) >>= λ A₁ → R.unify t (R.def (quote functionShape) (varg ℓ ∷ varg A₀ ∷ varg A₁ ∷ [])) >> buildPosRelDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → buildRelDesc fuel ℓ ℓ₁ A₁ >>= λ d₁ → R.returnTC (R.con (quote RelDesc.function+) (varg d₀ ∷ varg d₁ ∷ [])) tryMaybe : R.Term → R.TC R.Term tryMaybe t = newMeta tLevel >>= λ ℓ₀ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → R.unify t (R.def (quote maybeShape) (varg ℓ ∷ varg A₀ ∷ [])) >> buildRelDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → R.returnTC (R.con (quote RelDesc.maybe) (varg d₀ ∷ [])) autoRelDesc' : R.Term → R.Term → R.TC Unit autoRelDesc' t hole = R.inferType hole >>= λ H → newMeta tLevel >>= λ ℓ → newMeta tLevel >>= λ ℓ' → R.unify (tRelDesc ℓ) H >> R.checkType t (tStruct ℓ ℓ') >> buildRelDesc FUEL ℓ ℓ' t >>= R.unify hole macro -- (Type ℓ → Type ℓ₁) → PosRelDesc ℓ autoPosRelDesc : R.Term → R.Term → R.TC Unit autoPosRelDesc = autoPosRelDesc' -- (S : Type ℓ → Type ℓ₁) → RelDesc ℓ autoRelDesc : R.Term → R.Term → R.TC Unit autoRelDesc = autoRelDesc' -- (S : Type ℓ → Type ℓ₁) → (Type ℓ → Type ℓ₁) -- Sanity check: should be the identity AutoStructure : R.Term → R.Term → R.TC Unit AutoStructure t hole = newMeta (tRelDesc R.unknown) >>= λ d → R.unify hole (R.def (quote RelMacroStructure) [ varg d ]) >> autoRelDesc' t d -- (S : Type ℓ → Type ℓ₁) → StrRel S _ AutoRelStr : R.Term → R.Term → R.TC Unit AutoRelStr t hole = newMeta (tRelDesc R.unknown) >>= λ d → R.unify hole (R.def (quote RelMacroRelStr) [ varg d ]) >> autoRelDesc' t d -- (S : Type ℓ → Type ℓ₁) → SuitableStrRel S (AutoStrRel S) autoSuitableRel : R.Term → R.Term → R.TC Unit autoSuitableRel t hole = newMeta (tRelDesc R.unknown) >>= λ d → R.unify hole (R.def (quote relMacroSuitableRel) [ varg d ]) >> autoRelDesc' t d -- (S : Type ℓ → Type ℓ₁) → StrRelMatchesEquiv (AutoRelStr S) (AutoEquivStr S) autoMatchesEquiv : R.Term → R.Term → R.TC Unit autoMatchesEquiv t hole = newMeta (tRelDesc R.unknown) >>= λ d → R.unify hole (R.def (quote relMacroMatchesEquiv) [ varg d ]) >> autoRelDesc' t d
{ "alphanum_fraction": 0.6032663037, "avg_line_length": 35.7182539683, "ext": "agda", "hexsha": "43e3d849151e016f0afb29e09f8fe2a588946efb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/Structures/Relational/Auto.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/Structures/Relational/Auto.agda", "max_line_length": 116, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/Structures/Relational/Auto.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3324, "size": 9001 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) module LogicalFormulae where infix 5 _≡_ data _≡_ {a} {A : Set a} (x : A) : A → Set a where refl : x ≡ x {-# BUILTIN EQUALITY _≡_ #-} data False : Set where data False' {a : _} : Set a where record True : Set where {-# BUILTIN UNIT True #-} record True' {a : _} : Set a where infix 10 _||_ data _||_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where inl : A → A || B inr : B → A || B infix 15 _&&_ record _&&_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where constructor _,,_ field fst : A snd : B equalityLeft : {a b : _} {A : Set a} {B : Set b} {x1 x2 : A && B} → (x1 ≡ x2) → _&&_.fst x1 ≡ _&&_.fst x2 equalityLeft {x1 = a ,, _} {.a ,, _} refl = refl equalityRight : {a b : _} {A : Set a} {B : Set b} {x1 x2 : A && B} → (x1 ≡ x2) → _&&_.snd x1 ≡ _&&_.snd x2 equalityRight {x1 = _ ,, a} {_ ,, .a} refl = refl infix 15 _&_&_ record _&_&_ {a b c} (A : Set a) (B : Set b) (C : Set c) : Set (a ⊔ b ⊔ c) where field one : A two : B three : C data Sg {n : _} {m : _} (A : Set m) (B : A → Set n) : Set (m ⊔ n) where _,_ : (a : A) → (b : B a) → Sg A B underlying : {n m : _} {A : _} {prop : _} → Sg {n} {m} A prop -> A underlying (a , b) = a underlyingRefl : {n m : _} {A : _} {prop : _} → {r s : Sg {n} {m} A prop} → r ≡ s → underlying r ≡ underlying s underlyingRefl {r = (a , b)} {(.a , .b)} refl = refl transitivity : {a : _} {A : Set a} {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z) transitivity refl refl = refl liftEquality : {a : _} {A B : Set a} (f g : A → B) → (x y : A) → (f ≡ g) → (x ≡ y) → ((f x) ≡ (g y)) liftEquality f .f x .x refl refl = refl applyEquality : {a : _} {b : _} {A : Set a} {B : Set b} (f : A → B) → {x y : A} → (x ≡ y) → ((f x) ≡ (f y)) applyEquality {A} {B} f {x} {.x} refl = refl applyEquality2 : {a b c : _} {A : Set a} {B : Set b} {C : Set c} (f : A → B → C) → {x y : A} → (x ≡ y) → {m n : B} → (m ≡ n) → f x m ≡ f y n applyEquality2 f x=y m=n rewrite x=y | m=n = refl identityOfIndiscernablesLeft : {m n o : _} {A : Set m} {B : Set n} {a : A} {b : B} {c : A} → (prop : A → B → Set o) → (prop a b) → (a ≡ c) → (prop c b) identityOfIndiscernablesLeft {a = a} {b} {.a} prop pAB refl = pAB identityOfIndiscernablesRight : {m n o : _} {A : Set m} {B : Set n} {a : A} {b c : B} → (prop : A → B → Set o) → (prop a b) → (b ≡ c) → (prop a c) identityOfIndiscernablesRight {a = a} {b} {.b} prop prAB refl = prAB equalityCommutative : {a : _} {A : Set a} {x y : A} → (x ≡ y) → (y ≡ x) equalityCommutative refl = refl exFalso : {n : _} {A : Set n} → .(x : False) → A exFalso {a} = λ () exFalso' : {r n : _} {A : Set n} → .(x : False' {r}) → A exFalso' () orIsAssociative : {n : _} {a b c : Set n} → ((a || b) || c) → (a || (b || c)) orIsAssociative (inl (inl x)) = inl x orIsAssociative (inl (inr x)) = inr (inl x) orIsAssociative (inr x) = inr (inr x) lemConstructive : {n : _} → {p : Set n} → (p || (p → False)) → (((p → False) → False) → p) lemConstructive (inl p) = λ _ → p lemConstructive (inr notP) = λ negnegP → exFalso (negnegP notP) lemConverse : {n : _} → {p : Set n} → p → ((p → False) → False) lemConverse p = λ notP → notP p typeCast : {a : _} {A : Set a} {B : Set a} (el : A) (pr : A ≡ B) → B typeCast {a} {A} {.A} elt refl = elt data Singleton {a} {A : Set a} (x : A) : Set a where _with≡_ : (y : A) → x ≡ y → Singleton x inspect : ∀ {a} {A : Set a} (x : A) → Singleton x inspect x = x with≡ refl curry : {a b c : _} {A : Set a} {B : Set b} {C : Set c} (f : A → B → C) → ((Sg A (λ _ → B)) → C) curry f (a , b) = f a b uncurry : {a b c : _} {A : Set a} {B : Set b} {C : Set c} (f : (Sg A (λ _ → B)) → C) → (A → B → C) uncurry f a b = f (a , b) decidableOr : {a b : _} → (A : Set a) → (B : Set b) → (A || (A → False)) → (A || B) → (A || ((A → False) && B)) decidableOr {a} {b} A B decidable (inl x) = inl x decidableOr {a} {b} A B (inl y) (inr x) = inl y decidableOr {a} {b} A B (inr y) (inr x) = inr (record { fst = y ; snd = x}) embedLevel : {a b : _} → Set a → Set (a ⊔ b) embedLevel {a} {b} A = A && (True' {b})
{ "alphanum_fraction": 0.5020616056, "avg_line_length": 35.852173913, "ext": "agda", "hexsha": "0acefc96baa3822960f481627da1bf86d206c69e", "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": "LogicalFormulae.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": "LogicalFormulae.agda", "max_line_length": 151, "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": "LogicalFormulae.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": 1861, "size": 4123 }
------------------------------------------------------------------------ -- A variant of set quotients with erased higher constructors ------------------------------------------------------------------------ -- This module contains some basic definitions with few dependencies -- (in particular, not Quotient). See Quotient.Erased for more -- definitions. The definitions below are reexported from -- Quotient.Erased. {-# OPTIONS --erased-cubical --safe #-} -- Partly following the HoTT book, but adapted for erasure. -- -- Unlike the HoTT book, but following the cubical library (in which -- set quotients were implemented by Zesen Qian and Anders Mörtberg), -- the quotienting relations are not (always) required to be -- propositional. -- The module is parametrised by a notion of equality. The higher -- constructors of the HIT defining quotients use path equality, but -- the supplied notion of equality is used for many other things. import Equality.Path as P module Quotient.Erased.Basics {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq hiding (elim) open import Prelude open import Bijection equality-with-J using (_↔_) open import Equality.Path.Isomorphisms eq open import Function-universe equality-with-J hiding (_∘_) open import H-level equality-with-J import H-level P.equality-with-J as PH open import H-level.Closure equality-with-J private variable a b p r : Level A B : Type a R : A → A → Type r x y : A ------------------------------------------------------------------------ -- Quotients -- The quotient type constructor. infix 5 _/ᴱ_ data _/ᴱ_ (A : Type a) (@0 R : A → A → Type r) : Type (a ⊔ r) where [_] : A → A /ᴱ R @0 []-respects-relationᴾ : {x y : A} → R x y → [ x ] P.≡ [ y ] @0 /ᴱ-is-setᴾ : P.Is-set (A /ᴱ R) -- [_] respects the quotient relation (in erased contexts). @0 []-respects-relation : R x y → _≡_ {A = A /ᴱ R} [ x ] [ y ] []-respects-relation = _↔_.from ≡↔≡ ∘ []-respects-relationᴾ -- Quotients are sets (in erased contexts). @0 /ᴱ-is-set : Is-set (A /ᴱ R) /ᴱ-is-set = _↔_.from (H-level↔H-level 2) /ᴱ-is-setᴾ ------------------------------------------------------------------------ -- Eliminators -- An eliminator, expressed using paths. record Elimᴾ′ {A : Type a} {@0 R : A → A → Type r} (P : A /ᴱ R → Type p) : Type (a ⊔ r ⊔ p) where no-eta-equality field []ʳ : ∀ x → P [ x ] @0 []-respects-relationʳ : (r : R x y) → P.[ (λ i → P ([]-respects-relationᴾ r i)) ] []ʳ x ≡ []ʳ y @0 is-setʳ : {eq₁ eq₂ : x P.≡ y} {p : P x} {q : P y} (eq₃ : P.[ (λ i → P (eq₁ i)) ] p ≡ q) (eq₄ : P.[ (λ i → P (eq₂ i)) ] p ≡ q) → P.[ (λ i → P.[ (λ j → P (/ᴱ-is-setᴾ eq₁ eq₂ i j)) ] p ≡ q) ] eq₃ ≡ eq₄ open Elimᴾ′ public elimᴾ′ : {@0 R : A → A → Type r} {P : A /ᴱ R → Type p} → Elimᴾ′ P → (x : A /ᴱ R) → P x elimᴾ′ {A = A} {R = R} {P = P} e = helper where module E = Elimᴾ′ e helper : (x : A /ᴱ R) → P x helper [ x ] = E.[]ʳ x helper ([]-respects-relationᴾ r i) = E.[]-respects-relationʳ r i helper (/ᴱ-is-setᴾ p q i j) = E.is-setʳ (λ i → helper (p i)) (λ i → helper (q i)) i j -- A possibly more useful eliminator, expressed using paths. record Elimᴾ {A : Type a} {@0 R : A → A → Type r} (P : A /ᴱ R → Type p) : Type (a ⊔ r ⊔ p) where no-eta-equality field []ʳ : ∀ x → P [ x ] @0 []-respects-relationʳ : (r : R x y) → P.[ (λ i → P ([]-respects-relationᴾ r i)) ] []ʳ x ≡ []ʳ y @0 is-setʳ : ∀ x → P.Is-set (P x) open Elimᴾ public elimᴾ : {@0 R : A → A → Type r} {P : A /ᴱ R → Type p} → Elimᴾ P → (x : A /ᴱ R) → P x elimᴾ e = elimᴾ′ λ where .[]ʳ → E.[]ʳ .[]-respects-relationʳ → E.[]-respects-relationʳ .is-setʳ → P.heterogeneous-UIP E.is-setʳ _ where module E = Elimᴾ e private -- One can define elimᴾ′ using elimᴾ. elimᴾ′₂ : {@0 R : A → A → Type r} {P : A /ᴱ R → Type p} → Elimᴾ′ P → (x : A /ᴱ R) → P x elimᴾ′₂ {P = P} e = elimᴾ λ where .[]ʳ → E.[]ʳ .[]-respects-relationʳ → E.[]-respects-relationʳ .is-setʳ x {y} {z} p q → $⟨ E.is-setʳ p q ⟩ P.[ (λ i → P.[ (λ j → P (/ᴱ-is-setᴾ P.refl P.refl i j)) ] y ≡ z) ] p ≡ q ↝⟨ P.subst (λ eq → P.[ (λ i → P.[ (λ j → P (eq i j)) ] y ≡ z) ] p ≡ q) (PH.mono₁ 2 /ᴱ-is-setᴾ _ _) ⟩ P.[ (λ _ → P.[ (λ _ → P x) ] y ≡ z) ] p ≡ q ↔⟨⟩ p P.≡ q □ where module E = Elimᴾ′ e -- A non-dependent eliminator, expressed using paths. record Recᴾ {A : Type a} (@0 R : A → A → Type r) (B : Type b) : Type (a ⊔ r ⊔ b) where no-eta-equality field []ʳ : A → B @0 []-respects-relationʳ : (r : R x y) → []ʳ x P.≡ []ʳ y @0 is-setʳ : P.Is-set B open Recᴾ public recᴾ : {@0 R : A → A → Type r} → Recᴾ R B → A /ᴱ R → B recᴾ r = elimᴾ λ where .[]ʳ → R.[]ʳ .[]-respects-relationʳ → R.[]-respects-relationʳ .is-setʳ _ → R.is-setʳ where module R = Recᴾ r -- An eliminator. record Elim {A : Type a} {@0 R : A → A → Type r} (P : A /ᴱ R → Type p) : Type (a ⊔ r ⊔ p) where no-eta-equality field []ʳ : ∀ x → P [ x ] @0 []-respects-relationʳ : (r : R x y) → subst P ([]-respects-relation r) ([]ʳ x) ≡ []ʳ y @0 is-setʳ : ∀ x → Is-set (P x) open Elim public elim : {@0 R : A → A → Type r} {P : A /ᴱ R → Type p} → Elim P → (x : A /ᴱ R) → P x elim e = elimᴾ λ where .[]ʳ → E.[]ʳ .[]-respects-relationʳ → subst≡→[]≡ ∘ E.[]-respects-relationʳ .is-setʳ → _↔_.to (H-level↔H-level 2) ∘ E.is-setʳ where module E = Elim e -- A non-dependent eliminator. record Rec {A : Type a} (@0 R : A → A → Type r) (B : Type b) : Type (a ⊔ r ⊔ b) where no-eta-equality field []ʳ : A → B @0 []-respects-relationʳ : (r : R x y) → []ʳ x ≡ []ʳ y @0 is-setʳ : Is-set B open Rec public rec : {@0 R : A → A → Type r} → Rec R B → A /ᴱ R → B rec r = recᴾ λ where .[]ʳ → R.[]ʳ .[]-respects-relationʳ → _↔_.to ≡↔≡ ∘ R.[]-respects-relationʳ .is-setʳ → _↔_.to (H-level↔H-level 2) R.is-setʳ where module R = Rec r -- A variant of elim that can be used if the motive composed with [_] -- is a family of propositions. -- -- I took the idea for this eliminator from Nicolai Kraus. record Elim-prop {A : Type a} {@0 R : A → A → Type r} (P : A /ᴱ R → Type p) : Type (a ⊔ r ⊔ p) where no-eta-equality field []ʳ : ∀ x → P [ x ] @0 is-propositionʳ : ∀ x → Is-proposition (P [ x ]) open Elim-prop public elim-prop : {@0 R : A → A → Type r} {P : A /ᴱ R → Type p} → Elim-prop P → (x : A /ᴱ R) → P x elim-prop e = elim λ where .[]ʳ → E.[]ʳ .[]-respects-relationʳ _ → E.is-propositionʳ _ _ _ .is-setʳ → elim λ @0 where .[]ʳ → mono₁ 1 ∘ E.is-propositionʳ .[]-respects-relationʳ _ → H-level-propositional ext 2 _ _ .is-setʳ _ → mono₁ 1 (H-level-propositional ext 2) where module E = Elim-prop e -- A variant of rec that can be used if the motive is a proposition. record Rec-prop (A : Type a) (B : Type b) : Type (a ⊔ b) where no-eta-equality field []ʳ : A → B @0 is-propositionʳ : Is-proposition B open Rec-prop public rec-prop : {@0 R : A → A → Type r} → Rec-prop A B → A /ᴱ R → B rec-prop r = elim-prop λ where .[]ʳ → R.[]ʳ .is-propositionʳ _ → R.is-propositionʳ where module R = Rec-prop r
{ "alphanum_fraction": 0.4830989391, "avg_line_length": 29.2635379061, "ext": "agda", "hexsha": "01120f9653f1a417d8ffdadbb21a3f082c6abb8f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Quotient/Erased/Basics.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Quotient/Erased/Basics.agda", "max_line_length": 142, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Quotient/Erased/Basics.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 2976, "size": 8106 }
module conversion where open import lib open import cedille-types open import ctxt open import is-free open import lift open import rename open import subst open import syntax-util open import general-util open import erase {- Some notes: -- hnf{TERM} implements erasure as well as normalization. -- hnf{TYPE} does not descend into terms. -- definitions are assumed to be in hnf -} data unfolding : Set where no-unfolding : unfolding unfold : (unfold-all : 𝔹) {- if ff we unfold just the head -} → (unfold-lift : 𝔹) {- if tt we unfold lifting types -} → (dampen-after-head-beta : 𝔹) {- if tt we will not unfold definitions after a head beta reduction -} → (erase : 𝔹) -- if tt erase the term as we unfold → unfolding unfolding-get-erased : unfolding → 𝔹 unfolding-get-erased no-unfolding = ff unfolding-get-erased (unfold _ _ _ e) = e unfolding-set-erased : unfolding → 𝔹 → unfolding unfolding-set-erased no-unfolding e = no-unfolding unfolding-set-erased (unfold b1 b2 b3 _) e = unfold b1 b2 b3 e unfold-all : unfolding unfold-all = unfold tt tt ff tt unfold-head : unfolding unfold-head = unfold ff tt ff tt unfold-head-no-lift : unfolding unfold-head-no-lift = unfold ff ff ff ff unfold-head-one : unfolding unfold-head-one = unfold ff tt tt tt unfold-dampen : (after-head-beta : 𝔹) → unfolding → unfolding unfold-dampen _ no-unfolding = no-unfolding unfold-dampen _ (unfold tt b b' e) = unfold tt b b e -- we do not dampen unfolding when unfolding everywhere unfold-dampen tt (unfold ff b tt e) = no-unfolding unfold-dampen tt (unfold ff b ff e) = (unfold ff b ff e) unfold-dampen ff _ = no-unfolding unfolding-elab : unfolding → unfolding unfolding-elab no-unfolding = no-unfolding unfolding-elab (unfold b b' b'' _) = unfold b b' b'' ff conv-t : Set → Set conv-t T = ctxt → T → T → 𝔹 {-# TERMINATING #-} -- main entry point -- does not assume erased conv-term : conv-t term conv-type : conv-t type conv-kind : conv-t kind -- assume erased conv-terme : conv-t term conv-argse : conv-t (𝕃 term) conv-typee : conv-t type conv-kinde : conv-t kind -- call hnf, then the conv-X-norm functions conv-term' : conv-t term conv-type' : conv-t type hnf : {ed : exprd} → ctxt → (u : unfolding) → ⟦ ed ⟧ → (is-head : 𝔹) → ⟦ ed ⟧ -- assume head normalized inputs conv-term-norm : conv-t term conv-type-norm : conv-t type conv-kind-norm : conv-t kind hnf-optClass : ctxt → unfolding → optClass → optClass -- hnf-tk : ctxt → unfolding → tk → tk -- does not assume erased conv-tk : conv-t tk conv-liftingType : conv-t liftingType conv-optClass : conv-t optClass -- conv-optType : conv-t optType conv-tty* : conv-t (𝕃 tty) -- assume erased conv-tke : conv-t tk conv-liftingTypee : conv-t liftingType conv-optClasse : conv-t optClass -- -- conv-optTypee : conv-t optType conv-ttye* : conv-t (𝕃 tty) conv-ctr-ps : ctxt → var → var → maybe (𝕃 (var × type) × 𝕃 (var × type)) conv-ctr-args : conv-t (var × args) conv-ctr : conv-t var conv-term Γ t t' = conv-terme Γ (erase t) (erase t') conv-terme Γ t t' with decompose-apps t | decompose-apps t' conv-terme Γ t t' | Var _ x , args | Var _ x' , args' = ctxt-eq-rep Γ x x' && conv-argse Γ (erase-args args) (erase-args args') || conv-ctr-args Γ (x , args) (x' , args') || conv-term' Γ t t' conv-terme Γ t t' | _ | _ = conv-term' Γ t t' conv-argse Γ [] [] = tt conv-argse Γ (a :: args) (a' :: args') = conv-terme Γ a a' && conv-argse Γ args args' conv-argse Γ _ _ = ff conv-type Γ t t' = conv-typee Γ (erase t) (erase t') conv-typee Γ t t' with decompose-tpapps t | decompose-tpapps t' conv-typee Γ t t' | TpVar _ x , args | TpVar _ x' , args' = ctxt-eq-rep Γ x x' && conv-tty* Γ args args' || conv-type' Γ t t' conv-typee Γ t t' | _ | _ = conv-type' Γ t t' conv-kind Γ k k' = conv-kinde Γ (erase k) (erase k') conv-kinde Γ k k' = conv-kind-norm Γ (hnf Γ unfold-head k tt) (hnf Γ unfold-head k' tt) conv-term' Γ t t' = conv-term-norm Γ (hnf Γ unfold-head t tt) (hnf Γ unfold-head t' tt) conv-type' Γ t t' = conv-type-norm Γ (hnf Γ unfold-head t tt) (hnf Γ unfold-head t' tt) -- is-head is only used in hnf{TYPE} hnf{TERM} Γ no-unfolding e hd = erase-term e hnf{TERM} Γ u (Parens _ t _) hd = hnf Γ u t hd hnf{TERM} Γ u (App t1 Erased t2) hd = hnf Γ u t1 hd hnf{TERM} Γ u (App t1 NotErased t2) hd with hnf Γ u t1 hd hnf{TERM} Γ u (App _ NotErased t2) hd | Lam _ _ _ x _ t1 = hnf Γ (unfold-dampen tt u) (subst Γ t2 x t1) hd hnf{TERM} Γ u (App _ NotErased t2) hd | t1 = App t1 NotErased (hnf Γ (unfold-dampen ff u) t2 ff) hnf{TERM} Γ u (Lam _ Erased _ _ _ t) hd = hnf Γ u t hd hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd with hnf (ctxt-var-decl x Γ) u t hd hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | (App t' NotErased (Var _ x')) with x =string x' && ~ (is-free-in skip-erased x t') hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | (App t' NotErased (Var _ x')) | tt = t' -- eta-contraction hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | (App t' NotErased (Var _ x')) | ff = Lam posinfo-gen NotErased posinfo-gen x NoClass (App t' NotErased (Var posinfo-gen x')) hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | t' = Lam posinfo-gen NotErased posinfo-gen x NoClass t' hnf{TERM} Γ u (Let _ ff (DefTerm _ x _ t) t') hd = hnf Γ u (subst Γ t x t') hd hnf{TERM} Γ u (Let _ tt (DefTerm _ x _ t) t') hd = hnf Γ u t' hd hnf{TERM} Γ u (Let _ fe (DefType _ x _ _) t') hd = hnf (ctxt-var-decl x Γ) u t' hd hnf{TERM} Γ (unfold _ _ _ _) (Var _ x) hd with ctxt-lookup-term-var-def Γ x hnf{TERM} Γ (unfold _ _ _ _) (Var _ x) hd | nothing = Var posinfo-gen x hnf{TERM} Γ (unfold ff _ _ e) (Var _ x) hd | just t = erase-if e t -- definitions should be stored in hnf hnf{TERM} Γ (unfold tt b b' e) (Var _ x) hd | just t = hnf Γ (unfold tt b b' e) t hd -- this might not be fully normalized, only head-normalized hnf{TERM} Γ u (AppTp t tp) hd = hnf Γ u t hd hnf{TERM} Γ u (Sigma _ t) hd = hnf Γ u t hd hnf{TERM} Γ u (Epsilon _ _ _ t) hd = hnf Γ u t hd hnf{TERM} Γ u (IotaPair _ t1 t2 _ _) hd = hnf Γ u t1 hd hnf{TERM} Γ u (IotaProj t _ _) hd = hnf Γ u t hd hnf{TERM} Γ u (Phi _ eq t₁ t₂ _) hd = hnf Γ u t₂ hd hnf{TERM} Γ u (Rho _ _ _ t _ t') hd = hnf Γ u t' hd hnf{TERM} Γ u (Chi _ T t') hd = hnf Γ u t' hd hnf{TERM} Γ u (Delta _ T t') hd = id-term hnf{TERM} Γ u (Theta _ u' t ls) hd = hnf Γ u (lterms-to-term u' t ls) hd hnf{TERM} Γ u (Beta _ _ (SomeTerm t _)) hd = hnf Γ u t hd hnf{TERM} Γ u (Beta _ _ NoTerm) hd = id-term hnf{TERM} Γ u (Open _ _ _ _ t) hd = hnf Γ u t hd hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd with decompose-apps (hnf Γ u t hd) hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | tₕ , as with Mu' pi-gen NoTerm (recompose-apps as tₕ) NoType pi-gen (map (λ {(Case _ x as' t) → Case pi-gen x as' (hnf (foldr (λ {(CaseTermArg _ NotErased x) → ctxt-var-decl x; _ → id}) Γ as') (unfold-dampen ff u) t hd)}) (erase-cases cs)) pi-gen | tₕ hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x with foldl (λ {(Case _ xₘ cas tₘ) m? → m? maybe-or (conv-ctr-ps Γ xₘ x ≫=maybe uncurry λ psₘ ps → just (caseArgs-to-lams cas tₘ , length (erase-caseArgs cas) , length ps))}) nothing (erase-cases cs) hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x | just (tₓ , nas , nps) with drop nps (erase-args as) hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x | just (tₓ , nas , nps) | as' with nas =ℕ length as' hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x | just (tₓ , nas , nps) | as' | tt = hnf Γ (unfold-dampen tt u) (recompose-apps (map (TermArg NotErased) as') tₓ) hd hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x | just (tₓ , nas , nps) | as' | ff = tₒ hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x | nothing = tₒ hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | _ = tₒ hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd with decompose-apps (hnf Γ u t hd) hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as with (λ t → Mu pi-gen pi-gen x t NoType pi-gen (map (λ {(Case _ x as' t) → Case pi-gen x as' (hnf (foldr (λ {(CaseTermArg _ NotErased x) → ctxt-var-decl x; _ → id}) Γ as') (unfold-dampen ff u) t hd)}) (erase-cases cs)) pi-gen) | tₕ hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' with foldl (λ {(Case _ xₘ cas tₘ) m? → m? maybe-or (conv-ctr-ps Γ xₘ x' ≫=maybe uncurry λ psₘ ps → just (caseArgs-to-lams cas tₘ , length (erase-caseArgs cas) , length ps))}) nothing (erase-cases cs) | fresh-var "x" (ctxt-binds-var Γ) empty-renamectxt hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' | just (tₓ , nas , nps) | fₓ with drop nps (erase-args as) hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' | just (tₓ , nas , nps) | fₓ | as' with nas =ℕ length as' hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' | just (tₓ , nas , nps) | fₓ | as' | tt = hnf Γ (unfold-dampen tt u) (recompose-apps (map (TermArg NotErased) as') (subst Γ (mlam fₓ $ tₒ $ mvar fₓ) x tₓ)) hd hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' | just (tₓ , nas , nps) | fₓ | as' | ff = tₒ $ recompose-apps (map (TermArg NotErased) as') tₕ hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' | nothing | fₓ = tₒ $ recompose-apps as tₕ hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | _ = tₒ $ recompose-apps as tₕ hnf{TERM} Γ u x hd = x hnf{TYPE} Γ no-unfolding e _ = e hnf{TYPE} Γ u (TpParens _ t _) hd = hnf Γ u t hd hnf{TYPE} Γ u (NoSpans t _) hd = hnf Γ u t hd hnf{TYPE} Γ (unfold ff b' _ _) (TpVar _ x) ff = TpVar posinfo-gen x hnf{TYPE} Γ (unfold b b' _ _) (TpVar _ x) _ with ctxt-lookup-type-var-def Γ x hnf{TYPE} Γ (unfold b b' _ _) (TpVar _ x) _ | just tp = tp hnf{TYPE} Γ (unfold b b' _ _) (TpVar _ x) _ | nothing = TpVar posinfo-gen x hnf{TYPE} Γ u (TpAppt tp t) hd with hnf Γ u tp hd hnf{TYPE} Γ u (TpAppt _ t) hd | TpLambda _ _ x _ tp = hnf Γ u (subst Γ t x tp) hd hnf{TYPE} Γ u (TpAppt _ t) hd | tp = TpAppt tp (erase-if (unfolding-get-erased u) t) hnf{TYPE} Γ u (TpApp tp tp') hd with hnf Γ u tp hd hnf{TYPE} Γ u (TpApp _ tp') hd | TpLambda _ _ x _ tp = hnf Γ u (subst Γ tp' x tp) hd hnf{TYPE} Γ u (TpApp _ tp') hd | tp with hnf Γ u tp' hd hnf{TYPE} Γ u (TpApp _ _) hd | tp | tp' = try-pull-lift-types tp tp' {- given (T1 T2), with T1 and T2 types, see if we can pull a lifting operation from the heads of T1 and T2 to surround the entire application. If not, just return (T1 T2). -} where try-pull-lift-types : type → type → type try-pull-lift-types tp1 tp2 with decompose-tpapps tp1 | decompose-tpapps (hnf Γ u tp2 tt) try-pull-lift-types tp1 tp2 | Lft _ _ X t l , args1 | Lft _ _ X' t' l' , args2 = if conv-tty* Γ args1 args2 then try-pull-term-in Γ t l (length args1) [] [] else TpApp tp1 tp2 where try-pull-term-in : ctxt → term → liftingType → ℕ → 𝕃 var → 𝕃 liftingType → type try-pull-term-in Γ t (LiftParens _ l _) n vars ltps = try-pull-term-in Γ t l n vars ltps try-pull-term-in Γ t (LiftArrow _ l) 0 vars ltps = recompose-tpapps args1 (Lft posinfo-gen posinfo-gen X (Lam* vars (hnf Γ no-unfolding (App t NotErased (App* t' (map (λ v → NotErased , mvar v) vars))) tt)) (LiftArrow* ltps l)) try-pull-term-in Γ (Lam _ _ _ x _ t) (LiftArrow l1 l2) (suc n) vars ltps = try-pull-term-in (ctxt-var-decl x Γ) t l2 n (x :: vars) (l1 :: ltps) try-pull-term-in Γ t (LiftArrow l1 l2) (suc n) vars ltps = let x = fresh-var "x" (ctxt-binds-var Γ) empty-renamectxt in try-pull-term-in (ctxt-var-decl x Γ) (App t NotErased (mvar x)) l2 n (x :: vars) (l1 :: ltps) try-pull-term-in Γ t l n vars ltps = TpApp tp1 tp2 try-pull-lift-types tp1 tp2 | _ | _ = TpApp tp1 tp2 hnf{TYPE} Γ u@(unfold all? _ _ _) (Abs _ b _ x atk tp) _ with Abs posinfo-gen b posinfo-gen x (hnf Γ u atk ff) (hnf (ctxt-var-decl x Γ) u tp ff) hnf{TYPE} Γ u (Abs _ b _ x atk tp) _ | tp' with to-abs tp' hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | just (mk-abs b x atk tt {- x is free in tp -} tp) = Abs posinfo-gen b posinfo-gen x atk tp hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | just (mk-abs b x (Tkk k) ff tp) = Abs posinfo-gen b posinfo-gen x (Tkk k) tp hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | just (mk-abs b x (Tkt tp') ff tp) = TpArrow tp' b tp hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | nothing = tp'' hnf{TYPE} Γ u (TpArrow tp1 arrowtype tp2) _ = TpArrow (hnf Γ u tp1 ff) arrowtype (hnf Γ u tp2 ff) hnf{TYPE} Γ u (TpEq _ t1 t2 _) _ = TpEq posinfo-gen (erase t1) (erase t2) posinfo-gen hnf{TYPE} Γ u (TpLambda _ _ x atk tp) _ = TpLambda posinfo-gen posinfo-gen x (hnf Γ u atk ff) (hnf (ctxt-var-decl x Γ) u tp ff) hnf{TYPE} Γ u @ (unfold b tt b'' b''') (Lft _ _ y t l) _ = let t = hnf (ctxt-var-decl y Γ) u t tt in do-lift Γ (Lft posinfo-gen posinfo-gen y t l) y l (λ t → hnf{TERM} Γ unfold-head t ff) t -- We need hnf{TYPE} to preserve types' well-kindedness, so we must check if -- the defined term is being checked against a type and use chi to make sure -- that wherever it is substituted, the term will have the same directionality. -- For example, "[e ◂ {a ≃ b} = ρ e' - β] - A (ρ e - a)", would otherwise -- head-normalize to A (ρ (ρ e' - β) - a), which wouldn't check because it -- synthesizes the type of "ρ e' - β" (which in turn fails to synthesize the type -- of "β"). Similar issues could happen if the term is synthesized and it uses a ρ, -- and then substitutes into a place where it would be checked against a type. hnf{TYPE} Γ u (TpLet _ (DefTerm _ x ot t) T) hd = hnf Γ u (subst Γ (Chi posinfo-gen ot t) x T) hd -- Note that if we ever remove the requirement that type-lambdas have a classifier, -- we would need to introduce a type-level chi to do the same thing as above. -- Currently, synthesizing or checking a type should not make a difference. hnf{TYPE} Γ u (TpLet _ (DefType _ x k T) T') hd = hnf Γ u (subst Γ T x T') hd hnf{TYPE} Γ u x _ = x hnf{KIND} Γ no-unfolding e hd = e hnf{KIND} Γ u (KndParens _ k _) hd = hnf Γ u k hd hnf{KIND} Γ u@(unfold a _ _ _) (KndVar _ x ys) hd with ctxt-lookup-kind-var-def Γ x ... | nothing = KndVar posinfo-gen x ys ... | just (zs , k) with a | subst-params-args Γ zs ys k ... | tt | (kᵢ , [] , []) = hnf Γ u kᵢ hd ... | ff | (kᵢ , [] , []) = kᵢ ... | tf | (kᵢ , ps , as) = KndVar pi-gen x ys hnf{KIND} Γ u@(unfold a _ _ _) (KndPi _ _ x atk k) hd = if is-free-in check-erased x k then KndPi posinfo-gen posinfo-gen x atk (if a then hnf (ctxt-var-decl x Γ) u k ff else k) else tk-arrow-kind atk (if a then hnf Γ u k ff else k) hnf{KIND} Γ u@(unfold tt _ _ _) (KndArrow k k') hd = KndArrow (hnf Γ u k ff) (hnf Γ u k' ff) hnf{KIND} Γ u@(unfold tt _ _ _) (KndTpArrow T k) hd = KndTpArrow (hnf Γ u T ff) (hnf Γ u k ff) hnf{KIND} Γ u x hd = x hnf{LIFTINGTYPE} Γ u x hd = x hnf{TK} Γ u (Tkk k) _ = Tkk (hnf Γ u k tt) hnf{TK} Γ u (Tkt tp) _ = Tkt (hnf Γ u tp ff) hnf{QUALIF} Γ u x hd = x hnf{ARG} Γ u x hd = x hnf-optClass Γ u NoClass = NoClass hnf-optClass Γ u (SomeClass atk) = SomeClass (hnf Γ u atk ff) {- this function reduces a term to "head-applicative" normal form, which avoids unfolding definitions if they would lead to a top-level lambda-abstraction or top-level application headed by a variable for which we do not have a (global) definition. -} {-# TERMINATING #-} hanf : ctxt → (e : 𝔹) → term → term hanf Γ e t with hnf Γ (unfolding-set-erased unfold-head-one e) t tt hanf Γ e t | t' with decompose-apps t' hanf Γ e t | t' | (Var _ x) , [] = t' hanf Γ e t | t' | (Var _ x) , args with ctxt-lookup-term-var-def Γ x hanf Γ e t | t' | (Var _ x) , args | nothing = t' hanf Γ e t | t' | (Var _ x) , args | just _ = hanf Γ e t' hanf Γ e t | t' | h , args {- h could be a Lambda if args is [] -} = t -- unfold across the term-type barrier hnf-term-type : ctxt → (e : 𝔹) → type → type hnf-term-type Γ e (TpEq _ t1 t2 _) = TpEq posinfo-gen (hanf Γ e t1) (hanf Γ e t2) posinfo-gen hnf-term-type Γ e (TpAppt tp t) = hnf Γ (unfolding-set-erased unfold-head e) (TpAppt tp (hanf Γ e t)) tt hnf-term-type Γ e tp = hnf Γ unfold-head tp tt conv-cases : conv-t cases conv-cases Γ cs₁ cs₂ = isJust $ foldl (λ c₂ x → x ≫=maybe λ cs₁ → conv-cases' Γ cs₁ c₂) (just cs₁) cs₂ where conv-cases' : ctxt → cases → case → maybe cases conv-cases' Γ [] (Case _ x₂ as₂ t₂) = nothing conv-cases' Γ (c₁ @ (Case _ x₁ as₁ t₁) :: cs₁) c₂ @ (Case _ x₂ as₂ t₂) with conv-ctr Γ x₁ x₂ ...| ff = conv-cases' Γ cs₁ c₂ ≫=maybe λ cs₁ → just (c₁ :: cs₁) ...| tt = maybe-if (length as₂ =ℕ length as₁ && conv-term Γ (snd (expand-case c₁)) (snd (expand-case (Case pi-gen x₂ as₂ t₂)))) ≫maybe just cs₁ ctxt-term-udef : posinfo → defScope → opacity → var → term → ctxt → ctxt conv-term-norm Γ (Var _ x) (Var _ x') = ctxt-eq-rep Γ x x' || conv-ctr Γ x x' -- hnf implements erasure for terms, so we can ignore some subterms for App and Lam cases below conv-term-norm Γ (App t1 m t2) (App t1' m' t2') = conv-term-norm Γ t1 t1' && conv-term Γ t2 t2' conv-term-norm Γ (Lam _ l _ x oc t) (Lam _ l' _ x' oc' t') = conv-term (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) t t' conv-term-norm Γ (Hole _) _ = tt conv-term-norm Γ _ (Hole _) = tt conv-term-norm Γ (Mu _ _ x₁ t₁ _ _ cs₁ _) (Mu _ _ x₂ t₂ _ _ cs₂ _) = let --fₓ = fresh-var x₂ (ctxt-binds-var Γ) empty-renamectxt --μ = mlam fₓ $ Mu pi-gen pi-gen x₂ (mvar fₓ) NoType pi-gen cs₂ pi-gen Γ' = ctxt-rename x₁ x₂ $ ctxt-var-decl x₂ Γ in --ctxt-term-udef pi-gen localScope OpacTrans x₂ μ Γ in conv-term Γ t₁ t₂ && conv-cases Γ' cs₁ cs₂ -- (subst-cases Γ' id-term (mu-name-cast x₁) cs₁) (subst-cases Γ' id-term (mu-name-cast x₂) cs₂) conv-term-norm Γ (Mu' _ _ t₁ _ _ cs₁ _) (Mu' _ _ t₂ _ _ cs₂ _) = conv-term Γ t₁ t₂ && conv-cases Γ cs₁ cs₂ {- it can happen that a term is equal to a lambda abstraction in head-normal form, if that lambda-abstraction would eta-contract following some further beta-reductions. We implement this here by implicitly eta-expanding the variable and continuing the comparison. A simple example is λ v . t ((λ a . a) v) ≃ t -} conv-term-norm Γ (Lam _ l _ x oc t) t' = let x' = fresh-var x (ctxt-binds-var Γ) empty-renamectxt in conv-term (ctxt-rename x x' Γ) t (App t' NotErased (Var posinfo-gen x')) conv-term-norm Γ t' (Lam _ l _ x oc t) = let x' = fresh-var x (ctxt-binds-var Γ) empty-renamectxt in conv-term (ctxt-rename x x' Γ) (App t' NotErased (Var posinfo-gen x')) t conv-term-norm Γ _ _ = ff conv-type-norm Γ (TpVar _ x) (TpVar _ x') = ctxt-eq-rep Γ x x' conv-type-norm Γ (TpApp t1 t2) (TpApp t1' t2') = conv-type-norm Γ t1 t1' && conv-type Γ t2 t2' conv-type-norm Γ (TpAppt t1 t2) (TpAppt t1' t2') = conv-type-norm Γ t1 t1' && conv-term Γ t2 t2' conv-type-norm Γ (Abs _ b _ x atk tp) (Abs _ b' _ x' atk' tp') = eq-maybeErased b b' && conv-tk Γ atk atk' && conv-type (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) tp tp' conv-type-norm Γ (TpArrow tp1 a1 tp2) (TpArrow tp1' a2 tp2') = eq-maybeErased a1 a2 && conv-type Γ tp1 tp1' && conv-type Γ tp2 tp2' conv-type-norm Γ (TpArrow tp1 a tp2) (Abs _ b _ _ (Tkt tp1') tp2') = eq-maybeErased a b && conv-type Γ tp1 tp1' && conv-type Γ tp2 tp2' conv-type-norm Γ (Abs _ b _ _ (Tkt tp1) tp2) (TpArrow tp1' a tp2') = eq-maybeErased a b && conv-type Γ tp1 tp1' && conv-type Γ tp2 tp2' conv-type-norm Γ (Iota _ _ x m tp) (Iota _ _ x' m' tp') = conv-type Γ m m' && conv-type (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) tp tp' conv-type-norm Γ (TpEq _ t1 t2 _) (TpEq _ t1' t2' _) = conv-term Γ t1 t1' && conv-term Γ t2 t2' conv-type-norm Γ (Lft _ _ x t l) (Lft _ _ x' t' l') = conv-liftingType Γ l l' && conv-term (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) t t' conv-type-norm Γ (TpLambda _ _ x atk tp) (TpLambda _ _ x' atk' tp') = conv-tk Γ atk atk' && conv-type (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) tp tp' {-conv-type-norm Γ (TpLambda _ _ x atk tp) tp' = let x' = fresh-var x (ctxt-binds-var Γ) empty-renamectxt tp'' = if tk-is-type atk then TpAppt tp' (mvar x') else TpApp tp' (mtpvar x') in conv-type-norm (ctxt-rename x x' Γ) tp tp'' conv-type-norm Γ tp' (TpLambda _ _ x atk tp) = let x' = fresh-var x (ctxt-binds-var Γ) empty-renamectxt tp'' = if tk-is-type atk then TpAppt tp' (mvar x') else TpApp tp' (mtpvar x') in conv-type-norm (ctxt-rename x x' Γ) tp'' tp-} conv-type-norm Γ _ _ = ff {- even though hnf turns Pi-kinds where the variable is not free in the body into arrow kinds, we still need to check off-cases, because normalizing the body of a kind could cause the bound variable to be erased (hence allowing it to match an arrow kind). -} conv-kind-norm Γ (KndArrow k k₁) (KndArrow k' k'') = conv-kind Γ k k' && conv-kind Γ k₁ k'' conv-kind-norm Γ (KndArrow k k₁) (KndPi _ _ x (Tkk k') k'') = conv-kind Γ k k' && conv-kind Γ k₁ k'' conv-kind-norm Γ (KndArrow k k₁) _ = ff conv-kind-norm Γ (KndPi _ _ x (Tkk k₁) k) (KndArrow k' k'') = conv-kind Γ k₁ k' && conv-kind Γ k k'' conv-kind-norm Γ (KndPi _ _ x atk k) (KndPi _ _ x' atk' k'') = conv-tk Γ atk atk' && conv-kind (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) k k'' conv-kind-norm Γ (KndPi _ _ x (Tkt t) k) (KndTpArrow t' k'') = conv-type Γ t t' && conv-kind Γ k k'' conv-kind-norm Γ (KndPi _ _ x (Tkt t) k) _ = ff conv-kind-norm Γ (KndPi _ _ x (Tkk k') k) _ = ff conv-kind-norm Γ (KndTpArrow t k) (KndTpArrow t' k') = conv-type Γ t t' && conv-kind Γ k k' conv-kind-norm Γ (KndTpArrow t k) (KndPi _ _ x (Tkt t') k') = conv-type Γ t t' && conv-kind Γ k k' conv-kind-norm Γ (KndTpArrow t k) _ = ff conv-kind-norm Γ (Star x) (Star x') = tt conv-kind-norm Γ (Star x) _ = ff conv-kind-norm Γ _ _ = ff -- should not happen, since the kinds are in hnf conv-tk Γ tk tk' = conv-tke Γ (erase-tk tk) (erase-tk tk') conv-tke Γ (Tkk k) (Tkk k') = conv-kind Γ k k' conv-tke Γ (Tkt t) (Tkt t') = conv-type Γ t t' conv-tke Γ _ _ = ff conv-liftingType Γ l l' = conv-liftingTypee Γ (erase l) (erase l') conv-liftingTypee Γ l l' = conv-kind Γ (liftingType-to-kind l) (liftingType-to-kind l') conv-optClass Γ NoClass NoClass = tt conv-optClass Γ (SomeClass x) (SomeClass x') = conv-tk Γ (erase-tk x) (erase-tk x') conv-optClass Γ _ _ = ff conv-optClasse Γ NoClass NoClass = tt conv-optClasse Γ (SomeClass x) (SomeClass x') = conv-tk Γ x x' conv-optClasse Γ _ _ = ff conv-tty* Γ [] [] = tt conv-tty* Γ (tterm t :: args) (tterm t' :: args') = conv-term Γ (erase t) (erase t') && conv-tty* Γ args args' conv-tty* Γ (ttype t :: args) (ttype t' :: args') = conv-type Γ (erase t) (erase t') && conv-tty* Γ args args' conv-tty* Γ _ _ = ff conv-ttye* Γ [] [] = tt conv-ttye* Γ (tterm t :: args) (tterm t' :: args') = conv-term Γ t t' && conv-ttye* Γ args args' conv-ttye* Γ (ttype t :: args) (ttype t' :: args') = conv-type Γ t t' && conv-ttye* Γ args args' conv-ttye* Γ _ _ = ff conv-ctr Γ x₁ x₂ = conv-ctr-args Γ (x₁ , []) (x₂ , []) conv-ctr-ps Γ x₁ x₂ with env-lookup Γ x₁ | env-lookup Γ x₂ ...| just (ctr-def ps₁ T₁ n₁ i₁ a₁ , _) | just (ctr-def ps₂ T₂ n₂ i₂ a₂ , _) = maybe-if (n₁ =ℕ n₂ && i₁ =ℕ i₂ && a₁ =ℕ a₂) ≫maybe just (erase-params ps₁ , erase-params ps₂) ...| _ | _ = nothing conv-ctr-args Γ (x₁ , as₁) (x₂ , as₂) = maybe-else' (conv-ctr-ps Γ x₁ x₂) ff $ uncurry λ ps₁ ps₂ → conv-argse Γ (drop (length ps₁) $ erase-args as₁) (drop (length ps₂) $ erase-args as₂) hnf-qualif-term : ctxt → term → term hnf-qualif-term Γ t = hnf Γ unfold-head (qualif-term Γ t) tt hnf-qualif-type : ctxt → type → type hnf-qualif-type Γ t = hnf Γ unfold-head (qualif-type Γ t) tt hnf-qualif-kind : ctxt → kind → kind hnf-qualif-kind Γ t = hnf Γ unfold-head (qualif-kind Γ t) tt {-# TERMINATING #-} inconv : ctxt → term → term → 𝔹 inconv Γ t₁ t₂ = inconv-lams empty-renamectxt empty-renamectxt (hnf Γ unfold-all t₁ tt) (hnf Γ unfold-all t₂ tt) where fresh : var → renamectxt → renamectxt → var fresh x ρ₁ = fresh-var x (λ x → ctxt-binds-var Γ x || renamectxt-in-field ρ₁ x) make-subst : renamectxt → renamectxt → 𝕃 var → 𝕃 var → term → term → (renamectxt × renamectxt × term × term) make-subst ρ₁ ρ₂ [] [] t₁ t₂ = ρ₁ , ρ₂ , t₁ , t₂ -- subst-renamectxt Γ ρ₁ t₁ , subst-renamectxt Γ ρ₂ t₂ make-subst ρ₁ ρ₂ (x₁ :: xs₁) [] t₁ t₂ = let x = fresh x₁ ρ₁ ρ₂ in make-subst (renamectxt-insert ρ₁ x₁ x) (renamectxt-insert ρ₂ x x) xs₁ [] t₁ (mapp t₂ $ mvar x) make-subst ρ₁ ρ₂ [] (x₂ :: xs₂) t₁ t₂ = let x = fresh x₂ ρ₁ ρ₂ in make-subst (renamectxt-insert ρ₁ x x) (renamectxt-insert ρ₂ x₂ x) [] xs₂ (mapp t₁ $ mvar x) t₂ make-subst ρ₁ ρ₂ (x₁ :: xs₁) (x₂ :: xs₂) t₁ t₂ = let x = fresh x₁ ρ₁ ρ₂ in make-subst (renamectxt-insert ρ₁ x₁ x) (renamectxt-insert ρ₂ x₂ x) xs₁ xs₂ t₁ t₂ inconv-lams : renamectxt → renamectxt → term → term → 𝔹 inconv-apps : renamectxt → renamectxt → var → var → args → args → 𝔹 inconv-ctrs : renamectxt → renamectxt → var → var → args → args → 𝔹 inconv-mu : renamectxt → renamectxt → maybe (var × var) → cases → cases → 𝔹 inconv-args : renamectxt → renamectxt → args → args → 𝔹 inconv-args ρ₁ ρ₂ a₁ a₂ = let a₁ = erase-args a₁; a₂ = erase-args a₂ in ~ length a₁ =ℕ length a₂ || list-any (uncurry $ inconv-lams ρ₁ ρ₂) (zip a₁ a₂) inconv-lams ρ₁ ρ₂ t₁ t₂ = elim-pair (decompose-lams t₁) λ l₁ b₁ → elim-pair (decompose-lams t₂) λ l₂ b₂ → elim-pair (make-subst ρ₁ ρ₂ l₁ l₂ b₁ b₂) λ ρ₁ ρ₂b₁₂ → elim-pair ρ₂b₁₂ λ ρ₂ b₁₂ → elim-pair b₁₂ λ b₁ b₂ → case (decompose-apps b₁ , decompose-apps b₂) of uncurry λ where (Var _ x₁ , a₁) (Var _ x₂ , a₂) → inconv-apps ρ₁ ρ₂ x₁ x₂ a₁ a₂ || inconv-ctrs ρ₁ ρ₂ x₁ x₂ a₁ a₂ (Mu _ _ x₁ t₁ _ _ ms₁ _ , a₁) (Mu _ _ x₂ t₂ _ _ ms₂ _ , a₂) → inconv-mu ρ₁ ρ₂ (just $ x₁ , x₂) ms₁ ms₂ || inconv-lams ρ₁ ρ₂ t₁ t₂ || inconv-args ρ₁ ρ₂ a₁ a₂ (Mu' _ _ t₁ _ _ ms₁ _ , a₁) (Mu' _ _ t₂ _ _ ms₂ _ , a₂) → inconv-mu ρ₁ ρ₂ nothing ms₁ ms₂ || inconv-lams ρ₁ ρ₂ t₁ t₂ || inconv-args ρ₁ ρ₂ a₁ a₂ _ _ → ff inconv-apps ρ₁ ρ₂ x₁ x₂ a₁ a₂ = maybe-else' (renamectxt-lookup ρ₁ x₁) ff λ x₁ → maybe-else' (renamectxt-lookup ρ₂ x₂) ff λ x₂ → ~ x₁ =string x₂ || inconv-args ρ₁ ρ₂ a₁ a₂ inconv-ctrs ρ₁ ρ₂ x₁ x₂ as₁ as₂ with env-lookup Γ x₁ | env-lookup Γ x₂ ...| just (ctr-def ps₁ _ n₁ i₁ a₁ , _) | just (ctr-def ps₂ _ n₂ i₂ a₂ , _) = let ps₁ = erase-params ps₁; ps₂ = erase-params ps₂ as₁ = erase-args as₁; as₂ = erase-args as₂ in length as₁ ≤ length ps₁ + a₁ && -- Could use of "≤" here conflict with η-equality? length as₂ ≤ length ps₂ + a₂ && (~ n₁ =ℕ n₂ || ~ i₁ =ℕ i₂ || ~ a₁ =ℕ a₂ || ~ length as₁ + length ps₂ =ℕ length as₂ + length ps₁ || -- ^ as₁ ∸ ps₁ ≠ as₂ ∸ ps₂, + ps₁ + ps₂ to both sides ^ list-any (uncurry $ inconv-lams ρ₁ ρ₂) (zip (drop (length ps₁) as₁) (drop (length ps₂) as₂))) ...| _ | _ = ff inconv-mu ρ₁ ρ₂ xs? ms₁ ms₂ = ~ length ms₁ =ℕ length ms₂ || maybe-else ff id (foldr {B = maybe 𝔹} (λ c b? → b? ≫=maybe λ b → inconv-case c ≫=maybe λ b' → just (b || b')) (just ff) ms₁) where matching-case : case → maybe (term × ℕ × ℕ) matching-case (Case _ x _ _) = foldl (λ where (Case _ xₘ cas tₘ) m? → m? maybe-or (conv-ctr-ps Γ xₘ x ≫=maybe uncurry λ psₘ ps → just (caseArgs-to-lams cas tₘ , length cas , length ps))) nothing ms₂ inconv-case : case → maybe 𝔹 inconv-case c₁ @ (Case _ x cas₁ t₁) = matching-case c₁ ≫=maybe λ c₂ → just (inconv-lams ρ₁ ρ₂ (caseArgs-to-lams cas₁ t₁) (fst c₂)) ctxt-params-def : params → ctxt → ctxt ctxt-params-def ps Γ@(mk-ctxt (fn , mn , _ , q) syms i symb-occs Δ) = mk-ctxt (fn , mn , ps' , q) syms i symb-occs Δ where ps' = qualif-params Γ ps ctxt-kind-def : posinfo → var → params → kind → ctxt → ctxt ctxt-kind-def pi v ps2 k Γ@(mk-ctxt (fn , mn , ps1 , q) (syms , mn-fn) i symb-occs Δ) = mk-ctxt (fn , mn , ps1 , qualif-insert-params q (mn # v) v ps1) (trie-insert-append2 syms fn mn v , mn-fn) (trie-insert i (mn # v) (kind-def (ps1 ++ qualif-params Γ ps2) k' , fn , pi)) symb-occs Δ where k' = hnf Γ unfold-head (qualif-kind Γ k) tt ctxt-datatype-decl : var → var → args → ctxt → ctxt ctxt-datatype-decl vₒ vᵣ as Γ@(mk-ctxt mod ss is os (Δ , μ' , μ)) = mk-ctxt mod ss is os $ Δ , trie-insert μ' (mu-Type/ vᵣ) (vₒ , mu-isType/ vₒ , as) , μ -- assumption: classifier (i.e. kind) already qualified ctxt-datatype-def : posinfo → var → params → kind → kind → ctrs → ctxt → ctxt ctxt-datatype-def pi v psᵢ kᵢ k cs Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i os (Δ , μ' , μ)) = let v' = mn # v q' = qualif-insert-params q v' v ps in mk-ctxt (fn , mn , ps , q') (trie-insert-append2 syms fn mn v , mn-fn) (trie-insert i v' (type-def (just ps) OpacTrans nothing (abs-expand-kind psᵢ k) , fn , pi)) os (trie-insert Δ v' (ps ++ psᵢ , kᵢ , k , cs) , μ' , trie-insert μ (data-Is/ v') v') -- assumption: classifier (i.e. kind) already qualified ctxt-type-def : posinfo → defScope → opacity → var → maybe type → kind → ctxt → ctxt ctxt-type-def pi s op v t k Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i symb-occs Δ) = mk-ctxt (fn , mn , ps , q') ((if (s iff localScope) then syms else trie-insert-append2 syms fn mn v) , mn-fn) (trie-insert i v' (type-def (def-params s ps) op t' k , fn , pi)) symb-occs Δ where t' = maybe-map (λ t → hnf Γ unfold-head (qualif-type Γ t) tt) t v' = if s iff localScope then pi % v else mn # v q' = qualif-insert-params q v' v (if s iff localScope then [] else ps) ctxt-ctr-def : posinfo → var → type → params → (ctrs-length ctr-index : ℕ) → ctxt → ctxt ctxt-ctr-def pi c t ps' n i Γ@(mk-ctxt mod@(fn , mn , ps , q) (syms , mn-fn) is symb-occs Δ) = mk-ctxt (fn , mn , ps , q') ((trie-insert-append2 syms fn mn c) , mn-fn) (trie-insert is c' (ctr-def (ps ++ ps') t n i (unerased-arrows t) , fn , pi)) symb-occs Δ where c' = mn # c q' = qualif-insert-params q c' c ps -- assumption: classifier (i.e. type) already qualified ctxt-term-def : posinfo → defScope → opacity → var → maybe term → type → ctxt → ctxt ctxt-term-def pi s op v t tp Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i symb-occs Δ) = mk-ctxt (fn , mn , ps , q') ((if (s iff localScope) then syms else trie-insert-append2 syms fn mn v) , mn-fn) (trie-insert i v' (term-def (def-params s ps) op t' tp , fn , pi)) symb-occs Δ where t' = maybe-map (λ t → hnf Γ unfold-head (qualif-term Γ t) tt) t v' = if s iff localScope then pi % v else mn # v q' = qualif-insert-params q v' v (if s iff localScope then [] else ps) ctxt-term-udef pi s op v t Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i symb-occs Δ) = mk-ctxt (fn , mn , ps , qualif-insert-params q v' v (if s iff localScope then [] else ps)) ((if (s iff localScope) then syms else trie-insert-append2 syms fn mn v) , mn-fn) (trie-insert i v' (term-udef (def-params s ps) op t' , fn , pi)) symb-occs Δ where t' = hnf Γ unfold-head (qualif-term Γ t) tt v' = if s iff localScope then pi % v else mn # v
{ "alphanum_fraction": 0.6221707074, "avg_line_length": 50.9163934426, "ext": "agda", "hexsha": "b791c77c7de2443591df9a78a6d4058aa14cda50", "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": "f5ce42258b7d9bc66f75cd679c785d6133b82b58", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CarlOlson/cedille", "max_forks_repo_path": "src/conversion.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f5ce42258b7d9bc66f75cd679c785d6133b82b58", "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": "CarlOlson/cedille", "max_issues_repo_path": "src/conversion.agda", "max_line_length": 316, "max_stars_count": null, "max_stars_repo_head_hexsha": "f5ce42258b7d9bc66f75cd679c785d6133b82b58", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CarlOlson/cedille", "max_stars_repo_path": "src/conversion.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 12082, "size": 31059 }
-- | In this module we show that the substream relation is transitive. open import Streams open import Relation.Binary.PropositionalEquality as P open import Data.Product open import Function.Equivalence mutual record F : Set where coinductive field out : Fμ data Fμ : Set where pres : F → Fμ drop : Fμ → Fμ open F public μfilter : ∀{A} → Fμ → Stream A → Stream A filter : ∀{A} → F → Stream A → Stream A filter x = μfilter (out x) hd (μfilter (pres x) s) = hd s tl (μfilter (pres x) s) = filter x (tl s) μfilter (drop u) s = μfilter u (tl s) comp : F → F → F μcomp : Fμ → Fμ → Fμ out (comp x y) = μcomp (out x) (out y) μcomp (pres x) (pres y) = pres (comp x y) μcomp (pres x) (drop v) = drop (μcomp (out x) v) μcomp (drop u) v = drop (μcomp u v) _•_ : F → F → F y • x = comp x y _•μ_ : Fμ → Fμ → Fμ v •μ u = μcomp u v filter-comp : ∀{A} → ∀ x y (s : Stream A) → filter (y • x) s ~ filter y (filter x s) μfilter-comp : ∀{A} → ∀ u v (s : Stream A) → μfilter (v •μ u) s ~ μfilter v (μfilter u s) filter-comp x y s = μfilter-comp (out x) (out y) s hd~(μfilter-comp (pres x) (pres y) s) = refl tl~(μfilter-comp (pres x) (pres y) s) = filter-comp x y (tl s) μfilter-comp (pres x) (drop v) s = μfilter-comp (out x) v (tl s) -- The following cases are just the same, they need to be there for Agda to -- reduce the definition of μcomp μfilter-comp (drop u) (pres x) s = μfilter-comp u (pres x) (tl s) μfilter-comp (drop u) (drop v) s = μfilter-comp u (drop v) (tl s) _≤[_]_ : ∀{A} → Stream A → F → Stream A → Set s ≤[ x ] t = s ~ filter x t _≤μ[_]_ : ∀{A} → Stream A → Fμ → Stream A → Set s ≤μ[ x ] t = s ~ μfilter x t mutual record _≤_ {A : Set} (s t : Stream A) : Set where coinductive field out≤ : s ≤μ t data _≤μ_ {A : Set} (s t : Stream A) : Set where ma : hd s ≡ hd t → (tl s) ≤ (tl t) → s ≤μ t sk : s ≤μ (tl t) → s ≤μ t open _≤_ public witness : ∀{A} {s t : Stream A} → s ≤ t → F xwitness : ∀{A} {s t : Stream A} → s ≤μ t → Fμ out (witness p) = xwitness (out≤ p) xwitness (ma _ t≤) = pres (witness t≤) xwitness (sk u) = drop (xwitness u) impl₁ : ∀{A} {s t : Stream A} → (p : s ≤ t) → s ≤[ witness p ] t ximpl₁ : ∀{A} {s t : Stream A} → (p : s ≤μ t) → s ≤μ[ xwitness p ] t impl₁ {A} {s} {t} p = ximpl₁ (out≤ p) hd~ (ximpl₁ (ma h≡ t≤)) = h≡ tl~ (ximpl₁ (ma h≡ t≤)) = impl₁ t≤ ximpl₁ (sk q) = ximpl₁ q impl₂ : ∀{A} {s t : Stream A} (x : F) → s ≤[ x ] t → s ≤ t ximpl₂ : ∀{A} {s t : Stream A} (u : Fμ) → s ≤μ[ u ] t → s ≤μ t out≤ (impl₂ x p) = ximpl₂ (out x) p ximpl₂ (pres x) p = ma (hd~ p) (impl₂ x (tl~ p)) ximpl₂ (drop u) p = sk (ximpl₂ u p) ≤⇔filter-≤ : ∀{A} (s t : Stream A) → s ≤ t ⇔ ∃ λ p → s ≤[ p ] t ≤⇔filter-≤ s t = equivalence (λ x → witness x , impl₁ x) (λ {(x , p) → impl₂ x p}) filter-resp~ : ∀{A} {s t : Stream A} (x : F) → s ~ t → filter x s ~ filter x t μfilter-resp~ : ∀{A} {s t : Stream A} (u : Fμ) → s ~ t → μfilter u s ~ μfilter u t filter-resp~ x p = μfilter-resp~ (out x) p hd~ (μfilter-resp~ (pres x) p) = hd~ p tl~ (μfilter-resp~ (pres x) p) = filter-resp~ x (tl~ p) μfilter-resp~ (drop u) p = μfilter-resp~ u (tl~ p) {- We prove transitivity of the witnessed substream relation by r ~ filter x s ~ filter x (filter y t) ~ filter (comp x y) t -} ≤-filter-trans : ∀{A} {r s t : Stream A} {x y} → r ≤[ x ] s → s ≤[ y ] t → r ≤[ x • y ] t ≤-filter-trans {x = x} {y} p q = ~trans p ( ~trans (filter-resp~ x q) (~sym (filter-comp y x _))) ≤-trans : ∀{A} {r s t : Stream A} → r ≤ s → s ≤ t → r ≤ t ≤-trans p q = impl₂ (witness p • witness q) (≤-filter-trans {x = witness p} {y = witness q} (impl₁ p) (impl₁ q) ) -- lem : ∀{A} {s t : Stream A} → hd s ≡ hd t → tl s ≤ tl t → t ≤μ tl s → tl t ≤μ tl s -- lem s0≡t0 t'≤s' (ma t0≡s1 t'≤s'') with out≤ t'≤s' -- lem s0≡t0 t'≤s' (ma t0≡s1 t'≤s'') | ma s1≡t1 s''≤t'' = ma (P.sym s1≡t1) {!!} -- lem s0≡t0 t'≤s' (ma t0≡s1 t'≤s'') | sk p = {!!} -- lem {s = s} s0≡t0 s'≤t' (sk p) = {!!} -- ≤-antisym : ∀{A} {s t : Stream A} → -- s ≤ t → t ≤ s → s ~ t -- ≤μ-antisym : ∀{A} {s t : Stream A} → -- s ≤μ t → t ≤μ s → s ~ t -- ≤-antisym p q = ≤μ-antisym (out≤ p) (out≤ q) -- hd~ (≤μ-antisym (ma hs≡ht ts≤tt) _) = hs≡ht -- tl~ (≤μ-antisym (ma hs≡ht ts≤tt) (ma ht≡hs tt≤ts)) = ≤-antisym ts≤tt tt≤ts -- tl~ (≤μ-antisym (ma hs≡ht ts≤tt) (sk q)) = ≤μ-antisym (out≤ ts≤tt) {!!} -- ≤μ-antisym (sk p) q = {!!} {- ------------------ --- Try to convince Agda that x = zip(ev(x), odd(x)) is well-defined. even : ∀{A} → Stream A → Stream A hd (even s) = hd s tl (even s) = even (tl (tl s)) odd : ∀{A} → Stream A → Stream A odd s = even (tl s) zips : ∀{A} → Stream A → Stream A → Stream A hd (zips s t) = hd s tl (zips s t) = zips t (tl s) open import Data.Nat foo : Stream ℕ hd foo = 0 tl foo = zips (even foo) (odd foo) -- H : Stream ℕ → Stream ℕ → Stream ℕ -- f : ℕ → Stream ℕ → Stream ℕ → Stream ℕ -- H s t = f (hd t) s t -- hd (f zero s t) = hd s -- tl (f zero s t) = H s (tl t) -- f (suc n) s t = f n (tl s) t -}
{ "alphanum_fraction": 0.5060698027, "avg_line_length": 28.192513369, "ext": "agda", "hexsha": "d834280c4c68a1fa9d6b0c6ce9a69c3dad09f041", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "Streams/Substream.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hbasold/Sandbox", "max_issues_repo_path": "Streams/Substream.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "Streams/Substream.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2220, "size": 5272 }
{-# OPTIONS --without-K --safe #-} module Definition.Conversion.Conversion where open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.RedSteps open import Definition.Typed.Properties open import Definition.Conversion open import Definition.Conversion.Stability open import Definition.Conversion.Soundness open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.Substitution open import Definition.Typed.Consequences.Injectivity open import Definition.Typed.Consequences.Equality open import Definition.Typed.Consequences.Reduction open import Tools.Product import Tools.PropositionalEquality as PE mutual -- Conversion of algorithmic equality. convConv↑Term : ∀ {t u A B Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A ≡ B → Γ ⊢ t [conv↑] u ∷ A → Δ ⊢ t [conv↑] u ∷ B convConv↑Term Γ≡Δ A≡B ([↑]ₜ B₁ t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) = let _ , ⊢B = syntacticEq A≡B B′ , whnfB′ , D′ = whNorm ⊢B B₁≡B′ = trans (sym (subset* D)) (trans A≡B (subset* (red D′))) in [↑]ₜ B′ t′ u′ (stabilityRed* Γ≡Δ (red D′)) (stabilityRed*Term Γ≡Δ (conv* d B₁≡B′)) (stabilityRed*Term Γ≡Δ (conv* d′ B₁≡B′)) whnfB′ whnft′ whnfu′ (convConv↓Term Γ≡Δ B₁≡B′ whnfB′ t<>u) -- Conversion of algorithmic equality with terms and types in WHNF. convConv↓Term : ∀ {t u A B Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A ≡ B → Whnf B → Γ ⊢ t [conv↓] u ∷ A → Δ ⊢ t [conv↓] u ∷ B convConv↓Term Γ≡Δ A≡B whnfB (ℕ-ins x) rewrite ℕ≡A A≡B whnfB = ℕ-ins (stability~↓ Γ≡Δ x) convConv↓Term Γ≡Δ A≡B whnfB (Empty-ins x) rewrite Empty≡A A≡B whnfB = Empty-ins (stability~↓ Γ≡Δ x) convConv↓Term Γ≡Δ A≡B whnfB (Unit-ins x) rewrite Unit≡A A≡B whnfB = Unit-ins (stability~↓ Γ≡Δ x) convConv↓Term Γ≡Δ A≡B whnfB (ne-ins t u x x₁) with ne≡A x A≡B whnfB convConv↓Term Γ≡Δ A≡B whnfB (ne-ins t u x x₁) | B , neB , PE.refl = ne-ins (stabilityTerm Γ≡Δ (conv t A≡B)) (stabilityTerm Γ≡Δ (conv u A≡B)) neB (stability~↓ Γ≡Δ x₁) convConv↓Term Γ≡Δ A≡B whnfB (univ x x₁ x₂) rewrite U≡A A≡B = univ (stabilityTerm Γ≡Δ x) (stabilityTerm Γ≡Δ x₁) (stabilityConv↓ Γ≡Δ x₂) convConv↓Term Γ≡Δ A≡B whnfB (zero-refl x) rewrite ℕ≡A A≡B whnfB = let _ , ⊢Δ , _ = contextConvSubst Γ≡Δ in zero-refl ⊢Δ convConv↓Term Γ≡Δ A≡B whnfB (suc-cong x) rewrite ℕ≡A A≡B whnfB = suc-cong (stabilityConv↑Term Γ≡Δ x) convConv↓Term Γ≡Δ A≡B whnfB (η-eq x₁ x₂ y y₁ x₃) with Π≡A A≡B whnfB convConv↓Term Γ≡Δ A≡B whnfB (η-eq x₁ x₂ y y₁ x₃) | F′ , G′ , PE.refl = let F≡F′ , G≡G′ = injectivity A≡B in η-eq (stabilityTerm Γ≡Δ (conv x₁ A≡B)) (stabilityTerm Γ≡Δ (conv x₂ A≡B)) y y₁ (convConv↑Term (Γ≡Δ ∙ F≡F′) G≡G′ x₃) convConv↓Term Γ≡Δ A≡B whnfB (Σ-η ⊢p ⊢r pProd rProd fstConv sndConv) with Σ≡A A≡B whnfB ... | F , G , PE.refl = let F≡ , G≡ = Σ-injectivity A≡B ⊢F = proj₁ (syntacticEq F≡) ⊢G = proj₁ (syntacticEq G≡) ⊢fst = fstⱼ ⊢F ⊢G ⊢p in Σ-η (stabilityTerm Γ≡Δ (conv ⊢p A≡B)) (stabilityTerm Γ≡Δ (conv ⊢r A≡B)) pProd rProd (convConv↑Term Γ≡Δ F≡ fstConv) (convConv↑Term Γ≡Δ (substTypeEq G≡ (refl ⊢fst)) sndConv) convConv↓Term Γ≡Δ A≡B whnfB (η-unit [t] [u] tUnit uUnit) rewrite Unit≡A A≡B whnfB = let [t] = stabilityTerm Γ≡Δ [t] [u] = stabilityTerm Γ≡Δ [u] in η-unit [t] [u] tUnit uUnit -- Conversion of algorithmic equality with the same context. convConvTerm : ∀ {t u A B Γ} → Γ ⊢ t [conv↑] u ∷ A → Γ ⊢ A ≡ B → Γ ⊢ t [conv↑] u ∷ B convConvTerm t<>u A≡B = convConv↑Term (reflConEq (wfEq A≡B)) A≡B t<>u
{ "alphanum_fraction": 0.5949597298, "avg_line_length": 41.3870967742, "ext": "agda", "hexsha": "7f8d156540f2087ba9547ffcd6d06a44161d556e", "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/Conversion/Conversion.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/Conversion/Conversion.agda", "max_line_length": 85, "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/Conversion/Conversion.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1604, "size": 3849 }
module z05-00-internal-verification where open import bool open import eq open import nat open import nat-thms open import product open import sum {- ------------------------------------------------------------------------------ so far: EXTERNAL VERIFICATION - written programs (e.g., 'length') - proved properties (e.g., 'length-reverse') This style of verification in type theory is called external verification - proofs are external to programs - proofs are distinct artifacts about some pre-existing programs INTERNAL VERIFICATION write functions with semantically expressive types write datatypes that put restrictions on data may require embedding proofs in code ------------------------------------------------------------------------------ -- p 99 VECTORS - length of vector included in type : vector is INDEXED by its length -- vector.agda -} data 𝕍 {ℓ} (A : Set ℓ) : ℕ → Set ℓ where [] : 𝕍 A 0 _::_ : {n : ℕ} (x : A) (xs : 𝕍 A n) → 𝕍 A (suc n) -- compare to list (overloaded constructors OK) data L {ℓ} (A : Set ℓ) : Set ℓ where [] : L A _::_ : (x : A) (xs : L A) → L A infixr 6 _::_ _++𝕍_ -- p 101 [_]𝕍 : ∀ {ℓ} {A : Set ℓ} → A → 𝕍 A 1 [ x ]𝕍 = x :: [] -- type level addition on length _++𝕍_ : ∀ {ℓ} {A : Set ℓ}{n m : ℕ} → 𝕍 A n → 𝕍 A m → 𝕍 A (n + m) [] ++𝕍 ys = ys (x :: xs) ++𝕍 ys = x :: xs ++𝕍 ys -- p 102 -- no 'nil' list corner case head𝕍 : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → 𝕍 A (suc n) → A head𝕍 (x :: _) = x -- type level subtraction tail𝕍 : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → 𝕍 A n → 𝕍 A (pred n) tail𝕍 [] = [] tail𝕍 (_ :: xs) = xs -- p 103 -- length preserving (for lists, length preservation is separate proof) map𝕍 : ∀ {ℓ ℓ'} {A : Set ℓ} {B : Set ℓ'} {n : ℕ} → (A → B) → 𝕍 A n → 𝕍 B n map𝕍 f [] = [] map𝕍 f (x :: xs) = f x :: map𝕍 f xs -- p 104 -- takes a vector of length m -- each element is vector of length n -- concats into single vector of length m * n concat𝕍 : ∀{ℓ} {A : Set ℓ} {n m : ℕ} → 𝕍 (𝕍 A n) m → 𝕍 A (m * n) concat𝕍 [] = [] concat𝕍 (x :: xs) = x ++𝕍 (concat𝕍 xs) -- p 104 -- no need for maybe result as in lists by requiring n < m nth𝕍 : ∀ {ℓ} {A : Set ℓ} {m : ℕ} → (n : ℕ) → n < m ≡ tt → 𝕍 A m → A nth𝕍 0 _ (x :: _) = x -- Proof p (that index is less than length of vector) reused in recursive call. -- index is suc n -- length of list is suc m, for implicit m -- Agda implicitly introduces .m with suc .m -- p proves suc n < suc m ≡ tt -- def/eq to n < m ≡ tt -- so p has correct type to make the recursive call nth𝕍 (suc n) p (_ :: xs) = nth𝕍 n p xs -- us absurd pattern for the proof in last two cases -- length of list is zero, so no index can be smaller than that length -- must case-split on the index so Agda can the absurdity -- because the definition of _<_ splits on both inputs -- - returns ff separately for when the first input is is 0 and the second is 0 -- - and for the first input being suc n and second is 0 nth𝕍 (suc n) () [] nth𝕍 0 () [] -- p 105 repeat𝕍 : ∀ {ℓ} {A : Set ℓ} → (a : A) (n : ℕ) → 𝕍 A n repeat𝕍 a 0 = [] repeat𝕍 a (suc n) = a :: (repeat𝕍 a n) {- ------------------------------------------------------------------------------ -- p 106 BRAUN TREES : balanced binary heaps either empty or node consisting of some data x and a left and a right subtree data may be stored so that x is smaller than all data in left and right subtrees if such an ordering property is desired BRAUN TREE PROPERTY (BTP) : crucial property : sizes of left and right trees: for each node in the tree - either size (left) = size ( right ) or size (left) = size ( right ) + 1 ensures depth of the trees is ≤ log₂(N), where N is the number of nodes property maintained (via types) during insert make the type A and ordering on that type be parameters of the module braun-tree.adga -} module braun-tree {ℓ} (A : Set ℓ) (_<A_ : A → A → 𝔹) where -- index n is size (number of elements of type A) of the tree data braun-tree : (n : ℕ) → Set ℓ where bt-empty : braun-tree 0 bt-node : ∀ {n m : ℕ} → A → braun-tree n → braun-tree m → n ≡ m ∨ n ≡ suc m -- 'v' defined in sum.agda for disjunction of two types → braun-tree (suc (n + m)) {- -- p 107 sum.agda -- types A and B, possibly at different levels, accounted via ⊔ in return type -- ⊔ part of Agda’s primitive level system : imported from Agda.Primitive module in level.agda -- use this in code that intended to be run data _⊎_ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') : Set (ℓ ⊔ ℓ') where inj₁ : (x : A) → A ⊎ B -- built from an A inj₂ : (y : B) → A ⊎ B -- built from an B -- use this to represent a logical proposition _∨_ : ∀ {ℓ ℓ'} (A : Set ℓ) (B : Set ℓ') → Set (ℓ ⊔ ℓ') _∨_ = _⊎_ NO SEMANTIC DIFFERENCE - just different notation to help understanding code -} {- -------------------------------------------------- -- p 107-108 INSERTION -- this version keeps smaller (_<A_) elements closer to root when inserting -} -- type says given BT of size n, returns BT of size suc n bt-insert : ∀ {n : ℕ} → A → braun-tree n → braun-tree (suc n) -- insert into empty -- Create node with element and empty subtrees (both with size 0). -- 4th arg to BT constructor is BTP proof -- - both 0 so 'refl' -- - wrap in inj₁ to say 0 ≡ 0 (not n ≡ suc n) bt-insert a bt-empty = bt-node a bt-empty bt-empty (inj₁ refl) -- insert info non empty: tree has left and right satisfying BTP -- left of size n; right of size m -- p is BTP proof -- inferred type of return is BT (suc (suc (n + m))) -- because type before insert is BT (suc (n + m)) - left plus node element plus right -- insert adds ONE, so BT (suc (suc (m + n))) bt-insert a (bt-node{n}{m} a' l r p) -- regardless of what happens, left and right will be swapped, so size sum will have m first -- do rewrite before case splitting on which disjunct of BTP holds (n ≡ m or n ≡ suc m) -- does not change structure of tree -- will change what proof is used for BTP for new node returned. -- case split via WITH on P -- could split on p directly in pattern for input BT, -- but here rewrite is factored to be done once -- could do WITH on an if_then_else_ term, to put the min of element being inserted (a) -- and element at current root (a') as 1st component pair (a1), max as 2nd (a2) -- want min (a1) to be data at root of new BT -- want to insert max (a2) recursively into right rewrite +comm n m with p | if a <A a' then (a , a') else (a' , a) -- inj₁ case -- case where p is inj₁ for NEW new pattern variable 'p' -- underscore in place of original proof/p -- because considering case where original is 'inj₁ p' -- p : n ≡ m -- so new node -- with smaller element a1 at root and then swapped left and update right -- has type 'inj₂ refl' -- BTP for new node is suc m ≡ n v suc m ≡ suc n -- because size of new left is suc m, since it is the updated version of old right -- case has proof n ≡ m -- rewrite with that proof changes that to suc m ≡ suc n -- 'inj 2 refl' proves it bt-insert a (bt-node{n}{m} a' l r _) | inj₁ p | (a1 , a2) rewrite p = (bt-node a1 (bt-insert a2 r) l (inj₂ refl)) -- inj₂ case : n ≡ suc m -- so need proof suc m ≡ n v suc m ≡ suc n -- 'sym p' gives 'suc m ≡ n' -- wrap in 'inj₁' bt-insert a (bt-node{n}{m} a' l r _) | inj₂ p | (a1 , a2) = (bt-node a1 (bt-insert a2 r) l (inj₁ (sym p))) {- -------------------------------------------------- -- p 110 REMOVE MIN ELEMENT -} -- input has at least one element; returns pair of element and a BT one smaller bt-remove-min : ∀ {p : ℕ} → braun-tree (suc p) → A × braun-tree p -- no need for case of empty input -- because size would be 0, but input is 'suc p' -- removing sole node; return data and bt-empty bt-remove-min (bt-node a bt-empty bt-empty u) = a , bt-empty -- next two equations for left is empty and right subtree is a node -- IMPOSSIBLE by BTP -- still need to handle both proves with absurd bt-remove-min (bt-node a bt-empty (bt-node _ _ _ _) (inj₁ ())) bt-remove-min (bt-node a bt-empty (bt-node _ _ _ _) (inj₂ ())) -- right empty, left node (implies left size is 1, but not needed) -- return data left -- need to confirm size relationships satisfied, because -- size of input is suc (suc (n’ + m’) + 0) -- size of output is suc (n’ + m’) -- use +0 to drop the '+ 0' bt-remove-min (bt-node a (bt-node{n’}{m’} a’ l’ r’ u’) bt-empty u) rewrite +0 (n’ + m’) = a , bt-node a’ l’ r’ u’ -- left and right of input both nodes (not empty) -- return data input (the min data) -- reassemble output BT: remove min from left: bt-remove-min (bt-node a (bt-node a1 l1 r1 u1) (bt-node a2 l2 r2 u2) u) with bt-remove-min (bt-node a1 l1 r1 u1) -- then match on result of recursive call to bt-remove-min. -- produces min a1’ of left and updated left l’ -- then WITH to pick smaller of a1’ (minimum of left) and a2, minimum of right -- similar to the bt-insert with an if_then_else_ term. bt-remove-min (bt-node a (bt-node a1 l1 r1 u1) (bt-node a2 l2 r2 u2) u) | a1’ , l’ with if a1’ <A a2 then (a1’ , a2) else (a2 , a1’) -- p 113 first words TODO bt-remove-min (bt-node a (bt-node{n1}{m1} a1 l1 r1 u1) (bt-node{n2}{m2} _ l2 r2 u2) u) | _ , l’ | smaller , other rewrite +suc (n1 + m1) (n2 + m2) | +comm (n1 + m1) (n2 + m2) = a , bt-node smaller (bt-node other l2 r2 u2) l’ (lem u) where lem : ∀ {x y} → suc x ≡ y ∨ suc x ≡ suc y → y ≡ x ∨ y ≡ suc x lem (inj₁ p) = inj₂ (sym p) lem (inj₂ p) = inj₁ (sym (suc-inj p)) {- ------------------------------------------------------------------------------ -- p 114 Sigma Types Above expresses invariant properties of data using internally verified datatypes. Any data constructed via the constructors are guaranteed to satisfy the property, due to restrictions enforced by the constructors. Different case: state that a property holds of an existing data type. done using Σ-types (“sigma”) similar to Cartesian product type A × B (elements of A × B are pairs (a, b)) - but generalization where type of 2nd element can depend on type of 1st - aka "dependent product type" (though the notation comes from sum types, see below) see nat-nonzero.agda : type for nonzero natural numbers: -- a nat 'n' AND a proof 'iszero n ≡ ff' ℕ⁺ : Set ℕ⁺ = Σ ℕ (λ n → iszero n ≡ ff) conceptually similar to Cartesian product : N × (iszero n ≡ ff) - pair of number and equality proof - in Cartesian product version, 'n' is free - Σ-types enable referring to 1st of pair see product.agda : def of Σ parametrized by - type A - function B - input : type A - returns a type - types can be at different levels - Like sum types, Σ type is then at level ℓ ⊔ ℓ' (least upper bound of the two levels) data Σ {ℓ ℓ'} (A : Set ℓ) (B : A → Set ℓ') : Set (ℓ ⊔ ℓ') where _,_ : (a : A) → (b : B a) → Σ A B ^ B depends on ------------------------------------------------------------------------------ -- p 115 example: addition on nonzero nats -} open import nat-nonzero hiding (_+⁺_) _+⁺_ : ℕ⁺ → ℕ⁺ → ℕ⁺ (zero , ()) +⁺ n2 -- cannot happen, so uses absurd pattern (1 , p1) +⁺ y = suc⁺ y (suc (suc n1) , p1) +⁺ y = suc⁺ ((suc n1 , refl) +⁺ y) -- recursive call {- -- p 115 5.3.1 Why Sigma and Pi? why Σ symbol for type of dependent pairs? - because Σ-types generalize disjoint unions - in math, a disjoint union is union of two sets - where elements are tagged to indicate from which set they have come - cardinality of A ⊎ B, is sum of cardinalities of A and B even if they have a nonempty intersection. - This is where we get the notation for sum types in Figure 5.2. - The disjoint union can be defined mathematically as ({0} × A) ∪ ({1} × B) - each element of union looks like (n, x) where if the tag n is 0, then x P A, and if n is 1, then x P B. ------------------------------------------------------------------------------ -- p 116 Binary Search Trees for some type A and an ordering relation on that type values in left subtree always ≤ value at node ℕ values in right subtree always > value at node ℕ see z05-01-bst-test.agda z05-01-bst.agda -- p 117-120 TODO : read/understand discussion of bool-relations.agda relations.agda ------------------------------------------------------------------------------ -- p 123 Internal vs. External Verification internal verification : datatypes defined with invariants; functions take proofs of preconditions - Datatypes with essential invariants : enforce via internal - Complex programs - doing external of complex will cause reasoning about complexity not relevant to property being proved - internal weaves proofs thru code and datatype external verification : theorems about functions proved separately - Algebraic Properties e.g., proving associativity - Functions used in an internal verification's specification -- e.g., min/max used in bst - need to externally prove properties about min/max ------------------------------------------------------------------------------ -- p 126 Exercises 1. Nested vector type. Fill in the hole to define a type for matrices of nats where the type lists the dimensions of the matrix: -} -- inner vector is a row _by_matrix : ℕ → ℕ → Set rows by cols matrix = 𝕍 (𝕍 ℕ cols) rows matrix-to-vec-vec : ∀ {rows cols : ℕ} → rows by cols matrix → 𝕍 (𝕍 ℕ cols) rows matrix-to-vec-vec 𝕞 = 𝕞 -- 2a zero-matrix : (rows cols : ℕ) → rows by cols matrix zero-matrix rows cols = repeat𝕍 (repeat𝕍 0 cols) rows _ : zero-matrix 2 3 ≡ (0 :: 0 :: 0 :: []) :: (0 :: 0 :: 0 :: []) :: [] _ = refl _ : zero-matrix 0 0 ≡ [] _ = refl _ : zero-matrix 0 1 ≡ [] _ = refl _ : zero-matrix 1 0 ≡ [] :: [] _ = refl _ : zero-matrix 1 1 ≡ (0 :: []) :: [] _ = refl -- 2b matrix-elt : ∀ {rows cols : ℕ} → rows by cols matrix → (r : ℕ) → (c : ℕ) → r < rows ≡ tt → c < cols ≡ tt → ℕ matrix-elt 𝕞 r c r<rows c<cols = nth𝕍 c c<cols (nth𝕍 r r<rows (matrix-to-vec-vec 𝕞)) -- 2c diagonal-matrix : ℕ → (n : ℕ) → n by n matrix diagonal-matrix d n = mkRows n n n where -- when constructing rows/cols -- - row/col param corresponds to row/col - rows/cols -- - e.g., for 2 x 3 matrix -- row param 2 corresponds 2 - 2 = 0 mkElt : ℕ → ℕ → ℕ mkElt i col = if i =ℕ col then d else zero mkCols : (ℕ → ℕ) → (cols : ℕ) → 𝕍 ℕ cols mkCols _ zero = [] mkCols f sc@(suc c) = f sc :: mkCols f c mkRows : ℕ → (rows : ℕ) → (cols : ℕ) → 𝕍 (𝕍 ℕ cols) rows mkRows _ zero _ = [] mkRows i (suc r) c = mkCols (mkElt i) c :: mkRows (i ∸ 1) r c identity-matrix : (n : ℕ) → n by n matrix identity-matrix = diagonal-matrix 1 idm5 : 5 by 5 matrix idm5 = identity-matrix 5 _ : idm5 ≡ (1 :: 0 :: 0 :: 0 :: 0 :: []) :: (0 :: 1 :: 0 :: 0 :: 0 :: []) :: (0 :: 0 :: 1 :: 0 :: 0 :: []) :: (0 :: 0 :: 0 :: 1 :: 0 :: []) :: (0 :: 0 :: 0 :: 0 :: 1 :: []) :: [] _ = refl _ : matrix-elt idm5 0 0 refl refl ≡ 1 _ = refl _ : matrix-elt idm5 1 1 refl refl ≡ 1 _ = refl _ : matrix-elt idm5 0 1 refl refl ≡ 0 _ = refl -- 2d -- BEGIN https://typeslogicscats.gitlab.io/posts/agda-matrix.lagda.html prepend-column : ∀ {m n : ℕ} → 𝕍 ℕ n -- a column → n by m matrix → n by suc m matrix -- prepends the given column to the matrix prepend-column [] [] = [] prepend-column (x :: xs) (vec :: vecs) = (x :: vec) :: (prepend-column xs vecs) -- inverse of prepend-column (NOT USED) unprepend-column : ∀ {m n : ℕ} → n by suc m matrix → (𝕍 ℕ n) × (n by m matrix) unprepend-column [] = ([] , []) unprepend-column ((x :: vec) :: matrix) = let xs-vecs = unprepend-column matrix in x :: fst xs-vecs , vec :: snd xs-vecs fill-empty : (n : ℕ) → n by 0 matrix fill-empty 0 = [] fill-empty (suc n) = [] :: fill-empty n transpose : ∀ {i : ℕ} {j : ℕ} → i by j matrix → j by i matrix transpose {0} {j} [] = fill-empty j transpose {suc _} {_} (row :: rows) = prepend-column row (transpose rows) -- END https://typeslogicscats.gitlab.io/posts/agda-matrix.lagda.html ex2x3 : 2 by 3 matrix ex2x3 = (1 :: 2 :: 3 :: []) :: (0 :: 6 :: 7 :: []) :: [] _ : transpose ex2x3 ≡ (1 :: 0 :: []) :: (2 :: 6 :: []) :: (3 :: 7 :: []) :: [] _ = refl -- BEGIN https://www.cs.nott.ac.uk/~psztxa/g53cfr/solutions/ex02.agda vreturn : {A : Set} {n : ℕ} → A → 𝕍 A n vreturn {n = zero} a = [] vreturn {n = suc m} a = a :: vreturn {n = m} a vapp : {A B : Set} {n : ℕ} → 𝕍 (A → B) n → 𝕍 A n → 𝕍 B n vapp [] [] = [] vapp (f :: fs) (a :: as) = f a :: vapp fs as transposeX : {m n : ℕ} → m by n matrix → n by m matrix transposeX [] = vreturn [] transposeX (as :: ass) = vapp (vapp (vreturn _::_ ) as) (transposeX ass) _ : transposeX ex2x3 ≡ (1 :: 0 :: []) :: (2 :: 6 :: []) :: (3 :: 7 :: []) :: [] _ = refl -- END https://www.cs.nott.ac.uk/~psztxa/g53cfr/solutions/ex02.agda -- BEGIN HORRIBLE HACKY TRY postulate yyy : (n : ℕ) → (rc : ℕ) → rc < n ≡ tt xx : ∀ {x y : ℕ} → x =ℕ 0 ≡ ff → y =ℕ 0 ≡ ff → x ∸ y < x ≡ tt xx {x} {suc y} x≠0 y≠0 rewrite ∸< {x} {y} x≠0 = refl transpose' : ∀ {n m : ℕ} → n by m matrix → m by n matrix transpose' {0} {m} _ = zero-matrix m 0 transpose' {1} {m} _ = zero-matrix m 1 transpose' n@{suc (suc _)} {zero} 𝕞 = zero-matrix zero n transpose' n@{suc (suc _)} m@{suc _} 𝕞 = mkRows m n where mkElt : (newRow : ℕ) → newRow =ℕ 0 ≡ ff → (newCol : ℕ) → newCol =ℕ 0 ≡ ff → ℕ mkElt newRow rp newCol cp = matrix-elt 𝕞 (n ∸ newCol) (m ∸ newRow) -- (xx cp refl) (xx rp refl) -- (yyy (n ∸ newCol) n) (yyy (m ∸ newRow) m) {!!} {!!} mkCols : (∀ (new : ℕ) → new =ℕ 0 ≡ ff → ℕ) → (cols : ℕ) → 𝕍 ℕ cols mkCols _ zero = [] mkCols f sc@(suc c) = f sc refl :: mkCols f c mkRows : (rows : ℕ) → (cols : ℕ) → 𝕍 (𝕍 ℕ cols) rows mkRows zero _ = [] mkRows sr@(suc r) c = mkCols (mkElt sr refl) c :: mkRows r c _ : transpose' ex2x3 ≡ (1 :: 0 :: []) :: (2 :: 6 :: []) :: (3 :: 7 :: []) :: [] _ = refl -- END HORRIBLE HACKY TRY -- 2e dotProduct𝕍 : ∀ {n : ℕ} → 𝕍 ℕ n → 𝕍 ℕ n → ℕ dotProduct𝕍 [] [] = 0 dotProduct𝕍 (a :: as) (b :: bs) = a * b + (dotProduct𝕍 as bs) _ : dotProduct𝕍 (1 :: 3 :: 5 :: []) (4 :: 2 :: 1 :: []) ≡ 15 _ = refl foldr : ∀ {A B : Set} {n : ℕ} → (A → B → B) → B → 𝕍 A n → B foldr f z [] = z foldr f z (x :: xs) = f x (foldr f z xs) zipWith : ∀ {A B C : Set} {n : ℕ} → (A → B → C) → 𝕍 A n → 𝕍 B n → 𝕍 C n zipWith _ [] [] = [] zipWith f (x :: xs) (y :: ys) = f x y :: zipWith f xs ys dotProduct𝕍' : ∀ {n : ℕ} → 𝕍 ℕ n → 𝕍 ℕ n → ℕ dotProduct𝕍' as bs = foldr _+_ 0 (zipWith _*_ as bs) _ : dotProduct𝕍' (1 :: 3 :: 5 :: []) (4 :: 2 :: 1 :: []) ≡ 15 _ = refl -- 2f matrix-* : ∀ {m n p : ℕ} → m by n matrix → n by p matrix → m by p matrix matrix-* [] _ = [] matrix-* {m} {n} {p} (a :: as) bs = doRow {n} {p} a (transpose bs) :: matrix-* as bs where doRow : ∀ {n p : ℕ} → 𝕍 ℕ n → p by n matrix → 𝕍 ℕ p doRow a [] = [] doRow {n} {p} a (b :: bs) = dotProduct𝕍 a b :: doRow a bs ma : 2 by 3 matrix ma = (2 :: 3 :: 4 :: []) :: (1 :: 0 :: 0 :: []) :: [] mb : 3 by 2 matrix mb = (0 :: 1000 :: []) :: (1 :: 100 :: []) :: (0 :: 10 :: []) :: [] _ : matrix-* ma mb ≡ (3 :: 2340 :: []) :: (0 :: 1000 :: []) :: [] _ = refl identity-2 : 2 by 2 matrix identity-2 = identity-matrix 2 some-mat : 2 by 2 matrix some-mat = (1 :: 2 :: []) :: (3 :: 4 :: []) :: [] some-mat-trans : 2 by 2 matrix some-mat-trans = (1 :: 3 :: []) :: (2 :: 4 :: []) :: [] _ : matrix-* some-mat identity-2 ≡ some-mat _ = refl _ : transpose some-mat ≡ some-mat-trans _ = refl left-mat : 2 by 3 matrix left-mat = (1 :: 2 :: 3 :: []) :: (4 :: 5 :: 6 :: []) :: [] right-mat : 3 by 2 matrix right-mat = ( 7 :: 8 :: []) :: ( 9 :: 10 :: []) :: (11 :: 12 :: []) :: [] product : 2 by 2 matrix product = ( 58 :: 64 :: []) :: (139 :: 154 :: []) :: [] _ : matrix-* left-mat right-mat ≡ product _ = refl -- TODO https://www.cs.nott.ac.uk/~psztxa/g53cfr/solutions/ex02.agda -- 3 -- from list.agda data 𝕃 {ℓ} (A : Set ℓ) : Set ℓ where [] : 𝕃 A _::_ : (x : A) (xs : 𝕃 A) → 𝕃 A -- from vector.agda 𝕍-to-𝕃 : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → 𝕍 A n → 𝕃 A 𝕍-to-𝕃 [] = [] 𝕍-to-𝕃 (x :: xs) = x :: (𝕍-to-𝕃 xs) 𝕃-to-𝕍 : ∀ {ℓ} {A : Set ℓ} → 𝕃 A → Σ ℕ (λ n → 𝕍 A n) 𝕃-to-𝕍 [] = (0 , []) 𝕃-to-𝕍 (x :: xs) with 𝕃-to-𝕍 xs ... | (n , v) = (suc n , x :: v) e3 : ∀ {ℓ} {A : Set ℓ} {n : ℕ} → (v : 𝕍 A n) → 𝕃-to-𝕍 (𝕍-to-𝕃 v) ≡ n , v e3 [] = refl e3 (x :: v) with e3 v ... | zz rewrite zz = refl -- 4. fun takes V (A × B) n ; returns pair V A n and V B n -- similar to Haskell unzip unzip : ∀ {ℓ} {A B : Set ℓ} {n : ℕ} → 𝕍 (A × B) n → 𝕍 A n × 𝕍 B n unzip [] = [] , [] unzip ((a , b) :: v) = let rest = unzip v in a :: fst rest , b :: snd rest _ : unzip ((1 , 10) :: (2 , 20) :: (3 , 30) :: []) ≡ ( 1 :: 2 :: 3 :: []) , (10 :: 20 :: 30 :: []) _ = refl {- TODO -- 5. Implement remove-min / remove-max functions for bst. type. Using remove-min, define a general remove function - finds first value isomorphic to given one - returns bst without that value. If node holding that value has two (non-leaf) nodes as left and right sub-trees, then necessary to replace the removed element with its successor. This is the minimum value in the right subtree. -- 6. In list-merge-sort.agda : merge-sort using Braun trees. State and prove theorems about merge-sort. E.g., prove length of input list and length of returned sorted list are the same. -}
{ "alphanum_fraction": 0.5512166494, "avg_line_length": 31.7804878049, "ext": "agda", "hexsha": "bea1bfeb48922acafc7cb610fbc000f1851eb909", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-00-internal-verification.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-00-internal-verification.agda", "max_line_length": 97, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-00-internal-verification.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": 7721, "size": 22151 }
{-# OPTIONS --erased-cubical #-} -- Modules that use --cubical can be imported when --erased-cubical is -- used. open import Erased-cubical-Open-public.Cubical -- However, re-exports from such modules, made using module -- application, can only be used in erased contexts. _ : Set _ = A
{ "alphanum_fraction": 0.7182130584, "avg_line_length": 22.3846153846, "ext": "agda", "hexsha": "a3fb1b38e370484ab6215c5fc5a4e93f2b96c640", "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": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/Erased-cubical-Open-public.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "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-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/Erased-cubical-Open-public.agda", "max_line_length": 70, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/Erased-cubical-Open-public.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": 79, "size": 291 }
{-# OPTIONS --without-K --safe #-} open import Level -- ⊥ is Initial module Categories.Category.Instance.Zero where open import Data.Empty using (⊥; ⊥-elim) open import Function renaming (id to idf) open import Categories.Category open import Categories.Functor open import Categories.Category.Instance.Cats import Categories.Object.Initial as Init -- Unlike for ⊤ being Terminal, Agda can't deduce these, need to be explicit module _ {o ℓ e : Level} where open Init (Cats o ℓ e) Zero : Category o ℓ e Zero = record { Obj = Lift o ⊥ ; _⇒_ = λ _ _ → Lift ℓ ⊥ ; _≈_ = λ _ _ → Lift e ⊥ ; id = λ { { lift () } } ; _∘_ = λ a _ → a -- left-biased rather than strict ; assoc = λ { {lift () } } ; sym-assoc = λ { {lift () } } ; identityˡ = λ { {()} } ; identityʳ = λ { {()} } ; identity² = λ { {()} } ; ∘-resp-≈ = λ { () } ; equiv = record { refl = λ { {()} } ; sym = idf ; trans = λ a _ → a } } Zero-⊥ : Initial Zero-⊥ = record { ⊥ = Zero ; ! = record { F₀ = λ { (lift x) → ⊥-elim x } ; F₁ = λ { (lift ()) } ; identity = λ { {lift ()} } ; homomorphism = λ { {lift ()} } ; F-resp-≈ = λ { () } } ; !-unique = λ f → record { F⇒G = record { η = λ { () } ; commute = λ { () } ; sym-commute = λ { () } } ; F⇐G = record { η = λ { () } ; commute = λ { () } ; sym-commute = λ { () } } ; iso = λ { (lift ()) } } }
{ "alphanum_fraction": 0.4744525547, "avg_line_length": 26.4385964912, "ext": "agda", "hexsha": "4d08af6fce367c02c9be2b5e4f00810d9fcad85d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/Zero.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/Zero.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/Zero.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 516, "size": 1507 }
module Issue113 where module X where postulate D : Set open X public postulate x : D -- Should give the proper error message, not __IMPOSSIBLE__ from Highlight.Generate typeIncorrect : Set typeIncorrect = Set1
{ "alphanum_fraction": 0.7706422018, "avg_line_length": 14.5333333333, "ext": "agda", "hexsha": "e817138969df6fb56d0741727420a77b9f8789ec", "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/Issue113.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/Issue113.agda", "max_line_length": 83, "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/Issue113.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": 57, "size": 218 }
{-# OPTIONS --without-K --safe #-} module Data.Binary.Relations.Raw where -- This module defines the "raw" relations on the binary types. In other words, -- these relations are all functions which return either ⊤ or ⊥. -- -- Each relation is generic of its strictness: if its first argument is O, it's a -- strict relation (_<_); otherwise it's non-strict (_≤_). open import Data.Binary.Bits open import Data.Binary.Definitions open import Data.Unit using (⊤; tt) open import Data.Empty using (⊥; ⊥-elim) open import Relation.Nullary open import Data.Bool.Properties using (T?) open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Binary.Operations.Unary open import Data.Binary.Operations.Addition ------------------------------------------------------------------------ -- Definition of relations infix 4 ⟅_⟆_≺ᵇ_ ⟅_⟆_≺⁺_ ⟅_⟆_≺_ ⟅_⟆_≺ᵇ_ : Bit → Bit → Bit → Bit ⟅ p ⟆ I ≺ᵇ q = q ∧ p ⟅ p ⟆ O ≺ᵇ q = p ∨ q ⟅_⟆_≺⁺_ : Bit → 𝔹⁺ → 𝔹⁺ → Set ⟅ p ⟆ 1ᵇ ≺⁺ (y ∷ ys) = ⊤ ⟅ p ⟆ 1ᵇ ≺⁺ 1ᵇ = T p ⟅ p ⟆ (x ∷ xs) ≺⁺ 1ᵇ = ⊥ ⟅ p ⟆ (x ∷ xs) ≺⁺ (y ∷ ys) = ⟅ ⟅ p ⟆ x ≺ᵇ y ⟆ xs ≺⁺ ys ⟅_⟆_≺_ : Bit → 𝔹 → 𝔹 → Set ⟅ p ⟆ 0ᵇ ≺ 0ᵇ = T p ⟅ p ⟆ 0ᵇ ≺ (0< _) = ⊤ ⟅ p ⟆ 0< xs ≺ 0ᵇ = ⊥ ⟅ p ⟆ 0< xs ≺ 0< ys = ⟅ p ⟆ xs ≺⁺ ys ------------------------------------------------------------------------ -- Properties weaken⁺ : ∀ x xs ys → ⟅ x ⟆ xs ≺⁺ ys → ⟅ I ⟆ xs ≺⁺ ys weaken⁺ x (O ∷ xs) 1ᵇ xs<ys = xs<ys weaken⁺ x (O ∷ xs) (y ∷ ys) xs<ys = weaken⁺ (x ∨ y) xs ys xs<ys weaken⁺ x (I ∷ xs) 1ᵇ xs<ys = xs<ys weaken⁺ x (I ∷ xs) (O ∷ ys) xs<ys = xs<ys weaken⁺ x (I ∷ xs) (I ∷ ys) xs<ys = weaken⁺ x xs ys xs<ys weaken⁺ O 1ᵇ 1ᵇ xs<ys = tt weaken⁺ O 1ᵇ (x ∷ xs) xs<ys = tt weaken⁺ I 1ᵇ ys xs<ys = xs<ys weaken : ∀ xs ys → ⟅ O ⟆ xs ≺ ys → ⟅ I ⟆ xs ≺ ys weaken (0< xs) (0< ys) xs<ys = weaken⁺ O xs ys xs<ys weaken (0< x) 0ᵇ xs<ys = xs<ys weaken 0ᵇ (0< x) xs<ys = tt weaken 0ᵇ 0ᵇ xs<ys = tt ≺⁺-trans : ∀ x y xs ys zs → ⟅ x ⟆ xs ≺⁺ ys → ⟅ y ⟆ ys ≺⁺ zs → ⟅ x ∧ y ⟆ xs ≺⁺ zs ≺⁺-trans c₁ c₂ 1ᵇ ys (x ∷ zs) xs<ys ys<zs = tt ≺⁺-trans c₁ c₂ (x ∷ xs) 1ᵇ 1ᵇ xs<ys ys<zs = xs<ys ≺⁺-trans c₁ c₂ (x ∷ xs) 1ᵇ (z ∷ zs) () ys<zs ≺⁺-trans c₁ c₂ (x ∷ xs) (y ∷ ys) 1ᵇ xs<ys ys<zs = ys<zs ≺⁺-trans O O 1ᵇ 1ᵇ 1ᵇ xs<ys ys<zs = ys<zs ≺⁺-trans O O 1ᵇ (x ∷ xs) 1ᵇ xs<ys ys<zs = ys<zs ≺⁺-trans O I 1ᵇ 1ᵇ 1ᵇ xs<ys ys<zs = xs<ys ≺⁺-trans O I 1ᵇ (x ∷ xs) 1ᵇ xs<ys ys<zs = ys<zs ≺⁺-trans I O 1ᵇ 1ᵇ 1ᵇ xs<ys ys<zs = ys<zs ≺⁺-trans I O 1ᵇ (x ∷ xs) 1ᵇ xs<ys ys<zs = ys<zs ≺⁺-trans I I 1ᵇ ys 1ᵇ xs<ys ys<zs = tt ≺⁺-trans I c₂ (I ∷ xs) (O ∷ ys) (O ∷ zs) xs<ys ys<zs = ≺⁺-trans O (c₂ ∨ O) xs ys zs xs<ys ys<zs ≺⁺-trans I c₂ (I ∷ xs) (I ∷ ys) (O ∷ zs) xs<ys ys<zs = ≺⁺-trans I O xs ys zs xs<ys ys<zs ≺⁺-trans O c₂ (I ∷ xs) (O ∷ ys) (I ∷ zs) xs<ys ys<zs = ≺⁺-trans O (c₂ ∨ I) xs ys zs xs<ys ys<zs ≺⁺-trans O c₂ (I ∷ xs) (I ∷ ys) (I ∷ zs) xs<ys ys<zs = ≺⁺-trans O c₂ xs ys zs xs<ys ys<zs ≺⁺-trans O c₂ (I ∷ xs) (O ∷ ys) (O ∷ zs) xs<ys ys<zs = ≺⁺-trans O (c₂ ∨ O) xs ys zs xs<ys ys<zs ≺⁺-trans O c₂ (I ∷ xs) (I ∷ ys) (O ∷ zs) xs<ys ys<zs = ≺⁺-trans O O xs ys zs xs<ys ys<zs ≺⁺-trans O c₂ (O ∷ xs) (y ∷ ys) (I ∷ zs) xs<ys ys<zs = weaken⁺ (y ∧ (⟅ c₂ ⟆ y ≺ᵇ I)) xs zs (≺⁺-trans y (⟅ c₂ ⟆ y ≺ᵇ I) xs ys zs xs<ys ys<zs) ≺⁺-trans O c₂ (O ∷ xs) (O ∷ ys) (O ∷ zs) xs<ys ys<zs = ≺⁺-trans O (c₂ ∨ O) xs ys zs xs<ys ys<zs ≺⁺-trans O c₂ (O ∷ xs) (I ∷ ys) (O ∷ zs) xs<ys ys<zs = ≺⁺-trans I O xs ys zs xs<ys ys<zs ≺⁺-trans I O (I ∷ xs) (O ∷ ys) (I ∷ zs) xs<ys ys<zs = ≺⁺-trans O I xs ys zs xs<ys ys<zs ≺⁺-trans I O (I ∷ xs) (I ∷ ys) (I ∷ zs) xs<ys ys<zs = ≺⁺-trans I O xs ys zs xs<ys ys<zs ≺⁺-trans I O (O ∷ xs) (y ∷ ys) (I ∷ zs) xs<ys ys<zs = weaken⁺ (⟅ O ⟆ y ≺ᵇ I) xs zs (≺⁺-trans I (⟅ O ⟆ y ≺ᵇ I) xs ys zs xs<ys ys<zs) ≺⁺-trans I O (O ∷ xs) (O ∷ ys) (O ∷ zs) xs<ys ys<zs = ≺⁺-trans I O xs ys zs xs<ys ys<zs ≺⁺-trans I O (O ∷ xs) (I ∷ ys) (O ∷ zs) xs<ys ys<zs = ≺⁺-trans I O xs ys zs xs<ys ys<zs ≺⁺-trans I I (I ∷ xs) (O ∷ ys) (I ∷ zs) xs<ys ys<zs = weaken⁺ O xs zs (≺⁺-trans (O ∧ I) (⟅ I ⟆ O ≺ᵇ I) xs ys zs xs<ys ys<zs) ≺⁺-trans I I (I ∷ xs) (I ∷ ys) (I ∷ zs) xs<ys ys<zs = ≺⁺-trans (I ∧ I) (⟅ I ⟆ I ≺ᵇ I) xs ys zs xs<ys ys<zs ≺⁺-trans I I (O ∷ xs) (y ∷ ys) (z ∷ zs) xs<ys ys<zs = weaken⁺ (⟅ I ⟆ y ≺ᵇ z) xs zs (≺⁺-trans I (⟅ I ⟆ y ≺ᵇ z) xs ys zs xs<ys ys<zs) ≺-trans : ∀ x y xs ys zs → ⟅ x ⟆ xs ≺ ys → ⟅ y ⟆ ys ≺ zs → ⟅ x ∧ y ⟆ xs ≺ zs ≺-trans x y (0< x₁) (0< x₃) (0< x₂) xs<ys ys<zs = ≺⁺-trans x y x₁ x₃ x₂ xs<ys ys<zs ≺-trans x y (0< x₁) 0ᵇ (0< x₂) () ys<zs ≺-trans x y (0< x₁) (0< x₂) 0ᵇ xs<ys ys<zs = ys<zs ≺-trans x y (0< x₁) 0ᵇ 0ᵇ xs<ys ys<zs = xs<ys ≺-trans x y 0ᵇ ys (0< x₁) xs<ys ys<zs = tt ≺-trans x y 0ᵇ (0< x₁) 0ᵇ tt () ≺-trans O O 0ᵇ 0ᵇ 0ᵇ xs<ys ys<zs = ys<zs ≺-trans O I 0ᵇ 0ᵇ 0ᵇ xs<ys ys<zs = xs<ys ≺-trans I O 0ᵇ 0ᵇ 0ᵇ xs<ys ys<zs = ys<zs ≺-trans I I 0ᵇ 0ᵇ 0ᵇ xs<ys ys<zs = tt asym-≺⁺ : ∀ c xs ys → ⟅ c ⟆ ys ≺⁺ xs → ¬ ⟅ not c ⟆ xs ≺⁺ ys asym-≺⁺ O 1ᵇ 1ᵇ ys<xs xs<ys = ys<xs asym-≺⁺ O 1ᵇ (x ∷ xs) ys<xs xs<ys = ys<xs asym-≺⁺ O (O ∷ xs) 1ᵇ ys<xs xs<ys = xs<ys asym-≺⁺ O (O ∷ xs) (O ∷ ys) ys<xs xs<ys = asym-≺⁺ I ys xs xs<ys ys<xs asym-≺⁺ O (O ∷ xs) (I ∷ ys) ys<xs xs<ys = asym-≺⁺ I ys xs xs<ys ys<xs asym-≺⁺ O (I ∷ xs) 1ᵇ ys<xs xs<ys = xs<ys asym-≺⁺ O (I ∷ xs) (O ∷ ys) ys<xs xs<ys = asym-≺⁺ O ys xs xs<ys ys<xs asym-≺⁺ O (I ∷ xs) (I ∷ ys) ys<xs xs<ys = asym-≺⁺ I ys xs xs<ys ys<xs asym-≺⁺ I 1ᵇ 1ᵇ ys<xs xs<ys = xs<ys asym-≺⁺ I 1ᵇ (x ∷ xs) ys<xs xs<ys = ys<xs asym-≺⁺ I (O ∷ xs) 1ᵇ ys<xs xs<ys = xs<ys asym-≺⁺ I (O ∷ xs) (O ∷ ys) ys<xs xs<ys = asym-≺⁺ O ys xs xs<ys ys<xs asym-≺⁺ I (O ∷ xs) (I ∷ ys) ys<xs xs<ys = asym-≺⁺ I ys xs xs<ys ys<xs asym-≺⁺ I (I ∷ xs) 1ᵇ ys<xs xs<ys = xs<ys asym-≺⁺ I (I ∷ xs) (O ∷ ys) ys<xs xs<ys = asym-≺⁺ O ys xs xs<ys ys<xs asym-≺⁺ I (I ∷ xs) (I ∷ ys) ys<xs xs<ys = asym-≺⁺ O ys xs xs<ys ys<xs asym-≺ : ∀ c xs ys → ⟅ c ⟆ ys ≺ xs → ¬ ⟅ not c ⟆ xs ≺ ys asym-≺ c (0< xs) (0< ys) ys<xs xs<ys = asym-≺⁺ c xs ys ys<xs xs<ys asym-≺ c (0< x) 0ᵇ ys<xs xs<ys = xs<ys asym-≺ c 0ᵇ (0< x) ys<xs xs<ys = ys<xs asym-≺ c 0ᵇ 0ᵇ ys<xs xs<ys = asym-≺⁺ c 1ᵇ 1ᵇ ys<xs xs<ys pos-asym-≺⁺ : ∀ c xs ys → ¬ ⟅ c ⟆ ys ≺⁺ xs → ⟅ not c ⟆ xs ≺⁺ ys pos-asym-≺⁺ c 1ᵇ (x ∷ ys) ys≺xs = tt pos-asym-≺⁺ c (x ∷ xs) 1ᵇ ys≺xs = ys≺xs tt pos-asym-≺⁺ c (I ∷ xs) (I ∷ ys) ys≺xs = pos-asym-≺⁺ c xs ys ys≺xs pos-asym-≺⁺ O (O ∷ xs) (O ∷ ys) ys≺xs = pos-asym-≺⁺ O xs ys ys≺xs pos-asym-≺⁺ I (O ∷ xs) (O ∷ ys) ys≺xs = pos-asym-≺⁺ I xs ys ys≺xs pos-asym-≺⁺ O (O ∷ xs) (I ∷ ys) ys≺xs = pos-asym-≺⁺ O xs ys ys≺xs pos-asym-≺⁺ I (O ∷ xs) (I ∷ ys) ys≺xs = pos-asym-≺⁺ O xs ys ys≺xs pos-asym-≺⁺ O (I ∷ xs) (O ∷ ys) ys≺xs = pos-asym-≺⁺ I xs ys ys≺xs pos-asym-≺⁺ I (I ∷ xs) (O ∷ ys) ys≺xs = pos-asym-≺⁺ I xs ys ys≺xs pos-asym-≺⁺ O 1ᵇ 1ᵇ ys≺xs = tt pos-asym-≺⁺ I 1ᵇ 1ᵇ ys≺xs = ys≺xs tt pos-asym-≺ : ∀ c xs ys → ¬ ⟅ c ⟆ ys ≺ xs → ⟅ not c ⟆ xs ≺ ys pos-asym-≺ c (0< xs) (0< ys) ys≮xs = pos-asym-≺⁺ c xs ys ys≮xs pos-asym-≺ c (0< x) 0ᵇ ys≮xs = ys≮xs tt pos-asym-≺ c 0ᵇ (0< x) ys≮xs = tt pos-asym-≺ O 0ᵇ 0ᵇ ys≮xs = tt pos-asym-≺ I 0ᵇ 0ᵇ ys≮xs = ys≮xs tt ≺⁺-antisym : ∀ c → Antisymmetric _≡_ ⟅ c ⟆_≺⁺_ ≺⁺-antisym c {1ᵇ} {1ᵇ} xs<ys ys<xs = refl ≺⁺-antisym c {1ᵇ} {x ∷ ys} xs<ys () ≺⁺-antisym c {x ∷ xs} {1ᵇ} () ys<xs ≺⁺-antisym c {O ∷ xs} {O ∷ ys} xs<ys ys<xs = cong (O ∷_) (≺⁺-antisym (c ∨ O) xs<ys ys<xs) ≺⁺-antisym c {O ∷ xs} {I ∷ ys} xs<ys ys<xs = ⊥-elim (asym-≺⁺ O xs ys ys<xs (weaken⁺ (c ∨ I) xs ys xs<ys)) ≺⁺-antisym c {I ∷ xs} {O ∷ ys} xs<ys ys<xs = ⊥-elim (asym-≺⁺ O ys xs xs<ys (weaken⁺ (c ∨ I) ys xs ys<xs)) ≺⁺-antisym c {I ∷ xs} {I ∷ ys} xs<ys ys<xs = cong (I ∷_) (≺⁺-antisym c xs<ys ys<xs) ≺-antisym : ∀ c → Antisymmetric _≡_ ⟅ c ⟆_≺_ ≺-antisym c {0< x} {0< x₁} xs<ys ys<xs = cong 0<_ (≺⁺-antisym c xs<ys ys<xs) ≺-antisym c {0< x} {0ᵇ} () ys<xs ≺-antisym c {0ᵇ} {0< x} xs<ys () ≺-antisym c {0ᵇ} {0ᵇ} xs<ys ys<xs = refl ≼-refl : ∀ xs → ⟅ I ⟆ xs ≺⁺ xs ≼-refl 1ᵇ = tt ≼-refl (O ∷ xs) = ≼-refl xs ≼-refl (I ∷ xs) = ≼-refl xs ≺⁺-inc⁺⁺ : ∀ x xs → ⟅ x ⟆ xs ≺⁺ inc⁺⁺ xs ≺⁺-inc⁺⁺ _ 1ᵇ = tt ≺⁺-inc⁺⁺ c (I ∷ xs) = ≺⁺-inc⁺⁺ O xs ≺⁺-inc⁺⁺ O (O ∷ xs) = ≼-refl xs ≺⁺-inc⁺⁺ I (O ∷ xs) = ≼-refl xs ≺⁺-add : ∀ ys xs c₁ c₂ → ⟅ c₁ ⟆ xs ≺⁺ add c₂ ys xs ≺⁺-add 1ᵇ 1ᵇ c₁ O = tt ≺⁺-add 1ᵇ 1ᵇ c₁ I = tt ≺⁺-add 1ᵇ (x ∷ xs) c₁ O = ≺⁺-inc⁺⁺ c₁ (x ∷ xs) ≺⁺-add 1ᵇ (x ∷ xs) c₁ I = ≺⁺-inc⁺⁺ (⟅ c₁ ⟆ x ≺ᵇ x) xs ≺⁺-add (y ∷ ys) (x ∷ xs) c₁ c₂ = ≺⁺-add ys xs (⟅ c₁ ⟆ x ≺ᵇ sumᵇ c₂ y x) (carryᵇ c₂ y x) ≺⁺-add (y ∷ ys) 1ᵇ c₁ I = tt ≺⁺-add (O ∷ ys) 1ᵇ c₁ O = tt ≺⁺-add (I ∷ ys) 1ᵇ c₁ O = tt ≺-add : ∀ ys xs → ⟅ I ⟆ xs ≺ ys + xs ≺-add (0< x) (0< x₁) = ≺⁺-add x x₁ I O ≺-add (0< x) 0ᵇ = tt ≺-add 0ᵇ (0< x) = ≼-refl x ≺-add 0ᵇ 0ᵇ = tt ------------------------------------------------------------------------ -- Decidability infix 4 _!_≺⁺?_ _!_≺?_ _!_≺⁺?_ : ∀ x xs ys → Dec (⟅ x ⟆ xs ≺⁺ ys) c ! 1ᵇ ≺⁺? x ∷ xs = yes tt c ! 1ᵇ ≺⁺? 1ᵇ = T? c c ! x ∷ xs ≺⁺? 1ᵇ = no (λ z → z) c ! x ∷ xs ≺⁺? y ∷ ys = (⟅ c ⟆ x ≺ᵇ y) ! xs ≺⁺? ys _!_≺?_ : ∀ x xs ys → Dec (⟅ x ⟆ xs ≺ ys) c ! 0< xs ≺? 0< ys = c ! xs ≺⁺? ys c ! 0< xs ≺? 0ᵇ = no (λ z → z) c ! 0ᵇ ≺? 0< _ = yes tt c ! 0ᵇ ≺? 0ᵇ = T? c compare-≺ : ∀ c → Conn ⟅ c ⟆_≺_ ⟅ not c ⟆_≺_ compare-≺ c xs ys with c ! xs ≺? ys compare-≺ c xs ys | yes p = inj₁ p compare-≺ c xs ys | no ¬p = inj₂ (pos-asym-≺ c ys xs ¬p)
{ "alphanum_fraction": 0.5035080026, "avg_line_length": 43.2322274882, "ext": "agda", "hexsha": "37c9fb6e11b45c1be736ac036947018df85c1dc1", "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": "92af4d620febd47a9791d466d747278dc4a417aa", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-binary", "max_forks_repo_path": "Data/Binary/Relations/Raw.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "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-binary", "max_issues_repo_path": "Data/Binary/Relations/Raw.agda", "max_line_length": 140, "max_stars_count": 1, "max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-binary", "max_stars_repo_path": "Data/Binary/Relations/Raw.agda", "max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z", "num_tokens": 5592, "size": 9122 }
{-# OPTIONS --rewriting #-} module Properties.Step where open import Agda.Builtin.Equality using (_≡_; refl) open import Agda.Builtin.Float using (primFloatPlus; primFloatMinus; primFloatTimes; primFloatDiv; primFloatEquality; primFloatLess) open import Agda.Builtin.Bool using (true; false) open import Agda.Builtin.String using (primStringAppend) open import FFI.Data.Maybe using (just; nothing) open import Luau.Heap using (Heap; _[_]; alloc; ok; function_is_end) open import Luau.Syntax using (Block; Expr; nil; var; val; addr; bool; function_is_end; block_is_end; _$_; local_←_; return; done; _∙_; name; fun; arg; number; binexp; +; -; *; /; <; >; <=; >=; ==; ~=; ··; string) open import Luau.OpSem using (_⟦_⟧_⟶_; _⊢_⟶ᴱ_⊣_; _⊢_⟶ᴮ_⊣_; app₁ ; app₂ ; beta; function; block; return; done; local; subst; binOp₀; binOp₁; binOp₂; +; -; *; /; <; >; <=; >=; ==; ~=; ··; evalEqOp; evalNeqOp) open import Luau.RuntimeError using (BinOpError; RuntimeErrorᴱ; RuntimeErrorᴮ; FunctionMismatch; BinOpMismatch₁; BinOpMismatch₂; UnboundVariable; SEGV; app₁; app₂; block; local; return; bin₁; bin₂; +; -; *; /; <; >; <=; >=; ··) open import Luau.RuntimeType using (valueType; function; number) open import Luau.Substitution using (_[_/_]ᴮ) open import Properties.Remember using (remember; _,_) open import Utility.Bool using (not; _or_) data BinOpStepResult v op w : Set where step : ∀ x → (v ⟦ op ⟧ w ⟶ x) → BinOpStepResult v op w error₁ : BinOpError op (valueType(v)) → BinOpStepResult v op w error₂ : BinOpError op (valueType(w)) → BinOpStepResult v op w binOpStep : ∀ v op w → BinOpStepResult v op w binOpStep nil + w = error₁ (+ (λ ())) binOpStep (addr a) + w = error₁ (+ (λ ())) binOpStep (number m) + nil = error₂ (+ (λ ())) binOpStep (number m) + (addr a) = error₂ (+ (λ ())) binOpStep (number m) + (number n) = step (number (primFloatPlus m n)) (+ m n) binOpStep (number m) + (bool b) = error₂ (+ (λ ())) binOpStep (number m) + (string x) = error₂ (+ (λ ())) binOpStep (number m) - (string x) = error₂ (- (λ ())) binOpStep (number m) * (string x) = error₂ (* (λ ())) binOpStep (number m) / (string x) = error₂ (/ (λ ())) binOpStep (number m) < (string x) = error₂ (< (λ ())) binOpStep (number m) > (string x) = error₂ (> (λ ())) binOpStep (number m) == (string x) = step (bool false) (== (number m) (string x)) binOpStep (number m) ~= (string x) = step (bool true) (~= (number m) (string x)) binOpStep (number m) <= (string x) = error₂ (<= (λ ())) binOpStep (number m) >= (string x) = error₂ (>= (λ ())) binOpStep (bool b) + w = error₁ (+ (λ ())) binOpStep nil - w = error₁ (- (λ ())) binOpStep (addr a) - w = error₁ (- (λ ())) binOpStep (number x) - nil = error₂ (- (λ ())) binOpStep (number x) - (addr a) = error₂ (- (λ ())) binOpStep (number x) - (number n) = step (number (primFloatMinus x n)) (- x n) binOpStep (number x) - (bool b) = error₂ (- (λ ())) binOpStep (bool b) - w = error₁ (- (λ ())) binOpStep nil * w = error₁ (* (λ ())) binOpStep (addr a) * w = error₁ (* (λ ())) binOpStep (number m) * nil = error₂ (* (λ ())) binOpStep (number m) * (addr a) = error₂ (* (λ ())) binOpStep (number m) * (number n) = step (number (primFloatDiv m n)) (* m n) binOpStep (number m) * (bool b) = error₂ (* (λ ())) binOpStep (bool b) * w = error₁ (* (λ ())) binOpStep nil / w = error₁ (/ (λ ())) binOpStep (addr a) / w = error₁ (/ (λ ())) binOpStep (number m) / nil = error₂ (/ (λ ())) binOpStep (number m) / (addr a) = error₂ (/ (λ ())) binOpStep (number m) / (number n) = step (number (primFloatTimes m n)) (/ m n) binOpStep (number m) / (bool b) = error₂ (/ (λ ())) binOpStep (bool b) / w = error₁ (/ (λ ())) binOpStep nil < w = error₁ (< (λ ())) binOpStep (addr a) < w = error₁ (< (λ ())) binOpStep (number m) < nil = error₂ (< (λ ())) binOpStep (number m) < (addr a) = error₂ (< (λ ())) binOpStep (number m) < (number n) = step (bool (primFloatLess m n)) (< m n) binOpStep (number m) < (bool b) = error₂ (< (λ ())) binOpStep (bool b) < w = error₁ (< (λ ())) binOpStep nil > w = error₁ (> (λ ())) binOpStep (addr a) > w = error₁ (> (λ ())) binOpStep (number m) > nil = error₂ (> (λ ())) binOpStep (number m) > (addr a) = error₂ (> (λ ())) binOpStep (number m) > (number n) = step (bool (primFloatLess n m)) (> m n) binOpStep (number m) > (bool b) = error₂ (> (λ ())) binOpStep (bool b) > w = error₁ (> (λ ())) binOpStep v == w = step (bool (evalEqOp v w)) (== v w) binOpStep v ~= w = step (bool (evalNeqOp v w)) (~= v w) binOpStep nil <= w = error₁ (<= (λ ())) binOpStep (addr a) <= w = error₁ (<= (λ ())) binOpStep (number m) <= nil = error₂ (<= (λ ())) binOpStep (number m) <= (addr a) = error₂ (<= (λ ())) binOpStep (number m) <= (number n) = step (bool (primFloatLess m n or primFloatEquality m n)) (<= m n) binOpStep (number m) <= (bool b) = error₂ (<= (λ ())) binOpStep (bool b) <= w = error₁ (<= (λ ())) binOpStep nil >= w = error₁ (>= (λ ())) binOpStep (addr a) >= w = error₁ (>= (λ ())) binOpStep (number m) >= nil = error₂ (>= (λ ())) binOpStep (number m) >= (addr a) = error₂ (>= (λ ())) binOpStep (number m) >= (number n) = step (bool (primFloatLess n m or primFloatEquality m n)) (>= m n) binOpStep (number m) >= (bool b) = error₂ (>= (λ ())) binOpStep (bool b) >= w = error₁ (>= (λ ())) binOpStep (string x) + w = error₁ (+ (λ ())) binOpStep (string x) - w = error₁ (- (λ ())) binOpStep (string x) * w = error₁ (* (λ ())) binOpStep (string x) / w = error₁ (/ (λ ())) binOpStep (string x) < w = error₁ (< (λ ())) binOpStep (string x) > w = error₁ (> (λ ())) binOpStep (string x) <= w = error₁ (<= (λ ())) binOpStep (string x) >= w = error₁ (>= (λ ())) binOpStep nil ·· y = error₁ (·· (λ ())) binOpStep (addr x) ·· y = error₁ (BinOpError.·· (λ ())) binOpStep (number x) ·· y = error₁ (BinOpError.·· (λ ())) binOpStep (bool x) ·· y = error₁ (BinOpError.·· (λ ())) binOpStep (string x) ·· nil = error₂ (·· (λ ())) binOpStep (string x) ·· (addr y) = error₂ (·· (λ ())) binOpStep (string x) ·· (number y) = error₂ (·· (λ ())) binOpStep (string x) ·· (bool y) = error₂ (·· (λ ())) binOpStep (string x) ·· (string y) = step (string (primStringAppend x y)) (·· x y) data StepResultᴮ {a} (H : Heap a) (B : Block a) : Set data StepResultᴱ {a} (H : Heap a) (M : Expr a) : Set data StepResultᴮ H B where step : ∀ H′ B′ → (H ⊢ B ⟶ᴮ B′ ⊣ H′) → StepResultᴮ H B return : ∀ v {B′} → (B ≡ (return (val v) ∙ B′)) → StepResultᴮ H B done : (B ≡ done) → StepResultᴮ H B error : (RuntimeErrorᴮ H B) → StepResultᴮ H B data StepResultᴱ H M where step : ∀ H′ M′ → (H ⊢ M ⟶ᴱ M′ ⊣ H′) → StepResultᴱ H M value : ∀ V → (M ≡ val V) → StepResultᴱ H M error : (RuntimeErrorᴱ H M) → StepResultᴱ H M stepᴱ : ∀ {a} H M → StepResultᴱ {a} H M stepᴮ : ∀ {a} H B → StepResultᴮ {a} H B stepᴱ H (val v) = value v refl stepᴱ H (var x) = error UnboundVariable stepᴱ H (M $ N) with stepᴱ H M stepᴱ H (M $ N) | step H′ M′ D = step H′ (M′ $ N) (app₁ D) stepᴱ H (_ $ N) | value v refl with stepᴱ H N stepᴱ H (_ $ N) | value v refl | step H′ N′ s = step H′ (val v $ N′) (app₂ v s) stepᴱ H (_ $ _) | value (addr a) refl | value w refl with remember (H [ a ]) stepᴱ H (_ $ _) | value (addr a) refl | value w refl | (nothing , p) = error (app₁ (SEGV p)) stepᴱ H (_ $ _) | value (addr a) refl | value w refl | (just(function F is B end) , p) = step H (block (fun F) is B [ w / name (arg F) ]ᴮ end) (beta function F is B end w refl p) stepᴱ H (_ $ _) | value nil refl | value w refl = error (FunctionMismatch nil w (λ ())) stepᴱ H (_ $ _) | value (number m) refl | value w refl = error (FunctionMismatch (number m) w (λ ())) stepᴱ H (_ $ _) | value (bool b) refl | value w refl = error (FunctionMismatch (bool b) w (λ ())) stepᴱ H (_ $ _) | value (string x) refl | value w refl = error (FunctionMismatch (string x) w (λ ())) stepᴱ H (M $ N) | value V p | error E = error (app₂ E) stepᴱ H (M $ N) | error E = error (app₁ E) stepᴱ H (block b is B end) with stepᴮ H B stepᴱ H (block b is B end) | step H′ B′ D = step H′ (block b is B′ end) (block D) stepᴱ H (block b is (return _ ∙ B′) end) | return v refl = step H (val v) (return v) stepᴱ H (block b is done end) | done refl = step H (val nil) done stepᴱ H (block b is B end) | error E = error (block E) stepᴱ H (function F is C end) with alloc H (function F is C end) stepᴱ H function F is C end | ok a H′ p = step H′ (val (addr a)) (function a p) stepᴱ H (binexp M op N) with stepᴱ H M stepᴱ H (binexp M op N) | step H′ M′ s = step H′ (binexp M′ op N) (binOp₁ s) stepᴱ H (binexp M op N) | error E = error (bin₁ E) stepᴱ H (binexp M op N) | value v refl with stepᴱ H N stepᴱ H (binexp M op N) | value v refl | step H′ N′ s = step H′ (binexp (val v) op N′) (binOp₂ s) stepᴱ H (binexp M op N) | value v refl | error E = error (bin₂ E) stepᴱ H (binexp M op N) | value v refl | value w refl with binOpStep v op w stepᴱ H (binexp M op N) | value v refl | value w refl | step x p = step H (val x) (binOp₀ p) stepᴱ H (binexp M op N) | value v refl | value w refl | error₁ E = error (BinOpMismatch₁ v w E) stepᴱ H (binexp M op N) | value v refl | value w refl | error₂ E = error (BinOpMismatch₂ v w E) stepᴮ H (function F is C end ∙ B) with alloc H (function F is C end) stepᴮ H (function F is C end ∙ B) | ok a H′ p = step H′ (B [ addr a / name (fun F) ]ᴮ) (function a p) stepᴮ H (local x ← M ∙ B) with stepᴱ H M stepᴮ H (local x ← M ∙ B) | step H′ M′ D = step H′ (local x ← M′ ∙ B) (local D) stepᴮ H (local x ← _ ∙ B) | value v refl = step H (B [ v / name x ]ᴮ) (subst v) stepᴮ H (local x ← M ∙ B) | error E = error (local E) stepᴮ H (return M ∙ B) with stepᴱ H M stepᴮ H (return M ∙ B) | step H′ M′ D = step H′ (return M′ ∙ B) (return D) stepᴮ H (return _ ∙ B) | value V refl = return V refl stepᴮ H (return M ∙ B) | error E = error (return E) stepᴮ H done = done refl
{ "alphanum_fraction": 0.598185754, "avg_line_length": 56.4011627907, "ext": "agda", "hexsha": "cadd153076e18fa2a37ac18b32897fcf909a80d7", "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": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "XanderYZZ/luau", "max_forks_repo_path": "prototyping/Properties/Step.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "362428f8b4b6f5c9d43f4daf55bcf7873f536c3f", "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": "XanderYZZ/luau", "max_issues_repo_path": "prototyping/Properties/Step.agda", "max_line_length": 227, "max_stars_count": 1, "max_stars_repo_head_hexsha": "72d8d443431875607fd457a13fe36ea62804d327", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TheGreatSageEqualToHeaven/luau", "max_stars_repo_path": "prototyping/Properties/Step.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-05T21:53:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-12-05T21:53:03.000Z", "num_tokens": 3755, "size": 9701 }
-- Andreas, 2015-11-24, reported by Wolfram Kahl {-# OPTIONS -v impossible:60 #-} -- {-# OPTIONS -v tc.section:60 #-} -- {-# OPTIONS -v scope:10 #-} -- -- {-# OPTIONS -v tc.mod.apply:100 #-} postulate N : Set module A (O : Set) where record R : Set where field f : O module L where open R public module B (P : Set) where module M (Q : Set) where -- private open module AQ = A Q public -- Works, as module is named open A Q public -- Did not work, as module is anonymous private open module MP = M P public -- OR: open MP public open B open L N
{ "alphanum_fraction": 0.6155172414, "avg_line_length": 20.7142857143, "ext": "agda", "hexsha": "368e3eaef2c9fdf9e7cfa457539e081a9b4e74dd", "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/Issue1701II.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/Issue1701II.agda", "max_line_length": 72, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue1701II.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": 177, "size": 580 }
{-# OPTIONS --copatterns #-} module InstantiatedRecordModuleNoCopattern where module M (A : Set1) where open M -- underapplied open open M Set -- fully applied open record R : Set2 where constructor inn field out : Set1 r : R r = inn Set open R r -- fully applied open bla = out -- This is an ill-formed copattern: -- field of instantiated record module is not a projection!! wrong : R out wrong = Set -- InstantiatedRecordModuleNoCopattern.agda:23,1-16 -- Not a valid projection for a copattern: out -- when checking that the clause out wrong = Set has type R
{ "alphanum_fraction": 0.7140410959, "avg_line_length": 20.1379310345, "ext": "agda", "hexsha": "e806ca0a47e691decaa447dbad67249c33525d8e", "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/InstantiatedRecordModuleNoCopattern.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/InstantiatedRecordModuleNoCopattern.agda", "max_line_length": 60, "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/InstantiatedRecordModuleNoCopattern.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": 159, "size": 584 }
{-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Rel) module Algebra.Structures.Field {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where open import Algebra.Linear.Core open import Relation.Nullary using (¬_) open import Algebra.Structures _≈_ open import Algebra.FunctionProperties _≈_ open import Level using (_⊔_) record NonZero (0# : A) : Set (a ⊔ ℓ) where field value : A non-zero : ¬ (value ≈ 0#) MultiplicativeInverse : ∀ (0# : A) -> Set (a ⊔ ℓ) MultiplicativeInverse 0# = NonZero 0# → NonZero 0# record IsField (_+_ _*_ : Op₂ A) (0# 1# : A) (-_ : Op₁ A) (_⁻¹ : MultiplicativeInverse 0#) : Set (a ⊔ ℓ) where field isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1# _⁻¹-involutive : ∀ (x : NonZero 0#) → NonZero.value ((x ⁻¹) ⁻¹) ≈ NonZero.value x _⁻¹-inverse : ∀ (x : NonZero 0#) → ((NonZero.value x) * (NonZero.value (x ⁻¹))) ≈ 1# 0#-not-1# : ¬ (0# ≈ 1#) open IsCommutativeRing isCommutativeRing public open import Algebra.Properties.Ring (record { isRing = isRing }) public
{ "alphanum_fraction": 0.6353276353, "avg_line_length": 28.4594594595, "ext": "agda", "hexsha": "9de497b077e85ca77fd2819d7a9a975d7002ab1d", "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": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_path": "src/Algebra/Structures/Field.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "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": "felko/linear-algebra", "max_issues_repo_path": "src/Algebra/Structures/Field.agda", "max_line_length": 110, "max_stars_count": 15, "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_path": "src/Algebra/Structures/Field.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "num_tokens": 386, "size": 1053 }
{-# OPTIONS --without-K --exact-split #-} module integers where import rings-with-properties open rings-with-properties public -------------------------------------------------------------------------------- {- We give a self-contained proof that ℤ is the initial pointed type with an automorphism. -} -- We first introduce the type of pointed types with an automorphism UU-Pointed-Type-With-Aut : (l : Level) → UU (lsuc l) UU-Pointed-Type-With-Aut l = Σ (UU l) (λ X → X × (X ≃ X)) -- Some trivial bureaucracy for the type of pointed types with an automorphism type-Pointed-Type-With-Aut : {l : Level} → UU-Pointed-Type-With-Aut l → UU l type-Pointed-Type-With-Aut X = pr1 X point-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) → type-Pointed-Type-With-Aut X point-Pointed-Type-With-Aut X = pr1 (pr2 X) aut-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) → type-Pointed-Type-With-Aut X ≃ type-Pointed-Type-With-Aut X aut-Pointed-Type-With-Aut X = pr2 (pr2 X) map-aut-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) → type-Pointed-Type-With-Aut X → type-Pointed-Type-With-Aut X map-aut-Pointed-Type-With-Aut X = map-equiv (aut-Pointed-Type-With-Aut X) inv-map-aut-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) → type-Pointed-Type-With-Aut X → type-Pointed-Type-With-Aut X inv-map-aut-Pointed-Type-With-Aut X = inv-map-equiv (aut-Pointed-Type-With-Aut X) issec-inv-map-aut-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) → ((map-aut-Pointed-Type-With-Aut X) ∘ (inv-map-aut-Pointed-Type-With-Aut X)) ~ id issec-inv-map-aut-Pointed-Type-With-Aut X = issec-inv-map-equiv (aut-Pointed-Type-With-Aut X) isretr-inv-map-aut-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) → ((inv-map-aut-Pointed-Type-With-Aut X) ∘ (map-aut-Pointed-Type-With-Aut X)) ~ id isretr-inv-map-aut-Pointed-Type-With-Aut X = isretr-inv-map-equiv (aut-Pointed-Type-With-Aut X) -- ℤ is a pointed type with an automorphism ℤ-Pointed-Type-With-Aut : UU-Pointed-Type-With-Aut lzero ℤ-Pointed-Type-With-Aut = pair ℤ (pair zero-ℤ equiv-succ-ℤ) -- We introduce the type of morphisms of pointed types with an automorphism hom-Pointed-Type-With-Aut : {l1 l2 : Level} → UU-Pointed-Type-With-Aut l1 → UU-Pointed-Type-With-Aut l2 → UU (l1 ⊔ l2) hom-Pointed-Type-With-Aut {l1} {l2} X Y = Σ ( type-Pointed-Type-With-Aut X → type-Pointed-Type-With-Aut Y) ( λ f → Id (f (point-Pointed-Type-With-Aut X)) (point-Pointed-Type-With-Aut Y) × ( ( f ∘ (map-aut-Pointed-Type-With-Aut X)) ~ ( (map-aut-Pointed-Type-With-Aut Y) ∘ f))) -- Some trivial bureaucracy about morphisms of pointed types with an -- automorphism map-hom-Pointed-Type-With-Aut : {l1 l2 : Level} (X : UU-Pointed-Type-With-Aut l1) (Y : UU-Pointed-Type-With-Aut l2) → hom-Pointed-Type-With-Aut X Y → type-Pointed-Type-With-Aut X → type-Pointed-Type-With-Aut Y map-hom-Pointed-Type-With-Aut X Y f = pr1 f preserves-point-map-hom-Pointed-Type-With-Aut : {l1 l2 : Level} (X : UU-Pointed-Type-With-Aut l1) (Y : UU-Pointed-Type-With-Aut l2) (f : hom-Pointed-Type-With-Aut X Y) → Id ( map-hom-Pointed-Type-With-Aut X Y f (point-Pointed-Type-With-Aut X)) ( point-Pointed-Type-With-Aut Y) preserves-point-map-hom-Pointed-Type-With-Aut X Y f = pr1 (pr2 f) preserves-aut-map-hom-Pointed-Type-With-Aut : {l1 l2 : Level} (X : UU-Pointed-Type-With-Aut l1) (Y : UU-Pointed-Type-With-Aut l2) (f : hom-Pointed-Type-With-Aut X Y) → ( ( map-hom-Pointed-Type-With-Aut X Y f) ∘ (map-aut-Pointed-Type-With-Aut X)) ~ ( ( map-aut-Pointed-Type-With-Aut Y) ∘ (map-hom-Pointed-Type-With-Aut X Y f)) preserves-aut-map-hom-Pointed-Type-With-Aut X Y f = pr2 (pr2 f) -- We characterize the identity type of hom-Pointed-Type-With-Aut htpy-hom-Pointed-Type-With-Aut : {l1 l2 : Level} (X : UU-Pointed-Type-With-Aut l1) (Y : UU-Pointed-Type-With-Aut l2) (h1 h2 : hom-Pointed-Type-With-Aut X Y) → UU (l1 ⊔ l2) htpy-hom-Pointed-Type-With-Aut X Y h1 h2 = Σ ( map-hom-Pointed-Type-With-Aut X Y h1 ~ map-hom-Pointed-Type-With-Aut X Y h2) ( λ H → ( Id ( preserves-point-map-hom-Pointed-Type-With-Aut X Y h1) ( ( H (point-Pointed-Type-With-Aut X)) ∙ ( preserves-point-map-hom-Pointed-Type-With-Aut X Y h2))) × ( ( x : type-Pointed-Type-With-Aut X) → ( Id ( ( preserves-aut-map-hom-Pointed-Type-With-Aut X Y h1 x) ∙ ( ap (map-aut-Pointed-Type-With-Aut Y) (H x))) ( ( H (map-aut-Pointed-Type-With-Aut X x)) ∙ ( preserves-aut-map-hom-Pointed-Type-With-Aut X Y h2 x))))) refl-htpy-hom-Pointed-Type-With-Aut : {l1 l2 : Level} (X : UU-Pointed-Type-With-Aut l1) (Y : UU-Pointed-Type-With-Aut l2) (h : hom-Pointed-Type-With-Aut X Y) → htpy-hom-Pointed-Type-With-Aut X Y h h refl-htpy-hom-Pointed-Type-With-Aut X Y h = pair refl-htpy (pair refl (λ x → right-unit)) htpy-hom-Pointed-Type-With-Aut-eq : {l1 l2 : Level} (X : UU-Pointed-Type-With-Aut l1) (Y : UU-Pointed-Type-With-Aut l2) (h1 h2 : hom-Pointed-Type-With-Aut X Y) → Id h1 h2 → htpy-hom-Pointed-Type-With-Aut X Y h1 h2 htpy-hom-Pointed-Type-With-Aut-eq X Y h1 .h1 refl = refl-htpy-hom-Pointed-Type-With-Aut X Y h1 -- This is the meat of the characterization of the type of morphisms of pointed -- types with an equivalence. The only hard part is feeding the families -- explicitly to Agda over and over again, because Agda is apparently not that -- good at figuring out what the correct family is. is-contr-total-htpy-hom-Pointed-Type-With-Aut : {l1 l2 : Level} (X : UU-Pointed-Type-With-Aut l1) (Y : UU-Pointed-Type-With-Aut l2) (h1 : hom-Pointed-Type-With-Aut X Y) → is-contr ( Σ ( hom-Pointed-Type-With-Aut X Y) ( htpy-hom-Pointed-Type-With-Aut X Y h1)) is-contr-total-htpy-hom-Pointed-Type-With-Aut X Y h1 = is-contr-total-Eq-structure ( λ ( map-h2 : type-Pointed-Type-With-Aut X → type-Pointed-Type-With-Aut Y) ( str-h2 : ( Id ( map-h2 (point-Pointed-Type-With-Aut X)) ( point-Pointed-Type-With-Aut Y)) × ( ( x : type-Pointed-Type-With-Aut X) → Id ( map-h2 (map-aut-Pointed-Type-With-Aut X x)) ( map-aut-Pointed-Type-With-Aut Y (map-h2 x)))) ( H : map-hom-Pointed-Type-With-Aut X Y h1 ~ map-h2) → ( Id ( preserves-point-map-hom-Pointed-Type-With-Aut X Y h1) ( ( H (point-Pointed-Type-With-Aut X)) ∙ ( pr1 str-h2))) × ( ( x : type-Pointed-Type-With-Aut X) → ( Id ( ( preserves-aut-map-hom-Pointed-Type-With-Aut X Y h1 x) ∙ ( ap (map-aut-Pointed-Type-With-Aut Y) (H x))) ( ( H (map-aut-Pointed-Type-With-Aut X x)) ∙ ( pr2 str-h2 x))))) ( is-contr-total-htpy (map-hom-Pointed-Type-With-Aut X Y h1)) ( pair (map-hom-Pointed-Type-With-Aut X Y h1) refl-htpy) ( is-contr-total-Eq-structure ( λ ( pt-h2 : Id ( map-hom-Pointed-Type-With-Aut X Y h1 ( point-Pointed-Type-With-Aut X)) ( point-Pointed-Type-With-Aut Y)) ( aut-h2 : ( x : type-Pointed-Type-With-Aut X) → Id ( map-hom-Pointed-Type-With-Aut X Y h1 ( map-aut-Pointed-Type-With-Aut X x)) ( map-aut-Pointed-Type-With-Aut Y ( map-hom-Pointed-Type-With-Aut X Y h1 x))) ( α : Id ( preserves-point-map-hom-Pointed-Type-With-Aut X Y h1) ( pt-h2)) → ( ( x : type-Pointed-Type-With-Aut X) → Id ( ( preserves-aut-map-hom-Pointed-Type-With-Aut X Y h1 x) ∙ ( refl)) ( aut-h2 x))) ( is-contr-total-path ( preserves-point-map-hom-Pointed-Type-With-Aut X Y h1)) ( pair (preserves-point-map-hom-Pointed-Type-With-Aut X Y h1) refl) ( is-contr-equiv' ( Σ ( ( x : type-Pointed-Type-With-Aut X) → Id ( map-hom-Pointed-Type-With-Aut X Y h1 ( map-aut-Pointed-Type-With-Aut X x)) ( map-aut-Pointed-Type-With-Aut Y ( map-hom-Pointed-Type-With-Aut X Y h1 x))) ( λ aut-h2 → ( x : type-Pointed-Type-With-Aut X) → Id ( preserves-aut-map-hom-Pointed-Type-With-Aut X Y h1 x) ( aut-h2 x))) ( equiv-tot (equiv-htpy-concat htpy-right-unit)) ( is-contr-total-htpy ( preserves-aut-map-hom-Pointed-Type-With-Aut X Y h1)))) -- We complete the characterization of the identity type of the type of -- morphisms of types with a point and an automorphism is-equiv-htpy-hom-Pointed-Type-With-Aut : {l1 l2 : Level} (X : UU-Pointed-Type-With-Aut l1) (Y : UU-Pointed-Type-With-Aut l2) (h1 h2 : hom-Pointed-Type-With-Aut X Y) → is-equiv (htpy-hom-Pointed-Type-With-Aut-eq X Y h1 h2) is-equiv-htpy-hom-Pointed-Type-With-Aut X Y h1 = fundamental-theorem-id h1 ( refl-htpy-hom-Pointed-Type-With-Aut X Y h1) ( is-contr-total-htpy-hom-Pointed-Type-With-Aut X Y h1) ( htpy-hom-Pointed-Type-With-Aut-eq X Y h1) eq-htpy-hom-Pointed-Type-With-Aut : {l1 l2 : Level} (X : UU-Pointed-Type-With-Aut l1) (Y : UU-Pointed-Type-With-Aut l2) (h1 h2 : hom-Pointed-Type-With-Aut X Y) → htpy-hom-Pointed-Type-With-Aut X Y h1 h2 → Id h1 h2 eq-htpy-hom-Pointed-Type-With-Aut X Y h1 h2 = inv-is-equiv (is-equiv-htpy-hom-Pointed-Type-With-Aut X Y h1 h2) -- We show that from ℤ there is a morphism of pointed types with automorphism -- to any pointed type with automorphisms map-initial-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) → ℤ → type-Pointed-Type-With-Aut X map-initial-Pointed-Type-With-Aut X (inl zero-ℕ) = inv-map-aut-Pointed-Type-With-Aut X (point-Pointed-Type-With-Aut X) map-initial-Pointed-Type-With-Aut X (inl (succ-ℕ k)) = inv-map-aut-Pointed-Type-With-Aut X ( map-initial-Pointed-Type-With-Aut X (inl k)) map-initial-Pointed-Type-With-Aut X (inr (inl star)) = point-Pointed-Type-With-Aut X map-initial-Pointed-Type-With-Aut X (inr (inr zero-ℕ)) = map-aut-Pointed-Type-With-Aut X (point-Pointed-Type-With-Aut X) map-initial-Pointed-Type-With-Aut X (inr (inr (succ-ℕ k))) = map-aut-Pointed-Type-With-Aut X ( map-initial-Pointed-Type-With-Aut X (inr (inr k))) preserves-point-map-initial-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) → Id ( map-initial-Pointed-Type-With-Aut X zero-ℤ) ( point-Pointed-Type-With-Aut X) preserves-point-map-initial-Pointed-Type-With-Aut X = refl preserves-aut-map-initial-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) (k : ℤ) → Id ( map-initial-Pointed-Type-With-Aut X (succ-ℤ k)) ( map-aut-Pointed-Type-With-Aut X ( map-initial-Pointed-Type-With-Aut X k)) preserves-aut-map-initial-Pointed-Type-With-Aut X (inl zero-ℕ) = inv ( issec-inv-map-aut-Pointed-Type-With-Aut X (point-Pointed-Type-With-Aut X)) preserves-aut-map-initial-Pointed-Type-With-Aut X (inl (succ-ℕ k)) = inv ( issec-inv-map-aut-Pointed-Type-With-Aut X ( map-initial-Pointed-Type-With-Aut X (inl k))) preserves-aut-map-initial-Pointed-Type-With-Aut X (inr (inl star)) = refl preserves-aut-map-initial-Pointed-Type-With-Aut X (inr (inr zero-ℕ)) = refl preserves-aut-map-initial-Pointed-Type-With-Aut X (inr (inr (succ-ℕ x))) = refl hom-initial-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) → hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X hom-initial-Pointed-Type-With-Aut X = pair ( map-initial-Pointed-Type-With-Aut X) ( pair ( preserves-point-map-initial-Pointed-Type-With-Aut X) ( preserves-aut-map-initial-Pointed-Type-With-Aut X)) -- We now show that the morphism from ℤ to a pointed type with an automorphism -- is unique, using our characterization of the identity type of the type of -- morphisms of pointed types with an automorphism htpy-initial-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) (h : hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X) → map-initial-Pointed-Type-With-Aut X ~ map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h htpy-initial-Pointed-Type-With-Aut X h (inl zero-ℕ) = map-eq-transpose-equiv' ( aut-Pointed-Type-With-Aut X) ( ( inv ( preserves-point-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h)) ∙ ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h neg-one-ℤ)) htpy-initial-Pointed-Type-With-Aut X h (inl (succ-ℕ k)) = map-eq-transpose-equiv' ( aut-Pointed-Type-With-Aut X) ( ( htpy-initial-Pointed-Type-With-Aut X h (inl k)) ∙ ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h (inl (succ-ℕ k)))) htpy-initial-Pointed-Type-With-Aut X h (inr (inl star)) = inv ( preserves-point-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h) htpy-initial-Pointed-Type-With-Aut X h (inr (inr zero-ℕ)) = ( ap ( map-aut-Pointed-Type-With-Aut X) ( htpy-initial-Pointed-Type-With-Aut X h (inr (inl star)))) ∙ ( inv ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h (inr (inl star)))) htpy-initial-Pointed-Type-With-Aut X h (inr (inr (succ-ℕ k))) = ( ap ( map-aut-Pointed-Type-With-Aut X) ( htpy-initial-Pointed-Type-With-Aut X h (inr (inr k)))) ∙ ( inv ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h (inr (inr k)))) -- The following two steps become trivial if X is a set coh-point-htpy-initial-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) (h : hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X) → Id ( preserves-point-map-initial-Pointed-Type-With-Aut X) ( ( htpy-initial-Pointed-Type-With-Aut X h zero-ℤ) ∙ ( preserves-point-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h)) coh-point-htpy-initial-Pointed-Type-With-Aut X h = inv ( left-inv ( preserves-point-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h)) coh-aut-htpy-initial-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) (h : hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X) (k : ℤ) → Id ( ( preserves-aut-map-initial-Pointed-Type-With-Aut X k) ∙ ( ap ( map-aut-Pointed-Type-With-Aut X) ( htpy-initial-Pointed-Type-With-Aut X h k))) ( ( htpy-initial-Pointed-Type-With-Aut X h (succ-ℤ k)) ∙ ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h k)) coh-aut-htpy-initial-Pointed-Type-With-Aut X h (inl zero-ℕ) = inv ( inv-con ( issec-inv-map-equiv ( aut-Pointed-Type-With-Aut X) ( point-Pointed-Type-With-Aut X)) ( ( htpy-initial-Pointed-Type-With-Aut X h zero-ℤ) ∙ ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h neg-one-ℤ)) ( ap ( map-equiv (aut-Pointed-Type-With-Aut X)) ( htpy-initial-Pointed-Type-With-Aut X h neg-one-ℤ)) ( triangle-eq-transpose-equiv' ( aut-Pointed-Type-With-Aut X) ( ( inv ( preserves-point-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h)) ∙ ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h neg-one-ℤ)))) coh-aut-htpy-initial-Pointed-Type-With-Aut X h (inl (succ-ℕ k)) = inv ( inv-con ( issec-inv-map-equiv ( aut-Pointed-Type-With-Aut X) ( map-initial-Pointed-Type-With-Aut X (inl k))) ( ( htpy-initial-Pointed-Type-With-Aut X h (inl k)) ∙ ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h (inl (succ-ℕ k)))) ( ap ( map-equiv (aut-Pointed-Type-With-Aut X)) ( htpy-initial-Pointed-Type-With-Aut X h (inl (succ-ℕ k)))) ( triangle-eq-transpose-equiv' ( aut-Pointed-Type-With-Aut X) ( ( htpy-initial-Pointed-Type-With-Aut X h (inl k)) ∙ ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h (inl (succ-ℕ k)))))) coh-aut-htpy-initial-Pointed-Type-With-Aut X h (inr (inl star)) = ( inv right-unit) ∙ ( ( ap ( concat ( ap ( map-aut-Pointed-Type-With-Aut X) ( htpy-initial-Pointed-Type-With-Aut X h zero-ℤ)) ( map-aut-Pointed-Type-With-Aut X ( map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h zero-ℤ))) ( inv (left-inv ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h zero-ℤ)))) ∙ ( inv ( assoc ( ap ( map-aut-Pointed-Type-With-Aut X) ( htpy-initial-Pointed-Type-With-Aut X h zero-ℤ)) ( inv ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h zero-ℤ)) ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h zero-ℤ)))) coh-aut-htpy-initial-Pointed-Type-With-Aut X h (inr (inr zero-ℕ)) = ( inv right-unit) ∙ ( ( ap ( concat ( ap ( map-aut-Pointed-Type-With-Aut X) ( htpy-initial-Pointed-Type-With-Aut X h one-ℤ)) ( map-aut-Pointed-Type-With-Aut X ( map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h one-ℤ))) ( inv (left-inv ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h one-ℤ)))) ∙ ( inv ( assoc ( ap ( map-aut-Pointed-Type-With-Aut X) ( htpy-initial-Pointed-Type-With-Aut X h one-ℤ)) ( inv ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h one-ℤ)) ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h one-ℤ)))) coh-aut-htpy-initial-Pointed-Type-With-Aut X h (inr (inr (succ-ℕ k))) = ( inv right-unit) ∙ ( ( ap ( concat ( ap ( map-aut-Pointed-Type-With-Aut X) ( htpy-initial-Pointed-Type-With-Aut X h (inr (inr (succ-ℕ k))))) ( map-aut-Pointed-Type-With-Aut X ( map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h (inr (inr (succ-ℕ k)))))) ( inv (left-inv ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h (inr (inr (succ-ℕ k))))))) ∙ ( inv ( assoc ( ap ( map-aut-Pointed-Type-With-Aut X) ( htpy-initial-Pointed-Type-With-Aut X h (inr (inr (succ-ℕ k))))) ( inv ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h (inr (inr (succ-ℕ k))))) ( preserves-aut-map-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X h (inr (inr (succ-ℕ k))))))) is-initial-ℤ-Pointed-Type-With-Aut : {l : Level} (X : UU-Pointed-Type-With-Aut l) → is-contr (hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X) is-initial-ℤ-Pointed-Type-With-Aut X = pair ( hom-initial-Pointed-Type-With-Aut X) ( λ h → eq-htpy-hom-Pointed-Type-With-Aut ℤ-Pointed-Type-With-Aut X ( hom-initial-Pointed-Type-With-Aut X) ( h) ( pair ( htpy-initial-Pointed-Type-With-Aut X h) ( pair ( coh-point-htpy-initial-Pointed-Type-With-Aut X h) ( coh-aut-htpy-initial-Pointed-Type-With-Aut X h)))) -------------------------------------------------------------------------------- {- We exhibit ℤ as an abelian group, and as a ring. -} add-ℤ-Semi-Group : Semi-Group lzero add-ℤ-Semi-Group = pair ℤ-Set (pair add-ℤ associative-add-ℤ) is-unital-add-ℤ-Semi-Group : is-unital add-ℤ-Semi-Group is-unital-add-ℤ-Semi-Group = pair zero-ℤ (pair left-unit-law-add-ℤ right-unit-law-add-ℤ) add-ℤ-Monoid : Monoid lzero add-ℤ-Monoid = pair add-ℤ-Semi-Group is-unital-add-ℤ-Semi-Group has-inverses-add-ℤ-Monoid : is-group' add-ℤ-Semi-Group is-unital-add-ℤ-Semi-Group has-inverses-add-ℤ-Monoid = pair neg-ℤ (pair left-inverse-law-add-ℤ right-inverse-law-add-ℤ) is-group-add-ℤ-Semi-Group : is-group add-ℤ-Semi-Group is-group-add-ℤ-Semi-Group = pair is-unital-add-ℤ-Semi-Group has-inverses-add-ℤ-Monoid ℤ-Group : Group lzero ℤ-Group = pair add-ℤ-Semi-Group is-group-add-ℤ-Semi-Group ℤ-Ab : Ab lzero ℤ-Ab = pair ℤ-Group commutative-add-ℤ has-mul-ℤ-Ab : has-mul-Ab ℤ-Ab has-mul-ℤ-Ab = pair ( pair mul-ℤ associative-mul-ℤ) ( pair ( pair one-ℤ (pair left-unit-law-mul-ℤ right-unit-law-mul-ℤ)) ( pair left-distributive-mul-add-ℤ right-distributive-mul-add-ℤ)) ℤ-Ring : Ring lzero ℤ-Ring = pair ℤ-Ab has-mul-ℤ-Ab ℤ-Comm-Ring : Comm-Ring lzero ℤ-Comm-Ring = pair ℤ-Ring commutative-mul-ℤ mul-ℤ-Semi-Group : Semi-Group lzero mul-ℤ-Semi-Group = pair ℤ-Set (pair mul-ℤ associative-mul-ℤ) mul-ℤ-Monoid : Monoid lzero mul-ℤ-Monoid = pair ( mul-ℤ-Semi-Group) ( pair one-ℤ (pair left-unit-law-mul-ℤ right-unit-law-mul-ℤ)) -------------------------------------------------------------------------------- {- We characterize the identity type of ℤ. -} Eq-ℤ : ℤ → ℤ → UU lzero Eq-ℤ (inl x) (inl y) = Eq-ℕ x y Eq-ℤ (inl x) (inr y) = empty Eq-ℤ (inr x) (inl x₁) = empty Eq-ℤ (inr (inl x)) (inr (inl y)) = unit Eq-ℤ (inr (inl x)) (inr (inr y)) = empty Eq-ℤ (inr (inr x)) (inr (inl y)) = empty Eq-ℤ (inr (inr x)) (inr (inr y)) = Eq-ℕ x y is-prop-Eq-ℤ : (x y : ℤ) → is-prop (Eq-ℤ x y) is-prop-Eq-ℤ (inl x) (inl y) = is-prop-Eq-ℕ x y is-prop-Eq-ℤ (inl x) (inr y) = is-prop-empty is-prop-Eq-ℤ (inr x) (inl x₁) = is-prop-empty is-prop-Eq-ℤ (inr (inl x)) (inr (inl y)) = is-prop-unit is-prop-Eq-ℤ (inr (inl x)) (inr (inr y)) = is-prop-empty is-prop-Eq-ℤ (inr (inr x)) (inr (inl y)) = is-prop-empty is-prop-Eq-ℤ (inr (inr x)) (inr (inr y)) = is-prop-Eq-ℕ x y refl-Eq-ℤ : (x : ℤ) → Eq-ℤ x x refl-Eq-ℤ (inl x) = refl-Eq-ℕ x refl-Eq-ℤ (inr (inl x)) = star refl-Eq-ℤ (inr (inr x)) = refl-Eq-ℕ x Eq-ℤ-eq : {x y : ℤ} → Id x y → Eq-ℤ x y Eq-ℤ-eq {x} {.x} refl = refl-Eq-ℤ x contraction-total-Eq-ℤ : (x : ℤ) (y : Σ ℤ (Eq-ℤ x)) → Id (pair x (refl-Eq-ℤ x)) y contraction-total-Eq-ℤ (inl x) (pair (inl y) e) = eq-pair ( ap inl (eq-Eq-ℕ x y e)) ( is-prop'-is-prop ( is-prop-Eq-ℕ x y) ( tr ( Eq-ℤ (inl x)) ( ap inl (eq-Eq-ℕ x y e)) ( refl-Eq-ℤ (inl x))) ( e)) contraction-total-Eq-ℤ (inr (inl star)) (pair (inr (inl star)) e) = eq-pair refl (is-prop'-is-prop is-prop-unit (refl-Eq-ℤ zero-ℤ) e) contraction-total-Eq-ℤ (inr (inr x)) (pair (inr (inr y)) e) = eq-pair ( ap (inr ∘ inr) (eq-Eq-ℕ x y e)) ( is-prop'-is-prop ( is-prop-Eq-ℕ x y) ( tr ( Eq-ℤ (inr (inr x))) ( ap (inr ∘ inr) (eq-Eq-ℕ x y e)) ( refl-Eq-ℤ (inr (inr x)))) ( e)) is-contr-total-Eq-ℤ : (x : ℤ) → is-contr (Σ ℤ (Eq-ℤ x)) is-contr-total-Eq-ℤ x = pair (pair x (refl-Eq-ℤ x)) (contraction-total-Eq-ℤ x) is-equiv-Eq-ℤ-eq : (x y : ℤ) → is-equiv (Eq-ℤ-eq {x} {y}) is-equiv-Eq-ℤ-eq x = fundamental-theorem-id x ( refl-Eq-ℤ x) ( is-contr-total-Eq-ℤ x) ( λ y → Eq-ℤ-eq {x} {y}) eq-Eq-ℤ : {x y : ℤ} → Eq-ℤ x y → Id x y eq-Eq-ℤ {x} {y} = inv-is-equiv (is-equiv-Eq-ℤ-eq x y) -------------------------------------------------------------------------------- {- We prove some basic arithmetic properties of the integers. -} -------------------------------------------------------------------------------- {- We show that addition from the left and from the right are both equivalences. We conclude that they are both injective maps. -} is-emb-add-ℤ : (x : ℤ) → is-emb (add-ℤ x) is-emb-add-ℤ x = is-emb-is-equiv (add-ℤ x) (is-equiv-add-ℤ x) is-injective-add-ℤ : (x y z : ℤ) → Id (add-ℤ x y) (add-ℤ x z) → Id y z is-injective-add-ℤ x y z = inv-is-equiv (is-emb-add-ℤ x y z) is-emb-add-ℤ' : (y : ℤ) → is-emb (add-ℤ' y) is-emb-add-ℤ' y = is-emb-is-equiv (add-ℤ' y) (is-equiv-add-ℤ' y) is-injective-add-ℤ' : (y x w : ℤ) → Id (add-ℤ x y) (add-ℤ w y) → Id x w is-injective-add-ℤ' y x w = inv-is-equiv (is-emb-add-ℤ' y x w) -------------------------------------------------------------------------------- {- We show that multiplication by neg-one-ℤ is an equivalence. -} is-emb-neg-ℤ : is-emb neg-ℤ is-emb-neg-ℤ = is-emb-is-equiv neg-ℤ is-equiv-neg-ℤ is-injective-neg-ℤ : (x y : ℤ) → Id (neg-ℤ x) (neg-ℤ y) → Id x y is-injective-neg-ℤ x y = inv-is-equiv (is-emb-neg-ℤ x y) -------------------------------------------------------------------------------- {- We show that if x = mul-ℤ x y for some non-zero integer x, then y = 1. -} -------------------------------------------------------------------------------- {- We show that multiplication by a non-zero integer is an embedding. -} {- is-injective-mul-ℤ : (x y z : ℤ) → ¬ (Id zero-ℤ x) → Id (mul-ℤ x y) (mul-ℤ x z) → Id y z is-injective-mul-ℤ (inl zero-ℕ) y z p q = is-injective-neg-ℤ y z q is-injective-mul-ℤ (inl (succ-ℕ x)) y z p q = {!!} is-injective-mul-ℤ (inr x) y z p q = {!x!} neq-zero-mul-ℤ : (x y : ℤ) → ¬ (Id zero-ℤ x) → ¬ (Id zero-ℤ y) → ¬ (Id zero-ℤ (mul-ℤ x y)) neq-zero-mul-ℤ x y Hx Hy = {!!} -} -------------------------------------------------------------------------------- {- We prove some interchange laws and moves on iterated multiplications. -} interchange-2-3-mul-ℤ : {a b c d : ℤ} → Id (mul-ℤ (mul-ℤ a b) (mul-ℤ c d)) (mul-ℤ (mul-ℤ a c) (mul-ℤ b d)) interchange-2-3-mul-ℤ {a} {b} {c} {d} = ( associative-mul-ℤ a b (mul-ℤ c d)) ∙ ( ( ap ( mul-ℤ a) ( ( inv (associative-mul-ℤ b c d)) ∙ ( ( ap (λ t → mul-ℤ t d) (commutative-mul-ℤ b c)) ∙ ( associative-mul-ℤ c b d)))) ∙ ( inv (associative-mul-ℤ a c (mul-ℤ b d)))) interchange-1-3-mul-ℤ : {a b c d : ℤ} → Id (mul-ℤ (mul-ℤ a b) (mul-ℤ c d)) (mul-ℤ (mul-ℤ c b) (mul-ℤ a d)) interchange-1-3-mul-ℤ {a} {b} {c} {d} = ( ap (λ t → mul-ℤ t (mul-ℤ c d)) (commutative-mul-ℤ a b)) ∙ ( ( interchange-2-3-mul-ℤ {b}) ∙ ( ap (λ t → mul-ℤ t (mul-ℤ a d)) (commutative-mul-ℤ b c))) move-four-mul-ℤ : {a b c d : ℤ} → Id (mul-ℤ (mul-ℤ a b) (mul-ℤ c d)) (mul-ℤ (mul-ℤ a d) (mul-ℤ b c)) move-four-mul-ℤ {a} {b} {c} {d} = ( associative-mul-ℤ a b (mul-ℤ c d)) ∙ ( ( ap ( mul-ℤ a) ( ( inv (associative-mul-ℤ b c d)) ∙ ( commutative-mul-ℤ (mul-ℤ b c) d))) ∙ ( inv (associative-mul-ℤ a d (mul-ℤ b c)))) move-five-mul-ℤ : {a b c d : ℤ} → Id (mul-ℤ (mul-ℤ a b) (mul-ℤ c d)) (mul-ℤ (mul-ℤ b c) (mul-ℤ a d)) move-five-mul-ℤ {a} {b} {c} {d} = ( interchange-2-3-mul-ℤ {a} {b} {c} {d}) ∙ ( ( ap (λ t → mul-ℤ t (mul-ℤ b d)) (commutative-mul-ℤ a c)) ∙ ( ( interchange-2-3-mul-ℤ {c}) ∙ ( ap (λ t → mul-ℤ t (mul-ℤ a d)) (commutative-mul-ℤ c b))))
{ "alphanum_fraction": 0.5938571642, "avg_line_length": 39.6277695716, "ext": "agda", "hexsha": "de5e041d9023bc8e661bdaca13a039c97872f264", "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": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_path": "Agda/integers.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_path": "Agda/integers.agda", "max_line_length": 92, "max_stars_count": null, "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_path": "Agda/integers.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 9793, "size": 26828 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Categories.Category open import Cubical.Categories.Morphism renaming (isIso to isIsoC) open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open Iso open import Cubical.Foundations.HLevels open Precategory open import Cubical.Core.Glue open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport using (transpFill) module Cubical.Categories.Constructions.Slice {ℓ ℓ' : Level} (C : Precategory ℓ ℓ') (c : C .ob) {{isC : isCategory C}} where open import Cubical.Data.Sigma -- just a helper to prevent redundency TypeC : Type (ℓ-suc (ℓ-max ℓ ℓ')) TypeC = Type (ℓ-max ℓ ℓ') -- Components of a slice category record SliceOb : TypeC where constructor sliceob field {S-ob} : C .ob S-arr : C [ S-ob , c ] open SliceOb public record SliceHom (a b : SliceOb) : Type ℓ' where constructor slicehom field S-hom : C [ S-ob a , S-ob b ] -- commutative diagram S-comm : S-hom ⋆⟨ C ⟩ (S-arr b) ≡ S-arr a open SliceHom public -- Helpers for working with equality -- can probably replace these by showing that SliceOb is isomorphic to Sigma and -- that paths are isomorphic to Sigma? But sounds like that would need a lot of transp SliceOb-≡-intro : ∀ {a b} {f g} → (p : a ≡ b) → PathP (λ i → C [ p i , c ]) f g → sliceob {a} f ≡ sliceob {b} g SliceOb-≡-intro p q = λ i → sliceob {p i} (q i) module _ {xf yg : SliceOb} where private x = xf .S-ob f = xf .S-arr y = yg .S-ob g = yg .S-arr -- a path between slice objects is the "same" as a pair of paths between C obs and C arrows SOPathIsoPathΣ : Iso (xf ≡ yg) (Σ[ p ∈ x ≡ y ] PathP (λ i → C [ p i , c ]) f g) SOPathIsoPathΣ .fun p = (λ i → (p i) .S-ob) , (λ i → (p i) .S-arr) SOPathIsoPathΣ .inv (p , q) i = sliceob {p i} (q i) SOPathIsoPathΣ .rightInv _ = refl SOPathIsoPathΣ .leftInv _ = refl SOPath≃PathΣ = isoToEquiv SOPathIsoPathΣ SOPath≡PathΣ = ua (isoToEquiv SOPathIsoPathΣ) -- intro and elim for working with SliceHom equalities (is there a better way to do this?) SliceHom-≡-intro : ∀ {a b} {f g} {c₁} {c₂} → (p : f ≡ g) → PathP (λ i → (p i) ⋆⟨ C ⟩ (S-arr b) ≡ S-arr a) c₁ c₂ → slicehom f c₁ ≡ slicehom g c₂ SliceHom-≡-intro p q = λ i → slicehom (p i) (q i) SliceHom-≡-elim : ∀ {a b} {f g} {c₁} {c₂} → slicehom f c₁ ≡ slicehom g c₂ → Σ[ p ∈ f ≡ g ] PathP (λ i → (p i) ⋆⟨ C ⟩ (S-arr b) ≡ S-arr a) c₁ c₂ SliceHom-≡-elim r = (λ i → S-hom (r i)) , λ i → S-comm (r i) SliceHom-≡-intro' : ∀ {a b} {f g : C [ a .S-ob , b .S-ob ]} {c₁} {c₂} → (p : f ≡ g) → slicehom f c₁ ≡ slicehom g c₂ SliceHom-≡-intro' {a} {b} {f} {g} {c₁} {c₂} p i = slicehom (p i) (c₁≡c₂ i) where c₁≡c₂ : PathP (λ i → (p i) ⋆⟨ C ⟩ (b .S-arr) ≡ a .S-arr) c₁ c₂ c₁≡c₂ = isOfHLevel→isOfHLevelDep 1 (λ _ → isC .isSetHom _ _) c₁ c₂ p -- SliceHom is isomorphic to the Sigma type with the same components SliceHom-Σ-Iso : ∀ {a b} → Iso (SliceHom a b) (Σ[ h ∈ C [ S-ob a , S-ob b ] ] h ⋆⟨ C ⟩ (S-arr b) ≡ S-arr a) SliceHom-Σ-Iso .fun (slicehom h c) = h , c SliceHom-Σ-Iso .inv (h , c) = slicehom h c SliceHom-Σ-Iso .rightInv = λ x → refl SliceHom-Σ-Iso .leftInv = λ x → refl -- Precategory definition SliceCat : Precategory _ _ SliceCat .ob = SliceOb SliceCat .Hom[_,_] = SliceHom SliceCat .id (sliceob {x} f) = slicehom (C .id x) (C .⋆IdL _) SliceCat ._⋆_ {sliceob j} {sliceob k} {sliceob l} (slicehom f p) (slicehom g p') = slicehom (f ⋆⟨ C ⟩ g) ( f ⋆⟨ C ⟩ g ⋆⟨ C ⟩ l ≡⟨ C .⋆Assoc _ _ _ ⟩ f ⋆⟨ C ⟩ (g ⋆⟨ C ⟩ l) ≡⟨ cong (λ v → f ⋆⟨ C ⟩ v) p' ⟩ f ⋆⟨ C ⟩ k ≡⟨ p ⟩ j ∎) SliceCat .⋆IdL (slicehom S-hom S-comm) = SliceHom-≡-intro (⋆IdL C _) (toPathP (isC .isSetHom _ _ _ _)) SliceCat .⋆IdR (slicehom S-hom S-comm) = SliceHom-≡-intro (⋆IdR C _) (toPathP (isC .isSetHom _ _ _ _)) SliceCat .⋆Assoc f g h = SliceHom-≡-intro (⋆Assoc C _ _ _) (toPathP (isC .isSetHom _ _ _ _)) -- SliceCat is a Category instance isCatSlice : isCategory SliceCat isCatSlice .isSetHom {a} {b} (slicehom f c₁) (slicehom g c₂) p q = cong isoP p'≡q' where -- paths between SliceHoms are equivalent to the projection paths p' : Σ[ p ∈ f ≡ g ] PathP (λ i → (p i) ⋆⟨ C ⟩ (S-arr b) ≡ S-arr a) c₁ c₂ p' = SliceHom-≡-elim p q' : Σ[ p ∈ f ≡ g ] PathP (λ i → (p i) ⋆⟨ C ⟩ (S-arr b) ≡ S-arr a) c₁ c₂ q' = SliceHom-≡-elim q -- we want all paths between (dependent) paths of this type to be equal B = λ v → v ⋆⟨ C ⟩ (S-arr b) ≡ S-arr a -- need the groupoidness for dependent paths homIsGroupoidDep : isOfHLevelDep 2 B homIsGroupoidDep = isOfHLevel→isOfHLevelDep 2 (λ v x y → isSet→isGroupoid (isC .isSetHom) _ _ x y) -- we first prove that the projected paths are equal p'≡q' : p' ≡ q' p'≡q' = ΣPathP ((isC .isSetHom _ _ _ _) , toPathP (homIsGroupoidDep _ _ _ _ _)) -- and then we can use equivalence to lift these paths up -- to actual SliceHom paths isoP = λ g → cong (inv SliceHom-Σ-Iso) (fun (ΣPathIsoPathΣ) g) -- SliceCat is univalent if C is univalent module _ ⦃ isU : isUnivalent C ⦄ where open CatIso open Iso module _ { xf yg : SliceOb } where private x = xf .S-ob y = yg .S-ob -- names for the equivalences/isos pathIsoEquiv : (x ≡ y) ≃ (CatIso x y) pathIsoEquiv = univEquiv isU x y isoPathEquiv : (CatIso x y) ≃ (x ≡ y) isoPathEquiv = invEquiv pathIsoEquiv pToIIso' : Iso (x ≡ y) (CatIso x y) pToIIso' = equivToIso pathIsoEquiv -- the iso in SliceCat we're given induces an iso in C between x and y module _ ( cIso@(catiso kc lc s r) : CatIso {C = SliceCat} xf yg ) where extractIso' : CatIso {C = C} x y extractIso' .mor = kc .S-hom extractIso' .inv = lc .S-hom extractIso' .sec i = (s i) .S-hom extractIso' .ret i = (r i) .S-hom instance preservesUnivalenceSlice : isUnivalent SliceCat -- we prove the equivalence by going through Iso preservesUnivalenceSlice .univ xf@(sliceob {x} f) yg@(sliceob {y} g) = isoToIsEquiv sIso where -- this is just here because the type checker can't seem to infer xf and yg pToIIso : Iso (x ≡ y) (CatIso x y) pToIIso = pToIIso' {xf = xf} {yg} -- the meat of the proof sIso : Iso (xf ≡ yg) (CatIso xf yg) sIso .fun p = pathToIso xf yg p -- we use the normal pathToIso via path induction to get an isomorphism sIso .inv is@(catiso kc lc s r) = SliceOb-≡-intro x≡y (symP (sym (lc .S-comm) ◁ lf≡f)) where -- we get a path between xf and yg by combining paths between -- x and y, and f and g -- 1. x≡y follows from univalence of C -- 2. f≡g is more tricky; by commutativity, we know that g ≡ l ⋆ f -- so we want l to be id; we get this by showing: id ≡ pathToIso x y x≡y ≡ l -- where the first step follows from path induction, and the second from univalence of C -- morphisms in C from kc and lc k = kc .S-hom l = lc .S-hom -- extract out the iso between x and y extractIso : CatIso {C = C} x y extractIso = extractIso' is -- and we can use univalence of C to get x ≡ y x≡y : x ≡ y x≡y = pToIIso .inv extractIso -- to show that f ≡ g, we show that l ≡ id -- by using C's isomorphism pToI≡id : PathP (λ i → C [ x≡y (~ i) , x ]) (pathToIso {C = C} x y x≡y .inv) (C .id x) pToI≡id = J (λ y p → PathP (λ i → C [ p (~ i) , x ]) (pathToIso {C = C} x y p .inv) (C .id x)) (λ j → JRefl pToIFam pToIBase j .inv) x≡y where idx = C .id x pToIFam = (λ z _ → CatIso {C = C} x z) pToIBase = catiso (C .id x) idx (C .⋆IdL idx) (C .⋆IdL idx) l≡pToI : l ≡ pathToIso {C = C} x y x≡y .inv l≡pToI i = pToIIso .rightInv extractIso (~ i) .inv l≡id : PathP (λ i → C [ x≡y (~ i) , x ]) l (C .id x) l≡id = l≡pToI ◁ pToI≡id lf≡f : PathP (λ i → C [ x≡y (~ i) , c ]) (l ⋆⟨ C ⟩ f) f lf≡f = (λ i → (l≡id i) ⋆⟨ C ⟩ f) ▷ C .⋆IdL _ sIso .rightInv is@(catiso kc lc s r) i = catiso (kc'≡kc i) (lc'≡lc i) (s'≡s i) (r'≡r i) -- we prove rightInv using a combination of univalence and the fact that homs are an h-set where kc' = (sIso .fun) (sIso .inv is) .mor lc' = (sIso .fun) (sIso .inv is) .inv k' = kc' .S-hom l' = lc' .S-hom k = kc .S-hom l = lc .S-hom extractIso : CatIso {C = C} x y extractIso = extractIso' is -- we do the equality component wise -- mor k'≡k : k' ≡ k k'≡k i = (pToIIso .rightInv extractIso) i .mor kcom'≡kcom : PathP (λ j → (k'≡k j) ⋆⟨ C ⟩ g ≡ f) (kc' .S-comm) (kc .S-comm) kcom'≡kcom = isSetHomP1 _ _ λ i → (k'≡k i) ⋆⟨ C ⟩ g kc'≡kc : kc' ≡ kc kc'≡kc i = slicehom (k'≡k i) (kcom'≡kcom i) -- inv l'≡l : l' ≡ l l'≡l i = (pToIIso .rightInv extractIso) i .inv lcom'≡lcom : PathP (λ j → (l'≡l j) ⋆⟨ C ⟩ f ≡ g) (lc' .S-comm) (lc .S-comm) lcom'≡lcom = isSetHomP1 _ _ λ i → (l'≡l i) ⋆⟨ C ⟩ f lc'≡lc : lc' ≡ lc lc'≡lc i = slicehom (l'≡l i) (lcom'≡lcom i) -- sec s' = (sIso .fun) (sIso .inv is) .sec s'≡s : PathP (λ i → lc'≡lc i ⋆⟨ SliceCat ⟩ kc'≡kc i ≡ SliceCat .id _) s' s s'≡s = isSetHomP1 _ _ λ i → lc'≡lc i ⋆⟨ SliceCat ⟩ kc'≡kc i -- ret r' = (sIso .fun) (sIso .inv is) .ret r'≡r : PathP (λ i → kc'≡kc i ⋆⟨ SliceCat ⟩ lc'≡lc i ≡ SliceCat .id _) r' r r'≡r = isSetHomP1 _ _ λ i → kc'≡kc i ⋆⟨ SliceCat ⟩ lc'≡lc i sIso .leftInv p = p'≡p -- to show that the round trip is equivalent to the identity -- we show that this is true for each component (S-ob, S-arr) -- and then combine -- specifically, we show that p'Ob≡pOb and p'Mor≡pMor -- and it follows that p'≡p where p' = (sIso .inv) (sIso .fun p) pOb : x ≡ y pOb i = (p i) .S-ob p'Ob : x ≡ y p'Ob i = (p' i) .S-ob pMor : PathP (λ i → C [ pOb i , c ]) f g pMor i = (p i) .S-arr p'Mor : PathP (λ i → C [ p'Ob i , c ]) f g p'Mor i = (p' i) .S-arr -- we first show that it's equivalent to use sIso first then extract, or to extract first than use pToIIso extractCom : extractIso' (sIso .fun p) ≡ pToIIso .fun pOb extractCom = J (λ yg' p̃ → extractIso' (pathToIso xf yg' p̃) ≡ pToIIso' {xf = xf} {yg'} .fun (λ i → (p̃ i) .S-ob)) (cong extractIso' (JRefl pToIFam' pToIBase') ∙ sym (JRefl pToIFam pToIBase)) p where idx = C .id x pToIFam = (λ z _ → CatIso {C = C} x z) pToIBase = catiso (C .id x) idx (C .⋆IdL idx) (C .⋆IdL idx) idxf = SliceCat .id xf pToIFam' = (λ z _ → CatIso {C = SliceCat} xf z) pToIBase' = catiso (SliceCat .id xf) idxf (SliceCat .⋆IdL idxf) (SliceCat .⋆IdL idxf) -- why does this not follow definitionally? -- from extractCom, we get that performing the roundtrip on pOb gives us back p'Ob ppp : p'Ob ≡ (pToIIso .inv) (pToIIso .fun pOb) ppp = cong (pToIIso .inv) extractCom -- apply univalence of C -- this gives us the first component that we want p'Ob≡pOb : p'Ob ≡ pOb p'Ob≡pOb = ppp ∙ pToIIso .leftInv pOb -- isSetHom gives us the second component, path between morphisms p'Mor≡pMor : PathP (λ j → PathP (λ i → C [ (p'Ob≡pOb j) i , c ]) f g) p'Mor pMor p'Mor≡pMor = isSetHomP2l _ _ p'Mor pMor p'Ob≡pOb -- we can use the above paths to show that p' ≡ p p'≡p : p' ≡ p p'≡p i = comp (λ i' → SOPath≡PathΣ {xf = xf} {yg} (~ i')) (λ j → λ { (i = i0) → left (~ j) ; (i = i1) → right (~ j) }) (p'Σ≡pΣ i) where -- we break up p' and p into their constituent paths -- first via transport and then via our component definitions from before -- we show that p'ΣT ≡ p'Σ (and same for p) via univalence -- and p'Σ≡pΣ follows from our work from above p'ΣT : Σ[ p ∈ x ≡ y ] PathP (λ i → C [ p i , c ]) f g p'ΣT = transport SOPath≡PathΣ p' p'Σ : Σ[ p ∈ x ≡ y ] PathP (λ i → C [ p i , c ]) f g p'Σ = (p'Ob , p'Mor) pΣT : Σ[ p ∈ x ≡ y ] PathP (λ i → C [ p i , c ]) f g pΣT = transport SOPath≡PathΣ p pΣ : Σ[ p ∈ x ≡ y ] PathP (λ i → C [ p i , c ]) f g pΣ = (pOb , pMor)-- transport SOPathP≡PathPSO p -- using the computation rule to ua p'ΣT≡p'Σ : p'ΣT ≡ p'Σ p'ΣT≡p'Σ = uaβ SOPath≃PathΣ p' pΣT≡pΣ : pΣT ≡ pΣ pΣT≡pΣ = uaβ SOPath≃PathΣ p p'Σ≡pΣ : p'Σ ≡ pΣ p'Σ≡pΣ = ΣPathP (p'Ob≡pOb , p'Mor≡pMor) -- two sides of the square we're connecting left : PathP (λ i → SOPath≡PathΣ {xf = xf} {yg} i) p' p'Σ left = transport-filler SOPath≡PathΣ p' ▷ p'ΣT≡p'Σ right : PathP (λ i → SOPath≡PathΣ {xf = xf} {yg} i) p pΣ right = transport-filler SOPath≡PathΣ p ▷ pΣT≡pΣ -- properties -- TODO: move to own file open isIsoC renaming (inv to invC) -- make a slice isomorphism from just the hom sliceIso : ∀ {a b} (f : C [ a .S-ob , b .S-ob ]) (c : (f ⋆⟨ C ⟩ b .S-arr) ≡ a .S-arr) → isIsoC {C = C} f → isIsoC {C = SliceCat} (slicehom f c) sliceIso f c isof .invC = slicehom (isof .invC) (sym (invMoveL (isIso→areInv isof) c)) sliceIso f c isof .sec = SliceHom-≡-intro' (isof .sec) sliceIso f c isof .ret = SliceHom-≡-intro' (isof .ret)
{ "alphanum_fraction": 0.522739726, "avg_line_length": 38.0208333333, "ext": "agda", "hexsha": "fb2cfd3138a180c8a60c4725a80f78a67e3a4cd0", "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/Constructions/Slice.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/Constructions/Slice.agda", "max_line_length": 126, "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/Constructions/Slice.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5668, "size": 14600 }
module Reals where -- (a set with properties of) the reals data ℝ : Set where r0 : ℝ r1 : ℝ _+_ : ℝ → ℝ → ℝ -- equality data _==_ : ℝ → ℝ → Set where AXrefl== : ∀ {r} → r == r AXsymm== : ∀ {r s} → r == s → s == r AXtrans== : ∀ {r s t} → r == s → s == t → r == t AX+0 : ∀ {r} → (r + r0) == r AXsymm+ : ∀ {r s} → (r + s) == (s + r) AX+== : ∀ {r s t} → r == s → (r + t) == (s + t) THM0+ : {r : ℝ} → r == (r0 + r) THM0+ = AXsymm== (AXtrans== AXsymm+ AX+0) -- AXsymm+ AX+0 r0 + r == r + r0 and r + r0 == r -- AXtrans== so r0 + r == r -- AXsymm== so r == r0 + r THM0+alt : {r : ℝ} → r == (r0 + r) THM0+alt {r} = AXsymm== {r0 + r} {r} ((AXtrans== {r0 + r} {r + r0} {r}) (AXsymm+ {r0} {r}) (AX+0 {r})) -- strict partial ordering data _<_ : ℝ → ℝ → Set where AXtrans<<< : ∀ {r s t} → r < s → s < t → r < t AX<=< : ∀ {r s t} → r < s → s == t → r < t AX=<< : ∀ {r s t} → r == s → s < t → r < t AX0<1 : r0 < r1 AX+<< : ∀ {r s t} → r < s → (r + t) < (s + t) THM<+1 : {r : ℝ} → r < (r + r1) THM<+1 = AX<=< (AX=<< THM0+ (AX+<< AX0<1)) AXsymm+ -- AX0<1 0 < 1 -- AX<+ % so 0 + r < 1 + r -- AX=<< lem0+ % so r < 1 + r -- AX<=< % AXsymm+ so r < r + 1
{ "alphanum_fraction": 0.3654147105, "avg_line_length": 31.1707317073, "ext": "agda", "hexsha": "df4dda904ef694b748768bafe3b684924ff195df", "lang": "Agda", "max_forks_count": 66, "max_forks_repo_forks_event_max_datetime": "2022-01-18T10:12:38.000Z", "max_forks_repo_forks_event_min_datetime": "2017-01-21T21:36:16.000Z", "max_forks_repo_head_hexsha": "421132600b62845f00ced5344267775b4795df04", "max_forks_repo_licenses": [ "BSD-3-Clause", "MIT" ], "max_forks_repo_name": "jjallaire/skylighting", "max_forks_repo_path": "skylighting-core/test/cases/abc.agda", "max_issues_count": 133, "max_issues_repo_head_hexsha": "421132600b62845f00ced5344267775b4795df04", "max_issues_repo_issues_event_max_datetime": "2022-03-13T21:07:07.000Z", "max_issues_repo_issues_event_min_datetime": "2017-01-19T10:19:36.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause", "MIT" ], "max_issues_repo_name": "jjallaire/skylighting", "max_issues_repo_path": "skylighting-core/test/cases/abc.agda", "max_line_length": 104, "max_stars_count": 139, "max_stars_repo_head_hexsha": "421132600b62845f00ced5344267775b4795df04", "max_stars_repo_licenses": [ "BSD-3-Clause", "MIT" ], "max_stars_repo_name": "jjallaire/skylighting", "max_stars_repo_path": "skylighting-core/test/cases/abc.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-31T05:41:52.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-14T19:36:22.000Z", "num_tokens": 621, "size": 1278 }
-- Andreas, 2017-01-21, issue #2423 overloading inherited projections -- {-# OPTIONS -v tc.lhs.split:30 #-} -- {-# OPTIONS -v tc.proj.amb:100 #-} -- {-# OPTIONS -v tc.mod.apply:100 #-} postulate A : Set record R : Set where field f : A record S : Set where field r : R open R r public -- The inherited projection (in the eyes of the scope checker) S.f -- is actually a composition of projections R.f ∘ S.r -- s .S.f = s .S.r .R.f open S open R test : S → S test s .f = s .f -- Error WAS: -- Cannot eliminate type S with pattern .f (did you supply too many arguments?) -- NOW: -- Cannot eliminate type S with projection R.f -- Shows the chosen disambiguation in error message.
{ "alphanum_fraction": 0.6481481481, "avg_line_length": 21.2727272727, "ext": "agda", "hexsha": "cbbb62e0b4d17cf6949a48db0015ff7d289c709d", "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": "802a28aa8374f15fe9d011ceb80317fdb1ec0949", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Blaisorblade/Agda", "max_forks_repo_path": "test/Fail/Issue2423.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "802a28aa8374f15fe9d011ceb80317fdb1ec0949", "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": "Blaisorblade/Agda", "max_issues_repo_path": "test/Fail/Issue2423.agda", "max_line_length": 79, "max_stars_count": 3, "max_stars_repo_head_hexsha": "802a28aa8374f15fe9d011ceb80317fdb1ec0949", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "Blaisorblade/Agda", "max_stars_repo_path": "test/Fail/Issue2423.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": 213, "size": 702 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Morphisms between algebraic structures ------------------------------------------------------------------------ module Algebra.Morphism where open import Relation.Binary open import Algebra open import Algebra.FunctionProperties import Algebra.Properties.Group as GroupP open import Function open import Data.Product open import Level import Relation.Binary.EqReasoning as EqR ------------------------------------------------------------------------ -- Basic definitions module Definitions {f t ℓ} (From : Set f) (To : Set t) (_≈_ : Rel To ℓ) where Morphism : Set _ Morphism = From → To Homomorphic₀ : Morphism → From → To → Set _ Homomorphic₀ ⟦_⟧ ∙ ∘ = ⟦ ∙ ⟧ ≈ ∘ Homomorphic₁ : Morphism → Fun₁ From → Op₁ To → Set _ Homomorphic₁ ⟦_⟧ ∙_ ∘_ = ∀ x → ⟦ ∙ x ⟧ ≈ ∘ ⟦ x ⟧ Homomorphic₂ : Morphism → Fun₂ From → Op₂ To → Set _ Homomorphic₂ ⟦_⟧ _∙_ _∘_ = ∀ x y → ⟦ x ∙ y ⟧ ≈ (⟦ x ⟧ ∘ ⟦ y ⟧) ------------------------------------------------------------------------ -- An example showing how a morphism type can be defined -- Ring homomorphisms. record _-Ring⟶_ {r₁ r₂ r₃ r₄} (From : Ring r₁ r₂) (To : Ring r₃ r₄) : Set (r₁ ⊔ r₂ ⊔ r₃ ⊔ r₄) where private module F = Ring From module T = Ring To open Definitions F.Carrier T.Carrier T._≈_ field ⟦_⟧ : Morphism ⟦⟧-cong : ⟦_⟧ Preserves F._≈_ ⟶ T._≈_ +-homo : Homomorphic₂ ⟦_⟧ F._+_ T._+_ *-homo : Homomorphic₂ ⟦_⟧ F._*_ T._*_ 1-homo : Homomorphic₀ ⟦_⟧ F.1# T.1# open EqR T.setoid 0-homo : Homomorphic₀ ⟦_⟧ F.0# T.0# 0-homo = GroupP.left-identity-unique T.+-group ⟦ F.0# ⟧ ⟦ F.0# ⟧ (begin T._+_ ⟦ F.0# ⟧ ⟦ F.0# ⟧ ≈⟨ T.sym (+-homo F.0# F.0#) ⟩ ⟦ F._+_ F.0# F.0# ⟧ ≈⟨ ⟦⟧-cong (proj₁ F.+-identity F.0#) ⟩ ⟦ F.0# ⟧ ∎) -‿homo : Homomorphic₁ ⟦_⟧ F.-_ T.-_ -‿homo x = GroupP.left-inverse-unique T.+-group ⟦ F.-_ x ⟧ ⟦ x ⟧ (begin T._+_ ⟦ F.-_ x ⟧ ⟦ x ⟧ ≈⟨ T.sym (+-homo (F.-_ x) x) ⟩ ⟦ F._+_ (F.-_ x) x ⟧ ≈⟨ ⟦⟧-cong (proj₁ F.-‿inverse x) ⟩ ⟦ F.0# ⟧ ≈⟨ 0-homo ⟩ T.0# ∎)
{ "alphanum_fraction": 0.4757021846, "avg_line_length": 31.1527777778, "ext": "agda", "hexsha": "b17087eaffeab652908dd5ae38e6979bc3c9ba29", "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/Algebra/Morphism.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/Algebra/Morphism.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Algebra/Morphism.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": 838, "size": 2243 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Nullification.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.PathSplitEquiv open isPathSplitEquiv isNull : ∀ {ℓ ℓ'} (S : Type ℓ) (A : Type ℓ') → Type (ℓ-max ℓ ℓ') isNull S A = isPathSplitEquiv (const {A = A} {B = S}) data Null {ℓ ℓ'} (S : Type ℓ) (A : Type ℓ') : Type (ℓ-max ℓ ℓ') where ∣_∣ : A → Null S A -- the image of every map (S → Null S A) is contractible in Null S A hub : (f : S → Null S A) → Null S A spoke : (f : S → Null S A) (s : S) → hub f ≡ f s -- the image of every map (S → x ≡ y) for x y : A is contractible in x ≡ y ≡hub : ∀ {x y} (p : S → x ≡ y) → x ≡ y ≡spoke : ∀ {x y} (p : S → x ≡ y) (s : S) → ≡hub p ≡ p s isNull-Null : ∀ {ℓ ℓ'} {S : Type ℓ} {A : Type ℓ'} → isNull S (Null S A) fst (sec isNull-Null) f = hub f snd (sec isNull-Null) f i s = spoke f s i fst (secCong isNull-Null x y) p i = ≡hub (funExt⁻ p) i snd (secCong isNull-Null x y) p i j s = ≡spoke (funExt⁻ p) s i j
{ "alphanum_fraction": 0.5839622642, "avg_line_length": 40.7692307692, "ext": "agda", "hexsha": "a035eb088cef358b6d44920aa97c6435105e4fd6", "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": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/HITs/Nullification/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "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": "borsiemir/cubical", "max_issues_repo_path": "Cubical/HITs/Nullification/Base.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/HITs/Nullification/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 443, "size": 1060 }
module Numeral.Natural.Prime.Proofs.Representation where import Lvl open import Data.Either as Either using () open import Data.Tuple as Tuple using () open import Functional open import Function.Equals open import Lang.Instance open import Logic.Predicate open import Logic.Propositional open import Numeral.CoordinateVector open import Numeral.Finite open import Numeral.Natural open import Numeral.Natural.Oper open import Numeral.Natural.Prime open import Numeral.Natural.Relation open import Numeral.Natural.Relation.Divisibility open import Numeral.Natural.Relation.Divisibility.Proofs open import Numeral.Natural.Relation.Divisibility.Proofs.Product open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Structure.Relator.Equivalence.Proofs open import Structure.Relator.Properties open import Structure.Setoid renaming (_≡_ to _≡ₛ_ ; _≢_ to _≢ₛ_) open import Structure.Setoid.Uniqueness open import Syntax.Transitivity open import Type open import Type.Dependent private variable a b : ℕ record PrimePowers(f : ℕ → ℕ) : Type{Lvl.𝟎} where constructor intro field positive-powers : Σ ℕ (n ↦ Vector(n)(ℕ)) zeroes-correctness : ∀{n} → Positive(f(n)) ↔ ∃(i ↦ (Σ.right positive-powers(i) ≡ n)) prime-correctness : ∀{i} → Prime(Σ.right positive-powers(i)) product : ℕ product = foldᵣ(_⋅_)(1) (map(n ↦ n ^ f(n)) (Σ.right positive-powers)) powers-is-positive : ∀{i} → Positive(f(Σ.right positive-powers(i))) powers-is-positive = [↔]-to-[←] zeroes-correctness ([∃]-intro _ ⦃ [≡]-intro ⦄) -- postulate power-divide-product : ∀{i} → (Σ.right positive-powers i ∣ product) {-power-divide-product {pp}{i = 𝟎} = divides-with-[⋅] {b = (PrimePowers.positive-powers pp 𝟎) ^ (PrimePowers.power pp (PrimePowers.positive-powers pp 𝟎))} {c = foldᵣ(_⋅_)(1) (tail(map(n ↦ n ^ PrimePowers.power pp(n)) (PrimePowers.positive-powers pp)))} ([∨]-introₗ (divides-withᵣ-[^] ⦃ PrimePowers.powers-is-positive pp ⦄ (reflexivity(_∣_)))) power-divide-product {pp}{i = 𝐒 i} = divides-with-[⋅] {b = (PrimePowers.positive-powers pp 𝟎) ^ (PrimePowers.power pp (PrimePowers.positive-powers pp 𝟎))} {c = foldᵣ(_⋅_)(1) (tail(map(n ↦ n ^ PrimePowers.power pp(n)) (PrimePowers.positive-powers pp)))} ([∨]-introᵣ {!!}) -} instance PrimePowers-equiv : Equiv(∃ PrimePowers) Equiv._≡_ PrimePowers-equiv = (_⊜_) on₂ [∃]-witness Equiv.equivalence PrimePowers-equiv = on₂-equivalence ⦃ Equiv.equivalence [⊜]-equiv ⦄ {- -- Each positive number have a corresponding finite multiset of prime numbers such that it is equal to the product of the numbers in the multiset. -- Examples: -- n = (p₁ ^ n₁) ⋅ (p₂ ^ n₂) ⋅ … ⋅ (pₖ ^ nₖ) -- Also called: -- • Fundamental theorem of arithmetic. -- • Canonical representation of positive integers by primes. -- • Unique prime factorization theorem. prime-representation : ∀{n} → ⦃ pos : Positive(n) ⦄ → ∃! ⦃ PrimePowers-equiv ⦄ (pp ↦ (n ≡ PrimePowers.product pp)) ∃.witness (Tuple.left prime-representation) = {!!} ∃.proof (Tuple.left prime-representation) = {!!} _⊜_.proof (Tuple.right (prime-representation {𝐒 n}) {pp1} {pp2} p1 p2) {p} = {!!} -} open import Logic.Classical open import Numeral.Natural.Decidable {- prime-representation : ∀{n} → ⦃ pos : Positive(n) ⦄ → ∃! ⦃ PrimePowers-equiv ⦄ (pp ↦ (n ≡ PrimePowers.product([∃]-proof pp))) prime-representation {𝐒 n} ⦃ pos ⦄ = [∧]-intro p1 (\{x}{y} → p2{x}{y}) where p1 : ∃(pp ↦ (𝐒(n) ≡ PrimePowers.product ([∃]-proof pp))) p2 : Unique(pp ↦ (𝐒(n) ≡ PrimePowers.product ([∃]-proof pp))) p2 {[∃]-intro x ⦃ ppx ⦄}{[∃]-intro y ⦃ ppy ⦄} px py with PrimePowers.positive-powers ppx | PrimePowers.positive-powers ppy p2 {[∃]-intro x ⦃ ppx ⦄} {[∃]-intro y ⦃ ppy ⦄} px py | intro 𝟎 b | intro 𝟎 d = intro {!!} p2 {[∃]-intro x ⦃ ppx ⦄} {[∃]-intro y ⦃ ppy ⦄} px py | intro 𝟎 b | intro (𝐒 c) d = {!!} p2 {[∃]-intro x ⦃ ppx ⦄} {[∃]-intro y ⦃ ppy ⦄} px py | intro (𝐒 a) b | intro 𝟎 d = {!!} p2 {[∃]-intro x ⦃ ppx ⦄} {[∃]-intro y ⦃ ppy ⦄} px py | intro (𝐒 a) b | intro (𝐒 c) d = {!!} -- let xy = symmetry(_≡_) px 🝖 py -- in intro \{p} → {!PrimePowers.power-divide-product ppx!} -}
{ "alphanum_fraction": 0.6719014255, "avg_line_length": 45.9888888889, "ext": "agda", "hexsha": "cddfabd92b37bccf592749f3d5c30323a77fa4fb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Natural/Prime/Proofs/Representation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Natural/Prime/Proofs/Representation.agda", "max_line_length": 146, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Natural/Prime/Proofs/Representation.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": 1504, "size": 4139 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some defined operations over Rings ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- This module gives the definition of _^_ which is used throughout -- the library. It's a little different from the normal definition: -- -- x ^ zero = 1# -- x ^ suc i = x * x ^ i -- -- This is for two reasons. First, we want to avoid unnecessarily -- multiplying by 1# if possible: -- -- Standard definition: x ^ 2 = x * x * 1# -- Our definition: x ^ 2 = x * x -- -- This speeds up typechecking and makes for much more readable -- proofs. -- -- Secondly, we want to associate to the left: -- -- Standard definition: x ^ 3 = x * (x * (x * 1#)) -- Our definition: x ^ 2 = (x * x) * x -- -- As counterintuitive as it may seem, this also speeds up -- typechecking. open import Algebra module Algebra.Operations.Ring {ℓ₁ ℓ₂} (ring : RawRing ℓ₁ ℓ₂) where open import Data.Nat.Base as ℕ using (ℕ; suc; zero) open RawRing ring infixr 8 _^_+1 _^_+1 : Carrier → ℕ → Carrier x ^ zero +1 = x x ^ suc n +1 = (x ^ n +1) * x infixr 8 _^_ _^_ : Carrier → ℕ → Carrier x ^ zero = 1# x ^ suc i = x ^ i +1 {-# INLINE _^_ #-}
{ "alphanum_fraction": 0.5425940138, "avg_line_length": 25.0576923077, "ext": "agda", "hexsha": "0d783bfaa635673e2c6bcaaba1b4d217caae6c77", "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/Operations/Ring.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/Operations/Ring.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/Operations/Ring.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": 376, "size": 1303 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import Optics.All open import LibraBFT.Prelude open import LibraBFT.Lemmas open import LibraBFT.Base.PKCS open import LibraBFT.Base.Encode open import LibraBFT.Base.KVMap as KVMap open import LibraBFT.Impl.Base.Types open import LibraBFT.Impl.Consensus.Types.EpochIndep open import LibraBFT.Impl.Util.Crypto open import LibraBFT.Abstract.Types.EpochConfig UID NodeId -- This module defines the types that depend on an EpochConfig, -- but never inspect it. Consequently, we define everyting over -- an abstract 𝓔 passed around as a module parameter. -- -- Importantly, though, we are connecting abstract and concrete -- votes by defining what constitutes enough "evidence" that a -- vote was cast, which is passed around in the abstract model as -- the variable (𝓥 : VoteEvidence); here we instantiate it to -- 'ConcreteVoteEvidence'. -- -- TODO-3: update types to reflect more recent version of LibraBFT. -- This is a substantial undertaking that should probably be led by -- someone who can access our internal implementation. -- -- TODO-4: Make the Optics.Reflection stuff work with record -- parameters, so we can merge all modules back into Types. For -- now, this is the easiest way to avoid the issue that making a -- module inside Consensus.Types called EpochDep will break -- mkLens (not sure why). module LibraBFT.Impl.Consensus.Types.EpochDep (𝓔 : EpochConfig) where open EpochConfig 𝓔 open WithAbsVote 𝓔 -- A 'ConcreteVoteEvidence' is a piece of information that -- captures that the 'vd : AbsVoteData' in question was not /invented/ -- but instead, comes from a concrete vote that is /valid/ (that is, -- signature has been checked and author belongs to this epoch). -- -- Moreover, we will also store the RecordChain that leads to the vote; -- this requires some mutually-recursive shenanigans, so we first declare -- ConcreteVoteEvidence, then import the necessary modules, and then define it. record ConcreteVoteEvidence (vd : AbsVoteData) : Set open import LibraBFT.Abstract.Abstract UID _≟UID_ NodeId 𝓔 ConcreteVoteEvidence as Abs hiding (qcVotes; Vote) data VoteCoherence (v : Vote) (b : Abs.Block) : Set where initial : v ^∙ vParentId ≡ genesisUID → v ^∙ vParentRound ≡ 0 → Abs.bPrevQC b ≡ nothing → VoteCoherence v b ¬initial : ∀{b' q} → v ^∙ vParentId ≢ genesisUID → v ^∙ vParentRound ≢ 0 → v ^∙ vParentId ≡ Abs.bId b' → v ^∙ vParentRound ≡ Abs.bRound b' → (Abs.B b') ← (Abs.Q q) → (Abs.Q q) ← (Abs.B b) → VoteCoherence v b -- Estabilishing validity of a concrete vote involves checking: -- -- i) Vote author belongs to the current epoch -- ii) Vote signature is correctly verified -- iii) Existence of a RecordChain up to the voted-for block. -- iv) Coherence of 'vdParent' field with the above record chain. -- record IsValidVote (v : Vote) : Set where constructor IsValidVote∙new inductive field ₋ivvMember : Member ₋ivvAuthor : isMember? (₋vAuthor v) ≡ just ₋ivvMember ₋ivvSigned : WithVerSig (getPubKey ₋ivvMember) v ₋ivvVDhash : v ^∙ vLedgerInfo ∙ liConsensusDataHash ≡ hashVD (v ^∙ vVoteData) -- A valid vote must vote for a block that exists and is -- inserted in a RecordChain. ₋ivvBlock : Abs.Block ₋ivvBlockId : v ^∙ vProposedId ≡ Abs.bId ₋ivvBlock -- Moreover; we must check that the 'parent' field of the vote is coherent. ₋ivvCoherent : VoteCoherence v ₋ivvBlock -- Finally, the vote is for the correct epoch ₋ivvEpoch : v ^∙ vEpoch ≡ epoch ₋ivvEpoch2 : v ^∙ vParent ∙ biEpoch ≡ epoch -- Not needed? open IsValidVote public -- A valid vote can be directly mapped to an AbsVoteData. Abstraction of QCs -- and blocks will be given in LibraBFT.Concrete.Records, since those are -- more involved functions. α-ValidVote : (v : Vote) → Member → AbsVoteData α-ValidVote v mbr = AbsVoteData∙new (v ^∙ vProposed ∙ biRound) mbr (v ^∙ vProposed ∙ biId) -- α-ValidVote is the same for two votes that have the same vAuthor, vdProposed and vOrder α-ValidVote-≡ : ∀ {cv v'} {m : Member} → ₋vdProposed (₋vVoteData cv) ≡ ₋vdProposed (₋vVoteData v') → α-ValidVote cv m ≡ α-ValidVote v' m α-ValidVote-≡ {cv} {v'} prop≡ = AbsVoteData-η (cong ₋biRound prop≡) refl (cong ₋biId prop≡) -- Finally; evidence for some abstract vote consists of a concrete valid vote -- that is coherent with the abstract vote data. record ConcreteVoteEvidence vd where constructor CVE∙new inductive field ₋cveVote : Vote ₋cveIsValidVote : IsValidVote ₋cveVote ₋cveIsAbs : α-ValidVote ₋cveVote (₋ivvMember ₋cveIsValidVote) ≡ vd open ConcreteVoteEvidence public -- Gets the signature of a concrete vote evidence ₋cveSignature : ∀{vd} → ConcreteVoteEvidence vd → Signature ₋cveSignature = ₋vSignature ∘ ₋cveVote -- A valid quorum certificate contains a collection of valid votes, such that -- the members represented by those votes (which exist because the votes are valid) -- constitutes a quorum. record MetaIsValidQC (qc : QuorumCert) : Set where field ₋ivqcMetaVotesValid : All (IsValidVote ∘ rebuildVote qc) (qcVotes qc) ₋ivqcMetaIsQuorum : IsQuorum (All-reduce ₋ivvMember ₋ivqcMetaVotesValid) open MetaIsValidQC public vqcMember : (qc : QuorumCert) → MetaIsValidQC qc → ∀ {as} → as ∈ qcVotes qc → Member vqcMember qc v {α , _ , _} as∈qc with All-lookup (₋ivqcMetaVotesValid v) as∈qc ...| prf = ₋ivvMember prf -- A block tree depends on a epoch config but works regardlesss of which -- EpochConfig we have. record BlockTree : Set where constructor BlockTree∙new field ₋btIdToBlock : KVMap HashValue LinkableBlock ₋btRootId : HashValue ₋btHighestCertifiedBlockId : HashValue ₋btHighestQuorumCert : QuorumCert -- btHighestTimeoutCert : Maybe TimeoutCertificate ₋btHighestCommitCert : QuorumCert ₋btPendingVotes : PendingVotes ₋btPrunedBlockIds : List HashValue ₋btMaxPrunedBlocksInMem : ℕ ₋btIdToQuorumCert : KVMap HashValue (Σ QuorumCert MetaIsValidQC) open BlockTree public unquoteDecl btIdToBlock btRootId btHighestCertifiedBlockId btHighestQuorumCert btHighestCommitCert btPendingVotes btPrunedBlockIds btMaxPrunedBlocksInMem btIdToQuorumCert = mkLens (quote BlockTree) (btIdToBlock ∷ btRootId ∷ btHighestCertifiedBlockId ∷ btHighestQuorumCert ∷ btHighestCommitCert ∷ btPendingVotes ∷ btPrunedBlockIds ∷ btMaxPrunedBlocksInMem ∷ btIdToQuorumCert ∷ []) record BlockStore : Set where constructor BlockStore∙new field ₋bsInner : BlockTree -- bsStateComputer : StateComputer -- bsStorage : CBPersistentStorage open BlockStore public unquoteDecl bsInner = mkLens (quote BlockStore) (bsInner ∷ []) -- These are the parts of the RoundManager that depend on an -- EpochConfig. We do not particularly care which EpochConfig -- they care about yet. -- record RoundManagerWithEC : Set where constructor RoundManagerWithEC∙new field ₋epBlockStore : BlockStore open RoundManagerWithEC public unquoteDecl epBlockStore = mkLens (quote RoundManagerWithEC) (epBlockStore ∷ []) lBlockTree : Lens RoundManagerWithEC BlockTree lBlockTree = epBlockStore ∙ bsInner
{ "alphanum_fraction": 0.6817102138, "avg_line_length": 42.3227513228, "ext": "agda", "hexsha": "3e6629008e9d3d977553176f7a29780c7936943a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "cwjnkins/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Impl/Consensus/Types/EpochDep.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "cwjnkins/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Impl/Consensus/Types/EpochDep.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "cwjnkins/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Impl/Consensus/Types/EpochDep.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2345, "size": 7999 }
module Plain.Models where open import Data.Nat open import Plain.Terms -- The (complete) Herbrand universe for Σ U' : {n : ℕ} → (Signature n) → Set U' Σ = GTerm Σ open import Relation.Unary as U open import Level -- a (complete) Herbrand interpretation record Interp {n : ℕ} (Σ : Signature n) : Set₁ where field Carrier : Pred (U' Σ) Level.zero open Interp _∩ᵢ_ : {n : ℕ} → {Σ : Signature n} → Interp Σ → Interp Σ → Interp Σ i₁ ∩ᵢ i₂ = record { Carrier = (Carrier i₁) U.∩ Carrier i₂ } _∪ᵢ_ : {n : ℕ} → {Σ : Signature n} → Interp Σ → Interp Σ → Interp Σ i₁ ∪ᵢ i₂ = record { Carrier = (Carrier i₁) U.∪ Carrier i₂ } open import Data.List as L open import Data.List.All as LAl open import Data.List.Any as LAn open import Relation.Binary.Core open Program -- | Inductive model property record IsIndModel {n : ℕ} {Σ : Signature n} (i : Interp Σ) (P : Program Σ) : Set₂ where field forwClosed : (bs' : List (GTerm Σ)) → All (λ b → b ∈ Carrier i) bs' → (σ : GSubst Σ) → (a : Term Σ Var) → (bs : List (Term Σ Var)) → Any (λ cl → cl ≡ (a :- bs)) (prg P) → (L.map (app σ) bs) ≡ bs' → (app σ a ∈ Carrier i) open IsIndModel -- | Ind Model record IndModel {n : ℕ} {Σ : Signature n} (P : Program Σ) : Set₂ where field iInterp : Interp Σ isIndModel : IsIndModel iInterp P open IndModel open import Data.Product open import Data.List.All.Properties -- using (All-map) {- -- | Model intersection _∩m_ : {n : ℕ} → {Σ : Signature n} → {P : Program Σ} → (m₁ : IndModel P) → (m₂ : IndModel P) → IndModel P _∩m_ {n} {Σ} {P} m₁ m₂ = record { interp = interp m₁ ∩ᵢ interp m₂ ; isIndModel = prop-model-intersection-pair P m₁ m₂ } -} ⋂ᵢ : {n : ℕ} → {Σ : Signature n} → (I : Set) → (I → Interp Σ) → Interp Σ ⋂ᵢ I f = record { Carrier = ⋂ I (λ i t → t ∈ Carrier (f i)) } open import Function prop-model-intersection : {n : ℕ} → {Σ : Signature n} → (P : Program Σ) → (I : Set) -- ^ is non-empty by what argument? → (mps : I → IndModel P) → IsIndModel ( ⋂ᵢ I (iInterp ∘ mps)) P prop-model-intersection P I mps = record { forwClosed = λ bs' pbs' σ a bs pcl pbs i → forwClosed (isIndModel (mps i)) bs' (LAl.map (λ k → k i) pbs') σ a bs pcl pbs } -- | Coinductive model record IsCoiModel {n : ℕ} {Σ : Signature n} (i : Interp Σ) (P : Program Σ) : Set₂ where field backClosed : {a : Term Σ Var} → {bs : List (Term Σ Var)} → (a' : GTerm Σ) → a' ∈ Carrier i → ∃ (λ (σclsp : GSubst Σ × Any (λ c → a :- bs ≡ c) (prg P)) → app (proj₁ σclsp) a ≡ a' → All (λ c → c ∈ Carrier i) (L.map (app (proj₁ σclsp)) bs)) open IsCoiModel -- | Coi Model record CoiModel {n : ℕ} {Σ : Signature n} (P : Program Σ) : Set₂ where field cInterp : Interp Σ isCoiModel : IsCoiModel cInterp P open CoiModel ⋃ᵢ : {n : ℕ} → {Σ : Signature n} → (I : Set) → (I → Interp Σ) → Interp Σ ⋃ᵢ I f = record { Carrier = λ x → ⋃ I (λ i t → t ∈ Carrier (f i)) x } open import Data.Product as DP -- | model union property prop-model-union : {n : ℕ} → {Σ : Signature n} → (P : Program Σ) → (I : Set) -- ^ is non-empty by what argument? → (mps : I → CoiModel P) → IsCoiModel ( ⋃ᵢ I (cInterp ∘ mps)) P prop-model-union P I mps = record { backClosed = λ a' x → DP.map (λ id → id) (λ x₂ x₃ → LAl.map (λ x₄ → proj₁ x , x₄) (x₂ x₃)) (backClosed (isCoiModel (mps (proj₁ x))) a' (proj₂ x)) } open import Data.Unit prop-ex-ind-model : {n : ℕ} → {Σ : Signature n} → (P : Program Σ) → IndModel P prop-ex-ind-model P = record { iInterp = record { Carrier = U } ; isIndModel = record { forwClosed = λ bs' x σ a bs x₁ x₂ → tt } } open import Data.Empty prop-ex-coi-model : {n : ℕ} → {Σ : Signature n} → (P : Program Σ) → CoiModel P prop-ex-coi-model P = record { cInterp = record { Carrier = ∅ } ; isCoiModel = record { backClosed = λ a' () } }
{ "alphanum_fraction": 0.5772854596, "avg_line_length": 25.335483871, "ext": "agda", "hexsha": "08ee99a2f796bbdd557e1d7292852e3cf16b711b", "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": "411ca7970b6f64857a36ebcf648c9a58b90bb4b2", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "frantisekfarka/lp-mod", "max_forks_repo_path": "Plain/Models.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "411ca7970b6f64857a36ebcf648c9a58b90bb4b2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "frantisekfarka/lp-mod", "max_issues_repo_path": "Plain/Models.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "411ca7970b6f64857a36ebcf648c9a58b90bb4b2", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "frantisekfarka/lp-mod", "max_stars_repo_path": "Plain/Models.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1536, "size": 3927 }
import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; sym; trans; cong) open Eq.≡-Reasoning open import Data.Nat using (ℕ; zero; suc; _+_; _*_) open import Data.Nat.Properties.Simple using (+-suc) open import Data.Product using (∃; ∃-syntax; _,_) data even : ℕ → Set data odd : ℕ → Set data even where even-zero : even zero even-suc : ∀ {n : ℕ} → odd n → even (suc n) data odd where odd-suc : ∀ {n : ℕ} → even n → odd (suc n) lemma : ∀ (m : ℕ) → 2 * suc m ≡ suc (suc (2 * m)) lemma m = begin 2 * suc m ≡⟨⟩ suc m + (suc m + zero) ≡⟨⟩ suc (m + (suc (m + zero))) ≡⟨ cong suc (+-suc m (m + zero)) ⟩ suc (suc (m + (m + zero))) ≡⟨⟩ suc (suc (2 * m)) ∎ ∃-even : ∀ {n : ℕ} → even n → ∃[ m ] (2 * m ≡ n) ∃-odd : ∀ {n : ℕ} → odd n → ∃[ m ] (1 + 2 * m ≡ n) ∃-even even-zero = zero , refl ∃-even (even-suc o) with ∃-odd o ... | m , refl = suc m , lemma m ∃-odd (odd-suc e) with ∃-even e ... | m , refl = m , refl ∃-even′ : ∀ {n : ℕ} → even n → ∃[ m ] (n ≡ 2 * m) ∃-odd′ : ∀ {n : ℕ} → odd n → ∃[ m ] (n ≡ 1 + 2 * m) ∃-even′ even-zero = zero , refl ∃-even′ (even-suc o) with ∃-odd′ o ... | m , eqn rewrite eqn | +-suc m (m + 0) = suc m , {!!} ∃-odd′ (odd-suc e) with ∃-even′ e ... | m , eqn rewrite eqn = m , refl data Even : ℕ → Set where ev0 : Even zero ev2 : ∀ {n} → Even n → Even (suc (suc n)) ev-ex : ∀ {n : ℕ} → Even n → ∃[ m ] (2 * m ≡ n) ev-ex ev0 = (zero , refl) ev-ex (ev2 ev) with ev-ex ev ... | (m , refl) = (suc m , lemma m)
{ "alphanum_fraction": 0.473354232, "avg_line_length": 26.1475409836, "ext": "agda", "hexsha": "3055800aa7ad38106ec0cbeb371dcbcea77c963a", "lang": "Agda", "max_forks_count": 304, "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_path": "extra/extra/RewriteWTF.agda", "max_issues_count": 323, "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_path": "extra/extra/RewriteWTF.agda", "max_line_length": 78, "max_stars_count": 1003, "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_path": "extra/extra/RewriteWTF.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "num_tokens": 681, "size": 1595 }
{-# OPTIONS --allow-unsolved-metas #-} case_of_ : {A B : Set} → A → (A → B) → B case x of f = f x data D : Set where c : D → D postulate d : D A : Set P : A → Set record R : Set where no-eta-equality field f : A -- R : Set -- Rf : R → A data Box : Set where box : R → Box postulate f : D → Box -- pat-lam : Box → A -- pat-lam (box y) = R.f y g : D → A g x = case f x of λ { (box y) → R.f y } postulate B : Set p : P (g (c d)) p with B p | z = {!!}
{ "alphanum_fraction": 0.4866529774, "avg_line_length": 11.8780487805, "ext": "agda", "hexsha": "5f47222f2aa7ba81f20dd07357946c2c59bfbf8a", "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/Issue2193.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/Issue2193.agda", "max_line_length": 40, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2193.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": 206, "size": 487 }
{-# OPTIONS --safe #-} module Definition.Typed.Decidable where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.Consequences.Syntactic open import Definition.Conversion open import Definition.Conversion.Decidable open import Definition.Conversion.Soundness open import Definition.Conversion.Stability open import Definition.Conversion.Consequences.Completeness open import Tools.Nullary open import Tools.Product -- Decidability of conversion of well-formed types dec : ∀ {A B r Γ} → Γ ⊢ A ^ r → Γ ⊢ B ^ r → Dec (Γ ⊢ A ≡ B ^ r) dec ⊢A ⊢B = let ⊢Γ≡Γ = reflConEq (wf ⊢A) in map soundnessConv↑ completeEq (decConv↑ ⊢Γ≡Γ (completeEq (refl ⊢A)) (completeEq (refl ⊢B))) -- Decidability of conversion of well-formed terms decTerm : ∀ {t u A r Γ} → Γ ⊢ t ∷ A ^ r → Γ ⊢ u ∷ A ^ r → Dec (Γ ⊢ t ≡ u ∷ A ^ r) decTerm {r = [ ! , l ]} ⊢t ⊢u = let ⊢Γ≡Γ = reflConEq (wfTerm ⊢t) in map soundnessConv↑Term completeEqTerm (decConv↑TermConv ⊢Γ≡Γ (refl (syntacticTerm ⊢t)) (completeEqTerm (genRefl ⊢t)) (completeEqTerm (genRefl ⊢u))) decTerm {r = [ % , l ]} ⊢t ⊢u = let ⊢Γ≡Γ = reflConEq (wfTerm ⊢t) in map (λ x → proj₂ (proj₂ (soundness~↑% x))) completeEqTerm (decConv↑TermConv ⊢Γ≡Γ (refl (syntacticTerm ⊢t)) (completeEqTerm (genRefl ⊢t)) (completeEqTerm (genRefl ⊢u)))
{ "alphanum_fraction": 0.6826086957, "avg_line_length": 38.3333333333, "ext": "agda", "hexsha": "6d188c3ffa11764cc82c4aac31a888ae6c91d849", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/Typed/Decidable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/Typed/Decidable.agda", "max_line_length": 119, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/Typed/Decidable.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 490, "size": 1380 }
open import Relation.Binary using (IsDecEquivalence) open import Agda.Builtin.Equality -- module UnifyMguFTerminationHunt (FunctionName : Set) ⦃ isDecEquivalenceA : IsDecEquivalence (_≡_ {A = FunctionName}) ⦄ where module UnifyMguFTerminationHunt where postulate FunctionName : Set instance isDecEquivalenceA : IsDecEquivalence (_≡_ {A = FunctionName}) open IsDecEquivalence isDecEquivalenceA using () renaming (_≟_ to _≟F_) open import UnifyTermF FunctionName open import Data.Product using (∃; _,_) open import Data.Maybe using (Maybe; just; nothing) open import Category.Monad using (RawMonad) import Level open RawMonad (Data.Maybe.monad {Level.zero}) open import Relation.Nullary using (Dec; yes; no) open import Data.Fin using (Fin) open import Data.Nat using (suc) postulate _◃′_ : ∀ {m n} -> (f : m ~> n) -> Term m -> Term n _for'_ : ∀ {n} (t' : Term n) (x : Fin (suc n)) -> Fin (suc n) -> Term n amterm : ∀ {m} (s t : Term m) (acc : ∃ (AList m)) -> Maybe (∃ (AList m)) amterm leaf leaf acc = just acc amterm leaf (function _ _) acc = nothing amterm leaf (s' fork t') acc = nothing amterm (s' fork t') leaf acc = nothing amterm (s' fork t') (function _ _) acc = nothing amterm (s1 fork s2) (t1 fork t2) acc = amterm s2 t2 =<< amterm s1 t1 acc {- Data.Maybe.maybe (⋆amgu.amgu ⋆amguTerm' s2 t2) nothing (⋆amgu.amgu ⋆amguTerm' s1 t1 acc) -} amterm (function fn₁ ts₁) leaf acc = nothing amterm (function fn₁ {n₁} ts₁) (function fn₂ {n₂} ts₂) acc = nothing amterm (function fn₁ ts₁) (_ fork _) acc = nothing amterm (i x) (i y) (m , anil) = nothing amterm (i x) t (m , anil) = nothing amterm t (i x) (m , anil) = nothing amterm s t (n , σ asnoc r / z) = (λ σ -> σ ∃asnoc r / z) <$> -- amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ) amterm ((r for' z) ◃′ s) ((r for' z) ◃′ t) (n , σ) -- instance ⋆amguTerm' : ⋆amgu Term -- ⋆amguTerm' .⋆amgu.amgu leaf leaf acc = just acc -- ⋆amguTerm' .⋆amgu.amgu leaf (function _ _) acc = nothing -- ⋆amguTerm' .⋆amgu.amgu leaf (s' fork t') acc = nothing -- ⋆amguTerm' .⋆amgu.amgu (s' fork t') leaf acc = nothing -- ⋆amguTerm' .⋆amgu.amgu (s' fork t') (function _ _) acc = nothing -- ⋆amguTerm' .⋆amgu.amgu (s1 fork s2) (t1 fork t2) acc = amgu s2 t2 =<< amgu s1 t1 acc {- Data.Maybe.maybe (⋆amgu.amgu ⋆amguTerm' s2 t2) nothing (⋆amgu.amgu ⋆amguTerm' s1 t1 acc) -} -- ⋆amguTerm' .⋆amgu.amgu (function fn₁ ts₁) leaf acc = nothing -- ⋆amguTerm' .⋆amgu.amgu (function fn₁ {n₁} ts₁) (function fn₂ {n₂} ts₂) acc = nothing -- ⋆amguTerm' .⋆amgu.amgu (function fn₁ ts₁) (_ fork _) acc = nothing -- ⋆amguTerm' .⋆amgu.amgu (i x) (i y) (m , anil) = nothing -- ⋆amguTerm' .⋆amgu.amgu (i x) t (m , anil) = nothing -- ⋆amguTerm' .⋆amgu.amgu t (i x) (m , anil) = nothing -- ⋆amguTerm' .⋆amgu.amgu s t (n , σ asnoc r / z) = -- (λ σ -> σ ∃asnoc r / z) <$> -- -- amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ) -- amgu ((r for z) ◃′ s) ((r for z) ◃′ t) (n , σ) -- -- instance ⋆amguTerm' : ⋆amgu Term -- -- ⋆amgu.amgu ⋆amguTerm' leaf leaf acc = just acc -- -- ⋆amgu.amgu ⋆amguTerm' leaf (function _ _) acc = nothing -- -- ⋆amgu.amgu ⋆amguTerm' leaf (s' fork t') acc = nothing -- -- ⋆amgu.amgu ⋆amguTerm' (s' fork t') leaf acc = nothing -- -- ⋆amgu.amgu ⋆amguTerm' (s' fork t') (function _ _) acc = nothing -- -- ⋆amgu.amgu ⋆amguTerm' (s1 fork s2) (t1 fork t2) acc = {!amgu s2 t2 =<< amgu s1 t1 acc!} {- Data.Maybe.maybe (⋆amgu.amgu ⋆amguTerm' s2 t2) nothing (⋆amgu.amgu ⋆amguTerm' s1 t1 acc) -} -- -- ⋆amgu.amgu ⋆amguTerm' (function fn₁ ts₁) leaf acc = nothing -- -- ⋆amgu.amgu ⋆amguTerm' (function fn₁ {n₁} ts₁) (function fn₂ {n₂} ts₂) acc = nothing -- -- ⋆amgu.amgu ⋆amguTerm' (function fn₁ ts₁) (_ fork _) acc = nothing -- -- ⋆amgu.amgu ⋆amguTerm' (i x) (i y) (m , anil) = nothing -- -- ⋆amgu.amgu ⋆amguTerm' (i x) t (m , anil) = nothing -- -- ⋆amgu.amgu ⋆amguTerm' t (i x) (m , anil) = nothing -- -- ⋆amgu.amgu ⋆amguTerm' s t (n , σ asnoc r / z) = -- -- (λ σ -> σ ∃asnoc r / z) <$> -- -- -- amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ) -- -- amgu ((r for z) ◃′ s) ((r for z) ◃′ t) (n , σ) -- -- -- mutual -- -- -- instance ⋆amguTerm : ⋆amgu Term -- -- -- ⋆amgu.amgu ⋆amguTerm leaf leaf acc = just acc -- -- -- ⋆amgu.amgu ⋆amguTerm leaf (function _ _) acc = nothing -- -- -- ⋆amgu.amgu ⋆amguTerm leaf (s' fork t') acc = nothing -- -- -- ⋆amgu.amgu ⋆amguTerm (s' fork t') leaf acc = nothing -- -- -- ⋆amgu.amgu ⋆amguTerm (s' fork t') (function _ _) acc = nothing -- -- -- ⋆amgu.amgu ⋆amguTerm (s1 fork s2) (t1 fork t2) acc = -- -- -- amgu s2 t2 =<< amgu s1 t1 acc -- -- -- ⋆amgu.amgu ⋆amguTerm (function fn₁ ts₁) leaf acc = nothing -- -- -- ⋆amgu.amgu ⋆amguTerm (function fn₁ {n₁} ts₁) (function fn₂ {n₂} ts₂) acc -- -- -- with fn₁ ≟F fn₂ -- -- -- … | no _ = nothing -- -- -- … | yes _ with n₁ ≟ n₂ -- -- -- … | no _ = nothing -- -- -- … | yes refl = amgu ts₁ ts₂ acc -- -- -- ⋆amgu.amgu ⋆amguTerm (function fn₁ ts₁) (_ fork _) acc = nothing -- -- -- ⋆amgu.amgu ⋆amguTerm (i x) (i y) (m , anil) = just (flexFlex x y) -- -- -- ⋆amgu.amgu ⋆amguTerm (i x) t (m , anil) = flexRigid x t -- -- -- ⋆amgu.amgu ⋆amguTerm t (i x) (m , anil) = flexRigid x t -- -- -- ⋆amgu.amgu ⋆amguTerm s t (n , σ asnoc r / z) = -- -- -- (λ σ -> σ ∃asnoc r / z) <$> -- -- -- amgu ((r for z) ◃ s) ((r for z) ◃ t) (n , σ) -- -- -- instance ⋆amguVecTerm : ∀ {N} → ⋆amgu (flip Vec N ∘ Term) -- -- -- ⋆amgu.amgu ⋆amguVecTerm [] [] acc = just acc -- -- -- ⋆amgu.amgu ⋆amguVecTerm (t₁ ∷ t₁s) (t₂ ∷ t₂s) acc = amgu t₁s t₂s =<< amgu t₁ t₂ acc -- -- -- mgu : ∀ {m} -> (s t : Term m) -> Maybe (∃ (AList m)) -- -- -- mgu {m} s t = amgu s t (m , anil)
{ "alphanum_fraction": 0.5688105118, "avg_line_length": 49.4358974359, "ext": "agda", "hexsha": "219b0765e28a519c64c50e4da0c21a0c491f2e4f", "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/UnifyMguFTerminationHunt.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/UnifyMguFTerminationHunt.agda", "max_line_length": 188, "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/UnifyMguFTerminationHunt.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2494, "size": 5784 }
{-# OPTIONS --without-K #-} module SEquivSCPermEquiv where open import Level using (Level; _⊔_) open import Data.Fin using (Fin) open import Data.Product using (_,_; proj₁; proj₂) open import Data.Vec using (tabulate) open import Function using (_∘_; id) open import Data.Vec.Properties using (lookup∘tabulate) open import Relation.Binary using (Setoid) open import Function.Equality using (_⟨$⟩_; _⟶_) renaming (_∘_ to _⊚_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; module ≡-Reasoning) -- open import Proofs using (_!!_; finext) open import Equiv using (_≃_; qinv; module isqinv) open import EquivEquiv using (_S≃_; eq; _≋_; id≋) open import ConcretePermutation using (CPerm; cp; _∘̂_; 1C; cauchyext; SCPerm) open import ConcretePermutationProperties using (p≡) -- infix 4 _≃S_ ------------------------------------------------------------------------------ -- The big (semantic) theorem! -- On one side we have the setoid of permutations under ≡ -- On the other we have the setoid of equivalences under ≋ -- -- The regular equivalence ≃ relates sets. To relate the above two -- setoids, this regular equivalence is generalized to an equivalence -- ≃S that relates setoids each with its own equivalence relation. record _≃S_ {ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level} (A : Setoid ℓ₁ ℓ₂) (B : Setoid ℓ₃ ℓ₄) : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) where constructor equiv field f : A ⟶ B g : B ⟶ A α : ∀ {x y} → Setoid._≈_ B x y → Setoid._≈_ B ((f ⊚ g) ⟨$⟩ x) y β : ∀ {x y} → Setoid._≈_ A x y → Setoid._≈_ A ((g ⊚ f) ⟨$⟩ x) y -- Big theorem univalence : ∀ {m n} → (SCPerm m n) ≃S (Fin m S≃ Fin n) univalence {m} {n} = equiv fwd bwd α β where fwd' : (CPerm m n) → (Fin m ≃ Fin n) fwd' (cp π πᵒ αp βp) = (λ m → πᵒ !! m) , let index = (λ n → π !! n) in qinv index pf₁ pf₂ where open ≡-Reasoning pf₁ : ∀ m → πᵒ !! (π !! m) ≡ m pf₁ m = begin ( πᵒ !! (π !! m) ≡⟨ sym (lookup∘tabulate (λ x → πᵒ !! (π !! x)) m) ⟩ (π ∘̂ πᵒ) !! m ≡⟨ cong (λ x → x !! m) αp ⟩ 1C !! m ≡⟨ lookup∘tabulate id m ⟩ m ∎) pf₂ : ∀ m → π !! (πᵒ !! m) ≡ m pf₂ m = begin ( π !! (πᵒ !! m) ≡⟨ sym (lookup∘tabulate (λ x → π !! (πᵒ !! x)) m) ⟩ (πᵒ ∘̂ π) !! m ≡⟨ cong (λ x → x !! m) βp ⟩ 1C !! m ≡⟨ lookup∘tabulate id m ⟩ m ∎) bwd' : (Fin m ≃ Fin n) → (CPerm m n) bwd' (f , qinv g α β) = cp (tabulate g) (tabulate f) g∘̂f≡1C f∘̂g≡1C where open ≡-Reasoning g∘̂f≡1C : tabulate g ∘̂ tabulate f ≡ 1C g∘̂f≡1C = finext (λ i → begin ( tabulate f !! (tabulate g !! i) ≡⟨ lookup∘tabulate f (tabulate g !! i) ⟩ f (tabulate g !! i) ≡⟨ cong f (lookup∘tabulate g i) ⟩ f (g i) ≡⟨ α i ⟩ i ∎)) f∘̂g≡1C : tabulate f ∘̂ tabulate g ≡ 1C f∘̂g≡1C = finext (λ i → begin ( tabulate g !! (tabulate f !! i) ≡⟨ lookup∘tabulate g (tabulate f !! i) ⟩ g (tabulate f !! i) ≡⟨ cong g (lookup∘tabulate f i) ⟩ g (f i) ≡⟨ β i ⟩ i ∎)) fwd : (SCPerm m n) ⟶ (Fin m S≃ Fin n) fwd = record { _⟨$⟩_ = fwd' ; cong = λ { {π} {.π} refl → id≋ } } bwd : (Fin m S≃ Fin n) ⟶ (SCPerm m n) bwd = record { _⟨$⟩_ = bwd' ; cong = λ eq₁≋eq₂ → p≡ (finext (_≋_.g≡ eq₁≋eq₂)) } α : {eq₁ eq₂ : Fin m ≃ Fin n} → eq₁ ≋ eq₂ → (fwd ⊚ bwd ⟨$⟩ eq₁) ≋ eq₂ α {eq₁} {eq₂} eq₁≋eq₂ = eq (λ x → trans (lookup∘tabulate (proj₁ eq₁) x) (_≋_.f≡ eq₁≋eq₂ x)) (λ x → trans (lookup∘tabulate (isqinv.g (proj₂ eq₁)) x) (_≋_.g≡ eq₁≋eq₂ x)) β : {π₁ π₂ : CPerm m n} → π₁ ≡ π₂ → (bwd ⊚ fwd ⟨$⟩ π₁) ≡ π₂ β {π} {.π} refl = p≡ (cauchyext (CPerm.π π))
{ "alphanum_fraction": 0.4790492526, "avg_line_length": 32.3888888889, "ext": "agda", "hexsha": "72ebdac0951b57bf72abc812dada0b1572edbfee", "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/SEquivSCPermEquiv.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/SEquivSCPermEquiv.agda", "max_line_length": 86, "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/SEquivSCPermEquiv.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": 1597, "size": 4081 }
{-# OPTIONS --without-K #-} open import Base {- This file contains the lemma that a point (1 -> A) has n-connected fibers if A is (S n)-connected. The other direction will be added whenever it is needed. -} module Homotopy.PointConnected {i} (A : Set i) (a : A) where open import Homotopy.Connected open import Homotopy.Truncation open import Homotopy.PathTruncation point : unit {i} → A point _ = a abstract point-has-connected-fibers : ∀ {n} → is-connected (S n) A → has-connected-fibers n point point-has-connected-fibers {n} A-is-conn a₂ = center [a≡a₂]n , path where [a≡a₂]n : τ n (a ≡ a₂) [a≡a₂]n = connected-has-all-τ-paths A-is-conn a a₂ center : τ n (a ≡ a₂) → τ n (hfiber point a₂) center = τ-extend-nondep ⦃ τ-is-truncated n _ ⦄ (λ shift → proj $ tt , shift) path′ : ∀ f → proj f ≡ center [a≡a₂]n path′ (tt , a≡a₂) = ap center $ contr-has-all-paths (connected-has-connected-paths A-is-conn a a₂) (proj a≡a₂) [a≡a₂]n path : ∀ f → f ≡ center [a≡a₂]n path = τ-extend ⦃ λ _ → ≡-is-truncated n $ τ-is-truncated n _ ⦄ path′
{ "alphanum_fraction": 0.589787234, "avg_line_length": 28.6585365854, "ext": "agda", "hexsha": "31ae06f50dcc946b15b2fb26c2a3b410e52c30d7", "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/PointConnected.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/PointConnected.agda", "max_line_length": 77, "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/PointConnected.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": 417, "size": 1175 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Morphisms between algebraic structures ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Relation.Binary.Core module Algebra.Morphism.Structures where open import Algebra.Core open import Algebra.Bundles import Algebra.Morphism.Definitions as MorphismDefinitions open import Level using (Level; _⊔_) import Function.Definitions as FunctionDefinitions open import Relation.Binary.Morphism.Structures private variable a b ℓ₁ ℓ₂ : Level ------------------------------------------------------------------------ -- Morphisms over magma-like structures ------------------------------------------------------------------------ module MagmaMorphisms (M₁ : RawMagma a ℓ₁) (M₂ : RawMagma b ℓ₂) where open RawMagma M₁ renaming (Carrier to A; _≈_ to _≈₁_; _∙_ to _∙_) open RawMagma M₂ renaming (Carrier to B; _≈_ to _≈₂_; _∙_ to _◦_) open MorphismDefinitions A B _≈₂_ open FunctionDefinitions _≈₁_ _≈₂_ record IsMagmaHomomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where field isRelHomomorphism : IsRelHomomorphism _≈₁_ _≈₂_ ⟦_⟧ homo : Homomorphic₂ ⟦_⟧ _∙_ _◦_ open IsRelHomomorphism isRelHomomorphism public renaming (cong to ⟦⟧-cong) record IsMagmaMonomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where field isMagmaHomomorphism : IsMagmaHomomorphism ⟦_⟧ injective : Injective ⟦_⟧ open IsMagmaHomomorphism isMagmaHomomorphism public isRelMonomorphism : IsRelMonomorphism _≈₁_ _≈₂_ ⟦_⟧ isRelMonomorphism = record { isHomomorphism = isRelHomomorphism ; injective = injective } record IsMagmaIsomorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field isMagmaMonomorphism : IsMagmaMonomorphism ⟦_⟧ surjective : Surjective ⟦_⟧ open IsMagmaMonomorphism isMagmaMonomorphism public isRelIsomorphism : IsRelIsomorphism _≈₁_ _≈₂_ ⟦_⟧ isRelIsomorphism = record { isMonomorphism = isRelMonomorphism ; surjective = surjective } ------------------------------------------------------------------------ -- Morphisms over monoid-like structures ------------------------------------------------------------------------ module MonoidMorphisms (M₁ : RawMonoid a ℓ₁) (M₂ : RawMonoid b ℓ₂) where open RawMonoid M₁ renaming (Carrier to A; _≈_ to _≈₁_; _∙_ to _∙_; ε to ε₁) open RawMonoid M₂ renaming (Carrier to B; _≈_ to _≈₂_; _∙_ to _◦_; ε to ε₂) open MorphismDefinitions A B _≈₂_ open FunctionDefinitions _≈₁_ _≈₂_ open MagmaMorphisms (RawMonoid.rawMagma M₁) (RawMonoid.rawMagma M₂) record IsMonoidHomomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where field isMagmaHomomorphism : IsMagmaHomomorphism ⟦_⟧ ε-homo : Homomorphic₀ ⟦_⟧ ε₁ ε₂ open IsMagmaHomomorphism isMagmaHomomorphism public record IsMonoidMonomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where field isMonoidHomomorphism : IsMonoidHomomorphism ⟦_⟧ injective : Injective ⟦_⟧ open IsMonoidHomomorphism isMonoidHomomorphism public isMagmaMonomorphism : IsMagmaMonomorphism ⟦_⟧ isMagmaMonomorphism = record { isMagmaHomomorphism = isMagmaHomomorphism ; injective = injective } open IsMagmaMonomorphism isMagmaMonomorphism public using (isRelMonomorphism) record IsMonoidIsomorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field isMonoidMonomorphism : IsMonoidMonomorphism ⟦_⟧ surjective : Surjective ⟦_⟧ open IsMonoidMonomorphism isMonoidMonomorphism public isMagmaIsomorphism : IsMagmaIsomorphism ⟦_⟧ isMagmaIsomorphism = record { isMagmaMonomorphism = isMagmaMonomorphism ; surjective = surjective } open IsMagmaIsomorphism isMagmaIsomorphism public using (isRelIsomorphism) ------------------------------------------------------------------------ -- Morphisms over group-like structures ------------------------------------------------------------------------ module GroupMorphisms (G₁ : RawGroup a ℓ₁) (G₂ : RawGroup b ℓ₂) where open RawGroup G₁ renaming (Carrier to A; _≈_ to _≈₁_; _∙_ to _∙_; _⁻¹ to _⁻¹₁; ε to ε₁) open RawGroup G₂ renaming (Carrier to B; _≈_ to _≈₂_; _∙_ to _◦_; _⁻¹ to _⁻¹₂; ε to ε₂) open MorphismDefinitions A B _≈₂_ open FunctionDefinitions _≈₁_ _≈₂_ open MagmaMorphisms (RawGroup.rawMagma G₁) (RawGroup.rawMagma G₂) open MonoidMorphisms (RawGroup.rawMonoid G₁) (RawGroup.rawMonoid G₂) record IsGroupHomomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where field isMonoidHomomorphism : IsMonoidHomomorphism ⟦_⟧ ⁻¹-homo : Homomorphic₁ ⟦_⟧ _⁻¹₁ _⁻¹₂ open IsMonoidHomomorphism isMonoidHomomorphism public record IsGroupMonomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where field isGroupHomomorphism : IsGroupHomomorphism ⟦_⟧ injective : Injective ⟦_⟧ open IsGroupHomomorphism isGroupHomomorphism renaming (homo to ∙-homo) public isMonoidMonomorphism : IsMonoidMonomorphism ⟦_⟧ isMonoidMonomorphism = record { isMonoidHomomorphism = isMonoidHomomorphism ; injective = injective } open IsMonoidMonomorphism isMonoidMonomorphism public using (isRelMonomorphism) record IsGroupIsomorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field isGroupMonomorphism : IsGroupMonomorphism ⟦_⟧ surjective : Surjective ⟦_⟧ open IsGroupMonomorphism isGroupMonomorphism public isMonoidIsomorphism : IsMonoidIsomorphism ⟦_⟧ isMonoidIsomorphism = record { isMonoidMonomorphism = isMonoidMonomorphism ; surjective = surjective } open IsMonoidIsomorphism isMonoidIsomorphism public using (isRelIsomorphism) ------------------------------------------------------------------------ -- Morphisms over ring-like structures ------------------------------------------------------------------------ module RingMorphisms (R₁ : RawRing a ℓ₁) (R₂ : RawRing b ℓ₂) where open RawRing R₁ renaming ( Carrier to A; _≈_ to _≈₁_ ; *-rawMonoid to *-rawMonoid₁ ; +-rawGroup to +-rawGroup₁) open RawRing R₂ renaming ( Carrier to B; _≈_ to _≈₂_ ; *-rawMonoid to *-rawMonoid₂ ; +-rawGroup to +-rawGroup₂) module + = GroupMorphisms +-rawGroup₁ +-rawGroup₂ module * = MonoidMorphisms *-rawMonoid₁ *-rawMonoid₂ open MorphismDefinitions A B _≈₂_ open FunctionDefinitions _≈₁_ _≈₂_ record IsRingHomomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where field +-isGroupHomomorphism : +.IsGroupHomomorphism ⟦_⟧ *-isMonoidHomomorphism : *.IsMonoidHomomorphism ⟦_⟧ open +.IsGroupHomomorphism +-isGroupHomomorphism renaming (homo to +-homo; ε-homo to 0#-homo) public open *.IsMonoidHomomorphism *-isMonoidHomomorphism renaming (homo to *-homo; ε-homo to 1#-homo) public record IsRingMonomorphism (⟦_⟧ : A → B) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where field isRingHomomorphism : IsRingHomomorphism ⟦_⟧ injective : Injective ⟦_⟧ open IsRingHomomorphism isRingHomomorphism public +-isGroupMonomorphism : +.IsGroupMonomorphism ⟦_⟧ +-isGroupMonomorphism = record { isGroupHomomorphism = +-isGroupHomomorphism ; injective = injective } *-isMonoidMonomorphism : *.IsMonoidMonomorphism ⟦_⟧ *-isMonoidMonomorphism = record { isMonoidHomomorphism = *-isMonoidHomomorphism ; injective = injective } open *.IsMonoidMonomorphism *-isMonoidMonomorphism public using (isRelMonomorphism) record IsRingIsomorphism (⟦_⟧ : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where field isRingMonomorphism : IsRingMonomorphism ⟦_⟧ surjective : Surjective ⟦_⟧ open IsRingMonomorphism isRingMonomorphism public +-isGroupIsomorphism : +.IsGroupIsomorphism ⟦_⟧ +-isGroupIsomorphism = record { isGroupMonomorphism = +-isGroupMonomorphism ; surjective = surjective } *-isMonoidIsomorphism : *.IsMonoidIsomorphism ⟦_⟧ *-isMonoidIsomorphism = record { isMonoidMonomorphism = *-isMonoidMonomorphism ; surjective = surjective } open *.IsMonoidIsomorphism *-isMonoidIsomorphism public using (isRelIsomorphism) ------------------------------------------------------------------------ -- Re-export contents of modules publicly open MagmaMorphisms public open MonoidMorphisms public open GroupMorphisms public open RingMorphisms public
{ "alphanum_fraction": 0.6212521539, "avg_line_length": 32.9734848485, "ext": "agda", "hexsha": "2858e9f79f6a3235df149a0ec3b3fa453665c923", "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/Morphism/Structures.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/Morphism/Structures.agda", "max_line_length": 77, "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/Morphism/Structures.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": 2812, "size": 8705 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.SmashProduct.Base where open import Cubical.Foundations.Prelude -- This should be upstreamed to Basics when we develop some theory -- about pointed types ptType : Type₁ ptType = Σ[ A ∈ Type₀ ] A pt : ∀ (A : ptType) → A .fst pt A = A .snd data Smash (A B : ptType) : Type₀ where basel : Smash A B baser : Smash A B proj : (x : A .fst) → (y : B .fst) → Smash A B gluel : (a : A .fst) → proj a (pt B) ≡ basel gluer : (b : B .fst) → proj (pt A) b ≡ baser -- Commutativity comm : {A B : ptType} → Smash A B → Smash B A comm basel = baser comm baser = basel comm (proj x y) = proj y x comm (gluel a i) = gluer a i comm (gluer b i) = gluel b i commK : ∀ {A B : ptType} → (x : Smash A B) → comm (comm x) ≡ x commK basel = refl commK baser = refl commK (proj x y) = refl commK (gluel a x) = refl commK (gluer b x) = refl -- WIP below SmashPt : (A B : ptType) → ptType SmashPt A B = (Smash A B , basel) -- -- A (B C) = C (B A) = C (A B) = (A B) C -- rearrange : ∀ {A B C : ptType} → Smash A (SmashPt B C) → Smash C (SmashPt B A) -- rearrange basel = baser -- rearrange baser = basel -- rearrange {B = B} {C = C} (proj x basel) = proj (C .snd) baser -- rearrange {C = C} (proj x baser) = proj (C .snd) basel -- ? -- rearrange (proj x (proj y z)) = proj z (proj y x) -- rearrange {C = C} (proj x (gluel a i)) = proj (C .snd) {!!} -- rearrange (proj x (gluer b i)) = {!!} -- rearrange (gluel a i) = {!!} -- rearrange (gluer b i) = {!gluel ? i!}
{ "alphanum_fraction": 0.5792563601, "avg_line_length": 28.9245283019, "ext": "agda", "hexsha": "d244501446737117e392689211686e70f2413365", "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/HITs/SmashProduct/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/HITs/SmashProduct/Base.agda", "max_line_length": 81, "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/HITs/SmashProduct/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 601, "size": 1533 }
module ListThms where open import Sec4 import Sec2 {- Definition of a list -} data List (A : Set) : Set where [] : List A -- Empty list _∷_ : A → List A → List A -- Cons infixr 4 _∷_ -- Proposition stating what is a non empty list nelist : {A : Set} → (List A) → Prop nelist [] = ⊥ nelist (x ∷ x₁) = ⊤ -- Head function that only works on non empty list head : {A : Set} → (l : List A) → (p : nelist l) → A head [] () -- This can never happen head (x ∷ _) ⋆ = x -- This is the head of the list -- The tail of the list only works on non empty list tail : {A : Set} → (l : List A) → (p : nelist l) → (List A) tail [] () tail (_ ∷ l) ⋆ = l -- definition of a map map : {A B : Set} → (A → B) → (List A) → List B map f [] = [] map f (x ∷ l) = (f x) ∷ map f l -- definition of fold left fold : {A B : Set} → (A → B → B) → B → (List A) → B fold f x [] = x fold f x (x₁ ∷ l) = fold f (f x₁ x) l -- reduce only works on lists of length > 0 reduce : {A : Set} → (l : List A) → (p : nelist l) → (A → A → A) → A reduce [] () reduce (x ∷ l) _ f = fold f x l -- length of a list length : {A : Set} → (List A) → Sec2.ℕ length [] = Sec2.Z length (x ∷ l) = (Sec2.S Sec2.Z) Sec2.+ (length l) -- Proposition on ≤ _<=_ : Sec2.ℕ → Sec2.ℕ → Prop Sec2.Z <= Sec2.Z = ⊤ Sec2.Z <= Sec2.S y = ⊤ Sec2.S x <= y = x <= y _>=_ : Sec2.ℕ → Sec2.ℕ → Prop Sec2.Z >= Sec2.Z = ⊤ Sec2.Z >= Sec2.S y = ⊥ Sec2.S x >= y = x >= y -- Indexing into the list _!!_ : {A : Set} → ∀ (l : List A) → ∀ (i : Sec2.ℕ) → (nelist l) → Exists A (λ _ → ((i >= Sec2.Z) ∧ (i <= (length l)))) ([] !! i) () ((x ∷ l) !! i) ⋆ = [ x , (and (lem1 i) (lem (x ∷ l) i))] where cong-<= : (x y : Sec2.ℕ) → (x <= y) → (x <= Sec2.S y) cong-<= Sec2.Z y p = ⋆ cong-<= (Sec2.S x) Sec2.Z p = cong-<= x Sec2.Z p cong-<= (Sec2.S x) (Sec2.S y) p = cong-<= x (Sec2.S y) p lem1 : (i : Sec2.ℕ) → (i >= Sec2.Z) lem1 Sec2.Z = ⋆ lem1 (Sec2.S i) = lem1 i lem2 : (i : Sec2.ℕ) → (i <= Sec2.Z) lem2 Sec2.Z = ⋆ lem2 (Sec2.S i₁) = lem2 i₁ lem : {A : Set} → (l : List A) → (i : Sec2.ℕ) → (i <= (length l)) lem [] Sec2.Z = ⋆ lem [] (Sec2.S i) = lem2 i lem (x₁ ∷ l₁) i = cong-<= i (length l₁) (lem l₁ i) data Maybe (A : Set) : Set where Nothing : Maybe A Just : A → Maybe A index : {A : Set} → ∀ (l : List A) → (nelist l) → ∀ (i : Sec2.ℕ) → Sec2.So ((i Sec2.≥ Sec2.Z) Sec2.& (i Sec2.< (length l))) → Maybe A index l _ i _ = index' l i (Sec2.Z) where index' : {A : Set} → ∀ (l : List A) → ∀(i : Sec2.ℕ) → (c : Sec2.ℕ) → Maybe A index' [] i₁ c = Nothing index' (x₁ ∷ l₁) i₁ c with (i₁ Sec2.== c) index' (x₁ ∷ l₁) i₁ c | Sec2.T = Just x₁ index' (x₁ ∷ l₁) i₁ c | Sec2.F = index' l₁ i₁ (Sec2.S c) exx1 : Maybe Sec2.ℕ exx1 = index (1 ∷ []) ⋆ 0 Sec2.ok index'' : {A : Set} → ∀ (l : List A) → ∀ (i : Sec2.ℕ) → Sec2.So (i Sec2.< (length l)) → A index'' [] Sec2.Z () index'' [] (Sec2.S i) () index'' (x ∷ l) Sec2.Z Sec2.ok = x index'' (x ∷ l) (Sec2.S i) p = index'' l i p -- append two lists _++_ : {A : Set} → (l : List A) → (l' : List A) → (List A) [] ++ l' = l' (x ∷ l) ++ l' = (x ∷ (l ++ l')) -- composition of two functions _∘_ : {A B C : Set} → (A → B) → (B → C) → (A → C) f ∘ g = λ x → (g (f x)) cong : {A : Set} → (x : A) → (l m : List A) → (l Sec2.≡ m) → (x ∷ l) Sec2.≡ (x ∷ m) cong x l .l Sec2.refl = Sec2.refl cong2 : {A : Set} → (l m q : List A) → (l Sec2.≡ m) → (l ++ q) Sec2.≡ (m ++ q) cong2 l .l q Sec2.refl = Sec2.refl thm1-map : {A B : Set} → (f : A → B) → (l : List A) → (m : List A) → (map f (l ++ m)) Sec2.≡ (map f l) ++ (map f m) thm1-map f [] m = Sec2.refl thm1-map f (x ∷ l) m with (f x) thm1-map f (x ∷ l) m | p = cong p (map f (l ++ m)) (map f l ++ map f m) (thm1-map f l m) -- map ∘ thm2-map : {A B C : Set} → (f : A → B) → (g : B → C) → (l : List A) → (map (f ∘ g) l Sec2.≡ ((map f) ∘ (map g)) l) thm2-map f₁ g₁ [] = Sec2.refl thm2-map f₁ g₁ (x ∷ l) with (thm2-map f₁ g₁ l) thm2-map f₁ g₁ (x ∷ l) | p = cong (g₁ (f₁ x)) (map (λ z → g₁ (f₁ z)) l) (map g₁ (map f₁ l)) p -- Non empty list by construction data NeList (A : Set) : Set where ^_^ : A → NeList A _∶_ : A → NeList A → NeList A infixr 60 ^_^ infixr 60 _∶_ -- XXX: Prove these in Coq along with the other theorem from Mike Naha's -- tutorial in Agda.
{ "alphanum_fraction": 0.4757412399, "avg_line_length": 28, "ext": "agda", "hexsha": "95cbd3fa5e9fb035b3cac057b91352c02147cd04", "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": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "amal029/agda-tutorial-dybjer", "max_forks_repo_path": "ListThms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "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": "amal029/agda-tutorial-dybjer", "max_issues_repo_path": "ListThms.agda", "max_line_length": 115, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "amal029/agda-tutorial-dybjer", "max_stars_repo_path": "ListThms.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:52:30.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:52:30.000Z", "num_tokens": 1961, "size": 4452 }
{-# OPTIONS --cubical --safe #-} module Data.Empty.Properties where open import Data.Empty.Base open import Cubical.Data.Empty using (isProp⊥) public open import Level open import HLevels isProp¬ : (A : Type a) → isProp (¬ A) isProp¬ _ f g i x = isProp⊥ (f x) (g x) i
{ "alphanum_fraction": 0.6900369004, "avg_line_length": 22.5833333333, "ext": "agda", "hexsha": "21267743cef64da8b5701d29ba5cd9bf69a6b719", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z", "max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/Data/Empty/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/Data/Empty/Properties.agda", "max_line_length": 53, "max_stars_count": 4, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/Data/Empty/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z", "num_tokens": 87, "size": 271 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Category.Topos {o ℓ e} (C : Category o ℓ e) where open import Level open import Categories.Category.CartesianClosed C open import Categories.Category.Complete.Finitely C open import Categories.Diagram.Equalizer C open import Categories.Diagram.SubobjectClassifier C open Category C record Topos : Set (levelOfTerm C) where field cartesianClosed : CartesianClosed subobjectClassifier : SubobjectClassifier equalizer : ∀ {A B} (f g : A ⇒ B) → Equalizer f g open CartesianClosed cartesianClosed public module subobjectClassifier = SubobjectClassifier subobjectClassifier finitelyComplete : FinitelyComplete finitelyComplete = record { cartesian = cartesian ; equalizer = equalizer } open FinitelyComplete finitelyComplete using (module equalizer; pullback) public
{ "alphanum_fraction": 0.761589404, "avg_line_length": 27.4545454545, "ext": "agda", "hexsha": "470f44003661c74c2e4b5be02beb47f71f90c573", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_path": "Categories/Category/Topos.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_path": "Categories/Category/Topos.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_path": "Categories/Category/Topos.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 212, "size": 906 }
------------------------------------------------------------------------------ -- Axiomatic PA propositional equality ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module PA.Axiomatic.Mendelson.Relation.Binary.PropositionalEqualityI where open import PA.Axiomatic.Mendelson.Base ------------------------------------------------------------------------------ -- Identity properties ≈-refl : ∀ {n} → n ≈ n ≈-refl {n} = S₁ (S₅ n) (S₅ n) ≈-sym : ∀ {m n} → m ≈ n → n ≈ m ≈-sym h = S₁ h ≈-refl ≈-trans : ∀ {m n o} → m ≈ n → n ≈ o → m ≈ o ≈-trans h = S₁ (≈-sym h) ------------------------------------------------------------------------------ -- Substitution -- Using Mendelson's axioms we cannot prove -- a ≈ b A(x) -- ----------------- substitution -- A(x) -- where A(x) is an arbitrary propositional function, We can prove -- substitutivity of `_≈_` for the proper functional symbols of the -- language (`succ`, `add` and `mult`). That is, we can prove (by -- induction) -- succCong : ∀ {m n} → m ≈ n → succ m ≈ succ n -- +-rightCong : ∀ {m n p} → n ≈ p → m + n ≈ m + p -- +-leftCong : ∀ {m n p} → m ≈ n → m + p ≈ n + p -- *-rightCong : ∀ {m n p} → n ≈ p → m * n ≈ m * p -- *-leftCong : ∀ {m n p} → m ≈ n → m * p ≈ n * p -- The proofs of the above properties are in the `PropertiesI` module.
{ "alphanum_fraction": 0.4290364583, "avg_line_length": 32.6808510638, "ext": "agda", "hexsha": "a21ba5ab5cbaf51f0413dea27f8fb3da03cceac6", "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/PA/Axiomatic/Mendelson/Relation/Binary/PropositionalEqualityI.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/PA/Axiomatic/Mendelson/Relation/Binary/PropositionalEqualityI.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/PA/Axiomatic/Mendelson/Relation/Binary/PropositionalEqualityI.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": 445, "size": 1536 }
{-# OPTIONS --without-K #-} module Lecture7 where import Lecture6 open Lecture6 public -- Section 7.1 Fiberwise equivalences tot : {i j k : Level} {A : UU i} {B : A → UU j} {C : A → UU k} → ((x : A) → B x → C x) → ( Σ A B → Σ A C) tot f (dpair x y) = dpair x (f x y) -- There is a function from the fibers of the induced map on total spaces, to the fibers of the fiberwise transformation fib-ftr-fib-tot : {i j k : Level} {A : UU i} {B : A → UU j} {C : A → UU k} → (f : (x : A) → B x → C x) → (t : Σ A C) → fib (tot f) t → fib (f (pr1 t)) (pr2 t) fib-ftr-fib-tot f .(dpair x (f x y)) (dpair (dpair x y) refl) = dpair y refl -- This function has a converse fib-tot-fib-ftr : {i j k : Level} {A : UU i} {B : A → UU j} {C : A → UU k} → (f : (x : A) → B x → C x) → (t : Σ A C) → fib (f (pr1 t)) (pr2 t) → fib (tot f) t fib-tot-fib-ftr F (dpair a .(F a y)) (dpair y refl) = dpair (dpair a y) refl issec-fib-tot-fib-ftr : {i j k : Level} {A : UU i} {B : A → UU j} {C : A → UU k} → (f : (x : A) → B x → C x) → (t : Σ A C) → ((fib-ftr-fib-tot f t) ∘ (fib-tot-fib-ftr f t)) ~ id issec-fib-tot-fib-ftr f (dpair x .(f x y)) (dpair y refl) = refl isretr-fib-tot-fib-ftr : {i j k : Level} {A : UU i} {B : A → UU j} {C : A → UU k} → (f : (x : A) → B x → C x) → (t : Σ A C) → ((fib-tot-fib-ftr f t) ∘ (fib-ftr-fib-tot f t)) ~ id isretr-fib-tot-fib-ftr f .(dpair x (f x y)) (dpair (dpair x y) refl) = refl -- We establish that the fibers of the induced map on total spaces are equivalent to the fibers of the fiberwise transformation. is-equiv-fib-ftr-fib-tot : {i j k : Level} {A : UU i} {B : A → UU j} {C : A → UU k} → (f : (x : A) → B x → C x) → (t : Σ A C) → is-equiv (fib-ftr-fib-tot f t) is-equiv-fib-ftr-fib-tot f t = pair (dpair (fib-tot-fib-ftr f t) (issec-fib-tot-fib-ftr f t)) (dpair (fib-tot-fib-ftr f t) (isretr-fib-tot-fib-ftr f t)) -- Any fiberwise equivalence induces an equivalence on total spaces is-equiv-tot-is-equiv-ftr : {i j k : Level} {A : UU i} {B : A → UU j} {C : A → UU k} → (f : (x : A) → B x → C x) → ((x : A) → is-equiv (f x)) → is-equiv (tot f ) is-equiv-tot-is-equiv-ftr f H = is-equiv-is-contr-map (λ t → is-contr-is-equiv (fib-ftr-fib-tot f t) (is-equiv-fib-ftr-fib-tot f t) (is-contr-map-is-equiv (H _) (pr2 t))) -- Convesely, any fiberwise transformation that induces an equivalence on total spaces is a fiberwise equivalence. is-equiv-ftr-is-equiv-tot : {i j k : Level} {A : UU i} {B : A → UU j} {C : A → UU k} → (f : (x : A) → B x → C x) → is-equiv (tot f) → (x : A) → is-equiv (f x) is-equiv-ftr-is-equiv-tot f H x = is-equiv-is-contr-map (λ z → is-contr-is-equiv' (fib-ftr-fib-tot f (dpair x z)) (is-equiv-fib-ftr-fib-tot f (dpair x z)) (is-contr-map-is-equiv H (dpair x z))) -- Section 7.2 The fundamental theorem -- The general form of the fundamental theorem of identity types id-fundamental-gen : {i j : Level} {A : UU i} {B : A → UU j} (a : A) (b : B a) → is-contr (Σ A B) → (f : (x : A) → Id a x → B x) → (x : A) → is-equiv (f x) id-fundamental-gen {_} {_} {A} {B} a b C f x = is-equiv-ftr-is-equiv-tot f (is-equiv-is-contr _ (is-contr-total-path A a) C) x -- The canonical form of the fundamental theorem of identity types id-fundamental : {i j : Level} {A : UU i} {B : A → UU j} (a : A) (b : B a) → is-contr (Σ A B) → (x : A) → is-equiv (ind-Id (λ x p → B x) b x) id-fundamental {i} {j} {A} {B} a b H = id-fundamental-gen a b H (ind-Id (λ x p → B x) b) -- The converse of the fundamental theorem of identity types id-fundamental' : {i j : Level} {A : UU i} {B : A → UU j} (a : A) (b : B a) → ((x : A) → is-equiv (ind-Id (λ x p → B x) b x)) → is-contr (Σ A B) id-fundamental' {i} {j} {A} {B} a b H = is-contr-is-equiv' (tot (ind-Id (λ x p → B x) b)) (is-equiv-tot-is-equiv-ftr _ H) (is-contr-total-path A a) -- As an application we show that equivalences are embeddings. is-emb : {i j : Level} {A : UU i} {B : UU j} (f : A → B) → UU (i ⊔ j) is-emb f = (x y : _) → is-equiv (ap f {x} {y}) is-emb-is-equiv : {i j : Level} {A : UU i} {B : UU j} (f : A → B) → is-equiv f → is-emb f is-emb-is-equiv {i} {j} {A} {B} f E x = id-fundamental-gen x refl (is-contr-is-equiv' (tot (λ y (p : Id (f y) (f x)) → inv p)) (is-equiv-tot-is-equiv-ftr _ (λ y → is-equiv-inv (f y) (f x))) (is-contr-map-is-equiv E (f x))) (λ y p → ap f p) -- Exercises -- Exercise 7.1 tot-htpy : {i j k : Level} {A : UU i} {B : A → UU j} {C : A → UU k} {f g : (x : A) → B x → C x} → (H : (x : A) → f x ~ g x) → tot f ~ tot g tot-htpy H (dpair x y) = eq-pair (dpair refl (H x y)) tot-id : {i j : Level} {A : UU i} (B : A → UU j) → (tot (λ x (y : B x) → y)) ~ id tot-id B (dpair x y) = refl tot-comp : {i j j' j'' : Level} {A : UU i} {B : A → UU j} {B' : A → UU j'} {B'' : A → UU j''} (f : (x : A) → B x → B' x) (g : (x : A) → B' x → B'' x) → tot (λ x → (g x) ∘ (f x)) ~ ((tot g) ∘ (tot f)) tot-comp f g (dpair x y) = refl -- Exercise 7.7 id-fundamental-retr : {i j : Level} {A : UU i} {B : A → UU j} (a : A) → (i : (x : A) → B x → Id a x) → (R : (x : A) → retr (i x)) → (x : A) → is-equiv (i x) id-fundamental-retr {_} {_} {A} {B} a i R = is-equiv-ftr-is-equiv-tot i (is-equiv-is-contr (tot i) (is-contr-retract-of (Σ _ (λ y → Id a y)) (dpair (tot i) (dpair (tot λ x → pr1 (R x)) (htpy-concat (tot (λ x → pr1 (R x) ∘ i x)) (htpy-inv (tot-comp i (λ x → pr1 (R x)))) (htpy-concat (tot (λ x → id)) (tot-htpy λ x → pr2 (R x)) (tot-id B))))) (is-contr-total-path _ a)) (is-contr-total-path _ a))
{ "alphanum_fraction": 0.5252952582, "avg_line_length": 44.6692913386, "ext": "agda", "hexsha": "2b1394cbaf54f70e3e59884cb19caa1485558f68", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2018-06-25T15:05:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-02-22T19:58:46.000Z", "max_forks_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "glangmead/hott_cmu80818", "max_forks_repo_path": "Lecture7.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_issues_repo_issues_event_max_datetime": "2018-03-25T14:44:31.000Z", "max_issues_repo_issues_event_min_datetime": "2018-02-22T21:01:16.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "glangmead/hott_cmu80818", "max_issues_repo_path": "Lecture7.agda", "max_line_length": 178, "max_stars_count": 4, "max_stars_repo_head_hexsha": "af64d808630f4f1498a75201b6ca4d74d662516b", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "glangmead/hott_cmu80818", "max_stars_repo_path": "Lecture7.agda", "max_stars_repo_stars_event_max_datetime": "2018-09-04T02:52:25.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-03T20:32:19.000Z", "num_tokens": 2405, "size": 5673 }
{-# OPTIONS --rewriting #-} module Luau.StrictMode.ToString where open import Agda.Builtin.Nat using (Nat; suc) open import FFI.Data.String using (String; _++_) open import Luau.Subtyping using (_≮:_; Tree; witness; scalar; function; function-ok; function-err) open import Luau.StrictMode using (Warningᴱ; Warningᴮ; UnallocatedAddress; UnboundVariable; FunctionCallMismatch; FunctionDefnMismatch; BlockMismatch; app₁; app₂; BinOpMismatch₁; BinOpMismatch₂; bin₁; bin₂; block₁; return; LocalVarMismatch; local₁; local₂; function₁; function₂; heap; expr; block; addr) open import Luau.Syntax using (Expr; val; yes; var; var_∈_; _⟨_⟩∈_; _$_; addr; number; binexp; nil; function_is_end; block_is_end; done; return; local_←_; _∙_; fun; arg; name) open import Luau.Type using (strict; number; boolean; string; nil) open import Luau.TypeCheck(strict) using (_⊢ᴮ_∈_; _⊢ᴱ_∈_) open import Luau.Addr.ToString using (addrToString) open import Luau.Var.ToString using (varToString) open import Luau.Type.ToString using (typeToString) open import Luau.Syntax.ToString using (binOpToString) tmp : Nat → String tmp 0 = "w" tmp 1 = "x" tmp 2 = "y" tmp 3 = "z" tmp (suc (suc (suc n))) = tmp n ++ "'" treeToString : Tree → Nat → String → String treeToString (scalar number) n v = v ++ " is a number" treeToString (scalar boolean) n v = v ++ " is a boolean" treeToString (scalar string) n v = v ++ " is a string" treeToString (scalar nil) n v = v ++ " is nil" treeToString function n v = v ++ " is a function" treeToString (function-ok t) n v = treeToString t n (v ++ "()") treeToString (function-err t) n v = v ++ "(" ++ w ++ ") can error when\n " ++ treeToString t (suc n) w where w = tmp n subtypeWarningToString : ∀ {T U} → (T ≮: U) → String subtypeWarningToString (witness t p q) = "\n because provided type contains v, where " ++ treeToString t 0 "v" warningToStringᴱ : ∀ {H Γ T} M → {D : Γ ⊢ᴱ M ∈ T} → Warningᴱ H D → String warningToStringᴮ : ∀ {H Γ T} B → {D : Γ ⊢ᴮ B ∈ T} → Warningᴮ H D → String warningToStringᴱ (var x) (UnboundVariable p) = "Unbound variable " ++ varToString x warningToStringᴱ (val (addr a)) (UnallocatedAddress p) = "Unallocated address " ++ addrToString a warningToStringᴱ (M $ N) (FunctionCallMismatch {T = T} {U = U} p) = "Function has type " ++ typeToString T ++ " but argument has type " ++ typeToString U ++ subtypeWarningToString p warningToStringᴱ (M $ N) (app₁ W) = warningToStringᴱ M W warningToStringᴱ (M $ N) (app₂ W) = warningToStringᴱ N W warningToStringᴱ (function f ⟨ var x ∈ T ⟩∈ U is B end) (FunctionDefnMismatch {V = V} p) = "Function expresion " ++ varToString f ++ " has return type " ++ typeToString U ++ " but body returns " ++ typeToString V ++ subtypeWarningToString p warningToStringᴱ (function f ⟨ var x ∈ T ⟩∈ U is B end) (function₁ W) = warningToStringᴮ B W ++ "\n in function expression " ++ varToString f warningToStringᴱ block var b ∈ T is B end (BlockMismatch {U = U} p) = "Block " ++ varToString b ++ " has type " ++ typeToString T ++ " but body returns " ++ typeToString U ++ subtypeWarningToString p warningToStringᴱ block var b ∈ T is B end (block₁ W) = warningToStringᴮ B W ++ "\n in block " ++ varToString b warningToStringᴱ (binexp M op N) (BinOpMismatch₁ {T = T} p) = "Binary operator " ++ binOpToString op ++ " lhs has type " ++ typeToString T ++ subtypeWarningToString p warningToStringᴱ (binexp M op N) (BinOpMismatch₂ {U = U} p) = "Binary operator " ++ binOpToString op ++ " rhs has type " ++ typeToString U ++ subtypeWarningToString p warningToStringᴱ (binexp M op N) (bin₁ W) = warningToStringᴱ M W warningToStringᴱ (binexp M op N) (bin₂ W) = warningToStringᴱ N W warningToStringᴮ (function f ⟨ var x ∈ T ⟩∈ U is C end ∙ B) (FunctionDefnMismatch {V = V} p) = "Function declaration " ++ varToString f ++ " has return type " ++ typeToString U ++ " but body returns " ++ typeToString V ++ subtypeWarningToString p warningToStringᴮ (function f ⟨ var x ∈ T ⟩∈ U is C end ∙ B) (function₁ W) = warningToStringᴮ C W ++ "\n in function declaration " ++ varToString f warningToStringᴮ (function f ⟨ var x ∈ T ⟩∈ U is C end ∙ B) (function₂ W) = warningToStringᴮ B W warningToStringᴮ (local var x ∈ T ← M ∙ B) (LocalVarMismatch {U = U} p) = "Local variable " ++ varToString x ++ " has type " ++ typeToString T ++ " but expression has type " ++ typeToString U ++ subtypeWarningToString p warningToStringᴮ (local var x ∈ T ← M ∙ B) (local₁ W) = warningToStringᴱ M W ++ "\n in local variable declaration " ++ varToString x warningToStringᴮ (local var x ∈ T ← M ∙ B) (local₂ W) = warningToStringᴮ B W warningToStringᴮ (return M ∙ B) (return W) = warningToStringᴱ M W ++ "\n in return statement"
{ "alphanum_fraction": 0.6961100365, "avg_line_length": 76.2786885246, "ext": "agda", "hexsha": "08ee13b8cbe6cddf2f92d92f385f41298aeab326", "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": "d37d0c857ba543ea47f0b8fce5678f7aadf5239e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "EtiTheSpirit/luau", "max_forks_repo_path": "prototyping/Luau/StrictMode/ToString.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d37d0c857ba543ea47f0b8fce5678f7aadf5239e", "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": "EtiTheSpirit/luau", "max_issues_repo_path": "prototyping/Luau/StrictMode/ToString.agda", "max_line_length": 303, "max_stars_count": null, "max_stars_repo_head_hexsha": "d37d0c857ba543ea47f0b8fce5678f7aadf5239e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "EtiTheSpirit/luau", "max_stars_repo_path": "prototyping/Luau/StrictMode/ToString.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1492, "size": 4653 }
{-# OPTIONS --cubical-compatible #-} module WithoutK-PatternSynonyms1 where -- Equality defined with one index. data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x pattern r = refl -- The --cubical-compatible option works with pattern synonyms. K : (A : Set) (x : A) (P : x ≡ x → Set) → P refl → (p : x ≡ x ) → P p K A x P pr r = pr
{ "alphanum_fraction": 0.601744186, "avg_line_length": 24.5714285714, "ext": "agda", "hexsha": "76983fb8ecadd74d6308c6ab12af422bbae97534", "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/WithoutK-PatternSynonyms1.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/WithoutK-PatternSynonyms1.agda", "max_line_length": 70, "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/WithoutK-PatternSynonyms1.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 120, "size": 344 }
module BetterExampleOfDot where open import Data.Nat open import Agda.Builtin.Equality data CannotContruct : ℕ → Set where test : ∀ a b → ((a b : ℕ) → a + b ≡ b + a) → CannotContruct (a + b) → CannotContruct (b + a) test a b theory p with a + b | theory a b ... | .(b + a) | refl = p
{ "alphanum_fraction": 0.5638629283, "avg_line_length": 21.4, "ext": "agda", "hexsha": "07bba1a922c9b7224abc299a48d52cbc0a7e4b2e", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-03-12T21:33:35.000Z", "max_forks_repo_forks_event_min_datetime": "2019-10-07T01:38:12.000Z", "max_forks_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "dubinsky/intellij-dtlc", "max_forks_repo_path": "testData/parse/agda/BetterExampleOfDot.agda", "max_issues_count": 16, "max_issues_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be", "max_issues_repo_issues_event_max_datetime": "2021-03-15T17:04:36.000Z", "max_issues_repo_issues_event_min_datetime": "2019-03-30T04:29:32.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "dubinsky/intellij-dtlc", "max_issues_repo_path": "testData/parse/agda/BetterExampleOfDot.agda", "max_line_length": 43, "max_stars_count": 30, "max_stars_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "dubinsky/intellij-dtlc", "max_stars_repo_path": "testData/parse/agda/BetterExampleOfDot.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-29T13:18:34.000Z", "max_stars_repo_stars_event_min_datetime": "2019-05-11T16:26:38.000Z", "num_tokens": 108, "size": 321 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Heterogeneously-indexed binary relations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Binary.Indexed.Heterogeneous where ------------------------------------------------------------------------ -- Publicly export core definitions open import Relation.Binary.Indexed.Heterogeneous.Core public open import Relation.Binary.Indexed.Heterogeneous.Definitions public open import Relation.Binary.Indexed.Heterogeneous.Structures public open import Relation.Binary.Indexed.Heterogeneous.Bundles public ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 0.17 REL = IREL {-# WARNING_ON_USAGE REL "Warning: REL was deprecated in v0.17. Please use IREL instead." #-} Rel = IRel {-# WARNING_ON_USAGE Rel "Warning: Rel was deprecated in v0.17. Please use IRel instead." #-} Setoid = IndexedSetoid {-# WARNING_ON_USAGE Setoid "Warning: Setoid was deprecated in v0.17. Please use IndexedSetoid instead." #-} IsEquivalence = IsIndexedEquivalence {-# WARNING_ON_USAGE IsEquivalence "Warning: IsEquivalence was deprecated in v0.17. Please use IsIndexedEquivalence instead." #-}
{ "alphanum_fraction": 0.5891156463, "avg_line_length": 30.625, "ext": "agda", "hexsha": "40451a6eee51e0a3fbd931fc9857604cbf29fd23", "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/Indexed/Heterogeneous.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/Indexed/Heterogeneous.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/Relation/Binary/Indexed/Heterogeneous.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": 279, "size": 1470 }
module Text.Greek.SBLGNT.2John where open import Data.List open import Text.Greek.Bible open import Text.Greek.Script open import Text.Greek.Script.Unicode ΙΩΑΝΝΟΥ-Β : List (Word) ΙΩΑΝΝΟΥ-Β = word (Ὁ ∷ []) "2John.1.1" ∷ word (π ∷ ρ ∷ ε ∷ σ ∷ β ∷ ύ ∷ τ ∷ ε ∷ ρ ∷ ο ∷ ς ∷ []) "2John.1.1" ∷ word (ἐ ∷ κ ∷ ∙λ ∷ ε ∷ κ ∷ τ ∷ ῇ ∷ []) "2John.1.1" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ᾳ ∷ []) "2John.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.1" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2John.1.1" ∷ word (τ ∷ έ ∷ κ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "2John.1.1" ∷ word (α ∷ ὐ ∷ τ ∷ ῆ ∷ ς ∷ []) "2John.1.1" ∷ word (ο ∷ ὓ ∷ ς ∷ []) "2John.1.1" ∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "2John.1.1" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ ῶ ∷ []) "2John.1.1" ∷ word (ἐ ∷ ν ∷ []) "2John.1.1" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "2John.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.1" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "2John.1.1" ∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "2John.1.1" ∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ς ∷ []) "2John.1.1" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2John.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.1" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2John.1.1" ∷ word (ο ∷ ἱ ∷ []) "2John.1.1" ∷ word (ἐ ∷ γ ∷ ν ∷ ω ∷ κ ∷ ό ∷ τ ∷ ε ∷ ς ∷ []) "2John.1.1" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "2John.1.1" ∷ word (ἀ ∷ ∙λ ∷ ή ∷ θ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "2John.1.1" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "2John.1.2" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "2John.1.2" ∷ word (ἀ ∷ ∙λ ∷ ή ∷ θ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "2John.1.2" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "2John.1.2" ∷ word (μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ σ ∷ α ∷ ν ∷ []) "2John.1.2" ∷ word (ἐ ∷ ν ∷ []) "2John.1.2" ∷ word (ἡ ∷ μ ∷ ῖ ∷ ν ∷ []) "2John.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.2" ∷ word (μ ∷ ε ∷ θ ∷ []) "2John.1.2" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2John.1.2" ∷ word (ἔ ∷ σ ∷ τ ∷ α ∷ ι ∷ []) "2John.1.2" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2John.1.2" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "2John.1.2" ∷ word (α ∷ ἰ ∷ ῶ ∷ ν ∷ α ∷ []) "2John.1.2" ∷ word (ἔ ∷ σ ∷ τ ∷ α ∷ ι ∷ []) "2John.1.3" ∷ word (μ ∷ ε ∷ θ ∷ []) "2John.1.3" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "2John.1.3" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "2John.1.3" ∷ word (ἔ ∷ ∙λ ∷ ε ∷ ο ∷ ς ∷ []) "2John.1.3" ∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "2John.1.3" ∷ word (π ∷ α ∷ ρ ∷ ὰ ∷ []) "2John.1.3" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "2John.1.3" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ό ∷ ς ∷ []) "2John.1.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.3" ∷ word (π ∷ α ∷ ρ ∷ ὰ ∷ []) "2John.1.3" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "2John.1.3" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2John.1.3" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2John.1.3" ∷ word (υ ∷ ἱ ∷ ο ∷ ῦ ∷ []) "2John.1.3" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2John.1.3" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ό ∷ ς ∷ []) "2John.1.3" ∷ word (ἐ ∷ ν ∷ []) "2John.1.3" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "2John.1.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.3" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ ῃ ∷ []) "2John.1.3" ∷ word (Ἐ ∷ χ ∷ ά ∷ ρ ∷ η ∷ ν ∷ []) "2John.1.4" ∷ word (∙λ ∷ ί ∷ α ∷ ν ∷ []) "2John.1.4" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2John.1.4" ∷ word (ε ∷ ὕ ∷ ρ ∷ η ∷ κ ∷ α ∷ []) "2John.1.4" ∷ word (ἐ ∷ κ ∷ []) "2John.1.4" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "2John.1.4" ∷ word (τ ∷ έ ∷ κ ∷ ν ∷ ω ∷ ν ∷ []) "2John.1.4" ∷ word (σ ∷ ο ∷ υ ∷ []) "2John.1.4" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "2John.1.4" ∷ word (ἐ ∷ ν ∷ []) "2John.1.4" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "2John.1.4" ∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "2John.1.4" ∷ word (ἐ ∷ ν ∷ τ ∷ ο ∷ ∙λ ∷ ὴ ∷ ν ∷ []) "2John.1.4" ∷ word (ἐ ∷ ∙λ ∷ ά ∷ β ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2John.1.4" ∷ word (π ∷ α ∷ ρ ∷ ὰ ∷ []) "2John.1.4" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2John.1.4" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ό ∷ ς ∷ []) "2John.1.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.5" ∷ word (ν ∷ ῦ ∷ ν ∷ []) "2John.1.5" ∷ word (ἐ ∷ ρ ∷ ω ∷ τ ∷ ῶ ∷ []) "2John.1.5" ∷ word (σ ∷ ε ∷ []) "2John.1.5" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ α ∷ []) "2John.1.5" ∷ word (ο ∷ ὐ ∷ χ ∷ []) "2John.1.5" ∷ word (ὡ ∷ ς ∷ []) "2John.1.5" ∷ word (ἐ ∷ ν ∷ τ ∷ ο ∷ ∙λ ∷ ὴ ∷ ν ∷ []) "2John.1.5" ∷ word (κ ∷ α ∷ ι ∷ ν ∷ ὴ ∷ ν ∷ []) "2John.1.5" ∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ω ∷ ν ∷ []) "2John.1.5" ∷ word (σ ∷ ο ∷ ι ∷ []) "2John.1.5" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2John.1.5" ∷ word (ἣ ∷ ν ∷ []) "2John.1.5" ∷ word (ε ∷ ἴ ∷ χ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "2John.1.5" ∷ word (ἀ ∷ π ∷ []) "2John.1.5" ∷ word (ἀ ∷ ρ ∷ χ ∷ ῆ ∷ ς ∷ []) "2John.1.5" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2John.1.5" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "2John.1.5" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ή ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "2John.1.5" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.6" ∷ word (α ∷ ὕ ∷ τ ∷ η ∷ []) "2John.1.6" ∷ word (ἐ ∷ σ ∷ τ ∷ ὶ ∷ ν ∷ []) "2John.1.6" ∷ word (ἡ ∷ []) "2John.1.6" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ []) "2John.1.6" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2John.1.6" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "2John.1.6" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "2John.1.6" ∷ word (τ ∷ ὰ ∷ ς ∷ []) "2John.1.6" ∷ word (ἐ ∷ ν ∷ τ ∷ ο ∷ ∙λ ∷ ὰ ∷ ς ∷ []) "2John.1.6" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2John.1.6" ∷ word (α ∷ ὕ ∷ τ ∷ η ∷ []) "2John.1.6" ∷ word (ἡ ∷ []) "2John.1.6" ∷ word (ἐ ∷ ν ∷ τ ∷ ο ∷ ∙λ ∷ ή ∷ []) "2John.1.6" ∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2John.1.6" ∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "2John.1.6" ∷ word (ἠ ∷ κ ∷ ο ∷ ύ ∷ σ ∷ α ∷ τ ∷ ε ∷ []) "2John.1.6" ∷ word (ἀ ∷ π ∷ []) "2John.1.6" ∷ word (ἀ ∷ ρ ∷ χ ∷ ῆ ∷ ς ∷ []) "2John.1.6" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2John.1.6" ∷ word (ἐ ∷ ν ∷ []) "2John.1.6" ∷ word (α ∷ ὐ ∷ τ ∷ ῇ ∷ []) "2John.1.6" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ῆ ∷ τ ∷ ε ∷ []) "2John.1.6" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "2John.1.7" ∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ο ∷ ὶ ∷ []) "2John.1.7" ∷ word (π ∷ ∙λ ∷ ά ∷ ν ∷ ο ∷ ι ∷ []) "2John.1.7" ∷ word (ἐ ∷ ξ ∷ ῆ ∷ ∙λ ∷ θ ∷ ο ∷ ν ∷ []) "2John.1.7" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2John.1.7" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "2John.1.7" ∷ word (κ ∷ ό ∷ σ ∷ μ ∷ ο ∷ ν ∷ []) "2John.1.7" ∷ word (ο ∷ ἱ ∷ []) "2John.1.7" ∷ word (μ ∷ ὴ ∷ []) "2John.1.7" ∷ word (ὁ ∷ μ ∷ ο ∷ ∙λ ∷ ο ∷ γ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "2John.1.7" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ν ∷ []) "2John.1.7" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ν ∷ []) "2John.1.7" ∷ word (ἐ ∷ ρ ∷ χ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ν ∷ []) "2John.1.7" ∷ word (ἐ ∷ ν ∷ []) "2John.1.7" ∷ word (σ ∷ α ∷ ρ ∷ κ ∷ ί ∷ []) "2John.1.7" ∷ word (ο ∷ ὗ ∷ τ ∷ ό ∷ ς ∷ []) "2John.1.7" ∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "2John.1.7" ∷ word (ὁ ∷ []) "2John.1.7" ∷ word (π ∷ ∙λ ∷ ά ∷ ν ∷ ο ∷ ς ∷ []) "2John.1.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.7" ∷ word (ὁ ∷ []) "2John.1.7" ∷ word (ἀ ∷ ν ∷ τ ∷ ί ∷ χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ς ∷ []) "2John.1.7" ∷ word (β ∷ ∙λ ∷ έ ∷ π ∷ ε ∷ τ ∷ ε ∷ []) "2John.1.8" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ύ ∷ ς ∷ []) "2John.1.8" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2John.1.8" ∷ word (μ ∷ ὴ ∷ []) "2John.1.8" ∷ word (ἀ ∷ π ∷ ο ∷ ∙λ ∷ έ ∷ σ ∷ η ∷ τ ∷ ε ∷ []) "2John.1.8" ∷ word (ἃ ∷ []) "2John.1.8" ∷ word (ε ∷ ἰ ∷ ρ ∷ γ ∷ α ∷ σ ∷ ά ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "2John.1.8" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2John.1.8" ∷ word (μ ∷ ι ∷ σ ∷ θ ∷ ὸ ∷ ν ∷ []) "2John.1.8" ∷ word (π ∷ ∙λ ∷ ή ∷ ρ ∷ η ∷ []) "2John.1.8" ∷ word (ἀ ∷ π ∷ ο ∷ ∙λ ∷ ά ∷ β ∷ η ∷ τ ∷ ε ∷ []) "2John.1.8" ∷ word (π ∷ ᾶ ∷ ς ∷ []) "2John.1.9" ∷ word (ὁ ∷ []) "2John.1.9" ∷ word (π ∷ ρ ∷ ο ∷ ά ∷ γ ∷ ω ∷ ν ∷ []) "2John.1.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.9" ∷ word (μ ∷ ὴ ∷ []) "2John.1.9" ∷ word (μ ∷ έ ∷ ν ∷ ω ∷ ν ∷ []) "2John.1.9" ∷ word (ἐ ∷ ν ∷ []) "2John.1.9" ∷ word (τ ∷ ῇ ∷ []) "2John.1.9" ∷ word (δ ∷ ι ∷ δ ∷ α ∷ χ ∷ ῇ ∷ []) "2John.1.9" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "2John.1.9" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "2John.1.9" ∷ word (θ ∷ ε ∷ ὸ ∷ ν ∷ []) "2John.1.9" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "2John.1.9" ∷ word (ἔ ∷ χ ∷ ε ∷ ι ∷ []) "2John.1.9" ∷ word (ὁ ∷ []) "2John.1.9" ∷ word (μ ∷ έ ∷ ν ∷ ω ∷ ν ∷ []) "2John.1.9" ∷ word (ἐ ∷ ν ∷ []) "2John.1.9" ∷ word (τ ∷ ῇ ∷ []) "2John.1.9" ∷ word (δ ∷ ι ∷ δ ∷ α ∷ χ ∷ ῇ ∷ []) "2John.1.9" ∷ word (ο ∷ ὗ ∷ τ ∷ ο ∷ ς ∷ []) "2John.1.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.9" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "2John.1.9" ∷ word (π ∷ α ∷ τ ∷ έ ∷ ρ ∷ α ∷ []) "2John.1.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.9" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "2John.1.9" ∷ word (υ ∷ ἱ ∷ ὸ ∷ ν ∷ []) "2John.1.9" ∷ word (ἔ ∷ χ ∷ ε ∷ ι ∷ []) "2John.1.9" ∷ word (ε ∷ ἴ ∷ []) "2John.1.10" ∷ word (τ ∷ ι ∷ ς ∷ []) "2John.1.10" ∷ word (ἔ ∷ ρ ∷ χ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "2John.1.10" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2John.1.10" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2John.1.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.10" ∷ word (τ ∷ α ∷ ύ ∷ τ ∷ η ∷ ν ∷ []) "2John.1.10" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "2John.1.10" ∷ word (δ ∷ ι ∷ δ ∷ α ∷ χ ∷ ὴ ∷ ν ∷ []) "2John.1.10" ∷ word (ο ∷ ὐ ∷ []) "2John.1.10" ∷ word (φ ∷ έ ∷ ρ ∷ ε ∷ ι ∷ []) "2John.1.10" ∷ word (μ ∷ ὴ ∷ []) "2John.1.10" ∷ word (∙λ ∷ α ∷ μ ∷ β ∷ ά ∷ ν ∷ ε ∷ τ ∷ ε ∷ []) "2John.1.10" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "2John.1.10" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "2John.1.10" ∷ word (ο ∷ ἰ ∷ κ ∷ ί ∷ α ∷ ν ∷ []) "2John.1.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.10" ∷ word (χ ∷ α ∷ ί ∷ ρ ∷ ε ∷ ι ∷ ν ∷ []) "2John.1.10" ∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "2John.1.10" ∷ word (μ ∷ ὴ ∷ []) "2John.1.10" ∷ word (∙λ ∷ έ ∷ γ ∷ ε ∷ τ ∷ ε ∷ []) "2John.1.10" ∷ word (ὁ ∷ []) "2John.1.11" ∷ word (∙λ ∷ έ ∷ γ ∷ ω ∷ ν ∷ []) "2John.1.11" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "2John.1.11" ∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "2John.1.11" ∷ word (χ ∷ α ∷ ί ∷ ρ ∷ ε ∷ ι ∷ ν ∷ []) "2John.1.11" ∷ word (κ ∷ ο ∷ ι ∷ ν ∷ ω ∷ ν ∷ ε ∷ ῖ ∷ []) "2John.1.11" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2John.1.11" ∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ ι ∷ ς ∷ []) "2John.1.11" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "2John.1.11" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "2John.1.11" ∷ word (π ∷ ο ∷ ν ∷ η ∷ ρ ∷ ο ∷ ῖ ∷ ς ∷ []) "2John.1.11" ∷ word (Π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2John.1.12" ∷ word (ἔ ∷ χ ∷ ω ∷ ν ∷ []) "2John.1.12" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "2John.1.12" ∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ε ∷ ι ∷ ν ∷ []) "2John.1.12" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "2John.1.12" ∷ word (ἐ ∷ β ∷ ο ∷ υ ∷ ∙λ ∷ ή ∷ θ ∷ η ∷ ν ∷ []) "2John.1.12" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "2John.1.12" ∷ word (χ ∷ ά ∷ ρ ∷ τ ∷ ο ∷ υ ∷ []) "2John.1.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.12" ∷ word (μ ∷ έ ∷ ∙λ ∷ α ∷ ν ∷ ο ∷ ς ∷ []) "2John.1.12" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "2John.1.12" ∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ ζ ∷ ω ∷ []) "2John.1.12" ∷ word (γ ∷ ε ∷ ν ∷ έ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "2John.1.12" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2John.1.12" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "2John.1.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "2John.1.12" ∷ word (σ ∷ τ ∷ ό ∷ μ ∷ α ∷ []) "2John.1.12" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "2John.1.12" ∷ word (σ ∷ τ ∷ ό ∷ μ ∷ α ∷ []) "2John.1.12" ∷ word (∙λ ∷ α ∷ ∙λ ∷ ῆ ∷ σ ∷ α ∷ ι ∷ []) "2John.1.12" ∷ word (ἵ ∷ ν ∷ α ∷ []) "2John.1.12" ∷ word (ἡ ∷ []) "2John.1.12" ∷ word (χ ∷ α ∷ ρ ∷ ὰ ∷ []) "2John.1.12" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "2John.1.12" ∷ word (π ∷ ε ∷ π ∷ ∙λ ∷ η ∷ ρ ∷ ω ∷ μ ∷ έ ∷ ν ∷ η ∷ []) "2John.1.12" ∷ word (ᾖ ∷ []) "2John.1.12" ∷ word (Ἀ ∷ σ ∷ π ∷ ά ∷ ζ ∷ ε ∷ τ ∷ α ∷ ί ∷ []) "2John.1.13" ∷ word (σ ∷ ε ∷ []) "2John.1.13" ∷ word (τ ∷ ὰ ∷ []) "2John.1.13" ∷ word (τ ∷ έ ∷ κ ∷ ν ∷ α ∷ []) "2John.1.13" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2John.1.13" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ῆ ∷ ς ∷ []) "2John.1.13" ∷ word (σ ∷ ο ∷ υ ∷ []) "2John.1.13" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "2John.1.13" ∷ word (ἐ ∷ κ ∷ ∙λ ∷ ε ∷ κ ∷ τ ∷ ῆ ∷ ς ∷ []) "2John.1.13" ∷ []
{ "alphanum_fraction": 0.3610887996, "avg_line_length": 43.76953125, "ext": "agda", "hexsha": "fe25fa9ea0f646a41dbdb796610e3c55c89e6eef", "lang": "Agda", "max_forks_count": 5, "max_forks_repo_forks_event_max_datetime": "2017-06-11T11:25:09.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-27T22:34:13.000Z", "max_forks_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "scott-fleischman/GreekGrammar", "max_forks_repo_path": "agda/Text/Greek/SBLGNT/2John.agda", "max_issues_count": 13, "max_issues_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_issues_repo_issues_event_max_datetime": "2020-09-07T11:58:38.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-28T20:04:08.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "scott-fleischman/GreekGrammar", "max_issues_repo_path": "agda/Text/Greek/SBLGNT/2John.agda", "max_line_length": 77, "max_stars_count": 44, "max_stars_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "scott-fleischman/GreekGrammar", "max_stars_repo_path": "agda/Text/Greek/SBLGNT/2John.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-06T15:41:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-29T14:48:51.000Z", "num_tokens": 7802, "size": 11205 }
{-# OPTIONS --safe #-} module Cubical.HITs.FreeComMonoids where open import Cubical.HITs.FreeComMonoids.Base public open import Cubical.HITs.FreeComMonoids.Properties public
{ "alphanum_fraction": 0.8125, "avg_line_length": 25.1428571429, "ext": "agda", "hexsha": "c90d9c9be804f6d15a0cdad4e35e22509755e65b", "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/FreeComMonoids.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/FreeComMonoids.agda", "max_line_length": 57, "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/FreeComMonoids.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": 45, "size": 176 }
{-# OPTIONS --cubical --safe #-} module Data.Bits.Order.Reverse where open import Prelude open import Data.Bits -- Least significant bit first infix 4 _≲ᴮ_&_ _≲ᴮ_&_ : Bits → Bits → Bool → Bool [] ≲ᴮ ys & true = true [] ≲ᴮ [] & false = false [] ≲ᴮ 0∷ ys & false = true [] ≲ᴮ 1∷ ys & false = true 0∷ xs ≲ᴮ [] & s = false 0∷ xs ≲ᴮ 0∷ ys & s = xs ≲ᴮ ys & s 0∷ xs ≲ᴮ 1∷ ys & s = xs ≲ᴮ ys & true 1∷ xs ≲ᴮ [] & s = false 1∷ xs ≲ᴮ 0∷ ys & s = xs ≲ᴮ ys & false 1∷ xs ≲ᴮ 1∷ ys & s = xs ≲ᴮ ys & s infix 4 _≤ᴮ_ _<ᴮ_ _≤ᴮ_ : Bits → Bits → Bool xs ≤ᴮ ys = xs ≲ᴮ ys & true _<ᴮ_ : Bits → Bits → Bool xs <ᴮ ys = xs ≲ᴮ ys & false infix 4 _≤_ _<_ _≤_ : Bits → Bits → Type xs ≤ ys = T (xs ≤ᴮ ys) _<_ : Bits → Bits → Type xs < ys = T (xs <ᴮ ys)
{ "alphanum_fraction": 0.5102564103, "avg_line_length": 21.6666666667, "ext": "agda", "hexsha": "f1661e10d3253c0b9a6b0c2b7e75dc5ea947ff7a", "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/Bits/Order/Reverse.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/Bits/Order/Reverse.agda", "max_line_length": 41, "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/Bits/Order/Reverse.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": 406, "size": 780 }
module LanguageConstructs where open import Haskell.Prelude {-# FOREIGN AGDA2HS {-# LANGUAGE LambdaCase #-} #-} -------------------------------------------------- -- Lists oneTwoThree : List Int oneTwoThree = 1 ∷ 2 ∷ 3 ∷ [] {-# COMPILE AGDA2HS oneTwoThree #-} exactlyTwo : List a → Maybe (a × a) exactlyTwo (x ∷ y ∷ []) = Just (x , y) exactlyTwo _ = Nothing {-# COMPILE AGDA2HS exactlyTwo #-} -------------------------------------------------- -- If-then-else ifThenElse : Int → String ifThenElse n = if n >= 10 then "big" else "small" {-# COMPILE AGDA2HS ifThenElse #-} -------------------------------------------------- -- Case maybeToList : Maybe a → List a maybeToList = λ where Nothing → [] (Just x) → x ∷ [] {-# COMPILE AGDA2HS maybeToList #-} mhead : List a → Maybe a mhead xs = case xs of λ where [] → Nothing (x ∷ _) → Just x {-# COMPILE AGDA2HS mhead #-} -- Applied to lambda plus5minus5 : Int → Int plus5minus5 n = case n + 5 of λ m → m - 5 {-# COMPILE AGDA2HS plus5minus5 #-} -- Applied to non-lambda len : List a → Int len xs = case xs of length {-# COMPILE AGDA2HS len #-} -- Underapplied applyToFalse : (Bool → a) → a applyToFalse = case false of_ {-# COMPILE AGDA2HS applyToFalse #-} caseOf : a → (a → b) → b caseOf = case_of_ {-# COMPILE AGDA2HS caseOf #-} -------------------------------------------------- -- Enums enum₁ : List Int enum₁ = enumFromTo 5 10 {-# COMPILE AGDA2HS enum₁ #-} enum₂ : List Integer enum₂ = enumFromThenTo 10 20 100 {-# COMPILE AGDA2HS enum₂ #-} enum₃ : List Bool enum₃ = enumFrom false {-# COMPILE AGDA2HS enum₃ #-} enum₄ : List Ordering enum₄ = enumFromThen LT EQ {-# COMPILE AGDA2HS enum₄ #-} underappliedEnum : List Int → List (List Int) underappliedEnum = map (enumFromTo 1) {-# COMPILE AGDA2HS underappliedEnum #-}
{ "alphanum_fraction": 0.5736899563, "avg_line_length": 21.3023255814, "ext": "agda", "hexsha": "59948cf2299311be70bc0abf948e15756afb1abb", "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/LanguageConstructs.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/LanguageConstructs.agda", "max_line_length": 51, "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/LanguageConstructs.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": 549, "size": 1832 }
{-# OPTIONS --without-K #-} open import lib.Base module lib.Coinduction where infix 1000 ♯_ postulate -- Coinduction ∞ : ∀ {i} (A : Type i) → Type i ♯_ : ∀ {i} {A : Type i} → A → ∞ A ♭ : ∀ {i} {A : Type i} → ∞ A → A {-# BUILTIN INFINITY ∞ #-} {-# BUILTIN SHARP ♯_ #-} {-# BUILTIN FLAT ♭ #-}
{ "alphanum_fraction": 0.5, "avg_line_length": 18.4705882353, "ext": "agda", "hexsha": "f04fed13735f7c03dd2c6a5e9608c4f059b650e5", "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": "lib/Coinduction.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": "lib/Coinduction.agda", "max_line_length": 35, "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": "lib/Coinduction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 126, "size": 314 }
open import Agda.Builtin.Bool record ⊤ : Set where constructor tt data ⊥ : Set where record Σ (A : Set) (B : A → Set) : Set where field fst : A snd : B fst open Σ T : Bool → Set T false = ⊥ T true = ⊤ Foo : Bool → Set Foo false = Bool → Bool Foo true = Σ Bool T foo : (x : Bool) → Foo x foo false x = x foo true .fst = true foo true .snd = tt
{ "alphanum_fraction": 0.5858310627, "avg_line_length": 15.2916666667, "ext": "agda", "hexsha": "c88cebf34793f3be05c14c2f1c38fef23218584a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2964b.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2964b.agda", "max_line_length": 44, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2964b.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 137, "size": 367 }
{-# OPTIONS --without-K --safe #-} open import Algebra.Structures.Bundles.Field module Algebra.Linear.Category.Vect {k ℓᵏ} (K : Field k ℓᵏ) {a ℓ} where open import Relation.Binary using (Setoid) open import Algebra.Linear.Structures.Bundles open import Algebra.Linear.Morphism.Bundles K open import Categories.Category open LinearMap id : ∀ {V : VectorSpace K a ℓ} -> LinearMap V V id {V = V} = record { ⟦_⟧ = λ u -> u ; isLinearMap = record { isAbelianGroupMorphism = record { gp-homo = record { mn-homo = record { sm-homo = record { ⟦⟧-cong = λ r -> r ; ∙-homo = λ x y → VectorSpace.refl V } ; ε-homo = VectorSpace.refl V } } } ; ∙-homo = λ c u → VectorSpace.refl V } } _∘_ : ∀ {U V W : VectorSpace K a ℓ} -> LinearMap V W -> LinearMap U V -> LinearMap U W _∘_ {U = U} {V} {W} f g = record { ⟦_⟧ = λ u → f ⟪$⟫ g ⟪$⟫ u ; isLinearMap = record { isAbelianGroupMorphism = record { gp-homo = record { mn-homo = record { sm-homo = record { ⟦⟧-cong = λ r → ⟦⟧-cong f (⟦⟧-cong g r) ; ∙-homo = λ u v → VectorSpace.trans W (⟦⟧-cong f (+-homo g u v)) (+-homo f (g ⟪$⟫ u) (g ⟪$⟫ v)) } ; ε-homo = VectorSpace.trans W (⟦⟧-cong f (0#-homo g)) (0#-homo f) } } } ; ∙-homo = λ c u → VectorSpace.trans W (⟦⟧-cong f (∙-homo g c u)) (∙-homo f c (g ⟪$⟫ u)) } } private module Assoc {U V W X : VectorSpace K a ℓ} {f : LinearMap U V} {g : LinearMap V W} {h : LinearMap W X} where open Setoid (linearMap-setoid U X) open import Relation.Binary.EqReasoning (linearMap-setoid U X) right : ((h ∘ g) ∘ f) ≈ (h ∘ (g ∘ f)) right r = ⟦⟧-cong h (⟦⟧-cong g (⟦⟧-cong f r)) left : (h ∘ (g ∘ f)) ≈ ((h ∘ g) ∘ f) left r = ⟦⟧-cong h (⟦⟧-cong g (⟦⟧-cong f r)) Vect : Category _ _ _ Vect = record { Obj = VectorSpace K a ℓ ; _⇒_ = λ V W → LinearMap V W ; _≈_ = λ {V} {W} -> Setoid._≈_ (linearMap-setoid V W) ; id = id ; _∘_ = _∘_ ; assoc = λ {U} {V} {W} {X} {f} {g} {h} -> Assoc.right {U} {V} {W} {X} {f} {g} {h} ; sym-assoc = λ {U} {V} {W} {X} {f} {g} {h} -> Assoc.left {U} {V} {W} {X} {f} {g} {h} ; identityˡ = λ {U} {V} {f} -> ⟦⟧-cong f ; identityʳ = λ {U} {V} {f} → ⟦⟧-cong f ; equiv = λ {V} {W} -> Setoid.isEquivalence (linearMap-setoid V W) ; ∘-resp-≈ = λ {U} {V} {W} {f} {h} {g} {i} rf rg rx → VectorSpace.trans W (rf (⟦⟧-cong g rx)) (⟦⟧-cong h (rg (VectorSpace.refl U))) }
{ "alphanum_fraction": 0.5132, "avg_line_length": 31.6455696203, "ext": "agda", "hexsha": "2d3de69349451a5c270a1252711527e25f363fda", "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": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "felko/linear-algebra", "max_forks_repo_path": "src/Algebra/Linear/Category/Vect.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "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": "felko/linear-algebra", "max_issues_repo_path": "src/Algebra/Linear/Category/Vect.agda", "max_line_length": 108, "max_stars_count": 15, "max_stars_repo_head_hexsha": "d87c5a1eb5dd0569238272e67bce1899616b789a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "felko/linear-algebra", "max_stars_repo_path": "src/Algebra/Linear/Category/Vect.agda", "max_stars_repo_stars_event_max_datetime": "2020-12-30T06:18:08.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-02T14:11:00.000Z", "num_tokens": 1080, "size": 2500 }
-- Andreas, 2017-07-11, issue #2637, reported by nad. -- -- This error was triggered by a meta m in a constraint UnBlock m -- which is solved to infinity by the size solver. -- The constraint printer did not expect such a situation -- and crashed when printing the UnBlock constraint. {-# OPTIONS --allow-unsolved-metas #-} module _ (Z : Set) where open import Common.Size open import Common.Product postulate map : (A B C : Set) → (A → C) → A × B → C × B I : Set P : I → Set Q : Size → I → Set f : I → I lemma₁ : (R : I → Set) → (∀ x → R (f x) → R x) → ∀ x → R x → R (f x) lemma₂ : ∀ i x → Q i (f x) → Q i x works : ∀ i x → Q i (f x) × P x → Q i (f (f x)) × P x works i x = map (Q i (f x)) (P x) (Q i (f (f x))) (lemma₁ (Q i) (λ y → lemma₂ i y) (f x)) -- Replacing any underscore by its solution or parts of its solution -- makes the internal error disappear. lemma₃ : ∀ i x → Q i (f x) × P x → Q i (f (f x)) × P x lemma₃ i x = map (Q _ _) (P x) (Q _ (f (f x))) (lemma₁ _ (λ y → lemma₂ _ _) _)
{ "alphanum_fraction": 0.5549242424, "avg_line_length": 25.756097561, "ext": "agda", "hexsha": "48116aab17d681fa64d589bd6cbe7d55d2ecc248", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2637.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2637.agda", "max_line_length": 70, "max_stars_count": 2, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2637.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 388, "size": 1056 }
{-# OPTIONS --without-K --safe #-} open import Algebra module Magma.Properties {a ℓ} (M : Magma a ℓ) where open Magma M
{ "alphanum_fraction": 0.6507936508, "avg_line_length": 12.6, "ext": "agda", "hexsha": "312b39f3ce807a901ffad003a0037c20e0c90cdf", "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": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_forks_repo_path": "src/Magma/Properties.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_issues_repo_issues_event_max_datetime": "2021-10-09T08:24:56.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-04T05:30:30.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_issues_repo_path": "src/Magma/Properties.agda", "max_line_length": 34, "max_stars_count": 2, "max_stars_repo_head_hexsha": "443e831e536b756acbd1afd0d6bae7bc0d288048", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Akshobhya1234/agda-NonAssociativeAlgebra", "max_stars_repo_path": "src/Magma/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-17T09:14:03.000Z", "max_stars_repo_stars_event_min_datetime": "2021-08-15T06:16:13.000Z", "num_tokens": 39, "size": 126 }
module RationalUtils where open import Algebra import Algebra.Morphism.RingMonomorphism as RingMonomorphisms open import Data.Rational open import Data.Rational.Properties open import Data.Nat using (z≤n; s≤s) open import Data.Integer using (+≤+; +<+; +_; -[1+_]) open import Data.Product using (_×_; _,_) open import Data.Sum open import Function.Base using (_∘_; _∘′_) open import Level using (0ℓ) open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Relation.Nullary using (yes; no) open import Relation.Nullary.Negation using (contradiction) open import Vehicle.Data.Tensor open ≤-Reasoning private variable p q : ℚ private module +-*-Monomorphism = RingMonomorphisms toℚᵘ-isRingMonomorphism-+-* ------------------------------------------------------------------------ -- Things to work out how to put in standard library 2ℚ = + 2 / 1 3ℚ = + 3 / 1 ≰⇒≥ : _≰_ ⇒ _≥_ ≰⇒≥ = <⇒≤ ∘′ ≰⇒> p≤0⇒∣p∣≡-p : p ≤ 0ℚ → ∣ p ∣ ≡ - p p≤0⇒∣p∣≡-p {mkℚ +[1+ n ] _ _} p≤0 = contradiction (nonPositive p≤0) λ() p≤0⇒∣p∣≡-p {mkℚ +0 _ _} _ = refl p≤0⇒∣p∣≡-p {mkℚ -[1+ n ] _ _} _ = refl neg-involutive : Involutive _≡_ (-_) neg-involutive (mkℚ +[1+ n ] _ _) = refl neg-involutive (mkℚ +0 _ _) = refl neg-involutive (mkℚ -[1+ n ] _ _) = refl p≤∣p∣ : ∀ p → p ≤ ∣ p ∣ p≤∣p∣ p with 0ℚ ≤? p ... | yes 0≤p = ≤-reflexive (sym (0≤p⇒∣p∣≡p 0≤p)) ... | no 0≰p = ≤-trans (≰⇒≥ 0≰p) (0≤∣p∣ p) -p≤∣p∣ : ∀ p → - p ≤ ∣ p ∣ -p≤∣p∣ p with 0ℚ ≤? p ... | yes 0≤p = ≤-trans (neg-antimono-≤ 0≤p) (0≤∣p∣ p) ... | no 0≰p = ≤-reflexive (sym (p≤0⇒∣p∣≡-p (≰⇒≥ 0≰p))) -p≤q⇒-q≤p : - p ≤ q → - q ≤ p -p≤q⇒-q≤p {p} {q} = subst (- q ≤_) (neg-involutive p) ∘ neg-antimono-≤ p≤-q⇒q≤-p : p ≤ - q → q ≤ - p p≤-q⇒q≤-p {p} {q} = subst (_≤ - p) (neg-involutive q) ∘ neg-antimono-≤ -p<q⇒-q<p : - p < q → - q < p -p<q⇒-q<p {p} {q} = subst (- q <_) (neg-involutive p) ∘ neg-antimono-< p<-q⇒q<-p : p < - q → q < - p p<-q⇒q<-p {p} {q} = subst (_< - p) (neg-involutive q) ∘ neg-antimono-< postulate p-[p+q]≡q : ∀ p q → p - (p + q) ≡ q postulate p+q-p≡q : ∀ p q → p + q - p ≡ q postulate p-q+q≡p : ∀ p q → p - q + q ≡ p postulate *-monoʳ-≤ : ∀ r → Positive r → (r *_) Preserves _≤_ ⟶ _≤_ postulate p<r-q⇒p+q<r : ∀ p q r → p < r - q → p + q < r ∣p∣≤q⇒-q≤p≤q : ∀ p → ∣ p ∣ ≤ q → - q ≤ p × p ≤ q ∣p∣≤q⇒-q≤p≤q p ∣p∣≤q = -p≤q⇒-q≤p (≤-trans (-p≤∣p∣ p) ∣p∣≤q) , ≤-trans (p≤∣p∣ p) ∣p∣≤q -p≤q≤p⇒∣q∣≤p : - p ≤ q → q ≤ p → ∣ q ∣ ≤ p -p≤q≤p⇒∣q∣≤p {p} {q} -q≤p q≤p with ∣p∣≡p∨∣p∣≡-p q ... | inj₁ ∣q∣≡q = subst (_≤ p) (sym ∣q∣≡q) q≤p ... | inj₂ ∣q∣≡-q = subst (_≤ p) (sym ∣q∣≡-q) (-p≤q⇒-q≤p -q≤p) ∣p∣<q⇒-q<p<q : ∀ p → ∣ p ∣ < q → - q < p × p < q ∣p∣<q⇒-q<p<q p ∣p∣<q = -p<q⇒-q<p (≤-<-trans (-p≤∣p∣ p) ∣p∣<q) , ≤-<-trans (p≤∣p∣ p) ∣p∣<q -p<q<p⇒∣q∣<p : - p < q → q < p → ∣ q ∣ < p -p<q<p⇒∣q∣<p {p} {q} -p<q q<p with ∣p∣≡p∨∣p∣≡-p q ... | inj₁ ∣q∣≡q = subst (_< p) (sym ∣q∣≡q) q<p ... | inj₂ ∣q∣≡-q = subst (_< p) (sym ∣q∣≡-q) (-p<q⇒-q<p -p<q) p+q-q≡p : ∀ p q → p + q - q ≡ p p+q-q≡p p q = begin-equality p + q - q ≡⟨ +-assoc p q (- q) ⟩ p + (q - q) ≡⟨ cong (λ v → p + v) (+-inverseʳ q) ⟩ p + 0ℚ ≡⟨ +-identityʳ p ⟩ p ∎ +-isCommutativeSemigroup : IsCommutativeSemigroup _≡_ _+_ +-isCommutativeSemigroup = isCommutativeSemigroup where open IsCommutativeMonoid +-0-isCommutativeMonoid +-commutativeSemigroup : CommutativeSemigroup 0ℓ 0ℓ +-commutativeSemigroup = record { isCommutativeSemigroup = +-isCommutativeSemigroup } 2*p≡p+p : ∀ p → 2ℚ * p ≡ p + p 2*p≡p+p p = begin-equality 2ℚ * p ≡⟨⟩ (1ℚ + 1ℚ) * p ≡⟨ *-distribʳ-+ p 1ℚ 1ℚ ⟩ 1ℚ * p + 1ℚ * p ≡⟨ cong₂ _+_ (*-identityˡ p) (*-identityˡ p) ⟩ p + p ∎
{ "alphanum_fraction": 0.5111413043, "avg_line_length": 29.44, "ext": "agda", "hexsha": "07bee4507b422c2169a7f08c3e425f15dee44fd4", "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": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "vehicle-lang/vehicle", "max_forks_repo_path": "examples/windController/agdaProof/RationalUtils.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_issues_repo_issues_event_max_datetime": "2022-03-31T20:49:39.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-07T14:09:13.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "vehicle-lang/vehicle", "max_issues_repo_path": "examples/windController/agdaProof/RationalUtils.agda", "max_line_length": 73, "max_stars_count": 9, "max_stars_repo_head_hexsha": "25842faea65b4f7f0f7b1bb11ea6e4bf3f4a59b0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "vehicle-lang/vehicle", "max_stars_repo_path": "examples/windController/agdaProof/RationalUtils.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-17T18:51:05.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-10T12:56:42.000Z", "num_tokens": 2062, "size": 3680 }
module _ where open import Common.Prelude open import Common.String record IsString {a} (A : Set a) : Set a where field fromString : String → A open IsString {{...}} public {-# BUILTIN FROMSTRING fromString #-} instance StringIsString : IsString String StringIsString = record { fromString = λ s → s } ListIsString : IsString (List Char) ListIsString = record { fromString = stringToList } foo : List Char foo = "foo" open import Common.Equality thm : "foo" ≡ 'f' ∷ 'o' ∷ 'o' ∷ [] thm = refl
{ "alphanum_fraction": 0.6737864078, "avg_line_length": 18.3928571429, "ext": "agda", "hexsha": "20308bfeefe1e36e9f868aeb4ff805ab85930c1b", "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/OverloadedString.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/OverloadedString.agda", "max_line_length": 53, "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/OverloadedString.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": 155, "size": 515 }
module maybe-thms where open import eq open import level open import maybe open import product open import sum maybe-dec : ∀ {ℓ}{A : Set ℓ}(x : maybe A) → x ≡ nothing ∨ Σ A (λ a → x ≡ just a) maybe-dec nothing = inj₁ refl maybe-dec (just a) = inj₂ (a , refl)
{ "alphanum_fraction": 0.6769230769, "avg_line_length": 23.6363636364, "ext": "agda", "hexsha": "3b8da0d318d5127894bebedba398fd38126e9a05", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "maybe-thms.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "maybe-thms.agda", "max_line_length": 80, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "maybe-thms.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 90, "size": 260 }
open import SOAS.Metatheory.Syntax -- Unit law of metasubstitution module SOAS.Metatheory.SecondOrder.Unit {T : Set}(Syn : Syntax {T}) where open Syntax Syn open import SOAS.Metatheory.FreeMonoid Syn open import SOAS.Metatheory.SecondOrder.Metasubstitution Syn open import SOAS.Families.Core {T} open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Construction.Structure as Structure open import SOAS.ContextMaps.Combinators open import SOAS.ContextMaps.CategoryOfRenamings {T} import SOAS.Abstract.Coalgebra {T} as →□ open →□.Sorted open →□.Unsorted using (⊤ᵇ) renaming (Coalg to UCoalg ; Coalg⇒ to UCoalg⇒) import SOAS.Abstract.Box {T} as □ ; open □.Sorted open import SOAS.Abstract.Monoid open import SOAS.Abstract.ExpStrength open import SOAS.Coalgebraic.Monoid open import SOAS.Metatheory Syn open import SOAS.Metatheory.Monoid ⅀F ⅀:Str open import SOAS.ContextMaps.Properties open Theory private variable Γ Δ Π : Ctx α β : T 𝔛 𝔜 ℨ : Familyₛ -- Metasubstitution unit is a coalgebra homomorphisem from ⊤ ms-unitᵇ⇒ : UCoalg⇒ ⊤ᵇ [ 𝔛 ⊸ (𝕋ᵇ 𝔛) ]ᵇ (λ _ → ms-unit) ms-unitᵇ⇒ {𝔛} = record { ⟨r⟩ = λ{ {Γ = Γ}{Δ}{ρ} → iext (dext λ {Π} 𝔪 → sym (begin 𝕣𝕖𝕟 𝔛 (ms-unit 𝔪) (Π ∔∣ ρ) ≡⟨ Renaming.𝕥⟨𝕞⟩ 𝔛 ⟩ 𝕞𝕧𝕒𝕣 𝔛 𝔪 (λ p → 𝕣𝕖𝕟 𝔛 (𝕧𝕒𝕣 𝔛 (inl Π p)) (Π ∔∣ ρ)) ≡⟨ 𝕞≈₂ 𝔛 (λ v → Renaming.𝕥⟨𝕧⟩ 𝔛) ⟩ 𝕞𝕧𝕒𝕣 𝔛 𝔪 (λ v → 𝕧𝕒𝕣 𝔛 ((Π ∔∣ ρ) (inl Π v))) ≡⟨ 𝕞≈₂ 𝔛 (λ v → cong (𝕧𝕒𝕣 𝔛) (∔.+₁∘i₁ {f = id′ᵣ Π}{g = ρ})) ⟩ 𝕞𝕧𝕒𝕣 𝔛 𝔪 (λ v → 𝕧𝕒𝕣 𝔛 (∔.i₁ v)) ∎))} } where open ≡-Reasoning -- Right unit of metasubstitution □msub-runitᵃ⇒ : MetaAlg⇒ 𝔛 (𝕋ᵃ 𝔛) (□ᵃ 𝔛 (𝕋ᵃ 𝔛)) λ t ρ → □msub t ρ ms-unit □msub-runitᵃ⇒ {𝔛} = record { ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → dext λ ρ → begin □msub (𝕒𝕝𝕘 𝔛 t) ρ ms-unit ≡⟨ cong (λ - → - ms-unit) □MS.𝕥⟨𝕒⟩ ⟩ 𝕒𝕝𝕘 𝔛 (□estr [ 𝔛 ⊸ 𝕋ᵇ 𝔛 ]ᵇ (𝕋 𝔛) (⅀₁ □msub t) ρ ms-unit) ≡⟨ cong (𝕒𝕝𝕘 𝔛) (estr-unit′ ms-unitᵇ⇒) ⟩ 𝕒𝕝𝕘 𝔛 (⅀₁ (λ e′ → e′ ms-unit) (str ℐᴮ ⟅ 𝔛 ⇨ 𝕋 𝔛 ⟆ (⅀₁ □msub t) ρ)) ≡˘⟨ cong (𝕒𝕝𝕘 𝔛) (str-nat₂ ((λ e′ → e′ ms-unit)) (⅀₁ □msub t) ρ) ⟩ 𝕒𝕝𝕘 𝔛 (str ℐᴮ (𝕋 𝔛) (⅀₁ (λ { h′ ς → h′ ς ms-unit }) (⅀₁ □msub t)) ρ) ≡˘⟨ congr ⅀.homomorphism (λ - → 𝕒𝕝𝕘 𝔛 (str ℐᴮ (𝕋 𝔛) - ρ)) ⟩ 𝕒𝕝𝕘 𝔛 (str ℐᴮ (𝕋 𝔛) (⅀₁ (λ{ t ρ → □msub t ρ ms-unit}) t) ρ) ∎ } ; ⟨𝑣𝑎𝑟⟩ = λ{ {v = v} → dext λ ρ → cong (λ - → - ms-unit) □MS.𝕥⟨𝕧⟩} ; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{ε} → dext λ ρ → begin □msub (𝕞𝕧𝕒𝕣 𝔛 𝔪 ε) ρ ms-unit ≡⟨ cong (λ - → - ms-unit) □MS.𝕥⟨𝕞⟩ ⟩ 𝕤𝕦𝕓 𝔛 (ms-unit 𝔪) (copair (𝕋 𝔛) (λ v → □msub (ε v) ρ ms-unit) (𝕧𝕒𝕣 𝔛)) ≡⟨ Substitution.𝕥⟨𝕞⟩ 𝔛 ⟩ 𝕞𝕧𝕒𝕣 𝔛 𝔪 (λ v → 𝕤𝕦𝕓 𝔛 (𝕧𝕒𝕣 𝔛 (∔.i₁ v)) (copair (𝕋 𝔛) (λ v → □msub (ε v) ρ ms-unit) (𝕧𝕒𝕣 𝔛))) ≡⟨ 𝕞≈₂ 𝔛 (λ v → begin 𝕤𝕦𝕓 𝔛 (𝕧𝕒𝕣 𝔛 (∔.i₁ v)) (copair (𝕋 𝔛) (λ 𝔫 → □msub (ε 𝔫) ρ ms-unit) (𝕧𝕒𝕣 𝔛)) ≡⟨ Mon.lunit (𝕋ᵐ 𝔛) ⟩ copair (𝕋 𝔛) (λ 𝔫 → □msub (ε 𝔫) ρ ms-unit) (𝕧𝕒𝕣 𝔛) (∔.i₁ v) ≡⟨ copair∘i₁ (𝕋 𝔛) v ⟩ □msub (ε v) ρ ms-unit ∎) ⟩ 𝕞𝕧𝕒𝕣 𝔛 𝔪 (λ v → □msub (ε v) ρ ms-unit) ∎ } } where open ≡-Reasoning □msub-runit : (t : 𝕋 𝔛 α Γ)(ρ : Γ ↝ Δ) → □msub t ρ ms-unit ≡ 𝕣𝕖𝕟 𝔛 t ρ □msub-runit {𝔛} t ρ = sym (cong (λ - → - ρ) (Renaming.𝕤𝕖𝕞! 𝔛 □msub-runitᵃ⇒ t))
{ "alphanum_fraction": 0.5499691548, "avg_line_length": 36.0222222222, "ext": "agda", "hexsha": "a4943725a166ba31530c8405656efbe096ba5010", "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/SecondOrder/Unit.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/SecondOrder/Unit.agda", "max_line_length": 100, "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/SecondOrder/Unit.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": 2041, "size": 3242 }
module RandomAccessList.Zeroless.Properties where open import BuildingBlock open import BuildingBlock.BinaryLeafTree using (BinaryLeafTree; Node; Leaf; split) open import RandomAccessList.Zeroless.Core open import RandomAccessList.Zeroless.Core.Properties open import RandomAccessList.Zeroless open import Data.Unit using (tt) open import Data.Nat open import Data.Nat.Etc open import Data.Nat.Properties.Simple open import Data.Product as Prod open import Function open import Relation.Nullary using (Dec; yes; no; ¬_) open import Relation.Nullary.Decidable using (False; True; fromWitnessFalse; fromWitness) open import Relation.Nullary.Negation using (contradiction; contraposition) open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_; refl; cong; cong₂; trans; sym; inspect) open PropEq.≡-Reasoning tailₙ-suc : ∀ {n A} → (xs : 1-2-RAL A n) → (p : ⟦ xs ⟧ ≢ 0) → suc ⟦ tailₙ xs p ⟧ₙ ≡ ⟦ xs ⟧ₙ tailₙ-suc {n} {A} [] p = contradiction (⟦[]⟧≡0 ([] {A} {n}) refl) p tailₙ-suc (x 1∷ xs) p with ⟦ xs ⟧ ≟ 0 tailₙ-suc {n} (x 1∷ xs) p | yes q = begin suc 0 ≡⟨ cong suc (sym (*-right-zero 0)) ⟩ suc (2 * 0) ≡⟨ cong (λ w → suc (2 * w)) (sym (no-zero-divisor (2 * 2 ^ n) ⟦ xs ⟧ₙ (m^n≢0 2 (suc n) (λ ())) q)) ⟩ suc (2 * ⟦ xs ⟧ₙ) ∎ tailₙ-suc (x 1∷ xs) p | no ¬q = begin 3 + 2 * ⟦ tailₙ xs ¬q ⟧ₙ ≡⟨ cong suc (sym (+-*-suc 2 ⟦ tailₙ xs ¬q ⟧ₙ)) ⟩ 1 + 2 * suc ⟦ tailₙ xs ¬q ⟧ₙ ≡⟨ cong (λ w → 1 + 2 * w) (tailₙ-suc xs ¬q) ⟩ 1 + (2 * ⟦ xs ⟧ₙ) ∎ tailₙ-suc (x , y 2∷ xs) p = refl tail-suc : ∀ {A} → (xs : 1-2-RAL A 0) → (p : ⟦ xs ⟧ ≢ 0) → suc ⟦ tail xs p ⟧ ≡ ⟦ xs ⟧ tail-suc {A} [] p = contradiction (⟦[]⟧≡0 ([] {A} {0}) refl) p tail-suc (x 1∷ xs) p with ⟦ xs ⟧ ≟ 0 tail-suc (x 1∷ xs) p | yes q = cong (λ w → suc (w + 0)) (sym q) tail-suc (x 1∷ xs) p | no ¬q = begin 3 + 2 * ⟦ tailₙ xs ¬q ⟧ₙ + 0 ≡⟨ cong (λ w → 1 + w + 0) (sym (+-*-suc 2 ⟦ tailₙ xs ¬q ⟧ₙ)) ⟩ 1 + 2 * suc ⟦ tailₙ xs ¬q ⟧ₙ + 0 ≡⟨ cong (λ w → 1 + 2 * w + 0) (tailₙ-suc xs ¬q) ⟩ 1 + 2 * ⟦ xs ⟧ₙ + 0 ∎ tail-suc (x , y 2∷ xs) p = refl
{ "alphanum_fraction": 0.5592286501, "avg_line_length": 36.9152542373, "ext": "agda", "hexsha": "d492180ff25aac37df7ebbd68ee2eda4522bf985", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z", "max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/numeral", "max_forks_repo_path": "legacy/RandomAccessList/Zeroless/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "banacorn/numeral", "max_issues_repo_path": "legacy/RandomAccessList/Zeroless/Properties.agda", "max_line_length": 104, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/numeral", "max_stars_repo_path": "legacy/RandomAccessList/Zeroless/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z", "num_tokens": 945, "size": 2178 }
{-# OPTIONS --cubical --safe #-} module HITs.PropositionalTruncation where open import Cubical.HITs.PropositionalTruncation using (squash; ∥_∥; ∣_∣) renaming (recPropTrunc to rec; recPropTrunc→Set to rec→set) public
{ "alphanum_fraction": 0.7455357143, "avg_line_length": 24.8888888889, "ext": "agda", "hexsha": "b253e8d6876164a73eee44c6896d171ff97baf34", "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": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/HITs/PropositionalTruncation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/HITs/PropositionalTruncation.agda", "max_line_length": 61, "max_stars_count": null, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/HITs/PropositionalTruncation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 76, "size": 224 }
{- 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 Util.Prelude ------------------------------------------------------------------------------ open import Agda.Builtin.Float module LibraBFT.Impl.OBM.Rust.RustTypes where -- TODO-2 : reasoning about integer overflow F64 : Set F64 = Float -- This is 'Double' in Haskell. In Agda, 'Float' is represented as a Haskell 'Double'. U64 : Set U64 = ℕ U128 : Set U128 = ℕ Usize : Set Usize = ℕ postulate -- TODO-1: VecDeque, vdNew VecDeque : Set vdNew : VecDeque
{ "alphanum_fraction": 0.6477115118, "avg_line_length": 22.53125, "ext": "agda", "hexsha": "d3c44c8916af9303b36b1694080c6d1925a303b6", "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/OBM/Rust/RustTypes.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/OBM/Rust/RustTypes.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/OBM/Rust/RustTypes.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 194, "size": 721 }
-- Andreas, 2014-07-02 Documenting the ETA pragma open import Common.Equality mutual data Colist (A : Set) : Set where [] : Colist A _∷_ : A → ∞Colist A → Colist A record ∞Colist (A : Set) : Set where eta-equality coinductive constructor delay field force : Colist A open ∞Colist -- By default, recursive records do not have eta, -- but it can be turned on by force. -- In case of colists, it is ok, since there is no -- infinite eta-expansion (unlike for streams). test : {A : Set} (x : ∞Colist A) → x ≡ delay (force x) test x = refl
{ "alphanum_fraction": 0.6486956522, "avg_line_length": 23, "ext": "agda", "hexsha": "e306784075bbfb2f836f43a011425dabf992510b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Succeed/EtaColist.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Succeed/EtaColist.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/Succeed/EtaColist.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 185, "size": 575 }
record Foo : Set where cppattern -- Typo here no-eta-equality
{ "alphanum_fraction": 0.5465116279, "avg_line_length": 21.5, "ext": "agda", "hexsha": "b5d2179cecd29d899233f63dd4e1b4088f9ca32b", "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": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/issue5072.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "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-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/issue5072.agda", "max_line_length": 44, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/issue5072.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 22, "size": 86 }
-- Andreas, 2016-12-30, issue #1886, reported by nad -- {-# OPTIONS -v tc.data:40 -v scope.data.def:40 -v tc.decl:10 #-} data D (X : Set) : Set data D (X : Set Set) where
{ "alphanum_fraction": 0.6091954023, "avg_line_length": 21.75, "ext": "agda", "hexsha": "5ce9801a1984bcc1d57d5141833607ecdfd8b8d7", "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/Issue1886.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/Issue1886.agda", "max_line_length": 67, "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/Issue1886.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": 65, "size": 174 }
------------------------------------------------------------------------ -- The "terminates" relation ------------------------------------------------------------------------ open import Atom module Termination (atoms : χ-atoms) where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude open import Chi atoms open import Deterministic atoms open import Propositional atoms -- Terminates e means that e terminates with a value. Terminates : Exp → Type Terminates p = ∃ λ v → p ⇓ v -- This relation is propositional. Terminates-propositional : ∀ {e} → Is-proposition (Terminates e) Terminates-propositional (_ , e₁) (_ , e₂) = Σ-≡,≡→≡ (⇓-deterministic e₁ e₂) (⇓-propositional _ _)
{ "alphanum_fraction": 0.5723684211, "avg_line_length": 25.3333333333, "ext": "agda", "hexsha": "60dc07cf49f63eadad60cdfc3eb0f805cd091bda", "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": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/chi", "max_forks_repo_path": "src/Termination.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_issues_repo_issues_event_max_datetime": "2020-06-08T11:08:25.000Z", "max_issues_repo_issues_event_min_datetime": "2020-05-21T23:29:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/chi", "max_issues_repo_path": "src/Termination.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/chi", "max_stars_repo_path": "src/Termination.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-20T16:27:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:07.000Z", "num_tokens": 190, "size": 760 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.NType2 open import lib.types.Pi open import lib.types.Group open import lib.types.Int open import lib.types.List open import lib.types.Word open import lib.types.SetQuotient open import lib.groups.Homomorphism module lib.groups.GeneratedGroup {i m} where module GeneratedGroup (A : Type i) (R : Rel (Word A) m) where -- [qwr-sym] is not needed, but it seems more principled to -- make [QuotWordRel] an equivalence relation. data QuotWordRel : Word A → Word A → Type (lmax i m) where qwr-refl : ∀ {l₁ l₂} → l₁ == l₂ → QuotWordRel l₁ l₂ qwr-trans : ∀ {l₁ l₂ l₃} → QuotWordRel l₁ l₂ → QuotWordRel l₂ l₃ → QuotWordRel l₁ l₃ qwr-sym : ∀ {l₁ l₂} → QuotWordRel l₁ l₂ → QuotWordRel l₂ l₁ qwr-cong : ∀ {l₁ l₂ l₃ l₄} → QuotWordRel l₁ l₂ → QuotWordRel l₃ l₄ → QuotWordRel (l₁ ++ l₃) (l₂ ++ l₄) qwr-flip-r : ∀ x₁ → QuotWordRel (x₁ :: flip x₁ :: nil) nil qwr-rel : ∀ {l₁ l₂} → R l₁ l₂ → QuotWordRel l₁ l₂ qwr-cong-l : ∀ {l₁ l₂} → QuotWordRel l₁ l₂ → ∀ l₃ → QuotWordRel (l₁ ++ l₃) (l₂ ++ l₃) qwr-cong-l qwr l₃ = qwr-cong qwr (qwr-refl idp) qwr-cong-r : ∀ l₁ {l₂ l₃} → QuotWordRel l₂ l₃ → QuotWordRel (l₁ ++ l₂) (l₁ ++ l₃) qwr-cong-r l₁ qwr = qwr-cong (qwr-refl (idp {a = l₁})) qwr abstract infixr 10 _qwr⟨_⟩_ infixr 10 _qwr⟨id⟩_ infix 15 _qwr∎ _qwr⟨_⟩_ : ∀ l₁ {l₂ l₃} → QuotWordRel l₁ l₂ → QuotWordRel l₂ l₃ → QuotWordRel l₁ l₃ _ qwr⟨ p ⟩ q = qwr-trans p q _qwr⟨id⟩_ : ∀ l₁ {l₂} → QuotWordRel l₁ l₂ → QuotWordRel l₁ l₂ _ qwr⟨id⟩ q = q _qwr∎ : ∀ l → QuotWordRel l l _ qwr∎ = qwr-refl idp qwr-flip-l : ∀ x₁ → QuotWordRel (flip x₁ :: x₁ :: nil) nil qwr-flip-l x₁ = flip x₁ :: x₁ :: nil qwr⟨ qwr-refl (ap (λ s → flip x₁ :: s :: nil) (! (flip-flip x₁))) ⟩ flip x₁ :: flip (flip x₁) :: nil qwr⟨ qwr-flip-r (flip x₁) ⟩ nil qwr∎ -- The quotient QuotWord : Type (lmax i m) QuotWord = SetQuot QuotWordRel qw[_] : Word A → QuotWord qw[_] = q[_] {- In the case where this module is used to realize some free construction F (e.g. free group, free abelian group), this function becomes the unit of the adjunction F -| U (where U is the forgetful functor). -} insert : A → QuotWord insert a = qw[ inl a :: nil ] module QuotWordElim {k} {P : QuotWord → Type k} {{_ : {x : QuotWord} → is-set (P x)}} (incl* : (a : Word A) → P qw[ a ]) (rel* : ∀ {a₁ a₂} (r : QuotWordRel a₁ a₂) → incl* a₁ == incl* a₂ [ P ↓ quot-rel r ]) = SetQuotElim incl* rel* open QuotWordElim public renaming (f to QuotWord-elim) hiding (quot-rel-β) module QuotWordRec {k} {B : Type k} {{_ : is-set B}} (incl* : Word A → B) (rel* : ∀ {a₁ a₂} (r : QuotWordRel a₁ a₂) → incl* a₁ == incl* a₂) = SetQuotRec incl* rel* open QuotWordRec public renaming (f to QuotWord-rec) private infixl 80 _⊞_ _⊞_ : QuotWord → QuotWord → QuotWord _⊞_ = QuotWord-rec (λ l₁ → QuotWord-rec (λ l₂ → qw[ l₁ ++ l₂ ]) (λ r → quot-rel $ qwr-cong-r l₁ r)) (λ {l₁} {l₁'} r → λ= $ QuotWord-elim (λ l₂ → quot-rel $ qwr-cong-l r l₂) (λ _ → prop-has-all-paths-↓)) abstract qwr-cancel-l : ∀ l → QuotWordRel (Word-inverse l ++ l) nil qwr-cancel-l nil = qwr-refl idp qwr-cancel-l (x :: l) = Word-inverse (x :: l) ++ (x :: l) qwr⟨id⟩ (Word-inverse l ++ (flip x :: nil)) ++ (x :: l) qwr⟨ qwr-refl (++-assoc (reverse (Word-flip l)) (flip x :: nil) (x :: l)) ⟩ Word-inverse l ++ ((flip x :: nil) ++ (x :: l)) qwr⟨id⟩ Word-inverse l ++ (flip x :: x :: l) qwr⟨ qwr-cong-r (reverse (Word-flip l)) (qwr-cong-l (qwr-flip-l x) l) ⟩ Word-inverse l ++ l qwr⟨ qwr-cancel-l l ⟩ nil qwr∎ qwr-cancel-r : ∀ l → QuotWordRel (l ++ Word-inverse l) nil qwr-cancel-r l = l ++ Word-inverse l qwr⟨ qwr-refl (ap (_++ Word-inverse l) (! (Word-inverse-inverse l))) ⟩ Word-inverse (Word-inverse l) ++ Word-inverse l qwr⟨ qwr-cancel-l (Word-inverse l) ⟩ nil qwr∎ qwr-cong-inverse : ∀ {l₁ l₂} → QuotWordRel l₁ l₂ → QuotWordRel (Word-inverse l₁) (Word-inverse l₂) qwr-cong-inverse {l₁} {l₂} r = Word-inverse l₁ qwr⟨ qwr-refl (! (++-unit-r (Word-inverse l₁))) ⟩ Word-inverse l₁ ++ nil qwr⟨ qwr-cong-r (Word-inverse l₁) (qwr-sym (qwr-cancel-r l₂)) ⟩ Word-inverse l₁ ++ (l₂ ++ Word-inverse l₂) qwr⟨ qwr-cong-r (Word-inverse l₁) (qwr-cong-l (qwr-sym r) (Word-inverse l₂)) ⟩ reverse (Word-flip l₁) ++ (l₁ ++ Word-inverse l₂) qwr⟨ qwr-refl (! (++-assoc (Word-inverse l₁) l₁ (Word-inverse l₂))) ⟩ (Word-inverse l₁ ++ l₁) ++ Word-inverse l₂ qwr⟨ qwr-cong-l (qwr-cancel-l l₁) (Word-inverse l₂) ⟩ Word-inverse l₂ qwr∎ ⊟ : QuotWord → QuotWord ⊟ = QuotWord-rec (qw[_] ∘ Word-inverse) (λ r → quot-rel $ qwr-cong-inverse r) ⊞-unit : QuotWord ⊞-unit = qw[ nil ] abstract ⊞-unit-l : ∀ g → ⊞-unit ⊞ g == g ⊞-unit-l = QuotWord-elim (λ _ → idp) (λ _ → prop-has-all-paths-↓) ⊞-assoc : ∀ g₁ g₂ g₃ → (g₁ ⊞ g₂) ⊞ g₃ == g₁ ⊞ (g₂ ⊞ g₃) ⊞-assoc = QuotWord-elim (λ l₁ → QuotWord-elim (λ l₂ → QuotWord-elim (λ l₃ → ap qw[_] $ ++-assoc l₁ l₂ l₃) (λ _ → prop-has-all-paths-↓)) (λ _ → prop-has-all-paths-↓)) (λ _ → prop-has-all-paths-↓) ⊟-inv-l : ∀ g → (⊟ g) ⊞ g == ⊞-unit ⊟-inv-l = QuotWord-elim (λ l → quot-rel (qwr-cancel-l l)) (λ _ → prop-has-all-paths-↓) QuotWord-group-structure : GroupStructure QuotWord QuotWord-group-structure = record { ident = ⊞-unit ; inv = ⊟ ; comp = _⊞_ ; unit-l = ⊞-unit-l ; assoc = ⊞-assoc ; inv-l = ⊟-inv-l } GenGroup : Group (lmax i m) GenGroup = group _ QuotWord-group-structure module GenGroup = Group GenGroup open GenGroup using (El) public abstract pres-exp : ∀ (a : A) z → qw[ Word-exp a z ] == GenGroup.exp qw[ inl a :: nil ] z pres-exp a (pos O) = idp pres-exp a (pos (S O)) = idp pres-exp a (pos (S (S n))) = ap (GenGroup.comp qw[ inl a :: nil ]) (pres-exp a (pos (S n))) pres-exp a (negsucc O) = idp pres-exp a (negsucc (S n)) = ap (GenGroup.comp qw[ inr a :: nil ]) (pres-exp a (negsucc n)) rel-holds : ∀ {w₁} {w₂} (r : R w₁ w₂) → qw[ w₁ ] == qw[ w₂ ] rel-holds r = quot-rel (qwr-rel r) -- freeness module HomomorphismEquiv {j} (G : Group j) where private module G = Group G open RelationRespectingFunctions A R G public module _ (fun : RelationRespectingFunction) where private module fun = RelationRespectingFunction fun f* = fun.f abstract Word-extendᴳ-emap : ∀ {l₁ l₂} → QuotWordRel l₁ l₂ → Word-extendᴳ G f* l₁ == Word-extendᴳ G f* l₂ Word-extendᴳ-emap (qwr-refl idp) = idp Word-extendᴳ-emap (qwr-trans qwr qwr₁) = (Word-extendᴳ-emap qwr) ∙ (Word-extendᴳ-emap qwr₁) Word-extendᴳ-emap (qwr-sym qwr) = ! (Word-extendᴳ-emap qwr) Word-extendᴳ-emap (qwr-flip-r x) = G.comp (PlusMinus-extendᴳ G f* x) (PlusMinus-extendᴳ G f* (flip x)) =⟨ ap (G.comp (PlusMinus-extendᴳ G f* x)) (PlusMinus-extendᴳ-flip G f* x) ⟩ G.comp (PlusMinus-extendᴳ G f* x) (G.inv (PlusMinus-extendᴳ G f* x)) =⟨ G.inv-r (PlusMinus-extendᴳ G f* x) ⟩ G.ident =∎ Word-extendᴳ-emap (qwr-cong {l₁} {l₂} {l₃} {l₄} qwr qwr') = Word-extendᴳ G f* (l₁ ++ l₃) =⟨ Word-extendᴳ-++ G f* l₁ l₃ ⟩ G.comp (Word-extendᴳ G f* l₁) (Word-extendᴳ G f* l₃) =⟨ ap2 G.comp (Word-extendᴳ-emap qwr) (Word-extendᴳ-emap qwr') ⟩ G.comp (Word-extendᴳ G f* l₂) (Word-extendᴳ G f* l₄) =⟨ ! (Word-extendᴳ-++ G f* l₂ l₄) ⟩ Word-extendᴳ G f* (l₂ ++ l₄) =∎ Word-extendᴳ-emap (qwr-rel r) = fun.respects r extend : (GenGroup →ᴳ G) extend = record {M} where module M where f : QuotWord → G.El f = QuotWord-rec (Word-extendᴳ G f*) (λ r → Word-extendᴳ-emap r) abstract pres-comp : preserves-comp GenGroup.comp G.comp f pres-comp = QuotWord-elim (λ l₁ → QuotWord-elim (λ l₂ → Word-extendᴳ-++ G f* l₁ l₂) (λ _ → prop-has-all-paths-↓)) (λ _ → prop-has-all-paths-↓) private module Lemma (hom : GenGroup →ᴳ G) where private open GroupHom hom restr : A → G.El restr a = f qw[ inl a :: nil ] abstract PlusMinus-extendᴳ-hom : ∀ x → PlusMinus-extendᴳ G restr x == f qw[ x :: nil ] PlusMinus-extendᴳ-hom (inl x) = idp PlusMinus-extendᴳ-hom (inr x) = ! $ pres-inv qw[ inl x :: nil ] Word-extendᴳ-hom : ∀ l → Word-extendᴳ G restr l == f qw[ l ] Word-extendᴳ-hom nil = ! pres-ident Word-extendᴳ-hom (x :: nil) = PlusMinus-extendᴳ-hom x Word-extendᴳ-hom (x :: l@(_ :: _)) = G.comp (PlusMinus-extendᴳ G restr x) (Word-extendᴳ G restr l) =⟨ ap2 G.comp (PlusMinus-extendᴳ-hom x) (Word-extendᴳ-hom l) ⟩ G.comp (f qw[ x :: nil ]) (f qw[ l ]) =⟨ ! (pres-comp _ _) ⟩ f qw[ x :: l ] =∎ restr-respects-rel : ∀ {l₁ l₂} → R l₁ l₂ → Word-extendᴳ G restr l₁ == Word-extendᴳ G restr l₂ restr-respects-rel {l₁} {l₂} r = Word-extendᴳ G restr l₁ =⟨ Word-extendᴳ-hom l₁ ⟩ f qw[ l₁ ] =⟨ ap f (quot-rel (qwr-rel r)) ⟩ f qw[ l₂ ] =⟨ ! (Word-extendᴳ-hom l₂) ⟩ Word-extendᴳ G restr l₂ =∎ restrict : RelationRespectingFunction restrict = rel-res-fun restr restr-respects-rel open Lemma extend-is-equiv : is-equiv extend extend-is-equiv = is-eq _ from to-from from-to where to = extend from = restrict abstract to-from : ∀ h → to (from h) == h to-from h = group-hom= $ λ= $ QuotWord-elim (λ l → Word-extendᴳ-hom h l) (λ _ → prop-has-all-paths-↓) from-to : ∀ fun → from (to fun) == fun from-to fun = RelationRespectingFunction= (λ= λ a → idp) extend-equiv : RelationRespectingFunction ≃ (GenGroup →ᴳ G) extend-equiv = extend , extend-is-equiv
{ "alphanum_fraction": 0.5423040604, "avg_line_length": 36.1433447099, "ext": "agda", "hexsha": "705b27a9eac3d73443c0c88632dc8275258371e5", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "core/lib/groups/GeneratedGroup.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "core/lib/groups/GeneratedGroup.agda", "max_line_length": 106, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "core/lib/groups/GeneratedGroup.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": 4032, "size": 10590 }
module Nat.Class where open import Relation.Binary.PropositionalEquality open ≡-Reasoning record Nat (ℕ : Set) : Set₁ where field zero : ℕ succ : ℕ → ℕ ind : (P : ℕ → Set) → P zero → (∀ {k} → P k → P (succ k)) → ∀ n → P n _+_ : ℕ → ℕ → ℕ +-zero : ∀ {n} → zero + n ≡ n +-succ : ∀ {m n} → succ m + n ≡ m + succ n module _ {ℕ : Set} {{nn : Nat ℕ}} where open Nat nn +-succˡ : {m n : ℕ} → succ m + n ≡ succ (m + n) +-succˡ {m} {n} = ind Succˡ Succˡ-zero Succˡ-succ m n where Succˡ : ℕ → Set Succˡ m′ = ∀ n′ → succ m′ + n′ ≡ succ (m′ + n′) Succˡ-zero : Succˡ zero Succˡ-zero n′ = begin succ zero + n′ ≡⟨ +-succ ⟩ zero + succ n′ ≡⟨ +-zero ⟩ succ n′ ≡⟨ cong succ (sym +-zero) ⟩ succ (zero + n′) ∎ Succˡ-succ : ∀ {m′} → Succˡ m′ → Succˡ (succ m′) Succˡ-succ {m′} ih n′ = begin succ (succ m′) + n′ ≡⟨ +-succ ⟩ succ m′ + succ n′ ≡⟨ ih (succ n′) ⟩ succ (m′ + succ n′) ≡⟨ cong succ (sym +-succ) ⟩ succ (succ m′ + n′) ∎ +-succʳ : {m n : ℕ} → m + succ n ≡ succ (m + n) +-succʳ = trans (sym +-succ) +-succˡ +-assoc : {m n p : ℕ} → (m + n) + p ≡ m + (n + p) +-assoc {m} {n} {p} = ind Assoc Assoc-zero Assoc-succ m where Assoc : ℕ → Set Assoc k = (k + n) + p ≡ k + (n + p) Assoc-zero : Assoc zero Assoc-zero = begin (zero + n) + p ≡⟨ cong (_+ p) +-zero ⟩ n + p ≡⟨ sym +-zero ⟩ zero + (n + p) ∎ Assoc-succ : ∀ {k} → Assoc k → Assoc (succ k) Assoc-succ {k} ih = begin (succ k + n) + p ≡⟨ cong (_+ p) +-succˡ ⟩ succ (k + n) + p ≡⟨ +-succˡ ⟩ succ ((k + n) + p) ≡⟨ cong succ ih ⟩ succ (k + (n + p)) ≡⟨ sym +-succˡ ⟩ succ k + (n + p) ∎
{ "alphanum_fraction": 0.3989821883, "avg_line_length": 23.9634146341, "ext": "agda", "hexsha": "3de5919dcb02720d3ef7d172e70d92b665f47b95", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-28T12:49:47.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-28T12:49:47.000Z", "max_forks_repo_head_hexsha": "1b51e83acf193a556a61d44a4585a6467a383fa3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "iblech/agda-quotients", "max_forks_repo_path": "src/Nat/Class.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b51e83acf193a556a61d44a4585a6467a383fa3", "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": "iblech/agda-quotients", "max_issues_repo_path": "src/Nat/Class.agda", "max_line_length": 73, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b51e83acf193a556a61d44a4585a6467a383fa3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "iblech/agda-quotients", "max_stars_repo_path": "src/Nat/Class.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-29T13:10:27.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-29T13:10:27.000Z", "num_tokens": 783, "size": 1965 }
------------------------------------------------------------------------ -- Small parser combinator library used by Mixfix.Cyclic.Grammar ------------------------------------------------------------------------ module Mixfix.Cyclic.Lib where open import Algebra open import Codata.Musical.Notation open import Function using (const) open import Data.Bool using (Bool; true; false) open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.List using (List; []; _∷_; _++_) import Data.List.Properties private module LM {A : Set} = Monoid (Data.List.Properties.++-monoid A) open import Data.List.NonEmpty using (List⁺; _∷_; [_]; _∷⁺_) open import Data.Maybe using (Maybe; just; nothing; maybe) open import Data.Vec using (Vec; []; _∷_) open import Data.Product import Data.String.Properties as String open import Relation.Binary open DecSetoid String.≡-decSetoid using (_≟_) open import Relation.Nullary open import Relation.Binary.PropositionalEquality as P using (_≡_; refl) open import TotalParserCombinators.Parser renaming (_⊛_ to _⊛′_; _<$>_ to _<$>′_) import TotalParserCombinators.Lib as Lib open import Mixfix.Operator using (NamePart) private open module Tok = Lib.Token NamePart _≟_ using (tok) ------------------------------------------------------------------------ -- Programs -- Agda's termination checker only accepts corecursive definitions if -- they are /syntactically/ guarded by constructors. The following -- small language of "parser programs" reifies a selection of parser -- combinators as /constructors/. These constructors are then used in -- Mixfix.Cyclic.Grammar in order to ensure that Agda accepts the -- grammars defined there. infix 55 _+ infixl 50 _⊛_ _⊛∞_ _<$>_ infixl 5 _∣_ infixr 5 _∥_ data ParserProg : Set → Set₁ where fail : ∀ {R} → ParserProg R _∣_ : ∀ {R} (p₁ : ParserProg R) (p₂ : ParserProg R) → ParserProg R _⊛_ : ∀ {R₁ R₂} (p₁ : ParserProg (R₁ → R₂)) (p₂ : ParserProg R₁) → ParserProg R₂ _⊛∞_ : ∀ {R₁ R₂} (p₁ : ∞ (ParserProg (R₁ → R₂))) (p₂ : ∞ (ParserProg R₁)) → ParserProg R₂ _<$>_ : ∀ {R₁ R₂} (f : R₁ → R₂) (p : ParserProg R₁) → ParserProg R₂ _+ : ∀ {R} (p : ParserProg R) → ParserProg (List⁺ R) _between_ : ∀ {R n} (p : ∞ (ParserProg R)) (toks : Vec NamePart (1 + n)) → ParserProg (Vec R n) _∥_ : ∀ {I i} {R : I → Set} (p₁ : ParserProg (R i)) (p₂ : ParserProg (∃ R)) → ParserProg (∃ R) -- Interprets the parser programs as parsers. ⟦_⟧ : ∀ {R} → ParserProg R → Parser NamePart R [] ⟦ fail ⟧ = fail ⟦ p₁ ∣ p₂ ⟧ = ⟦ p₁ ⟧ ∣ ⟦ p₂ ⟧ ⟦ p₁ ⊛ p₂ ⟧ = ⟦ p₁ ⟧ ⊛′ ⟦ p₂ ⟧ ⟦ p₁ ⊛∞ p₂ ⟧ = ♯ ⟦ ♭ p₁ ⟧ ⊛′ ♯ ⟦ ♭ p₂ ⟧ ⟦ f <$> p ⟧ = f <$>′ ⟦ p ⟧ ⟦ p + ⟧ = one <$>′ ⟦ p ⟧ ⊛′ ♯ (⟦ just <$> p + ⟧ ∣ return nothing) where one = λ x → maybe (_∷⁺_ x) [ x ] ⟦ p between (t ∷ []) ⟧ = const [] <$>′ tok t ⟦ p between (t ∷ t′ ∷ ts) ⟧ = const _∷_ <$>′ tok t ⊛′ ♯ ⟦ ♭ p ⟧ ⊛′ ♯ ⟦ p between (t′ ∷ ts) ⟧ ⟦ p₁ ∥ p₂ ⟧ = -,_ <$>′ ⟦ p₁ ⟧ ∣ ⟦ p₂ ⟧ ------------------------------------------------------------------------ -- Semantics of the programs module Semantics where open import TotalParserCombinators.Semantics as Sem renaming ([_-_]_⊛_ to [_-_]_⊛′_) -- This definition may seem unnecessary: why not simply define -- -- x ∈⟦ p ⟧· s = x ∈ ⟦ p ⟧ · s? -- -- One reason is that it is hard for Agda to infer the value of p -- from ⟦ p ⟧ (note that ⟦_⟧ is a function which evaluates). By -- using the definition below this problem is avoided. A more -- important reason may be that the definition below ensures that -- the details of ⟦_⟧ do not need to be understood. infix 60 <$>_ infixl 50 _⊛_ _⊛∞_ infix 4 _∈⟦_⟧·_ data _∈⟦_⟧·_ : ∀ {R} → R → ParserProg R → List NamePart → Set₁ where ∣ˡ : ∀ {R x s} {p₁ : ParserProg R} {p₂ : ParserProg R} (x∈p₁ : x ∈⟦ p₁ ⟧· s) → x ∈⟦ p₁ ∣ p₂ ⟧· s ∣ʳ : ∀ {R x s} {p₁ : ParserProg R} {p₂ : ParserProg R} (x∈p₂ : x ∈⟦ p₂ ⟧· s) → x ∈⟦ p₁ ∣ p₂ ⟧· s _⊛_ : ∀ {s₁ s₂ R₁ R₂ f x} {p₁ : ParserProg (R₁ → R₂)} {p₂ : ParserProg R₁} (f∈p₁ : f ∈⟦ p₁ ⟧· s₁) (x∈p₂ : x ∈⟦ p₂ ⟧· s₂) → f x ∈⟦ p₁ ⊛ p₂ ⟧· s₁ ++ s₂ _⊛∞_ : ∀ {s₁ s₂ R₁ R₂ f x} {p₁ : ∞ (ParserProg (R₁ → R₂))} {p₂ : ∞ (ParserProg R₁)} (f∈p₁ : f ∈⟦ ♭ p₁ ⟧· s₁) (x∈p₂ : x ∈⟦ ♭ p₂ ⟧· s₂) → f x ∈⟦ p₁ ⊛∞ p₂ ⟧· s₁ ++ s₂ <$>_ : ∀ {s R₁ R₂ x} {f : R₁ → R₂} {p : ParserProg R₁} (x∈p : x ∈⟦ p ⟧· s) → f x ∈⟦ f <$> p ⟧· s +-[] : ∀ {R x s} {p : ParserProg R} (x∈p : x ∈⟦ p ⟧· s) → [ x ] ∈⟦ p + ⟧· s +-∷ : ∀ {R x s₁ s₂ xs} {p : ParserProg R} (x∈p : x ∈⟦ p ⟧· s₁) (xs∈p : xs ∈⟦ p + ⟧· s₂) → x ∷⁺ xs ∈⟦ p + ⟧· s₁ ++ s₂ between-[] : ∀ {R t} {p : ∞ (ParserProg R)} → [] ∈⟦ p between (t ∷ []) ⟧· t ∷ [] between-∷ : ∀ {R n t x xs s₁ s₂} {p : ∞ (ParserProg R)} {ts : Vec NamePart (suc n)} (x∈p : x ∈⟦ ♭ p ⟧· s₁) (xs∈⋯ : xs ∈⟦ p between ts ⟧· s₂) → x ∷ xs ∈⟦ p between (t ∷ ts) ⟧· t ∷ s₁ ++ s₂ ∥ˡ : ∀ {I i} {R : I → Set} {x s} {p₁ : ParserProg (R i)} {p₂ : ParserProg (∃ R)} (x∈p₁ : x ∈⟦ p₁ ⟧· s) → (-, x) ∈⟦ p₁ ∥ p₂ ⟧· s ∥ʳ : ∀ {I i} {R : I → Set} {s i′} {x : R i′} {p₁ : ParserProg (R i)} {p₂ : ParserProg (∃ R)} (x∈p₂ : (-, x) ∈⟦ p₂ ⟧· s) → (-, x) ∈⟦ p₁ ∥ p₂ ⟧· s -- The semantics is correct. (Note that this proof only establishes -- language equivalence, not parser equivalence; see -- TotalParserCombinators.Semantics.) sound : ∀ {R x s} {p : ParserProg R} → x ∈⟦ p ⟧· s → x ∈ ⟦ p ⟧ · s sound (∣ˡ x∈p₁) = ∣-left (sound x∈p₁) sound (∣ʳ x∈p₂) = ∣-right [] (sound x∈p₂) sound (f∈p₁ ⊛ x∈p₂) = [ ○ - ○ ] sound f∈p₁ ⊛′ sound x∈p₂ sound (f∈p₁ ⊛∞ x∈p₂) = [ ◌ - ◌ ] sound f∈p₁ ⊛′ sound x∈p₂ sound (<$> x∈p) = <$> sound x∈p sound (+-[] x∈p) = cast∈ refl refl (proj₂ LM.identity _) ([ ○ - ◌ ] <$> sound x∈p ⊛′ ∣-right [] return) sound (+-∷ x∈p xs∈p) = [ ○ - ◌ ] <$> sound x∈p ⊛′ ∣-left (<$> sound xs∈p) sound (∥ˡ x∈p₁) = ∣-left {x = (-, _)} (<$> sound x∈p₁) sound (∥ʳ x∈p₂) = ∣-right [] (sound x∈p₂) sound between-[] = <$> Tok.complete sound (between-∷ {ts = _ ∷ _} x∈p xs∈⋯) = [ ○ - ◌ ] [ ○ - ◌ ] <$> Tok.complete ⊛′ sound x∈p ⊛′ sound xs∈⋯ complete : ∀ {R x s} (p : ParserProg R) → x ∈ ⟦ p ⟧ · s → x ∈⟦ p ⟧· s complete fail () complete (p₁ ∣ p₂) (∣-left x∈p₁) = ∣ˡ (complete p₁ x∈p₁) complete (p₁ ∣ p₂) (∣-right .[] x∈p₂) = ∣ʳ (complete p₂ x∈p₂) complete (p₁ ⊛ p₂) (f∈p₁ ⊛ y∈p₂) = complete p₁ f∈p₁ ⊛ complete p₂ y∈p₂ complete (p₁ ⊛∞ p₂) (f∈p₁ ⊛ y∈p₂) = complete (♭ p₁) f∈p₁ ⊛∞ complete (♭ p₂) y∈p₂ complete (f <$> p) (<$> x∈p) = <$> complete p x∈p complete (p +) (<$> x∈p ⊛ ∣-left (<$> xs∈p+)) = +-∷ (complete p x∈p) (complete (p +) xs∈p+) complete (p +) (_⊛_ {s₁ = s} (<$> x∈p) (∣-right .[] return)) = P.subst (λ s → _ ∈⟦ p + ⟧· s) (P.sym (proj₂ LM.identity s)) (+-[] (complete p x∈p)) complete (p between (t ∷ [])) (<$> t∈) with Tok.sound t t∈ ... | (refl , refl) = between-[] complete (p between (t ∷ t′ ∷ ts)) (<$> t∈ ⊛ x∈p ⊛ xs∈) with Tok.sound t t∈ ... | (refl , refl) = between-∷ (complete (♭ p) x∈p) (complete (p between (t′ ∷ ts)) xs∈) complete (p₁ ∥ p₂) (∣-left (<$> x∈p₁)) = ∥ˡ (complete p₁ x∈p₁) complete (p₁ ∥ p₂) (∣-right .[] x∈p₂) = ∥ʳ (complete p₂ x∈p₂) ------------------------------------------------------------------------ -- A variant of the semantics -- The alternative semantics defined below may be slightly harder to -- understand, but it is (language) equivalent to the one above, and -- it simplifies the proof in Mixfix.Cyclic.Show. module Semantics-⊕ where open import TotalParserCombinators.Semantics.Continuation as ContSem hiding (sound; complete) infix 60 <$>_ infixl 50 _⊛_ _⊛∞_ infix 4 _⊕_∈⟦_⟧·_ data _⊕_∈⟦_⟧·_ : ∀ {R} → R → List NamePart → ParserProg R → List NamePart → Set₁ where ∣ˡ : ∀ {R x s s₁} {p₁ : ParserProg R} {p₂ : ParserProg R} (x∈p₁ : x ⊕ s₁ ∈⟦ p₁ ⟧· s) → x ⊕ s₁ ∈⟦ p₁ ∣ p₂ ⟧· s ∣ʳ : ∀ {R x s s₁} {p₁ : ParserProg R} {p₂ : ParserProg R} (x∈p₂ : x ⊕ s₁ ∈⟦ p₂ ⟧· s) → x ⊕ s₁ ∈⟦ p₁ ∣ p₂ ⟧· s _⊛_ : ∀ {s s₁ s₂ R₁ R₂ f x} {p₁ : ParserProg (R₁ → R₂)} {p₂ : ParserProg R₁} (f∈p₁ : f ⊕ s₁ ∈⟦ p₁ ⟧· s) (x∈p₂ : x ⊕ s₂ ∈⟦ p₂ ⟧· s₁) → f x ⊕ s₂ ∈⟦ p₁ ⊛ p₂ ⟧· s _⊛∞_ : ∀ {s s₁ s₂ R₁ R₂ f x} {p₁ : ∞ (ParserProg (R₁ → R₂))} {p₂ : ∞ (ParserProg R₁)} (f∈p₁ : f ⊕ s₁ ∈⟦ ♭ p₁ ⟧· s) (x∈p₂ : x ⊕ s₂ ∈⟦ ♭ p₂ ⟧· s₁) → f x ⊕ s₂ ∈⟦ p₁ ⊛∞ p₂ ⟧· s <$>_ : ∀ {s s′ R₁ R₂ x} {f : R₁ → R₂} {p : ParserProg R₁} (x∈p : x ⊕ s′ ∈⟦ p ⟧· s) → f x ⊕ s′ ∈⟦ f <$> p ⟧· s +-[] : ∀ {R x s s₁} {p : ParserProg R} (x∈p : x ⊕ s₁ ∈⟦ p ⟧· s) → [ x ] ⊕ s₁ ∈⟦ p + ⟧· s +-∷ : ∀ {R x s s₁ s₂ xs} {p : ParserProg R} (x∈p : x ⊕ s₁ ∈⟦ p ⟧· s) (xs∈p : xs ⊕ s₂ ∈⟦ p + ⟧· s₁) → x ∷⁺ xs ⊕ s₂ ∈⟦ p + ⟧· s between-[] : ∀ {R t s} {p : ∞ (ParserProg R)} → [] ⊕ s ∈⟦ p between (t ∷ []) ⟧· t ∷ s between-∷ : ∀ {R n t x xs s s₁ s₂} {p : ∞ (ParserProg R)} {ts : Vec NamePart (suc n)} (x∈p : x ⊕ s₁ ∈⟦ ♭ p ⟧· s) (xs∈⋯ : xs ⊕ s₂ ∈⟦ p between ts ⟧· s₁) → x ∷ xs ⊕ s₂ ∈⟦ p between (t ∷ ts) ⟧· t ∷ s ∥ˡ : ∀ {I i} {R : I → Set} {x s s′} {p₁ : ParserProg (R i)} {p₂ : ParserProg (∃ R)} (x∈p₁ : x ⊕ s′ ∈⟦ p₁ ⟧· s) → (-, x) ⊕ s′ ∈⟦ p₁ ∥ p₂ ⟧· s ∥ʳ : ∀ {I i} {R : I → Set} {s s′ i′} {x : R i′} {p₁ : ParserProg (R i)} {p₂ : ParserProg (∃ R)} (x∈p₂ : (-, x) ⊕ s′ ∈⟦ p₂ ⟧· s) → (-, x) ⊕ s′ ∈⟦ p₁ ∥ p₂ ⟧· s tok-sound : ∀ t {t′ s₁ s} → t′ ⊕ s₁ ∈ tok t · s → t ≡ t′ × s ≡ t′ ∷ s₁ tok-sound t ∈ with ContSem.sound′ ∈ tok-sound t ∈ | (s , refl , ∈′) with Tok.sound t ∈′ tok-sound t ∈ | (.(t ∷ []) , refl , ∈′) | (refl , refl) = (refl , refl) tok-complete : ∀ {t s} → t ⊕ s ∈ tok t · t ∷ s tok-complete = ContSem.complete′ (_ , refl , Tok.complete) sound : ∀ {R x s s′} {p : ParserProg R} → x ⊕ s′ ∈⟦ p ⟧· s → x ⊕ s′ ∈ ⟦ p ⟧ · s sound (∣ˡ x∈p₁) = ∣-left (sound x∈p₁) sound (∣ʳ x∈p₂) = ∣-right [] (sound x∈p₂) sound (f∈p₁ ⊛ x∈p₂) = [ ○ - ○ ] sound f∈p₁ ⊛ sound x∈p₂ sound (f∈p₁ ⊛∞ x∈p₂) = [ ◌ - ◌ ] sound f∈p₁ ⊛ sound x∈p₂ sound (<$> x∈p) = <$> sound x∈p sound (+-[] x∈p) = [ ○ - ◌ ] <$> sound x∈p ⊛ ∣-right [] return sound (+-∷ x∈p xs∈p) = [ ○ - ◌ ] <$> sound x∈p ⊛ ∣-left (<$> sound xs∈p) sound (∥ˡ x∈p₁) = ∣-left {x = (-, _)} (<$> sound x∈p₁) sound (∥ʳ x∈p₂) = ∣-right [] (sound x∈p₂) sound between-[] = <$> tok-complete sound (between-∷ {ts = _ ∷ _} x∈p xs∈⋯) = [ ○ - ◌ ] [ ○ - ◌ ] <$> tok-complete ⊛ sound x∈p ⊛ sound xs∈⋯ complete : ∀ {R x s s′} (p : ParserProg R) → x ⊕ s′ ∈ ⟦ p ⟧ · s → x ⊕ s′ ∈⟦ p ⟧· s complete fail () complete (p₁ ∣ p₂) (∣-left x∈p₁) = ∣ˡ (complete p₁ x∈p₁) complete (p₁ ∣ p₂) (∣-right .[] x∈p₂) = ∣ʳ (complete p₂ x∈p₂) complete (p₁ ⊛ p₂) ([ .○ - .○ ] f∈p₁ ⊛ y∈p₂) = complete p₁ f∈p₁ ⊛ complete p₂ y∈p₂ complete (p₁ ⊛∞ p₂) ([ .◌ - .◌ ] f∈p₁ ⊛ y∈p₂) = complete (♭ p₁) f∈p₁ ⊛∞ complete (♭ p₂) y∈p₂ complete (f <$> p) (<$> x∈p) = <$> complete p x∈p complete (p +) ([ .○ - .◌ ] <$> x∈p ⊛ ∣-left (<$> xs∈p+)) = +-∷ (complete p x∈p) (complete (p +) xs∈p+) complete (p +) ([ .○ - .◌ ] <$> x∈p ⊛ ∣-right .[] return) = +-[] (complete p x∈p) complete (p between (t ∷ [])) (<$> t∈) with tok-sound t t∈ ... | (refl , refl) = between-[] complete (p between (t ∷ t′ ∷ ts)) ([ .○ - .◌ ] [ .○ - .◌ ] <$> t∈ ⊛ x∈p ⊛ xs∈) with tok-sound t t∈ ... | (refl , refl) = between-∷ (complete (♭ p) x∈p) (complete (p between (t′ ∷ ts)) xs∈) complete (p₁ ∥ p₂) (∣-left (<$> x∈p₁)) = ∥ˡ (complete p₁ x∈p₁) complete (p₁ ∥ p₂) (∣-right .[] x∈p₂) = ∥ʳ (complete p₂ x∈p₂)
{ "alphanum_fraction": 0.4204051013, "avg_line_length": 41.9182389937, "ext": "agda", "hexsha": "2a97c2032b03b143fd4b4482df1f377ea0ddaae3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "Mixfix/Cyclic/Lib.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "Mixfix/Cyclic/Lib.agda", "max_line_length": 106, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "Mixfix/Cyclic/Lib.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 5581, "size": 13330 }
{-# OPTIONS --cubical #-} module Demos.AgdaBasics where open import Level open import Data.Nat open import Data.String data Bool : Type where false : Bool true : Bool _,not! : Bool → Bool false ,not! = true true ,not! = false _∧_ : Bool → Bool → Bool false ∧ y = false true ∧ y = y infixr 1 if_then_else_ if_then_else_ : Bool → A → A → A if false then true-path else false-path = false-path if true then true-path else false-path = true-path natOrString : (x : Bool) → if x then ℕ else String natOrString true = 4 natOrString false = "false"
{ "alphanum_fraction": 0.688172043, "avg_line_length": 19.2413793103, "ext": "agda", "hexsha": "c4f6cb6639969b23cc66f3d699a9124e526f0352", "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": "Demos/AgdaBasics.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": "Demos/AgdaBasics.agda", "max_line_length": 52, "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": "Demos/AgdaBasics.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": 176, "size": 558 }
module PairUnifier where record PairUnifier {t} {T : Set t} (t₁ t₂ : T) : Set t where field
{ "alphanum_fraction": 0.6666666667, "avg_line_length": 16, "ext": "agda", "hexsha": "f19c81e4656901710eab9fe133c8097f2f87db7c", "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/PairUnifier.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/PairUnifier.agda", "max_line_length": 60, "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/PairUnifier.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 36, "size": 96 }
------------------------------------------------------------------------ -- Weak bisimilarity ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --sized-types #-} open import Prelude hiding (module W) module Delay-monad.Alternative.Weak-bisimilarity {a} {A : Type a} where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Equivalence-relation equality-with-J open import Function-universe equality-with-J open import H-level equality-with-J open import H-level.Closure equality-with-J open import Delay-monad.Alternative open import Delay-monad.Alternative.Equivalence open import Delay-monad.Alternative.Partial-order import Delay-monad.Bisimilarity as B import Delay-monad.Partial-order as PO infix 4 _≈_ -- Weak bisimilarity. _≈_ : Delay A → Delay A → Type a x ≈ y = x ∥⊑∥ y × y ∥⊑∥ x -- Weak bisimilarity is pointwise propositional. ≈-propositional : ∀ x y → Is-proposition (x ≈ y) ≈-propositional x y = ×-closure 1 (∥⊑∥-propositional x y) (∥⊑∥-propositional y x) -- Weak bisimilarity is an equivalence relation. ≈-is-equivalence-relation : Is-equivalence-relation _≈_ ≈-is-equivalence-relation = record { reflexive = λ {x} → ∥⊑∥-reflexive x , ∥⊑∥-reflexive x ; symmetric = λ { (p , q) → q , p } ; transitive = λ {x y z} → Σ-zip (∥⊑∥-transitive x y z) (flip (∥⊑∥-transitive z y x)) } -- The notion of weak bisimilarity defined here is logically -- equivalent (via Delay⇔Delay) to the one defined for the -- coinductive delay monad (if A is a set). ≈⇔≈ : Is-set A → ∀ x y → x ≈ y ⇔ _⇔_.to Delay⇔Delay x B.≈ _⇔_.to Delay⇔Delay y ≈⇔≈ A-set x y = x ∥⊑∥ y × y ∥⊑∥ x ↝⟨ inverse (⊑⇔∥⊑∥ A-set x y ×-cong ⊑⇔∥⊑∥ A-set y x) ⟩ x ⊑ y × y ⊑ x ↝⟨ ⊑⇔⊑ x y ×-cong ⊑⇔⊑ y x ⟩ to x PO.⊑ to y × to y PO.⊑ to x ↝⟨ inverse PO.≈⇔⊑×⊒ ⟩□ to x B.≈ to y □ where open _⇔_ Delay⇔Delay ≈⇔≈′ : Is-set A → ∀ {x y} → x B.≈ y ⇔ _⇔_.from Delay⇔Delay x ≈ _⇔_.from Delay⇔Delay y ≈⇔≈′ A-set {x} {y} = x B.≈ y ↝⟨ PO.≈⇔⊑×⊒ ⟩ x PO.⊑ y × y PO.⊑ x ↝⟨ ⊑⇔⊑′ ×-cong ⊑⇔⊑′ ⟩ from x ⊑ from y × from y ⊑ from x ↝⟨ ⊑⇔∥⊑∥ A-set (from x) (from y) ×-cong ⊑⇔∥⊑∥ A-set (from y) (from x) ⟩□ from x ∥⊑∥ from y × from y ∥⊑∥ from x □ where open _⇔_ Delay⇔Delay
{ "alphanum_fraction": 0.5495420483, "avg_line_length": 32.904109589, "ext": "agda", "hexsha": "8e7f3419af71df3eae27fa7311e80ad08a177fc5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Delay-monad/Alternative/Weak-bisimilarity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Delay-monad/Alternative/Weak-bisimilarity.agda", "max_line_length": 113, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Delay-monad/Alternative/Weak-bisimilarity.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": 993, "size": 2402 }
-- This code is closely based on code due to Andy Morris. data _≡⁰_ {A : Set} (@0 x : A) : @0 A → Set where refl : x ≡⁰ x data _≡ʷ_ {A : Set} (@ω x : A) : @ω A → Set where refl : x ≡ʷ x works : ∀ {A} {@0 x y : A} → x ≡⁰ y → x ≡ʷ y works refl = refl also-works : ∀ {A} {@0 x y : A} → x ≡⁰ y → x ≡ʷ y also-works {x = x} refl = refl {x = x}
{ "alphanum_fraction": 0.5131964809, "avg_line_length": 31, "ext": "agda", "hexsha": "31ed25b9fa8973cafc749e904058ca84c5cd6234", "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": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Succeed/Issue5191.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "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-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Succeed/Issue5191.agda", "max_line_length": 63, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Succeed/Issue5191.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": 160, "size": 341 }
{- Definition of various kinds of categories. This library follows the UniMath terminology, that is: Concept Ob C Hom C Univalence Precategory Type Type No Category Type Set No Univalent Category Type Set Yes This file also contains - pathToIso : Turns a path between two objects into an isomorphism between them - opposite categories -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Category where open import Cubical.Core.Glue open import Cubical.Foundations.Prelude private variable ℓ ℓ' : Level -- Precategories record Precategory ℓ ℓ' : Type (ℓ-suc (ℓ-max ℓ ℓ')) where -- no-eta-equality ; NOTE: need eta equality for `opop` field ob : Type ℓ Hom[_,_] : ob → ob → Type ℓ' id : ∀ x → Hom[ x , x ] _⋆_ : ∀ {x y z} (f : Hom[ x , y ]) (g : Hom[ y , z ]) → Hom[ x , z ] ⋆IdL : ∀ {x y : ob} (f : Hom[ x , y ]) → (id x) ⋆ f ≡ f ⋆IdR : ∀ {x y} (f : Hom[ x , y ]) → f ⋆ (id y) ≡ f ⋆Assoc : ∀ {u v w x} (f : Hom[ u , v ]) (g : Hom[ v , w ]) (h : Hom[ w , x ]) → (f ⋆ g) ⋆ h ≡ f ⋆ (g ⋆ h) -- composition: alternative to diagramatic order _∘_ : ∀ {x y z} (g : Hom[ y , z ]) (f : Hom[ x , y ]) → Hom[ x , z ] g ∘ f = f ⋆ g open Precategory -- Helpful syntax/notation _[_,_] : (C : Precategory ℓ ℓ') → (x y : C .ob) → Type ℓ' _[_,_] = Hom[_,_] -- needed to define this in order to be able to make the subsequence syntax declaration seq' : ∀ (C : Precategory ℓ ℓ') {x y z} (f : C [ x , y ]) (g : C [ y , z ]) → C [ x , z ] seq' = _⋆_ infix 15 seq' syntax seq' C f g = f ⋆⟨ C ⟩ g -- composition comp' : ∀ (C : Precategory ℓ ℓ') {x y z} (g : C [ y , z ]) (f : C [ x , y ]) → C [ x , z ] comp' = _∘_ infix 16 comp' syntax comp' C g f = g ∘⟨ C ⟩ f -- Categories record isCategory (C : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where field isSetHom : ∀ {x y} → isSet (C [ x , y ]) -- Isomorphisms and paths in precategories record CatIso {C : Precategory ℓ ℓ'} (x y : C .Precategory.ob) : Type ℓ' where constructor catiso field mor : C [ x , y ] inv : C [ y , x ] sec : inv ⋆⟨ C ⟩ mor ≡ C .id y ret : mor ⋆⟨ C ⟩ inv ≡ C .id x pathToIso : {C : Precategory ℓ ℓ'} (x y : C .ob) (p : x ≡ y) → CatIso {C = C} x y pathToIso {C = C} x y p = J (λ z _ → CatIso x z) (catiso (C .id x) idx (C .⋆IdL idx) (C .⋆IdL idx)) p where idx = C .id x -- Univalent Categories record isUnivalent (C : Precategory ℓ ℓ') : Type (ℓ-max ℓ ℓ') where field univ : (x y : C .ob) → isEquiv (pathToIso {C = C} x y) open isUnivalent public -- Opposite Categories _^op : Precategory ℓ ℓ' → Precategory ℓ ℓ' (C ^op) .ob = C .ob (C ^op) .Hom[_,_] x y = C .Hom[_,_] y x (C ^op) .id = C .id (C ^op) ._⋆_ f g = C ._⋆_ g f (C ^op) .⋆IdL = C .⋆IdR (C ^op) .⋆IdR = C .⋆IdL (C ^op) .⋆Assoc f g h = sym (C .⋆Assoc _ _ _) open isCategory public -- opposite of opposite is definitionally equal to itself involutiveOp : ∀ {C : Precategory ℓ ℓ'} → (C ^op) ^op ≡ C involutiveOp = refl -- Other useful operations on categories -- whisker the parallel morphisms g and g' with f lPrecatWhisker : {C : Precategory ℓ ℓ'} {x y z : C .ob} (f : C [ x , y ]) (g g' : C [ y , z ]) (p : g ≡ g') → f ⋆⟨ C ⟩ g ≡ f ⋆⟨ C ⟩ g' lPrecatWhisker {C = C} f _ _ p = cong (_⋆_ C f) p
{ "alphanum_fraction": 0.5524096386, "avg_line_length": 26.7741935484, "ext": "agda", "hexsha": "ff6c617b103c132560471ddf810fc81652315217", "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": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "apabepa10/cubical", "max_forks_repo_path": "Cubical/Categories/Category.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "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": "apabepa10/cubical", "max_issues_repo_path": "Cubical/Categories/Category.agda", "max_line_length": 134, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "apabepa10/cubical", "max_stars_repo_path": "Cubical/Categories/Category.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1351, "size": 3320 }
open import Coinduction using ( ♭ ; ♯_ ) open import Data.Unit using ( ⊤ ; tt ) open import System.IO.Transducers.Syntax using ( lazy ; strict ; _⇒_is_ ; inp ; out ; done ) renaming ( _⟫_ to _⟫'_ ; _[&]_ to _[&]'_ ; _⟨&⟩_ to _⟨&⟩'_ ; discard to discard' ; π₁ to π₁' ; π₂ to π₂' ; ⟦_⟧ to ⟦_⟧' ) open import System.IO.Transducers.Session using ( Session ; I ; Σ ; _&_ ) open import System.IO.Transducers.Trace using ( Trace ) module System.IO.Transducers.Function where -- We can regard strict transducers as functions. -- Note that in the case of S ⇒ T where S is a Σ session, -- this agrees with the type of inp, so we can regard -- inp as a function of type ∞ (S ⇒ T) → (S to T is s). LHS : Session → Set LHS I = ⊤ LHS (Σ {A} V F) = A RHS : (S T : Session) → (LHS S) → Set₁ RHS I T a = I ⇒ T is strict RHS (Σ V F) T a = ♭ F a ⇒ T is lazy _⇛_ : Session → Session → Set₁ S ⇛ T = (a : LHS S) → (RHS S T a) -- Map from functions to syntax and back. φ : ∀ {S T} → (S ⇒ T is strict) → (S ⇛ T) φ {I} done a = done φ {Σ W F} (inp P) a = ♭ P a φ {Σ W F} done a = out a done φ' : ∀ {S T} → (S ⇛ T) → (S ⇒ T is strict) φ' {I} P = P tt φ' {Σ W F} P = inp (♯ P) -- Semantics of functions is inherited from semantics on syntax ⟦_⟧ : ∀ {S T} → (S ⇛ T) → (Trace S) → (Trace T) ⟦ P ⟧ = ⟦ φ' P ⟧' -- Structure on functions is inherited from structure on syntax id : ∀ {S} → (S ⇛ S) id {S} = φ (done {S}) _⟫_ : ∀ {S T U} → (S ⇛ T) → (T ⇛ U) → (S ⇛ U) _⟫_ {S} P Q = φ (φ' {S} P ⟫' φ' Q) _[&]_ : ∀ {S T U V} → (S ⇛ T) → (U ⇛ V) → ((S & U) ⇛ (T & V)) _[&]_ {S} P Q = φ (φ' {S} P [&]' φ' Q) _⟨&⟩_ : ∀ {S T U} → (S ⇛ T) → (S ⇛ U) → (S ⇛ (T & U)) _⟨&⟩_ {S} P Q = φ (φ' {S} P ⟨&⟩' φ' Q) discard : ∀ {S} → (S ⇛ I) discard {S} = φ (discard' {S}) π₁ : ∀ {S T} → ((S & T) ⇛ S) π₁ {S} = φ (π₁' {S}) π₂ : ∀ {S T} → ((S & T) ⇛ T) π₂ {S} = φ (π₂' {S})
{ "alphanum_fraction": 0.5015957447, "avg_line_length": 28.0597014925, "ext": "agda", "hexsha": "ab0b2e4fbc272f9c580f93c93a8a9d8383e6fad3", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z", "max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z", "max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/System/IO/Transducers/Function.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ilya-fiveisky/agda-system-io", "max_issues_repo_path": "src/System/IO/Transducers/Function.agda", "max_line_length": 73, "max_stars_count": 10, "max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ilya-fiveisky/agda-system-io", "max_stars_repo_path": "src/System/IO/Transducers/Function.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z", "num_tokens": 831, "size": 1880 }
{-# OPTIONS --without-K #-} open import HoTT open import homotopy.HSpace renaming (HSpaceStructure to HSS) open import homotopy.Freudenthal open import homotopy.IterSuspensionStable open import homotopy.Pi2HSusp open import homotopy.EM1HSpace module homotopy.EilenbergMacLane where -- EM(G,n) when G is π₁(A,a₀) module EMImplicit {i} (A : Type i) (cA : is-connected ⟨0⟩ A) (gA : has-level ⟨ 1 ⟩ A) (A-H : HSS A) (μcoh : HSS.μe- A-H (HSS.e A-H) == HSS.μ-e A-H (HSS.e A-H)) where private a₀ = HSS.e A-H X = ⊙[ A , a₀ ] ⊙EM : (n : ℕ) → Ptd i ⊙EM O = ⊙Ω X ⊙EM (S n) = ⊙Trunc ⟨ S n ⟩ (⊙Susp^ n X) module _ (n : ℕ) where EM = fst (⊙EM n) embase = snd (⊙EM n) EM-level : (n : ℕ) → has-level ⟨ n ⟩ (fst (⊙EM n)) EM-level O = gA a₀ a₀ EM-level (S n) = Trunc-level EM-conn : (n : ℕ) → is-connected ⟨ n ⟩ (EM (S n)) EM-conn n = Trunc-preserves-conn ⟨ S n ⟩ (transport (λ t → is-connected t (fst (⊙Susp^ n X))) (nlemma n) (⊙Susp^-conn n cA)) where nlemma : (n : ℕ) → (n -2) +2+ ⟨0⟩ == ⟨ n ⟩ nlemma O = idp nlemma (S n) = ap S (nlemma n) {- π (S k) (EM (S n)) (embase (S n)) == π k (EM n) (embase n) where k > 0 and n = S (S n') -} module Stable (k n' : ℕ) (tk : k ≠ 0) (tsk : S k ≠ 0) (indexing : k ≤ S (S n')) where private n : ℕ n = S (S n') lte : ⟨ k ⟩ ≤T ⟨ n ⟩ lte = ⟨⟩-monotone-≤ $ indexing kle : k ≤ (S n') *2 kle = ≤-trans indexing (lemma n') where lemma : (n' : ℕ) → S (S n') ≤ (S n') *2 lemma O = inl idp lemma (S n') = ≤-trans (≤-ap-S (lemma n')) (inr ltS) private module SS = Susp^Stable X cA (S n') k tk tsk kle abstract stable : π (S k) tsk (⊙EM (S n)) == π k tk (⊙EM n) stable = π (S k) tsk (⊙EM (S n)) =⟨ π-below-trunc _ tsk _ _ (≤T-ap-S lte) ⟩ π (S k) tsk (⊙Susp^ n X) =⟨ SS.stable ⟩ π k tk (⊙Susp^ (S n') X) =⟨ ! (π-below-trunc _ tk _ _ lte) ⟩ π k tk (⊙EM n) ∎ module BelowDiagonal where π₁ : (n : ℕ) (t1 : 1 ≠ 0 ) → π 1 t1 (⊙EM (S (S n))) == LiftUnit-Group π₁ n t1 = contr-is-0ᴳ (π 1 t1 (⊙EM (S (S n)))) (connected-at-level-is-contr (raise-level-≤T (≤T-ap-S (≤T-ap-S (-2≤T (n -2)))) (Trunc-level {n = ⟨0⟩})) (Trunc-preserves-conn ⟨0⟩ (path-conn (EM-conn (S n))))) -- some clutter here arises from the definition of <; -- any simple way to avoid this? π-below : (k n : ℕ) (tk : k ≠ 0) → (k < n) → π k tk (⊙EM n) == LiftUnit-Group π-below 0 _ tk lt = ⊥-rec (tk idp) π-below 1 .2 tk ltS = π₁ 0 tk π-below 1 .3 tk (ltSR ltS) = π₁ 1 tk π-below 1 (S (S n)) tk (ltSR (ltSR _)) = π₁ n tk π-below (S (S k)) ._ tssk ltS = Stable.stable (S k) k (ℕ-S≠O k) tssk (inr ltS) ∙ π-below (S k) _ (ℕ-S≠O k) ltS π-below (S (S k)) ._ tssk (ltSR ltS) = Stable.stable (S k) (S k) (ℕ-S≠O k) tssk (inr (ltSR ltS)) ∙ π-below (S k) _ (ℕ-S≠O k) (ltSR ltS) π-below (S (S k)) ._ tssk (ltSR (ltSR ltS)) = Stable.stable (S k) (S (S k)) (ℕ-S≠O k) tssk (inr (ltSR (ltSR ltS))) ∙ π-below (S k) _ (ℕ-S≠O k) (ltSR (ltSR ltS)) π-below (S (S k)) (S (S (S n))) tssk (ltSR (ltSR (ltSR lt))) = Stable.stable (S k) n (ℕ-S≠O k) tssk (inr (<-cancel-S (ltSR (ltSR (ltSR lt))))) ∙ π-below (S k) _ (ℕ-S≠O k) (<-cancel-S (ltSR (ltSR (ltSR lt)))) module OnDiagonal where π₁ : (tn : 1 ≠ O) (t1 : 1 ≠ O) → π 1 tn (⊙EM 1) == π 1 t1 X π₁ tn t1 = π-below-trunc 1 tn ⟨ 1 ⟩ X ≤T-refl ∙ ap (λ t → π 1 t X) (prop-has-all-paths (Π-level (λ _ → ⊥-is-prop)) tn t1) private module Π₂ = Pi2HSusp A gA cA A-H μcoh π₂ : (tn : 2 ≠ O) (t1 : 1 ≠ O) → π 2 tn (⊙EM 2) == π 1 t1 X π₂ tn t1 = π-below-trunc 2 tn ⟨ 2 ⟩ (⊙Susp X) ≤T-refl ∙ Π₂.π₂-Suspension t1 tn π-diag : (n : ℕ) (tn : n ≠ 0) (t1 : 1 ≠ O) → π n tn (⊙EM n) == π 1 t1 X π-diag 0 tn _ = ⊥-rec (tn idp) π-diag 1 tn t1 = π₁ tn t1 π-diag 2 tn t1 = π₂ tn t1 π-diag (S (S (S n))) tn t1 = Stable.stable (S (S n)) n (ℕ-S≠O _) tn ≤-refl ∙ π-diag (S (S n)) (ℕ-S≠O _) t1 module AboveDiagonal where π-above : (k n : ℕ) (tk : k ≠ 0) → (n < k) → π k tk (⊙EM n) == LiftUnit-Group π-above k n tk lt = contr-is-0ᴳ (π k tk (⊙EM n)) (inhab-prop-is-contr [ idp^ k ] (Trunc-preserves-level ⟨0⟩ (Ω^-level-in ⟨-1⟩ k _ (raise-level-≤T (lemma lt) (EM-level n))))) where lemma : {k n : ℕ} → n < k → S (S (n -2)) ≤T ((k -2) +2+ ⟨-1⟩) lemma ltS = inl (! (+2+-comm _ ⟨-1⟩)) lemma (ltSR lt) = ≤T-trans (lemma lt) (inr ltS) module Spectrum where private module Π₂ = Pi2HSusp A gA cA A-H μcoh spectrum0 : ⊙Ω (⊙EM 1) == ⊙EM 0 spectrum0 = ⊙Ω (⊙EM 1) =⟨ ⊙ua (Trunc=-equiv _ _) idp ⟩ ⊙Trunc ⟨ 0 ⟩ (⊙Ω X) =⟨ ⊙ua (unTrunc-equiv _ (gA a₀ a₀)) idp ⟩ ⊙Ω X ∎ spectrum1 : ⊙Ω (⊙EM 2) == ⊙EM 1 spectrum1 = ⊙Ω (⊙EM 2) =⟨ ⊙ua (Trunc=-equiv _ _) idp ⟩ ⊙Trunc ⟨ 1 ⟩ (⊙Ω (⊙Susp X)) =⟨ Π₂.⊙main-lemma ⟩ X =⟨ ! (⊙ua (unTrunc-equiv _ gA) idp) ⟩ ⊙EM 1 ∎ private nlemma : (n : ℕ) → Path {A = ℕ₋₂} (S ((n -2) +2+ ⟨0⟩)) (S (S (n -1))) nlemma O = idp nlemma (S n) = ap S (nlemma n) sconn : (n : ℕ) → is-connected (S (S (n -1))) (fst (⊙Susp^ (S n) X)) sconn n = transport (λ t → is-connected t (fst (⊙Susp^ (S n) X))) (nlemma n) (⊙Susp^-conn (S n) cA) kle : (n : ℕ) → ⟨ S (S n) ⟩ ≤T S ((n -1) +2+ S (n -1)) kle O = inl idp kle (S n) = ≤T-trans (≤T-ap-S (kle n)) (≤T-trans (inl (! (+2+-βr (S n -1) (S n -1)))) (inr ltS)) module FS (n : ℕ) = FreudenthalEquiv (n -1) (⟨ S (S n) ⟩) (kle n) (fst (⊙Susp^ (S n) X)) (snd (⊙Susp^ (S n) X)) (sconn n) spectrumSS : (n : ℕ) → ⊙Ω (⊙EM (S (S (S n)))) == ⊙EM (S (S n)) spectrumSS n = ⊙Ω (⊙EM (S (S (S n)))) =⟨ ⊙ua (Trunc=-equiv _ _) idp ⟩ ⊙Trunc ⟨ S (S n) ⟩ (⊙Ω (⊙Susp^ (S (S n)) X)) =⟨ ! (FS.⊙path n) ⟩ ⊙EM (S (S n)) ∎ abstract spectrum : (n : ℕ) → ⊙Ω (⊙EM (S n)) == ⊙EM n spectrum 0 = spectrum0 spectrum 1 = spectrum1 spectrum (S (S n)) = spectrumSS n module EMExplicit {i} (G : Group i) (G-abelian : is-abelian G) where module K₁ = EM₁ G module HSpace = EM₁HSpace G G-abelian open EMImplicit K₁.EM₁ K₁.EM₁-conn K₁.emlevel HSpace.H-EM₁ HSpace.μcoh public open BelowDiagonal public using (π-below) π-diag : (n : ℕ) (tn : n ≠ 0) → π n tn (⊙EM n) == G π-diag n tn = OnDiagonal.π-diag n tn (ℕ-S≠O 0) ∙ K₁.π₁.π₁-iso open AboveDiagonal public using (π-above) open Spectrum public using (spectrum)
{ "alphanum_fraction": 0.4696228045, "avg_line_length": 31.2882882883, "ext": "agda", "hexsha": "995d606a761b198ed556a3715ddbdae1cbc6b8c0", "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/EilenbergMacLane.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/EilenbergMacLane.agda", "max_line_length": 79, "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/EilenbergMacLane.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3116, "size": 6946 }
------------------------------------------------------------------------ -- An example ------------------------------------------------------------------------ module RecursiveTypes.Subtyping.Example where open import Codata.Musical.Notation open import Data.Fin open import Data.Nat open import RecursiveTypes.Syntax open import RecursiveTypes.Subtyping.Semantic.Coinductive -- σ = μX. X ⟶ X. σ : Ty 0 σ = μ var zero ⟶ var zero -- τ = μX. (X ⟶ ⊥) ⟶ ⊤. τ : Ty 0 τ = μ (var zero ⟶ ⊥) ⟶ ⊤ -- σ is a subtype of τ. σ≤τ : σ ≤Coind τ σ≤τ = ♯ (♯ σ≤τ ⟶ ♯ ⊥) ⟶ ♯ ⊤
{ "alphanum_fraction": 0.4707964602, "avg_line_length": 20.1785714286, "ext": "agda", "hexsha": "104caa697dcdaa0b658eb6e4c0cc6eb7ed790ecd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "RecursiveTypes/Subtyping/Example.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/codata", "max_issues_repo_path": "RecursiveTypes/Subtyping/Example.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "RecursiveTypes/Subtyping/Example.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 172, "size": 565 }
module Sigma.Subst.Properties where open import Data.Nat using (ℕ; _+_; zero; suc) open import Data.Fin using (Fin; zero; suc) open import Sigma.Subst.Core open import Sigma.Renaming.Base open import Function using (_∘_) open import Data.Product using (∃₂; _×_) renaming ( _,_ to ⟨_,_⟩ ) open import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl; sym; trans; cong; cong₂; cong-app) open Eq.≡-Reasoning -- ------------------------------------------------------------------------ -- We require a restricted form of functional extensionality -- to prove whether to subsitutions are equivalent postulate extensionality : ∀ { T U : Set } { f g : T → U } → (∀ (x : T) → f x ≡ g x) → f ≡ g -- ------------------------------------------------------------------------ -- Expansion law -- ------------------------------------------------------------------------ expansion : ∀ { T } ( σ₁ σ₂ : Sub T 0 ) → σ₁ ≡ σ₂ expansion σ₁ σ₂ = extensionality λ () -- ------------------------------------------------------------------------ -- ∷-laws -- ------------------------------------------------------------------------ -- Also known as the Interaction laws ∷-cong : ∀ { n } { T } { x₁ x₂ : T } { σ₁ σ₂ : Sub T n } → x₁ ≡ x₂ → σ₁ ≡ σ₂ -- ---------------- → x₁ ∷ σ₁ ≡ x₂ ∷ σ₂ ∷-cong x₁≡x₂ σ₁≡σ₂ = cong₂ (_∷_) x₁≡x₂ σ₁≡σ₂ ∷-head : ∀ { n } { T } { x : T } { σ : Sub T n } → head (x ∷ σ) ≡ x ∷-head = refl ∷-tail : ∀ { n } { T } { x : T } { σ : Sub T n } → tail (x ∷ σ) ≡ σ ∷-tail = refl ∷-uncons : ∀ { n } { T } { x : T } { σ : Sub T n } → uncons (x ∷ σ) ≡ ⟨ x , σ ⟩ ∷-uncons = refl ∷-head-tail-id : ∀ { n } { T } ( σ : Sub T (1 + n) ) → head σ ∷ tail σ ≡ σ ∷-head-tail-id σ = extensionality lemma where lemma : ∀ x → (head σ ∷ tail σ) x ≡ σ x lemma zero = refl lemma (suc x) = refl ∷-id-η : ∀ { n } → ( zero ∷ ↑ ) ≡ id { n = 1 + n } ∷-id-η = ∷-head-tail-id id ∷-∘-distrib : ∀ { n } { T U } { x : T } ( σ : Sub T n ) ( f : T → U ) → f ∘ ( x ∷ σ ) ≡ f x ∷ f ∘ σ ∷-∘-distrib { x = x } σ f = extensionality lemma where lemma : ∀ y → (f ∘ (x ∷ σ)) y ≡ ( f x ∷ (f ∘ σ) ) y lemma zero = refl lemma (suc y) = refl ∃-split : ∀ { n } { T } ( σ₁ : Sub T (1 + n) ) → ∃₂ λ ( x : T ) ( σ₂ : Sub T n ) → σ₁ ≡ x ∷ σ₂ ∃-split σ = ⟨ head σ , ⟨ tail σ , sym (∷-head-tail-id σ) ⟩ ⟩ -- TODO: Prove these. -- x₁ ≡ head (x₁ ∷ σ₁) ::-head -- ≡ head (x₂ ∷ σ₂) cong -- ≡ x₂ ::-head postulate ∷-injectiveˡ : ∀ { n } { T } ( x₁ x₂ : T ) ( σ₁ σ₂ : Sub T n ) → x₁ ∷ σ₁ ≡ x₁ ∷ σ₂ → x₁ ≡ x₂ ∷-injectiveʳ : ∀ { n } { T } ( x₁ x₂ : T ) ( σ₁ σ₂ : Sub T n ) → x₁ ∷ σ₁ ≡ x₁ ∷ σ₂ → σ₁ ≡ σ₂ ∷-injective : ∀ { n } { T } ( x₁ x₂ : T ) ( σ₁ σ₂ : Sub T n ) → x₁ ∷ σ₁ ≡ x₁ ∷ σ₂ → (x₁ ≡ x₂) × (σ₁ ≡ σ₂) ∷-injective x₁ x₂ σ₁ σ₂ x₁∷σ₁≡x₁∷σ₂ = ⟨ (∷-injectiveˡ x₁ x₂ σ₁ σ₂ x₁∷σ₁≡x₁∷σ₂) , (∷-injectiveʳ x₁ x₂ σ₁ σ₂ x₁∷σ₁≡x₁∷σ₂) ⟩ -- ------------------------------------------------------------------------ -- Coincidence laws -- ------------------------------------------------------------------------ -- Equivalences between uni and multi-variate primitives ++-∷ : ∀ { n } { T } (x : T) (σ : Sub T n) → x ∷ σ ≡ [ x ] ++ σ ++-∷ x σ = refl -- ------------------------------------------------------------------------ -- Multi-variate interaction laws -- ------------------------------------------------------------------------ ++-cong : ∀ { m n } { T } {σ₁¹ σ₁² : Sub T m} {σ₂¹ σ₂² : Sub T n} → σ₁¹ ≡ σ₁² → σ₂¹ ≡ σ₂² -- ----------------------- → σ₁¹ ++ σ₂¹ ≡ σ₁² ++ σ₂² ++-cong refl refl = refl -- TODO: ++-injective -- TODO: ++-≥ and ++-< ∷-drop : ∀ { m n } { T } (x : T) (σ : Sub T (m + n)) → drop (suc m) (x ∷ σ) ≡ drop m σ ∷-drop x σ = extensionality (lemma x σ) where lemma : ∀ { m n } { T } (x : T) (σ : Sub T (m + n)) → ∀ y → drop (suc m) (x ∷ σ) y ≡ drop m σ y lemma {zero} x σ y = refl lemma {suc m} x σ y = refl ++-drop : ∀ { m n : ℕ } { T } (σ₁ : Sub T m) (σ₂ : Sub T n) → drop m (σ₁ ++ σ₂) ≡ σ₂ ++-drop σ₁ σ₂ = extensionality (lemma σ₁ σ₂) where lemma : ∀ { m n } { T } (σ₁ : Sub T m) (σ₂ : Sub T n) → ∀ x → drop m (σ₁ ++ σ₂) x ≡ σ₂ x lemma {zero} σ₁ σ₂ x = refl lemma {suc m} σ₁ σ₂ x = lemma (σ₁ ∘ ↑) σ₂ x ∷-take : ∀ { m n } { T } (x : T) (σ : Sub T (m + n)) → take (suc m) (x ∷ σ) ≡ x ∷ take m σ ∷-take x σ = extensionality (lemma x σ) where lemma : ∀ { m n } { T } (x : T) (σ : Sub T (m + n)) → ∀ y → take (suc m) (x ∷ σ) y ≡ (x ∷ take m σ) y lemma x σ zero = refl lemma x σ (suc y) = refl ++-take : ∀ { m n } { T } (σ₁ : Sub T m) (σ₂ : Sub T n) → take m (σ₁ ++ σ₂) ≡ σ₁ ++-take σ₁ σ₂ = extensionality (lemma σ₁ σ₂) where lemma : ∀ { m n } { T } (σ₁ : Sub T m) (σ₂ : Sub T n) → ∀ x → take m (σ₁ ++ σ₂) x ≡ σ₁ x lemma σ₁ σ₂ zero = refl lemma σ₁ σ₂ (suc x) = lemma (σ₁ ∘ ↑) σ₂ x ++-take-drop-id : ∀ m { n } { T } (σ : Sub T (m + n)) → take m σ ++ drop m σ ≡ σ ++-take-drop-id m σ = extensionality (lemma m σ) where lemma : ∀ m { n } { T } (σ : Sub T (m + n)) → ∀ x → (take m σ ++ drop m σ) x ≡ σ x lemma zero σ x = refl lemma (suc m) σ zero = refl lemma (suc m) σ (suc x) = lemma m (σ ∘ ↑) x ∃-splitAt : ∀ m { n } { T } ( σ : Sub T (m + n) ) → ∃₂ λ ( σ₁ : Sub T m ) ( σ₂ : Sub T n ) → σ ≡ σ₁ ++ σ₂ ∃-splitAt m σ = ⟨ take m σ , ⟨ drop m σ , sym (++-take-drop-id m σ) ⟩ ⟩ take-∘-distrib : ∀ m { n } { T U } (σ : Sub T (m + n)) (f : T → U) → take m (f ∘ σ) ≡ f ∘ (take m σ) take-∘-distrib m σ f = extensionality (lemma m σ f) where lemma : ∀ m { n } { T U } (σ : Sub T (m + n)) (f : T → U) → ∀ x → take m (f ∘ σ) x ≡ (f ∘ (take m σ)) x lemma .(suc _) σ f zero = refl lemma .(suc _) σ f (suc x) = refl drop-∘-distrib : ∀ m { n } { T U } (σ : Sub T (m + n)) (f : T → U) → drop m (f ∘ σ) ≡ f ∘ (drop m σ) drop-∘-distrib m σ f = extensionality (lemma m σ f) where lemma : ∀ m { n } { T U } (σ : Sub T (m + n)) (f : T → U) → ∀ x → drop m (f ∘ σ) x ≡ (f ∘ (drop m σ)) x lemma zero σ f x = refl lemma (suc m) σ f x = refl ++-∘-distrib : ∀ { m n } { T U } (σ₁ : Sub T m) (σ₂ : Sub T n) (f : T → U) → f ∘ ( σ₁ ++ σ₂ ) ≡ (f ∘ σ₁) ++ (f ∘ σ₂) ++-∘-distrib { m } σ₁ σ₂ f = let σ = σ₁ ++ σ₂ in begin f ∘ σ ≡⟨ sym (++-take-drop-id m (f ∘ σ)) ⟩ take m (f ∘ σ) ++ drop m (f ∘ σ) ≡⟨ cong₂ _++_ (take-∘-distrib m σ f) (drop-∘-distrib m σ f) ⟩ f ∘ (take m σ) ++ f ∘ (drop m σ) ≡⟨ cong₂ (λ σ₁ σ₂ → f ∘ σ₁ ++ f ∘ σ₂) (++-take σ₁ σ₂) (++-drop σ₁ σ₂) ⟩ (f ∘ σ₁) ++ (f ∘ σ₂) ∎ -- ------------------------------------------------------------------------ -- Sub↔Vec -- ------------------------------------------------------------------------ -- TODO
{ "alphanum_fraction": 0.4053131493, "avg_line_length": 31.4859813084, "ext": "agda", "hexsha": "a3635babec7076587f8da4897ec9bf5f07a0ae6c", "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": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "johnyob/agda-sigma", "max_forks_repo_path": "src/Sigma/Subst/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "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-sigma", "max_issues_repo_path": "src/Sigma/Subst/Properties.agda", "max_line_length": 121, "max_stars_count": null, "max_stars_repo_head_hexsha": "bb895fa8a3ccbefbd2c4a135c79744ba06895be7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "johnyob/agda-sigma", "max_stars_repo_path": "src/Sigma/Subst/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2790, "size": 6738 }
------------------------------------------------------------------------ -- Parsing of mixfix operators ------------------------------------------------------------------------ -- This module defines a grammar for the precedence graph g. open import Mixfix.Expr module Mixfix.Cyclic.Grammar (i : PrecedenceGraphInterface) (g : PrecedenceGraphInterface.PrecedenceGraph i) where open import Codata.Musical.Notation open import Function using (flip; _$_) open import Data.List using (List; []; _∷_) open import Data.List.Membership.Propositional using (_∈_) open import Data.List.Relation.Unary.Any using (here; there) open import Data.Product import Relation.Binary.PropositionalEquality as P open PrecedenceCorrect i g import TotalParserCombinators.Parser as Parser open import Mixfix.Fixity open import Mixfix.Operator open import Mixfix.Cyclic.Lib renaming (ParserProg to Parser) -- The following definition uses a lexicographic combination of -- guarded corecursion and structural recursion. mutual -- Expressions. expr : ∞ (Parser (Expr anyPrecedence)) expr = ♯ precs anyPrecedence -- Expressions corresponding to zero or more nodes in the precedence -- graph: operator applications where the outermost operator has one -- of the precedences ps. The graph g is used for internal -- expressions. precs : (ps : List Precedence) → Parser (Expr ps) precs [] = fail precs (p ∷ ps) = (λ e → here P.refl ∙ proj₂ e) <$> prec p ∣ weakenE <$> precs ps -- Expressions corresponding to one node in the precedence graph: -- operator applications where the outermost operator has -- precedence p. The graph g is used for internal expressions. -- The code would be more readable if the delay constructors (♯_) -- could be omitted. prec : (p : Precedence) → Parser (∃ (ExprIn p)) prec p = closedOps ∥ nonAssoc ∥ preRight⁺ ∥ postLeft⁺ ∥ fail module Prec where -- [ fix ] parses the internal parts of operators with the -- current precedence level and fixity fix. [_] = λ (fix : Fixity) → inner (ops p fix) -- Operator applications where the outermost operator binds -- tighter than the current precedence level. p↑ = precs (↑ p) -- Closed operators. closedOps : Parser (ExprIn p non) closedOps = ⟪_⟫ <$> [ closed ] -- Non-associative infix operators. nonAssoc : Parser (ExprIn p non) nonAssoc = ♯ (_⟨_⟩_ <$> p↑ ⊛ [ infx non ]) ⊛∞ ♯ p↑ -- Right associative and prefix operators. preRight : Parser (Outer p right → ExprIn p right) preRight = ⟪_⟩_ <$> [ prefx ] ∣ _⟨_⟩ʳ_ <$> p↑ ⊛ [ infx right ] preRight⁺ : Parser (ExprIn p right) preRight⁺ = ♯ preRight ⊛∞ ♯ (similar <$> preRight⁺ ∣ tighter <$> p↑) -- Left associative and postfix operators. postLeft : Parser (Outer p left → ExprIn p left) postLeft = (λ op e₁ → e₁ ⟨ op ⟫ ) <$> [ postfx ] ∣ (λ op e₂ e₁ → e₁ ⟨ op ⟩ˡ e₂) <$> [ infx left ] ⊛ p↑ postLeft⁺ : Parser (ExprIn p left) postLeft⁺ = ♯ (flip _$_ <$> ( similar <$> postLeft⁺ ∣ tighter <$> p↑ )) ⊛∞ ♯ postLeft -- Internal parts (all name parts plus internal expressions) of -- operators of the given precedence and fixity. inner : ∀ {fix} (ops : List (∃ (Operator fix))) → Parser (Inner ops) inner [] = fail inner ((_ , op) ∷ ops) = (λ args → here P.refl ∙ args) <$> (expr between nameParts op) ∣ weakenI <$> inner ops -- Expression parsers. expression : Parser.Parser NamePart (Expr anyPrecedence) [] expression = ⟦ ♭ expr ⟧
{ "alphanum_fraction": 0.5978835979, "avg_line_length": 34.0540540541, "ext": "agda", "hexsha": "6f17d801c90d639d26086c67b088eef33ae92178", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "Mixfix/Cyclic/Grammar.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "Mixfix/Cyclic/Grammar.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "Mixfix/Cyclic/Grammar.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 993, "size": 3780 }
{- This second-order equational theory was created from the following second-order syntax description: syntax PCF type N : 0-ary _↣_ : 2-ary | r30 B : 0-ary term app : α ↣ β α -> β | _$_ l20 lam : α.β -> α ↣ β | ƛ_ r10 tr : B fl : B ze : N su : N -> N pr : N -> N iz : N -> B | 0? if : B α α -> α fix : α.α -> α theory (ƛβ) b : α.β a : α |> app (lam(x.b[x]), a) = b[a] (ƛη) f : α ↣ β |> lam (x. app(f, x)) = f (zz) |> iz (ze) = tr (zs) n : N |> iz (su (n)) = fl (ps) n : N |> pr (su (n)) = n (ift) t f : α |> if (tr, t, f) = t (iff) t f : α |> if (fl, t, f) = f (fix) t : α.α |> fix (x.t[x]) = t[fix (x.t[x])] -} module PCF.Equality where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Families.Build open import SOAS.ContextMaps.Inductive open import PCF.Signature open import PCF.Syntax open import SOAS.Metatheory.SecondOrder.Metasubstitution PCF:Syn open import SOAS.Metatheory.SecondOrder.Equality PCF:Syn private variable α β γ τ : PCFT Γ Δ Π : Ctx infix 1 _▹_⊢_≋ₐ_ -- Axioms of equality data _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ PCF) α Γ → (𝔐 ▷ PCF) α Γ → Set where ƛβ : ⁅ α ⊩ β ⁆ ⁅ α ⁆̣ ▹ ∅ ⊢ (ƛ 𝔞⟨ x₀ ⟩) $ 𝔟 ≋ₐ 𝔞⟨ 𝔟 ⟩ ƛη : ⁅ α ↣ β ⁆̣ ▹ ∅ ⊢ ƛ (𝔞 $ x₀) ≋ₐ 𝔞 zz : ⁅⁆ ▹ ∅ ⊢ 0? ze ≋ₐ tr zs : ⁅ N ⁆̣ ▹ ∅ ⊢ 0? (su 𝔞) ≋ₐ fl ps : ⁅ N ⁆̣ ▹ ∅ ⊢ pr (su 𝔞) ≋ₐ 𝔞 ift : ⁅ α ⁆ ⁅ α ⁆̣ ▹ ∅ ⊢ if tr 𝔞 𝔟 ≋ₐ 𝔞 iff : ⁅ α ⁆ ⁅ α ⁆̣ ▹ ∅ ⊢ if fl 𝔞 𝔟 ≋ₐ 𝔟 fix : ⁅ α ⊩ α ⁆̣ ▹ ∅ ⊢ fix (𝔞⟨ x₀ ⟩) ≋ₐ 𝔞⟨ (fix (𝔞⟨ x₀ ⟩)) ⟩ open EqLogic _▹_⊢_≋ₐ_ open ≋-Reasoning
{ "alphanum_fraction": 0.4763279446, "avg_line_length": 25.1014492754, "ext": "agda", "hexsha": "e24f112a545dce9d6ea4d5cff1126c089929c260", "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/PCF/Equality.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/PCF/Equality.agda", "max_line_length": 99, "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/PCF/Equality.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": 903, "size": 1732 }
{- This file contains: - Definition of propositional truncation -} {-# OPTIONS --cubical --safe #-} module Cubical.HITs.PropositionalTruncation.Base where open import Cubical.Core.Primitives -- Propositional truncation as a higher inductive type: data ∥_∥ {ℓ} (A : Type ℓ) : Type ℓ where ∣_∣ : A → ∥ A ∥ squash : ∀ (x y : ∥ A ∥) → x ≡ y -- Mere existence ∃ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ') ∃ A B = ∥ Σ A B ∥ infix 2 ∃-syntax ∃-syntax : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ') ∃-syntax = ∃ syntax ∃-syntax A (λ x → B) = ∃[ x ∈ A ] B
{ "alphanum_fraction": 0.5711892797, "avg_line_length": 19.2580645161, "ext": "agda", "hexsha": "e040012dfc116459808514b4e2537dacbe8c69ed", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmester0/cubical", "max_forks_repo_path": "Cubical/HITs/PropositionalTruncation/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmester0/cubical", "max_issues_repo_path": "Cubical/HITs/PropositionalTruncation/Base.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmester0/cubical", "max_stars_repo_path": "Cubical/HITs/PropositionalTruncation/Base.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "num_tokens": 252, "size": 597 }
-- Andreas, 2017-01-18, issue #2408 -- DLubs were not serialized, thus, there was a problem with -- level dependent on unused values. {-# OPTIONS --show-irrelevant #-} -- {-# OPTIONS -v tc:20 #-} open import Agda.Primitive data ⊥ : Set where data Unit : Set where unit : Unit -- Argument a is unused in l l : (u : Unit) (a : ⊥) → Level l unit a = lzero postulate u : Unit F : (a : ⊥) → Set (l u a) -- checked type signature -- F : (a : ⊥) → Set (l u a) -- of sort dLub Set (λ a → Set (lsuc (l u a)))
{ "alphanum_fraction": 0.5923076923, "avg_line_length": 18.5714285714, "ext": "agda", "hexsha": "96671042cacb9a0af88f52cc902d6a07505e4a78", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2408Unused.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2408Unused.agda", "max_line_length": 60, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2408Unused.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": 180, "size": 520 }