Search is not available for this dataset
text
string
meta
dict
module io where open import bool open import char open import list open import string open import unit ---------------------------------------------------------------------- -- datatypes ---------------------------------------------------------------------- postulate IO : Set → Set {-# COMPILED_TYPE IO IO #-} {-# BUILTIN IO IO #-} ---------------------------------------------------------------------- -- syntax ---------------------------------------------------------------------- infixl 1 _>>=_ infixl 1 _>>_ ---------------------------------------------------------------------- -- postulated operations ---------------------------------------------------------------------- postulate return : ∀ {A : Set} → A → IO A _>>=_ : ∀ {A B : Set} → IO A → (A → IO B) → IO B {-# COMPILED return (\ _ -> return ) #-} {-# COMPILED _>>=_ (\ _ _ -> (>>=)) #-} postulate putStr : string -> IO ⊤ -- Reads a file, which is assumed to be finite. readFiniteFile : string → IO string writeFile : string → string → IO ⊤ private data simple-list (A : Set) : Set where nil : simple-list A cons : A → simple-list A → simple-list A simple-list-to-𝕃 : ∀ {A : Set} → simple-list A → 𝕃 A simple-list-to-𝕃 nil = [] simple-list-to-𝕃 (cons x xs) = x :: (simple-list-to-𝕃 xs) {-# COMPILED_DATA simple-list ([]) [] (:) #-} private postulate privGetArgs : IO (simple-list string) privDoesFileExist : string → IO 𝔹 privTakeDirectory : string → string privTakeFileName : string → string privCombineFileNames : string → string → string {-# COMPILED putStr putStr #-} {-# COMPILED readFiniteFile readFile #-} {-# COMPILED writeFile writeFile #-} {-# IMPORT System.Environment #-} {-# COMPILED privGetArgs System.Environment.getArgs #-} {-# IMPORT System.Directory #-} {-# COMPILED privDoesFileExist System.Directory.doesFileExist #-} {-# IMPORT System.FilePath #-} {-# COMPILED privTakeDirectory System.FilePath.takeDirectory #-} {-# COMPILED privTakeFileName System.FilePath.takeFileName #-} {-# COMPILED privCombineFileNames System.FilePath.combine #-} getArgs : IO (𝕃 string) getArgs = privGetArgs >>= (λ args → return (simple-list-to-𝕃 args)) doesFileExist : string → IO 𝔹 doesFileExist = privDoesFileExist takeDirectory : string → string takeDirectory = privTakeDirectory takeFileName : string → string takeFileName = privTakeFileName combineFileNames : string → string → string combineFileNames = privCombineFileNames ---------------------------------------------------------------------- -- defined operations ---------------------------------------------------------------------- _>>_ : ∀ {A B : Set} → IO A → IO B → IO B x >> y = x >>= (λ q -> y) base-filenameh : 𝕃 char → 𝕃 char base-filenameh [] = [] base-filenameh ('.' :: cs) = cs base-filenameh (_ :: cs) = base-filenameh cs -- return the part of the string up to the last (rightmost) period ('.'); so for "foo.txt" return "foo" base-filename : string → string base-filename s = 𝕃char-to-string (reverse (base-filenameh (reverse (string-to-𝕃char s))))
{ "alphanum_fraction": 0.5369537275, "avg_line_length": 28.8148148148, "ext": "agda", "hexsha": "491f67819022b2679455b62e0f77b56be896883e", "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": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "io.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "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": "heades/AUGL", "max_issues_repo_path": "io.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "io.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 744, "size": 3112 }
import Relation.Binary.EqReasoning as EqReasoning open import SemiNearRingRecords module OrderLemmas (snro : SemiNearRing) where open SemiNearRing snro -- public open import CommAssocLemmas s _≃s_ _+s_ zers isCommMon using (assoc; comm) renaming (SA to Ss) open EqReasoning Ss monoPlusLeft : ∀ {a} {b} {c} → a ≤s b → (a +s c) ≤s (b +s c) monoPlusLeft {a} {b} {c} a≤b = begin (a +s c) +s (b +s c) ≈⟨ assoc _ _ _ ⟩ a +s (c +s (b +s c)) ≈⟨ refls <+> comm _ _ ⟩ a +s ((b +s c) +s c) ≈⟨ refls <+> assoc _ _ _ ⟩ a +s (b +s (c +s c)) ≈⟨ sym (assoc _ _ _) ⟩ (a +s b) +s (c +s c) ≈⟨ a≤b <+> idem _ ⟩ b +s c ∎ monoTimesLeft : ∀ {a} {b} {c} → a ≤s b → (a *s c) ≤s (b *s c) monoTimesLeft {a} {b} {c} a≤b = begin (a *s c) +s (b *s c) ≈⟨ sym (distr _ _ _) ⟩ (a +s b) *s c ≈⟨ a≤b <*> refls ⟩ -- a≤=b means a+b==b b *s c ∎ infixl 6 _[+]_ infixl 7 _[*]_ _[+]_ : ∀ {a} {a'} {b} {b'} -> a ≤s a' -> b ≤s b' -> (a +s b) ≤s (a' +s b') _[+]_ {a} {a'} {b} {b'} pa pb = begin (a +s b) +s (a' +s b') ≈⟨ assoc _ _ _ ⟩ a +s (b +s (a' +s b')) ≈⟨ refls <+> comm _ _ ⟩ a +s ((a' +s b') +s b) ≈⟨ refls <+> assoc _ _ _ ⟩ a +s (a' +s (b' +s b)) ≈⟨ sym (assoc _ _ _) ⟩ (a +s a') +s (b' +s b) ≈⟨ pa <+> comm _ _ ⟩ a' +s (b +s b') ≈⟨ refls <+> pb ⟩ a' +s b' ∎ _[*]_ : ∀ {a} {a'} {b} {b'} -> a ≤s a' -> b ≤s b' -> (a *s b) ≤s (a' *s b') _[*]_ {a} {a'} {b} {b'} pa pb = begin (a *s b) +s (a' *s b') ≈⟨ refls <+> (sym pa <*> refls) ⟩ a *s b +s (a +s a') *s b' ≈⟨ refls <+> distr _ _ _ ⟩ a *s b +s (a *s b' +s a' *s b') ≈⟨ sym (assoc _ _ _) ⟩ (a *s b +s a *s b') +s a' *s b' ≈⟨ sym (distl _ _ _) <+> (refls <*> sym pb) ⟩ a *s (b +s b') +s a' *s (b +s b') ≈⟨ sym (distr _ _ _) ⟩ (a +s a') *s (b +s b') ≈⟨ pa <*> pb ⟩ a' *s b' ∎ ≤s-trans : ∀ {a b c} → a ≤s b → b ≤s c → a ≤s c ≤s-trans {a} {b} {c} p q = begin a +s c ≈⟨ refls <+> sym q ⟩ a +s (b +s c) ≈⟨ sym (assoc _ _ _) ⟩ (a +s b) +s c ≈⟨ p <+> refls ⟩ b +s c ≈⟨ q ⟩ c ∎ ≃sTo≤s : ∀ {a b} → a ≃s b → a ≤s b ≃sTo≤s {a} {b} a=b = begin a +s b ≈⟨ a=b <+> refls ⟩ b +s b ≈⟨ idem _ ⟩ b ∎
{ "alphanum_fraction": 0.3768907563, "avg_line_length": 22.8846153846, "ext": "agda", "hexsha": "1410f8e08e021eb6fa3df31a628b8d0f1e080f0d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-29T04:53:48.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-29T04:53:48.000Z", "max_forks_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "DSLsofMath/ValiantAgda", "max_forks_repo_path": "code/OrderLemmas.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "DSLsofMath/ValiantAgda", "max_issues_repo_path": "code/OrderLemmas.agda", "max_line_length": 54, "max_stars_count": 3, "max_stars_repo_head_hexsha": "43729ff822a0b05c6cb74016b04bdc93c627b0b1", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "DSLsofMath/ValiantAgda", "max_stars_repo_path": "code/OrderLemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-15T03:04:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-23T00:41:14.000Z", "num_tokens": 1267, "size": 2380 }
-- The ATP roles must to have at least an argument -- This error is detected by Syntax.Translation.ConcreteToAbstract. module ATPMissingArgument where {-# ATP axiom #-}
{ "alphanum_fraction": 0.761627907, "avg_line_length": 21.5, "ext": "agda", "hexsha": "2aa36721254121bcf09e2c56330d9b9068cfa85b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/eagda", "max_forks_repo_path": "test/fail/ATPMissingArgument.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "asr/eagda", "max_issues_repo_path": "test/fail/ATPMissingArgument.agda", "max_line_length": 67, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/eagda", "max_stars_repo_path": "test/fail/ATPMissingArgument.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 36, "size": 172 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Inductive pointwise lifting of relations to vectors ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.Relation.Binary.Pointwise.Inductive where open import Data.Fin.Base using (Fin; zero; suc) open import Data.Nat.Base using (ℕ; zero; suc) open import Data.Product using (_×_; _,_; uncurry; <_,_>) open import Data.Vec.Base as Vec hiding ([_]; head; tail; map; lookup; uncons) open import Data.Vec.Relation.Unary.All using (All; []; _∷_) open import Level using (Level; _⊔_) open import Function.Base using (_∘_) open import Function.Equivalence using (_⇔_; equivalence) open import Relation.Binary open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Relation.Nullary open import Relation.Nullary.Decidable using (map′) open import Relation.Nullary.Product using (_×-dec_) open import Relation.Unary using (Pred) private variable a b c d ℓ ℓ₁ ℓ₂ : Level A : Set a B : Set b C : Set c D : Set d ------------------------------------------------------------------------ -- Definition infixr 5 _∷_ data Pointwise {a b ℓ} {A : Set a} {B : Set b} (_∼_ : REL A B ℓ) : ∀ {m n} (xs : Vec A m) (ys : Vec B n) → Set (a ⊔ b ⊔ ℓ) where [] : Pointwise _∼_ [] [] _∷_ : ∀ {m n x y} {xs : Vec A m} {ys : Vec B n} (x∼y : x ∼ y) (xs∼ys : Pointwise _∼_ xs ys) → Pointwise _∼_ (x ∷ xs) (y ∷ ys) ------------------------------------------------------------------------ -- Properties length-equal : ∀ {m n} {_∼_ : REL A B ℓ} {xs : Vec A m} {ys : Vec B n} → Pointwise _∼_ xs ys → m ≡ n length-equal [] = P.refl length-equal (_ ∷ xs∼ys) = P.cong suc (length-equal xs∼ys) ------------------------------------------------------------------------ -- Operations module _ {_∼_ : REL A B ℓ} where head : ∀ {m n x y} {xs : Vec A m} {ys : Vec B n} → Pointwise _∼_ (x ∷ xs) (y ∷ ys) → x ∼ y head (x∼y ∷ xs∼ys) = x∼y tail : ∀ {m n x y} {xs : Vec A m} {ys : Vec B n} → Pointwise _∼_ (x ∷ xs) (y ∷ ys) → Pointwise _∼_ xs ys tail (x∼y ∷ xs∼ys) = xs∼ys uncons : ∀ {m n x y} {xs : Vec A m} {ys : Vec B n} → Pointwise _∼_ (x ∷ xs) (y ∷ ys) → x ∼ y × Pointwise _∼_ xs ys uncons = < head , tail > lookup : ∀ {n} {xs : Vec A n} {ys : Vec B n} → Pointwise _∼_ xs ys → ∀ i → (Vec.lookup xs i) ∼ (Vec.lookup ys i) lookup (x∼y ∷ _) zero = x∼y lookup (_ ∷ xs∼ys) (suc i) = lookup xs∼ys i map : ∀ {ℓ₂} {_≈_ : REL A B ℓ₂} → _≈_ ⇒ _∼_ → ∀ {m n} → Pointwise _≈_ ⇒ Pointwise _∼_ {m} {n} map ∼₁⇒∼₂ [] = [] map ∼₁⇒∼₂ (x∼y ∷ xs∼ys) = ∼₁⇒∼₂ x∼y ∷ map ∼₁⇒∼₂ xs∼ys ------------------------------------------------------------------------ -- Relational properties refl : ∀ {_∼_ : Rel A ℓ} {n} → Reflexive _∼_ → Reflexive (Pointwise _∼_ {n}) refl ∼-refl {[]} = [] refl ∼-refl {x ∷ xs} = ∼-refl ∷ refl ∼-refl sym : ∀ {P : REL A B ℓ} {Q : REL B A ℓ} {m n} → Sym P Q → Sym (Pointwise P) (Pointwise Q {m} {n}) sym sm [] = [] sym sm (x∼y ∷ xs∼ys) = sm x∼y ∷ sym sm xs∼ys trans : ∀ {P : REL A B ℓ} {Q : REL B C ℓ} {R : REL A C ℓ} {m n o} → Trans P Q R → Trans (Pointwise P {m}) (Pointwise Q {n} {o}) (Pointwise R) trans trns [] [] = [] trans trns (x∼y ∷ xs∼ys) (y∼z ∷ ys∼zs) = trns x∼y y∼z ∷ trans trns xs∼ys ys∼zs decidable : ∀ {_∼_ : REL A B ℓ} → Decidable _∼_ → ∀ {m n} → Decidable (Pointwise _∼_ {m} {n}) decidable dec [] [] = yes [] decidable dec [] (y ∷ ys) = no λ() decidable dec (x ∷ xs) [] = no λ() decidable dec (x ∷ xs) (y ∷ ys) = map′ (uncurry _∷_) uncons (dec x y ×-dec decidable dec xs ys) ------------------------------------------------------------------------ -- Structures module _ {_∼_ : Rel A ℓ} where isEquivalence : IsEquivalence _∼_ → ∀ n → IsEquivalence (Pointwise _∼_ {n}) isEquivalence equiv n = record { refl = refl Eq.refl ; sym = sym Eq.sym ; trans = trans Eq.trans } where module Eq = IsEquivalence equiv isDecEquivalence : IsDecEquivalence _∼_ → ∀ n → IsDecEquivalence (Pointwise _∼_ {n}) isDecEquivalence decEquiv n = record { isEquivalence = isEquivalence Eq.isEquivalence n ; _≟_ = decidable Eq._≟_ } where module Eq = IsDecEquivalence decEquiv ------------------------------------------------------------------------ -- Bundles setoid : Setoid a ℓ → ℕ → Setoid a (a ⊔ ℓ) setoid S n = record { isEquivalence = isEquivalence Eq.isEquivalence n } where module Eq = Setoid S decSetoid : DecSetoid a ℓ → ℕ → DecSetoid a (a ⊔ ℓ) decSetoid S n = record { isDecEquivalence = isDecEquivalence Eq.isDecEquivalence n } where module Eq = DecSetoid S ------------------------------------------------------------------------ -- map module _ {_∼₁_ : REL A B ℓ₁} {_∼₂_ : REL C D ℓ₂} {f : A → C} {g : B → D} where map⁺ : (∀ {x y} → x ∼₁ y → f x ∼₂ g y) → ∀ {m n xs ys} → Pointwise _∼₁_ {m} {n} xs ys → Pointwise _∼₂_ (Vec.map f xs) (Vec.map g ys) map⁺ ∼₁⇒∼₂ [] = [] map⁺ ∼₁⇒∼₂ (x∼y ∷ xs∼ys) = ∼₁⇒∼₂ x∼y ∷ map⁺ ∼₁⇒∼₂ xs∼ys ------------------------------------------------------------------------ -- _++_ module _ {_∼_ : REL A B ℓ} where ++⁺ : ∀ {m n p q} {ws : Vec A m} {xs : Vec B p} {ys : Vec A n} {zs : Vec B q} → Pointwise _∼_ ws xs → Pointwise _∼_ ys zs → Pointwise _∼_ (ws ++ ys) (xs ++ zs) ++⁺ [] ys∼zs = ys∼zs ++⁺ (w∼x ∷ ws∼xs) ys∼zs = w∼x ∷ (++⁺ ws∼xs ys∼zs) ++ˡ⁻ : ∀ {m n} (ws : Vec A m) (xs : Vec B m) {ys : Vec A n} {zs : Vec B n} → Pointwise _∼_ (ws ++ ys) (xs ++ zs) → Pointwise _∼_ ws xs ++ˡ⁻ [] [] _ = [] ++ˡ⁻ (w ∷ ws) (x ∷ xs) (w∼x ∷ ps) = w∼x ∷ ++ˡ⁻ ws xs ps ++ʳ⁻ : ∀ {m n} (ws : Vec A m) (xs : Vec B m) {ys : Vec A n} {zs : Vec B n} → Pointwise _∼_ (ws ++ ys) (xs ++ zs) → Pointwise _∼_ ys zs ++ʳ⁻ [] [] ys∼zs = ys∼zs ++ʳ⁻ (w ∷ ws) (x ∷ xs) (_ ∷ ps) = ++ʳ⁻ ws xs ps ++⁻ : ∀ {m n} (ws : Vec A m) (xs : Vec B m) {ys : Vec A n} {zs : Vec B n} → Pointwise _∼_ (ws ++ ys) (xs ++ zs) → Pointwise _∼_ ws xs × Pointwise _∼_ ys zs ++⁻ ws xs ps = ++ˡ⁻ ws xs ps , ++ʳ⁻ ws xs ps ------------------------------------------------------------------------ -- concat module _ {_∼_ : REL A B ℓ} where concat⁺ : ∀ {m n p q} {xss : Vec (Vec A m) n} {yss : Vec (Vec B p) q} → Pointwise (Pointwise _∼_) xss yss → Pointwise _∼_ (concat xss) (concat yss) concat⁺ [] = [] concat⁺ (xs∼ys ∷ ps) = ++⁺ xs∼ys (concat⁺ ps) concat⁻ : ∀ {m n} (xss : Vec (Vec A m) n) (yss : Vec (Vec B m) n) → Pointwise _∼_ (concat xss) (concat yss) → Pointwise (Pointwise _∼_) xss yss concat⁻ [] [] [] = [] concat⁻ (xs ∷ xss) (ys ∷ yss) ps = ++ˡ⁻ xs ys ps ∷ concat⁻ xss yss (++ʳ⁻ xs ys ps) ------------------------------------------------------------------------ -- tabulate module _ {_∼_ : REL A B ℓ} where tabulate⁺ : ∀ {n} {f : Fin n → A} {g : Fin n → B} → (∀ i → f i ∼ g i) → Pointwise _∼_ (tabulate f) (tabulate g) tabulate⁺ {zero} f∼g = [] tabulate⁺ {suc n} f∼g = f∼g zero ∷ tabulate⁺ (f∼g ∘ suc) tabulate⁻ : ∀ {n} {f : Fin n → A} {g : Fin n → B} → Pointwise _∼_ (tabulate f) (tabulate g) → (∀ i → f i ∼ g i) tabulate⁻ (f₀∼g₀ ∷ _) zero = f₀∼g₀ tabulate⁻ (_ ∷ f∼g) (suc i) = tabulate⁻ f∼g i ------------------------------------------------------------------------ -- Degenerate pointwise relations module _ {P : Pred A ℓ} where Pointwiseˡ⇒All : ∀ {m n} {xs : Vec A m} {ys : Vec B n} → Pointwise (λ x y → P x) xs ys → All P xs Pointwiseˡ⇒All [] = [] Pointwiseˡ⇒All (p ∷ ps) = p ∷ Pointwiseˡ⇒All ps Pointwiseʳ⇒All : ∀ {n} {xs : Vec B n} {ys : Vec A n} → Pointwise (λ x y → P y) xs ys → All P ys Pointwiseʳ⇒All [] = [] Pointwiseʳ⇒All (p ∷ ps) = p ∷ Pointwiseʳ⇒All ps All⇒Pointwiseˡ : ∀ {n} {xs : Vec A n} {ys : Vec B n} → All P xs → Pointwise (λ x y → P x) xs ys All⇒Pointwiseˡ {ys = []} [] = [] All⇒Pointwiseˡ {ys = _ ∷ _} (p ∷ ps) = p ∷ All⇒Pointwiseˡ ps All⇒Pointwiseʳ : ∀ {n} {xs : Vec B n} {ys : Vec A n} → All P ys → Pointwise (λ x y → P y) xs ys All⇒Pointwiseʳ {xs = []} [] = [] All⇒Pointwiseʳ {xs = _ ∷ _} (p ∷ ps) = p ∷ All⇒Pointwiseʳ ps ------------------------------------------------------------------------ -- Pointwise _≡_ is equivalent to _≡_ Pointwise-≡⇒≡ : ∀ {n} {xs ys : Vec A n} → Pointwise _≡_ xs ys → xs ≡ ys Pointwise-≡⇒≡ [] = P.refl Pointwise-≡⇒≡ (P.refl ∷ xs∼ys) = P.cong (_ ∷_) (Pointwise-≡⇒≡ xs∼ys) ≡⇒Pointwise-≡ : ∀ {n} {xs ys : Vec A n} → xs ≡ ys → Pointwise _≡_ xs ys ≡⇒Pointwise-≡ P.refl = refl P.refl Pointwise-≡↔≡ : ∀ {n} {xs ys : Vec A n} → Pointwise _≡_ xs ys ⇔ xs ≡ ys Pointwise-≡↔≡ = equivalence Pointwise-≡⇒≡ ≡⇒Pointwise-≡ ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 0.15 Pointwise-≡ = Pointwise-≡↔≡ {-# WARNING_ON_USAGE Pointwise-≡ "Warning: Pointwise-≡ was deprecated in v0.15. Please use Pointwise-≡↔≡ instead." #-}
{ "alphanum_fraction": 0.4542173644, "avg_line_length": 35.5238095238, "ext": "agda", "hexsha": "86d595be1b38afee250441ce4089f1a9dda0b985", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Vec/Relation/Binary/Pointwise/Inductive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Vec/Relation/Binary/Pointwise/Inductive.agda", "max_line_length": 78, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Vec/Relation/Binary/Pointwise/Inductive.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": 3680, "size": 9698 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Prelude open import LibraBFT.Concrete.Obligations open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Impl.Base.Types open import LibraBFT.Impl.Consensus.Types open EpochConfig open import LibraBFT.Yasm.Yasm (ℓ+1 0ℓ) EpochConfig epochId authorsN ConcSysParms NodeId-PK-OK -- In this module, we assume that the implementation meets its -- obligations, and use this assumption to prove that, in any reachable -- state, the implementatioon enjoys one of the per-epoch correctness -- conditions proved in Abstract.Properties. It can be extended to other -- properties later. module LibraBFT.Concrete.Properties (impl-correct : ImplObligations) {e}(st : SystemState e) (r : ReachableSystemState st) (eid : Fin e) where open ImplObligations impl-correct open import LibraBFT.Concrete.System sps-cor open PerState st r open PerEpoch eid open import LibraBFT.Abstract.Abstract UID _≟UID_ NodeId 𝓔 (ConcreteVoteEvidence 𝓔) as Abs open import LibraBFT.Concrete.Intermediate 𝓔 (ConcreteVoteEvidence 𝓔) import LibraBFT.Concrete.Obligations.VotesOnce 𝓔 (ConcreteVoteEvidence 𝓔) as VO-obl import LibraBFT.Concrete.Obligations.LockedRound 𝓔 (ConcreteVoteEvidence 𝓔) as LR-obl open import LibraBFT.Concrete.Properties.VotesOnce as VO open import LibraBFT.Concrete.Properties.LockedRound as LR -------------------------------------------------------------------------------------------- -- * A /ValidSysState/ is one in which both peer obligations are obeyed by honest peers * -- -------------------------------------------------------------------------------------------- record ValidSysState {ℓ}(𝓢 : IntermediateSystemState ℓ) : Set (ℓ+1 ℓ0 ℓ⊔ ℓ) where field vss-votes-once : VO-obl.Type 𝓢 vss-locked-round : LR-obl.Type 𝓢 open ValidSysState public -- TODO-2 : This should be provided as a module parameter here, and the -- proofs provided to instantiate it should be refactored into LibraBFT.Impl. -- However, see the TODO-3 in LibraBFT.Concrete.Intermediate, which suggests -- that those proofs may change, perhaps some parts of them will remain in -- Concrete and others should be in Impl, depending on how that TODO-3 is -- addressed. There is not much point in doing said refactoring until we -- make progress on that question. validState : ValidSysState IntSystemState validState = record { vss-votes-once = VO.Proof.voo sps-cor vo₁ vo₂ st r eid ; vss-locked-round = LR.Proof.lrr sps-cor lr₁ st r eid } open IntermediateSystemState IntSystemState open All-InSys-props InSys open WithAssumptions InSys -- We can now invoke the various abstract correctness properties, using -- ConcCommitsDoNotConflict : ∀{q q'} → {rc : RecordChain (Abs.Q q)} → All-InSys rc → {rc' : RecordChain (Abs.Q q')} → All-InSys rc' → {b b' : Abs.Block} → CommitRule rc b → CommitRule rc' b' → NonInjective-≡ Abs.bId ⊎ ((Abs.B b) ∈RC rc' ⊎ (Abs.B b') ∈RC rc) ConcCommitsDoNotConflict = CommitsDoNotConflict (VO-obl.proof IntSystemState (vss-votes-once validState)) (LR-obl.proof IntSystemState (vss-locked-round validState)) module _ (∈QC⇒AllSent : Complete InSys) where ConcCommitsDoNotConflict' : ∀{q q'}{rc : RecordChain (Abs.Q q)}{rc' : RecordChain (Abs.Q q')}{b b' : Abs.Block} → InSys (Abs.Q q) → InSys (Abs.Q q') → CommitRule rc b → CommitRule rc' b' → NonInjective-≡ Abs.bId ⊎ ((Abs.B b) ∈RC rc' ⊎ (Abs.B b') ∈RC rc) ConcCommitsDoNotConflict' = CommitsDoNotConflict' (VO-obl.proof IntSystemState (vss-votes-once validState)) (LR-obl.proof IntSystemState (vss-locked-round validState)) ∈QC⇒AllSent ConcCommitsDoNotConflict'' : ∀{o o' q q'} → {rcf : RecordChainFrom o (Abs.Q q)} → {rcf' : RecordChainFrom o' (Abs.Q q')} → {b b' : Abs.Block} → InSys (Abs.Q q) → InSys (Abs.Q q') → CommitRuleFrom rcf b → CommitRuleFrom rcf' b' → NonInjective-≡ Abs.bId ⊎ Σ (RecordChain (Abs.Q q')) ((Abs.B b) ∈RC_) ⊎ Σ (RecordChain (Abs.Q q)) ((Abs.B b') ∈RC_) ConcCommitsDoNotConflict'' = CommitsDoNotConflict'' (VO-obl.proof IntSystemState (vss-votes-once validState)) (LR-obl.proof IntSystemState (vss-locked-round validState)) ∈QC⇒AllSent
{ "alphanum_fraction": 0.6238955823, "avg_line_length": 45.6880733945, "ext": "agda", "hexsha": "a92179445e3b22c4d06dd5b889026433f4dd2ddc", "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": "34e4627855fb198665d0c98f377403a906ba75d7", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "haroldcarr/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Concrete/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "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": "haroldcarr/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Concrete/Properties.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "34e4627855fb198665d0c98f377403a906ba75d7", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "haroldcarr/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Concrete/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1395, "size": 4980 }
{-# OPTIONS --without-K #-} module hott.equivalence.coind where open import level open import sum open import equality.core open import equality.calculus open import equality.reasoning open import function.core open import function.extensionality open import function.fibration open import function.isomorphism open import function.overloading open import container.core open import container.fixpoint open import container.m open import hott.equivalence.core open import hott.equivalence.alternative open import hott.level open import sets.unit apply≅' : ∀ {i j}{X : Set i}{Y : Set j} → X ≅' Y → X → Y apply≅' (i , _) = _≅_.to i is-≅' : ∀ {i j}{X : Set i}{Y : Set j} → (X → Y) → Set _ is-≅' {X = X}{Y = Y} f = apply≅' ⁻¹ f abstract ≅'-≈-fib-comm : ∀ {i j}{X : Set i}{Y : Set j}(eq : X ≅' Y) → proj₁ (≅'⇒≈ eq) ≡ apply≅' eq ≅'-≈-fib-comm eq = refl ≅'⇒≈-we : ∀ {i j}{X : Set i}{Y : Set j} → weak-equiv (≅'⇒≈ {X = X}{Y = Y}) ≅'⇒≈-we = proj₂ (≅⇒≈ (sym≅ ≈⇔≅')) is-≅'-≈-iso : ∀ {i j}{X : Set i}{Y : Set j}(f : X → Y) → is-≅' f ≅ weak-equiv f is-≅'-≈-iso {X = X}{Y = Y} f = begin is-≅' f ≡⟨ refl ⟩ (fib weak-equiv ∘' ≅'⇒≈) ⁻¹ f ≅⟨ fib-compose ≅'⇒≈ (fib weak-equiv) f ⟩ ( Σ (fib weak-equiv ⁻¹ f) λ { (we , _) → ≅'⇒≈ ⁻¹ we } ) ≅⟨ ( Σ-ap-iso refl≅ λ { (we , _) → contr-⊤-iso (≅'⇒≈-we we) } ) ⟩ ( fib weak-equiv ⁻¹ f × ⊤ ) ≅⟨ ×-right-unit ⟩ fib weak-equiv ⁻¹ f ≅⟨ fib-iso f ⟩ weak-equiv f ∎ where open ≅-Reasoning is-≅'-h1 : ∀ {i j}{X : Set i}{Y : Set j} → (f : X → Y) → h 1 (is-≅' f) is-≅'-h1 f = iso-level (sym≅ (is-≅'-≈-iso f)) (weak-equiv-h1 f) ≅'-Σ-iso : ∀ {i j}{X : Set i}{Y : Set j} → (X ≅' Y) ≅ (Σ (X → Y) λ f → is-≅' f) ≅'-Σ-iso {X = X}{Y = Y} = sym≅ (total-iso apply≅') ≅'-equality : ∀ {i j}{X : Set i}{Y : Set j} → {isom₁ isom₂ : X ≅' Y} → (apply isom₁ ≡ apply isom₂) → isom₁ ≡ isom₂ ≅'-equality {X = X}{Y = Y} {isom₁}{isom₂} p = iso⇒inj ≅'-Σ-iso q where q : apply ≅'-Σ-iso isom₁ ≡ apply ≅'-Σ-iso isom₂ q = unapΣ (p , h1⇒prop (is-≅'-h1 _) _ _) record F {i j}(Z : ∀ {i j} → Set i → Set j → Set (i ⊔ j)) (X : Set i)(Y : Set j) : Set (i ⊔ j) where constructor mk-F field f : X → Y g : Y → X φ : (x : X)(y : Y) → Z (f x ≡ y) (x ≡ g y) ~-container : ∀ i → Container _ _ _ ~-container i = record { I = Set i × Set i ; A = λ { (X , Y) → (X → Y) × (Y → X) } ; B = λ { {X , Y} _ → X × Y } ; r = λ { {a = f , g} (x , y) → (f x ≡ y) , (x ≡ g y) } } module D {i} where open Definition (~-container i) public open Fixpoint (fix M fixpoint) public hiding (fixpoint) unfold≅' : ∀ {i}{X Y : Set i} → X ≅' Y → D.F (λ { (X , Y) → X ≅' Y }) (X , Y) unfold≅' (isom , _) = (to , from) , λ { (x , y) → ≅⇒≅' (iso-adjunction isom x y) } where open _≅_ isom --unfold≅' : ∀ {i}{X Y : Set i} -- → X ≅' Y → D.F (λ { (X , Y) → X ≅' Y }) (X , Y) --unfold≅' {X = X}{Y = Y} (iso f g α β , δ) = -- ((f , g) , λ {(x , y) → ≅⇒≅' (φ x y)}) -- where -- open ≡-Reasoning -- -- δ' = co-coherence (iso f g α β) δ -- -- iso₁ : {x : X}{y : Y}(p : f x ≡ y) -- → ap f (sym (α x) · ap g p) · β y ≡ p -- iso₁ {x} .{f x} refl = begin -- ap f (sym (α x) · refl) · β (f x) -- ≡⟨ ap (λ z → ap f z · β (f x)) (left-unit (sym (α x))) ⟩ -- ap f (sym (α x)) · β (f x) -- ≡⟨ ap (λ z → z · β (f x)) (ap-inv f (α x)) ⟩ -- sym (ap f (α x)) · β (f x) -- ≡⟨ ap (λ z → sym z · β (f x)) (δ x) ⟩ -- sym (β (f x)) · β (f x) -- ≡⟨ right-inverse (β (f x)) ⟩ -- refl -- ∎ -- -- iso₂' : {x : X}{y : Y}(q : g y ≡ x) -- → sym (α x) · ap g (ap f (sym q) · β y) ≡ sym q -- iso₂' .{g y}{y} refl = begin -- sym (α (g y)) · ap g (refl · β y) -- ≡⟨ ap (λ z → sym (α (g y)) · ap g z) (right-unit (β y)) ⟩ -- sym (α (g y)) · ap g (β y) -- ≡⟨ ap (λ z → sym (α (g y)) · z) (δ' y) ⟩ -- sym (α (g y)) · α (g y) -- ≡⟨ right-inverse (α (g y)) ⟩ -- refl -- ∎ -- -- iso₂ : {x : X}{y : Y}(q : x ≡ g y) -- → sym (α x) · ap g (ap f q · β y) ≡ q -- iso₂ {x}{y} q = -- subst (λ z → sym (α x) · ap g (ap f z · β y) ≡ z) -- (double-inverse q) -- (iso₂' (sym q)) -- -- φ : (x : X)(y : Y) → (f x ≡ y) ≅ (x ≡ g y) -- φ x y = record -- { to = λ p → sym (α x) · ap g p -- ; from = λ q → ap f q · β y -- ; iso₁ = iso₁ -- ; iso₂ = iso₂ } Iso' : ∀ {i} → Set i × Set i → Set _ Iso' (X , Y) = X ≅' Y _~_ : ∀ {i} → Set i → Set i → Set i _~_ {i} X Y = D.M (X , Y) apply~ : ∀ {i}{X Y : Set i} → X ~ Y → X → Y apply~ eq = proj₁ (D.head eq) invert~ : ∀ {i}{X Y : Set i} → X ~ Y → Y → X invert~ eq = proj₂ (D.head eq) private u : ∀ {i}(XY : Set i × Set i) → let (X , Y) = XY in X ~ Y → X ≅' Y u (X , Y) eq = ≅⇒≅' (iso f g α β) where f : X → Y f = apply~ eq g : Y → X g = invert~ eq φ : (x : X)(y : Y) → (f x ≡ y) ~ (x ≡ g y) φ x y = D.tail eq (x , y) α : (x : X) → g (f x) ≡ x α x = sym (apply~ (φ x (f x)) refl) β : (y : Y) → f (g y) ≡ y β y = invert~ (φ (g y) y) refl -- u-morphism : ∀ {i}{X Y : Set i} -- → (eq : X ~ Y) -- → unfold≅' (u _ eq) -- ≡ D.imap u _ (D.out _ eq) -- u-morphism {i}{X}{Y} eq = unapΣ (refl , funext λ {(x , y) → lem₂ x y}) -- where -- f : X → Y -- f = apply~ eq -- -- g : Y → X -- g = invert~ eq -- -- φ : (x : X)(y : Y) → (f x ≡ y) ~ (x ≡ g y) -- φ x y = D.tail eq (x , y) -- -- σ τ : (x : X)(y : Y) → (f x ≡ y) ≅' (x ≡ g y) -- σ x y = proj₂ (unfold≅' (u _ eq)) (x , y) -- τ x y = u _ (φ x y) -- -- lem : (x : X)(y : Y)(p : f x ≡ y) -- → apply≅' (σ x y) p ≡ apply≅' (τ x y) p -- lem x .(f x) refl = ? -- -- lem₂ : (x : X)(y : Y) → proj₂ (unfold≅' (u (X , Y) eq)) (x , y) -- ≡ u _ (D.tail eq (x , y)) -- lem₂ x y = ≅'-equality (funext (lem x y)) -- -- v : ∀ {i}(XY : Set i × Set i) → let (X , Y) = XY in X ≅' Y → X ~ Y -- v = D.unfold (λ _ → unfold≅') -- -- vu-morphism : ∀ {i}{X Y : Set i} -- → (eq : X ~ Y) -- → D.out _ (v _ (u _ eq)) -- ≡ D.imap (v D.∘ⁱ u) _ (D.out _ eq) -- vu-morphism {X = X}{Y = Y} eq = ap (D.imap v _) (u-morphism eq) -- -- vu-id : ∀ {i}{X Y : Set i} (eq : X ~ Y) → v _ (u _ eq) ≡ eq -- vu-id eq = D.unfold-η D.out (v D.∘ⁱ u) vu-morphism eq · D.unfold-id eq -- -- uv-id : ∀ {i}{X Y : Set i} (i : X ≅' Y) → u _ (v _ i) ≡ i -- uv-id {X = X}{Y = Y} i = ≅'-equality refl -- -- ~⇔≅' : ∀ {i}{X Y : Set i} → (X ~ Y) ≅ (X ≅' Y) -- ~⇔≅' = iso (u _) (v _) vu-id uv-id
{ "alphanum_fraction": 0.4025859536, "avg_line_length": 30.1150442478, "ext": "agda", "hexsha": "4f67193aa6e3a3e90c74555018d2aebc9675e835", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_path": "hott/equivalence/coind.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/hott/equivalence/coind.agda", "max_line_length": 75, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "hott/equivalence/coind.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 3113, "size": 6806 }
module TestInt where open import PreludeInt open import PreludeShow mainS = showInt result where result = (mod (((int 2) + (int 2)) * (int 5)) (int 3))
{ "alphanum_fraction": 0.6903225806, "avg_line_length": 22.1428571429, "ext": "agda", "hexsha": "af0a2746c587fb917c7d5fb925a0b7353f562c4c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/Alonzo/TestInt.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/Alonzo/TestInt.agda", "max_line_length": 56, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/outdated-and-incorrect/Alonzo/TestInt.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 50, "size": 155 }
------------------------------------------------------------------------------ -- Arithmetic properties ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module LTC-PCF.Data.Nat.Properties where open import Common.FOL.Relation.Binary.EqReasoning open import LTC-PCF.Base open import LTC-PCF.Base.Properties open import LTC-PCF.Data.Nat open import LTC-PCF.Data.Nat.Rec open import LTC-PCF.Data.Nat.Rec.ConversionRules open import LTC-PCF.Data.Nat.UnaryNumbers ------------------------------------------------------------------------------ -- Congruence properties +-leftCong : ∀ {m n o} → m ≡ n → m + o ≡ n + o +-leftCong refl = refl +-rightCong : ∀ {m n o} → n ≡ o → m + n ≡ m + o +-rightCong refl = refl ∸-leftCong : ∀ {m n o} → m ≡ n → m ∸ o ≡ n ∸ o ∸-leftCong refl = refl ∸-rightCong : ∀ {m n o} → n ≡ o → m ∸ n ≡ m ∸ o ∸-rightCong refl = refl *-leftCong : ∀ {m n o} → m ≡ n → m * o ≡ n * o *-leftCong refl = refl *-rightCong : ∀ {m n o} → n ≡ o → m * n ≡ m * o *-rightCong refl = refl ------------------------------------------------------------------------------ -- Conversion rules +-0x : ∀ n → zero + n ≡ n +-0x n = rec zero n _ ≡⟨ rec-0 n ⟩ n ∎ +-Sx : ∀ m n → succ₁ m + n ≡ succ₁ (m + n) +-Sx m n = rec (succ₁ m) n (lam (λ _ → lam succ₁)) ≡⟨ rec-S m n (lam (λ _ → lam succ₁)) ⟩ (lam (λ _ → lam succ₁)) · m · (m + n) ≡⟨ ·-leftCong (beta (λ _ → lam succ₁) m) ⟩ lam succ₁ · (m + n) ≡⟨ beta succ₁ (m + n) ⟩ succ₁ (m + n) ∎ ∸-x0 : ∀ n → n ∸ zero ≡ n ∸-x0 n = rec zero n _ ≡⟨ rec-0 n ⟩ n ∎ ∸-xS : ∀ m n → m ∸ succ₁ n ≡ pred₁ (m ∸ n) ∸-xS m n = rec (succ₁ n) m (lam (λ _ → lam pred₁)) ≡⟨ rec-S n m (lam (λ _ → lam pred₁)) ⟩ lam (λ x → lam pred₁) · n · (m ∸ n) ≡⟨ ·-leftCong (beta (λ _ → lam pred₁) n) ⟩ lam pred₁ · (m ∸ n) ≡⟨ beta pred₁ (m ∸ n) ⟩ pred₁ (m ∸ n) ∎ *-0x : ∀ n → zero * n ≡ zero *-0x n = rec zero zero (lam (λ _ → lam (_+_ n))) ≡⟨ rec-0 zero ⟩ zero ∎ *-Sx : ∀ m n → succ₁ m * n ≡ n + m * n *-Sx m n = rec (succ₁ m) zero (lam (λ _ → lam (_+_ n))) ≡⟨ rec-S m zero (lam (λ _ → lam (_+_ n))) ⟩ (lam (λ _ → lam (_+_ n))) · m · (m * n) ≡⟨ ·-leftCong (beta (λ _ → lam (_+_ n)) m) ⟩ lam (_+_ n) · (m * n) ≡⟨ beta (_+_ n) (m * n) ⟩ n + (m * n) ∎ ------------------------------------------------------------------------------ +-leftIdentity : ∀ n → zero + n ≡ n +-leftIdentity = +-0x +-rightIdentity : ∀ {n} → N n → n + zero ≡ n +-rightIdentity nzero = +-leftIdentity zero +-rightIdentity (nsucc {n} Nn) = trans (+-Sx n zero) (succCong (+-rightIdentity Nn)) pred-N : ∀ {n} → N n → N (pred₁ n) pred-N nzero = subst N (sym pred-0) nzero pred-N (nsucc {n} Nn) = subst N (sym (pred-S n)) Nn +-N : ∀ {m n} → N m → N n → N (m + n) +-N {n = n} nzero Nn = subst N (sym (+-leftIdentity n)) Nn +-N {n = n} (nsucc {m} Nm) Nn = subst N (sym (+-Sx m n)) (nsucc (+-N Nm Nn)) ∸-N : ∀ {m n} → N m → N n → N (m ∸ n) ∸-N {m} Nm nzero = subst N (sym (∸-x0 m)) Nm ∸-N {m} Nm (nsucc {n} Nn) = subst N (sym (∸-xS m n)) (pred-N (∸-N Nm Nn)) +-assoc : ∀ {m} → N m → ∀ n o → m + n + o ≡ m + (n + o) +-assoc nzero n o = zero + n + o ≡⟨ +-leftCong (+-leftIdentity n) ⟩ n + o ≡⟨ sym (+-leftIdentity (n + o)) ⟩ zero + (n + o) ∎ +-assoc (nsucc {m} Nm) n o = succ₁ m + n + o ≡⟨ +-leftCong (+-Sx m n) ⟩ succ₁ (m + n) + o ≡⟨ +-Sx (m + n) o ⟩ succ₁ (m + n + o) ≡⟨ succCong (+-assoc Nm n o) ⟩ succ₁ (m + (n + o)) ≡⟨ sym (+-Sx m (n + o)) ⟩ succ₁ m + (n + o) ∎ x+Sy≡S[x+y] : ∀ {m} → N m → ∀ n → m + succ₁ n ≡ succ₁ (m + n) x+Sy≡S[x+y] nzero n = zero + succ₁ n ≡⟨ +-leftIdentity (succ₁ n) ⟩ succ₁ n ≡⟨ succCong (sym (+-leftIdentity n)) ⟩ succ₁ (zero + n) ∎ x+Sy≡S[x+y] (nsucc {m} Nm) n = succ₁ m + succ₁ n ≡⟨ +-Sx m (succ₁ n) ⟩ succ₁ (m + succ₁ n) ≡⟨ succCong (x+Sy≡S[x+y] Nm n) ⟩ succ₁ (succ₁ (m + n)) ≡⟨ succCong (sym (+-Sx m n)) ⟩ succ₁ (succ₁ m + n) ∎ 0∸x : ∀ {n} → N n → zero ∸ n ≡ zero 0∸x nzero = ∸-x0 zero 0∸x (nsucc {n} Nn) = zero ∸ succ₁ n ≡⟨ ∸-xS zero n ⟩ pred₁ (zero ∸ n) ≡⟨ predCong (0∸x Nn) ⟩ pred₁ zero ≡⟨ pred-0 ⟩ zero ∎ S∸S : ∀ {m n} → N m → N n → succ₁ m ∸ succ₁ n ≡ m ∸ n S∸S {m} _ nzero = succ₁ m ∸ [1] ≡⟨ ∸-xS (succ₁ m) zero ⟩ pred₁ (succ₁ m ∸ zero) ≡⟨ predCong (∸-x0 (succ₁ m)) ⟩ pred₁ (succ₁ m) ≡⟨ pred-S m ⟩ m ≡⟨ sym (∸-x0 m) ⟩ m ∸ zero ∎ S∸S nzero (nsucc {n} Nn) = [1] ∸ succ₁ (succ₁ n) ≡⟨ ∸-xS [1] (succ₁ n) ⟩ pred₁ ([1] ∸ succ₁ n) ≡⟨ predCong (S∸S nzero Nn) ⟩ pred₁ (zero ∸ n) ≡⟨ predCong (0∸x Nn) ⟩ pred₁ zero ≡⟨ pred-0 ⟩ zero ≡⟨ sym (0∸x (nsucc Nn)) ⟩ zero ∸ succ₁ n ∎ S∸S (nsucc {m} Nm) (nsucc {n} Nn) = succ₁ (succ₁ m) ∸ succ₁ (succ₁ n) ≡⟨ ∸-xS (succ₁ (succ₁ m)) (succ₁ n) ⟩ pred₁ (succ₁ (succ₁ m) ∸ succ₁ n) ≡⟨ predCong (S∸S (nsucc Nm) Nn) ⟩ pred₁ (succ₁ m ∸ n) ≡⟨ sym (∸-xS (succ₁ m) n) ⟩ succ₁ m ∸ succ₁ n ∎ [x+y]∸[x+z]≡y∸z : ∀ {m n o} → N m → N n → N o → (m + n) ∸ (m + o) ≡ n ∸ o [x+y]∸[x+z]≡y∸z {n = n} {o} nzero _ _ = (zero + n) ∸ (zero + o) ≡⟨ ∸-leftCong (+-leftIdentity n) ⟩ n ∸ (zero + o) ≡⟨ ∸-rightCong (+-leftIdentity o) ⟩ n ∸ o ∎ [x+y]∸[x+z]≡y∸z {n = n} {o} (nsucc {m} Nm) Nn No = (succ₁ m + n) ∸ (succ₁ m + o) ≡⟨ ∸-leftCong (+-Sx m n) ⟩ succ₁ (m + n) ∸ (succ₁ m + o) ≡⟨ ∸-rightCong (+-Sx m o) ⟩ succ₁ (m + n) ∸ succ₁ (m + o) ≡⟨ S∸S (+-N Nm Nn) (+-N Nm No) ⟩ (m + n) ∸ (m + o) ≡⟨ [x+y]∸[x+z]≡y∸z Nm Nn No ⟩ n ∸ o ∎ +-comm : ∀ {m n} → N m → N n → m + n ≡ n + m +-comm {n = n} nzero Nn = zero + n ≡⟨ +-leftIdentity n ⟩ n ≡⟨ sym (+-rightIdentity Nn) ⟩ n + zero ∎ +-comm {n = n} (nsucc {m} Nm) Nn = succ₁ m + n ≡⟨ +-Sx m n ⟩ succ₁ (m + n) ≡⟨ succCong (+-comm Nm Nn) ⟩ succ₁ (n + m) ≡⟨ sym (x+Sy≡S[x+y] Nn m) ⟩ n + succ₁ m ∎ *-leftZero : ∀ n → zero * n ≡ zero *-leftZero = *-0x *-rightZero : ∀ {n} → N n → n * zero ≡ zero *-rightZero nzero = *-leftZero zero *-rightZero (nsucc {n} Nn) = trans (*-Sx n zero) (trans (+-leftIdentity (n * zero)) (*-rightZero Nn)) *-N : ∀ {m n} → N m → N n → N (m * n) *-N {n = n} nzero _ = subst N (sym (*-leftZero n)) nzero *-N {n = n} (nsucc {m} Nm) Nn = subst N (sym (*-Sx m n)) (+-N Nn (*-N Nm Nn)) *-leftIdentity : ∀ {n} → N n → [1] * n ≡ n *-leftIdentity {n} Nn = [1] * n ≡⟨ *-Sx zero n ⟩ n + zero * n ≡⟨ +-rightCong (*-leftZero n) ⟩ n + zero ≡⟨ +-rightIdentity Nn ⟩ n ∎ x*Sy≡x+xy : ∀ {m n} → N m → N n → m * succ₁ n ≡ m + m * n x*Sy≡x+xy {n = n} nzero Nn = sym ( zero + zero * n ≡⟨ +-rightCong (*-leftZero n) ⟩ zero + zero ≡⟨ +-leftIdentity zero ⟩ zero ≡⟨ sym (*-leftZero (succ₁ n)) ⟩ zero * succ₁ n ∎ ) x*Sy≡x+xy {n = n} (nsucc {m} Nm) Nn = succ₁ m * succ₁ n ≡⟨ *-Sx m (succ₁ n) ⟩ succ₁ n + m * succ₁ n ≡⟨ +-rightCong (x*Sy≡x+xy Nm Nn) ⟩ succ₁ n + (m + m * n) ≡⟨ +-Sx n (m + m * n) ⟩ succ₁ (n + (m + m * n)) ≡⟨ succCong (sym (+-assoc Nn m (m * n))) ⟩ succ₁ (n + m + m * n) ≡⟨ succCong (+-leftCong (+-comm Nn Nm)) ⟩ succ₁ (m + n + m * n) ≡⟨ succCong (+-assoc Nm n (m * n)) ⟩ succ₁ (m + (n + m * n)) ≡⟨ sym (+-Sx m (n + m * n)) ⟩ succ₁ m + (n + m * n) ≡⟨ +-rightCong (sym (*-Sx m n)) ⟩ succ₁ m + succ₁ m * n ∎ *-comm : ∀ {m n} → N m → N n → m * n ≡ n * m *-comm {n = n} nzero Nn = trans (*-leftZero n) (sym (*-rightZero Nn)) *-comm {n = n} (nsucc {m} Nm) Nn = succ₁ m * n ≡⟨ *-Sx m n ⟩ n + m * n ≡⟨ +-rightCong (*-comm Nm Nn) ⟩ n + n * m ≡⟨ sym (x*Sy≡x+xy Nn Nm) ⟩ n * succ₁ m ∎ *∸-leftDistributive : ∀ {m n o} → N m → N n → N o → (m ∸ n) * o ≡ m * o ∸ n * o *∸-leftDistributive {m} {o = o} _ nzero _ = (m ∸ zero) * o ≡⟨ *-leftCong (∸-x0 m) ⟩ m * o ≡⟨ sym (∸-x0 (m * o)) ⟩ m * o ∸ zero ≡⟨ ∸-rightCong (sym (*-leftZero o)) ⟩ m * o ∸ zero * o ∎ *∸-leftDistributive {o = o} nzero (nsucc {n} Nn) No = (zero ∸ succ₁ n) * o ≡⟨ *-leftCong (0∸x (nsucc Nn)) ⟩ zero * o ≡⟨ *-leftZero o ⟩ zero ≡⟨ sym (0∸x (*-N (nsucc Nn) No)) ⟩ zero ∸ succ₁ n * o ≡⟨ ∸-leftCong (sym (*-leftZero o)) ⟩ zero * o ∸ succ₁ n * o ∎ *∸-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) nzero = (succ₁ m ∸ succ₁ n) * zero ≡⟨ *-comm (∸-N (nsucc Nm) (nsucc Nn)) nzero ⟩ zero * (succ₁ m ∸ succ₁ n) ≡⟨ *-leftZero (succ₁ m ∸ succ₁ n) ⟩ zero ≡⟨ sym (0∸x (*-N (nsucc Nn) nzero)) ⟩ zero ∸ succ₁ n * zero ≡⟨ ∸-leftCong (sym (*-leftZero (succ₁ m))) ⟩ zero * succ₁ m ∸ succ₁ n * zero ≡⟨ ∸-leftCong (*-comm nzero (nsucc Nm)) ⟩ succ₁ m * zero ∸ succ₁ n * zero ∎ *∸-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) = (succ₁ m ∸ succ₁ n) * succ₁ o ≡⟨ *-leftCong (S∸S Nm Nn) ⟩ (m ∸ n) * succ₁ o ≡⟨ *∸-leftDistributive Nm Nn (nsucc No) ⟩ m * succ₁ o ∸ n * succ₁ o ≡⟨ sym ([x+y]∸[x+z]≡y∸z (nsucc No) (*-N Nm (nsucc No)) (*-N Nn (nsucc No))) ⟩ (succ₁ o + m * succ₁ o) ∸ (succ₁ o + n * succ₁ o) ≡⟨ ∸-leftCong (sym (*-Sx m (succ₁ o))) ⟩ (succ₁ m * succ₁ o) ∸ (succ₁ o + n * succ₁ o) ≡⟨ ∸-rightCong (sym (*-Sx n (succ₁ o))) ⟩ (succ₁ m * succ₁ o) ∸ (succ₁ n * succ₁ o) ∎ *+-leftDistributive : ∀ {m n o} → N m → N n → N o → (m + n) * o ≡ m * o + n * o *+-leftDistributive {m} {n} Nm Nn nzero = (m + n) * zero ≡⟨ *-comm (+-N Nm Nn) nzero ⟩ zero * (m + n) ≡⟨ *-leftZero (m + n) ⟩ zero ≡⟨ sym (*-leftZero m) ⟩ zero * m ≡⟨ *-comm nzero Nm ⟩ m * zero ≡⟨ sym (+-rightIdentity (*-N Nm nzero)) ⟩ m * zero + zero ≡⟨ +-rightCong (trans (sym (*-leftZero n)) (*-comm nzero Nn)) ⟩ m * zero + n * zero ∎ *+-leftDistributive {n = n} nzero Nn (nsucc {o} No) = (zero + n) * succ₁ o ≡⟨ *-leftCong (+-leftIdentity n) ⟩ n * succ₁ o ≡⟨ sym (+-leftIdentity (n * succ₁ o)) ⟩ zero + n * succ₁ o ≡⟨ +-leftCong (sym (*-leftZero (succ₁ o))) ⟩ zero * succ₁ o + n * succ₁ o ∎ *+-leftDistributive (nsucc {m} Nm) nzero (nsucc {o} No) = (succ₁ m + zero) * succ₁ o ≡⟨ *-leftCong (+-rightIdentity (nsucc Nm)) ⟩ succ₁ m * succ₁ o ≡⟨ sym (+-rightIdentity (*-N (nsucc Nm) (nsucc No))) ⟩ succ₁ m * succ₁ o + zero ≡⟨ +-rightCong (sym (*-leftZero (succ₁ o))) ⟩ succ₁ m * succ₁ o + zero * succ₁ o ∎ *+-leftDistributive (nsucc {m} Nm) (nsucc {n} Nn) (nsucc {o} No) = (succ₁ m + succ₁ n) * succ₁ o ≡⟨ *-leftCong (+-Sx m (succ₁ n)) ⟩ succ₁ (m + succ₁ n) * succ₁ o ≡⟨ *-Sx (m + succ₁ n) (succ₁ o) ⟩ succ₁ o + (m + succ₁ n) * succ₁ o ≡⟨ +-rightCong (*+-leftDistributive Nm (nsucc Nn) (nsucc No)) ⟩ succ₁ o + (m * succ₁ o + succ₁ n * succ₁ o) ≡⟨ sym (+-assoc (nsucc No) (m * succ₁ o) (succ₁ n * succ₁ o)) ⟩ succ₁ o + m * succ₁ o + succ₁ n * succ₁ o ≡⟨ +-leftCong (sym (*-Sx m (succ₁ o))) ⟩ succ₁ m * succ₁ o + succ₁ n * succ₁ o ∎
{ "alphanum_fraction": 0.4494963003, "avg_line_length": 34.1981707317, "ext": "agda", "hexsha": "223294d7ff296fe288da395276f5ff52efa22649", "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/LTC-PCF/Data/Nat/Properties.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/LTC-PCF/Data/Nat/Properties.agda", "max_line_length": 81, "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/LTC-PCF/Data/Nat/Properties.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": 5276, "size": 11217 }
{-# OPTIONS --without-K #-} open import lib.Basics open import lib.types.TLevel open import lib.types.Pi open import lib.types.Truncation -- This module is dedicated to [Trunc 0 (x == y)] module lib.types.PathSet where _=₀_ : ∀ {i} {A : Type i} → A → A → Type i _=₀_ x y = Trunc 0 (x == y) _=0_ : ∀ {i} {A : Type i} → A → A → Type i _=0_ = _=₀_ infix 80 _∙₀_ _∙₀'_ -- \.\0 _∙₀_ : ∀ {i} {A : Type i} {x y z : A} → x =₀ y → y =₀ z → x =₀ z _∙₀_ = Trunc-fmap2 _∙_ _∙₀'_ : ∀ {i} {A : Type i} {x y z : A} → x =₀ y → y =₀ z → x =₀ z _∙₀'_ = Trunc-fmap2 _∙'_ !₀ : ∀ {i} {A : Type i} {x y : A} → x =₀ y → y =₀ x !₀ = Trunc-fmap ! idp₀ : ∀ {i} {A : Type i} {a : A} → a =₀ a idp₀ = [ idp ] ap₀ : ∀ {i j} {A : Type i} {B : Type j} {x y : A} (f : A → B) → x =₀ y → f x =₀ f y ap₀ f = Trunc-rec Trunc-level ([_] ∘ ap f) coe₀ : ∀ {i} {A B : Type i} (_ : is-set B) (p : A =₀ B) → A → B coe₀ B-level = Trunc-rec (→-is-set B-level) coe transport₀ : ∀ {i j} {A : Type i} (B : A → Type j) {x y : A} (B-level : is-set (B y)) (p : x =₀ y) → (B x → B y) transport₀ B B-level p = coe₀ B-level (ap₀ B p) module _ {i} {A : Type i} where abstract ∙₀-unit-r : ∀ {x y : A} (q : x =₀ y) → (q ∙₀ idp₀) == q ∙₀-unit-r = Trunc-elim (λ _ → =-preserves-level 0 Trunc-level) (λ p → ap [_] $ ∙-unit-r p) ∙₀-unit-l : ∀ {x y : A} (q : x =₀ y) → (idp₀ ∙₀ q) == q ∙₀-unit-l = Trunc-elim (λ _ → =-preserves-level 0 Trunc-level) (λ _ → idp) ∙₀-assoc : {x y z t : A} (p : x =₀ y) (q : y =₀ z) (r : z =₀ t) → (p ∙₀ q) ∙₀ r == p ∙₀ (q ∙₀ r) ∙₀-assoc = Trunc-elim (λ _ → Π-is-set λ _ → Π-is-set λ _ → =-preserves-level 0 Trunc-level) (λ p → Trunc-elim (λ _ → Π-is-set λ _ → =-preserves-level 0 Trunc-level) (λ q → Trunc-elim (λ _ → =-preserves-level 0 Trunc-level) (λ r → ap [_] $ ∙-assoc p q r))) !₀-inv-l : {x y : A} (p : x =₀ y) → (!₀ p) ∙₀ p == idp₀ !₀-inv-l = Trunc-elim (λ _ → =-preserves-level 0 Trunc-level) (λ p → ap [_] $ !-inv-l p) !₀-inv-r : {x y : A} (p : x =₀ y) → p ∙₀ (!₀ p) == idp₀ !₀-inv-r = Trunc-elim (λ _ → =-preserves-level 0 Trunc-level) (λ p → ap [_] $ !-inv-r p) ∙₀-ap₀ : ∀ {j} {B : Type j} (f : A → B) {x y z : A} (p : x =₀ y) (q : y =₀ z) → ap₀ f p ∙₀ ap₀ f q == ap₀ f (p ∙₀ q) ∙₀-ap₀ f = Trunc-elim (λ _ → Π-is-set λ _ → =-preserves-level 0 Trunc-level) (λ p → Trunc-elim (λ _ → =-preserves-level 0 Trunc-level) (λ q → ap [_] $ ∙-ap f p q)) ap₀-∘ : ∀ {j k} {B : Type j} {C : Type k} (g : B → C) (f : A → B) {x y : A} (p : x =₀ y) → ap₀ (g ∘ f) p == ap₀ g (ap₀ f p) ap₀-∘ f g = Trunc-elim (λ _ → =-preserves-level 0 Trunc-level) (λ p → ap [_] $ ap-∘ f g p) coe₀-∙₀ : {B C : Type i} (B-level : is-set B) (C-level : is-set C) → (p : A =₀ B) (q : B =₀ C) (a : A) → coe₀ C-level (p ∙₀ q) a == coe₀ C-level q (coe₀ B-level p a) coe₀-∙₀ B-level C-level = Trunc-elim (λ _ → Π-is-set λ _ → Π-is-set λ _ → =-preserves-level 0 C-level) (λ p → Trunc-elim (λ _ → Π-is-set λ _ → =-preserves-level 0 C-level) (λ q a → coe-∙ p q a)) trans₀-∙₀ : ∀ {j} {B : A → Type j} → (B-level : ∀ a → is-set (B a)) → {x y z : A} (p : x =₀ y) (q : y =₀ z) (b : B x) → transport₀ B (B-level _) (p ∙₀ q) b == transport₀ B (B-level _) q (transport₀ B (B-level _) p b) trans₀-∙₀ B-level = Trunc-elim (λ _ → Π-is-set λ _ → Π-is-set λ _ → =-preserves-level 0 $ B-level _) (λ p → Trunc-elim (λ _ → Π-is-set λ _ → =-preserves-level 0 $ B-level _) (λ q b → trans-∙ p q b)) trans₀-∙₀' : ∀ {j} {B : A → Type j} → (B-level : ∀ a → is-set (B a)) → {x y z : A} (p : x =₀ y) (q : y =₀ z) (b : B x) → transport₀ B (B-level _) (p ∙₀' q) b == transport₀ B (B-level _) q (transport₀ B (B-level _) p b) trans₀-∙₀' B-level = Trunc-elim (λ _ → Π-is-set λ _ → Π-is-set λ _ → =-preserves-level 0 $ B-level _) (λ p → Trunc-elim (λ _ → Π-is-set λ _ → =-preserves-level 0 $ B-level _) (λ q b → trans-∙' p q b)) {- module _ {i} {A : Type i} where trans-id≡₀cst : {a b c : A} (p : b ≡ c) (q : b ≡₀ a) → transport (λ x → x ≡₀ a) p q ≡ proj (! p) ∘₀ q trans-id≡₀cst refl q = ! $ refl₀-left-unit q trans-cst≡₀id : {a b c : A} (p : b ≡ c) (q : a ≡₀ b) → transport (λ x → a ≡₀ x) p q ≡ q ∘₀ proj p trans-cst≡₀id refl q = ! $ refl₀-right-unit q module _ {i} {A : Set i} where homotopy₀-naturality : ∀ {j} {B : Set j} (f g : A → B) (p : (x : A) → f x ≡₀ g x) {x y : A} (q : x ≡₀ y) → ap₀ f q ∘₀ p y ≡ p x ∘₀ ap₀ g q homotopy₀-naturality f g p {x} {y} q = π₀-extend ⦃ λ q → ≡-is-set {x = ap₀ f q ∘₀ p y} {y = p x ∘₀ ap₀ g q} $ π₀-is-set (f x ≡ g y) ⦄ (lemma {x} {y}) q where lemma : ∀ {x y : A} (q : x ≡ y) → ap₀ f (proj q) ∘₀ p y ≡ p x ∘₀ ap₀ g (proj q) lemma refl = refl₀ ∘₀ p _ ≡⟨ refl₀-left-unit (p _) ⟩ p _ ≡⟨ ! $ refl₀-right-unit _ ⟩∎ p _ ∘₀ refl₀ ∎ -- Loop space commutes with truncation in the sense that -- τ n (Ω X) = Ω (τ (S n) X) -- (actually, this is true more generally for paths spaces and we need this -- level of generality to prove it) module _ {i} {n : ℕ₋₂} {A : Set i} where private to : (x y : A) → (τ n (x ≡ y)) → ((proj {n = S n} x) ≡ (proj y)) to x y = τ-extend-nondep ⦃ τ-is-truncated (S n) A _ _ ⦄ (ap proj) -- [truncated-path-space (proj x) (proj y)] is [τ n (x ≡ y)] truncated-path-space : (u v : τ (S n) A) → Type≤ n i truncated-path-space = τ-extend-nondep ⦃ →-is-truncated (S n) (Type≤-is-truncated n _) ⦄ (λ x → τ-extend-nondep ⦃ Type≤-is-truncated n _ ⦄ (λ y → τ n (x ≡ y) , τ-is-truncated n _)) -- We now extend [to] to the truncation of [A], and this is why we needed to -- first extend the return type of [to] to' : (u v : τ (S n) A) → (π₁ (truncated-path-space u v) → u ≡ v) to' = τ-extend ⦃ λ x → Π-is-truncated (S n) (λ a → Π-is-truncated (S n) (λ b → ≡-is-truncated (S n) (τ-is-truncated (S n) A)))⦄ (λ x → τ-extend ⦃ λ t → Π-is-truncated (S n) (λ a → ≡-is-truncated (S n) (τ-is-truncated (S n) A))⦄ (λ y → to x y)) from'-refl : (u : τ (S n) A) → (π₁ (truncated-path-space u u)) from'-refl = τ-extend ⦃ λ x → truncated-is-truncated-S n (π₂ (truncated-path-space x x))⦄ (λ x → proj refl) from' : (u v : τ (S n) A) → (u ≡ v → π₁ (truncated-path-space u v)) from' u .u refl = from'-refl u from : (x y : A) → (proj {n = S n} x ≡ proj y → τ n (x ≡ y)) from x y p = from' (proj x) (proj y) p from-to : (x y : A) (p : τ n (x ≡ y)) → from x y (to x y p) ≡ p from-to x y = τ-extend ⦃ λ _ → ≡-is-truncated n (τ-is-truncated n _)⦄ (from-to' x y) where from-to' : (x y : A) (p : x ≡ y) → from x y (to x y (proj p)) ≡ proj p from-to' x .x refl = refl to'-from' : (u v : τ (S n) A) (p : u ≡ v) → to' u v (from' u v p) ≡ p to'-from' x .x refl = to'-from'-refl x where to'-from'-refl : (u : τ (S n) A) → to' u u (from' u u refl) ≡ refl to'-from'-refl = τ-extend ⦃ λ _ → ≡-is-truncated (S n) (≡-is-truncated (S n) (τ-is-truncated (S n) A))⦄ (λ _ → refl) to-from : (x y : A) (p : proj {n = S n} x ≡ proj y) → to x y (from x y p) ≡ p to-from x y p = to'-from' (proj x) (proj y) p τ-path-equiv-path-τ-S : {x y : A} → τ n (x ≡ y) ≃ (proj {n = S n} x ≡ proj y) τ-path-equiv-path-τ-S {x} {y} = (to x y , iso-is-eq _ (from x y) (to-from x y) (from-to x y)) module _ where open import Homotopy.Connected abstract connected-has-connected-paths : is-connected (S n) A → (p q : A) → is-connected n (p ≡ q) connected-has-connected-paths conn p q = equiv-types-truncated ⟨-2⟩ (τ-path-equiv-path-τ-S ⁻¹) (contr-is-prop conn (proj p) (proj q)) connected-has-all-τ-paths : is-connected (S n) A → (p q : A) → τ n (p ≡ q) connected-has-all-τ-paths conn p q = π₁ $ connected-has-connected-paths conn p q -}
{ "alphanum_fraction": 0.4628040898, "avg_line_length": 38.3288288288, "ext": "agda", "hexsha": "68744e9d2b12bad89d7c2e78daae528f76dc0811", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "core/lib/types/PathSet.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "core/lib/types/PathSet.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "core/lib/types/PathSet.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3563, "size": 8509 }
-- Issue #2791, reported by Ulf 2017-10-05 -- Reported fixed by Victor 2018-08-11 open import Agda.Builtin.Nat open import Agda.Builtin.Bool open import Agda.Builtin.Equality IF : Bool → Set → Set → Set IF true X Y = X IF false X Y = Y postulate F : (A : Set) (x : A) (B : Set) (y : B) → Set mutual ?b : Bool ?b = _ IFb = IF ?b Nat Bool ?X : IFb ?X = _ ?Y : Nat ?Y = _ foo : F Bool true Nat ?Y ≡ F IFb ?X IFb ?X foo = refl -- ?Y gets solved with 'true' error : ?Y + 1 ≡ 3 error = refl -- Expected failure: -- Nat != Bool of type Set -- when checking that the expression refl has type -- F Bool true Nat ?Y ≡ F IFb ?X IFb ?X
{ "alphanum_fraction": 0.6021341463, "avg_line_length": 16.8205128205, "ext": "agda", "hexsha": "2ebbc63550ca63037c6f1e4213e3e41505a3041d", "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/Issue2791.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/Issue2791.agda", "max_line_length": 50, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue2791.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": 250, "size": 656 }
{-# OPTIONS --safe #-} module Definition.Conversion.Decidable where open import Definition.Untyped open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Properties open import Definition.Conversion open import Definition.Conversion.Whnf open import Definition.Conversion.Soundness open import Definition.Conversion.Symmetry open import Definition.Conversion.Stability open import Definition.Conversion.Conversion open import Definition.Conversion.Lift open import Definition.Typed.Consequences.Syntactic open import Definition.Typed.Consequences.Substitution open import Definition.Typed.Consequences.Injectivity open import Definition.Typed.Consequences.Reduction open import Definition.Typed.Consequences.Equality open import Definition.Typed.Consequences.Inequality as IE open import Definition.Typed.Consequences.NeTypeEq open import Definition.Typed.Consequences.SucCong open import Definition.Conversion.HelperDecidable open import Tools.Nat open import Tools.Product open import Tools.Empty open import Tools.Nullary import Tools.PropositionalEquality as PE abstract -- Agda will do some slow unfolding without abstract ~atℕ : ∀ {Γ t u} → Γ ⊢ t ~ t ↓! ℕ ^ ι ⁰ → (∃ λ A → ∃ λ lA → Γ ⊢ t ~ u ↓! A ^ lA) → Γ ⊢ t ~ u ↓! ℕ ^ ι ⁰ ~atℕ t (A , lA , t~u) = let whnfA , neT , neU = ne~↓! t~u ⊢A , ⊢t , ⊢u = syntacticEqTerm (soundness~↓! t~u) _ , ⊢t∷ℕ , _ = syntacticEqTerm (soundness~↓! t) l≡l , ⊢ℕ≡A = neTypeEq neT ⊢t∷ℕ ⊢t A≡ℕ = ℕ≡A ⊢ℕ≡A whnfA in PE.subst₂ (λ X Y → _ ⊢ _ ~ _ ↓! X ^ Y) A≡ℕ (PE.sym l≡l) t~u ~atU : ∀ {Γ t u r lU l} → Γ ⊢ t ~ t ↓! Univ r lU ^ l → (∃ λ A → ∃ λ lA → Γ ⊢ t ~ u ↓! A ^ lA) → Γ ⊢ t ~ u ↓! Univ r lU ^ l ~atU t (A , lA , t~u) = let whnfA , neT , neU = ne~↓! t~u ⊢A , ⊢t , ⊢u = syntacticEqTerm (soundness~↓! t~u) _ , ⊢t∷U , _ = syntacticEqTerm (soundness~↓! t) l≡l , ⊢U≡A = neTypeEq neT ⊢t∷U ⊢t A≡U = U≡A-whnf ⊢U≡A whnfA in PE.subst₂ (λ X Y → _ ⊢ _ ~ _ ↓! X ^ Y) A≡U (PE.sym l≡l) t~u convert~ : ∀ {Γ Δ A lA B lB t M lM} → ⊢ Γ ≡ Δ → (Γ ⊢ A ~ A ↓! U lA ^ next lA) → (Δ ⊢ B ~ B ↓! U lB ^ next lB) → (Γ ⊢ A ~ B ↓! M ^ lM) → (Δ ⊢ t [conv↑] t ∷ B ^ ι lB) → (Δ ⊢ t [conv↑] t ∷ A ^ ι lA) convert~ Γ≡Δ A B A~B t = let whnfM , neA , neB = ne~↓! A~B ⊢M , ⊢A , ⊢B = syntacticEqTerm (soundness~↓! A~B) _ , ⊢A₂ , _ = syntacticEqTerm (soundness~↓! A) _ , ⊢B₂ , _ = syntacticEqTerm (soundness~↓! B) lA≡lM , ⊢UA≡M = neTypeEq neA ⊢A₂ ⊢A lM≡lB , ⊢M≡UA = neTypeEq neB ⊢B (stabilityTerm (symConEq Γ≡Δ) ⊢B₂) lA≡lB = next-inj (PE.trans lA≡lM lM≡lB) UA≡M = U≡A-whnf ⊢UA≡M whnfM ⊢A≡B = stabilityEq Γ≡Δ (univ (sym (soundness~↓! (PE.subst₂ (λ X Y → _ ⊢ _ ~ _ ↓! X ^ Y) UA≡M (PE.sym lA≡lM) A~B)))) in convConv↑Term (reflConEq (wfTerm ⊢B₂)) ⊢A≡B (PE.subst (λ X → _ ⊢ _ [conv↑] _ ∷ _ ^ ι X) (PE.sym lA≡lB) t) mutual -- Decidability of algorithmic equality of neutrals. dec~↑! : ∀ {k l R T Γ Δ lR lT} → ⊢ Γ ≡ Δ → Γ ⊢ k ~ k ↑! R ^ lR → Δ ⊢ l ~ l ↑! T ^ lT → Dec (∃ λ A → ∃ λ lA → Γ ⊢ k ~ l ↑! A ^ lA) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (var-refl {m} ⊢y m≡m) with n ≟ m dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (var-refl {m} ⊢y m≡m) | yes PE.refl = yes (_ , (_ , var-refl ⊢x n≡n)) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (var-refl {m} ⊢y m≡m) | no ¬p = no λ (_ , (_ , eq)) → ¬p (strongVarEq eq) dec~↑! Γ≡Δ (app-cong x~x t≡t) (app-cong y~y u≡u) with dec~↓! Γ≡Δ x~x y~y dec~↑! Γ≡Δ (app-cong x~x t≡t) (app-cong y~y u≡u) | yes (A , lA , x~y) = let whnfA , neK , neK₀ = ne~↓! x~y ⊢A , ⊢k , ⊢k₀ = syntacticEqTerm (soundness~↓! x~y) _ , ⊢k₁ , _ = syntacticEqTerm (soundness~↓! x~x) _ , ⊢k₂ , _ = syntacticEqTerm (soundness~↓! y~y) l₁≡lA , ΠFG≡A = neTypeEq neK ⊢k₁ ⊢k l₂≡lA , ΠF′G′≡A = neTypeEq neK₀ (stabilityTerm (symConEq Γ≡Δ) ⊢k₂) ⊢k₀ l₂≡l₁ = ιinj (PE.trans l₂≡lA (PE.sym l₁≡lA)) ΠFG≡ΠF′G′ = trans ΠFG≡A (PE.subst (λ X → _ ⊢ _ ≡ _ ^ [ ! , ι X ]) l₂≡l₁ (sym ΠF′G′≡A)) F≡F′ , rF≡rF′ , lF≡lF′ , lG≡lG′ , G≡G′ = injectivity ΠFG≡ΠF′G′ ⊢k₁′ = PE.subst₄ (λ X Y Z T → _ ⊢ _ ∷ Π _ ^ X ° Y ▹ _ ° Z ° T ^ [ ! , ι T ]) rF≡rF′ lF≡lF′ lG≡lG′ (PE.sym l₂≡l₁) ⊢k₁ F≡F″ = (PE.subst₂ (λ X Y → _ ⊢ _ ≡ _ ^ [ X , ι Y ]) rF≡rF′ lF≡lF′ F≡F′) in PE.subst (λ X → Dec (∃ λ A → ∃ λ lA → _ ⊢ _ ∘ _ ^ X ~ _ ∘ _ ^ _ ↑! _ ^ _)) l₂≡l₁ (dec~↑!-app Γ≡Δ ⊢k₁′ ⊢k₂ x~y (decConv↑TermConv′ Γ≡Δ (PE.sym (PE.cong₂ (λ X Y → [ X , ι Y ]) rF≡rF′ lF≡lF′)) PE.refl F≡F″ t≡t u≡u)) dec~↑! Γ≡Δ (app-cong x~x t≡t) (app-cong y~y u≡u) | no ¬p = no (λ { (_ , (_ , app-cong x′ y′)) → ¬p (_ , (_ , x′)) }) dec~↑! Γ≡Δ (natrec-cong {lF = l} F a0 aS k) (natrec-cong {lF = l₀} G b0 bS k₀) with dec-level l l₀ dec~↑! Γ≡Δ (natrec-cong {lF = l} F a0 aS k) (natrec-cong {lF = .l} G b0 bS k₀) | yes PE.refl with decConv↑ (Γ≡Δ ∙ refl (univ (ℕⱼ (wfEqTerm (soundness~↓! k))))) F G dec~↑! Γ≡Δ (natrec-cong {lF = l} F a0 aS k) (natrec-cong {lF = .l} G b0 bS k₀) | yes PE.refl | yes p with decConv↑TermConv Γ≡Δ (substTypeEq (soundnessConv↑ p) (refl (zeroⱼ (wfEqTerm (soundness~↓! k))))) a0 b0 | decConv↑TermConv Γ≡Δ (sucCong (soundnessConv↑ p)) aS bS | dec~↓! Γ≡Δ k k₀ dec~↑! Γ≡Δ (natrec-cong {lF = l} F a0 aS k) (natrec-cong {lF = .l} G b0 bS k₀) | yes PE.refl | yes p | yes p0 | yes pS | yes pK = yes (_ , _ , natrec-cong p p0 pS (~atℕ k pK)) dec~↑! Γ≡Δ (natrec-cong {lF = l} F a0 aS k) (natrec-cong {lF = .l} G b0 bS k₀) | yes PE.refl | yes p | yes p0 | yes pS | no ¬pK = no (λ { (_ , _ , natrec-cong x x₁ x₂ x₃) → ¬pK (_ , _ , x₃) }) dec~↑! Γ≡Δ (natrec-cong {lF = l} F a0 aS k) (natrec-cong {lF = .l} G b0 bS k₀) | yes PE.refl | yes p | yes p0 | no ¬pS | _ = no (λ { (_ , _ , natrec-cong x x₁ x₂ x₃) → ¬pS x₂ }) dec~↑! Γ≡Δ (natrec-cong {lF = l} F a0 aS k) (natrec-cong {lF = .l} G b0 bS k₀) | yes PE.refl | yes p | no ¬p0 | _ | _ = no (λ { (_ , _ , natrec-cong x x₁ x₂ x₃) → ¬p0 x₁ }) dec~↑! Γ≡Δ (natrec-cong {lF = l} F a0 aS k) (natrec-cong {lF = .l} G b0 bS k₀) | yes PE.refl | no ¬p = no (λ { (_ , _ , natrec-cong x x₁ x₂ x₃) → ¬p x }) dec~↑! Γ≡Δ (natrec-cong {lF = l} F a0 aS k) (natrec-cong {lF = l₀} G b0 bS k₀) | no ¬p = no (λ { (_ , .(ι l) , natrec-cong x x₁ x₂ x₃) → ¬p PE.refl }) dec~↑! Γ≡Δ (Emptyrec-cong {ll = l} {lEmpty = ll} F k) (Emptyrec-cong {ll = l₀} {lEmpty = ll₀} G k₀) with dec-level l l₀ | dec-level ll ll₀ dec~↑! Γ≡Δ (Emptyrec-cong {ll = l} {lEmpty = ll} F k) (Emptyrec-cong {ll = .l} {lEmpty = .ll} G k₀) | yes PE.refl | yes PE.refl with decConv↑ Γ≡Δ F G dec~↑! Γ≡Δ (Emptyrec-cong {ll = l} {lEmpty = ll} F k) (Emptyrec-cong {ll = .l} {lEmpty = .ll} G k₀) | yes PE.refl | yes PE.refl | yes p = let _ , ⊢k , _ = soundness~↑% k _ , ⊢k₀ , _ = soundness~↑% k₀ ⊢Γ = wfTerm ⊢k in yes (_ , _ , Emptyrec-cong p (%~↑ ⊢k (stabilityTerm (symConEq Γ≡Δ) ⊢k₀))) dec~↑! Γ≡Δ (Emptyrec-cong {ll = l} {lEmpty = ll} F k) (Emptyrec-cong {ll = .l} {lEmpty = .ll} G k₀) | yes PE.refl | yes PE.refl | no ¬p = no (λ { (_ , .(ι l) , Emptyrec-cong x x₁) → ¬p x }) dec~↑! Γ≡Δ (Emptyrec-cong {ll = l} {lEmpty = ll} F k) (Emptyrec-cong {ll = .l} {lEmpty = ll₀} G k₀) | yes PE.refl | no ¬p = no (λ { (_ , .(ι l) , Emptyrec-cong x x₁) → ¬p PE.refl }) dec~↑! Γ≡Δ (Emptyrec-cong {ll = l} F k) (Emptyrec-cong {ll = l₀} G k₀) | no ¬p | _ = no (λ { (_ , .(ι l) , Emptyrec-cong x x₁) → ¬p PE.refl }) dec~↑! Γ≡Δ (Id-cong A t u) (Id-cong B v w) with dec~↓! Γ≡Δ A B ... | no ¬p = no λ { (.(SProp _) , .(next _) , Id-cong x x₁ x₂) → ¬p (_ , _ , x) } ... | yes (M , lM , A~B) with decConv↑Term Γ≡Δ t (convert~ Γ≡Δ A B A~B v) | decConv↑Term Γ≡Δ u (convert~ Γ≡Δ A B A~B w) ... | yes tv | yes uw = yes (_ , _ , Id-cong (~atU A (M , lM , A~B)) tv uw) ... | yes tv | no ¬uw = no λ { (.(SProp _) , .(next _) , Id-cong x x₁ x₂) → let whnfU , neA , neB = ne~↓! x ⊢U , ⊢A , ⊢B = syntacticEqTerm (soundness~↓! x) _ , ⊢A₂ , _ = syntacticEqTerm (soundness~↓! A) nl≡nl , U≡U = neTypeEq neA ⊢A ⊢A₂ in ¬uw (PE.subst (λ X → _ ⊢ _ [conv↑] _ ∷ _ ^ ι X) (next-inj nl≡nl) x₂) } ... | no ¬tv | _ = no λ { (.(SProp _) , .(next _) , Id-cong x x₁ x₂) → let whnfU , neA , neB = ne~↓! x ⊢U , ⊢A , ⊢B = syntacticEqTerm (soundness~↓! x) _ , ⊢A₂ , _ = syntacticEqTerm (soundness~↓! A) nl≡nl , U≡U = neTypeEq neA ⊢A ⊢A₂ in ¬tv (PE.subst (λ X → _ ⊢ _ [conv↑] _ ∷ _ ^ ι X) (next-inj nl≡nl) x₁) } dec~↑! Γ≡Δ (Id-ℕ t u) (Id-ℕ v w) with dec~↓! Γ≡Δ t v | decConv↑Term Γ≡Δ u w ... | yes tv | yes uw = yes (_ , _ , Id-ℕ (~atℕ t tv) uw) ... | yes tv | no ¬uw = no λ { (_ , _ , Id-ℕ x x₁) → ¬uw x₁ } ... | no ¬tv | _ = no λ { (_ , _ , Id-ℕ x x₁) → ¬tv (_ , _ , x) } dec~↑! Γ≡Δ (Id-ℕ0 t) (Id-ℕ0 u) with dec~↓! Γ≡Δ t u ... | yes tu = yes (_ , _ , Id-ℕ0 (~atℕ t tu)) ... | no ¬tu = no λ { (_ , _ , Id-ℕ0 x) → ¬tu (_ , _ , x) } dec~↑! Γ≡Δ (Id-ℕS t u) (Id-ℕS v w) with decConv↑Term Γ≡Δ t v | dec~↓! Γ≡Δ u w ... | yes tv | yes uw = yes (_ , _ , Id-ℕS tv (~atℕ u uw)) ... | yes tv | no ¬uw = no λ { (_ , _ , Id-ℕS x x₁) → ¬uw (_ , _ , x₁) } ... | no ¬tv | _ = no λ { (_ , _ , Id-ℕS x x₁) → ¬tv x } dec~↑! Γ≡Δ (Id-U t u) (Id-U v w) with dec~↓! Γ≡Δ t v | decConv↑Term Γ≡Δ u w ... | yes tv | yes uw = yes (_ , _ , Id-U (~atU t tv) uw) ... | yes tv | no ¬uw = no λ { (_ , _ , Id-U x x₁) → ¬uw x₁ } ... | no ¬tv | _ = no λ { (_ , _ , Id-U x x₁) → ¬tv (_ , _ , x) } dec~↑! Γ≡Δ (Id-Uℕ t) (Id-Uℕ u) with dec~↓! Γ≡Δ t u ... | yes tu = yes (_ , _ , Id-Uℕ (~atU t tu)) ... | no ¬tu = no λ { (_ , _ , Id-Uℕ x) → ¬tu (_ , _ , x) } dec~↑! Γ≡Δ (Id-UΠ {rA = r} t u) (Id-UΠ {rA = r′} v w) with dec-relevance r r′ | decConv↑Term Γ≡Δ t v | dec~↓! Γ≡Δ u w ... | yes PE.refl | yes tv | yes uw = yes (_ , _ , Id-UΠ tv (~atU u uw)) ... | yes PE.refl | yes tv | no ¬uw = no λ { (_ , _ , Id-UΠ x x₁) → ¬uw (_ , _ , x₁) } ... | yes PE.refl | no ¬tv | _ = no λ { (_ , _ , Id-UΠ x x₁) → ¬tv x } ... | no ¬p | _ | _ = no λ { (_ , _ , Id-UΠ x x₁) → ¬p PE.refl } dec~↑! Γ≡Δ (cast-cong A B t eAB _) (cast-cong C D u eCD _) with dec~↓! Γ≡Δ A C | decConv↑Term Γ≡Δ B D ... | no ¬AC | _ = no λ { (_ , _ , cast-cong x x₁ x₂ x₃ x₄) → ¬AC (_ , _ , x) } ... | yes AC | no ¬BD = no λ { (_ , _ , cast-cong x x₁ x₂ x₃ x₄) → ¬BD x₁ } ... | yes (_ , _ , A~C) | yes BD with decConv↑Term Γ≡Δ t (convert~ Γ≡Δ A C A~C u) ... | yes p = yes (_ , _ , cast-cong (~atU A (_ , _ , A~C)) BD p eAB (stabilityTerm (symConEq Γ≡Δ) eCD)) ... | no ¬p = no λ { (_ , _ , cast-cong x x₁ x₂ x₃ x₄) → ¬p x₂ } dec~↑! Γ≡Δ (cast-ℕ A t eℕA _) (cast-ℕ B u eℕB _) with dec~↓! Γ≡Δ A B | decConv↑Term Γ≡Δ t u ... | yes AB | yes tu = yes (_ , _ , cast-ℕ (~atU A AB) tu eℕA (stabilityTerm (symConEq Γ≡Δ) eℕB)) ... | yes AB | no ¬tu = no λ { (_ , _ , cast-ℕ x x₁ x₂ x₃) → ¬tu x₁ } ... | no ¬AB | _ = no λ { (_ , _ , cast-ℕ x x₁ x₂ x₃) → ¬AB (_ , _ , x) } dec~↑! Γ≡Δ (cast-ℕℕ t eℕℕ _) (cast-ℕℕ u eℕℕ′ _) with dec~↓! Γ≡Δ t u ... | yes tu = yes (_ , _ , cast-ℕℕ (~atℕ t tu) eℕℕ (stabilityTerm (symConEq Γ≡Δ) eℕℕ′)) ... | no ¬tu = no λ { (_ , _ , cast-ℕℕ x x₁ x₂) → ¬tu (_ , _ , x) } dec~↑! Γ≡Δ (cast-Π {rA = r} Π A t eΠA _) (cast-Π {rA = r′} Π′ B u eΠB _) with dec-relevance r r′ | decConv↑Term Γ≡Δ Π Π′ | dec~↓! Γ≡Δ A B ... | no ¬p | _ | _ = no λ { (_ , _ , cast-Π x x₁ x₂ x₃ x₄) → ¬p PE.refl } ... | yes PE.refl | no ¬ΠΠ′ | _ = no λ { (_ , _ , cast-Π x x₁ x₂ x₃ x₄) → ¬ΠΠ′ x } ... | yes PE.refl | yes ΠΠ′ | no ¬AB = no λ { (_ , _ , cast-Π x x₁ x₂ x₃ x₄) → ¬AB (_ , _ , x₁) } ... | yes PE.refl | yes ΠΠ′ | yes AB with decConv↑TermConv Γ≡Δ (univ (soundnessConv↑Term ΠΠ′)) t u ... | yes p = yes (_ , _ , cast-Π ΠΠ′ (~atU A AB) p eΠA (stabilityTerm (symConEq Γ≡Δ) eΠB)) ... | no ¬p = no λ { (_ , _ , cast-Π x x₁ x₂ x₃ x₄) → ¬p x₂ } dec~↑! Γ≡Δ (cast-Πℕ {rA = r} Π t eΠℕ _) (cast-Πℕ {rA = r′} Π′ u eΠℕ′ _) with dec-relevance r r′ | decConv↑Term Γ≡Δ Π Π′ ... | no ¬p | _ = no λ { (_ , _ , cast-Πℕ x x₁ x₂ x₃) → ¬p PE.refl } ... | yes PE.refl | no ¬ΠΠ′ = no λ { (_ , _ , cast-Πℕ x x₁ x₂ x₃) → ¬ΠΠ′ x } ... | yes PE.refl | yes ΠΠ′ with decConv↑TermConv Γ≡Δ (univ (soundnessConv↑Term ΠΠ′)) t u ... | yes p = yes (_ , _ , cast-Πℕ ΠΠ′ p eΠℕ (stabilityTerm (symConEq Γ≡Δ) eΠℕ′)) ... | no ¬p = no λ { (_ , _ , cast-Πℕ x x₁ x₂ x₃) → ¬p x₁ } dec~↑! Γ≡Δ (cast-ℕΠ {rA = r} Π t eΠℕ _) (cast-ℕΠ {rA = r′} Π′ u eΠℕ′ _) with dec-relevance r r′ | decConv↑Term Γ≡Δ Π Π′ | decConv↑Term Γ≡Δ t u ... | no ¬p | _ | _ = no λ { (_ , _ , cast-ℕΠ x x₁ x₂ x₃) → ¬p PE.refl } ... | yes PE.refl | no ¬ΠΠ′ | _ = no λ { (_ , _ , cast-ℕΠ x x₁ x₂ x₃) → ¬ΠΠ′ x } ... | yes PE.refl | yes ΠΠ′ | no ¬p = no λ { (_ , _ , cast-ℕΠ x x₁ x₂ x₃) → ¬p x₁ } ... | yes PE.refl | yes ΠΠ′ | yes p = yes (_ , _ , cast-ℕΠ ΠΠ′ p eΠℕ (stabilityTerm (symConEq Γ≡Δ) eΠℕ′)) dec~↑! Γ≡Δ (cast-ΠΠ%! A B t eAB _) (cast-ΠΠ%! C D u eCD _) with decConv↑Term Γ≡Δ A C | decConv↑Term Γ≡Δ B D ... | no ¬AC | _ = no λ { (_ , _ , cast-ΠΠ%! x x₁ x₂ x₃ x₄) → ¬AC x } ... | yes AC | no ¬BD = no λ { (_ , _ , cast-ΠΠ%! x x₁ x₂ x₃ x₄) → ¬BD x₁ } ... | yes AC | yes BD with decConv↑TermConv Γ≡Δ (univ (soundnessConv↑Term AC)) t u ... | yes p = yes (_ , _ , cast-ΠΠ%! AC BD p eAB (stabilityTerm (symConEq Γ≡Δ) eCD)) ... | no ¬p = no λ { (_ , _ , cast-ΠΠ%! x x₁ x₂ x₃ x₄) → ¬p x₂ } dec~↑! Γ≡Δ (cast-ΠΠ!% A B t eAB _) (cast-ΠΠ!% C D u eCD _) with decConv↑Term Γ≡Δ A C | decConv↑Term Γ≡Δ B D ... | no ¬AC | _ = no λ { (_ , _ , cast-ΠΠ!% x x₁ x₂ x₃ x₄) → ¬AC x } ... | yes AC | no ¬BD = no λ { (_ , _ , cast-ΠΠ!% x x₁ x₂ x₃ x₄) → ¬BD x₁ } ... | yes AC | yes BD with decConv↑TermConv Γ≡Δ (univ (soundnessConv↑Term AC)) t u ... | yes p = yes (_ , _ , cast-ΠΠ!% AC BD p eAB (stabilityTerm (symConEq Γ≡Δ) eCD)) ... | no ¬p = no λ { (_ , _ , cast-ΠΠ!% x x₁ x₂ x₃ x₄) → ¬p x₂ } -- antidiagonal cases dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (app-cong x~x t≡t) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (natrec-cong x x₁ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (Emptyrec-cong x x₁) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (Id-cong x x₁ x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (Id-ℕ x x₁) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (Id-ℕ0 x) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (Id-ℕS x x₁) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (Id-U x x₁) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (Id-Uℕ x) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (Id-UΠ x x₁) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (cast-cong x x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (cast-ℕ x x₁ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (cast-ℕℕ x x₁ x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (cast-Π x x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (cast-Πℕ x x₁ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (cast-ℕΠ x x₁ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (cast-ΠΠ%! x x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (var-refl {n} ⊢x n≡n) (cast-ΠΠ!% x x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (var-refl x x₁) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (natrec-cong x x₁ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (Emptyrec-cong x x₁) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (Id-cong x x₁ x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (Id-ℕ x x₁) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (Id-ℕ0 x) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (Id-ℕS x x₁) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (Id-U x x₁) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (Id-Uℕ x) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (Id-UΠ x x₁) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (cast-cong x x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (cast-ℕ x x₁ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (cast-ℕℕ x x₁ x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (cast-Π x x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (cast-Πℕ x x₁ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (cast-ℕΠ x x₁ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (cast-ΠΠ%! x x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (app-cong x~x t≡t) (cast-ΠΠ!% x x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (var-refl x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (app-cong x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (Emptyrec-cong x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (Id-cong x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (Id-ℕ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (Id-ℕ0 x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (Id-ℕS x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (Id-U x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (Id-Uℕ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (Id-UΠ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (cast-cong x₄ x₅ x₆ x₇ x₈) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (cast-ℕ x₄ x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (cast-ℕℕ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (cast-Π x₄ x₅ x₆ x₇ x₈) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (cast-Πℕ x₄ x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (cast-ℕΠ x₄ x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (cast-ΠΠ%! x₄ x₅ x₆ x₇ x₈) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (natrec-cong x x₁ x₂ x₃) (cast-ΠΠ!% x₄ x₅ x₆ x₇ x₈) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (var-refl x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (app-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (natrec-cong x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (Id-cong x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (Id-ℕ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (Id-ℕ0 x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (Id-ℕS x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (Id-U x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (Id-Uℕ x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (Id-UΠ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (cast-cong x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (cast-ℕ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (cast-ℕℕ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (cast-Π x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (cast-Πℕ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (cast-ℕΠ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (cast-ΠΠ%! x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Emptyrec-cong x x₁) (cast-ΠΠ!% x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (var-refl x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (app-cong x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (natrec-cong x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (Emptyrec-cong x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (Id-ℕ x₃ x₄) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → Idℕ-elim neA e } dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (Id-ℕ0 x₃) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → Idℕ-elim neA e } dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (Id-ℕS x₃ x₄) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → Idℕ-elim neA e } dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (Id-U x₃ x₄) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → IdU-elim neA e } dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (Id-Uℕ x₃) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → IdU-elim neA e } dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (Id-UΠ x₃ x₄) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → IdU-elim neA e } dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (cast-cong x₃ x₄ x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (cast-ℕ x₃ x₄ x₅ e) = no λ { (_ , _ , ()) } dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (cast-ℕℕ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (cast-Π x₃ x₄ x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (cast-Πℕ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (cast-ℕΠ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (cast-ΠΠ%! x₃ x₄ x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-cong x x₁ x₂) (cast-ΠΠ!% x₃ x₄ x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (var-refl x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (app-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (natrec-cong x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (Emptyrec-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (Id-cong x₂ x₃ x₄) = let _ , neA , _ = ne~↓! x₂ in no λ { ( _ , ( _ , e )) → Idℕ-elim' neA e } dec~↑! Γ≡Δ (Id-ℕ x x₁) (Id-ℕ0 x₂) = let _ , net , _ = ne~↓! x in no (λ { ( _ , ( _ , e )) → Idℕ0-elim net e }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (Id-ℕS x₂ x₃) = let _ , net , _ = ne~↓! x in no (λ { ( _ , ( _ , e )) → IdℕS-elim net e }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (Id-U x₂ x₃) = no λ { ( _ , ( _ , e )) → IdℕU-elim e } dec~↑! Γ≡Δ (Id-ℕ x x₁) (Id-Uℕ x₂) = no λ { ( _ , ( _ , e )) → IdℕU-elim e } dec~↑! Γ≡Δ (Id-ℕ x x₁) (Id-UΠ x₂ x₃) = no λ { ( _ , ( _ , e )) → IdℕU-elim e } dec~↑! Γ≡Δ (Id-ℕ x x₁) (cast-cong x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (cast-ℕ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (cast-ℕℕ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (cast-Π x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (cast-Πℕ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (cast-ℕΠ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (cast-ΠΠ%! x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ x x₁) (cast-ΠΠ!% x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (var-refl x₁ x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (app-cong x₁ x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (natrec-cong x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (Emptyrec-cong x₁ x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (Id-cong x₁ x₂ x₃) = let _ , neA , _ = ne~↓! x₁ in no λ { ( _ , ( _ , e )) → Idℕ-elim' neA e } dec~↑! Γ≡Δ (Id-ℕ0 x) (Id-ℕ x₁ x₂) = let _ , net , _ = ne~↓! x₁ in no (λ { ( _ , ( _ , e )) → Idℕ0-elim' net e }) dec~↑! Γ≡Δ (Id-ℕ0 x) (Id-ℕS x₁ x₂) = no λ { ( _ , ( _ , e )) → Idℕ0S-elim e } dec~↑! Γ≡Δ (Id-ℕ0 x) (Id-U x₁ x₂) = no λ { ( _ , ( _ , e )) → IdℕU-elim e } dec~↑! Γ≡Δ (Id-ℕ0 x) (Id-Uℕ x₁) = no λ { ( _ , ( _ , e )) → IdℕU-elim e } dec~↑! Γ≡Δ (Id-ℕ0 x) (Id-UΠ x₁ x₂) = no λ { ( _ , ( _ , e )) → IdℕU-elim e } dec~↑! Γ≡Δ (Id-ℕ0 x) (cast-cong x₁ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (cast-ℕ x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (cast-ℕℕ x₁ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (cast-Π x₁ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (cast-Πℕ x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (cast-ℕΠ x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (cast-ΠΠ%! x₁ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕ0 x) (cast-ΠΠ!% x₁ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (var-refl x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (app-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (natrec-cong x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (Emptyrec-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (Id-cong x₂ x₃ x₄) = let _ , neA , _ = ne~↓! x₂ in no λ { ( _ , ( _ , e )) → Idℕ-elim' neA e } dec~↑! Γ≡Δ (Id-ℕS x x₁) (Id-ℕ x₂ x₃) = let _ , net , _ = ne~↓! x₂ in no (λ { ( _ , ( _ , e )) → IdℕS-elim' net e }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (Id-ℕ0 x₂) = no λ { ( _ , ( _ , e )) → Idℕ0S-elim' e } dec~↑! Γ≡Δ (Id-ℕS x x₁) (Id-U x₂ x₃) = no λ { ( _ , ( _ , e )) → IdℕU-elim e } dec~↑! Γ≡Δ (Id-ℕS x x₁) (Id-Uℕ x₂) = no λ { ( _ , ( _ , e )) → IdℕU-elim e } dec~↑! Γ≡Δ (Id-ℕS x x₁) (Id-UΠ x₂ x₃) = no λ { ( _ , ( _ , e )) → IdℕU-elim e } dec~↑! Γ≡Δ (Id-ℕS x x₁) (cast-cong x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (cast-ℕ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (cast-ℕℕ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (cast-Π x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (cast-Πℕ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (cast-ℕΠ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (cast-ΠΠ%! x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-ℕS x x₁) (cast-ΠΠ!% x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (var-refl x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (app-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (natrec-cong x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (Emptyrec-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (Id-cong x₂ x₃ x₄) = let _ , neA , _ = ne~↓! x₂ in no λ { ( _ , ( _ , e )) → IdU-elim' neA e } dec~↑! Γ≡Δ (Id-U x x₁) (Id-ℕ x₂ x₃) = no λ { ( _ , ( _ , e )) → IdUℕ-elim e } dec~↑! Γ≡Δ (Id-U x x₁) (Id-ℕ0 x₂) = no λ { ( _ , ( _ , e )) → IdUℕ-elim e } dec~↑! Γ≡Δ (Id-U x x₁) (Id-ℕS x₂ x₃) = no λ { ( _ , ( _ , e )) → IdUℕ-elim e } dec~↑! Γ≡Δ (Id-U x x₁) (Id-Uℕ x₂) = let _ , net , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → IdUUℕ-elim net e } dec~↑! Γ≡Δ (Id-U x x₁) (Id-UΠ x₂ x₃) = let _ , net , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → IdUUΠ-elim net e } dec~↑! Γ≡Δ (Id-U x x₁) (cast-cong x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (cast-ℕ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (cast-ℕℕ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (cast-Π x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (cast-Πℕ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (cast-ℕΠ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (cast-ΠΠ%! x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-U x x₁) (cast-ΠΠ!% x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (var-refl x₁ x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (app-cong x₁ x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (natrec-cong x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (Emptyrec-cong x₁ x₂) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (Id-cong x₁ x₂ x₃) = let _ , neA , _ = ne~↓! x₁ in no λ { ( _ , ( _ , e )) → IdU-elim' neA e } dec~↑! Γ≡Δ (Id-Uℕ x) (Id-ℕ x₁ x₂) = no λ { ( _ , ( _ , e )) → IdUℕ-elim e } dec~↑! Γ≡Δ (Id-Uℕ x) (Id-ℕ0 x₁) = no λ { ( _ , ( _ , e )) → IdUℕ-elim e } dec~↑! Γ≡Δ (Id-Uℕ x) (Id-ℕS x₁ x₂) = no λ { ( _ , ( _ , e )) → IdUℕ-elim e } dec~↑! Γ≡Δ (Id-Uℕ x) (Id-U x₁ x₂) = let _ , net , _ = ne~↓! x₁ in no λ { ( _ , ( _ , e )) → IdUUℕ-elim' net e } dec~↑! Γ≡Δ (Id-Uℕ x) (Id-UΠ x₁ x₂) = no λ { ( _ , ( _ , e )) → IdUUΠℕ-elim' e } dec~↑! Γ≡Δ (Id-Uℕ x) (cast-cong x₁ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (cast-ℕ x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (cast-ℕℕ x₁ x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (cast-Π x₁ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (cast-Πℕ x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (cast-ℕΠ x₁ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (cast-ΠΠ%! x₁ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-Uℕ x) (cast-ΠΠ!% x₁ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (var-refl x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (app-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (natrec-cong x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (Emptyrec-cong x₂ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (Id-cong x₂ x₃ x₄) = let _ , neA , _ = ne~↓! x₂ in no λ { ( _ , ( _ , e )) → IdU-elim' neA e } dec~↑! Γ≡Δ (Id-UΠ x x₁) (Id-ℕ x₂ x₃) = no λ { ( _ , ( _ , e )) → IdUℕ-elim e } dec~↑! Γ≡Δ (Id-UΠ x x₁) (Id-ℕ0 x₂) = no λ { ( _ , ( _ , e )) → IdUℕ-elim e } dec~↑! Γ≡Δ (Id-UΠ x x₁) (Id-ℕS x₂ x₃) = no λ { ( _ , ( _ , e )) → IdUℕ-elim e } dec~↑! Γ≡Δ (Id-UΠ x x₁) (Id-U x₂ x₃) = let _ , net , _ = ne~↓! x₂ in no λ { ( _ , ( _ , e )) → IdUUΠ-elim' net e } dec~↑! Γ≡Δ (Id-UΠ x x₁) (Id-Uℕ x₂) = no λ { ( _ , ( _ , e )) → IdUUΠℕ-elim e } dec~↑! Γ≡Δ (Id-UΠ x x₁) (cast-cong x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (cast-ℕ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (cast-ℕℕ x₂ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (cast-Π x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (cast-Πℕ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (cast-ℕΠ x₂ x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (cast-ΠΠ%! x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (Id-UΠ x x₁) (cast-ΠΠ!% x₂ x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (var-refl x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (app-cong x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (natrec-cong x₅ x₆ x₇ x₈) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (Emptyrec-cong x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (Id-cong x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (Id-ℕ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (Id-ℕ0 x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (Id-ℕS x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (Id-U x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (Id-Uℕ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (Id-UΠ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (cast-ℕ x₅ x₆ x₇ x₈) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → castℕ-elim neA e } dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (cast-ℕℕ x₅ x₆ x₇) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → castℕ-elim neA e } dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (cast-Π x₅ x₆ x₇ x₈ x₉) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → castΠ-elim neA e } dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (cast-Πℕ x₅ x₆ x₇ x₈) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → castΠ-elim neA e } dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (cast-ℕΠ x₅ x₆ x₇ x₈) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → castℕ-elim neA e } dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (cast-ΠΠ%! x₅ x₆ x₇ x₈ x₉) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → castΠ-elim neA e } dec~↑! Γ≡Δ (cast-cong x x₁ x₂ x₃ x₄) (cast-ΠΠ!% x₅ x₆ x₇ x₈ x₉) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → castΠ-elim neA e } dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (var-refl x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (app-cong x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (natrec-cong x₄ x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (Emptyrec-cong x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (Id-cong x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (Id-ℕ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (Id-ℕ0 x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (Id-ℕS x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (Id-U x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (Id-Uℕ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (Id-UΠ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (cast-cong x₄ x₅ x₆ x₇ x₈) = let _ , neA , _ = ne~↓! x₄ in no λ { ( _ , ( _ , e )) → castℕ-elim' neA e } dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (cast-ℕℕ x₄ x₅ x₆) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → castℕℕ-elim neA e } dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (cast-Π x₄ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (cast-Πℕ x₄ x₅ x₆ x₇) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (cast-ℕΠ x₄ x₅ x₆ x₇) = let _ , neA , _ = ne~↓! x in no λ { ( _ , ( _ , e )) → castℕneΠ-elim neA e } dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (cast-ΠΠ%! x₄ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-ℕ x x₁ x₂ x₃) (cast-ΠΠ!% x₄ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (var-refl x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (app-cong x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (natrec-cong x₃ x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (Emptyrec-cong x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (Id-cong x₃ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (Id-ℕ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (Id-ℕ0 x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (Id-ℕS x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (Id-U x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (Id-Uℕ x₃) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (Id-UΠ x₃ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (cast-cong x₃ x₄ x₅ x₆ x₇) = let _ , neA , _ = ne~↓! x₃ in no λ { ( _ , ( _ , e )) → castℕ-elim' neA e } dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (cast-ℕ x₃ x₄ x₅ x₆) = let _ , neA , _ = ne~↓! x₃ in no λ { ( _ , ( _ , e )) → castℕℕ-elim' neA e } dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (cast-Π x₃ x₄ x₅ x₆ x₇) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (cast-Πℕ x₃ x₄ x₅ x₆) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (cast-ℕΠ x₃ x₄ x₅ x₆) = no λ { ( _ , ( _ , e )) → castℕℕΠ-elim e } dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (cast-ΠΠ%! x₃ x₄ x₅ x₆ x₇) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-ℕℕ x x₁ x₂) (cast-ΠΠ!% x₃ x₄ x₅ x₆ x₇) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (var-refl x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (app-cong x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (natrec-cong x₅ x₆ x₇ x₈) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (Emptyrec-cong x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (Id-cong x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (Id-ℕ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (Id-ℕ0 x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (Id-ℕS x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (Id-U x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (Id-Uℕ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (Id-UΠ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (cast-cong x₅ x₆ x₇ x₈ x₉) = let _ , neA , _ = ne~↓! x₅ in no λ { ( _ , ( _ , e )) → castΠ-elim' neA e } dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (cast-ℕ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (cast-ℕℕ x₅ x₆ x₇) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (cast-Πℕ x₅ x₆ x₇ x₈) = let _ , neA , _ = ne~↓! x₁ in no λ { ( _ , ( _ , e )) → castΠneℕ-elim neA e } dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (cast-ℕΠ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-Π {rA = rA} x x₁ x₂ x₃ x₄) (cast-ΠΠ%! x₅ x₆ x₇ x₈ x₉) = let _ , neA , _ = ne~↓! x₁ in no λ { ( _ , ( _ , e )) → castΠneΠ-elim neA e } dec~↑! Γ≡Δ (cast-Π x x₁ x₂ x₃ x₄) (cast-ΠΠ!% x₅ x₆ x₇ x₈ x₉) = let _ , neA , _ = ne~↓! x₁ in no λ { ( _ , ( _ , e )) → castΠneΠ-elim neA e } dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (var-refl x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (app-cong x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (natrec-cong x₄ x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (Emptyrec-cong x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (Id-cong x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (Id-ℕ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (Id-ℕ0 x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (Id-ℕS x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (Id-U x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (Id-Uℕ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (Id-UΠ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (cast-cong x₄ x₅ x₆ x₇ x₈) = let _ , neA , _ = ne~↓! x₄ in no λ { ( _ , ( _ , e )) → castΠ-elim' neA e } dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (cast-ℕ x₄ x₅ x₆ x₇) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (cast-ℕℕ x₄ x₅ x₆) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (cast-Π x₄ x₅ x₆ x₇ x₈) = let _ , neA , _ = ne~↓! x₅ in no λ { ( _ , ( _ , e )) → castΠneℕ-elim' neA e } dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (cast-ℕΠ x₄ x₅ x₆ x₇) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (cast-ΠΠ%! x₄ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castΠΠℕ-elim e } dec~↑! Γ≡Δ (cast-Πℕ x x₁ x₂ x₃) (cast-ΠΠ!% x₄ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castΠΠℕ-elim e } dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (var-refl x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (app-cong x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (natrec-cong x₄ x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (Emptyrec-cong x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (Id-cong x₄ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (Id-ℕ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (Id-ℕ0 x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (Id-ℕS x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (Id-U x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (Id-Uℕ x₄) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (Id-UΠ x₄ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (cast-cong x₄ x₅ x₆ x₇ x₈) = let _ , neA , _ = ne~↓! x₄ in no λ { ( _ , ( _ , e )) → castℕ-elim' neA e } dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (cast-ℕ x₄ x₅ x₆ x₇) = let _ , neA , _ = ne~↓! x₄ in no λ { ( _ , ( _ , e )) → castℕneΠ-elim' neA e } dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (cast-ℕℕ x₄ x₅ x₆) = no λ { ( _ , ( _ , e )) → castℕℕΠ-elim' e } dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (cast-Π x₄ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (cast-Πℕ x₄ x₅ x₆ x₇) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (cast-ΠΠ%! x₄ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-ℕΠ x x₁ x₂ x₃) (cast-ΠΠ!% x₄ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim e } dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (var-refl x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (app-cong x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (natrec-cong x₅ x₆ x₇ x₈) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (Emptyrec-cong x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (Id-cong x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (Id-ℕ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (Id-ℕ0 x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (Id-ℕS x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (Id-U x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (Id-Uℕ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (Id-UΠ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (cast-cong x₅ x₆ x₇ x₈ x₉) = let _ , neA , _ = ne~↓! x₅ in no λ { ( _ , ( _ , e )) → castΠ-elim' neA e } dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (cast-ℕ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (cast-ℕℕ x₅ x₆ x₇) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (cast-Π x₅ x₆ x₇ x₈ x₉) = let _ , neA , _ = ne~↓! x₆ in no λ { ( _ , ( _ , e )) → castΠneΠ-elim' neA e } dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (cast-Πℕ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castΠΠℕ-elim' e } dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (cast-ℕΠ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-ΠΠ%! x x₁ x₂ x₃ x₄) (cast-ΠΠ!% x₅ x₆ x₇ x₈ x₉) = no λ { ( _ , ( _ , e )) → castΠΠ%!-elim e } dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (var-refl x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (app-cong x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (natrec-cong x₅ x₆ x₇ x₈) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (Emptyrec-cong x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (Id-cong x₅ x₆ x₇) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (Id-ℕ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (Id-ℕ0 x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (Id-ℕS x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (Id-U x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (Id-Uℕ x₅) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (Id-UΠ x₅ x₆) = no (λ { (_ , ()) }) dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (cast-cong x₅ x₆ x₇ x₈ x₉) = let _ , neA , _ = ne~↓! x₅ in no λ { ( _ , ( _ , e )) → castΠ-elim' neA e } dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (cast-ℕ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (cast-ℕℕ x₅ x₆ x₇) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (cast-Π x₅ x₆ x₇ x₈ x₉) = let _ , neA , _ = ne~↓! x₆ in no λ { ( _ , ( _ , e )) → castΠneΠ-elim' neA e } dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (cast-Πℕ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castΠΠℕ-elim' e } dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (cast-ℕΠ x₅ x₆ x₇ x₈) = no λ { ( _ , ( _ , e )) → castℕΠ-elim' e } dec~↑! Γ≡Δ (cast-ΠΠ!% x x₁ x₂ x₃ x₄) (cast-ΠΠ%! x₅ x₆ x₇ x₈ x₉) = no λ { ( _ , ( _ , e )) → castΠΠ!%-elim e } -- Decidability of algorithmic equality of neutrals with types in WHNF. dec~↓! : ∀ {k l R T Γ Δ lR lT} → ⊢ Γ ≡ Δ → Γ ⊢ k ~ k ↓! R ^ lR → Δ ⊢ l ~ l ↓! T ^ lT → Dec (∃ λ A → ∃ λ lA → Γ ⊢ k ~ l ↓! A ^ lA) dec~↓! Γ≡Δ ([~] A D whnfB k~l) ([~] A₁ D₁ whnfB₁ k~l₁) with dec~↑! Γ≡Δ k~l k~l₁ dec~↓! Γ≡Δ ([~] A D whnfB k~l) ([~] A₁ D₁ whnfB₁ k~l₁) | yes (B , lB , k~l₂) = let ⊢B , _ , _ = syntacticEqTerm (soundness~↑! k~l₂) C , whnfC , D′ = whNorm ⊢B in yes (C , _ , [~] B (red D′) whnfC k~l₂) dec~↓! Γ≡Δ ([~] A D whnfB k~l) ([~] A₁ D₁ whnfB₁ k~l₁) | no ¬p = no (λ { (A₂ , _ , [~] A₃ D₂ whnfB₂ k~l₂) → ¬p (A₃ , _ , k~l₂) }) -- Decidability of algorithmic equality of types. decConv↑ : ∀ {A B r Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A [conv↑] A ^ r → Δ ⊢ B [conv↑] B ^ r → Dec (Γ ⊢ A [conv↑] B ^ r) decConv↑ Γ≡Δ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) ([↑] A″ B″ D₁ D″ whnfA″ whnfB″ A′<>B″) rewrite whrDet* (D , whnfA′) (D′ , whnfB′) | whrDet* (D₁ , whnfA″) (D″ , whnfB″) with decConv↓ Γ≡Δ A′<>B′ A′<>B″ decConv↑ Γ≡Δ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) ([↑] A″ B″ D₁ D″ whnfA″ whnfB″ A′<>B″) | yes p = yes ([↑] B′ B″ D′ (stabilityRed* (symConEq Γ≡Δ) D″) whnfB′ whnfB″ p) decConv↑ {r = r} Γ≡Δ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) ([↑] A″ B″ D₁ D″ whnfA″ whnfB″ A′<>B″) | no ¬p = no (λ { ([↑] A‴ B‴ D₂ D‴ whnfA‴ whnfB‴ A′<>B‴) → let A‴≡B′ = whrDet* (D₂ , whnfA‴) (D′ , whnfB′) B‴≡B″ = whrDet* (D‴ , whnfB‴) (stabilityRed* (symConEq Γ≡Δ) D″ , whnfB″) in ¬p (PE.subst₂ (λ x y → _ ⊢ x [conv↓] y ^ r) A‴≡B′ B‴≡B″ A′<>B‴) }) -- Decidability of algorithmic equality of types in WHNF. decConv↓ : ∀ {A B r Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A [conv↓] A ^ r → Δ ⊢ B [conv↓] B ^ r → Dec (Γ ⊢ A [conv↓] B ^ r) decConv↓ Γ≡Δ (U-refl {r = r} x x₁) (U-refl {r = r′} x₂ x₃) with dec-relevance r r′ ... | yes p = yes (U-refl p x₁) ... | no ¬p = no λ p → ¬p (proj₁ (Uinjectivity (soundnessConv↓ p))) decConv↓ Γ≡Δ (univ x) (univ x₁) with decConv↓Term Γ≡Δ x x₁ ... | yes p = yes (univ p) ... | no ¬p = no (λ { (univ x) → ¬p x }) -- Decidability of algorithmic equality of terms. decConv↑Term : ∀ {t u A Γ Δ l} → ⊢ Γ ≡ Δ → Γ ⊢ t [conv↑] t ∷ A ^ l → Δ ⊢ u [conv↑] u ∷ A ^ l → Dec (Γ ⊢ t [conv↑] u ∷ A ^ l) decConv↑Term Γ≡Δ ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) ([↑]ₜ B₁ t″ u″ D₁ d₁ d″ whnfB₁ whnft″ whnfu″ t<>u₁) rewrite whrDet* (D , whnfB) (stabilityRed* (symConEq Γ≡Δ) D₁ , whnfB₁) | whrDet*Term (d , whnft′) (d′ , whnfu′) | whrDet*Term (d₁ , whnft″) (d″ , whnfu″) with decConv↓Term Γ≡Δ t<>u t<>u₁ decConv↑Term Γ≡Δ ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) ([↑]ₜ B₁ t″ u″ D₁ d₁ d″ whnfB₁ whnft″ whnfu″ t<>u₁) | yes p = let Δ≡Γ = symConEq Γ≡Δ in yes ([↑]ₜ B₁ u′ u″ (stabilityRed* Δ≡Γ D₁) d′ (stabilityRed*Term Δ≡Γ d″) whnfB₁ whnfu′ whnfu″ p) decConv↑Term Γ≡Δ ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) ([↑]ₜ B₁ t″ u″ D₁ d₁ d″ whnfB₁ whnft″ whnfu″ t<>u₁) | no ¬p = no (λ { ([↑]ₜ B₂ t‴ u‴ D₂ d₂ d‴ whnfB₂ whnft‴ whnfu‴ t<>u₂) → let B₂≡B₁ = whrDet* (D₂ , whnfB₂) (stabilityRed* (symConEq Γ≡Δ) D₁ , whnfB₁) t‴≡u′ = whrDet*Term (d₂ , whnft‴) (PE.subst (λ x → _ ⊢ _ ⇒* _ ∷ x ^ _) (PE.sym B₂≡B₁) d′ , whnfu′) u‴≡u″ = whrDet*Term (d‴ , whnfu‴) (PE.subst (λ x → _ ⊢ _ ⇒* _ ∷ x ^ _) (PE.sym B₂≡B₁) (stabilityRed*Term (symConEq Γ≡Δ) d″) , whnfu″) in ¬p (PE.subst₃ (λ x y z → _ ⊢ x [conv↓] y ∷ z ^ _) t‴≡u′ u‴≡u″ B₂≡B₁ t<>u₂) }) -- Decidability of algorithmic equality of terms in WHNF. decConv↓Term : ∀ {t u A Γ Δ l} → ⊢ Γ ≡ Δ → Γ ⊢ t [conv↓] t ∷ A ^ l → Δ ⊢ u [conv↓] u ∷ A ^ l → Dec (Γ ⊢ t [conv↓] u ∷ A ^ l) decConv↓Term Γ≡Δ (U-refl {r = r} _ x) (U-refl {r = r′} _ x₁) with dec-relevance r r′ ... | yes p = yes (U-refl p x) ... | no ¬p = no λ p → ¬p (proj₁ (Uinjectivity (univ (soundnessConv↓Term p)))) decConv↓Term Γ≡Δ (ne K) (ne K₁) with dec~↓! Γ≡Δ K K₁ ... | yes (A , lA , K~K₁) = yes (ne (~atU K (A , lA , K~K₁))) ... | no ¬p = no (λ { x → ¬p (Univ _ _ , _ , decConv↓Term-U-ins x K) }) decConv↓Term Γ≡Δ (ℕ-refl x) (ℕ-refl x₁) = yes (ℕ-refl x) decConv↓Term Γ≡Δ (Empty-refl {l = l} x x₁) (Empty-refl {l = l′} x₂ x₃) with dec-level l l′ ... | yes PE.refl = yes (Empty-refl x x₁) ... | no ¬p = no (λ { (Empty-refl x x₁) → ¬p PE.refl }) decConv↓Term Γ≡Δ (Π-cong {rF = rF} {lF = lF} {lG = lG} {lΠ = l} l≡ rF≡rF lF≡lF lG≡lG lF< lG< ⊢F F G) (Π-cong {rF = rH} {lF = lH} {lG = lE} {lΠ = l′} l′≡ _ _ _ _ _ ⊢H H E) with dec-relevance rF rH | dec-level lF lH | dec-level lG lE | dec-level l l′ ... | yes PE.refl | yes PE.refl | yes PE.refl | no ¬p = no λ { (Π-cong x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈) → ¬p PE.refl } ... | yes PE.refl | yes PE.refl | no ¬p | _ = no λ { (Π-cong x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈) → ¬p x₃ } ... | yes PE.refl | no ¬p | _ | _ = no λ { (Π-cong x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈) → ¬p x₂ } ... | no ¬p | _ | _ | _ = no λ { (Π-cong x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈) → ¬p x₁ } ... | yes PE.refl | yes PE.refl | yes PE.refl | yes PE.refl with decConv↑Term Γ≡Δ F H ... | no ¬p = no λ { (Π-cong x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈) → ¬p x₇ } ... | yes pFH with decConv↑Term (Γ≡Δ ∙ univ (soundnessConv↑Term pFH)) G E ... | no ¬p = no λ { (Π-cong x x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈) → ¬p x₈ } ... | yes pGE = yes (Π-cong l≡ rF≡rF lF≡lF lG≡lG lF< lG< ⊢F pFH pGE) decConv↓Term Γ≡Δ (∃-cong {l = l} l≡ ⊢F F G) (∃-cong {l = l′} _ ⊢H H E) with dec-level l l′ ... | no ¬p = no λ { (∃-cong x x₁ x₂ x₃) → ¬p PE.refl } ... | yes PE.refl with decConv↑Term Γ≡Δ F H ... | no ¬p = no λ { (∃-cong x x₁ x₂ x₃) → ¬p x₂ } ... | yes pFH with decConv↑Term (Γ≡Δ ∙ univ (soundnessConv↑Term pFH)) G E ... | no ¬p = no λ { (∃-cong x x₁ x₂ x₃) → ¬p x₃ } ... | yes pGE = yes (∃-cong l≡ ⊢F pFH pGE) decConv↓Term Γ≡Δ (ℕ-ins K) (ℕ-ins K₁) with dec~↓! Γ≡Δ K K₁ ... | yes p = yes (ℕ-ins (~atℕ K p)) ... | no ¬p = no λ x → ¬p (ℕ , _ , decConv↓Term-ℕ-ins x K) decConv↓Term Γ≡Δ (ne-ins ⊢k _ neA k) (ne-ins ⊢k₁ _ _ k₁) with dec~↓! Γ≡Δ k k₁ ... | yes (B , lB , k~k₁) = let whnfB , neK , neK₁ = ne~↓! k~k₁ _ , ⊢k∷B , _ = syntacticEqTerm (soundness~↓! k~k₁) l≡l , ⊢A≡B = neTypeEq neK ⊢k∷B ⊢k in yes (ne-ins ⊢k (stabilityTerm (symConEq Γ≡Δ) ⊢k₁) neA (PE.subst (λ X → _ ⊢ _ ~ _ ↓! _ ^ X) l≡l k~k₁)) ... | no ¬p = no λ x → ¬p (decConv↓Term-ne-ins neA x) decConv↓Term Γ≡Δ (zero-refl x) (zero-refl x₁) = yes (zero-refl x) decConv↓Term Γ≡Δ (suc-cong m) (suc-cong n) with decConv↑Term Γ≡Δ m n ... | yes p = yes (suc-cong p) ... | no ¬p = no λ { (suc-cong x) → ¬p x } decConv↓Term Γ≡Δ (η-eq lF< lG< ⊢F ⊢f _ funf _ f) (η-eq _ _ _ ⊢g _ fung _ g) with decConv↑Term (Γ≡Δ ∙ refl ⊢F) f g ... | yes p = yes (η-eq lF< lG< ⊢F ⊢f (stabilityTerm (symConEq Γ≡Δ) ⊢g) funf fung p) ... | no ¬p = no (λ { (η-eq x x₁ x₂ x₃ x₄ x₅ x₆ x₇) → ¬p x₇ }) decConv↓Term Γ≡Δ (U-refl x x₁) (ne x₂) = no (λ x₃ → decConv↓Term-U (symConv↓Term Γ≡Δ x₃) x₂ (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (U-refl x x₁) (Π-cong x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ x₁₀) = no λ { (ne ()) } decConv↓Term Γ≡Δ (ne x) (U-refl x₁ x₂) = no (λ x₃ → decConv↓Term-U x₃ x (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (ne x) (ℕ-refl x₁) = no (λ x₃ → decConv↓Term-U x₃ x (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (ne x) (Empty-refl x₁ x₂) = no (λ x₃ → decConv↓Term-U x₃ x (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (ne x) (Π-cong x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉) = no (λ x₃ → decConv↓Term-U x₃ x (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (ne x) (∃-cong x₁ x₂ x₃ x₄) = no (λ x₃ → decConv↓Term-U x₃ x (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (ℕ-refl x) (ne x₁) = no (λ x₃ → decConv↓Term-U (symConv↓Term Γ≡Δ x₃) x₁ (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (ℕ-refl x) (Π-cong x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉) = no λ { (ne ()) ; (ne-ins x x₁ () x₃) } decConv↓Term Γ≡Δ (Empty-refl x x₁) (ne x₂) = no (λ x₃ → decConv↓Term-U (symConv↓Term Γ≡Δ x₃) x₂ (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (Empty-refl x x₁) (Π-cong x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ x₁₀) = no λ { (ne ()) ; (ne-ins x x₁ () x₃) } decConv↓Term Γ≡Δ (Empty-refl x x₁) (∃-cong x₂ x₃ x₄ x₅) = no λ { (ne ()) ; (ne-ins x x₁ () x₃) } decConv↓Term Γ≡Δ (Π-cong l x x₁ x₂ x₃ x₄ x₅ x₆ x₇) (U-refl x₈ x₉) = no λ { (ne ()) } decConv↓Term Γ≡Δ (Π-cong l x x₁ x₂ x₃ x₄ x₅ x₆ x₇) (ne x₈) = no (λ x₉ → decConv↓Term-U (symConv↓Term Γ≡Δ x₉) x₈ (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (Π-cong l x x₁ x₂ x₃ x₄ x₅ x₆ x₇) (ℕ-refl x₈) = no λ { (ne ()) ; (ne-ins x x₁ () x₃) } decConv↓Term Γ≡Δ (Π-cong l x x₁ x₂ x₃ x₄ x₅ x₆ x₇) (Empty-refl x₈ x₉) = no λ { (ne ()) ; (ne-ins x x₁ () x₃) } decConv↓Term Γ≡Δ (Π-cong l x x₁ x₂ x₃ x₄ x₅ x₆ x₇) (∃-cong x₈ x₉ x₁₀ x₁₁) = no λ { (ne ()) ; (ne-ins x x₁ () x₃) } decConv↓Term Γ≡Δ (∃-cong l x x₁ x₂) (ne x₃) = no (λ x₉ → decConv↓Term-U (symConv↓Term Γ≡Δ x₉) x₃ (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (∃-cong l x x₁ x₂) (Empty-refl x₃ x₄) = no λ { (ne ()) ; (ne-ins x x₁ () x₃) } decConv↓Term Γ≡Δ (∃-cong l x x₁ x₂) (Π-cong x₃ x₄ x₅ x₆ x₇ x₈ x₉ x₁₀ x₁₁) = no λ { (ne ()) ; (ne-ins x x₁ () x₃) } decConv↓Term Γ≡Δ (ℕ-ins x) (zero-refl x₁) = no (λ x₂ → decConv↓Term-ℕ x₂ x (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (ℕ-ins x) (suc-cong x₁) = no (λ x₂ → decConv↓Term-ℕ x₂ x (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (ne-ins x x₁ () x₃) (ne x₄) decConv↓Term Γ≡Δ (ne-ins x x₁ () x₃) (ℕ-refl x₄) decConv↓Term Γ≡Δ (ne-ins x x₁ () x₃) (Empty-refl x₄ x₅) decConv↓Term Γ≡Δ (ne-ins x x₁ () x₃) (Π-cong x₄ x₅ x₆ x₇ x₈ x₉ x₁₀ x₁₁ x₁₂) decConv↓Term Γ≡Δ (ne-ins x x₁ () x₃) (∃-cong x₄ x₅ x₆ x₇) decConv↓Term Γ≡Δ (ne-ins x x₁ () x₃) (ℕ-ins x₄) decConv↓Term Γ≡Δ (ne-ins x x₁ () x₃) (zero-refl x₄) decConv↓Term Γ≡Δ (ne-ins x x₁ () x₃) (suc-cong x₄) decConv↓Term Γ≡Δ (ne-ins x x₁ () x₃) (η-eq x₄ x₅ x₆ x₇ x₈ x₉ x₁₀ x₁₁) decConv↓Term Γ≡Δ (zero-refl x) (ℕ-ins x₁) = no (λ x₂ → decConv↓Term-ℕ (symConv↓Term Γ≡Δ x₂) x₁ (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (zero-refl x) (suc-cong x₁) = no λ { (ℕ-ins ()) ; (ne-ins x x₁ () x₃) } decConv↓Term Γ≡Δ (suc-cong x) (ℕ-ins x₁) = no (λ x₂ → decConv↓Term-ℕ (symConv↓Term Γ≡Δ x₂) x₁ (λ { ([~] A D whnfB ()) })) decConv↓Term Γ≡Δ (suc-cong x) (zero-refl x₁) = no λ { (ℕ-ins ()) ; (ne-ins x x₁ () x₃) } decConv↓Term Γ≡Δ (η-eq x x₁ x₂ x₃ x₄ x₅ x₆ x₇) (ne-ins x₈ x₉ () x₁₁) -- Decidability of algorithmic equality of terms of equal types. decConv↑TermConv : ∀ {t u A B r Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A ≡ B ^ r → Γ ⊢ t [genconv↑] t ∷ A ^ r → Δ ⊢ u [genconv↑] u ∷ B ^ r → Dec (Γ ⊢ t [genconv↑] u ∷ A ^ r) decConv↑TermConv {r = [ ! , l ]} Γ≡Δ A≡B t u = decConv↑Term Γ≡Δ t (convConvTerm u (stabilityEq Γ≡Δ (sym A≡B))) decConv↑TermConv {r = [ % , l ]} Γ≡Δ A≡B (%~↑ ⊢t ⊢t') (%~↑ ⊢u ⊢u') = yes (%~↑ ⊢t (conv (stabilityTerm (symConEq Γ≡Δ) ⊢u) (sym A≡B))) decConv↑TermConv′ : ∀ {t u A B r r₁ r₂ Γ Δ} → ⊢ Γ ≡ Δ → r PE.≡ r₁ → r PE.≡ r₂ → Γ ⊢ A ≡ B ^ r → Γ ⊢ t [genconv↑] t ∷ A ^ r₁ → Δ ⊢ u [genconv↑] u ∷ B ^ r₂ → Dec (Γ ⊢ t [genconv↑] u ∷ A ^ r) decConv↑TermConv′ Γ≡Δ PE.refl PE.refl A≡B t u = decConv↑TermConv Γ≡Δ A≡B t u
{ "alphanum_fraction": 0.4704334959, "avg_line_length": 62.4184720639, "ext": "agda", "hexsha": "dbd47e13c9e5f565adbc183b63c86a9ea9eab5fc", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/Conversion/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/Conversion/Decidable.agda", "max_line_length": 139, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/Conversion/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": 31169, "size": 54741 }
{-# OPTIONS --erased-cubical #-} open import Agda.Builtin.Cubical.Glue open import Agda.Primitive open import Agda.Primitive.Cubical -- Glue must only be used in erased contexts when --erased-cubical is -- active. _ : SSet (lsuc lzero) _ = (φ : I) (A : Set) (B : Partial φ Set) (f : PartialP φ (λ x → B x ≃ A)) → primGlue A B f
{ "alphanum_fraction": 0.6617210682, "avg_line_length": 22.4666666667, "ext": "agda", "hexsha": "562a29f5f367ac6343240c79c309ad276542f2aa", "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/Erased-cubical-Glue.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/Erased-cubical-Glue.agda", "max_line_length": 69, "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/Erased-cubical-Glue.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": 337 }
-- {-# OPTIONS -v tc.inj:100 #-} -- Andreas, 2012-11-06, issue raised by Guillaume Brunerie module Issue747 where data ℕ : Set where O : ℕ S : ℕ → ℕ record Σ (A : Set) (P : A → Set) : Set where field π₁ : A π₂ : P π₁ data _≡_ {A : Set} : A → A → Set where refl : (a : A) → a ≡ a is-contr : Set → Set is-contr A = Σ A (λ x → ((y : A) → y ≡ x)) is-hlevel : (n : ℕ) → (Set → Set) is-hlevel O A = is-contr A is-hlevel (S n) A = (x y : A) → is-hlevel n (x ≡ y) -- is-hlevel should be injective postulate t : ℕ → Set → Set t-is-hlevel : {n : ℕ} {A : Set} → is-hlevel n (t n A) A : Set f : (n : ℕ) (B : Set) ⦃ x : is-hlevel n B ⦄ → Set g : (n : ℕ) → Set g n = f n (t n A) {- ⦃ t-is-hlevel {n} ⦄ -} -- instance should be found (depends on is-hlevel being injective)
{ "alphanum_fraction": 0.5289672544, "avg_line_length": 22.6857142857, "ext": "agda", "hexsha": "265019cb541c797a695ba38f9fb4ce9a7e3f7d72", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue747.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue747.agda", "max_line_length": 66, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/Issue747.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 338, "size": 794 }
postulate A : Set
{ "alphanum_fraction": 0.65, "avg_line_length": 6.6666666667, "ext": "agda", "hexsha": "97f50ec79fe708e3ac784d96210af1f70556e9f0", "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/Issue2229Base.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/Issue2229Base.agda", "max_line_length": 9, "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/Issue2229Base.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": 8, "size": 20 }
{-# OPTIONS --rewriting #-} module _ (R : Set) where {-# REWRITE R #-}
{ "alphanum_fraction": 0.5479452055, "avg_line_length": 12.1666666667, "ext": "agda", "hexsha": "f18d8cb13d7b495b40054bb215f3bf6239e385e5", "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/Issue1444.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/Issue1444.agda", "max_line_length": 27, "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/Issue1444.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": 20, "size": 73 }
{-# OPTIONS --without-K #-} open import HoTT open import homotopy.elims.CofPushoutSection module homotopy.CofiberComp {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} (f : fst (X ⊙→ Z)) (g : fst (Y ⊙→ Z)) where module CofiberComp where module H = ⊙WedgeRec f g ⊙h = H.⊙f; h = H.f module IntoCod = CofiberRec {f = fst f} {C = fst (⊙Cof ⊙h)} cfbase cfcod (λ x → cfglue (winl x)) module Into = CofiberRec {f = fst (⊙cfcod' f ⊙∘ g)} {C = fst (⊙Cof ⊙h)} cfbase IntoCod.f (λ y → cfglue (winr y)) into = Into.f out-glue : (w : X ∨ Y) → cfbase' (fst (⊙cfcod' f ⊙∘ g)) == cfcod (cfcod (h w)) out-glue = Wedge-elim (λ x → (cfglue (snd Y) ∙ ! (ap (cfcod ∘ cfcod) (snd f ∙ ! (snd g))) ∙ ! (ap cfcod (cfglue (snd X)))) ∙ ap cfcod (cfglue x)) cfglue (↓-cst=app-from-square $ out-square-lemma (cfglue (snd Y)) (ap (cfcod ∘ cfcod) (snd f ∙ ! (snd g))) (ap cfcod (cfglue (snd X))) ⊡v∙ ! (ap-∘ (cfcod ∘ cfcod) h wglue ∙ ap (ap (cfcod ∘ cfcod)) H.glue-β)) where out-square-lemma : ∀ {i} {A : Type i} {x y z w : A} (p : x == y) (q : z == y) (r : w == z) → Square ((p ∙ ! q ∙ ! r) ∙ r) idp q p out-square-lemma idp idp idp = ids module Out = CofiberRec {C = fst (⊙Cof (⊙cfcod' f ⊙∘ g))} cfbase (λ z → cfcod (cfcod z)) out-glue out = Out.f into-out : ∀ c → into (out c) == c into-out = CofPushoutSection.elim {h = h} (λ _ → unit) (λ _ → idp) idp (λ _ → idp) (↓-∘=idf-in into out ∘ λ x → ap (ap into) (Out.glue-β (winl x)) ∙ lemma₁ into (Into.glue-β (snd Y)) (ap-! into (ap (cfcod ∘ cfcod) (snd f ∙ ! (snd g))) ∙ ap ! (∘-ap into (cfcod ∘ cfcod) (snd f ∙ ! (snd g))) ∙ ap (! ∘ ap cfcod) (! H.glue-β) ∙ ap ! (∘-ap cfcod h wglue)) (ap-! into (ap cfcod (cfglue (snd X))) ∙ ap ! (∘-ap into cfcod (cfglue (snd X)) ∙ IntoCod.glue-β (snd X))) (∘-ap into cfcod (cfglue x) ∙ IntoCod.glue-β x) ∙ ap (λ w → w ∙ cfglue (winl x)) (lemma₂ cfglue wglue)) (↓-∘=idf-in into out ∘ λ y → ap (ap into) (Out.glue-β (winr y)) ∙ Into.glue-β y) where lemma₁ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {x y z u v : A} {p : x == y} {q : y == z} {r : z == u} {s : u == v} {p' : f x == f y} {q' : f y == f z} {r' : f z == f u} {s' : f u == f v} (α : ap f p == p') (β : ap f q == q') (γ : ap f r == r') (δ : ap f s == s') → ap f ((p ∙ q ∙ r) ∙ s) == (p' ∙ q' ∙ r') ∙ s' lemma₁ f {p = idp} {q = idp} {r = idp} {s = idp} idp idp idp idp = idp lemma₂ : ∀ {i j} {A : Type i} {B : Type j} {g : A → B} {b : B} (p : ∀ a → b == g a) {x y : A} (q : x == y) → p y ∙ ! (ap g q) ∙ ! (p x) == idp lemma₂ p {x} idp = !-inv-r (p x) out-into : ∀ κ → out (into κ) == κ out-into = Cofiber-elim idp out-into-cod (↓-∘=idf-from-square out into ∘ vert-degen-square ∘ λ y → ap (ap out) (Into.glue-β y) ∙ Out.glue-β (winr y)) where lemma : ∀ {i} {A : Type i} {x y z : A} (p : x == y) (q : y == z) → Square p (p ∙ q) q idp lemma idp idp = ids out-into-cod : ∀ c → out (into (cfcod c)) == cfcod c out-into-cod = Cofiber-elim (cfglue (snd Y) ∙ ! (ap (cfcod ∘ cfcod) (snd f ∙ ! (snd g))) ∙ ! (ap cfcod (cfglue (snd X)))) (λ y → idp) (↓-='-from-square ∘ λ x → (ap-∘ out IntoCod.f (cfglue x) ∙ ap (ap out) (IntoCod.glue-β x) ∙ Out.glue-β (winl x)) ∙v⊡ lemma _ _) eq : fst (⊙Cof (⊙cfcod' f ⊙∘ g)) ≃ fst (⊙Cof ⊙h) eq = equiv into out into-out out-into ⊙path : ⊙Cof (⊙cfcod' f ⊙∘ g) == ⊙Cof ⊙h ⊙path = ⊙ua (⊙≃-in eq idp)
{ "alphanum_fraction": 0.4507154213, "avg_line_length": 32.2564102564, "ext": "agda", "hexsha": "93378f42e580abeb4a5fe0e2a40b542e2f5a48b9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/CofiberComp.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmknapp/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/CofiberComp.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/CofiberComp.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1727, "size": 3774 }
-- Also works for parts of operators. module NotInScope where postulate X : Set if_then_else_ : X -> X -> X -> X x : X bad = if x thenn x else x
{ "alphanum_fraction": 0.6363636364, "avg_line_length": 14, "ext": "agda", "hexsha": "8b5f80b19be30dbe921cfbfbdeda461429544dbf", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/NotInScope.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/NotInScope.agda", "max_line_length": 37, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/NotInScope.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 51, "size": 154 }
{-# OPTIONS --without-K --exact-split #-} module 19-fundamental-cover where import 18-circle open 18-circle public {- Section 12.1 Families over the circle -} Aut : { l1 : Level} → UU l1 → UU l1 Aut Y = Y ≃ Y Fam-circle : ( l1 : Level) → UU (lsuc l1) Fam-circle l1 = Σ (UU l1) Aut Eq-Fam-circle : { l1 : Level} → Fam-circle l1 → Fam-circle l1 → UU l1 Eq-Fam-circle P Q = Σ ( (pr1 P) ≃ (pr1 Q)) ( λ h → ( (map-equiv h) ∘ (map-equiv (pr2 P))) ~ ((map-equiv (pr2 Q)) ∘ (map-equiv h))) reflexive-Eq-Fam-circle : { l1 : Level} (P : Fam-circle l1) → Eq-Fam-circle P P reflexive-Eq-Fam-circle (pair X e) = pair (equiv-id X) refl-htpy Eq-Fam-circle-eq : { l1 : Level} (P Q : Fam-circle l1) → Id P Q → Eq-Fam-circle P Q Eq-Fam-circle-eq P .P refl = reflexive-Eq-Fam-circle P abstract is-contr-total-Eq-Fam-circle : { l1 : Level} (P : Fam-circle l1) → is-contr (Σ (Fam-circle l1) (Eq-Fam-circle P)) is-contr-total-Eq-Fam-circle (pair X e) = is-contr-total-Eq-structure ( λ Y f h → ((map-equiv h) ∘ (map-equiv e)) ~ ((map-equiv f) ∘ (map-equiv h))) ( is-contr-total-equiv X) ( pair X (equiv-id X)) ( is-contr-total-htpy-equiv e) abstract is-equiv-Eq-Fam-circle-eq : { l1 : Level} (P Q : Fam-circle l1) → is-equiv (Eq-Fam-circle-eq P Q) is-equiv-Eq-Fam-circle-eq P = fundamental-theorem-id P ( reflexive-Eq-Fam-circle P) ( is-contr-total-Eq-Fam-circle P) ( Eq-Fam-circle-eq P) eq-Eq-Fam-circle : { l1 : Level} (P Q : Fam-circle l1) → Eq-Fam-circle P Q → Id P Q eq-Eq-Fam-circle P Q = inv-is-equiv (is-equiv-Eq-Fam-circle-eq P Q) ev-fam-circle : { l1 l2 : Level} {X : UU l1} (l : free-loops X) → ( X → UU l2) → Fam-circle l2 ev-fam-circle l P = pair ( P (base-free-loop l)) ( equiv-tr P (loop-free-loop l)) comparison-fam-circle : ( l1 : Level) → free-loops (UU l1) → Fam-circle l1 comparison-fam-circle l1 = tot (λ Y → equiv-eq) abstract is-equiv-comparison-fam-circle : ( l1 : Level) → is-equiv (comparison-fam-circle l1) is-equiv-comparison-fam-circle l1 = is-equiv-tot-is-fiberwise-equiv (λ Y → univalence Y Y) triangle-comparison-fam-circle : { l1 l2 : Level} {X : UU l1} (l : free-loops X) → (ev-fam-circle l) ~ ((comparison-fam-circle l2) ∘ (ev-free-loop l (UU l2))) triangle-comparison-fam-circle l P = eq-Eq-Fam-circle ( ev-fam-circle l P) ( comparison-fam-circle _ (ev-free-loop l (UU _) P)) ( pair (equiv-id _) (htpy-inv (tr-equiv-eq-ap (pr2 l)))) abstract is-equiv-ev-fam-circle-universal-property-circle : { l1 l2 : Level} {X : UU l1} (l : free-loops X) ( up-circle : universal-property-circle (lsuc l2) l) → is-equiv (ev-fam-circle {l2 = l2} l) is-equiv-ev-fam-circle-universal-property-circle {l2 = l2} l up-circle = is-equiv-comp ( ev-fam-circle l) ( comparison-fam-circle l2) ( ev-free-loop l (UU l2)) ( triangle-comparison-fam-circle l) ( up-circle (UU l2)) ( is-equiv-comparison-fam-circle l2) unique-family-property-circle : { l1 : Level} (l2 : Level) {X : UU l1} (l : free-loops X) → UU (l1 ⊔ (lsuc l2)) unique-family-property-circle l2 {X} l = ( Q : Fam-circle l2) → is-contr (Σ (X → UU l2) (λ P → Eq-Fam-circle Q (ev-fam-circle l P))) abstract unique-family-property-universal-property-circle : { l1 l2 : Level} {X : UU l1} (l : free-loops X) → universal-property-circle (lsuc l2) l → unique-family-property-circle l2 l unique-family-property-universal-property-circle l up-circle Q = is-contr-is-equiv' ( fib (ev-fam-circle l) Q) ( tot (λ P → (Eq-Fam-circle-eq Q (ev-fam-circle l P)) ∘ inv)) ( is-equiv-tot-is-fiberwise-equiv ( λ P → is-equiv-comp' _ _ ( is-equiv-inv _ _) ( is-equiv-Eq-Fam-circle-eq Q (ev-fam-circle l P)))) ( is-contr-map-is-equiv ( is-equiv-ev-fam-circle-universal-property-circle l up-circle) ( Q)) Section-Fam-circle : { l1 l2 : Level} {X : UU l1} (l : free-loops X) (P : Fam-circle l2) → UU _ Section-Fam-circle l P = Σ (pr1 P) (λ p → Id (map-equiv (pr2 P) p) p) fam-circle : { l1 l2 : Level} {X : UU l1} (l : free-loops X) → ( dependent-universal-property-circle (lsuc l2) l) → Fam-circle l2 → X → UU l2 fam-circle {l1} {l2} l dup-circle = inv-is-equiv ( is-equiv-ev-fam-circle-universal-property-circle l ( universal-property-dependent-universal-property-circle l dup-circle)) section-fam-circle : { l1 l2 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle l2 l) → ( Q : X → UU l2) (P : Fam-circle l2) → ( e : Eq-Fam-circle P (ev-fam-circle l Q)) → Section-Fam-circle l P → (x : X) → Q x section-fam-circle l dup-circle Q P (pair e H) (pair p α) = inv-is-equiv ( dup-circle Q) ( pair (map-equiv e p) ((inv (H p)) ∙ (ap (map-equiv e) α))) {- Section 12.2 The fundamental cover of the circle -} {- We show that if a type with a free loop satisfies the induction principle of the circle with respect to any universe level, then it satisfies the induction principle with respect to the zeroth universe level. -} naturality-tr-fiberwise-transformation : { l1 l2 l3 : Level} {X : UU l1} {P : X → UU l2} {Q : X → UU l3} ( f : (x : X) → P x → Q x) {x y : X} (α : Id x y) (p : P x) → Id (tr Q α (f x p)) (f y (tr P α p)) naturality-tr-fiberwise-transformation f refl p = refl functor-dependent-free-loops : { l1 l2 l3 : Level} {X : UU l1} (l : free-loops X) { P : X → UU l2} {Q : X → UU l3} (f : (x : X) → P x → Q x) → dependent-free-loops l P → dependent-free-loops l Q functor-dependent-free-loops l {P} {Q} f = toto ( λ q₀ → Id (tr Q (loop-free-loop l) q₀) q₀) ( f (base-free-loop l)) ( λ p₀ α → ( naturality-tr-fiberwise-transformation f (loop-free-loop l) p₀) ∙ ( ap (f (base-free-loop l)) α)) coherence-square-functor-dependent-free-loops : { l1 l2 l3 : Level} {X : UU l1} {P : X → UU l2} {Q : X → UU l3} ( f : (x : X) → P x → Q x) {x y : X} (α : Id x y) ( h : (x : X) → P x) → Id ( ( naturality-tr-fiberwise-transformation f α (h x)) ∙ ( ap (f y) (apd h α))) ( apd (postcomp-Π f h) α) coherence-square-functor-dependent-free-loops f refl h = refl square-functor-dependent-free-loops : { l1 l2 l3 : Level} {X : UU l1} (l : free-loops X) { P : X → UU l2} {Q : X → UU l3} (f : (x : X) → P x → Q x) → ( (functor-dependent-free-loops l f) ∘ (ev-free-loop' l P)) ~ ( (ev-free-loop' l Q) ∘ (postcomp-Π f)) square-functor-dependent-free-loops (pair x l) {P} {Q} f h = eq-Eq-dependent-free-loops (pair x l) Q ( functor-dependent-free-loops (pair x l) f ( ev-free-loop' (pair x l) P h)) ( ev-free-loop' (pair x l) Q (postcomp-Π f h)) ( pair refl ( right-unit ∙ (coherence-square-functor-dependent-free-loops f l h))) abstract is-equiv-functor-dependent-free-loops-is-fiberwise-equiv : { l1 l2 l3 : Level} {X : UU l1} (l : free-loops X) { P : X → UU l2} {Q : X → UU l3} {f : (x : X) → P x → Q x} ( is-equiv-f : (x : X) → is-equiv (f x)) → is-equiv (functor-dependent-free-loops l f) is-equiv-functor-dependent-free-loops-is-fiberwise-equiv (pair x l) {P} {Q} {f} is-equiv-f = is-equiv-toto-is-fiberwise-equiv-is-equiv-base-map ( λ q₀ → Id (tr Q l q₀) q₀) ( _) ( _) ( is-equiv-f x) ( λ p₀ → is-equiv-comp' ( concat ( naturality-tr-fiberwise-transformation f l p₀) ( f x p₀)) ( ap (f x)) ( is-emb-is-equiv (f x) (is-equiv-f x) (tr P l p₀) p₀) ( is-equiv-concat ( naturality-tr-fiberwise-transformation f l p₀) ( f x p₀))) abstract lower-dependent-universal-property-circle : { l1 l2 : Level} (l3 : Level) {X : UU l1} (l : free-loops X) → dependent-universal-property-circle (l2 ⊔ l3) l → dependent-universal-property-circle l3 l lower-dependent-universal-property-circle {l1} {l2} l3 l dup-circle P = is-equiv-left-is-equiv-right-square ( ev-free-loop' l P) ( ev-free-loop' l (λ x → raise l2 (P x))) ( postcomp-Π (λ x → map-raise l2 (P x))) ( functor-dependent-free-loops l (λ x → map-raise l2 (P x))) ( square-functor-dependent-free-loops l (λ x → map-raise l2 (P x))) ( is-equiv-postcomp-Π _ (λ x → is-equiv-map-raise l2 (P x))) ( is-equiv-functor-dependent-free-loops-is-fiberwise-equiv l ( λ x → is-equiv-map-raise l2 (P x))) ( dup-circle (λ x → raise l2 (P x))) abstract lower-lzero-dependent-universal-property-circle : { l1 l2 : Level} {X : UU l1} (l : free-loops X) → dependent-universal-property-circle l2 l → dependent-universal-property-circle lzero l lower-lzero-dependent-universal-property-circle = lower-dependent-universal-property-circle lzero {- The definition of the fundamental cover -} {- The fundamental cover -} abstract Fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l → Σ ( X → UU lzero) ( λ P → Eq-Fam-circle (pair ℤ equiv-succ-ℤ) (ev-fam-circle l P)) Fundamental-cover-circle {l1} l dup-circle = center ( unique-family-property-universal-property-circle l ( universal-property-dependent-universal-property-circle l ( lower-dependent-universal-property-circle {l2 = l1} (lsuc lzero) l dup-circle)) ( pair ℤ equiv-succ-ℤ)) fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l → X → UU lzero fundamental-cover-circle l dup-circle = pr1 (Fundamental-cover-circle l dup-circle) comp-fiber-fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → ℤ ≃ fundamental-cover-circle l dup-circle (base-free-loop l) comp-fiber-fundamental-cover-circle l dup-circle = pr1 ( pr2 ( Fundamental-cover-circle l dup-circle)) comp-tr-fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → ( ( map-equiv (comp-fiber-fundamental-cover-circle l dup-circle)) ∘ ( succ-ℤ)) ~ ( ( tr (fundamental-cover-circle l dup-circle) (loop-free-loop l)) ∘ ( map-equiv (comp-fiber-fundamental-cover-circle l dup-circle))) comp-tr-fundamental-cover-circle l dup-circle = pr2 ( pr2 ( Fundamental-cover-circle l dup-circle)) {- We show that the fundamental cover of the circle is a family of sets. -} abstract is-set-fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → ( x : X) → is-set (fundamental-cover-circle l dup-circle x) is-set-fundamental-cover-circle l dup-circle = is-connected-circle' l ( lower-dependent-universal-property-circle lzero l dup-circle) ( λ x → is-set (fundamental-cover-circle l dup-circle x)) ( λ x → is-prop-is-set (fundamental-cover-circle l dup-circle x)) ( is-trunc-is-equiv' zero-𝕋 ℤ ( map-equiv (comp-fiber-fundamental-cover-circle l dup-circle)) ( is-equiv-map-equiv (comp-fiber-fundamental-cover-circle l dup-circle)) ( is-set-ℤ)) {- Contractibility of a general total space -} contraction-total-space : { l1 l2 : Level} {A : UU l1} {B : A → UU l2} (center : Σ A B) → ( x : A) → UU (l1 ⊔ l2) contraction-total-space {B = B} center x = ( y : B x) → Id center (pair x y) path-total-path-fiber : { l1 l2 : Level} {A : UU l1} (B : A → UU l2) (x : A) → { y y' : B x} (q : Id y' y) → Id {A = Σ A B} (pair x y) (pair x y') path-total-path-fiber B x q = eq-pair refl (inv q) tr-path-total-path-fiber : { l1 l2 : Level} {A : UU l1} {B : A → UU l2} (c : Σ A B) (x : A) → { y y' : B x} (q : Id y' y) (α : Id c (pair x y')) → Id ( tr (λ z → Id c (pair x z)) q α) ( α ∙ (inv (path-total-path-fiber B x q))) tr-path-total-path-fiber c x refl α = inv right-unit segment-Σ : { l1 l2 l3 l4 : Level} {A : UU l1} {B : A → UU l2} → { x x' : A} (p : Id x x') { F : UU l3} {F' : UU l4} (f : F ≃ F') ( e : F ≃ B x) (e' : F' ≃ B x') ( H : ((map-equiv e') ∘ (map-equiv f)) ~ ((tr B p) ∘ (map-equiv e))) (y : F) → Id (pair x (map-equiv e y)) (pair x' (map-equiv e' (map-equiv f y))) segment-Σ refl f e e' H y = path-total-path-fiber _ _ (H y) contraction-total-space' : { l1 l2 l3 : Level} {A : UU l1} {B : A → UU l2} (c : Σ A B) → ( x : A) → {F : UU l3} (e : F ≃ B x) → UU (l1 ⊔ (l2 ⊔ l3)) contraction-total-space' c x {F} e = ( y : F) → Id c (pair x (map-equiv e y)) equiv-tr-contraction-total-space' : { l1 l2 l3 l4 : Level} {A : UU l1} {B : A → UU l2} (c : Σ A B) → { x x' : A} (p : Id x x') → { F : UU l3} {F' : UU l4} (f : F ≃ F') (e : F ≃ B x) (e' : F' ≃ B x') → ( H : ((map-equiv e') ∘ (map-equiv f)) ~ ((tr B p) ∘ (map-equiv e))) → ( contraction-total-space' c x' e') ≃ (contraction-total-space' c x e) equiv-tr-contraction-total-space' c p f e e' H = ( equiv-postcomp-Π ( λ y → equiv-concat' c (inv (segment-Σ p f e e' H y)))) ∘e ( precomp-Π-equiv f _) equiv-contraction-total-space : { l1 l2 l3 : Level} {A : UU l1} {B : A → UU l2} (c : Σ A B) → ( x : A) → {F : UU l3} (e : F ≃ B x) → ( contraction-total-space c x) ≃ (contraction-total-space' c x e) equiv-contraction-total-space c x e = precomp-Π-equiv e (λ y → Id c (pair x y)) tr-path-total-tr-coherence : { l1 l2 l3 l4 : Level} {A : UU l1} {B : A → UU l2} (c : Σ A B) (x : A) → { F : UU l3} {F' : UU l4} (f : F ≃ F') ( e : F ≃ B x) (e' : F' ≃ B x) ( H : ((map-equiv e') ∘ (map-equiv f)) ~ (map-equiv e)) → (y : F) (α : Id c (pair x (map-equiv e' (map-equiv f y)))) → Id ( tr (λ z → Id c (pair x z)) (H y) α) ( α ∙ (inv (segment-Σ refl f e e' H y))) tr-path-total-tr-coherence c x f e e' H y α = tr-path-total-path-fiber c x (H y) α square-tr-contraction-total-space : { l1 l2 l3 l4 : Level} {A : UU l1} {B : A → UU l2} (c : Σ A B) → { x x' : A} (p : Id x x') { F : UU l3} {F' : UU l4} (f : F ≃ F') (e : F ≃ B x) (e' : F' ≃ B x') ( H : ((map-equiv e') ∘ (map-equiv f)) ~ ((tr B p) ∘ (map-equiv e))) (h : contraction-total-space c x) → ( map-equiv ( ( equiv-tr-contraction-total-space' c p f e e' H) ∘e ( ( equiv-contraction-total-space c x' e') ∘e ( equiv-tr (contraction-total-space c) p))) ( h)) ~ ( map-equiv (equiv-contraction-total-space c x e) h) square-tr-contraction-total-space c refl f e e' H h y = ( inv (tr-path-total-tr-coherence c _ f e e' H y ( h (map-equiv e' (map-equiv f y))))) ∙ ( apd h (H y)) path-over-contraction-total-space' : {l1 l2 l3 l4 : Level} {A : UU l1} {B : A → UU l2} (c : Σ A B) → {x x' : A} (p : Id x x') → {F : UU l3} {F' : UU l4} (f : F ≃ F') ( e : F ≃ B x) (e' : F' ≃ B x') (H : ((map-equiv e') ∘ (map-equiv f)) ~ ((tr B p) ∘ (map-equiv e))) → (h : (y : F) → Id c (pair x (map-equiv e y))) → (h' : (y' : F') → Id c (pair x' (map-equiv e' y'))) → UU _ path-over-contraction-total-space' c {x} {x'} p {F} {F'} f e e' H h h' = ( postcomp-Π ( λ y → concat' c (segment-Σ p f e e' H y)) h) ~ ( precomp-Π ( map-equiv f) ( λ y' → Id c (pair x' (map-equiv e' y'))) ( h')) map-path-over-contraction-total-space' : { l1 l2 l3 l4 : Level} {A : UU l1} {B : A → UU l2} (c : Σ A B) → { x x' : A} (p : Id x x') → { F : UU l3} {F' : UU l4} (f : F ≃ F') ( e : F ≃ B x) (e' : F' ≃ B x') ( H : ((map-equiv e') ∘ (map-equiv f)) ~ ((tr B p) ∘ (map-equiv e))) → ( h : contraction-total-space' c x e) → ( h' : contraction-total-space' c x' e') → ( path-over-contraction-total-space' c p f e e' H h h') → ( path-over (contraction-total-space c) p ( inv-map-equiv (equiv-contraction-total-space c x e) h) ( inv-map-equiv (equiv-contraction-total-space c x' e') h')) map-path-over-contraction-total-space' c {x} {.x} refl f e e' H h h' α = inv-map-equiv ( equiv-ap ( ( equiv-tr-contraction-total-space' c refl f e e' H) ∘e ( equiv-contraction-total-space c x e')) ( inv-map-equiv (equiv-contraction-total-space c x e) h) ( inv-map-equiv (equiv-contraction-total-space c x e') h')) ( ( ( eq-htpy ( square-tr-contraction-total-space c refl f e e' H ( inv-map-equiv (equiv-contraction-total-space c x e) h))) ∙ ( issec-inv-is-equiv ( is-equiv-map-equiv (equiv-contraction-total-space c x e)) ( h))) ∙ ( ( eq-htpy ( htpy-con-inv h ( segment-Σ refl f e e' H) ( precomp-Π ( map-equiv f) ( λ y' → Id c (pair x (map-equiv e' y'))) ( h')) ( α))) ∙ ( inv ( ap ( map-equiv (equiv-tr-contraction-total-space' c refl f e e' H)) ( issec-inv-is-equiv ( is-equiv-map-equiv ( precomp-Π-equiv e' (λ y' → Id c (pair x y')))) ( h')))))) equiv-path-over-contraction-total-space' : { l1 l2 l3 l4 : Level} {A : UU l1} {B : A → UU l2} (c : Σ A B) → { x x' : A} (p : Id x x') → { F : UU l3} {F' : UU l4} (f : F ≃ F') ( e : F ≃ B x) (e' : F' ≃ B x') ( H : ((map-equiv e') ∘ (map-equiv f)) ~ ((tr B p) ∘ (map-equiv e))) → ( h : contraction-total-space' c x e) → ( h' : contraction-total-space' c x' e') → ( path-over (contraction-total-space c) p ( inv-map-equiv (equiv-contraction-total-space c x e) h) ( inv-map-equiv (equiv-contraction-total-space c x' e') h')) ≃ ( path-over-contraction-total-space' c p f e e' H h h') equiv-path-over-contraction-total-space' c {x} {.x} refl f e e' H h h' = ( inv-equiv ( equiv-htpy-con-inv h ( segment-Σ refl f e e' H) ( precomp-Π ( map-equiv f) ( λ y' → Id c (pair x (map-equiv e' y'))) ( h')))) ∘e ( ( equiv-funext) ∘e ( ( equiv-concat' h ( ap ( map-equiv (equiv-tr-contraction-total-space' c refl f e e' H)) ( issec-inv-is-equiv ( is-equiv-map-equiv ( precomp-Π-equiv e' (λ y' → Id c (pair x y')))) ( h')))) ∘e ( ( equiv-concat ( inv ( ( eq-htpy ( square-tr-contraction-total-space c refl f e e' H ( inv-map-equiv (equiv-contraction-total-space c x e) h))) ∙ ( issec-inv-is-equiv ( is-equiv-map-equiv (equiv-contraction-total-space c x e)) ( h)))) ( map-equiv ( ( equiv-tr-contraction-total-space' c refl f e e' H) ∘e ( ( equiv-contraction-total-space c x e') ∘e ( inv-equiv (equiv-contraction-total-space c x e')))) ( h'))) ∘e ( equiv-ap ( ( equiv-tr-contraction-total-space' c refl f e e' H) ∘e ( equiv-contraction-total-space c x e')) ( inv-map-equiv (equiv-contraction-total-space c x e) h) ( inv-map-equiv (equiv-contraction-total-space c x e') h'))))) {- We use the above construction to provide sufficient conditions for the total space of the fundamental cover to be contractible. -} center-total-fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → Σ X (fundamental-cover-circle l dup-circle) center-total-fundamental-cover-circle l dup-circle = pair ( base-free-loop l) ( map-equiv ( comp-fiber-fundamental-cover-circle l dup-circle) zero-ℤ) path-over-loop-contraction-total-fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → ( h : contraction-total-space' ( center-total-fundamental-cover-circle l dup-circle) ( base-free-loop l) ( comp-fiber-fundamental-cover-circle l dup-circle)) → ( p : path-over-contraction-total-space' ( center-total-fundamental-cover-circle l dup-circle) ( loop-free-loop l) ( equiv-succ-ℤ) ( comp-fiber-fundamental-cover-circle l dup-circle) ( comp-fiber-fundamental-cover-circle l dup-circle) ( comp-tr-fundamental-cover-circle l dup-circle) ( h) ( h)) → path-over ( contraction-total-space ( center-total-fundamental-cover-circle l dup-circle)) ( pr2 l) ( inv-map-equiv ( equiv-contraction-total-space ( center-total-fundamental-cover-circle l dup-circle) ( base-free-loop l) ( comp-fiber-fundamental-cover-circle l dup-circle)) ( h)) ( inv-map-equiv ( equiv-contraction-total-space ( center-total-fundamental-cover-circle l dup-circle) ( base-free-loop l) ( comp-fiber-fundamental-cover-circle l dup-circle)) ( h)) path-over-loop-contraction-total-fundamental-cover-circle l dup-circle h p = map-path-over-contraction-total-space' ( center-total-fundamental-cover-circle l dup-circle) ( loop-free-loop l) ( equiv-succ-ℤ) ( comp-fiber-fundamental-cover-circle l dup-circle) ( comp-fiber-fundamental-cover-circle l dup-circle) ( comp-tr-fundamental-cover-circle l dup-circle) ( h) ( h) ( p) contraction-total-fundamental-cover-circle-data : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → ( h : contraction-total-space' ( center-total-fundamental-cover-circle l dup-circle) ( base-free-loop l) ( comp-fiber-fundamental-cover-circle l dup-circle)) → ( p : path-over-contraction-total-space' ( center-total-fundamental-cover-circle l dup-circle) ( loop-free-loop l) ( equiv-succ-ℤ) ( comp-fiber-fundamental-cover-circle l dup-circle) ( comp-fiber-fundamental-cover-circle l dup-circle) ( comp-tr-fundamental-cover-circle l dup-circle) ( h) ( h)) → ( t : Σ X (fundamental-cover-circle l dup-circle)) → Id (center-total-fundamental-cover-circle l dup-circle) t contraction-total-fundamental-cover-circle-data {l1} l dup-circle h p (pair x y) = inv-is-equiv ( lower-dependent-universal-property-circle { l2 = lsuc lzero} l1 l dup-circle ( contraction-total-space ( center-total-fundamental-cover-circle l dup-circle))) ( pair ( inv-map-equiv ( equiv-contraction-total-space ( center-total-fundamental-cover-circle l dup-circle) ( base-free-loop l) ( comp-fiber-fundamental-cover-circle l dup-circle)) ( h)) ( path-over-loop-contraction-total-fundamental-cover-circle l dup-circle h p)) x y is-contr-total-fundamental-cover-circle-data : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → ( h : contraction-total-space' ( center-total-fundamental-cover-circle l dup-circle) ( base-free-loop l) ( comp-fiber-fundamental-cover-circle l dup-circle)) → ( p : path-over-contraction-total-space' ( center-total-fundamental-cover-circle l dup-circle) ( loop-free-loop l) ( equiv-succ-ℤ) ( comp-fiber-fundamental-cover-circle l dup-circle) ( comp-fiber-fundamental-cover-circle l dup-circle) ( comp-tr-fundamental-cover-circle l dup-circle) ( h) ( h)) → is-contr (Σ X (fundamental-cover-circle l dup-circle)) is-contr-total-fundamental-cover-circle-data l dup-circle h p = pair ( center-total-fundamental-cover-circle l dup-circle) ( contraction-total-fundamental-cover-circle-data l dup-circle h p) {- Section 12.4 The dependent universal property of ℤ -} abstract elim-ℤ : { l1 : Level} (P : ℤ → UU l1) ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → ( k : ℤ) → P k elim-ℤ P p0 pS (inl zero-ℕ) = inv-is-equiv (is-equiv-map-equiv (pS neg-one-ℤ)) p0 elim-ℤ P p0 pS (inl (succ-ℕ x)) = inv-is-equiv ( is-equiv-map-equiv (pS (inl (succ-ℕ x)))) ( elim-ℤ P p0 pS (inl x)) elim-ℤ P p0 pS (inr (inl star)) = p0 elim-ℤ P p0 pS (inr (inr zero-ℕ)) = map-equiv (pS zero-ℤ) p0 elim-ℤ P p0 pS (inr (inr (succ-ℕ x))) = map-equiv ( pS (inr (inr x))) ( elim-ℤ P p0 pS (inr (inr x))) comp-zero-elim-ℤ : { l1 : Level} (P : ℤ → UU l1) ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → Id (elim-ℤ P p0 pS zero-ℤ) p0 comp-zero-elim-ℤ P p0 pS = refl comp-succ-elim-ℤ : { l1 : Level} (P : ℤ → UU l1) ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) (k : ℤ) → Id ( elim-ℤ P p0 pS (succ-ℤ k)) (map-equiv (pS k) ( elim-ℤ P p0 pS k)) comp-succ-elim-ℤ P p0 pS (inl zero-ℕ) = inv ( issec-inv-is-equiv ( is-equiv-map-equiv (pS (inl zero-ℕ))) ( elim-ℤ P p0 pS (succ-ℤ (inl zero-ℕ)))) comp-succ-elim-ℤ P p0 pS (inl (succ-ℕ x)) = inv ( issec-inv-is-equiv ( is-equiv-map-equiv (pS (inl (succ-ℕ x)))) ( elim-ℤ P p0 pS (succ-ℤ (inl (succ-ℕ x))))) comp-succ-elim-ℤ P p0 pS (inr (inl star)) = refl comp-succ-elim-ℤ P p0 pS (inr (inr x)) = refl ELIM-ℤ : { l1 : Level} (P : ℤ → UU l1) ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → UU l1 ELIM-ℤ P p0 pS = Σ ( (k : ℤ) → P k) (λ f → ( ( Id (f zero-ℤ) p0) × ( (k : ℤ) → Id (f (succ-ℤ k)) ((map-equiv (pS k)) (f k))))) Elim-ℤ : { l1 : Level} (P : ℤ → UU l1) ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → ELIM-ℤ P p0 pS Elim-ℤ P p0 pS = pair ( elim-ℤ P p0 pS) ( pair ( comp-zero-elim-ℤ P p0 pS) ( comp-succ-elim-ℤ P p0 pS)) equiv-comparison-map-Eq-ELIM-ℤ : { l1 : Level} (P : ℤ → UU l1) ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → ( s t : ELIM-ℤ P p0 pS) (k : ℤ) → Id ((pr1 s) k) ((pr1 t) k) ≃ Id ((pr1 s) (succ-ℤ k)) ((pr1 t) (succ-ℤ k)) equiv-comparison-map-Eq-ELIM-ℤ P p0 pS s t k = ( ( equiv-concat (pr2 (pr2 s) k) (pr1 t (succ-ℤ k))) ∘e ( equiv-concat' (map-equiv (pS k) (pr1 s k)) (inv (pr2 (pr2 t) k)))) ∘e ( equiv-ap (pS k) (pr1 s k) (pr1 t k)) zero-Eq-ELIM-ℤ : { l1 : Level} (P : ℤ → UU l1) ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → ( s t : ELIM-ℤ P p0 pS) (H : (pr1 s) ~ (pr1 t)) → UU l1 zero-Eq-ELIM-ℤ P p0 pS s t H = Id (H zero-ℤ) ((pr1 (pr2 s)) ∙ (inv (pr1 (pr2 t)))) succ-Eq-ELIM-ℤ : { l1 : Level} (P : ℤ → UU l1) ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → ( s t : ELIM-ℤ P p0 pS) (H : (pr1 s) ~ (pr1 t)) → UU l1 succ-Eq-ELIM-ℤ P p0 pS s t H = ( k : ℤ) → Id ( H (succ-ℤ k)) ( map-equiv (equiv-comparison-map-Eq-ELIM-ℤ P p0 pS s t k) (H k)) Eq-ELIM-ℤ : { l1 : Level} (P : ℤ → UU l1) ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → ( s t : ELIM-ℤ P p0 pS) → UU l1 Eq-ELIM-ℤ P p0 pS s t = ELIM-ℤ ( λ k → Id (pr1 s k) (pr1 t k)) ( (pr1 (pr2 s)) ∙ (inv (pr1 (pr2 t)))) ( equiv-comparison-map-Eq-ELIM-ℤ P p0 pS s t) reflexive-Eq-ELIM-ℤ : { l1 : Level} (P : ℤ → UU l1) ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → ( s : ELIM-ℤ P p0 pS) → Eq-ELIM-ℤ P p0 pS s s reflexive-Eq-ELIM-ℤ P p0 pS (pair f (pair p H)) = pair ( refl-htpy) ( pair ( inv (right-inv p)) ( λ k → inv (right-inv (H k)))) Eq-ELIM-ℤ-eq : { l1 : Level} (P : ℤ → UU l1) → ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → ( s t : ELIM-ℤ P p0 pS) → Id s t → Eq-ELIM-ℤ P p0 pS s t Eq-ELIM-ℤ-eq P p0 pS s .s refl = reflexive-Eq-ELIM-ℤ P p0 pS s abstract is-contr-total-htpy' : {l1 l2 : Level} {A : UU l1} {B : A → UU l2} (f : (x : A) → B x) → is-contr (Σ ((x : A) → B x) (λ g → g ~ f)) is-contr-total-htpy' {A = A} {B} f = is-contr-is-equiv' ( Σ ((x : A) → B x) (λ g → f ~ g)) ( tot (λ g → htpy-inv)) ( is-equiv-tot-is-fiberwise-equiv (λ g → is-equiv-htpy-inv f g)) ( is-contr-total-htpy f) abstract is-contr-total-Eq-ELIM-ℤ : { l1 : Level} (P : ℤ → UU l1) → ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → ( s : ELIM-ℤ P p0 pS) → is-contr (Σ (ELIM-ℤ P p0 pS) (Eq-ELIM-ℤ P p0 pS s)) is-contr-total-Eq-ELIM-ℤ P p0 pS s = is-contr-total-Eq-structure ( λ f t H → ( zero-Eq-ELIM-ℤ P p0 pS s (pair f t) H) × ( succ-Eq-ELIM-ℤ P p0 pS s (pair f t) H)) ( is-contr-total-htpy (pr1 s)) ( pair (pr1 s) refl-htpy) ( is-contr-total-Eq-structure ( λ p K ( q : zero-Eq-ELIM-ℤ P p0 pS s ( pair (pr1 s) (pair p K)) ( refl-htpy)) → succ-Eq-ELIM-ℤ P p0 pS s ( pair (pr1 s) (pair p K)) ( refl-htpy)) ( is-contr-is-equiv' ( Σ (Id (pr1 s zero-ℤ) p0) (λ α → Id α (pr1 (pr2 s)))) ( tot (λ α → con-inv refl α (pr1 (pr2 s)))) ( is-equiv-tot-is-fiberwise-equiv ( λ α → is-equiv-con-inv refl α (pr1 (pr2 s)))) ( is-contr-total-path' (pr1 (pr2 s)))) ( pair (pr1 (pr2 s)) (inv (right-inv (pr1 (pr2 s))))) ( is-contr-is-equiv' ( Σ ( ( k : ℤ) → Id (pr1 s (succ-ℤ k)) (pr1 (pS k) (pr1 s k))) ( λ β → β ~ (pr2 (pr2 s)))) ( tot (λ β → htpy-con-inv refl-htpy β (pr2 (pr2 s)))) ( is-equiv-tot-is-fiberwise-equiv ( λ β → is-equiv-htpy-con-inv refl-htpy β (pr2 (pr2 s)))) ( is-contr-total-htpy' (pr2 (pr2 s))))) abstract is-equiv-Eq-ELIM-ℤ-eq : { l1 : Level} (P : ℤ → UU l1) → ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → ( s t : ELIM-ℤ P p0 pS) → is-equiv (Eq-ELIM-ℤ-eq P p0 pS s t) is-equiv-Eq-ELIM-ℤ-eq P p0 pS s = fundamental-theorem-id s ( reflexive-Eq-ELIM-ℤ P p0 pS s) ( is-contr-total-Eq-ELIM-ℤ P p0 pS s) ( Eq-ELIM-ℤ-eq P p0 pS s) eq-Eq-ELIM-ℤ : { l1 : Level} (P : ℤ → UU l1) → ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → ( s t : ELIM-ℤ P p0 pS) → Eq-ELIM-ℤ P p0 pS s t → Id s t eq-Eq-ELIM-ℤ P p0 pS s t = inv-is-equiv (is-equiv-Eq-ELIM-ℤ-eq P p0 pS s t) abstract is-prop-ELIM-ℤ : { l1 : Level} (P : ℤ → UU l1) → ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → is-prop (ELIM-ℤ P p0 pS) is-prop-ELIM-ℤ P p0 pS = is-prop-is-prop' ( λ s t → eq-Eq-ELIM-ℤ P p0 pS s t ( Elim-ℤ ( λ k → Id (pr1 s k) (pr1 t k)) ( (pr1 (pr2 s)) ∙ (inv (pr1 (pr2 t)))) ( equiv-comparison-map-Eq-ELIM-ℤ P p0 pS s t))) -- We finally arrive at the dependent universal property of ℤ abstract is-contr-ELIM-ℤ : { l1 : Level} (P : ℤ → UU l1) → ( p0 : P zero-ℤ) (pS : (k : ℤ) → (P k) ≃ (P (succ-ℤ k))) → is-contr (ELIM-ℤ P p0 pS) is-contr-ELIM-ℤ P p0 pS = is-contr-is-prop-inh (is-prop-ELIM-ℤ P p0 pS) (Elim-ℤ P p0 pS) -- The universal property of ℤ is now just a special case ELIM-ℤ' : { l1 : Level} {X : UU l1} (x : X) (e : X ≃ X) → UU l1 ELIM-ℤ' {X = X} x e = ELIM-ℤ (λ k → X) x (λ k → e) abstract universal-property-ℤ : { l1 : Level} {X : UU l1} (x : X) (e : X ≃ X) → is-contr (ELIM-ℤ' x e) universal-property-ℤ {X = X} x e = is-contr-ELIM-ℤ (λ k → X) x (λ k → e) {- Section 12.5 The identity type of the circle -} path-total-fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) (k : ℤ) → Id {A = Σ X (fundamental-cover-circle l dup-circle)} ( pair ( base-free-loop l) ( map-equiv (comp-fiber-fundamental-cover-circle l dup-circle) k)) ( pair ( base-free-loop l) ( map-equiv ( comp-fiber-fundamental-cover-circle l dup-circle) ( succ-ℤ k))) path-total-fundamental-cover-circle l dup-circle k = segment-Σ ( loop-free-loop l) ( equiv-succ-ℤ) ( comp-fiber-fundamental-cover-circle l dup-circle) ( comp-fiber-fundamental-cover-circle l dup-circle) ( comp-tr-fundamental-cover-circle l dup-circle) k CONTRACTION-fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → UU l1 CONTRACTION-fundamental-cover-circle l dup-circle = ELIM-ℤ ( λ k → Id ( center-total-fundamental-cover-circle l dup-circle) ( pair ( base-free-loop l) ( map-equiv (comp-fiber-fundamental-cover-circle l dup-circle) k))) ( refl) ( λ k → equiv-concat' ( center-total-fundamental-cover-circle l dup-circle) ( path-total-fundamental-cover-circle l dup-circle k)) Contraction-fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → CONTRACTION-fundamental-cover-circle l dup-circle Contraction-fundamental-cover-circle l dup-circle = Elim-ℤ ( λ k → Id ( center-total-fundamental-cover-circle l dup-circle) ( pair ( base-free-loop l) ( map-equiv (comp-fiber-fundamental-cover-circle l dup-circle) k))) ( refl) ( λ k → equiv-concat' ( center-total-fundamental-cover-circle l dup-circle) ( path-total-fundamental-cover-circle l dup-circle k)) abstract is-contr-total-fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → is-contr (Σ X (fundamental-cover-circle l dup-circle)) is-contr-total-fundamental-cover-circle l dup-circle = is-contr-total-fundamental-cover-circle-data l dup-circle ( pr1 (Contraction-fundamental-cover-circle l dup-circle)) ( htpy-inv ( pr2 (pr2 (Contraction-fundamental-cover-circle l dup-circle)))) pt-fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → fundamental-cover-circle l dup-circle (base-free-loop l) pt-fundamental-cover-circle l dup-circle = map-equiv (comp-fiber-fundamental-cover-circle l dup-circle) zero-ℤ fundamental-cover-circle-eq : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → ( x : X) → Id (base-free-loop l) x → fundamental-cover-circle l dup-circle x fundamental-cover-circle-eq l dup-circle .(base-free-loop l) refl = pt-fundamental-cover-circle l dup-circle abstract is-equiv-fundamental-cover-circle-eq : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → ( x : X) → is-equiv (fundamental-cover-circle-eq l dup-circle x) is-equiv-fundamental-cover-circle-eq l dup-circle = fundamental-theorem-id ( base-free-loop l) ( pt-fundamental-cover-circle l dup-circle) ( is-contr-total-fundamental-cover-circle l dup-circle) ( fundamental-cover-circle-eq l dup-circle) equiv-fundamental-cover-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → ( x : X) → ( Id (base-free-loop l) x) ≃ (fundamental-cover-circle l dup-circle x) equiv-fundamental-cover-circle l dup-circle x = pair ( fundamental-cover-circle-eq l dup-circle x) ( is-equiv-fundamental-cover-circle-eq l dup-circle x) comp-loop-space-circle : { l1 : Level} {X : UU l1} (l : free-loops X) → ( dup-circle : dependent-universal-property-circle (l1 ⊔ (lsuc lzero)) l) → ( Id (base-free-loop l) (base-free-loop l)) ≃ ℤ comp-loop-space-circle l dup-circle = ( inv-equiv (comp-fiber-fundamental-cover-circle l dup-circle)) ∘e ( equiv-fundamental-cover-circle l dup-circle (base-free-loop l))
{ "alphanum_fraction": 0.5696071867, "avg_line_length": 38.8763557484, "ext": "agda", "hexsha": "bd73b74c08d665d4ca4203fe9e3ae778c8e2dec8", "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": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "hemangandhi/HoTT-Intro", "max_forks_repo_path": "Agda/19-fundamental-cover.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "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": "hemangandhi/HoTT-Intro", "max_issues_repo_path": "Agda/19-fundamental-cover.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "hemangandhi/HoTT-Intro", "max_stars_repo_path": "Agda/19-fundamental-cover.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 13180, "size": 35844 }
module MLib.Algebra.PropertyCode.Structures where open import MLib.Prelude open import MLib.Finite open import MLib.Algebra.PropertyCode.RawStruct public open import MLib.Algebra.PropertyCode.Core public open import MLib.Algebra.PropertyCode public open import Relation.Binary as B using (Setoid) open import Data.List.Any using (Any; here; there) open import Data.Bool using (_∨_) open import Category.Applicative -------------------------------------------------------------------------------- -- Combinators for constructing property sets from smaller sets -------------------------------------------------------------------------------- subΠ : ∀ {k k′} {code : Code k} {code′ : Code k′} → let open Code code using (K) open Code code′ using () renaming (K to K′) in (∀ {n} → K′ n → Maybe (K n)) → Properties code → Properties code′ → Properties code′ hasProperty (subΠ f Π₀ Π₁) (π , κs) = hasProperty Π₁ (π , κs) ∨ satUnder where satUnder : Bool satUnder with List.All.traverse f κs satUnder | just κs′ = hasProperty Π₀ (π , κs′) satUnder | nothing = false subΠ′ : ∀ {k k′} {code : Code k} {code′ : Code k′} → let open Code code using (K) open Code code′ using () renaming (K to K′) in (∀ {n} → K′ n → Maybe (K n)) → Properties code → List (Property K′) → Properties code′ subΠ′ f Π πs = subΠ f Π (fromList πs) -------------------------------------------------------------------------------- -- Code Types -------------------------------------------------------------------------------- data MagmaK : ℕ → Set where ∙ : MagmaK 2 data MonoidK : ℕ → Set where ε : MonoidK 0 ∙ : MonoidK 2 data BimonoidK : ℕ → Set where 0# 1# : BimonoidK 0 + * : BimonoidK 2 -------------------------------------------------------------------------------- -- Code Proofs -------------------------------------------------------------------------------- module _ where open Code -- TODO: automate proofs like these. magmaCode : Code _ K magmaCode = MagmaK boundAt magmaCode 2 = 1 boundAt magmaCode _ = 0 isFiniteAt magmaCode 0 = enumerable-isFiniteSet [] λ () isFiniteAt magmaCode 1 = enumerable-isFiniteSet [] λ () isFiniteAt magmaCode (suc (suc (suc _))) = enumerable-isFiniteSet [] λ () isFiniteAt magmaCode 2 = enumerable-isFiniteSet (∙ ∷ []) λ {∙ → here ≡.refl} monoidCode : Code _ K monoidCode = MonoidK boundAt monoidCode 0 = 1 boundAt monoidCode 2 = 1 boundAt monoidCode _ = 0 isFiniteAt monoidCode 0 = enumerable-isFiniteSet (ε ∷ []) λ {ε → here ≡.refl} isFiniteAt monoidCode 1 = enumerable-isFiniteSet [] λ () isFiniteAt monoidCode 2 = enumerable-isFiniteSet (∙ ∷ []) λ {∙ → here ≡.refl} isFiniteAt monoidCode (suc (suc (suc _))) = enumerable-isFiniteSet [] λ () bimonoidCode : Code _ K bimonoidCode = BimonoidK boundAt bimonoidCode 0 = 2 boundAt bimonoidCode 2 = 2 boundAt bimonoidCode _ = 0 isFiniteAt bimonoidCode 0 = enumerable-isFiniteSet (0# ∷ 1# ∷ []) λ {0# → here ≡.refl; 1# → there (here ≡.refl)} isFiniteAt bimonoidCode 1 = enumerable-isFiniteSet [] λ () isFiniteAt bimonoidCode 2 = enumerable-isFiniteSet (+ ∷ * ∷ []) λ {+ → here ≡.refl; * → there (here ≡.refl)} isFiniteAt bimonoidCode (suc (suc (suc _))) = enumerable-isFiniteSet [] λ () -------------------------------------------------------------------------------- -- Subparts of bimonoids -------------------------------------------------------------------------------- +-part : ∀ {n} → BimonoidK n → Maybe (MonoidK n) +-part 0# = just ε +-part + = just ∙ +-part _ = nothing *-part : ∀ {n} → BimonoidK n → Maybe (MonoidK n) *-part 1# = just ε *-part * = just ∙ *-part _ = nothing -------------------------------------------------------------------------------- -- Some named property combinations -------------------------------------------------------------------------------- isSemigroup : Properties magmaCode isSemigroup = fromList (associative on ∙ ∷ []) isMonoid : Properties monoidCode isMonoid = subΠ′ (λ {∙ → just ∙; _ → nothing}) isSemigroup ( ε is leftIdentity for ∙ ∷ ε is rightIdentity for ∙ ∷ []) isCommutativeMonoid : Properties monoidCode isCommutativeMonoid = subΠ just isMonoid (fromList (commutative on ∙ ∷ [])) isSemiring : Properties bimonoidCode isSemiring = subΠ +-part isCommutativeMonoid ( subΠ′ *-part isMonoid ( 0# is leftZero for * ∷ 0# is rightZero for * ∷ * ⟨ distributesOverˡ ⟩ₚ + ∷ * ⟨ distributesOverʳ ⟩ₚ + ∷ [] )) -------------------------------------------------------------------------------- -- Subcode Proofs -------------------------------------------------------------------------------- magma⊂monoid : IsSubcode magmaCode monoidCode magma⊂monoid .subK→supK ∙ = ∙ magma⊂monoid .supK→subK ∙ = just ∙ magma⊂monoid .supK→subK ε = nothing magma⊂monoid .acrossSub ∙ = ≡.refl +-monoid⊂bimonoid : IsSubcode monoidCode bimonoidCode +-monoid⊂bimonoid .subK→supK ∙ = + +-monoid⊂bimonoid .subK→supK ε = 0# +-monoid⊂bimonoid .supK→subK + = just ∙ +-monoid⊂bimonoid .supK→subK 0# = just ε +-monoid⊂bimonoid .supK→subK _ = nothing +-monoid⊂bimonoid .acrossSub ∙ = ≡.refl +-monoid⊂bimonoid .acrossSub ε = ≡.refl *-monoid⊂bimonoid : IsSubcode monoidCode bimonoidCode *-monoid⊂bimonoid .subK→supK ∙ = * *-monoid⊂bimonoid .subK→supK ε = 1# *-monoid⊂bimonoid .supK→subK * = just ∙ *-monoid⊂bimonoid .supK→subK 1# = just ε *-monoid⊂bimonoid .supK→subK _ = nothing *-monoid⊂bimonoid .acrossSub ∙ = ≡.refl *-monoid⊂bimonoid .acrossSub ε = ≡.refl -------------------------------------------------------------------------------- -- Conversion to structures from the agda standard library -------------------------------------------------------------------------------- module Into {c ℓ} where open Algebra using (Semigroup; Monoid; CommutativeMonoid; Semiring) module _ (struct : Struct magmaCode c ℓ) where open Struct struct semigroup : ∀ ⦃ hasSemigroup : Hasₚ isSemigroup ⦄ → Semigroup _ _ semigroup ⦃ hasSemigroup ⦄ = record { _∙_ = ⟦ ∙ ⟧ ; isSemigroup = record { isEquivalence = isEquivalence ; assoc = from hasSemigroup (associative on ∙) ; ∙-cong = cong ∙ } } module _ (struct : Struct monoidCode c ℓ) where open Struct struct monoid : ⦃ hasMonoid : Hasₚ isMonoid ⦄ → Monoid c ℓ monoid ⦃ hasMonoid ⦄ = record { isMonoid = record { isSemigroup = S.isSemigroup ; identity = from hasMonoid (ε is leftIdentity for ∙) , from hasMonoid (ε is rightIdentity for ∙) } } where magmaPart : Struct magmaCode c ℓ magmaPart = substruct magma⊂monoid module S = Semigroup (semigroup magmaPart ⦃ toSubstruct magma⊂monoid (weaken hasMonoid) ⦄) commutativeMonoid : ⦃ hasCommutativeMonoid : Hasₚ isCommutativeMonoid ⦄ → CommutativeMonoid c ℓ commutativeMonoid ⦃ hasCommutativeMonoid ⦄ = record { isCommutativeMonoid = record { isSemigroup = S.isSemigroup ; identityˡ = from hasCommutativeMonoid (ε is leftIdentity for ∙) ; comm = from hasCommutativeMonoid (commutative on ∙) } } where magmaPart : Struct magmaCode c ℓ magmaPart = substruct magma⊂monoid module S = Semigroup (semigroup magmaPart ⦃ toSubstruct magma⊂monoid (weaken hasCommutativeMonoid) ⦄) module _ (struct : Struct bimonoidCode c ℓ) where open Struct struct semiring : ⦃ hasSemiring : Hasₚ isSemiring ⦄ → Semiring c ℓ semiring ⦃ hasSemiring ⦄ = record { isSemiring = record { isSemiringWithoutAnnihilatingZero = record { +-isCommutativeMonoid = +-CM.isCommutativeMonoid ; *-isMonoid = *-M.isMonoid ; distrib = from hasSemiring (* ⟨ distributesOverˡ ⟩ₚ +), from hasSemiring (* ⟨ distributesOverʳ ⟩ₚ +) } ; zero = from hasSemiring (0# is leftZero for *) , from hasSemiring (0# is rightZero for *) } } where +-monoidPart : Struct monoidCode c ℓ +-monoidPart = substruct +-monoid⊂bimonoid *-monoidPart : Struct monoidCode c ℓ *-monoidPart = substruct *-monoid⊂bimonoid module +-CM = CommutativeMonoid (commutativeMonoid +-monoidPart ⦃ toSubstruct +-monoid⊂bimonoid (weaken hasSemiring) ⦄) module *-M = Monoid (monoid *-monoidPart ⦃ toSubstruct *-monoid⊂bimonoid (weaken hasSemiring) ⦄)
{ "alphanum_fraction": 0.5712581992, "avg_line_length": 34.9375, "ext": "agda", "hexsha": "88550db0654555420212156ef995e0ca1ea80bb0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bch29/agda-matrices", "max_forks_repo_path": "src/MLib/Algebra/PropertyCode/Structures.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bch29/agda-matrices", "max_issues_repo_path": "src/MLib/Algebra/PropertyCode/Structures.agda", "max_line_length": 125, "max_stars_count": null, "max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bch29/agda-matrices", "max_stars_repo_path": "src/MLib/Algebra/PropertyCode/Structures.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2641, "size": 8385 }
-- MIT License -- Copyright (c) 2021 Luca Ciccone and Luca Padovani -- Permission is hereby granted, free of charge, to any person -- obtaining a copy of this software and associated documentation -- files (the "Software"), to deal in the Software without -- restriction, including without limitation the rights to use, -- copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following -- conditions: -- The above copyright notice and this permission notice shall be -- included in all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- OTHER DEALINGS IN THE SOFTWARE. {-# OPTIONS --guardedness --sized-types #-} open import Data.Empty open import Data.Product open import Data.Sum open import Data.List using ([]; _∷_; _∷ʳ_; _++_) open import Relation.Nullary open import Relation.Unary using (_∈_; _⊆_;_∉_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; subst; sym) open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (_◅◅_) open import Function.Base using (case_of_) open import Common module Convergence {ℙ : Set} (message : Message ℙ) where open import Trace message open import SessionType message open import Transitions message open import HasTrace message open import Session message open import TraceInclusion message open import Divergence message open import FairCompliance message PreConvergence : (SessionType -> SessionType -> Set) -> SessionType -> SessionType -> Set PreConvergence rel T S = ∀{φ} (tφ : T HasTrace φ) (sφ : ¬ S HasTrace φ) -> ∃[ ψ ] ∃[ x ] (ψ ⊑ φ × ∃ λ (tψ : T HasTrace (ψ ∷ʳ O x)) -> ∃ λ (sψ : S HasTrace (ψ ∷ʳ O x)) -> rel (after tψ) (after sψ)) data _↓_ : SessionType -> SessionType -> Set where converge : ∀{T S} -> PreConvergence _↓_ T S -> T ↓ S Convergence : SessionType -> SessionType -> Set Convergence = PreConvergence _↓_ con-sound : ∀{T S} -> T ↓ S -> ConvergenceS T S con-sound {T} {S} (converge C) {R} comp with fair-compliance->may-succeed comp ... | (R' # T') , reds , win#def w tdef with unzip-red* reds ... | φ , rr , tr with S HasTrace? φ ... | yes (S' , sdef , sr) = _ , zip-red* rr sr , win#def w sdef ... | no nsφ with C (_ , tdef , tr) nsφ ... | (ψ , x , prefix , tψx , sψx , con) with ⊑-has-co-trace prefix (_ , win->defined w , rr) | has-trace-snoc sψx ... | rψ | sψ@(_ , sdef , _) , _ with client-wins-or-accepts-prefix comp rψ tψx ... | inj₁ wψ = _ , zip-traces rψ sψ , win#def wψ sdef ... | inj₂ rψx with zip-traces rψx tψx ... | reds' with con-sound con (fair-compliance-red* comp reds') ... | (_ , reds'' , success) = _ , zip-traces rψx sψx ◅◅ reds'' , success inclusion->convergence : ∀{T S} -> TraceInclusionS T S -> T ↓ S inclusion->convergence sub = converge λ tφ nsφ -> ⊥-elim (nsφ (sub tφ)) not-convergence->exclusion : ∀{T S} -> ¬ T ↓ S -> ¬ TraceInclusionS T S not-convergence->exclusion not sub = not (inclusion->convergence sub) not-convergence+divergence : ∀{T S} -> T ↓ S -> T ↑ S -> ⊥ not-convergence+divergence (converge F) div = let φ = _↑_.trace div in let tφ = _↑_.with-trace div in let nsφ = _↑_.without-trace div in let _ , _ , pre , tψx , sψx , con' = F tφ nsφ in let div' = _↑_.divergence div pre tψx sψx in not-convergence+divergence con' div' ↓->preconv : ∀{S T} → S ↓ T → PreConvergence _↓_ S T ↓->preconv (converge x) = x conv->defined : ∀{S T} → Defined S → S ↓ T → Defined T conv->defined {_} {nil} inp (converge f) with f {[]} (inp _ , inp , refl) (λ x → not-nil-has-trace x) ... | _ , _ , none , _ , ht , _ = ⊥-elim (not-nil-has-trace ht) conv->defined {_} {inp _} inp (converge _) = inp conv->defined {_} {out _} inp (converge _) = out conv->defined {_} {nil} out (converge f) with f {[]} (out _ , out , refl) (λ x → not-nil-has-trace x) ... | _ , _ , none , _ , ht , _ = ⊥-elim (not-nil-has-trace ht) conv->defined {_} {inp _} out (converge _) = inp conv->defined {_} {out _} out (converge _) = out nil-converges : ∀{S} → nil ↓ S nil-converges {S} = converge λ tφ _ → ⊥-elim (not-nil-has-trace tφ) end-converges : ∀{T S} → End T → Defined S → T ↓ S end-converges (inp e) def = converge λ tφ sφ → let eq = empty-inp-has-empty-trace e tφ in ⊥-elim (sφ (subst (λ ψ → _ HasTrace ψ) (sym eq) (_ , def , refl))) end-converges (out e) def = converge λ tφ sφ → let eq = empty-out-has-empty-trace e tφ in ⊥-elim (sφ (subst (λ ψ → _ HasTrace ψ) (sym eq) (_ , def , refl))) pre-conv-inp-back : ∀{f g} → (∀{x} → x ∈ dom f → PreConvergence _↓_ (f x .force) (g x .force)) → PreConvergence _↓_ (inp f) (inp g) pre-conv-inp-back _ {[]} _ no-tr = ⊥-elim (no-tr (_ , inp , refl)) pre-conv-inp-back {f} conv {I x ∷ tr} ok-tr no-tr with x ∈? f pre-conv-inp-back {f} conv {I x ∷ tr} (_ , def , step inp red) no-tr | yes ok-x = let ϕ , α , (pref , (_ , d , r) , (_ , d' , r') , pr) = conv ok-x (_ , def , red) λ (_ , d , r) → no-tr (_ , d , step inp r) in I x ∷ ϕ , α , some pref , (_ , d , step inp r) , (_ , d' , step inp r') , pr pre-conv-inp-back {f} conv {I x ∷ tr} ok-tr no-tr | no no-x = ⊥-elim (no-x (inp-hastrace->defined ok-tr)) pre-conv-inp-back _ {O _ ∷ _} (_ , _ , step () _) _
{ "alphanum_fraction": 0.643886156, "avg_line_length": 44.1240310078, "ext": "agda", "hexsha": "4f549ef39cfa98e2d988313e9325846ed3d3a29c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "boystrange/FairSubtypingAgda", "max_forks_repo_path": "src/Convergence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "boystrange/FairSubtypingAgda", "max_issues_repo_path": "src/Convergence.agda", "max_line_length": 130, "max_stars_count": 4, "max_stars_repo_head_hexsha": "c4b78e70c3caf68d509f4360b9171d9f80ecb825", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "boystrange/FairSubtypingAgda", "max_stars_repo_path": "src/Convergence.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-24T14:38:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-07-29T14:32:30.000Z", "num_tokens": 1932, "size": 5692 }
module TestsTransport where open import Function open import Data.Product open import Relation.Binary.PropositionalEquality as P open ≡-Reasoning open import Isomorphisms open import Tests Foo : (A : Set) → (T : Testable A) → (x y : A) → (φ : Test T) → Set Foo A T x y ⊤ = _⊨_ {A} {T} x ⊤ ≡ _⊨_ {A} {T} y ⊤ Foo A T x y ⊥ = _⊨_ {A} {T} x ⊥ ≡ _⊨_ {A} {T} y ⊥ Foo A T x y (nonTriv nt) = sat≡ (kind T) (subT nt) (obs T) where sat≡ : (k : Kind) → SubTests T k → (A → ObsTy (index T) (parts T) k) → Set sat≡ ind φs o = cotuple (λ i y → y ⊨ app φs i) (o x) ≡ cotuple (λ i y → y ⊨ app φs i) (o y) sat≡ coind (i , φ) o = app (o x) i ⊨ φ ≡ app (o y) i ⊨ φ -- Note: Maybe Reveal_is_ can help to match on (kind T)?? {- ≃-transport : {A B : Set} → {T : Testable A} → (I : Iso A B) → (x y : A) → x ≃〈 T 〉 y → (Iso.iso I x) ≃〈 iso-testable T I 〉 (Iso.iso I y) ≃-transport {A} {B} {T₁} I x y p = record { eqProof = q } where T₂ = iso-testable T₁ I f : A → B f = Iso.iso I g : B → A g = IsIso.inv (Iso.indeedIso I) o₁ = obs T₁ o₂ = obs T₂ lem : (a : A) → (o₂ ∘ f) a ≡ o₁ a lem a = begin (o₂ ∘ f) a ≡⟨ refl ⟩ (o₁ ∘ g ∘ f) a ≡⟨ cong (λ x₁ → o₁ x₁) (IsIso.isLeftInv (Iso.indeedIso I) a) ⟩ o₁ a ∎ q : (φ : Test T₂) → f x ⊨ φ ≡ f y ⊨ φ q ⊤ = refl q ⊥ = refl q (nonTriv (nonTrivTest t)) = begin sat (kind T₂) t (o₂ (f x)) ≡⟨ cong (λ u → sat (kind T₂) t u) (lem x) ⟩ sat (kind T₂) t (o₁ x) ≡⟨ sat≡ (index T₁) (parts T₁) (kind T₁) o₂ (obsIso T₂) (partsTestable T₁) o₁ (obsIso T₁) lem p t ⟩ sat (kind T₂) t (o₁ y) ≡⟨ cong (λ u → sat (kind T₂) t u) (sym $ lem y) ⟩ sat (kind T₂) t (o₂ (f y)) ∎ where -- Agda complains at this point that -- T₁ != record { index = index T₁ ; parts = parts T₁ ; kind = kind T₁ -- ; obs = obs T₁ ; obsIso = obsIso T₁ -- ; partsTestable = partsTestable T₁} -- ... -- Is it possible to circumvent this issue? sat≡ : (Idx : Set) → (P : Idx → Set) → (k : Kind) → (o₂ : B → ObsTy Idx P k) → (isoT₂ : IsIso o₂) → (pTestable : (i : Idx) → Testable (P i)) → (o₁ : A → ObsTy Idx P k) → (isoT₁ : IsIso o₁) → ((a : A) → (o₂ ∘ f) a ≡ o₁ a) → x ≃〈 record { index = Idx ; parts = P ; kind = k ; obs = o₁ ; obsIso = isoT₁ ; partsTestable = pTestable } 〉 y → (t' : SubTests ( record { index = Idx ; parts = P ; kind = k ; obs = o₂ ; obsIso = isoT₂ ; partsTestable = pTestable }) k ) → sat k t' (o₁ x) ≡ sat k t' (o₁ y) sat≡ = {!!} -} {- ≃-transport {A} {B} {T₁} I x y p = q (index T₁) (parts T₁) (kind T₁) (obs T₂) (obsIso T₂) (partsTestable T₁) (obs T₁) (obsIso T₁) lem {!!} -- Agda complains at this point that -- T₁ != record { index = index T₁ ; parts = parts T₁ ; kind = kind T₁ -- ; obs = obs T₁ ; obsIso = obsIso T₁ -- ; partsTestable = partsTestable T₁} -- ... -- Is it possible to circumvent this issue? where T₂ = iso-testable T₁ I f : A → B f = Iso.iso I g : B → A g = IsIso.inv (Iso.indeedIso I) o₁ = obs T₁ o₂ = obs T₂ lem : (a : A) → (o₂ ∘ f) a ≡ o₁ a lem a = begin (o₂ ∘ f) a ≡⟨ refl ⟩ (o₁ ∘ g ∘ f) a ≡⟨ cong (λ x₁ → o₁ x₁) (IsIso.isLeftInv (Iso.indeedIso I) a) ⟩ o₁ a ∎ q : (Idx : Set) → (P : Idx → Set) → (k : Kind) → (o₂ : B → ObsTy Idx P k) → (isoT₂ : IsIso o₂) → (pTestable : (i : Idx) → Testable (P i)) → (o₁ : A → ObsTy Idx P k) → (isoT₁ : IsIso o₁) → ((a : A) → (o₂ ∘ f) a ≡ o₁ a) → x ≃〈 record { index = Idx ; parts = P ; kind = k ; obs = o₁ ; obsIso = isoT₁ ; partsTestable = pTestable } 〉 y → f x ≃〈 record { index = Idx ; parts = P ; kind = k ; obs = o₂ ; obsIso = isoT₂ ; partsTestable = pTestable } 〉 f y q Idx P ind o₂ isoT₂ pTestable o₁ isoT₁ lem p = record { eqProof = qi } where T₁' = record { index = Idx ; parts = P ; kind = ind ; obs = o₁ ; obsIso = isoT₁ ; partsTestable = pTestable } T₂' = record { index = Idx ; parts = P ; kind = ind ; obs = o₂ ; obsIso = isoT₂ ; partsTestable = pTestable } qi : (φ : Test T₂') → f x ⊨ φ ≡ f y ⊨ φ qi ⊤ = refl qi ⊥ = refl qi (nonTriv (nonTrivTest φs)) = begin cotuple (λ i z → z ⊨ app φs i) (o₂ (f x)) ≡⟨ cong (λ u → cotuple (λ i z → z ⊨ app φs i) u) (lem x) ⟩ cotuple (λ i z → z ⊨ app φs i) (o₁ x) ≡⟨ refl ⟩ _⊨_ {A} {T₁'} x (nonTriv (nonTrivTest φs)) ≡⟨ eqProof p (nonTriv (nonTrivTest φs)) ⟩ _⊨_ {A} {T₁'} y (nonTriv (nonTrivTest φs)) ≡⟨ refl ⟩ cotuple (λ i z → z ⊨ app φs i) (o₁ y) ≡⟨ cong (λ u → cotuple (λ i z → z ⊨ app φs i) u) (sym $ lem y) ⟩ cotuple (λ i z → z ⊨ app φs i) (o₂ (f y)) ∎ q Idx P coind o₂ isoT₂ pTestable o₁ isoT₁ lem p = record { eqProof = qc } where T₁' = record { index = Idx ; parts = P ; kind = coind ; obs = o₁ ; obsIso = isoT₁ ; partsTestable = pTestable } T₂' = record { index = Idx ; parts = P ; kind = coind ; obs = o₂ ; obsIso = isoT₂ ; partsTestable = pTestable } qc : (φ : Test T₂') → f x ⊨ φ ≡ f y ⊨ φ qc ⊤ = refl qc ⊥ = refl qc (nonTriv (nonTrivTest (i , φ))) = begin app (o₂ (f x)) i ⊨ φ ≡⟨ cong (λ u → app u i ⊨ φ) (lem x) ⟩ app (o₁ x) i ⊨ φ ≡⟨ {!!} ⟩ app (o₁ y) i ⊨ φ ≡⟨ cong (λ u → app u i ⊨ φ) (sym $ lem y) ⟩ app (o₂ (f y)) i ⊨ φ ∎ -}
{ "alphanum_fraction": 0.4220341639, "avg_line_length": 33.5842105263, "ext": "agda", "hexsha": "9cedbfc7636c5f9f7c5012a4b0db139489afaa2e", "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": "OTTTests/TestsTransport.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": "OTTTests/TestsTransport.agda", "max_line_length": 78, "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": "OTTTests/TestsTransport.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2482, "size": 6381 }
------------------------------------------------------------------------------ -- Exclusive disjunction theorems ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOL.ExclusiveDisjunction.TheoremsI where -- The theorems below are valid on intuitionistic logic and with an -- empty domain. open import FOL.Base hiding ( D≢∅ ; pem ) open import FOL.ExclusiveDisjunction.Base ------------------------------------------------------------------------------ p⊻q→p→¬q : {P Q : Set} → P ⊻ Q → P → ¬ Q p⊻q→p→¬q (inj₁ _ , h) p q = h (p , q) p⊻q→p→¬q (inj₂ _ , h) p q = h (p , q) p⊻q→q→¬p : {P Q : Set} → P ⊻ Q → Q → ¬ P p⊻q→q→¬p (inj₁ _ , h) q p = h (p , q) p⊻q→q→¬p (inj₂ _ , h) q p = h (p , q) p⊻q→¬p→q : {P Q : Set} → P ⊻ Q → ¬ P → Q p⊻q→¬p→q (inj₁ p , _) ¬p = ⊥-elim (¬p p) p⊻q→¬p→q (inj₂ q , _) _ = q p⊻q→¬q→p : {P Q : Set} → P ⊻ Q → ¬ Q → P p⊻q→¬q→p (inj₁ p , _) ¬q = p p⊻q→¬q→p (inj₂ q , _) ¬q = ⊥-elim (¬q q)
{ "alphanum_fraction": 0.4003558719, "avg_line_length": 33.0588235294, "ext": "agda", "hexsha": "333903e5edd1f3483defc57eed57e606e806b6ea", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOL/ExclusiveDisjunction/TheoremsI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOL/ExclusiveDisjunction/TheoremsI.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOL/ExclusiveDisjunction/TheoremsI.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": 426, "size": 1124 }
{-# OPTIONS --without-K --safe #-} open import Algebra.Structures.Bundles.Field module Algebra.Linear.Structures.VectorSpace {k ℓᵏ} (K : Field k ℓᵏ) where open import Algebra.FunctionProperties open import Relation.Binary using (Rel) open import Level using (_⊔_) open import Data.Nat using (ℕ) module VectorSpaceField where open Field K public using () renaming ( Carrier to K' ; _≈_ to _≈ᵏ_ ; refl to ≈ᵏ-refl ; sym to ≈ᵏ-sym ; trans to ≈ᵏ-trans ; reflexive to ≈ᵏ-reflexive ; isEquivalence to ≈ᵏ-isEquiv ; setoid to K-setoid ; _+_ to _+ᵏ_ ; _*_ to _*ᵏ_ ; _-_ to _-ᵏ_ ; 0# to 0ᵏ ; 1# to 1ᵏ ; -_ to -ᵏ_ ; _⁻¹ to _⁻¹ᵏ ; +-cong to +ᵏ-cong ; +-identity to +ᵏ-identity ; +-identityˡ to +ᵏ-identityˡ ; +-identityʳ to +ᵏ-identityʳ ; +-assoc to +ᵏ-assoc ; +-comm to +ᵏ-comm ; *-cong to *ᵏ-cong ; *-identity to *ᵏ-identity ; *-identityˡ to *ᵏ-identityˡ ; *-identityʳ to *ᵏ-identityʳ ; *-assoc to *ᵏ-assoc ; *-comm to *ᵏ-comm ; zero to *ᵏ-zero ; zeroˡ to *ᵏ-zeroˡ ; zeroʳ to *ᵏ-zeroʳ ; distrib to *ᵏ-+ᵏ-distrib ; distribˡ to *ᵏ-+ᵏ-distribˡ ; distribʳ to *ᵏ-+ᵏ-distribʳ ; -‿distribˡ-* to -ᵏ‿distribˡ-*ᵏ ; -‿distribʳ-* to -ᵏ‿distribʳ-*ᵏ ; -‿cong to -ᵏ‿cong ; -‿inverse to -ᵏ‿inverse ; -‿inverseˡ to -ᵏ‿inverseˡ ; -‿inverseʳ to -ᵏ‿inverseʳ ; uniqueˡ-⁻¹ to uniqueˡ-⁻¹ᵏ ; uniqueʳ-⁻¹ to uniqueʳ-⁻¹ᵏ ; _⁻¹-inverse to _⁻¹ᵏ-inverse ; _⁻¹-involutive to _⁻¹ᵏ-involutive ; 0#-not-1# to 0ᵏ-not-1ᵏ ) module _ {v ℓ} {V : Set v} (_≈_ : Rel V ℓ) where open VectorSpaceField open import Algebra.Structures _≈_ record IsVectorSpace (_+_ : Op₂ V) (_∙_ : K' → V → V) (-_ : Op₁ V) (0# : V) : Set (v ⊔ k ⊔ ℓ ⊔ ℓᵏ) where field isAbelianGroup : IsAbelianGroup _+_ 0# -_ *ᵏ-∙-compat : ∀ (a b : K') (u : V) -> ((a *ᵏ b) ∙ u) ≈ (a ∙ (b ∙ u)) ∙-+-distrib : ∀ (a : K') (u v : V) -> (a ∙ (u + v)) ≈ ((a ∙ u) + (a ∙ v)) ∙-+ᵏ-distrib : ∀ (a b : K') (u : V) -> ((a +ᵏ b) ∙ u) ≈ ((a ∙ u) + (b ∙ u)) ∙-cong : ∀ {a b : K'} {u v : V} -> a ≈ᵏ b -> u ≈ v -> (a ∙ u) ≈ (b ∙ v) ∙-identity : ∀ (x : V) → (1ᵏ ∙ x) ≈ x ∙-absorbˡ : ∀ (x : V) → (0ᵏ ∙ x) ≈ 0# open IsAbelianGroup isAbelianGroup public renaming ( assoc to +-assoc ; ∙-cong to +-cong ; identity to +-identity ; identityˡ to +-identityˡ ; identityʳ to +-identityʳ ; comm to +-comm ; inverse to -‿inverse ; inverseˡ to -‿inverseˡ ; inverseʳ to -‿inverseʳ ; ⁻¹-cong to -‿cong ) open import Algebra.Properties.AbelianGroup (record { isAbelianGroup = isAbelianGroup }) public renaming ( ε⁻¹≈ε to -0≈0 ; ∙-cancelˡ to +-cancelˡ ; ∙-cancelʳ to +-cancelʳ ; ∙-cancel to +-cancel ; identityˡ-unique to +-identityˡ-unique ; identityʳ-unique to +-identityʳ-unique ; identity-unique to +-identity-unique ; inverseˡ-unique to +-inverseˡ-unique ; inverseʳ-unique to +-inverseʳ-unique ; xyx⁻¹≈y to x+y-x≈y ; ⁻¹-∙-comm to -‿+-comm ) open import Relation.Binary.EqReasoning setoid ∙-absorbʳ : ∀ (a : K') -> (a ∙ 0#) ≈ 0# ∙-absorbʳ a = begin a ∙ 0# ≈⟨ trans (∙-cong ≈ᵏ-refl (sym (∙-absorbˡ 0#))) (sym (*ᵏ-∙-compat a 0ᵏ 0#)) ⟩ (a *ᵏ 0ᵏ) ∙ 0# ≈⟨ ∙-cong (*ᵏ-zeroʳ a) refl ⟩ 0ᵏ ∙ 0# ≈⟨ ∙-absorbˡ 0# ⟩ 0# ∎ ∙-∙-comm : ∀ (a b : K') (u : V) -> (a ∙ (b ∙ u)) ≈ (b ∙ (a ∙ u)) ∙-∙-comm a b u = begin a ∙ (b ∙ u) ≈⟨ sym (*ᵏ-∙-compat a b u) ⟩ (a *ᵏ b) ∙ u ≈⟨ ∙-cong (*ᵏ-comm a b) refl ⟩ (b *ᵏ a) ∙ u ≈⟨ *ᵏ-∙-compat b a u ⟩ b ∙ (a ∙ u) ∎ private lemma-inverseʳ : ∀ (u : V) -> (u + ((-ᵏ 1ᵏ) ∙ u)) ≈ 0# lemma-inverseʳ u = begin u + ((-ᵏ 1ᵏ) ∙ u) ≈⟨ +-cong (sym (∙-identity u)) refl ⟩ (1ᵏ ∙ u) + ((-ᵏ 1ᵏ) ∙ u) ≈⟨ sym (∙-+ᵏ-distrib 1ᵏ (-ᵏ 1ᵏ) u) ⟩ (1ᵏ +ᵏ (-ᵏ 1ᵏ)) ∙ u ≈⟨ ∙-cong (-ᵏ‿inverseʳ 1ᵏ) refl ⟩ 0ᵏ ∙ u ≈⟨ ∙-absorbˡ u ⟩ 0# ∎ -1∙u≈-u : ∀ (u : V) -> ((-ᵏ 1ᵏ) ∙ u) ≈ (- u) -1∙u≈-u u = begin ((-ᵏ 1ᵏ) ∙ u) ≈⟨ +-inverseʳ-unique u ((-ᵏ 1ᵏ) ∙ u) (lemma-inverseʳ u) ⟩ - u ∎
{ "alphanum_fraction": 0.4391709845, "avg_line_length": 30.15625, "ext": "agda", "hexsha": "01b143e40d17a11ca95562b2a38838343a2cad90", "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/Structures/VectorSpace.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/Structures/VectorSpace.agda", "max_line_length": 106, "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/Structures/VectorSpace.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": 2226, "size": 4825 }
-- Andreas, 2016-06-21 fixed context for a debug message {-# OPTIONS -v tc.section:10 #-} -- KEEP! to print debug message module _ {A : Set} where postulate B : Set module M {A : Set} where -- Intentional crash: fail : Set fail = Set -- Expected debug printout: -- checking section Issue2018debug {A = A₁ : Set} -- actual tele: {A : Set} -- checking section M {A = A₁ : Set} -- actual tele: {A : Set} {A₁ : Set} -- -- The last "actual tele" hints to a problem: Agda has renamed the second parameter!
{ "alphanum_fraction": 0.6492248062, "avg_line_length": 21.5, "ext": "agda", "hexsha": "cf1dc7b038151f410b36b0dd6664436f50e5becc", "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/Issue2018debug.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/Issue2018debug.agda", "max_line_length": 84, "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/Issue2018debug.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": 153, "size": 516 }
module hello-agda where open import IO using (run; putStrLn) import Agda.Builtin.IO as Builtin using (IO) open import Data.Unit.Polymorphic.Base using (⊤) open import Agda.Primitive using (lzero) main : Builtin.IO {lzero} ⊤ main = run (putStrLn "Hello, Agda!")
{ "alphanum_fraction": 0.7480916031, "avg_line_length": 29.1111111111, "ext": "agda", "hexsha": "72131b42cdb9d188337b80ba0f553f64c322169f", "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": "20fe690cbeddb9b80c8be54ff2818b4dd3f96470", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "neosimsim/myenv", "max_forks_repo_path": "tests/hello-agda.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20fe690cbeddb9b80c8be54ff2818b4dd3f96470", "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": "neosimsim/myenv", "max_issues_repo_path": "tests/hello-agda.agda", "max_line_length": 48, "max_stars_count": null, "max_stars_repo_head_hexsha": "20fe690cbeddb9b80c8be54ff2818b4dd3f96470", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "neosimsim/myenv", "max_stars_repo_path": "tests/hello-agda.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 78, "size": 262 }
module lambda.hw7 where open import Data.Product open import Relation.Nullary open import Relation.Nullary.Negation open import Relation.Binary.PropositionalEquality hiding (subst) open import Data.Nat open import Data.Fin hiding (lift) open import lambda.untyped open import lambda.vec open import lambda.system-f renaming (⊢_∶_ to ⊢F_∶_; type to typeF) hiding (subst; ↑; lift; subst₁) open import lambda.system-d renaming (⊢_∶_ to ⊢D_∶_; type to typeD; _⊢_∶_ to _⊢D_∶_; context to contextD) -- Peio BORTHELLE -- Homework 7 -- Maybe it's a bit unusual to present things like this, we didn't do any Agda -- but it would really have been more hassle formalizing the homework in Coq. -- So here it is, there are some utilities in the other files and also some -- bonus simply-typed lambda calculus. It was a bit more fun for me than to -- write again some long derivation tree with no guarantee at all that there -- isn't a stupid mistake kicking in. I tried to get the notations close to -- what we had in the lesson, hope this doesn't look too alien. -- Utilities A B C : typeD A = base 0 B = base 1 C = base 1 V₀ : ∀ {n} → typeF (suc n) V₀ = var zero V₁ : ∀ {n} → typeF (suc (suc n)) V₁ = var (suc zero) module Q₁ where -- Source terms t₁ t₂ t₃ t₄ : term 0 t₁ = lam (app (var zero) (var zero)) t₂ = app t₁ (lam (var zero)) t₃ = app t₁ t₁ t₄ = lam (lam (app (var (suc zero)) (app (var zero) (var (suc zero))))) -- a) system F F₁ F₂ F₄ : typeF 0 F₁ = (∀' V₀ ⇒ V₀) ⇒ (∀' V₀ ⇒ V₀) F₂ = ∀' V₀ ⇒ V₀ F₄ = ∀' ∀' (V₀ ⇒ V₁) ⇒ ((V₀ ⇒ V₁) ⇒ V₀) ⇒ V₁ F₁-p : ⊢F t₁ ∶ F₁ F₁-p = lam (∀' V₀ ⇒ V₀) (app (sub (∀' V₀ ⇒ V₀) ax) ax) F₂-p : ⊢F t₂ ∶ F₂ F₂-p = app (lam (∀' V₀ ⇒ V₀) (app (sub (∀' V₀ ⇒ V₀) ax) ax)) (gen (lam V₀ ax)) -- t₃ is not normalizing: it has a non-trivial beta-reduction to itself. -- Because system F is strongly normalizing this prooves that it has no valid -- typing judgment. t₃-no-norm : t₃ β* t₃ t₃-no-norm = β-beta ← ε F₄-p : ⊢F t₄ ∶ F₄ F₄-p = gen (gen (lam (V₀ ⇒ V₁) (lam ((V₀ ⇒ V₁) ⇒ V₀) (app ax (app ax ax))))) -- b) system D σ₁ σ₂ σ₄ : typeD σ₁ = (A ∧ A ⇒ B) ⇒ B σ₂ = A ⇒ A σ₄ = (A ⇒ B) ⇒ ((A ⇒ B) ⇒ A) ⇒ B σ₁-p : ⊢D t₁ ∶ σ₁ σ₁-p = lam (app (∧ᵉʳ ax) (∧ᵉˡ ax)) σ₂-p : ⊢D t₂ ∶ σ₂ σ₂-p = app (lam (app (∧ᵉʳ ax) (∧ᵉˡ ax))) (∧ⁱ (lam ax) (lam ax)) -- Same as system F for t₃ because of the strongly normalizing property. σ₄-p : ⊢D t₄ ∶ σ₄ σ₄-p = lam (lam (app ax (app ax ax))) module Q₂ where -- σ₁ σ₂ σ₃ σ₄ : typeD σ₁ = ((A ∧ B) ⇒ C) ⇒ A ⇒ B ⇒ C σ₂ = (A ⇒ B ⇒ C) ⇒ (A ∧ B) ⇒ C σ₃ = (C ⇒ A ∧ C ⇒ B) ⇒ C ⇒ (A ∧ B) σ₄ = C ⇒ (A ∧ B) ⇒ (C ⇒ A ∧ C ⇒ B) σ₁-p : ∀ {t} → ¬ ⊢D t ∶ σ₁ σ₁-p p = {!!} σ₂-p : ⊢D lam (lam (app (app (var (suc zero)) (var zero)) (var zero))) ∶ σ₂ σ₂-p = lam (lam (app (app ax (∧ᵉˡ ax)) (∧ᵉʳ ax))) σ₃-p : ⊢D lam (lam (app (var (suc zero)) (var zero))) ∶ σ₃ σ₃-p = lam (lam (∧ⁱ (app (∧ᵉˡ ax) ax) (app (∧ᵉʳ ax) ax))) σ₄-p : ⊢D lam (lam (lam (var (suc zero)))) ∶ σ₄ σ₄-p = lam (lam (∧ⁱ (lam (∧ᵉˡ ax)) (lam (∧ᵉʳ ax)))) module Q₃ where -- I got stuck on applying the substitution lemma on function type that are -- not lambda abstractions but ∧ eliminations. I don't manage to get from -- a proof of that type to a proof with the argument type on the top of the -- context. Maybe the substitution lemma is not well choosen. subj-red : ∀ {n T} → {x y : term n} → {Γ : contextD n} → Γ ⊢D x ∶ T → x →β y → Γ ⊢D y ∶ T subj-red ax () subj-red (∧ⁱ x₁ x₂) p = ∧ⁱ (subj-red x₁ p) (subj-red x₂ p) subj-red (∧ᵉˡ x) p = ∧ᵉˡ (subj-red x p) subj-red (∧ᵉʳ x) p = ∧ᵉʳ (subj-red x p) subj-red (app (lam x) y) β-beta = subst-p x (λ { zero → y; (suc i) → ax }) subj-red (app (∧ᵉˡ x) y) β-beta = {! !} subj-red (app (∧ᵉʳ x) y) β-beta = {! !} subj-red (app x y) (β-app₁ p) = app (subj-red x p) y subj-red (app x y) (β-app₂ p) = app x (subj-red y p) subj-red (lam x) (β-lam p) = lam (subj-red x p) module Q₄ where -- The BNF grammar i use is: -- -- <NF> ::= "λ" <VAR> "." <NF> | <NE> -- <NE> ::= <NE> <NF> | <VAR> -- -- I implemented this grammar as a judgment on untyped lambda terms -- with the datatypes `lambda.untyped.norm` and `lambda.untyped.neut`. -- Proof that NF and NE don't allow further derivation -- This proof as well as the reciprocical were quite mechanized but still -- a bit cumbersome. nf-last : ∀ {n} → {x : term n} → norm x → ¬ ∃[ y ] (x →β y) ne-last : ∀ {n} → {x : term n} → neut x → ¬ ∃[ y ] (x →β y) nf-last (lam x) (lam y , β-lam p) = nf-last x (y , p) nf-last (gnd x) (lam y , p) = ne-last x (lam y , p) nf-last (gnd x) (var i , p) = ne-last x (var i , p) nf-last (gnd x) (app a b , p) = ne-last x (app a b , p) ne-last var (y , ()) ne-last (app () y) (_ , β-beta) ne-last (app x y) (app a b , β-app₁ p) = ne-last x (a , p) ne-last (app x y) (app a b , β-app₂ p) = nf-last y (b , p) -- Proof that terms with no further derivation are in NF last-nf : ∀ {n} → (x : term n) → ¬ ∃[ y ] (x →β y) → norm x last-ne : ∀ {n y} → (x : term n) → ¬ ∃[ z ] (app x y →β z) → neut x last-nf (lam x) p = lam (last-nf x λ { (y , p₂) → p (lam y , β-lam p₂) }) last-nf (var x) p = gnd var last-nf (app x y) p = gnd (app (last-ne x λ { (z , p₁) → p (z , p₁) }) (last-nf y λ { (a , b) → p (app x a , β-app₂ b) })) last-ne {y = y} (lam x) p with p (subst₁ x y , β-beta) ... | () last-ne (var x) p = var last-ne {y = y} (app x z) p = app (last-ne x λ { (a , b) → p (app a y , β-app₁ b) }) (last-nf z λ { (a , b) → p (app (app x a) y , (β-app₁ (β-app₂ b))) }) const : ∀ {n} → contextD n const {zero} = ε const {suc n} = const ▸ base 0 -- Again because i messed up the renaming/substitution on ⊢D terms, i -- did not get to formalize the typing properly here. type-n : ∀ {n} → {x : term n} → norm x → ∃ (λ Γ → ∃ (λ T → Γ ⊢D x ∶ T)) type-e : ∀ {n} → {x : term n} → neut x → ∃ (λ Γ → ∃ (λ T → Γ ⊢D x ∶ T)) -- Here we compute inductively on the subterm, then "unload" the top of -- the context A and the result type B into the type A ⇒ B. type-n (lam x) = {! !} type-n (gnd x) = type-e x -- Here we create a context with fresh base types, assigning the matching -- one to the term. type-e (var {i}) = {! !} -- Here we compute inductively on both subterms: -- Γx ⊢D x ∶ Tx Γy ⊢D y ∶ Ty -- x is a neutral term so it has a type looking like -- T ⇒ A₁ ∧ T ⇒ A₁ ⇒ A₂ ∧ … -- We then simply extend it with An = Ty. This requires some proof -- rewriting with ∧ᵉ*. type-e (app x y) = {! !} -- Question 5 -- a) The definition of the conjunction in system F is: -- conjⁱ : Γ ⊢F x ∶ A → Γ ⊢F y ∶ B → Γ ⊢F (x , y) ∶ A ∧F B -- conjᵉʳ : Γ ⊢F x ∶ A ∧F B → Γ ⊢F π₀ x ∶ A -- conjᵉˡ : Γ ⊢F x : A ∧F B → Γ ⊢F π₁ x ∶ B -- The difference is that in system D, the conjunction is more of -- an intersection: if a single term has 2 type judgements, then -- it has a judgment for the intersection, whereas for system F -- it is a couple of 2 different terms.
{ "alphanum_fraction": 0.5592790763, "avg_line_length": 34.8137254902, "ext": "agda", "hexsha": "06a8cd208bc0b054acd8044550c29354fae619e3", "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": "09a231d9b3057d57b864070188ed9fe14a07eda2", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "Lapin0t/lambda", "max_forks_repo_path": "lambda/hw7.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "09a231d9b3057d57b864070188ed9fe14a07eda2", "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": "Lapin0t/lambda", "max_issues_repo_path": "lambda/hw7.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "09a231d9b3057d57b864070188ed9fe14a07eda2", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "Lapin0t/lambda", "max_stars_repo_path": "lambda/hw7.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2907, "size": 7102 }
-- {-# OPTIONS --show-implicit --show-irrelevant #-} module Data.QuadTree.FunctorProofs.FunctorLaws where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Logic open import Data.QuadTree.InternalAgda open import Agda.Primitive open import Data.QuadTree.Implementation.Functors -- First, define the Functor laws IdentityLaw : (f : (t : Set) -> {{ eqT : Eq t }} -> Set) -> {{ff : FunctorEq f}} -> Set₁ IdentityLaw f {{ff}} = {t : Set} -> {{ eqT : Eq t }} -> (v : f t) -> fmapₑ ff id v ≡ id v CompositionLaw : (f : (t : Set) -> {{ eqT : Eq t }} -> Set) -> {{ff : FunctorEq f}} -> Set₁ CompositionLaw f {{ff}} = {a b c : Set} -> {{ eqA : Eq a }} {{ eqB : Eq b }} {{ eqC : Eq c }} -> (v : f a) -> (fun1 : a -> b) -> (fun2 : b -> c) -> fmapₑ ff (fun2 ∘ fun1) v ≡ fmapₑ ff fun2 (fmapₑ ff fun1 v)
{ "alphanum_fraction": 0.592503023, "avg_line_length": 41.35, "ext": "agda", "hexsha": "44d8660188802050231d1e4dbd5b4a10b3478d3f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "JonathanBrouwer/research-project", "max_forks_repo_path": "src/Data/QuadTree/FunctorProofs/FunctorLaws.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "JonathanBrouwer/research-project", "max_issues_repo_path": "src/Data/QuadTree/FunctorProofs/FunctorLaws.agda", "max_line_length": 114, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "JonathanBrouwer/research-project", "max_stars_repo_path": "src/Data/QuadTree/FunctorProofs/FunctorLaws.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:10:20.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:10:20.000Z", "num_tokens": 289, "size": 827 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Program.Mirror.StructurallySmaller.StructurallySmallerSL where open import Data.List data Tree (D : Set) : Set where tree : D → List (Tree D) → Tree D foo : {D : Set} → Tree D → D foo (tree a []) = a foo (tree a (t ∷ ts)) = foo (tree a ts) bar : {D : Set} → Tree D → D bar (tree a []) = a bar {D} (tree a (t ∷ ts)) = helper (bar t) (bar (tree a ts)) where postulate helper : D → D → D
{ "alphanum_fraction": 0.5466666667, "avg_line_length": 27.2727272727, "ext": "agda", "hexsha": "e8b2ae36f1f254f798a9b74fde8643deda015fac", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/Mirror/StructurallySmaller/StructurallySmallerSL.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/Mirror/StructurallySmaller/StructurallySmallerSL.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/Mirror/StructurallySmaller/StructurallySmallerSL.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": 184, "size": 600 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.NType2 open import lib.Equivalence2 open import lib.types.Unit open import lib.types.Nat open import lib.types.Pi open import lib.types.Sigma open import lib.types.Paths open import lib.types.TLevel open import lib.types.Truncation module lib.NConnected where is-connected : ∀ {i} → ℕ₋₂ → Type i → Type i is-connected n A = is-contr (Trunc n A) has-conn-fibers : ∀ {i j} {A : Type i} {B : Type j} → ℕ₋₂ → (A → B) → Type (lmax i j) has-conn-fibers {A = A} {B = B} n f = Π B (λ b → is-connected n (hfiber f b)) {- all types are -2-connected -} -2-conn : ∀ {i} (A : Type i) → is-connected -2 A -2-conn A = Trunc-level {- all inhabited types are -1-connected -} inhab-conn : ∀ {i} {A : Type i} (a : A) → is-connected -1 A inhab-conn a = has-level-in ([ a ] , prop-has-all-paths [ a ]) {- connectedness is a prop -} is-connected-is-prop : ∀ {i} {n : ℕ₋₂} {A : Type i} → is-prop (is-connected n A) is-connected-is-prop = is-contr-is-prop {- "induction principle" for n-connected maps (where codomain is n-type) -} abstract pre∘-conn-is-equiv : ∀ {i j} {A : Type i} {B : Type j} {n : ℕ₋₂} → {h : A → B} → has-conn-fibers n h → (∀ {k} (P : B → n -Type k) → is-equiv (λ (s : Π B (fst ∘ P)) → s ∘ h)) pre∘-conn-is-equiv {A = A} {B = B} {n = n} {h = h} c P = is-eq f g f-g g-f where f : Π B (fst ∘ P) → Π A (fst ∘ P ∘ h) f k a = k (h a) helper : Π A (fst ∘ P ∘ h) → (b : B) → Trunc n (Σ A (λ a → h a == b)) → (fst (P b)) helper t b r = Trunc-rec {{snd (P b)}} (λ x → transport (λ y → fst (P y)) (snd x) (t (fst x))) r g : Π A (fst ∘ P ∘ h) → Π B (fst ∘ P) g t b = helper t b (contr-center (c b)) f-g : ∀ t → f (g t) == t f-g t = λ= $ λ a → transport (λ r → Trunc-rec {{snd (P (h a))}} _ r == t a) (! (contr-path(c (h a)) [ (a , idp) ])) idp g-f : ∀ k → g (f k) == k g-f k = λ= $ λ (b : B) → Trunc-elim {{λ r → =-preserves-level {x = helper (k ∘ h) b r} (snd (P b))}} (λ x → lemma (fst x) b (snd x)) (contr-center (c b)) where lemma : ∀ xl → ∀ b → (p : h xl == b) → helper (k ∘ h) b [ (xl , p) ] == k b lemma xl ._ idp = idp conn-extend : ∀ {i j k} {A : Type i} {B : Type j} {n : ℕ₋₂} → {h : A → B} → has-conn-fibers n h → (P : B → n -Type k) → Π A (fst ∘ P ∘ h) → Π B (fst ∘ P) conn-extend c P f = is-equiv.g (pre∘-conn-is-equiv c P) f conn-out = conn-extend conn-extend-β : ∀ {i j k} {A : Type i} {B : Type j} {n : ℕ₋₂} {h : A → B} (c : has-conn-fibers n h) (P : B → n -Type k) (f : Π A (fst ∘ P ∘ h)) → ∀ a → (conn-extend c P f (h a)) == f a conn-extend-β c P f = app= (is-equiv.f-g (pre∘-conn-is-equiv c P) f) {- generalized "almost induction principle" for maps into ≥n-types TODO: rearrange this to use ≤T? -} conn-extend-general : ∀ {i j} {A : Type i} {B : Type j} {n k : ℕ₋₂} → {f : A → B} → has-conn-fibers n f → ∀ {l} (P : B → (k +2+ n) -Type l) → ∀ t → has-level k (Σ (Π B (fst ∘ P)) (λ s → (s ∘ f) == t)) conn-extend-general {k = ⟨-2⟩} c P t = equiv-is-contr-map (pre∘-conn-is-equiv c P) t conn-extend-general {B = B} {n = n} {k = S k'} {f = f} c P t = has-level-in λ {(g , p) (h , q) → equiv-preserves-level (e g h p q) {{conn-extend-general {k = k'} c (Q g h) (app= (p ∙ ! q))}} } where Q : (g h : Π B (fst ∘ P)) → B → (k' +2+ n) -Type _ Q g h b = ((g b == h b) , has-level-apply (snd (P b)) _ _) app=-ap : ∀ {i j k} {A : Type i} {B : Type j} {C : B → Type k} (f : A → B) {g h : Π B C} (p : g == h) → app= (ap (λ k → k ∘ f) p) == (app= p ∘ f) app=-ap f idp = idp move-right-on-right-econv : ∀ {i} {A : Type i} {x y z : A} (p : x == y) (q : x == z) (r : y == z) → (p == q ∙ ! r) ≃ (p ∙ r == q) move-right-on-right-econv {x = x} p idp idp = (_ , pre∙-is-equiv (∙-unit-r p)) lemma : ∀ g h p q → (H : g ∼ h) → ((H ∘ f) == app= (p ∙ ! q)) ≃ (ap (λ v → v ∘ f) (λ= H) ∙ q == p) lemma g h p q H = move-right-on-right-econv (ap (λ v → v ∘ f) (λ= H)) p q ∘e transport (λ w → (w == app= (p ∙ ! q)) ≃ (ap (λ v → v ∘ f) (λ= H) == p ∙ ! q)) (app=-ap f (λ= H) ∙ ap (λ k → k ∘ f) (λ= $ app=-β H)) (ap-equiv app=-equiv _ _ ⁻¹) e : ∀ g h p q → (Σ (g ∼ h) (λ r → (r ∘ f) == app= (p ∙ ! q))) ≃ ((g , p) == (h , q)) e g h p q = ((=Σ-econv _ _ ∘e Σ-emap-r (λ u → ↓-app=cst-econv ∘e !-equiv)) ∘e (Σ-emap-l _ λ=-equiv)) ∘e Σ-emap-r (lemma g h p q) conn-in : ∀ {i j} {A : Type i} {B : Type j} {n : ℕ₋₂} {h : A → B} → (∀ (P : B → n -Type (lmax i j)) → Σ (Π A (fst ∘ P ∘ h) → Π B (fst ∘ P)) (λ u → ∀ (t : Π A (fst ∘ P ∘ h)) → u t ∘ h ∼ t)) → has-conn-fibers n h conn-in {A = A} {B = B} {h = h} sec b = let s = sec (λ b → (Trunc _ (hfiber h b) , Trunc-level)) in has-level-in (fst s (λ a → [ a , idp ]) b , Trunc-elim (λ k → transport (λ v → fst s (λ a → [ a , idp ]) (fst v) == [ fst k , snd v ]) (contr-path (pathfrom-is-contr (h (fst k))) (b , snd k)) (snd s (λ a → [ a , idp ]) (fst k)))) abstract pointed-conn-in : ∀ {i} {n : ℕ₋₂} (A : Type i) (a₀ : A) → has-conn-fibers {A = ⊤} n (cst a₀) → is-connected (S n) A pointed-conn-in {n = n} A a₀ c = has-level-in ([ a₀ ] , Trunc-elim (λ a → Trunc-rec (λ x → ap [_] (snd x)) (contr-center $ c a))) abstract pointed-conn-out : ∀ {i} {n : ℕ₋₂} (A : Type i) (a₀ : A) {{_ : is-connected (S n) A}} → has-conn-fibers {A = ⊤} n (cst a₀) pointed-conn-out {n = n} A a₀ {{c}} a = has-level-in (point , λ y → ! (cancel point) ∙ (ap out $ contr-has-all-paths (into point) (into y)) ∙ cancel y) where into-aux : Trunc n (Σ ⊤ (λ _ → a₀ == a)) → Trunc n (a₀ == a) into-aux = Trunc-fmap snd into : Trunc n (Σ ⊤ (λ _ → a₀ == a)) → [_] {n = S n} a₀ == [ a ] into = <– (Trunc=-equiv [ a₀ ] [ a ]) ∘ into-aux out-aux : Trunc n (a₀ == a) → Trunc n (Σ ⊤ (λ _ → a₀ == a)) out-aux = Trunc-fmap (λ p → (tt , p)) out : [_] {n = S n} a₀ == [ a ] → Trunc n (Σ ⊤ (λ _ → a₀ == a)) out = out-aux ∘ –> (Trunc=-equiv [ a₀ ] [ a ]) cancel : (x : Trunc n (Σ ⊤ (λ _ → a₀ == a))) → out (into x) == x cancel x = out (into x) =⟨ ap out-aux (<–-inv-r (Trunc=-equiv [ a₀ ] [ a ]) (into-aux x)) ⟩ out-aux (into-aux x) =⟨ Trunc-fmap-∘ _ _ x ⟩ Trunc-fmap (λ q → (tt , (snd q))) x =⟨ Trunc-elim {P = λ x → Trunc-fmap (λ q → (tt , snd q)) x == x} (λ _ → idp) x ⟩ x =∎ point : Trunc n (Σ ⊤ (λ _ → a₀ == a)) point = out $ contr-has-all-paths [ a₀ ] [ a ] prop-over-connected : ∀ {i j} {A : Type i} {a : A} {{p : is-connected 0 A}} → (P : A → hProp j) → fst (P a) → Π A (fst ∘ P) prop-over-connected P x = conn-extend (pointed-conn-out _ _) P (λ _ → x) {- Connectedness of a truncated type -} instance Trunc-preserves-conn : ∀ {i} {A : Type i} {n : ℕ₋₂} {m : ℕ₋₂} → is-connected n A → is-connected n (Trunc m A) Trunc-preserves-conn {n = ⟨-2⟩} _ = Trunc-level Trunc-preserves-conn {A = A} {n = S n} {m} c = lemma (contr-center c) (contr-path c) where lemma : (x₀ : Trunc (S n) A) → (∀ x → x₀ == x) → is-connected (S n) (Trunc m A) lemma = Trunc-elim (λ a → λ p → has-level-in ([ [ a ] ] , Trunc-elim (Trunc-elim {{λ _ → =-preserves-level (Trunc-preserves-level (S n) Trunc-level)}} (λ x → <– (Trunc=-equiv [ [ a ] ] [ [ x ] ]) (Trunc-fmap (ap [_]) (–> (Trunc=-equiv [ a ] [ x ]) (p [ x ]))))))) {- Connectedness of a Σ-type -} abstract instance Σ-conn : ∀ {i} {j} {A : Type i} {B : A → Type j} {n : ℕ₋₂} → is-connected n A → (∀ a → is-connected n (B a)) → is-connected n (Σ A B) Σ-conn {A = A} {B = B} {n = ⟨-2⟩} cA cB = -2-conn (Σ A B) Σ-conn {A = A} {B = B} {n = S m} cA cB = Trunc-elim {P = λ ta → (∀ tx → ta == tx) → is-connected (S m) (Σ A B)} (λ a₀ pA → Trunc-elim {P = λ tb → (∀ ty → tb == ty) → is-connected (S m) (Σ A B)} (λ b₀ pB → has-level-in ([ a₀ , b₀ ] , Trunc-elim {P = λ tp → [ a₀ , b₀ ] == tp} (λ {(r , s) → Trunc-rec (λ pa → Trunc-rec (λ pb → ap [_] (pair= pa (from-transp! B pa pb))) (–> (Trunc=-equiv [ b₀ ] [ transport! B pa s ]) (pB [ transport! B pa s ]))) (–> (Trunc=-equiv [ a₀ ] [ r ]) (pA [ r ]))}))) (contr-center (cB a₀)) (contr-path (cB a₀))) (contr-center cA) (contr-path cA) ×-conn : ∀ {i} {j} {A : Type i} {B : Type j} {n : ℕ₋₂} → is-connected n A → is-connected n B → is-connected n (A × B) ×-conn cA cB = Σ-conn cA (λ _ → cB) {- connectedness of a path space -} abstract instance path-conn : ∀ {i} {A : Type i} {x y : A} {n : ℕ₋₂} → is-connected (S n) A → is-connected n (x == y) path-conn {x = x} {y = y} cA = equiv-preserves-level (Trunc=-equiv [ x ] [ y ]) {{has-level-apply (contr-is-prop cA) [ x ] [ y ]}} {- an n-Type which is n-connected is contractible -} connected-at-level-is-contr : ∀ {i} {A : Type i} {n : ℕ₋₂} {{pA : has-level n A}} {{cA : is-connected n A}} → is-contr A connected-at-level-is-contr {{pA}} {{cA}} = equiv-preserves-level (unTrunc-equiv _) {{cA}} {- if A is n-connected and m ≤ n, then A is m-connected -} connected-≤T : ∀ {i} {m n : ℕ₋₂} {A : Type i} → m ≤T n → {{_ : is-connected n A}} → is-connected m A connected-≤T {m = m} {n = n} {A = A} leq = transport (λ B → is-contr B) (ua (Trunc-fuse A m n) ∙ ap (λ k → Trunc k A) (minT-out-l leq)) (Trunc-preserves-level m ⟨⟩) {- Equivalent types have the same connectedness -} equiv-preserves-conn : ∀ {i j} {A : Type i} {B : Type j} {n : ℕ₋₂} (e : A ≃ B) {{_ : is-connected n A}} → is-connected n B equiv-preserves-conn {n = n} e = equiv-preserves-level (Trunc-emap e) {- Composite of two connected functions is connected -} ∘-conn : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} → {n : ℕ₋₂} → (f : A → B) → (g : B → C) → has-conn-fibers n f → has-conn-fibers n g → has-conn-fibers n (g ∘ f) ∘-conn {n = n} f g cf cg = conn-in (λ P → conn-extend cg P ∘ conn-extend cf (P ∘ g) , lemma P) where lemma : ∀ P h x → conn-extend cg P (conn-extend cf (P ∘ g) h) (g (f x)) == h x lemma P h x = conn-extend cg P (conn-extend cf (P ∘ g) h) (g (f x)) =⟨ conn-extend-β cg P (conn-extend cf (P ∘ g) h) (f x) ⟩ conn-extend cf (P ∘ g) h (f x) =⟨ conn-extend-β cf (P ∘ g) h x ⟩ h x =∎
{ "alphanum_fraction": 0.4572228747, "avg_line_length": 38.4340277778, "ext": "agda", "hexsha": "e6f2b79282d887b6d54055a9525c79b7a5db0721", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/NConnected.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/NConnected.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/NConnected.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4438, "size": 11069 }
-- {-# OPTIONS -v tc.term.exlam:100 -v extendedlambda:100 -v int2abs.reifyterm:100 #-} -- Andreas, 2013-02-26 module Issue778 (Param : Set) where data ⊥ : Set where interactive : ⊥ → ⊥ interactive = λ {x → {!x!}} where aux : ⊥ → ⊥ aux x = x -- splitting did not work for extended lambda in the presence of -- module parameters and where block data ⊤ : Set where tt : ⊤ test : ⊤ → ⊤ test = λ { x → {!x!} } where aux : ⊤ → ⊤ aux x = x
{ "alphanum_fraction": 0.5869565217, "avg_line_length": 20.9090909091, "ext": "agda", "hexsha": "b3cf312543c49061389dd4dbacb0a60141086674", "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/Issue778.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/Issue778.agda", "max_line_length": 86, "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/Issue778.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": 460 }
module Shift (Gnd : Set)(U : Set)(El : U -> Set) where open import Basics open import Pr open import Nom import Kind open Kind Gnd U El import Cxt open Cxt Kind import Loc open Loc Kind import Term open Term Gnd U El popH : {D : Cxt}{M : Loc}{S T : Kind} -> D [ M / Head ]- T -> D [ M * S / Head ]- T popH ( ` x -! xg ) = ` x -! xg popH ( # v -! _ ) = # (pop v) -! _ weak : {G D : Cxt}{L M : Loc}{S : Kind} -> ({T : Kind} -> G [ L / Head ]- T -> D [ M / Head ]- T) -> {T : Kind} -> G [ L * S / Head ]- T -> D [ M * S / Head ]- T weak rho (` x -! p ) = popH (rho (` x -! p)) weak rho (# top -! _ ) = # top -! _ weak rho (# (pop v) -! _ ) = popH (rho (# v -! _)) shift : {G D : Cxt}{L M : Loc} -> ({T : Kind} -> G [ L / Head ]- T -> D [ M / Head ]- T) -> {j : Jud}{T : Kind} -> G [ L / j ]- T -> D [ M / j ]- T shift {G} {D} rho (t -! tg) = chug rho t tg where chug : {j : Jud}{L M : Loc} -> ({T : Kind} -> G [ L / Head ]- T -> D [ M / Head ]- T) -> {T : Kind}(t : L [ j ]- T) -> [| Good G t |] -> D [ M / j ]- T chug {Head} rho h hg = rho ( h -! hg ) chug rho [ s ] sg = G[ chug rho s sg ] chug rho (fn A f) fg = Gfn A (\ a -> chug rho (f a) (fg a)) chug rho (\\ b) bg = G\\ (chug (weak rho) b bg) chug rho (a ^ s) sg = a G^ chug rho s sg chug rho (r & s) rsg = chug rho r (fst rsg) G& chug rho s (snd rsg) chug rho nil _ = Gnil chug rho (h $ s) hsg = chug rho h (fst hsg) G$ chug rho s (snd hsg) bind : {G : Cxt}(x : Nom){Gx : [| G Hasn't x |]}{S : Kind}{j : Jud}{T : Kind} -> (G [ x - S ]) {Gx} [ EL / j ]- T -> G [ EL * S / j ]- T bind {G} x {Gx}{S} = shift topx where topx : {T : Kind} -> (G [ x - S ]) {Gx} [ EL / Head ]- T -> G [ EL * S / Head ]- T topx (` y -! yg) with nomEq x y topx (` .x -! refl) | yes refl = # top -! _ topx (` y -! yg) | no _ = ` y -! yg topx (# () -! _)
{ "alphanum_fraction": 0.4402748414, "avg_line_length": 36.3846153846, "ext": "agda", "hexsha": "622caa1832910f46284d2bffd2e641f2b771efce", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "benchmark/Syntacticosmos/Shift.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "benchmark/Syntacticosmos/Shift.agda", "max_line_length": 80, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "benchmark/Syntacticosmos/Shift.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 815, "size": 1892 }
-- Andreas, 2015-03-16 open import Common.Size open import Common.Prelude -- Note: the assumption of pred is absurd, -- but still should not make Agda loop. module _ (pred : ∀ i → Size< i) where data D (i : Size) : Set where wrap : (j : Size< i) → D i loop : ∀ i → D i → ⊥ loop i (wrap j) = loop j (wrap (pred j)) -- Loops during injectivity check d : ∀ i → D i d i = wrap (pred i) absurd : ⊥ absurd = FIXME loop ∞ (d ∞) -- Testcase temporarily mutilated, original error: -- -Issue1428a.agda:9,20-31 -- -Functions may not return sizes, thus, function type -- -(i : Size) → Size< i is illegal -- -when checking that the expression ∀ i → Size< i is a type -- +Issue1428a.agda:22,10-15 -- +Not in scope: -- + FIXME at Issue1428a.agda:22,10-15 -- +when scope checking FIXME
{ "alphanum_fraction": 0.6491677337, "avg_line_length": 23.6666666667, "ext": "agda", "hexsha": "c3fe6549c95b2ec643b195d2cb0a693bc080c56a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue1428a.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Fail/Issue1428a.agda", "max_line_length": 61, "max_stars_count": 3, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Fail/Issue1428a.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": 263, "size": 781 }
{-# OPTIONS --without-K --safe #-} -- | Exclusive option for predicates module Dodo.Unary.XOpt where -- Stdlib imports open import Level using (Level) open import Relation.Unary using (Pred) -- Local imports open import Dodo.Nullary.XOpt -- # XOpt₂ XOptPred₂ : {a ℓ₁ ℓ₂ : Level} {A : Set a} → Pred A ℓ₁ → Pred A ℓ₂ → Set _ XOptPred₂ {A = A} P Q = ∀ (x : A) → XOpt₂ (P x) (Q x) -- # XOpt₃ XOptPred₃ : {a ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} → Pred A ℓ₁ → Pred A ℓ₂ → Pred A ℓ₃ → Set _ XOptPred₃ {A = A} P Q R = ∀ (x : A) → XOpt₃ (P x) (Q x) (R x)
{ "alphanum_fraction": 0.6069469835, "avg_line_length": 23.7826086957, "ext": "agda", "hexsha": "4e06cef88415d497b3e403296e5c2e69ee7631c8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "sourcedennis/agda-dodo", "max_forks_repo_path": "src/Dodo/Unary/XOpt.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "sourcedennis/agda-dodo", "max_issues_repo_path": "src/Dodo/Unary/XOpt.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "sourcedennis/agda-dodo", "max_stars_repo_path": "src/Dodo/Unary/XOpt.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 224, "size": 547 }
{-# OPTIONS --without-K --safe #-} module Math.NumberTheory.Product.Nat.Properties where open import Data.Nat.Properties open import Math.NumberTheory.Product.Generic.Properties -- TODO rename _≈_ to _≡_ open CommutativeMonoidProductProperties *-1-commutativeMonoid public
{ "alphanum_fraction": 0.8007246377, "avg_line_length": 27.6, "ext": "agda", "hexsha": "e24086c7bfe2305de20a14f2c563d40700a18c76", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Math/NumberTheory/Product/Nat/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Math/NumberTheory/Product/Nat/Properties.agda", "max_line_length": 68, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Math/NumberTheory/Product/Nat/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 64, "size": 276 }
open import Prelude hiding (id; Bool) module Examples.Unification where data TC : Set where tc-int : TC tc-bool : TC _tc≟_ : (a b : TC) → Dec (a ≡ b) tc-int tc≟ tc-int = yes refl tc-int tc≟ tc-bool = no (λ ()) tc-bool tc≟ tc-int = no (λ ()) tc-bool tc≟ tc-bool = yes refl open import Implicits.Oliveira.Types TC _tc≟_ open import Implicits.Oliveira.Terms TC _tc≟_ open import Implicits.Oliveira.Contexts TC _tc≟_ open import Implicits.Oliveira.WellTyped TC _tc≟_ open import Implicits.Oliveira.Substitutions TC _tc≟_ open import Implicits.Oliveira.Types.Unification TC _tc≟_ open import Implicits.Oliveira.Types.Unification.McBride TC _tc≟_ as McBride using () open import Data.Star as S open import Data.Maybe open import Level using () renaming (zero to level₀) open import Data.Maybe using (monad; functor) open import Category.Functor open RawFunctor {level₀} functor module M = MetaTypeMetaSubst module T = MetaTypeTypeSubst Bool : ∀ {n} → Type n Bool = simpl (tc tc-bool) Int : ∀ {n} → Type n Int = simpl (tc tc-int) module ex₂ where -- mgu test for simple 2 variable substitution a : MetaType (suc (suc zero)) (suc zero) a = open-meta $ open-meta $ to-meta $ (simpl ((simpl (tvar zero)) →' (simpl (simpl (tvar (suc zero)) →' simpl (tvar (suc (suc zero))))))) b : SimpleType (suc zero) b = Int →' (simpl (Int →' simpl (tvar zero))) s = mgu a b u = asub (proj₁ $ from-just s) unifies : a M./ u ≡ (simpl (to-smeta b)) unifies = refl module ex₃ where -- mgu test for simple 1 variable substitution -- (limited α) a : MetaType (suc zero) (suc zero) a = open-meta (to-meta (∀' (simpl ((simpl (tvar zero)) →' simpl (tvar (suc zero)))))) b : SimpleType (suc zero) b = Int →' Int s : mgu a b ≡ nothing s = refl module ex₄ where -- with ∀' in there somewhere a : MetaType (suc zero) (suc zero) a = simpl ((∀' (s-mvar zero)) →' (s-tc tc-int)) -- won't unify with a because we'd need to instantiate s-mvar zero with -- a s-tvar that's not yet introduced b : SimpleType (suc zero) b = (∀' (simpl (tvar zero))) →' Int s : mgu a b ≡ nothing s = refl module ex₅ where -- renaming example a : MetaType (suc (suc zero)) (suc zero) a = (s-mvar zero) ⇒ (s-mvar (suc zero)) b : Type (suc zero) b = (simpl (tvar (zero))) ⇒ (simpl (tvar zero)) s : is-just (McBride.mgu a b) ≡ true s = refl open ex₅
{ "alphanum_fraction": 0.6564468711, "avg_line_length": 25.0631578947, "ext": "agda", "hexsha": "03246eff2cd02913b65b7fa10694c765173f1f79", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Examples/Unification.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Examples/Unification.agda", "max_line_length": 139, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Examples/Unification.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 842, "size": 2381 }
{-# OPTIONS --cubical-compatible #-} -- {-# OPTIONS -v tc.data:100 #-} module Issue865Big where data _≡_ (A : Set) : Set → Set₁ where refl : A ≡ A K : {A : Set} (P : A ≡ A → Set) → P refl → (p : A ≡ A) → P p K P h refl = h
{ "alphanum_fraction": 0.5286343612, "avg_line_length": 22.7, "ext": "agda", "hexsha": "8fcdaa37bb0c2094025647e52175a5eb644df3b3", "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/Issue865Big.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/Issue865Big.agda", "max_line_length": 60, "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/Issue865Big.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 90, "size": 227 }
------------------------------------------------------------------------ -- agda-combinatorics -- All modules ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module AgdaCombinatoricsEverything where import Math.BinomialTheorem.Generic -- Proof of the binomial theorem import Math.BinomialTheorem.Nat -- Definitions of combinatorial functions import Math.Combinatorics.Function -- Properties of combinatorial functions import Math.Combinatorics.Function.Properties -- Definitions of combinatorial functions on integer import Math.Combinatorics.IntegerFunction -- Properties of combinatorial functions on integer import Math.Combinatorics.IntegerFunction.Properties import Math.Combinatorics.ListFunction import Math.Combinatorics.ListFunction.Properties import Math.Combinatorics.VecFunction
{ "alphanum_fraction": 0.692575406, "avg_line_length": 26.9375, "ext": "agda", "hexsha": "2a638ac2d2bb58c71a9d258faefe194c3f29a785", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9fafa35c940ff7b893a80120f6a1f22b0a3917b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-combinatorics", "max_forks_repo_path": "AgdaCombinatoricsEverything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9fafa35c940ff7b893a80120f6a1f22b0a3917b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-combinatorics", "max_issues_repo_path": "AgdaCombinatoricsEverything.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "9fafa35c940ff7b893a80120f6a1f22b0a3917b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-combinatorics", "max_stars_repo_path": "AgdaCombinatoricsEverything.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-25T07:25:27.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-25T08:24:15.000Z", "num_tokens": 162, "size": 862 }
module Cats.Category.Constructions.Equalizer where open import Level open import Cats.Category.Base open import Cats.Util.Conv import Cats.Category.Constructions.Mono as Mono import Cats.Category.Constructions.Unique as Unique module Build {lo la l≈} (Cat : Category lo la l≈) where private open module Cat = Category Cat open Cat.≈-Reasoning open Mono.Build Cat open Unique.Build Cat record IsEqualizer {A B} (f g : A ⇒ B) {E} (e : E ⇒ A) : Set (lo ⊔ la ⊔ l≈) where field equalizes : f ∘ e ≈ g ∘ e universal : ∀ {Z} (z : Z ⇒ A) → f ∘ z ≈ g ∘ z → ∃![ u ] (e ∘ u ≈ z) record Equalizer {A B} (f g : A ⇒ B) : Set (lo ⊔ la ⊔ l≈) where field {E} : Obj e : E ⇒ A isEqualizer : IsEqualizer f g e open IsEqualizer isEqualizer public instance HasObj-Equalizer : ∀ {A B} {f g : A ⇒ B} → HasObj (Equalizer f g) lo la l≈ HasObj-Equalizer = record { Cat = Cat ; _ᴼ = Equalizer.E } HasArrow-Equalizer : ∀ {A B} {f g : A ⇒ B} → HasArrow (Equalizer f g) lo la l≈ HasArrow-Equalizer = record { Cat = Cat ; _⃗ = Equalizer.e } equalizer→mono : ∀ {A B} {f g : A ⇒ B} {E} {e : E ⇒ A} → IsEqualizer f g e → IsMono e equalizer→mono {f = f} {g} {E} {e} eql {Z} {i} {j} e∘i≈e∘j = ∃!→≈ (universal (e ∘ j) lemma) e∘i≈e∘j ≈.refl where open IsEqualizer eql lemma : f ∘ e ∘ j ≈ g ∘ e ∘ j lemma = begin f ∘ e ∘ j ≈⟨ unassoc ⟩ (f ∘ e) ∘ j ≈⟨ ∘-resp-l equalizes ⟩ (g ∘ e) ∘ j ≈⟨ assoc ⟩ g ∘ e ∘ j ∎
{ "alphanum_fraction": 0.5157958688, "avg_line_length": 23.8550724638, "ext": "agda", "hexsha": "d5578c410403b2f66eed9c759ba543369190af6f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Category/Constructions/Equalizer.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Category/Constructions/Equalizer.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Category/Constructions/Equalizer.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 621, "size": 1646 }
module DenotCommutes where open import Prelude open import T ---- Proof that dynamic semantics commute with denotational semantics module DenotCommutes where -- Proving that the dynamic semantics and the denotational semantics -- commute (at least if we are using regular equality as our -- equality for interpreted terms) basically requires -- extensionality, since we need to show that things at function -- type are equal. postulate iext : {A : Set}{B : A → Set}{f : ∀ {a} → B a}{g : ∀{a} → B a} → (∀ a → f {a} ≡ g {a}) → _≡_ { A = {a : A} → B a} f g postulate ext : {A : Set}{B : A → Set}{f : ∀ a → B a}{g : ∀ a → B a} → (∀ a → f a ≡ g a) → f ≡ g -- Show that renaming and substitution commute with denotational semantics -- in the appropriate sense. This mirrors a bunch of the machinery in SubstTheory. -- Some equality related stuff Meaning≡ : ∀ {Γ}(f g : meaningη Γ) → Set Meaning≡ f g = ∀ {A} x → f {A} x ≡ g {A} x -- These are extensionality like lemmas. I feel like they are usually nicer -- to use than actually using extensionality. -- They could be proven legitimately but we have ext and I am feeling lazy. meaningeq : ∀{Γ A} {f g : meaningη Γ} → Meaning≡ f g → (e : TExp Γ A) → meaning e f ≡ meaning e g meaningeq eq e = resp (meaning e) (iext (λ B → ext (λ x → eq x))) foldeq : ∀{A} {a0 a0' : A} {an an' : Nat} {as as' : Nat → A → A} → a0 ≡ a0' → ((n : Nat) (x : A) → as n x ≡ as' n x) → an ≡ an' → NAT.fold a0 as an ≡ NAT.fold a0' as' an' foldeq eq0 eqs eqn = resp3 NAT.fold eq0 (ext (λ n → ext (λ a → eqs n a))) eqn -- First stuff for renaming, lifting meaning-ren-wk : ∀{A B Γ Γ'} → (γ : TRen Γ Γ') → (η : meaningη Γ') → (a : interp A) → (x : B ∈ A :: Γ) → extendη η a (wk γ x) ≡ extendη (λ y → η (γ y)) a x meaning-ren-wk γ η a Z = Refl meaning-ren-wk γ η a (S x) = Refl meaning-ren : ∀{A Γ Γ'} → (γ : TRen Γ Γ') → (e : TExp Γ A) → (η : meaningη Γ') → meaning (ren γ e) η ≡ meaning e (η o γ) meaning-ren γ (var x) η = Refl meaning-ren γ (Λ e) η = ext (λ M → meaning-ren (wk γ) e (extendη η M) ≡≡ meaningeq (meaning-ren-wk γ η M) e) meaning-ren γ (e $ e') η = resp2 (λ x y → x y) (meaning-ren γ e η) (meaning-ren γ e' η) meaning-ren γ zero η = Refl meaning-ren γ (suc e) η = resp S (meaning-ren γ e η) meaning-ren γ (rec en e0 es) η = foldeq (meaning-ren γ e0 η) (λ _ M → meaning-ren (wk γ) es (extendη η M) ≡≡ meaningeq (meaning-ren-wk γ η M) es) (meaning-ren γ en η) meaning-sub-lift : ∀{A B Γ Γ'} → (γ : TSubst Γ Γ') → (η : meaningη Γ') → (a : interp A) → (x : B ∈ A :: Γ) → meaning (liftγ γ x) (extendη η a) ≡ extendη (λ y → meaning (γ y) η) a x meaning-sub-lift γ η a Z = Refl meaning-sub-lift γ η a (S x) = (meaning-ren S (γ x) (extendη η a)) ≡≡ resp (meaning (γ x)) (iext (λ C → ext (λ x → Refl))) -- Define a notion of how to commute a substitution with a -- denotational interpretation substMeaning : ∀{A Γ Γ'} → (γ : TSubst Γ Γ') → (f : meaningη Γ → interp A) → (meaningη Γ' → interp A) substMeaning γ f η = f (λ x → meaning (γ x) η) -- And show that that notion actually does commute with it. meaning-sub : ∀{A Γ Γ'} → (γ : TSubst Γ Γ') → (e : TExp Γ A) → (η : meaningη Γ') → meaning (ssubst γ e) η ≡ substMeaning γ (meaning e) η meaning-sub γ (var x) η = Refl meaning-sub γ (Λ e) η = ext (λ M → meaning-sub (liftγ γ) e (extendη η M) ≡≡ meaningeq (meaning-sub-lift γ η M) e) meaning-sub γ (e $ e') η = resp2 (λ x y → x y) (meaning-sub γ e η) (meaning-sub γ e' η) meaning-sub γ zero η = Refl meaning-sub γ (suc e) η = resp S (meaning-sub γ e η) meaning-sub γ (rec en e0 es) η = foldeq (meaning-sub γ e0 η) (λ _ M → meaning-sub (liftγ γ) es (extendη η M) ≡≡ meaningeq (meaning-sub-lift γ η M) es) (meaning-sub γ en η) -- Easy lemma about singleton contexts meaning-sing : ∀{A B}(e' : TCExp B) → (x : A ∈ [ B ]) → meaning (singγ e' x) emptyη ≡ extendη emptyη (meaning e' emptyη) x meaning-sing e Z = Refl meaning-sing e (S x) = Refl -- The basic fact we need about substitution. meaning-subst : ∀{A B}(e' : TCExp B)(e : TExp [ B ] A) → meaning e (extendη emptyη (cmeaning e')) ≡ cmeaning (subst e' e) meaning-subst e' e = symm (meaning-sub (singγ e') e emptyη ≡≡ resp (meaning e) (iext (λ A → ext (λ x → meaning-sing e' x)))) -- The main theorem about the dynamic semantics meaning-steps : ∀{A}{e e' : TCExp A} → (e ~> e') → cmeaning e ≡ cmeaning e' meaning-steps {e = e₁ $ e₂} (step-app-l St) = resp (λ f → f (meaning e₂ emptyη)) (meaning-steps St) meaning-steps {e = (Λ e₁) $ e₂} step-beta = meaning-subst e₂ e₁ meaning-steps (step-suc St) = resp S (meaning-steps St) meaning-steps {e = rec e e₀ es} (step-rec St) = resp (λ e' → NAT.fold (meaning e₀ emptyη) (λ n x → meaning es (extendη emptyη x)) e') (meaning-steps St) meaning-steps step-rec-z = Refl meaning-steps {e = rec (suc e) e₀ es} (step-rec-s _) = meaning-subst (rec e e₀ es) es meaning-eval : ∀{A}{e e' : TCExp A} → (e ~>* e') → cmeaning e ≡ cmeaning e' meaning-eval eval-refl = Refl meaning-eval (eval-cons S1 E) = meaning-steps S1 ≡≡ meaning-eval E open DenotCommutes public
{ "alphanum_fraction": 0.5427476928, "avg_line_length": 39.8819444444, "ext": "agda", "hexsha": "e02b5022d3f863c04f6a3826ba2975163b000eb8", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z", "max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msullivan/godels-t", "max_forks_repo_path": "DenotCommutes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "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": "msullivan/godels-t", "max_issues_repo_path": "DenotCommutes.agda", "max_line_length": 92, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msullivan/godels-t", "max_stars_repo_path": "DenotCommutes.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z", "num_tokens": 2021, "size": 5743 }
module Introduction.All where import Introduction.Basics import Introduction.Universes import Introduction.Unicode import Introduction.Built-in import Introduction.Modules import Introduction.Implicit import Introduction.Data.Vec import Introduction.Data.Empty import Introduction.Data.Parameterised import Introduction.Data.ByRecursion import Introduction.Operators import Introduction.Modules.Parameterised
{ "alphanum_fraction": 0.8853658537, "avg_line_length": 27.3333333333, "ext": "agda", "hexsha": "68d33acb84ecb2c660c4e32e31e28226bb731a21", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/Introduction/All.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/Introduction/All.agda", "max_line_length": 41, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/Introduction/All.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 70, "size": 410 }
-- Andreas, 2011-09-11 module Issue392 where import Common.Irrelevance -- Create an irrelevant record R1 (all fields irrelevant). record R1 : Set1 where field .f1 : Set {- module R1 .(r : R1) where .f1 : Set -- = R1.f1 r -} -- Create an irrelevant instance f2 of R1. record R2 : Set2 where field .f2 : R1 f3 : Set -- This succeeds even though f2 is irrelevant. open R1 f2 public {- A more realistic use would be s.th. like record IsEquivalence {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) : Set (a ⊔ ℓ) where field .refl : Reflexive _≈_ .sym : Symmetric _≈_ .trans : Transitive _≈_ record Setoid c ℓ : Set (suc (c ⊔ ℓ)) where infix 4 _≈_ field Carrier : Set c _≈_ : Rel Carrier ℓ .isEquivalence : IsEquivalence _≈_ open IsEquivalence isEquivalence public -}
{ "alphanum_fraction": 0.5933940774, "avg_line_length": 20.9047619048, "ext": "agda", "hexsha": "1c8b9dd2f9fcfbbcf4fa77093b1ac839bd473a35", "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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Succeed/Issue392.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/Issue392.agda", "max_line_length": 58, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/Issue392.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": 299, "size": 878 }
{-# OPTIONS --without-K --rewriting #-} {- Ribbon is an explicit covering space construction. This construction is given by Daniel Grayson, Favonia and Guillaume Brunerie together. -} open import HoTT -- A is the pointed base space. -- El is intended to be a (group-)set, module homotopy.RibbonCover {i : ULevel} where -- The HIT ribbon---reconstructed covering space module _ (X : Ptd i) {j} (gs : GroupSet (πS 0 X) j) (a₂ : de⊙ X) where private A = de⊙ X a₁ = pt X El = GroupSet.El gs El-level = GroupSet.El-level gs infix 80 _⊙_ _⊙_ = GroupSet.act gs RibbonSet : Type (lmax i j) RibbonSet = El × (a₁ =₀ a₂) data RibbonRel : RibbonSet → RibbonSet → Type (lmax i j) where ribbon-rel : ∀ el loop (p : a₁ =₀ a₂) → RibbonRel (el ⊙ loop , p) (el , loop ∙₀ p) Ribbon : Type (lmax i j) Ribbon = SetQuot RibbonRel module _ {X : Ptd i} {j} {gs : GroupSet (πS 0 X) j} {a₂ : de⊙ X} where private A = de⊙ X a = pt X El = GroupSet.El gs El-level = GroupSet.El-level gs infix 80 _⊙_ _⊙_ = GroupSet.act gs -- A point in the fiber [a₂]. {- [e] is a point in the [fiber a], and [p] is a path to transport [y] to fiber [a₂]. -} trace : El → a =₀ a₂ → Ribbon X gs a₂ trace el p = q[ el , p ] {- A loop based at [a] can used as a group action or for concatination. Both should be equivalent. -} paste : ∀ el loop (p : a =₀ a₂) → trace (el ⊙ loop) p == trace el (loop ∙₀ p) paste el loop p = quot-rel (ribbon-rel el loop p) {- Make each fiber a set and cancel all higher structures due to [paste]. -} Ribbon-level : is-set (Ribbon X gs a₂) Ribbon-level = SetQuot-level Ribbon-is-set = Ribbon-level -- Elimination rules. module RibbonElim {j} {P : Ribbon X gs a₂ → Type j} (P-level : ∀ r → is-set (P r)) (trace* : ∀ el p → P (trace el p)) (paste* : ∀ el loop p → trace* (el ⊙ loop) p == trace* el (loop ∙₀ p) [ P ↓ paste el loop p ]) where private q[_]* : (α : RibbonSet X gs a₂) → P q[ α ] q[ el , p ]* = trace* el p rel* : ∀ {α₁ α₂} (r : RibbonRel X gs a₂ α₁ α₂) → q[ α₁ ]* == q[ α₂ ]* [ P ↓ quot-rel r ] rel* (ribbon-rel el loop p) = paste* el loop p module M = SetQuotElim P-level q[_]* rel* f : Π (Ribbon X gs a₂) P f = M.f open RibbonElim public using () renaming (f to Ribbon-elim) module RibbonRec {j} {P : Type j} (P-level : is-set P) (trace* : ∀ el p → P) (paste* : ∀ el loop p → trace* (el ⊙ loop) p == trace* el (loop ∙₀ p)) where private module M = RibbonElim (λ _ → P-level) trace* (λ el loop p → ↓-cst-in (paste* el loop p)) f : Ribbon X gs a₂ → P f = M.f open RibbonRec public using () renaming (f to Ribbon-rec) -- This data structure gives a cover. Ribbon-cover : ∀ (X : Ptd i) {j} (gs : GroupSet (πS 0 X) j) → Cover (de⊙ X) (lmax i j) Ribbon-cover X gs = record { Fiber = Ribbon X gs ; Fiber-level = λ a → Ribbon-level } transp-trace : ∀ {A : Type i} {a₁} {j} {gs : GroupSet (πS 0 ⊙[ A , a₁ ]) j} {a₂} (q : a₁ == a₂) y p → transport (Ribbon ⊙[ A , a₁ ] gs) q (trace y p) == trace y (p ∙₀ [ q ]) transp-trace idp y p = ap (trace y) $ ! $ ∙₀-unit-r p
{ "alphanum_fraction": 0.5371611775, "avg_line_length": 28.5916666667, "ext": "agda", "hexsha": "fde4d608d512dd5a528403d560428d57bc6b628b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/RibbonCover.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/RibbonCover.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/RibbonCover.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1186, "size": 3431 }
{-# OPTIONS --safe #-} -- --without-K #-} open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; cong) open import Function using (_∘_) import Data.Empty as Empty import Data.Product as Product import Data.Product.Properties as Productₚ import Data.Unit as Unit import Data.Nat as Nat import Data.Vec as Vec import Data.Vec.Properties as Vecₚ import Data.Bool as Bool import Data.Fin as Fin import Data.Vec.Relation.Unary.All as All open Empty using (⊥-elim) open Nat using (ℕ; zero; suc) open Vec using (Vec; []; _∷_) open All using (All; []; _∷_) open Fin using (Fin ; zero ; suc) open Product using (_,_; proj₁; proj₂) import PiCalculus.Syntax open PiCalculus.Syntax.Scoped open import PiCalculus.Semantics open import PiCalculus.LinearTypeSystem.Algebras module PiCalculus.LinearTypeSystem.Strengthening (Ω : Algebras) where open Algebras Ω open import PiCalculus.LinearTypeSystem Ω open import PiCalculus.LinearTypeSystem.ContextLemmas Ω private variable n : ℕ idxs : Idxs n idx idx' : Idx t t' : Type i j : Fin n P Q : Scoped n ∋-strengthen : {γ : PreCtx (suc n)} {idxs : Idxs (suc n)} {Γ Θ : Ctx idxs} {m' : Usage idx' ²} → (i : Fin (suc n)) → (i≢j : i ≢ j) → γ ; Γ ∋[ j ] t' ; m' ▹ Θ → Vec.remove γ i ; ctx-remove Γ i ∋[ Fin.punchOut i≢j ] t' ; m' ▹ ctx-remove Θ i ∋-strengthen zero i≢x (zero , zero _) = ⊥-elim (i≢x refl) ∋-strengthen zero i≢x (suc t , suc x) = t , x ∋-strengthen {γ = _ -, _ -, _} {_ -, _ -, _} {_ -, _ -, _} (suc i) i≢x (zero , zero xyz) = zero , zero xyz ∋-strengthen {γ = _ -, _ -, _} {_ -, _ -, _} {_ -, _ -, _} {_ -, _ -, _} (suc i) i≢x (suc t , suc x) = there (∋-strengthen i (i≢x ∘ cong suc) (t , x)) ⊢-strengthen : {P : Scoped (suc n)} {γ : PreCtx (suc n)} {idxs : Idxs (suc n)} {Γ Θ : Ctx idxs} → (i : Fin (suc n)) → (uP : Unused i P) → γ ; Γ ⊢ P ▹ Θ → Vec.remove γ i ; ctx-remove Γ i ⊢ lower i P uP ▹ ctx-remove Θ i ⊢-strengthen i uP 𝟘 = 𝟘 ⊢-strengthen {γ = _ -, _} {Γ = _ -, _} {Θ = _ -, _} i uP (ν t m μ ⊢P) = ν t m μ (⊢-strengthen (suc i) uP ⊢P) ⊢-strengthen {γ = _ -, _} {Γ = _ -, _} {Θ = _ -, _} i (i≢x , uP) (_⦅⦆_ {Ξ = _ -, _} x ⊢P) = ∋-strengthen i i≢x x ⦅⦆ ⊢-strengthen (suc i) uP ⊢P ⊢-strengthen {γ = _ -, _} i (i≢x , i≢y , uP) (x ⟨ y ⟩ ⊢P) = ∋-strengthen i i≢x x ⟨ ∋-strengthen i i≢y y ⟩ ⊢-strengthen i uP ⊢P ⊢-strengthen {γ = _ -, _} i (uP , uQ) (⊢P ∥ ⊢Q) = ⊢-strengthen i uP ⊢P ∥ ⊢-strengthen i uQ ⊢Q
{ "alphanum_fraction": 0.5716535433, "avg_line_length": 37.9104477612, "ext": "agda", "hexsha": "ccf80f30ea51d5b1b7741d1443c45de7b66de7b2", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-14T16:24:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-25T13:57:13.000Z", "max_forks_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "guilhermehas/typing-linear-pi", "max_forks_repo_path": "src/PiCalculus/LinearTypeSystem/Strengthening.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a", "max_issues_repo_issues_event_max_datetime": "2022-03-15T09:16:14.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-15T09:16:14.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "guilhermehas/typing-linear-pi", "max_issues_repo_path": "src/PiCalculus/LinearTypeSystem/Strengthening.agda", "max_line_length": 150, "max_stars_count": 26, "max_stars_repo_head_hexsha": "0fc3cf6bcc0cd07d4511dbe98149ac44e6a38b1a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "guilhermehas/typing-linear-pi", "max_stars_repo_path": "src/PiCalculus/LinearTypeSystem/Strengthening.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-14T15:18:23.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-02T23:32:11.000Z", "num_tokens": 1046, "size": 2540 }
open import Functional hiding (Domain) import Structure.Logic.Classical.NaturalDeduction module Structure.Logic.Classical.SetTheory.ZFC {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic : _ ⦄ (_∈_ : Domain → Domain → Formula) where open Structure.Logic.Classical.NaturalDeduction.ClassicalLogic {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (classicLogic) open import Lang.Instance import Lvl open import Structure.Logic.Classical.NaturalDeduction.Proofs ⦃ classicLogic ⦄ open import Structure.Logic.Classical.SetTheory.SetBoundedQuantification ⦃ classicLogic ⦄ (_∈_) open import Structure.Logic.Classical.SetTheory.Relation ⦃ classicLogic ⦄ (_∈_) open import Structure.Logic.Constructive.Functions.Properties ⦃ constructiveLogicSignature ⦄ private module Meta where open import Numeral.Finite public open import Numeral.Finite.Bound{ℓₗ} public open import Numeral.Natural public -- The symbols/signature of ZFC set theory. record Signature : Set((ℓₗ Lvl.⊔ ℓₒ) Lvl.⊔ ℓₘₗ) where infixl 3000 _∪_ infixl 3001 _∩_ infixl 3002 _⨯_ _∖_ field -- Empty set -- The set consisting of no elements. ∅ : Domain -- Pair set. -- The set consisting of only two elements. pair : Domain → Domain → Domain -- Subset filtering. -- The subset of the specified set where all elements satisfy the specified formula. filter : Domain → (Domain → Formula) → Domain -- Power set. -- The set of all subsets of the specified set. ℘ : Domain → Domain -- Union over arbitrary sets. -- Constructs a set which consists of elements which are in any of the specified sets. ⋃ : Domain → Domain -- An inductive set. -- A set which has the `Inductive`-property. Also infinite. inductiveSet : Domain -- The map of a set. -- The set of values when a function is applied to every element of a set. -- Or: The image of the function on the set. -- Or: The image of the function. map : (Domain → Domain) → Domain → Domain -- An inverse function of a function from its domain to its image. inv : (Domain → Domain) → Domain → Domain -- Singleton set. -- A set consisting of only a single element. singleton : Domain → Domain singleton(s) = pair(s)(s) -- Union operator. -- Constructs a set which consists of both elements from LHS and RHS. _∪_ : Domain → Domain → Domain a ∪ b = ⋃(pair a b) -- Intersection operator. -- Constructs a set which consists of elements which are in both LHS and RHS. _∩_ : Domain → Domain → Domain a ∩ b = filter(a)(_∈ b) -- "Without"-operator. -- Constructs a set which consists of elements which are in LHS, but not RHS. _∖_ : Domain → Domain → Domain a ∖ b = filter(a)(_∉ b) -- Intersection over arbitrary sets. -- Constructs a set which consists of elements which are in all of the specified sets. ⋂ : Domain → Domain ⋂(a) = filter(⋃(a)) (a₁ ↦ ∀ₗ(a₂ ↦ (a₂ ∈ a) ⟶ (a₁ ∈ a₂))) -- Tuple value. -- An ordered pair of values. _,_ : Domain → Domain → Domain a , b = pair(singleton(a)) (pair(a)(b)) -- Set product (Set of tuples) (Cartesian product). _⨯_ : Domain → Domain → Domain a ⨯ b = filter(℘(℘(a ∪ b))) (t ↦ ∃ₗ(x ↦ (x ∈ a) ∧ ∃ₗ(y ↦ (y ∈ b) ∧ (t ≡ (x , y))))) identityPairing : Domain → Domain identityPairing(D) = filter(D ⨯ D) (xy ↦ ∃ₗ(a ↦ xy ≡ (a , a))) -- swappedPairing : Domain → Domain -- swappedPairing() = -- Set product over a finite indexed family (Cartesian product). -- TODO: Not really like this. See definition of (_⨯_) and (_,_), and try to express the same here -- TODO: Also, make it possible to take the set product of infinite indexed families -- TODO: Maybe just use functions like (𝕟(n) →ₛₑₜ _) for finite and (ℕ → _) for infinite -- ∏_ : ∀{n} → FiniteIndexedFamily(n) → Domain -- ∏_ {Meta.𝟎} _ = singleton(∅) -- ∏_ {Meta.𝐒(Meta.𝟎)} I = I(Meta.𝟎) -- ∏_ {Meta.𝐒(Meta.𝐒(n))} I = I(Meta.maximum) ⨯ (∏_ {Meta.𝐒(n)} (I ∘ Meta.bound-𝐒)) -- Quotient set. -- The set of equivalence classes. _/_ : Domain → BinaryRelator → Domain a / (_▫_) = filter(℘(a))(aₛ ↦ ∀ₛ(aₛ)(x ↦ ∀ₛ(aₛ)(y ↦ x ▫ y))) -- Equivalence class -- The set of elements which are equivalent to the specified one. [_of_,_] : Domain → Domain → BinaryRelator → Domain [ x of a , (_▫_) ] = filter(a)(y ↦ x ▫ y) -- TODO: Implement a choice function (the "axiom of choice" one) by inv -- choice : Domain → Domain → Domain -- The unmap of a set. -- The set of elements in the domain X when applied to a function gives an element in Y. -- Or: The inverse image of the function on the set. -- Or: The pre-image of the function on the set. -- Note: -- The domain is neccessary because a class function's domain is not neccesarily a set. -- For example: `const(x): Domain → Domain` for any (x: Domain) is a class function for which its domain is not a set. -- This is because const is defined for all objects in `Domain`, so if a set would have to have all objects in `Domain`, it has to be the universal set, but there is no universal set. unmap : Domain → (Domain → Domain) → Domain → Domain unmap(X) f(Y) = filter(X) (x ↦ f(x) ∈ Y) {- module Function ⦃ signature : Signature ⦄ where open Signature ⦃ ... ⦄ record SetRepresentable (f : Function) : Set((ℓₗ Lvl.⊔ ℓₒ) Lvl.⊔ ℓₘₗ) where constructor intro field set : Domain field proof : Proof(∀ₗ(x ↦ ∀ₗ(y ↦ (f(x) ≡ y) ⟷ ((x , y) ∈ set)))) -- An instance of Type(f) means that the function f has a default domain and codomain, and a proof that the function actually are closed inside this domain/codomain pair. record Type (f : Function) : Set((ℓₗ Lvl.⊔ ℓₒ) Lvl.⊔ ℓₘₗ) where constructor intro field domain : Domain codomain : Domain field closure : Proof(∀ₛ(domain)(x ↦ f(x) ∈ codomain)) open Type ⦃ ... ⦄ public -} module Tuple ⦃ signature : Signature ⦄ where -- TODO: Move open Signature ⦃ ... ⦄ left : Domain → Domain left(s) = ⋃(⋂ s) right : Domain → Domain right(s) = (⋃ s) ∖ left(s) -- A model of natural numbers expressed in set theory (using only sets). module NumeralNatural ⦃ signature : Signature ⦄ where -- TODO: Move open Signature ⦃ ... ⦄ -- The zero constant from the standard inductive set definition of ℕ in ZFC set theory. 𝟎 : Domain 𝟎 = ∅ -- The successor function from the standard inductive set definition of ℕ in ZFC set theory. -- This means that all lesser numbers are contained in every number. -- Examples: -- • 0: {} -- • 1: 0∪{0} = {0} = {{},{{}}} -- • 2: 1∪{1} = {0}∪{1} = {0,1} = {{},{{},{{}}}} -- • 3: 2∪{2} = {0,1}∪{2} = {0,1,2} = {{{},{{},{{}}}},{{{},{{},{{}}}}}} -- • 4: 3∪{3} = {0,1,2}∪{3} = {0,1,2,3} = {{{{},{{},{{}}}},{{{},{{},{{}}}}}},{{{{},{{},{{}}}},{{{},{{},{{}}}}}}}} 𝐒 : Domain → Domain 𝐒(n) = n ∪ singleton(n) -- A set is ℕ-inductive when has zero and all its successors. -- In loose terms: Inductive(I) means (I ⊆ ℕ) Inductive : Domain → Formula Inductive(I) = (𝟎 ∈ I) ∧ (∀ₗ(x ↦ (x ∈ I) ⟶ (𝐒(x) ∈ I))) -- The "smallest" inductive set is the set of natural numbers. -- All elements which can be expressed using only 𝟎 and 𝐒. ℕ : Domain ℕ = ⋂(filter(℘(inductiveSet)) Inductive) -- TODO: This pattern seems useful -- The relation "lesser than" in this model of ℕ. -- This works for all elements in ℕ by the definition of 𝟎 and 𝐒. _<_ : BinaryRelator a < b = a ∈ b _≤_ : BinaryRelator a ≤ b = (a < b) ∨ (a ≡ b) _>_ : BinaryRelator a > b = b < a _≥_ : BinaryRelator a ≥ b = b ≤ a infixl 2000 _<_ _≤_ _>_ _≥_ 𝕟 : Domain → Domain 𝕟(n) = filter(ℕ) (_< n) module Axioms ⦃ signature : Signature ⦄ where open NumeralNatural using () renaming (Inductive to [ℕ]-Inductive) open Signature ⦃ ... ⦄ -- `∅` is a set which is empty. -- • Allows a construction of an empty set. EmptySetMembership : Formula EmptySetMembership = Empty(∅) -- `pair` is the construction of a set with two elements. -- • Allows a construction of a set with two elements. PairingMembership : Formula PairingMembership = ∀ₗ(x₁ ↦ ∀ₗ(x₂ ↦ (∀ₗ(x ↦ (x ∈ pair(x₁)(x₂)) ⟷ (x ≡ x₁)∨(x ≡ x₂))))) -- `filter` is the set which is the subset of a set where all elements satisfies a predicate. RestrictedComprehension : (Domain → Formula) → Formula RestrictedComprehension(φ) = ∀ₗ(s ↦ ∀ₗ(x ↦ ((x ∈ filter(s)(φ)) ⟷ ((x ∈ s) ∧ φ(x))))) -- `℘` is the construction of a set which contains all the subsets of a set. -- • Allows a construction of a set that is the powerset of a set. PowerSetMembership : Formula PowerSetMembership = ∀ₗ(s ↦ ∀ₗ(x ↦ (x ∈ ℘(s)) ⟷ (x ⊆ s))) -- `⋃` is the construction of a set which contains all the elements of a collection of sets. -- • Allows a construction of a set that is the union of some sets. UnionMembership : Formula UnionMembership = ∀ₗ(ss ↦ ∀ₗ(x ↦ (x ∈ ⋃(ss)) ⟷ ∃ₗ(s ↦ (s ∈ ss)∧(x ∈ s)))) -- `inductiveSet` is ℕ-inductive. -- • An inductive set is infinite, so this implies that an infinite set exists. -- • Makes it possible to construct the set of natural numbers (ℕ). Infinity : Formula Infinity = [ℕ]-Inductive(inductiveSet) -- Set identity is extensionally determined. More specifically by its contents. -- • Guarantees the definition of equality for sets. Extensionality : Formula Extensionality = ∀ₗ(s₁ ↦ ∀ₗ(s₂ ↦ ∀ₗ(x ↦ (x ∈ s₁)⟷(x ∈ s₂)) ⟷ (s₁ ≡ s₂))) -- A non-empty set contain sets that are disjoint to it. -- • Prevents sets containing themselves. -- • Makes every set have an ordinal rank. Regularity : Formula Regularity = ∀ₗ(s₁ ↦ (NonEmpty(s₁) ⟶ ∃ₗ(s₂ ↦ (s₂ ∈ s₁) ∧ Disjoint(s₁)(s₂)))) -- `map` is the construction of the image of a function restricted to a set. -- • The `map`-function on a function is a function from sets to sets. Replacement : (Domain → Domain) → Formula Replacement(f) = ∀ₗ(A ↦ ∀ₗ(y ↦ (y ∈ map f(A)) ⟷ ∃ₛ(A)(x ↦ y ≡ f(x)))) -- ReplacementTraditional = ∀{φ : Domain → Domain → Formula} → Proof(∀ₗ(A ↦ TotalFunction(φ)(A) ⟶ ∃ₗ(B ↦ ∀ₗ(y ↦ (y ∈ B) ⟷ ∃ₗ(x ↦ (x ∈ A) ∧ φ(x)(y)))))) -- The set product of non-empty finite indexed family of sets where all the sets are non-empty is non-empty. -- TODO: Should the indexed family really be finite? https://en.wikipedia.org/wiki/Cartesian_product#Infinite_Cartesian_products -- Choice = ∀{n : Meta.ℕ}{F : FiniteIndexedFamily(Meta.𝐒(n))} → (∀{i : Meta.𝕟(Meta.𝐒(n))} → Proof(NonEmpty(F(i)))) → Proof(NonEmpty(∏ F)) -- `inv` constructs the right inverse for function composition. -- • All surjective class functions have a right inverse. -- • An element applied to the inverse function of a function yields/returns one of the arguments that yield/return this element as a value when it exists. -- TODO: MAybe this is too strong of a statement? Because the image is not neccessarily a set if the class function is defined for all objects (in the domain) in the theory? Is this really equivalent to `ChoiceTraditional`? Choice : (Domain → Domain) → Formula Choice(f) = ∀ₗ(y ↦ (Value f(y)) ⟶ ((f ∘ (inv f))(y) ≡ y)) -- ChoiceTraditional = Proof(∀ₗ(s ↦ (∅ ∉ s) ⟶ ∃ₛ(s →ₛₑₜ (⋃ s))(f ↦ ∀ₛ(s)(x ↦ ∀ₛ(⋃ s)(y ↦ ((x , y) ∈ f) ⟶ (y ∈ x)))))) -- ChoiceTraditional : (Domain → Domain → Domain) → Formula -- ChoiceTraditional(choice) = ∀ₗ(s ↦ ∀ₛ(s)(x ↦ NonEmpty(x) ⟶ (choice(s)(x) ∈ x))) record Z ⦃ signature : Signature ⦄ : Set((ℓₗ Lvl.⊔ ℓₒ) Lvl.⊔ ℓₘₗ) where open Axioms open Signature ⦃ ... ⦄ field extensional : Proof(Extensionality) empty : Proof(EmptySetMembership) pairing : Proof(PairingMembership) comprehension : ∀{φ} → Proof(RestrictedComprehension(φ)) union : Proof(UnionMembership) power : Proof(PowerSetMembership) infinity : Proof(Infinity) record ZF ⦃ signature : Signature ⦄ : Set((ℓₗ Lvl.⊔ ℓₒ) Lvl.⊔ ℓₘₗ) where open Axioms open Signature ⦃ ... ⦄ field extensional : Proof(Extensionality) empty : Proof(EmptySetMembership) pairing : Proof(PairingMembership) comprehension : ∀{φ} → Proof(RestrictedComprehension(φ)) union : Proof(UnionMembership) power : Proof(PowerSetMembership) infinity : Proof(Infinity) regular : Proof(Regularity) replacement : ∀{f} → Proof(Replacement(f)) record ZFC ⦃ signature : Signature ⦄ : Set((ℓₗ Lvl.⊔ ℓₒ) Lvl.⊔ ℓₘₗ) where open Axioms open Signature ⦃ ... ⦄ field extensional : Proof(Extensionality) empty : Proof(EmptySetMembership) pairing : Proof(PairingMembership) comprehension : ∀{φ} → Proof(RestrictedComprehension(φ)) union : Proof(UnionMembership) power : Proof(PowerSetMembership) infinity : Proof(Infinity) regular : Proof(Regularity) replacement : ∀{f} → Proof(Replacement(f)) choice : ∀{f} → Proof(Choice(f))
{ "alphanum_fraction": 0.6302067263, "avg_line_length": 40.012345679, "ext": "agda", "hexsha": "ce4c3baf5bb6b09b01648ed65a5cb5bb35a0db54", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC.agda", "max_line_length": 225, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "old/Structure/Logic/Classical/SetTheory/ZFC.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": 4301, "size": 12964 }
module Luau.RuntimeError where open import Agda.Builtin.Equality using (_≡_) open import Luau.Heap using (Heap; _[_]) open import FFI.Data.Maybe using (just; nothing) open import FFI.Data.String using (String) open import Luau.Syntax using (Block; Expr; nil; var; addr; block_is_end; _$_; local_←_; return; done; _∙_; number; binexp) open import Luau.RuntimeType using (RuntimeType; valueType) open import Luau.Value using (val) open import Properties.Equality using (_≢_) data RuntimeErrorᴮ {a} (H : Heap a) : Block a → Set data RuntimeErrorᴱ {a} (H : Heap a) : Expr a → Set data RuntimeErrorᴱ H where TypeMismatch : ∀ t v → (t ≢ valueType v) → RuntimeErrorᴱ H (val v) UnboundVariable : ∀ x → RuntimeErrorᴱ H (var x) SEGV : ∀ a → (H [ a ] ≡ nothing) → RuntimeErrorᴱ H (addr a) app₁ : ∀ {M N} → RuntimeErrorᴱ H M → RuntimeErrorᴱ H (M $ N) app₂ : ∀ {M N} → RuntimeErrorᴱ H N → RuntimeErrorᴱ H (M $ N) block : ∀ b {B} → RuntimeErrorᴮ H B → RuntimeErrorᴱ H (block b is B end) bin₁ : ∀ {M N op} → RuntimeErrorᴱ H M → RuntimeErrorᴱ H (binexp M op N) bin₂ : ∀ {M N op} → RuntimeErrorᴱ H N → RuntimeErrorᴱ H (binexp M op N) data RuntimeErrorᴮ H where local : ∀ x {M B} → RuntimeErrorᴱ H M → RuntimeErrorᴮ H (local x ← M ∙ B) return : ∀ {M B} → RuntimeErrorᴱ H M → RuntimeErrorᴮ H (return M ∙ B)
{ "alphanum_fraction": 0.6798780488, "avg_line_length": 46.8571428571, "ext": "agda", "hexsha": "b479a72a4f73a7c13993c7df5ff57448d4747b6a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_path": "prototyping/Luau/RuntimeError.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Tr4shh/Roblox-Luau", "max_issues_repo_path": "prototyping/Luau/RuntimeError.agda", "max_line_length": 123, "max_stars_count": null, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/Luau/RuntimeError.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 454, "size": 1312 }
{-# OPTIONS --without-K --safe #-} module Cats.Category.Sets.Facts.Terminal where open import Data.Unit using (⊤) open import Level using (Lift ; lift ; lower) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl) open import Cats.Category open import Cats.Category.Sets using (Sets) instance hasTerminal : ∀ {l} → HasTerminal (Sets l) hasTerminal = record { ⊤ = Lift _ ⊤ ; isTerminal = λ X → record { unique = λ _ _ → refl } }
{ "alphanum_fraction": 0.6846652268, "avg_line_length": 25.7222222222, "ext": "agda", "hexsha": "0de98dc12e6875a7679ac29a9adbfface5aa72ba", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-18T15:35:07.000Z", "max_forks_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/cats", "max_forks_repo_path": "Cats/Category/Sets/Facts/Terminal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "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": "JLimperg/cats", "max_issues_repo_path": "Cats/Category/Sets/Facts/Terminal.agda", "max_line_length": 68, "max_stars_count": 24, "max_stars_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/cats", "max_stars_repo_path": "Cats/Category/Sets/Facts/Terminal.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-06T05:00:46.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-03T15:18:57.000Z", "num_tokens": 125, "size": 463 }
{-# OPTIONS -WUnknownFixityInMixfixDecl #-} data Nat : Set where zero : Nat suc : Nat → Nat _+_ : Nat → Nat → Nat zero + n = n (suc m) + n = suc (m + n) private _*_ : Nat → Nat → Nat zero * n = zero (suc m) * n = n + (m * n) data List (A : Set) : Set where [] : List A _∷_ : A → List A → List A foldr : {A B : Set} → (A → B → B) → B → List A → B foldr _<>_ n [] = n foldr _<>_ n (x ∷ xs) = x <> (foldr _<>_ n xs) sumOfPowers : Nat → List Nat → Nat sumOfPowers x = foldr (λ p → (x ^ p) +_) zero where _^_ : Nat → Nat → Nat m ^ zero = suc zero m ^ suc n = m * (m ^ n)
{ "alphanum_fraction": 0.4991708126, "avg_line_length": 20.1, "ext": "agda", "hexsha": "e741723a775c642964753346d240975d72915e82", "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/Issue2899.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/Issue2899.agda", "max_line_length": 51, "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/Issue2899.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": 252, "size": 603 }
------------------------------------------------------------------------ -- An implementation of tree sort, formally proved to return a -- permutation of the input ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality open import Prelude hiding (id) module Tree-sort.Partial {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) {A : Type} (_≤_ : A → A → Bool) -- A comparison function. where open Derived-definitions-and-properties eq open import Bag-equivalence eq open import Bijection eq using (_↔_) open import Function-universe eq hiding (_∘_) open import List eq open import Tree eq ------------------------------------------------------------------------ -- Insertion into trees -- Inserts an element into the tree. insert : A → Tree A → Tree A insert x leaf = singleton x insert x (node l y r) = if x ≤ y then node (insert x l) y r else node l y (insert x r) -- The insert function inserts. Any-insert : ∀ (P : A → Type) x t → AnyT P (insert x t) ↔ P x ⊎ AnyT P t Any-insert P x leaf = AnyT P (singleton x) ↔⟨ Any-singleton P ⟩ P x ↔⟨ inverse ⊎-right-identity ⟩ P x ⊎ ⊥ ↔⟨⟩ P x ⊎ AnyT P leaf □ Any-insert P x (node l y r) with x ≤ y ... | true = AnyT P (insert x l) ⊎ P y ⊎ AnyT P r ↔⟨ Any-insert P x l ⊎-cong id ⟩ (P x ⊎ AnyT P l) ⊎ P y ⊎ AnyT P r ↔⟨ inverse ⊎-assoc ⟩ P x ⊎ AnyT P l ⊎ P y ⊎ AnyT P r □ ... | false = AnyT P l ⊎ P y ⊎ AnyT P (insert x r) ↔⟨ id ⊎-cong id ⊎-cong Any-insert P x r ⟩ AnyT P l ⊎ P y ⊎ P x ⊎ AnyT P r ↔⟨ lemma (AnyT P l) (P y) (P x) (AnyT P r) ⟩ P x ⊎ AnyT P l ⊎ P y ⊎ AnyT P r □ where -- The following lemma is easy to prove automatically (for instance -- by using a ring solver). lemma : (A B C D : Type) → A ⊎ B ⊎ C ⊎ D ↔ C ⊎ A ⊎ B ⊎ D lemma A B C D = A ⊎ B ⊎ C ⊎ D ↔⟨ id ⊎-cong ⊎-assoc ⟩ A ⊎ (B ⊎ C) ⊎ D ↔⟨ id ⊎-cong ⊎-comm ⊎-cong id ⟩ A ⊎ (C ⊎ B) ⊎ D ↔⟨ ⊎-assoc ⟩ (A ⊎ C ⊎ B) ⊎ D ↔⟨ ⊎-assoc ⊎-cong id ⟩ ((A ⊎ C) ⊎ B) ⊎ D ↔⟨ (⊎-comm ⊎-cong id) ⊎-cong id ⟩ ((C ⊎ A) ⊎ B) ⊎ D ↔⟨ inverse ⊎-assoc ⊎-cong id ⟩ (C ⊎ A ⊎ B) ⊎ D ↔⟨ inverse ⊎-assoc ⟩ C ⊎ (A ⊎ B) ⊎ D ↔⟨ id ⊎-cong inverse ⊎-assoc ⟩ C ⊎ A ⊎ B ⊎ D □ ------------------------------------------------------------------------ -- Turning a list into a search tree -- Converts the list to a search tree. to-search-tree : List A → Tree A to-search-tree = foldr insert leaf -- No elements are added or removed. to-search-tree-lemma : ∀ xs z → z ∈T to-search-tree xs ↔ z ∈ xs to-search-tree-lemma [] = λ z → z ∈T leaf ↔⟨⟩ z ∈ [] □ to-search-tree-lemma (x ∷ xs) = λ z → z ∈T insert x (to-search-tree xs) ↔⟨ Any-insert (λ x → z ≡ x) _ _ ⟩ z ≡ x ⊎ z ∈T to-search-tree xs ↔⟨ id ⊎-cong to-search-tree-lemma xs z ⟩ z ∈ x ∷ xs □ ------------------------------------------------------------------------ -- Sorting -- Sorts a list. tree-sort : List A → List A tree-sort = flatten ∘ to-search-tree -- The result is a permutation of the input. tree-sort-permutes : ∀ xs → tree-sort xs ≈-bag xs tree-sort-permutes xs = λ z → z ∈ flatten (to-search-tree xs) ↔⟨ flatten-lemma (to-search-tree xs) z ⟩ z ∈T to-search-tree xs ↔⟨ to-search-tree-lemma xs z ⟩ z ∈ xs □
{ "alphanum_fraction": 0.4837386464, "avg_line_length": 32.5047619048, "ext": "agda", "hexsha": "400a8e4fda12a9bfaa7af56ca1eb8d2858b85f04", "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/Tree-sort/Partial.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/Tree-sort/Partial.agda", "max_line_length": 84, "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/Tree-sort/Partial.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": 1201, "size": 3413 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Enriched where open import Categories.Category open import Categories.Monoidal -- moar
{ "alphanum_fraction": 0.7945205479, "avg_line_length": 20.8571428571, "ext": "agda", "hexsha": "527a2fd1bb5abfd7cf63fc92cd47326f0af5618a", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Enriched.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Enriched.agda", "max_line_length": 39, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Enriched.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 30, "size": 146 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.cubical.Square open import lib.types.Bool open import lib.types.Coproduct open import lib.types.FunctionSeq open import lib.types.Paths open import lib.types.Pointed open import lib.types.Span open import lib.types.Pushout open import lib.types.Sigma module lib.types.Smash where module _ {i j} (X : Ptd i) (Y : Ptd j) where ⊙∧-span : ⊙Span ⊙∧-span = ⊙span (X ⊙× Y) ⊙Bool (X ⊙⊔ Y) (⊔-rec (_, pt Y) (pt X ,_) , idp) (⊙⊔-fmap {Y = Y} ⊙cst ⊙cst) ∧-span : Span ∧-span = ⊙Span-to-Span ⊙∧-span abstract _∧_ : Type (lmax i j) _∧_ = Pushout ∧-span Smash = _∧_ module _ {i j} {X : Ptd i} {Y : Ptd j} where abstract smin : de⊙ X → de⊙ Y → Smash X Y smin x y = left (x , y) module _ {i j} (X : Ptd i) (Y : Ptd j) where _⊙∧_ = ptd (X ∧ Y) (smin (pt X) (pt Y)) ⊙Smash = _⊙∧_ module _ {i j} {X : Ptd i} {Y : Ptd j} where abstract smbasel : Smash X Y smbasel = right true smbaser : Smash X Y smbaser = right false smgluel : (x : de⊙ X) → smin x (pt Y) == smbasel smgluel x = glue (inl x) smgluer : (y : de⊙ Y) → smin (pt X) y == smbaser smgluer y = glue (inr y) ∧-norm-l-seq : (x : de⊙ X) → smin x (pt Y) =-= smin (pt X) (pt Y) ∧-norm-l-seq x = smgluel x ◃∙ ! (smgluel (pt X)) ◃∎ ∧-norm-l : (x : de⊙ X) → smin x (pt Y) == smin (pt X) (pt Y) ∧-norm-l x = ↯ (∧-norm-l-seq x) ∧-norm-r-seq : (y : de⊙ Y) → smin (pt X) y =-= smin (pt X) (pt Y) ∧-norm-r-seq y = smgluer y ◃∙ ! (smgluer (pt Y)) ◃∎ ∧-norm-r : (y : de⊙ Y) → smin (pt X) y == smin (pt X) (pt Y) ∧-norm-r y = ↯ (∧-norm-r-seq y) ∧-⊙inl : de⊙ Y → X ⊙→ ⊙Smash X Y ∧-⊙inl y = (λ x → smin x y) , smgluer y ∙ ! (smgluer (pt Y)) ∧-⊙inr : de⊙ X → Y ⊙→ ⊙Smash X Y ∧-⊙inr x = (λ y → smin x y) , smgluel x ∙ ! (smgluel (pt X)) ∧-glue-lr : smbasel == smbaser ∧-glue-lr = ! (smgluel (pt X)) ∙ smgluer (pt Y) ap-smin-l : {a b : de⊙ X} (p : a == b) → ap (λ x → smin x (pt Y)) p == smgluel a ∙ ! (smgluel b) ap-smin-l = ap-null-homotopic (λ x → smin x (pt Y)) smgluel ap-smin-r : {a b : de⊙ Y} (p : a == b) → ap (smin (pt X)) p == smgluer a ∙ ! (smgluer b) ap-smin-r = ap-null-homotopic (λ y → smin (pt X) y) smgluer module _ {i j} {X : Ptd i} {Y : Ptd j} where module SmashElim {k} {P : Smash X Y → Type k} (smin* : (x : de⊙ X) (y : de⊙ Y) → P (smin x y)) (smbasel* : P smbasel) (smbaser* : P smbaser) (smgluel* : (x : de⊙ X) → smin* x (pt Y) == smbasel* [ P ↓ smgluel x ]) (smgluer* : (y : de⊙ Y) → smin* (pt X) y == smbaser* [ P ↓ smgluer y ]) where -- It would be better to encapsulate the repetition in the following definitions in a -- private module as follows. Unfortunately, this is not possible when the smash -- datatype is declared abstract. {-private module M = PushoutElim (uncurry smin*) (Coprod-elim (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*)-} abstract f : (s : X ∧ Y) → P s f = PushoutElim.f (uncurry smin*) (Coprod-elim (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) smin-β : ∀ x y → f (smin x y) ↦ smin* x y smin-β x y = PushoutElim.left-β (uncurry smin*) (Coprod-elim (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) (x , y) {-# REWRITE smin-β #-} smbasel-β : f smbasel ↦ smbasel* smbasel-β = PushoutElim.right-β (uncurry smin*) (Coprod-elim (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) true {-# REWRITE smbasel-β #-} smbaser-β : f smbaser ↦ smbaser* smbaser-β = PushoutElim.right-β (uncurry smin*) (Coprod-elim (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) false {-# REWRITE smbaser-β #-} smgluel-β : ∀ (x : de⊙ X) → apd f (smgluel x) == smgluel* x smgluel-β = PushoutElim.glue-β (uncurry smin*) (Coprod-elim (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) ∘ inl smgluer-β : ∀ (y : de⊙ Y) → apd f (smgluer y) == smgluer* y smgluer-β = PushoutElim.glue-β (uncurry smin*) (Coprod-elim (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) ∘ inr Smash-elim = SmashElim.f module SmashRec {k} {C : Type k} (smin* : (x : de⊙ X) (y : de⊙ Y) → C) (smbasel* smbaser* : C) (smgluel* : (x : de⊙ X) → smin* x (pt Y) == smbasel*) (smgluer* : (y : de⊙ Y) → smin* (pt X) y == smbaser*) where -- It would be better to encapsulate the repetition in the following definitions in a -- private module as follows. Unfortunately, this is not possible when the smash -- datatype is declared abstract. {-private module M = PushoutRec {d = ∧-span X Y} (uncurry smin*) (Coprod-rec (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*)-} abstract f : X ∧ Y → C f = PushoutRec.f (uncurry smin*) (Coprod-elim (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) smin-β : ∀ x y → f (smin x y) ↦ smin* x y smin-β x y = PushoutRec.left-β {d = ∧-span X Y} (uncurry smin*) (Coprod-rec (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) (x , y) {-# REWRITE smin-β #-} smbasel-β : f smbasel ↦ smbasel* smbasel-β = PushoutRec.right-β {d = ∧-span X Y} (uncurry smin*) (Coprod-rec (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) true {-# REWRITE smbasel-β #-} smbaser-β : f smbaser ↦ smbaser* smbaser-β = PushoutRec.right-β {d = ∧-span X Y} (uncurry smin*) (Coprod-rec (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) false {-# REWRITE smbaser-β #-} smgluel-β : ∀ (x : de⊙ X) → ap f (smgluel x) == smgluel* x smgluel-β = PushoutRec.glue-β (uncurry smin*) (Coprod-rec (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) ∘ inl smgluer-β : ∀ (y : de⊙ Y) → ap f (smgluer y) == smgluer* y smgluer-β = PushoutRec.glue-β (uncurry smin*) (Coprod-rec (λ _ → smbasel*) (λ _ → smbaser*)) (Coprod-elim smgluel* smgluer*) ∘ inr ∧-norm-l-β : ∀ (x : de⊙ X) → ap f (∧-norm-l x) == smgluel* x ∙ ! (smgluel* (pt X)) ∧-norm-l-β x = ap f (∧-norm-l x) =⟨ ap-∙ f (smgluel x) (! (smgluel (pt X))) ⟩ ap f (smgluel x) ∙ ap f (! (smgluel (pt X))) =⟨ ap2 _∙_ (smgluel-β x) (ap-! f (smgluel (pt X)) ∙ ap ! (smgluel-β (pt X))) ⟩ smgluel* x ∙ ! (smgluel* (pt X)) =∎ ∧-norm-r-β : ∀ (y : de⊙ Y) → ap f (∧-norm-r y) == smgluer* y ∙ ! (smgluer* (pt Y)) ∧-norm-r-β y = ap f (∧-norm-r y) =⟨ ap-∙ f (smgluer y) (! (smgluer (pt Y))) ⟩ ap f (smgluer y) ∙ ap f (! (smgluer (pt Y))) =⟨ ap2 _∙_ (smgluer-β y) (ap-! f (smgluer (pt Y)) ∙ ap ! (smgluer-β (pt Y))) ⟩ smgluer* y ∙ ! (smgluer* (pt Y)) =∎ Smash-rec = SmashRec.f module SmashPathOverElim {k} {P : Smash X Y → Type k} (g₁ g₂ : (xy : Smash X Y) → P xy) (smin* : (x : de⊙ X) (y : de⊙ Y) → g₁ (smin x y) == g₂ (smin x y)) (smbasel* : g₁ smbasel == g₂ smbasel) (smbaser* : g₁ smbaser == g₂ smbaser) (smgluel* : (x : de⊙ X) → smin* x (pt Y) ◃ apd g₂ (smgluel x) == apd g₁ (smgluel x) ▹ smbasel*) (smgluer* : (y : de⊙ Y) → smin* (pt X) y ◃ apd g₂ (smgluer y) == apd g₁ (smgluer y) ▹ smbaser*) where f : g₁ ∼ g₂ f = Smash-elim {P = λ xy → g₁ xy == g₂ xy} smin* smbasel* smbaser* (λ x → ↓-=-in (smgluel* x)) (λ y → ↓-=-in (smgluer* y)) Smash-PathOver-elim = SmashPathOverElim.f module SmashPathElim {k} {C : Type k} (g₁ g₂ : Smash X Y → C) (smin* : (x : de⊙ X) (y : de⊙ Y) → g₁ (smin x y) == g₂ (smin x y)) (smbasel* : g₁ smbasel == g₂ smbasel) (smbaser* : g₁ smbaser == g₂ smbaser) (smgluel* : (x : de⊙ X) → Square (smin* x (pt Y)) (ap g₁ (smgluel x)) (ap g₂ (smgluel x)) smbasel*) (smgluer* : (y : de⊙ Y) → Square (smin* (pt X) y) (ap g₁ (smgluer y)) (ap g₂ (smgluer y)) smbaser*) where f : g₁ ∼ g₂ f = Smash-elim {P = λ xy → g₁ xy == g₂ xy} smin* smbasel* smbaser* (λ x → ↓-='-from-square (smgluel* x)) (λ y → ↓-='-from-square (smgluer* y)) Smash-Path-elim = SmashPathElim.f module _ {i j k l} {X : Ptd i} {Y : Ptd j} {X' : Ptd k} {Y' : Ptd l} (f : X ⊙→ X') (g : Y ⊙→ Y') where private module M = SmashRec {C = X' ∧ Y'} (λ x y → smin (fst f x) (fst g y)) (smin (pt X') (pt Y')) (smin (pt X') (pt Y')) (λ x → ap (λ y' → smin (fst f x) y') (snd g) ∙ ∧-norm-l (fst f x)) (λ y → ap (λ x' → smin x' (fst g y)) (snd f) ∙ ∧-norm-r (fst g y)) abstract ∧-fmap : X ∧ Y → X' ∧ Y' ∧-fmap = M.f ∧-fmap-smin-β : ∀ x y → ∧-fmap (smin x y) ↦ smin (fst f x) (fst g y) ∧-fmap-smin-β = M.smin-β {-# REWRITE ∧-fmap-smin-β #-} ∧-fmap-smbasel-β : ∧-fmap smbasel ↦ smin (pt X') (pt Y') ∧-fmap-smbasel-β = M.smbasel-β {-# REWRITE ∧-fmap-smbasel-β #-} ∧-fmap-smbaser-β : ∧-fmap smbaser ↦ smin (pt X') (pt Y') ∧-fmap-smbaser-β = M.smbaser-β {-# REWRITE ∧-fmap-smbaser-β #-} ∧-fmap-smgluel-β' : ∀ x → ap ∧-fmap (smgluel x) == ap (λ y' → smin (fst f x) y') (snd g) ∙ ∧-norm-l (fst f x) ∧-fmap-smgluel-β' x = M.smgluel-β x ∧-fmap-smgluer-β' : ∀ y → ap ∧-fmap (smgluer y) == ap (λ x' → smin x' (fst g y)) (snd f) ∙ ∧-norm-r (fst g y) ∧-fmap-smgluer-β' = M.smgluer-β ∧-fmap-smgluel-β : ∀ x → ap ∧-fmap (smgluel x) ◃∎ =ₛ ap (λ y' → smin (fst f x) y') (snd g) ◃∙ ∧-norm-l (fst f x) ◃∎ ∧-fmap-smgluel-β x = =ₛ-in (∧-fmap-smgluel-β' x) ∧-fmap-smgluer-β : ∀ y → ap ∧-fmap (smgluer y) ◃∎ =ₛ ap (λ x' → smin x' (fst g y)) (snd f) ◃∙ ∧-norm-r (fst g y) ◃∎ ∧-fmap-smgluer-β y = =ₛ-in (∧-fmap-smgluer-β' y) ⊙∧-fmap : X ⊙∧ Y ⊙→ X' ⊙∧ Y' ⊙∧-fmap = ∧-fmap , ap2 smin (snd f) (snd g) ∧-fmap-norm-l : ∀ x → ap ∧-fmap (∧-norm-l x) ◃∎ =ₛ ap (λ y' → smin (fst f x) y') (snd g) ◃∙ smgluel (fst f x) ◃∙ ! (smgluel (fst f (pt X))) ◃∙ ! (ap (smin (fst f (pt X))) (snd g)) ◃∎ ∧-fmap-norm-l x = ap ∧-fmap (∧-norm-l x) ◃∎ =ₛ⟨ ap-seq-∙ ∧-fmap (∧-norm-l-seq x) ⟩ ap ∧-fmap (smgluel x) ◃∙ ap ∧-fmap (! (smgluel (pt X))) ◃∎ =ₛ₁⟨ 1 & 1 & ap-! ∧-fmap (smgluel (pt X)) ⟩ ap ∧-fmap (smgluel x) ◃∙ ! (ap ∧-fmap (smgluel (pt X))) ◃∎ =ₛ⟨ 0 & 1 & ∧-fmap-smgluel-β x ⟩ ap (smin (fst f x)) (snd g) ◃∙ ∧-norm-l (fst f x) ◃∙ ! (ap ∧-fmap (smgluel (pt X))) ◃∎ =ₛ⟨ 2 & 1 & !-=ₛ (∧-fmap-smgluel-β (pt X)) ⟩ ap (smin (fst f x)) (snd g) ◃∙ ∧-norm-l (fst f x) ◃∙ ! (∧-norm-l (fst f (pt X))) ◃∙ ! (ap (smin (fst f (pt X))) (snd g)) ◃∎ =ₛ⟨ 2 & 1 & !-=ₛ (expand (∧-norm-l-seq (fst f (pt X)))) ⟩ ap (smin (fst f x)) (snd g) ◃∙ ∧-norm-l (fst f x) ◃∙ ! (! (smgluel (pt X'))) ◃∙ ! (smgluel (fst f (pt X))) ◃∙ ! (ap (smin (fst f (pt X))) (snd g)) ◃∎ =ₛ⟨ 1 & 1 & expand (∧-norm-l-seq (fst f x)) ⟩ ap (smin (fst f x)) (snd g) ◃∙ smgluel (fst f x) ◃∙ ! (smgluel (pt X')) ◃∙ ! (! (smgluel (pt X'))) ◃∙ ! (smgluel (fst f (pt X))) ◃∙ ! (ap (smin (fst f (pt X))) (snd g)) ◃∎ =ₛ⟨ 2 & 2 & seq-!-inv-r (! (smgluel (pt X')) ◃∎) ⟩ ap (smin (fst f x)) (snd g) ◃∙ smgluel (fst f x) ◃∙ ! (smgluel (fst f (pt X))) ◃∙ ! (ap (smin (fst f (pt X))) (snd g)) ◃∎ ∎ₛ ∧-fmap-norm-r : ∀ y → ap ∧-fmap (∧-norm-r y) ◃∎ =ₛ ap (λ x' → smin x' (fst g y)) (snd f) ◃∙ smgluer (fst g y) ◃∙ ! (smgluer (fst g (pt Y))) ◃∙ ! (ap (λ x' → smin x' (fst g (pt Y))) (snd f)) ◃∎ ∧-fmap-norm-r y = ap ∧-fmap (∧-norm-r y) ◃∎ =ₛ⟨ ap-seq-∙ ∧-fmap (∧-norm-r-seq y) ⟩ ap ∧-fmap (smgluer y) ◃∙ ap ∧-fmap (! (smgluer (pt Y))) ◃∎ =ₛ₁⟨ 1 & 1 & ap-! ∧-fmap (smgluer (pt Y)) ⟩ ap ∧-fmap (smgluer y) ◃∙ ! (ap ∧-fmap (smgluer (pt Y))) ◃∎ =ₛ⟨ 0 & 1 & ∧-fmap-smgluer-β y ⟩ ap (λ x' → smin x' (fst g y)) (snd f) ◃∙ ∧-norm-r (fst g y) ◃∙ ! (ap ∧-fmap (smgluer (pt Y))) ◃∎ =ₛ⟨ 2 & 1 & !-=ₛ (∧-fmap-smgluer-β (pt Y)) ⟩ ap (λ x' → smin x' (fst g y)) (snd f) ◃∙ ∧-norm-r (fst g y) ◃∙ ! (∧-norm-r (fst g (pt Y))) ◃∙ ! (ap (λ x' → smin x' (fst g (pt Y))) (snd f)) ◃∎ =ₛ⟨ 2 & 1 & !-=ₛ (expand (∧-norm-r-seq (fst g (pt Y)))) ⟩ ap (λ x' → smin x' (fst g y)) (snd f) ◃∙ ∧-norm-r (fst g y) ◃∙ ! (! (smgluer (pt Y'))) ◃∙ ! (smgluer (fst g (pt Y))) ◃∙ ! (ap (λ x' → smin x' (fst g (pt Y))) (snd f)) ◃∎ =ₛ⟨ 1 & 1 & expand (∧-norm-r-seq (fst g y)) ⟩ ap (λ x' → smin x' (fst g y)) (snd f) ◃∙ smgluer (fst g y) ◃∙ ! (smgluer (pt Y')) ◃∙ ! (! (smgluer (pt Y'))) ◃∙ ! (smgluer (fst g (pt Y))) ◃∙ ! (ap (λ x → smin x (fst g (pt Y))) (snd f)) ◃∎ =ₛ⟨ 2 & 2 & seq-!-inv-r (! (smgluer (pt Y')) ◃∎) ⟩ ap (λ x' → smin x' (fst g y)) (snd f) ◃∙ smgluer (fst g y) ◃∙ ! (smgluer (fst g (pt Y))) ◃∙ ! (ap (λ x' → smin x' (fst g (pt Y))) (snd f)) ◃∎ ∎ₛ module _ {i i' i'' j j' j''} {X : Ptd i} {X' : Ptd i'} {X'' : Ptd i''} (f : X ⊙→ X') (f' : X' ⊙→ X'') {Y : Ptd j} {Y' : Ptd j'} {Y'' : Ptd j''} (g : Y ⊙→ Y') (g' : Y' ⊙→ Y'') where ∧-fmap-comp : ∀ xy → ∧-fmap (f' ⊙∘ f) (g' ⊙∘ g) xy == ∧-fmap f' g' (∧-fmap f g xy) ∧-fmap-comp = Smash-elim {X = X} {Y = Y} {P = λ xy → ∧-fmap (f' ⊙∘ f) (g' ⊙∘ g) xy == ∧-fmap f' g' (∧-fmap f g xy)} (λ x y → idp) (! (ap2 smin (snd f') (snd g'))) (! (ap2 smin (snd f') (snd g'))) (λ x → ↓-='-in-=ₛ $ idp ◃∙ ap (∧-fmap f' g' ∘ ∧-fmap f g) (smgluel x) ◃∎ =ₛ⟨ 0 & 1 & expand [] ⟩ ap (∧-fmap f' g' ∘ ∧-fmap f g) (smgluel x) ◃∎ =ₛ₁⟨ ap-∘ (∧-fmap f' g') (∧-fmap f g) (smgluel x) ⟩ ap (∧-fmap f' g') (ap (∧-fmap f g) (smgluel x)) ◃∎ =ₛ⟨ ap-seq-=ₛ (∧-fmap f' g') (∧-fmap-smgluel-β f g x) ⟩ ap (∧-fmap f' g') (ap (smin (fst f x)) (snd g)) ◃∙ ap (∧-fmap f' g') (∧-norm-l (fst f x)) ◃∎ =ₛ₁⟨ 0 & 1 & ∘-ap (∧-fmap f' g') (smin (fst f x)) (snd g) ⟩ ap (smin (fst (f' ⊙∘ f) x) ∘ fst g') (snd g) ◃∙ ap (∧-fmap f' g') (∧-norm-l (fst f x)) ◃∎ =ₛ⟨ 1 & 1 & ∧-fmap-norm-l f' g' (fst f x) ⟩ ap (smin (fst (f' ⊙∘ f) x) ∘ fst g') (snd g) ◃∙ ap (smin (fst (f' ⊙∘ f) x)) (snd g') ◃∙ smgluel (fst (f' ⊙∘ f) x) ◃∙ ! (smgluel (fst f' (pt X'))) ◃∙ ! (ap (smin (fst f' (pt X'))) (snd g')) ◃∎ =ₛ₁⟨ 0 & 1 & ap-∘ (smin (fst (f' ⊙∘ f) x)) (fst g') (snd g) ⟩ ap (smin (fst (f' ⊙∘ f) x)) (ap (fst g') (snd g)) ◃∙ ap (smin (fst (f' ⊙∘ f) x)) (snd g') ◃∙ smgluel (fst (f' ⊙∘ f) x) ◃∙ ! (smgluel (fst f' (pt X'))) ◃∙ ! (ap (smin (fst f' (pt X'))) (snd g')) ◃∎ =ₛ⟨ 0 & 2 & ∙-ap-seq (smin (fst (f' ⊙∘ f) x)) (ap (fst g') (snd g) ◃∙ snd g' ◃∎) ⟩ ap (smin (fst f' (fst f x))) (snd (g' ⊙∘ g)) ◃∙ smgluel (fst (f' ⊙∘ f) x) ◃∙ ! (smgluel (fst f' (pt X'))) ◃∙ ! (ap (smin (fst f' (pt X'))) (snd g')) ◃∎ =ₛ⟨ 3 & 0 & !ₛ (seq-!-inv-r (ap (λ x'' → smin x'' (pt Y'')) (snd f') ◃∎)) ⟩ ap (smin (fst f' (fst f x))) (snd (g' ⊙∘ g)) ◃∙ smgluel (fst (f' ⊙∘ f) x) ◃∙ ! (smgluel (fst f' (pt X'))) ◃∙ ap (λ x'' → smin x'' (pt Y'')) (snd f') ◃∙ ! (ap (λ x'' → smin x'' (pt Y'')) (snd f')) ◃∙ ! (ap (smin (fst f' (pt X'))) (snd g')) ◃∎ =ₛ⟨ 4 & 2 & !ₛ $ !-=ₛ $ ap2-out' smin (snd f') (snd g') ⟩ ap (smin (fst f' (fst f x))) (snd (g' ⊙∘ g)) ◃∙ smgluel (fst (f' ⊙∘ f) x) ◃∙ ! (smgluel (fst f' (pt X'))) ◃∙ ap (λ x'' → smin x'' (pt Y'')) (snd f') ◃∙ ! (ap2 smin (snd f') (snd g')) ◃∎ =ₛ⟨ 3 & 1 & =ₛ-in {t = smgluel (fst f' (pt X')) ◃∙ ! (smgluel (pt X'')) ◃∎} $ ap-null-homotopic (λ x'' → smin x'' (pt Y'')) smgluel (snd f') ⟩ ap (smin (fst f' (fst f x))) (snd (g' ⊙∘ g)) ◃∙ smgluel (fst (f' ⊙∘ f) x) ◃∙ ! (smgluel (fst f' (pt X'))) ◃∙ smgluel (fst f' (pt X')) ◃∙ ! (smgluel (pt X'')) ◃∙ ! (ap2 smin (snd f') (snd g')) ◃∎ =ₛ⟨ 2 & 2 & seq-!-inv-l (smgluel (fst f' (pt X')) ◃∎) ⟩ ap (smin (fst f' (fst f x))) (snd (g' ⊙∘ g)) ◃∙ smgluel (fst (f' ⊙∘ f) x) ◃∙ ! (smgluel (pt X'')) ◃∙ ! (ap2 smin (snd f') (snd g')) ◃∎ =ₛ⟨ 1 & 2 & contract ⟩ ap (smin (fst f' (fst f x))) (snd (g' ⊙∘ g)) ◃∙ ∧-norm-l (fst (f' ⊙∘ f) x) ◃∙ ! (ap2 smin (snd f') (snd g')) ◃∎ =ₛ⟨ 0 & 2 & !ₛ (∧-fmap-smgluel-β (f' ⊙∘ f) (g' ⊙∘ g) x) ⟩ ap (∧-fmap (f' ⊙∘ f) (g' ⊙∘ g)) (smgluel x) ◃∙ ! (ap2 smin (snd f') (snd g')) ◃∎ ∎ₛ) (λ y → ↓-='-in-=ₛ $ idp ◃∙ ap (∧-fmap f' g' ∘ ∧-fmap f g) (smgluer y) ◃∎ =ₛ⟨ 0 & 1 & expand [] ⟩ ap (∧-fmap f' g' ∘ ∧-fmap f g) (smgluer y) ◃∎ =ₛ₁⟨ ap-∘ (∧-fmap f' g') (∧-fmap f g) (smgluer y) ⟩ ap (∧-fmap f' g') (ap (∧-fmap f g) (smgluer y)) ◃∎ =ₛ⟨ ap-seq-=ₛ (∧-fmap f' g') (∧-fmap-smgluer-β f g y) ⟩ ap (∧-fmap f' g') (ap (λ x' → smin x' (fst g y)) (snd f)) ◃∙ ap (∧-fmap f' g') (∧-norm-r (fst g y)) ◃∎ =ₛ₁⟨ 0 & 1 & ∘-ap (∧-fmap f' g') (λ x' → smin x' (fst g y)) (snd f) ⟩ ap (λ x' → smin (fst f' x') (fst (g' ⊙∘ g) y)) (snd f) ◃∙ ap (∧-fmap f' g') (∧-norm-r (fst g y)) ◃∎ =ₛ⟨ 1 & 1 & ∧-fmap-norm-r f' g' (fst g y) ⟩ ap (λ x' → smin (fst f' x') (fst (g' ⊙∘ g) y)) (snd f) ◃∙ ap (λ x'' → smin x'' (fst (g' ⊙∘ g) y)) (snd f') ◃∙ smgluer (fst (g' ⊙∘ g) y) ◃∙ ! (smgluer (fst g' (pt Y'))) ◃∙ ! (ap (λ x' → smin x' (fst g' (pt Y'))) (snd f')) ◃∎ =ₛ₁⟨ 0 & 1 & ap-∘ (λ x'' → smin x'' (fst (g' ⊙∘ g) y)) (fst f') (snd f) ⟩ ap (λ x'' → smin x'' (fst (g' ⊙∘ g) y)) (ap (fst f') (snd f)) ◃∙ ap (λ x'' → smin x'' (fst (g' ⊙∘ g) y)) (snd f') ◃∙ smgluer (fst (g' ⊙∘ g) y) ◃∙ ! (smgluer (fst g' (pt Y'))) ◃∙ ! (ap (λ x' → smin x' (fst g' (pt Y'))) (snd f')) ◃∎ =ₛ⟨ 0 & 2 & ∙-ap-seq (λ x'' → smin x'' (fst (g' ⊙∘ g) y)) (ap (fst f') (snd f) ◃∙ snd f' ◃∎) ⟩ ap (λ x'' → smin x'' (fst (g' ⊙∘ g) y)) (snd (f' ⊙∘ f)) ◃∙ smgluer (fst (g' ⊙∘ g) y) ◃∙ ! (smgluer (fst g' (pt Y'))) ◃∙ ! (ap (λ x' → smin x' (fst g' (pt Y'))) (snd f')) ◃∎ =ₛ⟨ 3 & 0 & !ₛ (seq-!-inv-r (ap (smin (pt X'')) (snd g') ◃∎)) ⟩ ap (λ x'' → smin x'' (fst (g' ⊙∘ g) y)) (snd (f' ⊙∘ f)) ◃∙ smgluer (fst (g' ⊙∘ g) y) ◃∙ ! (smgluer (fst g' (pt Y'))) ◃∙ ap (smin (pt X'')) (snd g') ◃∙ ! (ap (smin (pt X'')) (snd g')) ◃∙ ! (ap (λ x' → smin x' (fst g' (pt Y'))) (snd f')) ◃∎ =ₛ⟨ 4 & 2 & !ₛ $ !-=ₛ $ ap2-out smin (snd f') (snd g') ⟩ ap (λ x'' → smin x'' (fst (g' ⊙∘ g) y)) (snd (f' ⊙∘ f)) ◃∙ smgluer (fst (g' ⊙∘ g) y) ◃∙ ! (smgluer (fst g' (pt Y'))) ◃∙ ap (smin (pt X'')) (snd g') ◃∙ ! (ap2 smin (snd f') (snd g')) ◃∎ =ₛ⟨ 3 & 1 & =ₛ-in {t = smgluer (fst g' (pt Y')) ◃∙ ! (smgluer (pt Y'')) ◃∎} $ ap-null-homotopic (smin (pt X'')) smgluer (snd g') ⟩ ap (λ x'' → smin x'' (fst (g' ⊙∘ g) y)) (snd (f' ⊙∘ f)) ◃∙ smgluer (fst (g' ⊙∘ g) y) ◃∙ ! (smgluer (fst g' (pt Y'))) ◃∙ smgluer (fst g' (pt Y')) ◃∙ ! (smgluer (pt Y'')) ◃∙ ! (ap2 smin (snd f') (snd g')) ◃∎ =ₛ⟨ 2 & 2 & seq-!-inv-l (smgluer (fst g' (pt Y')) ◃∎) ⟩ ap (λ x'' → smin x'' (fst (g' ⊙∘ g) y)) (snd (f' ⊙∘ f)) ◃∙ smgluer (fst (g' ⊙∘ g) y) ◃∙ ! (smgluer (pt Y'')) ◃∙ ! (ap2 smin (snd f') (snd g')) ◃∎ =ₛ⟨ 1 & 2 & contract ⟩ ap (λ x'' → smin x'' (fst (g' ⊙∘ g) y)) (snd (f' ⊙∘ f)) ◃∙ ∧-norm-r (fst (g' ⊙∘ g) y) ◃∙ ! (ap2 smin (snd f') (snd g')) ◃∎ =ₛ⟨ 0 & 2 & !ₛ (∧-fmap-smgluer-β (f' ⊙∘ f) (g' ⊙∘ g) y) ⟩ ap (∧-fmap (f' ⊙∘ f) (g' ⊙∘ g)) (smgluer y) ◃∙ ! (ap2 smin (snd f') (snd g')) ◃∎ ∎ₛ) module _ {i j} {X : Ptd i} {Y : Ptd j} where ×-to-∧ : de⊙ X × de⊙ Y → X ∧ Y ×-to-∧ (x , y) = smin x y ×-⊙to-∧ : X ⊙× Y ⊙→ X ⊙∧ Y ×-⊙to-∧ = ×-to-∧ , idp module _ {i j} (X : Ptd i) (Y : Ptd j) where module SmashSwap = SmashRec {X = X} {Y = Y} {C = Y ∧ X} (λ x y → smin y x) (smin (pt Y) (pt X)) (smin (pt Y) (pt X)) ∧-norm-r ∧-norm-l ∧-swap : X ∧ Y → Y ∧ X ∧-swap = SmashSwap.f ⊙∧-swap : X ⊙∧ Y ⊙→ Y ⊙∧ X ⊙∧-swap = ∧-swap , idp ∧-swap-norm-l-β : ∀ x → ap ∧-swap (∧-norm-l x) == ∧-norm-r x ∧-swap-norm-l-β x = ap ∧-swap (∧-norm-l x) =⟨ SmashSwap.∧-norm-l-β x ⟩ ∧-norm-r x ∙ ! (∧-norm-r (pt X)) =⟨ ap (λ u → ∧-norm-r x ∙ ! u) (!-inv-r (smgluer (pt X))) ⟩ ∧-norm-r x ∙ idp =⟨ ∙-unit-r (∧-norm-r x) ⟩ ∧-norm-r x =∎ ∧-swap-norm-r-β : ∀ y → ap ∧-swap (∧-norm-r y) == ∧-norm-l y ∧-swap-norm-r-β y = ap ∧-swap (∧-norm-r y) =⟨ SmashSwap.∧-norm-r-β y ⟩ ∧-norm-l y ∙ ! (∧-norm-l (pt Y)) =⟨ ap (λ u → ∧-norm-l y ∙ ! u) (!-inv-r (smgluel (pt Y))) ⟩ ∧-norm-l y ∙ idp =⟨ ∙-unit-r (∧-norm-l y) ⟩ ∧-norm-l y =∎ ×-to-∧-swap : ∧-swap ∘ ×-to-∧ ∼ ×-to-∧ ∘ ×-swap ×-to-∧-swap (x , y) = idp ×-⊙to-∧-swap : ⊙∧-swap ◃⊙∘ ×-⊙to-∧ ◃⊙idf =⊙∘ ×-⊙to-∧ ◃⊙∘ ⊙×-swap ◃⊙idf ×-⊙to-∧-swap = =⊙∘-in $ ⊙λ=' ×-to-∧-swap idp module _ {i j} (X : Ptd i) (Y : Ptd j) where module SmashSwapInvolutive = SmashElim {X = X} {Y = Y} {P = λ xy → ∧-swap Y X (∧-swap X Y xy) == xy} (λ x y → idp) (smgluel (pt X)) (smgluer (pt Y)) (λ x → ↓-app=idf-in $ ! $ ap (∧-swap Y X ∘ ∧-swap X Y) (smgluel x) ∙ smgluel (pt X) =⟨ ap (_∙ smgluel (pt X)) $ ap-∘ (∧-swap Y X) (∧-swap X Y) (smgluel x) ⟩ ap (∧-swap Y X) (ap (∧-swap X Y) (smgluel x)) ∙ smgluel (pt X) =⟨ ap (λ p → ap (∧-swap Y X) p ∙ smgluel (pt X)) $ SmashSwap.smgluel-β X Y x ⟩ ap (∧-swap Y X) (∧-norm-r x) ∙ smgluel (pt X) =⟨ ap (_∙ smgluel (pt X)) (∧-swap-norm-r-β Y X x) ⟩ ∧-norm-l x ∙ smgluel (pt X) =⟨ ∙-assoc (smgluel x) (! (smgluel (pt X))) (smgluel (pt X))⟩ smgluel x ∙ ! (smgluel (pt X)) ∙ smgluel (pt X) =⟨ ap (smgluel x ∙_) (!-inv-l (smgluel (pt X))) ⟩ smgluel x ∙ idp =⟨ ∙-unit-r (smgluel x) ⟩ smgluel x =⟨ ! (∙'-unit-l (smgluel x)) ⟩ idp ∙' smgluel x =∎) (λ y → ↓-app=idf-in $ ! $ ap (∧-swap Y X ∘ ∧-swap X Y) (smgluer y) ∙ smgluer (pt Y) =⟨ ap (_∙ smgluer (pt Y)) $ ap-∘ (∧-swap Y X) (∧-swap X Y) (smgluer y) ⟩ ap (∧-swap Y X) (ap (∧-swap X Y) (smgluer y)) ∙ smgluer (pt Y) =⟨ ap (λ p → ap (∧-swap Y X) p ∙ smgluer (pt Y)) $ SmashSwap.smgluer-β X Y y ⟩ ap (∧-swap Y X) (∧-norm-l y) ∙ smgluer (pt Y) =⟨ ap (_∙ smgluer (pt Y)) (∧-swap-norm-l-β Y X y) ⟩ ∧-norm-r y ∙ smgluer (pt Y) =⟨ ∙-assoc (smgluer y) (! (smgluer (pt Y))) (smgluer (pt Y)) ⟩ smgluer y ∙ ! (smgluer (pt Y)) ∙ smgluer (pt Y) =⟨ ap (smgluer y ∙_) (!-inv-l (smgluer (pt Y))) ⟩ smgluer y ∙ idp =⟨ ∙-unit-r (smgluer y) ⟩ smgluer y =⟨ ! (∙'-unit-l (smgluer y)) ⟩ idp ∙' smgluer y =∎) ∧-swap-inv : ∀ xy → ∧-swap Y X (∧-swap X Y xy) == xy ∧-swap-inv = SmashSwapInvolutive.f ⊙∧-swap-inv : ⊙∧-swap Y X ◃⊙∘ ⊙∧-swap X Y ◃⊙idf =⊙∘ ⊙idf-seq ⊙∧-swap-inv = =⊙∘-in (⊙λ=' ∧-swap-inv idp) module _ {i j} (X : Ptd i) (Y : Ptd j) where ∧-swap-is-equiv : is-equiv (∧-swap X Y) ∧-swap-is-equiv = is-eq _ (∧-swap Y X) (∧-swap-inv Y X) (∧-swap-inv X Y) ∧-swap-equiv : (X ∧ Y) ≃ (Y ∧ X) ∧-swap-equiv = ∧-swap X Y , ∧-swap-is-equiv module _ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} (f : X ⊙→ X') (g : Y ⊙→ Y') where ∧-swap-naturality : ∀ xy → ∧-fmap g f (∧-swap X Y xy) == ∧-swap X' Y' (∧-fmap f g xy) ∧-swap-naturality = Smash-elim {X = X} {Y = Y} {P = λ xy → ∧-fmap g f (∧-swap X Y xy) == ∧-swap X' Y' (∧-fmap f g xy)} (λ x y → idp) (ap2 smin (snd g) (snd f)) (ap2 smin (snd g) (snd f)) (λ x → ↓-='-in-=ₛ $ idp ◃∙ ap (∧-swap X' Y' ∘ ∧-fmap f g) (smgluel x) ◃∎ =ₛ⟨ 0 & 1 & expand [] ⟩ ap (∧-swap X' Y' ∘ ∧-fmap f g) (smgluel x) ◃∎ =ₛ₁⟨ ap-∘ (∧-swap X' Y') (∧-fmap f g) (smgluel x) ⟩ ap (∧-swap X' Y') (ap (∧-fmap f g) (smgluel x)) ◃∎ =ₛ⟨ ap-seq-=ₛ (∧-swap X' Y') (∧-fmap-smgluel-β f g x) ⟩ ap (∧-swap X' Y') (ap (smin (fst f x)) (snd g)) ◃∙ ap (∧-swap X' Y') (∧-norm-l (fst f x)) ◃∎ =ₛ₁⟨ 0 & 1 & ∘-ap (∧-swap X' Y') (smin (fst f x)) (snd g) ⟩ ap (λ y' → smin y' (fst f x)) (snd g) ◃∙ ap (∧-swap X' Y') (∧-norm-l (fst f x)) ◃∎ =ₛ₁⟨ 1 & 1 & ∧-swap-norm-l-β X' Y' (fst f x) ⟩ ap (λ y' → smin y' (fst f x)) (snd g) ◃∙ ∧-norm-r (fst f x) ◃∎ =ₛ⟨ 1 & 1 & expand (∧-norm-r-seq (fst f x)) ⟩ ap (λ y' → smin y' (fst f x)) (snd g) ◃∙ smgluer (fst f x) ◃∙ ! (smgluer (pt X')) ◃∎ =ₛ⟨ 2 & 0 & !ₛ (seq-!-inv-l (smgluer (fst f (pt X)) ◃∎)) ⟩ ap (λ y' → smin y' (fst f x)) (snd g) ◃∙ smgluer (fst f x) ◃∙ ! (smgluer (fst f (pt X))) ◃∙ smgluer (fst f (pt X)) ◃∙ ! (smgluer (pt X')) ◃∎ =ₛ₁⟨ 3 & 2 & ! (ap-null-homotopic (smin (pt Y')) smgluer (snd f)) ⟩ ap (λ y' → smin y' (fst f x)) (snd g) ◃∙ smgluer (fst f x) ◃∙ ! (smgluer (fst f (pt X))) ◃∙ ap (smin (pt Y')) (snd f) ◃∎ =ₛ⟨ 3 & 0 & !ₛ (seq-!-inv-l (ap (λ y' → smin y' (fst f (pt X))) (snd g) ◃∎)) ⟩ ap (λ y' → smin y' (fst f x)) (snd g) ◃∙ smgluer (fst f x) ◃∙ ! (smgluer (fst f (pt X))) ◃∙ ! (ap (λ y' → smin y' (fst f (pt X))) (snd g)) ◃∙ ap (λ y' → smin y' (fst f (pt X))) (snd g) ◃∙ ap (smin (pt Y')) (snd f) ◃∎ =ₛ⟨ 4 & 2 & !ₛ (ap2-out smin (snd g) (snd f)) ⟩ ap (λ y' → smin y' (fst f x)) (snd g) ◃∙ smgluer (fst f x) ◃∙ ! (smgluer (fst f (pt X))) ◃∙ ! (ap (λ y' → smin y' (fst f (pt X))) (snd g)) ◃∙ ap2 smin (snd g) (snd f) ◃∎ =ₛ⟨ 0 & 4 & !ₛ (∧-fmap-norm-r g f x) ⟩ ap (∧-fmap g f) (∧-norm-r x) ◃∙ ap2 smin (snd g) (snd f) ◃∎ =ₛ₁⟨ 0 & 1 & ! (ap (ap (∧-fmap g f)) (SmashSwap.smgluel-β X Y x)) ⟩ ap (∧-fmap g f) (ap (∧-swap X Y) (smgluel x)) ◃∙ ap2 smin (snd g) (snd f) ◃∎ =ₛ₁⟨ 0 & 1 & ∘-ap (∧-fmap g f) (∧-swap X Y) (smgluel x) ⟩ ap (∧-fmap g f ∘ ∧-swap X Y) (smgluel x) ◃∙ ap2 smin (snd g) (snd f) ◃∎ ∎ₛ) (λ y → ↓-='-in-=ₛ $ idp ◃∙ ap (∧-swap X' Y' ∘ ∧-fmap f g) (smgluer y) ◃∎ =ₛ⟨ 0 & 1 & expand [] ⟩ ap (∧-swap X' Y' ∘ ∧-fmap f g) (smgluer y) ◃∎ =ₛ₁⟨ ap-∘ (∧-swap X' Y') (∧-fmap f g) (smgluer y) ⟩ ap (∧-swap X' Y') (ap (∧-fmap f g) (smgluer y)) ◃∎ =ₛ⟨ ap-seq-=ₛ (∧-swap X' Y') (∧-fmap-smgluer-β f g y) ⟩ ap (∧-swap X' Y') (ap (λ x' → smin x' (fst g y)) (snd f)) ◃∙ ap (∧-swap X' Y') (∧-norm-r (fst g y)) ◃∎ =ₛ₁⟨ 0 & 1 & ∘-ap (∧-swap X' Y') (λ x' → smin x' (fst g y)) (snd f) ⟩ ap (smin (fst g y)) (snd f) ◃∙ ap (∧-swap X' Y') (∧-norm-r (fst g y)) ◃∎ =ₛ₁⟨ 1 & 1 & ∧-swap-norm-r-β X' Y' (fst g y) ⟩ ap (smin (fst g y)) (snd f) ◃∙ ∧-norm-l (fst g y) ◃∎ =ₛ⟨ 1 & 1 & expand (∧-norm-l-seq (fst g y)) ⟩ ap (smin (fst g y)) (snd f) ◃∙ smgluel (fst g y) ◃∙ ! (smgluel (pt Y')) ◃∎ =ₛ⟨ 2 & 0 & !ₛ (seq-!-inv-l (smgluel (fst g (pt Y)) ◃∎)) ⟩ ap (smin (fst g y)) (snd f) ◃∙ smgluel (fst g y) ◃∙ ! (smgluel (fst g (pt Y))) ◃∙ smgluel (fst g (pt Y)) ◃∙ ! (smgluel (pt Y')) ◃∎ =ₛ₁⟨ 3 & 2 & ! (ap-null-homotopic (λ y' → smin y' (pt X')) smgluel (snd g)) ⟩ ap (smin (fst g y)) (snd f) ◃∙ smgluel (fst g y) ◃∙ ! (smgluel (fst g (pt Y))) ◃∙ ap (λ y' → smin y' (pt X')) (snd g) ◃∎ =ₛ⟨ 3 & 0 & !ₛ (seq-!-inv-l (ap (smin (fst g (pt Y))) (snd f) ◃∎)) ⟩ ap (smin (fst g y)) (snd f) ◃∙ smgluel (fst g y) ◃∙ ! (smgluel (fst g (pt Y))) ◃∙ ! (ap (smin (fst g (pt Y))) (snd f)) ◃∙ ap (smin (fst g (pt Y))) (snd f) ◃∙ ap (λ y' → smin y' (pt X')) (snd g) ◃∎ =ₛ⟨ 4 & 2 & !ₛ (ap2-out' smin (snd g) (snd f)) ⟩ ap (smin (fst g y)) (snd f) ◃∙ smgluel (fst g y) ◃∙ ! (smgluel (fst g (pt Y))) ◃∙ ! (ap (smin (fst g (pt Y))) (snd f)) ◃∙ ap2 smin (snd g) (snd f) ◃∎ =ₛ⟨ 0 & 4 & !ₛ (∧-fmap-norm-l g f y) ⟩ ap (∧-fmap g f) (∧-norm-l y) ◃∙ ap2 smin (snd g) (snd f) ◃∎ =ₛ₁⟨ 0 & 1 & ! (ap (ap (∧-fmap g f)) (SmashSwap.smgluer-β X Y y)) ⟩ ap (∧-fmap g f) (ap (∧-swap X Y) (smgluer y)) ◃∙ ap2 smin (snd g) (snd f) ◃∎ =ₛ₁⟨ 0 & 1 & ∘-ap (∧-fmap g f) (∧-swap X Y) (smgluer y) ⟩ ap (∧-fmap g f ∘ ∧-swap X Y) (smgluer y) ◃∙ ap2 smin (snd g) (snd f) ◃∎ ∎ₛ) ⊙∧-swap-naturality : ⊙∧-fmap g f ⊙∘ ⊙∧-swap X Y == ⊙∧-swap X' Y' ⊙∘ ⊙∧-fmap f g ⊙∧-swap-naturality = ⊙λ=' ∧-swap-naturality $ =ₛ-out $ ap2 smin (snd g) (snd f) ◃∎ =ₛ⟨ ap2-out smin (snd g) (snd f) ⟩ ap (λ u → smin u (fst f (pt X))) (snd g) ◃∙ ap (smin (pt Y')) (snd f) ◃∎ =ₛ⟨ !ₛ $ ap2-out' (λ x y → smin y x) (snd f) (snd g) ⟩ ap2 (λ x y → smin y x) (snd f) (snd g) ◃∎ =ₛ₁⟨ ! $ ap-ap2 (∧-swap X' Y') smin (snd f) (snd g) ⟩ ap (∧-swap X' Y') (ap2 smin (snd f) (snd g)) ◃∎ =ₛ⟨ 1 & 0 & contract ⟩ ap (∧-swap X' Y') (ap2 smin (snd f) (snd g)) ◃∙ idp ◃∎ ∎ₛ ∧-swap-fmap : ∀ xy → ∧-swap Y' X' (∧-fmap g f (∧-swap X Y xy)) == ∧-fmap f g xy ∧-swap-fmap xy = ∧-swap Y' X' (∧-fmap g f (∧-swap X Y xy)) =⟨ ap (∧-swap Y' X') (∧-swap-naturality xy) ⟩ ∧-swap Y' X' (∧-swap X' Y' (∧-fmap f g xy)) =⟨ ∧-swap-inv X' Y' (∧-fmap f g xy) ⟩ ∧-fmap f g xy =∎
{ "alphanum_fraction": 0.4261576971, "avg_line_length": 38.9256410256, "ext": "agda", "hexsha": "96764bfb1e5faf757851c0a9860950a0c459694c", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "core/lib/types/Smash.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "core/lib/types/Smash.agda", "max_line_length": 156, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "core/lib/types/Smash.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": 15141, "size": 30362 }
-- Testing parameterised records in parameterised modules module Exist (X : Set) where data [_] (a : Set) : Set where [] : [ a ] _∷_ : a -> [ a ] -> [ a ] map : forall {a b} -> (a -> b) -> [ a ] -> [ b ] map f [] = [] map f (x ∷ xs) = f x ∷ map f xs record ∃ (a : Set) (P : a -> Set) : Set where field witness : a proof : P witness ListP : (a : Set) -> (a -> Set) -> Set ListP a P = [ ∃ a P ] mapP : forall {a b P Q} -> (f : a -> b) -> (forall {x} -> P x -> Q (f x)) -> ListP a P -> ListP b Q mapP {a} {b} {P} {Q} f pres xs = map helper xs where helper : ∃ a P -> ∃ b Q helper r = record { witness = f (∃.witness r) ; proof = pres (∃.proof r) }
{ "alphanum_fraction": 0.4517906336, "avg_line_length": 24.2, "ext": "agda", "hexsha": "aea3fc8ea2ab7707e1da32a9a518734d3f13f070", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Exist.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Exist.agda", "max_line_length": 57, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/Exist.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 273, "size": 726 }
{-# OPTIONS --without-K --safe #-} open import Relation.Binary using (Rel; Setoid; IsEquivalence) module Structures {a ℓ} {A : Set a} -- The underlying set (_≈_ : Rel A ℓ) -- The underlying equality relation where open import Algebra.Core open import Level using (_⊔_) open import Data.Product using (_,_; proj₁; proj₂) open import Algebra.Definitions _≈_ open import Algebra.Structures _≈_ open import Definitions _≈_ ------------------------------------------------------------------------ -- Structures with 1 binary operation ------------------------------------------------------------------------ record IsLatinQuasigroup (∙ : Op₂ A ) : Set (a ⊔ ℓ) where field isMagma : IsMagma ∙ latinSquare : LatinSquare ∙ open IsMagma isMagma public latinSquare₁ : LatinSquare₁ ∙ latinSquare₁ = proj₁ latinSquare latinSquare₂ : LatinSquare₂ ∙ latinSquare₂ = proj₂ latinSquare record IsIdempotentMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where field isMagma : IsMagma ∙ idem : Idempotent ∙ open IsMagma isMagma public record IsAlternateMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where field isMagma : IsMagma ∙ alter : Alternative ∙ open IsMagma isMagma public record IsFlexibleMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where field isMagma : IsMagma ∙ flex : Flexible ∙ open IsMagma isMagma public record IsMedialMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where field isMagma : IsMagma ∙ medial : Medial ∙ open IsMagma isMagma public record IsSemimedialMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where field isMagma : IsMagma ∙ semiMedial : Semimedial ∙ open IsMagma isMagma public record IsInverseSemigroup (∙ : Op₂ A) : Set (a ⊔ ℓ) where field isSemigroup : IsSemigroup ∙ pseudoInverse : PseudoInverse ∙ open IsSemigroup isSemigroup public ------------------------------------------------------------------------ -- Structures with 1 binary operation and 1 element ------------------------------------------------------------------------ record IsLeftUnitalMagma (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where field isMagma : IsMagma ∙ identity : LeftIdentity ε ∙ open IsMagma isMagma public record IsRightUnitalMagma (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where field isMagma : IsMagma ∙ identity : RightIdentity ε ∙ open IsMagma isMagma public ------------------------------------------------------------------------ -- Structures with 2 binary operations, 1 unary operation & 1 element ------------------------------------------------------------------------ record IsNonAssociativeRing (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where field +-isAbelianGroup : IsAbelianGroup + 0# -_ *-cong : Congruent₂ * identity : Identity 1# * distrib : * DistributesOver + zero : Zero 0# * open IsAbelianGroup +-isAbelianGroup public renaming ( assoc to +-assoc ; ∙-cong to +-cong ; ∙-congˡ to +-congˡ ; ∙-congʳ to +-congʳ ; identity to +-identity ; identityˡ to +-identityˡ ; identityʳ to +-identityʳ ; inverse to -‿inverse ; inverseˡ to -‿inverseˡ ; inverseʳ to -‿inverseʳ ; ⁻¹-cong to -‿cong ; comm to +-comm ; isMagma to +-isMagma ; isSemigroup to +-isSemigroup ; isMonoid to +-isMonoid ; isUnitalMagma to +-isUnitalMagma ; isCommutativeMagma to +-isCommutativeMagma ; isCommutativeMonoid to +-isCommutativeMonoid ; isCommutativeSemigroup to +-isCommutativeSemigroup ; isInvertibleMagma to +-isInvertibleMagma ; isInvertibleUnitalMagma to +-isInvertibleUnitalMagma ; isGroup to +-isGroup ) *-isMagma : IsMagma * *-isMagma = record { isEquivalence = isEquivalence ; ∙-cong = *-cong } *-identityˡ : LeftIdentity 1# * *-identityˡ = proj₁ identity *-identityʳ : RightIdentity 1# * *-identityʳ = proj₂ identity ------------------------------------------------------------------------ -- Structures with 3 binary operation and 1 element ------------------------------------------------------------------------ record IsLeftBolLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where field isLoop : IsLoop ∙ \\ // ε leftBol : LeftBol ∙ open IsLoop isLoop public record IsRightBolLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where field isLoop : IsLoop ∙ \\ // ε rightBol : RightBol ∙ open IsLoop isLoop public record IsMoufangLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where field isLoop : IsLoop ∙ \\ // ε moufangIdentity : MoufangIdentity₁ ∙ moufangIdentity₂ : MoufangIdentity₂ ∙ moufangIdentity₃ : MoufangIdentity₃ ∙ moufangIdentity₄ : MoufangIdentity₄ ∙ open IsLoop isLoop public record IsPique (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where field isQuasigroup : IsQuasigroup ∙ \\ // idem : Idempotent ∙ open IsQuasigroup isQuasigroup public
{ "alphanum_fraction": 0.537531196, "avg_line_length": 29.4293785311, "ext": "agda", "hexsha": "023236c273f4c8a4777cff09afa65fd68a86e543", "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": "72030f78934877ad67bf4e36e74e43845cabbf55", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Akshobhya1234/Agda-Algebra", "max_forks_repo_path": "src/Structures.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "72030f78934877ad67bf4e36e74e43845cabbf55", "max_issues_repo_issues_event_max_datetime": "2022-01-31T18:19:52.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-02T20:50:34.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Akshobhya1234/Agda-Algebra", "max_issues_repo_path": "src/Structures.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "72030f78934877ad67bf4e36e74e43845cabbf55", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Akshobhya1234/Agda-Algebra", "max_stars_repo_path": "src/Structures.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1587, "size": 5209 }
-- Andreas, 2016-10-04, issue #2236 -- Result splitting should not insert hidden arguments visibly -- {-# OPTIONS -v interaction.case:100 #-} -- {-# OPTIONS -v tc.cover:100 #-} -- {-# OPTIONS -v reify.clause:100 #-} -- {-# OPTIONS -v reify.implicit:100 #-} splitMe : (A : Set) {B : Set} → Set splitMe = {!!} -- C-c C-c RET inserts hidden {B} splitMe' : (A : Set) {B : Set} (C : Set) {D : Set} → Set splitMe' = {!!} -- C-c C-c RET inserts hidden {B} and {D} splitMe'' : {B : Set} (C : Set) {D : Set} → Set splitMe'' = {!!} -- C-c C-c RET inserts hidden {D} postulate N : Set P : N → Set test : (A : Set) → ∀ {n} → P n → Set test = {!!} -- C-c C-c RET inserts hidden {n} -- Correct is: -- No hidden arguments inserted on lhs.
{ "alphanum_fraction": 0.5636856369, "avg_line_length": 27.3333333333, "ext": "agda", "hexsha": "c249a087281b3b75f37406df20b8d9defcaf12d5", "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/Issue2236.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/Issue2236.agda", "max_line_length": 62, "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/Issue2236.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": 256, "size": 738 }
{-# OPTIONS --without-K --exact-split --safe #-} open import Fragment.Algebra.Signature module Fragment.Algebra.Free.Base (Σ : Signature) where open import Fragment.Algebra.Algebra Σ open import Fragment.Algebra.Free.Atoms public open import Level using (Level; _⊔_) open import Function using (_∘_) open import Data.Empty using (⊥) open import Data.Nat using (ℕ) open import Data.Fin using (Fin) open import Data.Vec using (Vec; []; _∷_) open import Data.Vec.Relation.Binary.Pointwise.Inductive using (Pointwise; []; _∷_) open import Relation.Binary using (Setoid; IsEquivalence) open import Relation.Binary.PropositionalEquality as PE using (_≡_) private variable a ℓ : Level module _ (A : Set a) where data Term : Set a where atom : A → Term term : ∀ {arity} → (f : ops Σ arity) → Vec Term arity → Term module _ (S : Setoid a ℓ) where open Setoid S renaming (Carrier to A) data _~_ : Term A → Term A → Set (a ⊔ ℓ) where atom : ∀ {x y} → x ≈ y → atom x ~ atom y term : ∀ {arity xs ys} {f : ops Σ arity} → Pointwise _~_ xs ys → term f xs ~ term f ys private mutual map-~-refl : ∀ {n} {xs : Vec _ n} → Pointwise _~_ xs xs map-~-refl {xs = []} = [] map-~-refl {xs = x ∷ xs} = ~-refl ∷ map-~-refl ~-refl : ∀ {x} → x ~ x ~-refl {atom _} = atom refl ~-refl {term _ _} = term map-~-refl mutual map-~-sym : ∀ {n} {xs ys : Vec _ n} → Pointwise _~_ xs ys → Pointwise _~_ ys xs map-~-sym [] = [] map-~-sym (x≈y ∷ xs≈ys) = ~-sym x≈y ∷ map-~-sym xs≈ys ~-sym : ∀ {x y} → x ~ y → y ~ x ~-sym (atom x≈y) = atom (sym x≈y) ~-sym (term xs≈ys) = term (map-~-sym xs≈ys) mutual map-~-trans : ∀ {n} {xs ys zs : Vec _ n} → Pointwise _~_ xs ys → Pointwise _~_ ys zs → Pointwise _~_ xs zs map-~-trans [] [] = [] map-~-trans (x≈y ∷ xs≈ys) (y≈z ∷ ys≈zs) = ~-trans x≈y y≈z ∷ map-~-trans xs≈ys ys≈zs ~-trans : ∀ {x y z} → x ~ y → y ~ z → x ~ z ~-trans (atom x≈y) (atom y≈z) = atom (trans x≈y y≈z) ~-trans (term xs≈ys) (term ys≈zs) = term (map-~-trans xs≈ys ys≈zs) ~-isEquivalence : IsEquivalence _~_ ~-isEquivalence = record { refl = ~-refl ; sym = ~-sym ; trans = ~-trans } Herbrand : Setoid _ _ Herbrand = record { Carrier = Term A ; _≈_ = _~_ ; isEquivalence = ~-isEquivalence } Free : Algebra Free = record { ∥_∥/≈ = Herbrand ; ∥_∥/≈-isAlgebra = Free-isAlgebra } where term-cong : Congruence Herbrand term term-cong f p = term p Free-isAlgebra : IsAlgebra Herbrand Free-isAlgebra = record { ⟦_⟧ = term ; ⟦⟧-cong = term-cong } F : ℕ → Algebra F = Free ∘ Atoms (PE.setoid ⊥)
{ "alphanum_fraction": 0.4960025584, "avg_line_length": 29.2242990654, "ext": "agda", "hexsha": "bf03eae1905e0f8c12f3e1cebd89bb81e29a41e4", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Algebra/Free/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Algebra/Free/Base.agda", "max_line_length": 67, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Algebra/Free/Base.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "num_tokens": 1042, "size": 3127 }
-- 2011-09-14 posted by Nisse -- Andreas: this failed since SubstHH for Telescopes was wrong. -- {-# OPTIONS --show-implicit -v tc.lhs.unify:15 #-} module Issue292-14 where data D : Set where d : D postulate T : D → D → Set data T′ (x y : D) : Set where c : T x y → T′ x y F : D → D → Set F x d = T′ x d -- blocking unfolding of F x y record [F] : Set where field x y : D f : F x y -- T′ x y works data _≡_ (x : [F]) : [F] → Set where refl : x ≡ x Foo : ∀ {x} {t₁ t₂ : T x d} → record { f = c t₁ } ≡ record { f = c t₂ } → Set₁ Foo refl = Set
{ "alphanum_fraction": 0.5460869565, "avg_line_length": 20.5357142857, "ext": "agda", "hexsha": "41942a400ae45bab6f04d1d8f5ae106ae6e8bf81", "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/Issue292-14.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/Issue292-14.agda", "max_line_length": 63, "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/Issue292-14.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": 230, "size": 575 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} {-# OPTIONS --type-in-type #-} -- Note: Using this module is discouraged unless absolutely necessary. -- Use `Data.Product` or `Data.Both` instead. module Light.Indexed where open import Light.Level using (Level) postulate ℓ : Level record Indexed {aℓ} (𝕒 : Set aℓ) {aℓf : 𝕒 → Level} (𝕓 : ∀ a → Set (aℓf a)) : Set ℓ where constructor indexed field index : 𝕒 field thing : 𝕓 index open Indexed public
{ "alphanum_fraction": 0.6772908367, "avg_line_length": 29.5294117647, "ext": "agda", "hexsha": "4c516ae997489838fbb11fcf8b138f19c2210765", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "Light/Indexed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "Light/Indexed.agda", "max_line_length": 88, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "Light/Indexed.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 148, "size": 502 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Group.Action where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Structure open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Morphism open import Cubical.Algebra.Group.Properties open import Cubical.Algebra.Group.Notation open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Structures.LeftAction open import Cubical.Structures.Axioms open import Cubical.Structures.Macro open import Cubical.Structures.Auto open import Cubical.Data.Sigma private variable ℓ ℓ' : Level record IsGroupAction (G : Group {ℓ = ℓ}) (H : Group {ℓ = ℓ'}) (_α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩) : Type (ℓ-max ℓ ℓ') where constructor isgroupaction open GroupNotationG G field isHom : (g : ⟨ G ⟩) → isGroupHom H H (g α_) identity : (h : ⟨ H ⟩) → 0ᴳ α h ≡ h assoc : (g g' : ⟨ G ⟩) → (h : ⟨ H ⟩) → (g +ᴳ g') α h ≡ g α (g' α h) record GroupAction (G : Group {ℓ}) (H : Group {ℓ'}): Type (ℓ-suc (ℓ-max ℓ ℓ')) where constructor groupaction field _α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩ isGroupAction : IsGroupAction G H _α_ module ActionΣTheory {ℓ ℓ' : Level} where module _ (G : Group {ℓ}) (H : Group {ℓ'}) (_α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩) where open GroupNotationG G IsGroupActionΣ : Type (ℓ-max ℓ ℓ') IsGroupActionΣ = ((g : ⟨ G ⟩) → isGroupHom H H (g α_)) × ((h : ⟨ H ⟩) → 0ᴳ α h ≡ h) × ((g g' : ⟨ G ⟩) → (h : ⟨ H ⟩) → (g +ᴳ g') α h ≡ g α (g' α h)) isPropIsGroupActionΣ : isProp IsGroupActionΣ isPropIsGroupActionΣ = isPropΣ isPropIsHom λ _ → isPropΣ isPropIdentity λ _ → isPropAssoc where isPropIsHom = isPropΠ (λ g → isPropIsGroupHom H H) isPropIdentity = isPropΠ (λ h → GroupStr.is-set (snd H) (0ᴳ α h) h) isPropAssoc = isPropΠ3 (λ g g' h → GroupStr.is-set (snd H) ((g +ᴳ g') α h) (g α (g' α h))) IsGroupAction→IsGroupActionΣ : IsGroupAction G H _α_ → IsGroupActionΣ IsGroupAction→IsGroupActionΣ (isgroupaction isHom identity assoc) = isHom , identity , assoc IsGroupActionΣ→IsGroupAction : IsGroupActionΣ → IsGroupAction G H _α_ IsGroupActionΣ→IsGroupAction (isHom , identity , assoc) = isgroupaction isHom identity assoc IsGroupActionΣIso : Iso (IsGroupAction G H _α_) IsGroupActionΣ Iso.fun IsGroupActionΣIso = IsGroupAction→IsGroupActionΣ Iso.inv IsGroupActionΣIso = IsGroupActionΣ→IsGroupAction Iso.rightInv IsGroupActionΣIso = λ _ → refl Iso.leftInv IsGroupActionΣIso = λ _ → refl open ActionΣTheory isPropIsGroupAction : {ℓ ℓ' : Level } (G : Group {ℓ}) (H : Group {ℓ'}) (_α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩) → isProp (IsGroupAction G H _α_) isPropIsGroupAction G H _α_ = isOfHLevelRespectEquiv 1 (invEquiv (isoToEquiv (IsGroupActionΣIso G H _α_))) (isPropIsGroupActionΣ G H _α_) module ActionNotationα {N : Group {ℓ}} {H : Group {ℓ'}} (Act : GroupAction H N) where _α_ = GroupAction._α_ Act private isGroupAction = GroupAction.isGroupAction Act α-id = IsGroupAction.identity isGroupAction α-hom = IsGroupAction.isHom isGroupAction α-assoc = IsGroupAction.assoc isGroupAction module ActionLemmas {G : Group {ℓ}} {H : Group {ℓ'}} (Act : GroupAction G H) where open ActionNotationα {N = H} {H = G} Act open GroupNotationᴴ H open GroupNotationG G open MorphismLemmas {G = H} {H = H} open GroupLemmas abstract actOnUnit : (g : ⟨ G ⟩) → g α 0ᴴ ≡ 0ᴴ actOnUnit g = mapId (grouphom (g α_) (α-hom g)) actOn-Unit : (g : ⟨ G ⟩) → g α (-ᴴ 0ᴴ) ≡ 0ᴴ actOn-Unit g = (cong (g α_) (invId H)) ∙ actOnUnit g actOn- : (g : ⟨ G ⟩) (h : ⟨ H ⟩) → g α (-ᴴ h) ≡ -ᴴ (g α h) actOn- g h = mapInv (grouphom (g α_) (α-hom g)) h -idAct : (h : ⟨ H ⟩) → (-ᴳ 0ᴳ) α h ≡ h -idAct h = (cong (_α h) (invId G)) ∙ (α-id h) -- Examples -- left adjoint action of a group on a normal subgroup
{ "alphanum_fraction": 0.6263378315, "avg_line_length": 36.735042735, "ext": "agda", "hexsha": "655ec4a63580e18d0699a3b2e78dd35b45bb1cab", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/Action.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/Action.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/Action.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1511, "size": 4298 }
{- This file contains: - Properties of set truncations -} {-# OPTIONS --cubical --safe #-} module Cubical.HITs.SetTruncation.Properties where open import Cubical.HITs.SetTruncation.Base open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels private variable ℓ : Level A : Type ℓ -- lemma 6.9.1 in HoTT book elim : {B : ∥ A ∥₀ → Type ℓ} → (Bset : (x : ∥ A ∥₀) → isSet (B x)) → (g : (a : A) → B (∣ a ∣₀)) → (x : ∥ A ∥₀) → B x elim Bset g ∣ a ∣₀ = g a elim {A = A} {B = B} Bset g (squash₀ x y p q i j) = isOfHLevel→isOfHLevelDep 2 Bset _ _ (cong (elim Bset g) p) (cong (elim Bset g) q) (squash₀ x y p q) i j setTruncUniversal : {B : Type ℓ} → (isSet B) → (∥ A ∥₀ → B) ≃ (A → B) setTruncUniversal Bset = isoToEquiv (iso intro out leftInv rightInv) where intro = (λ h a → h ∣ a ∣₀) out = elim (λ x → Bset) leftInv : ∀ g → intro (out g) ≡ g leftInv g = refl rightInv : ∀ h → out (intro h) ≡ h rightInv h i x = elim (λ x → isProp→isSet (Bset (out (intro h) x) (h x))) (λ a → refl) x i elim2 : {B : ∥ A ∥₀ → ∥ A ∥₀ → Type ℓ} (Bset : ((x y : ∥ A ∥₀) → isSet (B x y))) (g : (a b : A) → B ∣ a ∣₀ ∣ b ∣₀) (x y : ∥ A ∥₀) → B x y elim2 Bset g = elim (λ _ → isOfHLevelPi 2 (λ _ → Bset _ _)) (λ a → elim (λ _ → Bset _ _) (λ b → g a b)) elim3 : {B : (x y z : ∥ A ∥₀) → Type ℓ} (Bset : ((x y z : ∥ A ∥₀) → isSet (B x y z))) (g : (a b c : A) → B ∣ a ∣₀ ∣ b ∣₀ ∣ c ∣₀) (x y z : ∥ A ∥₀) → B x y z elim3 Bset g = elim2 (λ _ _ → isOfHLevelPi 2 λ _ → Bset _ _ _) (λ a b → elim (λ _ → Bset _ _ _) (λ c → g a b c)) setTruncIsSet : isSet ∥ A ∥₀ setTruncIsSet a b p q = squash₀ a b p q setId : isSet A → ∥ A ∥₀ ≡ A setId {A = A} isset = isoToPath (iso (elim {A = A} (λ _ → isset) (λ x → x)) (λ x → ∣ x ∣₀) (λ b → refl) (λ b → idLemma b)) where idLemma : ∀ (b : ∥ A ∥₀) → ∣ elim (λ x → isset) (λ x → x) b ∣₀ ≡ b idLemma b = elim {B = (λ x → ∣ elim (λ _ → isset) (λ x → x) x ∣₀ ≡ x)} (λ x → isOfHLevelSuc 2 (setTruncIsSet {A = A}) ∣ elim (λ _ → isset) (λ x₁ → x₁) x ∣₀ x) (λ _ → refl) b
{ "alphanum_fraction": 0.5345303867, "avg_line_length": 28.96, "ext": "agda", "hexsha": "a9f795e55c8c9720eb1748b9f7d4f4b1acdc0f04", "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/SetTruncation/Properties.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/SetTruncation/Properties.agda", "max_line_length": 102, "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/SetTruncation/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 993, "size": 2172 }
{-# OPTIONS --without-K #-} open import Base open import Homotopy.TruncatedHIT open import Spaces.Spheres open import Integers module Sets.Quotient {i j} (A : Set i) ⦃ p : is-set A ⦄ (R : A → A → Set j) ⦃ q : (x y : A) → is-prop (R x y) ⦄ where private data _#/_ : Set (max i j) where #proj : A → _#/_ #top : (f : hSⁿ ⟨0⟩ → _#/_) → _#/_ _/_ : Set (max i j) _/_ = _#/_ proj : A → _/_ proj = #proj postulate -- HIT eq : (x y : A) (p : R x y) → proj x ≡ proj y top : (f : hSⁿ ⟨0⟩ → _/_) → _/_ top = #top postulate -- HIT rays : (f : hSⁿ ⟨0⟩ → _/_) (x : hSⁿ ⟨0⟩) → top f ≡ f x #/-rec : ∀ {k} (P : _/_ → Set k) (proj* : (x : A) → P (proj x)) (eq* : (x y : A) (p : R x y) → transport P (eq x y p) (proj* x) ≡ proj* y) (top* : (f : hSⁿ ⟨0⟩ → _/_) (p : (x : hSⁿ ⟨0⟩) → P (f x)) → P (top f)) (rays* : (f : hSⁿ ⟨0⟩ → _/_) (p : (x : hSⁿ ⟨0⟩) → P (f x)) (x : hSⁿ ⟨0⟩) → transport P (rays f x) (top* f p) ≡ p x) → ((t : _/_) → P t) #/-rec P proj* eq* top* rays* (#proj x) = proj* x #/-rec P proj* eq* top* rays* (#top f) = top* f (λ x → #/-rec P proj* eq* top* rays* (f x)) #/-rec-nondep : ∀ {k} (B : Set k) (proj* : A → B) (eq* : (x y : A) (p : R x y) → proj* x ≡ proj* y) (top* : (f : hSⁿ ⟨0⟩ → _/_) (p : hSⁿ ⟨0⟩ → B) → B) (rays* : (f : hSⁿ ⟨0⟩ → _/_) (p : hSⁿ ⟨0⟩ → B) (x : hSⁿ ⟨0⟩) → top* f p ≡ p x) → (_/_ → B) #/-rec-nondep B proj* eq* top* rays* (#proj x) = proj* x #/-rec-nondep B proj* eq* top* rays* (#top f) = top* f (λ x → #/-rec-nondep B proj* eq* top* rays* (f x)) /-rec : ∀ {k} (P : _/_ → Set k) (proj* : (x : A) → P (proj x)) (eq* : (x y : A) (p : R x y) → transport P (eq x y p) (proj* x) ≡ proj* y) (trunc : (x : _/_) → is-set (P x)) → ((t : _/_) → P t) /-rec P proj* eq* trunc = #/-rec P proj* eq* (λ f p₁ → π₁ (u f p₁)) (λ f p₁ → π₂ (u f p₁)) where u : _ u = truncated-has-filling-dep _/_ P ⟨0⟩ (λ ()) (λ f → (top f , rays f)) /-rec-nondep : ∀ {k} (B : Set k) (proj* : A → B) (eq* : (x y : A) (p : R x y) → proj* x ≡ proj* y) (trunc : is-set B) → (_/_ → B) /-rec-nondep B proj* eq* trunc = #/-rec-nondep B proj* eq* (λ _ p → π₁ (u p)) (λ _ p → π₂ (u p)) where u : _ u = truncated-has-spheres-filled ⟨0⟩ _ trunc -- Reduction rules for paths are not needed
{ "alphanum_fraction": 0.4343141318, "avg_line_length": 31.3376623377, "ext": "agda", "hexsha": "c188e91e931b3864662318e6520d8ff56cf98a4c", "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/Sets/Quotient.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/Sets/Quotient.agda", "max_line_length": 80, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/Sets/Quotient.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": 1065, "size": 2413 }
{-# OPTIONS --allow-unsolved-metas #-} -- When instantiating metas, we can't ignore variables occurring in -- irrelevant terms. If we do the irrelevant terms will become illformed -- (and we get __IMPOSSIBLE__s) -- For instance -- _42 := DontCare (Just (Var 0 [])) -- is a bad thing to do. In the example below we hit the __IMPOSSIBLE__ in -- the rename function in TypeChecking.MetaVars.assign. module DontIgnoreIrrelevantVars where import Common.Level import Common.Irrelevance record Category : Set₁ where field .Arr : Set postulate C : Category _∙_ : ∀ {A : Set} {B : A → Set} {C : Set} → (∀ {x} → B x → C) → (g : ∀ x → B x) → A → C f ∙ g = λ x → f (g x) Exp : (I : Set) → Category Exp I = record { Arr = I → Category.Arr C } postulate Functor : Category → Set postulate flattenP : ∀ D → Functor D → Functor D flattenHʳ : ∀ J → Functor (Exp J) → Functor (Exp J) flattenH : ∀ I → Functor (Exp I) → Functor (Exp I) flattenH I = flattenHʳ _ ∙ flattenP _
{ "alphanum_fraction": 0.6534552846, "avg_line_length": 26.5945945946, "ext": "agda", "hexsha": "6f9ac3fa996e0b58d3cb9d3ed05dcb4fe2b89eaa", "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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Succeed/DontIgnoreIrrelevantVars.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/DontIgnoreIrrelevantVars.agda", "max_line_length": 74, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/DontIgnoreIrrelevantVars.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": 313, "size": 984 }
module Categories.Support.Experimental where open import Relation.Binary.PropositionalEquality.TrustMe open import Categories.Support.PropositionalEquality ≣-relevant : ∀ {l} {A : Set l} {X Y : A} -> .(X ≣ Y) -> X ≣ Y ≣-relevant _ = trustMe private ≣-coe : ∀ {a} {A B : Set a} → (A ≣ B) -> A -> B ≣-coe ≣-refl a = a ≣-subst′ : ∀ {a p} {A : Set a} → (P : A -> Set p) -> {x y : A} -> .(x ≣ y) -> P x -> P y ≣-subst′ P eq Px = ≣-coe (≣-relevant (≣-cong P eq)) Px
{ "alphanum_fraction": 0.5628997868, "avg_line_length": 29.3125, "ext": "agda", "hexsha": "0af5c856f5703983954a9531c6df4d9b4dcc3b44", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Support/Experimental.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Support/Experimental.agda", "max_line_length": 88, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Support/Experimental.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 193, "size": 469 }
{-# OPTIONS --without-K --safe #-} open import Polynomial.Parameters module Polynomial.NormalForm.Construction {a ℓ} (coeffs : RawCoeff a ℓ) where open import Relation.Nullary using (Dec; yes; no) open import Level using (lift; lower; _⊔_) open import Data.Unit using (tt) open import Data.List using (_∷_; []; List; foldr) open import Data.Nat as ℕ using (ℕ; suc; zero) open import Data.Nat.Properties using (z≤′n) open import Data.Product using (_×_; _,_; map₁; curry; uncurry) open import Data.Maybe using (just; nothing) open import Data.Bool using (if_then_else_; true; false) open import Function open import Polynomial.NormalForm.InjectionIndex open import Polynomial.NormalForm.Definition coeffs open RawCoeff coeffs ---------------------------------------------------------------------- -- Construction -- -- Because the polynomial is stored in a canonical form, we use a -- normalising cons operator to construct the coefficient lists. ---------------------------------------------------------------------- -- Decision procedure for Zero zero? : ∀ {n} → (p : Poly n) → Dec (Zero p) zero? (Σ _ Π _) = no (λ z → z) zero? (Κ x Π _) with Zero-C x ... | true = yes tt ... | false = no (λ z → z) {-# INLINE zero? #-} -- Exponentiate the first variable of a polynomial infixr 8 _⍓*_ _⍓+_ _⍓*_ : ∀ {n} → Coeff n * → ℕ → Coeff n * _⍓+_ : ∀ {n} → Coeff n + → ℕ → Coeff n + [] ⍓* _ = [] (∹ xs) ⍓* i = ∹ xs ⍓+ i coeff (head (xs ⍓+ i)) = coeff (head xs) pow (head (xs ⍓+ i)) = pow (head xs) ℕ.+ i tail (xs ⍓+ i) = tail xs infixr 5 _∷↓_ _∷↓_ : ∀ {n} → PowInd (Poly n) → Coeff n * → Coeff n * x Δ i ∷↓ xs = case zero? x of λ { (yes p) → xs ⍓* suc i ; (no ¬p) → ∹ _≠0 x {¬p} Δ i & xs } {-# INLINE _∷↓_ #-} -- Inject a polynomial into a larger polynomoial with more variables _Π↑_ : ∀ {n m} → Poly n → (suc n ≤′ m) → Poly m (xs Π i≤n) Π↑ n≤m = xs Π (≤′-step i≤n ⟨ ≤′-trans ⟩ n≤m) {-# INLINE _Π↑_ #-} infixr 4 _Π↓_ _Π↓_ : ∀ {i n} → Coeff i * → suc i ≤′ n → Poly n [] Π↓ i≤n = Κ 0# Π z≤′n (∹ x ≠0 Δ zero & [] ) Π↓ i≤n = x Π↑ i≤n (∹ x Δ zero & ∹ xs) Π↓ i≤n = Σ (x Δ zero & ∹ xs) Π i≤n (∹ x Δ suc j & xs ) Π↓ i≤n = Σ (x Δ suc j & xs) Π i≤n {-# INLINE _Π↓_ #-} -------------------------------------------------------------------------------- -- These folds allow us to abstract over the proofs later: we try to avoid -- using ∷↓ and Π↓ directly anywhere except here, so if we prove that this fold -- acts the same on a normalised or non-normalised polynomial, we can prove th -- same about any operation which uses it. PolyF : ℕ → Set a PolyF i = Poly i × Coeff i * Fold : ℕ → Set a Fold i = PolyF i → PolyF i para : ∀ {i} → Fold i → Coeff i + → Coeff i * para f (x ≠0 Δ i & []) = case f (x , []) of λ { (y , ys) → y Δ i ∷↓ ys } para f (x ≠0 Δ i & ∹ xs) = case f (x , para f xs) of λ { (y , ys) → y Δ i ∷↓ ys } poly-map : ∀ {i} → (Poly i → Poly i) → Coeff i + → Coeff i * poly-map f = para (λ { (x , y) → (f x , y)}) {-# INLINE poly-map #-}
{ "alphanum_fraction": 0.5226615236, "avg_line_length": 33.4516129032, "ext": "agda", "hexsha": "953962552902040173d90cff336bde125e59bfe2", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_path": "src/Polynomial/NormalForm/Construction.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_path": "src/Polynomial/NormalForm/Construction.agda", "max_line_length": 81, "max_stars_count": 36, "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_path": "src/Polynomial/NormalForm/Construction.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "num_tokens": 1077, "size": 3111 }
-- Andreas, 2011-04-14 module UnificationUndecidedForNonStronglyRigidOccurrence where data Nat : Set where zero : Nat suc : Nat -> Nat data _≡_ {A : Set}(a : A) : A -> Set where refl : a ≡ a i : (f : Nat -> Nat)(n : Nat) -> n ≡ f n -> Nat i f n () -- this should fail, since n ≡ f n is not always empty, only in case of f=suc -- thus, an occurrence does not always mean no match, only strict occurrences -- mean that.
{ "alphanum_fraction": 0.6471962617, "avg_line_length": 26.75, "ext": "agda", "hexsha": "fe290ae090f722660e716907776528f9bbccf864", "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/UnificationUndecidedForNonStronglyRigidOccurrence.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/UnificationUndecidedForNonStronglyRigidOccurrence.agda", "max_line_length": 77, "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/UnificationUndecidedForNonStronglyRigidOccurrence.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": 143, "size": 428 }
{-# OPTIONS --safe #-} module JVM.Compiler where open import JVM.Types open import JVM.Syntax.Instructions module _ 𝑭 where open import JVM.Compiler.Monad StackTy ⟨ 𝑭 ∣_↝_⟩ noop using (Compiler) public module _ {𝑭} where open import JVM.Compiler.Monad StackTy ⟨ 𝑭 ∣_↝_⟩ noop hiding (Compiler) public
{ "alphanum_fraction": 0.7394136808, "avg_line_length": 25.5833333333, "ext": "agda", "hexsha": "d3abed2e814fdf6880c95c7bd6834ece31fcefaf", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ajrouvoet/jvm.agda", "max_forks_repo_path": "src/JVM/Compiler.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ajrouvoet/jvm.agda", "max_issues_repo_path": "src/JVM/Compiler.agda", "max_line_length": 80, "max_stars_count": 6, "max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ajrouvoet/jvm.agda", "max_stars_repo_path": "src/JVM/Compiler.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z", "num_tokens": 90, "size": 307 }
open import Data.Nat open import Data.Nat.Properties open import Data.Bool open import Function.Base open import Data.Product -- Sizes are ordinals up to ω, i.e. naturals 𝕊 : Set 𝕊 = ℕ hat : 𝕊 → 𝕊 hat = suc -- Sized naturals and lists indexed by a size data SNat : (k : 𝕊) → Set where SZero : (k : 𝕊) → SNat k SSucc : (k : 𝕊) → SNat k → SNat (hat k) data SList (A : Set) : (k : 𝕊) → Set where SNil : (k : 𝕊) → SList A k SCons : (k : 𝕊) → A → SList A k → SList A (hat k) -- Helpers to shift the size of lists up as needed shift : ∀ {A k} → SList A k → SList A (suc k) shift (SNil k) = SNil (suc k) shift (SCons k hd tl) = SCons (suc k) hd (shift tl) shiftBy : ∀ {A} → (k offset : 𝕊) → SList A k → SList A (k + offset) shiftBy _ offset (SNil k) = SNil (k + offset) shiftBy _ offset (SCons k hd tl) = SCons (k + offset) hd (shiftBy k offset tl) -- Minus and div functions, no unrolling needed -- Minus is size-preserving in the first argument, with an arbitrary second argument size -- Div is the same, also happening to be size-preesrving in the first argument minus : (k l : 𝕊) → SNat k → SNat l → SNat k minus _ _ (SZero k) _ = SZero k minus _ _ k (SZero l) = k minus _ _ (SSucc k n) (SSucc l m) = SSucc k (minus k l n m) div : (k l : 𝕊) → SNat k → SNat l → SNat k div _ _ (SZero k) _ = SZero k div _ _ (SSucc k n) m = SSucc _ (div k _ (minus k _ n m) m) -- Size-preserving filter filter : ∀ {A} → (k : 𝕊) → (A → Bool) → SList A k → SList A k filter zero _ ls = ls filter (suc k) _ (SNil _) = SNil _ filter (suc k) pred (SCons k hd tl) = if (pred hd) then SCons k hd (filter k pred tl) else shift (filter k pred tl) -- Two appends: First one explicitly returns a list whose size is the sum of the input list sizes, -- while the second one returns a list with *some* size, which we don't know is the sum of the sizes append : ∀ {A} → (k l : 𝕊) → SList A k → SList A l → SList A (k + l) append zero _ _ ls = ls append k l (SNil _) ls rewrite (+-comm k l) = shiftBy l k ls append (suc k) l (SCons k hd tl) ls = SCons (k + l) hd (append k l tl ls) append' : ∀ {A} → (k l : 𝕊) → SList A k → SList A l → ∃[ kl ] SList A kl append' zero l _ ls = l , ls append' k l (SNil _) ls = l , ls append' (suc k) l (SCons k hd tl) ls = let kl , kls = append' k l tl ls in suc kl , SCons kl hd kls -- Qsort returning a list of some size -- The most specific size we could give it would probably be exponential qsort : (k : 𝕊) → SList ℕ k → ∃[ k ] (SList ℕ k) qsort zero ls = zero , ls qsort k (SNil _) = k , SNil _ qsort (suc k) (SCons k hd tl) = let k1 , q1 = qsort k (filter k (_<ᵇ hd) tl) k2 , q2 = qsort k (filter k (not ∘ _<ᵇ_ hd) tl) in suc (k1 + k2) , SCons (k1 + k2) hd (append k1 k2 q1 q2) -- Longer example: base 2 logarithm data LogDom : (s : 𝕊) → (p : ℕ) → Set where LogDom1 : (s : 𝕊) → LogDom s (suc zero) LogDom2 : (s : 𝕊) → (p : ℕ) → LogDom s (suc ⌊ p /2⌋) → LogDom (hat s) (suc (suc p)) postulate logdomInv : (s : 𝕊) → (p : ℕ) → LogDom (hat s) (suc (suc p)) → LogDom s (suc ⌊ p /2⌋)
{ "alphanum_fraction": 0.6115321252, "avg_line_length": 33.7222222222, "ext": "agda", "hexsha": "6a1e92ffba61ecc8af886ab8b22d1b5431c6b367", "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": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "ionathanch/msc-thesis", "max_forks_repo_path": "code/InftyPair.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "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": "ionathanch/msc-thesis", "max_issues_repo_path": "code/InftyPair.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "ionathanch/msc-thesis", "max_stars_repo_path": "code/InftyPair.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1203, "size": 3035 }
module Impure.STLCRef.Welltyped where open import Prelude open import Data.Nat open import Data.Vec open import Data.List open import Data.Fin hiding (_<_) open import Extensions.List as L using () open import Impure.STLCRef.Syntax -- store typings World : Set World = List Type _⊢loc_∶_ : World → ℕ → Type → Set Σ ⊢loc i ∶ A = Σ L.[ i ]= A Ctx : (n : ℕ) → Set Ctx n = Vec Type n data _,_⊢_∶_ : ∀ {n} → Ctx n → World → Exp n → Type → Set where unit : ∀ {n} {Γ : Ctx n} {Σ} → --------------------------------------- Γ , Σ ⊢ unit ∶ Unit var : ∀ {n i A} {Γ : Ctx n} {Σ} → Γ [ i ]= A → --------------------------------------- Γ , Σ ⊢ var i ∶ A loc : ∀ {n i A} {Γ : Ctx n} {Σ} → Σ ⊢loc i ∶ A → --------------------------------------- Γ , Σ ⊢ loc i ∶ Ref A ƛ : ∀ {n e A B} {Γ : Ctx n} {Σ} → (A ∷ Γ) , Σ ⊢ e ∶ B → --------------------------------------- Γ , Σ ⊢ (ƛ A e) ∶ (A ⇒ B) _·_ : ∀ {n f x A B} {Γ : Ctx n} {Σ} → Γ , Σ ⊢ f ∶ (A ⇒ B) → Γ , Σ ⊢ x ∶ A → --------------------------------------- Γ , Σ ⊢ (f · x) ∶ B ref : ∀ {n x A} {Γ : Ctx n} {Σ} → Γ , Σ ⊢ x ∶ A → --------------------------------------- Γ , Σ ⊢ ref x ∶ Ref A !_ : ∀ {n x A} {Γ : Ctx n} {Σ} → Γ , Σ ⊢ x ∶ Ref A → --------------------------------------- Γ , Σ ⊢ (! x) ∶ A _≔_ : ∀ {n i x A} {Γ : Ctx n} {Σ} → Γ , Σ ⊢ i ∶ Ref A → Γ , Σ ⊢ x ∶ A → --------------------------------------- Γ , Σ ⊢ (i ≔ x) ∶ Unit open import Relation.Binary.List.Pointwise -- store welltypedness relation -- as a pointwise lifting of the welltyped relation on closed expressions between a world and a store _,_⊢_ : ∀ {n} → Ctx n → World → Store n → Set Γ , Σ ⊢ μ = Rel (λ A x → Γ , Σ ⊢ proj₁ x ∶ A) Σ μ
{ "alphanum_fraction": 0.3650793651, "avg_line_length": 27, "ext": "agda", "hexsha": "6e79c11752b0fb147b98742ac3b7bec6af7c52a0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Impure/STLCRef/Welltyped.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Impure/STLCRef/Welltyped.agda", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Impure/STLCRef/Welltyped.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 709, "size": 1890 }
module STLC.Coquand.Soundness where open import STLC.Coquand.Completeness public -------------------------------------------------------------------------------- -- Un⟦_⟧ postulate ⟦_⟧Un : ∀ {Γ Ξ A} → {ρ : Γ ⊩⋆ Ξ} → (M : Ξ ⊢ A) → Un⋆ ρ → Un (⟦ M ⟧ ρ) -- 𝒰⋆⟦_⟧ₛ postulate ⟦_⟧Un⋆ : ∀ {Γ Ξ Φ} → {ρ : Γ ⊩⋆ Ξ} → (σ : Ξ ⊢⋆ Φ) → Un⋆ ρ → Un⋆ (⟦ σ ⟧⋆ ρ) postulate ⟦_⟧Eq : ∀ {Γ Ξ A} → {ρ₁ ρ₂ : Γ ⊩⋆ Ξ} → (M : Ξ ⊢ A) → Eq⋆ ρ₁ ρ₂ → Un⋆ ρ₁ → Un⋆ ρ₂ → Eq (⟦ M ⟧ ρ₁) (⟦ M ⟧ ρ₂) -- Eq⋆⟦_⟧ₛ postulate ⟦_⟧Eq⋆ : ∀ {Γ Ξ Φ} → {ρ₁ ρ₂ : Γ ⊩⋆ Ξ} → (σ : Ξ ⊢⋆ Φ) → Eq⋆ ρ₁ ρ₂ → Un⋆ ρ₁ → Un⋆ ρ₂ → Eq⋆ (⟦ σ ⟧⋆ ρ₁) (⟦ σ ⟧⋆ ρ₂) -------------------------------------------------------------------------------- -- ⟦_⟧⬗Eq = symEq ∘ ↑⟨_⟩Eq⟦_⟧ ⟦_⟧⬗Eq : ∀ {Γ Γ′ Ξ A} → {ρ : Γ ⊩⋆ Ξ} → (M : Ξ ⊢ A) (η : Γ′ ∋⋆ Γ) → Un⋆ ρ → Eq (⟦ M ⟧ (η ⬗ ρ)) (acc η (⟦ M ⟧ ρ)) ⟦_⟧⬗Eq (𝓋 i) η υ = get⬗Eq η i υ ⟦_⟧⬗Eq (ƛ M) η υ = eq⊃ (λ η′ u → ⟦ M ⟧Eq (comp⬗◇Eq⋆ η′ η υ , reflEq u) (cong⬗Un⋆ η′ (cong⬗Un⋆ η υ) , u) (cong⬗Un⋆ (η′ ○ η) υ , u)) ⟦_⟧⬗Eq (M ∙ N) η υ = cong⟦∙⟧Eq idᵣ (⟦ M ⟧⬗Eq η υ) (⟦ M ⟧Un (cong⬗Un⋆ η υ)) (congaccUn η (⟦ M ⟧Un υ)) (⟦ N ⟧⬗Eq η υ) (⟦ N ⟧Un (cong⬗Un⋆ η υ)) (congaccUn η (⟦ N ⟧Un υ)) ⦙ acc⟦∙⟧idEq η (⟦ M ⟧Un υ) (congaccUn η (⟦ N ⟧Un υ)) ⦙ (cong⟦∙⟧Eq η ((lidaccEq (⟦ M ⟧Un υ)) ⁻¹) (⟦ M ⟧Un υ) (congaccUn idᵣ (⟦ M ⟧Un υ)) (reflEq (congaccUn η (⟦ N ⟧Un υ))) (congaccUn η (⟦ N ⟧Un υ)) (congaccUn η (⟦ N ⟧Un υ)) ⦙ acc⟦∙⟧Eq idᵣ η (⟦ M ⟧Un υ) (⟦ N ⟧Un υ)) -- ⟦_⟧⬗Eq⋆ = symEq ∘ ↑⟨_⟩Eq⋆⟦_⟧ₛ ⟦_⟧⬗Eq⋆ : ∀ {Γ Γ′ Ξ Φ} → {ρ : Γ ⊩⋆ Ξ} → (σ : Ξ ⊢⋆ Φ) (η : Γ′ ∋⋆ Γ) → Un⋆ ρ → Eq⋆ (⟦ σ ⟧⋆ (η ⬗ ρ)) (η ⬗ ⟦ σ ⟧⋆ ρ) ⟦_⟧⬗Eq⋆ ∅ η υ = ∅ ⟦_⟧⬗Eq⋆ (σ , M) η υ = ⟦ σ ⟧⬗Eq⋆ η υ , ⟦ M ⟧⬗Eq η υ -------------------------------------------------------------------------------- -- TODO: Generalise to zap⬖ postulate aux₄₈₁ : ∀ {Γ Ξ A} → {ρ : Γ ⊩⋆ Ξ} {a : Γ ⊩ A} → Un⋆ ρ → Eq⋆ ((ρ , a) ⬖ wkᵣ idᵣ) ρ -- TODO -- Basic properties of _◇_ -- Advanced properties of _◇_ -- Basic properties of _⬗_ -- Basic properties of _◆_ -- Advanced properties of _⬗_ -- Advanced properties of _◆_ -- TODO: Fix the instance argument problem; abstract over models; rename η to ξ… -------------------------------------------------------------------------------- renlift⟦_⟧Eq : ∀ {Γ Γ′ A B w w′} → {ρ : w ⊩⋆ Γ′} {a : w′ ⊩ A} → (M : Γ , A ⊢ B) (η₁ : Γ′ ∋⋆ Γ) (η₂ : w′ ∋⋆ w) → Un⋆ ρ → Un a → Eq (⟦ ren (liftᵣ {A} η₁) M ⟧ (η₂ ⬗ ρ , a)) (⟦ M ⟧ (η₂ ⬗ (ρ ⬖ η₁) , a)) renlift⟦_⟧Eq (𝓋 zero) η₁ η₂ υ u = reflEq u renlift⟦_⟧Eq {ρ = ρ} {a} (𝓋 (suc i)) η₁ η₂ υ u = ≡→Eq ((getᵥ (η₂ ⬗ ρ , a)) & natgetᵣ η₁ i) (conggetUn (getᵣ (wkᵣ η₁) i) (cong⬗Un⋆ η₂ υ , u)) ⦙ get⬖Eq η₁ (getᵣ η₁ i) i (cong⬗Un⋆ η₂ υ) ⁻¹ ⦙ conggetEq i (comp⬗⬖Eq⋆ η₂ η₁ υ ⁻¹) renlift⟦_⟧Eq (ƛ M) η₁ η₂ υ u = eq⊃ (λ η′ u′ → renlift⟦ M ⟧Eq (liftᵣ η₁) η′ (cong⬗Un⋆ η₂ υ , u) u′ ⦙ ⟦ M ⟧Eq ( ( cong⬗Eq⋆ η′ (( comp⬗⬖Eq⋆ η₂ η₁ υ ⦙ zap⬖Eq⋆ (wkᵣ η₁) η₁ (cong⬗Un⋆ η₂ υ) ⁻¹ ) ⁻¹) , reflEq (congaccUn η′ u) ) , reflEq u′ ) ((cong⬗Un⋆ η′ (cong⬖Un⋆ (wkᵣ η₁) (cong⬗Un⋆ η₂ υ , u)) , congaccUn η′ u) , u′) ((cong⬗Un⋆ η′ (cong⬗Un⋆ η₂ (cong⬖Un⋆ η₁ υ)) , congaccUn η′ u) , u′)) renlift⟦_⟧Eq (M ∙ N) η₁ η₂ υ u = cong⟦∙⟧Eq idᵣ (renlift⟦ M ⟧Eq η₁ η₂ υ u) (⟦ ren (liftᵣ η₁) M ⟧Un (cong⬗Un⋆ η₂ υ , u)) (⟦ M ⟧Un (cong⬗Un⋆ η₂ (cong⬖Un⋆ η₁ υ) , u)) (renlift⟦ N ⟧Eq η₁ η₂ υ u) (⟦ ren (liftᵣ η₁) N ⟧Un (cong⬗Un⋆ η₂ υ , u)) (⟦ N ⟧Un (cong⬗Un⋆ η₂ (cong⬖Un⋆ η₁ υ) , u)) -------------------------------------------------------------------------------- renwk⟦_⟧Eq : ∀ {Γ Γ′ A C w} → {ρ : w ⊩⋆ Γ′} {a : w ⊩ A} → (M : Γ ⊢ C) (η : Γ′ ∋⋆ Γ) → Un⋆ ρ → Un a → Eq (⟦ ren (wkᵣ {A} η) M ⟧ (ρ , a)) (⟦ M ⟧ (ρ ⬖ η)) renwk⟦_⟧Eq (𝓋 i) η υ u = get⬖Eq (wkᵣ η) (getᵣ (wkᵣ η) i) i (υ , u) ⁻¹ ⦙ conggetEq i (zap⬖Eq⋆ (wkᵣ η) η υ) renwk⟦_⟧Eq (ƛ M) η υ u = eq⊃ (λ η′ u′ → renlift⟦ M ⟧Eq (wkᵣ η) η′ (υ , u) u′ ⦙ ⟦ M ⟧Eq (cong⬗Eq⋆ η′ (zap⬖Eq⋆ (wkᵣ η) η υ) , reflEq u′) (cong⬗Un⋆ η′ (cong⬖Un⋆ (wkᵣ η) (υ , u)) , u′) (cong⬗Un⋆ η′ (cong⬖Un⋆ η υ) , u′)) renwk⟦_⟧Eq (M ∙ N) η υ u = cong⟦∙⟧Eq idᵣ (renwk⟦ M ⟧Eq η υ u) (⟦ ren (wkᵣ η) M ⟧Un (υ , u)) (⟦ M ⟧Un (cong⬖Un⋆ η υ)) (renwk⟦ N ⟧Eq η υ u) (⟦ ren (wkᵣ η) N ⟧Un (υ , u)) (⟦ N ⟧Un (cong⬖Un⋆ η υ)) -------------------------------------------------------------------------------- wk⟦_⟧Eq : ∀ {Γ A C w} → {ρ : w ⊩⋆ Γ} {a : w ⊩ A} → (M : Γ ⊢ C) → Un⋆ ρ → Un a → Eq (⟦ wk {A} M ⟧ (ρ , a)) (⟦ M ⟧ ρ) wk⟦_⟧Eq M υ u = renwk⟦ M ⟧Eq idᵣ υ u ⦙ ⟦ M ⟧Eq (rid⬖Eq⋆ υ) (cong⬖Un⋆ idᵣ υ) υ wk⟦_⟧Eq⋆ : ∀ {Γ Ξ A w} → {ρ : w ⊩⋆ Γ} {a : w ⊩ A} → (σ : Γ ⊢⋆ Ξ) → Un⋆ ρ → Un a → Eq⋆ (⟦ wkₛ {A} σ ⟧⋆ (ρ , a)) (⟦ σ ⟧⋆ ρ) wk⟦_⟧Eq⋆ ∅ υ u = ∅ wk⟦_⟧Eq⋆ (σ , M) υ u = wk⟦ σ ⟧Eq⋆ υ u , wk⟦ M ⟧Eq υ u -------------------------------------------------------------------------------- get⟦_⟧Eq : ∀ {Γ Ξ A w} → {ρ : w ⊩⋆ Γ} → (σ : Γ ⊢⋆ Ξ) (i : Ξ ∋ A) → Un⋆ ρ → Eq (⟦ getₛ σ i ⟧ ρ) (getᵥ (⟦ σ ⟧⋆ ρ) i) get⟦_⟧Eq (σ , M) zero υ = reflEq (⟦ M ⟧Un υ) get⟦_⟧Eq (σ , M) (suc i) υ = get⟦ σ ⟧Eq i υ -------------------------------------------------------------------------------- sublift⟦_⟧Eq : ∀ {Γ Ξ A B w} → {ρ : w ⊩⋆ Γ} {a : w ⊩ A} → (M : Ξ , A ⊢ B) (σ : Γ ⊢⋆ Ξ) → Un⋆ ρ → Un a → Eq (⟦ sub (liftₛ {A} σ) M ⟧ (ρ , a)) (⟦ M ⟧ (⟦ σ ⟧⋆ ρ , a)) sublift⟦_⟧Eq (𝓋 zero) σ υ u = reflEq u sublift⟦_⟧Eq {ρ = ρ} {a} (𝓋 (suc i)) σ υ u = ≡→Eq ((λ M′ → ⟦ M′ ⟧ (ρ , a)) & natgetₛ σ i) (⟦ getₛ (wkₛ σ) i ⟧Un (υ , u)) ⦙ wk⟦ getₛ σ i ⟧Eq υ u ⦙ get⟦ σ ⟧Eq i υ sublift⟦_⟧Eq (ƛ M) σ υ u = eq⊃ (λ η′ u′ → sublift⟦ M ⟧Eq (liftₛ σ) (cong⬗Un⋆ η′ υ , congaccUn η′ u) u′ ⦙ ⟦ M ⟧Eq ((⟦ wkₛ σ ⟧⬗Eq⋆ η′ (υ , u) , reflEq (congaccUn η′ u)) , reflEq u′) ((⟦ wkₛ σ ⟧Un⋆ (cong⬗Un⋆ η′ υ , congaccUn η′ u) , congaccUn η′ u) , u′) ((cong⬗Un⋆ η′ (⟦ wkₛ σ ⟧Un⋆ (υ , u)) , congaccUn η′ u) , u′) ⦙ ⟦ M ⟧Eq ((cong⬗Eq⋆ η′ (wk⟦ σ ⟧Eq⋆ υ u) , reflEq (congaccUn η′ u)) , reflEq u′) ((cong⬗Un⋆ η′ (⟦ wkₛ σ ⟧Un⋆ (υ , u)) , congaccUn η′ u) , u′) ((cong⬗Un⋆ η′ (⟦ σ ⟧Un⋆ υ) , congaccUn η′ u) , u′)) sublift⟦_⟧Eq (M ∙ N) σ υ u = cong⟦∙⟧Eq idᵣ (sublift⟦ M ⟧Eq σ υ u) (⟦ sub (liftₛ σ) M ⟧Un (υ , u)) (⟦ M ⟧Un (⟦ σ ⟧Un⋆ υ , u)) (sublift⟦ N ⟧Eq σ υ u) (⟦ sub (liftₛ σ) N ⟧Un (υ , u)) (⟦ N ⟧Un (⟦ σ ⟧Un⋆ υ , u)) -------------------------------------------------------------------------------- subliftwk⟦_⟧Eq : ∀ {Γ Ξ A A′ B w w′} → {ρ : w ⊩⋆ Γ} {a : w ⊩ A} {a′ : w′ ⊩ A′} → (M : Ξ , A′ ⊢ B) (σ : Γ ⊢⋆ Ξ) (η : w′ ∋⋆ w) → Un⋆ ρ → Un a → Un a′ → Eq (⟦ sub (liftₛ (wkₛ σ)) M ⟧ (η ⬗ ρ , acc η a , a′)) (⟦ sub (liftₛ σ) M ⟧ (η ⬗ ρ , a′)) subliftwk⟦_⟧Eq M σ η υ u u′ = sublift⟦ M ⟧Eq (wkₛ σ) (cong⬗Un⋆ η υ , congaccUn η u) u′ ⦙ ⟦ M ⟧Eq (wk⟦ σ ⟧Eq⋆ (cong⬗Un⋆ η υ) (congaccUn η u) , reflEq u′) (⟦ wkₛ σ ⟧Un⋆ (cong⬗Un⋆ η υ , congaccUn η u) , u′) (⟦ σ ⟧Un⋆ (cong⬗Un⋆ η υ) , u′) ⦙ sublift⟦ M ⟧Eq σ (cong⬗Un⋆ η υ) u′ ⁻¹ -------------------------------------------------------------------------------- subwk⟦_⟧Eq : ∀ {Γ Ξ A C w} → {ρ : w ⊩⋆ Γ} {a : w ⊩ A} → (M : Ξ ⊢ C) (σ : Γ ⊢⋆ Ξ) → Un⋆ ρ → Un a → Eq (⟦ sub (wkₛ {A} σ) M ⟧ (ρ , a)) (⟦ sub σ M ⟧ ρ) subwk⟦_⟧Eq {ρ = ρ} {a} (𝓋 i) σ υ u = ≡→Eq ((λ M′ → ⟦ M′ ⟧ (ρ , a)) & (natgetₛ σ i)) (⟦ getₛ (wkₛ σ) i ⟧Un (υ , u)) ⦙ wk⟦ getₛ σ i ⟧Eq υ u subwk⟦_⟧Eq (ƛ {A = A′} M) σ υ u = eq⊃ (λ η u′ → subliftwk⟦ M ⟧Eq σ η υ u u′) subwk⟦_⟧Eq (M ∙ N) σ υ u = cong⟦∙⟧Eq idᵣ (subwk⟦ M ⟧Eq σ υ u) (⟦ sub (wkₛ σ) M ⟧Un (υ , u)) (⟦ sub σ M ⟧Un υ) (subwk⟦ N ⟧Eq σ υ u) (⟦ sub (wkₛ σ) N ⟧Un (υ , u)) (⟦ sub σ N ⟧Un υ) -------------------------------------------------------------------------------- sub⟦_⟧Eq : ∀ {Γ Ξ A w} → {ρ : w ⊩⋆ Γ} → (M : Ξ ⊢ A) (σ : Γ ⊢⋆ Ξ) → Un⋆ ρ → Eq (⟦ sub σ M ⟧ ρ) (⟦ M ⟧ (⟦ σ ⟧⋆ ρ)) sub⟦_⟧Eq (𝓋 i) σ υ = get⟦ σ ⟧Eq i υ sub⟦_⟧Eq (ƛ M) σ υ = eq⊃ (λ η u → sublift⟦ M ⟧Eq σ (cong⬗Un⋆ η υ) u ⦙ ⟦ M ⟧Eq (⟦ σ ⟧⬗Eq⋆ η υ , reflEq u) (⟦ σ ⟧Un⋆ (cong⬗Un⋆ η υ) , u) (cong⬗Un⋆ η (⟦ σ ⟧Un⋆ υ) , u)) sub⟦_⟧Eq (M ∙ N) σ υ = cong⟦∙⟧Eq idᵣ (sub⟦ M ⟧Eq σ υ) (⟦ sub σ M ⟧Un υ) (⟦ M ⟧Un (⟦ σ ⟧Un⋆ υ)) (sub⟦ N ⟧Eq σ υ) (⟦ sub σ N ⟧Un υ) (⟦ N ⟧Un (⟦ σ ⟧Un⋆ υ)) -------------------------------------------------------------------------------- -- TODO: Rename this sublift⟦⟧Eq⁈ : ∀ {Γ Ξ A B w} → {ρ : w ⊩⋆ Γ} → (σ : Γ ⊢⋆ Ξ) (M : Ξ , A ⊢ B) (N : Γ ⊢ A) → Un⋆ ρ → Eq (⟦ sub (liftₛ {A} σ) M ⟧ (ρ , ⟦ N ⟧ ρ)) (⟦ sub (σ , N) M ⟧ ρ) sublift⟦⟧Eq⁈ {ρ = ρ} σ M N υ = sublift⟦ M ⟧Eq σ υ (⟦ N ⟧Un υ) ⦙ sub⟦ M ⟧Eq (σ , N) υ ⁻¹ -------------------------------------------------------------------------------- -- TODO: Generalise theorem 4 over models module _ where open 𝔐 canon mutual lemƛ : ∀ {Γ A B w} → {ρ : w ⊩⋆ Γ} {M M′ : Γ , A ⊢ B} → M ∼ M′ → Un⋆ ρ → Eq (⟦ ƛ M ⟧ ρ) (⟦ ƛ M′ ⟧ ρ) lemƛ p υ = eq⊃ (λ xs u → cong⟦ p ⟧Eq (cong⬗Un⋆ xs υ , u)) lem∙ : ∀ {Γ A B w} → {ρ : w ⊩⋆ Γ} {M M′ : Γ ⊢ A ⇒ B} {N N′ : Γ ⊢ A} → M ∼ M′ → N ∼ N′ → Un⋆ ρ → Eq (⟦ M ∙ N ⟧ ρ) (⟦ M′ ∙ N′ ⟧ ρ) lem∙ {M = M} {M′} {N} {N′} p q υ = cong⟦∙⟧Eq idᵣ (cong⟦ p ⟧Eq υ) (⟦ M ⟧Un υ) (⟦ M′ ⟧Un υ) (cong⟦ q ⟧Eq υ) (⟦ N ⟧Un υ) (⟦ N′ ⟧Un υ) lemred⇒ : ∀ {Γ Ξ A B w} → {ρ : w ⊩⋆ Γ} → (σ : Γ ⊢⋆ Ξ) (M : Ξ , A ⊢ B) (N : Γ ⊢ A) → Un⋆ ρ → Eq (⟦ sub σ (ƛ M) ∙ N ⟧ ρ) (⟦ sub (σ , N) M ⟧ ρ) lemred⇒ {ρ = ρ} σ M N υ = ⟦ sub (liftₛ σ) M ⟧Eq (lid⬗Eq⋆ υ , reflEq (⟦ N ⟧Un υ)) (cong⬗Un⋆ idᵣ υ , ⟦ N ⟧Un υ) (υ , ⟦ N ⟧Un υ) ⦙ sublift⟦⟧Eq⁈ σ M N υ lemexp⇒ : ∀ {Γ A B w} → {ρ : w ⊩⋆ Γ} → (M : Γ ⊢ A ⇒ B) → Un⋆ ρ → Eq (⟦ M ⟧ ρ) (⟦ ƛ (wk M ∙ 0) ⟧ ρ) lemexp⇒ {ρ = ρ} M υ = eq⊃ (λ η {a} u → acc⟦∙⟧idEq η (⟦ M ⟧Un υ) u ⁻¹ ⦙ cong⟦∙⟧Eq idᵣ (⟦ M ⟧⬗Eq η υ ⁻¹) (congaccUn η (⟦ M ⟧Un υ)) (⟦ M ⟧Un (cong⬗Un⋆ η υ)) (reflEq u) u u ⦙ cong⟦∙⟧Eq idᵣ (wk⟦ M ⟧Eq (cong⬗Un⋆ η υ) u ⁻¹) (⟦ M ⟧Un (cong⬗Un⋆ η υ)) (⟦ wk M ⟧Un (cong⬗Un⋆ η υ , u)) (reflEq u) u u) -- Theorem 4. cong⟦_⟧Eq : ∀ {Γ A w} → {M M′ : Γ ⊢ A} {ρ : w ⊩⋆ Γ} → M ∼ M′ → Un⋆ ρ → Eq (⟦ M ⟧ ρ) (⟦ M′ ⟧ ρ) cong⟦ refl∼ {M = M} ⟧Eq υ = reflEq (⟦ M ⟧Un υ) cong⟦ p ⁻¹∼ ⟧Eq υ = cong⟦ p ⟧Eq υ ⁻¹ cong⟦ p ⦙∼ q ⟧Eq υ = cong⟦ p ⟧Eq υ ⦙ cong⟦ q ⟧Eq υ cong⟦ ƛ∼ p ⟧Eq υ = lemƛ p υ cong⟦ p ∙∼ q ⟧Eq υ = lem∙ p q υ cong⟦ red⇒ σ M N ⟧Eq υ = lemred⇒ σ M N υ cong⟦ exp⇒ M ⟧Eq υ = lemexp⇒ M υ -------------------------------------------------------------------------------- -- Theorem 5. thm₅ : ∀ {Γ A} → (M M′ : Γ ⊢ A) → nf M ≡ nf M′ → M ∼ M′ thm₅ M M′ p = thm₂ M ⦙ ≡→∼ p ⦙ (thm₂ M′ ⁻¹) -------------------------------------------------------------------------------- -- proj⟨_⟩𝒰⋆ ⌊_⌋ᵤ : ∀ {Γ Γ′} → (η : Γ′ ∋⋆ Γ) → Un⋆ ⌊ η ⌋ᵥ ⌊ ∅ ⌋ᵤ = ∅ ⌊ η , i ⌋ᵤ = ⌊ η ⌋ᵤ , ⟪𝓋 i ⟫ᵤ -- refl𝒰⋆ idᵤ : ∀ {Γ} → Un⋆ (idᵥ {Γ}) idᵤ = ⌊ idᵣ ⌋ᵤ -- Theorem 6. thm₆ : ∀ {Γ A} → (M M′ : Γ ⊢ A) → M ∼ M′ → nf M ≡ nf M′ thm₆ M M′ p = cor₁ M M′ (cong⟦ p ⟧Eq idᵤ) --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.2956981244, "avg_line_length": 37.8478873239, "ext": "agda", "hexsha": "d0f31e6b1aef204686363a5b778e1c3d2f86f445", "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": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/coquand-kovacs", "max_forks_repo_path": "src/STLC/Coquand/Soundness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/coquand-kovacs", "max_issues_repo_path": "src/STLC/Coquand/Soundness.agda", "max_line_length": 131, "max_stars_count": null, "max_stars_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/coquand-kovacs", "max_stars_repo_path": "src/STLC/Coquand/Soundness.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6955, "size": 13436 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Group where open import Cubical.Algebra.Group.Base public open import Cubical.Algebra.Group.Properties public open import Cubical.Algebra.Group.GroupPath public open import Cubical.Algebra.Group.DirProd public open import Cubical.Algebra.Group.Morphisms public open import Cubical.Algebra.Group.MorphismProperties public open import Cubical.Algebra.Group.Subgroup public open import Cubical.Algebra.Group.QuotientGroup public open import Cubical.Algebra.Group.IsomorphismTheorems public open import Cubical.Algebra.Group.Instances.Unit public open import Cubical.Algebra.Group.Instances.Bool public open import Cubical.Algebra.Group.Instances.Int public
{ "alphanum_fraction": 0.85021398, "avg_line_length": 43.8125, "ext": "agda", "hexsha": "df70cc3b22ad6f966f8fece1d8d62832cba0d98c", "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/Algebra/Group.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/Algebra/Group.agda", "max_line_length": 60, "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/Algebra/Group.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": 154, "size": 701 }
-- Andreas, 2020-04-15, issue #4586 -- Better error for invalid let pattern. import Agda.Builtin.Nat test : Set₁ test = let 13 = Set in Set -- WAS: -- Set != x of type Set₁ -- when checking that the given dot pattern Set matches the inferred -- value x -- EXPECTED: -- Not a valid let pattern -- when scope checking let .Set = Set in Set
{ "alphanum_fraction": 0.6742857143, "avg_line_length": 19.4444444444, "ext": "agda", "hexsha": "a5c484394fbf67bcf1dede9244be094fbfd6ca27", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Fail/Issue4586LetPatternLiteral.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/Issue4586LetPatternLiteral.agda", "max_line_length": 68, "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/Issue4586LetPatternLiteral.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": 102, "size": 350 }
------------------------------------------------------------------------ -- The Agda standard library -- -- A binary representation of natural numbers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Bin where open import Data.Nat as Nat using (ℕ; zero; z≤n; s≤s) renaming (suc to 1+_) open import Data.Digit using (fromDigits; toDigits; Bit) open import Data.Fin as Fin using (Fin; zero) renaming (suc to 1+_) open import Data.Fin.Properties as FP using (_+′_) open import Data.List.Base as List hiding (downFrom) open import Function open import Data.Product using (uncurry; _,_; _×_) open import Relation.Binary open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; sym) open import Relation.Nullary open import Relation.Nullary.Decidable ------------------------------------------------------------------------ -- Bits pattern 0b = zero pattern 1b = 1+ zero pattern ⊥b = 1+ 1+ () ------------------------------------------------------------------------ -- The type -- A representation of binary natural numbers in which there is -- exactly one representative for every number. The function toℕ below -- defines the meaning of Bin. -- `bs 1#` stands for the binary number "1<reverse bs>" e.g. -- `(0b ∷ []) 1#` represents "10" -- `(0b ∷ 1b ∷ 1b ∷ []) 1#` represents "1110" Bin⁺ : Set Bin⁺ = List Bit infix 8 _1# data Bin : Set where 0# : Bin _1# : (bs : Bin⁺) → Bin ------------------------------------------------------------------------ -- Conversion functions -- Converting to a list of bits starting with the _least_ significant -- one. toBits : Bin → List Bit toBits 0# = [ 0b ] toBits (bs 1#) = bs ++ [ 1b ] -- Converting to a natural number. toℕ : Bin → ℕ toℕ = fromDigits ∘ toBits -- Converting from a list of bits, starting with the _least_ -- significant one. fromBits : List Bit → Bin fromBits [] = 0# fromBits (b ∷ bs) with fromBits bs fromBits (b ∷ bs) | bs′ 1# = (b ∷ bs′) 1# fromBits (0b ∷ bs) | 0# = 0# fromBits (1b ∷ bs) | 0# = [] 1# fromBits (⊥b ∷ bs) | _ private pattern 2+_ n = 1+ 1+ n ntoBits′ : ℕ → ℕ → List Bit ntoBits′ 0 _ = [] ntoBits′ 1 0 = 0b ∷ 1b ∷ [] ntoBits′ 1 1 = 1b ∷ [] ntoBits′ (2+ k) 0 = 0b ∷ ntoBits′ (1+ k) k ntoBits′ (2+ k) 1 = 1b ∷ ntoBits′ (1+ k) (1+ k) ntoBits′ (1+ k) (2+ n) = ntoBits′ k n ntoBits : ℕ → List Bit ntoBits n = ntoBits′ n n -- Converting from a natural number. fromℕ : ℕ → Bin fromℕ n = fromBits $ ntoBits n ------------------------------------------------------------------------ -- Order relation. -- Wrapped so that the parameters can be inferred. infix 4 _<_ data _<_ (b₁ b₂ : Bin) : Set where less : (lt : (Nat._<_ on toℕ) b₁ b₂) → b₁ < b₂ less-injective : ∀ {b₁ b₂} {lt₁ lt₂} → (b₁ < b₂ ∋ less lt₁) ≡ less lt₂ → lt₁ ≡ lt₂ less-injective refl = refl ------------------------------------------------------------------------ -- Arithmetic -- Power of two. infixr 8 2^_ 2^_ : ℕ → Bin⁺ 2^ 0 = [] 2^ (1+ n) = 0b ∷ 2^ n -- Base 2 logarithm (rounded downwards). ⌊log₂_⌋ : Bin⁺ → ℕ ⌊log₂ (b ∷ bs) ⌋ = 1+ ⌊log₂ bs ⌋ ⌊log₂ [] ⌋ = 0 -- Multiplication by 2. infix 7 _*2 _*2+1 _*2 : Bin → Bin 0# *2 = 0# (bs 1#) *2 = (0b ∷ bs) 1# _*2+1 : Bin → Bin 0# *2+1 = [] 1# (bs 1#) *2+1 = (1b ∷ bs) 1# -- Division by 2, rounded downwards. ⌊_/2⌋ : Bin → Bin ⌊ 0# /2⌋ = 0# ⌊ [] 1# /2⌋ = 0# ⌊ (b ∷ bs) 1# /2⌋ = bs 1# -- Addition. Carry : Set Carry = Bit addBits : Carry → Bit → Bit → Carry × Bit addBits c b₁ b₂ with c +′ (b₁ +′ b₂) ... | zero = (0b , 0b) ... | 1+ zero = (0b , 1b) ... | 1+ 1+ zero = (1b , 0b) ... | 1+ 1+ 1+ zero = (1b , 1b) ... | 1+ 1+ 1+ 1+ () addCarryToBitList : Carry → List Bit → List Bit addCarryToBitList 0b bs = bs addCarryToBitList 1b [] = 1b ∷ [] addCarryToBitList 1b (0b ∷ bs) = 1b ∷ bs addCarryToBitList 1b (1b ∷ bs) = 0b ∷ addCarryToBitList 1b bs addCarryToBitList ⊥b _ addCarryToBitList _ (⊥b ∷ _) addBitLists : Carry → List Bit → List Bit → List Bit addBitLists c [] bs₂ = addCarryToBitList c bs₂ addBitLists c bs₁ [] = addCarryToBitList c bs₁ addBitLists c (b₁ ∷ bs₁) (b₂ ∷ bs₂) with addBits c b₁ b₂ ... | (c' , b') = b' ∷ addBitLists c' bs₁ bs₂ infixl 6 _+_ _+_ : Bin → Bin → Bin m + n = fromBits (addBitLists 0b (toBits m) (toBits n)) -- Multiplication. infixl 7 _*_ _*_ : Bin → Bin → Bin 0# * n = 0# [] 1# * n = n -- (b + 2 * bs 1#) * n = b * n + 2 * (bs 1# * n) (b ∷ bs) 1# * n with bs 1# * n (b ∷ bs) 1# * n | 0# = 0# (0b ∷ bs) 1# * n | bs' 1# = (0b ∷ bs') 1# (1b ∷ bs) 1# * n | bs' 1# = n + (0b ∷ bs') 1# (⊥b ∷ _) 1# * _ | _ -- Successor. suc : Bin → Bin suc n = [] 1# + n -- Division by 2, rounded upwards. ⌈_/2⌉ : Bin → Bin ⌈ n /2⌉ = ⌊ suc n /2⌋ -- Predecessor. pred : Bin⁺ → Bin pred [] = 0# pred (0b ∷ bs) = pred bs *2+1 pred (1b ∷ bs) = (zero ∷ bs) 1# pred (⊥b ∷ bs) -- downFrom n enumerates all numbers from n - 1 to 0. This function is -- linear in n. Analysis: fromℕ takes linear time, and the preds used -- take amortised constant time (to see this, let the cost of a pred -- be 2, and put 1 debit on every bit which is 1). downFrom : ℕ → List Bin downFrom n = helper n (fromℕ n) where helper : ℕ → Bin → List Bin helper zero 0# = [] helper (1+ n) (bs 1#) = n′ ∷ helper n n′ where n′ = pred bs -- Impossible cases: helper zero (_ 1#) = [] helper (1+ _) 0# = [] ------------------------------------------------------------------------ -- Tests -- The tests below are run when this module is type checked. -- First some test helpers: private testLimit : ℕ testLimit = 5 nats : List ℕ nats = List.downFrom testLimit nats⁺ : List ℕ nats⁺ = filter (1 Nat.≤?_) nats natPairs : List (ℕ × ℕ) natPairs = List.zip nats (reverse nats) _=[_]_ : (ℕ → ℕ) → List ℕ → (Bin → Bin) → Set f =[ ns ] g = List.map f ns ≡ List.map (toℕ ∘ g ∘ fromℕ) ns _=[_]₂_ : (ℕ → ℕ → ℕ) → List (ℕ × ℕ) → (Bin → Bin → Bin) → Set f =[ ps ]₂ g = List.map (uncurry f) ps ≡ List.map (toℕ ∘ uncurry (g on fromℕ)) ps -- And then the tests: private test-*2+1 : (λ n → Nat._+_ (Nat._*_ n 2) 1) =[ nats ] _*2+1 test-*2+1 = refl test-*2 : (λ n → Nat._*_ n 2) =[ nats ] _*2 test-*2 = refl test-⌊_/2⌋ : Nat.⌊_/2⌋ =[ nats ] ⌊_/2⌋ test-⌊_/2⌋ = refl test-+ : Nat._+_ =[ natPairs ]₂ _+_ test-+ = refl test-* : Nat._*_ =[ natPairs ]₂ _*_ test-* = refl test-suc : 1+_ =[ nats ] suc test-suc = refl test-⌈_/2⌉ : Nat.⌈_/2⌉ =[ nats ] ⌈_/2⌉ test-⌈_/2⌉ = refl drop-1# : Bin → Bin⁺ drop-1# 0# = [] drop-1# (bs 1#) = bs test-pred : Nat.pred =[ nats⁺ ] (pred ∘ drop-1#) test-pred = refl test-downFrom : List.map toℕ (downFrom testLimit) ≡ List.downFrom testLimit test-downFrom = refl
{ "alphanum_fraction": 0.5137232361, "avg_line_length": 23.9965517241, "ext": "agda", "hexsha": "00732bfb53720faf7dc41ec1717aa0a8ce3d6611", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Bin.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Bin.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Bin.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2693, "size": 6959 }
------------------------------------------------------------------------ -- A compiler ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} module Lambda.Simplified.Compiler where open import Equality.Propositional.Cubical open import Prelude open import Vec.Function equality-with-J open import Lambda.Simplified.Syntax open import Lambda.Simplified.Virtual-machine private module C = Closure Code module T = Closure Tm -- The compiler (which takes a code continuation). comp : ∀ {n} → Tm n → Code n → Code n comp (var x) c = var x ∷ c comp (ƛ t) c = clo (comp t (ret ∷ [])) ∷ c comp (t₁ · t₂) c = comp t₁ (comp t₂ (app ∷ c)) -- Environments and values can also be compiled. mutual comp-env : ∀ {n} → T.Env n → C.Env n comp-env ρ n = comp-val (ρ n) comp-val : T.Value → C.Value comp-val (T.ƛ t ρ) = C.ƛ (comp t (ret ∷ [])) (comp-env ρ) -- Compilation takes empty environments to empty environments. comp-nil : comp-env nil ≡ nil comp-nil = empty≡nil ext -- Compilation commutes with cons. comp-cons : ∀ {n} {ρ : T.Env n} {v} → comp-env (cons v ρ) ≡ cons (comp-val v) (comp-env ρ) comp-cons = non-empty≡cons-head-tail ext _
{ "alphanum_fraction": 0.5772357724, "avg_line_length": 25.625, "ext": "agda", "hexsha": "9976a639fa1c54a8193273357e8b4bfeac7bed46", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Lambda/Simplified/Compiler.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/partiality-monad", "max_issues_repo_path": "src/Lambda/Simplified/Compiler.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Lambda/Simplified/Compiler.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": 342, "size": 1230 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Groups.Groups open import Groups.Homomorphisms.Definition open import Groups.Definition open import Numbers.Naturals.Definition open import Numbers.Naturals.Order open import Setoids.Orders open import Setoids.Setoids open import Functions open import Sets.EquivalenceRelations open import Rings.Definition open import Rings.Homomorphisms.Definition open import Groups.Homomorphisms.Lemmas open import Rings.IntegralDomains.Definition open import Rings.IntegralDomains.Examples open import Rings.EuclideanDomains.Definition open import Fields.Fields open import WellFoundedInduction open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) module Rings.EuclideanDomains.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (E : EuclideanDomain R) where open import Rings.PrincipalIdealDomains.Definition (EuclideanDomain.isIntegralDomain E) open import Rings.Ideals.Principal.Definition R open import Rings.Divisible.Definition R open Setoid S open Ring R open Equivalence eq euclideanDomainIsPid : {c : _} → PrincipalIdealDomain {c} euclideanDomainIsPid {pred = pred} ideal = {!!} -- We definitely need to be able to decide equality in order to deduce this; otherwise we can't tell the difference -- between "everything is 0" and "something is nonzero", and the proofs are genuinely different in the two cases. where r : A r = {!!} r!=0 : (r ∼ 0R) → False r!=0 = {!!} predR : pred r predR = {!!} sr : (s : A) → r ∣ s sr = EuclideanDomain.divisionAlg r!=0 s!=0 ?
{ "alphanum_fraction": 0.7507635919, "avg_line_length": 35.5869565217, "ext": "agda", "hexsha": "5ce73b11cf320633a0de974fb8d9a4f589467395", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Rings/EuclideanDomains/Lemmas.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Rings/EuclideanDomains/Lemmas.agda", "max_line_length": 154, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Rings/EuclideanDomains/Lemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 452, "size": 1637 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module StructurallySmaller where data ℕ : Set where zero : ℕ succ : ℕ → ℕ _+_ : ℕ → ℕ → ℕ zero + n = n succ m + n = succ (m + n) -- Foo is not structurally recursive even though zero + n normalises -- to n. {-# TERMINATING #-} foo : ℕ → ℕ foo zero = zero foo (succ n) = foo (zero + n)
{ "alphanum_fraction": 0.5456475584, "avg_line_length": 21.4090909091, "ext": "agda", "hexsha": "0542a268bdd51437c908c4942e6e20f6bca4beb7", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/StructurallySmaller.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/StructurallySmaller.agda", "max_line_length": 68, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/StructurallySmaller.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": 134, "size": 471 }
{- In some cases you may want to block certain terms from being evaluated by Agda at compile time. I found I needed to do this when generating large terms intended for evaluation at run-time only. You can use the runtime-only function for this. If its first argument is tt, then we will use a postulate runtime-identity to block Agda's compile-time evaluation. Otherwise, we will not block compile-time evaluation. -} module runtime-only where open import bool postulate runtime-identity : ∀{A : Set} → A → A {-# COMPILED runtime-identity (\ _ x -> x ) #-} runtime-only : ∀{A : Set} → 𝔹 → A → A runtime-only ff = λ x → x runtime-only tt = runtime-identity
{ "alphanum_fraction": 0.7142857143, "avg_line_length": 35.7368421053, "ext": "agda", "hexsha": "637be7f0b3d001c3191918cef61970abd6380401", "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": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "runtime-only.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "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": "heades/AUGL", "max_issues_repo_path": "runtime-only.agda", "max_line_length": 71, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "runtime-only.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 179, "size": 679 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Example showing how to define an indexed container ------------------------------------------------------------------------ {-# OPTIONS --with-K --safe --guardedness #-} module README.Data.Container.Indexed where open import Data.Unit open import Data.Empty open import Data.Nat.Base open import Data.Product open import Function open import Data.W.Indexed open import Data.Container.Indexed open import Data.Container.Indexed.WithK module _ {a} (A : Set a) where ------------------------------------------------------------------------ -- Vector as an indexed container -- An indexed container is defined by three things: -- 1. Commands the user can emit -- 2. Responses the indexed container returns to these commands -- 3. Update of the index based on the command and the response issued. -- For a vector, commands are constructors, responses are the number of subvectors -- (0 if the vector is empty, 1 otherwise) and the update corresponds to setting the -- size of the tail (if it exists). We can formalize these ideas like so: -- Depending on the size of the vector, we may have reached the end already (nil) -- or we may specify what the head should be (cons). This is the type of commands. data VecC : ℕ → Set a where nil : VecC zero cons : ∀ n → A → VecC (suc n) Vec : Container ℕ ℕ a _ Command Vec = VecC -- We then treat each command independently, specifying both the response and the -- next index based on that response. -- In the nil case, the response is the empty type: there won't be any tail. As -- a consequence, the next index won't be needed (and we can rely on the fact the -- user will never be able to call it). Response Vec nil = ⊥ next Vec nil = λ () -- In the cons case, the response is the unit type: there is exactly one tail. The -- next index is the predecessor of the current one. It is handily handed over to -- use by `cons`. -- cons Response Vec (cons n a) = ⊤ next Vec (cons n a) = λ _ → n -- Finally we can define the type of Vector as the least fixed point of Vec. Vector : ℕ → Set a Vector = μ Vec module _ {a} {A : Set a} where -- We can recover the usual constructors by using `sup` to enter the fixpoint -- and then using the appropriate pairing of a command & a handler for the -- response. -- For [], the response is ⊥ which makes it easy to conclude. [] : Vector A 0 [] = sup (nil , λ ()) -- For _∷_, the response is ⊤ so we need to pass a tail. We give the one we took -- as an argument. infixr 3 _∷_ _∷_ : ∀ {n} → A → Vector A n → Vector A (suc n) x ∷ xs = sup (cons _ x , λ _ → xs) -- We can now use these constructors to build up vectors: 1⋯3 : Vector ℕ 3 1⋯3 = 1 ∷ 2 ∷ 3 ∷ [] -- Horrible thing to check the definition of _∈_ is not buggy. -- Not sure whether we can say anything interesting about it in the case of Vector... open import Relation.Binary.HeterogeneousEquality _ : _∈_ {C = Vec ℕ} {X = Vector ℕ} 1⋯3 (⟦ Vec ℕ ⟧ (Vector ℕ) 4 ∋ cons _ 0 , λ _ → 1⋯3) _ = _ , refl
{ "alphanum_fraction": 0.6373239437, "avg_line_length": 30.9306930693, "ext": "agda", "hexsha": "0c94e182eca4c07305dd8523c942a46442ee8122", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/README/Data/Container/Indexed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/README/Data/Container/Indexed.agda", "max_line_length": 86, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/README/Data/Container/Indexed.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": 819, "size": 3124 }
{-# OPTIONS --safe --without-K #-} module Level where open import Agda.Primitive using (Level) renaming ( _⊔_ to _ℓ⊔_ ; lzero to ℓzero ; lsuc to ℓsuc ) public Type : (ℓ : Level) → Set (ℓsuc ℓ) Type ℓ = Set ℓ Type₀ = Type ℓzero Type₁ = Type (ℓsuc ℓzero) Type₂ = Type (ℓsuc (ℓsuc ℓzero)) Type₃ = Type (ℓsuc (ℓsuc (ℓsuc ℓzero))) variable a b c : Level A : Type a B : Type b C : Type c
{ "alphanum_fraction": 0.5929411765, "avg_line_length": 16.3461538462, "ext": "agda", "hexsha": "a250e7eba74b53c4cc0a662f3104651d90ee30ac", "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/Level.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/Level.agda", "max_line_length": 39, "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/Level.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 179, "size": 425 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Group.DirProd where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Monoid open import Cubical.Algebra.Semigroup open GroupStr open IsGroup hiding (rid ; lid ; invr ; invl) open IsMonoid hiding (rid ; lid) open IsSemigroup DirProd : ∀ {ℓ ℓ'} → Group ℓ → Group ℓ' → Group (ℓ-max ℓ ℓ') fst (DirProd G H) = fst G × fst H 1g (snd (DirProd G H)) = (1g (snd G)) , (1g (snd H)) _·_ (snd (DirProd G H)) x y = _·_ (snd G) (fst x) (fst y) , _·_ (snd H) (snd x) (snd y) (inv (snd (DirProd G H))) x = (inv (snd G) (fst x)) , (inv (snd H) (snd x)) is-set (isSemigroup (isMonoid (isGroup (snd (DirProd G H))))) = isSet× (is-set (snd G)) (is-set (snd H)) assoc (isSemigroup (isMonoid (isGroup (snd (DirProd G H))))) x y z i = assoc (snd G) (fst x) (fst y) (fst z) i , assoc (snd H) (snd x) (snd y) (snd z) i fst (identity (isMonoid (isGroup (snd (DirProd G H)))) x) i = rid (snd G) (fst x) i , rid (snd H) (snd x) i snd (identity (isMonoid (isGroup (snd (DirProd G H)))) x) i = lid (snd G) (fst x) i , lid (snd H) (snd x) i fst (inverse (isGroup (snd (DirProd G H))) x) i = (invr (snd G) (fst x) i) , invr (snd H) (snd x) i snd (inverse (isGroup (snd (DirProd G H))) x) i = (invl (snd G) (fst x) i) , invl (snd H) (snd x) i
{ "alphanum_fraction": 0.6169467787, "avg_line_length": 42, "ext": "agda", "hexsha": "352d5446fc029d5f369d325f61d2711d31ead933", "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/Algebra/Group/DirProd.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/Algebra/Group/DirProd.agda", "max_line_length": 83, "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/Algebra/Group/DirProd.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": 539, "size": 1428 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Bisimilarity for Conats ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe --sized-types #-} module Codata.Conat.Bisimilarity where open import Size open import Codata.Thunk open import Codata.Conat open import Relation.Binary infix 1 _⊢_≈_ data _⊢_≈_ i : (m n : Conat ∞) → Set where zero : i ⊢ zero ≈ zero suc : ∀ {m n} → Thunk^R _⊢_≈_ i m n → i ⊢ suc m ≈ suc n refl : ∀ {i m} → i ⊢ m ≈ m refl {m = zero} = zero refl {m = suc m} = suc λ where .force → refl sym : ∀ {i m n} → i ⊢ m ≈ n → i ⊢ n ≈ m sym zero = zero sym (suc eq) = suc λ where .force → sym (eq .force) trans : ∀ {i m n p} → i ⊢ m ≈ n → i ⊢ n ≈ p → i ⊢ m ≈ p trans zero zero = zero trans (suc eq₁) (suc eq₂) = suc λ where .force → trans (eq₁ .force) (eq₂ .force) infix 1 _⊢_≲_ data _⊢_≲_ i : (m n : Conat ∞) → Set where z≲n : ∀ {n} → i ⊢ zero ≲ n s≲s : ∀ {m n} → Thunk^R _⊢_≲_ i m n → i ⊢ suc m ≲ suc n ≈⇒≲ : ∀ {i m n} → i ⊢ m ≈ n → i ⊢ m ≲ n ≈⇒≲ zero = z≲n ≈⇒≲ (suc eq) = s≲s λ where .force → ≈⇒≲ (eq .force) ≲-refl : ∀ {i m} → i ⊢ m ≲ m ≲-refl = ≈⇒≲ refl ≲-antisym : ∀ {i m n} → i ⊢ m ≲ n → i ⊢ n ≲ m → i ⊢ m ≈ n ≲-antisym z≲n z≲n = zero ≲-antisym (s≲s le) (s≲s ge) = suc λ where .force → ≲-antisym (le .force) (ge .force) ≲-trans : ∀ {i m n p} → i ⊢ m ≲ n → i ⊢ n ≲ p → i ⊢ m ≲ p ≲-trans z≲n _ = z≲n ≲-trans (s≲s le₁) (s≲s le₂) = s≲s λ where .force → ≲-trans (le₁ .force) (le₂ .force)
{ "alphanum_fraction": 0.4644670051, "avg_line_length": 30.3076923077, "ext": "agda", "hexsha": "c9e3503a77ea4a5458f18fe3c644e9dbf9ff49a8", "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/Codata/Conat/Bisimilarity.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/Codata/Conat/Bisimilarity.agda", "max_line_length": 84, "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/Codata/Conat/Bisimilarity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 723, "size": 1576 }
{-# OPTIONS --without-K #-} open import Base module Homotopy.Pushout where open import Homotopy.PushoutDef public pushout-diag-flip : ∀ {i} → pushout-diag i → pushout-diag i pushout-diag-flip (diag A , B , C , f , g) = diag B , A , C , g , f pushout-flip : ∀ {i} {d : pushout-diag i} → pushout d → pushout (pushout-diag-flip d) pushout-flip {d = d} = pushout-rec-nondep (pushout $ pushout-diag-flip d) right left (! ◯ glue) pushout-flip-flip : ∀ {i} {d : pushout-diag i} (p : pushout d) → pushout-flip (pushout-flip p) ≡ p pushout-flip-flip {d = d} = pushout-rec (λ p → pushout-flip (pushout-flip p) ≡ p) (λ _ → refl) (λ _ → refl) (λ c → transport (λ p → pushout-flip (pushout-flip p) ≡ p) (glue c) refl ≡⟨ trans-app≡id (pushout-flip ◯ pushout-flip) (glue c) refl ⟩ ! (ap (pushout-flip ◯ pushout-flip) (glue c)) ∘ glue c ≡⟨ ap (λ x → ! x ∘ glue c) $ ap-compose pushout-flip pushout-flip (glue c) ⟩ ! (ap pushout-flip (ap pushout-flip (glue c))) ∘ glue c ≡⟨ ap (λ x → ! (ap pushout-flip x) ∘ glue c) $ pushout-β-glue-nondep (pushout $ pushout-diag-flip d) right left (! ◯ glue) c ⟩ ! (ap pushout-flip (! (glue c))) ∘ glue c ≡⟨ ap (λ x → ! x ∘ glue c) $ ap-opposite pushout-flip (glue c) ⟩ ! (! (ap pushout-flip (glue c))) ∘ glue c ≡⟨ ap (λ x → ! (! x) ∘ glue c) $ pushout-β-glue-nondep (pushout d) right left (! ◯ glue) c ⟩ ! (! (! (glue c))) ∘ glue c ≡⟨ ap (λ x → ! x ∘ glue c) $ opposite-opposite $ glue c ⟩ ! (glue c) ∘ glue c ≡⟨ opposite-left-inverse (glue c) ⟩∎ refl ∎) pushout-β-!glue-nondep : ∀ {i} {d : pushout-diag i} {l} (D : Set l) → let open pushout-diag d in (left* : A → D) (right* : B → D) (glue* : (c : C) → left* (f c) ≡ right* (g c)) (c : C) → ap (pushout-rec-nondep D left* right* glue*) (! (glue c)) ≡ ! (glue* c) pushout-β-!glue-nondep D left* right* glue* c = ap (pushout-rec-nondep D left* right* glue*) (! (glue c)) ≡⟨ ap-opposite (pushout-rec-nondep D left* right* glue*) $ glue c ⟩ ! (ap (pushout-rec-nondep D left* right* glue*) $ glue c) ≡⟨ ap ! $ pushout-β-glue-nondep D left* right* glue* c ⟩∎ ! (glue* c) ∎
{ "alphanum_fraction": 0.5541027953, "avg_line_length": 39.6071428571, "ext": "agda", "hexsha": "471e09d9abeac88ab320cfb8c52685cddcc05602", "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/Pushout.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/Pushout.agda", "max_line_length": 93, "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/Pushout.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": 903, "size": 2218 }
module Negative1 where data D : Set where lam : (D -> D) -> D
{ "alphanum_fraction": 0.5735294118, "avg_line_length": 11.3333333333, "ext": "agda", "hexsha": "a337e3a418e0f78db5ae9eb2f96fd7b7dccd6dd8", "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/Negative1.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/Negative1.agda", "max_line_length": 23, "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/Negative1.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 22, "size": 68 }
module FFI.Data.Text.Encoding where open import Agda.Builtin.String using (String) open import FFI.Data.ByteString using (ByteString) {-# FOREIGN GHC import qualified Data.Text.Encoding #-} postulate encodeUtf8 : String → ByteString {-# COMPILE GHC encodeUtf8 = Data.Text.Encoding.encodeUtf8 #-}
{ "alphanum_fraction": 0.7733333333, "avg_line_length": 27.2727272727, "ext": "agda", "hexsha": "54f324860d714a950fdee537cb198104775c7718", "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/FFI/Data/Text/Encoding.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/FFI/Data/Text/Encoding.agda", "max_line_length": 62, "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/FFI/Data/Text/Encoding.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": 64, "size": 300 }
{-| A custom prelude -} module Eth.Prelude where import Prelude import Prelude.Bool -- using (bool) import Prelude.List -- using (intercalate) import Prelude.Monad -- using ((>=>)) import Control.Monad.Identity -- using import Control.Monad.Writer -- using -- (MonadWriter, WriterT, Writer, execWriterT, execWriter, tell) import Control.Monad.Reader -- using -- (MonadReader, ReaderT, Reader, runReaderT, runReader, ask, local) infixl 6 <> export isNullStr : String -> Bool isNullStr = (== neutral) -- export -- (<>) : Monoid m => m -> m -> m -- (<>) = (<+>) export bool : a -> a -> Bool -> a bool x y b = case b of True => x False => y export execWriterT : Functor m => WriterT w m a -> m w execWriterT = map snd . runWriterT -- works : WriterT w (ReaderT r Identity) _ -> ReaderT r Identity w -- works = execWriterT @{ } -- doesnt : WriterT w (Reader r) _ -> Reader r w -- doesnt = execWriterT @{ FunctorReaderT } -- using ReaderTFunctor export execWriter : Writer w a -> w execWriter = runIdentity . execWriterT export runReader : Reader r a -> r -> a runReader m = runIdentity . runReaderT m -- M : Type -> Type -> Type -> Type -- M w r a = WriterT w (Reader r) a -- unM : M w r a -> w -> r -> a -- unM = ?foo
{ "alphanum_fraction": 0.6464401294, "avg_line_length": 22.4727272727, "ext": "agda", "hexsha": "715f4cb560a234cd794d98b6323e658b8b78402b", "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": "18e1f9271a3ce76319cdfbcffe027c2088a418aa", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "fredefox/ethambda-agda", "max_forks_repo_path": "src/Eth/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "18e1f9271a3ce76319cdfbcffe027c2088a418aa", "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": "fredefox/ethambda-agda", "max_issues_repo_path": "src/Eth/Prelude.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "18e1f9271a3ce76319cdfbcffe027c2088a418aa", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "fredefox/ethambda-agda", "max_stars_repo_path": "src/Eth/Prelude.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 372, "size": 1236 }
-- 2014-07-30 Andreas, issue reported by toporoskyy.y data Nat : Set where Zero : Nat Succ : Nat -> Nat boom : Nat -> Nat boom n@(Succ _) = Zero -- EXPECTED: -- Not supported: @-patterns -- when scope checking the left-hand side boom n@(Succ _) in the -- definition of boom
{ "alphanum_fraction": 0.6643109541, "avg_line_length": 20.2142857143, "ext": "agda", "hexsha": "5dadaf4baca52c556a8292d1fe3328c2ee8b2b0f", "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/Issue1236.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/Issue1236.agda", "max_line_length": 64, "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/Issue1236.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": 87, "size": 283 }
A : Set
{ "alphanum_fraction": 0.5, "avg_line_length": 4, "ext": "agda", "hexsha": "31e6184cf1c46b422afb176373a3e5089f14bf9d", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/HighlightMissingDefinition.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/HighlightMissingDefinition.agda", "max_line_length": 7, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/HighlightMissingDefinition.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": 4, "size": 8 }
open import Agda.Builtin.Nat open import Agda.Builtin.Bool open import Agda.Builtin.Equality F : Bool → Set F false = Bool F true = Nat f : ∀ b → F b → Nat f false false = 0 f false true = 1 f true x = 2 data D : Nat → Set where mkD : (b : Bool) (x : F b) → D (f b x) mutual ?X : Nat → Set ?X = _ ?b : Nat → Bool ?b = _ -- Here we should check -- (n : Nat) → ?X n == (x : F (?b 0)) → D (f (?b 0) x) -- and get stuck on comparing the domains, but special inference -- for constructors is overeager and compares the target types, -- solving -- ?X : Nat → Set -- ?X x := D (f (?b 0) x) -- Note that the call to f is not well-typed unless we solve the -- (as yet unsolved) constraint Nat == F (?b 0). constr₁ : (n : Nat) → ?X n constr₁ = mkD (?b 0) -- Now we can form other constraints on ?X. This one simplifies to -- f (?b 0) 1 ≡ 0 (*) constr₂ : ?X 1 ≡ D 0 constr₂ = refl -- Finally, we pick the wrong solution for ?b, causing (*) to become -- f false 1 ≡ 0 -- which crashes with an impossible when we try to reduce the call to f. solve-b : ?b ≡ λ _ → false solve-b = refl
{ "alphanum_fraction": 0.5766233766, "avg_line_length": 24.5744680851, "ext": "agda", "hexsha": "16cf6948a9e3c6c43a77c55b9469b5d112d31309", "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/Bugs/Issue3027.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/Bugs/Issue3027.agda", "max_line_length": 74, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Bugs/Issue3027.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": 418, "size": 1155 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.ZCohomology.Groups.Torus where open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.ZCohomology.Groups.Connected open import Cubical.ZCohomology.MayerVietorisUnreduced open import Cubical.ZCohomology.Groups.Unit open import Cubical.ZCohomology.Groups.Sn open import Cubical.ZCohomology.Groups.Prelims open import Cubical.ZCohomology.KcompPrelims open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Foundations.Univalence open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Data.Sigma open import Cubical.Data.Int renaming (_+_ to _+ℤ_; +-comm to +ℤ-comm ; +-assoc to +ℤ-assoc) open import Cubical.Data.Nat open import Cubical.Data.Unit open import Cubical.Algebra.Group open import Cubical.HITs.Pushout open import Cubical.HITs.S1 open import Cubical.HITs.Sn open import Cubical.HITs.Susp open import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2) hiding (map) open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim2 to pElim2 ; ∣_∣ to ∣_∣₁) hiding (map) open import Cubical.HITs.Nullification open import Cubical.HITs.Truncation renaming (elim to trElim ; elim2 to trElim2 ; map to trMap ; rec to trRec) open GroupHom open GroupIso private module congLemma (key : Unit') where module K = lockedCohom key main : (n : ℕ) (p : Path (coHomK n) (0ₖ n) (0ₖ n)) → Path (K.+K n (0ₖ n) (0ₖ n) ≡ K.+K n (0ₖ n) (0ₖ n)) (cong (K.+K n (0ₖ n)) p) (cong (λ x → K.+K n x (0ₖ n)) p) main n = congIdLeft≡congIdRight (K.+K n) (K.-K n) (0ₖ n) (K.rUnitK n) (K.lUnitK n) (rUnitlUnit0K key n) --------- H⁰(T²) ------------ H⁰-T²≅ℤ : GroupIso (coHomGr 0 (S₊ 1 × S₊ 1)) intGroup H⁰-T²≅ℤ = H⁰-connected (base , base) λ (a , b) → pRec propTruncIsProp (λ id1 → pRec propTruncIsProp (λ id2 → ∣ ΣPathP (id1 , id2) ∣₁) (Sn-connected 0 b) ) (Sn-connected 0 a) --------- H¹(T²) ------------------------------- H¹-T²≅ℤ×ℤ : GroupIso (coHomGr 1 ((S₊ 1) × (S₊ 1))) (dirProd intGroup intGroup) H¹-T²≅ℤ×ℤ = theIso □ dirProdGroupIso (invGroupIso (Hⁿ-Sⁿ≅ℤ 0)) (H⁰-Sⁿ≅ℤ 0) where helper : (x : hLevelTrunc 3 (S₊ 1)) → ∣ (S¹map x) ∣ ≡ x helper = trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ a → refl typIso : Iso _ _ typIso = setTruncIso (curryIso ⋄ codomainIso S1→K₁≡S1×Int ⋄ toProdIso) ⋄ setTruncOfProdIso theIso : GroupIso _ _ fun (map theIso) = Iso.fun (typIso) isHom (map theIso) = sElim2 (λ _ _ → isOfHLevelPath 2 (isOfHLevelΣ 2 setTruncIsSet (λ _ → setTruncIsSet)) _ _) λ f g → ΣPathP ((cong ∣_∣₂ (funExt (λ x → helper (f (x , base) +ₖ g (x , base)) ∙ sym (cong₂ (λ x y → x +ₖ y) (helper (f (x , base))) (helper (g (x , base))))))) , (cong ∣_∣₂ (funExt (toPropElim (λ _ → isSetInt _ _) (cong winding (basechange-lemma2 (λ x → f (base , x)) (λ x → g (base , x)) λ x → S¹map x) ∙∙ winding-hom (basechange2⁻ (S¹map (f (base , base))) (λ i → S¹map (f (base , (loop i))))) (basechange2⁻ (S¹map (g (base , base))) (λ i → S¹map (g (base , (loop i))))) ∙∙ sym (addLemma (winding (basechange2⁻ (S¹map (f (base , base))) (λ i → S¹map (f (base , (loop i)))))) (winding (basechange2⁻ (S¹map (g (base , base))) (λ i → S¹map (g (base , (loop i)))))))))))) inv theIso = Iso.inv typIso rightInv theIso = Iso.rightInv typIso leftInv theIso = Iso.leftInv typIso ----------------------- H²(T²) ------------------------------ open import Cubical.Foundations.Equiv H²-T²≅ℤ : GroupIso (coHomGr 2 (S₊ 1 × S₊ 1)) intGroup H²-T²≅ℤ = invGroupIso (ℤ≅H²-T² unlock) where module _ (key : Unit') where module K = lockedCohom key private _+K_ : {n : ℕ} → coHomK n → coHomK n → coHomK n _+K_ {n = n} = K.+K n -K_ : {n : ℕ} → coHomK n → coHomK n -K_ {n = n} = K.-K n -H_ : {A : Type₀} {n : ℕ} → coHom n A → coHom n A -H_ {n = n} = K.-H n _+H_ : {A : Type₀} {n : ℕ} → coHom n A → coHom n A → coHom n A _+H_ {n = n} = K.+H n typIso : Iso _ _ typIso = helper ⋄ (invIso (prodIso (GroupIso→Iso (Hⁿ-S¹≅0 0)) (invIso (GroupIso→Iso (Hⁿ-Sⁿ≅ℤ 0)))) ⋄ ((invIso setTruncOfProdIso) ⋄ (invIso (setTruncIso (curryIso ⋄ codomainIso (S1→K2≡K2×K1' key) ⋄ toProdIso))))) where helper : Iso Int (Unit × Int) Iso.inv helper = snd Iso.fun helper x = tt , x Iso.leftInv helper _ = refl Iso.rightInv helper _ = refl mapIsHom : (x y : Int) → Iso.fun typIso (x +ℤ y) ≡ ((Iso.fun typIso x) +H Iso.fun typIso y) mapIsHom a b = (cong f ((GroupHom.isHom (GroupIso.map (invGroupIso (dirProdGroupIso (Hⁿ-S¹≅0 0) (invGroupIso (Hⁿ-Sⁿ≅ℤ 0))))) (_ , a) (_ , b)) ∙ λ i → guyId i , +H≡+ₕ key _ (~ i) (g a) (g b))) ∙∙ helper (g a) (g b) ∙∙ cong₂ (_+H_) (λ i → f (guyId2 (~ i) , g a)) λ i → f (guyId2 (~ i) , g b) where f = Iso.fun (((invIso setTruncOfProdIso ⋄ invIso (setTruncIso (curryIso ⋄ codomainIso (S1→K2≡K2×K1' key) ⋄ toProdIso))))) g = GroupIso.inv (invGroupIso (Hⁿ-Sⁿ≅ℤ 0)) isPropH²-S¹ : isProp (coHom 2 (S₊ 1)) isPropH²-S¹ = isPropRetract (fun (map (Hⁿ-S¹≅0 0))) (inv (Hⁿ-S¹≅0 0)) (leftInv (Hⁿ-S¹≅0 0)) isPropUnit guyId : ∣ _ ∣₂ ≡ 0ₕ 2 guyId = isPropH²-S¹ _ _ guyId2 : ∣ _ ∣₂ ≡ 0ₕ 2 guyId2 = isPropH²-S¹ _ _ helper : (x y : ∥ ((S₊ 1) → (hLevelTrunc 3 (S₊ 1) )) ∥₂) → f ((0ₕ 2) , (x +H y)) ≡ f ((0ₕ 2) , x) +H f (0ₕ 2 , y) helper = sElim2 (λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ f g i → ∣ (λ x → helper2 (f (fst x)) (g (fst x)) (snd x) i) ∣₂ where helper2 : (x y : coHomK 1) (s : S₊ 1) → Iso.inv (S1→K2≡K2×K1' key) (0ₖ 2 , x +K y) s ≡ (Iso.inv (S1→K2≡K2×K1' key) (0ₖ 2 , x)) s +K (Iso.inv (S1→K2≡K2×K1' key) (0ₖ 2 , y)) s helper2 = trElim2 (λ _ _ → isOfHLevelΠ 3 λ _ → isOfHLevelTrunc 4 _ _) λ a b → λ {base → cong₂ (_+K_) (sym (K.lUnitK _ 0₂)) (sym (K.lUnitK _ 0₂)) ; (loop i) j → hcomp (λ k → λ{ (i = i0) → cong₂ (_+K_) (sym (K.lUnitK _ 0₂)) (sym (K.lUnitK _ 0₂)) (j ∧ k) ; (i = i1) → cong₂ (_+K_) (sym (K.lUnitK _ 0₂)) (sym (K.lUnitK _ 0₂)) (j ∧ k) ; (j = i0) → 0₂ +K (Kn→ΩKn+1 1 (∣ a ∣ +K ∣ b ∣) i) ; (j = i1) → cong₂ (_+K_) (sym (K.lUnitK _ (Kn→ΩKn+1 1 ∣ a ∣ i))) (sym (K.lUnitK _ (Kn→ΩKn+1 1 ∣ b ∣ i))) k}) (helper3 ∣ a ∣ ∣ b ∣ j i)} where helper3 : (a b : coHomK 1) → cong (0₂ +K_) (Kn→ΩKn+1 1 (a +K b)) ≡ cong₂ (_+K_) (Kn→ΩKn+1 1 a) (Kn→ΩKn+1 1 b) helper3 a b = cong (cong (0₂ +K_)) (+K→∙ key 1 a b) ∙ (congFunct (0₂ +K_) (Kn→ΩKn+1 1 a) (Kn→ΩKn+1 1 b) ∙∙ (λ i → congLemma.main key 2 (Kn→ΩKn+1 1 a) i ∙ cong (_+K_ ∣ north ∣) (λ i → Kn→ΩKn+1 1 b i)) ∙∙ sym (cong₂Funct (_+K_) (Kn→ΩKn+1 1 a) (Kn→ΩKn+1 1 b))) ℤ≅H²-T² : GroupIso intGroup (coHomGr 2 (S₊ 1 × S₊ 1)) fun (map ℤ≅H²-T²) = Iso.fun typIso isHom (map ℤ≅H²-T²) = pm key mapIsHom where pm : (t : Unit') → ((x y : Int) → Iso.fun typIso (x +ℤ y) ≡ (lockedCohom.+H t _ (Iso.fun typIso x) (Iso.fun typIso y))) → isGroupHom intGroup (coHomGr 2 (S₊ 1 × S₊ 1)) (Iso.fun typIso) pm unlock p = p inv ℤ≅H²-T² = Iso.inv typIso rightInv ℤ≅H²-T² = Iso.rightInv typIso leftInv ℤ≅H²-T² = Iso.leftInv typIso private to₂ : coHom 2 (S₊ 1 × S₊ 1) → Int to₂ = fun (map H²-T²≅ℤ) from₂ : Int → coHom 2 (S₊ 1 × S₊ 1) from₂ = inv H²-T²≅ℤ to₁ : coHom 1 (S₊ 1 × S₊ 1) → Int × Int to₁ = fun (map H¹-T²≅ℤ×ℤ) from₁ : Int × Int → coHom 1 (S₊ 1 × S₊ 1) from₁ = inv H¹-T²≅ℤ×ℤ to₀ : coHom 0 (S₊ 1 × S₊ 1) → Int to₀ = fun (map H⁰-T²≅ℤ) from₀ : Int → coHom 0 (S₊ 1 × S₊ 1) from₀ = inv H⁰-T²≅ℤ {- -- Compute fast: test : to₁ (from₁ (0 , 1) +ₕ from₁ (1 , 0)) ≡ (1 , 1) test = refl test2 : to₁ (from₁ (5 , 1) +ₕ from₁ (-2 , 3)) ≡ (3 , 4) test2 = refl -- Will not compute: test3 : to₂ (from₂ 0) ≡ 0 test3 = refl -}
{ "alphanum_fraction": 0.4571595672, "avg_line_length": 42.7458333333, "ext": "agda", "hexsha": "2e4a5934a02b7f4f31cffdd0c2852f9bae093e51", "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": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ayberkt/cubical", "max_forks_repo_path": "Cubical/ZCohomology/Groups/Torus.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "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": "ayberkt/cubical", "max_issues_repo_path": "Cubical/ZCohomology/Groups/Torus.agda", "max_line_length": 152, "max_stars_count": null, "max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ayberkt/cubical", "max_stars_repo_path": "Cubical/ZCohomology/Groups/Torus.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3685, "size": 10259 }
------------------------------------------------------------------------------ -- Properties related with lists ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.List.PropertiesI where open import Common.FOL.Relation.Binary.EqReasoning open import FOTC.Base open import FOTC.Base.List open import FOTC.Base.List.PropertiesI open import FOTC.Base.PropertiesI open import FOTC.Data.Conat open import FOTC.Data.List open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Nat.Inequalities.EliminationPropertiesI open import FOTC.Data.Nat.Inequalities.PropertiesI open import FOTC.Data.Nat.PropertiesI open import FOTC.Data.Nat.Type ------------------------------------------------------------------------------ -- Congruence properties ++-leftCong : ∀ {xs ys zs} → xs ≡ ys → xs ++ zs ≡ ys ++ zs ++-leftCong refl = refl ++-rightCong : ∀ {xs ys zs} → ys ≡ zs → xs ++ ys ≡ xs ++ zs ++-rightCong refl = refl mapCong₂ : ∀ {f xs ys} → xs ≡ ys → map f xs ≡ map f ys mapCong₂ refl = refl revCong₁ : ∀ {xs ys zs} → xs ≡ ys → rev xs zs ≡ rev ys zs revCong₁ refl = refl revCong₂ : ∀ {xs ys zs} → ys ≡ zs → rev xs ys ≡ rev xs zs revCong₂ refl = refl reverseCong : ∀ {xs ys} → xs ≡ ys → reverse xs ≡ reverse ys reverseCong refl = refl reverse'Cong : ∀ {xs ys} → xs ≡ ys → reverse' xs ≡ reverse' ys reverse'Cong refl = refl lengthCong : ∀ {xs ys} → xs ≡ ys → length xs ≡ length ys lengthCong refl = refl ------------------------------------------------------------------------------ -- Totality properties lengthList-N : ∀ {xs} → List xs → N (length xs) lengthList-N lnil = subst N (sym length-[]) nzero lengthList-N (lcons x {xs} Lxs) = subst N (sym (length-∷ x xs)) (nsucc (lengthList-N Lxs)) ++-List : ∀ {xs ys} → List xs → List ys → List (xs ++ ys) ++-List {ys = ys} lnil Lys = subst List (sym (++-[] ys)) Lys ++-List {ys = ys} (lcons x {xs} Lxs) Lys = subst List (sym (++-∷ x xs ys)) (lcons x (++-List Lxs Lys)) map-List : ∀ f {xs} → List xs → List (map f xs) map-List f lnil = subst List (sym (map-[] f)) lnil map-List f (lcons x {xs} Lxs) = subst List (sym (map-∷ f x xs)) (lcons (f · x) (map-List f Lxs)) rev-List : ∀ {xs ys} → List xs → List ys → List (rev xs ys) rev-List {ys = ys} lnil Lys = subst List (sym (rev-[] ys)) Lys rev-List {ys = ys} (lcons x {xs} Lxs) Lys = subst List (sym (rev-∷ x xs ys)) (rev-List Lxs (lcons x Lys)) reverse-List : ∀ {xs} → List xs → List (reverse xs) reverse-List Lxs = rev-List Lxs lnil reverse'-List : ∀ {xs} → List xs → List (reverse' xs) reverse'-List lnil = subst List (sym reverse'-[]) lnil reverse'-List (lcons x {xs} Lxs) = subst List (sym (reverse'-∷ x xs)) (++-List (reverse'-List Lxs) (lcons x lnil)) -- Length properties lg-x<lg-x∷xs : ∀ x {xs} → List xs → length xs < length (x ∷ xs) lg-x<lg-x∷xs x lnil = lt (length []) (length (x ∷ [])) ≡⟨ subst₂ (λ t t' → lt (length []) (length (x ∷ [])) ≡ lt t t') length-[] (length-∷ x []) refl ⟩ lt zero (succ₁ (length [])) ≡⟨ lt-0S (length []) ⟩ true ∎ lg-x<lg-x∷xs x (lcons y {xs} Lxs) = lt (length (y ∷ xs)) (length (x ∷ y ∷ xs)) ≡⟨ subst₂ (λ t t' → lt (length (y ∷ xs)) (length (x ∷ y ∷ xs)) ≡ lt t t') (length-∷ y xs) (length-∷ x (y ∷ xs)) refl ⟩ lt (succ₁ (length xs)) (succ₁ (length (y ∷ xs))) ≡⟨ lt-SS (length xs) (length (y ∷ xs)) ⟩ lt (length xs) (length (y ∷ xs)) ≡⟨ lg-x<lg-x∷xs y Lxs ⟩ true ∎ lg-xs<lg-[]→⊥ : ∀ {xs} → List xs → ¬ (length xs < length []) lg-xs<lg-[]→⊥ lnil lg-[]<lg-[] = ⊥-elim (0<0→⊥ helper) where helper : zero < zero helper = lt zero zero ≡⟨ subst₂ (λ t t' → lt zero zero ≡ lt t t') (sym length-[]) (sym length-[]) refl ⟩ lt (length []) (length []) ≡⟨ lg-[]<lg-[] ⟩ true ∎ lg-xs<lg-[]→⊥ (lcons x {xs} Lxs) lg-x∷xs<lg-[] = ⊥-elim (S<0→⊥ helper) where helper : succ₁ (length xs) < zero helper = lt (succ₁ (length xs)) zero ≡⟨ subst₂ (λ t t' → lt (succ₁ (length xs)) zero ≡ lt t t') (sym (length-∷ x xs)) (sym length-[]) refl ⟩ lt (length (x ∷ xs)) (length []) ≡⟨ lg-x∷xs<lg-[] ⟩ true ∎ lg-xs≡∞→lg-x∷xs≡∞ : ∀ x xs → length xs ≡ ∞ → length (x ∷ xs) ≡ ∞ lg-xs≡∞→lg-x∷xs≡∞ x xs h = length (x ∷ xs) ≡⟨ length-∷ x xs ⟩ succ₁ (length xs) ≡⟨ succCong h ⟩ succ₁ ∞ ≡⟨ sym ∞-eq ⟩ ∞ ∎ -- Append properties ++-leftIdentity : ∀ xs → [] ++ xs ≡ xs ++-leftIdentity = ++-[] ++-rightIdentity : ∀ {xs} → List xs → xs ++ [] ≡ xs ++-rightIdentity lnil = ++-leftIdentity [] ++-rightIdentity (lcons x {xs} Lxs) = (x ∷ xs) ++ [] ≡⟨ ++-∷ x xs [] ⟩ x ∷ (xs ++ []) ≡⟨ ∷-rightCong (++-rightIdentity Lxs) ⟩ x ∷ xs ∎ ++-assoc : ∀ {xs} → List xs → ∀ ys zs → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs) ++-assoc lnil ys zs = ([] ++ ys) ++ zs ≡⟨ ++-leftCong (++-leftIdentity ys) ⟩ ys ++ zs ≡⟨ sym (++-leftIdentity (ys ++ zs)) ⟩ [] ++ ys ++ zs ∎ ++-assoc (lcons x {xs} Lxs) ys zs = ((x ∷ xs) ++ ys) ++ zs ≡⟨ ++-leftCong (++-∷ x xs ys) ⟩ (x ∷ (xs ++ ys)) ++ zs ≡⟨ ++-∷ x (xs ++ ys) zs ⟩ x ∷ ((xs ++ ys) ++ zs) ≡⟨ ∷-rightCong (++-assoc Lxs ys zs) ⟩ x ∷ (xs ++ ys ++ zs) ≡⟨ sym (++-∷ x xs (ys ++ zs)) ⟩ (x ∷ xs) ++ ys ++ zs ∎ -- Map properties map-++ : ∀ f {xs} → List xs → ∀ ys → map f (xs ++ ys) ≡ map f xs ++ map f ys map-++ f lnil ys = map f ([] ++ ys) ≡⟨ mapCong₂ (++-leftIdentity ys) ⟩ map f ys ≡⟨ sym (++-leftIdentity (map f ys)) ⟩ [] ++ map f ys ≡⟨ ++-leftCong (sym (map-[] f)) ⟩ map f [] ++ map f ys ∎ map-++ f (lcons x {xs} Lxs) ys = map f ((x ∷ xs) ++ ys) ≡⟨ mapCong₂ (++-∷ x xs ys) ⟩ map f (x ∷ xs ++ ys) ≡⟨ map-∷ f x (xs ++ ys) ⟩ f · x ∷ map f (xs ++ ys) ≡⟨ ∷-rightCong (map-++ f Lxs ys) ⟩ f · x ∷ (map f xs ++ map f ys) ≡⟨ sym (++-∷ (f · x) (map f xs) (map f ys)) ⟩ (f · x ∷ map f xs) ++ map f ys ≡⟨ ++-leftCong (sym (map-∷ f x xs)) ⟩ map f (x ∷ xs) ++ map f ys ∎ map≡[] : ∀ {f xs} → List xs → map f xs ≡ [] → xs ≡ [] map≡[] lnil h = refl map≡[] {f} (lcons x {xs} Lxs) h = ⊥-elim ([]≢cons (trans (sym h) (map-∷ f x xs))) -- Reverse properties reverse-[x]≡[x] : ∀ x → reverse (x ∷ []) ≡ x ∷ [] reverse-[x]≡[x] x = rev (x ∷ []) [] ≡⟨ rev-∷ x [] [] ⟩ rev [] (x ∷ []) ≡⟨ rev-[] (x ∷ []) ⟩ x ∷ [] ∎ rev-++ : ∀ {xs} → List xs → ∀ ys → rev xs ys ≡ rev xs [] ++ ys rev-++ lnil ys = rev [] ys ≡⟨ rev-[] ys ⟩ ys ≡⟨ sym (++-leftIdentity ys) ⟩ [] ++ ys ≡⟨ ++-leftCong (sym (rev-[] [])) ⟩ rev [] [] ++ ys ∎ rev-++ (lcons x {xs} Lxs) ys = rev (x ∷ xs) ys ≡⟨ rev-∷ x xs ys ⟩ rev xs (x ∷ ys) ≡⟨ rev-++ Lxs (x ∷ ys) ⟩ rev xs [] ++ x ∷ ys ≡⟨ subst (λ t → rev xs [] ++ x ∷ ys ≡ rev xs [] ++ t) (sym ( (x ∷ []) ++ ys ≡⟨ ++-∷ x [] ys ⟩ x ∷ ([] ++ ys) ≡⟨ ∷-rightCong (++-leftIdentity ys) ⟩ x ∷ ys ∎ ) ) refl ⟩ rev xs [] ++ (x ∷ []) ++ ys ≡⟨ sym (++-assoc (rev-List Lxs lnil) (x ∷ []) ys) ⟩ (rev xs [] ++ (x ∷ [])) ++ ys ≡⟨ ++-leftCong (sym (rev-++ Lxs (x ∷ []))) ⟩ rev xs (x ∷ []) ++ ys ≡⟨ ++-leftCong (sym (rev-∷ x xs [])) ⟩ rev (x ∷ xs) [] ++ ys ∎ reverse-++ : ∀ {xs ys} → List xs → List ys → reverse (xs ++ ys) ≡ reverse ys ++ reverse xs reverse-++ {ys = ys} lnil Lys = reverse ([] ++ ys) ≡⟨ reverseCong (++-leftIdentity ys) ⟩ reverse ys ≡⟨ sym (++-rightIdentity (reverse-List Lys)) ⟩ reverse ys ++ [] ≡⟨ ++-rightCong (sym (rev-[] [])) ⟩ reverse ys ++ reverse [] ∎ reverse-++ (lcons x {xs} Lxs) lnil = reverse ((x ∷ xs) ++ []) ≡⟨ reverseCong (++-rightIdentity (lcons x Lxs)) ⟩ reverse (x ∷ xs) ≡⟨ sym (++-leftIdentity (reverse (x ∷ xs))) ⟩ [] ++ reverse (x ∷ xs) ≡⟨ ++-leftCong (sym (rev-[] [])) ⟩ reverse [] ++ reverse (x ∷ xs) ∎ reverse-++ (lcons x {xs} Lxs) (lcons y {ys} Lys) = reverse ((x ∷ xs) ++ y ∷ ys) ≡⟨ refl ⟩ rev ((x ∷ xs) ++ y ∷ ys) [] ≡⟨ revCong₁ (++-∷ x xs (y ∷ ys)) ⟩ rev (x ∷ (xs ++ y ∷ ys)) [] ≡⟨ rev-∷ x (xs ++ y ∷ ys) [] ⟩ rev (xs ++ y ∷ ys) (x ∷ []) ≡⟨ rev-++ (++-List Lxs (lcons y Lys)) (x ∷ []) ⟩ rev (xs ++ y ∷ ys) [] ++ (x ∷ []) ≡⟨ refl ⟩ reverse (xs ++ y ∷ ys) ++ (x ∷ []) ≡⟨ ++-leftCong (reverse-++ Lxs (lcons y Lys)) ⟩ (reverse (y ∷ ys) ++ reverse xs) ++ x ∷ [] ≡⟨ ++-assoc (reverse-List (lcons y Lys)) (reverse xs) (x ∷ []) ⟩ reverse (y ∷ ys) ++ reverse xs ++ x ∷ [] ≡⟨ refl ⟩ reverse (y ∷ ys) ++ rev xs [] ++ x ∷ [] ≡⟨ ++-rightCong (sym (rev-++ Lxs (x ∷ []))) ⟩ reverse (y ∷ ys) ++ rev xs (x ∷ []) ≡⟨ ++-rightCong (sym (rev-∷ x xs [])) ⟩ reverse (y ∷ ys) ++ rev (x ∷ xs) [] ≡⟨ refl ⟩ reverse (y ∷ ys) ++ reverse (x ∷ xs) ∎ reverse-∷ : ∀ x {ys} → List ys → reverse (x ∷ ys) ≡ reverse ys ++ (x ∷ []) reverse-∷ x lnil = rev (x ∷ []) [] ≡⟨ rev-∷ x [] [] ⟩ rev [] (x ∷ []) ≡⟨ rev-[] (x ∷ []) ⟩ x ∷ [] ≡⟨ sym (++-leftIdentity (x ∷ [])) ⟩ [] ++ x ∷ [] ≡⟨ ++-leftCong (sym (rev-[] [])) ⟩ rev [] [] ++ x ∷ [] ∎ reverse-∷ x (lcons y {ys} Lys) = sym prf where prf : reverse (y ∷ ys) ++ x ∷ [] ≡ reverse (x ∷ y ∷ ys) prf = reverse (y ∷ ys) ++ x ∷ [] ≡⟨ ++-rightCong (sym (reverse-[x]≡[x] x)) ⟩ (reverse (y ∷ ys) ++ reverse (x ∷ [])) ≡⟨ sym (reverse-++ (lcons x lnil) (lcons y Lys)) ⟩ reverse ((x ∷ []) ++ (y ∷ ys)) ≡⟨ reverseCong (++-∷ x [] (y ∷ ys)) ⟩ reverse (x ∷ ([] ++ (y ∷ ys))) ≡⟨ reverseCong (∷-rightCong (++-leftIdentity (y ∷ ys))) ⟩ reverse (x ∷ y ∷ ys) ∎ reverse'-involutive-helper : ∀ x {ys} → List ys → reverse' (ys ++ x ∷ []) ≡ x ∷ reverse' ys reverse'-involutive-helper x lnil = reverse' ([] ++ x ∷ []) ≡⟨ reverse'Cong (++-[] (x ∷ [])) ⟩ reverse' (x ∷ []) ≡⟨ reverse'-∷ x [] ⟩ reverse' [] ++ x ∷ [] ≡⟨ ++-leftCong reverse'-[] ⟩ [] ++ x ∷ [] ≡⟨ ++-[] (x ∷ []) ⟩ x ∷ [] ≡⟨ ∷-rightCong (sym reverse'-[]) ⟩ x ∷ reverse' [] ∎ reverse'-involutive-helper x (lcons y {ys} Lys) = reverse' ((y ∷ ys) ++ x ∷ []) ≡⟨ reverse'Cong (++-∷ y ys (x ∷ [])) ⟩ reverse' (y ∷ ys ++ x ∷ []) ≡⟨ reverse'-∷ y (ys ++ x ∷ []) ⟩ reverse' (ys ++ x ∷ []) ++ y ∷ [] ≡⟨ ++-leftCong (reverse'-involutive-helper x Lys) ⟩ (x ∷ reverse' ys) ++ (y ∷ []) ≡⟨ ++-∷ x (reverse' ys) (y ∷ []) ⟩ x ∷ (reverse' ys ++ y ∷ []) ≡⟨ ∷-rightCong (sym (reverse'-∷ y ys)) ⟩ x ∷ reverse' (y ∷ ys) ∎ -- Adapted from (Bird and Wadler, 1988 §5.4.2). reverse'-involutive : ∀ {xs} → List xs → reverse' (reverse' xs) ≡ xs reverse'-involutive lnil = reverse' (reverse' []) ≡⟨ reverse'Cong reverse'-[] ⟩ reverse' [] ≡⟨ reverse'-[] ⟩ [] ∎ reverse'-involutive (lcons x {xs} Lxs) = reverse' (reverse' (x ∷ xs)) ≡⟨ reverse'Cong (reverse'-∷ x xs) ⟩ reverse' (reverse' xs ++ (x ∷ [])) ≡⟨ reverse'-involutive-helper x (reverse'-List Lxs) ⟩ x ∷ reverse' (reverse' xs) ≡⟨ ∷-rightCong (reverse'-involutive Lxs) ⟩ x ∷ xs ∎ ------------------------------------------------------------------------------ -- References -- Bird, R. and Wadler, P. (1988). Introduction to Functional -- Programming. Prentice Hall International.
{ "alphanum_fraction": 0.4509383838, "avg_line_length": 34.3205882353, "ext": "agda", "hexsha": "f1af226446ad6024a5f0b1f786f74e3c729fb287", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Data/List/PropertiesI.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Data/List/PropertiesI.agda", "max_line_length": 81, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/List/PropertiesI.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": 4658, "size": 11669 }
module Vec where data Nat : Set where zero : Nat suc : Nat -> Nat data Vec (A : Set) : Nat -> Set where ε : Vec A zero _►_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n) vec : {A : Set}{n : Nat} -> A -> Vec A n vec {n = zero} x = ε vec {n = suc n} x = x ► vec x _<*>_ : {A B : Set}{n : Nat} -> Vec (A -> B) n -> Vec A n -> Vec B n ε <*> ε = ε (f ► fs) <*> (x ► xs) = f x ► (fs <*> xs) -- map -- zip
{ "alphanum_fraction": 0.4312354312, "avg_line_length": 19.5, "ext": "agda", "hexsha": "e98a58dfbf2f028a317a3b4014aee97aed476e5f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/tactics/bool/Vec.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/tactics/bool/Vec.agda", "max_line_length": 68, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/tactics/bool/Vec.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": 176, "size": 429 }
module MisformedTypeSignature where postulate A : Set (f g) : A
{ "alphanum_fraction": 0.7424242424, "avg_line_length": 11, "ext": "agda", "hexsha": "5e4b9a49121371049ddb18f582ba4a75f868adc4", "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/MisformedTypeSignature.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/MisformedTypeSignature.agda", "max_line_length": 35, "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/MisformedTypeSignature.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 19, "size": 66 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Vectors defined as functions from a finite set to a type. ------------------------------------------------------------------------ -- This implementation is designed for reasoning about fixed-size -- vectors where ease of retrieval of elements is prioritised. -- See `Data.Vec` for an alternative implementation using inductive -- data-types, which is more suitable for reasoning about vectors that -- will grow or shrink in size. {-# OPTIONS --without-K --safe #-} module Data.Vec.Functional where open import Data.Fin.Base using (Fin; zero; suc; splitAt; punchIn) open import Data.List.Base as L using (List) open import Data.Nat.Base using (ℕ; zero; suc; _+_) open import Data.Product using (Σ; ∃; _×_; _,_; proj₁; proj₂) open import Data.Sum.Base using (_⊎_; inj₁; inj₂; [_,_]) open import Data.Vec.Base as V using (Vec) open import Function open import Level using (Level) infixr 5 _∷_ _++_ infixl 4 _⊛_ private variable a b c : Level A : Set a B : Set b C : Set c ------------------------------------------------------------------------ -- Definition Vector : Set a → ℕ → Set a Vector A n = Fin n → A ------------------------------------------------------------------------ -- Conversion toVec : ∀ {n} → Vector A n → Vec A n toVec = V.tabulate fromVec : ∀ {n} → Vec A n → Vector A n fromVec = V.lookup toList : ∀ {n} → Vector A n → List A toList = L.tabulate fromList : ∀ (xs : List A) → Vector A (L.length xs) fromList = L.lookup ------------------------------------------------------------------------ -- Construction and deconstruction [] : Vector A zero [] () _∷_ : ∀ {n} → A → Vector A n → Vector A (suc n) (x ∷ xs) zero = x (x ∷ xs) (suc i) = xs i head : ∀ {n} → Vector A (suc n) → A head xs = xs zero tail : ∀ {n} → Vector A (suc n) → Vector A n tail xs = xs ∘ suc uncons : ∀ {n} → Vector A (suc n) → A × Vector A n uncons xs = head xs , tail xs replicate : ∀ {n} → A → Vector A n replicate = const remove : ∀ {n} → Fin (suc n) → Vector A (suc n) → Vector A n remove i t = t ∘ punchIn i ------------------------------------------------------------------------ -- Transformations map : (A → B) → ∀ {n} → Vector A n → Vector B n map f xs = f ∘ xs _++_ : ∀ {m n} → Vector A m → Vector A n → Vector A (m + n) _++_ {m = m} xs ys i = [ xs , ys ] (splitAt m i) foldr : (A → B → B) → B → ∀ {n} → Vector A n → B foldr f z {n = zero} xs = z foldr f z {n = suc n} xs = f (head xs) (foldr f z (tail xs)) foldl : (B → A → B) → B → ∀ {n} → Vector A n → B foldl f z {n = zero} xs = z foldl f z {n = suc n} xs = foldl f (f z (head xs)) (tail xs) rearrange : ∀ {m n} → (Fin m → Fin n) → Vector A n → Vector A m rearrange r xs = xs ∘ r _⊛_ : ∀ {n} → Vector (A → B) n → Vector A n → Vector B n _⊛_ = _ˢ_ zipWith : (A → B → C) → ∀ {n} → Vector A n → Vector B n → Vector C n zipWith f xs ys i = f (xs i) (ys i) zip : ∀ {n} → Vector A n → Vector B n → Vector (A × B) n zip = zipWith _,_
{ "alphanum_fraction": 0.5154605263, "avg_line_length": 27.3873873874, "ext": "agda", "hexsha": "1bc0eef9f58cda9c3bc9c1f0036aa8c8d2d74fa4", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Vec/Functional.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Vec/Functional.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Vec/Functional.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": 948, "size": 3040 }
open import Type open import Logic.Classical as Logic using (Classical) open import Logic.Predicate as Logic using () module Formalization.ClassicalPropositionalLogic ⦃ classical : ∀{ℓ} → Logic.∀ₗ(Classical{ℓ}) ⦄ where import Lvl open import Data open import Data.Boolean import Data.Boolean.Operators open import Data.Boolean.Stmt open import Data.Either as Either using (_‖_ ; Left ; Right) open import Data.Tuple as Tuple using () private module BoolOp = Data.Boolean.Operators.Logic open import Functional open import Function.Names using (_⊜_) open import Logic open import Logic.Propositional as Logic using (_←_) open import Logic.Propositional.Theorems as Logic using () open import Logic.Predicate.Theorems as Logic using () open import Relator.Equals open import Relator.Equals.Proofs open import Relator.Equals.Proofs.Equiv open import Sets.PredicateSet using (PredSet ; _∈_ ; _∉_ ; _∪_ ; _∪•_ ; _∖_ ; _⊆_ ; _⊇_ ; ∅ ; [≡]-to-[⊆] ; [≡]-to-[⊇]) renaming (•_ to singleton ; _≡_ to _≡ₛ_) open Sets.PredicateSet.BoundedQuantifiers open import Structure.Relator.Properties open import Syntax.Function open import Type.Properties.Decidable.Proofs open import Type.Properties.Decidable open import Type.Size.Countable private variable ℓₚ ℓ ℓ₁ ℓ₂ : Lvl.Level open import Formalization.ClassicalPropositionalLogic.NaturalDeduction open import Formalization.ClassicalPropositionalLogic.NaturalDeduction.Proofs open import Formalization.ClassicalPropositionalLogic.Syntax open import Formalization.ClassicalPropositionalLogic.Syntax.Proofs open import Formalization.ClassicalPropositionalLogic.Semantics open import Formalization.ClassicalPropositionalLogic.Semantics.Proofs import Formalization.ClassicalPropositionalLogic.TruthTable as TruthTable instance _ = classical-to-decidable instance _ = classical-to-decider module NaturalDeduction where private variable P : Type{ℓₚ} private variable Γ Γ₁ Γ₂ : Formulas(P){ℓ} private variable φ ψ : Formula(P) [⊢]-functionₗ : (Γ₁ ≡ₛ Γ₂) → ((Γ₁ ⊢_) ≡ₛ (Γ₂ ⊢_)) [⊢]-functionₗ Γ₁Γ₂ = Logic.[↔]-intro (weaken (Logic.[↔]-to-[←] Γ₁Γ₂)) (weaken (Logic.[↔]-to-[→] Γ₁Γ₂)) [⊢]-compose : (Γ ⊢ φ) → ((Γ ∪ singleton(φ)) ⊢ ψ) → (Γ ⊢ ψ) [⊢]-compose Γφ Γφψ = [∨]-elim Γφψ Γφψ ([∨]-introₗ Γφ) -- TODO: Is this provable? Does one need to include it in the definition of (_⊢_)? Is it even possible to include it? -- [⊢]-hypothesis : ((Γ ⊢ φ) → (Γ ⊢ ψ)) → ((Γ ∪ singleton(φ)) ⊢ ψ) -- [⊢]-hypothesis hyp = {!!} [⊢][→]-intro-from-[∨] : (Γ ⊢ ¬ φ) Logic.∨ (Γ ⊢ ψ) → (Γ ⊢ (φ ⟶ ψ)) [⊢][→]-intro-from-[∨] {Γ = Γ}{φ}{ψ} (Left x) = [⟶]-intro ([⊥]-elim ([⊥]-intro (direct (Right [≡]-intro)) (weaken-union {Γ₂ = singleton φ} x))) [⊢][→]-intro-from-[∨] (Right x) = [⟶]-intro (weaken-union x) -- A smallest finite set of assumptions that is able to derive a formula. finiteAssumptions : ∀{φ : Formula(P)} → (Γ ⊢ φ) → Formulas(P){Lvl.of(P)} finiteAssumptions {φ = φ} (direct _) = singleton(φ) finiteAssumptions {φ = .⊤} [⊤]-intro = ∅ finiteAssumptions {φ = .⊥} ([⊥]-intro p q) = finiteAssumptions p ∪ finiteAssumptions q finiteAssumptions {φ = φ} ([⊥]-elim p) = finiteAssumptions p finiteAssumptions {φ = ¬ φ} ([¬]-intro{φ = φ} p) = finiteAssumptions p ∖ singleton(φ) finiteAssumptions {φ = φ} ([¬]-elim {φ = φ} p) = finiteAssumptions p ∖ singleton(¬ φ) finiteAssumptions {φ = .(_ ∧ _)} ([∧]-intro p q) = finiteAssumptions p ∪ finiteAssumptions q finiteAssumptions {φ = φ} ([∧]-elimₗ p) = finiteAssumptions p finiteAssumptions {φ = φ} ([∧]-elimᵣ p) = finiteAssumptions p finiteAssumptions {φ = .(_ ∨ _)} ([∨]-introₗ p) = finiteAssumptions p finiteAssumptions {φ = .(_ ∨ _)} ([∨]-introᵣ p) = finiteAssumptions p finiteAssumptions {φ = _} ([∨]-elim {φ = φ}{ψ} p q r) = ((finiteAssumptions p ∖ singleton(φ)) ∪ (finiteAssumptions q ∖ singleton(ψ))) ∪ finiteAssumptions r finiteAssumptions {φ = .(_ ⟶ _)} ([⟶]-intro{φ = φ} p) = finiteAssumptions p ∖ singleton(φ) finiteAssumptions {φ = φ} ([⟶]-elim p q) = finiteAssumptions p ∪ finiteAssumptions q finiteAssumptions {φ = .(_ ⟷ _)} ([⟷]-intro{φ = φ}{ψ} p q) = (finiteAssumptions p ∖ singleton(ψ)) ∪ (finiteAssumptions q ∖ singleton(φ)) finiteAssumptions {φ = φ} ([⟷]-elimₗ p q) = finiteAssumptions p ∪ finiteAssumptions q finiteAssumptions {φ = φ} ([⟷]-elimᵣ p q) = finiteAssumptions p ∪ finiteAssumptions q finiteAssumptions-correctness : (p : (Γ ⊢ φ)) → (finiteAssumptions p ⊢ φ) finiteAssumptions-correctness (direct x) = direct [≡]-intro finiteAssumptions-correctness [⊤]-intro = [⊤]-intro finiteAssumptions-correctness ([⊥]-intro p q) = [⊥]-intro (weaken Left (finiteAssumptions-correctness p)) (weaken Right (finiteAssumptions-correctness q)) finiteAssumptions-correctness ([⊥]-elim p) = [⊥]-elim (finiteAssumptions-correctness p) finiteAssumptions-correctness ([¬]-intro p) = [¬]-intro (weaken (Logic.[↔]-to-[←] ([∖][∪]-is-[∪] {A = finiteAssumptions p}{B = singleton _}) ∘ Logic.[∨]-introₗ) (finiteAssumptions-correctness p)) finiteAssumptions-correctness ([¬]-elim p) = [¬]-elim (weaken (Logic.[↔]-to-[←] ([∖][∪]-is-[∪] {A = finiteAssumptions p}{B = singleton _}) ∘ Logic.[∨]-introₗ) (finiteAssumptions-correctness p)) finiteAssumptions-correctness ([∧]-intro p q) = [∧]-intro (weaken Left (finiteAssumptions-correctness p)) (weaken Right (finiteAssumptions-correctness q)) finiteAssumptions-correctness ([∧]-elimₗ p) = [∧]-elimₗ (finiteAssumptions-correctness p) finiteAssumptions-correctness ([∧]-elimᵣ p) = [∧]-elimᵣ (finiteAssumptions-correctness p) finiteAssumptions-correctness ([∨]-introₗ p) = [∨]-introₗ (finiteAssumptions-correctness p) finiteAssumptions-correctness ([∨]-introᵣ p) = [∨]-introᵣ (finiteAssumptions-correctness p) finiteAssumptions-correctness ([∨]-elim{φ = φ}{ψ} p q r) = [∨]-elim (weaken (sl ∘ Left) (finiteAssumptions-correctness p)) (weaken (sr ∘ Left) (finiteAssumptions-correctness q)) (weaken Right (finiteAssumptions-correctness r)) where postulate sl : (finiteAssumptions p ∪ singleton(φ)) ⊆ ((((finiteAssumptions p ∖ singleton(φ)) ∪ (finiteAssumptions q ∖ singleton(ψ))) ∪ finiteAssumptions r) ∪ singleton(φ)) postulate sr : (finiteAssumptions q ∪ singleton(ψ)) ⊆ ((((finiteAssumptions p ∖ singleton(φ)) ∪ (finiteAssumptions q ∖ singleton(ψ))) ∪ finiteAssumptions r) ∪ singleton(ψ)) finiteAssumptions-correctness ([⟶]-intro p) = [⟶]-intro (weaken (Logic.[↔]-to-[←] ([∖][∪]-is-[∪] {A = finiteAssumptions p}{B = singleton _}) ∘ Logic.[∨]-introₗ) (finiteAssumptions-correctness p)) finiteAssumptions-correctness ([⟶]-elim p q) = [⟶]-elim (weaken Left (finiteAssumptions-correctness p)) (weaken Right (finiteAssumptions-correctness q)) finiteAssumptions-correctness ([⟷]-intro p q) = [⟷]-intro (weaken (sl ∘ Left) (finiteAssumptions-correctness p)) (weaken (sr ∘ Left) (finiteAssumptions-correctness q)) where postulate sl : (finiteAssumptions p ∪ singleton(φ)) ⊆ (((finiteAssumptions p ∖ singleton(φ)) ∪ (finiteAssumptions q ∖ singleton(ψ))) ∪ singleton(φ)) postulate sr : (finiteAssumptions q ∪ singleton(ψ)) ⊆ (((finiteAssumptions p ∖ singleton(φ)) ∪ (finiteAssumptions q ∖ singleton(ψ))) ∪ singleton(ψ)) finiteAssumptions-correctness ([⟷]-elimₗ p q) = [⟷]-elimₗ (weaken Left (finiteAssumptions-correctness p)) (weaken Right (finiteAssumptions-correctness q)) finiteAssumptions-correctness ([⟷]-elimᵣ p q) = [⟷]-elimᵣ (weaken Left (finiteAssumptions-correctness p)) (weaken Right (finiteAssumptions-correctness q)) finiteAssumptions-subset : (p : (Γ ⊢ φ)) → (finiteAssumptions p ⊆ Γ) finiteAssumptions-subset (direct x) = \{[≡]-intro → x} finiteAssumptions-subset [⊤]-intro = empty finiteAssumptions-subset ([⊥]-intro p q) = [∪]-subset (\{x} → finiteAssumptions-subset p {x}) (\{x} → finiteAssumptions-subset q {x}) finiteAssumptions-subset ([⊥]-elim p) = finiteAssumptions-subset p finiteAssumptions-subset ([¬]-intro p) = [∪][∖]-invertᵣ-[⊆] {A = finiteAssumptions p} (finiteAssumptions-subset p) finiteAssumptions-subset ([¬]-elim p) = [∪][∖]-invertᵣ-[⊆] {A = finiteAssumptions p} (finiteAssumptions-subset p) finiteAssumptions-subset ([∧]-intro p q) = [∪]-subset (\{x} → finiteAssumptions-subset p {x}) (\{x} → finiteAssumptions-subset q {x}) finiteAssumptions-subset ([∧]-elimₗ p) = finiteAssumptions-subset p finiteAssumptions-subset ([∧]-elimᵣ p) = finiteAssumptions-subset p finiteAssumptions-subset ([∨]-introₗ p) = finiteAssumptions-subset p finiteAssumptions-subset ([∨]-introᵣ p) = finiteAssumptions-subset p finiteAssumptions-subset{Γ = Γ} ([∨]-elim p q r) = [∪]-subset (\{x} → [∪]-subset{C = Γ} ([∪][∖]-invertᵣ-[⊆] {B = Γ} (finiteAssumptions-subset p)) ([∪][∖]-invertᵣ-[⊆] {B = Γ} (finiteAssumptions-subset q)) {x}) (finiteAssumptions-subset r) finiteAssumptions-subset ([⟶]-intro p) = \{(Logic.[∧]-intro fpx φx) → Logic.[∨]-elim id (Logic.[⊥]-elim ∘ φx) (finiteAssumptions-subset p fpx)} finiteAssumptions-subset ([⟶]-elim p q) = [∪]-subset (\{x} → finiteAssumptions-subset p {x}) (\{x} → finiteAssumptions-subset q {x}) finiteAssumptions-subset ([⟷]-intro p q) = Logic.[∨]-elim ([∪][∖]-invertᵣ-[⊆] {A = finiteAssumptions p} (finiteAssumptions-subset p)) ([∪][∖]-invertᵣ-[⊆] {A = finiteAssumptions q} (finiteAssumptions-subset q)) finiteAssumptions-subset ([⟷]-elimₗ p q) = [∪]-subset (\{x} → finiteAssumptions-subset p {x}) (\{x} → finiteAssumptions-subset q {x}) finiteAssumptions-subset ([⟷]-elimᵣ p q) = [∪]-subset (\{x} → finiteAssumptions-subset p {x}) (\{x} → finiteAssumptions-subset q {x}) {- module _ where open import Numeral.Natural finiteAssumptions-index : (p : (Γ ⊢ φ)) → ∀{x} → (x ∈ finiteAssumptions p) → ℕ finiteAssumptions-index (direct x) [≡]-intro = {!!} finiteAssumptions-index [⊤]-intro () finiteAssumptions-index ([⊥]-intro p q) (Left x) = {!!} finiteAssumptions-index ([⊥]-intro p q) (Right x) = {!!} finiteAssumptions-index ([⊥]-elim p) = {!!} finiteAssumptions-index ([¬]-intro p) = {!!} finiteAssumptions-index ([¬]-elim p) = {!!} finiteAssumptions-index ([∧]-intro p p₁) = {!!} finiteAssumptions-index ([∧]-elimₗ p) = {!!} finiteAssumptions-index ([∧]-elimᵣ p) = {!!} finiteAssumptions-index ([∨]-introₗ p) = {!!} finiteAssumptions-index ([∨]-introᵣ p) = {!!} finiteAssumptions-index ([∨]-elim p p₁ p₂) = {!!} finiteAssumptions-index ([⟶]-intro p) = {!!} finiteAssumptions-index ([⟶]-elim p p₁) = {!!} finiteAssumptions-index ([⟷]-intro p p₁) = {!!} finiteAssumptions-index ([⟷]-elimₗ p p₁) = {!!} finiteAssumptions-index ([⟷]-elimᵣ p p₁) = {!!} -} module _ (Γ : Formulas(P){ℓ}) where ConsistentSubsetMaximality = ∀{Δ : Formulas(P){Lvl.of(P) Lvl.⊔ ℓ}} → Consistent(Δ) → (Γ ⊆ Δ) → (Δ ⊆ Γ) ConsistentElementMaximality = ∀{φ} → Consistent(Γ ∪ singleton(φ)) → (φ ∈ Γ) CompleteDerivability = ∀{φ} → (Γ ⊢ φ) Logic.∨ (Γ ⊢ (¬ φ)) CompleteMembership = ∀{φ} → (φ ∈ Γ) Logic.∨ ((¬ φ) ∈ Γ) -- Equivalences when `Γ` is consistent. Used in the definition of `MaximallyConsistent`. data ConsistentlyComplete : Stmt{Lvl.𝐒(Lvl.of(P) Lvl.⊔ ℓ)} where subset-intro : ConsistentSubsetMaximality → ConsistentlyComplete element-intro : ConsistentElementMaximality → ConsistentlyComplete complete-deriv-intro : CompleteDerivability → ConsistentlyComplete complete-member-intro : CompleteMembership → ConsistentlyComplete module CompleteMembership(p : CompleteMembership) where consistentSubsetMaximality : ConsistentSubsetMaximality consistentSubsetMaximality conΔ ΓΔ {φ} φΔ = Logic.[∨]-not-right (p{φ}) (¬φΓ ↦ conΔ([⊥]-intro (direct φΔ) (direct(ΓΔ ¬φΓ)))) module ConsistentElementMaximality(element-maximal : ConsistentElementMaximality) where consistentSubsetMaximality : ConsistentSubsetMaximality consistentSubsetMaximality conΔ ΓΔ {φ} φΔ = element-maximal ([⊢]-subset-consistency (Logic.[∨]-elim ΓΔ (\{([≡]-intro) → φΔ})) conΔ) element-maximal-contra : (φ ∉ Γ) → Inconsistent(Γ ∪ singleton(φ)) element-maximal-contra = Logic.[↔]-to-[←] Logic.contrapositive-variant2 element-maximal [⊢]-derivability-consistencyₗ : ((Γ ⊢ φ) ← Consistent(Γ ∪ singleton(φ))) [⊢]-derivability-consistencyₗ = direct ∘ element-maximal module Consistent(consistent : Consistent(Γ)) where [⊢]-to-[∈] : (Γ ⊢ φ) → (φ ∈ Γ) [⊢]-to-[∈] = Logic.[→]-from-contrary (\Γφ φ∉Γ → consistent ([⊢]-compose-inconsistency Γφ (element-maximal-contra φ∉Γ))) [⊢][∈]-equivalence : (Γ ⊢ φ) Logic.↔ (φ ∈ Γ) [⊢][∈]-equivalence = Logic.[↔]-intro direct [⊢]-to-[∈] -- [•]-maximal-membership : ((• p) ∈ Γ) Logic.↔ ? -- [•]-maximal-membership = [⊤]-maximal-membership : (⊤ ∈ Γ) Logic.↔ Logic.⊤ [⊤]-maximal-membership = Logic.[↔]-intro l r where l = const (element-maximal (Γ⊤-incons ↦ consistent([⊢]-compose-inconsistency [⊤]-intro Γ⊤-incons))) r = const Logic.[⊤]-intro [⊥]-maximal-membership : (⊥ ∈ Γ) Logic.↔ Logic.⊥ [⊥]-maximal-membership = Logic.[↔]-intro l r where l = Logic.[⊥]-elim r = consistent ∘ direct [¬]-maximal-membership : ((¬ φ) ∈ Γ) Logic.↔ (φ ∉ Γ) [¬]-maximal-membership = Logic.[↔]-intro l r where l = [⊢]-to-[∈] ∘ [¬]-intro ∘ element-maximal-contra r = [⊢]-consistent-noncontradicting-membership consistent [∧]-maximal-membership : ((φ ∧ ψ) ∈ Γ) Logic.↔ ((φ ∈ Γ) Logic.∧ (ψ ∈ Γ)) [∧]-maximal-membership = Logic.[↔]-intro l r where l = \{(Logic.[∧]-intro φΓ ψΓ) → [⊢]-to-[∈] ([∧]-intro (direct φΓ) (direct ψΓ))} r = φψΓ ↦ Logic.[∧]-intro ([⊢]-to-[∈] ([∧]-elimₗ(direct φψΓ))) ([⊢]-to-[∈] ([∧]-elimᵣ(direct φψΓ))) [∨]-maximal-membership : ((φ ∨ ψ) ∈ Γ) Logic.↔ ((φ ∈ Γ) Logic.∨ (ψ ∈ Γ)) [∨]-maximal-membership = Logic.[↔]-intro l r where l = Logic.[∨]-elim ([⊢]-to-[∈] ∘ [∨]-introₗ ∘ direct) ([⊢]-to-[∈] ∘ [∨]-introᵣ ∘ direct) r = Logic.contrapositiveₗ ⦃ classical ⦄ ((\{(Logic.[∧]-intro ¬φΓ ¬ψΓ) → φψΓ ↦ consistent([∨]-elim (element-maximal-contra ¬φΓ) (element-maximal-contra ¬ψΓ) (direct φψΓ))}) ∘ Logic.[↔]-to-[→] Logic.[¬]-preserves-[∨][∧]) [⟶]-maximal-membership : ((φ ⟶ ψ) ∈ Γ) Logic.↔ ((φ ∉ Γ) Logic.∨ (ψ ∈ Γ)) [⟶]-maximal-membership = Logic.[↔]-symmetry [⊢][∈]-equivalence ⦗ Logic.[↔]-transitivity ⦘ₗ [→]-disjunctive-form ⦗ Logic.[↔]-transitivity ⦘ₗ [⊢][∈]-equivalence ⦗ Logic.[↔]-transitivity ⦘ₗ [∨]-maximal-membership ⦗ Logic.[↔]-transitivity ⦘ₗ Logic.[↔]-intro (Either.mapLeft (Logic.[↔]-to-[←] [¬]-maximal-membership)) (Either.mapLeft ((Logic.[↔]-to-[→] [¬]-maximal-membership))) [⟷]-maximal-membership : ((φ ⟷ ψ) ∈ Γ) Logic.↔ (((φ ∈ Γ) Logic.∧ (ψ ∈ Γ)) Logic.∨ ((φ ∉ Γ) Logic.∧ (ψ ∉ Γ))) [⟷]-maximal-membership = Logic.[↔]-symmetry [⊢][∈]-equivalence ⦗ Logic.[↔]-transitivity ⦘ₗ [⟷]-conjunction-disjunction-negation ⦗ Logic.[↔]-transitivity ⦘ₗ [⊢][∈]-equivalence ⦗ Logic.[↔]-transitivity ⦘ₗ [∨]-maximal-membership ⦗ Logic.[↔]-transitivity ⦘ₗ Logic.[↔]-intro (Either.map (Logic.[↔]-to-[←] [∧]-maximal-membership) (Logic.[↔]-to-[←] [∧]-maximal-membership)) (Either.map (Logic.[↔]-to-[→] [∧]-maximal-membership) (Logic.[↔]-to-[→] [∧]-maximal-membership)) ⦗ Logic.[↔]-transitivity ⦘ₗ Logic.[↔]-intro (Either.mapRight (Tuple.map (Logic.[↔]-to-[←] [¬]-maximal-membership) (Logic.[↔]-to-[←] [¬]-maximal-membership))) (Either.mapRight (Tuple.map (Logic.[↔]-to-[→] [¬]-maximal-membership) (Logic.[↔]-to-[→] [¬]-maximal-membership))) complete-membership : CompleteMembership complete-membership = Logic.[¬→]-disjunctive-formᵣ (Logic.[↔]-to-[←] [¬]-maximal-membership) equal-model-existence : Logic.∃(𝔐 ↦ (Γ ≡ₛ (𝔐 ⊧_))) equal-model-existence = Logic.[∃]-intro witness ⦃ Logic.[↔]-intro l r ⦄ where witness = (p ↦ decide(0)((• p) ∈ Γ)) l : (witness ⊧ φ) → (φ ∈ Γ) r : witness ⊧₊ Γ r {• x} = Logic.[↔]-to-[→] decider-true r {⊤} = Logic.[↔]-to-[→] [⊤]-maximal-membership r {⊥} = Logic.[↔]-to-[→] [⊥]-maximal-membership r {¬ φ} = Logic.contrapositiveᵣ l ∘ Logic.[↔]-to-[→] [¬]-maximal-membership r {φ ∧ ψ} = Tuple.map r r ∘ Logic.[↔]-to-[→] [∧]-maximal-membership r {φ ∨ ψ} = Either.map r r ∘ Logic.[↔]-to-[→] [∨]-maximal-membership r {φ ⟶ ψ} = Either.map (Logic.contrapositiveᵣ l) r ∘ Logic.[↔]-to-[→] [⟶]-maximal-membership r {φ ⟷ ψ} = Either.map (Tuple.map r r) (Tuple.map (Logic.contrapositiveᵣ l) (Logic.contrapositiveᵣ l)) ∘ Logic.[↔]-to-[→] [⟷]-maximal-membership l {• x} = Logic.[↔]-to-[←] decider-true l {⊤} = Logic.[↔]-to-[←] [⊤]-maximal-membership l {¬ φ} = Logic.[↔]-to-[←] [¬]-maximal-membership ∘ Logic.contrapositiveᵣ r l {φ ∧ ψ} = Logic.[↔]-to-[←] [∧]-maximal-membership ∘ Tuple.map l l l {φ ∨ ψ} = Logic.[↔]-to-[←] [∨]-maximal-membership ∘ Either.map l l l {φ ⟶ ψ} = Logic.[↔]-to-[←] [⟶]-maximal-membership ∘ Either.map (Logic.contrapositiveᵣ r) l l {φ ⟷ ψ} = Logic.[↔]-to-[←] [⟷]-maximal-membership ∘ Either.map (Tuple.map l l) (Tuple.map (Logic.contrapositiveᵣ r) (Logic.contrapositiveᵣ r)) satisfiable : Satisfiable(Γ) satisfiable = Logic.[∃]-map-proof (\eq {φ} → Logic.[↔]-to-[→] (eq{φ})) equal-model-existence module ConsistentSubsetMaximality(p : ConsistentSubsetMaximality) where consistentElementMaximality : ConsistentElementMaximality consistentElementMaximality con = p con Left (Right [≡]-intro) module CompleteDerivability(p : CompleteDerivability) where module Consistent(consistent : Consistent(Γ)) where [⊢]-to-[∈]' : (Γ ⊢ φ) → (φ ∈ Γ) [⊢]-to-[∈]' {φ = φ} = Logic.[→]-disjunctive-formₗ {!!} consistentSubsetMaximality : ConsistentSubsetMaximality consistentSubsetMaximality {Δ} conΔ ΓΔ {φ} φΔ = {!Logic.[¬→]-disjunctive-formₗ (Either.map (weaken ΓΔ) (weaken ΓΔ) (p{φ}))!} {-with p{φ} | Logic.excluded-middle((¬ φ) ∈ Δ) ... | Left q | Left r = {!!} ... | Left q | Right r with () ← Logic.contrapositiveᵣ(weaken ΓΔ) {!!} {!!} ... | Right q | _ with () ← conΔ([⊥]-intro (direct φΔ) (weaken ΓΔ q))-} -- conΔ([⊥]-intro (direct φΔ) (direct(ΓΔ ¬φΓ))) -- Logic.[∨]-not-right (p{φ}) (¬φΓ ↦ ?) consistentElementMaximality : ConsistentElementMaximality consistentElementMaximality {φ} conΓφ with p{φ} | Logic.excluded-middle((¬ φ) ∈ Γ) ... | Left q | Left r with () ← consistent([⊥]-intro q (direct r)) ... | Left q | Right r = Logic.[¬¬]-elim (¬Γφ ↦ {![⊢]-consistent-noncontradicting-membership consistent !}) ... | Right q | _ with () ← conΓφ([¬]-intro-converse q) -- ConsistentSubsetMaximality.consistentElementMaximality {!!} -- [⊢]-derivability-consistencyᵣ consistent q -- [¬]-intro(Logic.[↔]-to-[→] [⊢]-derivability-inconsistency q) -- Logic.contrapositiveᵣ direct conΓφ -- (¬φΓ ↦ Logic.contrapositiveᵣ direct (conΓφ ∘ [¬]-intro-converse) {!r ∘ direct!}) -- [⊢]-consistent-noncontradicting-membership consistent -- (r ∘ direct) completeMembership : CompleteMembership completeMembership = Either.map [⊢]-to-[∈] [⊢]-to-[∈] p where [⊢]-to-[∈] = (ConsistentElementMaximality.Consistent.[⊢]-to-[∈] consistentElementMaximality consistent) record MaximallyConsistent (Γ : Formulas(P){ℓ}) : Stmt{Lvl.𝐒(Lvl.of(P) Lvl.⊔ ℓ)} where field consistent : Consistent(Γ) maximal : ConsistentlyComplete(Γ) subset-maximal : ConsistentSubsetMaximality(Γ) element-maximal : ConsistentElementMaximality(Γ) element-maximal with maximal ... | subset-intro p = ConsistentSubsetMaximality.consistentElementMaximality Γ p ... | element-intro p = p ... | complete-deriv-intro p = ConsistentSubsetMaximality.consistentElementMaximality Γ subset-maximal where ... | complete-member-intro p = ConsistentSubsetMaximality.consistentElementMaximality Γ (CompleteMembership.consistentSubsetMaximality Γ p) open ConsistentElementMaximality Γ element-maximal using ( element-maximal-contra ; [⊢]-derivability-consistencyₗ ) public open ConsistentElementMaximality.Consistent Γ element-maximal consistent using ( [⊢]-to-[∈] ; equal-model-existence ) public subset-maximal with maximal ... | subset-intro p = p ... | element-intro p = ConsistentElementMaximality.consistentSubsetMaximality Γ p ... | complete-deriv-intro p = CompleteMembership.consistentSubsetMaximality Γ (Either.map [⊢]-to-[∈] [⊢]-to-[∈] p) ... | complete-member-intro p = CompleteMembership.consistentSubsetMaximality Γ p {-r : (term-model(max Γ con) ⊧ φ) → (φ ∈ max Γ con) r {• x} modelsφ Γφ-incons = Logic.[↔]-to-[←] Logic.decide-is-true modelsφ Γφ-incons r {⊤} modelsφ Γφ-incons = con([⊢]-compose-inconsistency [⊤]-intro Γφ-incons)-} open MaximallyConsistent ⦃ … ⦄ using ( [⊢]-derivability-consistencyₗ ; [⊤]-maximal-membership ; [⊥]-maximal-membership ; [¬]-maximal-membership ; [∧]-maximal-membership ; [∨]-maximal-membership ; [⟶]-maximal-membership ; [⟷]-maximal-membership ) public module _ ⦃ countable-P : CountablyInfinite P ⦄ where -- Also called: Lindenbaums' lemma open import Numeral.Natural private variable n : ℕ {- data maxi (Γ : Formulas(P){ℓ}) : ℕ → Formulas(P){Lvl.of(P) Lvl.⊔ ℓ} where base : Γ ⊆ maxi Γ 𝟎 step : maxi Γ n ⊆ maxi Γ (𝐒(n)) form : let ψ = Logic.[∃]-witness (Formula-is-countably-infinite {P = P}) n in maxi Γ (𝐒(n)) (if Logic.decide(maxi Γ n ⊢ ψ) then ψ else (¬ ψ)) maxi-zero : (Γ ≡ₛ maxi Γ 𝟎) maxi-zero = Logic.[↔]-intro (\{(base p) → p}) base maxi-succ : let ψ = Logic.[∃]-witness (Formula-is-countably-infinite {P = P}) n in (((maxi Γ n) ∪ singleton(if Logic.decide(maxi Γ n ⊢ ψ) then ψ else (¬ ψ))) ≡ₛ maxi Γ (𝐒(n))) maxi-succ {n = n}{Γ = Γ} = Logic.[↔]-intro l r where p = Logic.[∃]-witness (Formula-is-countably-infinite {P = P}) n l : ((maxi Γ n) ∪ singleton(if Logic.decide(maxi Γ n ⊢ p) then p else (¬ p))) ⊇ maxi Γ (𝐒(n)) l (step x) = Left x l form = Right [≡]-intro r : ((maxi Γ n) ∪ singleton(if Logic.decide(maxi Γ n ⊢ p) then p else (¬ p))) ⊆ maxi Γ (𝐒(n)) r (Left x) = step x r (Right [≡]-intro) = form maxi-superset : Consistent(Γ) → (∀{n} → (Γ ⊆ maxi Γ n)) maxi-superset {Γ = Γ} con {𝟎} = Logic.[↔]-to-[→] maxi-zero maxi-superset {Γ = Γ} con {𝐒 n} {φ} Γφ = {!!} instance maxi-consistent : Consistent(Γ) → (∀{n} → Consistent(maxi Γ n)) maxi-consistent con {n = 𝟎} = [⊢]-subset-consistency (Logic.[↔]-to-[←] maxi-zero) con maxi-consistent {Γ = Γ} con {n = 𝐒 n} = [⊢]-subset-consistency (Logic.[↔]-to-[←] maxi-succ) con-eq where p = Logic.[∃]-witness (Formula-is-countably-infinite {P = P}) n con-eq : Consistent((maxi Γ n) ∪ singleton(if Logic.decide(maxi Γ n ⊢ p) then p else (¬ p))) con-eq with Logic.excluded-middle(maxi Γ n ⊢ p) | Logic.decide(maxi Γ n ⊢ p) ... | Left derp | _ = [⊢]-compose-consistency derp (maxi-consistent con {n = n}) ... | Right dernp | _ = [⊬]-negation-consistency(dernp ∘ [¬¬]-elim) -} maxi2 : Formulas(P){ℓ} → ℕ → Formulas(P){Lvl.of(P) Lvl.⊔ ℓ} maxi2 Γ 𝟎 = Lvl.Up{Lvl.of(P)} ∘ Γ maxi2 Γ (𝐒(n)) = let ψ = CountablyInfinite.index(Formula P) n in (maxi2 Γ n) ∪ singleton(if decide(0)(maxi2 Γ n ⊢ ψ) then ψ else (¬ ψ)) maxi2-succ : let ψ = CountablyInfinite.index(Formula P) n in (((maxi2 Γ n) ∪ singleton(if decide(0)(maxi2 Γ n ⊢ ψ) then ψ else (¬ ψ))) ≡ₛ maxi2 Γ (𝐒(n))) -- maxi2-succ {n = n}{Γ = Γ} = Logic.[↔]-intro {!!} {!!} maxi2-zero : (Γ ≡ₛ maxi2 Γ 𝟎) maxi2-zero {Γ = Γ} = Logic.[↔]-symmetry (Sets.PredicateSet.LvlUp-set-equality {S = Γ}) maxi2-superset : ∀{n} → (Γ ⊆ maxi2 Γ n) maxi2-superset {Γ = Γ} {𝟎} = Logic.[↔]-to-[→] (maxi2-zero {Γ = Γ}) maxi2-superset {Γ = Γ} {𝐒 n} = Left ∘ maxi2-superset {Γ = Γ} {n} instance maxi2-consistent : Consistent(Γ) → (∀{n} → Consistent(maxi2 Γ n)) maxi2-consistent {Γ = Γ} con {n = 𝟎} = [⊢]-subset-consistency (Logic.[↔]-to-[←] (maxi2-zero {Γ = Γ})) con maxi2-consistent {Γ = Γ} con {n = 𝐒 n} = [⊢]-subset-consistency (Logic.[↔]-to-[←] (maxi2-succ {Γ = Γ})) con-eq where p = CountablyInfinite.index(Formula P) n con-eq : Consistent((maxi2 Γ n) ∪ singleton(if decide(0)(maxi2 Γ n ⊢ p) then p else (¬ p))) con-eq with Logic.excluded-middle(maxi2 Γ n ⊢ p) | decide(0)(maxi2 Γ n ⊢ p) ... | Left derp | _ = [⊢]-compose-consistency derp (maxi2-consistent con {n = n}) ... | Right dernp | _ = [⊬]-negation-consistency(dernp ∘ [¬¬]-elim) max : (Γ : Formulas(P){ℓ}) → Formulas(P){Lvl.of(P) Lvl.⊔ ℓ} max(Γ) φ = Logic.∃(n ↦ φ ∈ maxi2 Γ n) maxi2-subset-max : (maxi2 Γ n ⊆ max Γ) maxi2-subset-max {Γ = Γ} {n} p = Logic.[∃]-intro n ⦃ p ⦄ open import Lang.Inspect max-maximal : (φ ∈ max Γ) Logic.∨ ((¬ φ) ∈ max Γ) max-maximal {φ = φ}{Γ = Γ} with n ← CountablyInfinite.indexing(Formula P) φ with Logic.excluded-middle(maxi2 Γ n ⊢ CountablyInfinite.index(Formula P) n) | inspect(maxi2 Γ) (𝐒 n) ... | Left p | intro q with r ← [≡]-with(_$ CountablyInfinite.index(Formula P) n) q = Left (Logic.[∃]-intro (𝐒(n)) ⦃ Right {!!} ⦄) ... | Right p | intro q = Right (Logic.[∃]-intro (𝐒(n)) ⦃ Right {!q!} ⦄) instance max-consistent : Consistent(Γ) → Consistent(max Γ) max-consistent {Γ = Γ} con = [⊢]-subset-consistency (Logic.[∃]-proof test5) (maxi2-consistent con {Logic.[∃]-witness test5}) where open import Numeral.Natural.Relation.Order open import Type.Properties.Inhabited test2 : (φ ∈ max Γ) → Logic.∃(n ↦ (φ ∈ maxi2 Γ n)) test2 p = p test3a : ∀{φ} → Logic.∃(n ↦ ((φ ∈ max Γ) → (φ ∈ maxi2 Γ n))) test3a = Logic.[∃]-unrelatedᵣ-[→]ₗ ⦃ pos = intro ⦃ 𝟎 ⦄ ⦄ test2 test3b : Logic.∃{Obj = Formula(P) → ℕ}(n ↦ (max Γ) ⊆ (φ ↦ φ ∈ maxi2 Γ (n(φ)))) test3b = Logic.[∀][∃]-to-function-existence test3a test4 : ∀{a b} → (a ≤ b) → ∀{Γ : Formulas(P){ℓ}} → ((maxi2 Γ a) ⊆ (maxi2 Γ b)) test4 {a = 𝟎} {𝟎} [≤]-minimum p = p test4 {a = 𝟎} {𝐒 b} [≤]-minimum {Γ} p = Left(test4 {a = 𝟎}{b} [≤]-minimum {Γ} p) test4 {a = 𝐒 a} {𝐒 b} ([≤]-with-[𝐒] ⦃ ab ⦄) {Γ} (Left p) = Left (test4 {a = a}{b} ab p) test4 {a = 𝐒 a} {𝐒 b} ([≤]-with-[𝐒] ⦃ ab ⦄) {Γ}{φ} (Right p) = {!test4 {a = a}{b = b} ab {Γ ∪ singleton(if Logic.decide(maxi2 Γ b ⊢ β) then β else (¬ β))}{φ} ? !} where β = CountablyInfinite.index(Formula P) b {-with Logic.excluded-middle(maxi2 Γ a ⊢ Logic.[∃]-witness Formula-is-countably-infinite a) | p ... | Left x | [≡]-intro = {!!} ... | Right x | q = test4 {a} {𝐒 b} {!!} {!!}-} -- TODO: Because test3 and test4 test5 : Logic.∃(n ↦ (max Γ) ⊆ (maxi2 Γ n)) -- with [∃]-intro n ⦃ pn ⦄ ← max Γ = {!!} -- [⊢]-subset-consistency (\{φ} → {!maxi2-consistent con {n = 𝟎}!}) {!con!} instance max-maximally-consistent : Consistent(Γ) → MaximallyConsistent(max Γ) MaximallyConsistent.consistent (max-maximally-consistent con) = max-consistent con MaximallyConsistent.maximal (max-maximally-consistent {Γ = Γ} con) = {!!} -- {φ} conm with n ← CountablyInfinite.indexing(Formula P) φ = {!!} max-superset : Γ ⊆ max Γ max-superset {Γ = Γ} Γφ = Logic.[∃]-intro 𝟎 ⦃ maxi2-superset {Γ = Γ}{n = 𝟎} Γφ ⦄ {- {- max : (Γ : Formulas(P){ℓ}) → Consistent(Γ) → Formulas(P){Lvl.𝐒(Lvl.of(P) Lvl.⊔ ℓ)} max Γ con φ = Consistent(Γ ∪ singleton(φ)) -- TODO: Probably not like this. The problem with this definition is that (Consistent(Γ ∪ singleton(φ)) → (Γ ⊢ φ)) is impossible to prove, and it is neccessary for proving that (max Γ con) for any Γ is a consistent set of formulas. This is related to the issue that if both (Γ ∪ singleton(φ)) and (Γ ∪ singleton(¬ φ)) is consistent, then both of them will be included. But this would lead to (max Γ cons) not necccesarily consistent. -- if decide(Consistent(Γ ∪ singleton(φ))) then (Γ ∪ singleton(φ)) else (Γ ∪ singleton(¬ φ)) {-data max2 (Γ : Formulas(P){ℓ}) (con : Consistent(Γ)) : Formulas(P){Lvl.𝐒(Lvl.of(P) Lvl.⊔ ℓ)} where Positive : Consistent (Γ ∪ singleton(φ)) → Inconsistent(Γ ∪ singleton(¬ φ)) → max2 Γ con φ Negative : Inconsistent(Γ ∪ singleton(φ)) → Consistent (Γ ∪ singleton(¬ φ)) → max2 Γ con φ -} max2 : (Γ : Formulas(P){ℓ}) → Consistent(Γ) → Formulas(P){Lvl.𝐒(Lvl.of(P) Lvl.⊔ ℓ)} max2 Γ con φ = Consistent(Γ ∪ singleton(φ)) Logic.∧ Inconsistent(Γ ∪ singleton(¬ φ)) max-maximal : ∀{con : Consistent(Γ)} → (φ ∈ max Γ con) Logic.∨ ((¬ φ) ∈ max Γ con) max-maximal {Γ = Γ}{φ = φ}{con = con} with Logic.excluded-middle(Inconsistent(Γ ∪ singleton(φ))) ⦃ classical ⦄ ... | Logic.[∨]-introₗ Γφ⊥ = Logic.[∨]-introᵣ (Γ¬φ⊥ ↦ Logic.[⊥]-elim(con ([⊥]-intro ([¬]-elim Γ¬φ⊥) ([¬]-intro Γφ⊥)))) ... | Logic.[∨]-introᵣ ¬Γφ⊥ = Logic.[∨]-introₗ ¬Γφ⊥ max-no-bottom : ∀{con : Consistent(Γ)} → (⊥ ∉ max Γ con) max-no-bottom = apply(direct(Right [≡]-intro)) max-consistent-containment : ∀{con : Consistent(Γ)} → (φ ∈ max Γ con) → ((¬ φ) ∈ max Γ con) → Logic.⊥ max-consistent-containment {Γ = Γ}{φ = φ}{con = con} ¬Γφ⊥ ¬Γ¬φ⊥ = ¬Γφ⊥ ([⊥]-intro (direct (Right [≡]-intro)) {!!}) max-consistency-membership : ∀{con} → Consistent(Γ ∪ singleton(φ)) Logic.↔ (φ ∈ max Γ con) max-consistency-membership = Logic.[↔]-intro id id max-inconsistency-membership2 : ∀{con} → Inconsistent(Γ ∪ singleton(φ)) Logic.↔ (φ ∉ max Γ con) max-inconsistency-membership2 = Logic.[↔]-intro Logic.[¬¬]-elim apply test : ∀{con} → (φ ∉ max Γ con) → ((¬ φ) ∈ max Γ con) test {con = con} p = [⊢]-compose-consistency ([¬]-intro(Logic.[¬¬]-elim p)) con max-consistent : ∀{con : Consistent(Γ)} → Consistent(max Γ con) max-consistent {Γ = Γ} {con = con} = Logic.contrapositiveᵣ {!!} con {-max-consistent {Γ = Γ} {con = con} (direct x) = max-no-bottom{con = con} x max-consistent {Γ = Γ} {con = con} ([⊥]-intro p q) = {!max-consistent q!} max-consistent {Γ = Γ} {con = con} ([⊥]-elim p) = max-consistent{con = con} p max-consistent {Γ = Γ} {con = con} ([¬]-elim p) = {!!} max-consistent {Γ = Γ} {con = con} ([∧]-elimₗ p) = {!max-consistent !} max-consistent {Γ = Γ} {con = con} ([∧]-elimᵣ p) = {!!} max-consistent {Γ = Γ} {con = con} ([∨]-elim p q r) = {!!} max-consistent {Γ = Γ} {con = con} ([⟶]-elim p q) = {!!} max-consistent {Γ = Γ} {con = con} ([⟷]-elimₗ p q) = {!!} max-consistent {Γ = Γ} {con = con} ([⟷]-elimᵣ p q) = {!!}-} {- test2 : ∀{con} → ((¬ φ) ∈ max Γ con) → (φ ∉ max Γ con) test2 {con = con} p q = {!!} test3 : ∀{con} → (max Γ con ⊢ φ) → (Γ ⊢ φ) test3 {Γ = Γ} {φ} {con = con} (direct x) = {!!} test3 {Γ = Γ} {.⊤} {con = con} [⊤]-intro = {!!} test3 {Γ = Γ} {.⊥} {con = con} ([⊥]-intro p p₁) = {!!} test3 {Γ = Γ} {φ} {con = con} ([⊥]-elim p) = {!!} test3 {Γ = Γ} {.(¬ _)} {con = con} ([¬]-intro p) = {!!} test3 {Γ = Γ} {φ} {con = con} ([¬]-elim p) = {!!} test3 {Γ = Γ} {.(_ ∧ _)} {con = con} ([∧]-intro p p₁) = {!!} test3 {Γ = Γ} {φ} {con = con} ([∧]-elimₗ p) = {!!} test3 {Γ = Γ} {φ} {con = con} ([∧]-elimᵣ p) = {!!} test3 {Γ = Γ} {.(_ ∨ _)} {con = con} ([∨]-introₗ p) = {!!} test3 {Γ = Γ} {.(_ ∨ _)} {con = con} ([∨]-introᵣ p) = {!!} test3 {Γ = Γ} {φ} {con = con} ([∨]-elim p p₁ p₂) = {!!} test3 {Γ = Γ} {.(_ ⟶ _)} {con = con} ([⟶]-intro p) = {!!} test3 {Γ = Γ} {φ} {con = con} ([⟶]-elim p p₁) = {!!} test3 {Γ = Γ} {.(_ ⟷ _)} {con = con} ([⟷]-intro p p₁) = {!!} test3 {Γ = Γ} {φ} {con = con} ([⟷]-elimₗ p p₁) = {!!} test3 {Γ = Γ} {φ} {con = con} ([⟷]-elimᵣ p p₁) = {!!} -} max-inconsistency-membership : ∀{con} → Inconsistent(Γ ∪ singleton(φ)) Logic.↔ ((¬ φ) ∈ max Γ con) max-inconsistency-membership {Γ = Γ}{φ = φ}{con = con} = Logic.double-negation ⦗ Logic.[↔]-transitivity ⦘ₗ Logic.[¬]-unaryOperator max-consistency-membership ⦗ Logic.[↔]-transitivity ⦘ₗ Logic.[↔]-intro ll (Γ¬φ-incons ↦ Γφ-incons ↦ con([⊥]-intro ([¬]-elim Γφ-incons) ([¬]-intro (Logic.[¬¬]-elim Γ¬φ-incons)))) where ll : Logic.¬((Γ ∪ singleton(¬ φ)) ⊢ ⊥) → Logic.¬((Γ ∪ singleton(φ)) ⊢ ⊥) → Empty ll ¬φin φin = {!!} -- () ← ¬φin([⊥]-intro {!!} (direct (Right [≡]-intro))) -- con([⊥]-intro {!!} {!!}) -- -- {![⊥]-intro (direct φin) (direct ¬φin)!}) -- Logic.contrapositiveₗ ⦃ classical ⦄ (Γ¬φ-incons ↦ Γφ-incons ↦ con([⊥]-intro ([¬]-elim (Logic.[¬¬]-elim Γ¬φ-incons)) ([¬]-intro Γφ-incons))) max-superset : ∀{con : Consistent(Γ)} → (Γ ⊆ max Γ con) max-superset {con = con} {x = φ} φΓ Γφ⊥ = con ([⊥]-intro (direct φΓ) ([¬]-intro Γφ⊥)) -- TODO: Are there any easy ways to prove this? instance max-maximally-consistent : ∀{con : Consistent(Γ)} → MaximallyConsistent(max Γ con) MaximallyConsistent.consistent (max-maximally-consistent {con = con}) = max-consistent{con = con} MaximallyConsistent.element-maximal max-maximally-consistent p = {!!} -- max-consistency-membership {!Logic.contrapositive-variant2ₗ weaken-union-singleton!} -- max-consistency-membership {!p!} -- max-[⊢]-subset : ∀{con : Consistent(Γ)} → ((max Γ con ⊢_) ⊆ (Γ ⊢_)) -- max-[⊢]-subset {con = con} p = {!!} -} -} module _ where open NaturalDeduction private variable P : Type{ℓₚ} private variable φ ψ : Formula(P) module _ where private variable Γ Γ₁ Γ₂ : Formulas(P){ℓₚ} soundness : (Γ ⊢ φ) → (Γ ⊨ φ) soundness (direct Γφ) 𝔐Γ = 𝔐Γ(Γφ) soundness [⊤]-intro = const(Logic.[⊤]-intro) soundness ([⊥]-intro Γφ Γ¬φ) 𝔐Γ = (soundness Γ¬φ 𝔐Γ) (soundness Γφ 𝔐Γ) soundness ([⊥]-elim Γ⊥) 𝔐Γ = Logic.[⊥]-elim(soundness Γ⊥ 𝔐Γ) soundness {Γ = Γ}{φ = φ} ([¬]-intro Γφ⊥) 𝔐Γ 𝔐φ = soundness Γφ⊥ ([⊧₊]-strengthen {Γ₁ = Γ}{Γ₂ = singleton _} (𝔐Γ) (Logic.[↔]-to-[→] [⊧]-to-[⊧₊] 𝔐φ)) soundness {Γ = Γ}{φ = φ} ([¬]-elim Γ¬φ⊥) {𝔐} 𝔐Γ = Logic.[¬¬]-elim {P = (𝔐 ⊧ φ)} (¬𝔐φ ↦ soundness Γ¬φ⊥ ([⊧₊]-strengthen {Γ₁ = Γ}{Γ₂ = singleton _} 𝔐Γ (Logic.[↔]-to-[→] [⊧]-to-[⊧₊] ¬𝔐φ))) soundness ([∧]-intro Γφ Γψ) 𝔐Γ = (Logic.[∧]-intro (soundness Γφ 𝔐Γ) (soundness Γψ 𝔐Γ)) soundness ([∧]-elimₗ Γφψ) = Logic.[∧]-elimₗ ∘ (soundness Γφψ) soundness ([∧]-elimᵣ Γφψ) = Logic.[∧]-elimᵣ ∘ (soundness Γφψ) soundness ([∨]-introₗ Γφ) = Logic.[∨]-introₗ ∘ (soundness Γφ) soundness ([∨]-introᵣ Γψ) = Logic.[∨]-introᵣ ∘ (soundness Γψ) soundness {Γ = Γ}{φ = φ} ([∨]-elim {φ = ψ₁} {ψ₂} Γψ₁φ Γψ₂φ Γψ₁ψ₂) {𝔐} 𝔐Γ = (Logic.[∨]-elim (𝔐ψ₁ ↦ soundness Γψ₁φ ([⊧₊]-strengthen {Γ₁ = Γ}{Γ₂ = singleton _} (𝔐Γ) (Logic.[↔]-to-[→] [⊧]-to-[⊧₊] 𝔐ψ₁))) (𝔐ψ₂ ↦ soundness Γψ₂φ ([⊧₊]-strengthen {Γ₁ = Γ}{Γ₂ = singleton _} (𝔐Γ) (Logic.[↔]-to-[→] [⊧]-to-[⊧₊] 𝔐ψ₂))) (soundness Γψ₁ψ₂ 𝔐Γ) ) soundness {Γ = Γ} ([⟶]-intro Γφψ) 𝔐Γ = Logic.[→]-disjunctive-formᵣ (𝔐φ ↦ soundness Γφψ ([⊧₊]-strengthen {Γ₁ = Γ}{Γ₂ = singleton _} (𝔐Γ) (Logic.[↔]-to-[→] [⊧]-to-[⊧₊] 𝔐φ))) soundness ([⟶]-elim Γφ Γφψ) 𝔐Γ = Logic.[→]-disjunctive-formₗ((soundness Γφψ) 𝔐Γ) (soundness Γφ 𝔐Γ) soundness {Γ = Γ} ([⟷]-intro {φ = φ} {ψ = ψ} Γψφ Γφψ) {𝔐} 𝔐Γ with Logic.excluded-middle(𝔐 ⊧ φ) | Logic.excluded-middle(𝔐 ⊧ ψ) ... | Logic.[∨]-introₗ 𝔐φ | Logic.[∨]-introₗ 𝔐ψ = Logic.[∨]-introₗ (Logic.[∧]-intro 𝔐φ 𝔐ψ) ... | Logic.[∨]-introₗ 𝔐φ | Logic.[∨]-introᵣ ¬𝔐ψ = (Logic.[⊥]-elim ∘ ¬𝔐ψ ∘ soundness Γφψ) (Logic.[∨]-elim 𝔐Γ \{[≡]-intro → 𝔐φ}) ... | Logic.[∨]-introᵣ ¬𝔐φ | Logic.[∨]-introₗ 𝔐ψ = (Logic.[⊥]-elim ∘ ¬𝔐φ ∘ soundness Γψφ) (Logic.[∨]-elim 𝔐Γ \{[≡]-intro → 𝔐ψ}) ... | Logic.[∨]-introᵣ ¬𝔐φ | Logic.[∨]-introᵣ ¬𝔐ψ = Logic.[∨]-introᵣ (Logic.[∧]-intro ¬𝔐φ ¬𝔐ψ) soundness {Γ = Γ} ([⟷]-elimₗ {φ = φ} {ψ = ψ} Γψ Γφψ) 𝔐Γ with soundness Γφψ 𝔐Γ ... | Logic.[∨]-introₗ(Logic.[∧]-intro 𝔐φ 𝔐ψ ) = 𝔐φ ... | Logic.[∨]-introᵣ(Logic.[∧]-intro ¬𝔐φ ¬𝔐ψ) = Logic.[⊥]-elim(¬𝔐ψ(soundness Γψ 𝔐Γ)) soundness {Γ = Γ} ([⟷]-elimᵣ {φ = φ} {ψ = ψ} Γφ Γφψ) 𝔐Γ with soundness Γφψ 𝔐Γ ... | Logic.[∨]-introₗ(Logic.[∧]-intro 𝔐φ 𝔐ψ ) = 𝔐ψ ... | Logic.[∨]-introᵣ(Logic.[∧]-intro ¬𝔐φ ¬𝔐ψ) = Logic.[⊥]-elim(¬𝔐φ(soundness Γφ 𝔐Γ)) satisfiable-consistent : Satisfiable(Γ) → Consistent(Γ) satisfiable-consistent sat = Logic.contrapositiveᵣ soundness (\p → Logic.[↔]-to-[→] [⊨]-unsatisfiability p sat) consistency-of-∅ : Consistent{P = P}{ℓ = ℓ}(∅) consistency-of-∅ = satisfiable-consistent [∅]-satisfiable module _ where open import Data.Boolean.Stmt.Proofs open import Lang.Inspect modelSet : Model(P) → Formulas(P) modelSet(𝔐) = 𝔐 ⊧_ module _ {𝔐 : Model(P)} where modelSet-satisfiable : Satisfiable(modelSet(𝔐)) modelSet-satisfiable = Logic.[∃]-intro 𝔐 ⦃ id ⦄ modelSet-maximally-consistent : MaximallyConsistent(modelSet(𝔐)) MaximallyConsistent.consistent modelSet-maximally-consistent = satisfiable-consistent modelSet-satisfiable MaximallyConsistent.maximal modelSet-maximally-consistent = element-intro p where p : ConsistentElementMaximality(modelSet(𝔐)) p {φ} cons with TruthTable.eval 𝔐 φ | inspect (TruthTable.eval 𝔐) φ ... | 𝑇 | intro eval-𝑇 = TruthTable.eval-to-models {φ = φ} (Logic.[↔]-to-[←] IsTrue.is-𝑇 eval-𝑇) ... | 𝐹 | intro eval-𝐹 = Logic.[⊥]-elim (cons ([⊥]-intro (direct (Right [≡]-intro)) (weaken Left (direct (TruthTable.eval-to-models {φ = ¬ φ} (Logic.[↔]-to-[←] IsTrue.is-𝑇 ([≡]-with(BoolOp.¬) eval-𝐹))))))) {-maximally-consistent-is-modelSet : MaximallyConsistent(Γ) → (Γ ≡ₛ modelSet(𝔐)) maximally-consistent-is-modelSet maxCon {• x} = Logic.[↔]-intro {!Logic.[↔]-to-[←] Logic.decide-is-true!} {!Logic.[↔]-to-[→] Logic.decide-is-true!} maximally-consistent-is-modelSet maxCon {⊤} = [⊤]-maximal-membership ⦃ maxCon ⦄ maximally-consistent-is-modelSet maxCon {⊥} = [⊥]-maximal-membership ⦃ maxCon ⦄ maximally-consistent-is-modelSet maxCon {¬ φ} = Logic.[↔]-transitivity ([¬]-maximal-membership ⦃ maxCon ⦄) (Logic.[¬]-unaryOperator (maximally-consistent-is-modelSet maxCon)) maximally-consistent-is-modelSet maxCon {φ ∧ ψ} = Logic.[↔]-transitivity ([∧]-maximal-membership ⦃ maxCon ⦄) (Logic.[∧]-binaryOperator (maximally-consistent-is-modelSet maxCon) (maximally-consistent-is-modelSet maxCon)) maximally-consistent-is-modelSet maxCon {φ ∨ ψ} = Logic.[↔]-transitivity ([∨]-maximal-membership ⦃ maxCon ⦄) (Logic.[∨]-binaryOperator (maximally-consistent-is-modelSet maxCon) (maximally-consistent-is-modelSet maxCon)) maximally-consistent-is-modelSet maxCon {φ ⟶ ψ} = {!!} maximally-consistent-is-modelSet maxCon {φ ⟷ ψ} = {!!}-} term-model : Formulas(P){ℓ} → Model(P) term-model(Γ) p = decide(0)((• p) ∈ Γ) module _ ⦃ countable-P : CountablyInfinite(P) ⦄ where private variable Γ Γ₁ Γ₂ : Formulas(P){ℓₚ} term-model-of-max-proof : (con : Consistent(Γ)) → (max Γ ≡ₛ (term-model(max Γ) ⊧_)) term-model-of-max-proof {Γ = Γ} con = Logic.[∃]-proof(MaximallyConsistent.equal-model-existence (max-maximally-consistent con)) consistent-satisfiable : Consistent(Γ) → Satisfiable(Γ) Logic.∃.witness (consistent-satisfiable {Γ = Γ} con) = term-model(max Γ) Logic.∃.proof (consistent-satisfiable {Γ = Γ} con) {γ} = (Logic.[↔]-to-[→] (term-model-of-max-proof {Γ = Γ} con {γ})) ∘ max-superset completeness : (Γ ⊨ φ) → (Γ ⊢ φ) completeness {Γ = Γ}{φ = φ} = (Logic.[↔]-to-[←] [⊢]-derivability-inconsistency) ∘ (Logic.[↔]-to-[←] Logic.contrapositive-variant2 consistent-satisfiable) ∘ (Logic.[↔]-to-[→] [⊨]-entailment-unsatisfiability)
{ "alphanum_fraction": 0.5879659108, "avg_line_length": 61.776096823, "ext": "agda", "hexsha": "5ec13c943f419a79d3dd052d5565cb1da8b5e4e6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Formalization/ClassicalPropositionalLogic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Formalization/ClassicalPropositionalLogic.agda", "max_line_length": 478, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Formalization/ClassicalPropositionalLogic.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": 16047, "size": 40834 }
open import Agda.Builtin.Nat [_] : (Nat → Set) → Set [ T ] = ∀ {i} → T i data D : Nat → Nat → Set where c : ∀ {i} → [ D i ]
{ "alphanum_fraction": 0.4692307692, "avg_line_length": 14.4444444444, "ext": "agda", "hexsha": "b353e08f7541bcffd811518ddff3e4c61657915b", "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/Issue2947.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/Issue2947.agda", "max_line_length": 30, "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/Issue2947.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": 56, "size": 130 }
open import Haskell.Prelude mutual data Map (k : Set) (a : Set) : Set where Bin : (sz : Nat) → (kx : k) → (x : a) → (l : Map k a) → (r : Map k a) → {{szVal : sz ≡ (size l) + (size r) + 1}} → Map k a Tip : Map k a {-# COMPILE AGDA2HS Map #-} size : {k a : Set} → Map k a → Nat size Tip = 0 size (Bin sz _ _ _ _) = sz {-# COMPILE AGDA2HS size #-}
{ "alphanum_fraction": 0.4623115578, "avg_line_length": 23.4117647059, "ext": "agda", "hexsha": "997e717b466d692129dde9de9042e2199ecaaa35", "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/Issue69.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/Issue69.agda", "max_line_length": 52, "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/Issue69.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": 156, "size": 398 }
{-# OPTIONS --cubical --no-import-sorts --guardedness --safe #-} module Cubical.Codata.M.AsLimit.Coalg.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function using ( _∘_ ) open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.GroupoidLaws open import Cubical.Data.Unit open import Cubical.Data.Nat open import Cubical.Data.Prod open import Cubical.Data.Sigma open import Cubical.Codata.M.AsLimit.Container open import Cubical.Codata.M.AsLimit.helper ------------------------------- -- Definition of a Coalgebra -- ------------------------------- Coalg₀ : ∀ {ℓ} {S : Container ℓ} -> Type (ℓ-suc ℓ) Coalg₀ {ℓ} {S = S} = Σ[ C ∈ Type ℓ ] (C → P₀ S C) -------------------------- -- Definition of a Cone -- -------------------------- Cone₀ : ∀ {ℓ} {S : Container ℓ} {C,γ : Coalg₀ {S = S}} -> Type ℓ Cone₀ {S = S} {C , _} = (n : ℕ) → C → X (sequence S) n Cone₁ : ∀ {ℓ} {S : Container ℓ} {C,γ : Coalg₀ {S = S}} -> (f : Cone₀ {C,γ = C,γ}) -> Type ℓ Cone₁ {S = S} {C , _} f = (n : ℕ) → π (sequence S) ∘ (f (suc n)) ≡ f n Cone : ∀ {ℓ} {S : Container ℓ} (C,γ : Coalg₀ {S = S}) -> Type ℓ Cone {S = S} C,γ = Σ[ Cone ∈ (Cone₀ {C,γ = C,γ}) ] (Cone₁{C,γ = C,γ} Cone)
{ "alphanum_fraction": 0.5991058122, "avg_line_length": 33.55, "ext": "agda", "hexsha": "95ce9fc1ee5aab0fdbb88a5f0650f7efee960819", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Codata/M/AsLimit/Coalg/Base.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Codata/M/AsLimit/Coalg/Base.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Codata/M/AsLimit/Coalg/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 467, "size": 1342 }
module Contexts where open import Prelude open import T open import SubstTheory module Contexts where infix 60 _e$_ _$e_ -- Has a hole of type (Γ ⊢ A), produces a term of type (Γ' ⊢ A') data TCtx (Γ : Ctx) (A : TTp) : (Γ' : Ctx) → (A' : TTp) → Set where ∘ : TCtx Γ A Γ A _e$_ : ∀{Γ' A' B} (e₁ : TExp Γ' (A' ⇒ B)) (C₂ : TCtx Γ A Γ' A') → TCtx Γ A Γ' B _$e_ : ∀{Γ' A' B} (C₁ : TCtx Γ A Γ' (A' ⇒ B)) (e₂ : TExp Γ' A') → TCtx Γ A Γ' B Λ : ∀{A₁ A₂ Γ'} (C : TCtx Γ A (A₁ :: Γ') A₂) → TCtx Γ A Γ' (A₁ ⇒ A₂) suc : ∀{Γ'} (C : TCtx Γ A Γ' nat) → TCtx Γ A Γ' nat rec1 : ∀{Γ' B} → (C : TCtx Γ A Γ' nat) → (e₀ : TExp Γ' B) → (es : TExp (B :: Γ') B) → TCtx Γ A Γ' B rec2 : ∀{Γ' B} → (e : TExp Γ' nat) → (C₀ : TCtx Γ A Γ' B) → (es : TExp (B :: Γ') B) → TCtx Γ A Γ' B rec3 : ∀{Γ' B} → (e : TExp Γ' nat) → (e₀ : TExp Γ' B) → (Cs : TCtx Γ A (B :: Γ') B) → TCtx Γ A Γ' B _<_> : ∀{Γ A Γ' A'} → TCtx Γ A Γ' A' → TExp Γ A → TExp Γ' A' ∘ < e' > = e' (e₁ e$ C₂) < e' > = e₁ $ C₂ < e' > (C₁ $e e₂) < e' > = C₁ < e' > $ e₂ Λ C < e' > = Λ (C < e' >) suc C < e' > = suc (C < e' >) rec1 C e₀ es < e' > = rec (C < e' >) e₀ es rec2 e C₀ es < e' > = rec e (C₀ < e' >) es rec3 e e₀ Cs < e' > = rec e e₀ (Cs < e' >) infix 70 _<<_>> _<_> _<<_>> : ∀{Γ A Γ' A' Γ'' A''} → TCtx Γ' A' Γ'' A'' → TCtx Γ A Γ' A' → TCtx Γ A Γ'' A'' ∘ << C' >> = C' (e₁ e$ C₂) << C' >> = e₁ e$ C₂ << C' >> (C₁ $e e₂) << C' >> = C₁ << C' >> $e e₂ Λ C << C' >> = Λ (C << C' >>) suc C << C' >> = suc (C << C' >>) rec1 C e₀ es << C' >> = rec1 (C << C' >>) e₀ es rec2 e C₀ es << C' >> = rec2 e (C₀ << C' >>) es rec3 e e₀ Cs << C' >> = rec3 e e₀ (Cs << C' >>) -- I hate having to prove this sort of theorem. composing-commutes : ∀{Γ A Γ' A' Γ'' A''} → (C : TCtx Γ' A' Γ'' A'') → (C' : TCtx Γ A Γ' A') → (e : TExp Γ A) → ((C << C' >>) < e >) ≡ C < C' < e > > composing-commutes ∘ C' e = Refl composing-commutes (e₁ e$ C) C' e = resp (_$_ e₁) (composing-commutes C C' e) composing-commutes (C $e e₂) C' e = resp (λ x → x $ e₂) (composing-commutes C C' e) composing-commutes (Λ C) C' e = resp Λ (composing-commutes C C' e) composing-commutes (suc C) C' e = resp suc (composing-commutes C C' e) composing-commutes (rec1 C e₀ es) C' e = resp (λ x → rec x e₀ es) (composing-commutes C C' e) composing-commutes (rec2 e' C es) C' e = resp (λ x → rec e' x es) (composing-commutes C C' e) composing-commutes (rec3 e' e₀ C) C' e = resp (λ x → rec e' e₀ x) (composing-commutes C C' e) -- If the hole is closed, then the rest needs to be too. tctx-empty-thing : ∀{F : Set} {Γ A A' B} → TCtx [] A (B :: Γ) A' → F tctx-empty-thing (e₁ e$ C) = tctx-empty-thing C tctx-empty-thing (C $e e₂) = tctx-empty-thing C tctx-empty-thing (Λ C) = tctx-empty-thing C tctx-empty-thing (suc C) = tctx-empty-thing C tctx-empty-thing (rec1 C e₀ es) = tctx-empty-thing C tctx-empty-thing (rec2 e C es) = tctx-empty-thing C tctx-empty-thing (rec3 e e₀ C) = tctx-empty-thing C -- Very restricted function for weakening a program context where -- the hole also occurs under no free variables. weaken-closed-tctx : ∀{Γ A A'} → TCtx [] A [] A' → TCtx Γ A Γ A' weaken-closed-tctx ∘ = ∘ weaken-closed-tctx (e₁ e$ C) = weaken-closed e₁ e$ weaken-closed-tctx C weaken-closed-tctx (C $e e₂) = weaken-closed-tctx C $e weaken-closed e₂ weaken-closed-tctx (Λ C) = tctx-empty-thing C weaken-closed-tctx (suc C) = suc (weaken-closed-tctx C) weaken-closed-tctx (rec1 C e₀ es) = rec1 (weaken-closed-tctx C) (weaken-closed e₀) (ren (wk closed-wkγ) es) weaken-closed-tctx (rec2 e C es) = rec2 (weaken-closed e) (weaken-closed-tctx C) (ren (wk closed-wkγ) es) weaken-closed-tctx (rec3 e e₀ C) = tctx-empty-thing C -- Substitution commutes with a closed context subst-commutes-w-closed-tctx : ∀{Γ A A'} → (γ : TSubst Γ []) → (C : TCtx [] A [] A') → (e : TExp Γ A) → C < ssubst γ e > ≡ ssubst γ ((weaken-closed-tctx C) < e >) subst-commutes-w-closed-tctx γ ∘ e = Refl subst-commutes-w-closed-tctx γ (e₁ e$ C) e = resp2 _$_ (symm (closed-subst _ e₁) ≡≡ symm (subren γ closed-wkγ e₁)) (subst-commutes-w-closed-tctx γ C e) subst-commutes-w-closed-tctx γ (C $e e₂) e = resp2 _$_ (subst-commutes-w-closed-tctx γ C e) (symm (closed-subst _ e₂) ≡≡ symm (subren γ closed-wkγ e₂)) subst-commutes-w-closed-tctx γ (Λ C) e = tctx-empty-thing C subst-commutes-w-closed-tctx γ (suc C) e = resp suc (subst-commutes-w-closed-tctx γ C e) subst-commutes-w-closed-tctx γ (rec1 C e₀ es) e with subren (liftγ γ) (wk closed-wkγ) es ... | lol1 with subeq (liftwk γ closed-wkγ) es ... | lol2 with lift-closed-subst (γ o closed-wkγ) es ... | lol3 with symm lol3 ≡≡ symm lol2 ≡≡ symm lol1 ... | lol = resp3 rec (subst-commutes-w-closed-tctx γ C e) (symm (closed-subst _ e₀) ≡≡ symm (subren γ closed-wkγ e₀)) lol subst-commutes-w-closed-tctx γ (rec2 en C es) e with subren (liftγ γ) (wk closed-wkγ) es ... | lol1 with subeq (liftwk γ closed-wkγ) es ... | lol2 with lift-closed-subst (γ o closed-wkγ) es ... | lol3 with symm lol3 ≡≡ symm lol2 ≡≡ symm lol1 ... | lol = resp3 rec (symm (closed-subst _ en) ≡≡ symm (subren γ closed-wkγ en)) (subst-commutes-w-closed-tctx γ C e) lol subst-commutes-w-closed-tctx γ (rec3 e e₀ C) e₁ = tctx-empty-thing C open Contexts public
{ "alphanum_fraction": 0.5375866359, "avg_line_length": 45.3790322581, "ext": "agda", "hexsha": "6bde34b218af017a641aacca9b1161334a1cc51c", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z", "max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "msullivan/godels-t", "max_forks_repo_path": "Contexts.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "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": "msullivan/godels-t", "max_issues_repo_path": "Contexts.agda", "max_line_length": 105, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "msullivan/godels-t", "max_stars_repo_path": "Contexts.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z", "num_tokens": 2332, "size": 5627 }
------------------------------------------------------------------------ -- Specialised eliminators ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} module Partiality-monad.Inductive.Eliminators where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude hiding (⊥) open import H-level equality-with-J open import H-level.Closure equality-with-J open import Nat equality-with-J as Nat open import Partiality-monad.Inductive ------------------------------------------------------------------------ -- Non-dependent eliminators Inc-nd : ∀ {a p q} (A : Type a) (P : Type p) (Q : P → P → Type q) → Type (p ⊔ q) Inc-nd A P Q = ∃ λ (p : ℕ → P) → ∀ n → Q (p n) (p (suc n)) record Arguments-nd {a} p q (A : Type a) : Type (a ⊔ lsuc (p ⊔ q)) where field P : Type p Q : P → P → Type q pe : P po : (x : A) → P pl : (s : Increasing-sequence A) (pq : Inc-nd A P Q) → P pa : (p₁ p₂ : P) (q₁ : Q p₁ p₂) (q₂ : Q p₂ p₁) → p₁ ≡ p₂ ps : Is-set P qr : (x : A ⊥) (p : P) → Q p p qt : {x y z : A ⊥} → x ⊑ y → y ⊑ z → (px py pz : P) → Q px py → Q py pz → Q px pz qe : (x : A ⊥) (p : P) → Q pe p qu : (s : Increasing-sequence A) (pq : Inc-nd A P Q) (n : ℕ) → Q (proj₁ pq n) (pl s pq) ql : ∀ s (ub : A ⊥) (is-ub : Is-upper-bound s ub) pq (pu : P) (qu : ∀ n → Q (proj₁ pq n) pu) → Q (pl s pq) pu qp : (p₁ p₂ : P) → Is-proposition (Q p₁ p₂) module _ {a p q} {A : Type a} (args : Arguments-nd p q A) where open Arguments-nd args private args′ : Arguments p q A args′ = record { P = λ _ → P ; Q = λ p-x p-y _ → Q p-x p-y ; pe = pe ; po = po ; pl = pl ; pa = λ x⊑y x⊒y p₁ p₂ q₁ q₂ → subst (const P) (antisymmetry x⊑y x⊒y) p₁ ≡⟨ subst-const (antisymmetry x⊑y x⊒y) ⟩ p₁ ≡⟨ pa p₁ p₂ q₁ q₂ ⟩∎ p₂ ∎ ; pp = ps ; qr = qr ; qt = qt ; qe = qe ; qu = qu ; ql = ql ; qp = λ p-x p-y _ → qp p-x p-y } ⊥-rec-nd : A ⊥ → P ⊥-rec-nd = ⊥-rec args′ ⊑-rec-nd : ∀ {x y} → x ⊑ y → Q (⊥-rec-nd x) (⊥-rec-nd y) ⊑-rec-nd = ⊑-rec args′ inc-rec-nd : Increasing-sequence A → Inc-nd A P Q inc-rec-nd = inc-rec args′ ⊥-rec-nd-never : ⊥-rec-nd never ≡ pe ⊥-rec-nd-never = ⊥-rec-never _ ⊥-rec-nd-now : ∀ x → ⊥-rec-nd (now x) ≡ po x ⊥-rec-nd-now = ⊥-rec-now _ ⊥-rec-nd-⨆ : ∀ s → ⊥-rec-nd (⨆ s) ≡ pl s (inc-rec-nd s) ⊥-rec-nd-⨆ = ⊥-rec-⨆ _ ------------------------------------------------------------------------ -- Eliminators which are trivial for _⊑_ record Arguments-⊥ {a} p (A : Type a) : Type (a ⊔ lsuc p) where field P : A ⊥ → Type p pe : P never po : ∀ x → P (now x) pl : ∀ s (p : ∀ n → P (s [ n ])) → P (⨆ s) pp : ∀ x → Is-proposition (P x) module _ {a p} {A : Type a} (args : Arguments-⊥ p A) where open Arguments-⊥ args ⊥-rec-⊥ : (x : A ⊥) → P x ⊥-rec-⊥ = ⊥-rec (record { Q = λ _ _ _ → ⊤ ; pe = pe ; po = po ; pl = λ s pq → pl s (proj₁ pq) ; pa = λ _ _ _ _ _ _ → pp _ _ _ ; pp = mono₁ 1 (pp _) ; qp = λ _ _ _ _ _ → refl }) inc-rec-⊥ : (s : ℕ → A ⊥) → ∀ n → P (s n) inc-rec-⊥ s = ⊥-rec-⊥ ∘ s ⊥-rec-⊥-never : ⊥-rec-⊥ never ≡ pe ⊥-rec-⊥-never = ⊥-rec-never _ ⊥-rec-⊥-now : ∀ x → ⊥-rec-⊥ (now x) ≡ po x ⊥-rec-⊥-now = ⊥-rec-now _ ⊥-rec-⊥-⨆ : ∀ s → ⊥-rec-⊥ (⨆ s) ≡ pl s (λ n → ⊥-rec-⊥ (s [ n ])) ⊥-rec-⊥-⨆ = ⊥-rec-⨆ _ ------------------------------------------------------------------------ -- Eliminators which are trivial for _⊥ record Arguments-⊑ {a} q (A : Type a) : Type (a ⊔ lsuc q) where field Q : {x y : A ⊥} → x ⊑ y → Type q qr : ∀ x → Q (⊑-refl x) qt : ∀ {x y z} (x⊑y : x ⊑ y) (y⊑z : y ⊑ z) → Q x⊑y → Q y⊑z → Q (⊑-trans x⊑y y⊑z) qe : ∀ x → Q (never⊑ x) qu : ∀ s (q : ∀ n → Q (increasing s n)) n → Q (upper-bound s n) ql : ∀ s ub is-ub (q : ∀ n → Q (increasing s n)) (qu : ∀ n → Q (is-ub n)) → Q (least-upper-bound s ub is-ub) qp : ∀ {x y} (x⊑y : x ⊑ y) → Is-proposition (Q x⊑y) module _ {a q} {A : Type a} (args : Arguments-⊑ q A) where open Arguments-⊑ args ⊑-rec-⊑ : ∀ {x y} (x⊑y : x ⊑ y) → Q x⊑y ⊑-rec-⊑ = ⊑-rec (record { P = λ _ → ⊤ ; Q = λ _ _ → Q ; pa = λ _ _ _ _ _ _ → refl ; pp = mono (Nat.zero≤ 2) ⊤-contractible ; qr = λ x _ → qr x ; qt = λ x⊑y y⊑z _ _ _ → qt x⊑y y⊑z ; qe = λ x _ → qe x ; qu = λ s pq → qu s (proj₂ pq) ; ql = λ s ub is-ub pq _ → ql s ub is-ub (proj₂ pq) ; qp = λ _ _ → qp }) inc-rec-⊑ : (s : Increasing-sequence A) → ∀ n → Q (increasing s n) inc-rec-⊑ (_ , inc) = ⊑-rec-⊑ ∘ inc
{ "alphanum_fraction": 0.4191493733, "avg_line_length": 29.1437125749, "ext": "agda", "hexsha": "88a388e809e6e77bc15501bba0f3398d1dd846af", "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/Partiality-monad/Inductive/Eliminators.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/Partiality-monad/Inductive/Eliminators.agda", "max_line_length": 97, "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/Partiality-monad/Inductive/Eliminators.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": 2095, "size": 4867 }
module x01naturals where {- ------------------------------------------------------------------------------ naturals : inductive datatype definition as a pair of inference rules: -- no assumptions --------- zero : ℕ -- base case m : ℕ -- assuming m is Natural --------- suc m : ℕ -- inductive case : then suc m is also a Natural in Agda: -} data ℕ : Set where zero : ℕ -- base case suc : ℕ → ℕ -- inductive case -- #### Exercise Write out `7` in longhand. seven : ℕ seven = suc (suc (suc (suc (suc (suc (suc zero)))))) {- inference rules consists of - zero or more _judgments_ written above a horizontal line, called the _hypotheses_ - single judgment written below, called the _conclusion_ `Set` : the way in Agda of saying that it is a type Inductive case defines natural numbers in terms of natural numbers. Base case jump starts the process of induction. ## Philosophy and history inductive def of nats is relatively recent - 1888 Richard Dedekind's paper "_Was sind und was sollen die Zahlen?_" (What are and what should be the numbers?) - 1889 Giuseppe Peano's book "_Arithmetices principia, nova methodo exposita_" (The principles of arithmetic presented by a new method) ------------------------------------------------------------------------------ ## PRAGMA the line -} {-# BUILTIN NATURAL ℕ #-} {- tells Agda that `ℕ` corresponds to the natural numbers - pragma must be given a previously declared type (in this case `ℕ`) - enables 0, 1, 2, ... shorthand - enables efficient internal Haskell representation ## IMPORTS To write equations that hold between terms involving natural numbers import the definition of equality and notations for reasoning about equality from the Agda standard library: -} import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) {- 1st line : brings equality module into scope and gives it the name `Eq`. 2nd line : opens that module and adds names in `using` clause into scope. 3rd line : opens module that specifies operators to support reasoning about equivalence and adds names in `using` clause into scope. later will see their definitions in Chapter Equality underbars indicate where terms appear - `_≡_` and `_≡⟨⟩_` : terms on each side - `begin_` is prefix : terms after - : `_∎` : terms before ------------------------------------------------------------------------------ ## operations on naturals are recursive functions -} -- ADDITION _+_ : ℕ → ℕ → ℕ zero + n = n -- base case : 0 + n ≡ n (suc m) + n = suc (m + n) -- inductive case : (1 + m) + n ≡ 1 + (m + n) : associativity {- Inductive definition works because addition of larger numbers is defined in terms of addition of smaller numbers : WELL FOUNDED -} _ : 2 + 3 ≡ 5 _ = begin 2 + 3 ≡⟨⟩ -- is shorthand for (suc (suc zero)) + (suc (suc (suc zero))) ≡⟨⟩ -- inductive case suc ((suc zero) + (suc (suc (suc zero)))) ≡⟨⟩ -- inductive case suc (suc (zero + (suc (suc (suc zero))))) ≡⟨⟩ -- base case suc (suc (suc (suc (suc zero)))) ≡⟨⟩ -- is longhand for 5 ∎ -- ∎ is QED -- equivalent _ : 2 + 3 ≡ 5 _ = begin 2 + 3 ≡⟨⟩ suc (1 + 3) ≡⟨⟩ suc (suc (0 + 3)) ≡⟨⟩ suc (suc 3) ≡⟨⟩ 5 ∎ -- A binary relation is said to be REFLEXIVE if every value relates to itself. -- Evidence that a value is equal to itself is written `refl` _ : 2 + 3 ≡ 5 _ = refl {- above derivations consist of - a signature (written with a colon, `:`), giving a type - a binding (written with an equal sign, `=`), giving a term of the given type. the dummy name `_` can be reused consists of a series of terms separated by `≡⟨⟩`. duality of interpretation - type as a proposition - term as evidence (aka proof) #### Exercise `+-example` Compute `3 + 4` -} _ : 3 + 4 ≡ 7 _ = begin 3 + 4 ≡⟨⟩ suc (2 + 4) ≡⟨⟩ suc (suc (1 + 4)) ≡⟨⟩ suc (suc (suc (0 + 4))) ≡⟨⟩ suc (suc (suc 4)) ≡⟨⟩ 7 ∎ _ : 3 + 4 ≡ 7 _ = refl {- ------------------------------------------------------------------------------ ## MULTIPLICATION -} _*_ : ℕ → ℕ → ℕ zero * n = zero -- 0 * n ≡ 0 (suc m) * n = n + (m * n) -- (1 + m) * n ≡ n + (m * n) {- computing `m * n` returns the sum of `m` copies of `n`. 2nd line because multiplication distributes over addition: (m + n) * p ≡ (m * p) + (n * p) We get the second equation from the third by - taking `m` to be `1` - `n` to be `m` - `p` to be `n` - then use fact that one is identity for multiplication, so - `1 * n ≡ n` WELL FOUNDED : _*_ of larger numbers is defined in terms of _*_ of smaller numbers -} _ : 2 * 3 ≡ 6 _ = begin 2 * 3 ≡⟨⟩ -- inductive case 3 + (1 * 3) ≡⟨⟩ -- inductive case 3 + (3 + (0 * 3)) ≡⟨⟩ -- base case 3 + (3 + 0) ≡⟨⟩ -- simplify 6 ∎ {- #### Exercise `*-example` Compute `3 * 4` -} _ : 3 * 4 ≡ 12 _ = begin 3 * 4 ≡⟨⟩ 4 + (2 * 4) ≡⟨⟩ 4 + (4 + (1 * 4)) ≡⟨⟩ 4 + (4 + (4 + (0 * 4))) ≡⟨⟩ -- base case 4 + (4 + (4 + 0)) ≡⟨⟩ -- addition 12 ∎ -- HC _*hc_ : ℕ → ℕ → ℕ n *hc zero = zero n *hc (suc m) = (n *hc m) + n _ : 2 *hc 3 ≡ 6 _ = begin 2 *hc 3 ≡⟨⟩ (2 *hc 2) + 2 ≡⟨⟩ ((2 *hc 1) + 2) + 2 ≡⟨⟩ (((2 *hc 0) + 2) + 2) + 2 ≡⟨⟩ (( 0 + 2) + 2) + 2 ≡⟨⟩ ( 2 + 2) + 2 ≡⟨⟩ 6 ∎ {- ------------------------------------------------------------------------------ #### Exercise (recommended) Define EXPONENTIATION -} _^_ : ℕ → ℕ → ℕ m ^ 0 = 1 -- m ^ 0 = 1 m ^ (suc n) = m * (m ^ n) -- m ^ (1 + n) = m * (m ^ n) -- Check that `3 ^ 4` is `81`. _ : 3 ^ 4 ≡ 81 _ = refl _ : 2 ^ 3 ≡ 8 _ = refl {- ------------------------------------------------------------------------------ ## MONUS SUBTRACTION uses pattern matching against both arguments: -} _∸_ : ℕ → ℕ → ℕ m ∸ zero = m zero ∸ suc n = zero suc m ∸ suc n = m ∸ n -- WELL FOUNDED : monus on bigger numbers is defined in terms of monus on smaller numbers. _ = begin 3 ∸ 2 ≡⟨⟩ 2 ∸ 1 ≡⟨⟩ 1 ∸ 0 ≡⟨⟩ 1 ∎ _ = begin 2 ∸ 3 ≡⟨⟩ 1 ∸ 2 ≡⟨⟩ 0 ∸ 1 ≡⟨⟩ 0 ∎ {- #### Exercise Compute `5 ∸ 3` and `3 ∸ 5`, reasoning as a chain of equations. -} _ = begin 5 ∸ 3 ≡⟨⟩ 4 ∸ 2 ≡⟨⟩ 3 ∸ 1 ≡⟨⟩ 2 ∸ 0 ≡⟨⟩ 2 ∎ _ = begin 3 ∸ 5 ≡⟨⟩ 2 ∸ 4 ≡⟨⟩ 1 ∸ 3 ≡⟨⟩ 0 ∸ 2 ≡⟨⟩ 0 ∎ {- ------------------------------------------------------------------------------ ## PRECEDENCE Application higher than operators : `suc m + n` means `(suc m) + n` multiplication higher than addition : `n + m * n` means `n + (m * n)` addition _associates to the left_ : `m + n + p` means `(m + n) + p` declare precedence and associativity of infix operators -} infixl 6 _+_ _∸_ infixl 7 _*_ {- `infixl` : associate to the left `infixr` : associate to the right `infix` : indicates that parentheses are required to disambiguate ------------------------------------------------------------------------------ ## CURRYING a function of two arguments in terms of - a function of the first argument - that returns a function of the second argument Function arrows associate to the right : `ℕ → ℕ → ℕ` stands for `ℕ → (ℕ → ℕ)` Application associates to the left : `_+_ 2 3` stands for `(_+_ 2) 3` Named for Haskell Curry. The idea actually appears in the _Begriffsschrift_ of Gottlob Frege, published in 1879. ------------------------------------------------------------------------------ ## The story of creation, revisited inductive definition defines naturals in terms of naturals recursive definition defines addition in terms of addition n : ℕ -------------- zero + n = n m + n = p --------------------- (suc m) + n = suc p ------------------------------------------------------------------------------ ## The story of creation, finitely {name=finite-creation} SKIPPED ------------------------------------------------------------------------------ ## Writing definitions interactively _+_ : ℕ → ℕ → ℕ m + n = ? ? : ask Agda to fill in `C-c C-l` ? replaced: _+_ : ℕ → ℕ → ℕ m + n = { }0 empty braces : a "numbered" *hole* Emacs will also create a window displaying the text ?0 : ℕ to indicate that hole 0 is to be filled in with a term of type `ℕ`. `C-c C-f` (for **f**orward) will move you into the next hole. To define addition by recursion on the first argument: cursor in hole : `C-c C-c` (for **c**ase). prompt: pattern variables to case (empty for split on result): Type `m` : case split on `m`: _+_ : ℕ → ℕ → ℕ zero + n = { }0 suc m + n = { }1 window at the bottom type of each: ?0 : ℕ ?1 : ℕ in hole 0 : `C-c C-,` displays info on required type of hole, and what free variables are available: Goal: ℕ ———————————————————————————————————————————————————————————— n : ℕ suggests filling the hole with `n` after hole filled in : `C-c C-space` : removes hole: _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = { }1 in hole 1 : `C-c C-,` displays info Goal: ℕ ———————————————————————————————————————————————————————————— n : ℕ m : ℕ in hole : `C-c C-r` (for **r**efine) will fill in with a constructor (if there is a unique choice) or tell you what constructors you might use, if there is a choice Don't know which constructor to introduce of zero or suc fill in hole with `suc ?` : `C-c C-space` _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc { }1 in new hole : `C-c C-,` Goal: ℕ ———————————————————————————————————————————————————————————— n : ℕ m : ℕ fill hole with `m + n` : `C-c C-space` complete the program: _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc (m + n) ------------------------------------------------------------------------------ ## More pragmas -} {-# BUILTIN NATPLUS _+_ #-} {-# BUILTIN NATTIMES _*_ #-} {-# BUILTIN NATMINUS _∸_ #-} {- tells Agda correspondance between operators correspond and the usual ones. Enables using corresponding Haskell operators on arbitrary-precision integer type. ------------------------------------------------------------------------------ #### Exercise `Bin` (stretch) {name=Bin} represent nat as bitstring -} data Bin : Set where ⟨⟩ : Bin _O : Bin → Bin _I : Bin → Bin {- bitstring 1011 (eleven) encoded as ⟨⟩ I O I I or, with leading zeros, ⟨⟩ O O I O I I define inc : Bin → Bin converts bitstring to bitstring for next higher number -} -- this definition has TWO forms of ZERO: '⟨⟩' and '⟨⟩ O' -- will probably cause problems later on inc : Bin → Bin inc ⟨⟩ = ⟨⟩ I inc (⟨⟩ O) = ⟨⟩ I inc (⟨⟩ I) = ⟨⟩ I O inc (b O) = b I inc (b I) = (inc b) O -- `IOII` eleven to `1100` twelve _ : inc (⟨⟩ I O I I) ≡ ⟨⟩ I I O O _ = refl -- Confirm correct answer for the bitstrings encoding zero through four. _ : inc (⟨⟩ O) ≡ ⟨⟩ I _ = refl _ : inc (⟨⟩ I) ≡ ⟨⟩ I O _ = refl _ : inc (⟨⟩ I O) ≡ ⟨⟩ I I _ = refl _ : inc (⟨⟩ I I) ≡ ⟨⟩ I O O _ = refl _ : inc (⟨⟩ I O O) ≡ ⟨⟩ I O I _ = refl {- using above, define to : ℕ → Bin from : Bin → ℕ `to` should not have leading zeros, except represent zero as `⟨⟩ O` confirm for zero through four -} to : ℕ → Bin to zero = ⟨⟩ O to (suc m) = inc (to m) from : Bin → ℕ from ⟨⟩ = 0 from (b O) = 2 * from b from (b I) = 2 * from b + 1 _ : from (⟨⟩ O) ≡ 0 _ = refl _ : from (⟨⟩ I) ≡ 1 _ = refl _ : from (⟨⟩ I O) ≡ 2 _ = refl _ : from (⟨⟩ I I) ≡ 3 _ = refl _ : from (⟨⟩ I O O) ≡ 4 _ = refl _ : from (⟨⟩ I I O) ≡ 6 _ = refl _ : to 0 ≡ (⟨⟩ O) _ = refl _ : to 1 ≡ (⟨⟩ I) _ = refl _ : to 2 ≡ (⟨⟩ I O) _ = refl _ : to 3 ≡ (⟨⟩ I I) _ = refl _ : to 4 ≡ (⟨⟩ I O O) _ = refl _ : to 6 ≡ (⟨⟩ I I O) _ = refl _ : from (to 12) ≡ 12 _ = refl _ : to (from (⟨⟩ I I O O)) ≡ ⟨⟩ I I O O _ = refl -- 842 exercise : bin-+ _bin-+_ : Bin → Bin → Bin ⟨⟩ bin-+ ⟨⟩ = ⟨⟩ ⟨⟩ bin-+ b = b b bin-+ ⟨⟩ = b (bl O) bin-+ (br O) = let r = bl bin-+ br in r O (bl O) bin-+ (br I) = let r = bl bin-+ br in r I (bl I) bin-+ (br O) = let r = bl bin-+ br in r I (bl I) bin-+ (br I) = let r = bl bin-+ br in (inc r) O _ : (⟨⟩) bin-+ (⟨⟩) ≡ (⟨⟩) _ = refl _ : (⟨⟩) bin-+ (⟨⟩ O) ≡ (⟨⟩ O) _ = refl _ : (⟨⟩ O) bin-+ (⟨⟩) ≡ (⟨⟩ O) _ = refl _ : (⟨⟩ O) bin-+ (⟨⟩ O) ≡ (⟨⟩ O) _ = refl _ : (⟨⟩ O) bin-+ (⟨⟩ I) ≡ (⟨⟩ I) _ = refl _ : (⟨⟩ I) bin-+ (⟨⟩ I) ≡ (⟨⟩ I O) _ = refl _ : (⟨⟩ I O) bin-+ (⟨⟩ I O) ≡ (⟨⟩ I O O) _ = refl _ : (⟨⟩ I I) bin-+ (⟨⟩ I I) ≡ (⟨⟩ I I O) _ = refl _ : (⟨⟩ I O I) bin-+ (⟨⟩ I) ≡ (⟨⟩ I I O) _ = refl _ : (⟨⟩ I I I) bin-+ (⟨⟩ I) ≡ (⟨⟩ I O O O) _ = refl ------------------------------------------------------------------------------ -- hc exercise : explore two representation of ZERO z1-bin-+ : ∀ (b1 b2 : Bin) → b1 ≡ ⟨⟩ → b1 bin-+ b2 ≡ b2 z1-bin-+ b1 ⟨⟩ p -- (b1 bin-+ ⟨⟩) ≡ ⟨⟩ rewrite p -- (⟨⟩ bin-+ ⟨⟩) ≡ ⟨⟩ -- ⟨⟩ ≡ ⟨⟩ = refl z1-bin-+ b1 (⟨⟩ O) p -- (b1 bin-+ (⟨⟩ O)) ≡ (⟨⟩ O) rewrite p -- (⟨⟩ bin-+ (⟨⟩ O)) ≡ (⟨⟩ O) -- (⟨⟩ O) ≡ (⟨⟩ O) = refl z1-bin-+ b1 (b O) p -- (b1 bin-+ (b O)) ≡ (b O) rewrite p -- (⟨⟩ bin-+ (b O)) ≡ (b O) -- (b O) ≡ (b O) = refl z1-bin-+ b1 (b I) p -- (b1 bin-+ (b I)) ≡ (b I) rewrite p -- (⟨⟩ bin-+ (b I)) ≡ (b I) -- (b I) ≡ (b I) = refl z-bin-+ : ∀ (b1 b2 : Bin) → b1 ≡ (⟨⟩ O) → b1 bin-+ b2 ≡ b2 z-bin-+ b1 ⟨⟩ p -- (b1 bin-+ ⟨⟩) ≡ ⟨⟩ rewrite p -- ((⟨⟩ O) bin-+ ⟨⟩) ≡ ⟨⟩ -- (⟨⟩ O) ≡ ⟨⟩ = {!!} z-bin-+ b1 (⟨⟩ O) p -- (b1 bin-+ (⟨⟩ O)) ≡ (⟨⟩ O) rewrite p -- ((⟨⟩ O) bin-+ (⟨⟩ O)) ≡ (⟨⟩ O) -- (⟨⟩ O) ≡ (⟨⟩ O) = refl z-bin-+ b1 (b O) p -- (b1 bin-+ (b O)) ≡ (b O) rewrite p -- ((⟨⟩ O) bin-+ (b O)) ≡ (b O) -- ((⟨⟩ bin-+ b) O) ≡ (b O) = {!!} z-bin-+ b1 (b I) p -- (b1 bin-+ (b I)) ≡ (b I) rewrite p -- ((⟨⟩ O) bin-+ (b I)) ≡ (b I) -- ((⟨⟩ bin-+ b) I) ≡ (b I) = {!!} hc : ∀ (m n : ℕ) → from (to m bin-+ to n) ≡ m + n hc zero n -- from (to zero bin-+ to n) ≡ zero + n = {!!} -- from ( (⟨⟩ O) bin-+ to n) ≡ n hc (suc m) n = {!!} {- ------------------------------------------------------------------------------ ## Standard library where to find relevant definitions in the standard library Naturals, constructors, operators : import Data.Nat using (ℕ; zero; suc; _+_; _*_; _^_; _∸_) https://agda.readthedocs.io/en/v2.6.1/language/pragmas.html ------------------------------------------------------------------------------ ## Unicode This chapter uses the following unicode: char code name emacs ------------------------------------------------------ ℕ U+2115 DOUBLE-STRUCK CAPITAL N (\bN) → U+2192 RIGHTWARDS ARROW (\to, \r, \->) ∸ U+2238 DOT MINUS (\.-) ≡ U+2261 IDENTICAL TO (\==) ⟨ U+27E8 MATHEMATICAL LEFT ANGLE BRACKET (\<) ⟩ U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET (\>) ∎ U+220E END OF PROOF (\qed) `\r` : variety of right arrows `\l` : variety of left arrows All the characters supported by `agda-mode`: M-x agda-input-show-translations To see how to input an existing specific Unicode character in an agda file, move cursor to character M-x quail-show-key -}
{ "alphanum_fraction": 0.4559169037, "avg_line_length": 23.9614814815, "ext": "agda", "hexsha": "4bd982345eb69efd96087a6fb29b80172284b584", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01naturals.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01naturals.agda", "max_line_length": 90, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01naturals.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": 5735, "size": 16174 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.ZCohomology.Groups.Connected where open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.ZCohomology.Groups.Unit open import Cubical.Foundations.HLevels open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2) open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; ∥_∥ to ∥_∥₁ ; ∣_∣ to ∣_∣₁) open import Cubical.HITs.Nullification open import Cubical.Data.Sigma hiding (_×_) open import Cubical.Data.Int renaming (_+_ to _+ℤ_; +-comm to +ℤ-comm ; +-assoc to +ℤ-assoc) open import Cubical.Data.Nat open import Cubical.HITs.Truncation renaming (rec to trRec) open import Cubical.Algebra.Group open import Cubical.Homotopy.Connected open import Cubical.Foundations.Equiv private H⁰-connected-type : ∀ {ℓ} {A : Type ℓ} (a : A) → isConnected 2 A → Iso (coHom 0 A) Int Iso.fun (H⁰-connected-type a con) = sRec isSetInt λ f → f a Iso.inv (H⁰-connected-type a con) b = ∣ (λ x → b) ∣₂ Iso.rightInv (H⁰-connected-type a con) b = refl Iso.leftInv (H⁰-connected-type a con) = sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) λ f → cong ∣_∣₂ (funExt λ x → trRec (isSetInt _ _) (cong f) (isConnectedPath 1 con a x .fst)) H⁰-connected : ∀ {ℓ} {A : Type ℓ} (a : A) → ((x : A) → ∥ a ≡ x ∥₁) → GroupIso (coHomGr 0 A) intGroup GroupHom.fun (GroupIso.map (H⁰-connected a con)) = sRec isSetInt (λ f → f a) GroupHom.isHom (GroupIso.map (H⁰-connected a con)) = sElim2 (λ _ _ → isProp→isSet (isSetInt _ _)) λ x y → addLemma (x a) (y a) GroupIso.inv (H⁰-connected a con) b = ∣ (λ _ → b) ∣₂ GroupIso.rightInv (H⁰-connected a con) _ = refl GroupIso.leftInv (H⁰-connected a con) = sElim (λ _ → isProp→isSet (setTruncIsSet _ _)) (λ f → cong ∣_∣₂ (funExt λ x → pRec (isSetInt _ _) (cong f) (con x)))
{ "alphanum_fraction": 0.7072564612, "avg_line_length": 45.7272727273, "ext": "agda", "hexsha": "280be782b8d40042abe5e8b4e54f9a476bae45c7", "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": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ayberkt/cubical", "max_forks_repo_path": "Cubical/ZCohomology/Groups/Connected.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ayberkt/cubical", "max_issues_repo_path": "Cubical/ZCohomology/Groups/Connected.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ayberkt/cubical", "max_stars_repo_path": "Cubical/ZCohomology/Groups/Connected.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 717, "size": 2012 }
{-# OPTIONS --without-K #-} module LeftCancellation where open import Data.Empty using (⊥; ⊥-elim) open import Data.Unit using (⊤; tt) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Data.Product using (_,_; proj₁; proj₂) open import Function renaming (_∘_ to _○_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong) renaming (trans to _∘_; sym to !_) open import Equiv using (_∼_; _≃_; sym≃; inj≃; qinv; _●_) ------------------------------------------------------------------------------ -- This is WAY simpler than using 'with' and 'inspect'! record Ev {A B : Set} (f : A → B) (x : A) : Set where constructor ev field v : B fx=v : f x ≡ v mkV : {A B : Set} → (f : A → B) → (x : A) → Ev f x mkV f x = ev (f x) refl private bad-path : {A B : Set} → (a : A) → (b : B) → inj₁ a ≡ inj₂ b → ⊥ bad-path x y () ------------------------------------------------------------------------------ -- Very complex proof that we can cancel units on the left of ⊎ -- Some repeated patterns: inj₁≡ : {A B : Set} → {a b : A} → inj₁ {A = A} {B} a ≡ inj₁ b → a ≡ b inj₁≡ refl = refl inj₂≡ : {A B : Set} → {a b : B} → inj₂ {A = A} {B} a ≡ inj₂ b → a ≡ b inj₂≡ refl = refl -- use injectivity of equivalences to go from f x ≡ f y to x ≡ y injectivity : {A B : Set} (equiv : (⊤ ⊎ A) ≃ (⊤ ⊎ B)) → (a : A) → proj₁ equiv (inj₁ tt) ≡ proj₁ equiv (inj₂ a) → (inj₁ tt ≡ inj₂ a) injectivity equiv x path = inj≃ equiv (inj₁ tt) (inj₂ x) path left-cancel-⊤ : {A B : Set} → ((⊤ ⊎ A) ≃ (⊤ ⊎ B)) → A ≃ B left-cancel-⊤ {A} {B} (f₁ , qinv g₁ α₁ β₁) = let eqv = (f₁ , qinv g₁ α₁ β₁) in let v₁ = mkV f₁ (inj₁ tt) in let v₂ = mkV g₁ (inj₁ tt) in mk₁ {A} {B} eqv v₁ v₂ where mk₁ : {A B : Set} (e : (⊤ ⊎ A) ≃ (⊤ ⊎ B)) → let (f₁ , qinv g₁ α₁ β₁) = e in Ev f₁ (inj₁ tt) → Ev g₁ (inj₁ tt) → A ≃ B mk₁ {A} {B} (f , qinv g α β) (ev (inj₁ tt) eq₁) (ev (inj₁ tt) eq₂) = A≃B where equiv : (⊤ ⊎ A) ≃ (⊤ ⊎ B) equiv = (f , qinv g α β) elim-path : {X Y Z : Set} → (e : (⊤ ⊎ X) ≃ (⊤ ⊎ Y)) → (x : X) → (proj₁ e) (inj₁ tt) ≡ (proj₁ e) (inj₂ x) → Z elim-path e a path = ⊥-elim (bad-path tt a (injectivity e a path)) mkf : (a : A) → Ev f (inj₂ a) → B mkf a (ev (inj₁ tt) eq) = elim-path equiv a (eq₁ ∘ ! eq) mkf a (ev (inj₂ y) fx≡v) = y ff : A → B ff a = mkf a (mkV f (inj₂ a)) mkg : (b : B) → Ev g (inj₂ b) → A mkg b (ev (inj₁ tt) eq) = elim-path (sym≃ equiv) b (eq₂ ∘ ! eq) mkg b (ev (inj₂ a) eq) = a gg : B → A gg b = mkg b (mkV g (inj₂ b)) mkα : (b : B) → (e : Ev g (inj₂ b)) → ff (mkg b e) ≡ b mkα b (ev (inj₁ tt) eq) = elim-path (sym≃ equiv) b (eq₂ ∘ ! eq) mkα b (ev (inj₂ a) eq) = mkα' (mkV f (inj₂ a)) where mkα' : (ev : Ev f (inj₂ a)) → mkf a ev ≡ b mkα' (ev (inj₁ tt) eq₃) = elim-path equiv a (eq₁ ∘ ! eq₃) mkα' (ev (inj₂ _) eq₃) = inj₂≡ (! (cong f eq ∘ eq₃) ∘ α (inj₂ b)) αα : ff ○ gg ∼ id αα b = mkα b (mkV g (inj₂ b)) -- need to expand the definition of ff and gg "by hand" otherwise there is -- nowhere to 'stick in' the explicit e₁ and e₂ we have. mkβ : (a : A) → (e₁ : Ev f (inj₂ a)) → (e₂ : Ev g (inj₂ (mkf a e₁))) → mkg (mkf a e₁) e₂ ≡ a mkβ a (ev (inj₁ tt) eq) _ = elim-path equiv a (eq₁ ∘ ! eq) mkβ a (ev (inj₂ y) eq) (ev (inj₁ tt) eq₃) = elim-path (sym≃ equiv) y (eq₂ ∘ ! eq₃) mkβ a (ev (inj₂ _) eq) (ev (inj₂ _) eq₃) = inj₂≡ (((! eq₃) ∘ cong g (! eq)) ∘ β (inj₂ a)) ββ : gg ○ ff ∼ id ββ a = let ev₁ = mkV f (inj₂ a) in mkβ a ev₁ (mkV g (inj₂ (mkf a ev₁))) A≃B : A ≃ B A≃B = ff , qinv gg αα ββ mk₁ (f , qinv g α β) (ev (inj₁ tt) eq₁) (ev (inj₂ a) eq₂) = let e = (f , qinv g α β) in ⊥-elim (bad-path tt a (injectivity e a ((eq₁ ∘ ! (α (inj₁ tt))) ∘ cong f eq₂))) mk₁ (f , qinv g α β) (ev (inj₂ b) eq₁) (ev (inj₁ tt) eq₂) = ⊥-elim (bad-path tt b (((! α (inj₁ tt)) ∘ cong f eq₂) ∘ eq₁)) mk₁ {A} {B} (f , qinv g α β) (ev (inj₂ x) ftt=x) (ev (inj₂ y) gtt=y) = A≃B where equiv : (⊤ ⊎ A) ≃ (⊤ ⊎ B) equiv = (f , qinv g α β) elim-path : {X Y Z : Set} → (e : (⊤ ⊎ X) ≃ (⊤ ⊎ Y)) → (x : X) → (proj₁ e) (inj₁ tt) ≡ (proj₁ e) (inj₂ x) → Z elim-path e a path = ⊥-elim (bad-path tt a (injectivity e a path)) mkf : (a : A) → Ev f (inj₂ a) → B mkf a (ev (inj₁ tt) _) = x mkf a (ev (inj₂ y) _) = y ff : A → B ff a = mkf a (mkV f (inj₂ a)) mkg : (b : B) → Ev g (inj₂ b) → A mkg b (ev (inj₁ tt) eq) = y mkg b (ev (inj₂ a) eq) = a gg : B → A gg b = mkg b (mkV g (inj₂ b)) mkα : (b : B) → (e₁ : Ev g (inj₂ b)) → (e₂ : Ev f (inj₂ (mkg b e₁))) → mkf (mkg b e₁) e₂ ≡ b mkα b (ev (inj₁ tt) gb=tt) (ev (inj₁ tt) fgb=tt) = inj₂≡ ((! ftt=x ∘ ! cong f gb=tt) ∘ α (inj₂ b)) mkα b (ev (inj₁ tt) gb=tt) (ev (inj₂ y₁) fy=y₁) = elim-path (sym≃ equiv) y₁ ( ! ((! cong g fy=y₁ ∘ β (inj₂ y)) ∘ (! gtt=y))) mkα b (ev (inj₂ z) gb=z) (ev (inj₁ tt) fgb=tt) = elim-path (sym≃ equiv) b ((cong g (! fgb=tt) ∘ β (inj₂ z)) ∘ (! gb=z)) mkα b (ev (inj₂ z) gb=z) (ev (inj₂ z₂) fgb=z₂) = let path = (cong g (! fgb=z₂) ∘ β (inj₂ z)) ∘ ! gb=z in inj₂≡ (inj≃ (sym≃ equiv) (inj₂ z₂) (inj₂ b) path) αα : ff ○ gg ∼ id αα b = let ev₁ = mkV g (inj₂ b) in mkα b ev₁ (mkV f (inj₂ (mkg b ev₁))) -- need to expand the definition of ff and gg "by hand" -- otherwise there is nowhere to 'stick in' the explicit e₁ -- and e₂ we have. mkβ : (a : A) → (e₁ : Ev f (inj₂ a)) → (e₂ : Ev g (inj₂ (mkf a e₁))) → mkg (mkf a e₁) e₂ ≡ a mkβ a (ev (inj₁ tt) eq) (ev (inj₁ _) eq₃) = inj₂≡ (! (cong g eq ∘ gtt=y) ∘ β (inj₂ a)) mkβ a (ev (inj₁ tt) eq) (ev (inj₂ y₁) eq₃) = elim-path equiv y₁ ((ftt=x ∘ (! α (inj₂ x))) ∘ cong f eq₃) mkβ a (ev (inj₂ z) fa=z) (ev (inj₁ tt) eq₃) = elim-path equiv a ((cong f (! eq₃) ∘ α (inj₂ z)) ∘ (! fa=z) ) mkβ a (ev (inj₂ _) fa=y) (ev (inj₂ _) eq₃) = inj₂≡ (((! eq₃) ∘ cong g (! fa=y)) ∘ β (inj₂ a)) ββ : gg ○ ff ∼ id ββ a = let ev₁ = mkV f (inj₂ a) in mkβ a ev₁ (mkV g (inj₂ (mkf a ev₁))) A≃B : A ≃ B A≃B = ff , qinv gg αα ββ ------------------------------------------------------------------------------ open import Data.Nat using (ℕ; _+_) open import Data.Fin using (Fin) open import FinEquivPlusTimes using (module Plus; Fin1≃⊤) open Plus using (⊎≃+; +≃⊎) open import Equiv using (_⊎≃_; id≃) left-cancel-1 : {m n : ℕ} → (Fin (1 + m) ≃ Fin (1 + n)) → Fin m ≃ Fin n left-cancel-1 pf = left-cancel-⊤ ((Fin1≃⊤ ⊎≃ id≃) ● +≃⊎ ● (pf ● ⊎≃+) ● (sym≃ Fin1≃⊤ ⊎≃ id≃))
{ "alphanum_fraction": 0.4521246459, "avg_line_length": 36.7708333333, "ext": "agda", "hexsha": "27a47e1aa75180c05e621c461f080a7a8208753b", "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/LeftCancellation.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/LeftCancellation.agda", "max_line_length": 92, "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/LeftCancellation.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": 3092, "size": 7060 }
module maryjohn2 where postulate Person : Set postulate john : Person postulate mary : Person postulate barbara : Person postulate IsStudent : Person -> Set postulate maryIsStudent : IsStudent mary postulate implication : IsStudent mary -> IsStudent john Lemma1 : Set Lemma1 = IsStudent john proof-lemma1 : Lemma1 proof-lemma1 = implication maryIsStudent Lemma2 : Set Lemma2 = IsStudent john -> IsStudent barbara proof-lemma2 : Lemma2 proof-lemma2 = \(x : IsStudent john) -> _
{ "alphanum_fraction": 0.7159309021, "avg_line_length": 21.7083333333, "ext": "agda", "hexsha": "c33a4305d9fda6dcc53d917e8be8907ee740f248", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_path": "tests/covered/maryjohn2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejtokarcik/agda-semantics", "max_issues_repo_path": "tests/covered/maryjohn2.agda", "max_line_length": 58, "max_stars_count": 3, "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_path": "tests/covered/maryjohn2.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "num_tokens": 137, "size": 521 }